@gardenfi/utils 2.1.3-beta.5 → 2.1.3-beta.7
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 +12 -8
- package/dist/index104.cjs +1 -1
- package/dist/index104.js +1 -1
- package/dist/index107.cjs +1 -1
- package/dist/index107.js +76 -35
- package/dist/index108.cjs +1 -1
- package/dist/index108.js +45 -43
- 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/index166.cjs +1 -1
- package/dist/index166.js +36 -34
- package/dist/index189.cjs +1 -1
- package/dist/index189.js +2 -2
- package/dist/index191.cjs +1 -1
- package/dist/index191.js +19 -15
- package/dist/index192.cjs +1 -1
- package/dist/index192.js +15 -18
- package/dist/index222.cjs +1 -1
- package/dist/index222.js +2 -2
- package/dist/index225.cjs +1 -1
- package/dist/index225.js +43 -43
- package/dist/index226.cjs +1 -1
- package/dist/index226.js +3 -113
- package/dist/index23.cjs +1 -1
- package/dist/index23.js +13 -31
- package/dist/index231.cjs +1 -1
- package/dist/index231.js +1 -1
- package/dist/index232.cjs +1 -1
- package/dist/index232.js +1 -1
- package/dist/index233.cjs +1 -1
- package/dist/index233.js +31 -2
- package/dist/index234.cjs +1 -1
- package/dist/index234.js +2 -14
- package/dist/index235.cjs +1 -1
- package/dist/index235.js +13 -12
- package/dist/index236.cjs +1 -1
- package/dist/index236.js +10 -45
- package/dist/index237.cjs +1 -1
- package/dist/index237.js +46 -10
- package/dist/index238.cjs +1 -1
- package/dist/index238.js +11 -7
- package/dist/index239.cjs +1 -1
- package/dist/index239.js +7 -9
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +58 -32
- package/dist/index240.cjs +1 -1
- package/dist/index240.js +8 -12
- package/dist/index241.cjs +1 -1
- package/dist/index241.js +13 -14
- package/dist/index242.cjs +1 -1
- package/dist/index242.js +14 -9
- package/dist/index243.cjs +1 -1
- package/dist/index243.js +7 -28
- package/dist/index245.cjs +1 -1
- package/dist/index245.js +3 -3
- package/dist/index246.cjs +1 -1
- package/dist/index246.js +3 -3
- package/dist/index247.cjs +1 -2
- package/dist/index247.js +13 -24
- package/dist/index248.cjs +1 -1
- package/dist/index248.js +15 -13
- package/dist/index249.cjs +2 -1
- package/dist/index249.js +23 -14
- package/dist/index25.cjs +16 -1
- package/dist/index25.js +113 -11
- package/dist/index26.cjs +1 -1
- package/dist/index26.js +32 -58
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +31 -13
- package/dist/index275.cjs +1 -1
- package/dist/index275.js +7 -6
- package/dist/index277.cjs +1 -1
- package/dist/index277.js +103 -16
- package/dist/index278.cjs +1 -1
- package/dist/index278.js +13 -220
- package/dist/index279.cjs +1 -1
- package/dist/index279.js +214 -6
- package/dist/index28.cjs +1 -16
- package/dist/index28.js +11 -113
- package/dist/index280.cjs +1 -1
- package/dist/index280.js +7 -7
- package/dist/index281.cjs +1 -1
- package/dist/index281.js +7 -27
- package/dist/index282.cjs +1 -1
- package/dist/index282.js +26 -34
- package/dist/index283.cjs +1 -1
- package/dist/index283.js +13 -12
- package/dist/index284.cjs +1 -1
- package/dist/index284.js +89 -51
- package/dist/index285.cjs +1 -1
- package/dist/index285.js +3 -67
- package/dist/index286.cjs +1 -1
- package/dist/index286.js +140 -3
- package/dist/index287.cjs +1 -1
- package/dist/index287.js +143 -128
- package/dist/index288.cjs +1 -1
- package/dist/index288.js +9 -155
- package/dist/index289.cjs +1 -1
- package/dist/index289.js +111 -7
- package/dist/index290.cjs +2 -1
- package/dist/index290.js +116 -95
- package/dist/index291.cjs +1 -2
- package/dist/index291.js +8 -131
- package/dist/index292.cjs +1 -1
- package/dist/index292.js +18 -27
- package/dist/index293.cjs +1 -1
- package/dist/index293.js +39 -35
- package/dist/index294.cjs +1 -1
- package/dist/index294.js +77 -10
- package/dist/index295.cjs +1 -1
- package/dist/index295.js +2 -20
- package/dist/index297.cjs +1 -1
- package/dist/index297.js +658 -2
- package/dist/index298.cjs +1 -1
- package/dist/index298.js +203 -37
- package/dist/index299.cjs +1 -1
- package/dist/index299.js +155 -620
- 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 +2 -1
- package/dist/index300.js +63 -203
- package/dist/index301.cjs +1 -1
- package/dist/index301.js +4 -172
- package/dist/index302.cjs +1 -2
- package/dist/index302.js +39 -65
- package/dist/index303.cjs +1 -1
- package/dist/index303.js +7 -4
- package/dist/index304.cjs +1 -1
- package/dist/index304.js +60 -38
- package/dist/index305.cjs +1 -1
- package/dist/index305.js +77 -7
- package/dist/index306.cjs +1 -1
- package/dist/index306.js +4 -63
- package/dist/index307.cjs +1 -1
- package/dist/index307.js +181 -64
- package/dist/index308.cjs +1 -1
- package/dist/index308.js +64 -4
- package/dist/index309.cjs +1 -1
- package/dist/index309.js +44 -194
- package/dist/index310.cjs +1 -1
- package/dist/index310.js +4 -18
- package/dist/index311.cjs +1 -1
- package/dist/index311.js +5 -64
- package/dist/index312.cjs +1 -1
- package/dist/index312.js +2 -45
- package/dist/index313.cjs +1 -1
- package/dist/index313.js +21 -4
- package/dist/index36.cjs +1 -1
- package/dist/index36.js +1 -1
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +0 -4
- package/dist/index43.cjs +1 -1
- package/dist/index43.js +40 -21
- package/dist/index44.cjs +1 -1
- package/dist/index44.js +24 -24
- package/dist/index58.cjs +1 -1
- package/dist/index58.js +111 -107
- 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 +8 -3
- package/dist/index84.cjs +1 -1
- package/dist/index84.js +53 -51
- package/dist/index85.cjs +1 -1
- package/dist/index85.js +18 -18
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +4 -4
- package/dist/index90.cjs +1 -1
- package/dist/index90.js +44 -42
- package/dist/index92.cjs +1 -1
- package/dist/index92.js +39 -39
- package/dist/index98.cjs +1 -1
- package/dist/index98.js +1 -1
- package/dist/src/lib/utils.d.ts +2 -1
- package/package.json +1 -1
- package/dist/index314.cjs +0 -1
- package/dist/index314.js +0 -107
- package/dist/index315.cjs +0 -1
- package/dist/index315.js +0 -7
- package/dist/index316.cjs +0 -1
- package/dist/index316.js +0 -4
- package/dist/index317.cjs +0 -1
- package/dist/index317.js +0 -24
package/dist/index73.js
CHANGED
package/dist/index74.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index150.cjs"),a=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index150.cjs"),a=require("./index243.cjs");async function y(r,{blockCount:i,blockNumber:e,blockTag:n="latest",rewardPercentiles:s}){const t=typeof e=="bigint"?o.numberToHex(e):void 0,u=await r.request({method:"eth_feeHistory",params:[o.numberToHex(i),t||n,s]},{dedupe:!!t});return a.formatFeeHistory(u)}exports.getFeeHistory=y;
|
package/dist/index74.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { numberToHex as o } from "./index150.js";
|
|
2
|
-
import { formatFeeHistory as
|
|
3
|
-
async function
|
|
4
|
-
const t = e ? o(e) : void 0, a = await r.request({
|
|
2
|
+
import { formatFeeHistory as f } from "./index243.js";
|
|
3
|
+
async function u(r, { blockCount: i, blockNumber: e, blockTag: n = "latest", rewardPercentiles: s }) {
|
|
4
|
+
const t = typeof e == "bigint" ? o(e) : void 0, a = await r.request({
|
|
5
5
|
method: "eth_feeHistory",
|
|
6
6
|
params: [
|
|
7
|
-
o(
|
|
8
|
-
t ||
|
|
9
|
-
|
|
7
|
+
o(i),
|
|
8
|
+
t || n,
|
|
9
|
+
s
|
|
10
10
|
]
|
|
11
11
|
}, { dedupe: !!t });
|
|
12
|
-
return
|
|
12
|
+
return f(a);
|
|
13
13
|
}
|
|
14
14
|
export {
|
|
15
|
-
|
|
15
|
+
u as getFeeHistory
|
|
16
16
|
};
|
package/dist/index79.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index150.cjs"),u=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index150.cjs"),u=require("./index248.cjs");async function i(o,{address:t,blockNumber:e,blockTag:r,storageKeys:n}){const a=r??"latest",c=e!==void 0?s.numberToHex(e):void 0,f=await o.request({method:"eth_getProof",params:[t,n,c||a]});return u.formatProof(f)}exports.getProof=i;
|
package/dist/index79.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { numberToHex as c } from "./index150.js";
|
|
2
|
-
import { formatProof as s } from "./
|
|
2
|
+
import { formatProof as s } from "./index248.js";
|
|
3
3
|
async function d(t, { address: e, blockNumber: o, blockTag: r, storageKeys: n }) {
|
|
4
4
|
const f = r ?? "latest", a = o !== void 0 ? c(o) : void 0, m = await t.request({
|
|
5
5
|
method: "eth_getProof",
|
package/dist/index83.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index182.cjs"),u=require("./index150.cjs");async function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index182.cjs"),u=require("./index150.cjs");async function i(e,{address:n,blockTag:o="latest",blockNumber:t}){const r=await e.request({method:"eth_getTransactionCount",params:[n,typeof t=="bigint"?u.numberToHex(t):o]},{dedupe:!!t});return a.hexToNumber(r)}exports.getTransactionCount=i;
|
package/dist/index83.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { hexToNumber as r } from "./index182.js";
|
|
2
|
-
import { numberToHex as
|
|
2
|
+
import { numberToHex as i } from "./index150.js";
|
|
3
3
|
async function m(o, { address: e, blockTag: n = "latest", blockNumber: t }) {
|
|
4
4
|
const a = await o.request({
|
|
5
5
|
method: "eth_getTransactionCount",
|
|
6
|
-
params: [
|
|
7
|
-
|
|
6
|
+
params: [
|
|
7
|
+
e,
|
|
8
|
+
typeof t == "bigint" ? i(t) : n
|
|
9
|
+
]
|
|
10
|
+
}, {
|
|
11
|
+
dedupe: !!t
|
|
12
|
+
});
|
|
8
13
|
return r(a);
|
|
9
14
|
}
|
|
10
15
|
export {
|
package/dist/index84.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 P=require("./index21.cjs"),v=require("./index122.cjs"),_=require("./index38.cjs"),x=require("./index127.cjs"),O=require("./index170.cjs"),T=require("./index177.cjs"),B=require("./index214.cjs"),j=require("./index221.cjs"),M=require("./index29.cjs"),Z=require("./index33.cjs");async function $(l,m){var D;const{account:w,allowFailure:u=!0,batchSize:k,blockNumber:C,blockTag:p,multicallAddress:z,stateOverride:R}=m,d=m.contracts,q=k??(typeof((D=l.batch)==null?void 0:D.multicall)=="object"&&l.batch.multicall.batchSize||1024);let g=z;if(!g){if(!l.chain)throw new Error("client chain not configured. multicallAddress is required.");g=B.getChainContractAddress({blockNumber:C,chain:l.chain,contract:"multicall3"})}const r=[[]];let a=0,f=0;for(let t=0;t<d.length;t++){const{abi:c,address:s,args:e,functionName:i}=d[t];try{const n=T.encodeFunctionData({abi:c,args:e,functionName:i});f+=(n.length-2)/2,q>0&&f>q&&r[a].length>0&&(a++,f=(n.length-2)/2,r[a]=[]),r[a]=[...r[a],{allowFailure:!0,callData:n,target:s}]}catch(n){const b=j.getContractError(n,{abi:c,address:s,args:e,docsPath:"/docs/contract/multicall",functionName:i,sender:w});if(!u)throw b;r[a]=[...r[a],{allowFailure:!0,callData:"0x",target:s}]}}const A=await Promise.allSettled(r.map(t=>M.getAction(l,Z.readContract,"readContract")({abi:P.multicall3Abi,account:w,address:g,args:[t],blockNumber:C,blockTag:p,functionName:"aggregate3",stateOverride:R}))),o=[];for(let t=0;t<A.length;t++){const c=A[t];if(c.status==="rejected"){if(!u)throw c.reason;for(let e=0;e<r[t].length;e++)o.push({status:"failure",error:c.reason,result:void 0});continue}const s=c.value;for(let e=0;e<s.length;e++){const{returnData:i,success:n}=s[e],{callData:b}=r[t][e],{abi:S,address:N,functionName:E,args:F}=d[o.length];try{if(b==="0x")throw new v.AbiDecodingZeroDataError;if(!n)throw new x.RawContractError({data:i});const h=O.decodeFunctionResult({abi:S,args:F,data:i,functionName:E});o.push(u?{result:h,status:"success"}:h)}catch(h){const y=j.getContractError(h,{abi:S,address:N,args:F,docsPath:"/docs/contract/multicall",functionName:E});if(!u)throw y;o.push({error:y,result:void 0,status:"failure"})}}}if(o.length!==d.length)throw new _.BaseError("multicall results mismatch");return o}exports.multicall=$;
|
package/dist/index84.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { multicall3Abi as
|
|
2
|
-
import { AbiDecodingZeroDataError as
|
|
3
|
-
import { BaseError as
|
|
4
|
-
import { RawContractError as
|
|
5
|
-
import { decodeFunctionResult as
|
|
6
|
-
import { encodeFunctionData as
|
|
7
|
-
import { getChainContractAddress as
|
|
8
|
-
import { getContractError as
|
|
9
|
-
import { getAction as
|
|
10
|
-
import { readContract as
|
|
11
|
-
async function
|
|
12
|
-
var
|
|
13
|
-
const { allowFailure: u = !0, batchSize:
|
|
14
|
-
let
|
|
15
|
-
if (!
|
|
1
|
+
import { multicall3Abi as P } from "./index21.js";
|
|
2
|
+
import { AbiDecodingZeroDataError as _ } from "./index122.js";
|
|
3
|
+
import { BaseError as v } from "./index38.js";
|
|
4
|
+
import { RawContractError as q } from "./index127.js";
|
|
5
|
+
import { decodeFunctionResult as B } from "./index170.js";
|
|
6
|
+
import { encodeFunctionData as O } from "./index177.js";
|
|
7
|
+
import { getChainContractAddress as T } from "./index214.js";
|
|
8
|
+
import { getContractError as F } from "./index221.js";
|
|
9
|
+
import { getAction as Z } from "./index29.js";
|
|
10
|
+
import { readContract as G } from "./index33.js";
|
|
11
|
+
async function X(n, w) {
|
|
12
|
+
var D;
|
|
13
|
+
const { account: b, allowFailure: u = !0, batchSize: j, blockNumber: p, blockTag: y, multicallAddress: N, stateOverride: R } = w, d = w.contracts, C = j ?? (typeof ((D = n.batch) == null ? void 0 : D.multicall) == "object" && n.batch.multicall.batchSize || 1024);
|
|
14
|
+
let m = N;
|
|
15
|
+
if (!m) {
|
|
16
16
|
if (!n.chain)
|
|
17
17
|
throw new Error("client chain not configured. multicallAddress is required.");
|
|
18
|
-
|
|
19
|
-
blockNumber:
|
|
18
|
+
m = T({
|
|
19
|
+
blockNumber: p,
|
|
20
20
|
chain: n.chain,
|
|
21
21
|
contract: "multicall3"
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
const e = [[]];
|
|
25
25
|
let a = 0, f = 0;
|
|
26
|
-
for (let t = 0; t <
|
|
27
|
-
const { abi: o, address: s, args: r, functionName: i } =
|
|
26
|
+
for (let t = 0; t < d.length; t++) {
|
|
27
|
+
const { abi: o, address: s, args: r, functionName: i } = d[t];
|
|
28
28
|
try {
|
|
29
|
-
const c =
|
|
29
|
+
const c = O({ abi: o, args: r, functionName: i });
|
|
30
30
|
f += (c.length - 2) / 2, // Check if batching is enabled.
|
|
31
|
-
|
|
32
|
-
f >
|
|
31
|
+
C > 0 && // Check if the current size of the batch exceeds the size limit.
|
|
32
|
+
f > C && // Check if the current chunk is not already empty.
|
|
33
33
|
e[a].length > 0 && (a++, f = (c.length - 2) / 2, e[a] = []), e[a] = [
|
|
34
34
|
...e[a],
|
|
35
35
|
{
|
|
@@ -39,12 +39,13 @@ async function W(n, w) {
|
|
|
39
39
|
}
|
|
40
40
|
];
|
|
41
41
|
} catch (c) {
|
|
42
|
-
const g =
|
|
42
|
+
const g = F(c, {
|
|
43
43
|
abi: o,
|
|
44
44
|
address: s,
|
|
45
45
|
args: r,
|
|
46
46
|
docsPath: "/docs/contract/multicall",
|
|
47
|
-
functionName: i
|
|
47
|
+
functionName: i,
|
|
48
|
+
sender: b
|
|
48
49
|
});
|
|
49
50
|
if (!u)
|
|
50
51
|
throw g;
|
|
@@ -58,17 +59,18 @@ async function W(n, w) {
|
|
|
58
59
|
];
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
|
-
const
|
|
62
|
-
abi:
|
|
63
|
-
|
|
62
|
+
const A = await Promise.allSettled(e.map((t) => Z(n, G, "readContract")({
|
|
63
|
+
abi: P,
|
|
64
|
+
account: b,
|
|
65
|
+
address: m,
|
|
64
66
|
args: [t],
|
|
65
|
-
blockNumber:
|
|
66
|
-
blockTag:
|
|
67
|
+
blockNumber: p,
|
|
68
|
+
blockTag: y,
|
|
67
69
|
functionName: "aggregate3",
|
|
68
|
-
stateOverride:
|
|
70
|
+
stateOverride: R
|
|
69
71
|
}))), l = [];
|
|
70
|
-
for (let t = 0; t <
|
|
71
|
-
const o =
|
|
72
|
+
for (let t = 0; t < A.length; t++) {
|
|
73
|
+
const o = A[t];
|
|
72
74
|
if (o.status === "rejected") {
|
|
73
75
|
if (!u)
|
|
74
76
|
throw o.reason;
|
|
@@ -82,37 +84,37 @@ async function W(n, w) {
|
|
|
82
84
|
}
|
|
83
85
|
const s = o.value;
|
|
84
86
|
for (let r = 0; r < s.length; r++) {
|
|
85
|
-
const { returnData: i, success: c } = s[r], { callData: g } = e[t][r], { abi:
|
|
87
|
+
const { returnData: i, success: c } = s[r], { callData: g } = e[t][r], { abi: S, address: x, functionName: k, args: z } = d[l.length];
|
|
86
88
|
try {
|
|
87
89
|
if (g === "0x")
|
|
88
|
-
throw new
|
|
90
|
+
throw new _();
|
|
89
91
|
if (!c)
|
|
90
|
-
throw new
|
|
91
|
-
const
|
|
92
|
-
abi:
|
|
93
|
-
args:
|
|
92
|
+
throw new q({ data: i });
|
|
93
|
+
const h = B({
|
|
94
|
+
abi: S,
|
|
95
|
+
args: z,
|
|
94
96
|
data: i,
|
|
95
|
-
functionName:
|
|
97
|
+
functionName: k
|
|
96
98
|
});
|
|
97
|
-
l.push(u ? { result:
|
|
98
|
-
} catch (
|
|
99
|
-
const
|
|
100
|
-
abi:
|
|
101
|
-
address:
|
|
102
|
-
args:
|
|
99
|
+
l.push(u ? { result: h, status: "success" } : h);
|
|
100
|
+
} catch (h) {
|
|
101
|
+
const E = F(h, {
|
|
102
|
+
abi: S,
|
|
103
|
+
address: x,
|
|
104
|
+
args: z,
|
|
103
105
|
docsPath: "/docs/contract/multicall",
|
|
104
|
-
functionName:
|
|
106
|
+
functionName: k
|
|
105
107
|
});
|
|
106
108
|
if (!u)
|
|
107
|
-
throw
|
|
108
|
-
l.push({ error:
|
|
109
|
+
throw E;
|
|
110
|
+
l.push({ error: E, result: void 0, status: "failure" });
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
}
|
|
112
|
-
if (l.length !==
|
|
113
|
-
throw new
|
|
114
|
+
if (l.length !== d.length)
|
|
115
|
+
throw new v("multicall results mismatch");
|
|
114
116
|
return l;
|
|
115
117
|
}
|
|
116
118
|
export {
|
|
117
|
-
|
|
119
|
+
X as multicall
|
|
118
120
|
};
|
package/dist/index85.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 B=require("./index233.cjs"),D=require("./index45.cjs"),F=require("./index122.cjs"),C=require("./index127.cjs"),H=require("./index143.cjs"),S=require("./index170.cjs"),A=require("./index177.cjs"),U=require("./index150.cjs"),j=require("./index221.cjs"),z=require("./index244.cjs"),I=require("./index155.cjs"),L=require("./index157.cjs"),M=require("./index184.cjs"),P=require("./index237.cjs"),V=require("./index197.cjs");async function Z(v,O){const{blockNumber:m,blockTag:w="latest",blocks:q,returnFullTransactions:N,traceTransfers:R,validation:x}=O;try{const c=[];for(const t of q){const l=t.blockOverrides?B.toRpc(t.blockOverrides):void 0,e=t.calls.map(n=>{const r=n,o=r.account?D.parseAccount(r.account):void 0,u={...r,data:r.abi?A.encodeFunctionData(r):r.data,from:r.from??(o==null?void 0:o.address)};return V.assertRequest(u),M.formatTransactionRequest(u)}),f=t.stateOverrides?P.serializeStateOverride(t.stateOverrides):void 0;c.push({blockOverrides:l,calls:e,stateOverrides:f})}const a=(typeof m=="bigint"?U.numberToHex(m):void 0)||w;return(await v.request({method:"eth_simulateV1",params:[{blockStateCalls:c,returnFullTransactions:N,traceTransfers:R,validation:x},a]})).map((t,l)=>({...I.formatBlock(t),calls:t.calls.map((e,f)=>{var g,k;const{abi:n,args:r,functionName:o,to:u}=q[l].calls[f],b=((g=e.error)==null?void 0:g.data)??e.returnData,E=BigInt(e.gasUsed),h=(k=e.logs)==null?void 0:k.map(s=>L.formatLog(s)),i=e.status==="0x1"?"success":"failure",T=n&&i==="success"&&b!=="0x"?S.decodeFunctionResult({abi:n,data:b,functionName:o}):null,y=(()=>{var p;if(i==="success")return;let s;if(((p=e.error)==null?void 0:p.data)==="0x"?s=new F.AbiDecodingZeroDataError:e.error&&(s=new C.RawContractError(e.error)),!!s)return j.getContractError(s,{abi:n??[],address:u,args:r,functionName:o??"<unknown>"})})();return{data:b,gasUsed:E,logs:h,status:i,...i==="success"?{result:T}:{error:y}}})}))}catch(c){const d=c,a=z.getNodeError(d,{});throw a instanceof H.UnknownNodeError?d:a}}exports.simulateBlocks=Z;
|
package/dist/index85.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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 y } from "./index233.js";
|
|
2
|
+
import { parseAccount as B } from "./index45.js";
|
|
3
|
+
import { AbiDecodingZeroDataError as C } from "./index122.js";
|
|
4
|
+
import { RawContractError as F } from "./index127.js";
|
|
5
|
+
import { UnknownNodeError as H } from "./index143.js";
|
|
6
|
+
import { decodeFunctionResult as U } 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";
|
|
@@ -11,39 +11,39 @@ 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 "./index237.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 f = t.blockOverrides ? y(t.blockOverrides) : void 0, r = t.calls.map((n) => {
|
|
22
|
+
const o = n, e = o.account ? B(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
|
+
}), d = t.stateOverrides ? _(t.stateOverrides) : void 0;
|
|
29
29
|
a.push({
|
|
30
|
-
blockOverrides:
|
|
30
|
+
blockOverrides: f,
|
|
31
31
|
calls: r,
|
|
32
|
-
stateOverrides:
|
|
32
|
+
stateOverrides: d
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
const c = (p ? S(p) : void 0) || N;
|
|
35
|
+
const c = (typeof p == "bigint" ? 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, f) => ({
|
|
43
43
|
...L(t),
|
|
44
|
-
calls: t.calls.map((r,
|
|
44
|
+
calls: t.calls.map((r, d) => {
|
|
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[f].calls[d], 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" ? U({
|
|
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 C() : r.error && (s = new F(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 H ? u : c;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
export {
|
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/index90.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("./index126.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("./index126.cjs"),R=require("./index135.cjs"),g=require("./index29.cjs"),O=require("./index39.cjs"),S=require("./index41.cjs"),h=require("./index216.cjs"),$=require("./index42.cjs"),P=require("./index68.cjs"),W=require("./index81.cjs"),m=require("./index20.cjs"),x=require("./index91.cjs");async function z(n,{confirmations:c=1,hash:p,onReplaced:B,pollingInterval:F=n.pollingInterval,retryCount:N=6,retryDelay:v=({count:d})=>~~(1<<d)*200,timeout:y=18e4}){const d=$.stringify(["waitForTransactionReceipt",n.uid,p]);let a,o,e,i=!1,f,T;const{promise:A,resolve:j,reject:q}=S.withResolvers(),E=y?setTimeout(()=>{T(),f(),q(new R.WaitForTransactionReceiptTimeoutError({hash:p}))},y):void 0;return f=O.observe(d,{onReplaced:B,resolve:j,reject:q},r=>{T=g.getAction(n,x.watchBlockNumber,"watchBlockNumber")({emitMissed:!0,emitOnBegin:!0,poll:!0,pollingInterval:F,async onBlockNumber(_){const u=b=>{clearTimeout(E),T(),b(),f()};let l=_;if(!i)try{if(e){if(c>1&&(!e.blockNumber||l-e.blockNumber+1n<c))return;u(()=>r.resolve(e));return}if(a||(i=!0,await h.withRetry(async()=>{a=await g.getAction(n,W.getTransaction,"getTransaction")({hash:p}),a.blockNumber&&(l=a.blockNumber)},{delay:v,retryCount:N}),i=!1),e=await g.getAction(n,m.getTransactionReceipt,"getTransactionReceipt")({hash:p}),c>1&&(!e.blockNumber||l-e.blockNumber+1n<c))return;u(()=>r.resolve(e))}catch(b){if(b instanceof R.TransactionNotFoundError||b instanceof R.TransactionReceiptNotFoundError){if(!a){i=!1;return}try{o=a,i=!0;const k=await h.withRetry(()=>g.getAction(n,P.getBlock,"getBlock")({blockNumber:l,includeTransactions:!0}),{delay:v,retryCount:N,shouldRetry:({error:s})=>s instanceof M.BlockNotFoundError});i=!1;const t=k.transactions.find(({from:s,nonce:I})=>s===o.from&&I===o.nonce);if(!t||(e=await g.getAction(n,m.getTransactionReceipt,"getTransactionReceipt")({hash:t.hash}),c>1&&(!e.blockNumber||l-e.blockNumber+1n<c)))return;let w="replaced";t.to===o.to&&t.value===o.value&&t.input===o.input?w="repriced":t.from===t.to&&t.value===0n&&(w="cancelled"),u(()=>{var s;(s=r.onReplaced)==null||s.call(r,{reason:w,replacedTransaction:o,transaction:t,transactionReceipt:e}),r.resolve(e)})}catch(k){u(()=>r.reject(k))}}else u(()=>r.reject(b))}}})}),A}exports.waitForTransactionReceipt=z;
|
package/dist/index90.js
CHANGED
|
@@ -3,51 +3,54 @@ import { WaitForTransactionReceiptTimeoutError as M, TransactionNotFoundError as
|
|
|
3
3
|
import { getAction as f } from "./index29.js";
|
|
4
4
|
import { observe as q } from "./index39.js";
|
|
5
5
|
import { withResolvers as z } from "./index41.js";
|
|
6
|
-
import { withRetry as
|
|
6
|
+
import { withRetry as y } from "./index216.js";
|
|
7
7
|
import { stringify as G } from "./index42.js";
|
|
8
8
|
import { getBlock as H } from "./index68.js";
|
|
9
9
|
import { getTransaction as J } from "./index81.js";
|
|
10
|
-
import { getTransactionReceipt as
|
|
10
|
+
import { getTransactionReceipt as B } from "./index20.js";
|
|
11
11
|
import { watchBlockNumber as K } from "./index91.js";
|
|
12
12
|
async function D(o, {
|
|
13
13
|
confirmations: a = 1,
|
|
14
14
|
hash: m,
|
|
15
|
-
onReplaced:
|
|
16
|
-
pollingInterval:
|
|
17
|
-
retryCount:
|
|
18
|
-
retryDelay:
|
|
15
|
+
onReplaced: h,
|
|
16
|
+
pollingInterval: F = o.pollingInterval,
|
|
17
|
+
retryCount: w = 6,
|
|
18
|
+
retryDelay: g = ({ count: b }) => ~~(1 << b) * 200,
|
|
19
19
|
// exponential backoff
|
|
20
|
-
timeout:
|
|
20
|
+
timeout: v = 18e4
|
|
21
21
|
}) {
|
|
22
22
|
const b = G(["waitForTransactionReceipt", o.uid, m]);
|
|
23
|
-
let c, n,
|
|
24
|
-
const { promise:
|
|
25
|
-
|
|
23
|
+
let c, n, e, i = !1, d, T;
|
|
24
|
+
const { promise: E, resolve: _, reject: R } = z(), j = v ? setTimeout(() => {
|
|
25
|
+
T(), d(), R(new M({ hash: m }));
|
|
26
|
+
}, v) : void 0;
|
|
27
|
+
return d = q(b, { onReplaced: h, resolve: _, reject: R }, (t) => {
|
|
28
|
+
T = f(o, K, "watchBlockNumber")({
|
|
26
29
|
emitMissed: !0,
|
|
27
30
|
emitOnBegin: !0,
|
|
28
31
|
poll: !0,
|
|
29
|
-
pollingInterval:
|
|
32
|
+
pollingInterval: F,
|
|
30
33
|
async onBlockNumber(I) {
|
|
31
|
-
const
|
|
32
|
-
clearTimeout(
|
|
34
|
+
const s = (p) => {
|
|
35
|
+
clearTimeout(j), T(), p(), d();
|
|
33
36
|
};
|
|
34
37
|
let u = I;
|
|
35
38
|
if (!i)
|
|
36
39
|
try {
|
|
37
|
-
if (
|
|
38
|
-
if (a > 1 && (!
|
|
40
|
+
if (e) {
|
|
41
|
+
if (a > 1 && (!e.blockNumber || u - e.blockNumber + 1n < a))
|
|
39
42
|
return;
|
|
40
|
-
|
|
43
|
+
s(() => t.resolve(e));
|
|
41
44
|
return;
|
|
42
45
|
}
|
|
43
|
-
if (c || (i = !0, await
|
|
46
|
+
if (c || (i = !0, await y(async () => {
|
|
44
47
|
c = await f(o, J, "getTransaction")({ hash: m }), c.blockNumber && (u = c.blockNumber);
|
|
45
48
|
}, {
|
|
46
|
-
delay:
|
|
47
|
-
retryCount:
|
|
48
|
-
}), i = !1),
|
|
49
|
+
delay: g,
|
|
50
|
+
retryCount: w
|
|
51
|
+
}), i = !1), e = await f(o, B, "getTransactionReceipt")({ hash: m }), a > 1 && (!e.blockNumber || u - e.blockNumber + 1n < a))
|
|
49
52
|
return;
|
|
50
|
-
|
|
53
|
+
s(() => t.resolve(e));
|
|
51
54
|
} catch (p) {
|
|
52
55
|
if (p instanceof O || p instanceof W) {
|
|
53
56
|
if (!c) {
|
|
@@ -56,40 +59,39 @@ async function D(o, {
|
|
|
56
59
|
}
|
|
57
60
|
try {
|
|
58
61
|
n = c, i = !0;
|
|
59
|
-
const
|
|
62
|
+
const k = await y(() => f(o, H, "getBlock")({
|
|
60
63
|
blockNumber: u,
|
|
61
64
|
includeTransactions: !0
|
|
62
65
|
}), {
|
|
63
|
-
delay:
|
|
64
|
-
retryCount:
|
|
65
|
-
shouldRetry: ({ error:
|
|
66
|
+
delay: g,
|
|
67
|
+
retryCount: w,
|
|
68
|
+
shouldRetry: ({ error: l }) => l instanceof A
|
|
66
69
|
});
|
|
67
70
|
i = !1;
|
|
68
|
-
const
|
|
69
|
-
if (!
|
|
70
|
-
hash:
|
|
71
|
-
}), a > 1 && (!
|
|
71
|
+
const r = k.transactions.find(({ from: l, nonce: x }) => l === n.from && x === n.nonce);
|
|
72
|
+
if (!r || (e = await f(o, B, "getTransactionReceipt")({
|
|
73
|
+
hash: r.hash
|
|
74
|
+
}), a > 1 && (!e.blockNumber || u - e.blockNumber + 1n < a)))
|
|
72
75
|
return;
|
|
73
|
-
let
|
|
74
|
-
|
|
75
|
-
var
|
|
76
|
-
(
|
|
77
|
-
reason:
|
|
76
|
+
let N = "replaced";
|
|
77
|
+
r.to === n.to && r.value === n.value && r.input === n.input ? N = "repriced" : r.from === r.to && r.value === 0n && (N = "cancelled"), s(() => {
|
|
78
|
+
var l;
|
|
79
|
+
(l = t.onReplaced) == null || l.call(t, {
|
|
80
|
+
reason: N,
|
|
78
81
|
replacedTransaction: n,
|
|
79
|
-
transaction:
|
|
80
|
-
transactionReceipt:
|
|
81
|
-
}), t.resolve(
|
|
82
|
+
transaction: r,
|
|
83
|
+
transactionReceipt: e
|
|
84
|
+
}), t.resolve(e);
|
|
82
85
|
});
|
|
83
|
-
} catch (
|
|
84
|
-
|
|
86
|
+
} catch (k) {
|
|
87
|
+
s(() => t.reject(k));
|
|
85
88
|
}
|
|
86
89
|
} else
|
|
87
|
-
|
|
90
|
+
s(() => t.reject(p));
|
|
88
91
|
}
|
|
89
92
|
}
|
|
90
93
|
});
|
|
91
|
-
});
|
|
92
|
-
return h;
|
|
94
|
+
}), E;
|
|
93
95
|
}
|
|
94
96
|
export {
|
|
95
97
|
D as waitForTransactionReceipt
|
package/dist/index92.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index29.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index29.cjs"),B=require("./index39.cjs"),q=require("./index40.cjs"),A=require("./index42.cjs"),p=require("./index68.cjs");function S(r,{blockTag:b="latest",emitMissed:y=!1,emitOnBegin:g=!1,onBlock:k,onError:u,includeTransactions:m,poll:d,pollingInterval:w=r.pollingInterval}){const h=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 h?(()=>{const c=A.stringify(["watchBlocks",r.uid,b,y,g,o,w]);return B.observe(c,{onBlock:k,onError:u},s=>q.poll(async()=>{var a;try{const e=await i.getAction(r,p.getBlock,"getBlock")({blockTag:b,includeTransactions:o});if(e.number!==null&&(t==null?void 0:t.number)!=null){if(e.number===t.number)return;if(e.number-t.number>1&&y)for(let l=(t==null?void 0:t.number)+1n;l<e.number;l++){const n=await i.getAction(r,p.getBlock,"getBlock")({blockNumber:l,includeTransactions:o});s.onBlock(n,t),t=n}}((t==null?void 0:t.number)==null||b==="pending"&&(e==null?void 0:e.number)==null||e.number!==null&&e.number>t.number)&&(s.onBlock(e,t),t=e)}catch(e){(a=s.onError)==null||a.call(s,e)}},{emitOnBegin:g,interval:w}))})():(()=>{let c=!0,s=!0,a=()=>c=!1;return(async()=>{try{g&&i.getAction(r,p.getBlock,"getBlock")({blockTag:b,includeTransactions:o}).then(n=>{c&&s&&(k(n,void 0),s=!1)}).catch(u);const e=(()=>{if(r.transport.type==="fallback"){const n=r.transport.transports.find(f=>f.config.type==="webSocket");return n?n.value:r.transport}return r.transport})(),{unsubscribe:l}=await e.subscribe({params:["newHeads"],async onData(n){if(!c)return;const f=await i.getAction(r,p.getBlock,"getBlock")({blockNumber:n.blockNumber,includeTransactions:o}).catch(()=>{});c&&(k(f,t),s=!1,t=f)},onError(n){u==null||u(n)}});a=l,c||a()}catch(e){u==null||u(e)}})(),()=>a()})()}exports.watchBlocks=S;
|