@coinbase/cdp-core 0.0.7 → 0.0.8
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 +7 -0
- package/dist/esm/index16.js +24 -25
- package/dist/types/index.d.ts +1 -1
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -26,6 +26,13 @@ npm install @coinbase/cdp-core
|
|
|
26
26
|
1. Sign in or create an account on the [CDP Portal](https://portal.cdp.coinbase.com)
|
|
27
27
|
2. On your dashboard, select a project from the dropdown at the at the top, and copy the Project ID
|
|
28
28
|
|
|
29
|
+
### Allowlist your local app
|
|
30
|
+
|
|
31
|
+
1. Navigate to the [Embedded Wallet Configuration](https://portal.cdp.coinbase.com/products/embedded-wallets/cors)
|
|
32
|
+
in CDP Portal, and click Add origin to include your local app
|
|
33
|
+
2. Enter the origin of your locally running app - e.g., `http://localhost:3000`
|
|
34
|
+
3. Click Add origin again to save your changes
|
|
35
|
+
|
|
29
36
|
### Initialize the SDK
|
|
30
37
|
|
|
31
38
|
Before calling any methods in the SDK, you must first initialize it:
|
package/dist/esm/index16.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Provider as y, Hex as I } from "ox";
|
|
2
2
|
import { createWalletClient as E } from "viem";
|
|
3
|
-
import { signEvmTypedData as S, signEvmHash as
|
|
3
|
+
import { signEvmTypedData as S, signEvmHash as P, getCurrentUser as f, signOut as R, sendEvmTransaction as T, signEvmTransaction as A, signEvmMessage as x } from "./index2.js";
|
|
4
4
|
import "./index3.js";
|
|
5
5
|
import { validateUserOwnsAddress as m, EIP1193ProviderError as l, STANDARD_ERROR_CODES as s, RPCRequestError as c, validateUserHasEvmAccount as C, validateUserConnected as D } from "./index4.js";
|
|
6
6
|
import { isChainIdSupportedForCDPSends as b, chainIdToNameMapping as j } from "./index12.js";
|
|
@@ -19,19 +19,19 @@ function g(e) {
|
|
|
19
19
|
async function U() {
|
|
20
20
|
return (await f())?.evmAccounts || [];
|
|
21
21
|
}
|
|
22
|
-
async function M(e,
|
|
23
|
-
const
|
|
22
|
+
async function M(e, n) {
|
|
23
|
+
const a = await D();
|
|
24
24
|
return e.emit("connect", {
|
|
25
|
-
chainId: I.fromNumber(
|
|
26
|
-
}),
|
|
25
|
+
chainId: I.fromNumber(n.getState().chainId)
|
|
26
|
+
}), a.evmAccounts;
|
|
27
27
|
}
|
|
28
28
|
async function _(e) {
|
|
29
|
-
const [
|
|
30
|
-
await m(
|
|
31
|
-
const t = Buffer.from(
|
|
29
|
+
const [n, a] = e;
|
|
30
|
+
await m(a);
|
|
31
|
+
const t = Buffer.from(n.slice(2), "hex").toString();
|
|
32
32
|
try {
|
|
33
33
|
return (await x({
|
|
34
|
-
evmAccount:
|
|
34
|
+
evmAccount: a,
|
|
35
35
|
message: t
|
|
36
36
|
})).signature;
|
|
37
37
|
} catch (o) {
|
|
@@ -42,13 +42,12 @@ async function _(e) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
async function k(e) {
|
|
45
|
-
const [
|
|
45
|
+
const [n, a] = e;
|
|
46
46
|
await m(n);
|
|
47
47
|
try {
|
|
48
|
-
const t = JSON.parse(a);
|
|
49
48
|
return (await S({
|
|
50
49
|
evmAccount: n,
|
|
51
|
-
typedData:
|
|
50
|
+
typedData: JSON.parse(a)
|
|
52
51
|
})).signature;
|
|
53
52
|
} catch (t) {
|
|
54
53
|
throw new l(
|
|
@@ -57,7 +56,7 @@ async function k(e) {
|
|
|
57
56
|
);
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
|
-
async function z(e,
|
|
59
|
+
async function z(e, n, a) {
|
|
61
60
|
const [t] = e;
|
|
62
61
|
if (!t || typeof t != "object")
|
|
63
62
|
throw new c(
|
|
@@ -69,10 +68,10 @@ async function z(e, a, n) {
|
|
|
69
68
|
s.rpc.invalidParams,
|
|
70
69
|
"Transaction must include 'to' field"
|
|
71
70
|
);
|
|
72
|
-
const d = (await C()).evmAccounts[0], u =
|
|
71
|
+
const d = (await C()).evmAccounts[0], u = n.getState(), i = t.chainId ? Number(t.chainId) : u.chainId;
|
|
73
72
|
if (b(i))
|
|
74
73
|
try {
|
|
75
|
-
return (await
|
|
74
|
+
return (await T({
|
|
76
75
|
evmAccount: d,
|
|
77
76
|
transaction: { ...g(t), chainId: i },
|
|
78
77
|
network: j[i]
|
|
@@ -88,7 +87,7 @@ async function z(e, a, n) {
|
|
|
88
87
|
const r = E({
|
|
89
88
|
// Safe as we check before calling this handler that chainId is configured
|
|
90
89
|
chain: u.chains.find((h) => h.id === i),
|
|
91
|
-
transport:
|
|
90
|
+
transport: a[i],
|
|
92
91
|
account: d
|
|
93
92
|
}), p = u.chains.find((h) => h.id === i), w = await r.prepareTransactionRequest({
|
|
94
93
|
...g(t),
|
|
@@ -111,12 +110,12 @@ async function z(e, a, n) {
|
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
112
|
async function J(e) {
|
|
114
|
-
const [
|
|
115
|
-
await m(
|
|
113
|
+
const [n, a] = e;
|
|
114
|
+
await m(a);
|
|
116
115
|
try {
|
|
117
|
-
return (await
|
|
118
|
-
evmAccount:
|
|
119
|
-
hash:
|
|
116
|
+
return (await P({
|
|
117
|
+
evmAccount: a,
|
|
118
|
+
hash: n
|
|
120
119
|
})).signature;
|
|
121
120
|
} catch (t) {
|
|
122
121
|
throw new l(
|
|
@@ -129,11 +128,11 @@ async function W(e) {
|
|
|
129
128
|
return `0x${e.getState().chainId.toString(16)}`;
|
|
130
129
|
}
|
|
131
130
|
async function $(e) {
|
|
132
|
-
await f() && await
|
|
131
|
+
await f() && await R(), e.emit("disconnect", new y.DisconnectedError());
|
|
133
132
|
}
|
|
134
|
-
function K(e,
|
|
135
|
-
const
|
|
136
|
-
|
|
133
|
+
function K(e, n) {
|
|
134
|
+
const a = Number.parseInt(e[0].chainId, 16);
|
|
135
|
+
n.getState().setChainId(a);
|
|
137
136
|
}
|
|
138
137
|
export {
|
|
139
138
|
U as handleAccounts,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -222,7 +222,7 @@ export declare const signOut: () => Promise<void>;
|
|
|
222
222
|
|
|
223
223
|
export declare type SignTypedDataRequest = {
|
|
224
224
|
method: "eth_signTypedData_v4";
|
|
225
|
-
params: [
|
|
225
|
+
params: [EvmAddress, string];
|
|
226
226
|
};
|
|
227
227
|
|
|
228
228
|
export declare const STANDARD_ERROR_CODES: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cdp-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/**",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"ox": "0.8.1",
|
|
18
18
|
"viem": "^2.33.0",
|
|
19
19
|
"zustand": "^5.0.6",
|
|
20
|
-
"@coinbase/cdp-api-client": "^0.0.
|
|
20
|
+
"@coinbase/cdp-api-client": "^0.0.8"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@size-limit/preset-big-lib": "^11.2.0",
|
|
@@ -29,30 +29,35 @@
|
|
|
29
29
|
{
|
|
30
30
|
"name": "full-package",
|
|
31
31
|
"path": "./dist/esm/index.js",
|
|
32
|
+
"running": false,
|
|
32
33
|
"import": "*",
|
|
33
34
|
"limit": "60 KB"
|
|
34
35
|
},
|
|
35
36
|
{
|
|
36
37
|
"name": "auth-only",
|
|
37
38
|
"path": "./dist/esm/index.js",
|
|
39
|
+
"running": false,
|
|
38
40
|
"import": "{ signInWithEmail, verifyEmailOTP, getCurrentUser, isSignedIn, signOut }",
|
|
39
41
|
"limit": "25 KB"
|
|
40
42
|
},
|
|
41
43
|
{
|
|
42
44
|
"name": "evm-only",
|
|
43
45
|
"path": "./dist/esm/index.js",
|
|
46
|
+
"running": false,
|
|
44
47
|
"import": "{ signEvmHash, signEvmTransaction, sendEvmTransaction, signEvmMessage, signEvmTypedData }",
|
|
45
48
|
"limit": "25 KB"
|
|
46
49
|
},
|
|
47
50
|
{
|
|
48
51
|
"name": "export",
|
|
49
52
|
"path": "./dist/esm/index.js",
|
|
53
|
+
"running": false,
|
|
50
54
|
"import": "{ exportEvmAccount }",
|
|
51
55
|
"limit": "25 KB"
|
|
52
56
|
},
|
|
53
57
|
{
|
|
54
58
|
"name": "provider-only",
|
|
55
59
|
"path": "./dist/esm/index.js",
|
|
60
|
+
"running": false,
|
|
56
61
|
"import": "{ createCDPEmbeddedWallet }",
|
|
57
62
|
"limit": "55 KB"
|
|
58
63
|
}
|