@coinbase/cdp-core 0.0.8 → 0.0.10
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/dist/esm/index100.js +7 -14
- package/dist/esm/index101.js +16 -80
- package/dist/esm/index102.js +72 -70
- package/dist/esm/index103.js +81 -0
- package/dist/esm/index13.js +18 -172
- package/dist/esm/index14.js +169 -157
- package/dist/esm/index15.js +157 -45
- package/dist/esm/index16.js +44 -142
- package/dist/esm/index17.js +144 -54
- package/dist/esm/index18.js +56 -41
- package/dist/esm/index19.js +40 -16
- package/dist/esm/index2.js +72 -68
- package/dist/esm/index20.js +16 -4
- package/dist/esm/index21.js +5 -5
- package/dist/esm/index22.js +5 -9
- package/dist/esm/index23.js +8 -17
- package/dist/esm/index24.js +16 -44
- package/dist/esm/index25.js +45 -13
- package/dist/esm/index26.js +13 -55
- package/dist/esm/index27.js +55 -6
- package/dist/esm/index28.js +6 -21
- package/dist/esm/index29.js +21 -11
- package/dist/esm/index3.js +4 -4
- package/dist/esm/index30.js +11 -3
- package/dist/esm/index31.js +3 -3
- package/dist/esm/index32.js +3 -34
- package/dist/esm/index33.js +32 -10
- package/dist/esm/index34.js +12 -4
- package/dist/esm/index35.js +4 -28
- package/dist/esm/index36.js +28 -6
- package/dist/esm/index37.js +6 -24
- package/dist/esm/index38.js +24 -16
- package/dist/esm/index39.js +16 -54
- package/dist/esm/index40.js +53 -22
- package/dist/esm/index41.js +23 -11
- package/dist/esm/index42.js +10 -26
- package/dist/esm/index43.js +26 -41
- package/dist/esm/index44.js +41 -54
- package/dist/esm/index45.js +54 -126
- package/dist/esm/index46.js +126 -11
- package/dist/esm/index47.js +9 -101
- package/dist/esm/index48.js +104 -6
- package/dist/esm/index49.js +7 -3
- package/dist/esm/index5.js +4 -4
- package/dist/esm/index50.js +3 -15
- package/dist/esm/index51.js +14 -42
- package/dist/esm/index52.js +38 -74
- package/dist/esm/index53.js +79 -2
- package/dist/esm/index54.js +2 -2
- package/dist/esm/index55.js +2 -13
- package/dist/esm/index56.js +8 -33
- package/dist/esm/index57.js +36 -5
- package/dist/esm/index58.js +5 -33
- package/dist/esm/index59.js +34 -8
- package/dist/esm/index60.js +8 -10
- package/dist/esm/index61.js +10 -11
- package/dist/esm/index62.js +11 -13
- package/dist/esm/index63.js +13 -18
- package/dist/esm/index64.js +18 -5
- package/dist/esm/index65.js +6 -5
- package/dist/esm/index66.js +5 -11
- package/dist/esm/index67.js +10 -16
- package/dist/esm/index68.js +15 -21
- package/dist/esm/index69.js +21 -49
- package/dist/esm/index70.js +51 -2
- package/dist/esm/index71.js +2 -21
- package/dist/esm/index72.js +18 -17
- package/dist/esm/index73.js +20 -80
- package/dist/esm/index74.js +79 -103
- package/dist/esm/index75.js +101 -30
- package/dist/esm/index76.js +32 -6
- package/dist/esm/index77.js +7 -10
- package/dist/esm/index78.js +10 -55
- package/dist/esm/index79.js +54 -10
- package/dist/esm/index80.js +11 -2
- package/dist/esm/index81.js +2 -45
- package/dist/esm/index82.js +44 -13
- package/dist/esm/index83.js +13 -78
- package/dist/esm/index84.js +79 -5
- package/dist/esm/index85.js +5 -13
- package/dist/esm/index86.js +12 -35
- package/dist/esm/index87.js +35 -41
- package/dist/esm/index88.js +40 -19
- package/dist/esm/index89.js +21 -10
- package/dist/esm/index90.js +9 -19
- package/dist/esm/index91.js +15 -89
- package/dist/esm/index92.js +92 -19
- package/dist/esm/index93.js +18 -115
- package/dist/esm/index94.js +118 -18
- package/dist/esm/index95.js +18 -28
- package/dist/esm/index96.js +26 -6
- package/dist/esm/index97.js +6 -9
- package/dist/esm/index98.js +11 -13
- package/dist/esm/index99.js +11 -8
- package/package.json +3 -3
package/dist/esm/index2.js
CHANGED
|
@@ -1,27 +1,36 @@
|
|
|
1
|
-
import { configureCdpApiClient as p, setAuthManager as
|
|
2
|
-
import { AuthManager as
|
|
3
|
-
import { toAuthState as
|
|
4
|
-
import { withAuth as
|
|
5
|
-
import { createExportKeyPair as
|
|
6
|
-
import { decryptWithPrivateKey as
|
|
7
|
-
import { MockAuthManager as
|
|
8
|
-
import { mockUser as
|
|
9
|
-
import { isChainSupportedForCDPSends as
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
const
|
|
1
|
+
import { configureCdpApiClient as p, setAuthManager as w, initiateAuthentication as h, verifyEmailAuthentication as y, createEndUserEvmAccount as f, signEvmHashWithEndUserAccount as I, signEvmTransactionWithEndUserAccount as l, sendEvmTransactionWithEndUserAccount as E, signEvmMessageWithEndUserAccount as v, signEvmTypedDataWithEndUserAccount as A, exportEndUserEvmAccount as k } from "@coinbase/cdp-api-client";
|
|
2
|
+
import { AuthManager as M } from "./index5.js";
|
|
3
|
+
import { toAuthState as u } from "./index6.js";
|
|
4
|
+
import { withAuth as i } from "./index7.js";
|
|
5
|
+
import { createExportKeyPair as S } from "./index8.js";
|
|
6
|
+
import { decryptWithPrivateKey as U } from "./index9.js";
|
|
7
|
+
import { MockAuthManager as C } from "./index10.js";
|
|
8
|
+
import { mockUser as d } from "./index11.js";
|
|
9
|
+
import { isChainSupportedForCDPSends as T } from "./index12.js";
|
|
10
|
+
import { getConfig as r, setCoreAuthManager as g, getCoreAuthManager as n, setConfig as j } from "./index13.js";
|
|
11
|
+
import { serializeTransaction as m } from "./index14.js";
|
|
12
|
+
const $ = async (e) => {
|
|
13
13
|
if (!e.projectId)
|
|
14
14
|
throw new Error("Project ID is required");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
let s;
|
|
16
|
+
try {
|
|
17
|
+
s = r().projectId !== e.projectId;
|
|
18
|
+
} catch {
|
|
19
|
+
s = !0;
|
|
20
|
+
}
|
|
21
|
+
if (j(e), r().useMock) {
|
|
22
|
+
g(new C(r().projectId));
|
|
18
23
|
return;
|
|
19
24
|
}
|
|
20
|
-
p({
|
|
21
|
-
debugging:
|
|
22
|
-
basePath:
|
|
23
|
-
}), s
|
|
24
|
-
|
|
25
|
+
if (p({
|
|
26
|
+
debugging: r().debugging,
|
|
27
|
+
basePath: r().basePath
|
|
28
|
+
}), s) {
|
|
29
|
+
const t = new M(r().projectId);
|
|
30
|
+
g(t), w(t);
|
|
31
|
+
}
|
|
32
|
+
await n().ensureInitialized();
|
|
33
|
+
}, q = async (e) => {
|
|
25
34
|
if (r().useMock)
|
|
26
35
|
return {
|
|
27
36
|
message: "Mock sign in initiated",
|
|
@@ -29,7 +38,7 @@ const q = async (e) => {
|
|
|
29
38
|
};
|
|
30
39
|
if (await n().isSignedIn())
|
|
31
40
|
throw new Error("User is already authenticated. Please sign out first.");
|
|
32
|
-
const t = await
|
|
41
|
+
const t = await h(r().projectId, {
|
|
33
42
|
email: e.email,
|
|
34
43
|
type: "email"
|
|
35
44
|
});
|
|
@@ -37,30 +46,33 @@ const q = async (e) => {
|
|
|
37
46
|
flowId: t.flowId,
|
|
38
47
|
message: t.message
|
|
39
48
|
};
|
|
40
|
-
},
|
|
49
|
+
}, B = async (e) => {
|
|
41
50
|
if (r().useMock)
|
|
42
51
|
return await n().setAuthState({
|
|
43
52
|
accessToken: "mock-access-token",
|
|
44
53
|
expiresAt: Date.now() + 1e3 * 60 * 60 * 24,
|
|
45
|
-
user:
|
|
54
|
+
user: d
|
|
46
55
|
}), {
|
|
47
56
|
message: "Mock email OTP verified",
|
|
48
|
-
user:
|
|
57
|
+
user: d,
|
|
49
58
|
isNewUser: !1
|
|
50
59
|
};
|
|
51
60
|
if (await n().isSignedIn())
|
|
52
61
|
throw new Error("User is already authenticated. Please sign out first.");
|
|
53
|
-
const t = await
|
|
62
|
+
const t = await y(r().projectId, {
|
|
54
63
|
flowId: e.flowId,
|
|
55
64
|
otp: e.otp
|
|
56
65
|
});
|
|
57
|
-
let a =
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
let a = u(t.accessToken, t.validUntil, t.endUser);
|
|
67
|
+
if (a.user.evmAccounts.length === 0)
|
|
68
|
+
try {
|
|
69
|
+
const o = await f(r().projectId, a.user.userId, {
|
|
70
|
+
walletSecretId: await n().getWalletSecretId(a)
|
|
71
|
+
});
|
|
72
|
+
a = u(t.accessToken, t.validUntil, o);
|
|
73
|
+
} catch (o) {
|
|
74
|
+
throw new Error(`Failed to create EVM account: ${o}`);
|
|
75
|
+
}
|
|
64
76
|
await n().setAuthState(a);
|
|
65
77
|
const c = await n().getUser();
|
|
66
78
|
return {
|
|
@@ -68,7 +80,7 @@ const q = async (e) => {
|
|
|
68
80
|
user: c,
|
|
69
81
|
isNewUser: t.isNewEndUser
|
|
70
82
|
};
|
|
71
|
-
},
|
|
83
|
+
}, V = async () => n().getUser(), G = async () => n().isSignedIn(), J = async () => {
|
|
72
84
|
if (r().useMock) {
|
|
73
85
|
await n().signOut();
|
|
74
86
|
return;
|
|
@@ -78,16 +90,16 @@ const q = async (e) => {
|
|
|
78
90
|
await n().signOut();
|
|
79
91
|
}, L = (e) => {
|
|
80
92
|
n().addAuthStateChangeCallback(e);
|
|
81
|
-
}, Q = async (e) => r().useMock ? { signature: "0x0" } :
|
|
82
|
-
signature: (await
|
|
93
|
+
}, Q = async (e) => r().useMock ? { signature: "0x0" } : i(e, n(), async ({ user: s, walletSecretId: t }) => ({
|
|
94
|
+
signature: (await I(r().projectId, s.userId, {
|
|
83
95
|
hash: e.hash,
|
|
84
96
|
address: e.evmAccount,
|
|
85
97
|
walletSecretId: t
|
|
86
98
|
})).signature
|
|
87
|
-
})), R = async (e) => r().useMock ? { signedTransaction: "0x0" } :
|
|
88
|
-
const a =
|
|
99
|
+
})), R = async (e) => r().useMock ? { signedTransaction: "0x0" } : i(e, n(), async ({ user: s, walletSecretId: t }) => {
|
|
100
|
+
const a = m(e.transaction);
|
|
89
101
|
return {
|
|
90
|
-
signedTransaction: (await
|
|
102
|
+
signedTransaction: (await l(
|
|
91
103
|
r().projectId,
|
|
92
104
|
s.userId,
|
|
93
105
|
{
|
|
@@ -97,14 +109,14 @@ const q = async (e) => {
|
|
|
97
109
|
}
|
|
98
110
|
)).signedTransaction
|
|
99
111
|
};
|
|
100
|
-
}),
|
|
101
|
-
if (!
|
|
112
|
+
}), X = async (e) => {
|
|
113
|
+
if (!T(e.network))
|
|
102
114
|
throw new Error(`Chain ${e.network} is not supported by the CDP Apis`);
|
|
103
115
|
if (r().useMock)
|
|
104
116
|
return { transactionHash: "0x0" };
|
|
105
|
-
const s =
|
|
106
|
-
return
|
|
107
|
-
transactionHash: (await
|
|
117
|
+
const s = m(e.transaction);
|
|
118
|
+
return i(e, n(), async ({ user: t, walletSecretId: a }) => ({
|
|
119
|
+
transactionHash: (await E(
|
|
108
120
|
r().projectId,
|
|
109
121
|
t.userId,
|
|
110
122
|
{
|
|
@@ -115,58 +127,50 @@ const q = async (e) => {
|
|
|
115
127
|
}
|
|
116
128
|
)).transactionHash
|
|
117
129
|
}));
|
|
118
|
-
},
|
|
119
|
-
signature: (await
|
|
130
|
+
}, Y = async (e) => r().useMock ? { signature: "0x0" } : i(e, n(), async ({ user: s, walletSecretId: t }) => ({
|
|
131
|
+
signature: (await v(r().projectId, s.userId, {
|
|
120
132
|
message: e.message,
|
|
121
133
|
address: e.evmAccount,
|
|
122
134
|
walletSecretId: t
|
|
123
135
|
})).signature
|
|
124
|
-
})),
|
|
125
|
-
signature: (await
|
|
136
|
+
})), Z = async (e) => r().useMock ? { signature: "0x0" } : i(e, n(), async ({ user: s, walletSecretId: t }) => ({
|
|
137
|
+
signature: (await A(r().projectId, s.userId, {
|
|
126
138
|
typedData: e.typedData,
|
|
127
139
|
address: e.evmAccount,
|
|
128
140
|
walletSecretId: t
|
|
129
141
|
})).signature
|
|
130
|
-
})),
|
|
142
|
+
})), _ = async (e) => {
|
|
131
143
|
if (r().useMock)
|
|
132
144
|
return {
|
|
133
145
|
privateKey: "mock-private-key"
|
|
134
146
|
};
|
|
135
|
-
const s = await
|
|
136
|
-
return
|
|
137
|
-
const c = await
|
|
147
|
+
const s = await S();
|
|
148
|
+
return i(e, n(), async ({ user: t, walletSecretId: a }) => {
|
|
149
|
+
const c = await k(r().projectId, t.userId, {
|
|
138
150
|
address: e.evmAccount,
|
|
139
151
|
walletSecretId: a,
|
|
140
152
|
exportEncryptionKey: s.publicKeyBase64
|
|
141
153
|
});
|
|
142
154
|
return {
|
|
143
|
-
privateKey: await
|
|
155
|
+
privateKey: await U(
|
|
144
156
|
s.privateKey,
|
|
145
157
|
c.encryptedPrivateKey
|
|
146
158
|
)
|
|
147
159
|
};
|
|
148
160
|
});
|
|
149
|
-
}, r = () => {
|
|
150
|
-
if (!i)
|
|
151
|
-
throw new Error("SDK not initialized");
|
|
152
|
-
return i;
|
|
153
|
-
}, n = () => {
|
|
154
|
-
if (!u)
|
|
155
|
-
throw new Error("SDK not initialized");
|
|
156
|
-
return u;
|
|
157
161
|
};
|
|
158
162
|
export {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
163
|
+
_ as exportEvmAccount,
|
|
164
|
+
V as getCurrentUser,
|
|
165
|
+
$ as initialize,
|
|
162
166
|
G as isSignedIn,
|
|
163
167
|
L as onAuthStateChange,
|
|
164
|
-
|
|
168
|
+
X as sendEvmTransaction,
|
|
165
169
|
Q as signEvmHash,
|
|
166
|
-
|
|
170
|
+
Y as signEvmMessage,
|
|
167
171
|
R as signEvmTransaction,
|
|
168
|
-
|
|
169
|
-
|
|
172
|
+
Z as signEvmTypedData,
|
|
173
|
+
q as signInWithEmail,
|
|
170
174
|
J as signOut,
|
|
171
|
-
|
|
175
|
+
B as verifyEmailOTP
|
|
172
176
|
};
|
package/dist/esm/index20.js
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
async function
|
|
2
|
-
const
|
|
3
|
-
|
|
1
|
+
async function n() {
|
|
2
|
+
const e = await window.crypto.subtle.generateKey(
|
|
3
|
+
{
|
|
4
|
+
name: "ECDSA",
|
|
5
|
+
namedCurve: "P-256"
|
|
6
|
+
// secp256r1
|
|
7
|
+
},
|
|
8
|
+
!1,
|
|
9
|
+
// Do not allow key export.
|
|
10
|
+
["sign", "verify"]
|
|
11
|
+
// Key usages
|
|
12
|
+
), r = await window.crypto.subtle.exportKey("spki", e.publicKey), t = new Uint8Array(r), a = btoa(
|
|
13
|
+
Array.from(t).map((i) => String.fromCharCode(i)).join("")
|
|
14
|
+
);
|
|
15
|
+
return { privateKey: e.privateKey, publicKeyBase64: a };
|
|
4
16
|
}
|
|
5
17
|
export {
|
|
6
|
-
|
|
18
|
+
n as createKeyPair
|
|
7
19
|
};
|
package/dist/esm/index21.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
return
|
|
4
|
-
}
|
|
1
|
+
async function t() {
|
|
2
|
+
const r = new Uint8Array(16);
|
|
3
|
+
return window.crypto.getRandomValues(r), Array.from(r, (n) => n.toString(16).padStart(2, "0")).join("");
|
|
4
|
+
}
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
t as generateRandomId
|
|
7
7
|
};
|
package/dist/esm/index22.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
serializers: void 0,
|
|
6
|
-
...e
|
|
7
|
-
};
|
|
8
|
-
}
|
|
1
|
+
const h = async (t) => {
|
|
2
|
+
const a = await window.crypto.subtle.digest("SHA-256", t), r = new Uint8Array(a);
|
|
3
|
+
return Array.from(r).map((s) => s.toString(16).padStart(2, "0")).join("");
|
|
4
|
+
};
|
|
9
5
|
export {
|
|
10
|
-
|
|
6
|
+
h as hash
|
|
11
7
|
};
|
package/dist/esm/index23.js
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const { chainId: n, nonce: e, ...s } = o, a = o.address;
|
|
9
|
-
t.push([
|
|
10
|
-
n ? i(n) : "0x",
|
|
11
|
-
a,
|
|
12
|
-
e ? i(e) : "0x",
|
|
13
|
-
...c({}, s)
|
|
14
|
-
]);
|
|
15
|
-
}
|
|
16
|
-
return t;
|
|
1
|
+
function n(e) {
|
|
2
|
+
return {
|
|
3
|
+
formatters: void 0,
|
|
4
|
+
fees: void 0,
|
|
5
|
+
serializers: void 0,
|
|
6
|
+
...e
|
|
7
|
+
};
|
|
17
8
|
}
|
|
18
9
|
export {
|
|
19
|
-
|
|
10
|
+
n as defineChain
|
|
20
11
|
};
|
package/dist/esm/index24.js
CHANGED
|
@@ -1,48 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
t += b[n[i]];
|
|
16
|
-
const r = `0x${t}`;
|
|
17
|
-
return typeof e.size == "number" ? (c(r, { size: e.size }), s(r, { dir: "right", size: e.size })) : r;
|
|
18
|
-
}
|
|
19
|
-
function y(n, e = {}) {
|
|
20
|
-
const { signed: t, size: r } = e, i = BigInt(n);
|
|
21
|
-
let o;
|
|
22
|
-
r ? t ? o = (1n << BigInt(r) * 8n - 1n) - 1n : o = 2n ** (BigInt(r) * 8n) - 1n : typeof n == "number" && (o = BigInt(Number.MAX_SAFE_INTEGER));
|
|
23
|
-
const g = typeof o == "bigint" && t ? -o - 1n : 0;
|
|
24
|
-
if (o && i > o || i < g) {
|
|
25
|
-
const f = typeof n == "bigint" ? "n" : "";
|
|
26
|
-
throw new x({
|
|
27
|
-
max: o ? `${o}${f}` : void 0,
|
|
28
|
-
min: `${g}${f}`,
|
|
29
|
-
signed: t,
|
|
30
|
-
size: r,
|
|
31
|
-
value: `${n}${f}`
|
|
32
|
-
});
|
|
1
|
+
import { toHex as i } from "./index25.js";
|
|
2
|
+
import { toYParitySignatureArray as c } from "./index14.js";
|
|
3
|
+
function f(r) {
|
|
4
|
+
if (!r || r.length === 0)
|
|
5
|
+
return [];
|
|
6
|
+
const t = [];
|
|
7
|
+
for (const o of r) {
|
|
8
|
+
const { chainId: n, nonce: e, ...s } = o, a = o.address;
|
|
9
|
+
t.push([
|
|
10
|
+
n ? i(n) : "0x",
|
|
11
|
+
a,
|
|
12
|
+
e ? i(e) : "0x",
|
|
13
|
+
...c({}, s)
|
|
14
|
+
]);
|
|
33
15
|
}
|
|
34
|
-
|
|
35
|
-
return r ? s(u, { size: r }) : u;
|
|
36
|
-
}
|
|
37
|
-
const d = /* @__PURE__ */ new TextEncoder();
|
|
38
|
-
function $(n, e = {}) {
|
|
39
|
-
const t = d.encode(n);
|
|
40
|
-
return m(t, e);
|
|
16
|
+
return t;
|
|
41
17
|
}
|
|
42
18
|
export {
|
|
43
|
-
|
|
44
|
-
m as bytesToHex,
|
|
45
|
-
y as numberToHex,
|
|
46
|
-
$ as stringToHex,
|
|
47
|
-
B as toHex
|
|
19
|
+
f as serializeAuthorizationList
|
|
48
20
|
};
|
package/dist/esm/index25.js
CHANGED
|
@@ -1,16 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { IntegerOutOfRangeError as x } from "./index47.js";
|
|
2
|
+
import { pad as s } from "./index33.js";
|
|
3
|
+
import { assertSize as c } from "./index41.js";
|
|
4
|
+
const b = /* @__PURE__ */ Array.from({ length: 256 }, (n, e) => e.toString(16).padStart(2, "0"));
|
|
5
|
+
function B(n, e = {}) {
|
|
6
|
+
return typeof n == "number" || typeof n == "bigint" ? y(n, e) : typeof n == "string" ? $(n, e) : typeof n == "boolean" ? z(n, e) : m(n, e);
|
|
7
|
+
}
|
|
8
|
+
function z(n, e = {}) {
|
|
9
|
+
const t = `0x${Number(n)}`;
|
|
10
|
+
return typeof e.size == "number" ? (c(t, { size: e.size }), s(t, { size: e.size })) : t;
|
|
11
|
+
}
|
|
12
|
+
function m(n, e = {}) {
|
|
13
|
+
let t = "";
|
|
14
|
+
for (let i = 0; i < n.length; i++)
|
|
15
|
+
t += b[n[i]];
|
|
16
|
+
const r = `0x${t}`;
|
|
17
|
+
return typeof e.size == "number" ? (c(r, { size: e.size }), s(r, { dir: "right", size: e.size })) : r;
|
|
18
|
+
}
|
|
19
|
+
function y(n, e = {}) {
|
|
20
|
+
const { signed: t, size: r } = e, i = BigInt(n);
|
|
21
|
+
let o;
|
|
22
|
+
r ? t ? o = (1n << BigInt(r) * 8n - 1n) - 1n : o = 2n ** (BigInt(r) * 8n) - 1n : typeof n == "number" && (o = BigInt(Number.MAX_SAFE_INTEGER));
|
|
23
|
+
const g = typeof o == "bigint" && t ? -o - 1n : 0;
|
|
24
|
+
if (o && i > o || i < g) {
|
|
25
|
+
const f = typeof n == "bigint" ? "n" : "";
|
|
26
|
+
throw new x({
|
|
27
|
+
max: o ? `${o}${f}` : void 0,
|
|
28
|
+
min: `${g}${f}`,
|
|
29
|
+
signed: t,
|
|
30
|
+
size: r,
|
|
31
|
+
value: `${n}${f}`
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
const u = `0x${(t && i < 0 ? (1n << BigInt(r * 8)) + BigInt(i) : i).toString(16)}`;
|
|
35
|
+
return r ? s(u, { size: r }) : u;
|
|
36
|
+
}
|
|
37
|
+
const d = /* @__PURE__ */ new TextEncoder();
|
|
38
|
+
function $(n, e = {}) {
|
|
39
|
+
const t = d.encode(n);
|
|
40
|
+
return m(t, e);
|
|
13
41
|
}
|
|
14
42
|
export {
|
|
15
|
-
|
|
43
|
+
z as boolToHex,
|
|
44
|
+
m as bytesToHex,
|
|
45
|
+
y as numberToHex,
|
|
46
|
+
$ as stringToHex,
|
|
47
|
+
B as toHex
|
|
16
48
|
};
|
package/dist/esm/index26.js
CHANGED
|
@@ -1,58 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
return r
|
|
13
|
-
}
|
|
14
|
-
const t = {
|
|
15
|
-
zero: 48,
|
|
16
|
-
nine: 57,
|
|
17
|
-
A: 65,
|
|
18
|
-
F: 70,
|
|
19
|
-
a: 97,
|
|
20
|
-
f: 102
|
|
21
|
-
};
|
|
22
|
-
function m(e) {
|
|
23
|
-
if (e >= t.zero && e <= t.nine)
|
|
24
|
-
return e - t.zero;
|
|
25
|
-
if (e >= t.A && e <= t.F)
|
|
26
|
-
return e - (t.A - 10);
|
|
27
|
-
if (e >= t.a && e <= t.f)
|
|
28
|
-
return e - (t.a - 10);
|
|
29
|
-
}
|
|
30
|
-
function y(e, n = {}) {
|
|
31
|
-
let r = e;
|
|
32
|
-
n.size && (u(r, { size: n.size }), r = s(r, { dir: "right", size: n.size }));
|
|
33
|
-
let i = r.slice(2);
|
|
34
|
-
i.length % 2 && (i = `0${i}`);
|
|
35
|
-
const z = i.length / 2, d = new Uint8Array(z);
|
|
36
|
-
for (let f = 0, o = 0; f < z; f++) {
|
|
37
|
-
const b = m(i.charCodeAt(o++)), c = m(i.charCodeAt(o++));
|
|
38
|
-
if (b === void 0 || c === void 0)
|
|
39
|
-
throw new g(`Invalid byte sequence ("${i[o - 2]}${i[o - 1]}" in "${i}").`);
|
|
40
|
-
d[f] = b * 16 + c;
|
|
41
|
-
}
|
|
42
|
-
return d;
|
|
43
|
-
}
|
|
44
|
-
function T(e, n) {
|
|
45
|
-
const r = h(e, n);
|
|
46
|
-
return y(r);
|
|
47
|
-
}
|
|
48
|
-
function l(e, n = {}) {
|
|
49
|
-
const r = A.encode(e);
|
|
50
|
-
return typeof n.size == "number" ? (u(r, { size: n.size }), s(r, { dir: "right", size: n.size })) : r;
|
|
1
|
+
import { stringToBytes as p } from "./index27.js";
|
|
2
|
+
import { keccak256 as f } from "./index28.js";
|
|
3
|
+
import { LruMap as m } from "./index29.js";
|
|
4
|
+
const r = /* @__PURE__ */ new m(8192);
|
|
5
|
+
function a(s, o) {
|
|
6
|
+
if (r.has(`${s}.${o}`))
|
|
7
|
+
return r.get(`${s}.${o}`);
|
|
8
|
+
const c = s.substring(2).toLowerCase(), n = f(p(c)), e = c.split("");
|
|
9
|
+
for (let t = 0; t < 40; t += 2)
|
|
10
|
+
n[t >> 1] >> 4 >= 8 && e[t] && (e[t] = e[t].toUpperCase()), (n[t >> 1] & 15) >= 8 && e[t + 1] && (e[t + 1] = e[t + 1].toUpperCase());
|
|
11
|
+
const i = `0x${e.join("")}`;
|
|
12
|
+
return r.set(`${s}.${o}`, i), i;
|
|
51
13
|
}
|
|
52
14
|
export {
|
|
53
|
-
|
|
54
|
-
y as hexToBytes,
|
|
55
|
-
T as numberToBytes,
|
|
56
|
-
l as stringToBytes,
|
|
57
|
-
F as toBytes
|
|
15
|
+
a as checksumAddress
|
|
58
16
|
};
|
package/dist/esm/index27.js
CHANGED
|
@@ -1,9 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isHex as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { BaseError as g } from "./index45.js";
|
|
2
|
+
import { isHex as x } from "./index32.js";
|
|
3
|
+
import { pad as s } from "./index33.js";
|
|
4
|
+
import { assertSize as u } from "./index41.js";
|
|
5
|
+
import { numberToHex as h } from "./index25.js";
|
|
6
|
+
const A = /* @__PURE__ */ new TextEncoder();
|
|
7
|
+
function F(e, n = {}) {
|
|
8
|
+
return typeof e == "number" || typeof e == "bigint" ? T(e, n) : typeof e == "boolean" ? B(e, n) : x(e) ? y(e, n) : l(e, n);
|
|
9
|
+
}
|
|
10
|
+
function B(e, n = {}) {
|
|
11
|
+
const r = new Uint8Array(1);
|
|
12
|
+
return r[0] = Number(e), typeof n.size == "number" ? (u(r, { size: n.size }), s(r, { size: n.size })) : r;
|
|
13
|
+
}
|
|
14
|
+
const t = {
|
|
15
|
+
zero: 48,
|
|
16
|
+
nine: 57,
|
|
17
|
+
A: 65,
|
|
18
|
+
F: 70,
|
|
19
|
+
a: 97,
|
|
20
|
+
f: 102
|
|
21
|
+
};
|
|
22
|
+
function m(e) {
|
|
23
|
+
if (e >= t.zero && e <= t.nine)
|
|
24
|
+
return e - t.zero;
|
|
25
|
+
if (e >= t.A && e <= t.F)
|
|
26
|
+
return e - (t.A - 10);
|
|
27
|
+
if (e >= t.a && e <= t.f)
|
|
28
|
+
return e - (t.a - 10);
|
|
29
|
+
}
|
|
30
|
+
function y(e, n = {}) {
|
|
31
|
+
let r = e;
|
|
32
|
+
n.size && (u(r, { size: n.size }), r = s(r, { dir: "right", size: n.size }));
|
|
33
|
+
let i = r.slice(2);
|
|
34
|
+
i.length % 2 && (i = `0${i}`);
|
|
35
|
+
const z = i.length / 2, d = new Uint8Array(z);
|
|
36
|
+
for (let f = 0, o = 0; f < z; f++) {
|
|
37
|
+
const b = m(i.charCodeAt(o++)), c = m(i.charCodeAt(o++));
|
|
38
|
+
if (b === void 0 || c === void 0)
|
|
39
|
+
throw new g(`Invalid byte sequence ("${i[o - 2]}${i[o - 1]}" in "${i}").`);
|
|
40
|
+
d[f] = b * 16 + c;
|
|
41
|
+
}
|
|
42
|
+
return d;
|
|
43
|
+
}
|
|
44
|
+
function T(e, n) {
|
|
45
|
+
const r = h(e, n);
|
|
46
|
+
return y(r);
|
|
47
|
+
}
|
|
48
|
+
function l(e, n = {}) {
|
|
49
|
+
const r = A.encode(e);
|
|
50
|
+
return typeof n.size == "number" ? (u(r, { size: n.size }), s(r, { dir: "right", size: n.size })) : r;
|
|
6
51
|
}
|
|
7
52
|
export {
|
|
8
|
-
|
|
53
|
+
B as boolToBytes,
|
|
54
|
+
y as hexToBytes,
|
|
55
|
+
T as numberToBytes,
|
|
56
|
+
l as stringToBytes,
|
|
57
|
+
F as toBytes
|
|
9
58
|
};
|
package/dist/esm/index28.js
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
writable: !0,
|
|
7
|
-
value: void 0
|
|
8
|
-
}), this.maxSize = e;
|
|
9
|
-
}
|
|
10
|
-
get(e) {
|
|
11
|
-
const t = super.get(e);
|
|
12
|
-
return super.has(e) && t !== void 0 && (this.delete(e), super.set(e, t)), t;
|
|
13
|
-
}
|
|
14
|
-
set(e, t) {
|
|
15
|
-
if (super.set(e, t), this.maxSize && this.size > this.maxSize) {
|
|
16
|
-
const s = this.keys().next().value;
|
|
17
|
-
s && this.delete(s);
|
|
18
|
-
}
|
|
19
|
-
return this;
|
|
20
|
-
}
|
|
1
|
+
import { keccak_256 as o } from "./index48.js";
|
|
2
|
+
import { isHex as r } from "./index32.js";
|
|
3
|
+
import { toBytes as c } from "./index27.js";
|
|
4
|
+
function k(t, e) {
|
|
5
|
+
return o(r(t, { strict: !1 }) ? c(t) : t);
|
|
21
6
|
}
|
|
22
7
|
export {
|
|
23
|
-
|
|
8
|
+
k as keccak256
|
|
24
9
|
};
|
package/dist/esm/index29.js
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
class r extends Map {
|
|
2
|
+
constructor(e) {
|
|
3
|
+
super(), Object.defineProperty(this, "maxSize", {
|
|
4
|
+
enumerable: !0,
|
|
5
|
+
configurable: !0,
|
|
6
|
+
writable: !0,
|
|
7
|
+
value: void 0
|
|
8
|
+
}), this.maxSize = e;
|
|
9
|
+
}
|
|
10
|
+
get(e) {
|
|
11
|
+
const t = super.get(e);
|
|
12
|
+
return super.has(e) && t !== void 0 && (this.delete(e), super.set(e, t)), t;
|
|
13
|
+
}
|
|
14
|
+
set(e, t) {
|
|
15
|
+
if (super.set(e, t), this.maxSize && this.size > this.maxSize) {
|
|
16
|
+
const s = this.keys().next().value;
|
|
17
|
+
s && this.delete(s);
|
|
18
|
+
}
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
10
21
|
}
|
|
11
22
|
export {
|
|
12
|
-
|
|
13
|
-
r as isAddressCache
|
|
23
|
+
r as LruMap
|
|
14
24
|
};
|