@coinbase/cdp-core 0.0.0 → 0.0.5

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 (106) hide show
  1. package/README.md +255 -0
  2. package/dist/esm/index.js +21 -0
  3. package/dist/esm/index10.js +119 -0
  4. package/dist/esm/index100.js +19 -0
  5. package/dist/esm/index101.js +83 -0
  6. package/dist/esm/index102.js +81 -0
  7. package/dist/esm/index11.js +8 -0
  8. package/dist/esm/index12.js +18 -0
  9. package/dist/esm/index13.js +174 -0
  10. package/dist/esm/index14.js +162 -0
  11. package/dist/esm/index15.js +50 -0
  12. package/dist/esm/index16.js +149 -0
  13. package/dist/esm/index17.js +58 -0
  14. package/dist/esm/index18.js +43 -0
  15. package/dist/esm/index19.js +19 -0
  16. package/dist/esm/index2.js +172 -0
  17. package/dist/esm/index20.js +7 -0
  18. package/dist/esm/index21.js +7 -0
  19. package/dist/esm/index22.js +11 -0
  20. package/dist/esm/index23.js +20 -0
  21. package/dist/esm/index24.js +48 -0
  22. package/dist/esm/index25.js +16 -0
  23. package/dist/esm/index26.js +58 -0
  24. package/dist/esm/index27.js +9 -0
  25. package/dist/esm/index28.js +24 -0
  26. package/dist/esm/index29.js +14 -0
  27. package/dist/esm/index3.js +109 -0
  28. package/dist/esm/index30.js +6 -0
  29. package/dist/esm/index31.js +6 -0
  30. package/dist/esm/index32.js +37 -0
  31. package/dist/esm/index33.js +15 -0
  32. package/dist/esm/index34.js +7 -0
  33. package/dist/esm/index35.js +31 -0
  34. package/dist/esm/index36.js +9 -0
  35. package/dist/esm/index37.js +27 -0
  36. package/dist/esm/index38.js +19 -0
  37. package/dist/esm/index39.js +57 -0
  38. package/dist/esm/index4.js +126 -0
  39. package/dist/esm/index40.js +26 -0
  40. package/dist/esm/index41.js +14 -0
  41. package/dist/esm/index42.js +30 -0
  42. package/dist/esm/index43.js +45 -0
  43. package/dist/esm/index44.js +58 -0
  44. package/dist/esm/index45.js +130 -0
  45. package/dist/esm/index46.js +15 -0
  46. package/dist/esm/index47.js +107 -0
  47. package/dist/esm/index48.js +9 -0
  48. package/dist/esm/index49.js +5 -0
  49. package/dist/esm/index5.js +194 -0
  50. package/dist/esm/index50.js +17 -0
  51. package/dist/esm/index51.js +45 -0
  52. package/dist/esm/index52.js +81 -0
  53. package/dist/esm/index53.js +4 -0
  54. package/dist/esm/index54.js +4 -0
  55. package/dist/esm/index55.js +15 -0
  56. package/dist/esm/index56.js +40 -0
  57. package/dist/esm/index57.js +9 -0
  58. package/dist/esm/index58.js +37 -0
  59. package/dist/esm/index59.js +11 -0
  60. package/dist/esm/index6.js +14 -0
  61. package/dist/esm/index60.js +13 -0
  62. package/dist/esm/index61.js +14 -0
  63. package/dist/esm/index62.js +16 -0
  64. package/dist/esm/index63.js +21 -0
  65. package/dist/esm/index64.js +8 -0
  66. package/dist/esm/index65.js +7 -0
  67. package/dist/esm/index66.js +13 -0
  68. package/dist/esm/index67.js +19 -0
  69. package/dist/esm/index68.js +25 -0
  70. package/dist/esm/index69.js +53 -0
  71. package/dist/esm/index7.js +14 -0
  72. package/dist/esm/index70.js +4 -0
  73. package/dist/esm/index71.js +23 -0
  74. package/dist/esm/index72.js +22 -0
  75. package/dist/esm/index73.js +82 -0
  76. package/dist/esm/index74.js +106 -0
  77. package/dist/esm/index75.js +35 -0
  78. package/dist/esm/index76.js +9 -0
  79. package/dist/esm/index77.js +12 -0
  80. package/dist/esm/index78.js +57 -0
  81. package/dist/esm/index79.js +13 -0
  82. package/dist/esm/index8.js +23 -0
  83. package/dist/esm/index80.js +4 -0
  84. package/dist/esm/index81.js +47 -0
  85. package/dist/esm/index82.js +16 -0
  86. package/dist/esm/index83.js +81 -0
  87. package/dist/esm/index84.js +7 -0
  88. package/dist/esm/index85.js +15 -0
  89. package/dist/esm/index86.js +38 -0
  90. package/dist/esm/index87.js +44 -0
  91. package/dist/esm/index88.js +23 -0
  92. package/dist/esm/index89.js +12 -0
  93. package/dist/esm/index9.js +17 -0
  94. package/dist/esm/index90.js +22 -0
  95. package/dist/esm/index91.js +96 -0
  96. package/dist/esm/index92.js +23 -0
  97. package/dist/esm/index93.js +120 -0
  98. package/dist/esm/index94.js +20 -0
  99. package/dist/esm/index95.js +30 -0
  100. package/dist/esm/index96.js +10 -0
  101. package/dist/esm/index97.js +13 -0
  102. package/dist/esm/index98.js +15 -0
  103. package/dist/esm/index99.js +12 -0
  104. package/dist/types/index.d.ts +287 -0
  105. package/package.json +69 -6
  106. package/index.js +0 -1
