11import type { Meta } from "@storybook/react" ;
22import { base } from "../../../chains/chain-definitions/base.js" ;
3+ import { sepolia } from "../../../chains/chain-definitions/sepolia.js" ;
34import { useActiveAccount } from "../../../react/core/hooks/wallets/useActiveAccount.js" ;
45import { useSendTransaction } from "../../../react/web/hooks/transaction/useSendTransaction.js" ;
56import { ConnectButton } from "../../../react/web/ui/ConnectWallet/ConnectButton.js" ;
67import { 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" ;
813import { toWei } from "../../../utils/units.js" ;
914import { 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} ;
1520export 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