@gardenfi/utils 2.1.2-beta.3 → 2.1.2-beta.4
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/index103.cjs +1 -1
- package/dist/index103.js +3 -3
- package/dist/index104.cjs +1 -1
- package/dist/index104.js +2 -2
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +2 -2
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +18 -17
- package/dist/index21.cjs +16 -1
- package/dist/index21.js +112 -30
- package/dist/index22.cjs +1 -16
- package/dist/index22.js +30 -113
- package/dist/index25.cjs +1 -1
- package/dist/index25.js +3 -3
- package/dist/index39.cjs +1 -1
- package/dist/index39.js +1 -1
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +25 -25
- package/dist/index41.cjs +1 -1
- package/dist/index41.js +1 -1
- package/dist/index42.cjs +1 -1
- package/dist/index42.js +4 -4
- package/dist/index73.cjs +1 -1
- package/dist/index73.js +10 -39
- package/dist/index74.cjs +1 -1
- package/dist/index74.js +17 -32
- package/dist/index75.cjs +1 -1
- package/dist/index75.js +37 -66
- package/dist/index76.cjs +1 -1
- package/dist/index76.js +34 -112
- package/dist/index77.cjs +1 -1
- package/dist/index77.js +63 -61
- package/dist/index78.cjs +1 -1
- package/dist/index78.js +113 -2
- package/dist/index79.cjs +1 -1
- package/dist/index79.js +66 -15
- package/dist/index80.cjs +1 -1
- package/dist/index80.js +2 -224
- package/dist/index81.cjs +1 -1
- package/dist/index81.js +13 -228
- package/dist/index82.cjs +1 -1
- package/dist/index82.js +218 -37
- package/dist/index83.cjs +1 -1
- package/dist/index83.js +225 -98
- package/dist/index84.cjs +1 -1
- package/dist/index84.js +8 -17
- package/dist/index85.cjs +1 -1
- package/dist/index85.js +38 -74
- package/dist/index86.cjs +1 -1
- package/dist/index86.js +104 -18
- package/dist/index87.cjs +1 -1
- package/dist/index87.js +17 -8
- package/dist/index88.cjs +1 -1
- package/dist/index88.js +77 -10
- package/dist/index89.cjs +1 -1
- package/dist/index89.js +18 -19
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +2 -2
- package/dist/index96.cjs +1 -1
- package/dist/index96.js +1 -1
- package/package.json +1 -1
package/dist/index87.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index26.cjs"),c=require("./index42.cjs");function u(t){if(!t||t.length===0)return[];const e=[];for(const r of t){const{chainId:i,nonce:o,...s}=r,a=r.address;e.push([i?n.toHex(i):"0x",a,o?n.toHex(o):"0x",...c.toYParitySignatureArray({},s)])}return e}exports.serializeAuthorizationList=u;
|
package/dist/index87.js
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { toHex as i } from "./index26.js";
|
|
2
|
+
import { toYParitySignatureArray as c } from "./index42.js";
|
|
3
|
+
function f(r) {
|
|
4
|
+
if (!r || r.length === 0)
|
|
5
|
+
return [];
|
|
6
|
+
const t = [];
|
|
7
|
+
for (const o of r) {
|
|
8
|
+
const { chainId: n, nonce: e, ...s } = o, a = o.address;
|
|
9
|
+
t.push([
|
|
10
|
+
n ? i(n) : "0x",
|
|
11
|
+
a,
|
|
12
|
+
e ? i(e) : "0x",
|
|
13
|
+
...c({}, s)
|
|
14
|
+
]);
|
|
15
|
+
}
|
|
16
|
+
return t;
|
|
8
17
|
}
|
|
9
18
|
export {
|
|
10
|
-
|
|
19
|
+
f as serializeAuthorizationList
|
|
11
20
|
};
|
package/dist/index88.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./index97.cjs"),w=require("./index94.cjs"),t=require("./index34.cjs"),P=require("./index48.cjs"),h=require("./index98.cjs"),d=require("./index50.cjs"),n=require("./index55.cjs"),c=require("./index35.cjs"),I=require("./index51.cjs"),u=require("./index91.cjs"),l=require("./index37.cjs");function m(o){const{authorizationList:e}=o;if(e)for(const s of e){const{chainId:r}=s,i=s.address;if(!c.isAddress(i))throw new t.InvalidAddressError({address:i});if(r<0)throw new d.InvalidChainIdError({chainId:r})}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/index88.js
CHANGED
|
@@ -1,14 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { versionedHashVersionKzg as c } from "./index97.js";
|
|
2
|
+
import { maxUint256 as m } from "./index94.js";
|
|
3
|
+
import { InvalidAddressError as s } from "./index34.js";
|
|
4
|
+
import { BaseError as h } from "./index48.js";
|
|
5
|
+
import { EmptyBlobError as P, InvalidVersionedHashSizeError as p, InvalidVersionedHashVersionError as x } from "./index98.js";
|
|
6
|
+
import { InvalidChainIdError as n } from "./index50.js";
|
|
7
|
+
import { FeeCapTooHighError as w, TipAboveFeeCapError as E } from "./index55.js";
|
|
8
|
+
import { isAddress as f } from "./index35.js";
|
|
9
|
+
import { size as F } from "./index51.js";
|
|
10
|
+
import { slice as I } from "./index91.js";
|
|
11
|
+
import { hexToNumber as G } from "./index37.js";
|
|
12
|
+
function C(t) {
|
|
13
|
+
const { authorizationList: e } = t;
|
|
14
|
+
if (e)
|
|
15
|
+
for (const o of e) {
|
|
16
|
+
const { chainId: r } = o, i = o.address;
|
|
17
|
+
if (!f(i))
|
|
18
|
+
throw new s({ address: i });
|
|
19
|
+
if (r < 0)
|
|
20
|
+
throw new n({ chainId: r });
|
|
21
|
+
}
|
|
22
|
+
d(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 !== c)
|
|
34
|
+
throw new x({
|
|
35
|
+
hash: o,
|
|
36
|
+
version: i
|
|
37
|
+
});
|
|
38
|
+
}
|
|
10
39
|
}
|
|
40
|
+
d(t);
|
|
41
|
+
}
|
|
42
|
+
function d(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 });
|
|
11
74
|
}
|
|
12
75
|
export {
|
|
13
|
-
d as
|
|
76
|
+
d as assertTransactionEIP1559,
|
|
77
|
+
B as assertTransactionEIP2930,
|
|
78
|
+
L as assertTransactionEIP4844,
|
|
79
|
+
C as assertTransactionEIP7702,
|
|
80
|
+
K as assertTransactionLegacy
|
|
14
81
|
};
|
package/dist/index89.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index34.cjs"),d=require("./index23.cjs"),l=require("./index35.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/index89.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return e.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/);
|
|
1
|
+
import { InvalidAddressError as s } from "./index34.js";
|
|
2
|
+
import { InvalidStorageKeySizeError as l } from "./index23.js";
|
|
3
|
+
import { isAddress as f } from "./index35.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;
|
|
19
18
|
}
|
|
20
19
|
export {
|
|
21
|
-
|
|
20
|
+
a as serializeAccessList
|
|
22
21
|
};
|
package/dist/index9.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("tough-cookie"),k=require("fetch-cookie"),n=require("./index17.cjs"),m=require("./index13.cjs"),f=require("./index14.cjs"),w=require("viem"),h=require("./index3.cjs"),y=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("tough-cookie"),k=require("fetch-cookie"),n=require("./index17.cjs"),m=require("./index13.cjs"),f=require("./index14.cjs"),w=require("viem"),h=require("./index3.cjs"),y=require("./index20.cjs"),C=require("./index19.cjs"),T=require("./index21.cjs"),v=c=>c&&c.__esModule?c:{default:c},S=v(k);class d{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 m.MemoryStorage),typeof window>"u"){const r=new g.CookieJar;this.fetchWithCookies=S.default(fetch,r)}else this.fetchWithCookies=window.fetch.bind(window)}static fromDigestKey(t,i,e){const r=w.createWalletClient({account:C.privateKeyToAccount(h.add0x(i.digestKey)),transport:w.http(),chain:y.mainnet});return new d(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(u){return n.Err("Failed to get nonce",u)}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.error?n.Err(t.error):n.Ok({Authorization:h.Authorization(t.val)})}}exports.Siwe=d;
|
package/dist/index9.js
CHANGED
|
@@ -5,9 +5,9 @@ import { MemoryStorage as w } from "./index13.js";
|
|
|
5
5
|
import { StoreKeys as d } from "./index14.js";
|
|
6
6
|
import { createWalletClient as g, http as k } from "viem";
|
|
7
7
|
import { add0x as p, parseJwt as y, Authorization as C } from "./index3.js";
|
|
8
|
-
import { mainnet as T } from "./
|
|
8
|
+
import { mainnet as T } from "./index20.js";
|
|
9
9
|
import { privateKeyToAccount as v } from "./index19.js";
|
|
10
|
-
import { createSiweMessage as S } from "./
|
|
10
|
+
import { createSiweMessage as S } from "./index21.js";
|
|
11
11
|
class f {
|
|
12
12
|
constructor(e, n, t) {
|
|
13
13
|
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/index96.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index78.cjs"),s=require("./index69.cjs"),r=require("./index38.cjs");function o(t,i){return e.sha256(s.isHex(t,{strict:!1})?r.toBytes(t):t)}exports.sha256=o;
|
package/dist/index96.js
CHANGED