From 1c351cef893b253bd9a52a9cb0e6626965cf6337 Mon Sep 17 00:00:00 2001 From: yawn <69970183+yawn-c111@users.noreply.github.com> Date: Thu, 3 Oct 2024 22:28:16 +0900 Subject: [PATCH 1/7] feat: add splits command --- pkgs/cli/src/abi/splits.ts | 108 ++++++++++++++++++++++++++++++++ pkgs/cli/src/commands/splits.ts | 61 ++++++++++++++++++ pkgs/cli/src/index.ts | 2 + pkgs/cli/src/modules/splits.ts | 31 +++++++++ 4 files changed, 202 insertions(+) create mode 100644 pkgs/cli/src/abi/splits.ts create mode 100644 pkgs/cli/src/commands/splits.ts create mode 100644 pkgs/cli/src/modules/splits.ts diff --git a/pkgs/cli/src/abi/splits.ts b/pkgs/cli/src/abi/splits.ts new file mode 100644 index 0000000..30233a0 --- /dev/null +++ b/pkgs/cli/src/abi/splits.ts @@ -0,0 +1,108 @@ +export const SPLITS_ABI = [ + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "split", + type: "address", + }, + ], + name: "SplitsCreated", + type: "event", + }, + { + inputs: [], + name: "FRACTION_TOKEN", + outputs: [ + { + internalType: "contract IFractionToken", + name: "", + type: "address", + }, + ], + stateMutability: "pure", + type: "function", + }, + { + inputs: [], + name: "HATS_TIME_FRAME_MODULE", + outputs: [ + { + internalType: "contract IHatsTimeFrameModule", + name: "", + type: "address", + }, + ], + stateMutability: "pure", + type: "function", + }, + { + inputs: [], + name: "SPLIT_FACTORY_V2", + outputs: [ + { + internalType: "contract ISplitFactoryV2", + name: "", + type: "address", + }, + ], + stateMutability: "pure", + type: "function", + }, + { + inputs: [], + name: "TRUSTED_FORWARDER", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "pure", + type: "function", + }, + { + inputs: [ + { + components: [ + { + internalType: "uint256", + name: "hatId", + type: "uint256", + }, + { + internalType: "uint256", + name: "multiplierBottom", + type: "uint256", + }, + { + internalType: "uint256", + name: "multiplierTop", + type: "uint256", + }, + { + internalType: "address[]", + name: "wearers", + type: "address[]", + }, + ], + internalType: "struct ISplitsCreator.SplitsInfo[]", + name: "_splitsInfo", + type: "tuple[]", + }, + ], + name: "create", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, +] as const; diff --git a/pkgs/cli/src/commands/splits.ts b/pkgs/cli/src/commands/splits.ts new file mode 100644 index 0000000..f68dac5 --- /dev/null +++ b/pkgs/cli/src/commands/splits.ts @@ -0,0 +1,61 @@ +import { Command } from "commander"; +import { create } from "../modules/splits"; +import { getAccount } from "../services/wallet"; +import { rootProgram } from ".."; +import { Address } from "viem"; + +export const splitsCommands = new Command(); + +// ############################################################### +// CLI init setup +// ############################################################### + +splitsCommands + .name("splits") + .description("This is a CLI splits for toban project") + .version("1.0.0"); + +// ############################################################### +// command setUp +// ############################################################### + +/** + * スプリットを作成 + */ +splitsCommands + .command("create") + .description("Create Splits") + .requiredOption( + "-splits", + "--splitsAddress ", + "Splits Address" + ) + .requiredOption("-hid --hatId ", "Hat ID") + .requiredOption( + "-mb --multiplierBottom ", + "Multiplier Bottom" + ) + .requiredOption("-mt --multiplierTop ", "Multiplier Top") + .requiredOption("-w --wearers ", "Wearers") + .action( + async ({ + splitsAddress, + hatId, + multiplierBottom, + multiplierTop, + wearer, + }) => { + const hash = await create(splitsAddress, [ + { + hatId: hatId, + multiplierBottom: multiplierBottom, + multiplierTop: multiplierTop, + wearers: [ + "0x777ee5eeed30c3712bee6c83260d786857d9c556" as Address, + // "0xEef377Bdf67A227a744e386231fB3f264C158CDF", + ], + }, + ]); + console.log("Transaction sent. Hash:", hash); + } + ); diff --git a/pkgs/cli/src/index.ts b/pkgs/cli/src/index.ts index 30beafc..15a491c 100755 --- a/pkgs/cli/src/index.ts +++ b/pkgs/cli/src/index.ts @@ -3,6 +3,7 @@ import { Command } from "commander"; import { hatsCommands } from "./commands/hats"; import { walletCommands } from "./commands/wallet"; +import { splitsCommands } from "./commands/splits"; import { PublicClient, WalletClient } from "viem"; import { getPublicClient } from "./modules/viem"; import { getWalletClient } from "./services/wallet"; @@ -33,5 +34,6 @@ rootProgram rootProgram.addCommand(bigbangCommands); rootProgram.addCommand(hatsCommands); rootProgram.addCommand(walletCommands); +rootProgram.addCommand(splitsCommands); rootProgram.parse(process.argv); diff --git a/pkgs/cli/src/modules/splits.ts b/pkgs/cli/src/modules/splits.ts new file mode 100644 index 0000000..fef7fc1 --- /dev/null +++ b/pkgs/cli/src/modules/splits.ts @@ -0,0 +1,31 @@ +import { HatsSubgraphClient } from "@hatsprotocol/sdk-v1-subgraph"; +import { Address } from "viem"; +import { base, optimism, sepolia } from "viem/chains"; +import { + hatsContractBaseConfig, + hatsTimeFrameContractBaseConfig, +} from "../config"; +import { publicClient, walletClient } from ".."; +import { SPLITS_ABI } from "../abi/splits"; + +type SplitsInfo = { + hatId: bigint; + multiplierBottom: bigint; + multiplierTop: bigint; + wearers: Address[]; +}; + +/** + * Splitsを作成 + */ +export const create = async (splitsAddress: Address, args: SplitsInfo[]) => { + const { request } = await publicClient.simulateContract({ + address: "0x39cB5bb4D84a37d1d9D0Abb0c9a6C5F5DE501aba" as Address, + abi: SPLITS_ABI, + account: walletClient.account, + functionName: "create", + args: [args], + }); + const hash = await walletClient.writeContract(request); + return hash; +}; From bc4528ed4c3e324eaff30712a88663dfc3f6e1b4 Mon Sep 17 00:00:00 2001 From: yawn <69970183+yawn-c111@users.noreply.github.com> Date: Thu, 3 Oct 2024 22:37:18 +0900 Subject: [PATCH 2/7] fix: type error in splits create command --- pkgs/cli/src/commands/splits.ts | 13 +++++-------- yarn.lock | 31 +++---------------------------- 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/pkgs/cli/src/commands/splits.ts b/pkgs/cli/src/commands/splits.ts index f68dac5..c5812df 100644 --- a/pkgs/cli/src/commands/splits.ts +++ b/pkgs/cli/src/commands/splits.ts @@ -43,17 +43,14 @@ splitsCommands hatId, multiplierBottom, multiplierTop, - wearer, + wearers, }) => { const hash = await create(splitsAddress, [ { - hatId: hatId, - multiplierBottom: multiplierBottom, - multiplierTop: multiplierTop, - wearers: [ - "0x777ee5eeed30c3712bee6c83260d786857d9c556" as Address, - // "0xEef377Bdf67A227a744e386231fB3f264C158CDF", - ], + hatId: BigInt(hatId), + multiplierBottom: BigInt(multiplierBottom), + multiplierTop: BigInt(multiplierTop), + wearers: [wearers] as Address[], }, ]); console.log("Transaction sent. Hash:", hash); diff --git a/yarn.lock b/yarn.lock index efa562f..5a4538a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5504,7 +5504,7 @@ streamsearch@^1.1.0: resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-1.1.0.tgz#404dd1e2247ca94af554e841a8ef0eaa238da764" integrity sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg== -"string-width-cjs@npm:string-width@^4.2.0": +"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -5521,15 +5521,6 @@ string-width@^2.1.1: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" -string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - string-width@^5.0.1, string-width@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" @@ -5615,7 +5606,7 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1": +"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -5629,13 +5620,6 @@ strip-ansi@^4.0.0: dependencies: ansi-regex "^3.0.0" -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - strip-ansi@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" @@ -6174,16 +6158,7 @@ workerpool@^6.5.1: resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.5.1.tgz#060f73b39d0caf97c6db64da004cd01b4c099544" integrity sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== From dbcb72e47035e360cf57396dcadf2d7bb79769b5 Mon Sep 17 00:00:00 2001 From: yawn <69970183+yawn-c111@users.noreply.github.com> Date: Thu, 3 Oct 2024 23:02:49 +0900 Subject: [PATCH 3/7] feat: enable multiple args in splits create command --- pkgs/cli/src/commands/splits.ts | 49 +++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/pkgs/cli/src/commands/splits.ts b/pkgs/cli/src/commands/splits.ts index c5812df..4fe5ccb 100644 --- a/pkgs/cli/src/commands/splits.ts +++ b/pkgs/cli/src/commands/splits.ts @@ -30,13 +30,38 @@ splitsCommands "--splitsAddress ", "Splits Address" ) - .requiredOption("-hid --hatId ", "Hat ID") + .requiredOption( + "-hid --hatId ", + "Hat ID", + (value, previous: string[]) => + previous ? previous.concat([value]) : [value], + [] + ) .requiredOption( "-mb --multiplierBottom ", - "Multiplier Bottom" + "Multiplier Bottom", + (value, previous: string[]) => + previous ? previous.concat([value]) : [value], + [] + ) + .requiredOption( + "-mt --multiplierTop ", + "Multiplier Top", + (value, previous: string[]) => + previous ? previous.concat([value]) : [value], + [] + ) + .requiredOption( + "-w, --wearers ", + "Wearers (comma-separated addresses)", + (value: string, previous: Address[]) => { + const addresses = value + .split(",") + .map((addr: string) => addr.trim()) as Address[]; + return previous ? previous.concat(addresses) : addresses; + }, + [] ) - .requiredOption("-mt --multiplierTop ", "Multiplier Top") - .requiredOption("-w --wearers ", "Wearers") .action( async ({ splitsAddress, @@ -45,14 +70,14 @@ splitsCommands multiplierTop, wearers, }) => { - const hash = await create(splitsAddress, [ - { - hatId: BigInt(hatId), - multiplierBottom: BigInt(multiplierBottom), - multiplierTop: BigInt(multiplierTop), - wearers: [wearers] as Address[], - }, - ]); + const splitsData = hatId.map((id: string, index: number) => ({ + hatId: BigInt(id), + multiplierBottom: BigInt(multiplierBottom[index]), + multiplierTop: BigInt(multiplierTop[index]), + wearers: wearers, + })); + + const hash = await create(splitsAddress as Address, splitsData); console.log("Transaction sent. Hash:", hash); } ); From d5d0a02c86986c47928c9c0fd9938f25a5229ab8 Mon Sep 17 00:00:00 2001 From: yawn <69970183+yawn-c111@users.noreply.github.com> Date: Thu, 3 Oct 2024 23:17:51 +0900 Subject: [PATCH 4/7] fix: wearers address in splits create command --- pkgs/cli/src/commands/splits.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkgs/cli/src/commands/splits.ts b/pkgs/cli/src/commands/splits.ts index 4fe5ccb..8dde9c0 100644 --- a/pkgs/cli/src/commands/splits.ts +++ b/pkgs/cli/src/commands/splits.ts @@ -54,11 +54,11 @@ splitsCommands .requiredOption( "-w, --wearers ", "Wearers (comma-separated addresses)", - (value: string, previous: Address[]) => { + (value: string, previous: Address[][]) => { const addresses = value .split(",") - .map((addr: string) => addr.trim()) as Address[]; - return previous ? previous.concat(addresses) : addresses; + .map((addr: string) => addr.trim() as Address); + return previous ? [...previous, addresses] : [addresses]; }, [] ) @@ -74,10 +74,12 @@ splitsCommands hatId: BigInt(id), multiplierBottom: BigInt(multiplierBottom[index]), multiplierTop: BigInt(multiplierTop[index]), - wearers: wearers, + wearers: wearers[index], })); - const hash = await create(splitsAddress as Address, splitsData); + console.log(splitsData); + + const hash = await create(splitsAddress, splitsData); console.log("Transaction sent. Hash:", hash); } ); From ed131a83b113a33f35787cb29d5c3213f6a3ea2e Mon Sep 17 00:00:00 2001 From: yawn <69970183+yawn-c111@users.noreply.github.com> Date: Thu, 3 Oct 2024 23:18:30 +0900 Subject: [PATCH 5/7] fix: delete log --- pkgs/cli/src/commands/splits.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/cli/src/commands/splits.ts b/pkgs/cli/src/commands/splits.ts index 8dde9c0..0a2f425 100644 --- a/pkgs/cli/src/commands/splits.ts +++ b/pkgs/cli/src/commands/splits.ts @@ -77,8 +77,6 @@ splitsCommands wearers: wearers[index], })); - console.log(splitsData); - const hash = await create(splitsAddress, splitsData); console.log("Transaction sent. Hash:", hash); } From e3f002401cd13acfa174652ba950b18cdf1f4c22 Mon Sep 17 00:00:00 2001 From: yu23ki14 Date: Thu, 3 Oct 2024 23:31:26 +0900 Subject: [PATCH 6/7] tmp --- pkgs/cli/src/commands/splits.ts | 12 ++++-------- pkgs/cli/src/modules/splits.ts | 8 +------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/pkgs/cli/src/commands/splits.ts b/pkgs/cli/src/commands/splits.ts index 0a2f425..6de9dc6 100644 --- a/pkgs/cli/src/commands/splits.ts +++ b/pkgs/cli/src/commands/splits.ts @@ -25,27 +25,23 @@ splitsCommands splitsCommands .command("create") .description("Create Splits") + .requiredOption("-splits, --splitsAddress ", "Splits Address") .requiredOption( - "-splits", - "--splitsAddress ", - "Splits Address" - ) - .requiredOption( - "-hid --hatId ", + "-hid, --hatId ", "Hat ID", (value, previous: string[]) => previous ? previous.concat([value]) : [value], [] ) .requiredOption( - "-mb --multiplierBottom ", + "-mb, --multiplierBottom ", "Multiplier Bottom", (value, previous: string[]) => previous ? previous.concat([value]) : [value], [] ) .requiredOption( - "-mt --multiplierTop ", + "-mt, --multiplierTop ", "Multiplier Top", (value, previous: string[]) => previous ? previous.concat([value]) : [value], diff --git a/pkgs/cli/src/modules/splits.ts b/pkgs/cli/src/modules/splits.ts index fef7fc1..f80bdf9 100644 --- a/pkgs/cli/src/modules/splits.ts +++ b/pkgs/cli/src/modules/splits.ts @@ -1,10 +1,4 @@ -import { HatsSubgraphClient } from "@hatsprotocol/sdk-v1-subgraph"; import { Address } from "viem"; -import { base, optimism, sepolia } from "viem/chains"; -import { - hatsContractBaseConfig, - hatsTimeFrameContractBaseConfig, -} from "../config"; import { publicClient, walletClient } from ".."; import { SPLITS_ABI } from "../abi/splits"; @@ -20,7 +14,7 @@ type SplitsInfo = { */ export const create = async (splitsAddress: Address, args: SplitsInfo[]) => { const { request } = await publicClient.simulateContract({ - address: "0x39cB5bb4D84a37d1d9D0Abb0c9a6C5F5DE501aba" as Address, + address: splitsAddress, abi: SPLITS_ABI, account: walletClient.account, functionName: "create", From 217e01ba69966dad499b1017f6a3c9ede6ecf929 Mon Sep 17 00:00:00 2001 From: yu23ki14 Date: Thu, 3 Oct 2024 23:42:13 +0900 Subject: [PATCH 7/7] tmp --- pkgs/cli/src/commands/splits.ts | 2 +- pkgs/cli/src/modules/bigbang.ts | 16 ++++++++--- pkgs/cli/src/modules/fractiontoken.ts | 16 ++++++----- pkgs/cli/src/modules/splits.ts | 38 ++++++++++++++++++++++++++- 4 files changed, 59 insertions(+), 13 deletions(-) diff --git a/pkgs/cli/src/commands/splits.ts b/pkgs/cli/src/commands/splits.ts index 6de9dc6..40662dc 100644 --- a/pkgs/cli/src/commands/splits.ts +++ b/pkgs/cli/src/commands/splits.ts @@ -74,6 +74,6 @@ splitsCommands })); const hash = await create(splitsAddress, splitsData); - console.log("Transaction sent. Hash:", hash); + console.log("Transaction Hash:", hash); } ); diff --git a/pkgs/cli/src/modules/bigbang.ts b/pkgs/cli/src/modules/bigbang.ts index 7537f66..79b6a9e 100644 --- a/pkgs/cli/src/modules/bigbang.ts +++ b/pkgs/cli/src/modules/bigbang.ts @@ -6,6 +6,7 @@ import { Address, decodeEventLog } from "viem"; import { publicClient, walletClient } from ".."; import { bigbangContractBaseConfig } from "../config"; import { startLoading } from "../services/loading"; +import { hatIdToTreeId } from "@hatsprotocol/sdk-v1-core"; /** * プロジェクト作成 @@ -53,13 +54,20 @@ export const bigbang = async (params: { stop(); - console.log( - decodeEventLog({ + if (log) { + const decodedLog = decodeEventLog({ abi: bigbangContractBaseConfig.abi, data: log.data, topics: log.topics, - }) - ); + }); + console.log(decodedLog); + console.log( + "Tree Link:", + `https://app.hatsprotocol.xyz/trees/${String( + publicClient.chain?.id + )}/${hatIdToTreeId(BigInt(decodedLog.args.topHatId))}` + ); + } return transactionHash; }; diff --git a/pkgs/cli/src/modules/fractiontoken.ts b/pkgs/cli/src/modules/fractiontoken.ts index ef5ae5f..bec6ff1 100644 --- a/pkgs/cli/src/modules/fractiontoken.ts +++ b/pkgs/cli/src/modules/fractiontoken.ts @@ -56,13 +56,15 @@ export const sendFractionToken = async ( stop(); - console.log( - decodeEventLog({ - abi: fractionTokenBaseConfig.abi, - data: log!.data, - topics: log!.topics, - }) - ); + if (log) { + console.log( + decodeEventLog({ + abi: fractionTokenBaseConfig.abi, + data: log!.data, + topics: log!.topics, + }) + ); + } return transactionHash; }; diff --git a/pkgs/cli/src/modules/splits.ts b/pkgs/cli/src/modules/splits.ts index f80bdf9..04df951 100644 --- a/pkgs/cli/src/modules/splits.ts +++ b/pkgs/cli/src/modules/splits.ts @@ -1,6 +1,7 @@ -import { Address } from "viem"; +import { Address, decodeEventLog } from "viem"; import { publicClient, walletClient } from ".."; import { SPLITS_ABI } from "../abi/splits"; +import { startLoading } from "../services/loading"; type SplitsInfo = { hatId: bigint; @@ -13,6 +14,7 @@ type SplitsInfo = { * Splitsを作成 */ export const create = async (splitsAddress: Address, args: SplitsInfo[]) => { + const stop = startLoading(); const { request } = await publicClient.simulateContract({ address: splitsAddress, abi: SPLITS_ABI, @@ -20,6 +22,40 @@ export const create = async (splitsAddress: Address, args: SplitsInfo[]) => { functionName: "create", args: [args], }); + const hash = await walletClient.writeContract(request); + + const receipt = await publicClient.waitForTransactionReceipt({ + hash, + }); + + const log = receipt.logs.find((log) => { + try { + const decodedLog = decodeEventLog({ + abi: SPLITS_ABI, + data: log.data, + topics: log.topics, + }); + return decodedLog.eventName === "SplitsCreated"; + } catch (error) {} + }); + + stop(); + + if (log) { + const decodedLog = decodeEventLog({ + abi: SPLITS_ABI, + data: log.data, + topics: log.topics, + }); + console.log(decodedLog); + console.log( + "Split Link:", + `https://app.splits.org/accounts/${ + decodedLog.args.split + }/?chainId=${String(publicClient.chain?.id)}` + ); + } + return hash; };