@gardenfi/utils 2.1.3-beta.2 → 2.1.3-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/index102.cjs +1 -1
- package/dist/index102.js +8 -12
- package/dist/index104.cjs +1 -1
- package/dist/index104.js +1 -1
- package/dist/index107.cjs +1 -1
- package/dist/index107.js +26 -38
- package/dist/index108.cjs +1 -1
- package/dist/index108.js +43 -45
- package/dist/index110.cjs +1 -1
- package/dist/index110.js +1 -1
- package/dist/index111.cjs +1 -1
- package/dist/index111.js +1 -1
- package/dist/index112.cjs +1 -1
- package/dist/index112.js +1 -1
- package/dist/index113.cjs +1 -1
- package/dist/index113.js +1 -1
- package/dist/index125.cjs +1 -1
- package/dist/index125.js +1 -1
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +4 -4
- package/dist/index189.cjs +1 -1
- package/dist/index189.js +2 -2
- package/dist/index191.cjs +1 -1
- package/dist/index191.js +15 -19
- package/dist/index22.cjs +1 -1
- package/dist/index22.js +6 -6
- package/dist/index23.cjs +1 -1
- package/dist/index23.js +13 -31
- package/dist/index230.cjs +1 -1
- package/dist/index230.js +10 -25
- package/dist/index231.cjs +1 -1
- package/dist/index231.js +16 -13
- package/dist/index232.cjs +1 -1
- package/dist/index232.js +21 -14
- package/dist/index233.cjs +1 -1
- package/dist/index233.js +2 -6
- package/dist/index234.cjs +1 -1
- package/dist/index234.js +12 -12
- package/dist/index235.cjs +1 -1
- package/dist/index235.js +12 -10
- package/dist/index236.cjs +1 -1
- package/dist/index236.js +46 -15
- package/dist/index237.cjs +1 -1
- package/dist/index237.js +11 -10
- package/dist/index238.cjs +1 -1
- package/dist/index238.js +7 -16
- package/dist/index239.cjs +1 -1
- package/dist/index239.js +8 -21
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +58 -32
- package/dist/index240.cjs +1 -1
- package/dist/index240.js +13 -30
- package/dist/index241.cjs +1 -1
- package/dist/index241.js +15 -2
- package/dist/index242.cjs +1 -1
- package/dist/index242.js +9 -13
- package/dist/index243.cjs +1 -1
- package/dist/index243.js +30 -12
- package/dist/index244.cjs +1 -1
- package/dist/index244.js +24 -47
- package/dist/index245.cjs +1 -1
- package/dist/index245.js +12 -11
- package/dist/index246.cjs +1 -1
- package/dist/index246.js +24 -7
- package/dist/index247.cjs +2 -1
- package/dist/index247.js +24 -9
- package/dist/index248.cjs +1 -1
- package/dist/index248.js +10 -10
- package/dist/index249.cjs +1 -1
- package/dist/index249.js +15 -14
- package/dist/index25.cjs +16 -1
- package/dist/index25.js +113 -11
- package/dist/index250.cjs +1 -1
- package/dist/index250.js +52 -9
- package/dist/index251.cjs +1 -1
- package/dist/index251.js +25 -24
- package/dist/index252.cjs +1 -1
- package/dist/index252.js +13 -12
- package/dist/index253.cjs +1 -1
- package/dist/index253.js +15 -24
- package/dist/index254.cjs +1 -2
- package/dist/index254.js +5 -24
- package/dist/index255.cjs +1 -1
- package/dist/index255.js +12 -12
- package/dist/index256.cjs +1 -1
- package/dist/index256.js +10 -15
- package/dist/index257.cjs +1 -1
- package/dist/index257.js +16 -52
- package/dist/index26.cjs +1 -1
- package/dist/index26.js +32 -58
- package/dist/index266.cjs +1 -1
- package/dist/index266.js +1 -1
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +31 -13
- package/dist/index275.cjs +1 -1
- package/dist/index275.js +6 -7
- package/dist/index277.cjs +1 -1
- package/dist/index277.js +2 -2
- package/dist/index278.cjs +1 -1
- package/dist/index278.js +1 -1
- package/dist/index28.cjs +1 -16
- package/dist/index28.js +11 -113
- package/dist/index284.cjs +1 -1
- package/dist/index284.js +1 -1
- package/dist/index286.cjs +1 -1
- package/dist/index286.js +3 -40
- package/dist/index287.cjs +1 -1
- package/dist/index287.js +141 -2
- package/dist/index288.cjs +1 -1
- package/dist/index288.js +148 -199
- package/dist/index289.cjs +1 -1
- package/dist/index289.js +9 -3
- package/dist/index290.cjs +1 -1
- package/dist/index290.js +103 -130
- package/dist/index291.cjs +2 -1
- package/dist/index291.js +102 -123
- package/dist/index292.cjs +1 -1
- package/dist/index292.js +28 -9
- package/dist/index293.cjs +1 -1
- package/dist/index293.js +31 -106
- package/dist/index294.cjs +1 -2
- package/dist/index294.js +8 -131
- package/dist/index295.cjs +1 -1
- package/dist/index295.js +19 -11
- package/dist/index296.cjs +1 -1
- package/dist/index296.js +68 -19
- package/dist/index297.cjs +1 -1
- package/dist/index297.js +2 -69
- package/dist/index298.cjs +1 -1
- package/dist/index298.js +39 -641
- package/dist/index299.cjs +1 -1
- package/dist/index299.js +620 -150
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +1 -1
- package/dist/index30.cjs +1 -1
- package/dist/index30.js +1 -1
- package/dist/index300.cjs +1 -2
- package/dist/index300.js +203 -63
- package/dist/index301.cjs +1 -1
- package/dist/index301.js +172 -4
- package/dist/index302.cjs +2 -1
- package/dist/index302.js +65 -39
- package/dist/index303.cjs +1 -1
- package/dist/index303.js +4 -7
- package/dist/index304.cjs +1 -1
- package/dist/index304.js +38 -60
- package/dist/index305.cjs +1 -1
- package/dist/index305.js +7 -77
- package/dist/index306.cjs +1 -1
- package/dist/index306.js +63 -4
- package/dist/index307.cjs +1 -1
- package/dist/index307.js +64 -181
- package/dist/index308.cjs +1 -1
- package/dist/index308.js +4 -64
- package/dist/index309.cjs +1 -1
- package/dist/index309.js +194 -44
- package/dist/index310.cjs +1 -1
- package/dist/index310.js +18 -4
- package/dist/index311.cjs +1 -1
- package/dist/index311.js +58 -99
- package/dist/index312.cjs +1 -1
- package/dist/index312.js +45 -5
- package/dist/index313.cjs +1 -1
- package/dist/index313.js +5 -2
- package/dist/index314.cjs +1 -1
- package/dist/index314.js +103 -18
- package/dist/index315.cjs +1 -1
- package/dist/index315.js +5 -72
- package/dist/index316.cjs +1 -1
- package/dist/index316.js +2 -22
- package/dist/index317.cjs +1 -0
- package/dist/index317.js +24 -0
- package/dist/index36.cjs +1 -1
- package/dist/index36.js +1 -1
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +4 -0
- package/dist/index53.cjs +1 -1
- package/dist/index53.js +2 -2
- package/dist/index54.cjs +1 -1
- package/dist/index54.js +1 -1
- package/dist/index55.cjs +1 -1
- package/dist/index55.js +2 -2
- package/dist/index56.cjs +1 -1
- package/dist/index56.js +1 -1
- package/dist/index57.cjs +1 -1
- package/dist/index57.js +2 -2
- package/dist/index58.cjs +1 -1
- package/dist/index58.js +111 -114
- package/dist/index59.cjs +1 -1
- package/dist/index59.js +11 -11
- package/dist/index60.cjs +1 -1
- package/dist/index60.js +1 -1
- package/dist/index61.cjs +1 -1
- package/dist/index61.js +1 -1
- package/dist/index62.cjs +1 -1
- package/dist/index62.js +1 -1
- package/dist/index64.cjs +1 -1
- package/dist/index64.js +26 -26
- package/dist/index66.cjs +1 -1
- package/dist/index66.js +3 -3
- package/dist/index73.cjs +1 -1
- package/dist/index73.js +1 -1
- package/dist/index74.cjs +1 -1
- package/dist/index74.js +8 -8
- package/dist/index79.cjs +1 -1
- package/dist/index79.js +1 -1
- package/dist/index83.cjs +1 -1
- package/dist/index83.js +3 -8
- package/dist/index85.cjs +1 -1
- package/dist/index85.js +19 -19
- package/dist/index86.cjs +1 -1
- package/dist/index86.js +2 -2
- package/dist/index88.cjs +1 -1
- package/dist/index88.js +1 -1
- package/dist/index89.cjs +1 -1
- package/dist/index89.js +1 -1
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +4 -4
- package/dist/index92.cjs +1 -1
- package/dist/index92.js +27 -27
- package/dist/index95.cjs +1 -1
- package/dist/index95.js +1 -1
- package/dist/index98.cjs +1 -1
- package/dist/index98.js +1 -1
- package/dist/src/lib/utils.d.ts +1 -2
- package/package.json +1 -1
package/dist/index85.js
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { toRpc as
|
|
2
|
-
import { parseAccount as
|
|
3
|
-
import { AbiDecodingZeroDataError as
|
|
4
|
-
import { RawContractError as
|
|
5
|
-
import { UnknownNodeError as
|
|
6
|
-
import { decodeFunctionResult as
|
|
1
|
+
import { toRpc as B } from "./index243.js";
|
|
2
|
+
import { parseAccount as C } from "./index45.js";
|
|
3
|
+
import { AbiDecodingZeroDataError as F } from "./index122.js";
|
|
4
|
+
import { RawContractError as H } from "./index127.js";
|
|
5
|
+
import { UnknownNodeError as U } from "./index143.js";
|
|
6
|
+
import { decodeFunctionResult as y } from "./index170.js";
|
|
7
7
|
import { encodeFunctionData as A } from "./index177.js";
|
|
8
8
|
import { numberToHex as S } from "./index150.js";
|
|
9
9
|
import { getContractError as z } from "./index221.js";
|
|
10
|
-
import { getNodeError as I } from "./
|
|
10
|
+
import { getNodeError as I } from "./index244.js";
|
|
11
11
|
import { formatBlock as L } from "./index155.js";
|
|
12
12
|
import { formatLog as V } from "./index157.js";
|
|
13
13
|
import { formatTransactionRequest as Z } from "./index184.js";
|
|
14
|
-
import { serializeStateOverride as _ } from "./
|
|
14
|
+
import { serializeStateOverride as _ } from "./index236.js";
|
|
15
15
|
import { assertRequest as j } from "./index197.js";
|
|
16
16
|
async function ar(w, x) {
|
|
17
17
|
const { blockNumber: p, blockTag: N = "latest", blocks: b, returnFullTransactions: O, traceTransfers: h, validation: E } = x;
|
|
18
18
|
try {
|
|
19
19
|
const a = [];
|
|
20
20
|
for (const t of b) {
|
|
21
|
-
const
|
|
22
|
-
const o = n, e = o.account ?
|
|
21
|
+
const d = t.blockOverrides ? B(t.blockOverrides) : void 0, r = t.calls.map((n) => {
|
|
22
|
+
const o = n, e = o.account ? C(o.account) : void 0, i = {
|
|
23
23
|
...o,
|
|
24
24
|
data: o.abi ? A(o) : o.data,
|
|
25
25
|
from: o.from ?? (e == null ? void 0 : e.address)
|
|
26
26
|
};
|
|
27
27
|
return j(i), Z(i);
|
|
28
|
-
}),
|
|
28
|
+
}), f = t.stateOverrides ? _(t.stateOverrides) : void 0;
|
|
29
29
|
a.push({
|
|
30
|
-
blockOverrides:
|
|
30
|
+
blockOverrides: d,
|
|
31
31
|
calls: r,
|
|
32
|
-
stateOverrides:
|
|
32
|
+
stateOverrides: f
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
const c = (
|
|
35
|
+
const c = (p ? S(p) : void 0) || N;
|
|
36
36
|
return (await w.request({
|
|
37
37
|
method: "eth_simulateV1",
|
|
38
38
|
params: [
|
|
39
39
|
{ blockStateCalls: a, returnFullTransactions: O, traceTransfers: h, validation: E },
|
|
40
40
|
c
|
|
41
41
|
]
|
|
42
|
-
})).map((t,
|
|
42
|
+
})).map((t, d) => ({
|
|
43
43
|
...L(t),
|
|
44
|
-
calls: t.calls.map((r,
|
|
44
|
+
calls: t.calls.map((r, f) => {
|
|
45
45
|
var k, g;
|
|
46
|
-
const { abi: n, args: o, functionName: e, to: i } = b[
|
|
46
|
+
const { abi: n, args: o, functionName: e, to: i } = b[d].calls[f], l = ((k = r.error) == null ? void 0 : k.data) ?? r.returnData, R = BigInt(r.gasUsed), T = (g = r.logs) == null ? void 0 : g.map((s) => V(s)), m = r.status === "0x1" ? "success" : "failure", q = n && m === "success" && l !== "0x" ? y({
|
|
47
47
|
abi: n,
|
|
48
48
|
data: l,
|
|
49
49
|
functionName: e
|
|
@@ -52,7 +52,7 @@ async function ar(w, x) {
|
|
|
52
52
|
if (m === "success")
|
|
53
53
|
return;
|
|
54
54
|
let s;
|
|
55
|
-
if (((v = r.error) == null ? void 0 : v.data) === "0x" ? s = new
|
|
55
|
+
if (((v = r.error) == null ? void 0 : v.data) === "0x" ? s = new F() : r.error && (s = new H(r.error)), !!s)
|
|
56
56
|
return z(s, {
|
|
57
57
|
abi: n ?? [],
|
|
58
58
|
address: i,
|
|
@@ -75,7 +75,7 @@ async function ar(w, x) {
|
|
|
75
75
|
}));
|
|
76
76
|
} catch (a) {
|
|
77
77
|
const u = a, c = I(u, {});
|
|
78
|
-
throw c instanceof
|
|
78
|
+
throw c instanceof U ? u : c;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
export {
|
package/dist/index86.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("./index245.cjs"),a=require("./index246.cjs"),Q=require("./index45.cjs"),n=require("./index117.cjs"),W=require("./index118.cjs"),X=require("./index38.cjs"),Y=require("./index177.cjs"),Z=require("./index59.cjs"),$=require("./index85.cjs"),k=require("./index182.cjs"),_="0x6080604052348015600e575f80fd5b5061016d8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063f8b2cb4f1461002d575b5f80fd5b610047600480360381019061004291906100db565b61005d565b604051610054919061011e565b60405180910390f35b5f8173ffffffffffffffffffffffffffffffffffffffff16319050919050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100aa82610081565b9050919050565b6100ba816100a0565b81146100c4575f80fd5b50565b5f813590506100d5816100b1565b92915050565b5f602082840312156100f0576100ef61007d565b5b5f6100fd848285016100c7565b91505092915050565b5f819050919050565b61011881610106565b82525050565b5f6020820190506101315f83018461010f565b9291505056fea26469706673582212203b9fe929fe995c7cf9887f0bdba8a36dd78e8b73f149b17d2d9ad7cd09d2dc6264736f6c634300081a0033";async function ss(q,o){const{blockNumber:C,blockTag:v,calls:N,stateOverrides:d,traceAssetChanges:f,traceTransfers:T,validation:w}=o,t=o.account?Q.parseAccount(o.account):void 0;if(f&&!t)throw new X.BaseError("`account` is required when `traceAssetChanges` is true");const B=t?z.encode(z.from("constructor(bytes, bytes)"),{bytecode:W.deploylessCallViaBytecodeBytecode,args:[_,a.encodeData(a.from("function getBalance(address)"),[t.address])]}):void 0,c=f?await Promise.all(o.calls.map(async s=>{if(!s.data&&!s.abi)return;const{accessList:e}=await Z.createAccessList(q,{account:t.address,...s,data:s.abi?Y.encodeFunctionData(s):s.data});return e.map(({address:r,storageKeys:i})=>i.length>0?r:null)})).then(s=>s.flat().filter(Boolean)):[],P=d==null?void 0:d.map(s=>s.address===(t==null?void 0:t.address)?{...s,nonce:0}:s),l=await $.simulateBlocks(q,{blockNumber:C,blockTag:v,blocks:[...f?[{calls:[{data:B}],stateOverrides:d},{calls:c.map((s,e)=>({abi:[a.from("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[t.address],to:s,from:n.zeroAddress,nonce:e})),stateOverrides:[{address:n.zeroAddress,nonce:0}]}]:[],{calls:[...N,{}].map((s,e)=>({...s,from:t==null?void 0:t.address,nonce:e})),stateOverrides:P},...f?[{calls:[{data:B}]},{calls:c.map((s,e)=>({abi:[a.from("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[t.address],to:s,from:n.zeroAddress,nonce:e})),stateOverrides:[{address:n.zeroAddress,nonce:0}]},{calls:c.map((s,e)=>({to:s,abi:[a.from("function decimals() returns (uint256)")],functionName:"decimals",from:n.zeroAddress,nonce:e})),stateOverrides:[{address:n.zeroAddress,nonce:0}]},{calls:c.map((s,e)=>({to:s,abi:[a.from("function tokenURI(uint256) returns (string)")],functionName:"tokenURI",args:[0n],from:n.zeroAddress,nonce:e})),stateOverrides:[{address:n.zeroAddress,nonce:0}]},{calls:c.map((s,e)=>({to:s,abi:[a.from("function symbol() returns (string)")],functionName:"symbol",from:n.zeroAddress,nonce:e})),stateOverrides:[{address:n.zeroAddress,nonce:0}]}]:[]],traceTransfers:T,validation:w}),I=f?l[2]:l[0],[u,b,,m,g,p,A,y]=f?l:[],{calls:D,...F}=I,L=D.slice(0,-1)??[],R=(u==null?void 0:u.calls)??[],S=(b==null?void 0:b.calls)??[],U=[...R,...S].map(s=>s.status==="success"?k.hexToBigInt(s.data):null),E=(m==null?void 0:m.calls)??[],H=(g==null?void 0:g.calls)??[],j=[...E,...H].map(s=>s.status==="success"?k.hexToBigInt(s.data):null),x=((p==null?void 0:p.calls)??[]).map(s=>s.status==="success"?s.result:null),M=((y==null?void 0:y.calls)??[]).map(s=>s.status==="success"?s.result:null),V=((A==null?void 0:A.calls)??[]).map(s=>s.status==="success"?s.result:null),h=[];for(const[s,e]of j.entries()){const r=U[s];if(typeof e!="bigint"||typeof r!="bigint")continue;const i=x[s-1],G=M[s-1],J=V[s-1],O=s===0?{address:n.ethAddress,decimals:18,symbol:"ETH"}:{address:c[s-1],decimals:J||i?Number(i??1):void 0,symbol:G??void 0};h.some(K=>K.token.address===O.address)||h.push({token:O,value:{pre:r,post:e,diff:e-r}})}return{assetChanges:h,block:F,results:L}}exports.simulateCalls=ss;
|
package/dist/index86.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { encode as K, from as M } from "./
|
|
2
|
-
import { encodeData as Q, from as c } from "./
|
|
1
|
+
import { encode as K, from as M } from "./index245.js";
|
|
2
|
+
import { encodeData as Q, from as c } from "./index246.js";
|
|
3
3
|
import { parseAccount as W } from "./index45.js";
|
|
4
4
|
import { zeroAddress as t, ethAddress as X } from "./index117.js";
|
|
5
5
|
import { deploylessCallViaBytecodeBytecode as Y } from "./index118.js";
|
package/dist/index88.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index223.cjs"),y=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index223.cjs"),y=require("./index250.cjs");async function f(e,{address:s,message:a,factory:r,factoryData:t,signature:i,...o}){const c=n.hashMessage(a);return y.verifyHash(e,{address:s,factory:r,factoryData:t,hash:c,signature:i,...o})}exports.verifyMessage=f;
|
package/dist/index88.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hashMessage as h } from "./index223.js";
|
|
2
|
-
import { verifyHash as i } from "./
|
|
2
|
+
import { verifyHash as i } from "./index250.js";
|
|
3
3
|
async function m(r, { address: a, message: o, factory: s, factoryData: t, signature: e, ...f }) {
|
|
4
4
|
const c = h(o);
|
|
5
5
|
return i(r, {
|
package/dist/index89.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index187.cjs"),h=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index187.cjs"),h=require("./index250.cjs");async function p(a,e){const{address:t,factory:r,factoryData:s,signature:y,message:o,primaryType:c,types:i,domain:n,...f}=e,d=u.hashTypedData({message:o,primaryType:c,types:i,domain:n});return h.verifyHash(a,{address:t,factory:r,factoryData:s,hash:d,signature:y,...f})}exports.verifyTypedData=p;
|
package/dist/index89.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hashTypedData as m } from "./index187.js";
|
|
2
|
-
import { verifyHash as d } from "./
|
|
2
|
+
import { verifyHash as d } from "./index250.js";
|
|
3
3
|
async function D(a, t) {
|
|
4
4
|
const { address: r, factory: e, factoryData: o, signature: s, message: y, primaryType: c, types: f, domain: i, ...n } = t, p = m({ message: y, primaryType: c, types: f, domain: i });
|
|
5
5
|
return d(a, {
|
package/dist/index9.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("tough-cookie"),g=require("fetch-cookie"),n=require("./index17.cjs"),k=require("./index13.cjs"),f=require("./index14.cjs"),h=require("./index3.cjs"),m=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("tough-cookie"),g=require("fetch-cookie"),n=require("./index17.cjs"),k=require("./index13.cjs"),f=require("./index14.cjs"),h=require("./index3.cjs"),m=require("./index23.cjs"),y=require("./index24.cjs"),C=require("./index22.cjs"),T=require("./index25.cjs"),v=require("./index26.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.error?n.Err(t.error):n.Ok({Authorization:h.Authorization(t.val)})}}exports.Siwe=u;
|
package/dist/index9.js
CHANGED
|
@@ -4,11 +4,11 @@ import { Ok as s, Err as r } from "./index17.js";
|
|
|
4
4
|
import { MemoryStorage as w } from "./index13.js";
|
|
5
5
|
import { StoreKeys as d } from "./index14.js";
|
|
6
6
|
import { add0x as g, parseJwt as p, Authorization as k } from "./index3.js";
|
|
7
|
-
import { createWalletClient as y } from "./
|
|
8
|
-
import { http as C } from "./
|
|
7
|
+
import { createWalletClient as y } from "./index23.js";
|
|
8
|
+
import { http as C } from "./index24.js";
|
|
9
9
|
import { privateKeyToAccount as T } from "./index22.js";
|
|
10
|
-
import { createSiweMessage as v } from "./
|
|
11
|
-
import { mainnet as S } from "./
|
|
10
|
+
import { createSiweMessage as v } from "./index25.js";
|
|
11
|
+
import { mainnet as S } from "./index26.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/index92.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index29.cjs"),h=require("./index39.cjs"),q=require("./index40.cjs"),A=require("./index42.cjs"),p=require("./index68.cjs");function S(r,{blockTag:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index29.cjs"),h=require("./index39.cjs"),q=require("./index40.cjs"),A=require("./index42.cjs"),p=require("./index68.cjs");function S(r,{blockTag:f="latest",emitMissed:y=!1,emitOnBegin:g=!1,onBlock:k,onError:u,includeTransactions:m,poll:d,pollingInterval:w=r.pollingInterval}){const B=typeof d<"u"?d:!(r.transport.type==="webSocket"||r.transport.type==="fallback"&&r.transport.transports[0].config.type==="webSocket"),o=m??!1;let t;return B?(()=>{const c=A.stringify(["watchBlocks",r.uid,f,y,g,o,w]);return h.observe(c,{onBlock:k,onError:u},n=>q.poll(async()=>{var a;try{const e=await i.getAction(r,p.getBlock,"getBlock")({blockTag:f,includeTransactions:o});if(e.number&&(t!=null&&t.number)){if(e.number===t.number)return;if(e.number-t.number>1&&y)for(let b=(t==null?void 0:t.number)+1n;b<e.number;b++){const s=await i.getAction(r,p.getBlock,"getBlock")({blockNumber:b,includeTransactions:o});n.onBlock(s,t),t=s}}(!(t!=null&&t.number)||f==="pending"&&!(e!=null&&e.number)||e.number&&e.number>t.number)&&(n.onBlock(e,t),t=e)}catch(e){(a=n.onError)==null||a.call(n,e)}},{emitOnBegin:g,interval:w}))})():(()=>{let c=!0,n=!0,a=()=>c=!1;return(async()=>{try{g&&i.getAction(r,p.getBlock,"getBlock")({blockTag:f,includeTransactions:o}).then(s=>{c&&n&&(k(s,void 0),n=!1)});const e=(()=>{if(r.transport.type==="fallback"){const s=r.transport.transports.find(l=>l.config.type==="webSocket");return s?s.value:r.transport}return r.transport})(),{unsubscribe:b}=await e.subscribe({params:["newHeads"],async onData(s){if(!c)return;const l=await i.getAction(r,p.getBlock,"getBlock")({blockNumber:s.blockNumber,includeTransactions:o}).catch(()=>{});c&&(k(l,t),n=!1,t=l)},onError(s){u==null||u(s)}});a=b,c||a()}catch(e){u==null||u(e)}})(),()=>a()})()}exports.watchBlocks=S;
|
package/dist/index92.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { getAction as
|
|
1
|
+
import { getAction as l } from "./index29.js";
|
|
2
2
|
import { observe as B } from "./index39.js";
|
|
3
3
|
import { poll as N } from "./index40.js";
|
|
4
4
|
import { stringify as S } from "./index42.js";
|
|
5
5
|
import { getBlock as p } from "./index68.js";
|
|
6
|
-
function j(e, { blockTag: b = "latest", emitMissed: y = !1, emitOnBegin: m = !1, onBlock: k, onError:
|
|
6
|
+
function j(e, { blockTag: b = "latest", emitMissed: y = !1, emitOnBegin: m = !1, onBlock: k, onError: a, includeTransactions: h, poll: d, pollingInterval: w = e.pollingInterval }) {
|
|
7
7
|
const g = typeof d < "u" ? d : !(e.transport.type === "webSocket" || e.transport.type === "fallback" && e.transport.transports[0].config.type === "webSocket"), f = h ?? !1;
|
|
8
8
|
let t;
|
|
9
9
|
return g ? (() => {
|
|
10
|
-
const
|
|
10
|
+
const u = S([
|
|
11
11
|
"watchBlocks",
|
|
12
12
|
e.uid,
|
|
13
13
|
b,
|
|
@@ -16,72 +16,72 @@ function j(e, { blockTag: b = "latest", emitMissed: y = !1, emitOnBegin: m = !1,
|
|
|
16
16
|
f,
|
|
17
17
|
w
|
|
18
18
|
]);
|
|
19
|
-
return B(
|
|
19
|
+
return B(u, { onBlock: k, onError: a }, (n) => N(async () => {
|
|
20
20
|
var o;
|
|
21
21
|
try {
|
|
22
|
-
const r = await
|
|
22
|
+
const r = await l(e, p, "getBlock")({
|
|
23
23
|
blockTag: b,
|
|
24
24
|
includeTransactions: f
|
|
25
25
|
});
|
|
26
|
-
if (r.number
|
|
26
|
+
if (r.number && (t != null && t.number)) {
|
|
27
27
|
if (r.number === t.number)
|
|
28
28
|
return;
|
|
29
29
|
if (r.number - t.number > 1 && y)
|
|
30
30
|
for (let c = (t == null ? void 0 : t.number) + 1n; c < r.number; c++) {
|
|
31
|
-
const
|
|
31
|
+
const s = await l(e, p, "getBlock")({
|
|
32
32
|
blockNumber: c,
|
|
33
33
|
includeTransactions: f
|
|
34
34
|
});
|
|
35
|
-
|
|
35
|
+
n.onBlock(s, t), t = s;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
// If no previous block exists, emit.
|
|
39
|
-
((t
|
|
40
|
-
b === "pending" && (r
|
|
39
|
+
(!(t != null && t.number) || // If the block tag is "pending" with no block number, emit.
|
|
40
|
+
b === "pending" && !(r != null && r.number) || // If the next block number is greater than the previous block number, emit.
|
|
41
41
|
// We don't want to emit blocks in the past.
|
|
42
|
-
r.number
|
|
42
|
+
r.number && r.number > t.number) && (n.onBlock(r, t), t = r);
|
|
43
43
|
} catch (r) {
|
|
44
|
-
(o =
|
|
44
|
+
(o = n.onError) == null || o.call(n, r);
|
|
45
45
|
}
|
|
46
46
|
}, {
|
|
47
47
|
emitOnBegin: m,
|
|
48
48
|
interval: w
|
|
49
49
|
}));
|
|
50
50
|
})() : (() => {
|
|
51
|
-
let
|
|
51
|
+
let u = !0, n = !0, o = () => u = !1;
|
|
52
52
|
return (async () => {
|
|
53
53
|
try {
|
|
54
|
-
m &&
|
|
54
|
+
m && l(e, p, "getBlock")({
|
|
55
55
|
blockTag: b,
|
|
56
56
|
includeTransactions: f
|
|
57
|
-
}).then((
|
|
58
|
-
|
|
57
|
+
}).then((s) => {
|
|
58
|
+
u && n && (k(s, void 0), n = !1);
|
|
59
59
|
});
|
|
60
60
|
const r = (() => {
|
|
61
61
|
if (e.transport.type === "fallback") {
|
|
62
|
-
const
|
|
63
|
-
return
|
|
62
|
+
const s = e.transport.transports.find((i) => i.config.type === "webSocket");
|
|
63
|
+
return s ? s.value : e.transport;
|
|
64
64
|
}
|
|
65
65
|
return e.transport;
|
|
66
66
|
})(), { unsubscribe: c } = await r.subscribe({
|
|
67
67
|
params: ["newHeads"],
|
|
68
|
-
async onData(
|
|
69
|
-
if (!
|
|
68
|
+
async onData(s) {
|
|
69
|
+
if (!u)
|
|
70
70
|
return;
|
|
71
|
-
const
|
|
72
|
-
blockNumber:
|
|
71
|
+
const i = await l(e, p, "getBlock")({
|
|
72
|
+
blockNumber: s.blockNumber,
|
|
73
73
|
includeTransactions: f
|
|
74
74
|
}).catch(() => {
|
|
75
75
|
});
|
|
76
|
-
|
|
76
|
+
u && (k(i, t), n = !1, t = i);
|
|
77
77
|
},
|
|
78
|
-
onError(
|
|
79
|
-
|
|
78
|
+
onError(s) {
|
|
79
|
+
a == null || a(s);
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
|
-
o = c,
|
|
82
|
+
o = c, u || o();
|
|
83
83
|
} catch (r) {
|
|
84
|
-
|
|
84
|
+
a == null || a(r);
|
|
85
85
|
}
|
|
86
86
|
})(), () => o();
|
|
87
87
|
})();
|
package/dist/index95.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index223.cjs"),f=require("./index274.cjs"),h=require("./index275.cjs"),M=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index223.cjs"),f=require("./index274.cjs"),h=require("./index275.cjs"),M=require("./index250.cjs");async function S(a,r){const{address:i,domain:t,message:s,nonce:n,scheme:d,signature:c,time:o=new Date,...g}=r,e=f.parseSiweMessage(s);if(!e.address||!h.validateSiweMessage({address:i,domain:t,message:e,nonce:n,scheme:d,time:o}))return!1;const u=l.hashMessage(s);return M.verifyHash(a,{address:e.address,hash:u,signature:c,...g})}exports.verifySiweMessage=S;
|
package/dist/index95.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { hashMessage as g } from "./index223.js";
|
|
2
2
|
import { parseSiweMessage as l } from "./index274.js";
|
|
3
3
|
import { validateSiweMessage as p } from "./index275.js";
|
|
4
|
-
import { verifyHash as h } from "./
|
|
4
|
+
import { verifyHash as h } from "./index250.js";
|
|
5
5
|
async function S(a, r) {
|
|
6
6
|
const { address: i, domain: t, message: s, nonce: o, scheme: n, signature: d, time: m = /* @__PURE__ */ new Date(), ...f } = r, e = l(s);
|
|
7
7
|
if (!e.address || !p({
|
package/dist/index98.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index71.cjs"),t=require("./index99.cjs"),a=require("./index100.cjs"),i=require("./index101.cjs"),n=require("./index43.cjs"),o=require("./index102.cjs"),u=require("./index103.cjs"),d=require("./index104.cjs"),g=require("./index96.cjs"),q=require("./index105.cjs"),c=require("./index106.cjs"),C=require("./index107.cjs"),h=require("./index97.cjs"),p=require("./index108.cjs"),w=require("./index109.cjs"),A=require("./index110.cjs"),T=require("./index111.cjs"),l=require("./index112.cjs"),S=require("./index113.cjs"),y=require("./index114.cjs"),m=require("./index37.cjs"),P=require("./index115.cjs"),z=require("./index36.cjs");function R(e){return{addChain:s=>t.addChain(e,s),deployContract:s=>a.deployContract(e,s),getAddresses:()=>i.getAddresses(e),getCallsStatus:s=>n.getCallsStatus(e,s),getCapabilities:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index71.cjs"),t=require("./index99.cjs"),a=require("./index100.cjs"),i=require("./index101.cjs"),n=require("./index43.cjs"),o=require("./index102.cjs"),u=require("./index103.cjs"),d=require("./index104.cjs"),g=require("./index96.cjs"),q=require("./index105.cjs"),c=require("./index106.cjs"),C=require("./index107.cjs"),h=require("./index97.cjs"),p=require("./index108.cjs"),w=require("./index109.cjs"),A=require("./index110.cjs"),T=require("./index111.cjs"),l=require("./index112.cjs"),S=require("./index113.cjs"),y=require("./index114.cjs"),m=require("./index37.cjs"),P=require("./index115.cjs"),z=require("./index36.cjs");function R(e){return{addChain:s=>t.addChain(e,s),deployContract:s=>a.deployContract(e,s),getAddresses:()=>i.getAddresses(e),getCallsStatus:s=>n.getCallsStatus(e,s),getCapabilities:()=>o.getCapabilities(e),getChainId:()=>r.getChainId(e),getPermissions:()=>u.getPermissions(e),prepareAuthorization:s=>d.prepareAuthorization(e,s),prepareTransactionRequest:s=>g.prepareTransactionRequest(e,s),requestAddresses:()=>q.requestAddresses(e),requestPermissions:s=>c.requestPermissions(e,s),sendCalls:s=>C.sendCalls(e,s),sendRawTransaction:s=>h.sendRawTransaction(e,s),sendTransaction:s=>p.sendTransaction(e,s),showCallsStatus:s=>w.showCallsStatus(e,s),signAuthorization:s=>A.signAuthorization(e,s),signMessage:s=>T.signMessage(e,s),signTransaction:s=>l.signTransaction(e,s),signTypedData:s=>S.signTypedData(e,s),switchChain:s=>y.switchChain(e,s),waitForCallsStatus:s=>m.waitForCallsStatus(e,s),watchAsset:s=>P.watchAsset(e,s),writeContract:s=>z.writeContract(e,s)}}exports.walletActions=R;
|
package/dist/index98.js
CHANGED
|
@@ -27,7 +27,7 @@ function X(s) {
|
|
|
27
27
|
deployContract: (r) => a(s, r),
|
|
28
28
|
getAddresses: () => i(s),
|
|
29
29
|
getCallsStatus: (r) => m(s, r),
|
|
30
|
-
getCapabilities: (
|
|
30
|
+
getCapabilities: () => e(s),
|
|
31
31
|
getChainId: () => o(s),
|
|
32
32
|
getPermissions: () => p(s),
|
|
33
33
|
prepareAuthorization: (r) => n(s, r),
|
package/dist/src/lib/utils.d.ts
CHANGED
|
@@ -9,8 +9,7 @@ export declare const sleep: (ms: number) => Promise<unknown>;
|
|
|
9
9
|
export declare const parseJwt: <T>(token: string) => T | undefined;
|
|
10
10
|
export declare enum Network {
|
|
11
11
|
MAINNET = "mainnet",
|
|
12
|
-
TESTNET = "testnet"
|
|
13
|
-
LOCALNET = "localnet"
|
|
12
|
+
TESTNET = "testnet"
|
|
14
13
|
}
|
|
15
14
|
export declare enum Environment {
|
|
16
15
|
MAINNET = "mainnet",
|