h_test_1 0.0.11 → 0.0.13

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("ethers"),y=require("../../../constants/protocol.constants.cjs"),F=require("../../../types/ethereum-network.types.cjs"),N=require("../../utils/time.utils.cjs"),_=require("./approveTokensToHinkal.cjs"),z=require("./constructBatchCall.cjs"),G=require("./recoverTransactionFromError.cjs"),L=require("../../utils/getContractAddress.cjs"),M=async(r,l,h,n,w,v,q,x,b=!0,k=!1)=>{const a=Array.isArray(l)?l:[l],e=Array.isArray(h)?h:[h];if(a.length!==e.length)throw new Error("token and amount length mismatch");const m=r.getContractWithSigner(F.ContractType.HinkalContract),H=await r.getEthereumAddress(),C=q??m,s=x??m,u="transact",T=e.findIndex(({erc20TokenAddress:t})=>t===y.zeroAddress),B=e.some(({erc20TokenAddress:t})=>t!==y.zeroAddress),g=T===-1?0n:a[T],p=r.getProviderAdapter();if(B&&await p.supportsBatchCall?.()&&p.sendBatchCallsTransaction){const t=e.map(I=>I.erc20TokenAddress),d=await z.buildApproveAndTransactCalls(t,a,L.getContractAddress(C),s,n,v,w,g);return await p.sendBatchCallsTransaction(d)}await _.approveTokensToHinkal(r,C,e,a);const f={value:g>0n?BigInt(g).toString():void 0};let o;const A=[n[0],n[1],n[2],v,w,{...f,from:H}],{runner:c}=s;if(!(c instanceof S.ethers.AbstractSigner))throw new Error("expected signer");if(b)try{o=Number(await s[u].estimateGas(...A)),console.log({gasCosts:o}),console.log({signerAddress:await c.getAddress(),chainIdHinkal:r.getCurrentChainId(),ethersNetwork:await c.provider.getNetwork()})}catch(t){console.log("hinkalDeposit: gas estimation error",{err:t})}const E=o&&o>=0?Math.ceil(o*12/10):void 0;f.gasLimit=E,await N.waitLittle();let i;try{k?i=await s[u].populateTransaction(...A):i=await s[u](...A)}catch(t){if(!t?.transactionHash)throw t;const d=await G.recoverTransactionFromError(c.provider,t.transactionHash);if(!d)throw t;i=d}return i};exports.transactCallDirect=M;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("ethers"),q=require("../../../constants/protocol.constants.cjs"),F=require("../../../types/ethereum-network.types.cjs"),N=require("../../utils/time.utils.cjs"),_=require("./approveTokensToHinkal.cjs"),z=require("./constructBatchCall.cjs"),G=require("./recoverTransactionFromError.cjs"),L=require("../../utils/getContractAddress.cjs"),M=async(r,l,h,n,v,m,b,k,x=!0,g=!1)=>{const a=Array.isArray(l)?l:[l],e=Array.isArray(h)?h:[h];if(a.length!==e.length)throw new Error("token and amount length mismatch");const C=r.getContractWithSigner(F.ContractType.HinkalContract),H=await r.getEthereumAddress(),f=b??C,s=k??C,u="transact",T=e.findIndex(({erc20TokenAddress:t})=>t===q.zeroAddress),B=e.some(({erc20TokenAddress:t})=>t!==q.zeroAddress),p=T===-1?0n:a[T],A=r.getProviderAdapter();if(!g&&B&&await A.supportsBatchCall?.()&&A.sendBatchCallsTransaction){const t=e.map(I=>I.erc20TokenAddress),d=await z.buildApproveAndTransactCalls(t,a,L.getContractAddress(f),s,n,m,v,p);return await A.sendBatchCallsTransaction(d)}g||await _.approveTokensToHinkal(r,f,e,a);const y={value:p>0n?BigInt(p).toString():void 0};let o;const w=[n[0],n[1],n[2],m,v,{...y,from:H}],{runner:c}=s;if(!(c instanceof S.ethers.AbstractSigner))throw new Error("expected signer");if(x)try{o=Number(await s[u].estimateGas(...w)),console.log({gasCosts:o}),console.log({signerAddress:await c.getAddress(),chainIdHinkal:r.getCurrentChainId(),ethersNetwork:await c.provider.getNetwork()})}catch(t){console.log("hinkalDeposit: gas estimation error",{err:t})}const E=o&&o>=0?Math.ceil(o*12/10):void 0;y.gasLimit=E,await N.waitLittle();let i;try{g?i=await s[u].populateTransaction(...w):i=await s[u](...w)}catch(t){if(!t?.transactionHash)throw t;const d=await G.recoverTransactionFromError(c.provider,t.transactionHash);if(!d)throw t;i=d}return i};exports.transactCallDirect=M;
@@ -6,42 +6,42 @@ import { approveTokensToHinkal as L } from "./approveTokensToHinkal.mjs";
6
6
  import { buildApproveAndTransactCalls as z } from "./constructBatchCall.mjs";
