@gardenfi/utils 2.5.1 → 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 (192) 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/index11.cjs +1 -1
  5. package/dist/index11.js +16 -20
  6. package/dist/index112.cjs +1 -1
  7. package/dist/index112.js +15 -15
  8. package/dist/index121.cjs +1 -1
  9. package/dist/index121.js +1 -1
  10. package/dist/index130.cjs +1 -1
  11. package/dist/index130.js +1 -1
  12. package/dist/index18.cjs +1 -1
  13. package/dist/index18.js +20 -9
  14. package/dist/index197.cjs +1 -1
  15. package/dist/index197.js +17 -30
  16. package/dist/index22.cjs +1 -1
  17. package/dist/index22.js +84 -51
  18. package/dist/index226.cjs +1 -1
  19. package/dist/index226.js +2 -2
  20. package/dist/index229.cjs +1 -1
  21. package/dist/index229.js +2 -2
  22. package/dist/index230.cjs +1 -1
  23. package/dist/index230.js +1 -1
  24. package/dist/index234.cjs +1 -1
  25. package/dist/index234.js +7 -8
  26. package/dist/index235.cjs +1 -1
  27. package/dist/index235.js +1 -1
  28. package/dist/index236.cjs +1 -1
  29. package/dist/index236.js +1 -1
  30. package/dist/index237.cjs +1 -1
  31. package/dist/index237.js +2 -2
  32. package/dist/index24.cjs +1 -1
  33. package/dist/index24.js +4 -5
  34. package/dist/index249.cjs +1 -1
  35. package/dist/index249.js +3 -3
  36. package/dist/index25.cjs +1 -1
  37. package/dist/index25.js +3 -5
  38. package/dist/index250.cjs +1 -1
  39. package/dist/index250.js +3 -3
  40. package/dist/index256.cjs +1 -1
  41. package/dist/index256.js +17 -12
  42. package/dist/index269.cjs +1 -1
  43. package/dist/index269.js +4 -4
  44. package/dist/index270.cjs +1 -1
  45. package/dist/index270.js +5 -5
  46. package/dist/index271.cjs +1 -1
  47. package/dist/index271.js +27 -21
  48. package/dist/index272.cjs +1 -1
  49. package/dist/index272.js +54 -20
  50. package/dist/index273.cjs +1 -1
  51. package/dist/index273.js +18 -54
  52. package/dist/index274.cjs +1 -1
  53. package/dist/index274.js +10 -34
  54. package/dist/index275.cjs +1 -1
  55. package/dist/index275.js +7 -10
  56. package/dist/index276.cjs +1 -1
  57. package/dist/index276.js +12 -13
  58. package/dist/index277.cjs +1 -1
  59. package/dist/index277.js +11 -12
  60. package/dist/index280.cjs +1 -1
  61. package/dist/index280.js +103 -11
  62. package/dist/index281.cjs +1 -1
  63. package/dist/index281.js +6 -103
  64. package/dist/index282.cjs +1 -1
  65. package/dist/index282.js +243 -5
  66. package/dist/index283.cjs +1 -1
  67. package/dist/index283.js +6 -224
  68. package/dist/index284.cjs +1 -1
  69. package/dist/index284.js +7 -7
  70. package/dist/index285.cjs +1 -1
  71. package/dist/index285.js +27 -7
  72. package/dist/index286.cjs +1 -1
  73. package/dist/index286.js +18 -25
  74. package/dist/index287.cjs +1 -1
  75. package/dist/index287.js +145 -18
  76. package/dist/index288.cjs +1 -1
  77. package/dist/index288.js +3 -146
  78. package/dist/index289.cjs +1 -1
  79. package/dist/index289.js +155 -3
  80. package/dist/index29.cjs +1 -1
  81. package/dist/index29.js +2 -2
  82. package/dist/index290.cjs +1 -1
  83. package/dist/index290.js +7 -138
  84. package/dist/index291.cjs +1 -1
  85. package/dist/index291.js +128 -143
  86. package/dist/index292.cjs +1 -1
  87. package/dist/index292.js +111 -7
  88. package/dist/index293.cjs +2 -1
  89. package/dist/index293.js +116 -95
  90. package/dist/index294.cjs +1 -2
  91. package/dist/index294.js +35 -127
  92. package/dist/index295.cjs +1 -1
  93. package/dist/index295.js +66 -30
  94. package/dist/index296.cjs +1 -1
  95. package/dist/index296.js +2 -79
  96. package/dist/index297.cjs +1 -1
  97. package/dist/index297.js +12 -2
  98. package/dist/index298.cjs +1 -1
  99. package/dist/index298.js +19 -11
  100. package/dist/index299.cjs +1 -1
  101. package/dist/index299.js +68 -19
  102. package/dist/index3.cjs +1 -1
  103. package/dist/index3.js +10 -8
  104. package/dist/index300.cjs +1 -1
  105. package/dist/index300.js +786 -66
  106. package/dist/index301.cjs +1 -1
  107. package/dist/index301.js +134 -684
  108. package/dist/index302.cjs +1 -1
  109. package/dist/index302.js +185 -124
  110. package/dist/index303.cjs +2 -1
  111. package/dist/index303.js +63 -198
  112. package/dist/index304.cjs +1 -2
  113. package/dist/index304.js +7 -66
  114. package/dist/index305.cjs +1 -1
  115. package/dist/index305.js +62 -4
  116. package/dist/index306.cjs +1 -1
  117. package/dist/index306.js +22 -40
  118. package/dist/index307.cjs +1 -1
  119. package/dist/index307.js +5 -7
  120. package/dist/index308.cjs +1 -1
  121. package/dist/index308.js +72 -57
  122. package/dist/index309.cjs +1 -1
  123. package/dist/index309.js +4 -78
  124. package/dist/index310.cjs +1 -1
  125. package/dist/index310.js +195 -4
  126. package/dist/index311.cjs +1 -1
  127. package/dist/index311.js +4 -194
  128. package/dist/index312.cjs +1 -1
  129. package/dist/index312.js +35 -58
  130. package/dist/index313.cjs +2 -1
  131. package/dist/index313.js +40 -43
  132. package/dist/index314.cjs +1 -1
  133. package/dist/index314.js +2 -5
  134. package/dist/index315.cjs +1 -1
  135. package/dist/index315.js +11 -5
  136. package/dist/index316.cjs +1 -1
  137. package/dist/index316.js +20 -2
  138. package/dist/index317.cjs +1 -1
  139. package/dist/index317.js +8 -21
  140. package/dist/index318.cjs +1 -0
  141. package/dist/index318.js +45 -0
  142. package/dist/index319.cjs +1 -0
  143. package/dist/index319.js +69 -0
  144. package/dist/index320.cjs +1 -0
  145. package/dist/index320.js +68 -0
  146. package/dist/index321.cjs +1 -0
  147. package/dist/index321.js +191 -0
  148. package/dist/index322.cjs +1 -0
  149. package/dist/index322.js +79 -0
  150. package/dist/index323.cjs +1 -0
  151. package/dist/index323.js +43 -0
  152. package/dist/index324.cjs +1 -0
  153. package/dist/index324.js +19 -0
  154. package/dist/index325.cjs +1 -0
  155. package/dist/index325.js +16 -0
  156. package/dist/index326.cjs +1 -0
  157. package/dist/index326.js +7 -0
  158. package/dist/index327.cjs +1 -0
  159. package/dist/index327.js +66 -0
  160. package/dist/index328.cjs +1 -0
  161. package/dist/index328.js +7 -0
  162. package/dist/index329.cjs +1 -0
  163. package/dist/index329.js +47 -0
  164. package/dist/index330.cjs +1 -0
  165. package/dist/index330.js +71 -0
  166. package/dist/index331.cjs +1 -0
  167. package/dist/index331.js +4 -0
  168. package/dist/index332.cjs +1 -0
  169. package/dist/index332.js +24 -0
  170. package/dist/index4.cjs +1 -1
  171. package/dist/index4.js +38 -38
  172. package/dist/index55.cjs +1 -1
  173. package/dist/index55.js +1 -1
  174. package/dist/index58.cjs +1 -1
  175. package/dist/index58.js +35 -34
  176. package/dist/index60.cjs +1 -1
  177. package/dist/index60.js +26 -30
  178. package/dist/index61.cjs +1 -1
  179. package/dist/index61.js +13 -9
  180. package/dist/index62.cjs +1 -1
  181. package/dist/index62.js +19 -19
  182. package/dist/index89.cjs +1 -1
  183. package/dist/index89.js +31 -30
  184. package/dist/index9.cjs +1 -1
  185. package/dist/index9.js +2 -2
  186. package/dist/index95.cjs +1 -1
  187. package/dist/index95.js +73 -73
  188. package/dist/src/lib/auth/apikey/apikey.d.ts +1 -1
  189. package/dist/src/lib/auth/auth.types.d.ts +1 -1
  190. package/dist/src/lib/fetcher/fetcher.d.ts +2 -0
  191. package/dist/src/lib/utils.d.ts +1 -0
  192. package/package.json +2 -2
