Skip to content

Commit

Permalink
fix: macro sanity remove importing types (#571)
Browse files Browse the repository at this point in the history
  • Loading branch information
austinabell committed Nov 18, 2021
1 parent 8e91eb4 commit 149883f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## [unreleased]
- fix(standards): Fix NFT impl macros to not import `HashMap` and `near_sdk::json_types::U128`. [PR 571](https://github.com/near/near-sdk-rs/pull/571).
- Add drain iterator for `near_sdk::store::UnorderedMap`. [PR 613](https://github.com/near/near-sdk-rs/pull/613).
- Will remove all values and iterate over owned values that were removed
- Fix codegen for methods inside a `#[near_bindgen]` to allow using `mut self` which will generate the same code as `self` and will not persist state. [PR 616](https://github.com/near/near-sdk-rs/pull/616).
Expand Down
1 change: 1 addition & 0 deletions examples/non-fungible-token/nft/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ impl NonFungibleTokenMetadataProvider for Contract {
mod tests {
use near_sdk::test_utils::{accounts, VMContextBuilder};
use near_sdk::testing_env;
use std::collections::HashMap;

use super::*;

Expand Down
1 change: 0 additions & 1 deletion examples/status-message-collections/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ mod tests {
use super::*;
use near_sdk::test_utils::VMContextBuilder;
use near_sdk::{testing_env, VMContext};
use std::convert::TryInto;

fn get_context(is_view: bool) -> VMContext {
VMContextBuilder::new()
Expand Down
16 changes: 9 additions & 7 deletions near-contract-standards/src/non_fungible_token/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#[macro_export]
macro_rules! impl_non_fungible_token_core {
($contract: ident, $token: ident) => {
use std::collections::HashMap;
use $crate::non_fungible_token::core::NonFungibleTokenCore;
use $crate::non_fungible_token::core::NonFungibleTokenResolver;

Expand Down Expand Up @@ -45,7 +44,7 @@ macro_rules! impl_non_fungible_token_core {
previous_owner_id: AccountId,
receiver_id: AccountId,
token_id: TokenId,
approved_account_ids: Option<HashMap<AccountId, u64>>,
approved_account_ids: Option<std::collections::HashMap<AccountId, u64>>,
) -> bool {
self.$token.nft_resolve_transfer(
previous_owner_id,
Expand Down Expand Up @@ -104,27 +103,30 @@ macro_rules! impl_non_fungible_token_approval {
#[macro_export]
macro_rules! impl_non_fungible_token_enumeration {
($contract: ident, $token: ident) => {
use near_sdk::json_types::U128;
use $crate::non_fungible_token::enumeration::NonFungibleTokenEnumeration;

#[near_bindgen]
impl NonFungibleTokenEnumeration for $contract {
fn nft_total_supply(&self) -> U128 {
fn nft_total_supply(&self) -> near_sdk::json_types::U128 {
self.$token.nft_total_supply()
}

fn nft_tokens(&self, from_index: Option<U128>, limit: Option<u64>) -> Vec<Token> {
fn nft_tokens(
&self,
from_index: Option<near_sdk::json_types::U128>,
limit: Option<u64>,
) -> Vec<Token> {
self.$token.nft_tokens(from_index, limit)
}

fn nft_supply_for_owner(&self, account_id: AccountId) -> U128 {
fn nft_supply_for_owner(&self, account_id: AccountId) -> near_sdk::json_types::U128 {
self.$token.nft_supply_for_owner(account_id)
}

fn nft_tokens_for_owner(
&self,
account_id: AccountId,
from_index: Option<U128>,
from_index: Option<near_sdk::json_types::U128>,
limit: Option<u64>,
) -> Vec<Token> {
self.$token.nft_tokens_for_owner(account_id, from_index, limit)
Expand Down

0 comments on commit 149883f

Please sign in to comment.