All files / src/parsers notlarvalabs.parser.ts

91.66% Statements 11/12
66.66% Branches 2/3
100% Functions 4/4
91.66% Lines 11/12

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      1x   1x     33x 510x 1x 1x     1x   510x 33x 1x   32x      
import { Log, TransactionResponse, ethers } from "ethers";
import { LogParser } from "./parser.definition";
 
export class NotLarvaLabsParser implements LogParser {
    
    platform: string = 'notlarvalabs';
    
    parseLogs(transaction:TransactionResponse, logs: Log[], tokenId: string): number {
        const result = logs.map((log: any) => {
          if (log.topics[0].toLowerCase() === '0x975c7be5322a86cddffed1e3e0e55471a764ac2764d25176ceb8e17feef9392c') {
            const relevantData = log.data.substring(2);
            Iif (tokenId !== parseInt(log.topics[1], 16).toString()) {
              return
            }
            return BigInt(`0x${relevantData}`) / BigInt('1000000000000000')
          }
        }).filter(n => n !== undefined)
        if (result.length) {
          return parseFloat(result[0].toString())/1000;
        }
        return undefined
    }
 
}