From 1741444687e971e3d922dd4648a4a4379e0f7866 Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Mon, 13 Dec 2021 09:20:54 -0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Add=20transactionHash=20?= =?UTF-8?q?to=20NFT=20payload?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a transactionHash field to the NFT payload so we can track which transaction originated the event --- src/eth/responses.ts | 1 + src/nftwatcher.ts | 4 +++- test/__snapshots__/nftwatcher.test.ts.snap | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/eth/responses.ts b/src/eth/responses.ts index c4def17..1551cd8 100644 --- a/src/eth/responses.ts +++ b/src/eth/responses.ts @@ -159,6 +159,7 @@ export interface NftBody { contract: string; blockHash: string; blockNumber: number; + transactionHash: string; retrievalTime: number | string; } diff --git a/src/nftwatcher.ts b/src/nftwatcher.ts index 35addfd..3fafab9 100644 --- a/src/nftwatcher.ts +++ b/src/nftwatcher.ts @@ -310,7 +310,7 @@ export class NFTWatcher implements ManagedResource { outputMessages = await this.abortHandle.race( Promise.all( transfers.map(t => - this.complementWithTokenInfo(t.from, t.to, t.tokenIndex, formattedBlock, blockTime) + this.complementWithTokenInfo(t.from, t.to, rawTx.hash, t.tokenIndex, formattedBlock, blockTime) ) ) ); @@ -324,6 +324,7 @@ export class NFTWatcher implements ManagedResource { async complementWithTokenInfo( from: string, to: string, + transactionHash: string, index: string, formattedBlock: FormattedBlock, blockTime: number @@ -372,6 +373,7 @@ export class NFTWatcher implements ManagedResource { contract: this.config.contractAddress, blockHash: formattedBlock.hash!, blockNumber: formattedBlock.number!, + transactionHash: transactionHash, tokenIndex: index, rawTokenURI: rawTokenURI, errorTokenURI: errorTokenURI, diff --git a/test/__snapshots__/nftwatcher.test.ts.snap b/test/__snapshots__/nftwatcher.test.ts.snap index 8cd99a9..0492e5a 100644 --- a/test/__snapshots__/nftwatcher.test.ts.snap +++ b/test/__snapshots__/nftwatcher.test.ts.snap @@ -52,6 +52,7 @@ Array [ "to": "0x4a93264d56a21eebef0cfa4c0c2e0f4ee7edd1a9", "tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa81f", "tokenURI": "https://api.poap.xyz/metadata/14889/2795551", + "transactionHash": "0x551d86ba0af658d6ec0ff5fd57de55a0d4e220ab572afa3604d9ada4af4a0f42", }, "time": 1637722390000, "type": "nft", @@ -106,6 +107,7 @@ Array [ "to": "0x21529e234bdcc3346f70bbc10b0e7517779e5946", "tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa820", "tokenURI": "https://api.poap.xyz/metadata/14889/2795552", + "transactionHash": "0x3dc8ac7da0e7fe05b601af903fde1a699499df04dc5fc161b1503192578e6b52", }, "time": 1637722390000, "type": "nft", @@ -160,6 +162,7 @@ Array [ "to": "0xd6acf737b303c0c05a8aa4aebc55ba5e4e75fffa", "tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa821", "tokenURI": "https://api.poap.xyz/metadata/14889/2795553", + "transactionHash": "0xf4d0118473dfe441e3e40a1265389d08202dbd010b013da9025365cadc6f02a6", }, "time": 1637722390000, "type": "nft", @@ -214,6 +217,7 @@ Array [ "to": "0xd3d75f5fcaee0007ff4adbb68916ac41d07cb6b5", "tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa822", "tokenURI": "https://api.poap.xyz/metadata/14889/2795554", + "transactionHash": "0x57af043e0b7eb355ed36ffefb22a689875c7e8319e3de1e7561cef7f8449173b", }, "time": 1637722410000, "type": "nft", @@ -277,6 +281,7 @@ Terms and Conditions: https://confirmed.onelink.me/mzYA/589f9ddf", "to": "0xab196927732745d69c5a063872f8330c230abd57", "tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa823", "tokenURI": "https://api.poap.xyz/metadata/14195/2795555", + "transactionHash": "0xa16cc1509a603e8dab4f0587bdc7350c55f8944291fb2bf8395c94824e47c510", }, "time": 1637722410000, "type": "nft", @@ -331,6 +336,7 @@ Terms and Conditions: https://confirmed.onelink.me/mzYA/589f9ddf", "to": "0x8170317a4d0cad589c87b35997257a24b7a286f8", "tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa824", "tokenURI": "https://api.poap.xyz/metadata/14889/2795556", + "transactionHash": "0x548b8aa6b310bc5f77ae20ea7f71c9969411c737b4798daf515723bc52a524ba", }, "time": 1637722410000, "type": "nft", @@ -390,6 +396,7 @@ Aquarium gear airdropped to players every 15 minutes! The crypto competition awa "to": "0xb528c573ddd7acaba1a1da77a4fd5a1ea4a32990", "tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa825", "tokenURI": "https://api.poap.xyz/metadata/14823/2795557", + "transactionHash": "0x3fa8aee375dcc7a4e018f4dd64ee6b9044e21b2f0dc6c38c523c5e145453134b", }, "time": 1637722410000, "type": "nft", @@ -444,6 +451,7 @@ Aquarium gear airdropped to players every 15 minutes! The crypto competition awa "to": "0x266ee152cf011964aa4399bb568709199da82063", "tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa826", "tokenURI": "https://api.poap.xyz/metadata/14889/2795558", + "transactionHash": "0xe64f728b4c96cd4c8d15c983442c39e92b99a5dee3607659f523d68b675ea384", }, "time": 1637722410000, "type": "nft", @@ -498,6 +506,7 @@ Aquarium gear airdropped to players every 15 minutes! The crypto competition awa "to": "0xc5aa3267d7d102aa4a429adccc8299a8333fa354", "tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa827", "tokenURI": "https://api.poap.xyz/metadata/14889/2795559", + "transactionHash": "0xebed169d875ff46b1566013c1eed7da5545ea57da728ad3bdd63c414872aab56", }, "time": 1637722415000, "type": "nft", @@ -552,6 +561,7 @@ Aquarium gear airdropped to players every 15 minutes! The crypto competition awa "to": "0x0001a532d73491f9d319e729e99697c3d9c0a227", "tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa828", "tokenURI": "https://api.poap.xyz/metadata/14699/2795560", + "transactionHash": "0xcaa6a19797160253c1e4f5c75cb19c55c606993f5e51b393a8b653d38bba33f2", }, "time": 1637722415000, "type": "nft", @@ -611,6 +621,7 @@ Aquarium gear airdropped to players every 15 minutes! The crypto competition awa "to": "0x0001a532d73491f9d319e729e99697c3d9c0a227", "tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa829", "tokenURI": "https://api.poap.xyz/metadata/14823/2795561", + "transactionHash": "0x74c6b3a6e5a2bb1013f0b6ab196327274e54d0b6b7aa25ee0c0cb43681bb1160", }, "time": 1637722415000, "type": "nft", @@ -671,6 +682,7 @@ POAP distributed directly to artist from SearchLight through secret passcode.", "to": "0x263436b572a205397ae127b29b777a846288bd88", "tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa82a", "tokenURI": "https://api.poap.xyz/metadata/14572/2795562", + "transactionHash": "0x8b9e4a17c5de59b16ab0a7d063870e39737bb3461959a17543380cbe196f4dc1", }, "time": 1637722420000, "type": "nft", @@ -725,6 +737,7 @@ POAP distributed directly to artist from SearchLight through secret passcode.", "to": "0x6c58c4f6c9a68e556a8f81a70500e32b9b2253fb", "tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa82b", "tokenURI": "https://api.poap.xyz/metadata/14889/2795563", + "transactionHash": "0x3ff4b7710af939b8f8798f779ce5da96df7b2fd6ab012caab16fde56331dec7c", }, "time": 1637722420000, "type": "nft", @@ -779,6 +792,7 @@ POAP distributed directly to artist from SearchLight through secret passcode.", "to": "0xe7283120e64075de2376b0ab081b972d3d2cb635", "tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa82c", "tokenURI": "https://api.poap.xyz/metadata/14889/2795564", + "transactionHash": "0xb1221f2e2591eaf5e793dc4277e8ac8f52e7ca1f07a685eb52e62a0ff550859d", }, "time": 1637722425000, "type": "nft", @@ -833,6 +847,7 @@ POAP distributed directly to artist from SearchLight through secret passcode.", "to": "0x27a4b36bda9a448e429087c3d07159ac443920a4", "tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa82d", "tokenURI": "https://api.poap.xyz/metadata/15032/2795565", + "transactionHash": "0x92dbe44ff5a6e8747d77c51ca97805a8eaaa0fc327f4d171bc2aa4c93831092d", }, "time": 1637722430000, "type": "nft", @@ -887,6 +902,7 @@ POAP distributed directly to artist from SearchLight through secret passcode.", "to": "0x1845a63ed77312ede219da627101fba43109b1a0", "tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa82e", "tokenURI": "https://api.poap.xyz/metadata/14889/2795566", + "transactionHash": "0x9b6ae0c82eb225d12b924bc598bf895b60eb9caa9382391d502404cd40589cbe", }, "time": 1637722440000, "type": "nft", @@ -941,6 +957,7 @@ POAP distributed directly to artist from SearchLight through secret passcode.", "to": "0x3ceefc02adaa498dbe80782da0aa4d585a9196b0", "tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa82f", "tokenURI": "https://api.poap.xyz/metadata/14893/2795567", + "transactionHash": "0x79c0258705996402230bae73108b704412355c2cdf9a5fcf8483ca12d7066059", }, "time": 1637722440000, "type": "nft",