@gardenfi/utils 2.5.2 → 2.5.3-beta.0
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/README.md +9 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +37 -36
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +4 -4
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +16 -20
- package/dist/index112.cjs +1 -1
- package/dist/index112.js +15 -15
- package/dist/index121.cjs +1 -1
- package/dist/index121.js +1 -1
- package/dist/index130.cjs +1 -1
- package/dist/index130.js +1 -1
- package/dist/index16.cjs +1 -1
- package/dist/index16.js +4 -4
- package/dist/index18.cjs +1 -1
- package/dist/index18.js +20 -9
- package/dist/index197.cjs +1 -1
- package/dist/index197.js +17 -30
- package/dist/index22.cjs +1 -1
- package/dist/index22.js +84 -51
- package/dist/index226.cjs +1 -1
- package/dist/index226.js +2 -2
- package/dist/index229.cjs +1 -1
- package/dist/index229.js +2 -2
- package/dist/index230.cjs +1 -1
- package/dist/index230.js +1 -1
- package/dist/index234.cjs +1 -1
- package/dist/index234.js +7 -8
- package/dist/index235.cjs +1 -1
- package/dist/index235.js +1 -1
- package/dist/index236.cjs +1 -1
- package/dist/index236.js +1 -1
- package/dist/index237.cjs +1 -1
- package/dist/index237.js +2 -2
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +30 -13
- package/dist/index249.cjs +1 -1
- package/dist/index249.js +3 -3
- package/dist/index25.cjs +1 -1
- package/dist/index25.js +30 -58
- package/dist/index250.cjs +1 -1
- package/dist/index250.js +3 -3
- package/dist/index256.cjs +1 -1
- package/dist/index256.js +17 -12
- package/dist/index26.cjs +1 -16
- package/dist/index26.js +11 -113
- package/dist/index269.cjs +1 -1
- package/dist/index269.js +4 -4
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +58 -32
- package/dist/index270.cjs +1 -1
- package/dist/index270.js +5 -5
- package/dist/index271.cjs +1 -1
- package/dist/index271.js +27 -21
- package/dist/index272.cjs +1 -1
- package/dist/index272.js +54 -20
- package/dist/index273.cjs +1 -1
- package/dist/index273.js +18 -54
- package/dist/index274.cjs +1 -1
- package/dist/index274.js +10 -34
- package/dist/index275.cjs +1 -1
- package/dist/index275.js +7 -10
- package/dist/index276.cjs +1 -1
- package/dist/index276.js +12 -13
- package/dist/index277.cjs +1 -1
- package/dist/index277.js +11 -12
- package/dist/index28.cjs +1 -1
- package/dist/index28.js +13 -31
- package/dist/index280.cjs +1 -1
- package/dist/index280.js +103 -11
- package/dist/index281.cjs +1 -1
- package/dist/index281.js +6 -103
- package/dist/index282.cjs +1 -1
- package/dist/index282.js +243 -5
- package/dist/index283.cjs +1 -1
- package/dist/index283.js +6 -224
- package/dist/index284.cjs +1 -1
- package/dist/index284.js +7 -7
- package/dist/index285.cjs +1 -1
- package/dist/index285.js +27 -7
- package/dist/index286.cjs +1 -1
- package/dist/index286.js +18 -25
- package/dist/index287.cjs +1 -1
- package/dist/index287.js +145 -18
- package/dist/index288.cjs +1 -1
- package/dist/index288.js +3 -146
- package/dist/index289.cjs +1 -1
- package/dist/index289.js +155 -3
- package/dist/index29.cjs +16 -1
- package/dist/index29.js +113 -11
- package/dist/index290.cjs +1 -1
- package/dist/index290.js +7 -138
- package/dist/index291.cjs +1 -1
- package/dist/index291.js +128 -143
- package/dist/index292.cjs +1 -1
- package/dist/index292.js +111 -7
- package/dist/index293.cjs +2 -1
- package/dist/index293.js +116 -95
- package/dist/index294.cjs +1 -2
- package/dist/index294.js +35 -127
- package/dist/index295.cjs +1 -1
- package/dist/index295.js +66 -30
- package/dist/index296.cjs +1 -1
- package/dist/index296.js +2 -79
- package/dist/index297.cjs +1 -1
- package/dist/index297.js +12 -2
- package/dist/index298.cjs +1 -1
- package/dist/index298.js +19 -11
- package/dist/index299.cjs +1 -1
- package/dist/index299.js +68 -19
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +10 -8
- package/dist/index300.cjs +1 -1
- package/dist/index300.js +786 -66
- package/dist/index301.cjs +1 -1
- package/dist/index301.js +134 -684
- package/dist/index302.cjs +1 -1
- package/dist/index302.js +185 -124
- package/dist/index303.cjs +2 -1
- package/dist/index303.js +63 -198
- package/dist/index304.cjs +1 -2
- package/dist/index304.js +7 -66
- package/dist/index305.cjs +1 -1
- package/dist/index305.js +62 -4
- package/dist/index306.cjs +1 -1
- package/dist/index306.js +22 -40
- package/dist/index307.cjs +1 -1
- package/dist/index307.js +5 -7
- package/dist/index308.cjs +1 -1
- package/dist/index308.js +72 -57
- package/dist/index309.cjs +1 -1
- package/dist/index309.js +4 -78
- package/dist/index310.cjs +1 -1
- package/dist/index310.js +195 -4
- package/dist/index311.cjs +1 -1
- package/dist/index311.js +4 -194
- package/dist/index312.cjs +1 -1
- package/dist/index312.js +35 -58
- package/dist/index313.cjs +2 -1
- package/dist/index313.js +40 -43
- package/dist/index314.cjs +1 -1
- package/dist/index314.js +2 -5
- package/dist/index315.cjs +1 -1
- package/dist/index315.js +11 -5
- package/dist/index316.cjs +1 -1
- package/dist/index316.js +20 -2
- package/dist/index317.cjs +1 -1
- package/dist/index317.js +8 -21
- package/dist/index318.cjs +1 -0
- package/dist/index318.js +45 -0
- package/dist/index319.cjs +1 -0
- package/dist/index319.js +69 -0
- package/dist/index320.cjs +1 -0
- package/dist/index320.js +68 -0
- package/dist/index321.cjs +1 -0
- package/dist/index321.js +191 -0
- package/dist/index322.cjs +1 -0
- package/dist/index322.js +79 -0
- package/dist/index323.cjs +1 -0
- package/dist/index323.js +43 -0
- package/dist/index324.cjs +1 -0
- package/dist/index324.js +19 -0
- package/dist/index325.cjs +1 -0
- package/dist/index325.js +16 -0
- package/dist/index326.cjs +1 -0
- package/dist/index326.js +7 -0
- package/dist/index327.cjs +1 -0
- package/dist/index327.js +66 -0
- package/dist/index328.cjs +1 -0
- package/dist/index328.js +7 -0
- package/dist/index329.cjs +1 -0
- package/dist/index329.js +47 -0
- package/dist/index330.cjs +1 -0
- package/dist/index330.js +71 -0
- package/dist/index331.cjs +1 -0
- package/dist/index331.js +4 -0
- package/dist/index332.cjs +1 -0
- package/dist/index332.js +24 -0
- package/dist/index55.cjs +1 -1
- package/dist/index55.js +1 -1
- package/dist/index58.cjs +1 -1
- package/dist/index58.js +35 -34
- package/dist/index60.cjs +1 -1
- package/dist/index60.js +26 -30
- package/dist/index61.cjs +1 -1
- package/dist/index61.js +13 -9
- package/dist/index62.cjs +1 -1
- package/dist/index62.js +19 -19
- package/dist/index89.cjs +1 -1
- package/dist/index89.js +31 -30
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +2 -2
- package/dist/index95.cjs +1 -1
- package/dist/index95.js +73 -73
- package/dist/src/lib/auth/apikey/apikey.d.ts +1 -1
- package/dist/src/lib/auth/auth.types.d.ts +1 -1
- package/dist/src/lib/fetcher/fetcher.d.ts +2 -0
- package/dist/src/lib/utils.d.ts +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index2.cjs"),e=require("./index3.cjs"),t=require("./index4.cjs"),r=require("./index5.cjs"),i=require("./index6.cjs"),s=require("./index7.cjs"),n=require("./index8.cjs"),c=require("./index9.cjs"),a=require("./index10.cjs"),u=require("./index11.cjs"),y=require("./index12.cjs"),p=require("./index13.cjs"),h=require("./index14.cjs"),k=require("./index15.cjs"),l=require("./index16.cjs"),q=require("./index17.cjs"),A=require("./index18.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.trim0x=e.trim0x;exports.with0x=e.with0x;exports.checkAllowanceAndApprove=t.checkAllowanceAndApprove;exports.waitForTransactionReceipt=t.waitForTransactionReceipt;exports.Err=r.Err;exports.Ok=r.Ok;exports.Void=r.Void;exports.DigestKey=i.DigestKey;exports.executeWithTryCatch=s.executeWithTryCatch;exports.Url=n.Url;exports.AuthHeaderEnum=c.AuthHeaderEnum;exports.Siwe=a.Siwe;exports.ApiKey=u.ApiKey;exports.Passkey=y.Passkey;exports.PasskeyLogin=p.PasskeyLogin;exports.MemoryStorage=h.MemoryStorage;exports.StoreKeys=k.StoreKeys;exports.fetchEVMBlockNumber=l.fetchEVMBlockNumber;exports.EventBroker=q.EventBroker;exports.Fetcher=A.Fetcher;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index2.cjs"),e=require("./index3.cjs"),t=require("./index4.cjs"),r=require("./index5.cjs"),i=require("./index6.cjs"),s=require("./index7.cjs"),n=require("./index8.cjs"),c=require("./index9.cjs"),a=require("./index10.cjs"),u=require("./index11.cjs"),y=require("./index12.cjs"),p=require("./index13.cjs"),h=require("./index14.cjs"),k=require("./index15.cjs"),l=require("./index16.cjs"),q=require("./index17.cjs"),A=require("./index18.cjs");exports.ApiStatus=o.ApiStatus;exports.Authorization=e.Authorization;exports.Environment=e.Environment;exports.Network=e.Network;exports.add0x=e.add0x;exports.hasKeys=e.hasKeys;exports.hexToU32Array=e.hexToU32Array;exports.parseJwt=e.parseJwt;exports.sleep=e.sleep;exports.trim0x=e.trim0x;exports.with0x=e.with0x;exports.checkAllowanceAndApprove=t.checkAllowanceAndApprove;exports.waitForTransactionReceipt=t.waitForTransactionReceipt;exports.Err=r.Err;exports.Ok=r.Ok;exports.Void=r.Void;exports.DigestKey=i.DigestKey;exports.executeWithTryCatch=s.executeWithTryCatch;exports.Url=n.Url;exports.AuthHeaderEnum=c.AuthHeaderEnum;exports.Siwe=a.Siwe;exports.ApiKey=u.ApiKey;exports.Passkey=y.Passkey;exports.PasskeyLogin=p.PasskeyLogin;exports.MemoryStorage=h.MemoryStorage;exports.StoreKeys=k.StoreKeys;exports.fetchEVMBlockNumber=l.fetchEVMBlockNumber;exports.EventBroker=q.EventBroker;exports.Fetcher=A.Fetcher;
|
package/dist/index.js
CHANGED
|
@@ -1,47 +1,48 @@
|
|
|
1
|
-
import { ApiStatus as
|
|
2
|
-
import { Authorization as p, Environment as m, Network as x, add0x as f, hexToU32Array as i, parseJwt as
|
|
3
|
-
import { checkAllowanceAndApprove as
|
|
4
|
-
import { Err as
|
|
5
|
-
import { DigestKey as
|
|
1
|
+
import { ApiStatus as o } from "./index2.js";
|
|
2
|
+
import { Authorization as p, Environment as m, Network as x, add0x as f, hasKeys as a, hexToU32Array as i, parseJwt as s, sleep as n, trim0x as c, with0x as h } from "./index3.js";
|
|
3
|
+
import { checkAllowanceAndApprove as A, waitForTransactionReceipt as k } from "./index4.js";
|
|
4
|
+
import { Err as w, Ok as d, Void as l } from "./index5.js";
|
|
5
|
+
import { DigestKey as K } from "./index6.js";
|
|
6
6
|
import { executeWithTryCatch as g } from "./index7.js";
|
|
7
|
-
import { Url as
|
|
8
|
-
import { AuthHeaderEnum as
|
|
9
|
-
import { Siwe as
|
|
10
|
-
import { ApiKey as
|
|
11
|
-
import { Passkey as
|
|
12
|
-
import { PasskeyLogin as
|
|
13
|
-
import { MemoryStorage as
|
|
14
|
-
import { StoreKeys as
|
|
15
|
-
import { fetchEVMBlockNumber as
|
|
16
|
-
import { EventBroker as
|
|
17
|
-
import { Fetcher as
|
|
7
|
+
import { Url as T } from "./index8.js";
|
|
8
|
+
import { AuthHeaderEnum as F } from "./index9.js";
|
|
9
|
+
import { Siwe as N } from "./index10.js";
|
|
10
|
+
import { ApiKey as U } from "./index11.js";
|
|
11
|
+
import { Passkey as b } from "./index12.js";
|
|
12
|
+
import { PasskeyLogin as C } from "./index13.js";
|
|
13
|
+
import { MemoryStorage as H } from "./index14.js";
|
|
14
|
+
import { StoreKeys as L } from "./index15.js";
|
|
15
|
+
import { fetchEVMBlockNumber as R } from "./index16.js";
|
|
16
|
+
import { EventBroker as j } from "./index17.js";
|
|
17
|
+
import { Fetcher as G } from "./index18.js";
|
|
18
18
|
export {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
U as ApiKey,
|
|
20
|
+
o as ApiStatus,
|
|
21
|
+
F as AuthHeaderEnum,
|
|
22
22
|
p as Authorization,
|
|
23
|
-
|
|
23
|
+
K as DigestKey,
|
|
24
24
|
m as Environment,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
w as Err,
|
|
26
|
+
j as EventBroker,
|
|
27
|
+
G as Fetcher,
|
|
28
|
+
H as MemoryStorage,
|
|
29
29
|
x as Network,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
d as Ok,
|
|
31
|
+
b as Passkey,
|
|
32
|
+
C as PasskeyLogin,
|
|
33
|
+
N as Siwe,
|
|
34
|
+
L as StoreKeys,
|
|
35
|
+
T as Url,
|
|
36
|
+
l as Void,
|
|
37
37
|
f as add0x,
|
|
38
|
-
|
|
38
|
+
A as checkAllowanceAndApprove,
|
|
39
39
|
g as executeWithTryCatch,
|
|
40
|
-
|
|
40
|
+
R as fetchEVMBlockNumber,
|
|
41
|
+
a as hasKeys,
|
|
41
42
|
i as hexToU32Array,
|
|
42
|
-
|
|
43
|
+
s as parseJwt,
|
|
43
44
|
n as sleep,
|
|
44
45
|
c as trim0x,
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
k as waitForTransactionReceipt,
|
|
47
|
+
h as with0x
|
|
47
48
|
};
|
package/dist/index10.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("tough-cookie"),g=require("fetch-cookie"),k=require("./index14.cjs"),f=require("./index15.cjs"),h=require("./index3.cjs"),n=require("./index5.cjs"),m=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("tough-cookie"),g=require("fetch-cookie"),k=require("./index14.cjs"),f=require("./index15.cjs"),h=require("./index3.cjs"),n=require("./index5.cjs"),m=require("./index28.cjs"),y=require("./index27.cjs"),C=require("./index23.cjs"),T=require("./index29.cjs"),v=require("./index25.cjs"),S=c=>c&&c.__esModule?c:{default:c},p=S(g);class u{constructor(t,i,e){if(this.url=t.endpoint("siwe"),this.walletClient=i,this.domain=(e==null?void 0:e.domain)||"app.garden.finance",this.domain.startsWith("https://")&&(this.domain=this.domain.split("https://")[1]),this.signingStatement=(e==null?void 0:e.signingStatement)??"Garden.fi",this.store=(e==null?void 0:e.store)??(typeof window<"u"?window.localStorage:new k.MemoryStorage),typeof window>"u"){const r=new w.CookieJar;this.fetchWithCookies=p.default(fetch,r)}else this.fetchWithCookies=window.fetch.bind(window)}static fromDigestKey(t,i,e){const r=m.createWalletClient({account:C.privateKeyToAccount(h.add0x(i.digestKey)),transport:y.http(),chain:v.mainnet});return new u(t,r,e)}verifyToken(t,i){try{const e=h.parseJwt(t);if(!e)return n.Ok(!1);const r=Math.floor(Date.now()/1e3)+120;return n.Ok(e.exp>r&&e.user_id.toLowerCase()===i.toLowerCase())}catch{return n.Ok(!1)}}async getToken(){var s;if(!((s=this.walletClient.account)!=null&&s.address))return n.Err("Wallet client does not have an account");const t=this.store.getItem(f.StoreKeys.AUTH_TOKEN);if(t){const o=this.verifyToken(t,this.walletClient.account.address);if(o.ok&&o.val)return n.Ok(t)}const i=await this.signStatement();if(i.error)return n.Err(i.error);let e;try{const a=await(await this.fetchWithCookies(this.url.endpoint("tokens"),{method:"POST",body:JSON.stringify({...i.val}),headers:{"Content-Type":"application/json"},credentials:"include"})).json();if(a.error||!a.result)return n.Err(a.error??"Failed to get token");e=a.result}catch(o){return n.Err("Failed to get token",o)}if(!this.verifyToken(e,this.walletClient.account.address).val)throw new Error("Token verification failed");return this.store.setItem(f.StoreKeys.AUTH_TOKEN,e),n.Ok(e)}async signStatement(){var a;if(!((a=this.walletClient.account)!=null&&a.address))return n.Err("Wallet client does not have a valid account");const t=new Date,i=new Date(t.getTime()+300*1e3);let e;try{const l=await(await this.fetchWithCookies(this.url.endpoint("challenges"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include"})).json();if(l.error||!l.result)return n.Err("Failed to get nonce");e=l.result}catch(d){return n.Err("Failed to get nonce",d)}const r=await this.walletClient.getChainId(),s=T.createSiweMessage({domain:this.domain,address:this.walletClient.account.address,statement:this.signingStatement,nonce:e,uri:"https://"+this.domain,version:"1",chainId:r,notBefore:i}),o=await this.walletClient.signMessage({account:this.walletClient.account,message:s});return n.Ok({message:s,signature:o,nonce:e})}async getAuthHeaders(){const t=await this.getToken();return t.ok?n.Ok({Authorization:h.Authorization(t.val)}):n.Err(t.error)}}exports.Siwe=u;
|
package/dist/index10.js
CHANGED
|
@@ -4,11 +4,11 @@ import { MemoryStorage as w } from "./index14.js";
|
|
|
4
4
|
import { StoreKeys as d } from "./index15.js";
|
|
5
5
|
import { add0x as g, parseJwt as k, Authorization as p } from "./index3.js";
|
|
6
6
|
import { Ok as s, Err as r } from "./index5.js";
|
|
7
|
-
import { createWalletClient as y } from "./
|
|
8
|
-
import { http as C } from "./
|
|
7
|
+
import { createWalletClient as y } from "./index28.js";
|
|
8
|
+
import { http as C } from "./index27.js";
|
|
9
9
|
import { privateKeyToAccount as T } from "./index23.js";
|
|
10
|
-
import { createSiweMessage as v } from "./
|
|
11
|
-
import { mainnet as S } from "./
|
|
10
|
+
import { createSiweMessage as v } from "./index29.js";
|
|
11
|
+
import { mainnet as S } from "./index25.js";
|
|
12
12
|
class f {
|
|
13
13
|
constructor(e, n, t) {
|
|
14
14
|
if (this.url = e.endpoint("siwe"), this.walletClient = n, this.domain = (t == null ? void 0 : t.domain) || "app.garden.finance", this.domain.startsWith("https://") && (this.domain = this.domain.split("https://")[1]), this.signingStatement = (t == null ? void 0 : t.signingStatement) ?? "Garden.fi", this.store = (t == null ? void 0 : t.store) ?? (typeof window < "u" ? window.localStorage : new w()), typeof window > "u") {
|
package/dist/index11.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 r=require("./index5.cjs"),f=require("./index9.cjs");class y{constructor(e){this._apiKey=e}async getToken(){const e=this.verifyToken();return e.error?r.Err(e.error):e.val?r.Ok(this._apiKey):r.Err("Token verification failed")}verifyToken(){return this._apiKey.length===64?r.Ok(!0):r.Err("Invalid API key length")}decodeBase64UrlSafe(e){let t=e.replace(/_/g,"/").replace(/-/g,"+");for(;t.length%4!==0;)t+="=";return Uint8Array.from(atob(t),n=>n.charCodeAt(0))}extractData(e){const t=new TextEncoder().encode("::"),n=e.findIndex((i,a)=>e.slice(a,a+t.length).every((l,u)=>l===t[u]));if(n===-1)return r.Err("Invalid format: delimiter not found");const o=e.slice(0,8),s=new DataView(o.buffer).getBigUint64(0,!1),c=e.slice(n+t.length);return r.Ok({expiryTimestamp:new Date(Number(s)*1e3),signature:Array.from(c).map(i=>i.toString(16).padStart(2,"0")).join("")})}async getAuthHeaders(){const e=await this.getToken();return e.ok?r.Ok({[f.AuthHeaderEnum.ApiKey]:e.val}):r.Err(e.error??"Failed to get auth token")}}exports.ApiKey=y;
|
package/dist/index11.js
CHANGED
|
@@ -1,46 +1,42 @@
|
|
|
1
|
-
import { Err as
|
|
2
|
-
import { AuthHeaderEnum as
|
|
3
|
-
class
|
|
1
|
+
import { Err as t, Ok as i } from "./index5.js";
|
|
2
|
+
import { AuthHeaderEnum as d } from "./index9.js";
|
|
3
|
+
class y {
|
|
4
4
|
constructor(e) {
|
|
5
|
-
this.
|
|
5
|
+
this._apiKey = e;
|
|
6
6
|
}
|
|
7
7
|
async getToken() {
|
|
8
8
|
const e = this.verifyToken();
|
|
9
|
-
return e.error ?
|
|
9
|
+
return e.error ? t(e.error) : e.val ? i(this._apiKey) : t("Token verification failed");
|
|
10
10
|
}
|
|
11
11
|
verifyToken() {
|
|
12
|
-
|
|
13
|
-
if (!r.ok)
|
|
14
|
-
return i(r.error);
|
|
15
|
-
const { expiryTimestamp: t } = r.val;
|
|
16
|
-
return t < /* @__PURE__ */ new Date() ? i("Token expired") : n(!0);
|
|
12
|
+
return this._apiKey.length === 64 ? i(!0) : t("Invalid API key length");
|
|
17
13
|
}
|
|
18
14
|
decodeBase64UrlSafe(e) {
|
|
19
15
|
let r = e.replace(/_/g, "/").replace(/-/g, "+");
|
|
20
16
|
for (; r.length % 4 !== 0; )
|
|
21
17
|
r += "=";
|
|
22
|
-
return Uint8Array.from(atob(r), (
|
|
18
|
+
return Uint8Array.from(atob(r), (n) => n.charCodeAt(0));
|
|
23
19
|
}
|
|
24
20
|
extractData(e) {
|
|
25
|
-
const r = new TextEncoder().encode("::"),
|
|
26
|
-
(a, o) => e.slice(o, o + r.length).every((f,
|
|
21
|
+
const r = new TextEncoder().encode("::"), n = e.findIndex(
|
|
22
|
+
(a, o) => e.slice(o, o + r.length).every((f, u) => f === r[u])
|
|
27
23
|
);
|
|
28
|
-
if (
|
|
29
|
-
return
|
|
24
|
+
if (n === -1)
|
|
25
|
+
return t("Invalid format: delimiter not found");
|
|
30
26
|
const s = e.slice(0, 8), c = new DataView(s.buffer).getBigUint64(
|
|
31
27
|
0,
|
|
32
28
|
!1
|
|
33
|
-
),
|
|
34
|
-
return
|
|
29
|
+
), l = e.slice(n + r.length);
|
|
30
|
+
return i({
|
|
35
31
|
expiryTimestamp: new Date(Number(c) * 1e3),
|
|
36
|
-
signature: Array.from(
|
|
32
|
+
signature: Array.from(l).map((a) => a.toString(16).padStart(2, "0")).join("")
|
|
37
33
|
});
|
|
38
34
|
}
|
|
39
35
|
async getAuthHeaders() {
|
|
40
36
|
const e = await this.getToken();
|
|
41
|
-
return e.ok ?
|
|
37
|
+
return e.ok ? i({ [d.ApiKey]: e.val }) : t(e.error ?? "Failed to get auth token");
|
|
42
38
|
}
|
|
43
39
|
}
|
|
44
40
|
export {
|
|
45
|
-
|
|
41
|
+
y as ApiKey
|
|
46
42
|
};
|
package/dist/index112.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("./index50.cjs"),h=require("./index41.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("./index50.cjs"),h=require("./index41.cjs"),g=require("./index143.cjs"),N=require("./index182.cjs"),w=require("./index159.cjs"),L=require("./index187.cjs"),c=require("./index155.cjs"),M=require("./index251.cjs"),S=require("./index113.cjs"),T="0x5792579257925792579257925792579257925792579257925792579257925792",v=c.numberToHex(0,{size:32});async function _(i,s){const{account:p=i.account,capabilities:l,chain:u=i.chain,experimental_fallback:C,experimental_fallbackDelay:m=32,forceAtomic:b=!1,id:x,version:y="2.0.0"}=s,r=p?k.parseAccount(p):null,d=s.calls.map(a=>{const e=a,o=e.abi?N.encodeFunctionData({abi:e.abi,functionName:e.functionName,args:e.args}):e.data;return{data:e.dataSuffix&&o?w.concat([o,e.dataSuffix]):o,to:e.to,value:e.value?c.numberToHex(e.value):void 0}});try{const a=await i.request({method:"wallet_sendCalls",params:[{atomicRequired:b,calls:d,capabilities:l,chainId:c.numberToHex(u.id),from:r==null?void 0:r.address,id:x,version:y}]},{retryCount:0});return typeof a=="string"?{id:a}:a}catch(a){const e=a;if(C&&(e.name==="MethodNotFoundRpcError"||e.name==="MethodNotSupportedRpcError"||e.name==="UnknownRpcError"||e.details.toLowerCase().includes("does not exist / is not available")||e.details.toLowerCase().includes("missing or invalid. request()")||e.details.toLowerCase().includes("did not match any variant of untagged enum")||e.details.toLowerCase().includes("account upgraded to unsupported contract")||e.details.toLowerCase().includes("eip-7702 not supported")||e.details.toLowerCase().includes("unsupported wc_ method")||e.details.toLowerCase().includes("feature toggled misconfigured"))){if(l&&Object.values(l).some(n=>!n.optional)){const n="non-optional `capabilities` are not supported on fallback to `eth_sendTransaction`.";throw new g.UnsupportedNonOptionalCapabilityError(new h.BaseError(n,{details:n}))}if(b&&d.length>1){const t="`forceAtomic` is not supported on fallback to `eth_sendTransaction`.";throw new g.AtomicityNotSupportedError(new h.BaseError(t,{details:t}))}const o=[];for(const t of d){const n=S.sendTransaction(i,{account:r,chain:u,data:t.data,to:t.to,value:t.value?L.hexToBigInt(t.value):void 0});o.push(n),m>0&&await new Promise(E=>setTimeout(E,m))}const f=await Promise.allSettled(o);if(f.every(t=>t.status==="rejected"))throw f[0].reason;const q=f.map(t=>t.status==="fulfilled"?t.value:v);return{id:w.concat([...q,c.numberToHex(u.id,{size:32}),T])}}throw M.getTransactionError(a,{...s,account:r,chain:s.chain})}}exports.fallbackMagicIdentifier=T;exports.fallbackTransactionErrorMagicIdentifier=v;exports.sendCalls=_;
|
package/dist/index112.js
CHANGED
|
@@ -3,28 +3,28 @@ import { BaseError as w } from "./index41.js";
|
|
|
3
3
|
import { UnsupportedNonOptionalCapabilityError as N, AtomicityNotSupportedError as T } from "./index143.js";
|
|
4
4
|
import { encodeFunctionData as k } from "./index182.js";
|
|
5
5
|
import { concat as b } from "./index159.js";
|
|
6
|
-
import { hexToBigInt as
|
|
6
|
+
import { hexToBigInt as L } from "./index187.js";
|
|
7
7
|
import { numberToHex as c } from "./index155.js";
|
|
8
|
-
import { getTransactionError as
|
|
8
|
+
import { getTransactionError as _ } from "./index251.js";
|
|
9
9
|
import { sendTransaction as S } from "./index113.js";
|
|
10
10
|
const A = "0x5792579257925792579257925792579257925792579257925792579257925792", I = c(0, {
|
|
11
11
|
size: 32
|
|
12
12
|
});
|
|
13
13
|
async function P(i, s) {
|
|
14
|
-
const { account: f = i.account, capabilities: l, chain: d = i.chain, experimental_fallback: g, experimental_fallbackDelay: m = 32, forceAtomic: h = !1, id: v, version: C = "2.0.0" } = s, r = f ? E(f) : null, u = s.calls.map((
|
|
15
|
-
const t =
|
|
14
|
+
const { account: f = i.account, capabilities: l, chain: d = i.chain, experimental_fallback: g, experimental_fallbackDelay: m = 32, forceAtomic: h = !1, id: v, version: C = "2.0.0" } = s, r = f ? E(f) : null, u = s.calls.map((e) => {
|
|
15
|
+
const t = e, a = t.abi ? k({
|
|
16
16
|
abi: t.abi,
|
|
17
17
|
functionName: t.functionName,
|
|
18
18
|
args: t.args
|
|
19
19
|
}) : t.data;
|
|
20
20
|
return {
|
|
21
|
-
data: t.dataSuffix &&
|
|
21
|
+
data: t.dataSuffix && a ? b([a, t.dataSuffix]) : a,
|
|
22
22
|
to: t.to,
|
|
23
23
|
value: t.value ? c(t.value) : void 0
|
|
24
24
|
};
|
|
25
25
|
});
|
|
26
26
|
try {
|
|
27
|
-
const
|
|
27
|
+
const e = await i.request({
|
|
28
28
|
method: "wallet_sendCalls",
|
|
29
29
|
params: [
|
|
30
30
|
{
|
|
@@ -38,10 +38,10 @@ async function P(i, s) {
|
|
|
38
38
|
}
|
|
39
39
|
]
|
|
40
40
|
}, { retryCount: 0 });
|
|
41
|
-
return typeof
|
|
42
|
-
} catch (
|
|
43
|
-
const t =
|
|
44
|
-
if (g && (t.name === "MethodNotFoundRpcError" || t.name === "MethodNotSupportedRpcError" || t.name === "UnknownRpcError" || t.details.toLowerCase().includes("does not exist / is not available") || t.details.toLowerCase().includes("missing or invalid. request()") || t.details.toLowerCase().includes("did not match any variant of untagged enum") || t.details.toLowerCase().includes("account upgraded to unsupported contract") || t.details.toLowerCase().includes("eip-7702 not supported") || t.details.toLowerCase().includes("unsupported wc_ method"))) {
|
|
41
|
+
return typeof e == "string" ? { id: e } : e;
|
|
42
|
+
} catch (e) {
|
|
43
|
+
const t = e;
|
|
44
|
+
if (g && (t.name === "MethodNotFoundRpcError" || t.name === "MethodNotSupportedRpcError" || t.name === "UnknownRpcError" || t.details.toLowerCase().includes("does not exist / is not available") || t.details.toLowerCase().includes("missing or invalid. request()") || t.details.toLowerCase().includes("did not match any variant of untagged enum") || t.details.toLowerCase().includes("account upgraded to unsupported contract") || t.details.toLowerCase().includes("eip-7702 not supported") || t.details.toLowerCase().includes("unsupported wc_ method") || t.details.toLowerCase().includes("feature toggled misconfigured"))) {
|
|
45
45
|
if (l && Object.values(l).some((n) => !n.optional)) {
|
|
46
46
|
const n = "non-optional `capabilities` are not supported on fallback to `eth_sendTransaction`.";
|
|
47
47
|
throw new N(new w(n, {
|
|
@@ -54,18 +54,18 @@ async function P(i, s) {
|
|
|
54
54
|
details: o
|
|
55
55
|
}));
|
|
56
56
|
}
|
|
57
|
-
const
|
|
57
|
+
const a = [];
|
|
58
58
|
for (const o of u) {
|
|
59
59
|
const n = S(i, {
|
|
60
60
|
account: r,
|
|
61
61
|
chain: d,
|
|
62
62
|
data: o.data,
|
|
63
63
|
to: o.to,
|
|
64
|
-
value: o.value ?
|
|
64
|
+
value: o.value ? L(o.value) : void 0
|
|
65
65
|
});
|
|
66
|
-
|
|
66
|
+
a.push(n), m > 0 && await new Promise((x) => setTimeout(x, m));
|
|
67
67
|
}
|
|
68
|
-
const p = await Promise.allSettled(
|
|
68
|
+
const p = await Promise.allSettled(a);
|
|
69
69
|
if (p.every((o) => o.status === "rejected"))
|
|
70
70
|
throw p[0].reason;
|
|
71
71
|
const y = p.map((o) => o.status === "fulfilled" ? o.value : I);
|
|
@@ -77,7 +77,7 @@ async function P(i, s) {
|
|
|
77
77
|
])
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
-
throw
|
|
80
|
+
throw _(e, {
|
|
81
81
|
...s,
|
|
82
82
|
account: r,
|
|
83
83
|
chain: s.chain
|
package/dist/index121.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("./index41.cjs"),p=require("./index52.cjs"),e=require("./index143.cjs"),I=require("./index155.cjs"),q=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("./index41.cjs"),p=require("./index52.cjs"),e=require("./index143.cjs"),I=require("./index155.cjs"),q=require("./index277.cjs"),m=require("./index46.cjs"),v=require("./index47.cjs");function N(t,E={}){return async(c,h={})=>{var i;const{dedupe:s=!1,methods:o,retryDelay:R=150,retryCount:l=3,uid:f}={...E,...h},{method:d}=c;if((i=o==null?void 0:o.exclude)!=null&&i.includes(d))throw new e.MethodNotSupportedRpcError(new Error("method not supported"),{method:d});if(o!=null&&o.include&&!o.include.includes(d))throw new e.MethodNotSupportedRpcError(new Error("method not supported"),{method:d});const y=s?I.stringToHex(`${f}.${v.stringify(c)}`):void 0;return q.withDedupe(()=>m.withRetry(async()=>{try{return await t(c)}catch(n){const r=n;switch(r.code){case e.ParseRpcError.code:throw new e.ParseRpcError(r);case e.InvalidRequestRpcError.code:throw new e.InvalidRequestRpcError(r);case e.MethodNotFoundRpcError.code:throw new e.MethodNotFoundRpcError(r,{method:c.method});case e.InvalidParamsRpcError.code:throw new e.InvalidParamsRpcError(r);case e.InternalRpcError.code:throw new e.InternalRpcError(r);case e.InvalidInputRpcError.code:throw new e.InvalidInputRpcError(r);case e.ResourceNotFoundRpcError.code:throw new e.ResourceNotFoundRpcError(r);case e.ResourceUnavailableRpcError.code:throw new e.ResourceUnavailableRpcError(r);case e.TransactionRejectedRpcError.code:throw new e.TransactionRejectedRpcError(r);case e.MethodNotSupportedRpcError.code:throw new e.MethodNotSupportedRpcError(r,{method:c.method});case e.LimitExceededRpcError.code:throw new e.LimitExceededRpcError(r);case e.JsonRpcVersionUnsupportedError.code:throw new e.JsonRpcVersionUnsupportedError(r);case e.UserRejectedRequestError.code:throw new e.UserRejectedRequestError(r);case e.UnauthorizedProviderError.code:throw new e.UnauthorizedProviderError(r);case e.UnsupportedProviderMethodError.code:throw new e.UnsupportedProviderMethodError(r);case e.ProviderDisconnectedError.code:throw new e.ProviderDisconnectedError(r);case e.ChainDisconnectedError.code:throw new e.ChainDisconnectedError(r);case e.SwitchChainError.code:throw new e.SwitchChainError(r);case e.UnsupportedNonOptionalCapabilityError.code:throw new e.UnsupportedNonOptionalCapabilityError(r);case e.UnsupportedChainIdError.code:throw new e.UnsupportedChainIdError(r);case e.DuplicateIdError.code:throw new e.DuplicateIdError(r);case e.UnknownBundleIdError.code:throw new e.UnknownBundleIdError(r);case e.BundleTooLargeError.code:throw new e.BundleTooLargeError(r);case e.AtomicReadyWalletRejectedUpgradeError.code:throw new e.AtomicReadyWalletRejectedUpgradeError(r);case e.AtomicityNotSupportedError.code:throw new e.AtomicityNotSupportedError(r);case 5e3:throw new e.UserRejectedRequestError(r);default:throw n instanceof U.BaseError?n:new e.UnknownRpcError(r)}}},{delay:({count:n,error:r})=>{var a;if(r&&r instanceof p.HttpRequestError){const u=(a=r==null?void 0:r.headers)==null?void 0:a.get("Retry-After");if(u!=null&&u.match(/\d/))return Number.parseInt(u)*1e3}return~~(1<<n)*R},retryCount:l,shouldRetry:({error:n})=>w(n)}),{enabled:s,id:y})}}function w(t){return"code"in t&&typeof t.code=="number"?t.code===-1||t.code===e.LimitExceededRpcError.code||t.code===e.InternalRpcError.code:t instanceof p.HttpRequestError&&t.status?t.status===403||t.status===408||t.status===413||t.status===429||t.status===500||t.status===502||t.status===503||t.status===504:!0}exports.buildRequest=N;exports.shouldRetry=w;
|
package/dist/index121.js
CHANGED
|
@@ -2,7 +2,7 @@ import { BaseError as z } from "./index41.js";
|
|
|
2
2
|
import { HttpRequestError as k } from "./index52.js";
|
|
3
3
|
import { MethodNotSupportedRpcError as s, UnknownRpcError as J, UserRejectedRequestError as u, AtomicityNotSupportedError as f, AtomicReadyWalletRejectedUpgradeError as E, BundleTooLargeError as l, UnknownBundleIdError as R, DuplicateIdError as m, UnsupportedChainIdError as y, UnsupportedNonOptionalCapabilityError as I, SwitchChainError as U, ChainDisconnectedError as v, ProviderDisconnectedError as b, UnsupportedProviderMethodError as N, UnauthorizedProviderError as q, JsonRpcVersionUnsupportedError as C, LimitExceededRpcError as a, TransactionRejectedRpcError as D, ResourceUnavailableRpcError as P, ResourceNotFoundRpcError as x, InvalidInputRpcError as j, InternalRpcError as i, InvalidParamsRpcError as B, MethodNotFoundRpcError as M, InvalidRequestRpcError as S, ParseRpcError as T } from "./index143.js";
|
|
4
4
|
import { stringToHex as O } from "./index155.js";
|
|
5
|
-
import { withDedupe as V } from "./
|
|
5
|
+
import { withDedupe as V } from "./index277.js";
|
|
6
6
|
import { withRetry as W } from "./index46.js";
|
|
7
7
|
import { stringify as _ } from "./index47.js";
|
|
8
8
|
function te(r, A = {}) {
|
package/dist/index130.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="2.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="2.35.1";exports.version=e;
|
package/dist/index130.js
CHANGED
package/dist/index16.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index5.cjs"),a=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index5.cjs"),a=require("./index24.cjs"),s=require("./index25.cjs"),l=require("./index26.cjs"),b=require("./index27.cjs"),n={42161:s.mainnet,421614:a.sepolia},h=async r=>{const{chain:e}=r;if(!e)return c.Err("No chain found");const o=(u=>u in n)(e.id)?n[e.id]:e;return await i(o)},i=async r=>{const e=l.createPublicClient({chain:r,transport:b.http()});try{const t=await e.getBlockNumber();return c.Ok(Number(t))}catch(t){return c.Err("Failed to fetch evm block number",t)}};exports._fetchEVMBlockNumber=i;exports.fetchEVMBlockNumber=h;
|
package/dist/index16.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Err as c, Ok as a } from "./index5.js";
|
|
2
|
-
import { sepolia as m } from "./
|
|
3
|
-
import { mainnet as s } from "./
|
|
4
|
-
import { createPublicClient as u } from "./
|
|
5
|
-
import { http as l } from "./
|
|
2
|
+
import { sepolia as m } from "./index24.js";
|
|
3
|
+
import { mainnet as s } from "./index25.js";
|
|
4
|
+
import { createPublicClient as u } from "./index26.js";
|
|
5
|
+
import { http as l } from "./index27.js";
|
|
6
6
|
const n = {
|
|
7
7
|
42161: s,
|
|
8
8
|
421614: m
|
package/dist/index18.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 h=require("./index30.cjs"),i=require("./index31.cjs");class u{static async _postWithFallback(a,t){let r="";for(const n of a)try{const s=await fetch(n,{method:"POST",...t});if(s.status>=500){r=await(s.text()||s.json());continue}return await this.parse(s)}catch(s){r=o(s);continue}throw new Error(r||"All APIs failed")}static async postWithFallback(a,t){return await c(t).retry(()=>this._postWithFallback(a,t))}static async _getWithFallback(a,t){let r="";for(const n of a)try{const s=await fetch(n,t);if(s.status>=500){r=await(s.text()||s.json());continue}return await this.parse(s)}catch(s){r=o(s);continue}throw new Error(r||"All APIs failed")}static async getWithFallback(a,t){return await c(t).retry(()=>this._getWithFallback(a,t))}static async _get(a,t){return await this.parse(await fetch(a,t))}static async get(a,t){return await c(t).retry(()=>this._get(a,t))}static async _post(a,t){return await this.parse(await fetch(a,{method:"POST",...t}))}static async post(a,t){return await c(t).retry(()=>this._post(a,t))}static async _patch(a,t){return await this.parse(await fetch(a,{method:"PATCH",...t}))}static async patch(a,t){return await c(t).retry(()=>this._patch(a,t))}static async parse(a){const t=await a.text();if(a.status>=200&&a.status<300)return i.safeParseJson(t);throw new Error(t)}}function o(e){return(e==null?void 0:e.message)||(e==null?void 0:e.toString())||"unknown error"}const c=e=>new h.Retry((e==null?void 0:e.retryCount)??2,(e==null?void 0:e.retryDelay)??1e3);exports.Fetcher=u;
|
package/dist/index18.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Retry as h } from "./index30.js";
|
|
2
2
|
import { safeParseJson as i } from "./index31.js";
|
|
3
|
-
class
|
|
3
|
+
class l {
|
|
4
4
|
static async _postWithFallback(a, t) {
|
|
5
5
|
let r = "";
|
|
6
|
-
for (const
|
|
6
|
+
for (const n of a)
|
|
7
7
|
try {
|
|
8
|
-
const e = await fetch(
|
|
8
|
+
const e = await fetch(n, {
|
|
9
9
|
method: "POST",
|
|
10
10
|
...t
|
|
11
11
|
});
|
|
@@ -15,7 +15,7 @@ class w {
|
|
|
15
15
|
}
|
|
16
16
|
return await this.parse(e);
|
|
17
17
|
} catch (e) {
|
|
18
|
-
r =
|
|
18
|
+
r = o(e);
|
|
19
19
|
continue;
|
|
20
20
|
}
|
|
21
21
|
throw new Error(r || "All APIs failed");
|
|
@@ -34,16 +34,16 @@ class w {
|
|
|
34
34
|
}
|
|
35
35
|
static async _getWithFallback(a, t) {
|
|
36
36
|
let r = "";
|
|
37
|
-
for (const
|
|
37
|
+
for (const n of a)
|
|
38
38
|
try {
|
|
39
|
-
const e = await fetch(
|
|
39
|
+
const e = await fetch(n, t);
|
|
40
40
|
if (e.status >= 500) {
|
|
41
41
|
r = await (e.text() || e.json());
|
|
42
42
|
continue;
|
|
43
43
|
}
|
|
44
44
|
return await this.parse(e);
|
|
45
45
|
} catch (e) {
|
|
46
|
-
r =
|
|
46
|
+
r = o(e);
|
|
47
47
|
continue;
|
|
48
48
|
}
|
|
49
49
|
throw new Error(r || "All APIs failed");
|
|
@@ -87,6 +87,17 @@ class w {
|
|
|
87
87
|
static async post(a, t) {
|
|
88
88
|
return await c(t).retry(() => this._post(a, t));
|
|
89
89
|
}
|
|
90
|
+
static async _patch(a, t) {
|
|
91
|
+
return await this.parse(
|
|
92
|
+
await fetch(a, {
|
|
93
|
+
method: "PATCH",
|
|
94
|
+
...t
|
|
95
|
+
})
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
static async patch(a, t) {
|
|
99
|
+
return await c(t).retry(() => this._patch(a, t));
|
|
100
|
+
}
|
|
90
101
|
/**
|
|
91
102
|
* Parses the response and returns the result as the specified type.
|
|
92
103
|
*
|
|
@@ -100,10 +111,10 @@ class w {
|
|
|
100
111
|
throw new Error(t);
|
|
101
112
|
}
|
|
102
113
|
}
|
|
103
|
-
function
|
|
114
|
+
function o(s) {
|
|
104
115
|
return (s == null ? void 0 : s.message) || (s == null ? void 0 : s.toString()) || "unknown error";
|
|
105
116
|
}
|
|
106
117
|
const c = (s) => new h((s == null ? void 0 : s.retryCount) ?? 2, (s == null ? void 0 : s.retryDelay) ?? 1e3);
|
|
107
118
|
export {
|
|
108
|
-
|
|
119
|
+
l as Fetcher
|
|
109
120
|
};
|
package/dist/index197.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 S=require("./index280.cjs"),m=require("./index281.cjs"),t=require("./index282.cjs");/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const i={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},v={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},B=BigInt(2);function G(n){const f=i.p,o=BigInt(3),I=BigInt(6),w=BigInt(11),u=BigInt(22),_=BigInt(23),d=BigInt(44),x=BigInt(88),c=n*n*n%f,e=c*c*n%f,l=t.pow2(e,o,f)*e%f,q=t.pow2(l,o,f)*e%f,r=t.pow2(q,B,f)*c%f,s=t.pow2(r,w,f)*r%f,b=t.pow2(s,u,f)*s%f,g=t.pow2(b,d,f)*b%f,h=t.pow2(g,x,f)*g%f,k=t.pow2(h,d,f)*b%f,C=t.pow2(k,o,f)*e%f,E=t.pow2(C,_,f)*s%f,F=t.pow2(E,I,f)*c%f,p=t.pow2(F,B,f);if(!a.eql(a.sqr(p),n))throw new Error("Cannot find square root");return p}const a=t.Field(i.p,{sqrt:G}),M=m.createCurve({...i,Fp:a,lowS:!0,endo:v},S.sha256);exports.secp256k1=M;
|
package/dist/index197.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { sha256 as
|
|
2
|
-
import { createCurve as G } from "./
|
|
3
|
-
import { Field as
|
|
1
|
+
import { sha256 as F } from "./index280.js";
|
|
2
|
+
import { createCurve as G } from "./index281.js";
|
|
3
|
+
import { Field as v, pow2 as n } from "./index282.js";
|
|
4
4
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5
|
-
const
|
|
5
|
+
const i = {
|
|
6
6
|
p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),
|
|
7
7
|
n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),
|
|
8
8
|
h: BigInt(1),
|
|
@@ -10,33 +10,20 @@ const B = {
|
|
|
10
10
|
b: BigInt(7),
|
|
11
11
|
Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
|
|
12
12
|
Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
|
|
13
|
-
}
|
|
14
|
-
BigInt(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
}, D = {
|
|
14
|
+
beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
|
|
15
|
+
basises: [
|
|
16
|
+
[BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],
|
|
17
|
+
[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]
|
|
18
|
+
]
|
|
19
|
+
}, I = /* @__PURE__ */ BigInt(2);
|
|
20
|
+
function M(t) {
|
|
21
|
+
const f = i.p, o = BigInt(3), p = BigInt(6), x = BigInt(11), _ = BigInt(22), m = BigInt(23), d = BigInt(44), q = BigInt(88), c = t * t * t % f, e = c * c * t % f, u = n(e, o, f) * e % f, k = n(u, o, f) * e % f, r = n(k, I, f) * c % f, b = n(r, x, f) * r % f, s = n(b, _, f) * b % f, g = n(s, d, f) * s % f, w = n(g, q, f) * g % f, h = n(w, d, f) * s % f, l = n(h, o, f) * e % f, C = n(l, m, f) * b % f, E = n(C, p, f) * c % f, B = n(E, I, f);
|
|
22
|
+
if (!a.eql(a.sqr(B), t))
|
|
19
23
|
throw new Error("Cannot find square root");
|
|
20
|
-
return
|
|
24
|
+
return B;
|
|
21
25
|
}
|
|
22
|
-
const
|
|
23
|
-
...B,
|
|
24
|
-
Fp: l,
|
|
25
|
-
lowS: !0,
|
|
26
|
-
// Allow only low-S signatures by default in sign() and verify()
|
|
27
|
-
endo: {
|
|
28
|
-
// Endomorphism, see above
|
|
29
|
-
beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
|
|
30
|
-
splitScalar: (n) => {
|
|
31
|
-
const f = B.n, e = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), a = -M * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), I = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), b = e, s = BigInt("0x100000000000000000000000000000000"), i = k(b * n, f), r = k(-a * n, f);
|
|
32
|
-
let c = h(n - i * e - r * I, f), o = h(-i * a - r * b, f);
|
|
33
|
-
const d = c > s, g = o > s;
|
|
34
|
-
if (d && (c = f - c), g && (o = f - o), c > s || o > s)
|
|
35
|
-
throw new Error("splitScalar: Endomorphism failed, k=" + n);
|
|
36
|
-
return { k1neg: d, k1: c, k2neg: g, k2: o };
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}, v);
|
|
26
|
+
const a = v(i.p, { sqrt: M }), R = G({ ...i, Fp: a, lowS: !0, endo: D }, F);
|
|
40
27
|
export {
|
|
41
|
-
|
|
28
|
+
R as secp256k1
|
|
42
29
|
};
|
package/dist/index22.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=[{inputs:[{components:[{name:"target",type:"address"},{name:"allowFailure",type:"bool"},{name:"callData",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"aggregate3",outputs:[{components:[{name:"success",type:"bool"},{name:"returnData",type:"bytes"}],name:"returnData",type:"tuple[]"}],stateMutability:"view",type:"function"}],n=[{name:"query",type:"function",stateMutability:"view",inputs:[{type:"tuple[]",name:"queries",components:[{type:"address",name:"sender"},{type:"string[]",name:"urls"},{type:"bytes",name:"data"}]}],outputs:[{type:"bool[]",name:"failures"},{type:"bytes[]",name:"responses"}]},{name:"HttpError",type:"error",inputs:[{type:"uint16",name:"status"},{type:"string",name:"message"}]}],e=[{inputs:[
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=[{inputs:[{components:[{name:"target",type:"address"},{name:"allowFailure",type:"bool"},{name:"callData",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"aggregate3",outputs:[{components:[{name:"success",type:"bool"},{name:"returnData",type:"bytes"}],name:"returnData",type:"tuple[]"}],stateMutability:"view",type:"function"}],n=[{name:"query",type:"function",stateMutability:"view",inputs:[{type:"tuple[]",name:"queries",components:[{type:"address",name:"sender"},{type:"string[]",name:"urls"},{type:"bytes",name:"data"}]}],outputs:[{type:"bool[]",name:"failures"},{type:"bytes[]",name:"responses"}]},{name:"HttpError",type:"error",inputs:[{type:"uint16",name:"status"},{type:"string",name:"message"}]}],e=[{inputs:[{name:"dns",type:"bytes"}],name:"DNSDecodingFailed",type:"error"},{inputs:[{name:"ens",type:"string"}],name:"DNSEncodingFailed",type:"error"},{inputs:[],name:"EmptyAddress",type:"error"},{inputs:[{name:"status",type:"uint16"},{name:"message",type:"string"}],name:"HttpError",type:"error"},{inputs:[],name:"InvalidBatchGatewayResponse",type:"error"},{inputs:[{name:"errorData",type:"bytes"}],name:"ResolverError",type:"error"},{inputs:[{name:"name",type:"bytes"},{name:"resolver",type:"address"}],name:"ResolverNotContract",type:"error"},{inputs:[{name:"name",type:"bytes"}],name:"ResolverNotFound",type:"error"},{inputs:[{name:"primary",type:"string"},{name:"primaryAddress",type:"bytes"}],name:"ReverseAddressMismatch",type:"error"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"UnsupportedResolverProfile",type:"error"}],a=[...e,{name:"resolveWithGateways",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes"},{name:"data",type:"bytes"},{name:"gateways",type:"string[]"}],outputs:[{name:"",type:"bytes"},{name:"address",type:"address"}]}],s=[...e,{name:"reverseWithGateways",type:"function",stateMutability:"view",inputs:[{type:"bytes",name:"reverseName"},{type:"uint256",name:"coinType"},{type:"string[]",name:"gateways"}],outputs:[{type:"string",name:"resolvedName"},{type:"address",name:"resolver"},{type:"address",name:"reverseResolver"}]}],p=[{name:"text",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"key",type:"string"}],outputs:[{name:"",type:"string"}]}],i=[{name:"addr",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"}],outputs:[{name:"",type:"address"}]},{name:"addr",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"coinType",type:"uint256"}],outputs:[{name:"",type:"bytes"}]}],r=[{inputs:[{name:"_signer",type:"address"},{name:"_hash",type:"bytes32"},{name:"_signature",type:"bytes"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{name:"_signer",type:"address"},{name:"_hash",type:"bytes32"},{name:"_signature",type:"bytes"}],outputs:[{type:"bool"}],stateMutability:"nonpayable",type:"function",name:"isValidSig"}],y=[{type:"event",name:"Approval",inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"event",name:"Transfer",inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"name",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"symbol",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"totalSupply",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}];exports.addressResolverAbi=i;exports.batchGatewayAbi=n;exports.erc20Abi=y;exports.multicall3Abi=t;exports.textResolverAbi=p;exports.universalResolverResolveAbi=a;exports.universalResolverReverseAbi=s;exports.universalSignatureValidatorAbi=r;
|