@gardenfi/utils 2.5.2 → 2.5.3-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/README.md +9 -0
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.js +37 -36
  4. package/dist/index10.cjs +1 -1
  5. package/dist/index10.js +4 -4
  6. package/dist/index11.cjs +1 -1
  7. package/dist/index11.js +16 -20
  8. package/dist/index112.cjs +1 -1
  9. package/dist/index112.js +15 -15
  10. package/dist/index121.cjs +1 -1
  11. package/dist/index121.js +1 -1
  12. package/dist/index130.cjs +1 -1
  13. package/dist/index130.js +1 -1
  14. package/dist/index16.cjs +1 -1
  15. package/dist/index16.js +4 -4
  16. package/dist/index18.cjs +1 -1
  17. package/dist/index18.js +20 -9
  18. package/dist/index197.cjs +1 -1
  19. package/dist/index197.js +17 -30
  20. package/dist/index22.cjs +1 -1
  21. package/dist/index22.js +84 -51
  22. package/dist/index226.cjs +1 -1
  23. package/dist/index226.js +2 -2
  24. package/dist/index229.cjs +1 -1
  25. package/dist/index229.js +2 -2
  26. package/dist/index230.cjs +1 -1
  27. package/dist/index230.js +1 -1
  28. package/dist/index234.cjs +1 -1
  29. package/dist/index234.js +7 -8
  30. package/dist/index235.cjs +1 -1
  31. package/dist/index235.js +1 -1
  32. package/dist/index236.cjs +1 -1
  33. package/dist/index236.js +1 -1
  34. package/dist/index237.cjs +1 -1
  35. package/dist/index237.js +2 -2
  36. package/dist/index24.cjs +1 -1
  37. package/dist/index24.js +30 -13
  38. package/dist/index249.cjs +1 -1
  39. package/dist/index249.js +3 -3
  40. package/dist/index25.cjs +1 -1
  41. package/dist/index25.js +30 -58
  42. package/dist/index250.cjs +1 -1
  43. package/dist/index250.js +3 -3
  44. package/dist/index256.cjs +1 -1
  45. package/dist/index256.js +17 -12
  46. package/dist/index26.cjs +1 -16
  47. package/dist/index26.js +11 -113
  48. package/dist/index269.cjs +1 -1
  49. package/dist/index269.js +4 -4
  50. package/dist/index27.cjs +1 -1
  51. package/dist/index27.js +58 -32
  52. package/dist/index270.cjs +1 -1
  53. package/dist/index270.js +5 -5
  54. package/dist/index271.cjs +1 -1
  55. package/dist/index271.js +27 -21
  56. package/dist/index272.cjs +1 -1
  57. package/dist/index272.js +54 -20
  58. package/dist/index273.cjs +1 -1
  59. package/dist/index273.js +18 -54
  60. package/dist/index274.cjs +1 -1
  61. package/dist/index274.js +10 -34
  62. package/dist/index275.cjs +1 -1
  63. package/dist/index275.js +7 -10
  64. package/dist/index276.cjs +1 -1
  65. package/dist/index276.js +12 -13
  66. package/dist/index277.cjs +1 -1
  67. package/dist/index277.js +11 -12
  68. package/dist/index28.cjs +1 -1
  69. package/dist/index28.js +13 -31
  70. package/dist/index280.cjs +1 -1
  71. package/dist/index280.js +103 -11
  72. package/dist/index281.cjs +1 -1
  73. package/dist/index281.js +6 -103
  74. package/dist/index282.cjs +1 -1
  75. package/dist/index282.js +243 -5
  76. package/dist/index283.cjs +1 -1
  77. package/dist/index283.js +6 -224
  78. package/dist/index284.cjs +1 -1
  79. package/dist/index284.js +7 -7
  80. package/dist/index285.cjs +1 -1
  81. package/dist/index285.js +27 -7
  82. package/dist/index286.cjs +1 -1
  83. package/dist/index286.js +18 -25
  84. package/dist/index287.cjs +1 -1
  85. package/dist/index287.js +145 -18
  86. package/dist/index288.cjs +1 -1
  87. package/dist/index288.js +3 -146
  88. package/dist/index289.cjs +1 -1
  89. package/dist/index289.js +155 -3
  90. package/dist/index29.cjs +16 -1
  91. package/dist/index29.js +113 -11
  92. package/dist/index290.cjs +1 -1
  93. package/dist/index290.js +7 -138
  94. package/dist/index291.cjs +1 -1
  95. package/dist/index291.js +128 -143
  96. package/dist/index292.cjs +1 -1
  97. package/dist/index292.js +111 -7
  98. package/dist/index293.cjs +2 -1
  99. package/dist/index293.js +116 -95
  100. package/dist/index294.cjs +1 -2
  101. package/dist/index294.js +35 -127
  102. package/dist/index295.cjs +1 -1
  103. package/dist/index295.js +66 -30
  104. package/dist/index296.cjs +1 -1
  105. package/dist/index296.js +2 -79
  106. package/dist/index297.cjs +1 -1
  107. package/dist/index297.js +12 -2
  108. package/dist/index298.cjs +1 -1
  109. package/dist/index298.js +19 -11
  110. package/dist/index299.cjs +1 -1
  111. package/dist/index299.js +68 -19
  112. package/dist/index3.cjs +1 -1
  113. package/dist/index3.js +10 -8
  114. package/dist/index300.cjs +1 -1
  115. package/dist/index300.js +786 -66
  116. package/dist/index301.cjs +1 -1
  117. package/dist/index301.js +134 -684
  118. package/dist/index302.cjs +1 -1
  119. package/dist/index302.js +185 -124
  120. package/dist/index303.cjs +2 -1
  121. package/dist/index303.js +63 -198
  122. package/dist/index304.cjs +1 -2
  123. package/dist/index304.js +7 -66
  124. package/dist/index305.cjs +1 -1
  125. package/dist/index305.js +62 -4
  126. package/dist/index306.cjs +1 -1
  127. package/dist/index306.js +22 -40
  128. package/dist/index307.cjs +1 -1
  129. package/dist/index307.js +5 -7
  130. package/dist/index308.cjs +1 -1
  131. package/dist/index308.js +72 -57
  132. package/dist/index309.cjs +1 -1
  133. package/dist/index309.js +4 -78
  134. package/dist/index310.cjs +1 -1
  135. package/dist/index310.js +195 -4
  136. package/dist/index311.cjs +1 -1
  137. package/dist/index311.js +4 -194
  138. package/dist/index312.cjs +1 -1
  139. package/dist/index312.js +35 -58
  140. package/dist/index313.cjs +2 -1
  141. package/dist/index313.js +40 -43
  142. package/dist/index314.cjs +1 -1
  143. package/dist/index314.js +2 -5
  144. package/dist/index315.cjs +1 -1
  145. package/dist/index315.js +11 -5
  146. package/dist/index316.cjs +1 -1
  147. package/dist/index316.js +20 -2
  148. package/dist/index317.cjs +1 -1
  149. package/dist/index317.js +8 -21
  150. package/dist/index318.cjs +1 -0
  151. package/dist/index318.js +45 -0
  152. package/dist/index319.cjs +1 -0
  153. package/dist/index319.js +69 -0
  154. package/dist/index320.cjs +1 -0
  155. package/dist/index320.js +68 -0
  156. package/dist/index321.cjs +1 -0
  157. package/dist/index321.js +191 -0
  158. package/dist/index322.cjs +1 -0
  159. package/dist/index322.js +79 -0
  160. package/dist/index323.cjs +1 -0
  161. package/dist/index323.js +43 -0
  162. package/dist/index324.cjs +1 -0
  163. package/dist/index324.js +19 -0
  164. package/dist/index325.cjs +1 -0
  165. package/dist/index325.js +16 -0
  166. package/dist/index326.cjs +1 -0
  167. package/dist/index326.js +7 -0
  168. package/dist/index327.cjs +1 -0
  169. package/dist/index327.js +66 -0
  170. package/dist/index328.cjs +1 -0
  171. package/dist/index328.js +7 -0
  172. package/dist/index329.cjs +1 -0
  173. package/dist/index329.js +47 -0
  174. package/dist/index330.cjs +1 -0
  175. package/dist/index330.js +71 -0
  176. package/dist/index331.cjs +1 -0
  177. package/dist/index331.js +4 -0
  178. package/dist/index332.cjs +1 -0
  179. package/dist/index332.js +24 -0
  180. package/dist/index55.cjs +1 -1
  181. package/dist/index55.js +1 -1
  182. package/dist/index58.cjs +1 -1
  183. package/dist/index58.js +35 -34
  184. package/dist/index60.cjs +1 -1
  185. package/dist/index60.js +26 -30
  186. package/dist/index61.cjs +1 -1
  187. package/dist/index61.js +13 -9
  188. package/dist/index62.cjs +1 -1
  189. package/dist/index62.js +19 -19
  190. package/dist/index89.cjs +1 -1
  191. package/dist/index89.js +31 -30
  192. package/dist/index9.cjs +1 -1
  193. package/dist/index9.js +2 -2
  194. package/dist/index95.cjs +1 -1
  195. package/dist/index95.js +73 -73
  196. package/dist/src/lib/auth/apikey/apikey.d.ts +1 -1
  197. package/dist/src/lib/auth/auth.types.d.ts +1 -1
  198. package/dist/src/lib/fetcher/fetcher.d.ts +2 -0
  199. package/dist/src/lib/utils.d.ts +1 -0
  200. package/package.json +2 -2
