From 85a455d56a90c2d4618060e466d3332fc62d43c7 Mon Sep 17 00:00:00 2001 From: Leonardo Zizzamia Date: Fri, 13 Sep 2024 17:18:20 +0800 Subject: [PATCH] ok --- site/docs/pages/transaction/types.mdx | 9 ++++++++- src/transaction/types.ts | 9 +++------ src/transaction/utils/sendBatchedTransactions.ts | 4 ++-- src/transaction/utils/sendSingleTransactions.ts | 4 ++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/site/docs/pages/transaction/types.mdx b/site/docs/pages/transaction/types.mdx index ae2c071686..ee4a1738db 100644 --- a/site/docs/pages/transaction/types.mdx +++ b/site/docs/pages/transaction/types.mdx @@ -5,6 +5,12 @@ description: Glossary of Types in Transaction components & utilities. # Types [Glossary of Types in Transaction components & utilities.] +## `Call` + +```ts +type Call = { to: Hex; data?: Hex; value?: bigint }; +``` + ## `LifeCycleStatus` ```ts @@ -63,11 +69,12 @@ type TransactionError = { ```ts type TransactionReact = { + calls?: Call[]; // An array of calls to be made in the transaction. Mutually exclusive with the `contracts` prop. capabilities?: WalletCapabilities; // Capabilities that a wallet supports (e.g. paymasters, session keys, etc). chainId?: number; // The chainId for the transaction. children: ReactNode; // The child components to be rendered within the transaction component. className?: string; // An optional CSS class name for styling the component. - contracts: ContractFunctionParameters[]; // An array of contract function parameters for the transaction. + contracts?: ContractFunctionParameters[]; // An array of contract function parameters for the transaction. Mutually exclusive with the `calls` prop. onError?: (e: TransactionError) => void; // An optional callback function that handles transaction errors. onStatus?: (lifeCycleStatus: LifeCycleStatus) => void; // An optional callback function that exposes the component lifecycle state onSuccess?: (response: TransactionResponse) => void; // An optional callback function that exposes the transaction receipts diff --git a/src/transaction/types.ts b/src/transaction/types.ts index 78808ef517..33a0da17aa 100644 --- a/src/transaction/types.ts +++ b/src/transaction/types.ts @@ -1,3 +1,4 @@ +// 🌲☀🌲 import type { ReactNode } from 'react'; import type { Address, @@ -11,7 +12,6 @@ import type { WriteContractMutateAsync, } from 'wagmi/query'; import type { WalletCapabilities as OnchainKitWalletCapabilities } from '../types'; -// 🌲☀🌲 import { TRANSACTION_TYPE_CALLS, TRANSACTION_TYPE_CONTRACTS, @@ -91,14 +91,11 @@ export type TransactionContextType = { transactionHash?: string; // An optional string representing the hash of the transaction. }; -/** - * Paymaster service configuration - */ type PaymasterService = { url: string; }; -export type sendBatchedTransactionsParams = { +export type SendBatchedTransactionsParams = { capabilities?: WalletCapabilities; // biome-ignore lint: cannot find module 'wagmi/experimental/query' sendCallsAsync: any; @@ -108,7 +105,7 @@ export type sendBatchedTransactionsParams = { writeContractsAsync: any; }; -export type sendSingleTransactionParams = { +export type SendSingleTransactionParams = { sendCallAsync: SendTransactionMutateAsync | (() => void); transactions: Call[] | ContractFunctionParameters[]; transactionType: string; diff --git a/src/transaction/utils/sendBatchedTransactions.ts b/src/transaction/utils/sendBatchedTransactions.ts index f30a583573..bc359442eb 100644 --- a/src/transaction/utils/sendBatchedTransactions.ts +++ b/src/transaction/utils/sendBatchedTransactions.ts @@ -2,7 +2,7 @@ import { TRANSACTION_TYPE_CALLS, TRANSACTION_TYPE_CONTRACTS, } from '../constants'; -import type { sendBatchedTransactionsParams } from '../types'; +import type { SendBatchedTransactionsParams } from '../types'; export const sendBatchedTransactions = async ({ capabilities, @@ -10,7 +10,7 @@ export const sendBatchedTransactions = async ({ transactions, transactionType, writeContractsAsync, -}: sendBatchedTransactionsParams) => { +}: SendBatchedTransactionsParams) => { if (!transactions) { return; } diff --git a/src/transaction/utils/sendSingleTransactions.ts b/src/transaction/utils/sendSingleTransactions.ts index f96f23c820..b83d48b428 100644 --- a/src/transaction/utils/sendSingleTransactions.ts +++ b/src/transaction/utils/sendSingleTransactions.ts @@ -1,13 +1,13 @@ import type { ContractFunctionParameters } from 'viem'; import { TRANSACTION_TYPE_CALLS } from '../constants'; -import type { Call, sendSingleTransactionParams } from '../types'; +import type { Call, SendSingleTransactionParams } from '../types'; export const sendSingleTransactions = async ({ sendCallAsync, transactions, transactionType, writeContractAsync, -}: sendSingleTransactionParams) => { +}: SendSingleTransactionParams) => { for (const transaction of transactions) { if (transactionType === TRANSACTION_TYPE_CALLS) { await sendCallAsync(transaction as Call);