Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous comments #177

Merged
merged 8 commits into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified examples/fungible-token/res/fungible_token.wasm
Binary file not shown.
15 changes: 9 additions & 6 deletions examples/fungible-token/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
* - JSON calls should pass U128 as a base-10 string. E.g. "100".
* - The contract optimizes the inner trie structure by hashing account IDs. It will prevent some
* abuse of deep tries. Shouldn't be an issue, once NEAR clients implement full hashing of keys.
* - This contract doesn't optimize the amount of storage, since any account can create unlimited
* amount of allowances to other accounts. It's unclear how to address this issue unless, this
* contract limits the total number of different allowances possible at the same time.
* And even if it limits the total number, it's still possible to transfer small amounts to
* multiple accounts.
* - The contract tracks storage difference before and after the call. If the storage increases,
evgenykuzyakov marked this conversation as resolved.
Show resolved Hide resolved
* the contract requires the caller of the contract to attach enough deposit to the function call
* to cover the storage stake difference.
evgenykuzyakov marked this conversation as resolved.
Show resolved Hide resolved
willemneal marked this conversation as resolved.
Show resolved Hide resolved
* It's done to prevent denial of service attack on the contract by taking all available storage.
evgenykuzyakov marked this conversation as resolved.
Show resolved Hide resolved
* If the storage decreases, the contract will issue a refund for the storage stake difference.
* The unused tokens from the attached deposit are also going to be refunded, so it's safe to
evgenykuzyakov marked this conversation as resolved.
Show resolved Hide resolved
* attach more deposit than required.
* - The deployed contract has to be locked. It means it should not have any access keys on the
evgenykuzyakov marked this conversation as resolved.
Show resolved Hide resolved
* account of the contract, to prevent contract from being modified or deleted.
*/
use borsh::{BorshDeserialize, BorshSerialize};
use near_sdk::collections::UnorderedMap;
Expand Down Expand Up @@ -56,7 +60,6 @@ impl Account {
}
}

//
#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize)]
pub struct FungibleToken {
Expand Down