@naculus/connect-appkit-react 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -23
- package/dist/index.d.ts +35 -23
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# @naculus/connect-appkit-react
|
|
2
2
|
|
|
3
|
-
**React bindings for Naculus Connect
|
|
3
|
+
**React bindings for Naculus Connect** — 54 hooks plus auto-generated React
|
|
4
|
+
wrappers for all 28 Stencil components.
|
|
5
|
+
|
|
6
|
+
The components are the smaller half. Two files in this package contain JSX; the
|
|
7
|
+
rest is connection state, capability negotiation, session keys, simulation and
|
|
8
|
+
transaction lifecycle, reachable as hooks.
|
|
4
9
|
|
|
5
10
|
> **🔗 Wraps `@naculus/connect-appkit-wc`. If you need the raw Web Components or another framework, see the table below.**
|
|
6
11
|
|
|
@@ -31,6 +36,80 @@ function App() {
|
|
|
31
36
|
}
|
|
32
37
|
```
|
|
33
38
|
|
|
39
|
+
## Hooks
|
|
40
|
+
|
|
41
|
+
<!-- This list is the point of the package and was missing from the README that
|
|
42
|
+
npm renders, so people reading the npm page concluded the capability layer
|
|
43
|
+
did not exist. Keep it in step with `src/index.ts`. -->
|
|
44
|
+
|
|
45
|
+
**Connection** — `useAccount`, `useConnect`, `useDisconnect`, `useWallet`,
|
|
46
|
+
`useSession`, `useChain`, `useSwitchChain`, `useWeb3`, `useWeb3ErrorHandler`
|
|
47
|
+
|
|
48
|
+
**Capabilities and batched calls (EIP-5792)** — `useCapabilities`,
|
|
49
|
+
`useSendCalls`, `useExecuteCalls`
|
|
50
|
+
|
|
51
|
+
**Smart accounts and delegation (ERC-4337, EIP-7702)** — `useSmartAccount`,
|
|
52
|
+
`useSendUserOperation`, `useUserOpStatus`, `useDelegation`,
|
|
53
|
+
`useDelegationPolicy`
|
|
54
|
+
|
|
55
|
+
**Session keys** — `useCreateSessionKey`, `useSessionKeys`,
|
|
56
|
+
`useSendWithSession`, `useRevokeSession`
|
|
57
|
+
|
|
58
|
+
**Sign-in (EIP-4361 / CAIP-122)** — `useSIWxLogin`, `useSIWxSession`,
|
|
59
|
+
`useSiwxAuthSession`, `useSignInWithEthereum`, `useSignInWithX`,
|
|
60
|
+
`useSignMessage`
|
|
61
|
+
|
|
62
|
+
**Transactions** — `useSendTransaction`, `useTxMonitor`, `useTxHistory`,
|
|
63
|
+
`useLastTx`, `useSimulateTransfer`, `useTransactionSimulation`,
|
|
64
|
+
`useValidateDestination`
|
|
65
|
+
|
|
66
|
+
**Tokens and balances** — `useBalance`, `useTokenBalance`, `useTokenList`,
|
|
67
|
+
`useTokenSearch`, `useERC20Allowance`, `useERC20Approve`, `useERC20Transfer`,
|
|
68
|
+
`useERC20TransferSimulation`
|
|
69
|
+
|
|
70
|
+
**Routing** — `useRouteQuote`, `useExecuteRoute`, `useCompareCosts`
|
|
71
|
+
|
|
72
|
+
**Solana** — `useSolanaAccount`, `useSolanaBalance`, `useSolanaTransaction`,
|
|
73
|
+
`useSolanaRoles`
|
|
74
|
+
|
|
75
|
+
**Embedded wallet** — `useEmbeddedWallet`, `usePassphraseGate`
|
|
76
|
+
|
|
77
|
+
**Names** — `useResolveName`, `useLookupAddress`
|
|
78
|
+
|
|
79
|
+
**Other** — `useViemClient`, `useNotification`
|
|
80
|
+
|
|
81
|
+
### Ask before executing
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
const { atomic } = useCapabilities();
|
|
85
|
+
|
|
86
|
+
if (atomic === "supported") {
|
|
87
|
+
await sendCalls(calls); // one batch, all or nothing
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`atomic` is `"supported" | "unsupported" | "unknown"`. A wallet that does not
|
|
92
|
+
implement `wallet_getCapabilities` has not said no — EIP-5792 is explicit that
|
|
93
|
+
absence is not a denial, and `"unknown"` also covers a query that failed or is
|
|
94
|
+
still in flight.
|
|
95
|
+
|
|
96
|
+
### Ask a Solana wallet which role it can fill
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
const { signer, payer, absence } = useSolanaRoles();
|
|
100
|
+
|
|
101
|
+
if (absence === null && signer === null) {
|
|
102
|
+
// The wallet said so: it signs and sends, but will not hand back a signed
|
|
103
|
+
// transaction. Offer another wallet before the co-signing flow starts.
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`signer` and `payer` are `null` when the wallet declared it cannot fill that
|
|
108
|
+
role. `absence` says why there is no answer at all — `"no_session"`,
|
|
109
|
+
`"not_solana"`, or `"unreported"` for a `@naculus/connector-solana` older
|
|
110
|
+
than the roles API — so a wallet that has not been asked is never shown as one
|
|
111
|
+
that cannot sign. Reading roles never prompts.
|
|
112
|
+
|
|
34
113
|
## License
|
|
35
114
|
|
|
36
115
|
MIT
|