@gardenfi/utils 2.0.6-alpha.0 → 2.0.6-alpha.1

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 (197) hide show
  1. package/dist/index100.cjs +1 -1
  2. package/dist/index100.js +41 -5
  3. package/dist/index101.cjs +1 -1
  4. package/dist/index101.js +643 -10
  5. package/dist/index102.cjs +1 -1
  6. package/dist/index102.js +232 -2
  7. package/dist/index103.cjs +1 -1
  8. package/dist/index103.js +169 -17
  9. package/dist/index104.cjs +1 -1
  10. package/dist/index104.js +12 -6
  11. package/dist/index105.cjs +1 -1
  12. package/dist/index105.js +128 -5
  13. package/dist/index106.cjs +2 -1
  14. package/dist/index106.js +3 -38
  15. package/dist/index107.cjs +1 -1
  16. package/dist/index107.js +17 -126
  17. package/dist/index108.cjs +1 -1
  18. package/dist/index108.js +39 -2
  19. package/dist/index109.cjs +1 -2
  20. package/dist/index109.js +2 -3
  21. package/dist/index110.cjs +1 -1
  22. package/dist/index110.js +2 -68
  23. package/dist/index111.cjs +1 -1
  24. package/dist/index111.js +32 -64
  25. package/dist/index112.cjs +1 -1
  26. package/dist/index112.js +12 -2
  27. package/dist/index113.cjs +1 -1
  28. package/dist/index113.js +17 -32
  29. package/dist/index114.cjs +1 -1
  30. package/dist/index114.js +5 -41
  31. package/dist/index115.cjs +1 -1
  32. package/dist/index115.js +10 -643
  33. package/dist/index116.cjs +1 -1
  34. package/dist/index116.js +16 -227
  35. package/dist/index117.cjs +1 -1
  36. package/dist/index117.js +6 -172
  37. package/dist/index118.cjs +1 -1
  38. package/dist/index118.js +5 -19
  39. package/dist/index18.cjs +1 -1
  40. package/dist/index18.js +11 -11
  41. package/dist/index19.cjs +1 -1
  42. package/dist/index19.js +9 -9
  43. package/dist/index21.cjs +1 -1
  44. package/dist/index21.js +3 -3
  45. package/dist/index23.cjs +1 -1
  46. package/dist/index23.js +41 -17
  47. package/dist/index24.cjs +1 -1
  48. package/dist/index24.js +44 -6
  49. package/dist/index25.cjs +1 -1
  50. package/dist/index25.js +24 -44
  51. package/dist/index26.cjs +1 -1
  52. package/dist/index26.js +6 -21
  53. package/dist/index27.cjs +1 -1
  54. package/dist/index27.js +13 -8
  55. package/dist/index28.cjs +1 -1
  56. package/dist/index28.js +15 -31
  57. package/dist/index29.cjs +1 -1
  58. package/dist/index29.js +5 -26
  59. package/dist/index30.cjs +1 -2
  60. package/dist/index30.js +13 -65
  61. package/dist/index31.cjs +1 -1
  62. package/dist/index31.js +10 -51
  63. package/dist/index32.cjs +1 -1
  64. package/dist/index32.js +12 -12
  65. package/dist/index33.cjs +1 -1
  66. package/dist/index33.js +11 -24
  67. package/dist/index34.cjs +1 -1
  68. package/dist/index34.js +13 -75
  69. package/dist/index35.cjs +1 -1
  70. package/dist/index35.js +2 -2
  71. package/dist/index36.cjs +1 -1
  72. package/dist/index36.js +55 -7
  73. package/dist/index37.cjs +1 -1
  74. package/dist/index37.js +16 -32
  75. package/dist/index38.cjs +1 -1
  76. package/dist/index38.js +5 -15
  77. package/dist/index39.cjs +1 -1
  78. package/dist/index39.js +9 -2
  79. package/dist/index40.cjs +1 -1
  80. package/dist/index40.js +171 -8
  81. package/dist/index41.cjs +1 -1
  82. package/dist/index41.js +102 -19
  83. package/dist/index42.cjs +1 -1
  84. package/dist/index42.js +21 -41
  85. package/dist/index43.cjs +1 -1
  86. package/dist/index43.js +17 -25
  87. package/dist/index44.cjs +1 -1
  88. package/dist/index44.js +7 -6
  89. package/dist/index45.cjs +1 -1
  90. package/dist/index45.js +20 -12
  91. package/dist/index46.cjs +1 -1
  92. package/dist/index46.js +8 -15
  93. package/dist/index47.cjs +1 -1
  94. package/dist/index47.js +31 -5
  95. package/dist/index48.cjs +1 -1
  96. package/dist/index48.js +26 -13
  97. package/dist/index49.cjs +2 -1
  98. package/dist/index49.js +65 -10
  99. package/dist/index50.cjs +1 -1
  100. package/dist/index50.js +51 -12
  101. package/dist/index51.cjs +1 -1
  102. package/dist/index51.js +12 -11
  103. package/dist/index52.cjs +1 -1
  104. package/dist/index52.js +24 -13
  105. package/dist/index53.cjs +1 -1
  106. package/dist/index53.js +75 -55
  107. package/dist/index54.cjs +1 -1
  108. package/dist/index54.js +7 -16
  109. package/dist/index55.cjs +1 -1
  110. package/dist/index55.js +32 -5
  111. package/dist/index56.cjs +1 -1
  112. package/dist/index56.js +15 -8
  113. package/dist/index57.cjs +1 -1
  114. package/dist/index57.js +2 -172
  115. package/dist/index58.cjs +1 -1
  116. package/dist/index58.js +7 -102
  117. package/dist/index59.cjs +1 -1
  118. package/dist/index59.js +20 -21
  119. package/dist/index60.cjs +1 -1
  120. package/dist/index60.js +110 -10
  121. package/dist/index61.cjs +1 -1
  122. package/dist/index61.js +15 -33
  123. package/dist/index62.cjs +1 -1
  124. package/dist/index62.js +223 -6
  125. package/dist/index63.cjs +1 -2
  126. package/dist/index63.js +10 -57
  127. package/dist/index64.cjs +1 -1
  128. package/dist/index64.js +35 -2
  129. package/dist/index65.cjs +2 -1
  130. package/dist/index65.js +58 -5
  131. package/dist/index66.cjs +1 -1
  132. package/dist/index66.js +21 -4
  133. package/dist/index67.cjs +1 -1
  134. package/dist/index67.js +4 -11
  135. package/dist/index68.cjs +1 -5
  136. package/dist/index68.js +3 -56
  137. package/dist/index69.cjs +1 -2
  138. package/dist/index69.js +17 -33
  139. package/dist/index70.cjs +1 -1
  140. package/dist/index70.js +42 -5
  141. package/dist/index71.cjs +1 -1
  142. package/dist/index71.js +8 -3
  143. package/dist/index72.cjs +1 -1
  144. package/dist/index72.js +101 -18
  145. package/dist/index73.cjs +1 -1
  146. package/dist/index73.js +2 -2
  147. package/dist/index74.cjs +1 -1
  148. package/dist/index74.js +2 -2
  149. package/dist/index75.cjs +1 -1
  150. package/dist/index75.js +1 -1
  151. package/dist/index76.cjs +1 -1
  152. package/dist/index76.js +13 -6
  153. package/dist/index77.cjs +1 -1
  154. package/dist/index77.js +6 -13
  155. package/dist/index78.cjs +1 -1
  156. package/dist/index78.js +16 -31
  157. package/dist/index79.cjs +1 -1
  158. package/dist/index79.js +78 -14
  159. package/dist/index80.cjs +1 -1
  160. package/dist/index80.js +14 -64
  161. package/dist/index81.cjs +1 -1
  162. package/dist/index81.js +17 -26
  163. package/dist/index82.cjs +1 -1
  164. package/dist/index82.js +192 -3
  165. package/dist/index83.cjs +1 -1
  166. package/dist/index83.js +64 -3
  167. package/dist/index84.cjs +1 -1
  168. package/dist/index84.js +2 -9
  169. package/dist/index85.cjs +1 -1
  170. package/dist/index85.js +5 -190
  171. package/dist/index86.cjs +1 -1
  172. package/dist/index86.js +11 -18
  173. package/dist/index87.cjs +5 -1
  174. package/dist/index87.js +50 -106
  175. package/dist/index88.cjs +2 -1
  176. package/dist/index88.js +33 -15
  177. package/dist/index89.cjs +1 -1
  178. package/dist/index89.js +5 -223
  179. package/dist/index90.cjs +1 -1
  180. package/dist/index90.js +3 -42
  181. package/dist/index91.cjs +1 -1
  182. package/dist/index91.js +6 -104
  183. package/dist/index92.cjs +1 -1
  184. package/dist/index92.js +31 -16
  185. package/dist/index93.cjs +1 -1
  186. package/dist/index93.js +24 -75
  187. package/dist/index94.cjs +1 -1
  188. package/dist/index94.js +3 -19
  189. package/dist/index96.cjs +1 -1
  190. package/dist/index96.js +66 -10
  191. package/dist/index97.cjs +1 -1
  192. package/dist/index97.js +69 -19
  193. package/dist/index98.cjs +1 -1
  194. package/dist/index98.js +2 -13
  195. package/dist/index99.cjs +1 -1
  196. package/dist/index99.js +30 -34
  197. package/package.json +1 -1
