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 | 1x 1x 1x 30x 493x 1x 1x 1x 1x 1x 1x 1x 492x 493x 30x 1x 29x | import { Log, TransactionResponse, ethers } from "ethers"; import { LogParser } from "./parser.definition"; import { config } from "../config"; const cargoTopicIdentifier = '0x5535fa724c02f50c6fb4300412f937dbcdf655b0ebd4ecaca9a0d377d0c0d9cc' export class CargoParser implements LogParser { platform: string = 'cargo'; parseLogs(transaction:TransactionResponse, logs: Log[], tokenId: string): number { const result = logs.map((log: any) => { if (log.topics[0] === cargoTopicIdentifier) { // cargo sale const data = log.data.substring(2); const dataSlices = data.match(/.{1,64}/g); const amount = BigInt(`0x${dataSlices[15]}`); const saleTokenId = `${parseInt(dataSlices[10], 16)}`; const commission = BigInt(`0x${dataSlices[16]}`) if (saleTokenId === tokenId) return amount + commission } return undefined }).filter(r => r !== undefined) if (result.length) { return (parseFloat((result[0] / BigInt('10000000000000000')).toString())/100) } return undefined } } |