Skip to content

Commit

Permalink
delete types and use AbiItemArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
yu23ki14 committed Dec 1, 2024
1 parent e5604cb commit f41a8ee
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 122 deletions.
214 changes: 107 additions & 107 deletions pkgs/frontend/abi/splits.ts
Original file line number Diff line number Diff line change
@@ -1,108 +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",
},
export const SPLITS_CREATOR_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;
15 changes: 8 additions & 7 deletions pkgs/frontend/hooks/useSplitsCreator.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { SPLITS_ABI } from "abi/splits";
import { SPLITS_CREATOR_ABI } from "abi/splits";
import { useCallback, useState } from "react";
import { SplitsInfo } from "utils/types";
import { Address, encodeFunctionData } from "viem";
import { SPLITS_CREATOR_ADDRESS } from "./useContracts";
import { AbiItemArgs, Address, encodeFunctionData } from "viem";
import { useSmartAccountClient } from "./useSmartWallet";
import { publicClient } from "./useViem";

Expand All @@ -18,7 +16,10 @@ export const useSplitsCreator = () => {
* Splitsを作成するコールバック関数
*/
const createSplits = useCallback(
async (params: { splitsAddress: Address; args: SplitsInfo[] }) => {
async (params: {
splitsCreatorAddress: Address;
args: AbiItemArgs<typeof SPLITS_CREATOR_ABI, "create">[0];
}) => {
if (!smartAccountClient) return;

setIsLoading(true);
Expand All @@ -27,9 +28,9 @@ export const useSplitsCreator = () => {
const txHash = await smartAccountClient.sendTransaction({
calls: [
{
to: SPLITS_CREATOR_ADDRESS,
to: params.splitsCreatorAddress,
data: encodeFunctionData({
abi: SPLITS_ABI,
abi: SPLITS_CREATOR_ABI,
functionName: "create",
args: [params.args],
}),
Expand Down
8 changes: 0 additions & 8 deletions pkgs/frontend/utils/types.ts

This file was deleted.

0 comments on commit f41a8ee

Please sign in to comment.