File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { useHappyChain } from "@happy.tech/react"
2+ import CallBatchDemo from "./demo-components/CallBatchDemo"
23import ChainSwitchingDemo from "./demo-components/ChainSwitchingDemo"
34import ConnectionDemo from "./demo-components/ConnectionDemo"
45import SessionKeyDemo from "./demo-components/SessionKeyDemo"
@@ -24,6 +25,7 @@ function App() {
2425 < ChainSwitchingDemo />
2526 < WalletFunctionalityDemo />
2627 < SessionKeyDemo />
28+ < CallBatchDemo />
2729 </ div >
2830 </ main >
2931 )
Original file line number Diff line number Diff line change 1+ import useClients from "../useClients"
2+
3+ const CallBatchDemo = ( ) => {
4+ const { walletClient } = useClients ( )
5+
6+ async function getCapabilities ( ) {
7+ // const caps = await walletClient?.getCapabilities()
8+ }
9+
10+ async function sendBatch ( ) {
11+ // const bundles = await walletClient?.sendCalls()
12+ }
13+
14+ async function getCallsStatus ( ) {
15+ // const stat = await walletClient?.getCallsStatus()
16+ }
17+
18+ return (
19+ < div className = "grid grid-cols-2 gap-4 backdrop-blur-sm bg-gray-200/35 p-4 rounded-lg" >
20+ < div className = "text-lg font-bold col-span-2" > EIP-5792</ div >
21+
22+ < button type = "button" onClick = { getCapabilities } className = "rounded-lg bg-sky-300 p-2 shadow-xl font-mono" >
23+ wallet_getCapabilities
24+ </ button >
25+
26+ < button
27+ type = "button"
28+ onClick = { sendBatch }
29+ className = "rounded-lg bg-sky-300 p-2 shadow-xl text-center font-mono"
30+ >
31+ wallet_sendCalls
32+ </ button >
33+
34+ < button type = "button" onClick = { getCallsStatus } className = "rounded-lg bg-sky-300 p-2 shadow-xl font-mono" >
35+ wallet_getCallsStatus
36+ </ button >
37+ </ div >
38+ )
39+ }
40+
41+ export default CallBatchDemo
Original file line number Diff line number Diff line change @@ -9,13 +9,14 @@ import {
99 createWalletClient ,
1010 custom ,
1111} from "viem"
12+ import { type Eip5792Actions , eip5792Actions } from "viem/experimental"
1213
1314/**
1415 * Creates custom public + wallet clients using the HappyProvider.
1516 */
1617export default function useClients ( ) : {
1718 publicClient : PublicClient
18- walletClient : WalletClient < CustomTransport , undefined , Account > | null
19+ walletClient : ( WalletClient < CustomTransport , undefined , Account > & Eip5792Actions ) | null
1920} {
2021 const { provider, user } = useHappyChain ( )
2122
@@ -27,7 +28,7 @@ export default function useClients(): {
2728 ? createWalletClient ( {
2829 account : user . address ,
2930 transport : custom ( provider ) ,
30- } )
31+ } ) . extend ( eip5792Actions ( ) )
3132 : null ,
3233 [ user , provider ] ,
3334 )
You can’t perform that action at this time.
0 commit comments