@hinkal/common 0.1.32 → 0.1.34

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 (108) hide show
  1. package/constants/deploy-data/deploy-data-localhost.json.cjs +1 -1
  2. package/constants/deploy-data/deploy-data-localhost.json.mjs +4 -4
  3. package/constants/fees.constants.cjs +1 -1
  4. package/constants/fees.constants.mjs +22 -22
  5. package/constants/token-data/localhostRegistry.json.cjs +1 -1
  6. package/constants/token-data/localhostRegistry.json.mjs +18 -44
  7. package/crypto/babyJub.cjs +1 -1
  8. package/crypto/babyJub.mjs +4 -4
  9. package/crypto/poseidon.cjs +1 -1
  10. package/crypto/poseidon.mjs +12 -12
  11. package/crypto/preProcessing.cjs +1 -1
  12. package/crypto/preProcessing.mjs +5 -7
  13. package/data-structures/Hinkal/Hinkal.cjs +1 -1
  14. package/data-structures/Hinkal/Hinkal.d.ts +1 -0
  15. package/data-structures/Hinkal/Hinkal.mjs +16 -16
  16. package/data-structures/Hinkal/IHinkal.d.ts +2 -1
  17. package/data-structures/Hinkal/hinkalActionBeefy.cjs +1 -1
  18. package/data-structures/Hinkal/hinkalActionBeefy.mjs +18 -20
  19. package/data-structures/Hinkal/hinkalActionConvex.cjs +1 -1
  20. package/data-structures/Hinkal/hinkalActionConvex.mjs +18 -21
  21. package/data-structures/Hinkal/hinkalActionLidoEth.cjs +1 -1
  22. package/data-structures/Hinkal/hinkalActionLidoEth.mjs +31 -31
  23. package/data-structures/Hinkal/hinkalActionPendle.cjs +1 -1
  24. package/data-structures/Hinkal/hinkalActionPendle.mjs +77 -80
  25. package/data-structures/Hinkal/hinkalActionPendleLP.cjs +1 -1
  26. package/data-structures/Hinkal/hinkalActionPendleLP.mjs +34 -34
  27. package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
  28. package/data-structures/Hinkal/hinkalActionStake.mjs +49 -53
  29. package/data-structures/Hinkal/hinkalActionVolatile.cjs +1 -1
  30. package/data-structures/Hinkal/hinkalActionVolatile.mjs +38 -44
  31. package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
  32. package/data-structures/Hinkal/hinkalDeposit.mjs +27 -28
  33. package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
  34. package/data-structures/Hinkal/hinkalPrivateWallet.mjs +8 -11
  35. package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
  36. package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +9 -8
  37. package/data-structures/crypto-keys/keys.cjs +1 -1
  38. package/data-structures/crypto-keys/keys.mjs +7 -6
  39. package/data-structures/event-service/AbstractAccessTokenSnapshotService.cjs +1 -1
  40. package/data-structures/event-service/AbstractAccessTokenSnapshotService.mjs +6 -9
  41. package/data-structures/event-service/AbstractCommitmentsSnapshotService.cjs +1 -4
  42. package/data-structures/event-service/AbstractCommitmentsSnapshotService.mjs +18 -26
  43. package/data-structures/snapshot/ClientAccessTokenSnapshotService.cjs +1 -1
  44. package/data-structures/snapshot/ClientAccessTokenSnapshotService.mjs +9 -12
  45. package/data-structures/snapshot/ClientCommitmentsSnapshotService.cjs +1 -1
  46. package/data-structures/snapshot/ClientCommitmentsSnapshotService.mjs +9 -12
  47. package/data-structures/snapshot/ClientNullifierSnapshotService.cjs +1 -1
  48. package/data-structures/snapshot/ClientNullifierSnapshotService.mjs +3 -6
  49. package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
  50. package/data-structures/transactions-manager/TransactionsManager.mjs +67 -75
  51. package/data-structures/transactions-manager/history/getVolatileData.cjs +1 -1
  52. package/data-structures/transactions-manager/history/getVolatileData.mjs +13 -13
  53. package/data-structures/volatile-helper/VolatileHelper.cjs +1 -1
  54. package/data-structures/volatile-helper/VolatileHelper.mjs +60 -60
  55. package/error-handling/error-codes.constants.cjs +1 -1
  56. package/error-handling/error-codes.constants.d.ts +2 -0
  57. package/error-handling/error-codes.constants.mjs +2 -0
  58. package/functions/pre-transaction/getFlatFees.cjs +1 -1
  59. package/functions/pre-transaction/getFlatFees.mjs +42 -42
  60. package/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
  61. package/functions/pre-transaction/outputUtxoProcessing.mjs +5 -8
  62. package/functions/pre-transaction/process-gas-estimates.cjs +1 -1
  63. package/functions/pre-transaction/process-gas-estimates.mjs +17 -26
  64. package/functions/pre-transaction/processAmountChanges.cjs +1 -1
  65. package/functions/pre-transaction/processAmountChanges.mjs +10 -13
  66. package/functions/protocols/pendle.helpers.cjs +1 -1
  67. package/functions/protocols/pendle.helpers.mjs +37 -39
  68. package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
  69. package/functions/snarkjs/constructGeneralZkProof.mjs +35 -37
  70. package/functions/staking/index.cjs +1 -1
  71. package/functions/staking/index.mjs +22 -24
  72. package/functions/utils/cacheFunctions.cjs +1 -1
  73. package/functions/utils/cacheFunctions.mjs +27 -30
  74. package/functions/utils/index.d.ts +1 -0
  75. package/functions/utils/process.utils.cjs +1 -1
  76. package/functions/utils/process.utils.mjs +16 -2
  77. package/functions/utils/resolve-sync.utils.cjs +1 -1
  78. package/functions/utils/resolve-sync.utils.d.ts +0 -1
  79. package/functions/utils/resolve-sync.utils.mjs +3 -12
  80. package/functions/web3/events/getShieldedBalance.cjs +2 -2
  81. package/functions/web3/events/getShieldedBalance.mjs +25 -25
  82. package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
  83. package/functions/web3/functionCalls/transactCallDirect.mjs +15 -15
  84. package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
  85. package/functions/web3/functionCalls/transactCallRelayer.mjs +2 -2
  86. package/functions/web3/odosAPI.cjs +1 -1
  87. package/functions/web3/odosAPI.mjs +11 -14
  88. package/functions/web3/oneInchAPI.cjs +1 -1
  89. package/functions/web3/oneInchAPI.mjs +7 -10
  90. package/functions/web3/runContractFunction.cjs +1 -1
  91. package/functions/web3/runContractFunction.mjs +35 -38
  92. package/functions/web3/uniswapAPI.cjs +1 -1
  93. package/functions/web3/uniswapAPI.mjs +30 -33
  94. package/index.cjs +1 -1
  95. package/index.mjs +281 -277
  96. package/package.json +3 -5
  97. package/providers/prepareEthersHinkal.cjs +1 -1
  98. package/providers/prepareEthersHinkal.mjs +5 -4
  99. package/providers/prepareWagmiv1Hinkal.cjs +1 -1
  100. package/providers/prepareWagmiv1Hinkal.mjs +5 -4
  101. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
  102. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
  103. package/webworker/snarkjsWorker/snarkjsWorkerLogic.cjs +1 -1
  104. package/webworker/snarkjsWorker/snarkjsWorkerLogic.mjs +16 -17
  105. package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
  106. package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
  107. package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
  108. package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