package/dist/index42.js CHANGED
@@ -1,44 +1,24 @@
1
- import { sha256 as C } from "./index87.js";
2
- import { createCurve as G } from "./index88.js";
3
- import { Field as N, mod as k, pow2 as t } from "./index89.js";
4
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
5
- const q = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), w = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), j = BigInt(1), _ = BigInt(2), h = (n, f) => (n + f / _) / f;
6
- function M(n) {
7
- const f = q, e = BigInt(3), r = BigInt(6), I = BigInt(11), a = BigInt(22), s = BigInt(23), i = BigInt(44), g = BigInt(88), o = n * n * n % f, c = o * o * n % f, d = t(c, e, f) * c % f, B = t(d, e, f) * c % f, m = t(B, _, f) * o % f, b = t(m, I, f) * m % f, p = t(b, a, f) * b % f, x = t(p, i, f) * p % f, P = t(x, g, f) * x % f, v = t(P, i, f) * p % f, E = t(v, e, f) * c % f, F = t(E, s, f) * b % f, S = t(F, r, f) * o % f, u = t(S, _, f);
8
- if (!l.eql(l.sqr(u), n))
9
- throw new Error("Cannot find square root");
10
- return u;
1
+ import { InvalidAddressError as c } from "./index32.js";
2
+ import { stringToBytes as m } from "./index36.js";
3
+ import { keccak256 as p } from "./index39.js";
4
+ import { LruMap as u } from "./index66.js";
5
+ import { isAddress as $ } from "./index33.js";
6
+ const s = /* @__PURE__ */ new u(8192);
7
+ function h(t, o) {
8
+ if (s.has(`${t}.${o}`))
9
+ return s.get(`${t}.${o}`);
10
+ const i = t.substring(2).toLowerCase(), n = p(m(i), "bytes"), e = i.split("");
11
+ for (let r = 0; r < 40; r += 2)
12
+ n[r >> 1] >> 4 >= 8 && e[r] && (e[r] = e[r].toUpperCase()), (n[r >> 1] & 15) >= 8 && e[r + 1] && (e[r + 1] = e[r + 1].toUpperCase());
13
+ const f = `0x${e.join("")}`;
14
+ return s.set(`${t}.${o}`, f), f;
15
+ }
16
+ function w(t, o) {
17
+ if (!$(t, { strict: !1 }))
18
+ throw new c({ address: t });
19
+ return h(t, o);
11
20
  }
12
- const l = N(q, void 0, void 0, { sqrt: M }), O = G({
13
- a: BigInt(0),
14
- // equation params: a, b
15
- b: BigInt(7),
16
- Fp: l,
17
- // Field's prime: 2n**256n - 2n**32n - 2n**9n - 2n**8n - 2n**7n - 2n**6n - 2n**4n - 1n
18
- n: w,
19
- // Curve order, total count of valid points in the field
20
- // Base point (x, y) aka generator point
21
- Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),
22
- Gy: BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),
23
- h: BigInt(1),
24
- // Cofactor
25
- lowS: !0,
26
- // Allow only low-S signatures by default in sign() and verify()
27
- endo: {
28
- // Endomorphism, see above
29
- beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
30
- splitScalar: (n) => {
31
- const f = w, e = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), r = -j * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), I = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), a = e, s = BigInt("0x100000000000000000000000000000000"), i = h(a * n, f), g = h(-r * n, f);
32
- let o = k(n - i * e - g * I, f), c = k(-i * r - g * a, f);
33
- const d = o > s, B = c > s;
34
- if (d && (o = f - o), B && (c = f - c), o > s || c > s)
35
- throw new Error("splitScalar: Endomorphism failed, k=" + n);
36
- return { k1neg: d, k1: o, k2neg: B, k2: c };
37
- }
38
- }
39
- }, C);
40
- BigInt(0);
41
- O.ProjectivePoint;
42
21
  export {
43
- O as secp256k1
22
+ h as checksumAddress,
23
+ w as getAddress
44
24
  };
package/dist/index43.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index50.cjs"),e=require("./index51.cjs");function t(s){if(typeof s=="string"){if(!e.isAddress(s,{strict:!1}))throw new n.InvalidAddressError({address:s});return{address:s,type:"json-rpc"}}if(!e.isAddress(s.address,{strict:!1}))throw new n.InvalidAddressError({address:s.address});return{address:s.address,nonceManager:s.nonceManager,sign:s.sign,experimental_signAuthorization:s.experimental_signAuthorization,signMessage:s.signMessage,signTransaction:s.signTransaction,signTypedData:s.signTypedData,source:"custom",type:"local"}}exports.toAccount=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./index44.cjs"),m=require("./index24.cjs"),k=require("./index45.cjs");async function B(t,{blockHash:o,blockNumber:r,blockTag:l,includeTransactions:i}={}){var c,s,u;const d=l??"latest",n=i??!1,a=r!==void 0?m.numberToHex(r):void 0;let e=null;if(o?e=await t.request({method:"eth_getBlockByHash",params:[o,n]},{dedupe:!0}):e=await t.request({method:"eth_getBlockByNumber",params:[a||d,n]},{dedupe:!!a}),!e)throw new f.BlockNotFoundError({blockHash:o,blockNumber:r});return(((u=(s=(c=t.chain)==null?void 0:c.formatters)==null?void 0:s.block)==null?void 0:u.format)||k.formatBlock)(e)}exports.getBlock=B;
package/dist/index43.js CHANGED
@@ -1,28 +1,20 @@
1
- import { InvalidAddressError as s } from "./index50.js";
2
- import { isAddress as a } from "./index51.js";
3
- function e(n) {
4
- if (typeof n == "string") {
5
- if (!a(n, { strict: !1 }))
6
- throw new s({ address: n });
7
- return {
8
- address: n,
9
- type: "json-rpc"
10
- };
11
- }
12
- if (!a(n.address, { strict: !1 }))
13
- throw new s({ address: n.address });
14
- return {
15
- address: n.address,
16
- nonceManager: n.nonceManager,
17
- sign: n.sign,
18
- experimental_signAuthorization: n.experimental_signAuthorization,
19
- signMessage: n.signMessage,
20
- signTransaction: n.signTransaction,
21
- signTypedData: n.signTypedData,
22
- source: "custom",
23
- type: "local"
24
- };
1
+ import { BlockNotFoundError as i } from "./index44.js";
2
+ import { numberToHex as l } from "./index24.js";
3
+ import { formatBlock as p } from "./index45.js";
4
+ async function T(e, { blockHash: t, blockNumber: r, blockTag: f, includeTransactions: u } = {}) {
5
+ var m, s, c;
6
+ const d = f ?? "latest", a = u ?? !1, n = r !== void 0 ? l(r) : void 0;
7
+ let o = null;
8
+ if (t ? o = await e.request({
9
+ method: "eth_getBlockByHash",
10
+ params: [t, a]
11
+ }, { dedupe: !0 }) : o = await e.request({
12
+ method: "eth_getBlockByNumber",
13
+ params: [n || d, a]
14
+ }, { dedupe: !!n }), !o)
15
+ throw new i({ blockHash: t, blockNumber: r });
16
+ return (((c = (s = (m = e.chain) == null ? void 0 : m.formatters) == null ? void 0 : s.block) == null ? void 0 : c.format) || p)(o);
25
17
  }
26
18
  export {
27
- e as toAccount
19
+ T as getBlock
28
20
  };
package/dist/index44.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index59.cjs"),c=require("./index56.cjs");function t(e){const s=c.keccak256(`0x${e.substring(4)}`).substring(26);return r.checksumAddress(`0x${s}`)}exports.publicKeyToAddress=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index65.cjs");class n extends t.BaseError{constructor({blockHash:r,blockNumber:e}){let o="Block";r&&(o=`Block at hash "${r}"`),e&&(o=`Block at number "${e}"`),super(`${o} could not be found.`,{name:"BlockNotFoundError"})}}exports.BlockNotFoundError=n;
package/dist/index44.js CHANGED
@@ -1,9 +1,10 @@
1
- import { checksumAddress as e } from "./index59.js";
2
- import { keccak256 as o } from "./index56.js";
3
- function d(r) {
4
- const s = o(`0x${r.substring(4)}`).substring(26);
5
- return e(`0x${s}`);
1
+ import { BaseError as e } from "./index65.js";
2
+ class d extends e {
3
+ constructor({ blockHash: r, blockNumber: t }) {
4
+ let o = "Block";
5
+ r && (o = `Block at hash "${r}"`), t && (o = `Block at number "${t}"`), super(`${o} could not be found.`, { name: "BlockNotFoundError" });
6
+ }
6
7
  }
7
8
  export {
8
- d as publicKeyToAddress
9
+ d as BlockNotFoundError
9
10
  };
package/dist/index45.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index42.cjs"),s=require("./index25.cjs"),a=require("./index52.cjs");let l=!1;async function g({hash:t,privateKey:i,to:e="object"}){const{r:u,s:c,recovery:r}=o.secp256k1.sign(t.slice(2),i.slice(2),{lowS:!0,extraEntropy:l}),n={r:s.numberToHex(u,{size:32}),s:s.numberToHex(c,{size:32}),v:r?28n:27n,yParity:r};return e==="bytes"||e==="hex"?a.serializeSignature({...n,to:e}):n}exports.sign=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index50.cjs");function i(e){const s=(e.transactions??[]).map(n=>typeof n=="string"?n:t.formatTransaction(n));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:s,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}exports.formatBlock=i;
package/dist/index45.js CHANGED
@@ -1,16 +1,24 @@
1
- import { secp256k1 as u } from "./index42.js";
2
- import { numberToHex as i } from "./index25.js";
3
- import { serializeSignature as a } from "./index52.js";
4
- let m = !1;
5
- async function y({ hash: n, privateKey: s, to: r = "object" }) {
6
- const { r: o, s: c, recovery: e } = u.sign(n.slice(2), s.slice(2), { lowS: !0, extraEntropy: m }), t = {
7
- r: i(o, { size: 32 }),
8
- s: i(c, { size: 32 }),
9
- v: e ? 28n : 27n,
10
- yParity: e
1
+ import { formatTransaction as i } from "./index50.js";
2
+ function a(e) {
3
+ const s = (e.transactions ?? []).map((n) => typeof n == "string" ? n : i(n));
4
+ return {
5
+ ...e,
6
+ baseFeePerGas: e.baseFeePerGas ? BigInt(e.baseFeePerGas) : null,
7
+ blobGasUsed: e.blobGasUsed ? BigInt(e.blobGasUsed) : void 0,
8
+ difficulty: e.difficulty ? BigInt(e.difficulty) : void 0,
9
+ excessBlobGas: e.excessBlobGas ? BigInt(e.excessBlobGas) : void 0,
10
+ gasLimit: e.gasLimit ? BigInt(e.gasLimit) : void 0,
11
+ gasUsed: e.gasUsed ? BigInt(e.gasUsed) : void 0,
12
+ hash: e.hash ? e.hash : null,
13
+ logsBloom: e.logsBloom ? e.logsBloom : null,
14
+ nonce: e.nonce ? e.nonce : null,
15
+ number: e.number ? BigInt(e.number) : null,
16
+ size: e.size ? BigInt(e.size) : void 0,
17
+ timestamp: e.timestamp ? BigInt(e.timestamp) : void 0,
18
+ transactions: s,
19
+ totalDifficulty: e.totalDifficulty ? BigInt(e.totalDifficulty) : null
11
20
  };
12
- return r === "bytes" || r === "hex" ? a({ ...t, to: r }) : t;
13
21
  }
14
22
  export {
15
- y as sign
23
+ a as formatBlock
16
24
  };
package/dist/index46.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index54.cjs"),c=require("./index45.cjs");async function u(r){const{contractAddress:t,chainId:e,nonce:n,privateKey:a,to:i="object"}=r,o=await c.sign({hash:s.hashAuthorization({contractAddress:t,chainId:e,nonce:n}),privateKey:a,to:i});return i==="object"?{contractAddress:t,chainId:e,nonce:n,...o}:o}exports.experimental_signAuthorization=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index47.cjs"),r=e=>`blockNumber.${e}`;async function u(e,{cacheTime:c=e.cacheTime}={}){const t=await o.withCache(()=>e.request({method:"eth_blockNumber"}),{cacheKey:r(e.uid),cacheTime:c});return BigInt(t)}exports.getBlockNumber=u;
package/dist/index46.js CHANGED
@@ -1,18 +1,11 @@
1
- import { hashAuthorization as c } from "./index54.js";
2
- import { sign as s } from "./index45.js";
3
- async function m(e) {
4
- const { contractAddress: t, chainId: n, nonce: o, privateKey: a, to: r = "object" } = e, i = await s({
5
- hash: c({ contractAddress: t, chainId: n, nonce: o }),
6
- privateKey: a,
7
- to: r
8
- });
9
- return r === "object" ? {
10
- contractAddress: t,
11
- chainId: n,
12
- nonce: o,
13
- ...i
14
- } : i;
1
+ import { withCache as t } from "./index47.js";
2
+ const r = (e) => `blockNumber.${e}`;
3
+ async function u(e, { cacheTime: c = e.cacheTime } = {}) {
4
+ const o = await t(() => e.request({
5
+ method: "eth_blockNumber"
6
+ }), { cacheKey: r(e.uid), cacheTime: c });
7
+ return BigInt(o);
15
8
  }
16
9
  export {
17
- m as experimental_signAuthorization
10
+ u as getBlockNumber
18
11
  };
package/dist/index47.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index55.cjs"),n=require("./index45.cjs");async function t({message:e,privateKey:s}){return await n.sign({hash:a.hashMessage(e),privateKey:s,to:"hex"})}exports.signMessage=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=new Map,c=new Map;function p(o){const a=(s,t)=>({clear:()=>t.delete(s),get:()=>t.get(s),set:n=>t.set(s,n)}),r=a(o,i),e=a(o,c);return{clear:()=>{r.clear(),e.clear()},promise:r,response:e}}async function l(o,{cacheKey:a,cacheTime:r=Number.POSITIVE_INFINITY}){const e=p(a),s=e.response.get();if(s&&r>0&&new Date().getTime()-s.created.getTime()<r)return s.data;let t=e.promise.get();t||(t=o(),e.promise.set(t));try{const n=await t;return e.response.set({created:new Date,data:n}),n}finally{e.promise.clear()}}exports.getCache=p;exports.promiseCache=i;exports.responseCache=c;exports.withCache=l;
package/dist/index47.js CHANGED
@@ -1,8 +1,34 @@
1
- import { hashMessage as e } from "./index55.js";
2
- import { sign as o } from "./index45.js";
3
- async function i({ message: s, privateKey: a }) {
4
- return await o({ hash: e(s), privateKey: a, to: "hex" });
1
+ const i = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
2
+ function p(o) {
3
+ const a = (s, t) => ({
4
+ clear: () => t.delete(s),
5
+ get: () => t.get(s),
6
+ set: (r) => t.set(s, r)
7
+ }), n = a(o, i), e = a(o, c);
8
+ return {
9
+ clear: () => {
10
+ n.clear(), e.clear();
11
+ },
12
+ promise: n,
13
+ response: e
14
+ };
15
+ }
16
+ async function l(o, { cacheKey: a, cacheTime: n = Number.POSITIVE_INFINITY }) {
17
+ const e = p(a), s = e.response.get();
18
+ if (s && n > 0 && (/* @__PURE__ */ new Date()).getTime() - s.created.getTime() < n)
19
+ return s.data;
20
+ let t = e.promise.get();
21
+ t || (t = o(), e.promise.set(t));
22
+ try {
23
+ const r = await t;
24
+ return e.response.set({ created: /* @__PURE__ */ new Date(), data: r }), r;
25
+ } finally {
26
+ e.promise.clear();
27
+ }
5
28
  }
6
29
  export {
7
- i as signMessage
30
+ p as getCache,
31
+ i as promiseCache,
32
+ c as responseCache,
33
+ l as withCache
8
34
  };
package/dist/index48.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index56.cjs"),c=require("./index57.cjs"),o=require("./index45.cjs");async function u(i){const{privateKey:r,transaction:e,serializer:n=c.serializeTransaction}=i,a=e.type==="eip4844"?{...e,sidecars:!1}:e,s=await o.sign({hash:t.keccak256(n(a)),privateKey:r});return n(e,s)}exports.signTransaction=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("./index49.cjs"),u=require("./index24.cjs"),g=require("./index50.cjs");async function l(t,{blockHash:a,blockNumber:n,blockTag:f,hash:r,index:o}){var c,d,m;const s=f||"latest",i=n!==void 0?u.numberToHex(n):void 0;let e=null;if(r?e=await t.request({method:"eth_getTransactionByHash",params:[r]},{dedupe:!0}):a?e=await t.request({method:"eth_getTransactionByBlockHashAndIndex",params:[a,u.numberToHex(o)]},{dedupe:!0}):(i||s)&&(e=await t.request({method:"eth_getTransactionByBlockNumberAndIndex",params:[i||s,u.numberToHex(o)]},{dedupe:!!i})),!e)throw new T.TransactionNotFoundError({blockHash:a,blockNumber:n,blockTag:s,hash:r,index:o});return(((m=(d=(c=t.chain)==null?void 0:c.formatters)==null?void 0:d.transaction)==null?void 0:m.format)||g.formatTransaction)(e)}exports.getTransaction=l;
package/dist/index48.js CHANGED
@@ -1,16 +1,29 @@
1
- import { keccak256 as e } from "./index56.js";
2
- import { serializeTransaction as o } from "./index57.js";
3
- import { sign as c } from "./index45.js";
4
- async function u(n) {
5
- const { privateKey: a, transaction: r, serializer: i = o } = n, t = r.type === "eip4844" ? {
6
- ...r,
7
- sidecars: !1
8
- } : r, s = await c({
9
- hash: e(i(t)),
10
- privateKey: a
11
- });
12
- return i(r, s);
1
+ import { TransactionNotFoundError as p } from "./index49.js";
2
+ import { numberToHex as i } from "./index24.js";
3
+ import { formatTransaction as T } from "./index50.js";
4
+ async function h(e, { blockHash: a, blockNumber: r, blockTag: c, hash: o, index: n }) {
5
+ var d, f, u;
6
+ const s = c || "latest", m = r !== void 0 ? i(r) : void 0;
7
+ let t = null;
8
+ if (o ? t = await e.request({
9
+ method: "eth_getTransactionByHash",
10
+ params: [o]
11
+ }, { dedupe: !0 }) : a ? t = await e.request({
12
+ method: "eth_getTransactionByBlockHashAndIndex",
13
+ params: [a, i(n)]
14
+ }, { dedupe: !0 }) : (m || s) && (t = await e.request({
15
+ method: "eth_getTransactionByBlockNumberAndIndex",
16
+ params: [m || s, i(n)]
17
+ }, { dedupe: !!m })), !t)
18
+ throw new p({
19
+ blockHash: a,
20
+ blockNumber: r,
21
+ blockTag: s,
22
+ hash: o,
23
+ index: n
24
+ });
25
+ return (((u = (f = (d = e.chain) == null ? void 0 : d.formatters) == null ? void 0 : f.transaction) == null ? void 0 : u.format) || T)(t);
13
26
  }
14
27
  export {
15
- u as signTransaction
28
+ h as getTransaction
16
29
  };
package/dist/index49.cjs CHANGED
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index58.cjs"),s=require("./index45.cjs");async function i(e){const{privateKey:t,...a}=e;return await s.sign({hash:n.hashTypedData(a),privateKey:t,to:"hex"})}exports.signTypedData=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index65.cjs");function c(t){const r=Object.entries(t).map(([a,e])=>e===void 0||e===!1?null:[a,e]).filter(Boolean),s=r.reduce((a,[e])=>Math.max(a,e.length),0);return r.map(([a,e])=>` ${`${a}:`.padEnd(s+1)} ${e}`).join(`
2
+ `)}class d extends o.BaseError{constructor({v:r}){super(`Invalid \`v\` value "${r}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}}class l extends o.BaseError{constructor({transaction:r}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",c(r),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class u extends o.BaseError{constructor({storageKey:r}){super(`Size for storage key "${r}" is invalid. Expected 32 bytes. Got ${Math.floor((r.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}class T extends o.BaseError{constructor({blockHash:r,blockNumber:s,blockTag:a,hash:e,index:n}){let i="Transaction";a&&n!==void 0&&(i=`Transaction at block time "${a}" at index "${n}"`),r&&n!==void 0&&(i=`Transaction at block hash "${r}" at index "${n}"`),s&&n!==void 0&&(i=`Transaction at block number "${s}" at index "${n}"`),e&&(i=`Transaction with hash "${e}"`),super(`${i} could not be found.`,{name:"TransactionNotFoundError"})}}class E extends o.BaseError{constructor({hash:r}){super(`Transaction receipt with hash "${r}" could not be found. The Transaction may not be processed on a block yet.`,{name:"TransactionReceiptNotFoundError"})}}class p extends o.BaseError{constructor({hash:r}){super(`Timed out while waiting for transaction with hash "${r}" to be confirmed.`,{name:"WaitForTransactionReceiptTimeoutError"})}}exports.InvalidLegacyVError=d;exports.InvalidSerializableTransactionError=l;exports.InvalidStorageKeySizeError=u;exports.TransactionNotFoundError=T;exports.TransactionReceiptNotFoundError=E;exports.WaitForTransactionReceiptTimeoutError=p;exports.prettyPrint=c;
package/dist/index49.js CHANGED
@@ -1,13 +1,68 @@
1
- import { hashTypedData as o } from "./index58.js";
2
- import { sign as r } from "./index45.js";
3
- async function p(t) {
4
- const { privateKey: a, ...e } = t;
5
- return await r({
6
- hash: o(e),
7
- privateKey: a,
8
- to: "hex"
9
- });
1
+ import { BaseError as o } from "./index65.js";
2
+ function c(e) {
3
+ const r = Object.entries(e).map(([t, n]) => n === void 0 || n === !1 ? null : [t, n]).filter(Boolean), s = r.reduce((t, [n]) => Math.max(t, n.length), 0);
4
+ return r.map(([t, n]) => ` ${`${t}:`.padEnd(s + 1)} ${n}`).join(`
5
+ `);
6
+ }
7
+ class u extends o {
8
+ constructor({ v: r }) {
9
+ super(`Invalid \`v\` value "${r}". Expected 27 or 28.`, {
10
+ name: "InvalidLegacyVError"
11
+ });
12
+ }
13
+ }
14
+ class l extends o {
15
+ constructor({ transaction: r }) {
16
+ super("Cannot infer a transaction type from provided transaction.", {
17
+ metaMessages: [
18
+ "Provided Transaction:",
19
+ "{",
20
+ c(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 T extends o {
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
+ class h extends o {
41
+ constructor({ blockHash: r, blockNumber: s, blockTag: t, hash: n, index: a }) {
42
+ let i = "Transaction";
43
+ t && a !== void 0 && (i = `Transaction at block time "${t}" at index "${a}"`), r && a !== void 0 && (i = `Transaction at block hash "${r}" at index "${a}"`), s && a !== void 0 && (i = `Transaction at block number "${s}" at index "${a}"`), n && (i = `Transaction with hash "${n}"`), super(`${i} could not be found.`, {
44
+ name: "TransactionNotFoundError"
45
+ });
46
+ }
47
+ }
48
+ class p extends o {
49
+ constructor({ hash: r }) {
50
+ super(`Transaction receipt with hash "${r}" could not be found. The Transaction may not be processed on a block yet.`, {
51
+ name: "TransactionReceiptNotFoundError"
52
+ });
53
+ }
54
+ }
55
+ class f extends o {
56
+ constructor({ hash: r }) {
57
+ super(`Timed out while waiting for transaction with hash "${r}" to be confirmed.`, { name: "WaitForTransactionReceiptTimeoutError" });
58
+ }
10
59
  }
11
60
  export {
12
- p as signTypedData
61
+ u as InvalidLegacyVError,
62
+ l as InvalidSerializableTransactionError,
63
+ T as InvalidStorageKeySizeError,
64
+ h as TransactionNotFoundError,
65
+ p as TransactionReceiptNotFoundError,
66
+ f as WaitForTransactionReceiptTimeoutError,
67
+ c as prettyPrint
13
68
  };
package/dist/index50.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index63.cjs");class r extends s.BaseError{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}exports.InvalidAddressError=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index35.cjs"),i={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function u(e){const d={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?r.hexToNumber(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?r.hexToNumber(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?i[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(d.authorizationList=l(e.authorizationList)),d.yParity=(()=>{if(e.yParity)return Number(e.yParity);if(typeof d.v=="bigint"){if(d.v===0n||d.v===27n)return 0;if(d.v===1n||d.v===28n)return 1;if(d.v>=35n)return d.v%2n===0n?1:0}})(),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}function l(e){return e.map(d=>({contractAddress:d.address,chainId:Number(d.chainId),nonce:Number(d.nonce),r:d.r,s:d.s,yParity:Number(d.yParity)}))}exports.formatTransaction=u;exports.transactionType=i;
package/dist/index50.js CHANGED
@@ -1,15 +1,54 @@
1
- import { BaseError as r } from "./index63.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
- }
1
+ import { hexToNumber as i } from "./index35.js";
2
+ const r = {
3
+ "0x0": "legacy",
4
+ "0x1": "eip2930",
5
+ "0x2": "eip1559",
6
+ "0x3": "eip4844",
7
+ "0x4": "eip7702"
8
+ };
9
+ function m(e) {
10
+ const d = {
11
+ ...e,
12
+ blockHash: e.blockHash ? e.blockHash : null,
13
+ blockNumber: e.blockNumber ? BigInt(e.blockNumber) : null,
14
+ chainId: e.chainId ? i(e.chainId) : void 0,
15
+ gas: e.gas ? BigInt(e.gas) : void 0,
16
+ gasPrice: e.gasPrice ? BigInt(e.gasPrice) : void 0,
17
+ maxFeePerBlobGas: e.maxFeePerBlobGas ? BigInt(e.maxFeePerBlobGas) : void 0,
18
+ maxFeePerGas: e.maxFeePerGas ? BigInt(e.maxFeePerGas) : void 0,
19
+ maxPriorityFeePerGas: e.maxPriorityFeePerGas ? BigInt(e.maxPriorityFeePerGas) : void 0,
20
+ nonce: e.nonce ? i(e.nonce) : void 0,
21
+ to: e.to ? e.to : null,
22
+ transactionIndex: e.transactionIndex ? Number(e.transactionIndex) : null,
23
+ type: e.type ? r[e.type] : void 0,
24
+ typeHex: e.type ? e.type : void 0,
25
+ value: e.value ? BigInt(e.value) : void 0,
26
+ v: e.v ? BigInt(e.v) : void 0
27
+ };
28
+ return e.authorizationList && (d.authorizationList = u(e.authorizationList)), d.yParity = (() => {
29
+ if (e.yParity)
30
+ return Number(e.yParity);
31
+ if (typeof d.v == "bigint") {
32
+ if (d.v === 0n || d.v === 27n)
33
+ return 0;
34
+ if (d.v === 1n || d.v === 28n)
35
+ return 1;
36
+ if (d.v >= 35n)
37
+ return d.v % 2n === 0n ? 1 : 0;
38
+ }
39
+ })(), 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;
40
+ }
41
+ function u(e) {
42
+ return e.map((d) => ({
43
+ contractAddress: d.address,
44
+ chainId: Number(d.chainId),
45
+ nonce: Number(d.nonce),
46
+ r: d.r,
47
+ s: d.s,
48
+ yParity: Number(d.yParity)
49
+ }));
12
50
  }
13
51
  export {
14
- d as InvalidAddressError
52
+ m as formatTransaction,
53
+ r as transactionType
15
54
  };
package/dist/index51.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index72.cjs"),i=require("./index59.cjs"),o=/^0x[a-fA-F0-9]{40}$/,t=new c.LruMap(8192);function f(e,n){const{strict:s=!0}=n??{},r=`${e}.${s}`;if(t.has(r))return t.get(r);const u=o.test(e)?e.toLowerCase()===e?!0:s?i.checksumAddress(e)===e:!0:!1;return t.set(r,u),u}exports.isAddress=f;exports.isAddressCache=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index49.cjs"),i=require("./index52.cjs");async function s(t,{hash:e}){var a,n,o;const r=await t.request({method:"eth_getTransactionReceipt",params:[e]},{dedupe:!0});if(!r)throw new c.TransactionReceiptNotFoundError({hash:e});return(((o=(n=(a=t.chain)==null?void 0:a.formatters)==null?void 0:n.transactionReceipt)==null?void 0:o.format)||i.formatTransactionReceipt)(r)}exports.getTransactionReceipt=s;
package/dist/index51.js CHANGED
@@ -1,14 +1,15 @@
1
- import { LruMap as u } from "./index72.js";
2
- import { checksumAddress as c } from "./index59.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 { TransactionReceiptNotFoundError as i } from "./index49.js";
2
+ import { formatTransactionReceipt as c } from "./index52.js";
3
+ async function f(t, { hash: r }) {
4
+ var o, a, n;
5
+ const e = await t.request({
6
+ method: "eth_getTransactionReceipt",
7
+ params: [r]
8
+ }, { dedupe: !0 });
9
+ if (!e)
10
+ throw new i({ hash: r });
11
+ return (((n = (a = (o = t.chain) == null ? void 0 : o.formatters) == null ? void 0 : a.transactionReceipt) == null ? void 0 : n.format) || c)(e);
10
12
  }
11
13
  export {
12
- h as isAddress,
13
- r as isAddressCache
14
+ f as getTransactionReceipt
14
15
  };
package/dist/index52.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index42.cjs"),n=require("./index35.cjs"),a=require("./index53.cjs");function g({r:i,s:o,to:u="hex",v:e,yParity:r}){const s=(()=>{if(r===0||r===1)return r;if(e&&(e===27n||e===28n||e>=35n))return e%2n===0n?1:0;throw new Error("Invalid `v` or `yParity` value")})(),t=`0x${new c.secp256k1.Signature(n.hexToBigInt(i),n.hexToBigInt(o)).toCompactHex()}${s===0?"1b":"1c"}`;return u==="hex"?t:a.hexToBytes(t)}exports.serializeSignature=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./index35.cjs"),d=require("./index86.cjs"),r=require("./index50.cjs"),u={"0x0":"reverted","0x1":"success"};function o(l){const s={...l,blockNumber:l.blockNumber?BigInt(l.blockNumber):null,contractAddress:l.contractAddress?l.contractAddress:null,cumulativeGasUsed:l.cumulativeGasUsed?BigInt(l.cumulativeGasUsed):null,effectiveGasPrice:l.effectiveGasPrice?BigInt(l.effectiveGasPrice):null,gasUsed:l.gasUsed?BigInt(l.gasUsed):null,logs:l.logs?l.logs.map(e=>d.formatLog(e)):null,to:l.to?l.to:null,transactionIndex:l.transactionIndex?b.hexToNumber(l.transactionIndex):null,status:l.status?u[l.status]:null,type:l.type?r.transactionType[l.type]||l.type:null};return l.blobGasPrice&&(s.blobGasPrice=BigInt(l.blobGasPrice)),l.blobGasUsed&&(s.blobGasUsed=BigInt(l.blobGasUsed)),s}exports.formatTransactionReceipt=o;exports.receiptStatuses=u;
package/dist/index52.js CHANGED
@@ -1,16 +1,27 @@
1
- import { secp256k1 as f } from "./index42.js";
2
- import { hexToBigInt as t } from "./index35.js";
3
- import { hexToBytes as m } from "./index53.js";
4
- function s({ r: o, s: i, to: u = "hex", v: r, yParity: e }) {
5
- const a = (() => {
6
- if (e === 0 || e === 1)
7
- return e;
8
- if (r && (r === 27n || r === 28n || r >= 35n))
9
- return r % 2n === 0n ? 1 : 0;
10
- throw new Error("Invalid `v` or `yParity` value");
11
- })(), n = `0x${new f.Signature(t(o), t(i)).toCompactHex()}${a === 0 ? "1b" : "1c"}`;
12
- return u === "hex" ? n : m(n);
1
+ import { hexToNumber as b } from "./index35.js";
2
+ import { formatLog as d } from "./index86.js";
3
+ import { transactionType as m } from "./index50.js";
4
+ const f = {
5
+ "0x0": "reverted",
6
+ "0x1": "success"
7
+ };
8
+ function r(l) {
9
+ const u = {
10
+ ...l,
11
+ blockNumber: l.blockNumber ? BigInt(l.blockNumber) : null,
12
+ contractAddress: l.contractAddress ? l.contractAddress : null,
13
+ cumulativeGasUsed: l.cumulativeGasUsed ? BigInt(l.cumulativeGasUsed) : null,
14
+ effectiveGasPrice: l.effectiveGasPrice ? BigInt(l.effectiveGasPrice) : null,
15
+ gasUsed: l.gasUsed ? BigInt(l.gasUsed) : null,
16
+ logs: l.logs ? l.logs.map((s) => d(s)) : null,
17
+ to: l.to ? l.to : null,
18
+ transactionIndex: l.transactionIndex ? b(l.transactionIndex) : null,
19
+ status: l.status ? f[l.status] : null,
20
+ type: l.type ? m[l.type] || l.type : null
21
+ };
22
+ return l.blobGasPrice && (u.blobGasPrice = BigInt(l.blobGasPrice)), l.blobGasUsed && (u.blobGasUsed = BigInt(l.blobGasUsed)), u;
13
23
  }
14
24
  export {
15
- s as serializeSignature
25
+ r as formatTransactionReceipt,
26
+ f as receiptStatuses
16
27
  };
package/dist/index53.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index63.cjs"),l=require("./index83.cjs"),u=require("./index61.cjs"),f=require("./index35.cjs"),m=require("./index25.cjs"),h=new TextEncoder;function A(e,n={}){return typeof e=="number"||typeof e=="bigint"?B(e,n):typeof e=="boolean"?x(e,n):l.isHex(e)?c(e,n):T(e,n)}function x(e,n={}){const t=new Uint8Array(1);return t[0]=Number(e),typeof n.size=="number"?(f.assertSize(t,{size:n.size}),u.pad(t,{size:n.size})):t}const i={zero:48,nine:57,A:65,F:70,a:97,f:102};function g(e){if(e>=i.zero&&e<=i.nine)return e-i.zero;if(e>=i.A&&e<=i.F)return e-(i.A-10);if(e>=i.a&&e<=i.f)return e-(i.a-10)}function c(e,n={}){let t=e;n.size&&(f.assertSize(t,{size:n.size}),t=u.pad(t,{dir:"right",size:n.size}));let r=t.slice(2);r.length%2&&(r=`0${r}`);const d=r.length/2,y=new Uint8Array(d);for(let s=0,o=0;s<d;s++){const b=g(r.charCodeAt(o++)),z=g(r.charCodeAt(o++));if(b===void 0||z===void 0)throw new a.BaseError(`Invalid byte sequence ("${r[o-2]}${r[o-1]}" in "${r}").`);y[s]=b*16+z}return y}function B(e,n){const t=m.numberToHex(e,n);return c(t)}function T(e,n={}){const t=h.encode(e);return typeof n.size=="number"?(f.assertSize(t,{size:n.size}),u.pad(t,{dir:"right",size:n.size})):t}exports.boolToBytes=x;exports.hexToBytes=c;exports.numberToBytes=B;exports.stringToBytes=T;exports.toBytes=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("./index35.cjs"),d=require("./index54.cjs"),y=require("./index55.cjs"),h=require("./index56.cjs"),B=require("./index57.cjs"),m=require("./index46.cjs");function q(t,{emitOnBegin:b=!1,emitMissed:l=!1,onBlockNumber:p,onError:a,poll:k,pollingInterval:i=t.pollingInterval}){const g=typeof k<"u"?k:!(t.transport.type==="webSocket"||t.transport.type==="fallback"&&t.transport.transports[0].config.type==="webSocket");let r;return g?(()=>{const f=B.stringify(["watchBlockNumber",t.uid,b,l,i]);return y.observe(f,{onBlockNumber:p,onError:a},o=>h.poll(async()=>{var c;try{const e=await d.getAction(t,m.getBlockNumber,"getBlockNumber")({cacheTime:0});if(r){if(e===r)return;if(e-r>1&&l)for(let s=r+1n;s<e;s++)o.onBlockNumber(s,r),r=s}(!r||e>r)&&(o.onBlockNumber(e,r),r=e)}catch(e){(c=o.onError)==null||c.call(o,e)}},{emitOnBegin:b,interval:i}))})():(()=>{const f=B.stringify(["watchBlockNumber",t.uid,b,l]);return y.observe(f,{onBlockNumber:p,onError:a},o=>{let c=!0,e=()=>c=!1;return(async()=>{try{const s=(()=>{if(t.transport.type==="fallback"){const n=t.transport.transports.find(u=>u.config.type==="webSocket");return n?n.value:t.transport}return t.transport})(),{unsubscribe:v}=await s.subscribe({params:["newHeads"],onData(n){var N;if(!c)return;const u=w.hexToBigInt((N=n.result)==null?void 0:N.number);o.onBlockNumber(u,r),r=u},onError(n){var u;(u=o.onError)==null||u.call(o,n)}});e=v,c||e()}catch(s){a==null||a(s)}})(),()=>e()})})()}exports.watchBlockNumber=q;