@coinbase/cdp-hooks 0.0.17 → 0.0.18
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 +14 -14
- package/dist/esm/index3.js +38 -38
- package/dist/types/index.d.ts +42 -14
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -70,8 +70,8 @@ The following code demonstrates this flow:
|
|
|
70
70
|
import { useSignInWithEmail, useVerifyEmailOTP } from "@coinbase/cdp-hooks";
|
|
71
71
|
|
|
72
72
|
function SignIn() {
|
|
73
|
-
const signInWithEmail = useSignInWithEmail();
|
|
74
|
-
const verifyEmailOTP = useVerifyEmailOTP();
|
|
73
|
+
const { signInWithEmail } = useSignInWithEmail();
|
|
74
|
+
const { verifyEmailOTP } = useVerifyEmailOTP();
|
|
75
75
|
|
|
76
76
|
const handleSignIn = async (email: string) => {
|
|
77
77
|
try {
|
|
@@ -107,8 +107,8 @@ Once the end user has signed in, you can display their information in your appli
|
|
|
107
107
|
import { useCurrentUser, useEvmAddress } from "@coinbase/cdp-hooks";
|
|
108
108
|
|
|
109
109
|
function UserInformation() {
|
|
110
|
-
const user = useCurrentUser();
|
|
111
|
-
const evmAddress = useEvmAddress();
|
|
110
|
+
const { currentUser: user } = useCurrentUser();
|
|
111
|
+
const { evmAddress } = useEvmAddress();
|
|
112
112
|
|
|
113
113
|
if (!user) {
|
|
114
114
|
return <div>Please sign in</div>;
|
|
@@ -135,8 +135,8 @@ We support signing and sending a Blockchain transaction in a single action on Ba
|
|
|
135
135
|
import { useSendEvmTransaction, useEvmAddress } from "@coinbase/cdp-hooks";
|
|
136
136
|
|
|
137
137
|
function SendTransaction() {
|
|
138
|
-
const sendTransaction = useSendEvmTransaction();
|
|
139
|
-
const evmAddress = useEvmAddress();
|
|
138
|
+
const { sendEvmTransaction: sendTransaction } = useSendEvmTransaction();
|
|
139
|
+
const { evmAddress } = useEvmAddress();
|
|
140
140
|
|
|
141
141
|
const handleSend = async () => {
|
|
142
142
|
if (!evmAddress) return;
|
|
@@ -175,8 +175,8 @@ import { http, createPublicClient } from "viem";
|
|
|
175
175
|
import { sepolia } from "viem/chains";
|
|
176
176
|
|
|
177
177
|
function CrossChainTransaction() {
|
|
178
|
-
const signTransaction = useSignEvmTransaction();
|
|
179
|
-
const evmAddress = useEvmAddress();
|
|
178
|
+
const { signEvmTransaction: signTransaction } = useSignEvmTransaction();
|
|
179
|
+
const { evmAddress } = useEvmAddress();
|
|
180
180
|
|
|
181
181
|
const handleSend = async () => {
|
|
182
182
|
if (!evmAddress) return;
|
|
@@ -225,10 +225,10 @@ End users can sign EVM messages, hashes, and typed data to generate signatures f
|
|
|
225
225
|
import { useSignEvmMessage, useSignEvmTypedData, useEvmAddress } from "@coinbase/cdp-hooks";
|
|
226
226
|
|
|
227
227
|
function SignData() {
|
|
228
|
-
const signMessage = useSignEvmMessage();
|
|
229
|
-
const signTypedData = useSignEvmTypedData();
|
|
230
|
-
const signHash = useSignEvmHash();
|
|
231
|
-
const evmAddress = useEvmAddress();
|
|
228
|
+
const { signEvmMessage: signMessage } = useSignEvmMessage();
|
|
229
|
+
const { signEvmTypedData: signTypedData } = useSignEvmTypedData();
|
|
230
|
+
const { signEvmHash: signHash } = useSignEvmHash();
|
|
231
|
+
const { evmAddress } = useEvmAddress();
|
|
232
232
|
|
|
233
233
|
const handleSignHash = async () => {
|
|
234
234
|
if (!evmAddress) return;
|
|
@@ -298,8 +298,8 @@ End users can export their private keys from their embedded wallet, allowing the
|
|
|
298
298
|
import { useExportEvmAccount, useEvmAddress } from "@coinbase/cdp-hooks";
|
|
299
299
|
|
|
300
300
|
function ExportKey() {
|
|
301
|
-
const exportAccount = useExportEvmAccount();
|
|
302
|
-
const evmAddress = useEvmAddress();
|
|
301
|
+
const { exportEvmAccount: exportAccount } = useExportEvmAccount();
|
|
302
|
+
const { evmAddress } = useEvmAddress();
|
|
303
303
|
|
|
304
304
|
const handleExport = async () => {
|
|
305
305
|
if (!evmAddress) return;
|
package/dist/esm/index3.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { signInWithEmail as c, verifyEmailOTP as p, signOut as u, signEvmHash as m, signEvmTransaction as E, sendEvmTransaction as d, signEvmMessage as g, signEvmTypedData as v, exportEvmAccount as w } from "@coinbase/cdp-core";
|
|
2
2
|
import { useCallback as a } from "react";
|
|
3
|
-
import { useCDP as
|
|
4
|
-
const
|
|
5
|
-
const { config: n } =
|
|
6
|
-
return n;
|
|
7
|
-
},
|
|
8
|
-
const { isInitialized: n } =
|
|
9
|
-
return n;
|
|
10
|
-
},
|
|
11
|
-
const { isSignedIn: n } =
|
|
12
|
-
return n;
|
|
13
|
-
},
|
|
14
|
-
const { currentUser: n } =
|
|
15
|
-
return n;
|
|
16
|
-
},
|
|
17
|
-
const { isSignedIn:
|
|
3
|
+
import { useCDP as r } from "./index2.js";
|
|
4
|
+
const f = () => {
|
|
5
|
+
const { config: n } = r();
|
|
6
|
+
return { config: n };
|
|
7
|
+
}, y = () => {
|
|
8
|
+
const { isInitialized: n } = r();
|
|
9
|
+
return { isInitialized: n };
|
|
10
|
+
}, I = () => ({ signInWithEmail: i(c) }), O = () => ({ verifyEmailOTP: i(p) }), A = () => {
|
|
11
|
+
const { isSignedIn: n } = r();
|
|
12
|
+
return { isSignedIn: n };
|
|
13
|
+
}, S = () => {
|
|
14
|
+
const { currentUser: n } = r();
|
|
15
|
+
return { currentUser: n };
|
|
16
|
+
}, C = () => ({ signOut: e(u) }), U = () => ({ evmAddress: S().currentUser?.evmAccounts?.[0] ?? null }), P = () => ({ signEvmHash: e(m) }), x = () => ({ signEvmTransaction: e(E) }), D = () => ({ sendEvmTransaction: e(d) }), H = () => ({ signEvmMessage: e(g) }), M = () => ({ signEvmTypedData: e(v) }), W = () => ({ exportEvmAccount: e(w) }), e = (n) => {
|
|
17
|
+
const { isSignedIn: s } = r();
|
|
18
18
|
return a(
|
|
19
|
-
async (...
|
|
20
|
-
if (!
|
|
19
|
+
async (...t) => {
|
|
20
|
+
if (!s)
|
|
21
21
|
throw new Error("User is not authenticated");
|
|
22
|
-
return n(...
|
|
22
|
+
return n(...t);
|
|
23
23
|
},
|
|
24
|
-
[
|
|
24
|
+
[s, n]
|
|
25
25
|
);
|
|
26
26
|
}, i = (n) => {
|
|
27
|
-
const { isSignedIn:
|
|
27
|
+
const { isSignedIn: s } = r();
|
|
28
28
|
return a(
|
|
29
|
-
async (...
|
|
30
|
-
if (
|
|
29
|
+
async (...t) => {
|
|
30
|
+
if (s)
|
|
31
31
|
throw new Error("User is already authenticated. Please sign out first.");
|
|
32
|
-
return n(...
|
|
32
|
+
return n(...t);
|
|
33
33
|
},
|
|
34
|
-
[
|
|
34
|
+
[s, n]
|
|
35
35
|
);
|
|
36
36
|
};
|
|
37
37
|
export {
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
f as useConfig,
|
|
39
|
+
S as useCurrentUser,
|
|
40
40
|
e as useEnforceAuthenticated,
|
|
41
41
|
i as useEnforceUnauthenticated,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
U as useEvmAddress,
|
|
43
|
+
W as useExportEvmAccount,
|
|
44
|
+
y as useIsInitialized,
|
|
45
45
|
A as useIsSignedIn,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
D as useSendEvmTransaction,
|
|
47
|
+
P as useSignEvmHash,
|
|
48
|
+
H as useSignEvmMessage,
|
|
49
|
+
x as useSignEvmTransaction,
|
|
50
|
+
M as useSignEvmTypedData,
|
|
51
|
+
I as useSignInWithEmail,
|
|
52
|
+
C as useSignOut,
|
|
53
|
+
O as useVerifyEmailOTP
|
|
54
54
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -84,39 +84,67 @@ export { SignInWithEmailOptions }
|
|
|
84
84
|
|
|
85
85
|
export { SignInWithEmailResult }
|
|
86
86
|
|
|
87
|
-
export declare const useConfig: () =>
|
|
87
|
+
export declare const useConfig: () => {
|
|
88
|
+
config: Config;
|
|
89
|
+
};
|
|
88
90
|
|
|
89
|
-
export declare const useCurrentUser: () =>
|
|
91
|
+
export declare const useCurrentUser: () => {
|
|
92
|
+
currentUser: User | null;
|
|
93
|
+
};
|
|
90
94
|
|
|
91
95
|
export declare const useEnforceAuthenticated: <TArgs extends unknown[], TReturn>(callback: (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
|
|
92
96
|
|
|
93
97
|
export declare const useEnforceUnauthenticated: <TArgs extends unknown[], TReturn>(callback: (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
|
|
94
98
|
|
|
95
|
-
export declare const useEvmAddress: () =>
|
|
99
|
+
export declare const useEvmAddress: () => {
|
|
100
|
+
evmAddress: EvmAddress | null;
|
|
101
|
+
};
|
|
96
102
|
|
|
97
|
-
export declare const useExportEvmAccount: () =>
|
|
103
|
+
export declare const useExportEvmAccount: () => {
|
|
104
|
+
exportEvmAccount: (options: ExportEvmAccountOptions) => Promise<ExportEvmAccountResult>;
|
|
105
|
+
};
|
|
98
106
|
|
|
99
|
-
export declare const useIsInitialized: () =>
|
|
107
|
+
export declare const useIsInitialized: () => {
|
|
108
|
+
isInitialized: boolean;
|
|
109
|
+
};
|
|
100
110
|
|
|
101
|
-
export declare const useIsSignedIn: () =>
|
|
111
|
+
export declare const useIsSignedIn: () => {
|
|
112
|
+
isSignedIn: boolean;
|
|
113
|
+
};
|
|
102
114
|
|
|
103
115
|
export { User }
|
|
104
116
|
|
|
105
|
-
export declare const useSendEvmTransaction: () =>
|
|
117
|
+
export declare const useSendEvmTransaction: () => {
|
|
118
|
+
sendEvmTransaction: (options: SendEvmTransactionOptions) => Promise<SendEvmTransactionResult>;
|
|
119
|
+
};
|
|
106
120
|
|
|
107
|
-
export declare const useSignEvmHash: () =>
|
|
121
|
+
export declare const useSignEvmHash: () => {
|
|
122
|
+
signEvmHash: (options: SignEvmHashOptions) => Promise<SignEvmHashResult>;
|
|
123
|
+
};
|
|
108
124
|
|
|
109
|
-
export declare const useSignEvmMessage: () =>
|
|
125
|
+
export declare const useSignEvmMessage: () => {
|
|
126
|
+
signEvmMessage: (options: SignEvmMessageOptions) => Promise<SignEvmMessageResult>;
|
|
127
|
+
};
|
|
110
128
|
|
|
111
|
-
export declare const useSignEvmTransaction: () =>
|
|
129
|
+
export declare const useSignEvmTransaction: () => {
|
|
130
|
+
signEvmTransaction: (options: SignEvmTransactionOptions) => Promise<SignEvmTransactionResult>;
|
|
131
|
+
};
|
|
112
132
|
|
|
113
|
-
export declare const useSignEvmTypedData: () =>
|
|
133
|
+
export declare const useSignEvmTypedData: () => {
|
|
134
|
+
signEvmTypedData: (options: SignEvmTypedDataOptions) => Promise<SignEvmTypedDataResult>;
|
|
135
|
+
};
|
|
114
136
|
|
|
115
|
-
export declare const useSignInWithEmail: () =>
|
|
137
|
+
export declare const useSignInWithEmail: () => {
|
|
138
|
+
signInWithEmail: (options: SignInWithEmailOptions) => Promise<SignInWithEmailResult>;
|
|
139
|
+
};
|
|
116
140
|
|
|
117
|
-
export declare const useSignOut: () =>
|
|
141
|
+
export declare const useSignOut: () => {
|
|
142
|
+
signOut: () => Promise<void>;
|
|
143
|
+
};
|
|
118
144
|
|
|
119
|
-
export declare const useVerifyEmailOTP: () =>
|
|
145
|
+
export declare const useVerifyEmailOTP: () => {
|
|
146
|
+
verifyEmailOTP: (options: VerifyEmailOTPOptions) => Promise<VerifyEmailOTPResult>;
|
|
147
|
+
};
|
|
120
148
|
|
|
121
149
|
export { VerifyEmailOTPOptions }
|
|
122
150
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cdp-hooks",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/**",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"react": ">=18.2.0",
|
|
17
|
-
"@coinbase/cdp-core": "^0.0.
|
|
17
|
+
"@coinbase/cdp-core": "^0.0.18"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@testing-library/jest-dom": "^6.6.3",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@size-limit/webpack": "^11.2.0",
|
|
30
30
|
"@size-limit/webpack-why": "^11.2.0",
|
|
31
31
|
"size-limit": "^11.2.0",
|
|
32
|
-
"@coinbase/cdp-core": "^0.0.
|
|
32
|
+
"@coinbase/cdp-core": "^0.0.18"
|
|
33
33
|
},
|
|
34
34
|
"size-limit": [
|
|
35
35
|
{
|