h_test_1 0.0.12 → 0.0.14

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("../../constants/chains.constants.cjs"),o=require("./constant.cjs"),l=(e,i,t)=>{const r=e==="v1x0"?"":e;if(t===s.chainIds.localhost||t===s.chainIds.solanaLocalnet)return o.localVerifiers[`${i}${r}Wasm`];const c=o.prodVerifiers(t,e)[`${i}${r}Wasm`];return console.log({verifier:c}),c},a=(e,i,t)=>{const r=e==="v1x0"?"":e;return t===s.chainIds.localhost||t===s.chainIds.solanaLocalnet?o.localVerifiers[`${i}${r}Zkey`]:o.prodVerifiers(t,e)[`${i}${r}Zkey`]};exports.getWASMFile=l;exports.getZKeyFile=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../constants/chains.constants.cjs"),c=require("./constant.cjs"),a=(e,i,t)=>{const r=e==="v1x0"?"":e;return t===s.chainIds.localhost||t===s.chainIds.solanaLocalnet?c.localVerifiers[`${i}${r}Wasm`]:c.prodVerifiers(t,e)[`${i}${r}Wasm`]},l=(e,i,t)=>{const r=e==="v1x0"?"":e;return t===s.chainIds.localhost||t===s.chainIds.solanaLocalnet?c.localVerifiers[`${i}${r}Zkey`]:c.prodVerifiers(t,e)[`${i}${r}Zkey`]};exports.getWASMFile=a;exports.getZKeyFile=l;
@@ -1,14 +1,11 @@
1
- import { chainIds as i } from "../../constants/chains.constants.mjs";
2
- import { prodVerifiers as c, localVerifiers as l } from "./constant.mjs";
3
- const $ = (e, r, t) => {
4
- const o = e === "v1x0" ? "" : e;
5
- if (t === i.localhost || t === i.solanaLocalnet)
6
- return l[`${r}${o}Wasm`];
7
- const s = c(t, e)[`${r}${o}Wasm`];
8
- return console.log({ verifier: s }), s;
9
- }, v = (e, r, t) => {
10
- const o = e === "v1x0" ? "" : e;
11
- return t === i.localhost || t === i.solanaLocalnet ? l[`${r}${o}Zkey`] : c(t, e)[`${r}${o}Zkey`];
1
+ import { chainIds as o } from "../../constants/chains.constants.mjs";
2
+ import { prodVerifiers as s, localVerifiers as c } from "./constant.mjs";
3
+ const $ = (e, t, r) => {
4
+ const i = e === "v1x0" ? "" : e;
5
+ return r === o.localhost || r === o.solanaLocalnet ? c[`${t}${i}Wasm`] : s(r, e)[`${t}${i}Wasm`];
6
+ }, v = (e, t, r) => {
7
+ const i = e === "v1x0" ? "" : e;
8
+ return r === o.localhost || r === o.solanaLocalnet ? c[`${t}${i}Zkey`] : s(r, e)[`${t}${i}Zkey`];
12
9
  };
13
10
  export {
14
11
  $ as getWASMFile,
@@ -1 +1 @@
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,w,v,x,b,k=!0,m=!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=x??C,s=b??C,u="transact",T=e.findIndex(({erc20TokenAddress:t})=>t===q.zeroAddress),B=e.some(({erc20TokenAddress:t})=>t!==q.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(f),s,n,v,w,g);return await p.sendBatchCallsTransaction(d)}m||await _.approveTokensToHinkal(r,f,e,a);const y={value:g>0n?BigInt(g).toString():void 0};let o;const A=[n[0],n[1],n[2],v,w,{...y,from:H}],{runner:c}=s;if(!(c instanceof S.ethers.AbstractSigner))throw new Error("expected signer");if(k)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;y.gasLimit=E,await N.waitLittle();let i;try{m?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;
@@ -1,47 +1,47 @@
1
1
  import { ethers as N } from "ethers";
2
- import { zeroAddress as y } from "../../../constants/protocol.constants.mjs";
2
+ import { zeroAddress as x } from "../../../constants/protocol.constants.mjs";
3
3
  import { ContractType as S } from "../../../types/ethereum-network.types.mjs";
4
4
  import { waitLittle as G } from "../../utils/time.utils.mjs";
5
5
  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, H, I, b = !0, v = !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 u = r.getContractWithSigner(S.HinkalContract), B = await r.getEthereumAddress(), C = H ?? u, e = I ?? u, p = "transact", T = o.findIndex(({ erc20TokenAddress: t }) => t === y), E = o.some(({ erc20TokenAddress: t }) => t !== y), h = T === -1 ? 0n : n[T], 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
- P(C),
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
- v || await L(r, C, o, n);
28
- const x = {
29
- value: h > 0n ? BigInt(h).toString() : void 0
27
+ p || await L(r, u, o, n);
28
+ const T = {
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
- { ...x, from: B }
38
+ { ...T, from: B }
39
39
  ], { runner: i } = e;
40
40
  if (!(i instanceof N.AbstractSigner))
41
41
  throw new Error("expected signer");
42
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()
@@ -50,10 +50,10 @@ const V = async (r, l, m, a, A, w, H, I, b = !0, v = !1) => {
50
50
  console.log("hinkalDeposit: gas estimation error", { err: t });
51
51
  }
52
52
  const k = s && s >= 0 ? Math.ceil(s * 12 / 10) : void 0;
53
- x.gasLimit = k, await G();
53
+ T.gasLimit = k, await G();
54
54
  let c;
55
55
  try {
56
- v ? 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.12",
3
+ "version": "0.0.14",
4
4
  "homepage": "hinkal.io",
5
5
  "author": {
6
6
  "name": "Hinkal Protocol"