@coinbase/cdp-core 0.0.11 → 0.0.13

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 (108) hide show
  1. package/README.md +24 -1
  2. package/dist/esm/index.js +19 -17
  3. package/dist/esm/index10.js +13 -115
  4. package/dist/esm/index100.js +11 -10
  5. package/dist/esm/index101.js +11 -15
  6. package/dist/esm/index102.js +9 -80
  7. package/dist/esm/index103.js +13 -75
  8. package/dist/esm/index104.js +83 -0
  9. package/dist/esm/index105.js +81 -0
  10. package/dist/esm/index11.js +117 -6
  11. package/dist/esm/index12.js +6 -16
  12. package/dist/esm/index13.js +16 -18
  13. package/dist/esm/index14.js +18 -172
  14. package/dist/esm/index15.js +170 -39
  15. package/dist/esm/index16.js +25 -16
  16. package/dist/esm/index17.js +40 -4
  17. package/dist/esm/index18.js +17 -5
  18. package/dist/esm/index19.js +4 -159
  19. package/dist/esm/index2.js +10 -10
  20. package/dist/esm/index20.js +5 -48
  21. package/dist/esm/index21.js +154 -140
  22. package/dist/esm/index22.js +47 -55
  23. package/dist/esm/index23.js +143 -6
  24. package/dist/esm/index24.js +56 -18
  25. package/dist/esm/index25.js +8 -45
  26. package/dist/esm/index26.js +17 -13
  27. package/dist/esm/index27.js +40 -50
  28. package/dist/esm/index28.js +13 -6
  29. package/dist/esm/index29.js +54 -20
  30. package/dist/esm/index3.js +4 -4
  31. package/dist/esm/index30.js +6 -11
  32. package/dist/esm/index31.js +21 -3
  33. package/dist/esm/index32.js +11 -3
  34. package/dist/esm/index33.js +3 -34
  35. package/dist/esm/index34.js +3 -12
  36. package/dist/esm/index35.js +34 -4
  37. package/dist/esm/index36.js +11 -27
  38. package/dist/esm/index37.js +4 -6
  39. package/dist/esm/index38.js +28 -24
  40. package/dist/esm/index39.js +6 -16
  41. package/dist/esm/index4.js +5 -4
  42. package/dist/esm/index40.js +22 -52
  43. package/dist/esm/index41.js +16 -23
  44. package/dist/esm/index42.js +53 -10
  45. package/dist/esm/index43.js +23 -27
  46. package/dist/esm/index44.js +9 -40
  47. package/dist/esm/index45.js +26 -54
  48. package/dist/esm/index46.js +42 -127
  49. package/dist/esm/index47.js +53 -10
  50. package/dist/esm/index48.js +125 -102
  51. package/dist/esm/index49.js +12 -6
  52. package/dist/esm/index5.js +92 -190
  53. package/dist/esm/index50.js +105 -3
  54. package/dist/esm/index51.js +6 -14
  55. package/dist/esm/index52.js +3 -43
  56. package/dist/esm/index53.js +14 -78
  57. package/dist/esm/index54.js +43 -2
  58. package/dist/esm/index55.js +79 -2
  59. package/dist/esm/index56.js +2 -13
  60. package/dist/esm/index57.js +2 -38
  61. package/dist/esm/index58.js +11 -5
  62. package/dist/esm/index59.js +32 -29
  63. package/dist/esm/index6.js +192 -12
  64. package/dist/esm/index60.js +6 -8
  65. package/dist/esm/index61.js +33 -9
  66. package/dist/esm/index62.js +8 -11
  67. package/dist/esm/index63.js +10 -13
  68. package/dist/esm/index64.js +11 -18
  69. package/dist/esm/index65.js +13 -5
  70. package/dist/esm/index66.js +19 -5
  71. package/dist/esm/index67.js +5 -10
  72. package/dist/esm/index68.js +5 -17
  73. package/dist/esm/index69.js +10 -22
  74. package/dist/esm/index7.js +12 -12
  75. package/dist/esm/index70.js +2 -51
  76. package/dist/esm/index71.js +21 -2
  77. package/dist/esm/index72.js +13 -17
  78. package/dist/esm/index73.js +21 -18
  79. package/dist/esm/index74.js +48 -77
  80. package/dist/esm/index75.js +18 -102
  81. package/dist/esm/index76.js +79 -32
  82. package/dist/esm/index77.js +103 -6
  83. package/dist/esm/index78.js +31 -53
  84. package/dist/esm/index79.js +6 -10
  85. package/dist/esm/index8.js +11 -20
  86. package/dist/esm/index80.js +79 -2
  87. package/dist/esm/index81.js +9 -44
  88. package/dist/esm/index82.js +54 -13
  89. package/dist/esm/index83.js +11 -10
  90. package/dist/esm/index84.js +2 -79
  91. package/dist/esm/index85.js +45 -5
  92. package/dist/esm/index86.js +13 -20
  93. package/dist/esm/index87.js +5 -10
  94. package/dist/esm/index88.js +11 -18
  95. package/dist/esm/index89.js +32 -90
  96. package/dist/esm/index9.js +20 -14
  97. package/dist/esm/index90.js +41 -20
  98. package/dist/esm/index91.js +20 -117
  99. package/dist/esm/index92.js +9 -12
  100. package/dist/esm/index93.js +17 -33
  101. package/dist/esm/index94.js +93 -41
  102. package/dist/esm/index95.js +21 -18
  103. package/dist/esm/index96.js +116 -26
  104. package/dist/esm/index97.js +18 -8
  105. package/dist/esm/index98.js +26 -9
  106. package/dist/esm/index99.js +8 -13
  107. package/dist/types/index.d.ts +4 -0
  108. package/package.json +2 -2
