Skip to content

Commit

Permalink
fix: 🐛 NFT watcher: Filter events by contract address
Browse files Browse the repository at this point in the history
Filter events to only pick the ones that match the contract monitored
  • Loading branch information
atoulme committed Dec 13, 2021
1 parent bd5b297 commit ce6b339
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 969 deletions.
12 changes: 7 additions & 5 deletions src/nftwatcher.ts
Expand Up @@ -298,11 +298,13 @@ export class NFTWatcher implements ManagedResource {
if (receipt != null && receipt.logs != null) {
const transfers = receipt.logs
?.map(log => {
if (log.topics[0] == transferEventSignature && log.topics.length == 4) {
const from = '0x' + log.topics[1].substr(26);
const to = '0x' + log.topics[2].substr(26);
const tokenIndex = log.topics[3];
return { from, to, tokenIndex };
if (this.config.contractAddress == log.address) {
if (log.topics[0] == transferEventSignature && log.topics.length == 4) {
const from = '0x' + log.topics[1].substr(26);
const to = '0x' + log.topics[2].substr(26);
const tokenIndex = log.topics[3];
return { from, to, tokenIndex };
}
}
})
.filter((x): x is NftTransfer => x !== null && x !== undefined);
Expand Down

0 comments on commit ce6b339

Please sign in to comment.