package/dist/index89.js CHANGED
@@ -1,17 +1,17 @@
1
- import { multicall3Abi as P } from "./index22.js";
2
- import { AbiDecodingZeroDataError as _ } from "./index127.js";
3
- import { BaseError as v } from "./index41.js";
4
- import { RawContractError as q } from "./index132.js";
5
- import { decodeFunctionResult as B } from "./index175.js";
1
+ import { multicall3Abi as _ } from "./index22.js";
2
+ import { AbiDecodingZeroDataError as v } from "./index127.js";
3
+ import { BaseError as q } from "./index41.js";
4
+ import { RawContractError as B } from "./index132.js";
5
+ import { decodeFunctionResult as L } from "./index175.js";
6
6
  import { encodeFunctionData as O } from "./index182.js";
7
7
  import { getChainContractAddress as T } from "./index219.js";
8
8
  import { getContractError as F } from "./index225.js";
9
9
  import { getAction as Z } from "./index32.js";
10
10
  import { readContract as G } from "./index36.js";
11
- async function X(n, w) {
11
+ async function Y(n, w) {
12
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;
13
+ const { account: b, authorizationList: j, allowFailure: u = !0, batchSize: y, blockNumber: p, blockTag: N, multicallAddress: R, stateOverride: x } = w, h = w.contracts, C = y ?? (typeof ((D = n.batch) == null ? void 0 : D.multicall) == "object" && n.batch.multicall.batchSize || 1024);
14
+ let m = R;
15
15
  if (!m) {
16
16
  if (!n.chain)
17
17
  throw new Error("client chain not configured. multicallAddress is required.");
@@ -23,8 +23,8 @@ async function X(n, w) {
23
23
  }
24
24
  const e = [[]];
25
25
  let a = 0, f = 0;
26
- for (let t = 0; t < d.length; t++) {
27
- const { abi: o, address: s, args: r, functionName: i } = d[t];
26
+ for (let t = 0; t < h.length; t++) {
27
+ const { abi: o, address: s, args: r, functionName: i } = h[t];
28
28
  try {
29
29
  const c = O({ abi: o, args: r, functionName: i });
30
30
  f += (c.length - 2) / 2, // Check if batching is enabled.
@@ -60,14 +60,15 @@ async function X(n, w) {
60
60
  }
61
61
  }
62
62
  const A = await Promise.allSettled(e.map((t) => Z(n, G, "readContract")({
63
- abi: P,
63
+ abi: _,
64
64
  account: b,
65
65
  address: m,
66
66
  args: [t],
67
+ authorizationList: j,
67
68
  blockNumber: p,
68
- blockTag: y,
69
+ blockTag: N,
69
70
  functionName: "aggregate3",
70
- stateOverride: R
71
+ stateOverride: x
71
72
  }))), l = [];
72
73
  for (let t = 0; t < A.length; t++) {
73
74
  const o = A[t];
@@ -84,26 +85,26 @@ async function X(n, w) {
84
85
  }
85
86
  const s = o.value;
86
87
  for (let r = 0; r < s.length; r++) {
87
- const { returnData: i, success: c } = s[r], { callData: g } = e[t][r], { abi: S, address: x, functionName: k, args: z } = d[l.length];
88
+ const { returnData: i, success: c } = s[r], { callData: g } = e[t][r], { abi: z, address: P, functionName: S, args: k } = h[l.length];
88
89
  try {
89
90
  if (g === "0x")
90
- throw new _();
91
+ throw new v();
91
92
  if (!c)
92
- throw new q({ data: i });
93
- const h = B({
94
- abi: S,
95
- args: z,
93
+ throw new B({ data: i });
94
+ const d = L({
95
+ abi: z,
96
+ args: k,
96
97
  data: i,
97
- functionName: k
98
+ functionName: S
98
99
  });
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,
100
+ l.push(u ? { result: d, status: "success" } : d);
101
+ } catch (d) {
102
+ const E = F(d, {
103
+ abi: z,
104
+ address: P,
105
+ args: k,
105
106
  docsPath: "/docs/contract/multicall",
106
- functionName: k
107
+ functionName: S
107
108
  });
108
109
  if (!u)
109
110
  throw E;
@@ -111,10 +112,10 @@ async function X(n, w) {
111
112
  }
112
113
  }
113
114
  }
114
- if (l.length !== d.length)
115
- throw new v("multicall results mismatch");
115
+ if (l.length !== h.length)
116
+ throw new q("multicall results mismatch");
116
117
  return l;
117
118
  }
118
119
  export {
119
- X as multicall
120
+ Y as multicall
120
121
  };
package/dist/index9.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=(t=>(t.Authorization="Authorization",t.ApiKey="api-key",t))(e||{});exports.AuthHeaderEnum=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=(t=>(t.Authorization="Authorization",t.ApiKey="garden-app-id",t))(e||{});exports.AuthHeaderEnum=e;
package/dist/index9.js CHANGED
@@ -1,4 +1,4 @@
1
- var o = /* @__PURE__ */ ((i) => (i.Authorization = "Authorization", i.ApiKey = "api-key", i))(o || {});
1
+ var r = /* @__PURE__ */ ((i) => (i.Authorization = "Authorization", i.ApiKey = "garden-app-id", i))(r || {});
2
2
  export {
3
- o as AuthHeaderEnum
3
+ r as AuthHeaderEnum
4
4
  };
package/dist/index95.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("./index131.cjs"),R=require("./index140.cjs"),l=require("./index32.cjs"),S=require("./index43.cjs"),$=require("./index45.cjs"),B=require("./index46.cjs"),C=require("./index47.cjs"),D=require("./index73.cjs"),P=require("./index86.cjs"),k=require("./index21.cjs"),W=require("./index96.cjs");async function z(r,T){const{checkReplacement:A=!0,confirmations:o=1,hash:u,onReplaced:F,retryCount:y=6,retryDelay:v=({count:t})=>~~(1<<t)*200,timeout:w=18e4}=T,_=C.stringify(["waitForTransactionReceipt",r.uid,u]),I=(()=>{var t;return T.pollingInterval?T.pollingInterval:(t=r.chain)!=null&&t.experimental_preconfirmationTime?r.chain.experimental_preconfirmationTime:r.pollingInterval})();let i,c,e,a=!1,g,d;const{promise:j,resolve:E,reject:N}=$.withResolvers(),q=w?setTimeout(()=>{d(),g(),N(new R.WaitForTransactionReceiptTimeoutError({hash:u}))},w):void 0;return g=S.observe(_,{onReplaced:F,resolve:E,reject:N},async t=>{if(e=await l.getAction(r,k.getTransactionReceipt,"getTransactionReceipt")({hash:u}).catch(()=>{}),e&&o<=1){clearTimeout(q),t.resolve(e),g();return}d=l.getAction(r,W.watchBlockNumber,"watchBlockNumber")({emitMissed:!0,emitOnBegin:!0,poll:!0,pollingInterval:I,async onBlockNumber(x){const f=b=>{clearTimeout(q),d(),b(),g()};let p=x;if(!a)try{if(e){if(o>1&&(!e.blockNumber||p-e.blockNumber+1n<o))return;f(()=>t.resolve(e));return}if(A&&!i&&(a=!0,await B.withRetry(async()=>{i=await l.getAction(r,P.getTransaction,"getTransaction")({hash:u}),i.blockNumber&&(p=i.blockNumber)},{delay:v,retryCount:y}),a=!1),e=await l.getAction(r,k.getTransactionReceipt,"getTransactionReceipt")({hash:u}),o>1&&(!e.blockNumber||p-e.blockNumber+1n<o))return;f(()=>t.resolve(e))}catch(b){if(b instanceof R.TransactionNotFoundError||b instanceof R.TransactionReceiptNotFoundError){if(!i){a=!1;return}try{c=i,a=!0;const h=await B.withRetry(()=>l.getAction(r,D.getBlock,"getBlock")({blockNumber:p,includeTransactions:!0}),{delay:v,retryCount:y,shouldRetry:({error:s})=>s instanceof O.BlockNotFoundError});a=!1;const n=h.transactions.find(({from:s,nonce:M})=>s===c.from&&M===c.nonce);if(!n||(e=await l.getAction(r,k.getTransactionReceipt,"getTransactionReceipt")({hash:n.hash}),o>1&&(!e.blockNumber||p-e.blockNumber+1n<o)))return;let m="replaced";n.to===c.to&&n.value===c.value&&n.input===c.input?m="repriced":n.from===n.to&&n.value===0n&&(m="cancelled"),f(()=>{var s;(s=t.onReplaced)==null||s.call(t,{reason:m,replacedTransaction:c,transaction:n,transactionReceipt:e}),t.resolve(e)})}catch(h){f(()=>t.reject(h))}}else f(()=>t.reject(b))}}})}),j}exports.waitForTransactionReceipt=z;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("./index131.cjs"),k=require("./index140.cjs"),f=require("./index32.cjs"),$=require("./index43.cjs"),C=require("./index45.cjs"),B=require("./index46.cjs"),D=require("./index47.cjs"),P=require("./index73.cjs"),W=require("./index86.cjs"),y=require("./index21.cjs"),z=require("./index96.cjs");async function G(r,b){const{checkReplacement:A=!0,confirmations:c=1,hash:p,onReplaced:F,retryCount:h=6,retryDelay:N=({count:t})=>~~(1<<t)*200,timeout:w=18e4}=b,I=D.stringify(["waitForTransactionReceipt",r.uid,p]),j=(()=>{var t;return b.pollingInterval?b.pollingInterval:(t=r.chain)!=null&&t.experimental_preconfirmationTime?r.chain.experimental_preconfirmationTime:r.pollingInterval})();let s,i,e,l=!1,n,a;const{promise:E,resolve:x,reject:v}=C.withResolvers(),q=w?setTimeout(()=>{a==null||a(),n==null||n(),v(new k.WaitForTransactionReceiptTimeoutError({hash:p}))},w):void 0;return n=$.observe(I,{onReplaced:F,resolve:x,reject:v},async t=>{if(e=await f.getAction(r,y.getTransactionReceipt,"getTransactionReceipt")({hash:p}).catch(()=>{}),e&&c<=1){clearTimeout(q),t.resolve(e),n==null||n();return}a=f.getAction(r,z.watchBlockNumber,"watchBlockNumber")({emitMissed:!0,emitOnBegin:!0,poll:!0,pollingInterval:j,async onBlockNumber(M){const g=d=>{clearTimeout(q),a==null||a(),d(),n==null||n()};let T=M;if(!l)try{if(e){if(c>1&&(!e.blockNumber||T-e.blockNumber+1n<c))return;g(()=>t.resolve(e));return}if(A&&!s&&(l=!0,await B.withRetry(async()=>{s=await f.getAction(r,W.getTransaction,"getTransaction")({hash:p}),s.blockNumber&&(T=s.blockNumber)},{delay:N,retryCount:h}),l=!1),e=await f.getAction(r,y.getTransactionReceipt,"getTransactionReceipt")({hash:p}),c>1&&(!e.blockNumber||T-e.blockNumber+1n<c))return;g(()=>t.resolve(e))}catch(d){if(d instanceof k.TransactionNotFoundError||d instanceof k.TransactionReceiptNotFoundError){if(!s){l=!1;return}try{i=s,l=!0;const m=await B.withRetry(()=>f.getAction(r,P.getBlock,"getBlock")({blockNumber:T,includeTransactions:!0}),{delay:N,retryCount:h,shouldRetry:({error:u})=>u instanceof S.BlockNotFoundError});l=!1;const o=m.transactions.find(({from:u,nonce:O})=>u===i.from&&O===i.nonce);if(!o||(e=await f.getAction(r,y.getTransactionReceipt,"getTransactionReceipt")({hash:o.hash}),c>1&&(!e.blockNumber||T-e.blockNumber+1n<c)))return;let R="replaced";o.to===i.to&&o.value===i.value&&o.input===i.input?R="repriced":o.from===o.to&&o.value===0n&&(R="cancelled"),g(()=>{var u;(u=t.onReplaced)==null||u.call(t,{reason:R,replacedTransaction:i,transaction:o,transactionReceipt:e}),t.resolve(e)})}catch(m){g(()=>t.reject(m))}}else g(()=>t.reject(d))}}})}),E}exports.waitForTransactionReceipt=G;
package/dist/index95.js CHANGED
@@ -1,106 +1,106 @@
1
- import { BlockNotFoundError as D } from "./index131.js";
2
- import { WaitForTransactionReceiptTimeoutError as M, TransactionNotFoundError as O, TransactionReceiptNotFoundError as W } from "./index140.js";
3
- import { getAction as s } from "./index32.js";
4
- import { observe as q } from "./index43.js";
5
- import { withResolvers as z } from "./index45.js";
1
+ import { BlockNotFoundError as M } from "./index131.js";
2
+ import { WaitForTransactionReceiptTimeoutError as O, TransactionNotFoundError as W, TransactionReceiptNotFoundError as q } from "./index140.js";
3
+ import { getAction as u } from "./index32.js";
4
+ import { observe as z } from "./index43.js";
5
+ import { withResolvers as G } from "./index45.js";
6
6
  import { withRetry as B } from "./index46.js";
7
- import { stringify as G } from "./index47.js";
8
- import { getBlock as H } from "./index73.js";
9
- import { getTransaction as J } from "./index86.js";
10
- import { getTransactionReceipt as g } from "./index21.js";
11
- import { watchBlockNumber as K } from "./index96.js";
12
- async function re(t, d) {
7
+ import { stringify as H } from "./index47.js";
8
+ import { getBlock as J } from "./index73.js";
9
+ import { getTransaction as K } from "./index86.js";
10
+ import { getTransactionReceipt as y } from "./index21.js";
11
+ import { watchBlockNumber as L } from "./index96.js";
12
+ async function er(t, b) {
13
13
  const {
14
14
  checkReplacement: F = !0,
15
- confirmations: n = 1,
16
- hash: u,
17
- onReplaced: _,
18
- retryCount: v = 6,
19
- retryDelay: y = ({ count: r }) => ~~(1 << r) * 200,
15
+ confirmations: a = 1,
16
+ hash: m,
17
+ onReplaced: I,
18
+ retryCount: N = 6,
19
+ retryDelay: R = ({ count: e }) => ~~(1 << e) * 200,
20
20
  // exponential backoff
21
- timeout: N = 18e4
22
- } = d, I = G(["waitForTransactionReceipt", t.uid, u]), E = (() => {
23
- var r;
24
- return d.pollingInterval ? d.pollingInterval : (r = t.chain) != null && r.experimental_preconfirmationTime ? t.chain.experimental_preconfirmationTime : t.pollingInterval;
21
+ timeout: h = 18e4
22
+ } = b, E = H(["waitForTransactionReceipt", t.uid, m]), j = (() => {
23
+ var e;
24
+ return b.pollingInterval ? b.pollingInterval : (e = t.chain) != null && e.experimental_preconfirmationTime ? t.chain.experimental_preconfirmationTime : t.pollingInterval;
25
25
  })();
26
- let i, a, e, c = !1, b, T;
27
- const { promise: j, resolve: x, reject: R } = z(), w = N ? setTimeout(() => {
28
- T(), b(), R(new M({ hash: u }));
29
- }, N) : void 0;
30
- return b = q(I, { onReplaced: _, resolve: x, reject: R }, async (r) => {
31
- if (e = await s(t, g, "getTransactionReceipt")({ hash: u }).catch(() => {
32
- }), e && n <= 1) {
33
- clearTimeout(w), r.resolve(e), b();
26
+ let l, i, r, s = !1, o, c;
27
+ const { promise: x, resolve: A, reject: v } = G(), w = h ? setTimeout(() => {
28
+ c == null || c(), o == null || o(), v(new O({ hash: m }));
29
+ }, h) : void 0;
30
+ return o = z(E, { onReplaced: I, resolve: A, reject: v }, async (e) => {
31
+ if (r = await u(t, y, "getTransactionReceipt")({ hash: m }).catch(() => {
32
+ }), r && a <= 1) {
33
+ clearTimeout(w), e.resolve(r), o == null || o();
34
34
  return;
35
35
  }
36
- T = s(t, K, "watchBlockNumber")({
36
+ c = u(t, L, "watchBlockNumber")({
37
37
  emitMissed: !0,
38
38
  emitOnBegin: !0,
39
39
  poll: !0,
40
- pollingInterval: E,
41
- async onBlockNumber(A) {
42
- const f = (p) => {
43
- clearTimeout(w), T(), p(), b();
40
+ pollingInterval: j,
41
+ async onBlockNumber(C) {
42
+ const p = (T) => {
43
+ clearTimeout(w), c == null || c(), T(), o == null || o();
44
44
  };
45
- let m = A;
46
- if (!c)
45
+ let d = C;
46
+ if (!s)
47
47
  try {
48
- if (e) {
49
- if (n > 1 && (!e.blockNumber || m - e.blockNumber + 1n < n))
48
+ if (r) {
49
+ if (a > 1 && (!r.blockNumber || d - r.blockNumber + 1n < a))
50
50
  return;
51
- f(() => r.resolve(e));
51
+ p(() => e.resolve(r));
52
52
  return;
53
53
  }
54
- if (F && !i && (c = !0, await B(async () => {
55
- i = await s(t, J, "getTransaction")({ hash: u }), i.blockNumber && (m = i.blockNumber);
54
+ if (F && !l && (s = !0, await B(async () => {
55
+ l = await u(t, K, "getTransaction")({ hash: m }), l.blockNumber && (d = l.blockNumber);
56
56
  }, {
57
- delay: y,
58
- retryCount: v
59
- }), c = !1), e = await s(t, g, "getTransactionReceipt")({ hash: u }), n > 1 && (!e.blockNumber || m - e.blockNumber + 1n < n))
57
+ delay: R,
58
+ retryCount: N
59
+ }), s = !1), r = await u(t, y, "getTransactionReceipt")({ hash: m }), a > 1 && (!r.blockNumber || d - r.blockNumber + 1n < a))
60
60
  return;
61
- f(() => r.resolve(e));
62
- } catch (p) {
63
- if (p instanceof O || p instanceof W) {
64
- if (!i) {
65
- c = !1;
61
+ p(() => e.resolve(r));
62
+ } catch (T) {
63
+ if (T instanceof W || T instanceof q) {
64
+ if (!l) {
65
+ s = !1;
66
66
  return;
67
67
  }
68
68
  try {
69
- a = i, c = !0;
70
- const h = await B(() => s(t, H, "getBlock")({
71
- blockNumber: m,
69
+ i = l, s = !0;
70
+ const k = await B(() => u(t, J, "getBlock")({
71
+ blockNumber: d,
72
72
  includeTransactions: !0
73
73
  }), {
74
- delay: y,
75
- retryCount: v,
76
- shouldRetry: ({ error: l }) => l instanceof D
74
+ delay: R,
75
+ retryCount: N,
76
+ shouldRetry: ({ error: f }) => f instanceof M
77
77
  });
78
- c = !1;
79
- const o = h.transactions.find(({ from: l, nonce: C }) => l === a.from && C === a.nonce);
80
- if (!o || (e = await s(t, g, "getTransactionReceipt")({
81
- hash: o.hash
82
- }), n > 1 && (!e.blockNumber || m - e.blockNumber + 1n < n)))
78
+ s = !1;
79
+ const n = k.transactions.find(({ from: f, nonce: D }) => f === i.from && D === i.nonce);
80
+ if (!n || (r = await u(t, y, "getTransactionReceipt")({
81
+ hash: n.hash
82
+ }), a > 1 && (!r.blockNumber || d - r.blockNumber + 1n < a)))
83
83
  return;
84
- let k = "replaced";
85
- o.to === a.to && o.value === a.value && o.input === a.input ? k = "repriced" : o.from === o.to && o.value === 0n && (k = "cancelled"), f(() => {
86
- var l;
87
- (l = r.onReplaced) == null || l.call(r, {
88
- reason: k,
89
- replacedTransaction: a,
90
- transaction: o,
91
- transactionReceipt: e
92
- }), r.resolve(e);
84
+ let g = "replaced";
85
+ n.to === i.to && n.value === i.value && n.input === i.input ? g = "repriced" : n.from === n.to && n.value === 0n && (g = "cancelled"), p(() => {
86
+ var f;
87
+ (f = e.onReplaced) == null || f.call(e, {
88
+ reason: g,
89
+ replacedTransaction: i,
90
+ transaction: n,
91
+ transactionReceipt: r
92
+ }), e.resolve(r);
93
93
  });
94
- } catch (h) {
95
- f(() => r.reject(h));
94
+ } catch (k) {
95
+ p(() => e.reject(k));
96
96
  }
97
97
  } else
98
- f(() => r.reject(p));
98
+ p(() => e.reject(T));
99
99
  }
100
100
  }
101
101
  });
102
- }), j;
102
+ }), x;
103
103
  }
104
104
  export {
105
- re as waitForTransactionReceipt
105
+ er as waitForTransactionReceipt
106
106
  };
@@ -2,7 +2,7 @@ import { AsyncResult, Result } from '../../result/result';
2
2
  import { AuthHeader, IAuth } from '../auth.types';
3
3
 
4
4
  export declare class ApiKey implements IAuth {
5
- private readonly apiKey;
5
+ private readonly _apiKey;
6
6
  constructor(apiKey: string);
7
7
  getToken(): AsyncResult<string, string>;
8
8
  verifyToken(): Result<boolean, string>;
@@ -8,7 +8,7 @@ export type SiweOpts = {
8
8
  };
9
9
  export declare enum AuthHeaderEnum {
10
10
  Authorization = "Authorization",
11
- ApiKey = "api-key"
11
+ ApiKey = "garden-app-id"
12
12
  }
13
13
  export type AuthHeader = Record<AuthHeaderEnum.ApiKey, string> | Record<AuthHeaderEnum.Authorization, string>;
14
14
  export interface IAuth {
@@ -31,6 +31,8 @@ export declare class Fetcher {
31
31
  * Asynchronously sends a POST request to the specified URL or RequestInfo, with optional initialization options.
32
32
  */
33
33
  static post<T>(input: RequestInfo | URL, init?: Request): Promise<T>;
34
+ private static _patch;
35
+ static patch<T>(input: RequestInfo | URL, init?: Request): Promise<T>;
34
36
  /**
35
37
  * Parses the response and returns the result as the specified type.
36
38
  *
@@ -20,3 +20,4 @@ export declare enum Environment {
20
20
  export declare const add0x: (str: string) => `0x${string}`;
21
21
  export declare function hexToU32Array(hexString: string, endian?: 'big' | 'little'): number[];
22
22
  export declare function trim0x(str: string): string;
23
+ export declare const hasKeys: (obj: any, keys: string[]) => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/utils",
3
- "version": "2.5.2",
3
+ "version": "2.5.3-beta.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "vite build",
@@ -42,4 +42,4 @@
42
42
  "jwt-decode": "^4.0.0",
43
43
  "tough-cookie": "^5.1.2"
44
44
  }
45
- }
45
+ }