near / devrel

The space for DevRel
MIT License
9 stars 0 forks source link

NFT example update to work with wallet on TestNet #314

Closed ilblackdragon closed 3 years ago

zavodil commented 3 years ago

This issue happens because simple nft_mint call is not enough to show NFT on the Collectibles Tab in the wallet. We have a several ways to fix it: 1) update nft_mint section in the example: we will set owner_id=$CONTRACT_NAME and run nft_transfer then to send it to user's account_id. It is a typical workflow when contract mints tokens and distribute them to recipients. nft_transfer will trigger token display. 2) add nft_marketplace contract to the example: we will mint token and offer it for sale on a marketplace. offer will trigger token display. This will extend init process of the example due to marketplace initialization. 3) Update near-wallet to check nft_mint calls

@ilblackdragon @thisisjoshford @mehtaphysical wdyt?

zavodil commented 3 years ago

mint call is quite challenging to perform, since it's not payable, but it requires tokens to cover storage for metadata. So I believe the way how it was designed is to call it within the wrapper function (as nft_mint). I asked wallet team if they are in position to track nft_mint calls since they are already tracking mint calls

ilblackdragon commented 3 years ago

Yes, that's an issue with the library implementation. It's tracked here https://github.com/near/near-sdk-rs/issues/542

We def should change that implementation first.

My question is what is the wallet using to pick up for minting in the wallet. @MaximusHaximus what are you currently using?

MaximusHaximus commented 3 years ago

@zavodil We use an indexer query to find transactions that appear to be NFT transactions. We currently look for any method called starting with nft_, where the receiver_id in the JSON args of the method call is the active account. Is it possible the usages of nft_mint you are seeing don't use receiver_id in the JSON args for the nft_mint call?

For your reference, this is the code: https://github.com/near/near-contract-helper/blob/master/middleware/indexer.js#L144-L160

We're happy to update our queries if there is an obvious solution here; maybe you have an example transaction we could use to model the behaviour?

This is also a relevant discussion happening right now in the NEPs repository which makes me believe that having log outputs from NEP171 contracts is the 'correct' solution here: https://github.com/near/NEPs/issues/254

zavodil commented 3 years ago

@zavodil We use an indexer query to find transactions that appear to be NFT transactions. We currently look for any method called starting with nft_, where the receiver_id in the JSON args of the method call is the active account. Is it possible the usages of nft_mint you are seeing don't use receiver_id in the JSON args for the nft_mint call?

Many thanks, I pushed PR with the corresponding fix https://github.com/near-examples/NFT/pull/176 We just have to use receiver_id instead of token_owner_id everywhere