futureversecom / trn-seed

Implementation of The Root Network node in Rust, based on the Substrate framework.

Home Page:https://www.therootnetwork.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Emit event consistently

leo-plugdefi opened this issue · comments

observation:

  1. mint event not always emitted, e.g. when collection is created, some token could be minted, but no mint event to be picked up by indexer
  2. transfer event not always emitted, e.g. there are quite a few places called do_transfer_unchecked, but didn't emit the ownership transfer event emitted, in that case, it makes indexer harder to track the ownership for token.

proposal:
check all the places where token is minted, emit mint event per token, and check all the places where token is transferred, emit transfer event per token

Id like to clarify a few things:

  • Are you using solidity precompiles (smart contract addresses) to perform the mint and/or transfer? Or are you using the substrate extrinsics?
  • What sort of indexer are you using to subscribe to events? TheGraph? or a custom indexer?

^ Answers to the questions above would help us replicate the issue.

Thanks @zees-dev
We are using substrate extrinsic and we are listening to the chain using a custom indexer, but I believe you will observe the same behaviour using subsquid or polkadotjs UI as well.

Id like to clarify a few things:

* Are you using solidity precompiles (smart contract addresses) to perform the mint and/or transfer? Or are you using the substrate extrinsics?

* What sort of indexer are you using to subscribe to events? TheGraph? or a custom indexer?

^ Answers to the questions above would help us replicate the issue.

@leo-plugdefi
Would you have a script that performs an extrinsic (mint and/or transfer) which we could use as a testcase (for issue replciation)?

@leo-plugdefi Would you have a script that performs an extrinsic (mint and/or transfer) which we could use as a testcase (for issue replciation)?
Hi Zees, you can call the method "nft.createCollection" in NFT pallet from polkadot.js UI. We created a Collection with 10 NFTs, this is the TXs:

https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fporcini.au.rootnet.app%2Farchive%2Fws#/explorer/query/0x89d40fd6093e6f39a39298c43e8cdc155def3cc50c3d67797dc5c206d65db6c3

image

the chain emit the "nft.CollectionCreate" events, however swallowed all mint events for NFT minting. from the users' point of view they know they create a NFT collection with 10 tokens, however the NFT marketplace don't, we need these events to keep tracking collection/token create, mint, ownership transfer.

Just to clarify - you are expecting X amount of mint events (assuming you've minted X no. of tokens)?

Consistent with both ERC721 and ERC721A standards, emitting X amount of mint event when X no. of tokens are minted, would be ideal. If the cost of gas is a concern, we could still work within the existing mint event structure, but it should be emitted. Let's find a solution that works best for everyone. @zees-dev

Can verify minting does seem to emit event with the token ids minted (list):
Screenshot 2023-02-03 at 2 44 12 PM

Screenshot 2023-02-03 at 2 44 23 PM


However can confirm creating collection event does not contain the token ids minted.
It would make sense to also introduce an attribute, ideally a list to display token ids minted.

Can verify minting does seem to emit event with the token ids minted (list): Screenshot 2023-02-03 at 2 44 12 PM

Screenshot 2023-02-03 at 2 44 23 PM

However can confirm creating collection event does not contain the token ids minted. It would make sense to also introduce an attribute, ideally a list to display token ids minted.

maybe the token owners should be included as well :)

Addressed in this PR: #443

Creating a collection should now emit this event:

CollectionCreate {
    collection_uuid: CollectionUuid,
    initial_issuance: TokenCount,
    max_issuance: Option<TokenCount>,
    collection_owner: T::AccountId,
    metadata_scheme: MetadataScheme,
    name: CollectionNameType,
    royalties_schedule: Option<RoyaltiesSchedule<T::AccountId>>,
    origin_chain: OriginChain,
}

Minting should the following event:

Mint {
    collection_id: CollectionUuid,
    start: SerialNumber,
    end: SerialNumber,
    owner: T::AccountId,
}

^ note: start and end token ids are inclusive - owner is the account the tokens are minted to.

We tried to avoid dispatching too many events - as there is a cost for that.
For example if the user mints 1000+ tokens - there would be way too many events in the polkadotjs app.

Again - still open to discussion; this was a quick impl.
Feel free to suggest alternatives.