@@ -1,57 +1,54 @@
1
- import { logError as f } from "../../error-handling/logError.mjs";
2
- import { serializeDecodedTxs as m, deserializeDecodedTxs as S } from "./getDataFromTransaction.mjs";
3
- import { set as p, get as x } from "idb-keyval";
1
+ import { serializeDecodedTxs as C, deserializeDecodedTxs as S } from "./getDataFromTransaction.mjs";
2
+ import { set as d, get as m } from "idb-keyval";
4
3
  const y = {
5
4
  encryptedOutputs: [],
6
5
  lastOutput: ""
7
- }, h = (e, t) => {
6
+ }, l = (e, t) => {
8
7
  const r = e.substring(0, 25), s = t.substring(0, 25);
9
8
  return { shortPublicKey: r, shortHinkalAddress: s };
10
- }, u = /* @__PURE__ */ new Map(), O = (e, t, r) => {
9
+ }, u = /* @__PURE__ */ new Map(), k = (e, t, r) => {
11
10
  if (!e || !t || !r)
12
11
  throw Error("GetHinkalCache: incorrect arguments");
13
- const { shortPublicKey: s, shortHinkalAddress: o } = h(t, r);
12
+ const { shortPublicKey: s, shortHinkalAddress: o } = l(t, r);
14
13
  return JSON.parse(
15
14
  typeof localStorage < "u" ? localStorage.getItem(`hinkalCache-${e}-${s}-${o}`) ?? JSON.stringify(y) : u.get(`hinkalCache-${e}-${s}-${o}`) ?? JSON.stringify(y)
16
15
  );
17
- }, d = (e, t, r, s) => {
16
+ }, p = (e, t, r, s) => {
18
17
  if (!t || !r || !s)
19
18
  throw Error("SetHinkalCache: incorrect arguments");
20
- const { shortPublicKey: o, shortHinkalAddress: a } = h(r, s);
19
+ const { shortPublicKey: o, shortHinkalAddress: a } = l(r, s);
21
20
  typeof localStorage < "u" ? localStorage.setItem(`hinkalCache-${t}-${o}-${a}`, JSON.stringify(e)) : u.set(`hinkalCache-${t}-${o}-${a}`, JSON.stringify(e));
22
- }, w = (e, t, r) => {
23
- d(y, e, t, r);
24
- }, C = (e, t, r) => `txsCache-${e}-${t}-${r}`, J = async (e, t, r, s, o) => {
21
+ }, T = (e, t, r) => {
22
+ p(y, e, t, r);
23
+ }, f = (e, t, r) => `txsCache-${e}-${t}-${r}`, O = async (e, t, r, s, o) => {
25
24
  if (!t || !r || !s)
26
25
  throw Error("saveTxsCache: incorrect arguments");
27
- const { shortPublicKey: a, shortHinkalAddress: c } = h(r, s), l = m(e);
28
- f("saveTxsCache before saving", { serializedTxs: l });
29
- const n = C(t, a, c), i = JSON.stringify({ serializedTxs: l, lastHash: o });
26
+ const { shortPublicKey: a, shortHinkalAddress: n } = l(r, s), g = C(e), c = f(t, a, n), h = JSON.stringify({ serializedTxs: g, lastHash: o });
30
27
  try {
31
- await p(n, i);
28
+ await d(c, h);
32
29
  } catch {
33
- localStorage.setItem(n, i);
30
+ localStorage.setItem(c, h);
34
31
  }
35
- }, $ = { serializedTxs: [], lastHash: "" }, N = async (e, t, r) => {
32
+ }, x = { serializedTxs: [], lastHash: "" }, w = async (e, t, r) => {
36
33
  if (!e || !t || !r)
37
34
  throw Error("loadTxsCache: incorrect arguments");
38
- const { shortPublicKey: s, shortHinkalAddress: o } = h(t, r), a = C(e, s, o);
39
- let c;
35
+ const { shortPublicKey: s, shortHinkalAddress: o } = l(t, r), a = f(e, s, o);
36
+ let n;
40
37
  try {
41
- const g = await x(a);
42
- if (!g)
38
+ const i = await m(a);
39
+ if (!i)
43
40
  throw new Error("Empty indexedDB cache");
44
- c = g;
41
+ n = i;
45
42
  } catch {
46
- c = localStorage.getItem(a);
43
+ n = localStorage.getItem(a);
47
44
  }
48
- const { serializedTxs: l, lastHash: n } = JSON.parse(c ?? JSON.stringify($)), i = l.map((g) => S(g));
49
- return f("loadTxsCache ", { decodedTxs: i, lastHash: n }), { decodedTxs: i, lastHash: n === "" ? void 0 : n };
45
+ const { serializedTxs: g, lastHash: c } = JSON.parse(n ?? JSON.stringify(x));
46
+ return { decodedTxs: g.map((i) => S(i)), lastHash: c === "" ? void 0 : c };
50
47
  };
51
48
  export {
52
- O as getHinkalCache,
53
- N as loadTxsCache,
54
- w as resetCache,
55
- J as saveTxsCache,
56
- d as setHinkalCache
49
+ k as getHinkalCache,
50
+ w as loadTxsCache,
51
+ T as resetCache,
52
+ O as saveTxsCache,
53
+ p as setHinkalCache
57
54
  };
@@ -17,3 +17,4 @@ export * from './nickname.utils';
17
17
  export * from './caseInsensitive.utils';
18
18
  export * from './time.utils';
19
19
  export * from './volatile-patcher.utils';
