Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 1x 1x 1x 31x 501x 1x 1x 1x 1x 1x 500x 501x 31x 1x 1x 30x | import { Log, TransactionResponse, ethers } from "ethers";
import { LogParser } from "./parser.definition";
import { config } from "../config";
import looksRareABI from '../abi/looksRareABI.json';
const raribleTopicIdentifier = '0x268820db288a211986b26a8fda86b1e0046281b21206936bb0e61c67b5c79ef4'
export class RaribleParser implements LogParser {
platform: string = 'rarible';
parseLogs(transaction:TransactionResponse, logs: Log[], tokenId: string): number {
const result = logs.map((log: any) => {
if (log.topics[0] === raribleTopicIdentifier ) {
const nftData = log.data.substring(2);
const nftDataSlices = nftData.match(/.{1,64}/g);
Iif (nftDataSlices.length !== 16) {
// invalid slice
return undefined
}
Iif (BigInt(`0x${nftDataSlices[12]}`).toString() !== tokenId) return;
// rarible sale
return BigInt(`0x${nftDataSlices[4]}`);
}
return undefined
}).filter(r => r !== undefined)
if (result.length) {
const amount = result.reduce((previous,current) => previous + current, BigInt(0));
return (parseFloat((amount / BigInt('10000000000000000')).toString())/100)
}
return undefined
}
} |