-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(example): basic implementation of ERC20 (#228)
* chore(erc20): basic skeleton of erc20 * feat(erc20): test initial storage * chore(erc20): adapt to new constructor * chore(erc20): use auto-generated getters * feat(examples): add example of const functions * chore(erc20): test decimals * feat(zink): introduce u256 * fix(storage): keys in ls bytes * feat(zink): complete functions of erc20 * feat(erc20): add _mint and _burn * feat(erc20): complete host calls * fix(codegen): ls bytes conversion * feat(abi): introduce u256 * chore(zink): ignore tests of erc20 atm
- Loading branch information
Showing
26 changed files
with
517 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//! Storage example. | ||
#![cfg_attr(target_arch = "wasm32", no_std)] | ||
#![cfg_attr(target_arch = "wasm32", no_main)] | ||
|
||
extern crate zink; | ||
|
||
/// set value to the storage. | ||
#[zink::external] | ||
pub fn decimals() -> i32 { | ||
8 | ||
} | ||
|
||
#[cfg(not(target_arch = "wasm32"))] | ||
fn main() {} | ||
|
||
#[test] | ||
fn value() -> anyhow::Result<()> { | ||
use zint::{Bytes32, Contract}; | ||
|
||
let mut contract = Contract::search("constfn")?.compile()?; | ||
|
||
let decimals = 8.to_bytes32().to_vec(); | ||
let info = contract.execute(&[b"decimals()".to_vec(), decimals.clone()])?; | ||
assert_eq!(info.ret, decimals); | ||
Ok(()) | ||
} |
Oops, something went wrong.