@gardenfi/utils 2.4.5 → 2.4.6
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.
- package/dist/index119.cjs +1 -1
- package/dist/index119.js +1 -1
- package/dist/index195.cjs +1 -1
- package/dist/index195.js +3 -3
- package/dist/index225.cjs +1 -1
- package/dist/index225.js +2 -2
- package/dist/index228.cjs +1 -1
- package/dist/index228.js +2 -2
- package/dist/index229.cjs +1 -1
- package/dist/index229.js +1 -1
- package/dist/index23.cjs +1 -1
- package/dist/index23.js +6 -6
- package/dist/index234.cjs +1 -1
- package/dist/index234.js +1 -1
- package/dist/index235.cjs +1 -1
- package/dist/index235.js +1 -1
- package/dist/index236.cjs +1 -1
- package/dist/index236.js +2 -2
- package/dist/index241.cjs +1 -1
- package/dist/index241.js +3 -3
- package/dist/index243.cjs +1 -1
- package/dist/index243.js +1 -1
- package/dist/index248.cjs +1 -1
- package/dist/index248.js +3 -3
- package/dist/index249.cjs +1 -1
- package/dist/index249.js +3 -3
- package/dist/index254.cjs +1 -1
- package/dist/index254.js +102 -24
- package/dist/index255.cjs +1 -1
- package/dist/index255.js +6 -13
- package/dist/index256.cjs +1 -1
- package/dist/index256.js +223 -14
- package/dist/index257.cjs +1 -1
- package/dist/index257.js +25 -5
- package/dist/index258.cjs +1 -1
- package/dist/index258.js +13 -13
- package/dist/index259.cjs +1 -1
- package/dist/index259.js +14 -9
- package/dist/index26.cjs +1 -1
- package/dist/index26.js +2 -2
- package/dist/index260.cjs +1 -1
- package/dist/index260.js +5 -16
- package/dist/index261.cjs +1 -2
- package/dist/index261.js +13 -41
- package/dist/index262.cjs +1 -1
- package/dist/index262.js +11 -2
- package/dist/index263.cjs +1 -1
- package/dist/index263.js +16 -5
- package/dist/index264.cjs +2 -1
- package/dist/index264.js +40 -9
- package/dist/index265.cjs +1 -1
- package/dist/index265.js +2 -20
- package/dist/index266.cjs +1 -1
- package/dist/index266.js +5 -8
- package/dist/index267.cjs +1 -1
- package/dist/index267.js +9 -65
- package/dist/index268.cjs +1 -1
- package/dist/index268.js +17 -63
- package/dist/index269.cjs +1 -1
- package/dist/index269.js +8 -186
- package/dist/index270.cjs +1 -1
- package/dist/index270.js +66 -22
- package/dist/index271.cjs +1 -1
- package/dist/index271.js +61 -38
- package/dist/index272.cjs +1 -1
- package/dist/index272.js +179 -69
- package/dist/index273.cjs +1 -1
- package/dist/index273.js +21 -39
- package/dist/index274.cjs +1 -1
- package/dist/index274.js +35 -9
- package/dist/index275.cjs +1 -1
- package/dist/index275.js +70 -7
- package/dist/index276.cjs +1 -1
- package/dist/index276.js +40 -12
- package/dist/index277.cjs +1 -2
- package/dist/index277.js +16 -18
- package/dist/index278.cjs +1 -1
- package/dist/index278.js +12 -13
- package/dist/index279.cjs +1 -1
- package/dist/index279.js +12 -11
- package/dist/index280.cjs +2 -1
- package/dist/index280.js +18 -103
- package/dist/index281.cjs +1 -1
- package/dist/index281.js +14 -6
- package/dist/index282.cjs +1 -1
- package/dist/index282.js +152 -221
- package/dist/index283.cjs +1 -1
- package/dist/index283.js +9 -6
- package/dist/index284.cjs +1 -1
- package/dist/index284.js +114 -7
- package/dist/index285.cjs +2 -1
- package/dist/index285.js +132 -24
- package/dist/index286.cjs +1 -1
- package/dist/index286.js +11 -19
- package/dist/index287.cjs +1 -1
- package/dist/index287.js +6 -146
- package/dist/index288.cjs +1 -1
- package/dist/index288.js +7 -4
- package/dist/index289.cjs +1 -1
- package/dist/index289.js +23 -137
- package/dist/index290.cjs +1 -1
- package/dist/index290.js +17 -153
- package/dist/index291.cjs +1 -1
- package/dist/index291.js +146 -9
- package/dist/index292.cjs +1 -1
- package/dist/index292.js +3 -113
- package/dist/index293.cjs +1 -2
- package/dist/index293.js +128 -122
- package/dist/index294.cjs +1 -1
- package/dist/index294.js +73 -134
- package/dist/index295.cjs +1 -1
- package/dist/index295.js +2 -43
- package/dist/index296.cjs +1 -1
- package/dist/index296.js +693 -73
- package/dist/index297.cjs +1 -1
- package/dist/index297.js +140 -2
- package/dist/index298.cjs +1 -1
- package/dist/index298.js +41 -10
- package/dist/index299.cjs +1 -1
- package/dist/index299.js +201 -19
- package/dist/index301.cjs +2 -1
- package/dist/index301.js +63 -695
- package/dist/index302.cjs +1 -1
- package/dist/index302.js +4 -201
- package/dist/index303.cjs +1 -2
- package/dist/index303.js +39 -65
- package/dist/index304.cjs +1 -1
- package/dist/index304.js +7 -4
- package/dist/index305.cjs +1 -1
- package/dist/index305.js +60 -38
- package/dist/index306.cjs +1 -1
- package/dist/index306.js +77 -7
- package/dist/index307.cjs +1 -1
- package/dist/index307.js +4 -63
- package/dist/index308.cjs +1 -1
- package/dist/index308.js +181 -64
- package/dist/index309.cjs +1 -1
- package/dist/index309.js +12 -4
- package/dist/index310.cjs +1 -1
- package/dist/index310.js +19 -194
- package/dist/index311.cjs +1 -1
- package/dist/index311.js +63 -4
- package/dist/index312.cjs +1 -1
- package/dist/index312.js +40 -59
- package/dist/index313.cjs +1 -1
- package/dist/index313.js +4 -44
- package/dist/index53.cjs +1 -1
- package/dist/index53.js +1 -1
- package/dist/index98.cjs +1 -1
- package/dist/index98.js +2 -2
- package/package.json +1 -1
package/dist/index302.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n="#__bigint";function e(i,f,r){return JSON.stringify(i,(g,t)=>typeof t=="bigint"?t.toString()+n:t,r)}exports.stringify=e;
|
package/dist/index302.js
CHANGED
|
@@ -1,204 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const g = BigInt(0), h = BigInt(1);
|
|
5
|
-
function b(t, r) {
|
|
6
|
-
const e = r.negate();
|
|
7
|
-
return t ? e : r;
|
|
8
|
-
}
|
|
9
|
-
function L(t, r, e) {
|
|
10
|
-
const n = (s) => s.pz, i = R(t.Fp, e.map(n));
|
|
11
|
-
return e.map((s, f) => s.toAffine(i[f])).map(t.fromAffine);
|
|
12
|
-
}
|
|
13
|
-
function I(t, r) {
|
|
14
|
-
if (!Number.isSafeInteger(t) || t <= 0 || t > r)
|
|
15
|
-
throw new Error("invalid window size, expected [1.." + r + "], got W=" + t);
|
|
16
|
-
}
|
|
17
|
-
function E(t, r) {
|
|
18
|
-
I(t, r);
|
|
19
|
-
const e = Math.ceil(r / t) + 1, n = 2 ** (t - 1), i = 2 ** t, o = z(t), s = BigInt(t);
|
|
20
|
-
return { windows: e, windowSize: n, mask: o, maxNumber: i, shiftBy: s };
|
|
21
|
-
}
|
|
22
|
-
function v(t, r, e) {
|
|
23
|
-
const { windowSize: n, mask: i, maxNumber: o, shiftBy: s } = e;
|
|
24
|
-
let f = Number(t & i), a = t >> s;
|
|
25
|
-
f > n && (f -= o, a += h);
|
|
26
|
-
const d = r * n, c = d + Math.abs(f) - 1, p = f === 0, l = f < 0, u = r % 2 !== 0;
|
|
27
|
-
return { nextN: a, offset: c, isZero: p, isNeg: l, isNegF: u, offsetF: d };
|
|
28
|
-
}
|
|
29
|
-
function j(t, r) {
|
|
30
|
-
if (!Array.isArray(t))
|
|
31
|
-
throw new Error("array expected");
|
|
32
|
-
t.forEach((e, n) => {
|
|
33
|
-
if (!(e instanceof r))
|
|
34
|
-
throw new Error("invalid point at index " + n);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
function _(t, r) {
|
|
38
|
-
if (!Array.isArray(t))
|
|
39
|
-
throw new Error("array of scalars expected");
|
|
40
|
-
t.forEach((e, n) => {
|
|
41
|
-
if (!r.isValid(e))
|
|
42
|
-
throw new Error("invalid scalar at index " + n);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
const N = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakMap();
|
|
46
|
-
function A(t) {
|
|
47
|
-
return M.get(t) || 1;
|
|
48
|
-
}
|
|
49
|
-
function S(t) {
|
|
50
|
-
if (t !== g)
|
|
51
|
-
throw new Error("invalid wNAF");
|
|
52
|
-
}
|
|
53
|
-
function U(t, r) {
|
|
54
|
-
return {
|
|
55
|
-
constTimeNegate: b,
|
|
56
|
-
hasPrecomputes(e) {
|
|
57
|
-
return A(e) !== 1;
|
|
58
|
-
},
|
|
59
|
-
// non-const time multiplication ladder
|
|
60
|
-
unsafeLadder(e, n, i = t.ZERO) {
|
|
61
|
-
let o = e;
|
|
62
|
-
for (; n > g; )
|
|
63
|
-
n & h && (i = i.add(o)), o = o.double(), n >>= h;
|
|
64
|
-
return i;
|
|
65
|
-
},
|
|
66
|
-
/**
|
|
67
|
-
* Creates a wNAF precomputation window. Used for caching.
|
|
68
|
-
* Default window size is set by `utils.precompute()` and is equal to 8.
|
|
69
|
-
* Number of precomputed points depends on the curve size:
|
|
70
|
-
* 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:
|
|
71
|
-
* - 𝑊 is the window size
|
|
72
|
-
* - 𝑛 is the bitlength of the curve order.
|
|
73
|
-
* For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
|
|
74
|
-
* @param elm Point instance
|
|
75
|
-
* @param W window size
|
|
76
|
-
* @returns precomputed point tables flattened to a single array
|
|
77
|
-
*/
|
|
78
|
-
precomputeWindow(e, n) {
|
|
79
|
-
const { windows: i, windowSize: o } = E(n, r), s = [];
|
|
80
|
-
let f = e, a = f;
|
|
81
|
-
for (let d = 0; d < i; d++) {
|
|
82
|
-
a = f, s.push(a);
|
|
83
|
-
for (let c = 1; c < o; c++)
|
|
84
|
-
a = a.add(f), s.push(a);
|
|
85
|
-
f = a.double();
|
|
86
|
-
}
|
|
87
|
-
return s;
|
|
88
|
-
},
|
|
89
|
-
/**
|
|
90
|
-
* Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
|
|
91
|
-
* @param W window size
|
|
92
|
-
* @param precomputes precomputed tables
|
|
93
|
-
* @param n scalar (we don't check here, but should be less than curve order)
|
|
94
|
-
* @returns real and fake (for const-time) points
|
|
95
|
-
*/
|
|
96
|
-
wNAF(e, n, i) {
|
|
97
|
-
let o = t.ZERO, s = t.BASE;
|
|
98
|
-
const f = E(e, r);
|
|
99
|
-
for (let a = 0; a < f.windows; a++) {
|
|
100
|
-
const { nextN: d, offset: c, isZero: p, isNeg: l, isNegF: u, offsetF: m } = v(i, a, f);
|
|
101
|
-
i = d, p ? s = s.add(b(u, n[m])) : o = o.add(b(l, n[c]));
|
|
102
|
-
}
|
|
103
|
-
return S(i), { p: o, f: s };
|
|
104
|
-
},
|
|
105
|
-
/**
|
|
106
|
-
* Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
|
|
107
|
-
* @param W window size
|
|
108
|
-
* @param precomputes precomputed tables
|
|
109
|
-
* @param n scalar (we don't check here, but should be less than curve order)
|
|
110
|
-
* @param acc accumulator point to add result of multiplication
|
|
111
|
-
* @returns point
|
|
112
|
-
*/
|
|
113
|
-
wNAFUnsafe(e, n, i, o = t.ZERO) {
|
|
114
|
-
const s = E(e, r);
|
|
115
|
-
for (let f = 0; f < s.windows && i !== g; f++) {
|
|
116
|
-
const { nextN: a, offset: d, isZero: c, isNeg: p } = v(i, f, s);
|
|
117
|
-
if (i = a, !c) {
|
|
118
|
-
const l = n[d];
|
|
119
|
-
o = o.add(p ? l.negate() : l);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return S(i), o;
|
|
123
|
-
},
|
|
124
|
-
getPrecomputes(e, n, i) {
|
|
125
|
-
let o = N.get(n);
|
|
126
|
-
return o || (o = this.precomputeWindow(n, e), e !== 1 && (typeof i == "function" && (o = i(o)), N.set(n, o))), o;
|
|
127
|
-
},
|
|
128
|
-
wNAFCached(e, n, i) {
|
|
129
|
-
const o = A(e);
|
|
130
|
-
return this.wNAF(o, this.getPrecomputes(o, e, i), n);
|
|
131
|
-
},
|
|
132
|
-
wNAFCachedUnsafe(e, n, i, o) {
|
|
133
|
-
const s = A(e);
|
|
134
|
-
return s === 1 ? this.unsafeLadder(e, n, o) : this.wNAFUnsafe(s, this.getPrecomputes(s, e, i), n, o);
|
|
135
|
-
},
|
|
136
|
-
// We calculate precomputes for elliptic curve point multiplication
|
|
137
|
-
// using windowed method. This specifies window size and
|
|
138
|
-
// stores precomputed values. Usually only base point would be precomputed.
|
|
139
|
-
setWindowSize(e, n) {
|
|
140
|
-
I(n, r), M.set(e, n), N.delete(e);
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
function $(t, r, e, n) {
|
|
145
|
-
let i = r, o = t.ZERO, s = t.ZERO;
|
|
146
|
-
for (; e > g || n > g; )
|
|
147
|
-
e & h && (o = o.add(i)), n & h && (s = s.add(i)), i = i.double(), e >>= h, n >>= h;
|
|
148
|
-
return { p1: o, p2: s };
|
|
149
|
-
}
|
|
150
|
-
function D(t, r, e, n) {
|
|
151
|
-
j(e, t), _(n, r);
|
|
152
|
-
const i = e.length, o = n.length;
|
|
153
|
-
if (i !== o)
|
|
154
|
-
throw new Error("arrays of points and scalars must have equal length");
|
|
155
|
-
const s = t.ZERO, f = B(BigInt(i));
|
|
156
|
-
let a = 1;
|
|
157
|
-
f > 12 ? a = f - 3 : f > 4 ? a = f - 2 : f > 0 && (a = 2);
|
|
158
|
-
const d = z(a), c = new Array(Number(d) + 1).fill(s), p = Math.floor((r.BITS - 1) / a) * a;
|
|
159
|
-
let l = s;
|
|
160
|
-
for (let u = p; u >= 0; u -= a) {
|
|
161
|
-
c.fill(s);
|
|
162
|
-
for (let w = 0; w < o; w++) {
|
|
163
|
-
const F = n[w], y = Number(F >> BigInt(u) & d);
|
|
164
|
-
c[y] = c[y].add(e[w]);
|
|
165
|
-
}
|
|
166
|
-
let m = s;
|
|
167
|
-
for (let w = c.length - 1, F = s; w > 0; w--)
|
|
168
|
-
F = F.add(c[w]), m = m.add(F);
|
|
169
|
-
if (l = l.add(m), u !== 0)
|
|
170
|
-
for (let w = 0; w < a; w++)
|
|
171
|
-
l = l.double();
|
|
172
|
-
}
|
|
173
|
-
return l;
|
|
174
|
-
}
|
|
175
|
-
function x(t, r) {
|
|
176
|
-
if (r) {
|
|
177
|
-
if (r.ORDER !== t)
|
|
178
|
-
throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
|
|
179
|
-
return Z(r), r;
|
|
180
|
-
} else
|
|
181
|
-
return O(t);
|
|
182
|
-
}
|
|
183
|
-
function G(t, r, e = {}) {
|
|
184
|
-
if (!r || typeof r != "object")
|
|
185
|
-
throw new Error(`expected valid ${t} CURVE object`);
|
|
186
|
-
for (const f of ["p", "n", "h"]) {
|
|
187
|
-
const a = r[f];
|
|
188
|
-
if (!(typeof a == "bigint" && a > g))
|
|
189
|
-
throw new Error(`CURVE.${f} must be positive bigint`);
|
|
190
|
-
}
|
|
191
|
-
const n = x(r.p, e.Fp), i = x(r.n, e.Fn), s = ["Gx", "Gy", "a", "b"];
|
|
192
|
-
for (const f of s)
|
|
193
|
-
if (!n.isValid(r[f]))
|
|
194
|
-
throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);
|
|
195
|
-
return { Fp: n, Fn: i };
|
|
1
|
+
const r = "#__bigint";
|
|
2
|
+
function g(i, f, n) {
|
|
3
|
+
return JSON.stringify(i, (e, t) => typeof t == "bigint" ? t.toString() + r : t, n);
|
|
196
4
|
}
|
|
197
5
|
export {
|
|
198
|
-
|
|
199
|
-
$ as mulEndoUnsafe,
|
|
200
|
-
b as negateCt,
|
|
201
|
-
L as normalizeZ,
|
|
202
|
-
D as pippenger,
|
|
203
|
-
U as wNAF
|
|
6
|
+
g as stringify
|
|
204
7
|
};
|
package/dist/index303.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`);super(d,e.cause?{cause:e.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${n.getVersion()}`}),this.cause=e.cause,this.details=a,this.docs=i,this.docsPath=u,this.shortMessage=r}walk(r){return l(this,r)}}function l(t,r){return r!=null&&r(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause?l(t.cause,r):r?null:t}exports.BaseError=c;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index282.cjs");function n(t,e){if(i.size(t)>e)throw new i.SizeOverflowError({givenSize:i.size(t),maxSize:e})}function o(t,e){if(typeof e=="number"&&e>0&&e>i.size(t)-1)throw new i.SliceOffsetOutOfBoundsError({offset:e,position:"start",size:i.size(t)})}function z(t,e,r){if(typeof e=="number"&&typeof r=="number"&&i.size(t)!==r-e)throw new i.SliceOffsetOutOfBoundsError({offset:r,position:"end",size:i.size(t)})}function a(t,e={}){const{dir:r,size:s=32}=e;if(s===0)return t;const f=t.replace("0x","");if(f.length>s*2)throw new i.SizeExceedsPaddingSizeError({size:Math.ceil(f.length/2),targetSize:s,type:"Hex"});return`0x${f[r==="right"?"padEnd":"padStart"](s*2,"0")}`}exports.assertEndOffset=z;exports.assertSize=n;exports.assertStartOffset=o;exports.pad=a;
|
package/dist/index303.js
CHANGED
|
@@ -1,69 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return e.cause.details;
|
|
9
|
-
if (e.cause.shortMessage)
|
|
10
|
-
return e.cause.shortMessage;
|
|
11
|
-
}
|
|
12
|
-
return e.cause && "details" in e.cause && typeof e.cause.details == "string" ? e.cause.details : (s = e.cause) != null && s.message ? e.cause.message : e.details;
|
|
13
|
-
})(), u = e.cause instanceof c && e.cause.docsPath || e.docsPath, i = `https://oxlib.sh${u ?? ""}`, d = [
|
|
14
|
-
t || "An error occurred.",
|
|
15
|
-
...e.metaMessages ? ["", ...e.metaMessages] : [],
|
|
16
|
-
...a || u ? [
|
|
17
|
-
"",
|
|
18
|
-
a ? `Details: ${a}` : void 0,
|
|
19
|
-
u ? `See: ${i}` : void 0
|
|
20
|
-
] : []
|
|
21
|
-
].filter((s) => typeof s == "string").join(`
|
|
22
|
-
`);
|
|
23
|
-
super(d, e.cause ? { cause: e.cause } : void 0), Object.defineProperty(this, "details", {
|
|
24
|
-
enumerable: !0,
|
|
25
|
-
configurable: !0,
|
|
26
|
-
writable: !0,
|
|
27
|
-
value: void 0
|
|
28
|
-
}), Object.defineProperty(this, "docs", {
|
|
29
|
-
enumerable: !0,
|
|
30
|
-
configurable: !0,
|
|
31
|
-
writable: !0,
|
|
32
|
-
value: void 0
|
|
33
|
-
}), Object.defineProperty(this, "docsPath", {
|
|
34
|
-
enumerable: !0,
|
|
35
|
-
configurable: !0,
|
|
36
|
-
writable: !0,
|
|
37
|
-
value: void 0
|
|
38
|
-
}), Object.defineProperty(this, "shortMessage", {
|
|
39
|
-
enumerable: !0,
|
|
40
|
-
configurable: !0,
|
|
41
|
-
writable: !0,
|
|
42
|
-
value: void 0
|
|
43
|
-
}), Object.defineProperty(this, "cause", {
|
|
44
|
-
enumerable: !0,
|
|
45
|
-
configurable: !0,
|
|
46
|
-
writable: !0,
|
|
47
|
-
value: void 0
|
|
48
|
-
}), Object.defineProperty(this, "name", {
|
|
49
|
-
enumerable: !0,
|
|
50
|
-
configurable: !0,
|
|
51
|
-
writable: !0,
|
|
52
|
-
value: "BaseError"
|
|
53
|
-
}), Object.defineProperty(this, "version", {
|
|
54
|
-
enumerable: !0,
|
|
55
|
-
configurable: !0,
|
|
56
|
-
writable: !0,
|
|
57
|
-
value: `ox@${n()}`
|
|
58
|
-
}), this.cause = e.cause, this.details = a, this.docs = i, this.docsPath = u, this.shortMessage = t;
|
|
59
|
-
}
|
|
60
|
-
walk(t) {
|
|
61
|
-
return l(this, t);
|
|
62
|
-
}
|
|
1
|
+
import { SizeExceedsPaddingSizeError as s, size as i, SliceOffsetOutOfBoundsError as f, SizeOverflowError as p } from "./index282.js";
|
|
2
|
+
function c(t, e) {
|
|
3
|
+
if (i(t) > e)
|
|
4
|
+
throw new p({
|
|
5
|
+
givenSize: i(t),
|
|
6
|
+
maxSize: e
|
|
7
|
+
});
|
|
63
8
|
}
|
|
64
|
-
function
|
|
65
|
-
|
|
9
|
+
function S(t, e) {
|
|
10
|
+
if (typeof e == "number" && e > 0 && e > i(t) - 1)
|
|
11
|
+
throw new f({
|
|
12
|
+
offset: e,
|
|
13
|
+
position: "start",
|
|
14
|
+
size: i(t)
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function d(t, e, r) {
|
|
18
|
+
if (typeof e == "number" && typeof r == "number" && i(t) !== r - e)
|
|
19
|
+
throw new f({
|
|
20
|
+
offset: r,
|
|
21
|
+
position: "end",
|
|
22
|
+
size: i(t)
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function u(t, e = {}) {
|
|
26
|
+
const { dir: r, size: n = 32 } = e;
|
|
27
|
+
if (n === 0)
|
|
28
|
+
return t;
|
|
29
|
+
const o = t.replace("0x", "");
|
|
30
|
+
if (o.length > n * 2)
|
|
31
|
+
throw new s({
|
|
32
|
+
size: Math.ceil(o.length / 2),
|
|
33
|
+
targetSize: n,
|
|
34
|
+
type: "Hex"
|
|
35
|
+
});
|
|
36
|
+
return `0x${o[r === "right" ? "padEnd" : "padStart"](n * 2, "0")}`;
|
|
66
37
|
}
|
|
67
38
|
export {
|
|
68
|
-
|
|
39
|
+
d as assertEndOffset,
|
|
40
|
+
c as assertSize,
|
|
41
|
+
S as assertStartOffset,
|
|
42
|
+
u as pad
|
|
69
43
|
};
|
package/dist/index304.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n="
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index228.cjs"),o=require("./index311.cjs"),n=require("./index282.cjs");function i(e,r={}){const{as:s=typeof e=="string"?"Hex":"Bytes"}=r,t=c.keccak_256(o.from(e));return s==="Bytes"?t:n.fromBytes(t)}exports.keccak256=i;
|
package/dist/index304.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { keccak_256 as f } from "./index228.js";
|
|
2
|
+
import { from as m } from "./index311.js";
|
|
3
|
+
import { fromBytes as s } from "./index282.js";
|
|
4
|
+
function p(t, o = {}) {
|
|
5
|
+
const { as: e = typeof t == "string" ? "Hex" : "Bytes" } = o, r = f(m(t));
|
|
6
|
+
return e === "Bytes" ? r : s(r);
|
|
4
7
|
}
|
|
5
8
|
export {
|
|
6
|
-
|
|
9
|
+
p as keccak256
|
|
7
10
|
};
|
package/dist/index305.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index306.cjs"),a=require("./index301.cjs");function d(r){let i=!0,t="",e=0,n="",o=!1;for(let s=0;s<r.length;s++){const u=r[s];if(["(",")",","].includes(u)&&(i=!0),u==="("&&e++,u===")"&&e--,!!i){if(e===0){if(u===" "&&["event","function","error",""].includes(n))n="";else if(n+=u,u===")"){o=!0;break}continue}if(u===" "){r[s-1]!==","&&t!==","&&t!==",("&&(t="",i=!1);continue}n+=u,t+=u}}if(!o)throw new a.BaseError("Unable to normalize signature.");return n}function l(r,i){const t=typeof r,e=i.type;switch(e){case"address":return c.validate(r,{strict:!1});case"bool":return t==="boolean";case"function":return t==="string";case"string":return t==="string";default:return e==="tuple"&&"components"in i?Object.values(i.components).every((n,o)=>l(Object.values(r)[o],n)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(e)?t==="number"||t==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(e)?t==="string"||r instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(e)?Array.isArray(r)&&r.every(n=>l(n,{...i,type:e.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function f(r,i,t){for(const e in r){const n=r[e],o=i[e];if(n.type==="tuple"&&o.type==="tuple"&&"components"in n&&"components"in o)return f(n.components,o.components,t[e]);const s=[n.type,o.type];if(s.includes("address")&&s.includes("bytes20")?!0:s.includes("address")&&s.includes("string")?c.validate(t[e],{strict:!1}):s.includes("address")&&s.includes("bytes")?c.validate(t[e],{strict:!1}):!1)return s}}exports.getAmbiguousTypes=f;exports.isArgOfType=l;exports.normalizeSignature=d;
|
package/dist/index305.js
CHANGED
|
@@ -1,43 +1,65 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { validate as c } from "./index306.js";
|
|
2
|
+
import { BaseError as f } from "./index301.js";
|
|
3
|
+
function y(r) {
|
|
4
|
+
let i = !0, t = "", e = 0, n = "", o = !1;
|
|
5
|
+
for (let s = 0; s < r.length; s++) {
|
|
6
|
+
const u = r[s];
|
|
7
|
+
if (["(", ")", ","].includes(u) && (i = !0), u === "(" && e++, u === ")" && e--, !!i) {
|
|
8
|
+
if (e === 0) {
|
|
9
|
+
if (u === " " && ["event", "function", "error", ""].includes(n))
|
|
10
|
+
n = "";
|
|
11
|
+
else if (n += u, u === ")") {
|
|
12
|
+
o = !0;
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (u === " ") {
|
|
18
|
+
r[s - 1] !== "," && t !== "," && t !== ",(" && (t = "", i = !1);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
n += u, t += u;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (!o)
|
|
25
|
+
throw new f("Unable to normalize signature.");
|
|
26
|
+
return n;
|
|
8
27
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
28
|
+
function l(r, i) {
|
|
29
|
+
const t = typeof r, e = i.type;
|
|
30
|
+
switch (e) {
|
|
31
|
+
case "address":
|
|
32
|
+
return c(r, { strict: !1 });
|
|
33
|
+
case "bool":
|
|
34
|
+
return t === "boolean";
|
|
35
|
+
case "function":
|
|
36
|
+
return t === "string";
|
|
37
|
+
case "string":
|
|
38
|
+
return t === "string";
|
|
39
|
+
default:
|
|
40
|
+
return e === "tuple" && "components" in i ? Object.values(i.components).every((n, o) => l(Object.values(r)[o], n)) : /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(e) ? t === "number" || t === "bigint" : /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(e) ? t === "string" || r instanceof Uint8Array : /[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(e) ? Array.isArray(r) && r.every((n) => l(n, {
|
|
41
|
+
...i,
|
|
42
|
+
// Pop off `[]` or `[M]` from end of type
|
|
43
|
+
type: e.replace(/(\[[0-9]{0,}\])$/, "")
|
|
44
|
+
})) : !1;
|
|
45
|
+
}
|
|
16
46
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (o.length > n * 2)
|
|
31
|
-
throw new s({
|
|
32
|
-
size: Math.ceil(o.length / 2),
|
|
33
|
-
targetSize: n,
|
|
34
|
-
type: "Hex"
|
|
35
|
-
});
|
|
36
|
-
return `0x${o[r === "right" ? "padEnd" : "padStart"](n * 2, "0")}`;
|
|
47
|
+
function a(r, i, t) {
|
|
48
|
+
for (const e in r) {
|
|
49
|
+
const n = r[e], o = i[e];
|
|
50
|
+
if (n.type === "tuple" && o.type === "tuple" && "components" in n && "components" in o)
|
|
51
|
+
return a(n.components, o.components, t[e]);
|
|
52
|
+
const s = [n.type, o.type];
|
|
53
|
+
if (s.includes("address") && s.includes("bytes20") ? !0 : s.includes("address") && s.includes("string") ? c(t[e], {
|
|
54
|
+
strict: !1
|
|
55
|
+
}) : s.includes("address") && s.includes("bytes") ? c(t[e], {
|
|
56
|
+
strict: !1
|
|
57
|
+
}) : !1)
|
|
58
|
+
return s;
|
|
59
|
+
}
|
|
37
60
|
}
|
|
38
61
|
export {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
u as pad
|
|
62
|
+
a as getAmbiguousTypes,
|
|
63
|
+
l as isArgOfType,
|
|
64
|
+
y as normalizeSignature
|
|
43
65
|
};
|
package/dist/index306.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./index311.cjs"),c=require("./index314.cjs"),o=require("./index301.cjs"),m=require("./index304.cjs"),b=/^0x[a-fA-F0-9]{40}$/;function i(e,t={}){const{strict:s=!0}=t;if(!b.test(e))throw new a({address:e,cause:new l});if(s){if(e.toLowerCase()===e)return;if(d(e)!==e)throw new a({address:e,cause:new h})}}function d(e){if(c.checksum.has(e))return c.checksum.get(e);i(e,{strict:!1});const t=e.substring(2).toLowerCase(),s=m.keccak256(f.fromString(t),{as:"Bytes"}),n=t.split("");for(let r=0;r<40;r+=2)s[r>>1]>>4>=8&&n[r]&&(n[r]=n[r].toUpperCase()),(s[r>>1]&15)>=8&&n[r+1]&&(n[r+1]=n[r+1].toUpperCase());const u=`0x${n.join("")}`;return c.checksum.set(e,u),u}function p(e,t={}){const{strict:s=!0}=t??{};try{return i(e,{strict:s}),!0}catch{return!1}}class a extends o.BaseError{constructor({address:t,cause:s}){super(`Address "${t}" is invalid.`,{cause:s}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class l extends o.BaseError{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class h extends o.BaseError{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}exports.InvalidAddressError=a;exports.InvalidChecksumError=h;exports.InvalidInputError=l;exports.assert=i;exports.checksum=d;exports.validate=p;
|
package/dist/index306.js
CHANGED
|
@@ -1,10 +1,80 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { fromString as d } from "./index311.js";
|
|
2
|
+
import { checksum as o } from "./index314.js";
|
|
3
|
+
import { BaseError as c } from "./index301.js";
|
|
4
|
+
import { keccak256 as f } from "./index304.js";
|
|
5
|
+
const l = /^0x[a-fA-F0-9]{40}$/;
|
|
6
|
+
function u(r, t = {}) {
|
|
7
|
+
const { strict: s = !0 } = t;
|
|
8
|
+
if (!l.test(r))
|
|
9
|
+
throw new i({
|
|
10
|
+
address: r,
|
|
11
|
+
cause: new h()
|
|
12
|
+
});
|
|
13
|
+
if (s) {
|
|
14
|
+
if (r.toLowerCase() === r)
|
|
15
|
+
return;
|
|
16
|
+
if (m(r) !== r)
|
|
17
|
+
throw new i({
|
|
18
|
+
address: r,
|
|
19
|
+
cause: new p()
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function m(r) {
|
|
24
|
+
if (o.has(r))
|
|
25
|
+
return o.get(r);
|
|
26
|
+
u(r, { strict: !1 });
|
|
27
|
+
const t = r.substring(2).toLowerCase(), s = f(d(t), { as: "Bytes" }), n = t.split("");
|
|
28
|
+
for (let e = 0; e < 40; e += 2)
|
|
29
|
+
s[e >> 1] >> 4 >= 8 && n[e] && (n[e] = n[e].toUpperCase()), (s[e >> 1] & 15) >= 8 && n[e + 1] && (n[e + 1] = n[e + 1].toUpperCase());
|
|
30
|
+
const a = `0x${n.join("")}`;
|
|
31
|
+
return o.set(r, a), a;
|
|
32
|
+
}
|
|
33
|
+
function k(r, t = {}) {
|
|
34
|
+
const { strict: s = !0 } = t ?? {};
|
|
35
|
+
try {
|
|
36
|
+
return u(r, { strict: s }), !0;
|
|
37
|
+
} catch {
|
|
38
|
+
return !1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
class i extends c {
|
|
42
|
+
constructor({ address: t, cause: s }) {
|
|
43
|
+
super(`Address "${t}" is invalid.`, {
|
|
44
|
+
cause: s
|
|
45
|
+
}), Object.defineProperty(this, "name", {
|
|
46
|
+
enumerable: !0,
|
|
47
|
+
configurable: !0,
|
|
48
|
+
writable: !0,
|
|
49
|
+
value: "Address.InvalidAddressError"
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
class h extends c {
|
|
54
|
+
constructor() {
|
|
55
|
+
super("Address is not a 20 byte (40 hexadecimal character) value."), Object.defineProperty(this, "name", {
|
|
56
|
+
enumerable: !0,
|
|
57
|
+
configurable: !0,
|
|
58
|
+
writable: !0,
|
|
59
|
+
value: "Address.InvalidInputError"
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
class p extends c {
|
|
64
|
+
constructor() {
|
|
65
|
+
super("Address does not match its checksum counterpart."), Object.defineProperty(this, "name", {
|
|
66
|
+
enumerable: !0,
|
|
67
|
+
configurable: !0,
|
|
68
|
+
writable: !0,
|
|
69
|
+
value: "Address.InvalidChecksumError"
|
|
70
|
+
});
|
|
71
|
+
}
|
|
7
72
|
}
|
|
8
73
|
export {
|
|
9
|
-
|
|
74
|
+
i as InvalidAddressError,
|
|
75
|
+
p as InvalidChecksumError,
|
|
76
|
+
h as InvalidInputError,
|
|
77
|
+
u as assert,
|
|
78
|
+
m as checksum,
|
|
79
|
+
k as validate
|
|
10
80
|
};
|
package/dist/index307.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=/^(.*)\[([0-9]*)\]$/,t=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,g=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;exports.arrayRegex=e;exports.bytesRegex=t;exports.integerRegex=g;
|
package/dist/index307.js
CHANGED
|
@@ -1,65 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { BaseError as f } from "./index303.js";
|
|
3
|
-
function y(r) {
|
|
4
|
-
let i = !0, t = "", e = 0, n = "", o = !1;
|
|
5
|
-
for (let s = 0; s < r.length; s++) {
|
|
6
|
-
const u = r[s];
|
|
7
|
-
if (["(", ")", ","].includes(u) && (i = !0), u === "(" && e++, u === ")" && e--, !!i) {
|
|
8
|
-
if (e === 0) {
|
|
9
|
-
if (u === " " && ["event", "function", "error", ""].includes(n))
|
|
10
|
-
n = "";
|
|
11
|
-
else if (n += u, u === ")") {
|
|
12
|
-
o = !0;
|
|
13
|
-
break;
|
|
14
|
-
}
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
if (u === " ") {
|
|
18
|
-
r[s - 1] !== "," && t !== "," && t !== ",(" && (t = "", i = !1);
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
n += u, t += u;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
if (!o)
|
|
25
|
-
throw new f("Unable to normalize signature.");
|
|
26
|
-
return n;
|
|
27
|
-
}
|
|
28
|
-
function l(r, i) {
|
|
29
|
-
const t = typeof r, e = i.type;
|
|
30
|
-
switch (e) {
|
|
31
|
-
case "address":
|
|
32
|
-
return c(r, { strict: !1 });
|
|
33
|
-
case "bool":
|
|
34
|
-
return t === "boolean";
|
|
35
|
-
case "function":
|
|
36
|
-
return t === "string";
|
|
37
|
-
case "string":
|
|
38
|
-
return t === "string";
|
|
39
|
-
default:
|
|
40
|
-
return e === "tuple" && "components" in i ? Object.values(i.components).every((n, o) => l(Object.values(r)[o], n)) : /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(e) ? t === "number" || t === "bigint" : /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(e) ? t === "string" || r instanceof Uint8Array : /[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(e) ? Array.isArray(r) && r.every((n) => l(n, {
|
|
41
|
-
...i,
|
|
42
|
-
// Pop off `[]` or `[M]` from end of type
|
|
43
|
-
type: e.replace(/(\[[0-9]{0,}\])$/, "")
|
|
44
|
-
})) : !1;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function a(r, i, t) {
|
|
48
|
-
for (const e in r) {
|
|
49
|
-
const n = r[e], o = i[e];
|
|
50
|
-
if (n.type === "tuple" && o.type === "tuple" && "components" in n && "components" in o)
|
|
51
|
-
return a(n.components, o.components, t[e]);
|
|
52
|
-
const s = [n.type, o.type];
|
|
53
|
-
if (s.includes("address") && s.includes("bytes20") ? !0 : s.includes("address") && s.includes("string") ? c(t[e], {
|
|
54
|
-
strict: !1
|
|
55
|
-
}) : s.includes("address") && s.includes("bytes") ? c(t[e], {
|
|
56
|
-
strict: !1
|
|
57
|
-
}) : !1)
|
|
58
|
-
return s;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
const e = /^(.*)\[([0-9]*)\]$/, t = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/, n = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
|
|
61
2
|
export {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
3
|
+
e as arrayRegex,
|
|
4
|
+
t as bytesRegex,
|
|
5
|
+
n as integerRegex
|
|
65
6
|
};
|