Crates.io | near-non-transferrable-token |
lib.rs | near-non-transferrable-token |
version | 0.0.4 |
source | src |
created_at | 2022-09-19 13:52:05.713193 |
updated_at | 2022-12-08 08:52:18.143034 |
description | NEAR smart contracts library. |
homepage | https://popula.io |
repository | https://github.com/beepopula/near-non-transferrable-token |
max_upload_size | |
id | 669155 |
size | 47,036 |
use near_non_transferrable_token::{impl_fungible_token_core, impl_fungible_token_storage};
#[near_bindgen]
impl Contract {
#[init]
pub fn new(
owner_id: AccountId,
metadata: FungibleTokenMetadata,
) -> Self {
assert!(!env::state_exists(), "Already initialized");
metadata.assert_valid();
let mut this = Self {
token: FungibleToken::new(b"a".to_vec()),
metadata: LazyOption::new(b"m".to_vec(), Some(&metadata)),
owner_id,
white_list: HashSet::new()
};
this
}
}
impl_fungible_token_core!(Contract, token);
impl_fungible_token_storage!(Contract, token);
#[near_bindgen]
impl FungibleTokenMetadataProvider for Contract {
fn ft_metadata(&self) -> FungibleTokenMetadata {
self.metadata.get().unwrap()
}
}
See https://github.com/beepopula/Drip-contract for more details.
Separate Balances for different contracts:
#[derive(BorshDeserialize, BorshSerialize)]
pub struct Account {
pub contract_ids: UnorderedMap<Option<AccountId>, Balance>,
pub deposit_map: UnorderedMap<AccountId, HashMap<Option<AccountId>, Balance>> //key: specific community drip
}
NOTES:
This crate follows Cargo's semver guidelines.
State breaking changes (low-level serialization format of any data type) will be avoided at all costs. If a change like this were to happen, it would come with a major version and come with a compiler error. If you encounter one that does not, open an issue!
The minimum supported Rust version is currently 1.56
. There are no guarantees that this will be upheld if a security patch release needs to come in that requires a Rust toolchain increase.