Skip to content

Commit

Permalink
Merge pull request #135 from hackdays-io/feature/waitlog
Browse files Browse the repository at this point in the history
Feature/waitlog
  • Loading branch information
yu23ki14 authored Oct 3, 2024
2 parents 98e155f + 199061c commit 2309ea1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
30 changes: 29 additions & 1 deletion pkgs/cli/src/modules/bigbang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// 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";

/**
* プロジェクト作成
Expand All @@ -18,6 +19,8 @@ export const bigbang = async (params: {
hatterHatImageURI: string;
trustedForwarder: Address;
}) => {
const stop = startLoading();

const { request } = await publicClient.simulateContract({
...bigbangContractBaseConfig,
account: walletClient.account,
Expand All @@ -33,5 +36,30 @@ 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: bigbangContractBaseConfig.abi,
data: log.data,
topics: log.topics,
});
return decodedLog.eventName === "Executed";
} catch (error) {}
})!;

stop();

console.log(
decodeEventLog({
abi: bigbangContractBaseConfig.abi,
data: log.data,
topics: log.topics,
})
);

return transactionHash;
};
8 changes: 7 additions & 1 deletion pkgs/cli/src/modules/fractiontoken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

0 comments on commit 2309ea1

Please sign in to comment.