@aurum-sdk/hooks 0.1.4 → 0.1.5
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 +6 -131
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# @aurum-sdk/hooks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[Docs](https://docs.aurumsdk.com/)
|
|
4
|
+
[Live Demo](https://demo.aurumsdk.com/)
|
|
5
|
+
[Website](https://aurumsdk.com/)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
React hooks for Aurum SDK.
|
|
8
|
+
|
|
9
|
+
---
|
|
6
10
|
|
|
7
11
|
## Installation
|
|
8
12
|
|
|
@@ -65,132 +69,3 @@ function WalletButton() {
|
|
|
65
69
|
);
|
|
66
70
|
}
|
|
67
71
|
```
|
|
68
|
-
|
|
69
|
-
## Available Hooks
|
|
70
|
-
|
|
71
|
-
### `useAurum`
|
|
72
|
-
|
|
73
|
-
Access the raw Aurum SDK instance.
|
|
74
|
-
|
|
75
|
-
```tsx
|
|
76
|
-
const { aurum, isReady } = useAurum();
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
| Return | Type | Description |
|
|
80
|
-
| --------- | --------- | ----------------------------------------- |
|
|
81
|
-
| `aurum` | `Aurum` | The Aurum SDK instance |
|
|
82
|
-
| `isReady` | `boolean` | Whether the SDK has finished initializing |
|
|
83
|
-
|
|
84
|
-
### `useAccount`
|
|
85
|
-
|
|
86
|
-
Access connected user information.
|
|
87
|
-
|
|
88
|
-
```tsx
|
|
89
|
-
const { publicAddress, walletName, walletId, email, isConnected, isInitializing } = useAccount();
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
| Return | Type | Description |
|
|
93
|
-
| ---------------- | ------------------------- | -------------------------------------- |
|
|
94
|
-
| `publicAddress` | `string \| undefined` | The connected wallet address |
|
|
95
|
-
| `walletName` | `WalletName \| undefined` | Name of the connected wallet |
|
|
96
|
-
| `walletId` | `WalletId \| undefined` | ID of the connected wallet |
|
|
97
|
-
| `email` | `string \| undefined` | Email address when logged in via email |
|
|
98
|
-
| `isConnected` | `boolean` | Whether a wallet is connected |
|
|
99
|
-
| `isInitializing` | `boolean` | Whether the SDK is initializing |
|
|
100
|
-
|
|
101
|
-
### `useConnect`
|
|
102
|
-
|
|
103
|
-
Connect to a wallet via modal, direct connection, or headless flows.
|
|
104
|
-
|
|
105
|
-
```tsx
|
|
106
|
-
const { connect, emailAuthStart, emailAuthVerify, getWalletConnectSession, isPending, error } = useConnect();
|
|
107
|
-
|
|
108
|
-
// Open wallet selection modal
|
|
109
|
-
await connect();
|
|
110
|
-
|
|
111
|
-
// Or connect directly to a specific wallet (skips modal)
|
|
112
|
-
import { WalletId } from '@aurum-sdk/types';
|
|
113
|
-
await connect(WalletId.MetaMask);
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
| Return | Type | Description |
|
|
117
|
-
| ------------------------- | -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
|
|
118
|
-
| `connect` | `(walletId?: WalletId) => Promise<string>` | Opens wallet modal, or connects directly if walletId provided |
|
|
119
|
-
| `emailAuthStart` | `(email: string) => Promise<{ flowId: string }>` | Sends OTP to email for Coinbase Embedded Wallet |
|
|
120
|
-
| `emailAuthVerify` | `(flowId: string, otp: string) => Promise<{ address: string, email: string, isNewUser: boolean }>` | Verifies OTP and completes connection |
|
|
121
|
-
| `getWalletConnectSession` | `() => Promise<{ uri: string, waitForConnection: () => Promise<string> }>` | Gets WalletConnect URI for custom QR display |
|
|
122
|
-
| `isPending` | `boolean` | Whether connection is in progress |
|
|
123
|
-
| `error` | `Error \| null` | Error from last connection attempt |
|
|
124
|
-
|
|
125
|
-
**Note:** `WalletId.Email` and `WalletId.WalletConnect` cannot be used with `connect(walletId)` — use the headless methods below instead.
|
|
126
|
-
|
|
127
|
-
> **ConnectWidget Compatibility:** Do not use `useConnect()` with `<ConnectWidget>`. Use `useAccount()` to react to connection state changes instead.
|
|
128
|
-
|
|
129
|
-
#### Headless Email Authentication
|
|
130
|
-
|
|
131
|
-
Two-step flow for Coinbase Embedded Wallet:
|
|
132
|
-
|
|
133
|
-
```tsx
|
|
134
|
-
const { emailAuthStart, emailAuthVerify, isPending, error } = useConnect();
|
|
135
|
-
|
|
136
|
-
// Step 1: Send OTP
|
|
137
|
-
const { flowId } = await emailAuthStart('user@example.com');
|
|
138
|
-
|
|
139
|
-
// Step 2: User enters OTP from their email
|
|
140
|
-
const otp = await promptUserForOTP();
|
|
141
|
-
|
|
142
|
-
// Step 3: Verify and connect
|
|
143
|
-
const { address, email } = await emailAuthVerify(flowId, otp);
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
#### Headless WalletConnect
|
|
147
|
-
|
|
148
|
-
For custom QR code displays:
|
|
149
|
-
|
|
150
|
-
```tsx
|
|
151
|
-
const { getWalletConnectSession, isPending, error } = useConnect();
|
|
152
|
-
|
|
153
|
-
const { uri, waitForConnection } = await getWalletConnectSession();
|
|
154
|
-
|
|
155
|
-
// Display your own QR code
|
|
156
|
-
renderQRCode(uri);
|
|
157
|
-
|
|
158
|
-
// Wait for user to scan and approve
|
|
159
|
-
const address = await waitForConnection();
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
### `useDisconnect`
|
|
163
|
-
|
|
164
|
-
Disconnect the current wallet.
|
|
165
|
-
|
|
166
|
-
```tsx
|
|
167
|
-
const { disconnect } = useDisconnect();
|
|
168
|
-
|
|
169
|
-
await disconnect();
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
| Return | Type | Description |
|
|
173
|
-
| ------------ | --------------------- | ------------------------------ |
|
|
174
|
-
| `disconnect` | `() => Promise<void>` | Disconnects the current wallet |
|
|
175
|
-
|
|
176
|
-
### `useChain`
|
|
177
|
-
|
|
178
|
-
Access chain information and switch chains.
|
|
179
|
-
|
|
180
|
-
```tsx
|
|
181
|
-
import { sepolia } from 'viem/chains';
|
|
182
|
-
|
|
183
|
-
const { chainId, switchChain, error } = useChain();
|
|
184
|
-
|
|
185
|
-
await switchChain(sepolia.id, sepolia);
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
| Return | Type | Description |
|
|
189
|
-
| ------------- | ------------------------------------ | ------------------------------ |
|
|
190
|
-
| `chainId` | `number \| null` | Current chain ID |
|
|
191
|
-
| `switchChain` | `(chainId, chain?) => Promise<void>` | Switch to a different chain |
|
|
192
|
-
| `error` | `Error \| null` | Error from last switch attempt |
|
|
193
|
-
|
|
194
|
-
## License
|
|
195
|
-
|
|
196
|
-
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aurum-sdk/hooks",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "React hooks for Aurum SDK",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@aurum-sdk/core": "^0.1.
|
|
35
|
-
"@aurum-sdk/types": "^0.1.
|
|
34
|
+
"@aurum-sdk/core": "^0.1.5",
|
|
35
|
+
"@aurum-sdk/types": "^0.1.5"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@testing-library/react": "^16.0.0",
|