Skip to content

Commit

Permalink
chore: release
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizzamia committed Aug 6, 2024
1 parent c1f2cf6 commit f55bd00
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 57 deletions.
14 changes: 14 additions & 0 deletions .changeset/twelve-grapes-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
"@coinbase/onchainkit": minor
---

- **feat**: refactored the `<Transaction>` component's `onSuccess` handler to manage multiple receipts for various contracts, supporting both EOA and Smart Wallet scenarios.

Breaking Changes
When using `onSuccess` in the `<Transaction>` component, refactor the response to handle:

```ts
type TransactionResponse = {
transactionReceipts: TransactionReceipt[];
};
```
27 changes: 16 additions & 11 deletions site/docs/pages/transaction/transaction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ export default function TransactionComponents() {
];

return address ? (
<Transaction address={address} chainId={BASE_SEPOLIA_CHAIN_ID} contracts={contracts}> // [!code focus]
<Transaction // [!code focus]
address={address} // [!code focus]
chainId={BASE_SEPOLIA_CHAIN_ID} // [!code focus]
contracts={contracts} // [!code focus]
> // [!code focus]
<TransactionButton /> // [!code focus]
<TransactionSponsor /> // [!code focus]
<TransactionStatus> // [!code focus]
Expand Down Expand Up @@ -129,15 +133,18 @@ export default function TransactionComponents() {
```tsx
// ommited for brevity

<Transaction address={address} contracts={contracts}> // [!code focus]
<TransactionButton /> // [!code focus]
<Transaction // [!code focus]
address={address} // [!code focus]
contracts={contracts} // [!code focus]
> // [!code focus]
<TransactionButton /> // [!code focus]
<TransactionSponsor /> // [!code focus]
<TransactionToast> // [!code focus]
<TransactionToastIcon /> // [!code focus]
<TransactionToastLabel /> // [!code focus]
<TransactionToastAction /> // [!code focus]
</TransactionToast> // [!code focus]
</Transaction> // [!code focus]
<TransactionToast> // [!code focus]
<TransactionToastIcon /> // [!code focus]
<TransactionToastLabel /> // [!code focus]
<TransactionToastAction /> // [!code focus]
</TransactionToast> // [!code focus]
</Transaction> // [!code focus]
```

<App>
Expand Down Expand Up @@ -263,9 +270,7 @@ The components are designed to work together hierarchically. For each component,
## Props

- [`TransactionButtonReact`](/transaction/types#transactionbuttonreact)
- [`TransactionContextType`](/transaction/types#transactioncontexttype)
- [`TransactionError`](/transaction/types#transactionerror)
- [`TransactionProviderReact`](/transaction/types#transactionproviderreact)
- [`TransactionReact`](/transaction/types#transactionreact)
- [`TransactionSponsorReact`](/transaction/types#transactionsponsorreact)
- [`TransactionStatusReact`](/transaction/types#transactionstatusreact)
Expand Down
36 changes: 0 additions & 36 deletions site/docs/pages/transaction/types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,6 @@ type TransactionButtonReact = {
};
```

## `TransactionContextType`

```ts
type TransactionContextType = {
address: Address; // The wallet address involved in the transaction.
chainId?: number; // The chainId for the transaction.
contracts: ContractFunctionParameters[]; // An array of contracts for the transaction.
errorMessage?: string; // An error message string if the transaction encounters an issue.
hasPaymaster?: boolean; // A boolean indicating if app has paymaster configured
isLoading: boolean; // A boolean indicating if the transaction is currently loading.
isToastVisible: boolean; // A boolean indicating if the transaction toast notification is visible.
onSubmit: () => void; // A function called when the transaction is submitted.
receipt?: TransactionReceipt; // The receipt of the transaction
setErrorMessage: (error: string) => void; // A function to set the error message for the transaction.
setIsToastVisible: (isVisible: boolean) => void; // A function to set the visibility of the transaction toast.
setTransactionId: (id: string) => void; // A function to set the transaction ID.
statusWriteContract?: string; // An optional string indicating the current status of the transaction.
statusWriteContracts?: string; // An optional string indicating the current status of the transaction.
transactionId?: string; // An optional string representing the ID of the transaction.
transactionHash?: string; // An optional string representing the hash of the transaction.
};
```

## `TransactionError`

```ts
Expand All @@ -46,18 +23,6 @@ type TransactionError = {
};
```

## `TransactionProviderReact`

```ts
type TransactionProviderReact = {
address: Address; // The wallet address to be provided to child components.
children: ReactNode; // The child components to be rendered within the provider component.
contracts: ContractFunctionParameters[]; // An array of contract function parameters provided to the child components.
onError?: (e: TransactionError) => void; // An optional callback function that handles errors within the provider.
onSuccess?: (response: TransactionResponse) => void; // An optional callback function that exposes the transaction receipts
};
```

## `TransactionReact`

```ts
Expand All @@ -77,7 +42,6 @@ type TransactionReact = {
type TransactionResponse = {
transactionReceipts: TransactionReceipt[];
};

```

## `TransactionSponsorReact`
Expand Down
3 changes: 0 additions & 3 deletions src/transaction/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 🌲☀🌲
export { Transaction } from './components/Transaction';
export { TransactionButton } from './components/TransactionButton';
export { TransactionProvider } from './components/TransactionProvider';
export { TransactionSponsor } from './components/TransactionSponsor';
export { TransactionStatus } from './components/TransactionStatus';
export { TransactionStatusAction } from './components/TransactionStatusAction';
Expand All @@ -12,9 +11,7 @@ export { TransactionToastAction } from './components/TransactionToastAction';
export { TransactionToastLabel } from './components/TransactionToastLabel';
export type {
TransactionButtonReact,
TransactionContextType,
TransactionError,
TransactionProviderReact,
TransactionReact,
TransactionSponsorReact,
TransactionStatusReact,
Expand Down
6 changes: 0 additions & 6 deletions src/transaction/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ export type TransactionButtonReact = {
text?: string; // An optional text to be displayed in the button component.
};

/**
* Note: exported as public Type
*/
export type TransactionContextType = {
address: Address; // The wallet address involved in the transaction.
chainId?: number; // The chainId for the transaction.
Expand Down Expand Up @@ -52,9 +49,6 @@ export type TransactionError = {
error: string; // The error message providing details about the transaction error.
};

/**
* Note: exported as public Type
*/
export type TransactionProviderReact = {
address: Address; // The wallet address to be provided to child components.
capabilities?: WalletCapabilities; // Capabilities that a wallet supports (e.g. paymasters, session keys, etc).
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = '0.27.1';
export const version = '0.28.0';

0 comments on commit f55bd00

Please sign in to comment.