@gardenfi/utils 2.0.4 → 2.0.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/index.cjs +1 -1
- package/dist/index.js +33 -24
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +24 -32
- package/dist/index100.cjs +1 -0
- package/dist/index100.js +130 -0
- package/dist/index101.cjs +1 -0
- package/dist/index101.js +115 -0
- package/dist/index102.cjs +1 -0
- package/dist/index102.js +81 -0
- package/dist/index103.cjs +1 -0
- package/dist/index103.js +4 -0
- package/dist/index104.cjs +1 -0
- package/dist/index104.js +20 -0
- package/dist/index105.cjs +1 -0
- package/dist/index105.js +21 -0
- package/dist/index106.cjs +1 -0
- package/dist/index106.js +19 -0
- package/dist/index107.cjs +1 -0
- package/dist/index107.js +226 -0
- package/dist/index108.cjs +2 -0
- package/dist/index108.js +5 -0
- package/dist/index109.cjs +1 -0
- package/dist/index109.js +37 -0
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +136 -14
- package/dist/index110.cjs +1 -0
- package/dist/index110.js +21 -0
- package/dist/index111.cjs +1 -0
- package/dist/index111.js +72 -0
- package/dist/index112.cjs +1 -0
- package/dist/index112.js +70 -0
- package/dist/index113.cjs +1 -0
- package/dist/index113.js +4 -0
- package/dist/index114.cjs +1 -0
- package/dist/index114.js +43 -0
- package/dist/index115.cjs +1 -0
- package/dist/index115.js +646 -0
- package/dist/index116.cjs +1 -0
- package/dist/index116.js +234 -0
- package/dist/index117.cjs +1 -0
- package/dist/index117.js +175 -0
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +9 -182
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +2 -94
- package/dist/index14.cjs +1 -16
- package/dist/index14.js +32 -112
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +18 -31
- package/dist/index16.cjs +1 -1
- package/dist/index16.js +188 -31
- package/dist/index17.cjs +1 -1
- package/dist/index17.js +93 -17
- package/dist/index18.cjs +1 -1
- package/dist/index18.js +35 -7
- package/dist/index19.cjs +1 -1
- package/dist/index19.js +31 -20
- package/dist/index20.cjs +16 -1
- package/dist/index20.js +113 -21
- package/dist/index21.cjs +1 -1
- package/dist/index21.js +31 -9
- package/dist/index22.cjs +1 -1
- package/dist/index22.js +17 -31
- package/dist/index23.cjs +1 -1
- package/dist/index23.js +7 -26
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +41 -19
- package/dist/index25.cjs +1 -1
- package/dist/index25.js +19 -49
- package/dist/index26.cjs +1 -1
- package/dist/index26.js +8 -12
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +30 -23
- package/dist/index28.cjs +1 -1
- package/dist/index28.js +25 -74
- package/dist/index29.cjs +2 -1
- package/dist/index29.js +62 -20
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +30 -7
- package/dist/index30.cjs +1 -1
- package/dist/index30.js +51 -7
- package/dist/index31.cjs +1 -1
- package/dist/index31.js +12 -32
- package/dist/index32.cjs +1 -1
- package/dist/index32.js +24 -15
- package/dist/index33.cjs +1 -1
- package/dist/index33.js +76 -2
- package/dist/index34.cjs +1 -1
- package/dist/index34.js +23 -8
- package/dist/index35.cjs +1 -1
- package/dist/index35.js +7 -20
- package/dist/index36.cjs +1 -1
- package/dist/index36.js +32 -12
- package/dist/index37.cjs +1 -1
- package/dist/index37.js +15 -34
- package/dist/index38.cjs +1 -2
- package/dist/index38.js +2 -60
- package/dist/index39.cjs +1 -1
- package/dist/index39.js +9 -2
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +2 -2
- package/dist/index40.cjs +1 -1
- package/dist/index40.js +20 -4
- package/dist/index41.cjs +1 -1
- package/dist/index41.js +12 -11
- package/dist/index42.cjs +1 -1
- package/dist/index42.js +34 -3
- package/dist/index43.cjs +2 -1
- package/dist/index43.js +58 -20
- package/dist/index44.cjs +1 -1
- package/dist/index44.js +2 -13
- package/dist/index45.cjs +1 -1
- package/dist/index45.js +5 -54
- package/dist/index46.cjs +1 -1
- package/dist/index46.js +6 -6
- package/dist/index47.cjs +1 -1
- package/dist/index47.js +4 -21
- package/dist/index48.cjs +1 -1
- package/dist/index48.js +11 -11
- package/dist/index49.cjs +5 -1
- package/dist/index49.js +56 -3
- package/dist/index50.cjs +2 -1
- package/dist/index50.js +32 -9
- package/dist/index51.cjs +1 -1
- package/dist/index51.js +5 -19
- package/dist/index52.cjs +1 -1
- package/dist/index52.js +3 -6
- package/dist/index53.cjs +1 -1
- package/dist/index53.js +21 -8
- package/dist/index54.cjs +1 -1
- package/dist/index54.js +11 -103
- package/dist/index55.cjs +1 -1
- package/dist/index55.js +51 -24
- package/dist/index56.cjs +1 -1
- package/dist/index56.js +8 -18
- package/dist/index57.cjs +1 -1
- package/dist/index57.js +20 -37
- package/dist/index58.cjs +1 -0
- package/dist/index58.js +14 -0
- package/dist/index59.cjs +1 -0
- package/dist/index59.js +11 -0
- package/dist/index60.cjs +1 -0
- package/dist/index60.js +13 -0
- package/dist/index61.cjs +1 -0
- package/dist/index61.js +14 -0
- package/dist/index62.cjs +1 -0
- package/dist/index62.js +9 -0
- package/dist/index63.cjs +1 -0
- package/dist/index63.js +16 -0
- package/dist/index64.cjs +1 -0
- package/dist/index64.js +35 -0
- package/dist/index65.cjs +1 -0
- package/dist/index65.js +17 -0
- package/dist/index66.cjs +1 -0
- package/dist/index66.js +67 -0
- package/dist/index67.cjs +1 -0
- package/dist/index67.js +30 -0
- package/dist/index68.cjs +1 -0
- package/dist/index68.js +5 -0
- package/dist/index69.cjs +1 -0
- package/dist/index69.js +6 -0
- package/dist/index7.cjs +1 -1
- package/dist/index7.js +2 -109
- package/dist/index70.cjs +1 -0
- package/dist/index70.js +16 -0
- package/dist/index71.cjs +1 -0
- package/dist/index71.js +44 -0
- package/dist/index72.cjs +1 -0
- package/dist/index72.js +8 -0
- package/dist/index73.cjs +1 -0
- package/dist/index73.js +11 -0
- package/dist/index74.cjs +1 -0
- package/dist/index74.js +106 -0
- package/dist/index75.cjs +1 -0
- package/dist/index75.js +194 -0
- package/dist/index76.cjs +1 -0
- package/dist/index76.js +21 -0
- package/dist/index77.cjs +1 -0
- package/dist/index77.js +14 -0
- package/dist/index78.cjs +1 -0
- package/dist/index78.js +22 -0
- package/dist/index79.cjs +1 -0
- package/dist/index79.js +15 -0
- package/dist/index8.cjs +1 -1
- package/dist/index8.js +95 -10
- package/dist/index80.cjs +1 -0
- package/dist/index80.js +28 -0
- package/dist/index81.cjs +1 -0
- package/dist/index81.js +9 -0
- package/dist/index82.cjs +1 -0
- package/dist/index82.js +16 -0
- package/dist/index83.cjs +1 -0
- package/dist/index83.js +18 -0
- package/dist/index84.cjs +1 -0
- package/dist/index84.js +8 -0
- package/dist/index85.cjs +1 -0
- package/dist/index85.js +16 -0
- package/dist/index86.cjs +1 -0
- package/dist/index86.js +13 -0
- package/dist/index87.cjs +1 -0
- package/dist/index87.js +19 -0
- package/dist/index88.cjs +1 -0
- package/dist/index88.js +174 -0
- package/dist/index89.cjs +1 -0
- package/dist/index89.js +41 -0
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +44 -2
- package/dist/index90.cjs +1 -0
- package/dist/index90.js +11 -0
- package/dist/index91.cjs +1 -0
- package/dist/index91.js +7 -0
- package/dist/index92.cjs +1 -0
- package/dist/index92.js +13 -0
- package/dist/index93.cjs +1 -0
- package/dist/index93.js +4 -0
- package/dist/index94.cjs +1 -0
- package/dist/index94.js +107 -0
- package/dist/index95.cjs +1 -0
- package/dist/index95.js +45 -0
- package/dist/index96.cjs +1 -0
- package/dist/index96.js +23 -0
- package/dist/index97.cjs +1 -0
- package/dist/index97.js +9 -0
- package/dist/index98.cjs +1 -0
- package/dist/index98.js +7 -0
- package/dist/index99.cjs +1 -0
- package/dist/index99.js +40 -0
- package/dist/src/lib/auth/apikey/apikey.d.ts +12 -0
- package/dist/src/lib/auth/auth.types.d.ts +21 -8
- package/dist/src/lib/auth/index.d.ts +5 -1
- package/dist/src/lib/auth/passkey/passkey.d.ts +10 -0
- package/dist/src/lib/auth/passkey/passkey.types.d.ts +17 -0
- package/dist/src/lib/auth/passkey/passkeyLogin.d.ts +37 -0
- package/dist/src/lib/auth/{siwe.d.ts → siwe/siwe.d.ts} +4 -15
- package/dist/src/lib/utils.d.ts +3 -0
- package/package.json +2 -1
package/dist/index.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 o=require("./index2.cjs"),e=require("./index3.cjs"),s=require("./index4.cjs"),r=require("./index5.cjs"),i=require("./index6.cjs"),n=require("./index7.cjs"),u=require("./index8.cjs"),c=require("./index9.cjs"),a=require("./index10.cjs"),p=require("./index11.cjs"),k=require("./index12.cjs"),l=require("./index13.cjs"),t=require("./index14.cjs"),y=require("./index15.cjs");exports.ApiStatus=o.ApiStatus;exports.Authorization=e.Authorization;exports.Environment=e.Environment;exports.Network=e.Network;exports.add0x=e.add0x;exports.hexToU32Array=e.hexToU32Array;exports.parseJwt=e.parseJwt;exports.sleep=e.sleep;exports.with0x=e.with0x;exports.checkAllowanceAndApprove=s.checkAllowanceAndApprove;exports.Err=r.Err;exports.Ok=r.Ok;exports.Result=r.Result;exports.Void=r.Void;exports.Url=i.Url;exports.AuthHeaderEnum=n.AuthHeaderEnum;exports.Siwe=u.Siwe;exports.ApiKey=c.ApiKey;exports.Passkey=a.Passkey;exports.PasskeyLogin=p.PasskeyLogin;exports.MemoryStorage=k.MemoryStorage;exports.StoreKeys=l.StoreKeys;exports.fetchBitcoinBlockNumber=t.fetchBitcoinBlockNumber;exports.fetchEVMBlockNumber=t.fetchEVMBlockNumber;exports.EventBroker=y.EventBroker;
|
package/dist/index.js
CHANGED
|
@@ -1,32 +1,41 @@
|
|
|
1
1
|
import { ApiStatus as e } from "./index2.js";
|
|
2
|
-
import { Authorization as p, Environment as m, Network as f, sleep as
|
|
3
|
-
import { checkAllowanceAndApprove as
|
|
4
|
-
import { Err as h, Ok as
|
|
5
|
-
import { Url as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
2
|
+
import { Authorization as p, Environment as m, Network as x, add0x as f, hexToU32Array as i, parseJwt as a, sleep as n, with0x as s } from "./index3.js";
|
|
3
|
+
import { checkAllowanceAndApprove as k } from "./index4.js";
|
|
4
|
+
import { Err as h, Ok as l, Result as u, Void as y } from "./index5.js";
|
|
5
|
+
import { Url as w } from "./index6.js";
|
|
6
|
+
import { AuthHeaderEnum as B } from "./index7.js";
|
|
7
|
+
import { Siwe as v } from "./index8.js";
|
|
8
|
+
import { ApiKey as b } from "./index9.js";
|
|
9
|
+
import { Passkey as K } from "./index10.js";
|
|
10
|
+
import { PasskeyLogin as P } from "./index11.js";
|
|
11
|
+
import { MemoryStorage as V } from "./index12.js";
|
|
12
|
+
import { StoreKeys as H } from "./index13.js";
|
|
13
|
+
import { fetchBitcoinBlockNumber as L, fetchEVMBlockNumber as O } from "./index14.js";
|
|
14
|
+
import { EventBroker as T } from "./index15.js";
|
|
11
15
|
export {
|
|
16
|
+
b as ApiKey,
|
|
12
17
|
e as ApiStatus,
|
|
13
|
-
B as
|
|
18
|
+
B as AuthHeaderEnum,
|
|
14
19
|
p as Authorization,
|
|
15
20
|
m as Environment,
|
|
16
21
|
h as Err,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
T as EventBroker,
|
|
23
|
+
V as MemoryStorage,
|
|
24
|
+
x as Network,
|
|
25
|
+
l as Ok,
|
|
26
|
+
K as Passkey,
|
|
27
|
+
P as PasskeyLogin,
|
|
21
28
|
u as Result,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
v as Siwe,
|
|
30
|
+
H as StoreKeys,
|
|
31
|
+
w as Url,
|
|
32
|
+
y as Void,
|
|
33
|
+
f as add0x,
|
|
34
|
+
k as checkAllowanceAndApprove,
|
|
35
|
+
L as fetchBitcoinBlockNumber,
|
|
36
|
+
O as fetchEVMBlockNumber,
|
|
37
|
+
i as hexToU32Array,
|
|
38
|
+
a as parseJwt,
|
|
39
|
+
n as sleep,
|
|
40
|
+
s as with0x
|
|
32
41
|
};
|
package/dist/index10.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 t=require("./index16.cjs"),o=require("./index7.cjs"),s=require("./index3.cjs");class i{constructor(e){this.token=e}async getToken(){return this.token?this.verifyToken(this.token).ok?t.Ok(this.token):t.Err("Token is invalid"):t.Err("Token is not set")}verifyToken(e){try{const r=s.parseJwt(e);if(!r)return t.Ok(!1);const n=Math.floor(Date.now()/1e3)+120;return t.Ok(r.exp>n)}catch{return t.Ok(!1)}}async getAuthHeaders(){const e=await this.getToken();return e.ok?t.Ok({[o.AuthHeaderEnum.Authorization]:e.val}):t.Err(e.error??"Failed to get auth token")}}exports.Passkey=i;
|
package/dist/index10.js
CHANGED
|
@@ -1,36 +1,28 @@
|
|
|
1
|
-
import { Err as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
421614: b
|
|
8
|
-
}, N = async (r) => {
|
|
9
|
-
const { chain: t } = r;
|
|
10
|
-
if (!t) return o("No chain found");
|
|
11
|
-
const i = ((a) => a in e)(t.id) ? e[t.id] : t;
|
|
12
|
-
return await l(i);
|
|
13
|
-
}, l = async (r) => {
|
|
14
|
-
const t = s({
|
|
15
|
-
chain: r,
|
|
16
|
-
transport: m()
|
|
17
|
-
});
|
|
18
|
-
try {
|
|
19
|
-
const c = await t.getBlockNumber();
|
|
20
|
-
return n(Number(c));
|
|
21
|
-
} catch (c) {
|
|
22
|
-
return o("Failed to fetch evm block number", c);
|
|
1
|
+
import { Err as r, Ok as e } from "./index16.js";
|
|
2
|
+
import { AuthHeaderEnum as s } from "./index7.js";
|
|
3
|
+
import { parseJwt as i } from "./index3.js";
|
|
4
|
+
class c {
|
|
5
|
+
constructor(t) {
|
|
6
|
+
this.token = t;
|
|
23
7
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const t = await r.getLatestTip();
|
|
27
|
-
return n(t);
|
|
28
|
-
} catch (t) {
|
|
29
|
-
return o("Failed to fetch bitcoin block number", t);
|
|
8
|
+
async getToken() {
|
|
9
|
+
return this.token ? this.verifyToken(this.token).ok ? e(this.token) : r("Token is invalid") : r("Token is not set");
|
|
30
10
|
}
|
|
31
|
-
|
|
11
|
+
verifyToken(t) {
|
|
12
|
+
try {
|
|
13
|
+
const o = i(t);
|
|
14
|
+
if (!o) return e(!1);
|
|
15
|
+
const n = Math.floor(Date.now() / 1e3) + 120;
|
|
16
|
+
return e(o.exp > n);
|
|
17
|
+
} catch {
|
|
18
|
+
return e(!1);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async getAuthHeaders() {
|
|
22
|
+
const t = await this.getToken();
|
|
23
|
+
return t.ok ? e({ [s.Authorization]: t.val }) : r(t.error ?? "Failed to get auth token");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
32
26
|
export {
|
|
33
|
-
|
|
34
|
-
C as fetchBitcoinBlockNumber,
|
|
35
|
-
N as fetchEVMBlockNumber
|
|
27
|
+
c as Passkey
|
|
36
28
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index96.cjs"),e={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new o.RecursiveReadLimitExceededError({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(t){if(t<0||t>this.bytes.length-1)throw new o.PositionOutOfBoundsError({length:this.bytes.length,position:t})},decrementPosition(t){if(t<0)throw new o.NegativeOffsetError({offset:t});const i=this.position-t;this.assertPosition(i),this.position=i},getReadCount(t){return this.positionReadCount.get(t||this.position)||0},incrementPosition(t){if(t<0)throw new o.NegativeOffsetError({offset:t});const i=this.position+t;this.assertPosition(i),this.position=i},inspectByte(t){const i=t??this.position;return this.assertPosition(i),this.bytes[i]},inspectBytes(t,i){const s=i??this.position;return this.assertPosition(s+t-1),this.bytes.subarray(s,s+t)},inspectUint8(t){const i=t??this.position;return this.assertPosition(i),this.bytes[i]},inspectUint16(t){const i=t??this.position;return this.assertPosition(i+1),this.dataView.getUint16(i)},inspectUint24(t){const i=t??this.position;return this.assertPosition(i+2),(this.dataView.getUint16(i)<<8)+this.dataView.getUint8(i+2)},inspectUint32(t){const i=t??this.position;return this.assertPosition(i+3),this.dataView.getUint32(i)},pushByte(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushBytes(t){this.assertPosition(this.position+t.length-1),this.bytes.set(t,this.position),this.position+=t.length},pushUint8(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushUint16(t){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,t),this.position+=2},pushUint24(t){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,t>>8),this.dataView.setUint8(this.position+2,t&255),this.position+=3},pushUint32(t){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,t),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const t=this.inspectByte();return this.position++,t},readBytes(t,i){this.assertReadLimit(),this._touch();const s=this.inspectBytes(t);return this.position+=i??t,s},readUint8(){this.assertReadLimit(),this._touch();const t=this.inspectUint8();return this.position+=1,t},readUint16(){this.assertReadLimit(),this._touch();const t=this.inspectUint16();return this.position+=2,t},readUint24(){this.assertReadLimit(),this._touch();const t=this.inspectUint24();return this.position+=3,t},readUint32(){this.assertReadLimit(),this._touch();const t=this.inspectUint32();return this.position+=4,t},get remaining(){return this.bytes.length-this.position},setPosition(t){const i=this.position;return this.assertPosition(t),this.position=t,()=>this.position=i},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const t=this.getReadCount();this.positionReadCount.set(this.position,t+1),t>0&&this.recursiveReadCount++}};function n(t,{recursiveReadLimit:i=8192}={}){const s=Object.create(e);return s.bytes=t,s.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength),s.positionReadCount=new Map,s.recursiveReadLimit=i,s}exports.createCursor=n;
|
package/dist/index100.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { RecursiveReadLimitExceededError as e, PositionOutOfBoundsError as n, NegativeOffsetError as o } from "./index96.js";
|
|
2
|
+
const h = {
|
|
3
|
+
bytes: new Uint8Array(),
|
|
4
|
+
dataView: new DataView(new ArrayBuffer(0)),
|
|
5
|
+
position: 0,
|
|
6
|
+
positionReadCount: /* @__PURE__ */ new Map(),
|
|
7
|
+
recursiveReadCount: 0,
|
|
8
|
+
recursiveReadLimit: Number.POSITIVE_INFINITY,
|
|
9
|
+
assertReadLimit() {
|
|
10
|
+
if (this.recursiveReadCount >= this.recursiveReadLimit)
|
|
11
|
+
throw new e({
|
|
12
|
+
count: this.recursiveReadCount + 1,
|
|
13
|
+
limit: this.recursiveReadLimit
|
|
14
|
+
});
|
|
15
|
+
},
|
|
16
|
+
assertPosition(t) {
|
|
17
|
+
if (t < 0 || t > this.bytes.length - 1)
|
|
18
|
+
throw new n({
|
|
19
|
+
length: this.bytes.length,
|
|
20
|
+
position: t
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
decrementPosition(t) {
|
|
24
|
+
if (t < 0)
|
|
25
|
+
throw new o({ offset: t });
|
|
26
|
+
const i = this.position - t;
|
|
27
|
+
this.assertPosition(i), this.position = i;
|
|
28
|
+
},
|
|
29
|
+
getReadCount(t) {
|
|
30
|
+
return this.positionReadCount.get(t || this.position) || 0;
|
|
31
|
+
},
|
|
32
|
+
incrementPosition(t) {
|
|
33
|
+
if (t < 0)
|
|
34
|
+
throw new o({ offset: t });
|
|
35
|
+
const i = this.position + t;
|
|
36
|
+
this.assertPosition(i), this.position = i;
|
|
37
|
+
},
|
|
38
|
+
inspectByte(t) {
|
|
39
|
+
const i = t ?? this.position;
|
|
40
|
+
return this.assertPosition(i), this.bytes[i];
|
|
41
|
+
},
|
|
42
|
+
inspectBytes(t, i) {
|
|
43
|
+
const s = i ?? this.position;
|
|
44
|
+
return this.assertPosition(s + t - 1), this.bytes.subarray(s, s + t);
|
|
45
|
+
},
|
|
46
|
+
inspectUint8(t) {
|
|
47
|
+
const i = t ?? this.position;
|
|
48
|
+
return this.assertPosition(i), this.bytes[i];
|
|
49
|
+
},
|
|
50
|
+
inspectUint16(t) {
|
|
51
|
+
const i = t ?? this.position;
|
|
52
|
+
return this.assertPosition(i + 1), this.dataView.getUint16(i);
|
|
53
|
+
},
|
|
54
|
+
inspectUint24(t) {
|
|
55
|
+
const i = t ?? this.position;
|
|
56
|
+
return this.assertPosition(i + 2), (this.dataView.getUint16(i) << 8) + this.dataView.getUint8(i + 2);
|
|
57
|
+
},
|
|
58
|
+
inspectUint32(t) {
|
|
59
|
+
const i = t ?? this.position;
|
|
60
|
+
return this.assertPosition(i + 3), this.dataView.getUint32(i);
|
|
61
|
+
},
|
|
62
|
+
pushByte(t) {
|
|
63
|
+
this.assertPosition(this.position), this.bytes[this.position] = t, this.position++;
|
|
64
|
+
},
|
|
65
|
+
pushBytes(t) {
|
|
66
|
+
this.assertPosition(this.position + t.length - 1), this.bytes.set(t, this.position), this.position += t.length;
|
|
67
|
+
},
|
|
68
|
+
pushUint8(t) {
|
|
69
|
+
this.assertPosition(this.position), this.bytes[this.position] = t, this.position++;
|
|
70
|
+
},
|
|
71
|
+
pushUint16(t) {
|
|
72
|
+
this.assertPosition(this.position + 1), this.dataView.setUint16(this.position, t), this.position += 2;
|
|
73
|
+
},
|
|
74
|
+
pushUint24(t) {
|
|
75
|
+
this.assertPosition(this.position + 2), this.dataView.setUint16(this.position, t >> 8), this.dataView.setUint8(this.position + 2, t & 255), this.position += 3;
|
|
76
|
+
},
|
|
77
|
+
pushUint32(t) {
|
|
78
|
+
this.assertPosition(this.position + 3), this.dataView.setUint32(this.position, t), this.position += 4;
|
|
79
|
+
},
|
|
80
|
+
readByte() {
|
|
81
|
+
this.assertReadLimit(), this._touch();
|
|
82
|
+
const t = this.inspectByte();
|
|
83
|
+
return this.position++, t;
|
|
84
|
+
},
|
|
85
|
+
readBytes(t, i) {
|
|
86
|
+
this.assertReadLimit(), this._touch();
|
|
87
|
+
const s = this.inspectBytes(t);
|
|
88
|
+
return this.position += i ?? t, s;
|
|
89
|
+
},
|
|
90
|
+
readUint8() {
|
|
91
|
+
this.assertReadLimit(), this._touch();
|
|
92
|
+
const t = this.inspectUint8();
|
|
93
|
+
return this.position += 1, t;
|
|
94
|
+
},
|
|
95
|
+
readUint16() {
|
|
96
|
+
this.assertReadLimit(), this._touch();
|
|
97
|
+
const t = this.inspectUint16();
|
|
98
|
+
return this.position += 2, t;
|
|
99
|
+
},
|
|
100
|
+
readUint24() {
|
|
101
|
+
this.assertReadLimit(), this._touch();
|
|
102
|
+
const t = this.inspectUint24();
|
|
103
|
+
return this.position += 3, t;
|
|
104
|
+
},
|
|
105
|
+
readUint32() {
|
|
106
|
+
this.assertReadLimit(), this._touch();
|
|
107
|
+
const t = this.inspectUint32();
|
|
108
|
+
return this.position += 4, t;
|
|
109
|
+
},
|
|
110
|
+
get remaining() {
|
|
111
|
+
return this.bytes.length - this.position;
|
|
112
|
+
},
|
|
113
|
+
setPosition(t) {
|
|
114
|
+
const i = this.position;
|
|
115
|
+
return this.assertPosition(t), this.position = t, () => this.position = i;
|
|
116
|
+
},
|
|
117
|
+
_touch() {
|
|
118
|
+
if (this.recursiveReadLimit === Number.POSITIVE_INFINITY)
|
|
119
|
+
return;
|
|
120
|
+
const t = this.getReadCount();
|
|
121
|
+
this.positionReadCount.set(this.position, t + 1), t > 0 && this.recursiveReadCount++;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
function a(t, { recursiveReadLimit: i = 8192 } = {}) {
|
|
125
|
+
const s = Object.create(h);
|
|
126
|
+
return s.bytes = t, s.dataView = new DataView(t.buffer, t.byteOffset, t.byteLength), s.positionReadCount = /* @__PURE__ */ new Map(), s.recursiveReadLimit = i, s;
|
|
127
|
+
}
|
|
128
|
+
export {
|
|
129
|
+
a as createCursor
|
|
130
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("./index112.cjs"),s=require("./index111.cjs"),S=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),b=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),f=new Uint32Array(64);class g extends H.HashMD{constructor(){super(64,32,8,!1),this.A=b[0]|0,this.B=b[1]|0,this.C=b[2]|0,this.D=b[3]|0,this.E=b[4]|0,this.F=b[5]|0,this.G=b[6]|0,this.H=b[7]|0}get(){const{A:d,B:o,C:x,D:e,E:a,F:i,G:c,H:r}=this;return[d,o,x,e,a,i,c,r]}set(d,o,x,e,a,i,c,r){this.A=d|0,this.B=o|0,this.C=x|0,this.D=e|0,this.E=a|0,this.F=i|0,this.G=c|0,this.H=r|0}process(d,o){for(let t=0;t<16;t++,o+=4)f[t]=d.getUint32(o,!1);for(let t=16;t<64;t++){const A=f[t-15],n=f[t-2],C=s.rotr(A,7)^s.rotr(A,18)^A>>>3,u=s.rotr(n,17)^s.rotr(n,19)^n>>>10;f[t]=u+f[t-7]+C+f[t-16]|0}let{A:x,B:e,C:a,D:i,E:c,F:r,G:h,H:l}=this;for(let t=0;t<64;t++){const A=s.rotr(c,6)^s.rotr(c,11)^s.rotr(c,25),n=l+A+H.Chi(c,r,h)+S[t]+f[t]|0,u=(s.rotr(x,2)^s.rotr(x,13)^s.rotr(x,22))+H.Maj(x,e,a)|0;l=h,h=r,r=c,c=i+n|0,i=a,a=e,e=x,x=n+u|0}x=x+this.A|0,e=e+this.B|0,a=a+this.C|0,i=i+this.D|0,c=c+this.E|0,r=r+this.F|0,h=h+this.G|0,l=l+this.H|0,this.set(x,e,a,i,c,r,h,l)}roundClean(){f.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const y=s.wrapConstructor(()=>new g);exports.SHA256=g;exports.sha256=y;
|
package/dist/index101.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { HashMD as m, Chi as p, Maj as u } from "./index112.js";
|
|
2
|
+
import { wrapConstructor as D, rotr as i } from "./index111.js";
|
|
3
|
+
const g = /* @__PURE__ */ new Uint32Array([
|
|
4
|
+
1116352408,
|
|
5
|
+
1899447441,
|
|
6
|
+
3049323471,
|
|
7
|
+
3921009573,
|
|
8
|
+
961987163,
|
|
9
|
+
1508970993,
|
|
10
|
+
2453635748,
|
|
11
|
+
2870763221,
|
|
12
|
+
3624381080,
|
|
13
|
+
310598401,
|
|
14
|
+
607225278,
|
|
15
|
+
1426881987,
|
|
16
|
+
1925078388,
|
|
17
|
+
2162078206,
|
|
18
|
+
2614888103,
|
|
19
|
+
3248222580,
|
|
20
|
+
3835390401,
|
|
21
|
+
4022224774,
|
|
22
|
+
264347078,
|
|
23
|
+
604807628,
|
|
24
|
+
770255983,
|
|
25
|
+
1249150122,
|
|
26
|
+
1555081692,
|
|
27
|
+
1996064986,
|
|
28
|
+
2554220882,
|
|
29
|
+
2821834349,
|
|
30
|
+
2952996808,
|
|
31
|
+
3210313671,
|
|
32
|
+
3336571891,
|
|
33
|
+
3584528711,
|
|
34
|
+
113926993,
|
|
35
|
+
338241895,
|
|
36
|
+
666307205,
|
|
37
|
+
773529912,
|
|
38
|
+
1294757372,
|
|
39
|
+
1396182291,
|
|
40
|
+
1695183700,
|
|
41
|
+
1986661051,
|
|
42
|
+
2177026350,
|
|
43
|
+
2456956037,
|
|
44
|
+
2730485921,
|
|
45
|
+
2820302411,
|
|
46
|
+
3259730800,
|
|
47
|
+
3345764771,
|
|
48
|
+
3516065817,
|
|
49
|
+
3600352804,
|
|
50
|
+
4094571909,
|
|
51
|
+
275423344,
|
|
52
|
+
430227734,
|
|
53
|
+
506948616,
|
|
54
|
+
659060556,
|
|
55
|
+
883997877,
|
|
56
|
+
958139571,
|
|
57
|
+
1322822218,
|
|
58
|
+
1537002063,
|
|
59
|
+
1747873779,
|
|
60
|
+
1955562222,
|
|
61
|
+
2024104815,
|
|
62
|
+
2227730452,
|
|
63
|
+
2361852424,
|
|
64
|
+
2428436474,
|
|
65
|
+
2756734187,
|
|
66
|
+
3204031479,
|
|
67
|
+
3329325298
|
|
68
|
+
]), b = /* @__PURE__ */ new Uint32Array([
|
|
69
|
+
1779033703,
|
|
70
|
+
3144134277,
|
|
71
|
+
1013904242,
|
|
72
|
+
2773480762,
|
|
73
|
+
1359893119,
|
|
74
|
+
2600822924,
|
|
75
|
+
528734635,
|
|
76
|
+
1541459225
|
|
77
|
+
]), h = /* @__PURE__ */ new Uint32Array(64);
|
|
78
|
+
class w extends m {
|
|
79
|
+
constructor() {
|
|
80
|
+
super(64, 32, 8, !1), this.A = b[0] | 0, this.B = b[1] | 0, this.C = b[2] | 0, this.D = b[3] | 0, this.E = b[4] | 0, this.F = b[5] | 0, this.G = b[6] | 0, this.H = b[7] | 0;
|
|
81
|
+
}
|
|
82
|
+
get() {
|
|
83
|
+
const { A: d, B: o, C: t, D: s, E: a, F: f, G: c, H: e } = this;
|
|
84
|
+
return [d, o, t, s, a, f, c, e];
|
|
85
|
+
}
|
|
86
|
+
// prettier-ignore
|
|
87
|
+
set(d, o, t, s, a, f, c, e) {
|
|
88
|
+
this.A = d | 0, this.B = o | 0, this.C = t | 0, this.D = s | 0, this.E = a | 0, this.F = f | 0, this.G = c | 0, this.H = e | 0;
|
|
89
|
+
}
|
|
90
|
+
process(d, o) {
|
|
91
|
+
for (let x = 0; x < 16; x++, o += 4)
|
|
92
|
+
h[x] = d.getUint32(o, !1);
|
|
93
|
+
for (let x = 16; x < 64; x++) {
|
|
94
|
+
const A = h[x - 15], n = h[x - 2], C = i(A, 7) ^ i(A, 18) ^ A >>> 3, H = i(n, 17) ^ i(n, 19) ^ n >>> 10;
|
|
95
|
+
h[x] = H + h[x - 7] + C + h[x - 16] | 0;
|
|
96
|
+
}
|
|
97
|
+
let { A: t, B: s, C: a, D: f, E: c, F: e, G: r, H: l } = this;
|
|
98
|
+
for (let x = 0; x < 64; x++) {
|
|
99
|
+
const A = i(c, 6) ^ i(c, 11) ^ i(c, 25), n = l + A + p(c, e, r) + g[x] + h[x] | 0, H = (i(t, 2) ^ i(t, 13) ^ i(t, 22)) + u(t, s, a) | 0;
|
|
100
|
+
l = r, r = e, e = c, c = f + n | 0, f = a, a = s, s = t, t = n + H | 0;
|
|
101
|
+
}
|
|
102
|
+
t = t + this.A | 0, s = s + this.B | 0, a = a + this.C | 0, f = f + this.D | 0, c = c + this.E | 0, e = e + this.F | 0, r = r + this.G | 0, l = l + this.H | 0, this.set(t, s, a, f, c, e, r, l);
|
|
103
|
+
}
|
|
104
|
+
roundClean() {
|
|
105
|
+
h.fill(0);
|
|
106
|
+
}
|
|
107
|
+
destroy() {
|
|
108
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const G = /* @__PURE__ */ D(() => new w());
|
|
112
|
+
export {
|
|
113
|
+
w as SHA256,
|
|
114
|
+
G as sha256
|
|
115
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./index103.cjs"),w=require("./index93.cjs"),t=require("./index54.cjs"),P=require("./index43.cjs"),h=require("./index99.cjs"),d=require("./index45.cjs"),n=require("./index50.cjs"),c=require("./index58.cjs"),I=require("./index47.cjs"),u=require("./index89.cjs"),l=require("./index34.cjs");function m(o){const{authorizationList:e}=o;if(e)for(const s of e){const{contractAddress:r,chainId:i}=s;if(!c.isAddress(r))throw new t.InvalidAddressError({address:r});if(i<0)throw new d.InvalidChainIdError({chainId:i})}f(o)}function T(o){const{blobVersionedHashes:e}=o;if(e){if(e.length===0)throw new h.EmptyBlobError;for(const s of e){const r=I.size(s),i=l.hexToNumber(u.slice(s,0,1));if(r!==32)throw new h.InvalidVersionedHashSizeError({hash:s,size:r});if(i!==E.versionedHashVersionKzg)throw new h.InvalidVersionedHashVersionError({hash:s,version:i})}}f(o)}function f(o){const{chainId:e,maxPriorityFeePerGas:s,maxFeePerGas:r,to:i}=o;if(e<=0)throw new d.InvalidChainIdError({chainId:e});if(i&&!c.isAddress(i))throw new t.InvalidAddressError({address:i});if(r&&r>w.maxUint256)throw new n.FeeCapTooHighError({maxFeePerGas:r});if(s&&r&&s>r)throw new n.TipAboveFeeCapError({maxFeePerGas:r,maxPriorityFeePerGas:s})}function x(o){const{chainId:e,maxPriorityFeePerGas:s,gasPrice:r,maxFeePerGas:i,to:a}=o;if(e<=0)throw new d.InvalidChainIdError({chainId:e});if(a&&!c.isAddress(a))throw new t.InvalidAddressError({address:a});if(s||i)throw new P.BaseError("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(r&&r>w.maxUint256)throw new n.FeeCapTooHighError({maxFeePerGas:r})}function v(o){const{chainId:e,maxPriorityFeePerGas:s,gasPrice:r,maxFeePerGas:i,to:a}=o;if(a&&!c.isAddress(a))throw new t.InvalidAddressError({address:a});if(typeof e<"u"&&e<=0)throw new d.InvalidChainIdError({chainId:e});if(s||i)throw new P.BaseError("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(r&&r>w.maxUint256)throw new n.FeeCapTooHighError({maxFeePerGas:r})}exports.assertTransactionEIP1559=f;exports.assertTransactionEIP2930=x;exports.assertTransactionEIP4844=T;exports.assertTransactionEIP7702=m;exports.assertTransactionLegacy=v;
|
package/dist/index102.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { versionedHashVersionKzg as d } from "./index103.js";
|
|
2
|
+
import { maxUint256 as m } from "./index93.js";
|
|
3
|
+
import { InvalidAddressError as s } from "./index54.js";
|
|
4
|
+
import { BaseError as h } from "./index43.js";
|
|
5
|
+
import { EmptyBlobError as P, InvalidVersionedHashSizeError as p, InvalidVersionedHashVersionError as x } from "./index99.js";
|
|
6
|
+
import { InvalidChainIdError as n } from "./index45.js";
|
|
7
|
+
import { FeeCapTooHighError as w, TipAboveFeeCapError as E } from "./index50.js";
|
|
8
|
+
import { isAddress as f } from "./index58.js";
|
|
9
|
+
import { size as F } from "./index47.js";
|
|
10
|
+
import { slice as I } from "./index89.js";
|
|
11
|
+
import { hexToNumber as G } from "./index34.js";
|
|
12
|
+
function C(t) {
|
|
13
|
+
const { authorizationList: e } = t;
|
|
14
|
+
if (e)
|
|
15
|
+
for (const o of e) {
|
|
16
|
+
const { contractAddress: r, chainId: i } = o;
|
|
17
|
+
if (!f(r))
|
|
18
|
+
throw new s({ address: r });
|
|
19
|
+
if (i < 0)
|
|
20
|
+
throw new n({ chainId: i });
|
|
21
|
+
}
|
|
22
|
+
c(t);
|
|
23
|
+
}
|
|
24
|
+
function L(t) {
|
|
25
|
+
const { blobVersionedHashes: e } = t;
|
|
26
|
+
if (e) {
|
|
27
|
+
if (e.length === 0)
|
|
28
|
+
throw new P();
|
|
29
|
+
for (const o of e) {
|
|
30
|
+
const r = F(o), i = G(I(o, 0, 1));
|
|
31
|
+
if (r !== 32)
|
|
32
|
+
throw new p({ hash: o, size: r });
|
|
33
|
+
if (i !== d)
|
|
34
|
+
throw new x({
|
|
35
|
+
hash: o,
|
|
36
|
+
version: i
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
c(t);
|
|
41
|
+
}
|
|
42
|
+
function c(t) {
|
|
43
|
+
const { chainId: e, maxPriorityFeePerGas: o, maxFeePerGas: r, to: i } = t;
|
|
44
|
+
if (e <= 0)
|
|
45
|
+
throw new n({ chainId: e });
|
|
46
|
+
if (i && !f(i))
|
|
47
|
+
throw new s({ address: i });
|
|
48
|
+
if (r && r > m)
|
|
49
|
+
throw new w({ maxFeePerGas: r });
|
|
50
|
+
if (o && r && o > r)
|
|
51
|
+
throw new E({ maxFeePerGas: r, maxPriorityFeePerGas: o });
|
|
52
|
+
}
|
|
53
|
+
function B(t) {
|
|
54
|
+
const { chainId: e, maxPriorityFeePerGas: o, gasPrice: r, maxFeePerGas: i, to: a } = t;
|
|
55
|
+
if (e <= 0)
|
|
56
|
+
throw new n({ chainId: e });
|
|
57
|
+
if (a && !f(a))
|
|
58
|
+
throw new s({ address: a });
|
|
59
|
+
if (o || i)
|
|
60
|
+
throw new h("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");
|
|
61
|
+
if (r && r > m)
|
|
62
|
+
throw new w({ maxFeePerGas: r });
|
|
63
|
+
}
|
|
64
|
+
function K(t) {
|
|
65
|
+
const { chainId: e, maxPriorityFeePerGas: o, gasPrice: r, maxFeePerGas: i, to: a } = t;
|
|
66
|
+
if (a && !f(a))
|
|
67
|
+
throw new s({ address: a });
|
|
68
|
+
if (typeof e < "u" && e <= 0)
|
|
69
|
+
throw new n({ chainId: e });
|
|
70
|
+
if (o || i)
|
|
71
|
+
throw new h("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");
|
|
72
|
+
if (r && r > m)
|
|
73
|
+
throw new w({ maxFeePerGas: r });
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
c as assertTransactionEIP1559,
|
|
77
|
+
B as assertTransactionEIP2930,
|
|
78
|
+
L as assertTransactionEIP4844,
|
|
79
|
+
C as assertTransactionEIP7702,
|
|
80
|
+
K as assertTransactionLegacy
|
|
81
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=1;exports.versionedHashVersionKzg=e;
|
package/dist/index103.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index24.cjs"),c=require("./index88.cjs");function u(t){if(!t||t.length===0)return[];const e=[];for(const n of t){const{contractAddress:s,chainId:r,nonce:i,...a}=n;e.push([r?o.toHex(r):"0x",s,i?o.toHex(i):"0x",...c.toYParitySignatureArray({},a)])}return e}exports.serializeAuthorizationList=u;
|
package/dist/index104.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { toHex as i } from "./index24.js";
|
|
2
|
+
import { toYParitySignatureArray as c } from "./index88.js";
|
|
3
|
+
function d(r) {
|
|
4
|
+
if (!r || r.length === 0)
|
|
5
|
+
return [];
|
|
6
|
+
const t = [];
|
|
7
|
+
for (const e of r) {
|
|
8
|
+
const { contractAddress: s, chainId: o, nonce: n, ...a } = e;
|
|
9
|
+
t.push([
|
|
10
|
+
o ? i(o) : "0x",
|
|
11
|
+
s,
|
|
12
|
+
n ? i(n) : "0x",
|
|
13
|
+
...c({}, a)
|
|
14
|
+
]);
|
|
15
|
+
}
|
|
16
|
+
return t;
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
d as serializeAuthorizationList
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index54.cjs"),d=require("./index29.cjs"),l=require("./index58.cjs");function a(e){if(!e||e.length===0)return[];const n=[];for(let t=0;t<e.length;t++){const{address:i,storageKeys:r}=e[t];for(let s=0;s<r.length;s++)if(r[s].length-2!==64)throw new d.InvalidStorageKeySizeError({storageKey:r[s]});if(!l.isAddress(i,{strict:!1}))throw new o.InvalidAddressError({address:i});n.push([i,r])}return n}exports.serializeAccessList=a;
|
package/dist/index105.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { InvalidAddressError as s } from "./index54.js";
|
|
2
|
+
import { InvalidStorageKeySizeError as l } from "./index29.js";
|
|
3
|
+
import { isAddress as f } from "./index58.js";
|
|
4
|
+
function a(r) {
|
|
5
|
+
if (!r || r.length === 0)
|
|
6
|
+
return [];
|
|
7
|
+
const n = [];
|
|
8
|
+
for (let o = 0; o < r.length; o++) {
|
|
9
|
+
const { address: i, storageKeys: e } = r[o];
|
|
10
|
+
for (let t = 0; t < e.length; t++)
|
|
11
|
+
if (e[t].length - 2 !== 64)
|
|
12
|
+
throw new l({ storageKey: e[t] });
|
|
13
|
+
if (!f(i, { strict: !1 }))
|
|
14
|
+
throw new s({ address: i });
|
|
15
|
+
n.push([i, e]);
|
|
16
|
+
}
|
|
17
|
+
return n;
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
a as serializeAccessList
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index114.cjs"),s=require("./index111.cjs"),o=require("./index115.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;
|
package/dist/index106.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { hmac as c } from "./index114.js";
|
|
2
|
+
import { concatBytes as m, randomBytes as n } from "./index111.js";
|
|
3
|
+
import { weierstrass as a } from "./index115.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, m(...t)),
|
|
9
|
+
randomBytes: n
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function p(r, e) {
|
|
13
|
+
const t = (o) => a({ ...r, ...i(o) });
|
|
14
|
+
return { ...t(e), create: t };
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
p as createCurve,
|
|
18
|
+
i as getHash
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index116.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;
|