@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.
Files changed (212) hide show
  1. package/dist/index102.cjs +1 -1
  2. package/dist/index102.js +12 -8
  3. package/dist/index104.cjs +1 -1
  4. package/dist/index104.js +1 -1
  5. package/dist/index107.cjs +1 -1
  6. package/dist/index107.js +76 -35
  7. package/dist/index108.cjs +1 -1
  8. package/dist/index108.js +45 -43
  9. package/dist/index110.cjs +1 -1
  10. package/dist/index110.js +1 -1
  11. package/dist/index111.cjs +1 -1
  12. package/dist/index111.js +1 -1
  13. package/dist/index112.cjs +1 -1
  14. package/dist/index112.js +1 -1
  15. package/dist/index113.cjs +1 -1
  16. package/dist/index113.js +1 -1
  17. package/dist/index125.cjs +1 -1
  18. package/dist/index125.js +1 -1
  19. package/dist/index15.cjs +1 -1
  20. package/dist/index15.js +4 -4
  21. package/dist/index166.cjs +1 -1
  22. package/dist/index166.js +36 -34
  23. package/dist/index189.cjs +1 -1
  24. package/dist/index189.js +2 -2
  25. package/dist/index191.cjs +1 -1
  26. package/dist/index191.js +19 -15
  27. package/dist/index192.cjs +1 -1
  28. package/dist/index192.js +15 -18
  29. package/dist/index222.cjs +1 -1
  30. package/dist/index222.js +2 -2
  31. package/dist/index225.cjs +1 -1
  32. package/dist/index225.js +43 -43
  33. package/dist/index226.cjs +1 -1
  34. package/dist/index226.js +3 -113
  35. package/dist/index23.cjs +1 -1
  36. package/dist/index23.js +13 -31
  37. package/dist/index231.cjs +1 -1
  38. package/dist/index231.js +1 -1
  39. package/dist/index232.cjs +1 -1
  40. package/dist/index232.js +1 -1
  41. package/dist/index233.cjs +1 -1
  42. package/dist/index233.js +31 -2
  43. package/dist/index234.cjs +1 -1
  44. package/dist/index234.js +2 -14
  45. package/dist/index235.cjs +1 -1
  46. package/dist/index235.js +13 -12
  47. package/dist/index236.cjs +1 -1
  48. package/dist/index236.js +10 -45
  49. package/dist/index237.cjs +1 -1
  50. package/dist/index237.js +46 -10
  51. package/dist/index238.cjs +1 -1
  52. package/dist/index238.js +11 -7
  53. package/dist/index239.cjs +1 -1
  54. package/dist/index239.js +7 -9
  55. package/dist/index24.cjs +1 -1
  56. package/dist/index24.js +58 -32
  57. package/dist/index240.cjs +1 -1
  58. package/dist/index240.js +8 -12
  59. package/dist/index241.cjs +1 -1
  60. package/dist/index241.js +13 -14
  61. package/dist/index242.cjs +1 -1
  62. package/dist/index242.js +14 -9
  63. package/dist/index243.cjs +1 -1
  64. package/dist/index243.js +7 -28
  65. package/dist/index245.cjs +1 -1
  66. package/dist/index245.js +3 -3
  67. package/dist/index246.cjs +1 -1
  68. package/dist/index246.js +3 -3
  69. package/dist/index247.cjs +1 -2
  70. package/dist/index247.js +13 -24
  71. package/dist/index248.cjs +1 -1
  72. package/dist/index248.js +15 -13
  73. package/dist/index249.cjs +2 -1
  74. package/dist/index249.js +23 -14
  75. package/dist/index25.cjs +16 -1
  76. package/dist/index25.js +113 -11
  77. package/dist/index26.cjs +1 -1
  78. package/dist/index26.js +32 -58
  79. package/dist/index27.cjs +1 -1
  80. package/dist/index27.js +31 -13
  81. package/dist/index275.cjs +1 -1
  82. package/dist/index275.js +7 -6
  83. package/dist/index277.cjs +1 -1
  84. package/dist/index277.js +103 -16
  85. package/dist/index278.cjs +1 -1
  86. package/dist/index278.js +13 -220
  87. package/dist/index279.cjs +1 -1
  88. package/dist/index279.js +214 -6
  89. package/dist/index28.cjs +1 -16
  90. package/dist/index28.js +11 -113
  91. package/dist/index280.cjs +1 -1
  92. package/dist/index280.js +7 -7
  93. package/dist/index281.cjs +1 -1
  94. package/dist/index281.js +7 -27
  95. package/dist/index282.cjs +1 -1
  96. package/dist/index282.js +26 -34
  97. package/dist/index283.cjs +1 -1
  98. package/dist/index283.js +13 -12
  99. package/dist/index284.cjs +1 -1
  100. package/dist/index284.js +89 -51
  101. package/dist/index285.cjs +1 -1
  102. package/dist/index285.js +3 -67
  103. package/dist/index286.cjs +1 -1
  104. package/dist/index286.js +140 -3
  105. package/dist/index287.cjs +1 -1
  106. package/dist/index287.js +143 -128
  107. package/dist/index288.cjs +1 -1
  108. package/dist/index288.js +9 -155
  109. package/dist/index289.cjs +1 -1
  110. package/dist/index289.js +111 -7
  111. package/dist/index290.cjs +2 -1
  112. package/dist/index290.js +116 -95
  113. package/dist/index291.cjs +1 -2
  114. package/dist/index291.js +8 -131
  115. package/dist/index292.cjs +1 -1
  116. package/dist/index292.js +18 -27
  117. package/dist/index293.cjs +1 -1
  118. package/dist/index293.js +39 -35
  119. package/dist/index294.cjs +1 -1
  120. package/dist/index294.js +77 -10
  121. package/dist/index295.cjs +1 -1
  122. package/dist/index295.js +2 -20
  123. package/dist/index297.cjs +1 -1
  124. package/dist/index297.js +658 -2
  125. package/dist/index298.cjs +1 -1
  126. package/dist/index298.js +203 -37
  127. package/dist/index299.cjs +1 -1
  128. package/dist/index299.js +155 -620
  129. package/dist/index3.cjs +1 -1
  130. package/dist/index3.js +1 -1
  131. package/dist/index30.cjs +1 -1
  132. package/dist/index30.js +1 -1
  133. package/dist/index300.cjs +2 -1
  134. package/dist/index300.js +63 -203
  135. package/dist/index301.cjs +1 -1
  136. package/dist/index301.js +4 -172
  137. package/dist/index302.cjs +1 -2
  138. package/dist/index302.js +39 -65
  139. package/dist/index303.cjs +1 -1
  140. package/dist/index303.js +7 -4
  141. package/dist/index304.cjs +1 -1
  142. package/dist/index304.js +60 -38
  143. package/dist/index305.cjs +1 -1
  144. package/dist/index305.js +77 -7
  145. package/dist/index306.cjs +1 -1
  146. package/dist/index306.js +4 -63
  147. package/dist/index307.cjs +1 -1
  148. package/dist/index307.js +181 -64
  149. package/dist/index308.cjs +1 -1
  150. package/dist/index308.js +64 -4
  151. package/dist/index309.cjs +1 -1
  152. package/dist/index309.js +44 -194
  153. package/dist/index310.cjs +1 -1
  154. package/dist/index310.js +4 -18
  155. package/dist/index311.cjs +1 -1
  156. package/dist/index311.js +5 -64
  157. package/dist/index312.cjs +1 -1
  158. package/dist/index312.js +2 -45
  159. package/dist/index313.cjs +1 -1
  160. package/dist/index313.js +21 -4
  161. package/dist/index36.cjs +1 -1
  162. package/dist/index36.js +1 -1
  163. package/dist/index4.cjs +1 -1
  164. package/dist/index4.js +0 -4
  165. package/dist/index43.cjs +1 -1
  166. package/dist/index43.js +40 -21
  167. package/dist/index44.cjs +1 -1
  168. package/dist/index44.js +24 -24
  169. package/dist/index58.cjs +1 -1
  170. package/dist/index58.js +111 -107
  171. package/dist/index59.cjs +1 -1
  172. package/dist/index59.js +11 -11
  173. package/dist/index60.cjs +1 -1
  174. package/dist/index60.js +1 -1
  175. package/dist/index61.cjs +1 -1
  176. package/dist/index61.js +1 -1
  177. package/dist/index62.cjs +1 -1
  178. package/dist/index62.js +1 -1
  179. package/dist/index64.cjs +1 -1
  180. package/dist/index64.js +26 -26
  181. package/dist/index66.cjs +1 -1
  182. package/dist/index66.js +3 -3
  183. package/dist/index73.cjs +1 -1
  184. package/dist/index73.js +1 -1
  185. package/dist/index74.cjs +1 -1
  186. package/dist/index74.js +8 -8
  187. package/dist/index79.cjs +1 -1
  188. package/dist/index79.js +1 -1
  189. package/dist/index83.cjs +1 -1
  190. package/dist/index83.js +8 -3
  191. package/dist/index84.cjs +1 -1
  192. package/dist/index84.js +53 -51
  193. package/dist/index85.cjs +1 -1
  194. package/dist/index85.js +18 -18
  195. package/dist/index9.cjs +1 -1
  196. package/dist/index9.js +4 -4
  197. package/dist/index90.cjs +1 -1
  198. package/dist/index90.js +44 -42
  199. package/dist/index92.cjs +1 -1
  200. package/dist/index92.js +39 -39
  201. package/dist/index98.cjs +1 -1
  202. package/dist/index98.js +1 -1
  203. package/dist/src/lib/utils.d.ts +2 -1
  204. package/package.json +1 -1
  205. package/dist/index314.cjs +0 -1
  206. package/dist/index314.js +0 -107
  207. package/dist/index315.cjs +0 -1
  208. package/dist/index315.js +0 -7
  209. package/dist/index316.cjs +0 -1
  210. package/dist/index316.js +0 -4
  211. package/dist/index317.cjs +0 -1
  212. package/dist/index317.js +0 -24
