@coinbase/cdp-core 0.0.32 → 0.0.33

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 (274) hide show
  1. package/dist/esm/index.native.js +40 -38
  2. package/dist/esm/index.native10.js +115 -21
  3. package/dist/esm/index.native100.js +6 -9
  4. package/dist/esm/index.native101.js +11 -13
  5. package/dist/esm/index.native102.js +11 -8
  6. package/dist/esm/index.native103.js +7 -14
  7. package/dist/esm/index.native104.js +16 -80
  8. package/dist/esm/index.native105.js +79 -11
  9. package/dist/esm/index.native106.js +12 -35
  10. package/dist/esm/index.native107.js +35 -41
  11. package/dist/esm/index.native108.js +38 -75
  12. package/dist/esm/index.native109.js +81 -0
  13. package/dist/esm/index.native11.js +20 -30
  14. package/dist/esm/index.native12.js +30 -7
  15. package/dist/esm/index.native13.js +9 -15
  16. package/dist/esm/index.native14.js +14 -15
  17. package/dist/esm/index.native15.js +13 -116
  18. package/dist/esm/index.native16.js +116 -11
  19. package/dist/esm/index.native17.js +14 -42
  20. package/dist/esm/index.native18.js +42 -20
  21. package/dist/esm/index.native19.js +20 -172
  22. package/dist/esm/index.native2.js +3 -3
  23. package/dist/esm/index.native20.js +170 -39
  24. package/dist/esm/index.native21.js +41 -49
  25. package/dist/esm/index.native22.js +47 -70
  26. package/dist/esm/index.native23.js +69 -23
  27. package/dist/esm/index.native24.js +22 -156
  28. package/dist/esm/index.native25.js +157 -45
  29. package/dist/esm/index.native26.js +43 -245
  30. package/dist/esm/index.native27.js +247 -53
  31. package/dist/esm/index.native28.js +56 -17
  32. package/dist/esm/index.native29.js +15 -21
  33. package/dist/esm/index.native3.js +40 -30
  34. package/dist/esm/index.native30.js +21 -49
  35. package/dist/esm/index.native31.js +50 -8
  36. package/dist/esm/index.native32.js +8 -17
  37. package/dist/esm/index.native33.js +16 -44
  38. package/dist/esm/index.native34.js +45 -13
  39. package/dist/esm/index.native35.js +13 -55
  40. package/dist/esm/index.native36.js +55 -6
  41. package/dist/esm/index.native37.js +6 -21
  42. package/dist/esm/index.native38.js +21 -11
  43. package/dist/esm/index.native39.js +11 -3
  44. package/dist/esm/index.native4.js +67 -21
  45. package/dist/esm/index.native40.js +3 -3
  46. package/dist/esm/index.native41.js +3 -34
  47. package/dist/esm/index.native42.js +32 -10
  48. package/dist/esm/index.native43.js +12 -4
  49. package/dist/esm/index.native44.js +4 -28
  50. package/dist/esm/index.native45.js +28 -6
  51. package/dist/esm/index.native46.js +6 -24
  52. package/dist/esm/index.native47.js +24 -16
  53. package/dist/esm/index.native48.js +16 -54
  54. package/dist/esm/index.native49.js +53 -22
  55. package/dist/esm/index.native5.js +21 -254
  56. package/dist/esm/index.native50.js +23 -11
  57. package/dist/esm/index.native51.js +10 -26
  58. package/dist/esm/index.native52.js +26 -41
  59. package/dist/esm/index.native53.js +41 -54
  60. package/dist/esm/index.native54.js +54 -126
  61. package/dist/esm/index.native55.js +126 -11
  62. package/dist/esm/index.native56.js +9 -101
  63. package/dist/esm/index.native57.js +104 -6
  64. package/dist/esm/index.native58.js +7 -3
  65. package/dist/esm/index.native59.js +3 -15
  66. package/dist/esm/index.native6.js +262 -176
  67. package/dist/esm/index.native60.js +14 -42
  68. package/dist/esm/index.native61.js +38 -74
  69. package/dist/esm/index.native62.js +79 -2
  70. package/dist/esm/index.native63.js +2 -2
  71. package/dist/esm/index.native64.js +2 -13
  72. package/dist/esm/index.native65.js +8 -33
  73. package/dist/esm/index.native66.js +36 -5
  74. package/dist/esm/index.native67.js +5 -33
  75. package/dist/esm/index.native68.js +34 -8
  76. package/dist/esm/index.native69.js +8 -10
  77. package/dist/esm/index.native7.js +213 -115
  78. package/dist/esm/index.native70.js +10 -11
  79. package/dist/esm/index.native71.js +11 -13
  80. package/dist/esm/index.native72.js +13 -18
  81. package/dist/esm/index.native73.js +18 -5
  82. package/dist/esm/index.native74.js +6 -5
  83. package/dist/esm/index.native75.js +5 -11
  84. package/dist/esm/index.native76.js +10 -54
  85. package/dist/esm/index.native77.js +54 -10
  86. package/dist/esm/index.native78.js +11 -2
  87. package/dist/esm/index.native79.js +2 -45
  88. package/dist/esm/index.native8.js +115 -137
  89. package/dist/esm/index.native80.js +44 -13
  90. package/dist/esm/index.native81.js +14 -2
  91. package/dist/esm/index.native82.js +1 -1
  92. package/dist/esm/index.native83.js +2 -20
  93. package/dist/esm/index.native84.js +103 -79
  94. package/dist/esm/index.native85.js +18 -102
  95. package/dist/esm/index.native86.js +79 -32
  96. package/dist/esm/index.native87.js +32 -6
  97. package/dist/esm/index.native88.js +6 -78
  98. package/dist/esm/index.native89.js +2 -2
  99. package/dist/esm/index.native9.js +138 -113
  100. package/dist/esm/index.native90.js +3 -3
  101. package/dist/esm/index.native92.js +3 -3
  102. package/dist/esm/index.native93.js +1 -1
  103. package/dist/esm/index.native94.js +3 -3
  104. package/dist/esm/index.native95.js +79 -10
  105. package/dist/esm/index.native96.js +10 -5
  106. package/dist/esm/index.native97.js +5 -18
  107. package/dist/esm/index.native98.js +18 -28
  108. package/dist/esm/index.native99.js +26 -6
  109. package/dist/esm/index.web100.js +13 -28
  110. package/dist/esm/index.web101.js +10 -8
  111. package/dist/esm/index.web102.js +17 -11
  112. package/dist/esm/index.web103.js +80 -12
  113. package/dist/esm/index.web104.js +13 -10
  114. package/dist/esm/index.web105.js +36 -17
  115. package/dist/esm/index.web106.js +40 -79
  116. package/dist/esm/index.web26.js +1 -1
  117. package/dist/esm/index.web5.js +131 -109
  118. package/dist/esm/index.web6.js +65 -38
  119. package/dist/esm/index.web75.js +6 -6
  120. package/dist/esm/index.web84.js +1 -1
  121. package/dist/esm/index.web87.js +21 -10
  122. package/dist/esm/index.web88.js +10 -79
  123. package/dist/esm/index.web89.js +19 -20
  124. package/dist/esm/index.web90.js +93 -9
  125. package/dist/esm/index.web91.js +19 -18
  126. package/dist/esm/index.web92.js +105 -81
  127. package/dist/esm/index.web93.js +78 -20
  128. package/dist/esm/index.web94.js +9 -117
  129. package/dist/esm/index.web96.js +18 -13
  130. package/dist/esm/index.web97.js +27 -35
  131. package/dist/esm/index.web98.js +7 -41
  132. package/dist/esm/index.web99.js +11 -18
  133. package/dist/native/index.native.js +40 -38
  134. package/dist/native/index.native10.js +115 -21
  135. package/dist/native/index.native100.js +6 -9
  136. package/dist/native/index.native101.js +11 -13
  137. package/dist/native/index.native102.js +11 -8
  138. package/dist/native/index.native103.js +7 -14
  139. package/dist/native/index.native104.js +16 -80
  140. package/dist/native/index.native105.js +79 -11
  141. package/dist/native/index.native106.js +12 -35
  142. package/dist/native/index.native107.js +35 -41
  143. package/dist/native/index.native108.js +38 -75
  144. package/dist/native/index.native109.js +81 -0
  145. package/dist/native/index.native11.js +20 -30
  146. package/dist/native/index.native12.js +30 -7
  147. package/dist/native/index.native13.js +9 -15
  148. package/dist/native/index.native14.js +14 -15
  149. package/dist/native/index.native15.js +13 -116
  150. package/dist/native/index.native16.js +116 -11
  151. package/dist/native/index.native17.js +14 -42
  152. package/dist/native/index.native18.js +42 -20
  153. package/dist/native/index.native19.js +20 -172
  154. package/dist/native/index.native2.js +3 -3
  155. package/dist/native/index.native20.js +170 -39
  156. package/dist/native/index.native21.js +41 -49
  157. package/dist/native/index.native22.js +47 -70
  158. package/dist/native/index.native23.js +69 -23
  159. package/dist/native/index.native24.js +22 -156
  160. package/dist/native/index.native25.js +157 -45
  161. package/dist/native/index.native26.js +43 -245
  162. package/dist/native/index.native27.js +247 -53
  163. package/dist/native/index.native28.js +56 -17
  164. package/dist/native/index.native29.js +15 -21
  165. package/dist/native/index.native3.js +40 -30
  166. package/dist/native/index.native30.js +21 -49
  167. package/dist/native/index.native31.js +50 -8
  168. package/dist/native/index.native32.js +8 -17
  169. package/dist/native/index.native33.js +16 -44
  170. package/dist/native/index.native34.js +45 -13
  171. package/dist/native/index.native35.js +13 -55
  172. package/dist/native/index.native36.js +55 -6
  173. package/dist/native/index.native37.js +6 -21
  174. package/dist/native/index.native38.js +21 -11
  175. package/dist/native/index.native39.js +11 -3
  176. package/dist/native/index.native4.js +67 -21
  177. package/dist/native/index.native40.js +3 -3
  178. package/dist/native/index.native41.js +3 -34
  179. package/dist/native/index.native42.js +32 -10
  180. package/dist/native/index.native43.js +12 -4
  181. package/dist/native/index.native44.js +4 -28
  182. package/dist/native/index.native45.js +28 -6
  183. package/dist/native/index.native46.js +6 -24
  184. package/dist/native/index.native47.js +24 -16
  185. package/dist/native/index.native48.js +16 -54
  186. package/dist/native/index.native49.js +53 -22
  187. package/dist/native/index.native5.js +21 -254
  188. package/dist/native/index.native50.js +23 -11
  189. package/dist/native/index.native51.js +10 -26
  190. package/dist/native/index.native52.js +26 -41
  191. package/dist/native/index.native53.js +41 -54
  192. package/dist/native/index.native54.js +54 -126
  193. package/dist/native/index.native55.js +126 -11
  194. package/dist/native/index.native56.js +9 -101
  195. package/dist/native/index.native57.js +104 -6
  196. package/dist/native/index.native58.js +7 -3
  197. package/dist/native/index.native59.js +3 -15
  198. package/dist/native/index.native6.js +262 -176
  199. package/dist/native/index.native60.js +14 -42
  200. package/dist/native/index.native61.js +38 -74
  201. package/dist/native/index.native62.js +79 -2
  202. package/dist/native/index.native63.js +2 -2
  203. package/dist/native/index.native64.js +2 -13
  204. package/dist/native/index.native65.js +8 -33
  205. package/dist/native/index.native66.js +36 -5
  206. package/dist/native/index.native67.js +5 -33
  207. package/dist/native/index.native68.js +34 -8
  208. package/dist/native/index.native69.js +8 -10
  209. package/dist/native/index.native7.js +213 -115
  210. package/dist/native/index.native70.js +10 -11
  211. package/dist/native/index.native71.js +11 -13
  212. package/dist/native/index.native72.js +13 -18
  213. package/dist/native/index.native73.js +18 -5
  214. package/dist/native/index.native74.js +6 -5
  215. package/dist/native/index.native75.js +5 -11
  216. package/dist/native/index.native76.js +10 -54
  217. package/dist/native/index.native77.js +54 -10
  218. package/dist/native/index.native78.js +11 -2
  219. package/dist/native/index.native79.js +2 -45
  220. package/dist/native/index.native8.js +115 -137
  221. package/dist/native/index.native80.js +44 -13
  222. package/dist/native/index.native81.js +14 -2
  223. package/dist/native/index.native82.js +1 -1
  224. package/dist/native/index.native83.js +2 -20
  225. package/dist/native/index.native84.js +103 -79
  226. package/dist/native/index.native85.js +18 -102
  227. package/dist/native/index.native86.js +79 -32
  228. package/dist/native/index.native87.js +32 -6
  229. package/dist/native/index.native88.js +6 -78
  230. package/dist/native/index.native89.js +2 -2
  231. package/dist/native/index.native9.js +138 -113
  232. package/dist/native/index.native90.js +3 -3
  233. package/dist/native/index.native92.js +3 -3
  234. package/dist/native/index.native93.js +1 -1
  235. package/dist/native/index.native94.js +3 -3
  236. package/dist/native/index.native95.js +79 -10
  237. package/dist/native/index.native96.js +10 -5
  238. package/dist/native/index.native97.js +5 -18
  239. package/dist/native/index.native98.js +18 -28
  240. package/dist/native/index.native99.js +26 -6
  241. package/dist/native-types/auth/authManager.d.ts +3 -0
  242. package/dist/native-types/platform/native/secureStorage.d.ts +2 -0
  243. package/dist/native-types/platform/types.d.ts +7 -0
  244. package/dist/types/auth/authManager.d.ts +3 -0
  245. package/dist/types/platform/native/secureStorage.d.ts +2 -0
  246. package/dist/types/platform/types.d.ts +7 -0
  247. package/dist/web/index.web100.js +13 -28
  248. package/dist/web/index.web101.js +10 -8
  249. package/dist/web/index.web102.js +17 -11
  250. package/dist/web/index.web103.js +80 -12
  251. package/dist/web/index.web104.js +13 -10
  252. package/dist/web/index.web105.js +36 -17
  253. package/dist/web/index.web106.js +40 -79
  254. package/dist/web/index.web26.js +1 -1
  255. package/dist/web/index.web5.js +131 -109
  256. package/dist/web/index.web6.js +65 -38
  257. package/dist/web/index.web75.js +6 -6
  258. package/dist/web/index.web84.js +1 -1
  259. package/dist/web/index.web87.js +21 -10
  260. package/dist/web/index.web88.js +10 -79
  261. package/dist/web/index.web89.js +19 -20
  262. package/dist/web/index.web90.js +93 -9
  263. package/dist/web/index.web91.js +19 -18
  264. package/dist/web/index.web92.js +105 -81
  265. package/dist/web/index.web93.js +78 -20
  266. package/dist/web/index.web94.js +9 -117
  267. package/dist/web/index.web96.js +18 -13
  268. package/dist/web/index.web97.js +27 -35
  269. package/dist/web/index.web98.js +7 -41
  270. package/dist/web/index.web99.js +11 -18
  271. package/dist/web-types/auth/authManager.d.ts +3 -0
  272. package/dist/web-types/platform/native/secureStorage.d.ts +2 -0
  273. package/dist/web-types/platform/types.d.ts +7 -0
  274. package/package.json +8 -4
