@coinbase/cdp-core 0.0.19 → 0.0.21
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 +88 -6
- package/dist/esm/index.js +29 -27
- package/dist/esm/index103.js +1 -1
- package/dist/esm/index104.js +1 -1
- package/dist/esm/index13.js +9 -3
- package/dist/esm/index17.js +3 -3
- package/dist/esm/index2.js +154 -87
- package/dist/esm/index24.js +1 -1
- package/dist/esm/index47.js +1 -1
- package/dist/esm/index48.js +1 -1
- package/dist/esm/index7.js +7 -6
- package/dist/esm/index70.js +17 -2
- package/dist/esm/index71.js +19 -17
- package/dist/esm/index72.js +47 -13
- package/dist/esm/index73.js +2 -23
- package/dist/esm/index74.js +17 -47
- package/dist/esm/index77.js +1 -1
- package/dist/esm/index8.js +10 -8
- package/dist/esm/index80.js +50 -74
- package/dist/esm/index81.js +11 -10
- package/dist/esm/index82.js +2 -55
- package/dist/esm/index83.js +45 -11
- package/dist/esm/index84.js +14 -2
- package/dist/esm/index85.js +9 -44
- package/dist/esm/index86.js +78 -13
- package/dist/esm/index88.js +20 -12
- package/dist/esm/index89.js +9 -35
- package/dist/esm/index90.js +19 -41
- package/dist/esm/index91.js +93 -20
- package/dist/esm/index92.js +20 -9
- package/dist/esm/index93.js +114 -16
- package/dist/esm/index94.js +11 -92
- package/dist/esm/index95.js +35 -20
- package/dist/esm/index96.js +41 -117
- package/dist/esm/index98.js +1 -1
- package/dist/types/index.d.ts +39 -2
- package/package.json +4 -4
package/dist/esm/index95.js
CHANGED
|
@@ -1,23 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
1
|
+
import { hexToBigInt as n } from "./index43.js";
|
|
2
|
+
import { defineBlock as r } from "./index40.js";
|
|
3
|
+
import { defineTransaction as s, formatTransaction as m } from "./index42.js";
|
|
4
|
+
import { defineTransactionReceipt as l } from "./index45.js";
|
|
5
|
+
const p = {
|
|
6
|
+
block: /* @__PURE__ */ r({
|
|
7
|
+
format(e) {
|
|
8
|
+
return {
|
|
9
|
+
transactions: e.transactions?.map((t) => {
|
|
10
|
+
if (typeof t == "string")
|
|
11
|
+
return t;
|
|
12
|
+
const i = m(t);
|
|
13
|
+
return i.typeHex === "0x7e" && (i.isSystemTx = t.isSystemTx, i.mint = t.mint ? n(t.mint) : void 0, i.sourceHash = t.sourceHash, i.type = "deposit"), i;
|
|
14
|
+
}),
|
|
15
|
+
stateRoot: e.stateRoot
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}),
|
|
19
|
+
transaction: /* @__PURE__ */ s({
|
|
20
|
+
format(e) {
|
|
21
|
+
const o = {};
|
|
22
|
+
return e.type === "0x7e" && (o.isSystemTx = e.isSystemTx, o.mint = e.mint ? n(e.mint) : void 0, o.sourceHash = e.sourceHash, o.type = "deposit"), o;
|
|
23
|
+
}
|
|
24
|
+
}),
|
|
25
|
+
transactionReceipt: /* @__PURE__ */ l({
|
|
26
|
+
format(e) {
|
|
27
|
+
return {
|
|
28
|
+
l1GasPrice: e.l1GasPrice ? n(e.l1GasPrice) : null,
|
|
29
|
+
l1GasUsed: e.l1GasUsed ? n(e.l1GasUsed) : null,
|
|
30
|
+
l1Fee: e.l1Fee ? n(e.l1Fee) : null,
|
|
31
|
+
l1FeeScalar: e.l1FeeScalar ? Number(e.l1FeeScalar) : null
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
})
|
|
20
35
|
};
|
|
21
36
|
export {
|
|
22
|
-
|
|
37
|
+
p as formatters
|
|
23
38
|
};
|
package/dist/esm/index96.js
CHANGED
|
@@ -1,120 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return i && Object.freeze(e), n ? n[s] = t : c.set(e, { [s]: t }), t;
|
|
13
|
-
}, E = (e, r) => {
|
|
14
|
-
c ||= /* @__PURE__ */ new WeakMap();
|
|
15
|
-
let s = c.get(e);
|
|
16
|
-
if (s?.[r])
|
|
17
|
-
return s[r];
|
|
18
|
-
const i = e.type === "public", n = !!i;
|
|
19
|
-
let t;
|
|
20
|
-
if (e.asymmetricKeyType === "x25519") {
|
|
21
|
-
switch (r) {
|
|
22
|
-
case "ECDH-ES":
|
|
23
|
-
case "ECDH-ES+A128KW":
|
|
24
|
-
case "ECDH-ES+A192KW":
|
|
25
|
-
case "ECDH-ES+A256KW":
|
|
26
|
-
break;
|
|
27
|
-
default:
|
|
28
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
29
|
-
}
|
|
30
|
-
t = e.toCryptoKey(e.asymmetricKeyType, n, i ? [] : ["deriveBits"]);
|
|
31
|
-
}
|
|
32
|
-
if (e.asymmetricKeyType === "ed25519") {
|
|
33
|
-
if (r !== "EdDSA" && r !== "Ed25519")
|
|
34
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
35
|
-
t = e.toCryptoKey(e.asymmetricKeyType, n, [
|
|
36
|
-
i ? "verify" : "sign"
|
|
37
|
-
]);
|
|
38
|
-
}
|
|
39
|
-
if (e.asymmetricKeyType === "rsa") {
|
|
40
|
-
let a;
|
|
41
|
-
switch (r) {
|
|
42
|
-
case "RSA-OAEP":
|
|
43
|
-
a = "SHA-1";
|
|
44
|
-
break;
|
|
45
|
-
case "RS256":
|
|
46
|
-
case "PS256":
|
|
47
|
-
case "RSA-OAEP-256":
|
|
48
|
-
a = "SHA-256";
|
|
49
|
-
break;
|
|
50
|
-
case "RS384":
|
|
51
|
-
case "PS384":
|
|
52
|
-
case "RSA-OAEP-384":
|
|
53
|
-
a = "SHA-384";
|
|
54
|
-
break;
|
|
55
|
-
case "RS512":
|
|
56
|
-
case "PS512":
|
|
57
|
-
case "RSA-OAEP-512":
|
|
58
|
-
a = "SHA-512";
|
|
59
|
-
break;
|
|
60
|
-
default:
|
|
61
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
62
|
-
}
|
|
63
|
-
if (r.startsWith("RSA-OAEP"))
|
|
64
|
-
return e.toCryptoKey({
|
|
65
|
-
name: "RSA-OAEP",
|
|
66
|
-
hash: a
|
|
67
|
-
}, n, i ? ["encrypt"] : ["decrypt"]);
|
|
68
|
-
t = e.toCryptoKey({
|
|
69
|
-
name: r.startsWith("PS") ? "RSA-PSS" : "RSASSA-PKCS1-v1_5",
|
|
70
|
-
hash: a
|
|
71
|
-
}, n, [i ? "verify" : "sign"]);
|
|
72
|
-
}
|
|
73
|
-
if (e.asymmetricKeyType === "ec") {
|
|
74
|
-
const o = (/* @__PURE__ */ new Map([
|
|
75
|
-
["prime256v1", "P-256"],
|
|
76
|
-
["secp384r1", "P-384"],
|
|
77
|
-
["secp521r1", "P-521"]
|
|
78
|
-
])).get(e.asymmetricKeyDetails?.namedCurve);
|
|
79
|
-
if (!o)
|
|
80
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
81
|
-
r === "ES256" && o === "P-256" && (t = e.toCryptoKey({
|
|
82
|
-
name: "ECDSA",
|
|
83
|
-
namedCurve: o
|
|
84
|
-
}, n, [i ? "verify" : "sign"])), r === "ES384" && o === "P-384" && (t = e.toCryptoKey({
|
|
85
|
-
name: "ECDSA",
|
|
86
|
-
namedCurve: o
|
|
87
|
-
}, n, [i ? "verify" : "sign"])), r === "ES512" && o === "P-521" && (t = e.toCryptoKey({
|
|
88
|
-
name: "ECDSA",
|
|
89
|
-
namedCurve: o
|
|
90
|
-
}, n, [i ? "verify" : "sign"])), r.startsWith("ECDH-ES") && (t = e.toCryptoKey({
|
|
91
|
-
name: "ECDH",
|
|
92
|
-
namedCurve: o
|
|
93
|
-
}, n, i ? [] : ["deriveBits"]));
|
|
94
|
-
}
|
|
95
|
-
if (!t)
|
|
96
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
97
|
-
return s ? s[r] = t : c.set(e, { [r]: t }), t;
|
|
98
|
-
}, d = async (e, r) => {
|
|
99
|
-
if (e instanceof Uint8Array || S(e))
|
|
100
|
-
return e;
|
|
101
|
-
if (K(e)) {
|
|
102
|
-
if (e.type === "secret")
|
|
103
|
-
return e.export();
|
|
104
|
-
if ("toCryptoKey" in e && typeof e.toCryptoKey == "function")
|
|
105
|
-
try {
|
|
106
|
-
return E(e, r);
|
|
107
|
-
} catch (i) {
|
|
108
|
-
if (i instanceof TypeError)
|
|
109
|
-
throw i;
|
|
110
|
-
}
|
|
111
|
-
let s = e.export({ format: "jwk" });
|
|
112
|
-
return f(e, s, r);
|
|
113
|
-
}
|
|
114
|
-
if (p(e))
|
|
115
|
-
return e.k ? m(e.k) : f(e, e, r, !0);
|
|
116
|
-
throw new Error("unreachable");
|
|
1
|
+
import { InvalidAddressError as a } from "./index58.js";
|
|
2
|
+
import { isAddress as f } from "./index32.js";
|
|
3
|
+
import { concatHex as p } from "./index33.js";
|
|
4
|
+
import { toHex as i } from "./index27.js";
|
|
5
|
+
import { toRlp as x } from "./index46.js";
|
|
6
|
+
import { serializeTransaction as l } from "./index15.js";
|
|
7
|
+
function T(r, e) {
|
|
8
|
+
return h(r) ? z(r) : l(r, e);
|
|
9
|
+
}
|
|
10
|
+
const E = {
|
|
11
|
+
transaction: T
|
|
117
12
|
};
|
|
13
|
+
function z(r) {
|
|
14
|
+
w(r);
|
|
15
|
+
const { sourceHash: e, data: o, from: m, gas: t, isSystemTx: u, mint: s, to: c, value: n } = r, d = [
|
|
16
|
+
e,
|
|
17
|
+
m,
|
|
18
|
+
c ?? "0x",
|
|
19
|
+
s ? i(s) : "0x",
|
|
20
|
+
n ? i(n) : "0x",
|
|
21
|
+
t ? i(t) : "0x",
|
|
22
|
+
u ? "0x1" : "0x",
|
|
23
|
+
o ?? "0x"
|
|
24
|
+
];
|
|
25
|
+
return p([
|
|
26
|
+
"0x7e",
|
|
27
|
+
x(d)
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
function h(r) {
|
|
31
|
+
return r.type === "deposit" || typeof r.sourceHash < "u";
|
|
32
|
+
}
|
|
33
|
+
function w(r) {
|
|
34
|
+
const { from: e, to: o } = r;
|
|
35
|
+
if (e && !f(e))
|
|
36
|
+
throw new a({ address: e });
|
|
37
|
+
if (o && !f(o))
|
|
38
|
+
throw new a({ address: o });
|
|
39
|
+
}
|
|
118
40
|
export {
|
|
119
|
-
|
|
41
|
+
w as assertTransactionDeposit,
|
|
42
|
+
T as serializeTransaction,
|
|
43
|
+
E as serializers
|
|
120
44
|
};
|
package/dist/esm/index98.js
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { APIErrorType } from '@coinbase/cdp-api-client';
|
|
|
4
4
|
import { Chain } from 'viem/chains';
|
|
5
5
|
import { Chain as Chain_2 } from 'viem';
|
|
6
6
|
import { ErrorType } from '@coinbase/cdp-api-client';
|
|
7
|
+
import { EvmUserOperation } from '@coinbase/cdp-api-client';
|
|
7
8
|
import { HttpErrorType } from '@coinbase/cdp-api-client';
|
|
8
9
|
import { LocalAccount } from 'viem';
|
|
9
10
|
import { Mutate } from 'zustand';
|
|
@@ -24,10 +25,9 @@ export { APIError }
|
|
|
24
25
|
|
|
25
26
|
export { APIErrorType }
|
|
26
27
|
|
|
27
|
-
export declare type AuthenticationMethod = EmailAuthentication;
|
|
28
|
-
|
|
29
28
|
export declare type AuthenticationMethods = {
|
|
30
29
|
email?: EmailAuthentication;
|
|
30
|
+
sms?: SmsAuthentication;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
export declare type CDPEmbeddedWallet = {
|
|
@@ -50,6 +50,7 @@ export declare type Config = {
|
|
|
50
50
|
useMock?: boolean;
|
|
51
51
|
debugging?: boolean;
|
|
52
52
|
basePath?: string;
|
|
53
|
+
createAccountOnLogin?: "evm-eoa" | "evm-smart";
|
|
53
54
|
};
|
|
54
55
|
|
|
55
56
|
export declare function createCDPEmbeddedWallet<chains extends readonly [Chain, ...Chain[]]>(_parameters: CDPEmbeddedWalletConfig<chains>): CDPEmbeddedWallet;
|
|
@@ -101,6 +102,12 @@ export declare type EthSignRequest = {
|
|
|
101
102
|
|
|
102
103
|
export declare type EvmAddress = `0x${string}`;
|
|
103
104
|
|
|
105
|
+
export declare type EvmCall = {
|
|
106
|
+
to: EvmAddress;
|
|
107
|
+
value?: bigint;
|
|
108
|
+
data?: Hex;
|
|
109
|
+
};
|
|
110
|
+
|
|
104
111
|
export declare type ExactPartial<T> = {
|
|
105
112
|
[P in keyof T]?: T[P] extends object ? ExactPartial<T[P]> : T[P];
|
|
106
113
|
};
|
|
@@ -119,6 +126,16 @@ export declare const getAccessToken: () => Promise<string | null>;
|
|
|
119
126
|
|
|
120
127
|
export declare const getCurrentUser: () => Promise<User | null>;
|
|
121
128
|
|
|
129
|
+
export declare const getUserOperation: (options: GetUserOperationOptions) => Promise<GetUserOperationResult>;
|
|
130
|
+
|
|
131
|
+
export declare type GetUserOperationOptions = {
|
|
132
|
+
userOperationHash: Hex;
|
|
133
|
+
evmSmartAccount: EvmAddress;
|
|
134
|
+
network: SendEvmTransactionWithEndUserAccountBodyNetwork;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export declare type GetUserOperationResult = EvmUserOperation;
|
|
138
|
+
|
|
122
139
|
export declare type Hex = `0x${string}`;
|
|
123
140
|
|
|
124
141
|
export { HttpErrorType }
|
|
@@ -192,6 +209,20 @@ export declare type SendTransactionRequestParams = [
|
|
|
192
209
|
}
|
|
193
210
|
];
|
|
194
211
|
|
|
212
|
+
export declare const sendUserOperation: (options: SendUserOperationOptions) => Promise<SendUserOperationResult>;
|
|
213
|
+
|
|
214
|
+
export declare type SendUserOperationOptions = {
|
|
215
|
+
evmSmartAccount: EvmAddress;
|
|
216
|
+
network: SendEvmTransactionWithEndUserAccountBodyNetwork;
|
|
217
|
+
calls: EvmCall[];
|
|
218
|
+
useCdpPaymaster?: boolean;
|
|
219
|
+
paymasterUrl?: string;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export declare type SendUserOperationResult = {
|
|
223
|
+
userOperationHash: Hex;
|
|
224
|
+
};
|
|
225
|
+
|
|
195
226
|
export declare const signEvmHash: (options: SignEvmHashOptions) => Promise<SignEvmHashResult>;
|
|
196
227
|
|
|
197
228
|
export declare type SignEvmHashOptions = {
|
|
@@ -265,6 +296,11 @@ export declare type SignTypedDataRequest = {
|
|
|
265
296
|
params: [EvmAddress, string];
|
|
266
297
|
};
|
|
267
298
|
|
|
299
|
+
export declare type SmsAuthentication = {
|
|
300
|
+
type: "sms";
|
|
301
|
+
phoneNumber: string;
|
|
302
|
+
};
|
|
303
|
+
|
|
268
304
|
export declare const STANDARD_ERROR_CODES: {
|
|
269
305
|
rpc: {
|
|
270
306
|
invalidInput: -32000;
|
|
@@ -307,6 +343,7 @@ export declare type User = {
|
|
|
307
343
|
userId: string;
|
|
308
344
|
authenticationMethods: AuthenticationMethods;
|
|
309
345
|
evmAccounts?: EvmAddress[];
|
|
346
|
+
evmSmartAccounts?: EvmAddress[];
|
|
310
347
|
};
|
|
311
348
|
|
|
312
349
|
export declare const verifyEmailOTP: (options: VerifyEmailOTPOptions) => Promise<VerifyEmailOTPResult>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cdp-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
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.21"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@size-limit/preset-big-lib": "^11.2.0",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"path": "./dist/esm/index.js",
|
|
46
46
|
"running": false,
|
|
47
47
|
"import": "{ signEvmHash, signEvmTransaction, sendEvmTransaction, signEvmMessage, signEvmTypedData }",
|
|
48
|
-
"limit": "
|
|
48
|
+
"limit": "30 KB"
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
"name": "export",
|
|
52
52
|
"path": "./dist/esm/index.js",
|
|
53
53
|
"running": false,
|
|
54
54
|
"import": "{ exportEvmAccount }",
|
|
55
|
-
"limit": "
|
|
55
|
+
"limit": "30 KB"
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
"name": "provider-only",
|