Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizzamia committed Sep 13, 2024
1 parent 6d3a30f commit 85a455d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
9 changes: 8 additions & 1 deletion site/docs/pages/transaction/types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 3 additions & 6 deletions src/transaction/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// 🌲☀🌲
import type { ReactNode } from 'react';
import type {
Address,
Expand All @@ -11,7 +12,6 @@ import type {
WriteContractMutateAsync,
} from 'wagmi/query';
import type { WalletCapabilities as OnchainKitWalletCapabilities } from '../types';
// 🌲☀🌲
import {
TRANSACTION_TYPE_CALLS,
TRANSACTION_TYPE_CONTRACTS,
Expand Down Expand Up @@ -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;
Expand All @@ -108,7 +105,7 @@ export type sendBatchedTransactionsParams = {
writeContractsAsync: any;
};

export type sendSingleTransactionParams = {
export type SendSingleTransactionParams = {
sendCallAsync: SendTransactionMutateAsync<Config, unknown> | (() => void);
transactions: Call[] | ContractFunctionParameters[];
transactionType: string;
Expand Down
4 changes: 2 additions & 2 deletions src/transaction/utils/sendBatchedTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import {
TRANSACTION_TYPE_CALLS,
TRANSACTION_TYPE_CONTRACTS,
} from '../constants';
import type { sendBatchedTransactionsParams } from '../types';
import type { SendBatchedTransactionsParams } from '../types';

export const sendBatchedTransactions = async ({
capabilities,
sendCallsAsync,
transactions,
transactionType,
writeContractsAsync,
}: sendBatchedTransactionsParams) => {
}: SendBatchedTransactionsParams) => {
if (!transactions) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/transaction/utils/sendSingleTransactions.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down

0 comments on commit 85a455d

Please sign in to comment.