Skip to content

Commit

Permalink
expose read address and h256 (ontio#68)
Browse files Browse the repository at this point in the history
* publish to crates.io

* expose read address and h256
  • Loading branch information
laizy authored Mar 26, 2020
1 parent 3ac2003 commit 11f4671
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
4 changes: 4 additions & 0 deletions ontio-bump-alloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name = "ontio-bump-alloc"
version = "0.1.0"
authors = ["laizy <[email protected]>"]
edition = "2018"
license = "Apache-2.0/MIT"
homepage = "https://github.com/ontio/ontology-wasm-cdt-rust"
repository = "https://github.com/ontio/ontology-wasm-cdt-rust"
description = "bump memory allocation for ontology wasm engine"

[dependencies]
cfg-if = { version = "0.1", default-features = false }
8 changes: 4 additions & 4 deletions ontio-codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name = "ontio-codegen"
version = "0.1.0"
authors = ["laizy <[email protected]>"]
edition = "2018"
license = "Apache-2.0/MIT"
homepage = "https://github.com/ontio/ontology-wasm-cdt-rust"
repository = "https://github.com/ontio/ontology-wasm-cdt-rust"
description = "codegen for ontio-std"

[lib]
proc-macro = true
Expand All @@ -17,7 +21,3 @@ heck = {version = "0.3.1",default-features = false}

[dev-dependencies]
ontio-std = {path="../ontio-std"}

[features]
mock = ["ontio-std/mock"]

4 changes: 4 additions & 0 deletions ontio-derive-codec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name = "ontio-derive-codec"
version = "0.1.0"
authors = ["Lucas <[email protected]>"]
edition = "2018"
license = "Apache-2.0/MIT"
homepage = "https://github.com/ontio/ontology-wasm-cdt-rust"
repository = "https://github.com/ontio/ontology-wasm-cdt-rust"
description = "codec derive macro for ontio-std"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
10 changes: 7 additions & 3 deletions ontio-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ name = "ontio-std"
version = "0.1.0"
authors = ["laizy <[email protected]>"]
edition = "2018"
license = "Apache-2.0/MIT"
homepage = "https://github.com/ontio/ontology-wasm-cdt-rust"
repository = "https://github.com/ontio/ontology-wasm-cdt-rust"
description = "development library for ontology wasm contract"

[dependencies]
wee_alloc = "0.4"
ontio-bump-alloc = {path = "../ontio-bump-alloc", optional = true}
ontio-bump-alloc = {version = "0.1", path = "../ontio-bump-alloc", optional = true}
fixed-hash = { version = "0.4", default-features = false }
cfg-if = { version = "0.1", default-features = false }
byteorder = { version = "1", default-features= false, features = ["i128"] }
ontio-codegen = { path = "../ontio-codegen"}
ontio-derive-codec = { path = "../ontio-derive-codec"}
ontio-codegen = { version = "0.1", path = "../ontio-codegen"}
ontio-derive-codec = { version = "0.1", path = "../ontio-derive-codec"}
sha2 = {version="0.8", optional=true}

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions ontio-std/src/abi/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ impl<'a> Source<'a> {
T::decode(self)
}

pub(crate) fn read_address(&mut self) -> Result<&'a Address, Error> {
pub fn read_address(&mut self) -> Result<&'a Address, Error> {
let buf = self.next_bytes(20)?;
Ok(unsafe { &*(buf.as_ptr() as *const Address) })
}

pub(crate) fn read_h256(&mut self) -> Result<&'a H256, Error> {
pub fn read_h256(&mut self) -> Result<&'a H256, Error> {
let buf = self.next_bytes(32)?;
Ok(unsafe { &*(buf.as_ptr() as *const H256) })
}
Expand Down
4 changes: 2 additions & 2 deletions ontio-std/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ mod env {
author_len: u32, email_ptr: *const u8, email_len: u32, desc_ptr: *const u8,
desc_len: u32, new_addr_ptr: *mut u8,
) -> u32;
pub fn ontio_contract_delete() -> !;
pub fn ontio_contract_destroy() -> !;
}
}

Expand Down Expand Up @@ -187,7 +187,7 @@ pub fn contract_migrate(
///delete the contract
pub fn contract_delete() -> ! {
unsafe {
env::ontio_contract_delete();
env::ontio_contract_destroy();
}
}
///Save key-value as a key-value pair
Expand Down

0 comments on commit 11f4671

Please sign in to comment.