@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.
- package/constants/deploy-data/deploy-data-localhost.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-localhost.json.mjs +4 -4
- package/constants/fees.constants.cjs +1 -1
- package/constants/fees.constants.mjs +22 -22
- package/constants/token-data/localhostRegistry.json.cjs +1 -1
- package/constants/token-data/localhostRegistry.json.mjs +18 -44
- package/crypto/babyJub.cjs +1 -1
- package/crypto/babyJub.mjs +4 -4
- package/crypto/poseidon.cjs +1 -1
- package/crypto/poseidon.mjs +12 -12
- package/crypto/preProcessing.cjs +1 -1
- package/crypto/preProcessing.mjs +5 -7
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +1 -0
- package/data-structures/Hinkal/Hinkal.mjs +16 -16
- package/data-structures/Hinkal/IHinkal.d.ts +2 -1
- package/data-structures/Hinkal/hinkalActionBeefy.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionBeefy.mjs +18 -20
- package/data-structures/Hinkal/hinkalActionConvex.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionConvex.mjs +18 -21
- package/data-structures/Hinkal/hinkalActionLidoEth.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionLidoEth.mjs +31 -31
- package/data-structures/Hinkal/hinkalActionPendle.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendle.mjs +77 -80
- package/data-structures/Hinkal/hinkalActionPendleLP.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendleLP.mjs +34 -34
- package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionStake.mjs +49 -53
- package/data-structures/Hinkal/hinkalActionVolatile.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionVolatile.mjs +38 -44
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +27 -28
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +8 -11
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +9 -8
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.mjs +7 -6
- package/data-structures/event-service/AbstractAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/AbstractAccessTokenSnapshotService.mjs +6 -9
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.cjs +1 -4
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.mjs +18 -26
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.mjs +9 -12
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.mjs +9 -12
- package/data-structures/snapshot/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientNullifierSnapshotService.mjs +3 -6
- package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
- package/data-structures/transactions-manager/TransactionsManager.mjs +67 -75
- package/data-structures/transactions-manager/history/getVolatileData.cjs +1 -1
- package/data-structures/transactions-manager/history/getVolatileData.mjs +13 -13
- package/data-structures/volatile-helper/VolatileHelper.cjs +1 -1
- package/data-structures/volatile-helper/VolatileHelper.mjs +60 -60
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.d.ts +2 -0
- package/error-handling/error-codes.constants.mjs +2 -0
- package/functions/pre-transaction/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.mjs +42 -42
- package/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
- package/functions/pre-transaction/outputUtxoProcessing.mjs +5 -8
- package/functions/pre-transaction/process-gas-estimates.cjs +1 -1
- package/functions/pre-transaction/process-gas-estimates.mjs +17 -26
- package/functions/pre-transaction/processAmountChanges.cjs +1 -1
- package/functions/pre-transaction/processAmountChanges.mjs +10 -13
- package/functions/protocols/pendle.helpers.cjs +1 -1
- package/functions/protocols/pendle.helpers.mjs +37 -39
- package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.mjs +35 -37
- package/functions/staking/index.cjs +1 -1
- package/functions/staking/index.mjs +22 -24
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.mjs +27 -30
- package/functions/utils/index.d.ts +1 -0
- package/functions/utils/process.utils.cjs +1 -1
- package/functions/utils/process.utils.mjs +16 -2
- package/functions/utils/resolve-sync.utils.cjs +1 -1
- package/functions/utils/resolve-sync.utils.d.ts +0 -1
- package/functions/utils/resolve-sync.utils.mjs +3 -12
- package/functions/web3/events/getShieldedBalance.cjs +2 -2
- package/functions/web3/events/getShieldedBalance.mjs +25 -25
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +15 -15
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +2 -2
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +11 -14
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +7 -10
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.mjs +35 -38
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.mjs +30 -33
- package/index.cjs +1 -1
- package/index.mjs +281 -277
- package/package.json +3 -5
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +5 -4
- package/providers/prepareWagmiv1Hinkal.cjs +1 -1
- package/providers/prepareWagmiv1Hinkal.mjs +5 -4
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLogic.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLogic.mjs +16 -17
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
|
@@ -1,57 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
-
},
|
|
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(),
|
|
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 } =
|
|
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
|
-
},
|
|
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 } =
|
|
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
|
-
},
|
|
23
|
-
|
|
24
|
-
},
|
|
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:
|
|
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
|
|
28
|
+
await d(c, h);
|
|
32
29
|
} catch {
|
|
33
|
-
localStorage.setItem(
|
|
30
|
+
localStorage.setItem(c, h);
|
|
34
31
|
}
|
|
35
|
-
},
|
|
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 } =
|
|
39
|
-
let
|
|
35
|
+
const { shortPublicKey: s, shortHinkalAddress: o } = l(t, r), a = f(e, s, o);
|
|
36
|
+
let n;
|
|
40
37
|
try {
|
|
41
|
-
const
|
|
42
|
-
if (!
|
|
38
|
+
const i = await m(a);
|
|
39
|
+
if (!i)
|
|
43
40
|
throw new Error("Empty indexedDB cache");
|
|
44
|
-
|
|
41
|
+
n = i;
|
|
45
42
|
} catch {
|
|
46
|
-
|
|
43
|
+
n = localStorage.getItem(a);
|
|
47
44
|
}
|
|
48
|
-
const { serializedTxs:
|
|
49
|
-
return
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
k as getHinkalCache,
|
|
50
|
+
w as loadTxsCache,
|
|
51
|
+
T as resetCache,
|
|
52
|
+
O as saveTxsCache,
|
|
53
|
+
p as setHinkalCache
|
|
57
54
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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
|
|
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
|
-
|
|
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,
|
|
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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const c = (t) => t.reduce((e, n) => e.then(() => n()), Promise.resolve()),
|
|
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
|
-
}
|
|
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
|
-
|
|
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
|
|
2
|
-
Please try again with ${g.symbol}`;throw new S.ErrorWithAmount(f,T)}e.push(
|
|
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
|
|
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 (
|
|
13
|
-
const n = await C.acquire(), { inputUtxos:
|
|
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:
|
|
17
|
+
balance: a.reduce((t, d) => {
|
|
18
18
|
const o = e.isVolatile ? e.sharedAddress : e.erc20TokenAddress;
|
|
19
|
-
return
|
|
19
|
+
return g(o, d.erc20TokenAddress) ? t + d.amount : t;
|
|
20
20
|
}, 0n),
|
|
21
|
-
timestamp:
|
|
22
|
-
(t) =>
|
|
21
|
+
timestamp: a.filter(
|
|
22
|
+
(t) => g(t.erc20TokenAddress, e.erc20TokenAddress)
|
|
23
23
|
)[0]?.timeStamp,
|
|
24
|
-
nfts:
|
|
25
|
-
(t) =>
|
|
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 (
|
|
45
|
-
const { userKeys: u } =
|
|
46
|
-
let
|
|
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:
|
|
50
|
+
hinkal: i,
|
|
51
51
|
erc20TokenAddress: n[o],
|
|
52
52
|
tokenId: c[o],
|
|
53
53
|
sliceIfMore6: !1
|
|
54
54
|
});
|
|
55
|
-
|
|
55
|
+
d = Math.max(r.length, d), t.push(r);
|
|
56
56
|
} else
|
|
57
57
|
t.push([]);
|
|
58
|
-
return
|
|
58
|
+
return d === 2 ? t : (t.forEach((o, r) => {
|
|
59
59
|
if (o.length > s) {
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
const f = k(n[r],
|
|
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(
|
|
64
|
+
throw new S(h, y);
|
|
65
65
|
}
|
|
66
|
-
e.push(
|
|
66
|
+
e.push(m);
|
|
67
67
|
} else if (o.length <= s) {
|
|
68
|
-
const
|
|
69
|
-
let
|
|
70
|
-
for (;
|
|
71
|
-
|
|
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(
|
|
79
|
+
e.push(m);
|
|
80
80
|
}
|
|
81
81
|
}), e);
|
|
82
82
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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
|
|
2
|
-
import { ContractType as
|
|
3
|
-
import { approveTokenToHinkal as
|
|
4
|
-
import { waitLittle as
|
|
5
|
-
const
|
|
6
|
-
const a = s.getContractWithSigner(
|
|
7
|
-
|
|
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 ===
|
|
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[
|
|
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()
|
|
21
|
-
} catch (
|
|
22
|
-
console.log("hinkalDeposit: gas estimation error: ", { err:
|
|
20
|
+
)).toNumber();
|
|
21
|
+
} catch (A) {
|
|
22
|
+
console.log("hinkalDeposit: gas estimation error: ", { err: A });
|
|
23
23
|
}
|
|
24
|
-
const
|
|
25
|
-
return i.gasLimit =
|
|
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
|
-
|
|
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
|
|
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
|
|
5
|
-
import "
|
|
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
|
|
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
|
|
2
|
-
import { localhostNetwork as
|
|
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
|
|
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
|
-
|
|
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() :
|
|
22
|
+
chainId: r.getCurrentChainId() !== 31337 ? r.getCurrentChainId() : a,
|
|
26
23
|
inputTokens: [
|
|
27
24
|
{
|
|
28
25
|
tokenAddress: t?.wrappedErc20TokenAddress ?? t.erc20TokenAddress,
|
|
29
|
-
amount: u(t,
|
|
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:
|
|
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:
|
|
39
|
+
}, { odosResponse: s, status: d } = await i(
|
|
43
40
|
r.getCurrentChainId(),
|
|
44
41
|
o
|
|
45
42
|
);
|
|
46
|
-
if (
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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 :
|
|
27
|
-
toTokenAddress:
|
|
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,
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
11
|
-
import "libsodium-wrappers";
|
|
12
|
-
import "process";
|
|
13
|
-
import "buffer";
|
|
10
|
+
import "circomlibjs";
|
|
14
11
|
import "../../constants/reorg-depths.constants.mjs";
|
|
15
|
-
const
|
|
12
|
+
const w = 5e4, l = 1, P = 11, d = 15, m = async (o, e) => {
|
|
16
13
|
try {
|
|
17
|
-
const t = await
|
|
18
|
-
return
|
|
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 = (
|
|
20
|
+
}, E = (o, e, t) => new Promise((a, s) => {
|
|
24
21
|
const i = setTimeout(() => {
|
|
25
|
-
|
|
22
|
+
s(new Error(T.TRANSACTION_TIMEOUT));
|
|
26
23
|
}, t);
|
|
27
|
-
|
|
28
|
-
clearTimeout(i),
|
|
29
|
-
}).catch((
|
|
30
|
-
clearTimeout(i), r
|
|
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:
|
|
30
|
+
contractFunction: o,
|
|
34
31
|
args: e,
|
|
35
32
|
gasPrice: t,
|
|
36
|
-
gasLimit:
|
|
37
|
-
nonce:
|
|
33
|
+
gasLimit: a,
|
|
34
|
+
nonce: s,
|
|
38
35
|
confirmations: i,
|
|
39
|
-
waitTime:
|
|
36
|
+
waitTime: r
|
|
40
37
|
}) => {
|
|
41
|
-
const n = await
|
|
38
|
+
const n = await o(...e, {
|
|
42
39
|
type: 0,
|
|
43
|
-
gasLimit:
|
|
40
|
+
gasLimit: a,
|
|
44
41
|
gasPrice: t,
|
|
45
|
-
nonce:
|
|
42
|
+
nonce: s
|
|
46
43
|
});
|
|
47
|
-
return
|
|
44
|
+
return await E(
|
|
48
45
|
n,
|
|
49
|
-
i ??
|
|
50
|
-
|
|
46
|
+
i ?? l,
|
|
47
|
+
r ?? w
|
|
51
48
|
);
|
|
52
|
-
},
|
|
53
|
-
provider:
|
|
49
|
+
}, N = async ({
|
|
50
|
+
provider: o,
|
|
54
51
|
contractFunction: e,
|
|
55
52
|
args: t,
|
|
56
|
-
gasLimit:
|
|
57
|
-
nonce:
|
|
53
|
+
gasLimit: a,
|
|
54
|
+
nonce: s,
|
|
58
55
|
confirmations: i
|
|
59
56
|
}) => {
|
|
60
57
|
try {
|
|
61
|
-
const
|
|
62
|
-
|
|
58
|
+
const r = await m(
|
|
59
|
+
o,
|
|
63
60
|
0
|
|
64
61
|
/* Initial */
|
|
65
62
|
);
|
|
66
|
-
return await u({ contractFunction: e, args: t, gasPrice:
|
|
67
|
-
} catch (
|
|
68
|
-
const n = p(
|
|
69
|
-
if (n ===
|
|
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
|
-
|
|
69
|
+
o,
|
|
73
70
|
1
|
|
74
71
|
/* Secondary */
|
|
75
72
|
);
|
|
76
|
-
return await u({ contractFunction: e, args: t, gasPrice: c, gasLimit:
|
|
73
|
+
return await u({ contractFunction: e, args: t, gasPrice: c, gasLimit: a, nonce: s, confirmations: i });
|
|
77
74
|
}
|
|
78
|
-
throw
|
|
75
|
+
throw r;
|
|
79
76
|
}
|
|
80
77
|
};
|
|
81
78
|
export {
|
|
82
|
-
|
|
79
|
+
N as runContractFunction
|
|
83
80
|
};
|