Skip to content

Commit 07614c1

Browse files
committed
storybook updates
1 parent 3496e97 commit 07614c1

File tree

1 file changed

+40
-13
lines changed

1 file changed

+40
-13
lines changed
Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,52 @@
11
import type { Meta } from "@storybook/react";
22
import { base } from "../../../chains/chain-definitions/base.js";
3+
import { sepolia } from "../../../chains/chain-definitions/sepolia.js";
34
import { useActiveAccount } from "../../../react/core/hooks/wallets/useActiveAccount.js";
45
import { useSendTransaction } from "../../../react/web/hooks/transaction/useSendTransaction.js";
56
import { ConnectButton } from "../../../react/web/ui/ConnectWallet/ConnectButton.js";
67
import { Button } from "../../../react/web/ui/components/buttons.js";
7-
import { prepareTransaction } from "../../../transaction/prepare-transaction.js";
8+
import { Spinner } from "../../../react/web/ui/components/Spinner.js";
9+
import {
10+
type PreparedTransaction,
11+
prepareTransaction,
12+
} from "../../../transaction/prepare-transaction.js";
813
import { toWei } from "../../../utils/units.js";
914
import { storyClient } from "../../utils.js";
1015

11-
const meta: Meta<typeof SendEth> = {
12-
component: SendEth,
16+
const meta: Meta<typeof Variant> = {
17+
component: Variant,
1318
title: "Bridge/Transaction/useSendTransaction",
1419
};
1520
export default meta;
1621

17-
export function SendEth() {
22+
const sendBase = prepareTransaction({
23+
chain: base,
24+
client: storyClient,
25+
to: "0x83Dd93fA5D8343094f850f90B3fb90088C1bB425",
26+
value: toWei("100"),
27+
});
28+
29+
// using an unsupported chain to popup deposit screen
30+
const sendSepolia = prepareTransaction({
31+
chain: sepolia,
32+
client: storyClient,
33+
to: "0x83Dd93fA5D8343094f850f90B3fb90088C1bB425",
34+
value: toWei("100"),
35+
});
36+
37+
export const BuyAndExecuteTx = {
38+
args: {
39+
transaction: sendBase,
40+
},
41+
};
42+
43+
export const DepositAndExecuteTx = {
44+
args: {
45+
transaction: sendSepolia,
46+
},
47+
};
48+
49+
function Variant(props: { transaction: PreparedTransaction }) {
1850
const sendTx = useSendTransaction();
1951
const account = useActiveAccount();
2052

@@ -24,18 +56,13 @@ export function SendEth() {
2456
return (
2557
<Button
2658
variant="primary"
59+
gap="xs"
2760
onClick={() => {
28-
const sendFunds = prepareTransaction({
29-
chain: base,
30-
client: storyClient,
31-
to: "0x83Dd93fA5D8343094f850f90B3fb90088C1bB425",
32-
value: toWei("100"),
33-
});
34-
35-
sendTx.mutate(sendFunds);
61+
sendTx.mutate(props.transaction);
3662
}}
3763
>
38-
{sendTx.isPending ? "Sending..." : "Send 100 Base ETH"}
64+
{sendTx.isPending && <Spinner size="sm" />}
65+
Execute
3966
</Button>
4067
);
4168
}

0 commit comments

Comments
 (0)