Skip to content

Commit

Permalink
chore: version packages 🔖
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Aug 22, 2024
1 parent 26f8637 commit b82c904
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 107 deletions.
106 changes: 0 additions & 106 deletions .changeset/sweet-ghosts-act.md

This file was deleted.

110 changes: 110 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,115 @@
# Changelog

## 0.30.0

### Minor Changes

- ed2379e: - **feat**: Moved the `onError` and `onSuccess` lifecycle listeners from the `<SwapButton>` component to the `<Swap>` component. By @zizzamia #1139

Breaking Changes
OnchainKit standardizes lifecycle listeners with three callbacks: `onError`, `onSuccess`, and `onStatus`. The `onError` and `onSuccess` callbacks handle only the `error` and `success` states, respectively. In contrast, the `onStatus` callback provides more granular phases of each component's experience.

Before, we used `onError` and `onSuccess` in the `<SwapButton />` component.

```ts
const handleOnError = useCallback((error) => {
console.log(error);
}, []);

const handleOnSuccess = useCallback((response) => {
console.log(response);
}, []);

...

<Swap address={address}>
<SwapAmountInput
label="Sell"
swappableTokens={swappableTokens}
token={ETHToken}
type="from"
/>
<SwapToggleButton />
<SwapAmountInput
label="Buy"
swappableTokens={swappableTokens}
token={USDCToken}
type="to"
/>
<SwapButton
onError={handleOnError}
onSuccess={handleOnSuccess}
/>
<SwapMessage />
</Swap>
```

After, we use `onStatus` in the `<Swap />` component.

```ts
const handleOnStatus = useCallback((lifeCycleStatus: LifeCycleStatus) => {
console.log('Status:', lifeCycleStatus);
}, []);
...
<Swap
address={address}
onStatus={handleOnStatus}
>
<SwapAmountInput
label="Sell"
swappableTokens={swappableTokens}
token={ETHToken}
type="from"
/>
<SwapToggleButton />
<SwapAmountInput
label="Buy"
swappableTokens={swappableTokens}
token={USDCToken}
type="to"
/>
<SwapButton />
<SwapMessage />
</Swap>
```

The `onStatus` callback will expose

```ts
export type LifeCycleStatus =
| {
statusName: "init";
statusData: null;
}
| {
statusName: "error";
statusData: SwapError;
}
| {
statusName: "amountChange";
statusData: null;
}
| {
statusName: "transactionPending";
statusData: null;
}
| {
statusName: "transactionApproved";
statusData: {
transactionHash: Hex;
transactionType: "ERC20" | "Permit2";
};
}
| {
statusName: "success";
statusData: {
transactionReceipt: TransactionReceipt;
};
};
```

## 0.29.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coinbase/onchainkit",
"version": "0.29.5",
"version": "0.30.0",
"type": "module",
"repository": "https://github.com/coinbase/onchainkit.git",
"license": "MIT",
Expand Down

0 comments on commit b82c904

Please sign in to comment.