@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.
Files changed (95) hide show
  1. package/dist/esm/index100.js +7 -14
  2. package/dist/esm/index101.js +16 -80
  3. package/dist/esm/index102.js +72 -70
  4. package/dist/esm/index103.js +81 -0
  5. package/dist/esm/index13.js +18 -172
  6. package/dist/esm/index14.js +169 -157
  7. package/dist/esm/index15.js +157 -45
  8. package/dist/esm/index16.js +44 -142
  9. package/dist/esm/index17.js +144 -54
  10. package/dist/esm/index18.js +56 -41
  11. package/dist/esm/index19.js +40 -16
  12. package/dist/esm/index2.js +72 -68
  13. package/dist/esm/index20.js +16 -4
  14. package/dist/esm/index21.js +5 -5
  15. package/dist/esm/index22.js +5 -9
  16. package/dist/esm/index23.js +8 -17
  17. package/dist/esm/index24.js +16 -44
  18. package/dist/esm/index25.js +45 -13
  19. package/dist/esm/index26.js +13 -55
  20. package/dist/esm/index27.js +55 -6
  21. package/dist/esm/index28.js +6 -21
  22. package/dist/esm/index29.js +21 -11
  23. package/dist/esm/index3.js +4 -4
  24. package/dist/esm/index30.js +11 -3
  25. package/dist/esm/index31.js +3 -3
  26. package/dist/esm/index32.js +3 -34
  27. package/dist/esm/index33.js +32 -10
  28. package/dist/esm/index34.js +12 -4
  29. package/dist/esm/index35.js +4 -28
  30. package/dist/esm/index36.js +28 -6
  31. package/dist/esm/index37.js +6 -24
  32. package/dist/esm/index38.js +24 -16
  33. package/dist/esm/index39.js +16 -54
  34. package/dist/esm/index40.js +53 -22
  35. package/dist/esm/index41.js +23 -11
  36. package/dist/esm/index42.js +10 -26
  37. package/dist/esm/index43.js +26 -41
  38. package/dist/esm/index44.js +41 -54
  39. package/dist/esm/index45.js +54 -126
  40. package/dist/esm/index46.js +126 -11
  41. package/dist/esm/index47.js +9 -101
  42. package/dist/esm/index48.js +104 -6
  43. package/dist/esm/index49.js +7 -3
  44. package/dist/esm/index5.js +4 -4
  45. package/dist/esm/index50.js +3 -15
  46. package/dist/esm/index51.js +14 -42
  47. package/dist/esm/index52.js +38 -74
  48. package/dist/esm/index53.js +79 -2
  49. package/dist/esm/index54.js +2 -2
  50. package/dist/esm/index55.js +2 -13
  51. package/dist/esm/index56.js +8 -33
  52. package/dist/esm/index57.js +36 -5
  53. package/dist/esm/index58.js +5 -33
  54. package/dist/esm/index59.js +34 -8
  55. package/dist/esm/index60.js +8 -10
  56. package/dist/esm/index61.js +10 -11
  57. package/dist/esm/index62.js +11 -13
  58. package/dist/esm/index63.js +13 -18
  59. package/dist/esm/index64.js +18 -5
  60. package/dist/esm/index65.js +6 -5
  61. package/dist/esm/index66.js +5 -11
  62. package/dist/esm/index67.js +10 -16
  63. package/dist/esm/index68.js +15 -21
  64. package/dist/esm/index69.js +21 -49
  65. package/dist/esm/index70.js +51 -2
  66. package/dist/esm/index71.js +2 -21
  67. package/dist/esm/index72.js +18 -17
  68. package/dist/esm/index73.js +20 -80
  69. package/dist/esm/index74.js +79 -103
  70. package/dist/esm/index75.js +101 -30
  71. package/dist/esm/index76.js +32 -6
  72. package/dist/esm/index77.js +7 -10
  73. package/dist/esm/index78.js +10 -55
  74. package/dist/esm/index79.js +54 -10
  75. package/dist/esm/index80.js +11 -2
  76. package/dist/esm/index81.js +2 -45
  77. package/dist/esm/index82.js +44 -13
  78. package/dist/esm/index83.js +13 -78
  79. package/dist/esm/index84.js +79 -5
  80. package/dist/esm/index85.js +5 -13
  81. package/dist/esm/index86.js +12 -35
  82. package/dist/esm/index87.js +35 -41
  83. package/dist/esm/index88.js +40 -19
  84. package/dist/esm/index89.js +21 -10
  85. package/dist/esm/index90.js +9 -19
  86. package/dist/esm/index91.js +15 -89
  87. package/dist/esm/index92.js +92 -19
  88. package/dist/esm/index93.js +18 -115
  89. package/dist/esm/index94.js +118 -18
  90. package/dist/esm/index95.js +18 -28
  91. package/dist/esm/index96.js +26 -6
  92. package/dist/esm/index97.js +6 -9
  93. package/dist/esm/index98.js +11 -13
  94. package/dist/esm/index99.js +11 -8
  95. package/package.json +3 -3
