From 98dc0d076fce18add248b83907ae6d85cc2a20b8 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Fri, 30 Dec 2022 12:15:10 -0800 Subject: [PATCH] trying to parse tx data --- src/template/Sections.jsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/template/Sections.jsx b/src/template/Sections.jsx index 64fac6d..04e1de0 100644 --- a/src/template/Sections.jsx +++ b/src/template/Sections.jsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { ethers, BigNumber } from 'ethers'; -import { useAccount, useContractReads, usePrepareContractWrite, useContractWrite } from 'wagmi'; +import { useAccount, useContractReads, usePrepareContractWrite, useContractWrite, useTransaction } from 'wagmi'; import Typewriter from 'react-ts-typewriter'; import Slider from 'rc-slider'; import { Parallax } from 'react-parallax'; @@ -180,7 +180,9 @@ function Section3() { unaboomerSupply: 0, bombSupply: 0, bombsExploded: 0, - unaboomersKilled: 0 + unaboomersKilled: 0, + results: [], + tokensKilled: [] }); const handleStateChange = (obj) =>{ setOptions(preState => ({...preState , ...obj})) @@ -286,6 +288,17 @@ function Section3() { args: [options.sendBombAmount] }); const sendBombsWrite = useContractWrite(sendBombsPrepare.config); + const { data: tx } = useTransaction({ ...sendBombsWrite.data, enabled: sendBombsWrite.isSuccess }); + if (tx) { + // let r; + const iface = new ethers.utils.Interface(MainABI); + console.log(tx) + // let txRes = iface.decodeFunctionResult("sendBombs", tx.data); + // console.log(txRes) + // const {0: results, 1: tokensKilled} = txRes.functionFragment.outputs; + // console.log(results); + // console.log(tokensKilled); + } return (
{isConnected &&