From be54d7a50cd9a79c114f6f8b8f24231e409ba056 Mon Sep 17 00:00:00 2001 From: yu23ki14 Date: Thu, 3 Oct 2024 23:21:04 +0900 Subject: [PATCH 1/2] add bigbang log --- pkgs/cli/src/modules/bigbang.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/pkgs/cli/src/modules/bigbang.ts b/pkgs/cli/src/modules/bigbang.ts index 3bbc967..b2b834d 100644 --- a/pkgs/cli/src/modules/bigbang.ts +++ b/pkgs/cli/src/modules/bigbang.ts @@ -2,9 +2,11 @@ // Write with viem // ############################################################### -import { Address } from "viem"; +import { Address, decodeEventLog } from "viem"; import { publicClient, walletClient } from ".."; import { bigbangContractBaseConfig } from "../config"; +import { startLoading } from "../services/loading"; +import { BIGBANG_ABI } from "../abi/bigbang"; /** * プロジェクト作成 @@ -18,6 +20,8 @@ export const bigbang = async (params: { hatterHatImageURI: string; trustedForwarder: Address; }) => { + const stop = startLoading(); + const { request } = await publicClient.simulateContract({ ...bigbangContractBaseConfig, account: walletClient.account, @@ -33,5 +37,24 @@ export const bigbang = async (params: { }); const transactionHash = await walletClient.writeContract(request); + const receipt = await publicClient.waitForTransactionReceipt({ + hash: transactionHash, + }); + + const log = receipt.logs.find((log) => { + try { + const decodedLog = decodeEventLog({ + abi: BIGBANG_ABI, + data: log.data, + topics: log.topics, + }); + return decodedLog.eventName === "Executed"; + } catch (error) {} + }); + + stop(); + + console.log(log); + return transactionHash; }; From 199061c2101468a294caa659053b66a8f06e0ea3 Mon Sep 17 00:00:00 2001 From: yu23ki14 Date: Thu, 3 Oct 2024 23:24:49 +0900 Subject: [PATCH 2/2] decode log --- pkgs/cli/src/modules/bigbang.ts | 13 +++++++++---- pkgs/cli/src/modules/fractiontoken.ts | 8 +++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/pkgs/cli/src/modules/bigbang.ts b/pkgs/cli/src/modules/bigbang.ts index b2b834d..7537f66 100644 --- a/pkgs/cli/src/modules/bigbang.ts +++ b/pkgs/cli/src/modules/bigbang.ts @@ -6,7 +6,6 @@ import { Address, decodeEventLog } from "viem"; import { publicClient, walletClient } from ".."; import { bigbangContractBaseConfig } from "../config"; import { startLoading } from "../services/loading"; -import { BIGBANG_ABI } from "../abi/bigbang"; /** * プロジェクト作成 @@ -44,17 +43,23 @@ export const bigbang = async (params: { const log = receipt.logs.find((log) => { try { const decodedLog = decodeEventLog({ - abi: BIGBANG_ABI, + abi: bigbangContractBaseConfig.abi, data: log.data, topics: log.topics, }); return decodedLog.eventName === "Executed"; } catch (error) {} - }); + })!; stop(); - console.log(log); + console.log( + decodeEventLog({ + abi: bigbangContractBaseConfig.abi, + data: log.data, + topics: log.topics, + }) + ); return transactionHash; }; diff --git a/pkgs/cli/src/modules/fractiontoken.ts b/pkgs/cli/src/modules/fractiontoken.ts index 7b0ff6a..ef5ae5f 100644 --- a/pkgs/cli/src/modules/fractiontoken.ts +++ b/pkgs/cli/src/modules/fractiontoken.ts @@ -56,7 +56,13 @@ export const sendFractionToken = async ( stop(); - console.log(log); + console.log( + decodeEventLog({ + abi: fractionTokenBaseConfig.abi, + data: log!.data, + topics: log!.topics, + }) + ); return transactionHash; };