@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,14 +1,9 @@
1
- import { LruMap as u } from "./index29.js";
2
- import { checksumAddress as c } from "./index26.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
+ import { keccak_256 as o } from "./index50.js";
2
+ import { isHex as r } from "./index34.js";
3
+ import { toBytes as c } from "./index29.js";
4
+ function k(t, e) {
5
+ return o(r(t, { strict: !1 }) ? c(t) : t);
10
6
  }
11
7
  export {
12
- h as isAddress,
13
- r as isAddressCache
8
+ k as keccak256
14
9
  };
@@ -1,6 +1,24 @@
1
- function n(e) {
2
- return `0x${e.reduce((c, r) => c + r.replace("0x", ""), "")}`;
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
+ }
3
21
  }
4
22
  export {
5
- n as concatHex
23
+ r as LruMap
6
24
  };
@@ -1,6 +1,14 @@
1
- function e(t, { strict: r = !0 } = {}) {
2
- return !t || typeof t != "string" ? !1 : r ? /^0x[0-9a-fA-F]*$/.test(t) : t.startsWith("0x");
1
+ import { LruMap as u } from "./index31.js";
2
+ import { checksumAddress as c } from "./index28.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;
3
10
  }
4
11
  export {
5
- e as isHex
12
+ h as isAddress,
13
+ r as isAddressCache
6
14
  };
