All files / src/parsers blur.io.basic.parser.ts

73.33% Statements 11/15
16.66% Branches 4/24
100% Functions 4/4
73.33% Lines 11/15

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 271x     1x   1x 1x   1x   1x     19x 224x     224x 19x         19x      
import { Log, TransactionResponse, ethers } from "ethers";
import { LogParser } from "./parser.definition";
import { config } from "../config";
import blurABI from '../abi/blur.json';
 
const blurContractAddress = '0x000000000000ad05ccc4f10045630fb830b95127';
const blurInterface = new ethers.Interface(blurABI);
 
export class BlurIOBasicParser implements LogParser {
    
    platform: string = 'blurio';
    
    parseLogs(transaction:TransactionResponse, logs: Log[], tokenId: string): number {
        const result = logs.map((log: any) => {
          Iif (log.address.toLowerCase() === blurContractAddress.toLowerCase()) {  
            return blurInterface.parseLog(log);
          }
        }).filter(l => l?.name === 'OrdersMatched' && l?.args.buy.tokenId.toString() === tokenId)
        Iif (result.length) {
          const weiValue = (result[0]?.args?.buy.price)?.toString();
          const value = ethers.formatEther(weiValue);
          return parseFloat(value);          
        }
        return undefined
    }
 
}