@@ -1,4 +1,81 @@
1
- const n = 2n ** 256n - 1n;
1
+ import { versionedHashVersionKzg as c } from "./index56.js";
2
+ import { maxUint256 as m } from "./index57.js";
3
+ import { InvalidAddressError as s } from "./index58.js";
4
+ import { BaseError as h } from "./index47.js";
5
+ import { EmptyBlobError as P, InvalidVersionedHashSizeError as p, InvalidVersionedHashVersionError as x } from "./index59.js";
6
+ import { InvalidChainIdError as n } from "./index60.js";
7
+ import { FeeCapTooHighError as w, TipAboveFeeCapError as E } from "./index61.js";
8
+ import { isAddress as f } from "./index32.js";
9
+ import { size as F } from "./index37.js";
10
+ import { slice as I } from "./index38.js";
11
+ import { hexToNumber as G } from "./index43.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
+ }
2
75
  export {
3
- n as maxUint256
76
+ d as assertTransactionEIP1559,
77
+ B as assertTransactionEIP2930,
78
+ L as assertTransactionEIP4844,
79
+ C as assertTransactionEIP7702,
80
+ K as assertTransactionLegacy
4
81
  };
@@ -1,15 +1,4 @@
1
- import { BaseError as r } from "./index45.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
- }
1
+ const e = 1;
13
2
  export {
14
- d as InvalidAddressError
3
+ e as versionedHashVersionKzg
15
4
  };
@@ -1,40 +1,4 @@
1
- import { versionedHashVersionKzg as a } from "./index54.js";
2
- import { BaseError as s } from "./index45.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
- }
1
+ const n = 2n ** 256n - 1n;
35
2
  export {
36
- t as BlobSizeTooLargeError,
37
- d as EmptyBlobError,
38
- l as InvalidVersionedHashSizeError,
39
- c as InvalidVersionedHashVersionError
3
+ n as maxUint256
40
4
  };
@@ -1,9 +1,15 @@
1
- import { BaseError as i } from "./index45.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" });
1
+ import { BaseError as r } from "./index47.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
+ });
5
11
  }
6
12
  }
7
13
  export {
8
- o as InvalidChainIdError
14
+ d as InvalidAddressError
9
15
  };
@@ -1,37 +1,40 @@
1
- import { formatGwei as a } from "./index65.js";
2
- import { BaseError as o } from "./index45.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"
1
+ import { versionedHashVersionKzg as a } from "./index56.js";
2
+ import { BaseError as s } from "./index47.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
8
  });
9
9
  }
10
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"
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"
25
32
  });
26
33
  }
27
34
  }
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
35
  export {
35
- n as FeeCapTooHighError,
36
- h as TipAboveFeeCapError
36
+ t as BlobSizeTooLargeError,
37
+ d as EmptyBlobError,
38
+ l as InvalidVersionedHashSizeError,
39
+ c as InvalidVersionedHashVersionError
37
40
  };