@@ -1,37 +1,6 @@
1
- import { SizeExceedsPaddingSizeError as d } from "./index34.js";
2
- function f(n, { dir: r, size: t = 32 } = {}) {
3
- return typeof n == "string" ? p(n, { dir: r, size: t }) : i(n, { dir: r, size: t });
4
- }
5
- function p(n, { dir: r, size: t = 32 } = {}) {
6
- if (t === null)
7
- return n;
8
- const e = n.replace("0x", "");
9
- if (e.length > t * 2)
10
- throw new d({
11
- size: Math.ceil(e.length / 2),
12
- targetSize: t,
13
- type: "hex"
14
- });
15
- return `0x${e[r === "right" ? "padEnd" : "padStart"](t * 2, "0")}`;
16
- }
17
- function i(n, { dir: r, size: t = 32 } = {}) {
18
- if (t === null)
19
- return n;
20
- if (n.length > t)
21
- throw new d({
22
- size: n.length,
23
- targetSize: t,
24
- type: "bytes"
25
- });
26
- const e = new Uint8Array(t);
27
- for (let a = 0; a < t; a++) {
28
- const o = r === "right";
29
- e[o ? a : t - a - 1] = n[o ? a : n.length - a - 1];
30
- }
31
- return e;
1
+ function n(e) {
2
+ return `0x${e.reduce((c, r) => c + r.replace("0x", ""), "")}`;
32
3
  }
33
4
  export {
34
- f as pad,
35
- i as padBytes,
36
- p as padHex
5
+ n as concatHex
37
6
  };
@@ -1,15 +1,6 @@
1
- import { BaseError as o } from "./index45.js";
2
- class d extends o {
3
- constructor({ offset: r, position: s, size: e }) {
4
- super(`Slice ${s === "start" ? "starting" : "ending"} at offset "${r}" is out-of-bounds (size: ${e}).`, { name: "SliceOffsetOutOfBoundsError" });
5
- }
6
- }
7
- class n extends o {
8
- constructor({ size: r, targetSize: s, type: e }) {
9
- super(`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()} size (${r}) exceeds padding size (${s}).`, { name: "SizeExceedsPaddingSizeError" });
10
- }
1
+ function e(t, { strict: r = !0 } = {}) {
2
+ return !t || typeof t != "string" ? !1 : r ? /^0x[0-9a-fA-F]*$/.test(t) : t.startsWith("0x");
11
3
  }
12
4
  export {
13
- n as SizeExceedsPaddingSizeError,
14
- d as SliceOffsetOutOfBoundsError
5
+ e as isHex
15
6
  };
@@ -1,7 +1,37 @@
1
- import { isHex as r } from "./index32.js";
2
- function i(t) {
3
- return r(t, { strict: !1 }) ? Math.ceil((t.length - 2) / 2) : t.length;
1
+ import { SizeExceedsPaddingSizeError as d } from "./index36.js";
2
+ function f(n, { dir: r, size: t = 32 } = {}) {
3
+ return typeof n == "string" ? p(n, { dir: r, size: t }) : i(n, { dir: r, size: t });
4
+ }
5
+ function p(n, { dir: r, size: t = 32 } = {}) {
6
+ if (t === null)
7
+ return n;
8
+ const e = n.replace("0x", "");
9
+ if (e.length > t * 2)
10
+ throw new d({
11
+ size: Math.ceil(e.length / 2),
12
+ targetSize: t,
13
+ type: "hex"
14
+ });
15
+ return `0x${e[r === "right" ? "padEnd" : "padStart"](t * 2, "0")}`;
16
+ }
17
+ function i(n, { dir: r, size: t = 32 } = {}) {
18
+ if (t === null)
19
+ return n;
20
+ if (n.length > t)
21
+ throw new d({
22
+ size: n.length,
23
+ targetSize: t,
24
+ type: "bytes"
25
+ });
26
+ const e = new Uint8Array(t);
27
+ for (let a = 0; a < t; a++) {
28
+ const o = r === "right";
29
+ e[o ? a : t - a - 1] = n[o ? a : n.length - a - 1];
30
+ }
31
+ return e;
4
32
  }
5
33
  export {
6
- i as size
34
+ f as pad,
35
+ i as padBytes,
36
+ p as padHex
7
37
  };
@@ -1,31 +1,15 @@
1
- import { SliceOffsetOutOfBoundsError as n } from "./index34.js";
2
- import { isHex as c } from "./index32.js";
3
- import { size as s } from "./index35.js";
4
- function O(e, f, i, { strict: o } = {}) {
5
- return c(e, { strict: !1 }) ? l(e, f, i, {
6
- strict: o
7
- }) : u(e, f, i, {
8
- strict: o
9
- });
1
+ import { BaseError as o } from "./index47.js";
2
+ class d extends o {
3
+ constructor({ offset: r, position: s, size: e }) {
4
+ super(`Slice ${s === "start" ? "starting" : "ending"} at offset "${r}" is out-of-bounds (size: ${e}).`, { name: "SliceOffsetOutOfBoundsError" });
5
+ }
10
6
  }
11
- function t(e, f, i) {
12
- if (s(e) !== i - f)
13
- throw new n({
14
- offset: i,
15
- position: "end",
16
- size: s(e)
17
- });
18
- }
19
- function u(e, f, i, { strict: o } = {}) {
20
- const r = e.slice(f, i);
21
- return o && t(r, f, i), r;
22
- }
23
- function l(e, f, i, { strict: o } = {}) {
24
- const r = `0x${e.replace("0x", "").slice(f * 2, i * 2)}`;
25
- return o && t(r, f, i), r;
7
+ class n extends o {
8
+ constructor({ size: r, targetSize: s, type: e }) {
9
+ super(`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()} size (${r}) exceeds padding size (${s}).`, { name: "SizeExceedsPaddingSizeError" });
10
+ }
26
11
  }
27
12
  export {
28
- O as slice,
29
- u as sliceBytes,
30
- l as sliceHex
13
+ n as SizeExceedsPaddingSizeError,
14
+ d as SliceOffsetOutOfBoundsError
31
15
  };
@@ -1,9 +1,7 @@
1
- function f(e, { dir: n = "left" } = {}) {
2
- let t = typeof e == "string" ? e.replace("0x", "") : e, i = 0;
3
- for (let l = 0; l < t.length - 1 && t[n === "left" ? l : t.length - l - 1].toString() === "0"; l++)
4
- i++;
5
- return t = n === "left" ? t.slice(i) : t.slice(0, t.length - i), typeof e == "string" ? (t.length === 1 && n === "right" && (t = `${t}0`), `0x${t.length % 2 === 1 ? `0${t}` : t}`) : t;
1
+ import { isHex as r } from "./index34.js";
2
+ function i(t) {
3
+ return r(t, { strict: !1 }) ? Math.ceil((t.length - 2) / 2) : t.length;
6
4
  }
7
5
  export {
8
- f as trim
6
+ i as size
9
7
  };
@@ -1,27 +1,31 @@
1
- import { defineFormatter as s } from "./index39.js";
2
- import { formatTransaction as t } from "./index40.js";
3
- function a(e) {
4
- const i = (e.transactions ?? []).map((n) => typeof n == "string" ? n : t(n));
5
- return {
6
- ...e,
7
- baseFeePerGas: e.baseFeePerGas ? BigInt(e.baseFeePerGas) : null,
8
- blobGasUsed: e.blobGasUsed ? BigInt(e.blobGasUsed) : void 0,
9
- difficulty: e.difficulty ? BigInt(e.difficulty) : void 0,
10
- excessBlobGas: e.excessBlobGas ? BigInt(e.excessBlobGas) : void 0,
11
- gasLimit: e.gasLimit ? BigInt(e.gasLimit) : void 0,
12
- gasUsed: e.gasUsed ? BigInt(e.gasUsed) : void 0,
13
- hash: e.hash ? e.hash : null,
14
- logsBloom: e.logsBloom ? e.logsBloom : null,
15
- nonce: e.nonce ? e.nonce : null,
16
- number: e.number ? BigInt(e.number) : null,
17
- size: e.size ? BigInt(e.size) : void 0,
18
- timestamp: e.timestamp ? BigInt(e.timestamp) : void 0,
19
- transactions: i,
20
- totalDifficulty: e.totalDifficulty ? BigInt(e.totalDifficulty) : null
21
- };
1
+ import { SliceOffsetOutOfBoundsError as n } from "./index36.js";
2
+ import { isHex as c } from "./index34.js";
3
+ import { size as s } from "./index37.js";
4
+ function O(e, f, i, { strict: o } = {}) {
5
+ return c(e, { strict: !1 }) ? l(e, f, i, {
6
+ strict: o
7
+ }) : u(e, f, i, {
8
+ strict: o
9
+ });
10
+ }
11
+ function t(e, f, i) {
12
+ if (s(e) !== i - f)
13
+ throw new n({
14
+ offset: i,
15
+ position: "end",
16
+ size: s(e)
17
+ });
18
+ }
19
+ function u(e, f, i, { strict: o } = {}) {
20
+ const r = e.slice(f, i);
21
+ return o && t(r, f, i), r;
22
+ }
23
+ function l(e, f, i, { strict: o } = {}) {
24
+ const r = `0x${e.replace("0x", "").slice(f * 2, i * 2)}`;
25
+ return o && t(r, f, i), r;
22
26
  }
23
- const d = /* @__PURE__ */ s("block", a);
24
27
  export {
25
- d as defineBlock,
26
- a as formatBlock
28
+ O as slice,
29
+ u as sliceBytes,
30
+ l as sliceHex
27
31
  };
@@ -1,19 +1,9 @@
1
- function a(e, f) {
2
- return ({ exclude: t, format: n }) => ({
3
- exclude: t,
4
- format: (r) => {
5
- const o = f(r);
6
- if (t)
7
- for (const m of t)
8
- delete o[m];
9
- return {
10
- ...o,
11
- ...n(r)
12
- };
13
- },
14
- type: e
15
- });
1
+ function f(e, { dir: n = "left" } = {}) {
2
+ let t = typeof e == "string" ? e.replace("0x", "") : e, i = 0;
3
+ for (let l = 0; l < t.length - 1 && t[n === "left" ? l : t.length - l - 1].toString() === "0"; l++)
4
+ i++;
5
+ return t = n === "left" ? t.slice(i) : t.slice(0, t.length - i), typeof e == "string" ? (t.length === 1 && n === "right" && (t = `${t}0`), `0x${t.length % 2 === 1 ? `0${t}` : t}`) : t;
16
6
  }
17
7
  export {
18
- a as defineFormatter
8
+ f as trim
19
9
  };
@@ -1,5 +1,6 @@
1
1
  import { getCurrentUser as u } from "./index2.js";
2
2
  import "./index3.js";
3
+ import "viem";
3
4
  const n = {
4
5
  rpc: {
5
6
  invalidInput: -32e3,
@@ -97,7 +98,7 @@ async function d() {
97
98
  );
98
99
  return e;
99
100
  }
100
- async function m(e) {
101
+ async function w(e) {
101
102
  const t = await d();
102
103
  if (!t.evmAccounts.includes(e))
103
104
  throw new o(
@@ -106,7 +107,7 @@ async function m(e) {
106
107
  );
107
108
  return t;
108
109
  }
109
- async function w() {
110
+ async function f() {
110
111
  const e = await d();
111
112
  if (!e.evmAccounts[0])
112
113
  throw new o(
@@ -121,6 +122,6 @@ export {
121
122
  n as STANDARD_ERROR_CODES,
122
123
  l as validateRequest,
123
124
  d as validateUserConnected,
124
- w as validateUserHasEvmAccount,
125
- m as validateUserOwnsAddress
125
+ f as validateUserHasEvmAccount,
126
+ w as validateUserOwnsAddress
126
127
  };
@@ -1,57 +1,27 @@
1
- import { hexToNumber as i } from "./index41.js";
2
- import { defineFormatter as r } from "./index39.js";
3
- const u = {
4
- "0x0": "legacy",
5
- "0x1": "eip2930",
6
- "0x2": "eip1559",
7
- "0x3": "eip4844",
8
- "0x4": "eip7702"
9
- };
10
- function l(e) {
11
- const d = {
1
+ import { defineFormatter as s } from "./index41.js";
2
+ import { formatTransaction as t } from "./index42.js";
3
+ function a(e) {
4
+ const i = (e.transactions ?? []).map((n) => typeof n == "string" ? n : t(n));
5
+ return {
12
6
  ...e,
13
- blockHash: e.blockHash ? e.blockHash : null,
14
- blockNumber: e.blockNumber ? BigInt(e.blockNumber) : null,
15
- chainId: e.chainId ? i(e.chainId) : void 0,
16
- gas: e.gas ? BigInt(e.gas) : void 0,
17
- gasPrice: e.gasPrice ? BigInt(e.gasPrice) : void 0,
18
- maxFeePerBlobGas: e.maxFeePerBlobGas ? BigInt(e.maxFeePerBlobGas) : void 0,
19
- maxFeePerGas: e.maxFeePerGas ? BigInt(e.maxFeePerGas) : void 0,
20
- maxPriorityFeePerGas: e.maxPriorityFeePerGas ? BigInt(e.maxPriorityFeePerGas) : void 0,
21
- nonce: e.nonce ? i(e.nonce) : void 0,
22
- to: e.to ? e.to : null,
23
- transactionIndex: e.transactionIndex ? Number(e.transactionIndex) : null,
24
- type: e.type ? u[e.type] : void 0,
25
- typeHex: e.type ? e.type : void 0,
26
- value: e.value ? BigInt(e.value) : void 0,
27
- v: e.v ? BigInt(e.v) : void 0
7
+ baseFeePerGas: e.baseFeePerGas ? BigInt(e.baseFeePerGas) : null,
8
+ blobGasUsed: e.blobGasUsed ? BigInt(e.blobGasUsed) : void 0,
9
+ difficulty: e.difficulty ? BigInt(e.difficulty) : void 0,
10
+ excessBlobGas: e.excessBlobGas ? BigInt(e.excessBlobGas) : void 0,
11
+ gasLimit: e.gasLimit ? BigInt(e.gasLimit) : void 0,
12
+ gasUsed: e.gasUsed ? BigInt(e.gasUsed) : void 0,
13
+ hash: e.hash ? e.hash : null,
14
+ logsBloom: e.logsBloom ? e.logsBloom : null,
15
+ nonce: e.nonce ? e.nonce : null,
16
+ number: e.number ? BigInt(e.number) : null,
17
+ size: e.size ? BigInt(e.size) : void 0,
18
+ timestamp: e.timestamp ? BigInt(e.timestamp) : void 0,
19
+ transactions: i,
20
+ totalDifficulty: e.totalDifficulty ? BigInt(e.totalDifficulty) : null
28
21
  };
29
- return e.authorizationList && (d.authorizationList = m(e.authorizationList)), d.yParity = (() => {
30
- if (e.yParity)
31
- return Number(e.yParity);
32
- if (typeof d.v == "bigint") {
33
- if (d.v === 0n || d.v === 27n)
34
- return 0;
35
- if (d.v === 1n || d.v === 28n)
36
- return 1;
37
- if (d.v >= 35n)
38
- return d.v % 2n === 0n ? 1 : 0;
39
- }
40
- })(), d.type === "legacy" && (delete d.accessList, delete d.maxFeePerBlobGas, delete d.maxFeePerGas, delete d.maxPriorityFeePerGas, delete d.yParity), d.type === "eip2930" && (delete d.maxFeePerBlobGas, delete d.maxFeePerGas, delete d.maxPriorityFeePerGas), d.type === "eip1559" && delete d.maxFeePerBlobGas, d;
41
- }
42
- const P = /* @__PURE__ */ r("transaction", l);
43
- function m(e) {
44
- return e.map((d) => ({
45
- address: d.address,
46
- chainId: Number(d.chainId),
47
- nonce: Number(d.nonce),
48
- r: d.r,
49
- s: d.s,
50
- yParity: Number(d.yParity)
51
- }));
52
22
  }
23
+ const d = /* @__PURE__ */ s("block", a);
53
24
  export {
54
- P as defineTransaction,
55
- l as formatTransaction,
56
- u as transactionType
25
+ d as defineBlock,
26
+ a as formatBlock
57
27
  };
@@ -1,26 +1,19 @@
1
- import { SizeOverflowError as u } from "./index47.js";
2
- import { size as t } from "./index35.js";
3
- function s(n, { size: i }) {
4
- if (t(n) > i)
5
- throw new u({
6
- givenSize: t(n),
7
- maxSize: i
8
- });
9
- }
10
- function z(n, i = {}) {
11
- const { signed: o } = i;
12
- i.size && s(n, { size: i.size });
13
- const e = BigInt(n);
14
- if (!o)
15
- return e;
16
- const r = (n.length - 2) / 2, f = (1n << BigInt(r) * 8n - 1n) - 1n;
17
- return e <= f ? e : e - BigInt(`0x${"f".padStart(r * 2, "f")}`) - 1n;
18
- }
19
- function g(n, i = {}) {
20
- return Number(z(n, i));
1
+ function a(e, f) {
2
+ return ({ exclude: t, format: n }) => ({
3
+ exclude: t,
4
+ format: (r) => {
5
+ const o = f(r);
6
+ if (t)
7
+ for (const m of t)
8
+ delete o[m];
9
+ return {
10
+ ...o,
11
+ ...n(r)
12
+ };
13
+ },
14
+ type: e
15
+ });
21
16
  }
22
17
  export {
23
- s as assertSize,
24
- z as hexToBigInt,
25
- g as hexToNumber
18
+ a as defineFormatter
26
19
  };
@@ -1,14 +1,57 @@
1
- function r(n, { args: t, eventName: a } = {}) {
2
- return {
3
- ...n,
4
- blockHash: n.blockHash ? n.blockHash : null,
5
- blockNumber: n.blockNumber ? BigInt(n.blockNumber) : null,
6
- logIndex: n.logIndex ? Number(n.logIndex) : null,
7
- transactionHash: n.transactionHash ? n.transactionHash : null,
8
- transactionIndex: n.transactionIndex ? Number(n.transactionIndex) : null,
9
- ...a ? { args: t, eventName: a } : {}
1
+ import { hexToNumber as i } from "./index43.js";
2
+ import { defineFormatter as r } from "./index41.js";
3
+ const u = {
4
+ "0x0": "legacy",
5
+ "0x1": "eip2930",
6
+ "0x2": "eip1559",
7
+ "0x3": "eip4844",
8
+ "0x4": "eip7702"
9
+ };
10
+ function l(e) {
11
+ const d = {
12
+ ...e,
13
+ blockHash: e.blockHash ? e.blockHash : null,
14
+ blockNumber: e.blockNumber ? BigInt(e.blockNumber) : null,
15
+ chainId: e.chainId ? i(e.chainId) : void 0,
16
+ gas: e.gas ? BigInt(e.gas) : void 0,
17
+ gasPrice: e.gasPrice ? BigInt(e.gasPrice) : void 0,
18
+ maxFeePerBlobGas: e.maxFeePerBlobGas ? BigInt(e.maxFeePerBlobGas) : void 0,
19
+ maxFeePerGas: e.maxFeePerGas ? BigInt(e.maxFeePerGas) : void 0,
20
+ maxPriorityFeePerGas: e.maxPriorityFeePerGas ? BigInt(e.maxPriorityFeePerGas) : void 0,
21
+ nonce: e.nonce ? i(e.nonce) : void 0,
22
+ to: e.to ? e.to : null,
23
+ transactionIndex: e.transactionIndex ? Number(e.transactionIndex) : null,
24
+ type: e.type ? u[e.type] : void 0,
25
+ typeHex: e.type ? e.type : void 0,
26
+ value: e.value ? BigInt(e.value) : void 0,
27
+ v: e.v ? BigInt(e.v) : void 0
10
28
  };
29
+ return e.authorizationList && (d.authorizationList = m(e.authorizationList)), d.yParity = (() => {
30
+ if (e.yParity)
31
+ return Number(e.yParity);
32
+ if (typeof d.v == "bigint") {
33
+ if (d.v === 0n || d.v === 27n)
34
+ return 0;
35
+ if (d.v === 1n || d.v === 28n)
36
+ return 1;
37
+ if (d.v >= 35n)
38
+ return d.v % 2n === 0n ? 1 : 0;
39
+ }
40
+ })(), d.type === "legacy" && (delete d.accessList, delete d.maxFeePerBlobGas, delete d.maxFeePerGas, delete d.maxPriorityFeePerGas, delete d.yParity), d.type === "eip2930" && (delete d.maxFeePerBlobGas, delete d.maxFeePerGas, delete d.maxPriorityFeePerGas), d.type === "eip1559" && delete d.maxFeePerBlobGas, d;
41
+ }
42
+ const P = /* @__PURE__ */ r("transaction", l);
43
+ function m(e) {
44
+ return e.map((d) => ({
45
+ address: d.address,
46
+ chainId: Number(d.chainId),
47
+ nonce: Number(d.nonce),
48
+ r: d.r,
49
+ s: d.s,
50
+ yParity: Number(d.yParity)
51
+ }));
11
52
  }
12
53
  export {
13
- r as formatLog
54
+ P as defineTransaction,
55
+ l as formatTransaction,
56
+ u as transactionType
14
57
  };
@@ -1,30 +1,26 @@
1
- import { hexToNumber as d } from "./index41.js";
2
- import { defineFormatter as b } from "./index39.js";
3
- import { formatLog as m } from "./index42.js";
4
- import { transactionType as o } from "./index40.js";
5
- const f = {
6
- "0x0": "reverted",
7
- "0x1": "success"
8
- };
9
- function r(l) {
10
- const s = {
11
- ...l,
12
- blockNumber: l.blockNumber ? BigInt(l.blockNumber) : null,
13
- contractAddress: l.contractAddress ? l.contractAddress : null,
14
- cumulativeGasUsed: l.cumulativeGasUsed ? BigInt(l.cumulativeGasUsed) : null,
15
- effectiveGasPrice: l.effectiveGasPrice ? BigInt(l.effectiveGasPrice) : null,
16
- gasUsed: l.gasUsed ? BigInt(l.gasUsed) : null,
17
- logs: l.logs ? l.logs.map((u) => m(u)) : null,
18
- to: l.to ? l.to : null,
19
- transactionIndex: l.transactionIndex ? d(l.transactionIndex) : null,
20
- status: l.status ? f[l.status] : null,
21
- type: l.type ? o[l.type] || l.type : null
22
- };
23
- return l.blobGasPrice && (s.blobGasPrice = BigInt(l.blobGasPrice)), l.blobGasUsed && (s.blobGasUsed = BigInt(l.blobGasUsed)), s;
1
+ import { SizeOverflowError as u } from "./index49.js";
2
+ import { size as t } from "./index37.js";
3
+ function s(n, { size: i }) {
4
+ if (t(n) > i)
5
+ throw new u({
6
+ givenSize: t(n),
7
+ maxSize: i
8
+ });
9
+ }
10
+ function z(n, i = {}) {
11
+ const { signed: o } = i;
12
+ i.size && s(n, { size: i.size });
13
+ const e = BigInt(n);
14
+ if (!o)
15
+ return e;
16
+ const r = (n.length - 2) / 2, f = (1n << BigInt(r) * 8n - 1n) - 1n;
17
+ return e <= f ? e : e - BigInt(`0x${"f".padStart(r * 2, "f")}`) - 1n;
18
+ }
19
+ function g(n, i = {}) {
20
+ return Number(z(n, i));
24
21
  }
25
- const U = /* @__PURE__ */ b("transactionReceipt", r);
26
22
  export {
27
- U as defineTransactionReceipt,
28
- r as formatTransactionReceipt,
29
- f as receiptStatuses
23
+ s as assertSize,
24
+ z as hexToBigInt,
25
+ g as hexToNumber
30
26
  };
@@ -1,45 +1,14 @@
1
- import { BaseError as l } from "./index45.js";
2
- import { createCursor as r } from "./index46.js";
3
- import { hexToBytes as g } from "./index27.js";
4
- import { bytesToHex as u } from "./index25.js";
5
- function m(n, e = "hex") {
6
- const i = s(n), h = r(new Uint8Array(i.length));
7
- return i.encode(h), e === "hex" ? u(h.bytes) : h.bytes;
8
- }
9
- function s(n) {
10
- return Array.isArray(n) ? p(n.map((e) => s(e))) : y(n);
11
- }
12
- function p(n) {
13
- const e = n.reduce((t, f) => t + f.length, 0), i = o(e);
14
- return {
15
- length: e <= 55 ? 1 + e : 1 + i + e,
16
- encode(t) {
17
- e <= 55 ? t.pushByte(192 + e) : (t.pushByte(247 + i), i === 1 ? t.pushUint8(e) : i === 2 ? t.pushUint16(e) : i === 3 ? t.pushUint24(e) : t.pushUint32(e));
18
- for (const { encode: f } of n)
19
- f(t);
20
- }
21
- };
22
- }
23
- function y(n) {
24
- const e = typeof n == "string" ? g(n) : n, i = o(e.length);
1
+ function r(n, { args: t, eventName: a } = {}) {
25
2
  return {
26
- length: e.length === 1 && e[0] < 128 ? 1 : e.length <= 55 ? 1 + e.length : 1 + i + e.length,
27
- encode(t) {
28
- e.length === 1 && e[0] < 128 ? t.pushBytes(e) : e.length <= 55 ? (t.pushByte(128 + e.length), t.pushBytes(e)) : (t.pushByte(183 + i), i === 1 ? t.pushUint8(e.length) : i === 2 ? t.pushUint16(e.length) : i === 3 ? t.pushUint24(e.length) : t.pushUint32(e.length), t.pushBytes(e));
29
- }
3
+ ...n,
4
+ blockHash: n.blockHash ? n.blockHash : null,
5
+ blockNumber: n.blockNumber ? BigInt(n.blockNumber) : null,
6
+ logIndex: n.logIndex ? Number(n.logIndex) : null,
7
+ transactionHash: n.transactionHash ? n.transactionHash : null,
8
+ transactionIndex: n.transactionIndex ? Number(n.transactionIndex) : null,
9
+ ...a ? { args: t, eventName: a } : {}
30
10
  };
31
11
  }
32
- function o(n) {
33
- if (n < 2 ** 8)
34
- return 1;
35
- if (n < 2 ** 16)
36
- return 2;
37
- if (n < 2 ** 24)
38
- return 3;
39
- if (n < 2 ** 32)
40
- return 4;
41
- throw new l("Length is too large.");
42
- }
43
12
  export {
44
- m as toRlp
13
+ r as formatLog
45
14
  };