File tree Expand file tree Collapse file tree 3 files changed +46
-2
lines changed Expand file tree Collapse file tree 3 files changed +46
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { useHappyChain } from "@happy.tech/react"
2
+ import CallBatchDemo from "./demo-components/CallBatchDemo"
2
3
import ChainSwitchingDemo from "./demo-components/ChainSwitchingDemo"
3
4
import ConnectionDemo from "./demo-components/ConnectionDemo"
4
5
import SessionKeyDemo from "./demo-components/SessionKeyDemo"
@@ -24,6 +25,7 @@ function App() {
24
25
< ChainSwitchingDemo />
25
26
< WalletFunctionalityDemo />
26
27
< SessionKeyDemo />
28
+ < CallBatchDemo />
27
29
</ div >
28
30
</ main >
29
31
)
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 {
9
9
createWalletClient ,
10
10
custom ,
11
11
} from "viem"
12
+ import { type Eip5792Actions , eip5792Actions } from "viem/experimental"
12
13
13
14
/**
14
15
* Creates custom public + wallet clients using the HappyProvider.
15
16
*/
16
17
export default function useClients ( ) : {
17
18
publicClient : PublicClient
18
- walletClient : WalletClient < CustomTransport , undefined , Account > | null
19
+ walletClient : ( WalletClient < CustomTransport , undefined , Account > & Eip5792Actions ) | null
19
20
} {
20
21
const { provider, user } = useHappyChain ( )
21
22
@@ -27,7 +28,7 @@ export default function useClients(): {
27
28
? createWalletClient ( {
28
29
account : user . address ,
29
30
transport : custom ( provider ) ,
30
- } )
31
+ } ) . extend ( eip5792Actions ( ) )
31
32
: null ,
32
33
[ user , provider ] ,
33
34
)
You can’t perform that action at this time.
0 commit comments