Crates.io | fvm-macros |
lib.rs | fvm-macros |
version | 1.0.0 |
source | src |
created_at | 2023-02-07 03:44:54.486986 |
updated_at | 2023-02-07 03:44:54.486986 |
description | provide the macros for user to write contract more convenient |
homepage | |
repository | https://github.com/hyperchain/hyperchain |
max_upload_size | |
id | 778472 |
size | 63,625 |
Provides the macros needed to write fvm contracts
Macros can be used in contract for simplify contract preparation process, like this:
use fvm_macros::contract;
use fvm_macros::storage;
use fvm_std::collections::hyper_map::HyperMap;
#[storage]
pub struct SetHash {
map: HyperMap<String, String>,
}
#[contract]
impl SetHash {
fn new() -> Self {
Self { map: HyperMap::new() }
}
pub fn set_hash(&mut self, key: String, value: String) {
self.map.insert(key, value);
}
pub fn get_hash(&mut self, key: String) -> &String {
self.map.get(&key).unwrap()
}
}
Now write contract have two mode:
Contract with normal mode limited data storage format, and user can write contract more
convenient. User can use all macros except advance_contract
.
Contract with advance mode not limited data storage format, and it must open advance
feature with fvm-std
and 'fvm-macros' lib to use this mode. The execute speed of contract
in this mode would be fast then the contract in normal mode.