7
7
  import { recoverTransactionFromError as M } from "./recoverTransactionFromError.mjs";
8
8
  import { getContractAddress as P } from "../../utils/getContractAddress.mjs";
9
- const V = async (r, l, m, a, A, w, y, H, I = !0, b = !1) => {
9
+ const V = async (r, l, m, a, w, v, H, I, b = !0, p = !1) => {
10
10
  const n = Array.isArray(l) ? l : [l], o = Array.isArray(m) ? m : [m];
11
11
  if (n.length !== o.length)
12
12
  throw new Error("token and amount length mismatch");
13
- const v = r.getContractWithSigner(S.HinkalContract), B = await r.getEthereumAddress(), u = y ?? v, e = H ?? v, p = "transact", C = o.findIndex(({ erc20TokenAddress: t }) => t === x), E = o.some(({ erc20TokenAddress: t }) => t !== x), h = C === -1 ? 0n : n[C], g = r.getProviderAdapter();
14
- if (E && await g.supportsBatchCall?.() && g.sendBatchCallsTransaction) {
13
+ const C = r.getContractWithSigner(S.HinkalContract), B = await r.getEthereumAddress(), u = H ?? C, e = I ?? C, h = "transact", y = o.findIndex(({ erc20TokenAddress: t }) => t === x), E = o.some(({ erc20TokenAddress: t }) => t !== x), g = y === -1 ? 0n : n[y], f = r.getProviderAdapter();
14
+ if (!p && E && await f.supportsBatchCall?.() && f.sendBatchCallsTransaction) {
15
15
  const t = o.map((F) => F.erc20TokenAddress), d = await z(
16
16
  t,
17
17
  n,
18
18
  P(u),
19
19
  e,
20
20
  a,
21
+ v,
21
22
  w,
22
- A,
23
- h
23
+ g
24
24
  );
25
- return await g.sendBatchCallsTransaction(d);
25
+ return await f.sendBatchCallsTransaction(d);
26
26
  }
27
- await L(r, u, o, n);
27
+ p || await L(r, u, o, n);
28
28
  const T = {
29
- value: h > 0n ? BigInt(h).toString() : void 0
29
+ value: g > 0n ? BigInt(g).toString() : void 0
30
30
  };
31
31
  let s;
32
- const f = [
32
+ const A = [
33
33
  a[0],
34
34
  a[1],
35
35
  a[2],
36
+ v,
36
37
  w,
37
- A,
38
38
  { ...T, from: B }
39
39
  ], { runner: i } = e;
40
40
  if (!(i instanceof N.AbstractSigner))
41
41
  throw new Error("expected signer");
42
- if (I)
42
+ if (b)
43
43
  try {
44
- s = Number(await e[p].estimateGas(...f)), console.log({ gasCosts: s }), console.log({
44
+ s = Number(await e[h].estimateGas(...A)), console.log({ gasCosts: s }), console.log({
45
45
  signerAddress: await i.getAddress(),
46
46
  chainIdHinkal: r.getCurrentChainId(),
47
47
  ethersNetwork: await i.provider.getNetwork()
@@ -53,7 +53,7 @@ const V = async (r, l, m, a, A, w, y, H, I = !0, b = !1) => {
53
53
  T.gasLimit = k, await G();
54
54
  let c;
55
55
  try {
56
- b ? c = await e[p].populateTransaction(...f) : c = await e[p](...f);
56
+ p ? c = await e[h].populateTransaction(...A) : c = await e[h](...A);
57
57
  } catch (t) {
58
58
  if (!t?.transactionHash)
59
59
  throw t;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "h_test_1",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "homepage": "hinkal.io",
5
5
  "author": {
6
6
  "name": "Hinkal Protocol"