@@ -1,4 +1,81 @@
1
- const e = 1;
1
+ import { versionedHashVersionKzg as c } from "./index.native63.js";
2
+ import { maxUint256 as m } from "./index.native64.js";
3
+ import { InvalidAddressError as s } from "./index.native65.js";
4
+ import { BaseError as h } from "./index.native54.js";
5
+ import { EmptyBlobError as P, InvalidVersionedHashSizeError as p, InvalidVersionedHashVersionError as x } from "./index.native66.js";
6
+ import { InvalidChainIdError as n } from "./index.native67.js";
7
+ import { FeeCapTooHighError as w, TipAboveFeeCapError as E } from "./index.native68.js";
8
+ import { isAddress as f } from "./index.native39.js";
9
+ import { size as F } from "./index.native44.js";
10
+ import { slice as I } from "./index.native45.js";
11
+ import { hexToNumber as G } from "./index.native50.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
- e as versionedHashVersionKzg
76
+ d as assertTransactionEIP1559,
77
+ B as assertTransactionEIP2930,
78
+ L as assertTransactionEIP4844,
79
+ C as assertTransactionEIP7702,
80
+ K as assertTransactionLegacy
4
81
  };
@@ -1,4 +1,4 @@
1
- const n = 2n ** 256n - 1n;
1
+ const e = 1;
2
2
  export {
3
- n as maxUint256
3
+ e as versionedHashVersionKzg
4
4
  };
