@gardenfi/utils 2.1.3-beta.1 → 2.1.3-beta.11

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 (149) hide show
  1. package/dist/index104.cjs +1 -1
  2. package/dist/index104.js +1 -1
  3. package/dist/index107.cjs +1 -1
  4. package/dist/index107.js +71 -42
  5. package/dist/index108.cjs +1 -1
  6. package/dist/index108.js +2 -2
  7. package/dist/index110.cjs +1 -1
  8. package/dist/index110.js +1 -1
  9. package/dist/index111.cjs +1 -1
  10. package/dist/index111.js +1 -1
  11. package/dist/index112.cjs +1 -1
  12. package/dist/index112.js +1 -1
  13. package/dist/index113.cjs +1 -1
  14. package/dist/index113.js +1 -1
  15. package/dist/index125.cjs +1 -1
  16. package/dist/index125.js +1 -1
  17. package/dist/index15.cjs +1 -1
  18. package/dist/index15.js +4 -4
  19. package/dist/index166.cjs +1 -1
  20. package/dist/index166.js +36 -34
  21. package/dist/index192.cjs +1 -1
  22. package/dist/index192.js +15 -18
  23. package/dist/index222.cjs +1 -1
  24. package/dist/index222.js +2 -2
  25. package/dist/index225.cjs +1 -1
  26. package/dist/index225.js +43 -43
  27. package/dist/index226.cjs +1 -1
  28. package/dist/index226.js +3 -113
  29. package/dist/index23.cjs +1 -1
  30. package/dist/index23.js +13 -31
  31. package/dist/index231.cjs +1 -1
  32. package/dist/index231.js +1 -1
  33. package/dist/index232.cjs +1 -1
  34. package/dist/index232.js +1 -1
  35. package/dist/index233.cjs +1 -1
  36. package/dist/index233.js +2 -2
  37. package/dist/index24.cjs +1 -1
  38. package/dist/index24.js +58 -32
  39. package/dist/index245.cjs +1 -1
  40. package/dist/index245.js +3 -3
  41. package/dist/index246.cjs +1 -1
  42. package/dist/index246.js +3 -3
  43. package/dist/index247.cjs +1 -2
  44. package/dist/index247.js +13 -24
  45. package/dist/index248.cjs +1 -1
  46. package/dist/index248.js +15 -13
  47. package/dist/index249.cjs +2 -1
  48. package/dist/index249.js +23 -14
  49. package/dist/index25.cjs +16 -1
  50. package/dist/index25.js +113 -11
  51. package/dist/index26.cjs +1 -1
  52. package/dist/index26.js +32 -58
  53. package/dist/index266.cjs +1 -1
  54. package/dist/index266.js +1 -1
  55. package/dist/index27.cjs +1 -1
  56. package/dist/index27.js +31 -13
  57. package/dist/index277.cjs +1 -1
  58. package/dist/index277.js +103 -16
  59. package/dist/index278.cjs +1 -1
  60. package/dist/index278.js +13 -220
  61. package/dist/index279.cjs +1 -1
  62. package/dist/index279.js +214 -6
  63. package/dist/index28.cjs +1 -16
  64. package/dist/index28.js +11 -113
  65. package/dist/index280.cjs +1 -1
  66. package/dist/index280.js +7 -7
  67. package/dist/index281.cjs +1 -1
  68. package/dist/index281.js +7 -27
  69. package/dist/index282.cjs +1 -1
  70. package/dist/index282.js +26 -34
  71. package/dist/index283.cjs +1 -1
  72. package/dist/index283.js +13 -12
  73. package/dist/index284.cjs +1 -1
  74. package/dist/index284.js +89 -51
  75. package/dist/index285.cjs +1 -1
  76. package/dist/index285.js +3 -67
  77. package/dist/index286.cjs +1 -1
  78. package/dist/index286.js +140 -3
  79. package/dist/index287.cjs +1 -1
  80. package/dist/index287.js +143 -128
  81. package/dist/index288.cjs +1 -1
  82. package/dist/index288.js +9 -155
  83. package/dist/index289.cjs +1 -1
  84. package/dist/index289.js +111 -7
  85. package/dist/index290.cjs +2 -1
  86. package/dist/index290.js +116 -95
  87. package/dist/index291.cjs +1 -2
  88. package/dist/index291.js +8 -131
  89. package/dist/index292.cjs +1 -1
  90. package/dist/index292.js +19 -40
  91. package/dist/index293.cjs +1 -1
  92. package/dist/index293.js +43 -2
  93. package/dist/index294.cjs +1 -1
  94. package/dist/index294.js +74 -202
  95. package/dist/index295.cjs +1 -1
  96. package/dist/index295.js +2 -69
  97. package/dist/index296.cjs +1 -1
  98. package/dist/index296.js +68 -11
  99. package/dist/index297.cjs +1 -1
  100. package/dist/index297.js +656 -18
  101. package/dist/index298.cjs +1 -1
  102. package/dist/index298.js +197 -633
  103. package/dist/index299.cjs +1 -1
  104. package/dist/index299.js +78 -73
  105. package/dist/index300.cjs +2 -2
  106. package/dist/index300.js +7 -7
  107. package/dist/index302.cjs +1 -1
  108. package/dist/index302.js +1 -1
  109. package/dist/index303.cjs +1 -1
  110. package/dist/index303.js +2 -2
  111. package/dist/index305.cjs +1 -1
  112. package/dist/index305.js +1 -1
  113. package/dist/index307.cjs +1 -1
  114. package/dist/index307.js +2 -2
  115. package/dist/index308.cjs +1 -1
  116. package/dist/index308.js +1 -1
  117. package/dist/index310.cjs +1 -1
  118. package/dist/index310.js +1 -1
  119. package/dist/index311.cjs +1 -1
  120. package/dist/index311.js +5 -105
  121. package/dist/index312.cjs +1 -1
  122. package/dist/index312.js +2 -5
  123. package/dist/index313.cjs +1 -1
  124. package/dist/index313.js +22 -2
  125. package/dist/index36.cjs +1 -1
  126. package/dist/index36.js +1 -1
  127. package/dist/index43.cjs +1 -1
  128. package/dist/index43.js +40 -21
  129. package/dist/index44.cjs +1 -1
  130. package/dist/index44.js +24 -24
  131. package/dist/index58.cjs +1 -1
  132. package/dist/index58.js +98 -97
  133. package/dist/index79.cjs +1 -1
  134. package/dist/index79.js +1 -1
  135. package/dist/index84.cjs +1 -1
  136. package/dist/index84.js +53 -51
  137. package/dist/index9.cjs +1 -1
  138. package/dist/index9.js +4 -4
  139. package/dist/index90.cjs +1 -1
  140. package/dist/index90.js +44 -42
  141. package/dist/index92.cjs +1 -1
  142. package/dist/index92.js +15 -15
  143. package/package.json +1 -1
  144. package/dist/index314.cjs +0 -1
  145. package/dist/index314.js +0 -22
  146. package/dist/index315.cjs +0 -1
  147. package/dist/index315.js +0 -74
  148. package/dist/index316.cjs +0 -1
  149. package/dist/index316.js +0 -24
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/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:b="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,b,y,g,o,w]);return h.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)});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;
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;
package/dist/index92.js CHANGED
@@ -4,7 +4,7 @@ import { poll as N } from "./index40.js";
4
4
  import { stringify as S } from "./index42.js";
