Skip to content

Commit 7e34c0c

Browse files
committed
feat: app demo scaffold
1 parent 5f55df9 commit 7e34c0c

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

demos/react/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useHappyChain } from "@happy.tech/react"
2+
import CallBatchDemo from "./demo-components/CallBatchDemo"
23
import ChainSwitchingDemo from "./demo-components/ChainSwitchingDemo"
34
import ConnectionDemo from "./demo-components/ConnectionDemo"
45
import SessionKeyDemo from "./demo-components/SessionKeyDemo"
@@ -24,6 +25,7 @@ function App() {
2425
<ChainSwitchingDemo />
2526
<WalletFunctionalityDemo />
2627
<SessionKeyDemo />
28+
<CallBatchDemo />
2729
</div>
2830
</main>
2931
)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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

demos/react/src/useClients.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff 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
*/
1617
export 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
)

0 commit comments

Comments
 (0)