package/dist/index73.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Eip712DomainNotFoundError as u } from "./index241.js";
1
+ import { Eip712DomainNotFoundError as u } from "./index242.js";
2
2
  import { getAction as d } from "./index29.js";
3
3
  import { readContract as f } from "./index33.js";
4
4
  async function E(a, o) {
package/dist/index74.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index150.cjs"),a=require("./index242.cjs");async function H(r,{blockCount:s,blockNumber:e,blockTag:n="latest",rewardPercentiles:i}){const t=e?o.numberToHex(e):void 0,u=await r.request({method:"eth_feeHistory",params:[o.numberToHex(s),t||n,i]},{dedupe:!!t});return a.formatFeeHistory(u)}exports.getFeeHistory=H;
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 m } from "./index242.js";
3
- async function H(r, { blockCount: n, blockNumber: e, blockTag: s = "latest", rewardPercentiles: i }) {
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(n),
8
- t || s,
9
- i
7
+ o(i),
8
+ t || n,
9
+ s
10
10
  ]
11
11
  }, { dedupe: !!t });
12
- return m(a);
12
+ return f(a);
13
13
  }
14
14
  export {
15
- H as getFeeHistory
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("./index249.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;
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 "./index249.js";
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 s(e,{address:n,blockTag:o="latest",blockNumber:t}){const r=await e.request({method:"eth_getTransactionCount",params:[n,t?u.numberToHex(t):o]},{dedupe:!!t});return a.hexToNumber(r)}exports.getTransactionCount=s;
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 s } from "./index150.js";
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: [e, t ? s(t) : n]
7
- }, { dedupe: !!t });
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 N=require("./index21.cjs"),P=require("./index122.cjs"),v=require("./index38.cjs"),_=require("./index127.cjs"),x=require("./index170.cjs"),O=require("./index177.cjs"),T=require("./index214.cjs"),y=require("./index221.cjs"),B=require("./index29.cjs"),M=require("./index33.cjs");async function Z(l,m){var A;const{allowFailure:u=!0,batchSize:j,blockNumber:w,blockTag:k,multicallAddress:p,stateOverride:z}=m,d=m.contracts,C=j??(typeof((A=l.batch)==null?void 0:A.multicall)=="object"&&l.batch.multicall.batchSize||1024);let g=p;if(!g){if(!l.chain)throw new Error("client chain not configured. multicallAddress is required.");g=T.getChainContractAddress({blockNumber:w,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=O.encodeFunctionData({abi:c,args:e,functionName:i});f+=(n.length-2)/2,C>0&&f>C&&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=y.getContractError(n,{abi:c,address:s,args:e,docsPath:"/docs/contract/multicall",functionName:i});if(!u)throw b;r[a]=[...r[a],{allowFailure:!0,callData:"0x",target:s}]}}const q=await Promise.allSettled(r.map(t=>B.getAction(l,M.readContract,"readContract")({abi:N.multicall3Abi,address:g,args:[t],blockNumber:w,blockTag:k,functionName:"aggregate3",stateOverride:z}))),o=[];for(let t=0;t<q.length;t++){const c=q[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:D,address:R,functionName:S,args:E}=d[o.length];try{if(b==="0x")throw new P.AbiDecodingZeroDataError;if(!n)throw new _.RawContractError({data:i});const h=x.decodeFunctionResult({abi:D,args:E,data:i,functionName:S});o.push(u?{result:h,status:"success"}:h)}catch(h){const F=y.getContractError(h,{abi:D,address:R,args:E,docsPath:"/docs/contract/multicall",functionName:S});if(!u)throw F;o.push({error:F,result:void 0,status:"failure"})}}}if(o.length!==d.length)throw new v.BaseError("multicall results mismatch");return o}exports.multicall=Z;
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 x } from "./index21.js";
2
- import { AbiDecodingZeroDataError as P } from "./index122.js";
3
- import { BaseError as _ } from "./index38.js";
4
- import { RawContractError as v } from "./index127.js";
5
- import { decodeFunctionResult as q } from "./index170.js";
6
- import { encodeFunctionData as B } from "./index177.js";
7
- import { getChainContractAddress as O } from "./index214.js";
8
- import { getContractError as E } from "./index221.js";
9
- import { getAction as T } from "./index29.js";
10
- import { readContract as Z } from "./index33.js";
11
- async function W(n, w) {
12
- var A;
13
- const { allowFailure: u = !0, batchSize: F, blockNumber: b, blockTag: j, multicallAddress: y, stateOverride: N } = w, h = w.contracts, p = F ?? (typeof ((A = n.batch) == null ? void 0 : A.multicall) == "object" && n.batch.multicall.batchSize || 1024);
14
- let d = y;
15
- if (!d) {
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
- d = O({
19
- blockNumber: b,
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 < h.length; t++) {
27
- const { abi: o, address: s, args: r, functionName: i } = h[t];
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 = B({ abi: o, args: r, functionName: i });
29
+ const c = O({ abi: o, args: r, functionName: i });
30
30
  f += (c.length - 2) / 2, // Check if batching is enabled.
31
- p > 0 && // Check if the current size of the batch exceeds the size limit.
32
- f > p && // Check if the current chunk is not already empty.
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 = E(c, {
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 C = await Promise.allSettled(e.map((t) => T(n, Z, "readContract")({
62
- abi: x,
63
- address: d,
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: b,
66
- blockTag: j,
67
+ blockNumber: p,
68
+ blockTag: y,
67
69
  functionName: "aggregate3",
68
- stateOverride: N
70
+ stateOverride: R
69
71
  }))), l = [];
70
- for (let t = 0; t < C.length; t++) {
71
- const o = C[t];
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: D, address: R, functionName: S, args: k } = h[l.length];
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 P();
90
+ throw new _();
89
91
  if (!c)
90
- throw new v({ data: i });
91
- const m = q({
92
- abi: D,
93
- args: k,
92
+ throw new q({ data: i });
93
+ const h = B({
94
+ abi: S,
95
+ args: z,
94
96
  data: i,
95
- functionName: S
97
+ functionName: k
96
98
  });
97
- l.push(u ? { result: m, status: "success" } : m);
98
- } catch (m) {
99
- const z = E(m, {
100
- abi: D,
101
- address: R,
102
- args: k,
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: S
106
+ functionName: k
105
107
  });
106
108
  if (!u)
107
- throw z;
108
- l.push({ error: z, result: void 0, status: "failure" });
109
+ throw E;
110
+ l.push({ error: E, result: void 0, status: "failure" });
109
111
  }
110
112
  }
111
113
  }
112
- if (l.length !== h.length)
113
- throw new _("multicall results mismatch");
114
+ if (l.length !== d.length)
115
+ throw new v("multicall results mismatch");
114
116
  return l;
115
117
  }
116
118
  export {
117
- W as multicall
119
+ X as multicall
118
120
  };
package/dist/index85.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("./index243.cjs"),F=require("./index45.cjs"),y=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("./index236.cjs"),V=require("./index197.cjs");async function Z(p,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?D.toRpc(t.blockOverrides):void 0,e=t.calls.map(n=>{const r=n,s=r.account?F.parseAccount(r.account):void 0,u={...r,data:r.abi?A.encodeFunctionData(r):r.data,from:r.from??(s==null?void 0:s.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=(m?U.numberToHex(m):void 0)||w;return(await p.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 k,g;const{abi:n,args:r,functionName:s,to:u}=q[l].calls[f],b=((k=e.error)==null?void 0:k.data)??e.returnData,E=BigInt(e.gasUsed),h=(g=e.logs)==null?void 0:g.map(o=>L.formatLog(o)),i=e.status==="0x1"?"success":"failure",T=n&&i==="success"&&b!=="0x"?S.decodeFunctionResult({abi:n,data:b,functionName:s}):null,B=(()=>{var v;if(i==="success")return;let o;if(((v=e.error)==null?void 0:v.data)==="0x"?o=new y.AbiDecodingZeroDataError:e.error&&(o=new C.RawContractError(e.error)),!!o)return j.getContractError(o,{abi:n??[],address:u,args:r,functionName:s??"<unknown>"})})();return{data:b,gasUsed:E,logs:h,status:i,...i==="success"?{result:T}:{error:B}}})}))}catch(c){const d=c,a=z.getNodeError(d,{});throw a instanceof H.UnknownNodeError?d:a}}exports.simulateBlocks=Z;
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 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";
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 "./index236.js";
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 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 = {
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
- }), f = t.stateOverrides ? _(t.stateOverrides) : void 0;
28
+ }), d = t.stateOverrides ? _(t.stateOverrides) : void 0;
29
29
  a.push({
30
- blockOverrides: d,
30
+ blockOverrides: f,
31
31
  calls: r,
32
- stateOverrides: f
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, d) => ({
42
+ })).map((t, f) => ({
43
43
  ...L(t),
44
- calls: t.calls.map((r, f) => {
44
+ calls: t.calls.map((r, d) => {
45
45
  var k, g;
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({
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 F() : r.error && (s = new H(r.error)), !!s)
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 U ? u : c;
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("./index27.cjs"),y=require("./index26.cjs"),C=require("./index22.cjs"),T=require("./index28.cjs"),v=require("./index24.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;
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 "./index27.js";
8
- import { http as C } from "./index26.js";
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 "./index28.js";
11
- import { mainnet as S } from "./index24.js";
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"),k=require("./index135.cjs"),g=require("./index29.cjs"),O=require("./index39.cjs"),S=require("./index41.cjs"),y=require("./index216.cjs"),$=require("./index42.cjs"),P=require("./index68.cjs"),W=require("./index81.cjs"),q=require("./index20.cjs"),x=require("./index91.cjs");async function z(n,{confirmations:c=1,hash:p,onReplaced:h,pollingInterval:m=n.pollingInterval,retryCount:w=6,retryDelay:R=({count:d})=>~~(1<<d)*200,timeout:N=18e4}){const d=$.stringify(["waitForTransactionReceipt",n.uid,p]);let a,o,e,i=!1;const{promise:B,resolve:F,reject:v}=S.withResolvers(),A=N?setTimeout(()=>v(new k.WaitForTransactionReceiptTimeoutError({hash:p})),N):void 0,j=O.observe(d,{onReplaced:h,resolve:F,reject:v},r=>{const E=g.getAction(n,x.watchBlockNumber,"watchBlockNumber")({emitMissed:!0,emitOnBegin:!0,poll:!0,pollingInterval:m,async onBlockNumber(_){const u=b=>{clearTimeout(A),E(),b(),j()};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 y.withRetry(async()=>{a=await g.getAction(n,W.getTransaction,"getTransaction")({hash:p}),a.blockNumber&&(l=a.blockNumber)},{delay:R,retryCount:w}),i=!1),e=await g.getAction(n,q.getTransactionReceipt,"getTransactionReceipt")({hash:p}),c>1&&(!e.blockNumber||l-e.blockNumber+1n<c))return;u(()=>r.resolve(e))}catch(b){if(b instanceof k.TransactionNotFoundError||b instanceof k.TransactionReceiptNotFoundError){if(!a){i=!1;return}try{o=a,i=!0;const f=await y.withRetry(()=>g.getAction(n,P.getBlock,"getBlock")({blockNumber:l,includeTransactions:!0}),{delay:R,retryCount:w,shouldRetry:({error:s})=>s instanceof M.BlockNotFoundError});i=!1;const t=f.transactions.find(({from:s,nonce:I})=>s===o.from&&I===o.nonce);if(!t||(e=await g.getAction(n,q.getTransactionReceipt,"getTransactionReceipt")({hash:t.hash}),c>1&&(!e.blockNumber||l-e.blockNumber+1n<c)))return;let T="replaced";t.to===o.to&&t.value===o.value&&t.input===o.input?T="repriced":t.from===t.to&&t.value===0n&&(T="cancelled"),u(()=>{var s;(s=r.onReplaced)==null||s.call(r,{reason:T,replacedTransaction:o,transaction:t,transactionReceipt:e}),r.resolve(e)})}catch(f){u(()=>r.reject(f))}}else u(()=>r.reject(b))}}})});return B}exports.waitForTransactionReceipt=z;
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 v } from "./index216.js";
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 R } from "./index20.js";
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: y,
16
- pollingInterval: B = o.pollingInterval,
17
- retryCount: k = 6,
18
- retryDelay: N = ({ count: b }) => ~~(1 << b) * 200,
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: w = 18e4
20
+ timeout: v = 18e4
21
21
  }) {
22
22
  const b = G(["waitForTransactionReceipt", o.uid, m]);
23
- let c, n, r, i = !1;
24
- const { promise: h, resolve: F, reject: g } = z(), E = w ? setTimeout(() => g(new M({ hash: m })), w) : void 0, _ = q(b, { onReplaced: y, resolve: F, reject: g }, (t) => {
25
- const j = f(o, K, "watchBlockNumber")({
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: B,
32
+ pollingInterval: F,
30
33
  async onBlockNumber(I) {
31
- const l = (p) => {
32
- clearTimeout(E), j(), p(), _();
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 (r) {
38
- if (a > 1 && (!r.blockNumber || u - r.blockNumber + 1n < a))
40
+ if (e) {
41
+ if (a > 1 && (!e.blockNumber || u - e.blockNumber + 1n < a))
39
42
  return;
40
- l(() => t.resolve(r));
43
+ s(() => t.resolve(e));
41
44
  return;
42
45
  }
43
- if (c || (i = !0, await v(async () => {
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: N,
47
- retryCount: k
48
- }), i = !1), r = await f(o, R, "getTransactionReceipt")({ hash: m }), a > 1 && (!r.blockNumber || u - r.blockNumber + 1n < a))
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
- l(() => t.resolve(r));
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 d = await v(() => f(o, H, "getBlock")({
62
+ const k = await y(() => f(o, H, "getBlock")({
60
63
  blockNumber: u,
61
64
  includeTransactions: !0
62
65
  }), {
63
- delay: N,
64
- retryCount: k,
65
- shouldRetry: ({ error: s }) => s instanceof A
66
+ delay: g,
67
+ retryCount: w,
68
+ shouldRetry: ({ error: l }) => l instanceof A
66
69
  });
67
70
  i = !1;
68
- const e = d.transactions.find(({ from: s, nonce: x }) => s === n.from && x === n.nonce);
69
- if (!e || (r = await f(o, R, "getTransactionReceipt")({
70
- hash: e.hash
71
- }), a > 1 && (!r.blockNumber || u - r.blockNumber + 1n < a)))
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 T = "replaced";
74
- e.to === n.to && e.value === n.value && e.input === n.input ? T = "repriced" : e.from === e.to && e.value === 0n && (T = "cancelled"), l(() => {
75
- var s;
76
- (s = t.onReplaced) == null || s.call(t, {
77
- reason: T,
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: e,
80
- transactionReceipt: r
81
- }), t.resolve(r);
82
+ transaction: r,
83
+ transactionReceipt: e
84
+ }), t.resolve(e);
82
85
  });
83
- } catch (d) {
84
- l(() => t.reject(d));
86
+ } catch (k) {
87
+ s(() => t.reject(k));
85
88
  }
86
89
  } else
87
- l(() => t.reject(p));
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"),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;
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;