@hinkal/common 0.2.4 → 0.2.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.
- package/API/API.cjs +1 -1
- package/API/API.d.ts +2 -2
- package/API/API.mjs +22 -22
- package/API/duneAPI.cjs +1 -1
- package/API/duneAPI.mjs +2 -3
- package/API/userVerifyTransactions.cjs +1 -1
- package/API/userVerifyTransactions.d.ts +7 -6
- package/API/userVerifyTransactions.mjs +14 -13
- package/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.mjs +2 -2
- package/constants/contracts.constants.cjs +1 -1
- package/constants/contracts.constants.mjs +134 -138
- package/constants/deploy-data/deploy-data-arbMainnet.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-arbMainnet.json.mjs +11 -846
- package/constants/deploy-data/deploy-data-avalanche.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-avalanche.json.mjs +13 -848
- package/constants/deploy-data/deploy-data-base.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-base.json.mjs +17 -852
- package/constants/deploy-data/deploy-data-bnbMainnet.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-bnbMainnet.json.mjs +20 -855
- package/constants/deploy-data/deploy-data-ethMainnet.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-ethMainnet.json.mjs +15 -850
- package/constants/deploy-data/deploy-data-localhost.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-localhost.json.mjs +100 -935
- package/constants/deploy-data/deploy-data-optimism.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-optimism.json.mjs +18 -849
- package/constants/deploy-data/deploy-data-polygon.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-polygon.json.mjs +9 -844
- package/constants/kyc.constants.cjs +1 -1
- package/constants/kyc.constants.mjs +18 -30
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.d.ts +2 -3
- package/constants/server.constants.mjs +6 -7
- package/constants/token-data/ERC20Registry.cjs +1 -1
- package/constants/token-data/ERC20Registry.mjs +48 -48
- package/constants/token-data/arbMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/arbMainnetRegistry.json.mjs +1 -4
- package/constants/token-data/arbMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/arbMainnetRegistryFixed.json.mjs +1 -4
- package/constants/token-data/avalancheRegistry.json.cjs +1 -1
- package/constants/token-data/avalancheRegistry.json.mjs +1 -4
- package/constants/token-data/avalancheRegistryFixed.json.cjs +1 -1
- package/constants/token-data/avalancheRegistryFixed.json.mjs +1 -4
- package/constants/token-data/baseRegistry.json.cjs +1 -1
- package/constants/token-data/baseRegistry.json.mjs +1 -4
- package/constants/token-data/baseRegistryFixed.json.cjs +1 -1
- package/constants/token-data/baseRegistryFixed.json.mjs +1 -4
- package/constants/token-data/bnbMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/bnbMainnetRegistry.json.mjs +1 -4
- package/constants/token-data/bnbMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/bnbMainnetRegistryFixed.json.mjs +1 -4
- package/constants/token-data/ethMainnetRegistry.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistry.json.mjs +1 -4
- package/constants/token-data/ethMainnetRegistryFixed.json.cjs +1 -1
- package/constants/token-data/ethMainnetRegistryFixed.json.mjs +1 -4
- package/constants/token-data/index.d.ts +15 -972
- package/constants/token-data/localhostRegistry.json.cjs +1 -1
- package/constants/token-data/localhostRegistry.json.mjs +1 -4
- package/constants/token-data/optimismRegistry.json.cjs +1 -1
- package/constants/token-data/optimismRegistry.json.mjs +1 -4
- package/constants/token-data/optimismRegistryFixed.json.cjs +1 -1
- package/constants/token-data/optimismRegistryFixed.json.mjs +1 -4
- package/constants/token-data/polygonRegistry.json.cjs +1 -1
- package/constants/token-data/polygonRegistry.json.mjs +1 -4
- package/constants/token-data/polygonRegistryFixed.json.cjs +1 -1
- package/constants/token-data/polygonRegistryFixed.json.mjs +1 -4
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +0 -2
- package/data-structures/Hinkal/Hinkal.mjs +32 -38
- package/data-structures/Hinkal/IHinkal.d.ts +0 -2
- package/data-structures/Hinkal/hinkalActionBeefy.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionBeefy.mjs +20 -21
- package/data-structures/Hinkal/hinkalActionConvex.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionConvex.mjs +12 -13
- package/data-structures/Hinkal/hinkalActionCurve.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionCurve.mjs +14 -15
- package/data-structures/Hinkal/hinkalActionLidoEth.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionLidoEth.mjs +16 -17
- package/data-structures/Hinkal/hinkalActionPendle.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendle.d.ts +1 -1
- package/data-structures/Hinkal/hinkalActionPendle.mjs +23 -24
- package/data-structures/Hinkal/hinkalActionPendleLP.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendleLP.mjs +20 -21
- package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionStake.d.ts +1 -1
- package/data-structures/Hinkal/hinkalActionStake.mjs +5 -6
- package/data-structures/Hinkal/hinkalActionVolatile.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionVolatile.d.ts +1 -1
- package/data-structures/Hinkal/hinkalActionVolatile.mjs +8 -9
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.d.ts +2 -2
- package/data-structures/Hinkal/hinkalDeposit.mjs +54 -93
- package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +2 -3
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +4 -5
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +22 -23
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.d.ts +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +12 -13
- package/data-structures/merkle-tree/MerkleTree.cjs +1 -1
- package/data-structures/merkle-tree/MerkleTree.d.ts +0 -2
- package/data-structures/merkle-tree/MerkleTree.mjs +25 -38
- package/data-structures/merkle-tree/index.d.ts +0 -1
- package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
- package/data-structures/transactions-manager/TransactionsManager.d.ts +5 -6
- package/data-structures/transactions-manager/TransactionsManager.mjs +111 -118
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.d.ts +0 -4
- package/error-handling/error-codes.constants.mjs +2 -6
- package/externalABIs/BabPassport.json.cjs +1 -1
- package/externalABIs/BabPassport.json.mjs +3 -8
- package/externalABIs/BeefyRouterAbi.json.cjs +1 -1
- package/externalABIs/BeefyRouterAbi.json.mjs +2 -5
- package/externalABIs/BeefyStrategyAbi.json.cjs +1 -1
- package/externalABIs/BeefyStrategyAbi.json.mjs +2 -5
- package/externalABIs/BeefyVaultAbi.json.cjs +1 -1
- package/externalABIs/BeefyVaultAbi.json.mjs +2 -5
- package/externalABIs/BeefyZapAbi.json.cjs +1 -1
- package/externalABIs/BeefyZapAbi.json.mjs +2 -5
- package/externalABIs/BeefyZapOneInchAbi.json.cjs +1 -1
- package/externalABIs/BeefyZapOneInchAbi.json.mjs +2 -5
- package/externalABIs/ConvexBoosterAbi.json.cjs +1 -1
- package/externalABIs/ConvexBoosterAbi.json.mjs +2 -5
- package/externalABIs/ConvexBoosterAbiMainnet.json.cjs +1 -1
- package/externalABIs/ConvexBoosterAbiMainnet.json.mjs +2 -5
- package/externalABIs/ConvexRewardPoolAbi.json.cjs +1 -1
- package/externalABIs/ConvexRewardPoolAbi.json.mjs +2 -5
- package/externalABIs/CurveReadingWrapperAbi.json.cjs +1 -1
- package/externalABIs/CurveReadingWrapperAbi.json.mjs +2 -5
- package/externalABIs/CurveWrappedMainPool.json.cjs +1 -1
- package/externalABIs/CurveWrappedMainPool.json.mjs +2 -5
- package/externalABIs/CurveZap.json.cjs +1 -1
- package/externalABIs/CurveZap.json.mjs +2 -5
- package/externalABIs/CvxCrvUtilities.json.cjs +1 -1
- package/externalABIs/CvxCrvUtilities.json.mjs +2 -5
- package/externalABIs/ERC20.json.cjs +1 -1
- package/externalABIs/ERC20.json.mjs +3 -20
- package/externalABIs/GalxePassport.json.cjs +1 -1
- package/externalABIs/GalxePassport.json.mjs +3 -8
- package/externalABIs/IQuoterV2.json.cjs +1 -1
- package/externalABIs/IQuoterV2.json.mjs +3 -20
- package/externalABIs/ISwapRouter.json.cjs +1 -1
- package/externalABIs/ISwapRouter.json.mjs +2 -5
- package/externalABIs/IUniswapV3Factory.json.cjs +1 -1
- package/externalABIs/IUniswapV3Factory.json.mjs +3 -20
- package/externalABIs/IUniswapV3Pool.json.cjs +1 -1
- package/externalABIs/IUniswapV3Pool.json.mjs +3 -20
- package/externalABIs/PendleRouterAbi.json.cjs +1 -1
- package/externalABIs/PendleRouterAbi.json.mjs +2 -5
- package/externalABIs/UniswapV2PoolAbi.json.cjs +1 -1
- package/externalABIs/UniswapV2PoolAbi.json.mjs +3 -16
- package/externalABIs/index.d.ts +11 -307
- package/externalABIs/transactionsProver.json.cjs +1 -1
- package/externalABIs/transactionsProver.json.mjs +3 -20
- package/functions/kyc/zkMeHelper.cjs +1 -1
- package/functions/kyc/zkMeHelper.d.ts +1 -0
- package/functions/kyc/zkMeHelper.mjs +11 -8
- package/functions/pre-transaction/process-gas-estimates.cjs +1 -1
- package/functions/pre-transaction/process-gas-estimates.mjs +2 -3
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +8 -3
- package/functions/private-wallet/emporium.helpers.mjs +23 -11
- package/functions/private-wallet/index.d.ts +1 -0
- package/functions/private-wallet/opProducer.cjs +1 -1
- package/functions/private-wallet/opProducer.mjs +10 -9
- package/functions/private-wallet/smartContractWalletCalculator.cjs +1 -0
- package/functions/private-wallet/smartContractWalletCalculator.d.ts +1 -0
- package/functions/private-wallet/smartContractWalletCalculator.mjs +20 -0
- package/functions/protocols/convex.protocols.cjs +1 -1
- package/functions/protocols/convex.protocols.mjs +2 -3
- package/functions/protocols/pendle.helpers.cjs +1 -1
- package/functions/protocols/pendle.helpers.mjs +13 -14
- package/functions/snarkjs/constant.cjs +1 -1
- package/functions/snarkjs/constant.d.ts +0 -1
- package/functions/snarkjs/constant.mjs +5 -6
- package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
- package/functions/snarkjs/constructEmporiumProof.d.ts +1 -1
- package/functions/snarkjs/constructEmporiumProof.mjs +31 -31
- package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.d.ts +1 -1
- package/functions/snarkjs/constructGeneralZkProof.mjs +75 -76
- package/functions/snarkjs/generateZkProof.cjs +1 -1
- package/functions/snarkjs/generateZkProof.d.ts +1 -1
- package/functions/snarkjs/generateZkProof.mjs +15 -4
- package/functions/utils/axelar.utils.cjs +1 -1
- package/functions/utils/axelar.utils.mjs +2 -3
- package/functions/utils/cacheDevice.utils.cjs +1 -1
- package/functions/utils/cacheDevice.utils.mjs +8 -9
- package/functions/utils/erc20tokenFunctions.cjs +1 -1
- package/functions/utils/erc20tokenFunctions.mjs +7 -8
- package/functions/utils/evmNetworkFunctions.cjs +1 -1
- package/functions/utils/evmNetworkFunctions.mjs +3 -4
- package/functions/utils/string.utils.cjs +1 -1
- package/functions/utils/string.utils.d.ts +1 -0
- package/functions/utils/string.utils.mjs +16 -6
- package/functions/utils/userAgent.cjs +1 -1
- package/functions/utils/userAgent.mjs +8 -8
- package/functions/web3/functionCalls/accessTokenCalls.cjs +1 -1
- package/functions/web3/functionCalls/accessTokenCalls.mjs +8 -8
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.d.ts +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +29 -43
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +8 -10
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.d.ts +2 -1
- package/functions/web3/odosAPI.mjs +18 -19
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.d.ts +2 -1
- package/functions/web3/oneInchAPI.mjs +15 -17
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.d.ts +4 -4
- package/functions/web3/uniswapAPI.mjs +43 -54
- package/index.cjs +1 -1
- package/index.mjs +641 -617
- package/package.json +2 -3
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.d.ts +0 -1
- package/providers/EthersProviderAdapter.mjs +37 -26
- package/providers/WagmiProviderAdapter.cjs +1 -1
- package/providers/WagmiProviderAdapter.d.ts +0 -1
- package/providers/WagmiProviderAdapter.mjs +56 -45
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +2 -4
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +2 -4
- package/types/ethereum-network.types.cjs +1 -1
- package/types/ethereum-network.types.d.ts +61 -62
- package/types/ethereum-network.types.mjs +1 -1
- package/types/hinkal.types.d.ts +0 -4
- package/types/kyc.types.cjs +1 -1
- package/types/kyc.types.d.ts +1 -1
- package/types/kyc.types.mjs +1 -1
- package/types/rewards.types.d.ts +0 -5
- package/types/time.types.cjs +1 -1
- package/types/time.types.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/constants/token-data/index.cjs +0 -1
- package/constants/token-data/index.mjs +0 -34
- package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.cjs +0 -1
- package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.d.ts +0 -3
- package/data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.mjs +0 -9
- package/externalABIs/index.cjs +0 -1
- package/externalABIs/index.mjs +0 -23
- package/functions/snarkjs/generateZkProofEnclave.cjs +0 -1
- package/functions/snarkjs/generateZkProofEnclave.d.ts +0 -5
- package/functions/snarkjs/generateZkProofEnclave.mjs +0 -33
- package/functions/snarkjs/generateZkProofSelf.cjs +0 -1
- package/functions/snarkjs/generateZkProofSelf.d.ts +0 -5
- package/functions/snarkjs/generateZkProofSelf.mjs +0 -17
- package/functions/web3/getContractMetadata.cjs +0 -1
- package/functions/web3/getContractMetadata.d.ts +0 -5
- package/functions/web3/getContractMetadata.mjs +0 -30
- package/types/remote-proof.types.d.ts +0 -15
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { networkRegistry as
|
|
1
|
+
import { networkRegistry as g } from "../../constants/chains.constants.mjs";
|
|
2
2
|
import { transactionErrorCodes as A } from "../../error-handling/error-codes.constants.mjs";
|
|
3
3
|
import "ethers";
|
|
4
4
|
import "axios";
|
|
@@ -29,13 +29,13 @@ const X = async (t, e, o, u, d = [], l, E = !1) => {
|
|
|
29
29
|
});
|
|
30
30
|
const i = [...await I(t, e, o)], a = [];
|
|
31
31
|
for (let r = 0; r < e.length; r += 1) {
|
|
32
|
-
const { outputUtxos:
|
|
33
|
-
a.push(
|
|
32
|
+
const { outputUtxos: y } = C(t.userKeys, i[r], o[r]);
|
|
33
|
+
a.push(y);
|
|
34
34
|
}
|
|
35
35
|
const s = await t.getRandomRelay();
|
|
36
36
|
if (!s)
|
|
37
37
|
throw Error(A.RELAYER_NOT_AVAILABLE);
|
|
38
|
-
const { contractData:
|
|
38
|
+
const { contractData: x } = g[t.getCurrentChainId()], { emporiumAddress: p } = x;
|
|
39
39
|
if (!p)
|
|
40
40
|
throw Error("No Emporium Address Provided");
|
|
41
41
|
const { zkCallData: n, circomData: c, dimData: f } = await R(
|
|
@@ -48,7 +48,6 @@ const X = async (t, e, o, u, d = [], l, E = !1) => {
|
|
|
48
48
|
i[0].length,
|
|
49
49
|
p,
|
|
50
50
|
d,
|
|
51
|
-
t.generateProofRemotely,
|
|
52
51
|
s,
|
|
53
52
|
t.getCurrentChainId(),
|
|
54
53
|
u,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("../../constants/chains.constants.cjs"),I=require("../../error-handling/error-codes.constants.cjs"),m=require("../../functions/pre-transaction/getFlatFees.cjs"),U=require("../../functions/pre-transaction/processAmountChanges.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("../../constants/chains.constants.cjs"),I=require("../../error-handling/error-codes.constants.cjs"),m=require("../../functions/pre-transaction/getFlatFees.cjs"),U=require("../../functions/pre-transaction/processAmountChanges.cjs"),b=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),P=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),S=require("../../functions/web3/events/getShieldedBalance.cjs"),T=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),h=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),c=require("../../types/external-action.types.cjs"),D=(e,s)=>{const{contractData:t}=q.networkRegistry[e.getCurrentChainId()];let r;switch(s){case c.ExternalActionId.Uniswap:r=t?.uniswapExternalActionAddress;break;case c.ExternalActionId.Odos:r=t?.odosExternalActionInstanceAddress;break;case c.ExternalActionId.OneInch:r=t?.oneInchExternalActionInstanceAddress;break;default:r=t?.uniswapExternalActionAddress;break}if(!r)throw new Error("No external Address set during swap");return r},F=async(e,s,t,r,p,g=!1,w=!1)=>{const{flatFees:i,feeUnit:y}=await m.getFlatFees(e.getCurrentChainId(),s,r,t);t=U.processAmountChanges({erc20Addresses:s,amountChanges:t,flatFees:i,feeUnit:y,externalActionId:r});const E=D(e,r),n={externalActionId:r,externalAddress:E,externalActionMetadata:p},o=[...await S.addPaddingToUtxos(e,s,t)],f=`swapperM${t.length.toString()}x${o[0].length}x1`,C=[!1,!0],l=[];for(let a=0;a<s.length;a+=1){const{outputUtxos:R}=b.outputUtxoProcessing(e.userKeys,o[a],t[a]);l.push(R)}const u=await e.getRandomRelay();if(!u)throw Error(I.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{zkCallData:d,circomData:A,dimData:x}=await P.constructZkProof(e.merkleTreeHinkal,e.merkleTreeAccessToken,o,l,e.userKeys,f,n.externalActionId,n.externalAddress,n.externalActionMetadata,u,e.getCurrentChainId(),C,i);return g?await T.estimateGasRelayer(e,d,x,A):await h.transactCallRelayer(e.getCurrentChainId(),d,x,A,w)};exports.hinkalSwap=F;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { networkRegistry as
|
|
1
|
+
import { networkRegistry as R } from "../../constants/chains.constants.mjs";
|
|
2
2
|
import { transactionErrorCodes as I } from "../../error-handling/error-codes.constants.mjs";
|
|
3
3
|
import { getFlatFees as U } from "../../functions/pre-transaction/getFlatFees.mjs";
|
|
4
4
|
import { processAmountChanges as D } from "../../functions/pre-transaction/processAmountChanges.mjs";
|
|
5
5
|
import { outputUtxoProcessing as T } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
6
6
|
import { constructZkProof as b } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
7
|
-
import { addPaddingToUtxos as
|
|
8
|
-
import { estimateGasRelayer as
|
|
9
|
-
import { transactCallRelayer as
|
|
7
|
+
import { addPaddingToUtxos as F } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
8
|
+
import { estimateGasRelayer as L } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
9
|
+
import { transactCallRelayer as M } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
10
10
|
import { ExternalActionId as i } from "../../types/external-action.types.mjs";
|
|
11
|
-
const
|
|
12
|
-
const { contractData: e } =
|
|
11
|
+
const N = (t, a) => {
|
|
12
|
+
const { contractData: e } = R[t.getCurrentChainId()];
|
|
13
13
|
let r;
|
|
14
|
-
switch (
|
|
14
|
+
switch (a) {
|
|
15
15
|
case i.Uniswap:
|
|
16
16
|
r = e?.uniswapExternalActionAddress;
|
|
17
17
|
break;
|
|
@@ -28,50 +28,49 @@ const M = (t, o) => {
|
|
|
28
28
|
if (!r)
|
|
29
29
|
throw new Error("No external Address set during swap");
|
|
30
30
|
return r;
|
|
31
|
-
},
|
|
31
|
+
}, H = async (t, a, e, r, u, A = !1, x = !1) => {
|
|
32
32
|
const { flatFees: c, feeUnit: w } = await U(
|
|
33
33
|
t.getCurrentChainId(),
|
|
34
|
-
|
|
34
|
+
a,
|
|
35
35
|
r,
|
|
36
36
|
e
|
|
37
37
|
);
|
|
38
|
-
e = D({ erc20Addresses:
|
|
39
|
-
const
|
|
38
|
+
e = D({ erc20Addresses: a, amountChanges: e, flatFees: c, feeUnit: w, externalActionId: r });
|
|
39
|
+
const E = N(t, r), s = {
|
|
40
40
|
externalActionId: r,
|
|
41
|
-
externalAddress:
|
|
41
|
+
externalAddress: E,
|
|
42
42
|
externalActionMetadata: u
|
|
43
|
-
}, n = [...await
|
|
44
|
-
for (let
|
|
45
|
-
const { outputUtxos:
|
|
46
|
-
d.push(
|
|
43
|
+
}, n = [...await F(t, a, e)], g = `swapperM${e.length.toString()}x${n[0].length}x1`, y = [!1, !0], d = [];
|
|
44
|
+
for (let o = 0; o < a.length; o += 1) {
|
|
45
|
+
const { outputUtxos: C } = T(t.userKeys, n[o], e[o]);
|
|
46
|
+
d.push(C);
|
|
47
47
|
}
|
|
48
48
|
const l = await t.getRandomRelay();
|
|
49
49
|
if (!l)
|
|
50
50
|
throw Error(I.RELAYER_NOT_AVAILABLE);
|
|
51
|
-
const { zkCallData:
|
|
51
|
+
const { zkCallData: p, circomData: m, dimData: f } = await b(
|
|
52
52
|
t.merkleTreeHinkal,
|
|
53
53
|
t.merkleTreeAccessToken,
|
|
54
54
|
n,
|
|
55
55
|
d,
|
|
56
56
|
t.userKeys,
|
|
57
|
-
|
|
57
|
+
g,
|
|
58
58
|
s.externalActionId,
|
|
59
59
|
s.externalAddress,
|
|
60
60
|
s.externalActionMetadata,
|
|
61
|
-
t.generateProofRemotely,
|
|
62
61
|
l,
|
|
63
62
|
t.getCurrentChainId(),
|
|
64
63
|
y,
|
|
65
64
|
c
|
|
66
65
|
);
|
|
67
|
-
return A ? await
|
|
66
|
+
return A ? await L(t, p, f, m) : await M(
|
|
68
67
|
t.getCurrentChainId(),
|
|
69
|
-
m,
|
|
70
|
-
f,
|
|
71
68
|
p,
|
|
69
|
+
f,
|
|
70
|
+
m,
|
|
72
71
|
x
|
|
73
72
|
);
|
|
74
73
|
};
|
|
75
74
|
export {
|
|
76
|
-
|
|
75
|
+
H as hinkalSwap
|
|
77
76
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/protocol.constants.cjs"),I=require("../../error-handling/error-codes.constants.cjs"),f=require("../../functions/utils/erc20tokenFunctions.cjs"),m=require("../../functions/pre-transaction/getFlatFees.cjs"),F=require("../../functions/pre-transaction/processAmountChanges.cjs"),D=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/protocol.constants.cjs"),I=require("../../error-handling/error-codes.constants.cjs"),f=require("../../functions/utils/erc20tokenFunctions.cjs"),m=require("../../functions/pre-transaction/getFlatFees.cjs"),F=require("../../functions/pre-transaction/processAmountChanges.cjs"),D=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),U=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),P=require("../../functions/web3/events/getShieldedBalance.cjs"),R=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),_=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),h=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),g=require("../../types/external-action.types.cjs"),M=async(t,o,e,C,n,p=!1)=>{const{flatFees:d,feeUnit:w}=await m.getFlatFees(t.getCurrentChainId(),o,g.ExternalActionId.Transact,e);n||F.processAmountChanges({erc20Addresses:o,amountChanges:e,flatFees:d,feeUnit:w,externalActionId:g.ExternalActionId.Transact});const a=f.getERC20Token(o[0],t.getCurrentChainId());if(!a)throw Error("Deposit Action: No Token Found");const s={externalActionId:0n,externalAddress:C,externalActionMetadata:"0x00"},c=[...await P.addPaddingToUtxos(t,o,e)],q=`swapperM${e.length.toString()}x${c[0].length}x1`,E=[!1],x=[];for(let r=0;r<o.length;r+=1){const{outputUtxos:y}=D.outputUtxoProcessing(t.userKeys,c[r],e[r]);x.push(y)}const A=await t.getRandomRelay();if(!n&&!A)throw Error(I.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{zkCallData:i,circomData:u,dimData:l}=await U.constructZkProof(t.merkleTreeHinkal,t.merkleTreeAccessToken,c,x,t.userKeys,q,s.externalActionId,s.externalAddress,s.externalActionMetadata,n?T.zeroAddress:A,t.getCurrentChainId(),E,d);if(p)return await R.estimateGasRelayer(t,i,l,u);if(n){if(!a)throw Error("Withdraw Action: No Token Found");return await _.transactCallDirect(t,e[0],a,i,u,l)}return await h.transactCallRelayer(t.getCurrentChainId(),i,l,u)};exports.hinkalWithdraw=M;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { IHinkal } from './IHinkal';
|
|
2
|
-
export declare const hinkalWithdraw: (hinkal: IHinkal, erc20Addresses: string[], amountChanges: bigint[], recipientAddress: string, isRelayerOff: boolean, onlyGasEstimate?: boolean) => Promise<
|
|
2
|
+
export declare const hinkalWithdraw: (hinkal: IHinkal, erc20Addresses: string[], amountChanges: bigint[], recipientAddress: string, isRelayerOff: boolean, onlyGasEstimate?: boolean) => Promise<bigint | import('../../index.ts').RelayerTransaction | import("ethers").ContractTransaction>;
|
|
@@ -4,13 +4,13 @@ import { getERC20Token as y } from "../../functions/utils/erc20tokenFunctions.mj
|
|
|
4
4
|
import { getFlatFees as D } from "../../functions/pre-transaction/getFlatFees.mjs";
|
|
5
5
|
import { processAmountChanges as U } from "../../functions/pre-transaction/processAmountChanges.mjs";
|
|
6
6
|
import { outputUtxoProcessing as F } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
7
|
-
import { constructZkProof as
|
|
8
|
-
import { addPaddingToUtxos as
|
|
9
|
-
import { estimateGasRelayer as
|
|
10
|
-
import { transactCallDirect as
|
|
11
|
-
import { transactCallRelayer as
|
|
7
|
+
import { constructZkProof as N } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
8
|
+
import { addPaddingToUtxos as R } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
9
|
+
import { estimateGasRelayer as L } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
10
|
+
import { transactCallDirect as M } from "../../functions/web3/functionCalls/transactCallDirect.mjs";
|
|
11
|
+
import { transactCallRelayer as P } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
12
12
|
import { ExternalActionId as l } from "../../types/external-action.types.mjs";
|
|
13
|
-
const
|
|
13
|
+
const h = async (t, e, r, u, a, A = !1) => {
|
|
14
14
|
const { flatFees: x, feeUnit: w } = await D(
|
|
15
15
|
t.getCurrentChainId(),
|
|
16
16
|
e,
|
|
@@ -31,7 +31,7 @@ const j = async (t, e, r, u, a, A = !1) => {
|
|
|
31
31
|
externalActionId: 0n,
|
|
32
32
|
externalAddress: u,
|
|
33
33
|
externalActionMetadata: "0x00"
|
|
34
|
-
}, c = [...await
|
|
34
|
+
}, c = [...await R(t, e, r)], g = `swapperM${r.length.toString()}x${c[0].length}x1`, C = [!1], d = [];
|
|
35
35
|
for (let o = 0; o < e.length; o += 1) {
|
|
36
36
|
const { outputUtxos: E } = F(t.userKeys, c[o], r[o]);
|
|
37
37
|
d.push(E);
|
|
@@ -39,7 +39,7 @@ const j = async (t, e, r, u, a, A = !1) => {
|
|
|
39
39
|
const f = await t.getRandomRelay();
|
|
40
40
|
if (!a && !f)
|
|
41
41
|
throw Error(I.RELAYER_NOT_AVAILABLE);
|
|
42
|
-
const { zkCallData: s, circomData: m, dimData: p } = await
|
|
42
|
+
const { zkCallData: s, circomData: m, dimData: p } = await N(
|
|
43
43
|
t.merkleTreeHinkal,
|
|
44
44
|
t.merkleTreeAccessToken,
|
|
45
45
|
c,
|
|
@@ -49,21 +49,20 @@ const j = async (t, e, r, u, a, A = !1) => {
|
|
|
49
49
|
i.externalActionId,
|
|
50
50
|
i.externalAddress,
|
|
51
51
|
i.externalActionMetadata,
|
|
52
|
-
t.generateProofRemotely,
|
|
53
52
|
a ? T : f,
|
|
54
53
|
t.getCurrentChainId(),
|
|
55
54
|
C,
|
|
56
55
|
x
|
|
57
56
|
);
|
|
58
57
|
if (A)
|
|
59
|
-
return await
|
|
58
|
+
return await L(t, s, p, m);
|
|
60
59
|
if (a) {
|
|
61
60
|
if (!n)
|
|
62
61
|
throw Error("Withdraw Action: No Token Found");
|
|
63
|
-
return await
|
|
62
|
+
return await M(t, r[0], n, s, m, p);
|
|
64
63
|
}
|
|
65
|
-
return await
|
|
64
|
+
return await P(t.getCurrentChainId(), s, p, m);
|
|
66
65
|
};
|
|
67
66
|
export {
|
|
68
|
-
|
|
67
|
+
h as hinkalWithdraw
|
|
69
68
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../error-handling/logError.cjs"),u=require("./MerkleTreeIncompleteError.cjs");class h{constructor(t,e,n,i,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../error-handling/logError.cjs"),u=require("./MerkleTreeIncompleteError.cjs");class h{constructor(t,e,r,n,i,s){this.hashFunction=t,this.levels=e,this.defaultNodeValue=r,this.tree=n??new Map,this.count=s??0n,this.index=i??2n**(e-1n)}tree;count;index;static createWithData(t,e,r,n,i,s){return new h(n,i,s,t,e,r)}static create(t,e,r){return new h(t,e,r)}getStartIndex(){return 2n**(this.levels-1n)}logarithm2(t){let e=0n;for(;2n**e<t;)e+=1n;return e}bigIntMax(t,e){return t>e?t:e}forceInsert(t,e){if(e<this.getStartIndex())throw new RangeError;this.tree.set(e,t);const r=this.index-this.getStartIndex(),n=this.logarithm2(r);let i=e;for(let s=1n;s<=n;s+=1n){i/=2n;const l=this.hashFunction(this.tree.get(i*2n)||this.defaultNodeValue,this.tree.get(i*2n+1n)||this.defaultNodeValue);this.tree.set(i,l)}}insert(t,e){let r=!1;return this.tree.has(e)&&(r=!0,o.logError(`Editing commitment index: ${e} `)),r||(this.count+=1n),this.index=this.bigIntMax(this.index,e+1n),this.forceInsert(t,e),!0}remove(t){this.forceInsert(this.defaultNodeValue,t)}completenessCheck(){if(this.count!==this.index-this.getStartIndex())throw new u.MerkleTreeIncompleteError}getRootHash(){this.completenessCheck();for(let t=1n;t<2n**this.levels;t*=2n)if(this.tree.get(t))return this.tree.get(t);return this.defaultNodeValue}getMerkleData(){return this.completenessCheck(),new Map(this.tree)}getSiblingIndex(t){return t===1n?1n:t%2n===1n?t-1n:t+1n}getSiblingHashesForVerification(t){this.completenessCheck();let e;for(let n=this.getStartIndex();n<this.getStartIndex()+this.index;n+=1n)if(this.tree.get(n)===t){e=n;break}if(e===void 0)return new Array(Number(this.levels)).fill(0n);const r=[];for(;e!==0n;)r.push(this.tree.get(this.getSiblingIndex(e))||this.defaultNodeValue),e/=2n;return r}getSiblingSides(t){this.completenessCheck();let e;for(let n=this.getStartIndex();n<this.getStartIndex()+this.index;n+=1n)if(this.tree.get(n)===t){e=n;break}if(e===void 0)return new Array(Number(this.levels)).fill(0n);const r=[];for(;e!==0n;){const n=e%2n===0n?0n:1n;r.push(n),e/=2n}return r}toJSON(){const{tree:t,count:e,index:r}=this;return{tree:Object.fromEntries(t),count:e.toString(),index:r.toString()}}}exports.MerkleTree=h;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { logError as l } from "../../error-handling/logError.mjs";
|
|
2
2
|
import { MerkleTreeIncompleteError as a } from "./MerkleTreeIncompleteError.mjs";
|
|
3
3
|
class h {
|
|
4
|
-
constructor(e, t,
|
|
5
|
-
this.hashFunction = e, this.levels = t, this.defaultNodeValue =
|
|
4
|
+
constructor(e, t, n, i, r, s) {
|
|
5
|
+
this.hashFunction = e, this.levels = t, this.defaultNodeValue = n, this.tree = i ?? /* @__PURE__ */ new Map(), this.count = s ?? 0n, this.index = r ?? 2n ** (t - 1n);
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* the map where the items are stored
|
|
@@ -18,16 +18,16 @@ class h {
|
|
|
18
18
|
* meaning that there aren't any missing elements between getStartIndex() and index
|
|
19
19
|
*/
|
|
20
20
|
index;
|
|
21
|
-
static createWithData(e, t,
|
|
22
|
-
return new h(
|
|
21
|
+
static createWithData(e, t, n, i, r, s) {
|
|
22
|
+
return new h(i, r, s, e, t, n);
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* @param hashFunction the hashFunction used to fill the upper layers of the merkle tree
|
|
26
26
|
* @param levels the amount of layers in the merkle tree
|
|
27
27
|
* @param defaultNodeValue the default value of an empty node in the merkle tree
|
|
28
28
|
*/
|
|
29
|
-
static create(e, t,
|
|
30
|
-
return new h(e, t,
|
|
29
|
+
static create(e, t, n) {
|
|
30
|
+
return new h(e, t, n);
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* get starting nodeIndex from which inserts are allowed
|
|
@@ -51,9 +51,9 @@ class h {
|
|
|
51
51
|
if (t < this.getStartIndex())
|
|
52
52
|
throw new RangeError();
|
|
53
53
|
this.tree.set(t, e);
|
|
54
|
-
const
|
|
54
|
+
const n = this.index - this.getStartIndex(), i = this.logarithm2(n);
|
|
55
55
|
let r = t;
|
|
56
|
-
for (let s = 1n; s <=
|
|
56
|
+
for (let s = 1n; s <= i; s += 1n) {
|
|
57
57
|
r /= 2n;
|
|
58
58
|
const o = this.hashFunction(
|
|
59
59
|
this.tree.get(r * 2n) || this.defaultNodeValue,
|
|
@@ -70,8 +70,8 @@ class h {
|
|
|
70
70
|
* @throws will throw RangeError if nodeIndex is less than getStartIndex()
|
|
71
71
|
*/
|
|
72
72
|
insert(e, t) {
|
|
73
|
-
let
|
|
74
|
-
return this.tree.has(t) && (
|
|
73
|
+
let n = !1;
|
|
74
|
+
return this.tree.has(t) && (n = !0, l(`Editing commitment index: ${t} `)), n || (this.count += 1n), this.index = this.bigIntMax(this.index, t + 1n), this.forceInsert(e, t), !0;
|
|
75
75
|
}
|
|
76
76
|
remove(e) {
|
|
77
77
|
this.forceInsert(this.defaultNodeValue, e);
|
|
@@ -105,17 +105,17 @@ class h {
|
|
|
105
105
|
getSiblingHashesForVerification(e) {
|
|
106
106
|
this.completenessCheck();
|
|
107
107
|
let t;
|
|
108
|
-
for (let
|
|
109
|
-
if (this.tree.get(
|
|
110
|
-
t =
|
|
108
|
+
for (let i = this.getStartIndex(); i < this.getStartIndex() + this.index; i += 1n)
|
|
109
|
+
if (this.tree.get(i) === e) {
|
|
110
|
+
t = i;
|
|
111
111
|
break;
|
|
112
112
|
}
|
|
113
113
|
if (t === void 0)
|
|
114
114
|
return new Array(Number(this.levels)).fill(0n);
|
|
115
|
-
const
|
|
115
|
+
const n = [];
|
|
116
116
|
for (; t !== 0n; )
|
|
117
|
-
|
|
118
|
-
return
|
|
117
|
+
n.push(this.tree.get(this.getSiblingIndex(t)) || this.defaultNodeValue), t /= 2n;
|
|
118
|
+
return n;
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
121
121
|
* get item's sibling hashes side
|
|
@@ -125,41 +125,28 @@ class h {
|
|
|
125
125
|
getSiblingSides(e) {
|
|
126
126
|
this.completenessCheck();
|
|
127
127
|
let t;
|
|
128
|
-
for (let
|
|
129
|
-
if (this.tree.get(
|
|
130
|
-
t =
|
|
128
|
+
for (let i = this.getStartIndex(); i < this.getStartIndex() + this.index; i += 1n)
|
|
129
|
+
if (this.tree.get(i) === e) {
|
|
130
|
+
t = i;
|
|
131
131
|
break;
|
|
132
132
|
}
|
|
133
133
|
if (t === void 0)
|
|
134
134
|
return new Array(Number(this.levels)).fill(0n);
|
|
135
|
-
const
|
|
135
|
+
const n = [];
|
|
136
136
|
for (; t !== 0n; ) {
|
|
137
|
-
const
|
|
138
|
-
|
|
137
|
+
const i = t % 2n === 0n ? 0n : 1n;
|
|
138
|
+
n.push(i), t /= 2n;
|
|
139
139
|
}
|
|
140
|
-
return
|
|
140
|
+
return n;
|
|
141
141
|
}
|
|
142
142
|
toJSON() {
|
|
143
|
-
const { tree: e, count: t, index:
|
|
143
|
+
const { tree: e, count: t, index: n } = this;
|
|
144
144
|
return {
|
|
145
145
|
tree: Object.fromEntries(e),
|
|
146
146
|
count: t.toString(),
|
|
147
|
-
index:
|
|
147
|
+
index: n.toString()
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
|
-
clone() {
|
|
151
|
-
return h.createWithData(
|
|
152
|
-
new Map(this.tree),
|
|
153
|
-
this.index,
|
|
154
|
-
this.count,
|
|
155
|
-
this.hashFunction,
|
|
156
|
-
this.levels,
|
|
157
|
-
this.defaultNodeValue
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
getIndex() {
|
|
161
|
-
return this.index;
|
|
162
|
-
}
|
|
163
150
|
}
|
|
164
151
|
export {
|
|
165
152
|
h as MerkleTree
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("axios");require("../../constants/coingecko.constants.cjs");const y=require("../../API/API.cjs");require("ethers");require("../../types/curve.types.cjs");
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("axios");require("../../constants/coingecko.constants.cjs");const y=require("../../API/API.cjs");require("ethers");require("../../types/curve.types.cjs");const A=require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const k=require("../../functions/snarkjs/generateZkProof.cjs");require("../../types/circom-data.types.cjs");const q=require("../../types/transactions.types.cjs"),I=require("../../types/time.types.cjs"),x=require("./history/getTxDetails.cjs");require("circomlibjs-hinkal-fork");const P=require("../../error-handling/error-codes.constants.cjs"),w=require("../crypto-keys/keys.cjs"),C=require("../crypto-keys/encryptDecryptUtxo.cjs"),p=require("../../functions/utils/getDataFromTransaction.cjs"),S=require("../../functions/utils/cacheFunctions.cjs");class v{circuitSize=50;hinkalContract;init(e){this.hinkalContract=e}requireInit(){if(!this.hinkalContract)throw Error("TransactionsManager not initialized")}filterOwnTransactions=async(e,t,r,n)=>{const{transactMethodId:s,transactWithExternalActionMethodId:a,hinkalInterface:i}=A.getHinkalParameters(T.getNonLocalhostChainId(e)),c=o=>"decodedInput"in o,d=t.filter(o=>o.methodId===s||o.methodId===a).map(o=>c(o)?o:{...o,decodedInput:p.decodeTxInput(i,o.input),status:o.isError==="0"?"SUCCESS":"FAILURE"}),h=r.getShieldedPrivateKey();return d.filter(o=>{try{if(c(o)){if(C.decryptUtxo(Buffer.from(o.decodedInput.encryptedOutputs[0].slice(2),"hex"),r),!n&&o.methodId===s){const{extraRandomization:f,H0:g,H1:m}=o.decodedInput.stealthAddressStructure;return w.UserKeys.checkSignature(f,g,m,h)}return!0}return!1}catch{return!1}})};saveTxsInStorage=(e,t,r,n)=>{const s=r.getShieldedPublicKey();return S.saveTxsCache(e,t,s,this.hinkalContract.address,n)};loadTxsFromStorage=async(e,t)=>{const r=t.getShieldedPublicKey();return await S.loadTxsCache(e,r,this.hinkalContract.address)};getAllTransactions=async(e,t,r)=>{if(r){const{transactions:i}=await y.API.userGetTransactions(e,r);return i}const{decodedTxs:n,lastHash:s}=await this.loadTxsFromStorage(e,t),{transactions:a}=await y.API.userGetTransactions(e,r,s);return[...a,...n]};getHinkalHistoryBase=async(e,t,r,n=!1)=>{this.requireInit();const s=await this.getAllTransactions(e,t,r)??[];s.sort((i,c)=>c.timeStamp-i.timeStamp);const a=await this.filterOwnTransactions(e,s,t,n);return!r&&s.length>0&&await this.saveTxsInStorage(a,e,t,s[0].hash),a};getHinkalHistory=async(e,t)=>{const r=await this.getHinkalHistoryBase(e,t,void 0,!0),n=p.decodeTxLogs(e,r);return await Promise.all(n.map(async a=>({...a,status:a.status,details:await x.getTxDetails(e,a.decodedInput,a.utxosArray)})))};sortInBatches=e=>{const t=[];let r=0,n=0;e.forEach(i=>{r===0&&t.push([]),t[n].push(i),r+=1,r===this.circuitSize&&(r=0,n+=1)});const s=t[t.length-1],a=s.length;if(a<this.circuitSize){const i=this.circuitSize-a,c=new Array(i).fill(q.emptyDecodedTx);t[t.length-1]=s.concat(c)}return t};generateTransactionsProof=async(e,t,r)=>{const n=this.sortInBatches(t),s=new Array(n.length).fill([]);for(let a=0;a<n.length;a+=1){const i=n[a].map(u=>u.decodedInput.stealthAddressStructure),c=i.map(u=>u.extraRandomization),l=i.map(u=>u.stealthAddress),d={shieldedPrivateKey:r,extraRandomizations:c,stealthAddresses:l},{zkCallData:h}=await k.generateZkProof(e,"transactionsProver",d);s[a]=h}return{zkCallDataArray:s}};userVerifyTransactions=async(e,t,r,n,s,a)=>await y.API.userVerifyTransactions(e,t,r,n,s,a);processAndSendTransactionsForVerification=async(e,t,r,n)=>{this.requireInit();const s=I.getCurrentWeek(),a=n?s-1:s,i=await this.getHinkalHistoryBase(e,t,a);let c=[],l=[];i.length>0&&({zkCallDataArray:l}=await this.generateTransactionsProof(e,i,t.getShieldedPrivateKey()),c=i.map(g=>g.hash));const d=t.getBackendToken(),{trade:h,transactions:u,lockedDeposit:o,verification:f}=await this.userVerifyTransactions(e,c,l,d,r,a);return{trade:h,transactions:u,lockedDeposit:o,verification:f}};multiProcessAndSendTransactionsForVerification=async(e,t)=>{const r=T.chainIdsByType[T.EthereumNetworkType.Mainnet];let n=!0;for(let s=0;s<r.length;s+=1)try{const{hasCertified:a}=await y.API.verificationStartDate(r[s],t);if(a)continue;const{verification:i}=await this.processAndSendTransactionsForVerification(r[s],e,t,!0);if(n=n&&i,!n)break}catch(a){console.log(`current chain ${r[s]} certification error`,{err:a}),n=!1;break}if(!n)throw Error(P.transactionErrorCodes.MULTI_VERIFICATION_FAILED);return!0}}exports.TransactionsManager=v;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Contract } from 'ethers';
|
|
2
|
-
import { DecodedTx,
|
|
2
|
+
import { DecodedTx, RawTx } from '../../types';
|
|
3
3
|
import { TransactionField } from './history/history.types';
|
|
4
4
|
import { UserKeys } from '../crypto-keys';
|
|
5
5
|
export declare class TransactionsManager {
|
|
@@ -10,18 +10,17 @@ export declare class TransactionsManager {
|
|
|
10
10
|
private filterOwnTransactions;
|
|
11
11
|
private saveTxsInStorage;
|
|
12
12
|
private loadTxsFromStorage;
|
|
13
|
-
getAllTransactions: (chainId: number, userKeys: UserKeys, week?: number
|
|
14
|
-
getHinkalHistoryBase: (chainId: number, userKeys: UserKeys, week?: number, includeOthersDeposits?: boolean
|
|
13
|
+
getAllTransactions: (chainId: number, userKeys: UserKeys, week?: number) => Promise<RawTx[]>;
|
|
14
|
+
getHinkalHistoryBase: (chainId: number, userKeys: UserKeys, week?: number, includeOthersDeposits?: boolean) => Promise<DecodedTx[]>;
|
|
15
15
|
getHinkalHistory: (chainId: number, userKeys: UserKeys) => Promise<TransactionField[]>;
|
|
16
16
|
private sortInBatches;
|
|
17
17
|
private generateTransactionsProof;
|
|
18
18
|
private userVerifyTransactions;
|
|
19
|
-
|
|
20
|
-
processAndSendTransactionsForVerification: (chainId: number, userKeys: UserKeys, ethereumAddress: string, latestCertifiedHash?: string, startWeek?: number) => Promise<{
|
|
19
|
+
processAndSendTransactionsForVerification: (chainId: number, userKeys: UserKeys, ethereumAddress: string, isPastWeek: boolean) => Promise<{
|
|
21
20
|
trade: number;
|
|
22
21
|
transactions: number;
|
|
23
22
|
lockedDeposit: number;
|
|
24
23
|
verification: boolean;
|
|
25
24
|
}>;
|
|
26
|
-
multiProcessAndSendTransactionsForVerification: (userKeys: UserKeys, ethereumAddress: string
|
|
25
|
+
multiProcessAndSendTransactionsForVerification: (userKeys: UserKeys, ethereumAddress: string) => Promise<boolean>;
|
|
27
26
|
}
|