From 83ca2d6854ed2a94a9273875737402e24da49e79 Mon Sep 17 00:00:00 2001 From: Roman Useinov Date: Fri, 14 Jul 2023 11:43:28 +0200 Subject: [PATCH 1/6] [Enhancement] Deprecate Fungible Token declarative macros. --- CHANGELOG.md | 1 + examples/fungible-token/ft/src/lib.rs | 90 ++++++++++++++++++- .../test-contract-defi/src/lib.rs | 3 +- examples/fungible-token/tests/workspaces.rs | 70 ++++----------- .../src/fungible_token/core.rs | 49 +++++++++- .../src/fungible_token/macros.rs | 6 ++ .../src/fungible_token/mod.rs | 3 + .../src/fungible_token/resolver.rs | 45 ++++++++++ .../src/storage_management/mod.rs | 69 ++++++++++++++ 9 files changed, 277 insertions(+), 59 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c9d50620..2ad8fe645 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ ### Removed - Deprecated declarative macros for NFT impl code generation. [PR 1042](https://github.com/near/near-sdk-rs/pull/1042) +- Deprecated declarative macros for FT impl code generation. TODO: FIX LINK [PR 1042](https://github.com/near/near-sdk-rs/pull/1042) ## [4.1.0] - 2022-11-09 diff --git a/examples/fungible-token/ft/src/lib.rs b/examples/fungible-token/ft/src/lib.rs index 14eb75c73..42c005063 100644 --- a/examples/fungible-token/ft/src/lib.rs +++ b/examples/fungible-token/ft/src/lib.rs @@ -18,7 +18,10 @@ NOTES: use near_contract_standards::fungible_token::metadata::{ FungibleTokenMetadata, FungibleTokenMetadataProvider, FT_METADATA_SPEC, }; -use near_contract_standards::fungible_token::FungibleToken; +use near_contract_standards::fungible_token::{ + FungibleToken, FungibleTokenCore, FungibleTokenResolver, StorageManagement, +}; +use near_contract_standards::storage_management::{StorageBalance, StorageBalanceBounds}; use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; use near_sdk::collections::LazyOption; use near_sdk::json_types::U128; @@ -80,7 +83,8 @@ impl Contract { owner_id: &owner_id, amount: &total_supply, memo: Some("new tokens are minted"), - }.emit(); + } + .emit(); this } @@ -94,8 +98,86 @@ impl Contract { } } -near_contract_standards::impl_fungible_token_core!(Contract, token, on_tokens_burned); -near_contract_standards::impl_fungible_token_storage!(Contract, token, on_account_closed); +#[near_bindgen] +impl FungibleTokenCore for Contract { + #[payable] + fn ft_transfer(&mut self, receiver_id: AccountId, amount: U128, memo: Option) { + self.token.ft_transfer(receiver_id, amount, memo) + } + + #[payable] + fn ft_transfer_call( + &mut self, + receiver_id: AccountId, + amount: U128, + memo: Option, + msg: String, + ) -> PromiseOrValue { + self.token.ft_transfer_call(receiver_id, amount, memo, msg) + } + + fn ft_total_supply(&self) -> U128 { + self.token.ft_total_supply() + } + + fn ft_balance_of(&self, account_id: AccountId) -> U128 { + self.token.ft_balance_of(account_id) + } +} + +#[near_bindgen] +impl FungibleTokenResolver for Contract { + #[private] + fn ft_resolve_transfer( + &mut self, + sender_id: AccountId, + receiver_id: AccountId, + amount: U128, + ) -> U128 { + let (used_amount, burned_amount) = + self.token.internal_ft_resolve_transfer(&sender_id, receiver_id, amount); + if burned_amount > 0 { + self.on_tokens_burned(sender_id, burned_amount); + } + used_amount.into() + } +} + +#[near_bindgen] +impl StorageManagement for Contract { + #[payable] + fn storage_deposit( + &mut self, + account_id: Option, + registration_only: Option, + ) -> StorageBalance { + self.token.storage_deposit(account_id, registration_only) + } + + #[payable] + fn storage_withdraw(&mut self, amount: Option) -> StorageBalance { + self.token.storage_withdraw(amount) + } + + #[payable] + fn storage_unregister(&mut self, force: Option) -> bool { + #[allow(unused_variables)] + if let Some((account_id, balance)) = self.token.internal_storage_unregister(force) { + self.on_account_closed(account_id, balance); + true + } else { + false + } + } + + fn storage_balance_bounds(&self) -> StorageBalanceBounds { + self.token.storage_balance_bounds() + } + + fn storage_balance_of(&self, account_id: AccountId) -> Option { + self.token.storage_balance_of(account_id) + } +} #[near_bindgen] impl FungibleTokenMetadataProvider for Contract { diff --git a/examples/fungible-token/test-contract-defi/src/lib.rs b/examples/fungible-token/test-contract-defi/src/lib.rs index b37ad94e0..a762f7cf5 100644 --- a/examples/fungible-token/test-contract-defi/src/lib.rs +++ b/examples/fungible-token/test-contract-defi/src/lib.rs @@ -5,8 +5,7 @@ use near_contract_standards::fungible_token::receiver::FungibleTokenReceiver; use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; use near_sdk::json_types::U128; use near_sdk::{ - env, log, near_bindgen, require, AccountId, Balance, Gas, PanicOnDefault, - PromiseOrValue, + env, log, near_bindgen, require, AccountId, Balance, Gas, PanicOnDefault, PromiseOrValue, }; const BASE_GAS: u64 = 5_000_000_000_000; diff --git a/examples/fungible-token/tests/workspaces.rs b/examples/fungible-token/tests/workspaces.rs index 5775d27ff..3a0390c2e 100644 --- a/examples/fungible-token/tests/workspaces.rs +++ b/examples/fungible-token/tests/workspaces.rs @@ -1,15 +1,11 @@ - use near_sdk::json_types::U128; use near_sdk::ONE_YOCTO; use near_units::parse_near; -use workspaces::{Account, AccountId, Contract,DevNetwork, Worker}; use workspaces::operations::Function; use workspaces::result::ValueOrReceiptId; +use workspaces::{Account, AccountId, Contract, DevNetwork, Worker}; -async fn register_user( - contract: &Contract, - account_id: &AccountId, -) -> anyhow::Result<()> { +async fn register_user(contract: &Contract, account_id: &AccountId) -> anyhow::Result<()> { let res = contract .call("storage_deposit") .args_json((account_id, Option::::None)) @@ -26,8 +22,7 @@ async fn init( worker: &Worker, initial_balance: U128, ) -> anyhow::Result<(Contract, Account, Contract)> { - let ft_contract = - worker.dev_deploy(include_bytes!("../res/fungible_token.wasm")).await?; + let ft_contract = worker.dev_deploy(include_bytes!("../res/fungible_token.wasm")).await?; let res = ft_contract .call("new_default_meta") @@ -39,12 +34,7 @@ async fn init( let defi_contract = worker.dev_deploy(include_bytes!("../res/defi.wasm")).await?; - let res = defi_contract - .call("new") - .args_json((ft_contract.id(),)) - .max_gas() - .transact() - .await?; + let res = defi_contract.call("new").args_json((ft_contract.id(),)).max_gas().transact().await?; assert!(res.is_success()); let alice = ft_contract @@ -96,18 +86,10 @@ async fn test_simple_transfer() -> anyhow::Result<()> { .await?; assert!(res.is_success()); - let root_balance = contract - .call("ft_balance_of") - .args_json((contract.id(),)) - .view() - .await? - .json::()?; - let alice_balance = contract - .call("ft_balance_of") - .args_json((alice.id(),)) - .view() - .await? - .json::()?; + let root_balance = + contract.call("ft_balance_of").args_json((contract.id(),)).view().await?.json::()?; + let alice_balance = + contract.call("ft_balance_of").args_json((alice.id(),)).view().await?.json::()?; assert_eq!(initial_balance.0 - transfer_amount.0, root_balance.0); assert_eq!(transfer_amount.0, alice_balance.0); @@ -199,13 +181,13 @@ async fn simulate_transfer_call_with_burned_amount() -> anyhow::Result<()> { Function::new("ft_transfer_call") .args_json((defi_contract.id(), transfer_amount, Option::::None, "10")) .deposit(ONE_YOCTO) - .gas(300_000_000_000_000 / 2) + .gas(300_000_000_000_000 / 2), ) .call( Function::new("storage_unregister") .args_json((Some(true),)) .deposit(ONE_YOCTO) - .gas(300_000_000_000_000 / 2) + .gas(300_000_000_000_000 / 2), ) .transact() .await?; @@ -261,12 +243,8 @@ async fn simulate_transfer_call_with_immediate_return_and_no_refund() -> anyhow: .await?; assert!(res.is_success()); - let root_balance = contract - .call("ft_balance_of") - .args_json((contract.id(),)) - .view() - .await? - .json::()?; + let root_balance = + contract.call("ft_balance_of").args_json((contract.id(),)).view().await?.json::()?; let defi_balance = contract .call("ft_balance_of") .args_json((defi_contract.id(),)) @@ -298,12 +276,8 @@ async fn simulate_transfer_call_when_called_contract_not_registered_with_ft() -> assert!(res.is_failure()); // balances remain unchanged - let root_balance = contract - .call("ft_balance_of") - .args_json((contract.id(),)) - .view() - .await? - .json::()?; + let root_balance = + contract.call("ft_balance_of").args_json((contract.id(),)).view().await?.json::()?; let defi_balance = contract .call("ft_balance_of") .args_json((defi_contract.id(),)) @@ -341,12 +315,8 @@ async fn simulate_transfer_call_with_promise_and_refund() -> anyhow::Result<()> .await?; assert!(res.is_success()); - let root_balance = contract - .call("ft_balance_of") - .args_json((contract.id(),)) - .view() - .await? - .json::()?; + let root_balance = + contract.call("ft_balance_of").args_json((contract.id(),)).view().await?.json::()?; let defi_balance = contract .call("ft_balance_of") .args_json((defi_contract.id(),)) @@ -394,12 +364,8 @@ async fn simulate_transfer_call_promise_panics_for_a_full_refund() -> anyhow::Re } // balances remain unchanged - let root_balance = contract - .call("ft_balance_of") - .args_json((contract.id(),)) - .view() - .await? - .json::()?; + let root_balance = + contract.call("ft_balance_of").args_json((contract.id(),)).view().await?.json::()?; let defi_balance = contract .call("ft_balance_of") .args_json((defi_contract.id(),)) diff --git a/near-contract-standards/src/fungible_token/core.rs b/near-contract-standards/src/fungible_token/core.rs index 2c74293fd..03143c08b 100644 --- a/near-contract-standards/src/fungible_token/core.rs +++ b/near-contract-standards/src/fungible_token/core.rs @@ -2,7 +2,54 @@ use near_sdk::ext_contract; use near_sdk::json_types::U128; use near_sdk::AccountId; use near_sdk::PromiseOrValue; - +/// The core methods for a basic fungible token. Extension standards may be +/// added in addition to this trait. +/// +/// # Examples +/// +/// ``` +/// use near_sdk::{near_bindgen, PanicOnDefault, AccountId, PromiseOrValue}; +/// use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; +/// use near_sdk::collections::LazyOption; +/// use near_sdk::json_types::U128; +/// use near_contract_standards::fungible_token::{FungibleToken, FungibleTokenCore}; +/// use near_contract_standards::fungible_token::metadata::FungibleTokenMetadata; +/// +/// #[near_bindgen] +/// #[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)] +/// pub struct Contract { +/// token: FungibleToken, +/// metadata: LazyOption, +/// } +/// +/// #[near_bindgen] +/// impl FungibleTokenCore for Contract { +/// #[payable] +/// fn ft_transfer(&mut self, receiver_id: AccountId, amount: U128, memo: Option) { +/// self.token.ft_transfer(receiver_id, amount, memo) +/// } +/// +/// #[payable] +/// fn ft_transfer_call( +/// &mut self, +/// receiver_id: AccountId, +/// amount: U128, +/// memo: Option, +/// msg: String, +/// ) -> PromiseOrValue { +/// self.token.ft_transfer_call(receiver_id, amount, memo, msg) +/// } +/// +/// fn ft_total_supply(&self) -> U128 { +/// self.token.ft_total_supply() +/// } +/// +/// fn ft_balance_of(&self, account_id: AccountId) -> U128 { +/// self.token.ft_balance_of(account_id) +/// } +/// } +/// ``` +/// #[ext_contract(ext_ft_core)] pub trait FungibleTokenCore { /// Transfers positive `amount` of tokens from the `env::predecessor_account_id` to `receiver_id`. diff --git a/near-contract-standards/src/fungible_token/macros.rs b/near-contract-standards/src/fungible_token/macros.rs index 6286d693f..1092923ec 100644 --- a/near-contract-standards/src/fungible_token/macros.rs +++ b/near-contract-standards/src/fungible_token/macros.rs @@ -1,6 +1,9 @@ /// The core methods for a basic fungible token. Extension standards may be /// added in addition to this macro. #[macro_export] +#[deprecated( + note = "implement the near_contract_standards::fungible_token::{FungibleTokenCore, FungibleTokenResolver} traits manually instead." +)] macro_rules! impl_fungible_token_core { ($contract: ident, $token: ident $(, $on_tokens_burned_fn:ident)?) => { use $crate::fungible_token::core::FungibleTokenCore; @@ -64,6 +67,9 @@ macro_rules! impl_fungible_token_core { /// Takes name of the Contract struct, the inner field for the token and optional method name to /// call when the account was closed. #[macro_export] +#[deprecated( + note = "implement the near_contract_standards::fungible_token::StorageManagement trait manually instead." +)] macro_rules! impl_fungible_token_storage { ($contract: ident, $token: ident $(, $on_account_closed_fn:ident)?) => { use $crate::storage_management::{ diff --git a/near-contract-standards/src/fungible_token/mod.rs b/near-contract-standards/src/fungible_token/mod.rs index 031197c08..377cfd663 100644 --- a/near-contract-standards/src/fungible_token/mod.rs +++ b/near-contract-standards/src/fungible_token/mod.rs @@ -7,5 +7,8 @@ pub mod receiver; pub mod resolver; pub mod storage_impl; +pub use self::core::FungibleTokenCore; +pub use crate::storage_management::StorageManagement; pub use core_impl::FungibleToken; pub use macros::*; +pub use resolver::FungibleTokenResolver; diff --git a/near-contract-standards/src/fungible_token/resolver.rs b/near-contract-standards/src/fungible_token/resolver.rs index b97d8ca29..f0b82e68f 100644 --- a/near-contract-standards/src/fungible_token/resolver.rs +++ b/near-contract-standards/src/fungible_token/resolver.rs @@ -1,5 +1,50 @@ use near_sdk::{ext_contract, json_types::U128, AccountId}; +/// [`FungibleTokenResolver`] provides token transfer resolve functionality. +/// +/// # Examples +/// +/// ``` +/// use near_sdk::{near_bindgen, PanicOnDefault, AccountId, Balance, log}; +/// use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; +/// use near_sdk::collections::LazyOption; +/// use near_sdk::json_types::U128; +/// use near_contract_standards::fungible_token::{FungibleToken, FungibleTokenResolver}; +/// use near_contract_standards::fungible_token::metadata::FungibleTokenMetadata; +/// +/// #[near_bindgen] +/// #[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)] +/// pub struct Contract { +/// token: FungibleToken, +/// metadata: LazyOption, +/// } +/// +/// #[near_bindgen] +/// impl Contract { +/// fn on_tokens_burned(&mut self, account_id: AccountId, amount: Balance) { +/// log!("Account @{} burned {}", account_id, amount); +/// } +/// } +/// +///#[near_bindgen] +/// impl FungibleTokenResolver for Contract { +/// #[private] +/// fn ft_resolve_transfer( +/// &mut self, +/// sender_id: AccountId, +/// receiver_id: AccountId, +/// amount: U128, +/// ) -> U128 { +/// let (used_amount, burned_amount) = +/// self.token.internal_ft_resolve_transfer(&sender_id, receiver_id, amount); +/// if burned_amount > 0 { +/// self.on_tokens_burned(sender_id, burned_amount); +/// } +/// used_amount.into() +/// } +/// } +/// ``` +/// #[ext_contract(ext_ft_resolver)] pub trait FungibleTokenResolver { fn ft_resolve_transfer( diff --git a/near-contract-standards/src/storage_management/mod.rs b/near-contract-standards/src/storage_management/mod.rs index 13d024791..d22e28baf 100644 --- a/near-contract-standards/src/storage_management/mod.rs +++ b/near-contract-standards/src/storage_management/mod.rs @@ -19,6 +19,75 @@ pub struct StorageBalanceBounds { pub max: Option, } +/// Ensures that when fungible token storage grows by collections adding entries, +/// the storage is be paid by the caller. This ensures that storage cannot grow to a point +/// that the FT contract runs out of Ⓝ. +/// Takes name of the Contract struct, the inner field for the token and optional method name to +/// call when the account was closed. +/// +/// # Examples +/// +/// ``` +/// use near_sdk::{near_bindgen, PanicOnDefault, AccountId, Balance, log}; +/// use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; +/// use near_sdk::collections::LazyOption; +/// use near_sdk::json_types::U128; +/// use near_contract_standards::fungible_token::{FungibleToken, StorageManagement}; +/// use near_contract_standards::storage_management::{StorageBalance, StorageBalanceBounds}; +/// use near_contract_standards::fungible_token::metadata::FungibleTokenMetadata; +/// +/// #[near_bindgen] +/// #[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)] +/// pub struct Contract { +/// token: FungibleToken, +/// metadata: LazyOption, +/// } +/// +/// #[near_bindgen] +/// impl Contract { +/// fn on_account_closed(&mut self, account_id: AccountId, balance: Balance) { +/// log!("Closed @{} with {}", account_id, balance); +/// } +/// } +/// +/// #[near_bindgen] +/// impl StorageManagement for Contract { +/// #[payable] +/// fn storage_deposit( +/// &mut self, +/// account_id: Option, +/// registration_only: Option, +/// ) -> StorageBalance { +/// self.token.storage_deposit(account_id, registration_only) +/// } +/// +/// #[payable] +/// fn storage_withdraw(&mut self, amount: Option) -> StorageBalance { +/// self.token.storage_withdraw(amount) +/// } +/// +/// #[payable] +/// fn storage_unregister(&mut self, force: Option) -> bool { +/// #[allow(unused_variables)] +/// if let Some((account_id, balance)) = self.token.internal_storage_unregister(force) { +/// self.on_account_closed(account_id, balance); +/// true +/// } else { +/// false +/// } +/// } +/// +/// fn storage_balance_bounds(&self) -> StorageBalanceBounds { +/// self.token.storage_balance_bounds() +/// } +/// +/// fn storage_balance_of(&self, account_id: AccountId) -> Option { +/// self.token.storage_balance_of(account_id) +/// } +/// } +/// +/// ``` +/// pub trait StorageManagement { // if `registration_only=true` MUST refund above the minimum balance if the account didn't exist and // refund full deposit if the account exists. From ec6857a474a1d913918391dade2b65dd32ad65ee Mon Sep 17 00:00:00 2001 From: Roman Useinov Date: Sun, 6 Aug 2023 15:25:21 +0200 Subject: [PATCH 2/6] address review comments --- examples/fungible-token/ft/src/lib.rs | 18 ++++++------------ .../src/fungible_token/mod.rs | 3 +-- .../src/storage_management/mod.rs | 6 ++++-- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/examples/fungible-token/ft/src/lib.rs b/examples/fungible-token/ft/src/lib.rs index 42c005063..5b8951e37 100644 --- a/examples/fungible-token/ft/src/lib.rs +++ b/examples/fungible-token/ft/src/lib.rs @@ -19,9 +19,11 @@ use near_contract_standards::fungible_token::metadata::{ FungibleTokenMetadata, FungibleTokenMetadataProvider, FT_METADATA_SPEC, }; use near_contract_standards::fungible_token::{ - FungibleToken, FungibleTokenCore, FungibleTokenResolver, StorageManagement, + FungibleToken, FungibleTokenCore, FungibleTokenResolver, +}; +use near_contract_standards::storage_management::{ + StorageBalance, StorageBalanceBounds, StorageManagement, }; -use near_contract_standards::storage_management::{StorageBalance, StorageBalanceBounds}; use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; use near_sdk::collections::LazyOption; use near_sdk::json_types::U128; @@ -88,14 +90,6 @@ impl Contract { this } - - fn on_account_closed(&mut self, account_id: AccountId, balance: Balance) { - log!("Closed @{} with {}", account_id, balance); - } - - fn on_tokens_burned(&mut self, account_id: AccountId, amount: Balance) { - log!("Account @{} burned {}", account_id, amount); - } } #[near_bindgen] @@ -137,7 +131,7 @@ impl FungibleTokenResolver for Contract { let (used_amount, burned_amount) = self.token.internal_ft_resolve_transfer(&sender_id, receiver_id, amount); if burned_amount > 0 { - self.on_tokens_burned(sender_id, burned_amount); + log!("Account @{} burned {}", account_id, burned_amount); } used_amount.into() } @@ -163,7 +157,7 @@ impl StorageManagement for Contract { fn storage_unregister(&mut self, force: Option) -> bool { #[allow(unused_variables)] if let Some((account_id, balance)) = self.token.internal_storage_unregister(force) { - self.on_account_closed(account_id, balance); + log!("Closed @{} with {}", account_id, balance); true } else { false diff --git a/near-contract-standards/src/fungible_token/mod.rs b/near-contract-standards/src/fungible_token/mod.rs index 377cfd663..03caf013a 100644 --- a/near-contract-standards/src/fungible_token/mod.rs +++ b/near-contract-standards/src/fungible_token/mod.rs @@ -7,8 +7,7 @@ pub mod receiver; pub mod resolver; pub mod storage_impl; -pub use self::core::FungibleTokenCore; -pub use crate::storage_management::StorageManagement; +pub use crate::fungible_token::core::FungibleTokenCore; pub use core_impl::FungibleToken; pub use macros::*; pub use resolver::FungibleTokenResolver; diff --git a/near-contract-standards/src/storage_management/mod.rs b/near-contract-standards/src/storage_management/mod.rs index d22e28baf..6b704129d 100644 --- a/near-contract-standards/src/storage_management/mod.rs +++ b/near-contract-standards/src/storage_management/mod.rs @@ -32,8 +32,10 @@ pub struct StorageBalanceBounds { /// use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; /// use near_sdk::collections::LazyOption; /// use near_sdk::json_types::U128; -/// use near_contract_standards::fungible_token::{FungibleToken, StorageManagement}; -/// use near_contract_standards::storage_management::{StorageBalance, StorageBalanceBounds}; +/// use near_contract_standards::fungible_token::FungibleToken; +/// use near_contract_standards::storage_management::{ +/// StorageBalance, StorageBalanceBounds, StorageManagement, +/// }; /// use near_contract_standards::fungible_token::metadata::FungibleTokenMetadata; /// /// #[near_bindgen] From 667199a1b5feb0205b36548143ee549b4df5b5ec Mon Sep 17 00:00:00 2001 From: Roman Useinov Date: Sun, 6 Aug 2023 15:27:51 +0200 Subject: [PATCH 3/6] fix param --- examples/fungible-token/ft/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/fungible-token/ft/src/lib.rs b/examples/fungible-token/ft/src/lib.rs index 5b8951e37..4e84a18de 100644 --- a/examples/fungible-token/ft/src/lib.rs +++ b/examples/fungible-token/ft/src/lib.rs @@ -131,7 +131,7 @@ impl FungibleTokenResolver for Contract { let (used_amount, burned_amount) = self.token.internal_ft_resolve_transfer(&sender_id, receiver_id, amount); if burned_amount > 0 { - log!("Account @{} burned {}", account_id, burned_amount); + log!("Account @{} burned {}", sender_id, burned_amount); } used_amount.into() } From f6d9fe818759b5cf2aee2146e5520dfd117e4add Mon Sep 17 00:00:00 2001 From: Roman Useinov Date: Sun, 6 Aug 2023 15:54:42 +0200 Subject: [PATCH 4/6] unused import --- examples/fungible-token/ft/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/fungible-token/ft/src/lib.rs b/examples/fungible-token/ft/src/lib.rs index 4e84a18de..aa3c87da3 100644 --- a/examples/fungible-token/ft/src/lib.rs +++ b/examples/fungible-token/ft/src/lib.rs @@ -28,8 +28,7 @@ use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; use near_sdk::collections::LazyOption; use near_sdk::json_types::U128; use near_sdk::{ - env, log, near_bindgen, require, AccountId, Balance, BorshStorageKey, PanicOnDefault, - PromiseOrValue, + env, log, near_bindgen, require, AccountId, BorshStorageKey, PanicOnDefault, PromiseOrValue, }; #[near_bindgen] From 99e1a44dba47a0f4794e97692025677a1ff4a225 Mon Sep 17 00:00:00 2001 From: Roman Useinov Date: Wed, 16 Aug 2023 00:05:47 +0200 Subject: [PATCH 5/6] fix comments --- CHANGELOG.md | 2 +- near-contract-standards/src/fungible_token/mod.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ad8fe645..de465d806 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ ### Removed - Deprecated declarative macros for NFT impl code generation. [PR 1042](https://github.com/near/near-sdk-rs/pull/1042) -- Deprecated declarative macros for FT impl code generation. TODO: FIX LINK [PR 1042](https://github.com/near/near-sdk-rs/pull/1042) +- Deprecated declarative macros for FT impl code generation. [PR 1054](https://github.com/near/near-sdk-rs/pull/1054) ## [4.1.0] - 2022-11-09 diff --git a/near-contract-standards/src/fungible_token/mod.rs b/near-contract-standards/src/fungible_token/mod.rs index 03caf013a..32c65dbc7 100644 --- a/near-contract-standards/src/fungible_token/mod.rs +++ b/near-contract-standards/src/fungible_token/mod.rs @@ -1,3 +1,8 @@ +//! This module represents a Fungible Token standard. +//! +//! # Examples +//! See [`FungibleTokenCore`] and [`FungibleTokenResolver`] for example usage. + pub mod core; pub mod core_impl; pub mod events; From 211cf088d3c6b37d84f61906360872545dd08a15 Mon Sep 17 00:00:00 2001 From: Roman Useinov Date: Wed, 16 Aug 2023 11:42:52 +0200 Subject: [PATCH 6/6] update --- near-contract-standards/src/fungible_token/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/near-contract-standards/src/fungible_token/mod.rs b/near-contract-standards/src/fungible_token/mod.rs index 32c65dbc7..109cbf45f 100644 --- a/near-contract-standards/src/fungible_token/mod.rs +++ b/near-contract-standards/src/fungible_token/mod.rs @@ -1,7 +1,8 @@ //! This module represents a Fungible Token standard. //! //! # Examples -//! See [`FungibleTokenCore`] and [`FungibleTokenResolver`] for example usage. +//! See [`FungibleTokenCore`] and [`FungibleTokenResolver`] for example usage and [`FungibleToken`] +//! for core standard implementation. pub mod core; pub mod core_impl;