5
5
  import { getBlock as p } from "./index68.js";
6
6
  function j(e, { blockTag: b = "latest", emitMissed: y = !1, emitOnBegin: m = !1, onBlock: k, onError: u, includeTransactions: h, poll: d, pollingInterval: w = e.pollingInterval }) {
7
- const g = typeof d < "u" ? d : !(e.transport.type === "webSocket" || e.transport.type === "fallback" && e.transport.transports[0].config.type === "webSocket"), f = h ?? !1;
7
+ const g = typeof d < "u" ? d : !(e.transport.type === "webSocket" || e.transport.type === "fallback" && e.transport.transports[0].config.type === "webSocket"), o = h ?? !1;
8
8
  let t;
9
9
  return g ? (() => {
10
10
  const a = S([
@@ -13,24 +13,24 @@ function j(e, { blockTag: b = "latest", emitMissed: y = !1, emitOnBegin: m = !1,
13
13
  b,
14
14
  y,
15
15
  m,
16
- f,
16
+ o,
17
17
  w
18
18
  ]);
19
19
  return B(a, { onBlock: k, onError: u }, (s) => N(async () => {
20
- var o;
20
+ var c;
21
21
  try {
22
22
  const r = await i(e, p, "getBlock")({
23
23
  blockTag: b,
24
- includeTransactions: f
24
+ includeTransactions: o
25
25
  });
26
26
  if (r.number !== null && (t == null ? void 0 : t.number) != null) {
27
27
  if (r.number === t.number)
28
28
  return;
29
29
  if (r.number - t.number > 1 && y)
30
- for (let c = (t == null ? void 0 : t.number) + 1n; c < r.number; c++) {
30
+ for (let f = (t == null ? void 0 : t.number) + 1n; f < r.number; f++) {
31
31
  const n = await i(e, p, "getBlock")({
32
- blockNumber: c,
33
- includeTransactions: f
32
+ blockNumber: f,
33
+ includeTransactions: o
34
34
  });
35
35
  s.onBlock(n, t), t = n;
36
36
  }
@@ -41,36 +41,36 @@ function j(e, { blockTag: b = "latest", emitMissed: y = !1, emitOnBegin: m = !1,
41
41
  // We don't want to emit blocks in the past.
42
42
  r.number !== null && r.number > t.number) && (s.onBlock(r, t), t = r);
43
43
  } catch (r) {
44
- (o = s.onError) == null || o.call(s, r);
44
+ (c = s.onError) == null || c.call(s, r);
45
45
  }
46
46
  }, {
47
47
  emitOnBegin: m,
48
48
  interval: w
49
49
  }));
50
50
  })() : (() => {
51
- let a = !0, s = !0, o = () => a = !1;
51
+ let a = !0, s = !0, c = () => a = !1;
52
52
  return (async () => {
53
53
  try {
54
54
  m && i(e, p, "getBlock")({
55
55
  blockTag: b,
56
- includeTransactions: f
56
+ includeTransactions: o
57
57
  }).then((n) => {
58
58
  a && s && (k(n, void 0), s = !1);
59
- });
59
+ }).catch(u);
60
60
  const r = (() => {
61
61
  if (e.transport.type === "fallback") {
62
62
  const n = e.transport.transports.find((l) => l.config.type === "webSocket");
63
63
  return n ? n.value : e.transport;
64
64
  }
65
65
  return e.transport;
66
- })(), { unsubscribe: c } = await r.subscribe({
66
+ })(), { unsubscribe: f } = await r.subscribe({
67
67
  params: ["newHeads"],
68
68
  async onData(n) {
69
69
  if (!a)
70
70
  return;
71
71
  const l = await i(e, p, "getBlock")({
72
72
  blockNumber: n.blockNumber,
73
- includeTransactions: f
73
+ includeTransactions: o
74
74
  }).catch(() => {
75
75
  });
76
76
  a && (k(l, t), s = !1, t = l);
@@ -79,11 +79,11 @@ function j(e, { blockTag: b = "latest", emitMissed: y = !1, emitOnBegin: m = !1,
79
79
  u == null || u(n);
80
80
  }
81
81
  });
82
- o = c, a || o();
82
+ c = f, a || c();
83
83
  } catch (r) {
84
84
  u == null || u(r);
85
85
  }
86
- })(), () => o();
86
+ })(), () => c();
87
87
  })();
88
88
  }
89
89
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/utils",
3
- "version": "2.1.3-beta.1",
3
+ "version": "2.1.3-beta.11",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "vite build",
package/dist/index314.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=BigInt(2**32-1),c=BigInt(32);function u(t,o=!1){return o?{h:Number(t&l),l:Number(t>>c&l)}:{h:Number(t>>c&l)|0,l:Number(t&l)|0}}function B(t,o=!1){const r=t.length;let n=new Uint32Array(r),i=new Uint32Array(r);for(let e=0;e<r;e++){const{h:f,l:s}=u(t[e],o);[n[e],i[e]]=[f,s]}return[n,i]}const g=(t,o,r)=>t<<r|o>>>32-r,m=(t,o,r)=>o<<r|t>>>32-r,S=(t,o,r)=>o<<r-32|t>>>64-r,a=(t,o,r)=>t<<r-32|o>>>64-r;exports.fromBig=u;exports.rotlBH=S;exports.rotlBL=a;exports.rotlSH=g;exports.rotlSL=m;exports.split=B;
package/dist/index314.js DELETED
@@ -1,22 +0,0 @@
1
- const o = /* @__PURE__ */ BigInt(4294967295), i = /* @__PURE__ */ BigInt(32);
2
- function s(t, r = !1) {
3
- return r ? { h: Number(t & o), l: Number(t >> i & o) } : { h: Number(t >> i & o) | 0, l: Number(t & o) | 0 };
4
- }
5
- function h(t, r = !1) {
6
- const n = t.length;
7
- let l = new Uint32Array(n), c = new Uint32Array(n);
8
- for (let e = 0; e < n; e++) {
9
- const { h: u, l: f } = s(t[e], r);
10
- [l[e], c[e]] = [u, f];
11
- }
12
- return [l, c];
13
- }
14
- const m = (t, r, n) => t << n | r >>> 32 - n, A = (t, r, n) => r << n | t >>> 32 - n, B = (t, r, n) => r << n - 32 | t >>> 64 - n, a = (t, r, n) => t << n - 32 | r >>> 64 - n;
15
- export {
16
- s as fromBig,
17
- B as rotlBH,
18
- a as rotlBL,
19
- m as rotlSH,
20
- A as rotlSL,
21
- h as split
22
- };
package/dist/index315.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function o(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function y(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function r(e,...t){if(!o(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function l(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function h(e,t){r(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function p(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function w(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const i=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function f(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function u(e){for(let t=0;t<e.length;t++)e[t]=f(e[t]);return e}const g=i?e=>e:u;function s(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function c(e){return typeof e=="string"&&(e=s(e)),r(e),e}class b{}function x(e){const t=a=>e().update(c(a)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}exports.Hash=b;exports.abytes=r;exports.aexists=l;exports.anumber=y;exports.aoutput=h;exports.byteSwap=f;exports.byteSwap32=u;exports.clean=w;exports.createHasher=x;exports.isBytes=o;exports.isLE=i;exports.swap32IfBE=g;exports.toBytes=c;exports.u32=p;exports.utf8ToBytes=s;
package/dist/index315.js DELETED
@@ -1,74 +0,0 @@
1
- /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2
- function f(e) {
3
- return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
4
- }
5
- function l(e) {
6
- if (!Number.isSafeInteger(e) || e < 0)
7
- throw new Error("positive integer expected, got " + e);
8
- }
9
- function r(e, ...t) {
10
- if (!f(e))
11
- throw new Error("Uint8Array expected");
12
- if (t.length > 0 && !t.includes(e.length))
13
- throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
14
- }
15
- function y(e, t = !0) {
16
- if (e.destroyed)
17
- throw new Error("Hash instance has been destroyed");
18
- if (t && e.finished)
19
- throw new Error("Hash#digest() has already been called");
20
- }
21
- function w(e, t) {
22
- r(e);
23
- const n = t.outputLen;
24
- if (e.length < n)
25
- throw new Error("digestInto() expects output buffer of length at least " + n);
26
- }
27
- function p(e) {
28
- return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4));
29
- }
30
- function a(...e) {
31
- for (let t = 0; t < e.length; t++)
32
- e[t].fill(0);
33
- }
34
- const i = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
35
- function u(e) {
36
- return e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255;
37
- }
38
- function c(e) {
39
- for (let t = 0; t < e.length; t++)
40
- e[t] = u(e[t]);
41
- return e;
42
- }
43
- const g = i ? (e) => e : c;
44
- function s(e) {
45
- if (typeof e != "string")
46
- throw new Error("string expected");
47
- return new Uint8Array(new TextEncoder().encode(e));
48
- }
49
- function h(e) {
50
- return typeof e == "string" && (e = s(e)), r(e), e;
51
- }
52
- class x {
53
- }
54
- function b(e) {
55
- const t = (o) => e().update(h(o)).digest(), n = e();
56
- return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
57
- }
58
- export {
59
- x as Hash,
60
- r as abytes,
61
- y as aexists,
62
- l as anumber,
63
- w as aoutput,
64
- u as byteSwap,
65
- c as byteSwap32,
66
- a as clean,
67
- b as createHasher,
68
- f as isBytes,
69
- i as isLE,
70
- g as swap32IfBE,
71
- h as toBytes,
72
- p as u32,
73
- s as utf8ToBytes
74
- };
package/dist/index316.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class i extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&t!==void 0&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const s=this.keys().next().value;s&&this.delete(s)}return this}}exports.LruMap=i;
package/dist/index316.js DELETED
@@ -1,24 +0,0 @@
1
- class r extends Map {
2
- constructor(e) {
3
- super(), Object.defineProperty(this, "maxSize", {
4
- enumerable: !0,
5
- configurable: !0,
6
- writable: !0,
7
- value: void 0
8
- }), this.maxSize = e;
9
- }
10
- get(e) {
11
- const t = super.get(e);
12
- return super.has(e) && t !== void 0 && (this.delete(e), super.set(e, t)), t;
13
- }
14
- set(e, t) {
15
- if (super.set(e, t), this.maxSize && this.size > this.maxSize) {
16
- const s = this.keys().next().value;
17
- s && this.delete(s);
18
- }
19
- return this;
20
- }
21
- }
22
- export {
23
- r as LruMap
24
- };