hirosystems / chainhook

Extract transactions from Stacks and Bitcoin and build event driven re-org resistant indexers and databases.
GNU General Public License v3.0
158 stars 65 forks source link

return `event_index` in Stacks transaction event metadata #387

Closed rafaelcr closed 8 months ago

rafaelcr commented 1 year ago

Stacks transaction events have an event index that indicates their ordering inside it. They are sent from the Stacks node to RPC listeners like so (see event_index):

    {
      "txid": "0xb55e53065b3e934716eb0f7dcce5138b719ea247459f18f60893e15c8d9a0159",
      "type": "ft_mint_event",
      "committed": true,
      "event_index": 46,
      "ft_mint_event": {
        "amount": "40000000000000",
        "recipient": "SP16KWQY6ZPXNYT43A4RKXBXMFT3V7ZMV5YYNR1CK",
        "asset_identifier": "SP3XYJ8XFZYF7MD86QQ5EF8HBVHHZFFQ9HM6SPJNQ.meme-token::MEME"
      }
    },

However, chainhook payloads do not return these indexes inside events, which makes it impossible to sort them by the order in which they were processed (no event_index here):

{
  "data": {
    "amount": "144",
    "asset_identifier": "SP466FNC0P7JWTNM2R9T199QRZN1MYEDTAR0KP27.miamicoin-token::miamicoin",
    "recipient": "SPCXZRY4FQZQHQ1EMBSDM1183HDK2ZGHPW3M1MA4",
    "sender": "SP3HXJJMJQ06GNAZ8XWDN1QM48JEDC6PP6W3YZPZJ"
  },
  "type": "FTTransferEvent"
}

Could this index be returned with these events? This is necessary for the Token Metadata API to process notifications correctly. Ideally, events should look like this:

{
  "data": {
    "amount": "144",
    "asset_identifier": "SP466FNC0P7JWTNM2R9T199QRZN1MYEDTAR0KP27.miamicoin-token::miamicoin",
    "recipient": "SPCXZRY4FQZQHQ1EMBSDM1183HDK2ZGHPW3M1MA4",
    "sender": "SP3HXJJMJQ06GNAZ8XWDN1QM48JEDC6PP6W3YZPZJ"
  },
  "type": "FTTransferEvent",
  "position": {
    "index": 46,
  }
}
github-actions[bot] commented 8 months ago

:tada: This issue has been resolved in version 1.3.1 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: