@gardenfi/utils 2.1.2-beta.7 → 2.1.2-beta.8

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 (173) hide show
  1. package/dist/index100.cjs +1 -1
  2. package/dist/index100.js +5 -5
  3. package/dist/index101.cjs +2 -1
  4. package/dist/index101.js +3 -11
  5. package/dist/index102.cjs +1 -1
  6. package/dist/index102.js +18 -6
  7. package/dist/index103.cjs +1 -1
  8. package/dist/index103.js +638 -15
  9. package/dist/index104.cjs +1 -1
  10. package/dist/index104.js +173 -5
  11. package/dist/index18.cjs +1 -1
  12. package/dist/index18.js +2 -2
  13. package/dist/index19.cjs +1 -1
  14. package/dist/index19.js +9 -9
  15. package/dist/index20.cjs +1 -1
  16. package/dist/index20.js +1 -1
  17. package/dist/index21.cjs +1 -1
  18. package/dist/index21.js +3 -3
  19. package/dist/index22.cjs +1 -1
  20. package/dist/index22.js +1 -1
  21. package/dist/index23.cjs +2 -1
  22. package/dist/index23.js +49 -40
  23. package/dist/index24.cjs +1 -1
  24. package/dist/index24.js +24 -45
  25. package/dist/index25.cjs +1 -1
  26. package/dist/index25.js +41 -25
  27. package/dist/index26.cjs +1 -1
  28. package/dist/index26.js +45 -6
  29. package/dist/index27.cjs +1 -1
  30. package/dist/index27.js +24 -12
  31. package/dist/index28.cjs +1 -1
  32. package/dist/index28.js +6 -15
  33. package/dist/index29.cjs +1 -1
  34. package/dist/index29.js +13 -5
  35. package/dist/index30.cjs +1 -1
  36. package/dist/index30.js +14 -12
  37. package/dist/index31.cjs +1 -1
  38. package/dist/index31.js +5 -10
  39. package/dist/index32.cjs +1 -1
  40. package/dist/index32.js +13 -12
  41. package/dist/index33.cjs +1 -1
  42. package/dist/index33.js +10 -11
  43. package/dist/index34.cjs +1 -1
  44. package/dist/index34.js +12 -13
  45. package/dist/index35.cjs +1 -1
  46. package/dist/index35.js +11 -23
  47. package/dist/index36.cjs +1 -1
  48. package/dist/index36.js +13 -55
  49. package/dist/index37.cjs +1 -1
  50. package/dist/index37.js +23 -16
  51. package/dist/index38.cjs +1 -1
  52. package/dist/index38.js +55 -5
  53. package/dist/index39.cjs +1 -1
  54. package/dist/index39.js +16 -8
  55. package/dist/index40.cjs +1 -1
  56. package/dist/index40.js +5 -171
  57. package/dist/index41.cjs +1 -1
  58. package/dist/index41.js +8 -103
  59. package/dist/index42.cjs +1 -1
  60. package/dist/index42.js +170 -20
  61. package/dist/index43.cjs +1 -2
  62. package/dist/index43.js +97 -44
  63. package/dist/index44.cjs +1 -1
  64. package/dist/index44.js +21 -24
  65. package/dist/index45.cjs +1 -1
  66. package/dist/index45.js +1 -1
  67. package/dist/index47.cjs +1 -1
  68. package/dist/index47.js +6 -40
  69. package/dist/index48.cjs +2 -1
  70. package/dist/index48.js +58 -33
  71. package/dist/index49.cjs +1 -1
  72. package/dist/index49.js +2 -70
  73. package/dist/index50.cjs +1 -1
  74. package/dist/index50.js +5 -111
  75. package/dist/index51.cjs +1 -1
  76. package/dist/index51.js +4 -67
  77. package/dist/index52.cjs +1 -1
  78. package/dist/index52.js +12 -2
  79. package/dist/index53.cjs +1 -1
  80. package/dist/index53.js +8 -17
  81. package/dist/index54.cjs +5 -1
  82. package/dist/index54.js +48 -215
  83. package/dist/index55.cjs +2 -1
  84. package/dist/index55.js +31 -228
  85. package/dist/index56.cjs +1 -2
  86. package/dist/index56.js +5 -59
  87. package/dist/index57.cjs +1 -1
  88. package/dist/index57.js +2 -22
  89. package/dist/index58.cjs +1 -1
  90. package/dist/index58.js +18 -101
  91. package/dist/index59.cjs +1 -1
  92. package/dist/index59.js +8 -3
  93. package/dist/index60.cjs +1 -1
  94. package/dist/index60.js +9 -16
  95. package/dist/index61.cjs +1 -1
  96. package/dist/index61.js +11 -8
  97. package/dist/index62.cjs +1 -1
  98. package/dist/index62.js +6 -10
  99. package/dist/index63.cjs +1 -1
  100. package/dist/index63.js +13 -11
  101. package/dist/index64.cjs +1 -1
  102. package/dist/index64.js +31 -12
  103. package/dist/index65.cjs +1 -1
  104. package/dist/index65.js +14 -18
  105. package/dist/index66.cjs +1 -1
  106. package/dist/index66.js +64 -6
  107. package/dist/index67.cjs +1 -1
  108. package/dist/index67.js +25 -40
  109. package/dist/index68.cjs +1 -1
  110. package/dist/index68.js +3 -79
  111. package/dist/index69.cjs +1 -1
  112. package/dist/index69.js +3 -14
  113. package/dist/index70.cjs +1 -1
  114. package/dist/index70.js +8 -18
  115. package/dist/index71.cjs +1 -1
  116. package/dist/index71.js +191 -8
  117. package/dist/index72.cjs +1 -1
  118. package/dist/index72.js +18 -191
  119. package/dist/index73.cjs +1 -1
  120. package/dist/index73.js +39 -63
  121. package/dist/index74.cjs +1 -1
  122. package/dist/index74.js +34 -4
  123. package/dist/index75.cjs +1 -1
  124. package/dist/index75.js +70 -2
  125. package/dist/index76.cjs +1 -1
  126. package/dist/index76.js +111 -5
  127. package/dist/index77.cjs +1 -1
  128. package/dist/index77.js +67 -11
  129. package/dist/index78.cjs +1 -1
  130. package/dist/index78.js +2 -8
  131. package/dist/index79.cjs +1 -5
  132. package/dist/index79.js +15 -55
  133. package/dist/index80.cjs +1 -2
  134. package/dist/index80.js +220 -31
  135. package/dist/index81.cjs +1 -1
  136. package/dist/index81.js +231 -5
  137. package/dist/index82.cjs +1 -1
  138. package/dist/index82.js +43 -2
  139. package/dist/index83.cjs +1 -1
  140. package/dist/index83.js +104 -6
  141. package/dist/index84.cjs +1 -1
  142. package/dist/index84.js +16 -31
  143. package/dist/index85.cjs +1 -1
  144. package/dist/index85.js +75 -24
  145. package/dist/index86.cjs +1 -1
  146. package/dist/index86.js +19 -3
  147. package/dist/index87.cjs +1 -1
  148. package/dist/index87.js +8 -11
  149. package/dist/index88.cjs +1 -1
  150. package/dist/index88.js +11 -19
  151. package/dist/index89.cjs +1 -1
  152. package/dist/index89.js +19 -8
  153. package/dist/index90.cjs +1 -1
  154. package/dist/index90.js +1 -1
  155. package/dist/index91.cjs +1 -1
  156. package/dist/index91.js +37 -17
  157. package/dist/index92.cjs +1 -1
  158. package/dist/index92.js +2 -644
  159. package/dist/index93.cjs +1 -1
  160. package/dist/index93.js +5 -173
  161. package/dist/index94.cjs +1 -1
  162. package/dist/index94.js +10 -127
  163. package/dist/index95.cjs +1 -2
  164. package/dist/index95.js +128 -3
  165. package/dist/index96.cjs +1 -1
  166. package/dist/index96.js +7 -2
  167. package/dist/index97.cjs +1 -1
  168. package/dist/index97.js +2 -2
  169. package/dist/index98.cjs +1 -1
  170. package/dist/index98.js +2 -2
  171. package/dist/index99.cjs +1 -1
  172. package/dist/index99.js +17 -35
  173. package/package.json +1 -1
package/dist/index51.js CHANGED
@@ -1,70 +1,7 @@
1
- import { aexists as g, aoutput as d } from "./index48.js";
2
- import { Hash as b, createView as p, toBytes as a } from "./index49.js";
3
- function w(o, t, s, i) {
4
- if (typeof o.setBigUint64 == "function")
5
- return o.setBigUint64(t, s, i);
6
- const n = BigInt(32), h = BigInt(4294967295), e = Number(s >> n & h), r = Number(s & h), u = i ? 4 : 0, c = i ? 0 : 4;
7
- o.setUint32(t + u, e, i), o.setUint32(t + c, r, i);
8
- }
9
- function B(o, t, s) {
10
- return o & t ^ ~o & s;
11
- }
12
- function L(o, t, s) {
13
- return o & t ^ o & s ^ t & s;
14
- }
15
- class U extends b {
16
- constructor(t, s, i, n) {
17
- super(), this.blockLen = t, this.outputLen = s, this.padOffset = i, this.isLE = n, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(t), this.view = p(this.buffer);
18
- }
19
- update(t) {
20
- g(this);
21
- const { view: s, buffer: i, blockLen: n } = this;
22
- t = a(t);
23
- const h = t.length;
24
- for (let e = 0; e < h; ) {
25
- const r = Math.min(n - this.pos, h - e);
26
- if (r === n) {
27
- const u = p(t);
28
- for (; n <= h - e; e += n)
29
- this.process(u, e);
30
- continue;
31
- }
32
- i.set(t.subarray(e, e + r), this.pos), this.pos += r, e += r, this.pos === n && (this.process(s, 0), this.pos = 0);
33
- }
34
- return this.length += t.length, this.roundClean(), this;
35
- }
36
- digestInto(t) {
37
- g(this), d(t, this), this.finished = !0;
38
- const { buffer: s, view: i, blockLen: n, isLE: h } = this;
39
- let { pos: e } = this;
40
- s[e++] = 128, this.buffer.subarray(e).fill(0), this.padOffset > n - e && (this.process(i, 0), e = 0);
41
- for (let f = e; f < n; f++)
42
- s[f] = 0;
43
- w(i, n - 8, BigInt(this.length * 8), h), this.process(i, 0);
44
- const r = p(t), u = this.outputLen;
45
- if (u % 4)
46
- throw new Error("_sha2: outputLen should be aligned to 32bit");
47
- const c = u / 4, l = this.get();
48
- if (c > l.length)
49
- throw new Error("_sha2: outputLen bigger than state");
50
- for (let f = 0; f < c; f++)
51
- r.setUint32(4 * f, l[f], h);
52
- }
53
- digest() {
54
- const { buffer: t, outputLen: s } = this;
55
- this.digestInto(t);
56
- const i = t.slice(0, s);
57
- return this.destroy(), i;
58
- }
59
- _cloneInto(t) {
60
- t || (t = new this.constructor()), t.set(...this.get());
61
- const { blockLen: s, buffer: i, length: n, finished: h, destroyed: e, pos: r } = this;
62
- return t.length = n, t.pos = r, t.finished = h, t.destroyed = e, n % s && t.buffer.set(i), t;
63
- }
1
+ import { isHex as r } from "./index69.js";
2
+ function i(t) {
3
+ return r(t, { strict: !1 }) ? Math.ceil((t.length - 2) / 2) : t.length;
64
4
  }
65
5
  export {
66
- B as Chi,
67
- U as HashMD,
68
- L as Maj,
69
- w as setBigUint64
6
+ i as size
70
7
  };
package/dist/index52.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;exports.crypto=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(n,{args:a,eventName:t}={}){return{...n,blockHash:n.blockHash?n.blockHash:null,blockNumber:n.blockNumber?BigInt(n.blockNumber):null,logIndex:n.logIndex?Number(n.logIndex):null,transactionHash:n.transactionHash?n.transactionHash:null,transactionIndex:n.transactionIndex?Number(n.transactionIndex):null,...t?{args:a,eventName:t}:{}}}exports.formatLog=r;
package/dist/index52.js CHANGED
@@ -1,4 +1,14 @@
1
- const o = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
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 } : {}
10
+ };
11
+ }
2
12
  export {
3
- o as crypto
13
+ r as formatLog
4
14
  };
package/dist/index53.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index47.cjs"),s=require("./index49.cjs"),o=require("./index92.cjs");/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function c(e){return{hash:e,hmac:(r,...t)=>a.hmac(e,r,s.concatBytes(...t)),randomBytes:s.randomBytes}}function u(e,r){const t=n=>o.weierstrass({...e,...c(n)});return{...t(r),create:t}}exports.createCurve=u;exports.getHash=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};exports.transactionType=e;
package/dist/index53.js CHANGED
@@ -1,19 +1,10 @@
1
- import { hmac as c } from "./index47.js";
2
- import { randomBytes as m, concatBytes as n } from "./index49.js";
3
- import { weierstrass as a } from "./index92.js";
4
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
5
- function i(r) {
6
- return {
7
- hash: r,
8
- hmac: (e, ...t) => c(r, e, n(...t)),
9
- randomBytes: m
10
- };
11
- }
12
- function p(r, e) {
13
- const t = (o) => a({ ...r, ...i(o) });
14
- return { ...t(e), create: t };
15
- }
1
+ const e = {
2
+ "0x0": "legacy",
3
+ "0x1": "eip2930",
4
+ "0x2": "eip1559",
5
+ "0x3": "eip4844",
6
+ "0x4": "eip7702"
7
+ };
16
8
  export {
17
- p as createCurve,
18
- i as getHash
9
+ e as transactionType
19
10
  };
package/dist/index54.cjs CHANGED
@@ -1 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index55.cjs");/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const d=BigInt(0),c=BigInt(1),w=BigInt(2),j=BigInt(3),E=BigInt(4),S=BigInt(5),I=BigInt(8);function g(t,i){const r=t%i;return r>=d?r:i+r}function L(t,i,r){if(i<d)throw new Error("invalid exponent, negatives unsupported");if(r<=d)throw new Error("invalid modulus");if(r===c)return d;let n=c;for(;i>d;)i&c&&(n=n*t%r),t=t*t%r,i>>=c;return n}function H(t,i,r){let n=t;for(;i-- >d;)n*=n,n%=r;return n}function m(t,i){if(t===d)throw new Error("invert: expected non-zero number");if(i<=d)throw new Error("invert: expected positive modulus, got "+i);let r=g(t,i),n=i,s=d,u=c;for(;r!==d;){const o=n/r,e=n%r,l=s-u*o;n=r,r=e,s=u,u=l}if(n!==c)throw new Error("invert: does not exist");return g(s,i)}function T(t){const i=(t-c)/w;let r,n,s;for(r=t-c,n=0;r%w===d;r/=w,n++);for(s=w;s<t&&L(s,i,t)!==t-c;s++)if(s>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){const f=(t+c)/E;return function(e,l){const h=e.pow(l,f);if(!e.eql(e.sqr(h),l))throw new Error("Cannot find square root");return h}}const u=(r+c)/w;return function(o,e){if(o.pow(e,i)===o.neg(o.ONE))throw new Error("Cannot find square root");let l=n,h=o.pow(o.mul(o.ONE,s),r),v=o.pow(e,u),q=o.pow(e,r);for(;!o.eql(q,o.ONE);){if(o.eql(q,o.ZERO))return o.ZERO;let b=1;for(let B=o.sqr(q);b<l&&!o.eql(B,o.ONE);b++)B=o.sqr(B);const y=o.pow(h,c<<BigInt(l-b-1));h=o.sqr(y),v=o.mul(v,y),q=o.mul(q,h),l=b}return v}}function x(t){if(t%E===j){const i=(t+c)/E;return function(n,s){const u=n.pow(s,i);if(!n.eql(n.sqr(u),s))throw new Error("Cannot find square root");return u}}if(t%I===S){const i=(t-S)/I;return function(n,s){const u=n.mul(s,w),f=n.pow(u,i),o=n.mul(s,f),e=n.mul(n.mul(o,w),f),l=n.mul(o,n.sub(e,n.ONE));if(!n.eql(n.sqr(l),s))throw new Error("Cannot find square root");return l}}return T(t)}const Z=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function k(t){const i={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Z.reduce((n,s)=>(n[s]="function",n),i);return a.validateObject(t,r)}function M(t,i,r){if(r<d)throw new Error("invalid exponent, negatives unsupported");if(r===d)return t.ONE;if(r===c)return i;let n=t.ONE,s=i;for(;r>d;)r&c&&(n=t.mul(n,s)),s=t.sqr(s),r>>=c;return n}function _(t,i){const r=new Array(i.length),n=i.reduce((u,f,o)=>t.is0(f)?u:(r[o]=u,t.mul(u,f)),t.ONE),s=t.inv(n);return i.reduceRight((u,f,o)=>t.is0(f)?u:(r[o]=t.mul(u,r[o]),t.mul(u,f)),s),r}function p(t,i){const r=i!==void 0?i:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function z(t,i,r=!1,n={}){if(t<=d)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:s,nByteLength:u}=p(t,i);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let f;const o=Object.freeze({ORDER:t,isLE:r,BITS:s,BYTES:u,MASK:a.bitMask(s),ZERO:d,ONE:c,create:e=>g(e,t),isValid:e=>{if(typeof e!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof e);return d<=e&&e<t},is0:e=>e===d,isOdd:e=>(e&c)===c,neg:e=>g(-e,t),eql:(e,l)=>e===l,sqr:e=>g(e*e,t),add:(e,l)=>g(e+l,t),sub:(e,l)=>g(e-l,t),mul:(e,l)=>g(e*l,t),pow:(e,l)=>M(o,e,l),div:(e,l)=>g(e*m(l,t),t),sqrN:e=>e*e,addN:(e,l)=>e+l,subN:(e,l)=>e-l,mulN:(e,l)=>e*l,inv:e=>m(e,t),sqrt:n.sqrt||(e=>(f||(f=x(t)),f(o,e))),invertBatch:e=>_(o,e),cmov:(e,l,h)=>h?l:e,toBytes:e=>r?a.numberToBytesLE(e,u):a.numberToBytesBE(e,u),fromBytes:e=>{if(e.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+e.length);return r?a.bytesToNumberLE(e):a.bytesToNumberBE(e)}});return Object.freeze(o)}function N(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const i=t.toString(2).length;return Math.ceil(i/8)}function C(t){const i=N(t);return i+Math.ceil(i/2)}function A(t,i,r=!1){const n=t.length,s=N(i),u=C(i);if(n<16||n<u||n>1024)throw new Error("expected "+u+"-1024 bytes of input, got "+n);const f=r?a.bytesToNumberLE(t):a.bytesToNumberBE(t),o=g(f,i-c)+c;return r?a.numberToBytesLE(o,s):a.numberToBytesBE(o,s)}exports.Field=z;exports.FpInvertBatch=_;exports.FpPow=M;exports.FpSqrt=x;exports.getFieldBytesLength=N;exports.getMinHashLength=C;exports.invert=m;exports.mapHashToField=A;exports.mod=g;exports.nLength=p;exports.pow=L;exports.pow2=H;exports.tonelliShanks=T;exports.validateField=k;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index51.cjs"),n=require("./index48.cjs");class o extends n.BaseError{constructor({expectedLength:r,givenLength:e,type:t}){super([`ABI encoding array length mismatch for type ${t}.`,`Expected length: ${r}`,`Given length: ${e}`].join(`
2
+ `),{name:"AbiEncodingArrayLengthMismatchError"})}}class a extends n.BaseError{constructor({expectedSize:r,value:e}){super(`Size of bytes "${e}" (bytes${i.size(e)}) does not match expected size (bytes${r}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class c extends n.BaseError{constructor({expectedLength:r,givenLength:e}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${r}`,`Given length (values): ${e}`].join(`
3
+ `),{name:"AbiEncodingLengthMismatchError"})}}class d extends n.BaseError{constructor({expectedSize:r,givenSize:e}){super(`Expected bytes${r}, got bytes${e}.`,{name:"BytesSizeMismatchError"})}}class E extends n.BaseError{constructor(r,{docsPath:e}){super([`Type "${r}" is not a valid encoding type.`,"Please provide a valid ABI type."].join(`
4
+ `),{docsPath:e,name:"InvalidAbiEncodingType"})}}class g extends n.BaseError{constructor(r){super([`Value "${r}" is not a valid array.`].join(`
5
+ `),{name:"InvalidArrayError"})}}exports.AbiEncodingArrayLengthMismatchError=o;exports.AbiEncodingBytesSizeMismatchError=a;exports.AbiEncodingLengthMismatchError=c;exports.BytesSizeMismatchError=d;exports.InvalidAbiEncodingTypeError=E;exports.InvalidArrayError=g;
package/dist/index54.js CHANGED
@@ -1,226 +1,59 @@
1
- import { numberToBytesLE as S, numberToBytesBE as x, bitMask as _, bytesToNumberLE as y, bytesToNumberBE as L, validateObject as M } from "./index55.js";
2
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3
- const d = BigInt(0), c = BigInt(1), w = /* @__PURE__ */ BigInt(2), C = /* @__PURE__ */ BigInt(3), b = /* @__PURE__ */ BigInt(4), N = /* @__PURE__ */ BigInt(5), m = /* @__PURE__ */ BigInt(8);
4
- function g(t, i) {
5
- const r = t % i;
6
- return r >= d ? r : i + r;
7
- }
8
- function Z(t, i, r) {
9
- if (i < d)
10
- throw new Error("invalid exponent, negatives unsupported");
11
- if (r <= d)
12
- throw new Error("invalid modulus");
13
- if (r === c)
14
- return d;
15
- let e = c;
16
- for (; i > d; )
17
- i & c && (e = e * t % r), t = t * t % r, i >>= c;
18
- return e;
19
- }
20
- function V(t, i, r) {
21
- let e = t;
22
- for (; i-- > d; )
23
- e *= e, e %= r;
24
- return e;
25
- }
26
- function I(t, i) {
27
- if (t === d)
28
- throw new Error("invert: expected non-zero number");
29
- if (i <= d)
30
- throw new Error("invert: expected positive modulus, got " + i);
31
- let r = g(t, i), e = i, s = d, u = c;
32
- for (; r !== d; ) {
33
- const o = e / r, n = e % r, l = s - u * o;
34
- e = r, r = n, s = u, u = l;
1
+ import { size as i } from "./index51.js";
2
+ import { BaseError as n } from "./index48.js";
3
+ class c extends n {
4
+ constructor({ expectedLength: e, givenLength: r, type: s }) {
5
+ super([
6
+ `ABI encoding array length mismatch for type ${s}.`,
7
+ `Expected length: ${e}`,
8
+ `Given length: ${r}`
9
+ ].join(`
10
+ `), { name: "AbiEncodingArrayLengthMismatchError" });
35
11
  }
36
- if (e !== c)
37
- throw new Error("invert: does not exist");
38
- return g(s, i);
39
12
  }
40
- function j(t) {
41
- const i = (t - c) / w;
42
- let r, e, s;
43
- for (r = t - c, e = 0; r % w === d; r /= w, e++)
44
- ;
45
- for (s = w; s < t && Z(s, i, t) !== t - c; s++)
46
- if (s > 1e3)
47
- throw new Error("Cannot find square root: likely non-prime P");
48
- if (e === 1) {
49
- const f = (t + c) / b;
50
- return function(n, l) {
51
- const h = n.pow(l, f);
52
- if (!n.eql(n.sqr(h), l))
53
- throw new Error("Cannot find square root");
54
- return h;
55
- };
13
+ class d extends n {
14
+ constructor({ expectedSize: e, value: r }) {
15
+ super(`Size of bytes "${r}" (bytes${i(r)}) does not match expected size (bytes${e}).`, { name: "AbiEncodingBytesSizeMismatchError" });
56
16
  }
57
- const u = (r + c) / w;
58
- return function(o, n) {
59
- if (o.pow(n, i) === o.neg(o.ONE))
60
- throw new Error("Cannot find square root");
61
- let l = e, h = o.pow(o.mul(o.ONE, s), r), v = o.pow(n, u), a = o.pow(n, r);
62
- for (; !o.eql(a, o.ONE); ) {
63
- if (o.eql(a, o.ZERO))
64
- return o.ZERO;
65
- let q = 1;
66
- for (let B = o.sqr(a); q < l && !o.eql(B, o.ONE); q++)
67
- B = o.sqr(B);
68
- const E = o.pow(h, c << BigInt(l - q - 1));
69
- h = o.sqr(E), v = o.mul(v, E), a = o.mul(a, h), l = q;
70
- }
71
- return v;
72
- };
73
17
  }
74
- function z(t) {
75
- if (t % b === C) {
76
- const i = (t + c) / b;
77
- return function(e, s) {
78
- const u = e.pow(s, i);
79
- if (!e.eql(e.sqr(u), s))
80
- throw new Error("Cannot find square root");
81
- return u;
82
- };
18
+ class m extends n {
19
+ constructor({ expectedLength: e, givenLength: r }) {
20
+ super([
21
+ "ABI encoding params/values length mismatch.",
22
+ `Expected length (params): ${e}`,
23
+ `Given length (values): ${r}`
24
+ ].join(`
25
+ `), { name: "AbiEncodingLengthMismatchError" });
83
26
  }
84
- if (t % m === N) {
85
- const i = (t - N) / m;
86
- return function(e, s) {
87
- const u = e.mul(s, w), f = e.pow(u, i), o = e.mul(s, f), n = e.mul(e.mul(o, w), f), l = e.mul(o, e.sub(n, e.ONE));
88
- if (!e.eql(e.sqr(l), s))
89
- throw new Error("Cannot find square root");
90
- return l;
91
- };
92
- }
93
- return j(t);
94
- }
95
- const A = [
96
- "create",
97
- "isValid",
98
- "is0",
99
- "neg",
100
- "inv",
101
- "sqrt",
102
- "sqr",
103
- "eql",
104
- "add",
105
- "sub",
106
- "mul",
107
- "pow",
108
- "div",
109
- "addN",
110
- "subN",
111
- "mulN",
112
- "sqrN"
113
- ];
114
- function Y(t) {
115
- const i = {
116
- ORDER: "bigint",
117
- MASK: "bigint",
118
- BYTES: "isSafeInteger",
119
- BITS: "isSafeInteger"
120
- }, r = A.reduce((e, s) => (e[s] = "function", e), i);
121
- return M(t, r);
122
- }
123
- function k(t, i, r) {
124
- if (r < d)
125
- throw new Error("invalid exponent, negatives unsupported");
126
- if (r === d)
127
- return t.ONE;
128
- if (r === c)
129
- return i;
130
- let e = t.ONE, s = i;
131
- for (; r > d; )
132
- r & c && (e = t.mul(e, s)), s = t.sqr(s), r >>= c;
133
- return e;
134
27
  }
135
- function H(t, i) {
136
- const r = new Array(i.length), e = i.reduce((u, f, o) => t.is0(f) ? u : (r[o] = u, t.mul(u, f)), t.ONE), s = t.inv(e);
137
- return i.reduceRight((u, f, o) => t.is0(f) ? u : (r[o] = t.mul(u, r[o]), t.mul(u, f)), s), r;
138
- }
139
- function K(t, i) {
140
- const r = i !== void 0 ? i : t.toString(2).length, e = Math.ceil(r / 8);
141
- return { nBitLength: r, nByteLength: e };
142
- }
143
- function p(t, i, r = !1, e = {}) {
144
- if (t <= d)
145
- throw new Error("invalid field: expected ORDER > 0, got " + t);
146
- const { nBitLength: s, nByteLength: u } = K(t, i);
147
- if (u > 2048)
148
- throw new Error("invalid field: expected ORDER of <= 2048 bytes");
149
- let f;
150
- const o = Object.freeze({
151
- ORDER: t,
152
- isLE: r,
153
- BITS: s,
154
- BYTES: u,
155
- MASK: _(s),
156
- ZERO: d,
157
- ONE: c,
158
- create: (n) => g(n, t),
159
- isValid: (n) => {
160
- if (typeof n != "bigint")
161
- throw new Error("invalid field element: expected bigint, got " + typeof n);
162
- return d <= n && n < t;
163
- },
164
- is0: (n) => n === d,
165
- isOdd: (n) => (n & c) === c,
166
- neg: (n) => g(-n, t),
167
- eql: (n, l) => n === l,
168
- sqr: (n) => g(n * n, t),
169
- add: (n, l) => g(n + l, t),
170
- sub: (n, l) => g(n - l, t),
171
- mul: (n, l) => g(n * l, t),
172
- pow: (n, l) => k(o, n, l),
173
- div: (n, l) => g(n * I(l, t), t),
174
- // Same as above, but doesn't normalize
175
- sqrN: (n) => n * n,
176
- addN: (n, l) => n + l,
177
- subN: (n, l) => n - l,
178
- mulN: (n, l) => n * l,
179
- inv: (n) => I(n, t),
180
- sqrt: e.sqrt || ((n) => (f || (f = z(t)), f(o, n))),
181
- invertBatch: (n) => H(o, n),
182
- // TODO: do we really need constant cmov?
183
- // We don't have const-time bigints anyway, so probably will be not very useful
184
- cmov: (n, l, h) => h ? l : n,
185
- toBytes: (n) => r ? S(n, u) : x(n, u),
186
- fromBytes: (n) => {
187
- if (n.length !== u)
188
- throw new Error("Field.fromBytes: expected " + u + " bytes, got " + n.length);
189
- return r ? y(n) : L(n);
190
- }
191
- });
192
- return Object.freeze(o);
193
- }
194
- function T(t) {
195
- if (typeof t != "bigint")
196
- throw new Error("field order must be bigint");
197
- const i = t.toString(2).length;
198
- return Math.ceil(i / 8);
28
+ class E extends n {
29
+ constructor({ expectedSize: e, givenSize: r }) {
30
+ super(`Expected bytes${e}, got bytes${r}.`, {
31
+ name: "BytesSizeMismatchError"
32
+ });
33
+ }
199
34
  }
200
- function O(t) {
201
- const i = T(t);
202
- return i + Math.ceil(i / 2);
35
+ class g extends n {
36
+ constructor(e, { docsPath: r }) {
37
+ super([
38
+ `Type "${e}" is not a valid encoding type.`,
39
+ "Please provide a valid ABI type."
40
+ ].join(`
41
+ `), { docsPath: r, name: "InvalidAbiEncodingType" });
42
+ }
203
43
  }
204
- function G(t, i, r = !1) {
205
- const e = t.length, s = T(i), u = O(i);
206
- if (e < 16 || e < u || e > 1024)
207
- throw new Error("expected " + u + "-1024 bytes of input, got " + e);
208
- const f = r ? y(t) : L(t), o = g(f, i - c) + c;
209
- return r ? S(o, s) : x(o, s);
44
+ class l extends n {
45
+ constructor(e) {
46
+ super([`Value "${e}" is not a valid array.`].join(`
47
+ `), {
48
+ name: "InvalidArrayError"
49
+ });
50
+ }
210
51
  }
211
52
  export {
212
- p as Field,
213
- H as FpInvertBatch,
214
- k as FpPow,
215
- z as FpSqrt,
216
- T as getFieldBytesLength,
217
- O as getMinHashLength,
218
- I as invert,
219
- G as mapHashToField,
220
- g as mod,
221
- K as nLength,
222
- Z as pow,
223
- V as pow2,
224
- j as tonelliShanks,
225
- Y as validateField
53
+ c as AbiEncodingArrayLengthMismatchError,
54
+ d as AbiEncodingBytesSizeMismatchError,
55
+ m as AbiEncodingLengthMismatchError,
56
+ E as BytesSizeMismatchError,
57
+ g as InvalidAbiEncodingTypeError,
58
+ l as InvalidArrayError
226
59
  };
package/dist/index55.cjs CHANGED
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const y=BigInt(0),d=BigInt(1),N=BigInt(2);function b(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function m(t){if(!b(t))throw new Error("Uint8Array expected")}function _(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const k=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function B(t){m(t);let e="";for(let r=0;r<t.length;r++)e+=k[t[r]];return e}function x(t){const e=t.toString(16);return e.length&1?"0"+e:e}function E(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?y:BigInt("0x"+t)}const f={_0:48,_9:57,A:65,F:70,a:97,f:102};function T(t){if(t>=f._0&&t<=f._9)return t-f._0;if(t>=f.A&&t<=f.F)return t-(f.A-10);if(t>=f.a&&t<=f.f)return t-(f.a-10)}function p(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){const a=T(t.charCodeAt(i)),s=T(t.charCodeAt(i+1));if(a===void 0||s===void 0){const c=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=a*16+s}return n}function H(t){return E(B(t))}function O(t){return m(t),E(B(Uint8Array.from(t).reverse()))}function U(t,e){return p(t.toString(16).padStart(e*2,"0"))}function F(t,e){return U(t,e).reverse()}function V(t){return p(x(t))}function M(t,e,r){let n;if(typeof e=="string")try{n=p(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(b(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const o=n.length;if(typeof r=="number"&&o!==r)throw new Error(t+" of length "+r+" expected, got "+o);return n}function I(...t){let e=0;for(let n=0;n<t.length;n++){const o=t[n];m(o),e+=o.length}const r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){const i=t[n];r.set(i,o),o+=i.length}return r}function R(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function j(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}const w=t=>typeof t=="bigint"&&y<=t;function S(t,e,r){return w(t)&&w(e)&&w(r)&&e<=t&&t<r}function z(t,e,r,n){if(!S(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function C(t){let e;for(e=0;t>y;t>>=d,e+=1);return e}function D(t,e){return t>>BigInt(e)&d}function G(t,e,r){return t|(r?d:y)<<BigInt(e)}const L=t=>(N<<BigInt(t-1))-d,h=t=>new Uint8Array(t),A=t=>Uint8Array.from(t);function P(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=h(t),o=h(t),i=0;const a=()=>{n.fill(1),o.fill(0),i=0},s=(...u)=>r(o,n,...u),c=(u=h())=>{o=s(A([0]),u),n=s(),u.length!==0&&(o=s(A([1]),u),n=s())},v=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const l=[];for(;u<e;){n=s();const g=n.slice();l.push(g),u+=n.length}return I(...l)};return(u,l)=>{a(),c(u);let g;for(;!(g=l(v()));)c();return a(),g}}const q={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||b(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function W(t,e,r={}){const n=(o,i,a)=>{const s=q[i];if(typeof s!="function")throw new Error("invalid validator function");const c=t[o];if(!(a&&c===void 0)&&!s(c,t))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+c)};for(const[o,i]of Object.entries(e))n(o,i,!1);for(const[o,i]of Object.entries(r))n(o,i,!0);return t}const J=()=>{throw new Error("not implemented")};function K(t){const e=new WeakMap;return(r,...n)=>{const o=e.get(r);if(o!==void 0)return o;const i=t(r,...n);return e.set(r,i),i}}exports.aInRange=z;exports.abool=_;exports.abytes=m;exports.bitGet=D;exports.bitLen=C;exports.bitMask=L;exports.bitSet=G;exports.bytesToHex=B;exports.bytesToNumberBE=H;exports.bytesToNumberLE=O;exports.concatBytes=I;exports.createHmacDrbg=P;exports.ensureBytes=M;exports.equalBytes=R;exports.hexToBytes=p;exports.hexToNumber=E;exports.inRange=S;exports.isBytes=b;exports.memoized=K;exports.notImplemented=J;exports.numberToBytesBE=U;exports.numberToBytesLE=F;exports.numberToHexUnpadded=x;exports.numberToVarBytesBE=V;exports.utf8ToBytes=j;exports.validateObject=W;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index56.cjs"),t=require("./index48.cjs");class i extends t.BaseError{constructor({cause:r,maxFeePerGas:e}={}){super(`The fee cap (\`maxFeePerGas\`${e?` = ${a.formatGwei(e)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:r,name:"FeeCapTooHighError"})}}Object.defineProperty(i,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class n extends t.BaseError{constructor({cause:r,maxPriorityFeePerGas:e,maxFeePerGas:o}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${e?` = ${a.formatGwei(e)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${o?` = ${a.formatGwei(o)} gwei`:""}).`].join(`
2
+ `),{cause:r,name:"TipAboveFeeCapError"})}}Object.defineProperty(n,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});exports.FeeCapTooHighError=i;exports.TipAboveFeeCapError=n;