@@ -1,15 +1,4 @@
1
- import { BaseError as r } from "./index.native53.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 n = 2n ** 256n - 1n;
13
2
  export {
14
- d as InvalidAddressError
3
+ n as maxUint256
15
4
  };
@@ -1,40 +1,15 @@
1
- import { versionedHashVersionKzg as a } from "./index.native62.js";
2
- import { BaseError as s } from "./index.native53.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.`, {
1
+ import { BaseError as r } from "./index.native54.js";
2
+ class d extends r {
3
+ constructor({ address: s }) {
4
+ super(`Address "${s}" is invalid.`, {
27
5
  metaMessages: [
28
- `Expected: ${a}`,
29
- `Received: ${r}`
6
+ "- Address must be a hex value of 20 bytes (40 hex characters).",
7
+ "- Address must match its checksum counterpart."
30
8
  ],
31
- name: "InvalidVersionedHashVersionError"
9
+ name: "InvalidAddressError"
32
10
  });
33
11
  }
34
12
  }
35
13
  export {
36
- t as BlobSizeTooLargeError,
37
- d as EmptyBlobError,
38
- l as InvalidVersionedHashSizeError,
39
- c as InvalidVersionedHashVersionError
14
+ d as InvalidAddressError
40
15
  };
@@ -1,9 +1,40 @@
1
- import { BaseError as i } from "./index.native53.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 { versionedHashVersionKzg as a } from "./index.native63.js";
2
+ import { BaseError as s } from "./index.native54.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
+ });
5
33
  }
