@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,6 +1,6 @@
|
|
|
1
1
|
import { chainIds as p } from "../../constants/chains.constants.mjs";
|
|
2
2
|
import { logError as x } from "../../error-handling/logError.mjs";
|
|
3
|
-
const
|
|
3
|
+
const e = {
|
|
4
4
|
ethMainnet: "https://hinkal-zk-verifiers-may-2024.s3.us-west-1.amazonaws.com/",
|
|
5
5
|
polygon: "https://hinkal-zk-new-verifiers.s3.us-west-1.amazonaws.com/",
|
|
6
6
|
bnb: "https://hinkal-zk-verifiers-may-2024.s3.us-west-1.amazonaws.com/",
|
|
@@ -27,7 +27,7 @@ const k = "https://enclave-server.hinkal.pro", e = {
|
|
|
27
27
|
default:
|
|
28
28
|
return x("Warning: no S3 bucket specified for selected chainid: ", s), e.polygon;
|
|
29
29
|
}
|
|
30
|
-
},
|
|
30
|
+
}, k = (s) => {
|
|
31
31
|
const a = r(s);
|
|
32
32
|
return {
|
|
33
33
|
swapperM1x2x1Zkey: `${a}swapperM1x2x1_final-31337.zkey`,
|
|
@@ -101,7 +101,7 @@ const k = "https://enclave-server.hinkal.pro", e = {
|
|
|
101
101
|
swapperMW5x6Wasm: `${a}swapperMW5x6-31337.wasm`,
|
|
102
102
|
swapperMW5x6Zkey: `${a}swapperMW5x6_final-31337.zkey`
|
|
103
103
|
};
|
|
104
|
-
},
|
|
104
|
+
}, m = {
|
|
105
105
|
swapperM1x2x1Zkey: "swapperM1x2x1_final-31337.zkey",
|
|
106
106
|
swapperM1x2x1Wasm: "swapperM1x2x1-31337.wasm",
|
|
107
107
|
swapperM1x6x1Zkey: "swapperM1x6x1_final-31337.zkey",
|
|
@@ -180,7 +180,6 @@ const k = "https://enclave-server.hinkal.pro", e = {
|
|
|
180
180
|
swapperMW5x6Zkey: "swapperMW5x6_final-31337.zkey"
|
|
181
181
|
};
|
|
182
182
|
export {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
m as prodVerifiers
|
|
183
|
+
m as localVerifiers,
|
|
184
|
+
k as prodVerifiers
|
|
186
185
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("../../data-structures/utxo/Utxo.cjs"),J=require("../../constants/protocol.constants.cjs"),$=require("../../constants/chains.constants.cjs"),u=require("../../webworker/zkProofWorker/zkProofWorker.types.cjs"),S=require("../../webworker/performTaskWithWorker.cjs"),p=require("../../webworker/worker.registry.cjs"),n=require("./common.snarkjs.cjs"),F=require("../web3/etherFunctions.cjs"),Q=require("../private-wallet/emporium.helpers.cjs"),X=require("../../types/external-action.types.cjs"),Y=require("../../types/circom-data.types.cjs"),x=require("./generateCircomData.cjs"),U=require("./generateZkProof.cjs"),ee=async(k,g,t,a,s,N,b,E,z,A=J.zeroAddress,H=$.chainIds.localhost,i=t.map(()=>!1),h=t.map(()=>0n),c,te,ae)=>{const f=k.getRootHash(),y=g.getRootHash(),T=t.map(e=>e.map(o=>o.getConstructableParams())),_=s.getSignature(),{accessTokenSiblings:v,accessTokenSiblingSides:K}=await S.performTaskWithWorker({type:p.WorkerVariant.ZKProof,payload:{type:u.ZKProofWorkerActionType.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES,data:{userSignature:_,merkleTreeAccessTokenSerialized:g.toJSON()}}}),{inCommitmentSiblings:O,inCommitmentSiblingSides:Z}=await S.performTaskWithWorker({type:p.WorkerVariant.ZKProof,payload:{type:u.ZKProofWorkerActionType.CALC_COMMITMENTS_SIBLING_AND_SIDES,data:{inputUtxosSerialized:T,userSignature:_,merkleTreeSerialized:k.toJSON()}}}),L=n.calcAmountChanges(t,a),m=n.calcEncryptedOutputs(a,!1),l=s.getShieldedPrivateKey(),I=G.Utxo.findCorrectRandomization(F.randomBigInt(31),l),M=await S.performTaskWithWorker({type:p.WorkerVariant.ZKProof,payload:{type:u.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS,data:{inputUtxosSerialized:T,onChainCreation:i}}}),d=t.map(e=>e[0].tokenId??0),r={rootHashHinkal:f,erc20TokenAddresses:t.map(e=>e[0].erc20TokenAddress),tokenIds:d,inNullifiers:M,outTimeStamp:BigInt(a[0][0].timeStamp),extraRandomization:I,amountChanges:L,outCommitments:n.buildOutCommitments(a,i).map(e=>e[0]),rootHashAccessToken:y,calldataHash:0n,shieldedPrivateKey:l,hinkalWalletNonce:c??0n,accessTokenSiblings:v,accessTokenSiblingSides:K,onChainCreation:i,outAmounts:a.map(e=>e[0].amount),outPublicKeys:a.map(e=>e[0].getStealthAddress()),inAmounts:t.map(e=>e.map(o=>o.amount.toString())),inTimeStamps:t.map(e=>e.map(o=>o.timeStamp)),inRandomizations:t.map(e=>e.map(o=>o.randomization)),inCommitmentSiblings:O,inCommitmentSiblingSides:Z},w=c?s.getWalletSalt(c):void 0;let W=E,C=X.ExternalActionId.Emporium,P=Q.encodeEmporiumMetadata(z,w);const q=`swapperMW${N}x${b}`,D=n.calcPublicSignalCount(q,r.erc20TokenAddresses,r.amountChanges,r.inNullifiers,r.outCommitments,d.length);r.calldataHash=n.createCallDataHash(D,A,W,C,P,m,h,void 0);const{zkCallData:R}=await U.generateZkProof(H,q,r),B=n.calcStealthAddressStructure(I,l),V=await x.generateCircomData(f,y,t,a,m,h,D,C,W,P,A,r.calldataHash,d,B,i,Y.defaultHookData),j={tokenNumber:t.length,nullifierAmount:t[0].length,outputAmount:a[0].length};return{zkCallData:R,circomData:V,dimData:j,encryptedOutputs:m}};exports.constructEmporiumProof=ee;
|
|
@@ -2,7 +2,7 @@ import { MerkleTree } from '../../data-structures/merkle-tree';
|
|
|
2
2
|
import { Utxo } from '../../data-structures/utxo/Utxo';
|
|
3
3
|
import { UserKeys } from '../../data-structures/crypto-keys/keys';
|
|
4
4
|
import { CircomDataType, DimDataType } from '../../types/circom-data.types';
|
|
5
|
-
export declare const constructEmporiumProof: (merkleTree: MerkleTree<bigint>, merkleTreeAccessToken: MerkleTree<bigint>, inputUtxos: Utxo[][], outputUtxos: Utxo[][], userKeys: UserKeys, tokenCount: number, inputCount: number, emporiumAddress: string, operations: string[],
|
|
5
|
+
export declare const constructEmporiumProof: (merkleTree: MerkleTree<bigint>, merkleTreeAccessToken: MerkleTree<bigint>, inputUtxos: Utxo[][], outputUtxos: Utxo[][], userKeys: UserKeys, tokenCount: number, inputCount: number, emporiumAddress: string, operations: string[], relay?: string, chainId?: number, onChainCreation?: boolean[], flatFees?: bigint[], walletNonce?: bigint, volatileAmounts?: bigint[], volatileAction?: string) => Promise<{
|
|
6
6
|
zkCallData: import('../../index.ts').NewZkCallDataType;
|
|
7
7
|
circomData: CircomDataType;
|
|
8
8
|
dimData: DimDataType;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Utxo as
|
|
2
|
-
import { zeroAddress as
|
|
3
|
-
import { chainIds as
|
|
1
|
+
import { Utxo as $ } from "../../data-structures/utxo/Utxo.mjs";
|
|
2
|
+
import { zeroAddress as V } from "../../constants/protocol.constants.mjs";
|
|
3
|
+
import { chainIds as j } from "../../constants/chains.constants.mjs";
|
|
4
4
|
import { ZKProofWorkerActionType as d } from "../../webworker/zkProofWorker/zkProofWorker.types.mjs";
|
|
5
5
|
import { performTaskWithWorker as p } from "../../webworker/performTaskWithWorker.mjs";
|
|
6
6
|
import { WorkerVariant as S } from "../../webworker/worker.registry.mjs";
|
|
7
|
-
import { calcAmountChanges as
|
|
8
|
-
import { randomBigInt as
|
|
9
|
-
import { encodeEmporiumMetadata as
|
|
10
|
-
import { ExternalActionId as
|
|
11
|
-
import { defaultHookData as
|
|
12
|
-
import { generateCircomData as
|
|
13
|
-
import { generateZkProof as
|
|
14
|
-
const
|
|
15
|
-
const u = f.getRootHash(), k = g.getRootHash(), I = a.map((t) => t.map((r) => r.getConstructableParams())), C = n.getSignature(), { accessTokenSiblings:
|
|
7
|
+
import { calcAmountChanges as q, calcEncryptedOutputs as F, buildOutCommitments as Q, calcPublicSignalCount as X, createCallDataHash as Y, calcStealthAddressStructure as x } from "./common.snarkjs.mjs";
|
|
8
|
+
import { randomBigInt as U } from "../web3/etherFunctions.mjs";
|
|
9
|
+
import { encodeEmporiumMetadata as tt } from "../private-wallet/emporium.helpers.mjs";
|
|
10
|
+
import { ExternalActionId as at } from "../../types/external-action.types.mjs";
|
|
11
|
+
import { defaultHookData as et } from "../../types/circom-data.types.mjs";
|
|
12
|
+
import { generateCircomData as ot } from "./generateCircomData.mjs";
|
|
13
|
+
import { generateZkProof as rt } from "./generateZkProof.mjs";
|
|
14
|
+
const It = async (f, g, a, e, n, _, b, H, z, A = V, v = j.localhost, m = a.map(() => !1), h = a.map(() => 0n), i, mt, nt) => {
|
|
15
|
+
const u = f.getRootHash(), k = g.getRootHash(), I = a.map((t) => t.map((r) => r.getConstructableParams())), C = n.getSignature(), { accessTokenSiblings: L, accessTokenSiblingSides: O } = await p({
|
|
16
16
|
type: S.ZKProof,
|
|
17
17
|
payload: {
|
|
18
18
|
type: d.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES,
|
|
@@ -21,13 +21,13 @@ const Ct = async (f, g, a, e, n, _, b, H, z, v, A = j, L = q.localhost, m = a.ma
|
|
|
21
21
|
merkleTreeAccessTokenSerialized: g.toJSON()
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
}), { inCommitmentSiblings:
|
|
24
|
+
}), { inCommitmentSiblings: W, inCommitmentSiblingSides: K } = await p({
|
|
25
25
|
type: S.ZKProof,
|
|
26
26
|
payload: {
|
|
27
27
|
type: d.CALC_COMMITMENTS_SIBLING_AND_SIDES,
|
|
28
28
|
data: { inputUtxosSerialized: I, userSignature: C, merkleTreeSerialized: f.toJSON() }
|
|
29
29
|
}
|
|
30
|
-
}),
|
|
30
|
+
}), M = q(a, e), l = F(e, !1), s = n.getShieldedPrivateKey(), y = $.findCorrectRandomization(U(31), s), R = await p({
|
|
31
31
|
type: S.ZKProof,
|
|
32
32
|
payload: {
|
|
33
33
|
type: d.BUILD_IN_NULLIFIERS,
|
|
@@ -37,28 +37,28 @@ const Ct = async (f, g, a, e, n, _, b, H, z, v, A = j, L = q.localhost, m = a.ma
|
|
|
37
37
|
rootHashHinkal: u,
|
|
38
38
|
erc20TokenAddresses: a.map((t) => t[0].erc20TokenAddress),
|
|
39
39
|
tokenIds: c,
|
|
40
|
-
inNullifiers:
|
|
40
|
+
inNullifiers: R,
|
|
41
41
|
outTimeStamp: BigInt(e[0][0].timeStamp),
|
|
42
42
|
extraRandomization: y,
|
|
43
|
-
amountChanges:
|
|
44
|
-
outCommitments:
|
|
43
|
+
amountChanges: M,
|
|
44
|
+
outCommitments: Q(e, m).map((t) => t[0]),
|
|
45
45
|
rootHashAccessToken: k,
|
|
46
46
|
calldataHash: 0n,
|
|
47
47
|
shieldedPrivateKey: s,
|
|
48
48
|
hinkalWalletNonce: i ?? 0n,
|
|
49
|
-
accessTokenSiblings:
|
|
50
|
-
accessTokenSiblingSides:
|
|
49
|
+
accessTokenSiblings: L,
|
|
50
|
+
accessTokenSiblingSides: O,
|
|
51
51
|
onChainCreation: m,
|
|
52
52
|
outAmounts: e.map((t) => t[0].amount),
|
|
53
53
|
outPublicKeys: e.map((t) => t[0].getStealthAddress()),
|
|
54
54
|
inAmounts: a.map((t) => t.map((r) => r.amount.toString())),
|
|
55
55
|
inTimeStamps: a.map((t) => t.map((r) => r.timeStamp)),
|
|
56
56
|
inRandomizations: a.map((t) => t.map((r) => r.randomization)),
|
|
57
|
-
inCommitmentSiblings:
|
|
58
|
-
inCommitmentSiblingSides:
|
|
59
|
-
},
|
|
60
|
-
let N = H, T =
|
|
61
|
-
const E = `swapperMW${_}x${b}`, P =
|
|
57
|
+
inCommitmentSiblings: W,
|
|
58
|
+
inCommitmentSiblingSides: K
|
|
59
|
+
}, w = i ? n.getWalletSalt(i) : void 0;
|
|
60
|
+
let N = H, T = at.Emporium, D = tt(z, w);
|
|
61
|
+
const E = `swapperMW${_}x${b}`, P = X(
|
|
62
62
|
E,
|
|
63
63
|
o.erc20TokenAddresses,
|
|
64
64
|
o.amountChanges,
|
|
@@ -66,7 +66,7 @@ const Ct = async (f, g, a, e, n, _, b, H, z, v, A = j, L = q.localhost, m = a.ma
|
|
|
66
66
|
o.outCommitments,
|
|
67
67
|
c.length
|
|
68
68
|
);
|
|
69
|
-
o.calldataHash =
|
|
69
|
+
o.calldataHash = Y(
|
|
70
70
|
P,
|
|
71
71
|
A,
|
|
72
72
|
N,
|
|
@@ -76,7 +76,7 @@ const Ct = async (f, g, a, e, n, _, b, H, z, v, A = j, L = q.localhost, m = a.ma
|
|
|
76
76
|
h,
|
|
77
77
|
void 0
|
|
78
78
|
);
|
|
79
|
-
const { zkCallData:
|
|
79
|
+
const { zkCallData: B } = await rt(v, E, o), Z = x(y, s), G = await ot(
|
|
80
80
|
u,
|
|
81
81
|
k,
|
|
82
82
|
a,
|
|
@@ -90,16 +90,16 @@ const Ct = async (f, g, a, e, n, _, b, H, z, v, A = j, L = q.localhost, m = a.ma
|
|
|
90
90
|
A,
|
|
91
91
|
o.calldataHash,
|
|
92
92
|
c,
|
|
93
|
-
|
|
93
|
+
Z,
|
|
94
94
|
m,
|
|
95
|
-
|
|
96
|
-
),
|
|
95
|
+
et
|
|
96
|
+
), J = {
|
|
97
97
|
tokenNumber: a.length,
|
|
98
98
|
nullifierAmount: a[0].length,
|
|
99
99
|
outputAmount: e[0].length
|
|
100
100
|
};
|
|
101
|
-
return { zkCallData:
|
|
101
|
+
return { zkCallData: B, circomData: G, dimData: J, encryptedOutputs: l };
|
|
102
102
|
};
|
|
103
103
|
export {
|
|
104
|
-
|
|
104
|
+
It as constructEmporiumProof
|
|
105
105
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("../../constants/chains.constants.cjs"),j=require("../../constants/protocol.constants.cjs"),G=require("../../data-structures/utxo/Utxo.cjs"),m=require("../../types/hinkal.stake.types.cjs"),k=require("../../webworker/performTaskWithWorker.cjs"),S=require("../../webworker/worker.registry.cjs"),p=require("../../webworker/zkProofWorker/zkProofWorker.types.cjs"),J=require("../web3/etherFunctions.cjs"),i=require("./common.snarkjs.cjs"),F=require("./generateCircomData.cjs"),Q=require("./generateZkProof.cjs"),X=async(u,f,a,r,h,g,y,T,C,P=j.zeroAddress,z=V.chainIds.localhost,s=a.map(()=>!1),_=a.map(()=>0n),I=void 0,n)=>{const W=u.getRootHash(),H=f.getRootHash(),b=a.map(e=>e.map(t=>t.getConstructableParams())),D=h.getSignature(),{accessTokenSiblings:Z,accessTokenSiblingSides:K}=await k.performTaskWithWorker({type:S.WorkerVariant.ZKProof,payload:{type:p.ZKProofWorkerActionType.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES,data:{userSignature:D,merkleTreeAccessTokenSerialized:f.toJSON()}}}),{inCommitmentSiblings:O,inCommitmentSiblingSides:R}=await k.performTaskWithWorker({type:S.WorkerVariant.ZKProof,payload:{type:p.ZKProofWorkerActionType.CALC_COMMITMENTS_SIBLING_AND_SIDES,data:{inputUtxosSerialized:b,userSignature:D,merkleTreeSerialized:u.toJSON()}}}),B=i.calcAmountChanges(a,r),d=i.calcEncryptedOutputs(r,(n&&n.mode!==m.HinkalStakeMode.Deposit)??!1),l=h.getShieldedPrivateKey(),N=G.Utxo.findCorrectRandomization(J.randomBigInt(31),l),E=await k.performTaskWithWorker({type:S.WorkerVariant.ZKProof,payload:{type:p.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS,data:{inputUtxosSerialized:b,onChainCreation:s}}}),o={rootHashHinkal:W,shieldedPrivateKey:l,erc20TokenAddresses:a.map(e=>e[0].erc20TokenAddress),inAmounts:a.map(e=>e.map(t=>t.amount.toString())),inTimeStamps:a.map(e=>e.map(t=>t.timeStamp)),inRandomizations:a.map(e=>e.map(t=>t.randomization)),inNullifiers:E,inCommitmentSiblings:O,inCommitmentSiblingSides:R,outAmounts:r.map(e=>e.map(t=>t.amount.toString())),outTimeStamp:BigInt(r[0][0].timeStamp),outPublicKeys:r.map(e=>e.map(t=>t.getStealthAddress())),extraRandomization:N,amountChanges:B,outCommitments:i.buildOutCommitments(r,s),rootHashAccessToken:H,accessTokenSiblings:Z,accessTokenSiblingSides:K,calldataHash:0n};n||(o.onChainCreation=s);const c=a.map(e=>e[0].tokenId??0),q=c.reduce((e,t)=>e+t,0)>0?c.length:0;q>0&&(o.tokenIds=c);const A=i.calcPublicSignalCount(g,o.erc20TokenAddresses,o.amountChanges,o.inNullifiers,o.outCommitments,q);o.calldataHash=i.createCallDataHash(A,P,T,y,C,d,_,I),n&&(n.mode===m.HinkalStakeMode.Deposit&&(o.mode=0),n.mode===m.HinkalStakeMode.Stake&&(o.mode=1),n.mode===m.HinkalStakeMode.Unstake&&(o.mode=2),o.stakedTokenRecipient=n.stakedTokenRecipient,o.stakeBlinding=n.stakeBlinding,o.depositorAddress=n.depositorAddress);const{zkCallData:L}=await Q.generateZkProof(z,g,o),M=i.calcStealthAddressStructure(N,l),w=await F.generateCircomData(W,H,a,r,d,_,A,y,T,C,P,o.calldataHash,c,M,s,I),v={tokenNumber:a.length,nullifierAmount:a[0].length,outputAmount:r[0].length};return{zkCallData:L,circomData:w,dimData:v,encryptedOutputs:d}};exports.constructZkProof=X;
|
|
@@ -4,7 +4,7 @@ import { Utxo } from '../../data-structures/utxo/Utxo';
|
|
|
4
4
|
import { CircomDataType, DimDataType, HookDataType } from '../../types/circom-data.types';
|
|
5
5
|
import { ExternalActionId } from '../../types/external-action.types';
|
|
6
6
|
import { StakeArgs } from '../../types/hinkal.stake.types';
|
|
7
|
-
export declare const constructZkProof: (merkleTree: MerkleTree<bigint>, merkleTreeAccessToken: MerkleTree<bigint>, inputUtxos: Utxo[][], outputUtxos: Utxo[][], userKeys: UserKeys, verifierName: string, externalActionId: ExternalActionId | 0n, externalAddress: string | undefined, externalActionMetadata: string,
|
|
7
|
+
export declare const constructZkProof: (merkleTree: MerkleTree<bigint>, merkleTreeAccessToken: MerkleTree<bigint>, inputUtxos: Utxo[][], outputUtxos: Utxo[][], userKeys: UserKeys, verifierName: string, externalActionId: ExternalActionId | 0n, externalAddress: string | undefined, externalActionMetadata: string, relay?: string, chainId?: number, onChainCreation?: boolean[], flatFees?: bigint[], hookData?: HookDataType | undefined, stakeArgs?: StakeArgs) => Promise<{
|
|
8
8
|
zkCallData: import('../../index.ts').NewZkCallDataType;
|
|
9
9
|
circomData: CircomDataType;
|
|
10
10
|
dimData: DimDataType;
|
|
@@ -1,106 +1,105 @@
|
|
|
1
|
-
import { chainIds as
|
|
2
|
-
import { zeroAddress as
|
|
3
|
-
import { Utxo as
|
|
4
|
-
import { HinkalStakeMode as
|
|
5
|
-
import { performTaskWithWorker as
|
|
6
|
-
import { WorkerVariant as
|
|
7
|
-
import { ZKProofWorkerActionType as
|
|
8
|
-
import { randomBigInt as
|
|
9
|
-
import { calcAmountChanges as
|
|
10
|
-
import { generateCircomData as
|
|
11
|
-
import { generateZkProof as
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
type: S.ZKProof,
|
|
1
|
+
import { chainIds as G } from "../../constants/chains.constants.mjs";
|
|
2
|
+
import { zeroAddress as J } from "../../constants/protocol.constants.mjs";
|
|
3
|
+
import { Utxo as V } from "../../data-structures/utxo/Utxo.mjs";
|
|
4
|
+
import { HinkalStakeMode as d } from "../../types/hinkal.stake.types.mjs";
|
|
5
|
+
import { performTaskWithWorker as l } from "../../webworker/performTaskWithWorker.mjs";
|
|
6
|
+
import { WorkerVariant as p } from "../../webworker/worker.registry.mjs";
|
|
7
|
+
import { ZKProofWorkerActionType as S } from "../../webworker/zkProofWorker/zkProofWorker.types.mjs";
|
|
8
|
+
import { randomBigInt as j } from "../web3/etherFunctions.mjs";
|
|
9
|
+
import { calcAmountChanges as q, calcEncryptedOutputs as F, buildOutCommitments as Q, calcPublicSignalCount as X, createCallDataHash as Y, calcStealthAddressStructure as $ } from "./common.snarkjs.mjs";
|
|
10
|
+
import { generateCircomData as U } from "./generateCircomData.mjs";
|
|
11
|
+
import { generateZkProof as x } from "./generateZkProof.mjs";
|
|
12
|
+
const po = async (f, g, a, n, h, k, u, C, I, T = J, R = G.localhost, m = a.map(() => !1), y = a.map(() => 0n), N = void 0, i) => {
|
|
13
|
+
const P = f.getRootHash(), D = g.getRootHash(), _ = a.map((o) => o.map((t) => t.getConstructableParams())), b = h.getSignature(), { accessTokenSiblings: B, accessTokenSiblingSides: E } = await l({
|
|
14
|
+
type: p.ZKProof,
|
|
16
15
|
payload: {
|
|
17
|
-
type:
|
|
16
|
+
type: S.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES,
|
|
18
17
|
data: {
|
|
19
|
-
userSignature:
|
|
20
|
-
merkleTreeAccessTokenSerialized:
|
|
18
|
+
userSignature: b,
|
|
19
|
+
merkleTreeAccessTokenSerialized: g.toJSON()
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
|
-
}), { inCommitmentSiblings:
|
|
24
|
-
type:
|
|
22
|
+
}), { inCommitmentSiblings: K, inCommitmentSiblingSides: L } = await l({
|
|
23
|
+
type: p.ZKProof,
|
|
25
24
|
payload: {
|
|
26
|
-
type:
|
|
27
|
-
data: { inputUtxosSerialized:
|
|
25
|
+
type: S.CALC_COMMITMENTS_SIBLING_AND_SIDES,
|
|
26
|
+
data: { inputUtxosSerialized: _, userSignature: b, merkleTreeSerialized: f.toJSON() }
|
|
28
27
|
}
|
|
29
|
-
}),
|
|
28
|
+
}), O = q(a, n), c = F(
|
|
30
29
|
n,
|
|
31
|
-
(i && i.mode !==
|
|
32
|
-
),
|
|
33
|
-
type:
|
|
30
|
+
(i && i.mode !== d.Deposit) ?? !1
|
|
31
|
+
), s = h.getShieldedPrivateKey(), H = V.findCorrectRandomization(j(31), s), Z = await l({
|
|
32
|
+
type: p.ZKProof,
|
|
34
33
|
payload: {
|
|
35
|
-
type:
|
|
36
|
-
data: { inputUtxosSerialized:
|
|
34
|
+
type: S.BUILD_IN_NULLIFIERS,
|
|
35
|
+
data: { inputUtxosSerialized: _, onChainCreation: m }
|
|
37
36
|
}
|
|
38
|
-
}),
|
|
39
|
-
rootHashHinkal:
|
|
40
|
-
shieldedPrivateKey:
|
|
41
|
-
erc20TokenAddresses: a.map((
|
|
42
|
-
inAmounts: a.map((
|
|
43
|
-
inTimeStamps: a.map((
|
|
44
|
-
inRandomizations: a.map((
|
|
45
|
-
inNullifiers:
|
|
46
|
-
inCommitmentSiblings:
|
|
47
|
-
inCommitmentSiblingSides:
|
|
48
|
-
outAmounts: n.map((
|
|
37
|
+
}), e = {
|
|
38
|
+
rootHashHinkal: P,
|
|
39
|
+
shieldedPrivateKey: s,
|
|
40
|
+
erc20TokenAddresses: a.map((o) => o[0].erc20TokenAddress),
|
|
41
|
+
inAmounts: a.map((o) => o.map((t) => t.amount.toString())),
|
|
42
|
+
inTimeStamps: a.map((o) => o.map((t) => t.timeStamp)),
|
|
43
|
+
inRandomizations: a.map((o) => o.map((t) => t.randomization)),
|
|
44
|
+
inNullifiers: Z,
|
|
45
|
+
inCommitmentSiblings: K,
|
|
46
|
+
inCommitmentSiblingSides: L,
|
|
47
|
+
outAmounts: n.map((o) => o.map((t) => t.amount.toString())),
|
|
49
48
|
outTimeStamp: BigInt(n[0][0].timeStamp),
|
|
50
|
-
outPublicKeys: n.map((
|
|
51
|
-
extraRandomization:
|
|
52
|
-
amountChanges:
|
|
53
|
-
outCommitments:
|
|
54
|
-
rootHashAccessToken:
|
|
55
|
-
accessTokenSiblings:
|
|
56
|
-
accessTokenSiblingSides:
|
|
49
|
+
outPublicKeys: n.map((o) => o.map((t) => t.getStealthAddress())),
|
|
50
|
+
extraRandomization: H,
|
|
51
|
+
amountChanges: O,
|
|
52
|
+
outCommitments: Q(n, m),
|
|
53
|
+
rootHashAccessToken: D,
|
|
54
|
+
accessTokenSiblings: B,
|
|
55
|
+
accessTokenSiblingSides: E,
|
|
57
56
|
calldataHash: 0n
|
|
58
57
|
};
|
|
59
|
-
i || (
|
|
60
|
-
const r = a.map((
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
i || (e.onChainCreation = m);
|
|
59
|
+
const r = a.map((o) => o[0].tokenId ?? 0), z = r.reduce((o, t) => o + t, 0) > 0 ? r.length : 0;
|
|
60
|
+
z > 0 && (e.tokenIds = r);
|
|
61
|
+
const A = X(
|
|
62
|
+
k,
|
|
63
|
+
e.erc20TokenAddresses,
|
|
64
|
+
e.amountChanges,
|
|
65
|
+
e.inNullifiers,
|
|
66
|
+
e.outCommitments,
|
|
67
|
+
z
|
|
69
68
|
);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
C,
|
|
73
|
-
g,
|
|
69
|
+
e.calldataHash = Y(
|
|
70
|
+
A,
|
|
74
71
|
T,
|
|
72
|
+
C,
|
|
75
73
|
u,
|
|
76
|
-
s,
|
|
77
74
|
I,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
c,
|
|
76
|
+
y,
|
|
77
|
+
N
|
|
78
|
+
), i && (i.mode === d.Deposit && (e.mode = 0), i.mode === d.Stake && (e.mode = 1), i.mode === d.Unstake && (e.mode = 2), e.stakedTokenRecipient = i.stakedTokenRecipient, e.stakeBlinding = i.stakeBlinding, e.depositorAddress = i.depositorAddress);
|
|
79
|
+
const { zkCallData: w } = await x(R, k, e), W = $(H, s), v = await U(
|
|
82
80
|
P,
|
|
81
|
+
D,
|
|
83
82
|
a,
|
|
84
83
|
n,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
T,
|
|
89
|
-
g,
|
|
84
|
+
c,
|
|
85
|
+
y,
|
|
86
|
+
A,
|
|
90
87
|
u,
|
|
91
88
|
C,
|
|
92
|
-
|
|
89
|
+
I,
|
|
90
|
+
T,
|
|
91
|
+
e.calldataHash,
|
|
93
92
|
r,
|
|
94
|
-
|
|
93
|
+
W,
|
|
95
94
|
m,
|
|
96
|
-
|
|
97
|
-
),
|
|
95
|
+
N
|
|
96
|
+
), M = {
|
|
98
97
|
tokenNumber: a.length,
|
|
99
98
|
nullifierAmount: a[0].length,
|
|
100
99
|
outputAmount: n[0].length
|
|
101
100
|
};
|
|
102
|
-
return { zkCallData:
|
|
101
|
+
return { zkCallData: w, circomData: v, dimData: M, encryptedOutputs: c };
|
|
103
102
|
};
|
|
104
103
|
export {
|
|
105
|
-
|
|
104
|
+
po as constructZkProof
|
|
106
105
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../../webworker/performTaskWithWorker.cjs"),l=require("../../webworker/snarkjsWorker/snarkjsWorker.types.cjs"),c=require("../../webworker/worker.registry.cjs"),t=require("./getZKFiles.cjs"),y=async(e,r,o)=>{const a=t.getWASMFile(r,e),s=t.getZKeyFile(r,e),{publicSignals:n,zkCallData:i}=await k.performTaskWithWorker({type:c.WorkerVariant.SnarkJS,payload:{type:l.SnarkJSWorkerActionType.FULL_PROVE,data:{input:o,chainId:e,wasmFilePath:a,zKeyFilePath:s}}});return{zkCallData:i,publicSignals:n}};exports.generateZkProof=y;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NewZkCallDataType } from '../../types';
|
|
2
|
-
export declare const generateZkProof: (chainId: number, verifierName: string, input: any
|
|
2
|
+
export declare const generateZkProof: (chainId: number, verifierName: string, input: any) => Promise<{
|
|
3
3
|
zkCallData: NewZkCallDataType;
|
|
4
4
|
publicSignals: string[];
|
|
5
5
|
}>;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { performTaskWithWorker as n } from "../../webworker/performTaskWithWorker.mjs";
|
|
2
|
+
import { SnarkJSWorkerActionType as l } from "../../webworker/snarkjsWorker/snarkjsWorker.types.mjs";
|
|
3
|
+
import { WorkerVariant as m } from "../../webworker/worker.registry.mjs";
|
|
4
|
+
import { getWASMFile as k, getZKeyFile as s } from "./getZKFiles.mjs";
|
|
5
|
+
const F = async (t, r, o) => {
|
|
6
|
+
const a = k(r, t), e = s(r, t), { publicSignals: p, zkCallData: i } = await n({
|
|
7
|
+
type: m.SnarkJS,
|
|
8
|
+
payload: {
|
|
9
|
+
type: l.FULL_PROVE,
|
|
10
|
+
data: { input: o, chainId: t, wasmFilePath: a, zKeyFilePath: e }
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return { zkCallData: i, publicSignals: p };
|
|
14
|
+
};
|
|
4
15
|
export {
|
|
5
|
-
|
|
16
|
+
F as generateZkProof
|
|
6
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/coingecko.constants.cjs");const s=require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const a=e=>{const r=s.AxelarRegistry.find(t=>t.chainId===e.chainId);if(!r)return;const{sourceChain:i,sourceAddress:n}=r;return{destinationChain:i,destinationAddress:n,messageFee:e.gasFeeInWei??0n}};exports.getAxelarMigrationInfo=a;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "../../constants/token-data/index.mjs";
|
|
2
1
|
import "../../constants/chains.constants.mjs";
|
|
3
2
|
import "../../constants/vite.constants.mjs";
|
|
4
3
|
import "../../constants/contracts.constants.mjs";
|
|
@@ -7,7 +6,7 @@ import "../../constants/coingecko.constants.mjs";
|
|
|
7
6
|
import { AxelarRegistry as n } from "../../constants/axelar.constants.mjs";
|
|
8
7
|
import "../../constants/rewards.constants.mjs";
|
|
9
8
|
import "../../constants/reorg-depths.constants.mjs";
|
|
10
|
-
const
|
|
9
|
+
const f = (i) => {
|
|
11
10
|
const r = n.find((o) => o.chainId === i.chainId);
|
|
12
11
|
if (!r)
|
|
13
12
|
return;
|
|
@@ -19,5 +18,5 @@ const h = (i) => {
|
|
|
19
18
|
};
|
|
20
19
|
};
|
|
21
20
|
export {
|
|
22
|
-
|
|
21
|
+
f as getAxelarMigrationInfo
|
|
23
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/chains.constants.cjs");const t=require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.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("../../data-structures/cacheDevices/FileCacheDevice.cjs"),o=require("../../data-structures/cacheDevices/LocalStorageCacheDevice.cjs"),s=e=>{if(t.isNode){let r,c;e&&({useFileCache:r,cacheFilePath:c}=e);const i=require("path").resolve(process.cwd(),"hinkalCache.json");return new a.FileCacheDevice(r,c??i)}else return new o.LocalStorageCacheDevice};exports.createCacheDevice=s;
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import "../../constants/token-data/index.mjs";
|
|
2
1
|
import "../../constants/chains.constants.mjs";
|
|
3
|
-
import { isNode as
|
|
2
|
+
import { isNode as c } from "../../constants/vite.constants.mjs";
|
|
4
3
|
import "../../constants/contracts.constants.mjs";
|
|
5
4
|
import "../../constants/kyc.constants.mjs";
|
|
6
5
|
import "../../constants/coingecko.constants.mjs";
|
|
7
6
|
import "../../constants/axelar.constants.mjs";
|
|
8
7
|
import "../../constants/rewards.constants.mjs";
|
|
9
8
|
import "../../constants/reorg-depths.constants.mjs";
|
|
10
|
-
import { FileCacheDevice as
|
|
11
|
-
import { LocalStorageCacheDevice as
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
9
|
+
import { FileCacheDevice as i } from "../../data-structures/cacheDevices/FileCacheDevice.mjs";
|
|
10
|
+
import { LocalStorageCacheDevice as a } from "../../data-structures/cacheDevices/LocalStorageCacheDevice.mjs";
|
|
11
|
+
const D = (e) => {
|
|
12
|
+
if (c) {
|
|
14
13
|
let r, t;
|
|
15
14
|
e && ({ useFileCache: r, cacheFilePath: t } = e);
|
|
16
15
|
const o = require("path").resolve(process.cwd(), "hinkalCache.json");
|
|
17
|
-
return new
|
|
16
|
+
return new i(r, t ?? o);
|
|
18
17
|
} else
|
|
19
|
-
return new
|
|
18
|
+
return new a();
|
|
20
19
|
};
|
|
21
20
|
export {
|
|
22
|
-
|
|
21
|
+
D as createCacheDevice
|
|
23
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/token-data/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../constants/token-data/ERC20Registry.cjs"),g=require("../../data-structures/custom-token-registry/CustomTokenRegistry.cjs"),i=(e,t)=>{const s=n.getERC20Registry(t),o=g.customTokenRegistry.getCustomTokens(t);return[...s,...o].find(r=>e===void 0?!1:r.erc20TokenAddress.toLowerCase()===e.toLowerCase())},u=(e,t)=>{const s=n.getERC20Registry(t),o=g.customTokenRegistry.getCustomTokens(t);return[...s,...o].find(r=>e===void 0?!1:r.symbol.toLowerCase()===e.toLowerCase())},k=(e,t)=>{const s=n.getERC20Registry(t);if(e.hasHToken)return s.find(o=>o.underlyingErc20TokenAddress?.toLowerCase()===e.erc20TokenAddress.toLowerCase()&&o.isHToken)};exports.getERC20Token=i;exports.getERC20TokenBySymbol=u;exports.getHToken=k;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import "../../constants/token-data/index.mjs";
|
|
2
|
-
import { customTokenRegistry as i } from "../../data-structures/custom-token-registry/CustomTokenRegistry.mjs";
|
|
3
1
|
import { getERC20Registry as n } from "../../constants/token-data/ERC20Registry.mjs";
|
|
4
|
-
|
|
2
|
+
import { customTokenRegistry as i } from "../../data-structures/custom-token-registry/CustomTokenRegistry.mjs";
|
|
3
|
+
const T = (e, o) => {
|
|
5
4
|
const r = n(o), t = i.getCustomTokens(o);
|
|
6
5
|
return [...r, ...t].find((s) => e === void 0 ? !1 : s.erc20TokenAddress.toLowerCase() === e.toLowerCase());
|
|
7
|
-
},
|
|
6
|
+
}, g = (e, o) => {
|
|
8
7
|
const r = n(o), t = i.getCustomTokens(o);
|
|
9
8
|
return [...r, ...t].find((s) => e === void 0 ? !1 : s.symbol.toLowerCase() === e.toLowerCase());
|
|
10
|
-
},
|
|
9
|
+
}, c = (e, o) => {
|
|
11
10
|
const r = n(o);
|
|
12
11
|
if (e.hasHToken)
|
|
13
12
|
return r.find(
|
|
@@ -15,7 +14,7 @@ const g = (e, o) => {
|
|
|
15
14
|
);
|
|
16
15
|
};
|
|
17
16
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
T as getERC20Token,
|
|
18
|
+
g as getERC20TokenBySymbol,
|
|
19
|
+
c as getHToken
|
|
21
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const i=e=>r.networkRegistry[e],c=e=>Object.keys(r.chainIdsByType)[Object.values(r.chainIdsByType).findIndex(t=>t.includes(e.chainId))];exports.getNetworkObject=i;exports.getNetworkType=c;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "../../constants/token-data/index.mjs";
|
|
2
1
|
import { networkRegistry as r, chainIdsByType as e } from "../../constants/chains.constants.mjs";
|
|
3
2
|
import "../../constants/vite.constants.mjs";
|
|
4
3
|
import "../../constants/contracts.constants.mjs";
|
|
@@ -7,8 +6,8 @@ import "../../constants/coingecko.constants.mjs";
|
|
|
7
6
|
import "../../constants/axelar.constants.mjs";
|
|
8
7
|
import "../../constants/rewards.constants.mjs";
|
|
9
8
|
import "../../constants/reorg-depths.constants.mjs";
|
|
10
|
-
const
|
|
9
|
+
const k = (t) => r[t], a = (t) => Object.keys(e)[Object.values(e).findIndex((o) => o.includes(t.chainId))];
|
|
11
10
|
export {
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
k as getNetworkObject,
|
|
12
|
+
a as getNetworkType
|
|
14
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(t){return t?.toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.substring(1)).join(" ")}function s(t){return t.charAt(0).toUpperCase()+t.slice(1)}function u(t){return!t||t===null||Array.isArray(t)&&t.length===0?!0:Object.keys(t).length===0&&t.constructor===Object}const c=t=>{t.startsWith("0x")&&(t=t.slice(2));const e=[];for(let r=0;r<t.length;r+=2){const i=parseInt(t.slice(r,r+2),16);e.push(i)}return new TextDecoder("utf-8").decode(new Uint8Array(e))};exports.capitalizeFirstLetter=s;exports.hexToUtf8=c;exports.isNullOrEmpty=u;exports.toTitleCase=n;
|
|
@@ -6,3 +6,4 @@ export declare function toTitleCase(str: string): string;
|
|
|
6
6
|
export declare function capitalizeFirstLetter(str: string): string;
|
|
7
7
|
/** Returns true if a value is null, undefined, or an empty object, array (length 0), or string (e.g. '') */
|
|
8
8
|
export declare function isNullOrEmpty(obj: unknown): boolean;
|
|
9
|
+
export declare const hexToUtf8: (hex: string) => string;
|