rmrk-team / rmrk-tools

Tools for the RMRK NFT standard on Kusama
GNU General Public License v3.0
96 stars 36 forks source link

Add onMint callback to MINT interaction #89

Open Yuripetusko opened 2 years ago

Yuripetusko commented 2 years ago

Because TS/extrinsic implementation version of RMRK standard uses block number in NFT id, this prevents you from doing anything with an NFT in the same block as it is MINTed. This is because you need to know at which block the NFT was minted before you can construct additional remarks for it.

with that in mind, I propose to accept an optional onMint array with nft fields object passed with MINT interaction. This array would use double curly brace notation that will be interpolated into nft id that is being minted at a runtime.

RMRK::MINT::2.0.0::${encodeURIComponent(
  JSON.stringify({
    collection: '8949162-e0b9bdcc456a36497a',
    symbol: 'KANL',
    transferable: 1,
    sn: 00009999,
    metadata: 'ipfs://ipfs/foo',
    onMint: [
      `RMRK::RESADD::2.0.0::{{nft.id}}::${encodeURIComponent(
          JSON.stringify({
            id: nanoid(8),
            src: 'ipfs://ipfs/foo',
          })
        )}`
    ]
  })
)}
Swader commented 2 years ago

Needs a spec change, and a whitelist for callback ops to LIST, SEND, RESADD. Otherwise fine, but needs to be aware of possible double curlies in the resource fields, if someone decides to break things 🤔

yornaath commented 2 years ago

Definitely a 👍 Need the exact use case you are using as an example.

boyswan commented 2 years ago

This would be a hugely useful addition to the spec!