6
34
  }
7
35
  export {
8
- o as InvalidChainIdError
36
+ t as BlobSizeTooLargeError,
37
+ d as EmptyBlobError,
38
+ l as InvalidVersionedHashSizeError,
39
+ c as InvalidVersionedHashVersionError
9
40
  };
@@ -1,37 +1,9 @@
1
- import { formatGwei as a } from "./index.native73.js";
2
- import { BaseError as o } from "./index.native53.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
- });
1
+ import { BaseError as i } from "./index.native54.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" });
9
5
  }
10
6
  }
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
7
  export {
35
- n as FeeCapTooHighError,
36
- h as TipAboveFeeCapError
8
+ o as InvalidChainIdError
37
9
  };
@@ -1,11 +1,37 @@
1
- import { hexToBytes as i } from "./index.native35.js";
2
- import { bytesToHex as f } from "./index.native33.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 { formatGwei as a } from "./index.native74.js";
2
+ import { BaseError as o } from "./index.native54.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
+ }
8
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
+ });
9
34
  export {
10
- y as blobsToCommitments
35
+ n as FeeCapTooHighError,
36
+ h as TipAboveFeeCapError
11
37
  };
@@ -1,13 +1,11 @@
1
- import { hexToBytes as b } from "./index.native35.js";
2
- import { bytesToHex as y } from "./index.native33.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));
1
+ import { hexToBytes as i } from "./index.native36.js";
2
+ import { bytesToHex as f } from "./index.native34.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));
10
8
  }