@@ -1,27 +1,36 @@
1
- import { configureCdpApiClient as p, setAuthManager as h, initiateAuthentication as l, verifyEmailAuthentication as I, createEndUserEvmAccount as f, signEvmHashWithEndUserAccount as y, signEvmTransactionWithEndUserAccount as E, sendEvmTransactionWithEndUserAccount as v, signEvmMessageWithEndUserAccount as A, signEvmTypedDataWithEndUserAccount as k, exportEndUserEvmAccount as S } from "@coinbase/cdp-api-client";
2
- import { AuthManager as U } from "./index5.js";
3
- import { toAuthState as g } from "./index6.js";
4
- import { withAuth as o } from "./index7.js";
5
- import { createExportKeyPair as M } from "./index8.js";
6
- import { decryptWithPrivateKey as T } from "./index9.js";
7
- import { MockAuthManager as j } from "./index10.js";
8
- import { mockUser as m } from "./index11.js";
9
- import { isChainSupportedForCDPSends as P } from "./index12.js";
10
- import { serializeTransaction as w } from "./index13.js";
11
- let i = null, u = null;
12
- const q = async (e) => {
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
- const s = i?.projectId !== e.projectId;
16
- if (i = e, i.useMock) {
17
- u = new j(i.projectId);
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: i.debugging,
22
- basePath: i.basePath
23
- }), s && (u = new U(i.projectId), h(u)), await n().ensureInitialized();
24
- }, B = async (e) => {
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 l(r().projectId, {
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
- }, F = async (e) => {
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: m
54
+ user: d
46
55
  }), {
47
56
  message: "Mock email OTP verified",
48
- user: m,
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 I(r().projectId, {
62
+ const t = await y(r().projectId, {
54
63
  flowId: e.flowId,
55
64
  otp: e.otp
56
65
  });
57
- let a = g(t.accessToken, t.validUntil, t.endUser);
58
- if (t.isNewEndUser) {
59
- const d = await f(r().projectId, a.user.userId, {
60
- walletSecretId: await n().getWalletSecretId(a)
61
- });
62
- a = g(t.accessToken, t.validUntil, d);
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
- }, $ = async () => n().getUser(), G = async () => n().isSignedIn(), J = async () => {
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" } : o(e, n(), async ({ user: s, walletSecretId: t }) => ({
82
- signature: (await y(r().projectId, s.userId, {
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" } : o(e, n(), async ({ user: s, walletSecretId: t }) => {
88
- const a = w(e.transaction);
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 E(
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
- }), V = async (e) => {
101
- if (!P(e.network))
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 = w(e.transaction);
106
- return o(e, n(), async ({ user: t, walletSecretId: a }) => ({
107
- transactionHash: (await v(
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
- }, X = async (e) => r().useMock ? { signature: "0x0" } : o(e, n(), async ({ user: s, walletSecretId: t }) => ({
119
- signature: (await A(r().projectId, s.userId, {
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
- })), Y = async (e) => r().useMock ? { signature: "0x0" } : o(e, n(), async ({ user: s, walletSecretId: t }) => ({
125
- signature: (await k(r().projectId, s.userId, {
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
- })), Z = async (e) => {
142
+ })), _ = async (e) => {
131
143
  if (r().useMock)
132
144
  return {
133
145
  privateKey: "mock-private-key"
134
146
  };
135
- const s = await M();
136
- return o(e, n(), async ({ user: t, walletSecretId: a }) => {
137
- const c = await S(r().projectId, t.userId, {
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 T(
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
- Z as exportEvmAccount,
160
- $ as getCurrentUser,
161
- q as initialize,
163
+ _ as exportEvmAccount,
164
+ V as getCurrentUser,
165
+ $ as initialize,
162
166
  G as isSignedIn,
163
167
  L as onAuthStateChange,
164
- V as sendEvmTransaction,
168
+ X as sendEvmTransaction,
165
169
  Q as signEvmHash,
166
- X as signEvmMessage,
170
+ Y as signEvmMessage,
167
171
  R as signEvmTransaction,
168
- Y as signEvmTypedData,
169
- B as signInWithEmail,
172
+ Z as signEvmTypedData,
173
+ q as signInWithEmail,
170
174
  J as signOut,
171
- F as verifyEmailOTP
175
+ B as verifyEmailOTP
172
176
  };
@@ -1,7 +1,19 @@
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("");
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
- t as generateRandomId
18
+ n as createKeyPair
7
19
  };
@@ -1,7 +1,7 @@
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
- };
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
- h as hash
6
+ t as generateRandomId
7
7
  };
@@ -1,11 +1,7 @@
1
- function n(e) {
2
- return {
3
- formatters: void 0,
4
- fees: void 0,
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
- n as defineChain
6
+ h as hash
11
7
  };
@@ -1,20 +1,11 @@
1
- import { toHex as i } from "./index24.js";
2
- import { toYParitySignatureArray as c } from "./index13.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
- ]);
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
- f as serializeAuthorizationList
10
+ n as defineChain
20
11
  };
@@ -1,48 +1,20 @@
1
- import { IntegerOutOfRangeError as x } from "./index46.js";
2
- import { pad as s } from "./index32.js";
3
- import { assertSize as c } from "./index40.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
- });
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
- 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);
16
+ return t;
41
17
  }
42
18
  export {
43
- z as boolToHex,
44
- m as bytesToHex,
45
- y as numberToHex,
46
- $ as stringToHex,
47
- B as toHex
19
+ f as serializeAuthorizationList
48
20
  };
@@ -1,16 +1,48 @@
1
- import { stringToBytes as p } from "./index26.js";
2
- import { keccak256 as f } from "./index27.js";
3
- import { LruMap as m } from "./index28.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;
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
- a as checksumAddress
43
+ z as boolToHex,
44
+ m as bytesToHex,
45
+ y as numberToHex,
46
+ $ as stringToHex,
47
+ B as toHex
16
48
  };
@@ -1,58 +1,16 @@
1
- import { BaseError as g } from "./index44.js";
2
- import { isHex as x } from "./index31.js";
3
- import { pad as s } from "./index32.js";
4
- import { assertSize as u } from "./index40.js";
5
- import { numberToHex as h } from "./index24.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;
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
- B as boolToBytes,
54
- y as hexToBytes,
55
- T as numberToBytes,
56
- l as stringToBytes,
57
- F as toBytes
15
+ a as checksumAddress
58
16
  };
@@ -1,9 +1,58 @@
1
- import { keccak_256 as o } from "./index47.js";
2
- import { isHex as r } from "./index31.js";
3
- import { toBytes as c } from "./index26.js";
4
- function k(t, e) {
5
- return o(r(t, { strict: !1 }) ? c(t) : t);
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
- k as keccak256
53
+ B as boolToBytes,
54
+ y as hexToBytes,
55
+ T as numberToBytes,
56
+ l as stringToBytes,
57
+ F as toBytes
9
58
  };
@@ -1,24 +1,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
- }
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
- r as LruMap
8
+ k as keccak256
24
9
  };
@@ -1,14 +1,24 @@
1
- import { LruMap as u } from "./index28.js";
2
- import { checksumAddress as c } from "./index25.js";
3
- const i = /^0x[a-fA-F0-9]{40}$/, r = /* @__PURE__ */ new u(8192);
4
- function h(t, s) {
5
- const { strict: n = !0 } = s ?? {}, e = `${t}.${n}`;
6
- if (r.has(e))
7
- return r.get(e);
8
- const o = i.test(t) ? t.toLowerCase() === t ? !0 : n ? c(t) === t : !0 : !1;
9
- return r.set(e, o), o;
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
- h as isAddress,
13
- r as isAddressCache
23
+ r as LruMap
14
24
  };