package/dist/index62.js CHANGED
@@ -1,48 +1,48 @@
1
1
  import { textResolverAbi as l, universalResolverResolveAbi as p } from "./index22.js";
2
- import { decodeFunctionResult as A } from "./index175.js";
3
- import { encodeFunctionData as R } from "./index182.js";
4
- import { getChainContractAddress as h } from "./index219.js";
2
+ import { decodeFunctionResult as h } from "./index175.js";
3
+ import { encodeFunctionData as A } from "./index182.js";
4
+ import { getChainContractAddress as R } from "./index219.js";
5
5
  import { toHex as b } from "./index155.js";
6
6
  import { isNullUniversalResolverError as g } from "./index234.js";
7
7
  import { localBatchGatewayUrl as w } from "./index208.js";
8
8
  import { namehash as x } from "./index158.js";
9
- import { packetToBytes as C } from "./index235.js";
10
- import { getAction as y } from "./index32.js";
9
+ import { packetToBytes as y } from "./index235.js";
10
+ import { getAction as C } from "./index32.js";
11
11
  import { readContract as N } from "./index36.js";
12
- async function j(n, t) {
13
- const { blockNumber: s, blockTag: m, key: d, name: o, gatewayUrls: u, strict: f } = t, { chain: e } = n, v = (() => {
14
- if (t.universalResolverAddress)
15
- return t.universalResolverAddress;
16
- if (!e)
12
+ async function j(n, e) {
13
+ const { blockNumber: s, blockTag: m, key: d, name: o, gatewayUrls: u, strict: f } = e, { chain: t } = n, v = (() => {
14
+ if (e.universalResolverAddress)
15
+ return e.universalResolverAddress;
16
+ if (!t)
17
17
  throw new Error("client chain not configured. universalResolverAddress is required.");
18
- return h({
18
+ return R({
19
19
  blockNumber: s,
20
- chain: e,
20
+ chain: t,
21
21
  contract: "ensUniversalResolver"
22
22
  });
23
- })(), a = e == null ? void 0 : e.ensTlds;
23
+ })(), a = t == null ? void 0 : t.ensTlds;
24
24
  if (a && !a.some((r) => o.endsWith(r)))
25
25
  return null;
26
26
  try {
27
27
  const r = {
28
28
  address: v,
29
29
  abi: p,
30
- functionName: "resolve",
31
30
  args: [
32
- b(C(o)),
33
- R({
31
+ b(y(o)),
32
+ A({
34
33
  abi: l,
35
34
  functionName: "text",
36
35
  args: [x(o), d]
37
36
  }),
38
37
  u ?? [w]
39
38
  ],
39
+ functionName: "resolveWithGateways",
40
40
  blockNumber: s,
41
41
  blockTag: m
42
- }, i = await y(n, N, "readContract")(r);
42
+ }, i = await C(n, N, "readContract")(r);
43
43
  if (i[0] === "0x")
44
44
  return null;
45
- const c = A({
45
+ const c = h({
46
46
  abi: l,
47
47
  functionName: "text",
48
48
  data: i[0]
@@ -51,7 +51,7 @@ async function j(n, t) {
51
51
  } catch (r) {
52
52
  if (f)
53
53
  throw r;
54
- if (g(r, "resolve"))
54
+ if (g(r))
55
55
  return null;
56
56
  throw r;
57
57
  }
package/dist/index89.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./index22.cjs"),v=require("./index127.cjs"),_=require("./index41.cjs"),x=require("./index132.cjs"),O=require("./index175.cjs"),T=require("./index182.cjs"),B=require("./index219.cjs"),j=require("./index225.cjs"),M=require("./index32.cjs"),Z=require("./index36.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=$;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index22.cjs"),_=require("./index127.cjs"),x=require("./index41.cjs"),O=require("./index132.cjs"),T=require("./index175.cjs"),B=require("./index182.cjs"),L=require("./index219.cjs"),z=require("./index225.cjs"),M=require("./index32.cjs"),Z=require("./index36.cjs");async function $(l,m){var D;const{account:w,authorizationList:j,allowFailure:u=!0,batchSize:k,blockNumber:C,blockTag:p,multicallAddress:R,stateOverride:N}=m,d=m.contracts,q=k??(typeof((D=l.batch)==null?void 0:D.multicall)=="object"&&l.batch.multicall.batchSize||1024);let g=R;if(!g){if(!l.chain)throw new Error("client chain not configured. multicallAddress is required.");g=L.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=B.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=z.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:v.multicall3Abi,account:w,address:g,args:[t],authorizationList:j,blockNumber:C,blockTag:p,functionName:"aggregate3",stateOverride:N}))),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:P,functionName:E,args:F}=d[o.length];try{if(b==="0x")throw new _.AbiDecodingZeroDataError;if(!n)throw new O.RawContractError({data:i});const h=T.decodeFunctionResult({abi:S,args:F,data:i,functionName:E});o.push(u?{result:h,status:"success"}:h)}catch(h){const y=z.getContractError(h,{abi:S,address:P,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 x.BaseError("multicall results mismatch");return o}exports.multicall=$;
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.1",
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
+ }