11
9
  export {
12
- h as blobsToProofs
10
+ y as blobsToCommitments
13
11
  };
@@ -1,121 +1,219 @@
1
- import { Provider as h } from "ox";
2
- import { http as m } from "viem";
3
- import { create as p } from "zustand";
4
- import { subscribeWithSelector as g, persist as f } from "./index.native24.js";
5
- import { validateRequest as I, EIP1193ProviderError as S, STANDARD_ERROR_CODES as w } from "./index.native8.js";
6
- import { EventEmitter as C } from "./index.native25.js";
7
- import { getPlatformStorage as b } from "./index.native4.js";
8
- import "@coinbase/cdp-api-client";
9
- import { handleGetCapabilities as _, handleGetCallsStatus as A, handleSendCalls as v, handleChainId as D, handleSignTypedData as P, handleEthSign as E, handleSwitchEthereumChain as R, handleDisconnect as y, handleSendTransaction as T, handlePersonalSign as q, handleRequestAccounts as G, handleAccounts as L } from "./index.native26.js";
10
- import { onAuthStateChange as M } from "./index.native5.js";
11
- import { baseSepolia as l } from "./index.native27.js";
12
- function N(r, n, s) {
13
- n.subscribe(
14
- (e) => e.chainId,
15
- (e, t) => {
16
- e !== t && r.emit("chainChanged", e);
1
+ import { logOutEndUser as l, refreshAccessToken as c, registerTemporaryWalletSecret as o } from "@coinbase/cdp-api-client";
2
+ import { SignJWT as u } from "./index.native21.js";
3
+ import "viem";
4
+ import { toAuthState as f } from "./index.native14.js";
5
+ import { getPlatformCrypto as n } from "./index.native5.js";
6
+ import { sortKeys as S } from "./index.native18.js";
7
+ const i = 60 * 1e3;
8
+ class p {
9
+ projectId;
10
+ authState = null;
11
+ walletSecret = null;
12
+ authStateChangeCallbacks = [];
13
+ initPromise = null;
14
+ refreshTimeout = null;
15
+ /**
16
+ * Initializes the token manager.
17
+ *
18
+ * @param projectId - The project ID.
19
+ */
20
+ constructor(e) {
21
+ this.projectId = e, 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. Attempts to refresh the token if it's expired.
34
+ *
35
+ * @returns True if the user is signed in, false otherwise.
36
+ */
37
+ async isSignedIn() {
38
+ if (!this.authState)
39
+ return !1;
40
+ if (this.authState.expiresAt > Date.now() + i)
41
+ return !0;
42
+ try {
43
+ return await this.getToken() !== null;
44
+ } catch {
45
+ return !1;
17
46
  }
18
- ), n.subscribe(
19
- (e) => e.user,
20
- (e, t) => {
21
- if (!(e?.userId === t?.userId && e?.evmAccounts?.length === t?.evmAccounts?.length)) {
22
- if (!e && t) {
23
- r.emit("disconnect", new h.DisconnectedError());
24
- return;
25
- }
26
- if (e && e.evmAccounts?.length && (!t || t.evmAccounts?.length === 0)) {
27
- const a = n.getState().chainId;
28
- r.emit("connect", { chainId: a });
29
- return;
30
- }
31
- }
47
+ }
48
+ /**
49
+ * Signs out the user, clearing all authentication state.
50
+ */
51
+ async signOut() {
52
+ try {
53
+ await l(this.projectId);
54
+ } catch {
55
+ } finally {
56
+ await this.clearAuthState();
32
57
  }
33
- );
34
- const { chainId: i, setChainId: o } = n.getState(), d = i || s.chains[0].id;
35
- return i || o(d), h.from({
36
- request: async (e) => {
37
- I(e, s);
38
- const t = e;
39
- switch (t.method) {
40
- case "eth_accounts":
41
- return L();
42
- case "eth_requestAccounts":
43
- return G(r, n);
44
- case "personal_sign":
45
- return q(t.params);
46
- case "eth_sendTransaction":
47
- return T(t.params, n, s.transports);
48
- case "wallet_disconnect":
49
- return y();
50
- case "wallet_switchEthereumChain":
51
- return R(t.params, n);
52
- case "eth_sign":
53
- return E(t.params);
54
- case "eth_signTypedData_v4":
55
- return P(t.params);
56
- case "eth_chainId":
57
- return D(n);
58
- case "wallet_sendCalls":
59
- return v(t.params, n);
60
- case "wallet_getCallsStatus":
61
- return A(t.params, n);
62
- case "wallet_getCapabilities":
63
- return _();
64
- // Catch-all for any unknown method
65
- default:
66
- throw new S(
67
- w.provider.unsupportedMethod,
68
- `Method ${t.method} not supported`
69
- );
70
- }
71
- },
72
- // Event emitter methods - only the ones required by the interface
73
- on: r.on.bind(r),
74
- removeListener: r.removeListener.bind(r)
75
- });
76
- }
77
- const u = {
78
- chains: [l],
79
- transports: {
80
- [l.id]: m()
81
58
  }
82
- };
83
- function K(r) {
84
- if (r?.chains.length === 0)
85
- throw new Error("At least one chain must be configured");
86
- const n = r?.chains ?? u.chains, s = r?.transports ?? u.transports;
87
- if (n.length === 0)
88
- throw new Error("No chains found in configuration");
89
- const i = new C(), o = b(), d = {
90
- getItem: (t) => o.getItem(t),
91
- setItem: (t, a) => o.setItem(t, a),
92
- removeItem: (t) => o.removeItem(t)
93
- }, c = p()(
94
- g(
95
- f(
96
- (t) => ({
97
- chainId: n[0].id,
98
- setChainId: (a) => t({ chainId: a }),
99
- chains: n,
100
- user: null,
101
- setUser: (a) => t({ user: a })
102
- }),
103
- {
104
- name: "cdp-provider-store",
105
- storage: d
106
- }
107
- )
108
- )
109
- );
110
- return c.persist.rehydrate(), M((t) => {
111
- c.getState().setUser(t);
112
- }), {
113
- provider: N(i, c, {
114
- chains: n,
115
- transports: s
116
- })
117
- };
59
+ /**
60
+ * Adds a callback to be called when the auth state changes.
61
+ *
62
+ * @param callback - The function to call when the auth state changes.
63
+ */
64
+ addAuthStateChangeCallback(e) {
65
+ this.authStateChangeCallbacks.push(e), e(this.authState?.user ?? null);
66
+ }
67
+ /**
68
+ * Gets the access token, refreshing it if it is expired. Returns null if the user is not
69
+ * signed in.
70
+ *
71
+ * @returns The access token.
72
+ */
73
+ async getToken() {
74
+ return this.shouldRefreshToken() && await this.refreshAccessToken(), this.authState?.accessToken ?? null;
75
+ }
76
+ /**
77
+ * Gets the currently registered wallet secret ID. Rejects if the user is not signed in.
78
+ *
79
+ * @returns The wallet secret ID.
80
+ */
81
+ async getWalletSecretId() {
82
+ if (!await this.isSignedIn())
83
+ throw new Error("Cannot get wallet secret ID if the user is not signed in");
84
+ return this.shouldRefreshWalletSecret() && await this.refreshWalletSecret(), this.walletSecret.walletSecretId;
85
+ }
86
+ /**
87
+ * Gets the X-Wallet-Auth header. Rejects if the user is not signed in.
88
+ *
89
+ * @param options - The options for the request.
90
+ * @param options.requestMethod - The HTTP method of the request.
91
+ * @param options.requestHost - The host of the request.
92
+ * @param options.requestPath - The path of the request.
93
+ * @param options.requestData - The data of the request.
94
+ * @returns The X-Wallet-Auth header.
95
+ */
96
+ async getXWalletAuth(e) {
97
+ if (!await this.isSignedIn())
98
+ throw new Error("Cannot get X-Wallet-Auth header if the user is not signed in");
99
+ this.shouldRefreshWalletSecret() && await this.refreshWalletSecret();
100
+ const t = `${e.requestMethod} ${e.requestHost}${e.requestPath}`, r = Math.floor(Date.now() / 1e3), s = n(), a = {
101
+ uris: [t]
102
+ };
103
+ if (e.requestData && Object.keys(e.requestData).length > 0) {
104
+ const h = S(e.requestData);
105
+ a.reqHash = await s.hash(new TextEncoder().encode(JSON.stringify(h)));
106
+ }
107
+ return await new u(a).setProtectedHeader({ alg: "ES256", typ: "JWT" }).setIssuedAt(r).setNotBefore(r).setJti(s.generateRandomId()).sign(this.walletSecret.keyPair.privateKey);
108
+ }
109
+ /**
110
+ * Sets the authentication state.
111
+ *
112
+ * @param authState - The authentication state.
113
+ */
114
+ async setAuthState(e) {
115
+ this.authState = e, this.authStateChangeCallbacks.forEach((t) => t(this.authState?.user ?? null)), this.scheduleTokenRefresh();
116
+ }
117
+ /**
118
+ * Clears the authentication state.
119
+ */
120
+ async clearAuthState() {
121
+ this.authState = null, this.walletSecret = null, this.cancelTokenRefresh(), this.authStateChangeCallbacks.forEach((e) => e(null));
122
+ }
123
+ /**
124
+ * Ensures the AuthManager is initialized before proceeding.
125
+ * If initialization is already in progress, waits for it to complete.
126
+ */
127
+ async ensureInitialized() {
128
+ if (this.initPromise) {
129
+ await this.initPromise;
130
+ return;
131
+ }
132
+ throw new Error("AuthManager not initialized");
133
+ }
134
+ /**
135
+ * Internal async initialization logic.
136
+ */
137
+ async _doInitialize() {
138
+ try {
139
+ await this.refreshAccessToken();
140
+ } catch (e) {
141
+ console.warn("Failed to refresh access token during initialization:", e);
142
+ }
143
+ }
144
+ /**
145
+ * Returns whether the token should be refreshed.
146
+ *
147
+ * @returns True if the token should be refreshed, false otherwise.
148
+ */
149
+ shouldRefreshToken() {
150
+ return !(this.authState && this.authState.expiresAt > Date.now() + i);
151
+ }
152
+ /**
153
+ * Refreshes the access token and transitions the auth state accordingly.
154
+ * If a refresh is already in progress, it will wait for that refresh to complete.
155
+ *
156
+ * @returns The new access token.
157
+ */
158
+ async refreshAccessToken() {
159
+ try {
160
+ const e = await c(this.projectId, {
161
+ grantType: "refresh_token"
162
+ }), t = f(
163
+ e.accessToken,
164
+ e.validUntil,
165
+ e.endUser
166
+ );
167
+ await this.setAuthState(t);
168
+ } catch {
169
+ await this.signOut();
170
+ }
171
+ }
172
+ /**
173
+ * Returns whether the wallet secret should be refreshed.
174
+ *
175
+ * @returns True if the wallet secret should be refreshed, false otherwise.
176
+ */
177
+ shouldRefreshWalletSecret() {
178
+ return !(this.walletSecret && this.walletSecret.expiresAt > Date.now() + i);
179
+ }
180
+ /**
181
+ * Refreshes the wallet secret. Assumes the user is signed in.
182
+ *
183
+ * @returns The wallet secret.
184
+ */
185
+ async refreshWalletSecret() {
186
+ const e = n(), t = this.walletSecret?.walletSecretId ?? e.generateRandomId(), r = this.walletSecret?.keyPair ?? await e.createKeyPair(), s = this.authState.expiresAt, a = new Date(s).toISOString();
187
+ this.walletSecret = { walletSecretId: t, keyPair: r, expiresAt: s };
188
+ try {
189
+ await o(this.projectId, this.authState.user.userId, {
190
+ walletSecretId: t,
191
+ publicKey: r.publicKeyBase64,
192
+ validUntil: a
193
+ });
194
+ } catch (h) {
195
+ throw this.walletSecret = null, h;
196
+ }
197
+ }
198
+ /**
199
+ * Schedules a token refresh to occur exactly when shouldRefreshToken() would return true.
200
+ * Uses the same REFRESH_CREDENTIALS_BUFFER_MS timing as the rest of the auth system.
201
+ */
202
+ scheduleTokenRefresh() {
203
+ if (this.cancelTokenRefresh(), !this.authState)
204
+ return;
205
+ const t = this.authState.expiresAt - i - Date.now();
206
+ t <= 0 || (this.refreshTimeout = setTimeout(async () => {
207
+ await this.refreshAccessToken(), this.scheduleTokenRefresh();
208
+ }, t));
209
+ }
210
+ /**
211
+ * Cancels any scheduled token refresh.
212
+ */
213
+ cancelTokenRefresh() {
214
+ this.refreshTimeout && (clearTimeout(this.refreshTimeout), this.refreshTimeout = null);
215
+ }
118
216
  }
119
217
  export {
120
- K as createCDPEmbeddedWallet
218
+ p as AuthManager
121
219
  };