Skip to content

Commit

Permalink
Merge pull request openethereum#42 from paritytech/pwasm-abi-upgrade
Browse files Browse the repository at this point in the history
pwasm-abi 0.2 upgrade
  • Loading branch information
lexfrl authored Jan 21, 2019
2 parents f71074a + 70e5b0d commit 57cc59c
Show file tree
Hide file tree
Showing 25 changed files with 649 additions and 565 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,15 @@ Let's implement a simple [ERC-20](https://en.wikipedia.org/wiki/ERC20) token con

pub mod token {
use pwasm_ethereum;
use pwasm_std::*;
use pwasm_std::hash::H256;
use bigint::U256;
use pwasm_abi::types::*;

// eth_abi is a procedural macros https://doc.rust-lang.org/book/first-edition/procedural-macros.html
use pwasm_abi_derive::eth_abi;

static TOTAL_SUPPLY_KEY: H256 = H256([2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
lazy_static! {
static ref TOTAL_SUPPLY_KEY: H256 =
H256::from([2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
}

#[eth_abi(TokenEndpoint)]
pub trait TokenInterface {
Expand Down Expand Up @@ -278,6 +279,9 @@ Let's implement the `transfer` method for our ERC-20 contract. `step-4` director
```rust
pub mod token {

use pwasm_ethereum;
use pwasm_std::types::*;

#[eth_abi(TokenEndpoint, TokenClient)]
pub trait TokenInterface {
/// The constructor
Expand Down Expand Up @@ -335,8 +339,8 @@ pub mod token {
// Generates a balance key for some address.
// Used to map balances with their owners.
fn balance_key(address: &Address) -> H256 {
let mut key = H256::from(address);
key[0] = 1; // just a naive "namespace";
let mut key = H256::from(*address);
key.as_bytes_mut()[0] = 1; // just a naive "namespace";
key
}
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2018-07-24
nightly-2018-11-12
86 changes: 48 additions & 38 deletions step-0/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions step-0/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version = "0.1.0"
authors = ["Alexey Frolov <[email protected]>"]

[dependencies]
pwasm-std = "0.10"
pwasm-ethereum = "0.6"
pwasm-std = "0.13"
pwasm-ethereum = "0.8"

[lib]
crate-type = ["cdylib"]
Expand Down
2 changes: 1 addition & 1 deletion step-0/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2018-07-24
nightly-2018-11-12
Loading

0 comments on commit 57cc59c

Please sign in to comment.