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

Update fungible token example to use basic NEP 141 #289

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
87 changes: 43 additions & 44 deletions examples/fungible-token/Cargo.lock

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

7 changes: 2 additions & 5 deletions examples/fungible-token/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fungible-token"
version = "0.3.0"
version = "1.0.0"
authors = ["Near Inc <hello@nearprotocol.com>"]
edition = "2018"

Expand All @@ -14,12 +14,9 @@ near-sdk = { path = "../../near-sdk" }
near-sdk-sim = { path = "../../near-sdk-sim" }

[profile.release]
codegen-units = 1
# Tell `rustc` to optimize for small code size.
codegen-units=1
opt-level = "z"
lto = true
debug = false
panic = "abort"
overflow-checks = true


36 changes: 1 addition & 35 deletions examples/fungible-token/README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1 @@
# Fungible token

Example implementation of a Fungible Token Standard (NEP#21).

NOTES:
- The maximum balance value is limited by U128 (2**128 - 1).
- 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.

## Building
To build run:
```bash
./build.sh
```

## Testing
To test run:
```bash
cargo test --package fungible-token -- --nocapture
```

## Changelog

### `0.3.0`

#### Breaking storage change

- Switching `UnorderedMap` to `LookupMap`. It makes it cheaper and faster due to decreased storage access.

# TBD
4 changes: 1 addition & 3 deletions examples/fungible-token/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash
set -e
cd "`dirname $0`"
source ../flags.sh
cargo build --target wasm32-unknown-unknown --release
RUSTFLAGS='-C link-arg=-s' cargo build --target wasm32-unknown-unknown --release
cp target/wasm32-unknown-unknown/release/fungible_token.wasm ./res/

Binary file modified examples/fungible-token/res/fungible_token.wasm
Binary file not shown.
Loading