Skip to content

Commit

Permalink
feat: 🎸 Add transactionHash to NFT payload
Browse files Browse the repository at this point in the history
Add a transactionHash field to the NFT payload so we can track which
transaction originated the event
  • Loading branch information
atoulme committed Dec 13, 2021
1 parent 81b7179 commit 1741444
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/eth/responses.ts
Expand Up @@ -159,6 +159,7 @@ export interface NftBody {
contract: string;
blockHash: string;
blockNumber: number;
transactionHash: string;
retrievalTime: number | string;
}

Expand Down
4 changes: 3 additions & 1 deletion src/nftwatcher.ts
Expand Up @@ -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)
)
)
);
Expand All @@ -324,6 +324,7 @@ export class NFTWatcher implements ManagedResource {
async complementWithTokenInfo(
from: string,
to: string,
transactionHash: string,
index: string,
formattedBlock: FormattedBlock,
blockTime: number
Expand Down Expand Up @@ -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,
Expand Down
17 changes: 17 additions & 0 deletions test/__snapshots__/nftwatcher.test.ts.snap
Expand Up @@ -52,6 +52,7 @@ Array [
"to": "0x4a93264d56a21eebef0cfa4c0c2e0f4ee7edd1a9",
"tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa81f",
"tokenURI": "https://api.poap.xyz/metadata/14889/2795551",
"transactionHash": "0x551d86ba0af658d6ec0ff5fd57de55a0d4e220ab572afa3604d9ada4af4a0f42",
},
"time": 1637722390000,
"type": "nft",
Expand Down Expand Up @@ -106,6 +107,7 @@ Array [
"to": "0x21529e234bdcc3346f70bbc10b0e7517779e5946",
"tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa820",
"tokenURI": "https://api.poap.xyz/metadata/14889/2795552",
"transactionHash": "0x3dc8ac7da0e7fe05b601af903fde1a699499df04dc5fc161b1503192578e6b52",
},
"time": 1637722390000,
"type": "nft",
Expand Down Expand Up @@ -160,6 +162,7 @@ Array [
"to": "0xd6acf737b303c0c05a8aa4aebc55ba5e4e75fffa",
"tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa821",
"tokenURI": "https://api.poap.xyz/metadata/14889/2795553",
"transactionHash": "0xf4d0118473dfe441e3e40a1265389d08202dbd010b013da9025365cadc6f02a6",
},
"time": 1637722390000,
"type": "nft",
Expand Down Expand Up @@ -214,6 +217,7 @@ Array [
"to": "0xd3d75f5fcaee0007ff4adbb68916ac41d07cb6b5",
"tokenIndex": "0x00000000000000000000000000000000000000000000000000000000002aa822",
"tokenURI": "https://api.poap.xyz/metadata/14889/2795554",
"transactionHash": "0x57af043e0b7eb355ed36ffefb22a689875c7e8319e3de1e7561cef7f8449173b",
},
"time": 1637722410000,
"type": "nft",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 1741444

Please sign in to comment.