@coinbase/cdp-hooks 0.0.0 → 0.0.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 +311 -0
- package/dist/esm/index.js +22 -0
- package/dist/esm/index2.js +35 -0
- package/dist/esm/index3.js +54 -0
- package/dist/types/index.d.ts +119 -0
- package/package.json +63 -6
- package/index.js +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
This package provides React hooks for conveniently accessing embedded wallet functionality.
|
|
2
|
+
Built on top of `@coinbase/cdp-core`, it offers a React-friendly interface for end user authentication
|
|
3
|
+
and embedded wallet operations.
|
|
4
|
+
|
|
5
|
+
## Quickstart
|
|
6
|
+
This guide will help you get started with @coinbase/cdp-hooks. You'll learn how to install the package, set up the provider, and use the hooks in a variety of ways.
|
|
7
|
+
|
|
8
|
+
### Installation
|
|
9
|
+
|
|
10
|
+
First, add the package to your project using your preferred package manager.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# With npm
|
|
14
|
+
npm install @coinbase/cdp-core @coinbase/cdp-hooks
|
|
15
|
+
|
|
16
|
+
# With pnpm
|
|
17
|
+
pnpm add @coinbase/cdp-core @coinbase/cdp-hooks
|
|
18
|
+
|
|
19
|
+
# With yarn
|
|
20
|
+
yarn add @coinbase/cdp-core @coinbase/cdp-hooks
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Gather your CDP Project Information
|
|
24
|
+
|
|
25
|
+
1. Sign in or create an account on the [CDP Portal](https://portal.cdp.coinbase.com)
|
|
26
|
+
2. On your dashboard, select a project from the dropdown at the at the top, and copy the Project ID
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Setup Provider
|
|
30
|
+
|
|
31
|
+
Next, you need to wrap your application with the CDPHooksProvider, which provides the necessary context for
|
|
32
|
+
hooks to work correctly.
|
|
33
|
+
|
|
34
|
+
Update your main application file (e.g., main.tsx) to include the provider:
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { CDPHooksProvider } from "@coinbase/cdp-hooks";
|
|
38
|
+
import { App } from './App'; // Your main App component
|
|
39
|
+
|
|
40
|
+
function App() {
|
|
41
|
+
return (
|
|
42
|
+
<CDPHooksProvider
|
|
43
|
+
config={{
|
|
44
|
+
// Copy and paste your project ID here.
|
|
45
|
+
projectId: "your-project-id",
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
<App />
|
|
49
|
+
</CDPHooksProvider>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Sign In a User
|
|
55
|
+
|
|
56
|
+
End user authentication proceeds in two steps:
|
|
57
|
+
1. The user inputs their email address to initiate the authentication flow, which will send the user a One Time Password (OTP) and return a `flowId`
|
|
58
|
+
2. The user submits the six-digit OTP and `flowId`, after which the user will be authenticated, returning a User object.
|
|
59
|
+
|
|
60
|
+
The following code demonstrates this flow:
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
import { useSignInWithEmail, useVerifyEmailOTP } from "@coinbase/cdp-hooks";
|
|
64
|
+
|
|
65
|
+
function SignIn() {
|
|
66
|
+
const signInWithEmail = useSignInWithEmail();
|
|
67
|
+
const verifyEmailOTP = useVerifyEmailOTP();
|
|
68
|
+
|
|
69
|
+
const handleSignIn = async (email: string) => {
|
|
70
|
+
try {
|
|
71
|
+
// Start sign in flow
|
|
72
|
+
const { flowId } = await signInWithEmail({ email });
|
|
73
|
+
|
|
74
|
+
// In a real application, you would prompt the user for the OTP they received
|
|
75
|
+
// in their email. Here, we hardcode it for convenience.
|
|
76
|
+
const otp = "123456";
|
|
77
|
+
|
|
78
|
+
// Complete sign in
|
|
79
|
+
const { user, isNewUser } = await verifyEmailOTP({
|
|
80
|
+
flowId,
|
|
81
|
+
otp
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
console.log("Signed in user:", user);
|
|
85
|
+
console.log("User EVM address", user.evmAccounts[0]);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error("Sign in failed:", error);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
return <button onClick={() => handleSignIn("user@example.com")}>Sign In</button>;
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### View User Information
|
|
96
|
+
|
|
97
|
+
Once the end user has signed in, you can display their information in your application:
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import { useCurrentUser, useEvmAddress } from "@coinbase/cdp-hooks";
|
|
101
|
+
|
|
102
|
+
function UserInformation() {
|
|
103
|
+
const user = useCurrentUser();
|
|
104
|
+
const evmAddress = useEvmAddress();
|
|
105
|
+
|
|
106
|
+
if (!user) {
|
|
107
|
+
return <div>Please sign in</div>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<div>
|
|
112
|
+
<h2>User Information</h2>
|
|
113
|
+
<p>User ID: {user.userId}</p>
|
|
114
|
+
<p>EVM Address: {evmAddress}</p>
|
|
115
|
+
</div>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Send a Transaction
|
|
121
|
+
|
|
122
|
+
We support signing and sending a Blockchain transaction in a single action on Base or Base Sepolia:
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
import { useSendEvmTransaction, useEvmAddress } from "@coinbase/cdp-hooks";
|
|
126
|
+
|
|
127
|
+
function SendTransaction() {
|
|
128
|
+
const sendTransaction = useSendEvmTransaction();
|
|
129
|
+
const evmAddress = useEvmAddress();
|
|
130
|
+
|
|
131
|
+
const handleSend = async () => {
|
|
132
|
+
if (!evmAddress) return;
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
const result = await sendTransaction({
|
|
136
|
+
evmAccount: evmAddress,
|
|
137
|
+
transaction: {
|
|
138
|
+
to: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
139
|
+
value: 100000000000000n, // 0.0001 ETH in wei
|
|
140
|
+
nonce: 0,
|
|
141
|
+
gas: 21000n,
|
|
142
|
+
maxFeePerGas: 30000000000n,
|
|
143
|
+
maxPriorityFeePerGas: 1000000000n,
|
|
144
|
+
chainId: 84532, // Base Sepolia
|
|
145
|
+
type: "eip1559",
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
console.log("Transaction hash:", result.transactionHash);
|
|
150
|
+
} catch (error) {
|
|
151
|
+
console.error("Transaction failed:", error);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
return <button onClick={handleSend}>Send Transaction</button>;
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
For networks other than Base or Base Sepolia, your end user must sign the transaction, and then
|
|
160
|
+
you must broadcast the transaction yourself. This example uses the public client from `viem` to broadcast the transaction.
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
import { useSignEvmTransaction, useEvmAddress } from "@coinbase/cdp-hooks";
|
|
164
|
+
import { http, createPublicClient } from "viem";
|
|
165
|
+
import { sepolia } from "viem/chains";
|
|
166
|
+
|
|
167
|
+
function CrossChainTransaction() {
|
|
168
|
+
const signTransaction = useSignEvmTransaction();
|
|
169
|
+
const evmAddress = useEvmAddress();
|
|
170
|
+
|
|
171
|
+
const handleSend = async () => {
|
|
172
|
+
if (!evmAddress) return;
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
// Sign the transaction
|
|
176
|
+
const { signedTransaction } = await signTransaction({
|
|
177
|
+
evmAccount: evmAddress,
|
|
178
|
+
transaction: {
|
|
179
|
+
to: "0x...",
|
|
180
|
+
value: 100000000000000n,
|
|
181
|
+
nonce: 0,
|
|
182
|
+
gas: 21000n,
|
|
183
|
+
maxFeePerGas: 30000000000n,
|
|
184
|
+
maxPriorityFeePerGas: 1000000000n,
|
|
185
|
+
chainId: 11155111, // Sepolia
|
|
186
|
+
type: "eip1559",
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// Broadcast using a different client
|
|
191
|
+
const client = createPublicClient({
|
|
192
|
+
chain: sepolia,
|
|
193
|
+
transport: http()
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
const hash = await client.sendRawTransaction({
|
|
197
|
+
serializedTransaction: signedTransaction
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
console.log("Transaction hash:", hash);
|
|
201
|
+
} catch (error) {
|
|
202
|
+
console.error("Transaction failed:", error);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
return <button onClick={handleSend}>Send Transaction</button>;
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Sign Messages and Typed Data
|
|
211
|
+
|
|
212
|
+
End users can sign EVM messages, hashes, and typed data to generate signatures for various onchain applications.
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
import { useSignEvmMessage, useSignEvmTypedData, useEvmAddress } from "@coinbase/cdp-hooks";
|
|
216
|
+
|
|
217
|
+
function SignData() {
|
|
218
|
+
const signMessage = useSignEvmMessage();
|
|
219
|
+
const signTypedData = useSignEvmTypedData();
|
|
220
|
+
const signHash = useSignEvmHash();
|
|
221
|
+
const evmAddress = useEvmAddress();
|
|
222
|
+
|
|
223
|
+
const handleSignHash = async () => {
|
|
224
|
+
if (!evmAddress) return;
|
|
225
|
+
|
|
226
|
+
const result = await signMessage({
|
|
227
|
+
evmAccount: evmAddress,
|
|
228
|
+
message: "Hello World"
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
console.log("Message signature:", result.signature);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const handleSignMessage = async () => {
|
|
235
|
+
if (!evmAddress) return;
|
|
236
|
+
|
|
237
|
+
const result = await signMessage({
|
|
238
|
+
evmAccount: evmAddress,
|
|
239
|
+
message: "Hello World"
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
console.log("Message signature:", result.signature);
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
const handleSignTypedData = async () => {
|
|
246
|
+
if (!evmAddress) return;
|
|
247
|
+
|
|
248
|
+
const result = await signTypedData({
|
|
249
|
+
evmAccount: evmAddress,
|
|
250
|
+
typedData: {
|
|
251
|
+
domain: {
|
|
252
|
+
name: "Example DApp",
|
|
253
|
+
version: "1",
|
|
254
|
+
chainId: 84532,
|
|
255
|
+
},
|
|
256
|
+
types: {
|
|
257
|
+
Person: [
|
|
258
|
+
{ name: "name", type: "string" },
|
|
259
|
+
{ name: "wallet", type: "address" }
|
|
260
|
+
]
|
|
261
|
+
},
|
|
262
|
+
primaryType: "Person",
|
|
263
|
+
message: {
|
|
264
|
+
name: "Bob",
|
|
265
|
+
wallet: evmAddress
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
console.log("Typed data signature:", result.signature);
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
return (
|
|
274
|
+
<div>
|
|
275
|
+
<button onClick={handleSignMessage}>Sign Message</button>
|
|
276
|
+
<button onClick={handleSignTypedData}>Sign Typed Data</button>
|
|
277
|
+
<button onClick={handleSignHash}>Sign Hash</button>
|
|
278
|
+
</div>
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Export Private Key
|
|
284
|
+
|
|
285
|
+
End users can export their private keys from their embedded wallet, allowing them to import it into an EVM-compatible wallet of their choice.
|
|
286
|
+
|
|
287
|
+
```tsx
|
|
288
|
+
import { useExportEvmAccount, useEvmAddress } from "@coinbase/cdp-hooks";
|
|
289
|
+
|
|
290
|
+
function ExportKey() {
|
|
291
|
+
const exportAccount = useExportEvmAccount();
|
|
292
|
+
const evmAddress = useEvmAddress();
|
|
293
|
+
|
|
294
|
+
const handleExport = async () => {
|
|
295
|
+
if (!evmAddress) return;
|
|
296
|
+
|
|
297
|
+
try {
|
|
298
|
+
const { privateKey } = await exportAccount({
|
|
299
|
+
evmAccount: evmAddress
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
console.log("Private Key:", privateKey);
|
|
303
|
+
// Warning: Handle private keys with extreme care!
|
|
304
|
+
} catch (error) {
|
|
305
|
+
console.error("Export failed:", error);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
return <button onClick={handleExport}>Export Private Key</button>;
|
|
310
|
+
}
|
|
311
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CDPContext as n, CDPHooksProvider as u } from "./index2.js";
|
|
2
|
+
import { useConfig as t, useCurrentUser as r, useEnforceAuthenticated as o, useEnforceUnauthenticated as a, useEvmAddress as E, useExportEvmAccount as m, useIsInitialized as d, useIsSignedIn as g, useSendEvmTransaction as c, useSignEvmHash as v, useSignEvmMessage as S, useSignEvmTransaction as f, useSignEvmTypedData as C, useSignInWithEmail as I, useSignOut as h, useVerifyEmailOTP as p } from "./index3.js";
|
|
3
|
+
export {
|
|
4
|
+
n as CDPContext,
|
|
5
|
+
u as CDPHooksProvider,
|
|
6
|
+
t as useConfig,
|
|
7
|
+
r as useCurrentUser,
|
|
8
|
+
o as useEnforceAuthenticated,
|
|
9
|
+
a as useEnforceUnauthenticated,
|
|
10
|
+
E as useEvmAddress,
|
|
11
|
+
m as useExportEvmAccount,
|
|
12
|
+
d as useIsInitialized,
|
|
13
|
+
g as useIsSignedIn,
|
|
14
|
+
c as useSendEvmTransaction,
|
|
15
|
+
v as useSignEvmHash,
|
|
16
|
+
S as useSignEvmMessage,
|
|
17
|
+
f as useSignEvmTransaction,
|
|
18
|
+
C as useSignEvmTypedData,
|
|
19
|
+
I as useSignInWithEmail,
|
|
20
|
+
h as useSignOut,
|
|
21
|
+
p as useVerifyEmailOTP
|
|
22
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { initialize as C, onAuthStateChange as m } from "@coinbase/cdp-core";
|
|
3
|
+
import { createContext as P, useState as o, useEffect as d, useMemo as f, useContext as x } from "react";
|
|
4
|
+
const i = P(null);
|
|
5
|
+
function w({ children: t, config: e }) {
|
|
6
|
+
const [n, u] = o(null), [r, s] = o(!1);
|
|
7
|
+
d(() => {
|
|
8
|
+
s(!1), (async () => {
|
|
9
|
+
await C(e), m((c) => {
|
|
10
|
+
u(c);
|
|
11
|
+
}), s(!0);
|
|
12
|
+
})();
|
|
13
|
+
}, [e]);
|
|
14
|
+
const a = f(
|
|
15
|
+
() => ({
|
|
16
|
+
isInitialized: r,
|
|
17
|
+
currentUser: n,
|
|
18
|
+
isSignedIn: !!n,
|
|
19
|
+
config: e
|
|
20
|
+
}),
|
|
21
|
+
[n, r, e]
|
|
22
|
+
);
|
|
23
|
+
return /* @__PURE__ */ l(i.Provider, { value: a, children: t });
|
|
24
|
+
}
|
|
25
|
+
function I() {
|
|
26
|
+
const t = x(i);
|
|
27
|
+
if (!t)
|
|
28
|
+
throw new Error("useCDP must be used within a CDPHooksProvider");
|
|
29
|
+
return t;
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
i as CDPContext,
|
|
33
|
+
w as CDPHooksProvider,
|
|
34
|
+
I as useCDP
|
|
35
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { signOut as c, signEvmHash as u, signEvmTransaction as p, sendEvmTransaction as d, signEvmMessage as m, signEvmTypedData as E, exportEvmAccount as g, signInWithEmail as v, verifyEmailOTP as S } from "@coinbase/cdp-core";
|
|
2
|
+
import { useCallback as a } from "react";
|
|
3
|
+
import { useCDP as t } from "./index2.js";
|
|
4
|
+
const h = () => {
|
|
5
|
+
const { config: n } = t();
|
|
6
|
+
return n;
|
|
7
|
+
}, I = () => {
|
|
8
|
+
const { isInitialized: n } = t();
|
|
9
|
+
return n;
|
|
10
|
+
}, y = () => i(v), C = () => i(S), A = () => {
|
|
11
|
+
const { isSignedIn: n } = t();
|
|
12
|
+
return n;
|
|
13
|
+
}, w = () => {
|
|
14
|
+
const { currentUser: n } = t();
|
|
15
|
+
return n;
|
|
16
|
+
}, U = () => e(c), O = () => w()?.evmAccounts?.[0] ?? null, x = () => e(u), D = () => e(p), H = () => e(d), M = () => e(m), P = () => e(E), b = () => e(g), e = (n) => {
|
|
17
|
+
const { isSignedIn: r } = t();
|
|
18
|
+
return a(
|
|
19
|
+
async (...s) => {
|
|
20
|
+
if (!r)
|
|
21
|
+
throw new Error("User is not authenticated");
|
|
22
|
+
return n(...s);
|
|
23
|
+
},
|
|
24
|
+
[r, n]
|
|
25
|
+
);
|
|
26
|
+
}, i = (n) => {
|
|
27
|
+
const { isSignedIn: r } = t();
|
|
28
|
+
return a(
|
|
29
|
+
async (...s) => {
|
|
30
|
+
if (r)
|
|
31
|
+
throw new Error("User is already authenticated. Please sign out first.");
|
|
32
|
+
return n(...s);
|
|
33
|
+
},
|
|
34
|
+
[r, n]
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
h as useConfig,
|
|
39
|
+
w as useCurrentUser,
|
|
40
|
+
e as useEnforceAuthenticated,
|
|
41
|
+
i as useEnforceUnauthenticated,
|
|
42
|
+
O as useEvmAddress,
|
|
43
|
+
b as useExportEvmAccount,
|
|
44
|
+
I as useIsInitialized,
|
|
45
|
+
A as useIsSignedIn,
|
|
46
|
+
H as useSendEvmTransaction,
|
|
47
|
+
x as useSignEvmHash,
|
|
48
|
+
M as useSignEvmMessage,
|
|
49
|
+
D as useSignEvmTransaction,
|
|
50
|
+
P as useSignEvmTypedData,
|
|
51
|
+
y as useSignInWithEmail,
|
|
52
|
+
U as useSignOut,
|
|
53
|
+
C as useVerifyEmailOTP
|
|
54
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { AllowedEvmTransactionType } from '@coinbase/cdp-core';
|
|
2
|
+
import { Config } from '@coinbase/cdp-core';
|
|
3
|
+
import { Context } from 'react';
|
|
4
|
+
import { EIP712TypedData } from '@coinbase/cdp-core';
|
|
5
|
+
import { EvmAddress } from '@coinbase/cdp-core';
|
|
6
|
+
import { ExportEvmAccountOptions } from '@coinbase/cdp-core';
|
|
7
|
+
import { ExportEvmAccountResult } from '@coinbase/cdp-core';
|
|
8
|
+
import { Hex } from '@coinbase/cdp-core';
|
|
9
|
+
import { JSX } from 'react/jsx-runtime';
|
|
10
|
+
import { ReactNode } from 'react';
|
|
11
|
+
import { SendEvmTransactionOptions } from '@coinbase/cdp-core';
|
|
12
|
+
import { SendEvmTransactionResult } from '@coinbase/cdp-core';
|
|
13
|
+
import { SignEvmHashOptions } from '@coinbase/cdp-core';
|
|
14
|
+
import { SignEvmHashResult } from '@coinbase/cdp-core';
|
|
15
|
+
import { SignEvmMessageOptions } from '@coinbase/cdp-core';
|
|
16
|
+
import { SignEvmMessageResult } from '@coinbase/cdp-core';
|
|
17
|
+
import { SignEvmTransactionOptions } from '@coinbase/cdp-core';
|
|
18
|
+
import { SignEvmTransactionResult } from '@coinbase/cdp-core';
|
|
19
|
+
import { SignEvmTypedDataOptions } from '@coinbase/cdp-core';
|
|
20
|
+
import { SignEvmTypedDataResult } from '@coinbase/cdp-core';
|
|
21
|
+
import { SignInWithEmailOptions } from '@coinbase/cdp-core';
|
|
22
|
+
import { SignInWithEmailResult } from '@coinbase/cdp-core';
|
|
23
|
+
import { User } from '@coinbase/cdp-core';
|
|
24
|
+
import { VerifyEmailOTPOptions } from '@coinbase/cdp-core';
|
|
25
|
+
import { VerifyEmailOTPResult } from '@coinbase/cdp-core';
|
|
26
|
+
|
|
27
|
+
export { AllowedEvmTransactionType }
|
|
28
|
+
|
|
29
|
+
export declare const CDPContext: Context<CDPContextValue | null>;
|
|
30
|
+
|
|
31
|
+
export declare interface CDPContextValue {
|
|
32
|
+
isInitialized: boolean;
|
|
33
|
+
currentUser: User | null;
|
|
34
|
+
isSignedIn: boolean;
|
|
35
|
+
config: Config;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export declare function CDPHooksProvider({ children, config }: CDPHooksProviderProps): JSX.Element;
|
|
39
|
+
|
|
40
|
+
export declare interface CDPHooksProviderProps {
|
|
41
|
+
children: ReactNode;
|
|
42
|
+
config: Config;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { Config }
|
|
46
|
+
|
|
47
|
+
export { EIP712TypedData }
|
|
48
|
+
|
|
49
|
+
export { EvmAddress }
|
|
50
|
+
|
|
51
|
+
export { ExportEvmAccountOptions }
|
|
52
|
+
|
|
53
|
+
export { ExportEvmAccountResult }
|
|
54
|
+
|
|
55
|
+
export { Hex }
|
|
56
|
+
|
|
57
|
+
export { SendEvmTransactionOptions }
|
|
58
|
+
|
|
59
|
+
export { SendEvmTransactionResult }
|
|
60
|
+
|
|
61
|
+
export { SignEvmHashOptions }
|
|
62
|
+
|
|
63
|
+
export { SignEvmHashResult }
|
|
64
|
+
|
|
65
|
+
export { SignEvmMessageOptions }
|
|
66
|
+
|
|
67
|
+
export { SignEvmMessageResult }
|
|
68
|
+
|
|
69
|
+
export { SignEvmTransactionOptions }
|
|
70
|
+
|
|
71
|
+
export { SignEvmTransactionResult }
|
|
72
|
+
|
|
73
|
+
export { SignEvmTypedDataOptions }
|
|
74
|
+
|
|
75
|
+
export { SignEvmTypedDataResult }
|
|
76
|
+
|
|
77
|
+
export { SignInWithEmailOptions }
|
|
78
|
+
|
|
79
|
+
export { SignInWithEmailResult }
|
|
80
|
+
|
|
81
|
+
export declare const useConfig: () => Config;
|
|
82
|
+
|
|
83
|
+
export declare const useCurrentUser: () => User | null;
|
|
84
|
+
|
|
85
|
+
export declare const useEnforceAuthenticated: <TArgs extends unknown[], TReturn>(callback: (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
|
|
86
|
+
|
|
87
|
+
export declare const useEnforceUnauthenticated: <TArgs extends unknown[], TReturn>(callback: (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
|
|
88
|
+
|
|
89
|
+
export declare const useEvmAddress: () => EvmAddress | null;
|
|
90
|
+
|
|
91
|
+
export declare const useExportEvmAccount: () => ((options: ExportEvmAccountOptions) => Promise<ExportEvmAccountResult>);
|
|
92
|
+
|
|
93
|
+
export declare const useIsInitialized: () => boolean;
|
|
94
|
+
|
|
95
|
+
export declare const useIsSignedIn: () => boolean;
|
|
96
|
+
|
|
97
|
+
export { User }
|
|
98
|
+
|
|
99
|
+
export declare const useSendEvmTransaction: () => ((options: SendEvmTransactionOptions) => Promise<SendEvmTransactionResult>);
|
|
100
|
+
|
|
101
|
+
export declare const useSignEvmHash: () => ((options: SignEvmHashOptions) => Promise<SignEvmHashResult>);
|
|
102
|
+
|
|
103
|
+
export declare const useSignEvmMessage: () => ((options: SignEvmMessageOptions) => Promise<SignEvmMessageResult>);
|
|
104
|
+
|
|
105
|
+
export declare const useSignEvmTransaction: () => ((options: SignEvmTransactionOptions) => Promise<SignEvmTransactionResult>);
|
|
106
|
+
|
|
107
|
+
export declare const useSignEvmTypedData: () => ((options: SignEvmTypedDataOptions) => Promise<SignEvmTypedDataResult>);
|
|
108
|
+
|
|
109
|
+
export declare const useSignInWithEmail: () => ((options: SignInWithEmailOptions) => Promise<SignInWithEmailResult>);
|
|
110
|
+
|
|
111
|
+
export declare const useSignOut: () => (() => Promise<void>);
|
|
112
|
+
|
|
113
|
+
export declare const useVerifyEmailOTP: () => ((options: VerifyEmailOTPOptions) => Promise<VerifyEmailOTPResult>);
|
|
114
|
+
|
|
115
|
+
export { VerifyEmailOTPOptions }
|
|
116
|
+
|
|
117
|
+
export { VerifyEmailOTPResult }
|
|
118
|
+
|
|
119
|
+
export { }
|
package/package.json
CHANGED
|
@@ -1,8 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cdp-hooks",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
"version": "0.0.5",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist/**",
|
|
7
|
+
"!dist/**/*.tsbuildinfo"
|
|
8
|
+
],
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"default": "./dist/esm/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"react": ">=18.2.0",
|
|
17
|
+
"@coinbase/cdp-core": "^0.0.5"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
21
|
+
"@testing-library/react": "^16.3.0",
|
|
22
|
+
"@types/react": "^19.1.0",
|
|
23
|
+
"@types/react-dom": "^19.1.0",
|
|
24
|
+
"jsdom": "^24.0.0",
|
|
25
|
+
"react": "^19.1.0",
|
|
26
|
+
"react-dom": "^19.1.0",
|
|
27
|
+
"vitest": "^3.2.2",
|
|
28
|
+
"@size-limit/preset-big-lib": "^11.2.0",
|
|
29
|
+
"@size-limit/webpack": "^11.2.0",
|
|
30
|
+
"@size-limit/webpack-why": "^11.2.0",
|
|
31
|
+
"size-limit": "^11.2.0",
|
|
32
|
+
"@coinbase/cdp-core": "^0.0.5"
|
|
33
|
+
},
|
|
34
|
+
"size-limit": [
|
|
35
|
+
{
|
|
36
|
+
"name": "full-package",
|
|
37
|
+
"path": "./dist/esm/index.js",
|
|
38
|
+
"import": "*",
|
|
39
|
+
"limit": "65 KB"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "config-only",
|
|
43
|
+
"path": "./dist/esm/index.js",
|
|
44
|
+
"import": "{ CDPHooksProvider, useConfig, useIsInitialized }",
|
|
45
|
+
"limit": "65 KB"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "auth-hooks-only",
|
|
49
|
+
"path": "./dist/esm/index.js",
|
|
50
|
+
"import": "{ CDPHooksProvider, useSignInWithEmail, useVerifyEmailOTP, useCurrentUser, useIsSignedIn, useSignOut }",
|
|
51
|
+
"limit": "65 KB"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "pnpm run clean && pnpm run check:types && vite build --config ../../vite.config.base.ts",
|
|
56
|
+
"build:watch": "vite build --config ../../vite.config.base.ts --watch",
|
|
57
|
+
"check:types": "tsc --noEmit",
|
|
58
|
+
"clean": "rm -rf dist",
|
|
59
|
+
"clean:all": "pnpm clean && rm -rf node_modules",
|
|
60
|
+
"size-limit": "size-limit",
|
|
61
|
+
"size-limit:why": "size-limit --why",
|
|
62
|
+
"test": "vitest",
|
|
63
|
+
"test:run": "vitest --run"
|
|
64
|
+
}
|
|
65
|
+
}
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log("Temporary package");
|