@@ -0,0 +1,194 @@
1
+ import { logOutEndUser as c, refreshAccessToken as o, registerTemporaryWalletSecret as u } from "@coinbase/cdp-api-client";
2
+ import { SignJWT as S } from "./index18.js";
3
+ import { toAuthState as w } from "./index6.js";
4
+ import { createKeyPair as f } from "./index19.js";
5
+ import { generateRandomId as n } from "./index20.js";
6
+ import { hash as d } from "./index21.js";
7
+ import { sortKeys as y } from "./index12.js";
8
+ const h = 60 * 1e3;
9
+ class E {
10
+ projectId;
11
+ authState = null;
12
+ walletSecret = null;
13
+ authStateChangeCallbacks = [];
14
+ initPromise = null;
15
+ /**
16
+ * Initializes the token manager.
17
+ *
18
+ * @param projectId - The project ID.
19
+ */
20
+ constructor(t) {
21
+ this.projectId = t, this.initPromise = this._doInitialize();
22
+ }
23
+ /**
24
+ * Gets the current user, or null if there is no user signed in.
25
+ *
26
+ * @returns The current user.
27
+ */
28
+ async getUser() {
29
+ return this.authState?.user ?? null;
30
+ }
31
+ /**
32
+ * Returns whether the user is signed in - i.e., whether there is an unexpired
33
+ * access token and user.
34
+ *
35
+ * @returns True if the user is signed in, false otherwise.
36
+ */
37
+ async isSignedIn() {
38
+ return this.authState ? Promise.resolve(this.authState.expiresAt > Date.now()) : Promise.resolve(!1);
39
+ }
40
+ /**
41
+ * Signs out the user, clearing all authentication state.
42
+ */
43
+ async signOut() {
44
+ try {
45
+ await c(this.projectId);
46
+ } catch {
47
+ } finally {
48
+ await this.clearAuthState();
49
+ }
50
+ }
51
+ /**
52
+ * Adds a callback to be called when the auth state changes.
53
+ *
54
+ * @param callback - The function to call when the auth state changes.
55
+ */
56
+ addAuthStateChangeCallback(t) {
57
+ this.authStateChangeCallbacks.push(t), t(this.authState?.user ?? null);
58
+ }
59
+ /**
60
+ * Gets the access token, refreshing it if it is expired. Returns null if the user is not
61
+ * signed in.
62
+ *
63
+ * @returns The access token.
64
+ */
65
+ async getToken() {
66
+ return this.shouldRefreshToken() && await this.refreshAccessToken(), this.authState?.accessToken ?? null;
67
+ }
68
+ /**
69
+ * Gets the currently registered wallet secret ID. Rejects if the user is not signed in.
70
+ *
71
+ * @param authState - The auth state to use. If not provided, the current auth state will be used.
72
+ *
73
+ * @returns The wallet secret ID.
74
+ */
75
+ async getWalletSecretId(t) {
76
+ return this.shouldRefreshWalletSecret() && await this.refreshWalletSecret(t), this.walletSecret.walletSecretId;
77
+ }
78
+ /**
79
+ * Gets the X-Wallet-Auth header. Rejects if the user is not signed in.
80
+ *
81
+ * @param options - The options for the request.
82
+ * @param options.requestMethod - The HTTP method of the request.
83
+ * @param options.requestHost - The host of the request.
84
+ * @param options.requestPath - The path of the request.
85
+ * @param options.requestData - The data of the request.
86
+ * @returns The X-Wallet-Auth header.
87
+ */
88
+ async getXWalletAuth(t) {
89
+ this.shouldRefreshWalletSecret() && await this.refreshWalletSecret();
90
+ const e = `${t.requestMethod} ${t.requestHost}${t.requestPath}`, a = Math.floor(Date.now() / 1e3), r = {
91
+ uris: [e]
92
+ };
93
+ if (t.requestData && Object.keys(t.requestData).length > 0) {
94
+ const s = y(t.requestData);
95
+ r.reqHash = await d(new TextEncoder().encode(JSON.stringify(s)));
96
+ }
97
+ return await new S(r).setProtectedHeader({ alg: "ES256", typ: "JWT" }).setIssuedAt(a).setNotBefore(a).setJti(await n()).sign(this.walletSecret.keyPair.privateKey);
98
+ }
99
+ /**
100
+ * Sets the authentication state.
101
+ *
102
+ * @param authState - The authentication state.
103
+ */
104
+ async setAuthState(t) {
105
+ this.authState = t, this.authStateChangeCallbacks.forEach((e) => e(this.authState?.user ?? null));
106
+ }
107
+ /**
108
+ * Clears the authentication state.
109
+ */
110
+ async clearAuthState() {
111
+ this.authState = null, this.walletSecret = null, this.authStateChangeCallbacks.forEach((t) => t(null));
112
+ }
113
+ /**
114
+ * Ensures the AuthManager is initialized before proceeding.
115
+ * If initialization is already in progress, waits for it to complete.
116
+ */
117
+ async ensureInitialized() {
118
+ if (this.initPromise) {
119
+ await this.initPromise;
120
+ return;
121
+ }
122
+ throw new Error("AuthManager not initialized");
123
+ }
124
+ /**
125
+ * Internal async initialization logic.
126
+ */
127
+ async _doInitialize() {
128
+ try {
129
+ await this.refreshAccessToken();
130
+ } catch (t) {
131
+ console.warn("Failed to refresh access token during initialization:", t);
132
+ }
133
+ }
134
+ /**
135
+ * Returns whether the token should be refreshed.
136
+ *
137
+ * @returns True if the token should be refreshed, false otherwise.
138
+ */
139
+ shouldRefreshToken() {
140
+ return !(this.authState && this.authState.expiresAt > Date.now() + h);
141
+ }
142
+ /**
143
+ * Refreshes the access token and transitions the auth state accordingly.
144
+ * If a refresh is already in progress, it will wait for that refresh to complete.
145
+ *
146
+ * @returns The new access token.
147
+ */
148
+ async refreshAccessToken() {
149
+ try {
150
+ const t = await o(this.projectId, {
151
+ grantType: "refresh_token"
152
+ }), e = w(
153
+ t.accessToken,
154
+ t.validUntil,
155
+ t.endUser
156
+ );
157
+ await this.setAuthState(e);
158
+ } catch {
159
+ await this.clearAuthState();
160
+ }
161
+ }
162
+ /**
163
+ * Returns whether the wallet secret should be refreshed.
164
+ *
165
+ * @returns True if the wallet secret should be refreshed, false otherwise.
166
+ */
167
+ shouldRefreshWalletSecret() {
168
+ return !(this.walletSecret && this.walletSecret.expiresAt > Date.now() + h);
169
+ }
170
+ /**
171
+ * Refreshes the wallet secret.
172
+ *
173
+ * @param authState - The auth state to use. If not provided, the current auth state will be used.
174
+ * @returns The wallet secret.
175
+ */
176
+ async refreshWalletSecret(t) {
177
+ if (!t && !await this.isSignedIn())
178
+ throw new Error("Cannot refresh wallet secret if the auth state is not present or expired");
179
+ const e = t ?? this.authState, a = this.walletSecret?.walletSecretId ?? await n(), r = this.walletSecret?.keyPair ?? await f(), s = e.expiresAt, l = new Date(s).toISOString();
180
+ this.walletSecret = { walletSecretId: a, keyPair: r, expiresAt: s };
181
+ try {
182
+ await u(this.projectId, e.user.userId, {
183
+ walletSecretId: a,
184
+ publicKey: r.publicKeyBase64,
185
+ validUntil: l
186
+ });
187
+ } catch (i) {
188
+ throw this.walletSecret = null, i;
189
+ }
190
+ }
191
+ }
192
+ export {
193
+ E as AuthManager
194
+ };
@@ -0,0 +1,17 @@
1
+ import { InvalidSerializableTransactionError as f } from "./index51.js";
2
+ function d(e) {
3
+ if (e.type)
4
+ return e.type;
5
+ if (typeof e.authorizationList < "u")
6
+ return "eip7702";
7
+ if (typeof e.blobs < "u" || typeof e.blobVersionedHashes < "u" || typeof e.maxFeePerBlobGas < "u" || typeof e.sidecars < "u")
8
+ return "eip4844";
9
+ if (typeof e.maxFeePerGas < "u" || typeof e.maxPriorityFeePerGas < "u")
10
+ return "eip1559";
11
+ if (typeof e.gasPrice < "u")
12
+ return typeof e.accessList < "u" ? "eip2930" : "legacy";
13
+ throw new f({ transaction: e });
14
+ }
15
+ export {
16
+ d as getTransactionType
17
+ };
@@ -0,0 +1,45 @@
1
+ import { BaseError as t } from "./index44.js";
2
+ function i(n) {
3
+ const r = Object.entries(n).map(([a, e]) => e === void 0 || e === !1 ? null : [a, e]).filter(Boolean), o = r.reduce((a, [e]) => Math.max(a, e.length), 0);
4
+ return r.map(([a, e]) => ` ${`${a}:`.padEnd(o + 1)} ${e}`).join(`
5
+ `);
6
+ }
7
+ class c extends t {
8
+ constructor({ v: r }) {
9
+ super(`Invalid \`v\` value "${r}". Expected 27 or 28.`, {
10
+ name: "InvalidLegacyVError"
11
+ });
12
+ }
13
+ }
14
+ class d extends t {
15
+ constructor({ transaction: r }) {
16
+ super("Cannot infer a transaction type from provided transaction.", {
17
+ metaMessages: [
18
+ "Provided Transaction:",
19
+ "{",
20
+ i(r),
21
+ "}",
22
+ "",
23
+ "To infer the type, either provide:",
24
+ "- a `type` to the Transaction, or",
25
+ "- an EIP-1559 Transaction with `maxFeePerGas`, or",
26
+ "- an EIP-2930 Transaction with `gasPrice` & `accessList`, or",
27
+ "- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or",
28
+ "- an EIP-7702 Transaction with `authorizationList`, or",
29
+ "- a Legacy Transaction with `gasPrice`"
30
+ ],
31
+ name: "InvalidSerializableTransactionError"
32
+ });
33
+ }
34
+ }
35
+ class l extends t {
36
+ constructor({ storageKey: r }) {
37
+ super(`Size for storage key "${r}" is invalid. Expected 32 bytes. Got ${Math.floor((r.length - 2) / 2)} bytes.`, { name: "InvalidStorageKeySizeError" });
38
+ }
39
+ }
40
+ export {
41
+ c as InvalidLegacyVError,
42
+ d as InvalidSerializableTransactionError,
43
+ l as InvalidStorageKeySizeError,
44
+ i as prettyPrint
45
+ };
@@ -0,0 +1,81 @@
1
+ import { versionedHashVersionKzg as c } from "./index53.js";
2
+ import { maxUint256 as m } from "./index54.js";
3
+ import { InvalidAddressError as s } from "./index55.js";
4
+ import { BaseError as h } from "./index44.js";
5
+ import { EmptyBlobError as P, InvalidVersionedHashSizeError as p, InvalidVersionedHashVersionError as x } from "./index56.js";
6
+ import { InvalidChainIdError as n } from "./index57.js";
7
+ import { FeeCapTooHighError as w, TipAboveFeeCapError as E } from "./index58.js";
8
+ import { isAddress as f } from "./index29.js";
9
+ import { size as F } from "./index34.js";
10
+ import { slice as I } from "./index35.js";
11
+ import { hexToNumber as G } from "./index40.js";
12
+ function C(t) {
13
+ const { authorizationList: e } = t;
14
+ if (e)
15
+ for (const o of e) {
16
+ const { chainId: r } = o, i = o.address;
17
+ if (!f(i))
18
+ throw new s({ address: i });
19
+ if (r < 0)
20
+ throw new n({ chainId: r });
21
+ }
22
+ d(t);
23
+ }
24
+ function L(t) {
25
+ const { blobVersionedHashes: e } = t;
26
+ if (e) {
27
+ if (e.length === 0)
28
+ throw new P();
29
+ for (const o of e) {
30
+ const r = F(o), i = G(I(o, 0, 1));
31
+ if (r !== 32)
32
+ throw new p({ hash: o, size: r });
33
+ if (i !== c)
34
+ throw new x({
35
+ hash: o,
36
+ version: i
37
+ });
38
+ }
39
+ }
40
+ d(t);
41
+ }
42
+ function d(t) {
43
+ const { chainId: e, maxPriorityFeePerGas: o, maxFeePerGas: r, to: i } = t;
44
+ if (e <= 0)
45
+ throw new n({ chainId: e });
46
+ if (i && !f(i))
47
+ throw new s({ address: i });
48
+ if (r && r > m)
49
+ throw new w({ maxFeePerGas: r });
50
+ if (o && r && o > r)
51
+ throw new E({ maxFeePerGas: r, maxPriorityFeePerGas: o });
52
+ }
53
+ function B(t) {
54
+ const { chainId: e, maxPriorityFeePerGas: o, gasPrice: r, maxFeePerGas: i, to: a } = t;
55
+ if (e <= 0)
56
+ throw new n({ chainId: e });
57
+ if (a && !f(a))
58
+ throw new s({ address: a });
59
+ if (o || i)
60
+ throw new h("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");
61
+ if (r && r > m)
62
+ throw new w({ maxFeePerGas: r });
63
+ }
64
+ function K(t) {
65
+ const { chainId: e, maxPriorityFeePerGas: o, gasPrice: r, maxFeePerGas: i, to: a } = t;
66
+ if (a && !f(a))
67
+ throw new s({ address: a });
68
+ if (typeof e < "u" && e <= 0)
69
+ throw new n({ chainId: e });
70
+ if (o || i)
71
+ throw new h("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");
72
+ if (r && r > m)
73
+ throw new w({ maxFeePerGas: r });
74
+ }
75
+ export {
76
+ d as assertTransactionEIP1559,
77
+ B as assertTransactionEIP2930,
78
+ L as assertTransactionEIP4844,
79
+ C as assertTransactionEIP7702,
80
+ K as assertTransactionLegacy
81
+ };
@@ -0,0 +1,4 @@
1
+ const e = 1;
2
+ export {
3
+ e as versionedHashVersionKzg
4
+ };
@@ -0,0 +1,4 @@
1
+ const n = 2n ** 256n - 1n;
2
+ export {
3
+ n as maxUint256
4
+ };
@@ -0,0 +1,15 @@
1
+ import { BaseError as r } from "./index44.js";
2
+ class d extends r {
3
+ constructor({ address: s }) {
4
+ super(`Address "${s}" is invalid.`, {
5
+ metaMessages: [
6
+ "- Address must be a hex value of 20 bytes (40 hex characters).",
7
+ "- Address must match its checksum counterpart."
8
+ ],
9
+ name: "InvalidAddressError"
10
+ });
11
+ }
12
+ }
13
+ export {
14
+ d as InvalidAddressError
15
+ };
@@ -0,0 +1,40 @@
1
+ import { versionedHashVersionKzg as a } from "./index53.js";
2
+ import { BaseError as s } from "./index44.js";
3
+ class t extends s {
4
+ constructor({ maxSize: e, size: r }) {
5
+ super("Blob size is too large.", {
6
+ metaMessages: [`Max: ${e} bytes`, `Given: ${r} bytes`],
7
+ name: "BlobSizeTooLargeError"
8
+ });
9
+ }
10
+ }
11
+ class d extends s {
12
+ constructor() {
13
+ super("Blob data must not be empty.", { name: "EmptyBlobError" });
14
+ }
15
+ }
16
+ class l extends s {
17
+ constructor({ hash: e, size: r }) {
18
+ super(`Versioned hash "${e}" size is invalid.`, {
19
+ metaMessages: ["Expected: 32", `Received: ${r}`],
20
+ name: "InvalidVersionedHashSizeError"
21
+ });
22
+ }
23
+ }
24
+ class c extends s {
25
+ constructor({ hash: e, version: r }) {
26
+ super(`Versioned hash "${e}" version is invalid.`, {
27
+ metaMessages: [
28
+ `Expected: ${a}`,
29
+ `Received: ${r}`
30
+ ],
31
+ name: "InvalidVersionedHashVersionError"
32
+ });
33
+ }
34
+ }
35
+ export {
36
+ t as BlobSizeTooLargeError,
37
+ d as EmptyBlobError,
38
+ l as InvalidVersionedHashSizeError,
39
+ c as InvalidVersionedHashVersionError
40
+ };
@@ -0,0 +1,9 @@
1
+ import { BaseError as i } from "./index44.js";
2
+ class o extends i {
3
+ constructor({ chainId: r }) {
4
+ super(typeof r == "number" ? `Chain ID "${r}" is invalid.` : "Chain ID is invalid.", { name: "InvalidChainIdError" });
5
+ }
6
+ }
7
+ export {
8
+ o as InvalidChainIdError
9
+ };
@@ -0,0 +1,37 @@
1
+ import { formatGwei as a } from "./index64.js";
2
+ import { BaseError as o } from "./index44.js";
3
+ class n extends o {
4
+ constructor({ cause: r, maxFeePerGas: e } = {}) {
5
+ super(`The fee cap (\`maxFeePerGas\`${e ? ` = ${a(e)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`, {
6
+ cause: r,
7
+ name: "FeeCapTooHighError"
8
+ });
9
+ }
10
+ }
11
+ Object.defineProperty(n, "nodeMessage", {
12
+ enumerable: !0,
13
+ configurable: !0,
14
+ writable: !0,
15
+ value: /max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/
16
+ });
17
+ class h extends o {
18
+ constructor({ cause: r, maxPriorityFeePerGas: e, maxFeePerGas: t } = {}) {
19
+ super([
20
+ `The provided tip (\`maxPriorityFeePerGas\`${e ? ` = ${a(e)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${t ? ` = ${a(t)} gwei` : ""}).`
21
+ ].join(`
22
+ `), {
23
+ cause: r,
24
+ name: "TipAboveFeeCapError"
25
+ });
26
+ }
27
+ }
28
+ Object.defineProperty(h, "nodeMessage", {
29
+ enumerable: !0,
30
+ configurable: !0,
31
+ writable: !0,
32
+ value: /max priority fee per gas higher than max fee per gas|tip higher than fee cap/
33
+ });
34
+ export {
35
+ n as FeeCapTooHighError,
36
+ h as TipAboveFeeCapError
37
+ };
@@ -0,0 +1,11 @@
1
+ import { hexToBytes as i } from "./index26.js";
2
+ import { bytesToHex as f } from "./index24.js";
3
+ function y(o) {
4
+ const { kzg: s } = o, n = o.to ?? (typeof o.blobs[0] == "string" ? "hex" : "bytes"), m = typeof o.blobs[0] == "string" ? o.blobs.map((t) => i(t)) : o.blobs, b = [];
5
+ for (const t of m)
6
+ b.push(Uint8Array.from(s.blobToKzgCommitment(t)));
7
+ return n === "bytes" ? b : b.map((t) => f(t));
8
+ }
9
+ export {
10
+ y as blobsToCommitments
11
+ };
@@ -0,0 +1,14 @@
1
+ const u = (e, s, t) => {
2
+ const c = new Date(s).getTime(), o = {
3
+ userId: t.userId,
4
+ evmAccounts: t.evmAccounts?.map((r) => r) ?? []
5
+ };
6
+ return {
7
+ accessToken: e,
8
+ expiresAt: c,
9
+ user: o
10
+ };
11
+ };
12
+ export {
13
+ u as toAuthState
14
+ };
@@ -0,0 +1,13 @@
1
+ import { hexToBytes as b } from "./index26.js";
2
+ import { bytesToHex as y } from "./index24.js";
3
+ function h(t) {
4
+ const { kzg: m } = t, c = t.to ?? (typeof t.blobs[0] == "string" ? "hex" : "bytes"), s = typeof t.blobs[0] == "string" ? t.blobs.map((o) => b(o)) : t.blobs, i = typeof t.commitments[0] == "string" ? t.commitments.map((o) => b(o)) : t.commitments, n = [];
5
+ for (let o = 0; o < s.length; o++) {
6
+ const f = s[o], l = i[o];
7
+ n.push(Uint8Array.from(m.computeBlobKzgProof(f, l)));
8
+ }
9
+ return c === "bytes" ? n : n.map((o) => y(o));
10
+ }
11
+ export {
12
+ h as blobsToProofs
13
+ };
@@ -0,0 +1,14 @@
1
+ import { commitmentToVersionedHash as i } from "./index76.js";
2
+ function r(o) {
3
+ const { commitments: t, version: n } = o, e = o.to ?? (typeof t[0] == "string" ? "hex" : "bytes"), s = [];
4
+ for (const m of t)
5
+ s.push(i({
6
+ commitment: m,
7
+ to: e,
8
+ version: n
9
+ }));
10
+ return s;
11
+ }
12
+ export {
13
+ r as commitmentsToVersionedHashes
14
+ };
@@ -0,0 +1,16 @@
1
+ import { blobsToCommitments as f } from "./index59.js";
2
+ import { blobsToProofs as l } from "./index60.js";
3
+ import { toBlobs as p } from "./index75.js";
4
+ function k(t) {
5
+ const { data: i, kzg: n, to: m } = t, s = t.blobs ?? p({ data: i, to: m }), b = t.commitments ?? f({ blobs: s, kzg: n, to: m }), r = t.proofs ?? l({ blobs: s, commitments: b, kzg: n, to: m }), c = [];
6
+ for (let o = 0; o < s.length; o++)
7
+ c.push({
8
+ blob: s[o],
9
+ commitment: b[o],
10
+ proof: r[o]
11
+ });
12
+ return c;
13
+ }
14
+ export {
15
+ k as toBlobSidecars
16
+ };
@@ -0,0 +1,21 @@
1
+ import { InvalidAddressError as s } from "./index55.js";
2
+ import { InvalidStorageKeySizeError as l } from "./index51.js";
3
+ import { isAddress as f } from "./index29.js";
4
+ function a(r) {
5
+ if (!r || r.length === 0)
6
+ return [];
7
+ const n = [];
8
+ for (let o = 0; o < r.length; o++) {
9
+ const { address: i, storageKeys: e } = r[o];
10
+ for (let t = 0; t < e.length; t++)
11
+ if (e[t].length - 2 !== 64)
12
+ throw new l({ storageKey: e[t] });
13
+ if (!f(i, { strict: !1 }))
14
+ throw new s({ address: i });
15
+ n.push([i, e]);
16
+ }
17
+ return n;
18
+ }
19
+ export {
20
+ a as serializeAccessList
21
+ };
@@ -0,0 +1,8 @@
1
+ import { gweiUnits as i } from "./index65.js";
2
+ import { formatUnits as o } from "./index66.js";
3
+ function f(r, t = "wei") {
4
+ return o(r, i[t]);
5
+ }
6
+ export {
7
+ f as formatGwei
8
+ };
@@ -0,0 +1,7 @@
1
+ const e = {
2
+ ether: -9,
3
+ wei: 9
4
+ };
5
+ export {
6
+ e as gweiUnits
7
+ };
@@ -0,0 +1,13 @@
1
+ function a(r, n) {
2
+ let t = r.toString();
3
+ const i = t.startsWith("-");
4
+ i && (t = t.slice(1)), t = t.padStart(n, "0");
5
+ let [l, e] = [
6
+ t.slice(0, t.length - n),
7
+ t.slice(t.length - n)
8
+ ];
9
+ return e = e.replace(/(0+)$/, ""), `${i ? "-" : ""}${l || "0"}${e ? `.${e}` : ""}`;
10
+ }
11
+ export {
12
+ a as formatUnits
13
+ };
@@ -0,0 +1,19 @@
1
+ import { FlattenedSign as n } from "./index78.js";
2
+ class o {
3
+ #e;
4
+ constructor(e) {
5
+ this.#e = new n(e);
6
+ }
7
+ setProtectedHeader(e) {
8
+ return this.#e.setProtectedHeader(e), this;
9
+ }
10
+ async sign(e, r) {
11
+ const t = await this.#e.sign(e, r);
12
+ if (t.payload === void 0)
13
+ throw new TypeError("use the flattened module for creating JWS with b64: false");
14
+ return `${t.protected}.${t.payload}.${t.signature}`;
15
+ }
16
+ }
17
+ export {
18
+ o as CompactSign
19
+ };
@@ -0,0 +1,25 @@
1
+ class c extends Error {
2
+ static code = "ERR_JOSE_GENERIC";
3
+ code = "ERR_JOSE_GENERIC";
4
+ constructor(s, e) {
5
+ super(s, e), this.name = this.constructor.name, Error.captureStackTrace?.(this, this.constructor);
6
+ }
7
+ }
8
+ class E extends c {
9
+ static code = "ERR_JOSE_NOT_SUPPORTED";
10
+ code = "ERR_JOSE_NOT_SUPPORTED";
11
+ }
12
+ class o extends c {
13
+ static code = "ERR_JWS_INVALID";
14
+ code = "ERR_JWS_INVALID";
15
+ }
16
+ class r extends c {
17
+ static code = "ERR_JWT_INVALID";
18
+ code = "ERR_JWT_INVALID";
19
+ }
20
+ export {
21
+ c as JOSEError,
22
+ E as JOSENotSupported,
23
+ o as JWSInvalid,
24
+ r as JWTInvalid
25
+ };