@@ -1,14 +1,194 @@
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
- };
1
+ import { logOutEndUser as c, refreshAccessToken as o, registerTemporaryWalletSecret as u } from "@coinbase/cdp-api-client";
2
+ import { SignJWT as S } from "./index17.js";
3
+ import { toAuthState as w } from "./index7.js";
4
+ import { createKeyPair as f } from "./index18.js";
5
+ import { generateRandomId as n } from "./index19.js";
6
+ import { hash as d } from "./index20.js";
7
+ import { sortKeys as y } from "./index13.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
+ }
12
192
  export {
13
- u as toAuthState
193
+ E as AuthManager
14
194
  };
@@ -1,11 +1,9 @@
1
- import { hexToBytes as i } from "./index27.js";
2
- import { bytesToHex as f } from "./index25.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));
1
+ import { BaseError as i } from "./index47.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
+ }
8
6
  }
9
7
  export {
10
- y as blobsToCommitments
8
+ o as InvalidChainIdError
11
9
  };
@@ -1,13 +1,37 @@
1
- import { hexToBytes as b } from "./index27.js";
2
- import { bytesToHex as y } from "./index25.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)));
1
+ import { formatGwei as a } from "./index67.js";
2
+ import { BaseError as o } from "./index47.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
+ });
8
9
  }
9
- return c === "bytes" ? n : n.map((o) => y(o));
10
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
+ });
11
34
  export {
12
- h as blobsToProofs
35
+ n as FeeCapTooHighError,
36
+ h as TipAboveFeeCapError
13
37
  };
@@ -1,14 +1,11 @@
1
- import { commitmentToVersionedHash as i } from "./index77.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;
1
+ import { hexToBytes as i } from "./index29.js";
2
+ import { bytesToHex as f } from "./index27.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));
11
8
  }
12
9
  export {
13
- r as commitmentsToVersionedHashes
10
+ y as blobsToCommitments
14
11
  };
@@ -1,16 +1,13 @@
1
- import { blobsToCommitments as f } from "./index60.js";
2
- import { blobsToProofs as l } from "./index61.js";
3
- import { toBlobs as p } from "./index76.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;
1
+ import { hexToBytes as b } from "./index29.js";
2
+ import { bytesToHex as y } from "./index27.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));
13
10
  }
14
11
  export {
15
- k as toBlobSidecars
12
+ h as blobsToProofs
16
13
  };
@@ -1,21 +1,14 @@
1
- import { InvalidAddressError as s } from "./index56.js";
2
- import { InvalidStorageKeySizeError as l } from "./index52.js";
3
- import { isAddress as f } from "./index30.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;
1
+ import { commitmentToVersionedHash as i } from "./index79.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;
18
11
  }
19
12
  export {
20
- a as serializeAccessList
13
+ r as commitmentsToVersionedHashes
21
14
  };
@@ -1,8 +1,16 @@
1
- import { gweiUnits as i } from "./index66.js";
2
- import { formatUnits as o } from "./index67.js";
3
- function f(r, t = "wei") {
4
- return o(r, i[t]);
1
+ import { blobsToCommitments as f } from "./index62.js";
2
+ import { blobsToProofs as l } from "./index63.js";
3
+ import { toBlobs as p } from "./index78.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;
5
13
  }
6
14
  export {
7
- f as formatGwei
15
+ k as toBlobSidecars
8
16
  };
@@ -1,7 +1,21 @@
1
- const e = {
2
- ether: -9,
3
- wei: 9
4
- };
1
+ import { InvalidAddressError as s } from "./index58.js";
2
+ import { InvalidStorageKeySizeError as l } from "./index54.js";
3
+ import { isAddress as f } from "./index32.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
+ }
5
19
  export {
6
- e as gweiUnits
20
+ a as serializeAccessList
7
21
  };
@@ -1,13 +1,8 @@
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}` : ""}`;
1
+ import { gweiUnits as i } from "./index68.js";
2
+ import { formatUnits as o } from "./index69.js";
3
+ function f(r, t = "wei") {
4
+ return o(r, i[t]);
10
5
  }
11
6
  export {
12
- a as formatUnits
7
+ f as formatGwei
13
8
  };