20
+ export * from './process.utils';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=()=>typeof process<"u"&&process?.release?.name==="node";exports.isOnServer=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=()=>typeof process<"u"&&process?.release?.name==="node",u=()=>typeof window<"u",s=e=>new Promise(t=>{setTimeout(t,e)});function c(e,t){let n;return function(...o){const i=()=>{clearTimeout(n),e(...o)};clearTimeout(n),n=setTimeout(i,t)}}exports.debounce=c;exports.isOnClient=u;exports.isOnServer=r;exports.wait=s;
@@ -1,4 +1,18 @@
1
- const e = () => typeof process < "u" && process?.release?.name === "node";
1
+ const u = () => typeof process < "u" && process?.release?.name === "node", s = () => typeof window < "u", c = (e) => new Promise((t) => {
2
+ setTimeout(t, e);
3
+ });
4
+ function d(e, t) {
5
+ let n;
6
+ return function(...o) {
7
+ const i = () => {
8
+ clearTimeout(n), e(...o);
9
+ };
10
+ clearTimeout(n), n = setTimeout(i, t);
11
+ };
12
+ }
2
13
  export {
3
- e as isOnServer
14
+ d as debounce,
15
+ s as isOnClient,
16
+ u as isOnServer,
17
+ c as wait
4
18
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=t=>t.reduce((e,o)=>e.then(()=>o()),Promise.resolve()),i=(t,e,o)=>{const r=[];if(o){let n=t;for(;n<=e;){const s=Math.min(n+o-1,e);r.push({from:n,to:s}),n=s+1}}else r.push({from:t,to:e});return r},u=(t,e=100)=>new Promise((o,r)=>{setTimeout(async()=>{try{await t(),o(0)}catch(n){r(n)}},e)});exports.getSequence=i;exports.promisify=u;exports.resolveSync=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=t=>t.reduce((e,n)=>e.then(()=>n()),Promise.resolve()),u=(t,e,n)=>{const r=[];if(n){let o=t;for(;o<=e;){const s=Math.min(o+n-1,e);r.push({from:o,to:s}),o=s+1}}else r.push({from:t,to:e});return r};exports.getSequence=u;exports.resolveSync=c;
@@ -3,4 +3,3 @@ export declare const getSequence: (fromBlockNumber: number, lastBlockNumber: num
3
3
  from: number;
4
4
  to: number;
5
5
  }[];
6
- export declare const promisify: (callback: () => Promise<any>, timeout?: number) => Promise<unknown>;
@@ -1,4 +1,4 @@
1
- const c = (t) => t.reduce((e, n) => e.then(() => n()), Promise.resolve()), i = (t, e, n) => {
1
+ const c = (t) => t.reduce((e, n) => e.then(() => n()), Promise.resolve()), h = (t, e, n) => {
2
2
  const s = [];
3
3
  if (n) {
4
4
  let o = t;
@@ -15,17 +15,8 @@ const c = (t) => t.reduce((e, n) => e.then(() => n()), Promise.resolve()), i = (
15
15
  to: e
16
16
  });
17
17
  return s;
18
- }, h = (t, e = 100) => new Promise((n, s) => {
19
- setTimeout(async () => {
20
- try {
21
- await t(), n(0);
22
- } catch (o) {
23
- s(o);
24
- }
25
- }, e);
26
- });
18
+ };
27
19
  export {
28
- i as getSequence,
29
- h as promisify,
20
+ h as getSequence,
30
21
  c as resolveSync
31
22
  };
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("async-mutex"),q=require("../../../constants/token-data/ERC20Registry.cjs"),I=require("../../utils/erc20tokenFunctions.cjs"),p=require("../../utils/caseInsensitive.utils.cjs"),k=require("../../utils/volatile-patcher.utils.cjs"),U=require("../../../data-structures/utxo/Utxo.cjs"),w=require("../../../data-structures/custom-token-registry/CustomTokenRegistry.cjs"),x=require("../../../data-structures/volatile-helper/VolatileHelper.cjs"),P=require("../etherFunctions.cjs"),S=require("../../../error-handling/customErrors/ErrorWithAmount.cjs"),y=require("./getInputUtxoAndBalance.cjs"),b=new A.Mutex,v=async a=>{const r=await b.acquire(),{inputUtxos:c}=await y.getInputUtxoAndBalance({hinkal:a,sliceIfMore6:!1}),n=a.getCurrentChainId(),u=[...q.getERC20Registry(n),...w.customTokenRegistry.getCustomTokens(n)];await k.patchRegistry(n);const h=u.map(e=>({token:e,balance:c.reduce((t,i)=>{const s=e.isVolatile?e.sharedAddress:e.erc20TokenAddress;return p.caseInsensitiveEqual(s,i.erc20TokenAddress)?t+i.amount:t},0n),timestamp:c.filter(t=>p.caseInsensitiveEqual(t.erc20TokenAddress,e.erc20TokenAddress))[0]?.timeStamp,nfts:c.filter(t=>p.caseInsensitiveEqual(t.erc20TokenAddress,e.erc20TokenAddress)&&t.tokenId!==0).map(t=>({tokenId:t.tokenId,timestamp:t.timeStamp}))})),m=await Promise.all(h.map(async e=>{if(!e.token.isVolatile)return e;e.token?.sharedAddress||console.log("VolatileToken must have a corresponding sharedAddress");let t=0n;return e.balance>0n&&(t=await x.VolatileHelper.getVolatileTokenBalance(n,e.token.sharedAddress,e.balance)),{...e,balance:BigInt(t)}}));return r(),m},E=async(a,r,c,n=6,u=r.map(()=>0),h=!1)=>{const{userKeys:m}=a,e=[],t=[];let i=0;for(let s=0;s<r.length;s+=1)if(h===!1){const{inputUtxos:o}=await y.getInputUtxoAndBalance({hinkal:a,erc20TokenAddress:r[s],tokenId:u[s],sliceIfMore6:!1});i=Math.max(o.length,i),t.push(o)}else t.push([]);return console.log({maxUtxoNum:i}),i===2?t:(t.forEach((s,o)=>{if(s.length>n){const l=s.slice(0,n),d=l.reduce((g,f)=>g+f.amount,0n);if(c[o]<0n&&d<-c[o]){const g=I.getERC20Token(r[o],a.getCurrentChainId()),f=Number(P.getAmountWithPrecision(d,g,2)),T=`Unfortunately your transaction did not go through due to UTXOs limitations.
2
- Please try again with ${g.symbol}`;throw new S.ErrorWithAmount(f,T)}e.push(l)}else if(s.length<=n){const l=[...s];let d=n-s.length;for(;d>0;)d-=1,l.push(new U.Utxo({amount:0n,erc20TokenAddress:r[o],shieldedPrivateKey:m.getShieldedPrivateKey(),tokenId:u[o]}));e.push(l)}}),e)};exports.addPaddingToUtxos=E;exports.getShieldedBalance=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("async-mutex"),q=require("../../../constants/token-data/ERC20Registry.cjs"),I=require("../../utils/erc20tokenFunctions.cjs"),p=require("../../utils/caseInsensitive.utils.cjs"),k=require("../../utils/volatile-patcher.utils.cjs"),U=require("../../../data-structures/utxo/Utxo.cjs"),w=require("../../../data-structures/custom-token-registry/CustomTokenRegistry.cjs"),x=require("../../../data-structures/volatile-helper/VolatileHelper.cjs"),P=require("../etherFunctions.cjs"),S=require("../../../error-handling/customErrors/ErrorWithAmount.cjs"),y=require("./getInputUtxoAndBalance.cjs"),b=new A.Mutex,v=async i=>{const r=await b.acquire(),{inputUtxos:a}=await y.getInputUtxoAndBalance({hinkal:i,sliceIfMore6:!1}),n=i.getCurrentChainId(),u=[...q.getERC20Registry(n),...w.customTokenRegistry.getCustomTokens(n)];await k.patchRegistry(n);const h=u.map(e=>({token:e,balance:a.reduce((t,c)=>{const s=e.isVolatile?e.sharedAddress:e.erc20TokenAddress;return p.caseInsensitiveEqual(s,c.erc20TokenAddress)?t+c.amount:t},0n),timestamp:a.filter(t=>p.caseInsensitiveEqual(t.erc20TokenAddress,e.erc20TokenAddress))[0]?.timeStamp,nfts:a.filter(t=>p.caseInsensitiveEqual(t.erc20TokenAddress,e.erc20TokenAddress)&&t.tokenId!==0).map(t=>({tokenId:t.tokenId,timestamp:t.timeStamp}))})),m=await Promise.all(h.map(async e=>{if(!e.token.isVolatile)return e;e.token?.sharedAddress||console.log("VolatileToken must have a corresponding sharedAddress");let t=0n;return e.balance>0n&&(t=await x.VolatileHelper.getVolatileTokenBalance(n,e.token.sharedAddress,e.balance)),{...e,balance:BigInt(t)}}));return r(),m},E=async(i,r,a,n=6,u=r.map(()=>0),h=!1)=>{const{userKeys:m}=i,e=[],t=[];let c=0;for(let s=0;s<r.length;s+=1)if(h===!1){const{inputUtxos:o}=await y.getInputUtxoAndBalance({hinkal:i,erc20TokenAddress:r[s],tokenId:u[s],sliceIfMore6:!1});c=Math.max(o.length,c),t.push(o)}else t.push([]);return c===2?t:(t.forEach((s,o)=>{if(s.length>n){const d=s.slice(0,n),l=d.reduce((g,f)=>g+f.amount,0n);if(a[o]<0n&&l<-a[o]){const g=I.getERC20Token(r[o],i.getCurrentChainId()),f=Number(P.getAmountWithPrecision(l,g,2)),T=`Unfortunately your transaction did not go through due to UTXOs limitations.
2
+ Please try again with ${g.symbol}`;throw new S.ErrorWithAmount(f,T)}e.push(d)}else if(s.length<=n){const d=[...s];let l=n-s.length;for(;l>0;)l-=1,d.push(new U.Utxo({amount:0n,erc20TokenAddress:r[o],shieldedPrivateKey:m.getShieldedPrivateKey(),tokenId:u[o]}));e.push(d)}}),e)};exports.addPaddingToUtxos=E;exports.getShieldedBalance=v;
@@ -1,7 +1,7 @@
1
1
  import { Mutex as A } from "async-mutex";
2
2
  import { getERC20Registry as w } from "../../../constants/token-data/ERC20Registry.mjs";
3
3
  import { getERC20Token as k } from "../../utils/erc20tokenFunctions.mjs";
4
- import { caseInsensitiveEqual as h } from "../../utils/caseInsensitive.utils.mjs";
4
+ import { caseInsensitiveEqual as g } from "../../utils/caseInsensitive.utils.mjs";
5
5
  import { patchRegistry as I } from "../../utils/volatile-patcher.utils.mjs";
6
6
  import { Utxo as U } from "../../../data-structures/utxo/Utxo.mjs";
7
7
  import { customTokenRegistry as P } from "../../../data-structures/custom-token-registry/CustomTokenRegistry.mjs";
@@ -9,20 +9,20 @@ import { VolatileHelper as b } from "../../../data-structures/volatile-helper/Vo
9
9
  import { getAmountWithPrecision as x } from "../etherFunctions.mjs";
10
10
  import { ErrorWithAmount as S } from "../../../error-handling/customErrors/ErrorWithAmount.mjs";
11
11
  import { getInputUtxoAndBalance as T } from "./getInputUtxoAndBalance.mjs";
12
- const C = new A(), O = async (a) => {
13
- const n = await C.acquire(), { inputUtxos: d } = await T({ hinkal: a, sliceIfMore6: !1 }), s = a.getCurrentChainId(), c = [...w(s), ...P.getCustomTokens(s)];
12
+ const C = new A(), O = async (i) => {
13
+ const n = await C.acquire(), { inputUtxos: a } = await T({ hinkal: i, sliceIfMore6: !1 }), s = i.getCurrentChainId(), c = [...w(s), ...P.getCustomTokens(s)];
14
14
  await I(s);
15
15
  const p = c.map((e) => ({
16
16
  token: e,
17
- balance: d.reduce((t, i) => {
17
+ balance: a.reduce((t, d) => {
18
18
  const o = e.isVolatile ? e.sharedAddress : e.erc20TokenAddress;
19
- return h(o, i.erc20TokenAddress) ? t + i.amount : t;
19
+ return g(o, d.erc20TokenAddress) ? t + d.amount : t;
20
20
  }, 0n),
21
- timestamp: d.filter(
22
- (t) => h(t.erc20TokenAddress, e.erc20TokenAddress)
21
+ timestamp: a.filter(
22
+ (t) => g(t.erc20TokenAddress, e.erc20TokenAddress)
23
23
  )[0]?.timeStamp,
24
- nfts: d.filter(
25
- (t) => h(t.erc20TokenAddress, e.erc20TokenAddress) && t.tokenId !== 0
24
+ nfts: a.filter(
25
+ (t) => g(t.erc20TokenAddress, e.erc20TokenAddress) && t.tokenId !== 0
26
26
  ).map((t) => ({ tokenId: t.tokenId, timestamp: t.timeStamp }))
27
27
  })), u = await Promise.all(
28
28
  p.map(async (e) => {
@@ -41,34 +41,34 @@ const C = new A(), O = async (a) => {
41
41
  })
42
42
  );
43
43
  return n(), u;
44
- }, X = async (a, n, d, s = 6, c = n.map(() => 0), p = !1) => {
45
- const { userKeys: u } = a, e = [], t = [];
46
- let i = 0;
44
+ }, X = async (i, n, a, s = 6, c = n.map(() => 0), p = !1) => {
45
+ const { userKeys: u } = i, e = [], t = [];
46
+ let d = 0;
47
47
  for (let o = 0; o < n.length; o += 1)
48
48
  if (p === !1) {
49
49
  const { inputUtxos: r } = await T({
50
- hinkal: a,
50
+ hinkal: i,
51
51
  erc20TokenAddress: n[o],
52
52
  tokenId: c[o],
53
53
  sliceIfMore6: !1
54
54
  });
55
- i = Math.max(r.length, i), t.push(r);
55
+ d = Math.max(r.length, d), t.push(r);
56
56
  } else
57
57
  t.push([]);
58
- return console.log({ maxUtxoNum: i }), i === 2 ? t : (t.forEach((o, r) => {
58
+ return d === 2 ? t : (t.forEach((o, r) => {
59
59
  if (o.length > s) {
60
- const l = o.slice(0, s), m = l.reduce((f, g) => f + g.amount, 0n);
61
- if (d[r] < 0n && m < -d[r]) {
62
- const f = k(n[r], a.getCurrentChainId()), g = Number(x(m, f, 2)), y = `Unfortunately your transaction did not go through due to UTXOs limitations.
60
+ const m = o.slice(0, s), l = m.reduce((f, h) => f + h.amount, 0n);
61
+ if (a[r] < 0n && l < -a[r]) {
62
+ const f = k(n[r], i.getCurrentChainId()), h = Number(x(l, f, 2)), y = `Unfortunately your transaction did not go through due to UTXOs limitations.
63
63
  Please try again with ${f.symbol}`;
64
- throw new S(g, y);
64
+ throw new S(h, y);
65
65
  }
66
- e.push(l);
66
+ e.push(m);
67
67
  } else if (o.length <= s) {
68
- const l = [...o];
69
- let m = s - o.length;
70
- for (; m > 0; )
71
- m -= 1, l.push(
68
+ const m = [...o];
69
+ let l = s - o.length;
70
+ for (; l > 0; )
71
+ l -= 1, m.push(
72
72
  new U({
73
73
  amount: 0n,
74
74
  erc20TokenAddress: n[r],
@@ -76,7 +76,7 @@ const C = new A(), O = async (a) => {
76
76
  tokenId: c[r]
77
77
  })
78
78
  );
79
- e.push(l);
79
+ e.push(m);
80
80
  }
81
81
  }), e);
82
82
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../../../constants/protocol.constants.cjs"),T=require("../../../types/ethereum-network.types.cjs"),f=require("./approveToken.cjs"),A=require("../../utils/time.utils.cjs"),b=async(r,o,s,t,i,n,u,h)=>{const a=r.getContractWithSigner(T.ContractType.HinkalContract),p=await r.getEthereumAddress(),v=u??a,d=h??a,g="transact";console.log("before the direct transaction"),o>0n&&s.erc20TokenAddress!==l.zeroAddress&&await f.approveTokenToHinkal(r,v,o,s);const c={value:o>0n&&s.erc20TokenAddress===l.zeroAddress?BigInt(o).toString():void 0};let e;try{e=(await d.estimateGas[g](t[0],t[1],t[2],n,i,{...c,from:p})).toNumber(),console.log({"gas costs of deposit":e})}catch(y){console.log("hinkalDeposit: gas estimation error: ",{err:y})}const m=e&&e>=0?Math.ceil(e*12/10):void 0;return c.gasLimit=m,await A.waitLittle(),await d[g](t[0],t[1],t[2],n,i,c)};exports.transactCallDirect=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../../../constants/protocol.constants.cjs"),T=require("../../../types/ethereum-network.types.cjs"),A=require("./approveToken.cjs"),q=require("../../utils/time.utils.cjs"),S=async(s,e,o,t,i,n,l,h)=>{const a=s.getContractWithSigner(T.ContractType.HinkalContract),p=await s.getEthereumAddress(),v=l??a,d=h??a,g="transact";e>0n&&o.erc20TokenAddress!==u.zeroAddress&&await A.approveTokenToHinkal(s,v,e,o);const c={value:e>0n&&o.erc20TokenAddress===u.zeroAddress?BigInt(e).toString():void 0};let r;try{r=(await d.estimateGas[g](t[0],t[1],t[2],n,i,{...c,from:p})).toNumber()}catch(y){console.log("hinkalDeposit: gas estimation error: ",{err:y})}const m=r&&r>=0?Math.ceil(r*12/10):void 0;return c.gasLimit=m,await q.waitLittle(),await d[g](t[0],t[1],t[2],n,i,c)};exports.transactCallDirect=S;
@@ -1,28 +1,28 @@
1
- import { zeroAddress as m } from "../../../constants/protocol.constants.mjs";
2
- import { ContractType as A } from "../../../types/ethereum-network.types.mjs";
3
- import { approveTokenToHinkal as T } from "./approveToken.mjs";
4
- import { waitLittle as y } from "../../utils/time.utils.mjs";
5
- const H = async (s, r, e, t, c, n, f, p) => {
6
- const a = s.getContractWithSigner(A.HinkalContract), h = await s.getEthereumAddress(), l = f ?? a, d = p ?? a, g = "transact";
7
- console.log("before the direct transaction"), r > 0n && e.erc20TokenAddress !== m && await T(s, l, r, e);
1
+ import { zeroAddress as g } from "../../../constants/protocol.constants.mjs";
2
+ import { ContractType as T } from "../../../types/ethereum-network.types.mjs";
3
+ import { approveTokenToHinkal as y } from "./approveToken.mjs";
4
+ import { waitLittle as u } from "../../utils/time.utils.mjs";
5
+ const S = async (s, r, e, t, c, n, p, f) => {
6
+ const a = s.getContractWithSigner(T.HinkalContract), h = await s.getEthereumAddress(), v = p ?? a, d = f ?? a, m = "transact";
7
+ r > 0n && e.erc20TokenAddress !== g && await y(s, v, r, e);
8
8
  const i = {
9
- value: r > 0n && e.erc20TokenAddress === m ? BigInt(r).toString() : void 0
9
+ value: r > 0n && e.erc20TokenAddress === g ? BigInt(r).toString() : void 0
10
10
  };
11
11
  let o;
12
12
  try {
13
- o = (await d.estimateGas[g](
13
+ o = (await d.estimateGas[m](
14
14
  t[0],
15
15
  t[1],
16
16
  t[2],
17
17
  n,
18
18
  c,
19
19
  { ...i, from: h }
20
- )).toNumber(), console.log({ "gas costs of deposit": o });
21
- } catch (x) {
22
- console.log("hinkalDeposit: gas estimation error: ", { err: x });
20
+ )).toNumber();
21
+ } catch (A) {
22
+ console.log("hinkalDeposit: gas estimation error: ", { err: A });
23
23
  }
24
- const v = o && o >= 0 ? Math.ceil(o * 12 / 10) : void 0;
25
- return i.gasLimit = v, await y(), await d[g](
24
+ const x = o && o >= 0 ? Math.ceil(o * 12 / 10) : void 0;
25
+ return i.gasLimit = x, await u(), await d[m](
26
26
  t[0],
27
27
  t[1],
28
28
  t[2],
@@ -32,5 +32,5 @@ const H = async (s, r, e, t, c, n, f, p) => {
32
32
  );
33
33
  };
34
34
  export {
35
- H as transactCallDirect
35
+ S as transactCallDirect
36
36
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../../API/callRelayer.cjs");require("../../../constants/chains.constants.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("../../../constants/vite.constants.cjs");const n=require("../../snarkjs/common.snarkjs.cjs");require("../../../types/circom-data.types.cjs");require("../../utils/external-action.utils.cjs");const u=async(a,r,s,c,t)=>{const i=n.serializeCircomData(c),e=await o.callRelayerTransactAPI(a,{a:r[0],b:r[1],c:r[2],dimData:s,circomData:i,withPrivateMempool:t});if(e.status==="success")return e.message;throw new Error(e.error)};exports.transactCallRelayer=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../../API/callRelayer.cjs");require("../../../constants/chains.constants.cjs");require("ethers");require("circomlibjs");require("../../../data-structures/crypto-keys/keys.cjs");require("../../../constants/vite.constants.cjs");const n=require("../../snarkjs/common.snarkjs.cjs");require("../../../types/circom-data.types.cjs");require("../../utils/external-action.utils.cjs");const u=async(a,r,s,c,t)=>{const i=n.serializeCircomData(c),e=await o.callRelayerTransactAPI(a,{a:r[0],b:r[1],c:r[2],dimData:s,circomData:i,withPrivateMempool:t});if(e.status==="success")return e.message;throw new Error(e.error)};exports.transactCallRelayer=u;
@@ -1,8 +1,8 @@
1
1
  import { callRelayerTransactAPI as e } from "../../../API/callRelayer.mjs";
2
2
  import "../../../constants/chains.constants.mjs";
3
3
  import "ethers";
4
- import "circomlibjs-hinkal-fork";
5
- import "libsodium-wrappers";
4
+ import "circomlibjs";
5
+ import "../../../data-structures/crypto-keys/keys.mjs";
6
6
  import "../../../constants/vite.constants.mjs";
7
7
  import { serializeCircomData as m } from "../../snarkjs/common.snarkjs.mjs";
8
8
  import "../../../types/circom-data.types.mjs";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../API/callOdosAPI.cjs"),n=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const d=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const a=require("../../error-handling/error-codes.constants.cjs"),q=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const A=async(r,e,o,u)=>{try{const t={chainId:r.getCurrentChainId()!==31337?r.getCurrentChainId():n.localhostNetwork,inputTokens:[{tokenAddress:e?.wrappedErc20TokenAddress??e.erc20TokenAddress,amount:q.getAmountInWei(e,u).toString()}],outputTokens:[{tokenAddress:o?.wrappedErc20TokenAddress??o.erc20TokenAddress,proportion:1}],userAddr:n.networkRegistry[r.getCurrentChainId()].contractData.odosExternalActionInstanceAddress||d.zeroAddress,slippageLimitPercent:10,disableRFQs:!0},{odosResponse:s,status:i}=await c.callOdosAPI(r.getCurrentChainId(),t);if(i!=="success")throw Error("Odos API Fetch Error");return{outSwapAmountValue:BigInt(s.outputTokens[0].amount),odosDataValue:s.transaction.data}}catch(t){throw console.log({error:t}),Error(a.transactionErrorCodes.NO_ODOS_PRICE)}};exports.getOdosPrice=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../API/callOdosAPI.cjs"),n=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const d=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const a=require("../../error-handling/error-codes.constants.cjs"),q=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("ethers");const A=async(r,e,o,u)=>{try{const t={chainId:r.getCurrentChainId()!==31337?r.getCurrentChainId():n.localhostNetwork,inputTokens:[{tokenAddress:e?.wrappedErc20TokenAddress??e.erc20TokenAddress,amount:q.getAmountInWei(e,u).toString()}],outputTokens:[{tokenAddress:o?.wrappedErc20TokenAddress??o.erc20TokenAddress,proportion:1}],userAddr:n.networkRegistry[r.getCurrentChainId()].contractData.odosExternalActionInstanceAddress||d.zeroAddress,slippageLimitPercent:10,disableRFQs:!0},{odosResponse:s,status:c}=await i.callOdosAPI(r.getCurrentChainId(),t);if(c!=="success")throw Error("Odos API Fetch Error");return{outSwapAmountValue:BigInt(s.outputTokens[0].amount),odosDataValue:s.transaction.data}}catch(t){throw console.log({error:t}),Error(a.transactionErrorCodes.NO_ODOS_PRICE)}};exports.getOdosPrice=A;
@@ -1,9 +1,9 @@
1
- import { callOdosAPI as d } from "../../API/callOdosAPI.mjs";
2
- import { localhostNetwork as p, networkRegistry as m } from "../../constants/chains.constants.mjs";
1
+ import { callOdosAPI as i } from "../../API/callOdosAPI.mjs";
2
+ import { localhostNetwork as a, networkRegistry as p } from "../../constants/chains.constants.mjs";
3
3
  import "../../constants/vite.constants.mjs";
4
4
  import "../../constants/contracts.constants.mjs";
5
5
  import "../../constants/kyc.constants.mjs";
6
- import { zeroAddress as a } from "../../constants/protocol.constants.mjs";
6
+ import { zeroAddress as m } from "../../constants/protocol.constants.mjs";
7
7
  import "../../constants/coingecko.constants.mjs";
8
8
  import "../../constants/axelar.constants.mjs";
9
9
  import "../../constants/rewards.constants.mjs";
@@ -14,19 +14,16 @@ import "axios";
14
14
  import "../../types/circom-data.types.mjs";
15
15
  import "../../types/transactions.types.mjs";
16
16
  import "../../types/curve.types.mjs";
17
+ import "circomlibjs";
17
18
  import "ethers";
18
- import "circomlibjs-hinkal-fork";
19
- import "libsodium-wrappers";
20
- import "process";
21
- import "buffer";
22
- const b = async (r, t, e, i) => {
19
+ const N = async (r, t, e, n) => {
23
20
  try {
24
21
  const o = {
25
- chainId: r.getCurrentChainId() !== 31337 ? r.getCurrentChainId() : p,
22
+ chainId: r.getCurrentChainId() !== 31337 ? r.getCurrentChainId() : a,
26
23
  inputTokens: [
27
24
  {
28
25
  tokenAddress: t?.wrappedErc20TokenAddress ?? t.erc20TokenAddress,
29
- amount: u(t, i).toString()
26
+ amount: u(t, n).toString()
30
27
  }
31
28
  ],
32
29
  outputTokens: [
@@ -35,15 +32,15 @@ const b = async (r, t, e, i) => {
35
32
  proportion: 1
36
33
  }
37
34
  ],
38
- userAddr: m[r.getCurrentChainId()].contractData.odosExternalActionInstanceAddress || a,
35
+ userAddr: p[r.getCurrentChainId()].contractData.odosExternalActionInstanceAddress || m,
39
36
  slippageLimitPercent: 10,
40
37
  disableRFQs: !0
41
38
  // sometimes swap fails because of RFQs
42
- }, { odosResponse: s, status: n } = await d(
39
+ }, { odosResponse: s, status: d } = await i(
43
40
  r.getCurrentChainId(),
44
41
  o
45
42
  );
46
- if (n !== "success")
43
+ if (d !== "success")
47
44
  throw Error("Odos API Fetch Error");
48
45
  return {
49
46
  outSwapAmountValue: BigInt(s.outputTokens[0].amount),
@@ -54,5 +51,5 @@ const b = async (r, t, e, i) => {
54
51
  }
55
52
  };
56
53
  export {
57
- b as getOdosPrice
54
+ N as getOdosPrice
58
55
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../API/callOneInchAPI.cjs");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const e=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const u=require("../../error-handling/error-codes.constants.cjs"),d=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const a=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const q=async(s,t,n,c)=>{try{const o={fromTokenAddress:t.erc20TokenAddress!==e.zeroAddress?t.erc20TokenAddress:e.oneInchZeroAddress,toTokenAddress:n.erc20TokenAddress!==e.zeroAddress?n.erc20TokenAddress:e.oneInchZeroAddress,fromAddress:e.zeroAddress,destReceiver:s.getContractMetadata(a.ContractType.OneInchExternalActionContract).address,amount:d.getAmountInWei(t,c),slippage:10,disableEstimate:!0,allowPartialFill:!1},r=await i.callOneInchAPI(s.getCurrentChainId(),o);if(!r||!r.tx)throw Error("OneInch API price fetch error");return{outSwapAmountValue:BigInt(r.toAmount),oneInchDataValue:r.tx.data}}catch(o){throw console.log({error:o}),Error(u.transactionErrorCodes.NO_ONEINCH_PRICE)}};exports.getOneInchPrice=q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../API/callOneInchAPI.cjs");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const e=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const d=require("../../error-handling/error-codes.constants.cjs"),u=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const a=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("ethers");const l=async(s,t,n,c)=>{try{const o={fromTokenAddress:t.erc20TokenAddress!==e.zeroAddress?t.erc20TokenAddress:e.oneInchZeroAddress,toTokenAddress:n.erc20TokenAddress!==e.zeroAddress?n.erc20TokenAddress:e.oneInchZeroAddress,fromAddress:e.zeroAddress,destReceiver:s.getContractMetadata(a.ContractType.OneInchExternalActionContract).address,amount:u.getAmountInWei(t,c),slippage:10,disableEstimate:!0,allowPartialFill:!1},r=await i.callOneInchAPI(s.getCurrentChainId(),o);if(!r||!r.tx)throw Error("OneInch API price fetch error");return{outSwapAmountValue:BigInt(r.toAmount),oneInchDataValue:r.tx.data}}catch(o){throw console.log({error:o}),Error(d.transactionErrorCodes.NO_ONEINCH_PRICE)}};exports.getOneInchPrice=l;
@@ -3,7 +3,7 @@ import "../../constants/chains.constants.mjs";
3
3
  import "../../constants/vite.constants.mjs";
4
4
  import "../../constants/contracts.constants.mjs";
5
5
  import "../../constants/kyc.constants.mjs";
6
- import { zeroAddress as e, oneInchZeroAddress as m } from "../../constants/protocol.constants.mjs";
6
+ import { zeroAddress as e, oneInchZeroAddress as i } from "../../constants/protocol.constants.mjs";
7
7
  import "../../constants/coingecko.constants.mjs";
8
8
  import "../../constants/axelar.constants.mjs";
9
9
  import "../../constants/rewards.constants.mjs";
@@ -15,20 +15,17 @@ import "../../types/circom-data.types.mjs";
15
15
  import { ContractType as p } from "../../types/ethereum-network.types.mjs";
16
16
  import "../../types/transactions.types.mjs";
17
17
  import "../../types/curve.types.mjs";
18
+ import "circomlibjs";
18
19
  import "ethers";
19
- import "circomlibjs-hinkal-fork";
20
- import "libsodium-wrappers";
21
- import "process";
22
- import "buffer";
23
- const v = async (s, t, i, n) => {
20
+ const _ = async (s, t, n, m) => {
24
21
  try {
25
22
  const o = {
26
- fromTokenAddress: t.erc20TokenAddress !== e ? t.erc20TokenAddress : m,
27
- toTokenAddress: i.erc20TokenAddress !== e ? i.erc20TokenAddress : m,
23
+ fromTokenAddress: t.erc20TokenAddress !== e ? t.erc20TokenAddress : i,
24
+ toTokenAddress: n.erc20TokenAddress !== e ? n.erc20TokenAddress : i,
28
25
  fromAddress: e,
29
26
  // we user zero address here because this paramater is not relevant to us, only destReceiver is
30
27
  destReceiver: s.getContractMetadata(p.OneInchExternalActionContract).address,
31
- amount: d(t, n),
28
+ amount: d(t, m),
32
29
  slippage: 10,
33
30
  disableEstimate: !0,
34
31
  // disable gas estimation, we don't need it
@@ -50,5 +47,5 @@ const v = async (s, t, i, n) => {
50
47
  }
51
48
  };
52
49
  export {
53
- v as getOneInchPrice
50
+ _ as getOneInchPrice
54
51
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../error-handling/error-codes.constants.cjs");require("ethers");const T=require("../../error-handling/get-error.message.cjs");require("axios");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/reorg-depths.constants.cjs");const q=5e4,d=1,m=11,w=15,g=async(s,o)=>{try{const r=await s.getFeeData(),n=o===0?m:w,e=r.gasPrice?.mul(n).div(10)??void 0;return console.log("getGasPrice , ",e?.toBigInt(),{gasPremiumType:o}),e}catch(r){console.log("getGasPrice error: ",{err:r});return}},E=(s,o,r)=>new Promise((n,e)=>{const a=setTimeout(()=>{e(new Error(c.transactionErrorCodes.TRANSACTION_TIMEOUT))},r);s.wait(o).then(t=>{clearTimeout(a),n(t)}).catch(t=>{clearTimeout(a),e(t)})}),l=async({contractFunction:s,args:o,gasPrice:r,gasLimit:n,nonce:e,confirmations:a,waitTime:t})=>{const i=await s(...o,{type:0,gasLimit:n,gasPrice:r,nonce:e});return console.log("runTransaction: ",i?.hash),await E(i,a??d,t??q)},P=async({provider:s,contractFunction:o,args:r,gasLimit:n,nonce:e,confirmations:a})=>{try{const t=await g(s,0);return await l({contractFunction:o,args:r,gasPrice:t,gasLimit:n,nonce:e,confirmations:a})}catch(t){const i=T.getErrorMessage(t);if(i===c.UserFriendlyErrorCodes.MAX_FEE_GAS_ERROR||i===c.transactionErrorCodes.TRANSACTION_TIMEOUT){console.log("Timeout Hit: Increase gas");const u=await g(s,1);return await l({contractFunction:o,args:r,gasPrice:u,gasLimit:n,nonce:e,confirmations:a})}throw t}};exports.runContractFunction=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../error-handling/error-codes.constants.cjs");require("ethers");const m=require("../../error-handling/get-error.message.cjs");require("axios");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("../../constants/reorg-depths.constants.cjs");const l=5e4,d=1,w=11,P=15,g=async(t,s)=>{try{const r=await t.getFeeData(),a=s===0?w:P;return r.gasPrice?.mul(a).div(10)??void 0}catch(r){console.log("getGasPrice error: ",{err:r});return}},q=(t,s,r)=>new Promise((a,o)=>{const n=setTimeout(()=>{o(new Error(c.transactionErrorCodes.TRANSACTION_TIMEOUT))},r);t.wait(s).then(e=>{clearTimeout(n),a(e)}).catch(e=>{clearTimeout(n),o(e)})}),T=async({contractFunction:t,args:s,gasPrice:r,gasLimit:a,nonce:o,confirmations:n,waitTime:e})=>{const i=await t(...s,{type:0,gasLimit:a,gasPrice:r,nonce:o});return await q(i,n??d,e??l)},E=async({provider:t,contractFunction:s,args:r,gasLimit:a,nonce:o,confirmations:n})=>{try{const e=await g(t,0);return await T({contractFunction:s,args:r,gasPrice:e,gasLimit:a,nonce:o,confirmations:n})}catch(e){const i=m.getErrorMessage(e);if(i===c.UserFriendlyErrorCodes.MAX_FEE_GAS_ERROR||i===c.transactionErrorCodes.TRANSACTION_TIMEOUT){console.log("Timeout Hit: Increase gas");const u=await g(t,1);return await T({contractFunction:s,args:r,gasPrice:u,gasLimit:a,nonce:o,confirmations:n})}throw e}};exports.runContractFunction=E;
@@ -1,4 +1,4 @@
1
- import { UserFriendlyErrorCodes as l, transactionErrorCodes as g } from "../../error-handling/error-codes.constants.mjs";
1
+ import { UserFriendlyErrorCodes as g, transactionErrorCodes as T } from "../../error-handling/error-codes.constants.mjs";
2
2
  import "ethers";
3
3
  import { getErrorMessage as p } from "../../error-handling/get-error.message.mjs";
4
4
  import "axios";
@@ -7,77 +7,74 @@ import "../../constants/vite.constants.mjs";
7
7
  import "../../types/circom-data.types.mjs";
8
8
  import "../../types/transactions.types.mjs";
9
9
  import "../../types/curve.types.mjs";
10
- import "circomlibjs-hinkal-fork";
11
- import "libsodium-wrappers";
12
- import "process";
13
- import "buffer";
10
+ import "circomlibjs";
14
11
  import "../../constants/reorg-depths.constants.mjs";
15
- const T = 5e4, w = 1, P = 11, d = 15, m = async (a, e) => {
12
+ const w = 5e4, l = 1, P = 11, d = 15, m = async (o, e) => {
16
13
  try {
17
- const t = await a.getFeeData(), s = e === 0 ? P : d, r = t.gasPrice?.mul(s).div(10) ?? void 0;
18
- return console.log("getGasPrice , ", r?.toBigInt(), { gasPremiumType: e }), r;
14
+ const t = await o.getFeeData(), a = e === 0 ? P : d;
15
+ return t.gasPrice?.mul(a).div(10) ?? void 0;
19
16
  } catch (t) {
20
17
  console.log("getGasPrice error: ", { err: t });
21
18
  return;
22
19
  }
23
- }, E = (a, e, t) => new Promise((s, r) => {
20
+ }, E = (o, e, t) => new Promise((a, s) => {
24
21
  const i = setTimeout(() => {
25
- r(new Error(g.TRANSACTION_TIMEOUT));
22
+ s(new Error(T.TRANSACTION_TIMEOUT));
26
23
  }, t);
27
- a.wait(e).then((o) => {
28
- clearTimeout(i), s(o);
29
- }).catch((o) => {
30
- clearTimeout(i), r(o);
24
+ o.wait(e).then((r) => {
25
+ clearTimeout(i), a(r);
26
+ }).catch((r) => {
27
+ clearTimeout(i), s(r);
31
28
  });
32
29
  }), u = async ({
33
- contractFunction: a,
30
+ contractFunction: o,
34
31
  args: e,
35
32
  gasPrice: t,
36
- gasLimit: s,
37
- nonce: r,
33
+ gasLimit: a,
34
+ nonce: s,
38
35
  confirmations: i,
39
- waitTime: o
36
+ waitTime: r
40
37
  }) => {
41
- const n = await a(...e, {
38
+ const n = await o(...e, {
42
39
  type: 0,
43
- gasLimit: s,
40
+ gasLimit: a,
44
41
  gasPrice: t,
45
- nonce: r
42
+ nonce: s
46
43
  });
47
- return console.log("runTransaction: ", n?.hash), await E(
44
+ return await E(
48
45
  n,
49
- i ?? w,
50
- o ?? T
46
+ i ?? l,
47
+ r ?? w
51
48
  );
52
- }, U = async ({
53
- provider: a,
49
+ }, N = async ({
50
+ provider: o,
54
51
  contractFunction: e,
55
52
  args: t,
56
- gasLimit: s,
57
- nonce: r,
53
+ gasLimit: a,
54
+ nonce: s,
58
55
  confirmations: i
59
56
  }) => {
60
57
  try {
61
- const o = await m(
62
- a,
58
+ const r = await m(
59
+ o,
63
60
  0
64
61
  /* Initial */
65
62
  );
66
- return await u({ contractFunction: e, args: t, gasPrice: o, gasLimit: s, nonce: r, confirmations: i });
67
- } catch (o) {
68
- const n = p(o);
69
- if (n === l.MAX_FEE_GAS_ERROR || n === g.TRANSACTION_TIMEOUT) {
63
+ return await u({ contractFunction: e, args: t, gasPrice: r, gasLimit: a, nonce: s, confirmations: i });
64
+ } catch (r) {
65
+ const n = p(r);
66
+ if (n === g.MAX_FEE_GAS_ERROR || n === T.TRANSACTION_TIMEOUT) {
70
67
  console.log("Timeout Hit: Increase gas");
71
68
  const c = await m(
72
- a,
69
+ o,
73
70
  1
74
71
  /* Secondary */
75
72
  );
76
- return await u({ contractFunction: e, args: t, gasPrice: c, gasLimit: s, nonce: r, confirmations: i });
73
+ return await u({ contractFunction: e, args: t, gasPrice: c, gasLimit: a, nonce: s, confirmations: i });
77
74
  }
78
- throw o;
75
+ throw r;
79
76
  }
80
77
  };
81
78
  export {
82
- U as runContractFunction
79
+ N as runContractFunction
83
80
  };