h_test_1 0.0.19 → 0.0.21
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/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.mjs +2 -4
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +61 -57
- package/functions/pre-transaction/getKycAndSignatureData.cjs +1 -1
- package/functions/pre-transaction/getKycAndSignatureData.mjs +14 -12
- package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.mjs +80 -76
- package/functions/snarkjs/getMerkleTreeSiblingsAndRootHashes.cjs +1 -1
- package/functions/snarkjs/getMerkleTreeSiblingsAndRootHashes.mjs +77 -70
- package/package.json +11 -1
- package/providers/WagmiProviderAdapter.d.ts +1 -1
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("ethers"),k=require("../../types/hinkal.types.cjs"),S=require("../../types/ethereum-network.types.cjs"),U=require("./hinkalCheckSolanaTokenRegistry.cjs"),I=require("../../functions/web3/functionCalls/accessTokenCalls.cjs"),K=require("../../functions/web3/events/getShieldedBalance.cjs"),y=require("../crypto-keys/keys.cjs"),T=require("./hinkalDeposit.cjs"),W=require("./hinkalDepositAndWithdraw.cjs"),m=require("./hinkalSolanaDeposit.cjs"),x=require("./hinkalSwap.cjs"),F=require("./hinkalWithdraw.cjs"),N=require("./resetMerkleTrees.cjs"),M=require("../merkle-tree/MerkleTree.cjs"),_=require("../../error-handling/error-codes.constants.cjs"),R=require("../../crypto/poseidon.cjs"),o=require("../../constants/chains.constants.cjs");require("../../API/getServerURL.cjs");require("axios");require("../../constants/coingecko.constants.cjs");require("../../constants/server.constants.cjs");require("../http/HttpClient.cjs");const C=require("../../API/API.cjs");require("../../API/tenderly.api.cjs");require("../../constants/token-data/index.cjs");require("../../constants/contracts.constants.cjs");const O=require("../../constants/kyc.constants.cjs"),G=require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");require("../../constants/schedule.constants.cjs");require("../../constants/tokens.constants.cjs");const z=require("../../functions/utils/reloadPage.cjs"),j=require("../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs"),$=require("./hinkalPrivateWallet.cjs"),J=require("../../functions/utils/cacheDevice.utils.cjs"),V=require("../../functions/web3/getContractMetadata.cjs"),Q=require("./hinkalGetRecipientInfo.cjs"),w=require("../../functions/web3/events/getApprovedBalance.cjs"),X=require("./hinkalSignSubAccount.cjs"),B=require("./hinkalCheckTokenRegistry.cjs"),Y=require("./hinkalActionReceive.cjs"),Z=require("../TokenDBs/PrivateTokensDB.cjs");require("idb-keyval");const ee=require("../../functions/utils/erc20tokenFunctions.cjs");require("multiformats");const P=require("@solana/web3.js");require("@solana/spl-token");require("tronweb");const d=require("../../functions/utils/token-check.utils.cjs");require("async-mutex");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../types/circom-data.types.cjs");require("../../types/activities.types.cjs");const L=require("../../functions/pre-transaction/solana.cjs");require("tweetnacl");require("bs58");require("@coral-xyz/anchor");require("buffer");require("libsodium-wrappers");require("lodash");require("../../functions/utils/userAgent.cjs");require("circomlibjs-hinkal-fork");require("process");require("../../providers/EthersProviderAdapter.cjs");const re=require("../../providers/SolanaProviderAdapter.cjs");require("node-forge");require("../../API/enclaveUtxoCalls.cjs");require("../../functions/web3/events/getInputUtxoAndBalance.cjs");require("../../functions/web3/getTokenHolder.cjs");const te=require("../../functions/private-wallet/emporium.helpers.cjs"),ie=require("./hinkalProoflessDeposit.cjs"),ae=require("./hinkalProxySwap.cjs"),ne=require("./hinkalMultiSend.cjs"),se=require("./hinkalTransfer.cjs"),oe=require("./hinkalProxyToPrivate.cjs"),E=require("../../providers/TronProviderAdapter.cjs"),he=require("./hinkalSolanaDepositAndWithdraw.cjs"),le=require("./hinkalSolanaWithdraw.cjs"),ce=require("./hinkalSolanaTransfer.cjs"),de=require("./hinkalSolanaSwap.cjs"),ue=require("./hinkalSolanaProxySend.cjs"),pe=require("./hinkalSolanaProxySwap.cjs"),H=require("./hinkalSolanaProxyShield.cjs"),D=require("../../functions/web3/fetchSolanaMerkleTreeRootHash.cjs"),ge=require("./hinkalDepositAndBridge.cjs"),ke=require("./hinkalClaimUtxo.cjs"),Pe=require("./hinkalSolanaProoflessDeposit.cjs"),ve=require("./hinkalSolanaClaimUtxo.cjs"),ye=require("./hinkalWithdrawStuckUtxos.cjs");class Ae{ethereumProviderAdapter;solanaProviderAdapter;tronProviderAdapter;userKeys;signingMessage="Login to Hinkal Protocol";privateTransferSigningMessage="Login to Hinkal's Private Transfer App";merkleTreeHinkalByChain={};merkleTreeAccessTokenByChain={};nullifiersByChain={};encryptedOutputsByChain={};approvalsByChain={};commitmentsSnapshotServiceByChain={};nullifierSnapshotServiceByChain={};accessTokenSnapshotServiceByChain={};approvalsSnapshotServiceByChain={};utxoUtils;cacheDevice;generateProofRemotely;disableMerkleTreeUpdates;constructor(e){this.userKeys=new y.UserKeys(void 0),o.HINKAL_SUPPORTED_CHAINS.forEach(r=>{this.merkleTreeHinkalByChain[r]=M.MerkleTree.create(R.poseidonFunction,0n),this.merkleTreeAccessTokenByChain[r]=M.MerkleTree.create(R.poseidonFunction,0n),this.nullifiersByChain[r]=new Set,this.encryptedOutputsByChain[r]=[],this.approvalsByChain[r]=new Map}),this.generateProofRemotely=e?.generateProofRemotely??!0,this.utxoUtils=new j.MultiThreadedUtxoUtils,this.cacheDevice=J.createCacheDevice(e),this.disableMerkleTreeUpdates=e?.disableMerkleTreeUpdates??!1}async initProviderAdapter(e,r){const t=r instanceof re.SolanaProviderAdapter,i=r instanceof E.TronProviderAdapter;let a=o.chainIds.ethMainnet;t?a=o.chainIds.solanaMainnet:i&&(a=o.chainIds.tronMainnet),await this.updateProviderAdapter(a,r),t?this.solanaProviderAdapter?.initConnector(e):i?this.tronProviderAdapter?.initConnector(e):this.ethereumProviderAdapter?.initConnector(e);let n;t?n=await this.connectAndPatchProvider(!0,e):i?n=await r.connectAndPatchProvider(e):n=await this.connectAndPatchProvider(!1,e),await r.init(n),await this.setListeners()}getSigningMessage(e=k.LoginMessageMode.PROTOCOL){switch(e){case k.LoginMessageMode.PRIVATE_TRANSFER:return this.privateTransferSigningMessage;case k.LoginMessageMode.PROTOCOL:default:return this.signingMessage}}async initUserKeys(e=k.LoginMessageMode.PROTOCOL){const r=this.getSigningMessage(e);this.userKeys=new y.UserKeys(await this.getProviderAdapter().signMessage(r))}initUserKeysWithSignature(e){this.userKeys=new y.UserKeys(e)}async initUserKeysFromSeedPhrases(e){const r=e.join(" "),t=q.ethers.toUtf8Bytes(r),i=q.ethers.keccak256(t);this.userKeys=new y.UserKeys(i)}async resetMerkle(e){if(this.disableMerkleTreeUpdates)return;(e?.every(t=>this.isSelectedNetworkSupported(t))??!0)&&await N.resetMerkleTrees(this,e)}getProviderAdapter(e){let r=e;r||(this.ethereumProviderAdapter?r=o.chainIds.ethMainnet:this.solanaProviderAdapter?r=o.chainIds.solanaMainnet:r=o.chainIds.tronMainnet);let t;if(o.isSolanaLike(r)?t=this.solanaProviderAdapter:o.isTronLike(r)?t=this.tronProviderAdapter:t=this.ethereumProviderAdapter,!t)throw new Error("ProviderAdapter is not initialized");return t}getTronWeb(){const e=this.tronProviderAdapter;if(!e)throw new Error("Tron provider adapter not initialized");if(!(e instanceof E.TronProviderAdapter))throw new Error("Tron provider adapter is not a TronProviderAdapter");const r=e.getTronWeb();if(!r)throw new Error("TronWeb not available");return r}getSupportedChains(){return this.ethereumProviderAdapter&&this.solanaProviderAdapter?o.WALLET_SUPPORTED_CHAINS:this.ethereumProviderAdapter?o.HINKAL_SUPPORTED_CHAINS.filter(e=>!o.isSolanaLike(e)&&!o.isTronLike(e)):this.solanaProviderAdapter?o.HINKAL_SUPPORTED_CHAINS.filter(e=>o.isSolanaLike(e)):this.tronProviderAdapter?o.HINKAL_SUPPORTED_CHAINS.filter(e=>o.isTronLike(e)):[]}async waitForTransaction(e,r,t=1){return!!await this.getProviderAdapter(e).waitForTransaction(e,r,t)}getContract(e,r,t=void 0){return this.getProviderAdapter(e).getContract(e,r,t)}getContractWithFetcherByChainId(e,r,t=void 0){return V.getContractWithFetcherByChainId(e,r,t)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,r,t){return await this.getProviderAdapter().signTypedData(e,r,t)}async signWithSubAccount(e,r,t,i){return X.hinkalSignSubAccount(e,r,t,i)}getContractWithSigner(e,r,t=""){return this.getProviderAdapter(e).getContractWithSigner(e,r,t)}getContractWithFetcher(e,r,t=""){return this.getProviderAdapter(e).getContractWithFetcher(e,r,t)}isSelectedNetworkSupported(e){return!!o.networkRegistry[e]}async switchNetwork(e){try{await this.getProviderAdapter().switchNetwork(e)}catch{throw new Error(_.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}isPermitterAvailable(e){return this.getProviderAdapter(e).isPermitterAvailable()}async connectAndPatchProvider(e,r){return await this.getProviderAdapter(e?o.chainIds.solanaMainnet:o.chainIds.ethMainnet).connectAndPatchProvider(r)}async disconnectFromConnector(){await this.ethereumProviderAdapter?.disconnectFromConnector(),await this.solanaProviderAdapter?.disconnectFromConnector(),await this.tronProviderAdapter?.disconnectFromConnector()}async resetProviderAdapters(){this.ethereumProviderAdapter=void 0,this.solanaProviderAdapter=void 0,this.tronProviderAdapter=void 0}async updateProviderAdapter(e,r){try{o.isSolanaLike(e)?(this.solanaProviderAdapter&&this.solanaProviderAdapter.release(),this.solanaProviderAdapter=r):o.isTronLike(e)?(this.tronProviderAdapter&&this.tronProviderAdapter.release(),this.tronProviderAdapter=r):(this.ethereumProviderAdapter&&this.ethereumProviderAdapter.release(),this.ethereumProviderAdapter=r)}catch(t){throw console.error(t),Error("updateProviderAdapter failed, please try again.")}}async setListeners(){this.ethereumProviderAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}}),this.solanaProviderAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}}),this.tronProviderAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}})}async onAccountChanged(){await this.ethereumProviderAdapter?.onAccountChanged(),await this.solanaProviderAdapter?.onAccountChanged(),await this.tronProviderAdapter?.onAccountChanged();const e=k.EventType.AccountChanged;typeof document<"u"?document?.dispatchEvent(new Event(e)):process?.emit("message",e,void 0)}async onChainChanged(e){e?await this.getProviderAdapter(e).onChainChanged(e):(await this.disconnectFromConnector(),z.reloadPage())}async monitorConnectedAddress(e){await C.API.monitor(await this.getEthereumAddressByChain(e))}async getBalances(e,r,t,i,a=!1,n,s=!1){return K.getShieldedBalance(this,e,r,t,i,a,this.generateProofRemotely,n,s)}async getApprovedBalances(e,r=!1,t=!1){return w.getApprovedBalance(this,e,r,t)}async getTotalBalance(e,r,t,i=!1,a,n=!1){const s=t??await this.getEthereumAddressByChain(e),h=r??this.userKeys,l=await this.getBalances(e,h.getShieldedPrivateKey(),h.getShieldedPublicKey(),s,i,a,n),u=!o.isSolanaLike(e)&&!n?await this.getApprovedBalances(e,i,a):new Map,p=G.isExtension?await Z.privateTokensDB.getPrivateTokens(e,s):ee.getErc20TokensForChain(e),c=[];return p.forEach(g=>{const v=g.erc20TokenAddress.toLowerCase(),A=l.get(v),f=u.get(v),b={token:g,balance:(A?.balance??0n)+(f?.balance??0n),timestamp:A?.timestamp||f?.timestamp||"0",nfts:A?.nfts||[]};c.push(b)}),c}async getStuckShieldedBalances(e,r,t){return(await this.getTotalBalance(e,r,t,!1,!1,!0)).filter(a=>a.balance>0n)}getSupportedPassportLinks(){return O.supportedPassportLinks}checkAccessToken(e,r){return I.checkHinkalAccessToken(this,e,r)}async getHinkalTreeRootHash(e){if(o.isSolanaLike(e)){const{hinkalIdl:t,hinkalAddress:i,originalDeployer:a}=o.networkRegistry[e].contractData;if(!t||!i||!a)throw new Error(`Missing Solana configuration for chain ${e}`);const n=new P.PublicKey(a),s=new P.PublicKey(i),h=L.getMerkleAccountPublicKey(s,n),l=this.getSolanaProgram(t);return D.fetchSolanaMerkleTreeRootHash(l,h)}return this.getContractWithFetcherByChainId(e,S.ContractType.HinkalContract).getRootHash()}async getAccessTokenTreeRootHash(e){if(o.isSolanaLike(e)){const{hinkalIdl:t,hinkalAddress:i,originalDeployer:a}=o.networkRegistry[e].contractData;if(!t||!i||!a)throw new Error(`Missing Solana configuration for chain ${e}`);const n=new P.PublicKey(a),s=new P.PublicKey(i),h=L.getAccessTokenMerkleAccountPublicKey(s,n),l=this.getSolanaProgram(t);return D.fetchSolanaMerkleTreeRootHash(l,h)}return this.getContractWithFetcherByChainId(e,S.ContractType.AccessTokenContract).getRootHash()}async resetMerkleTreesIfNecessary(e){const t=(await Promise.all((e??this.getSupportedChains()).map(async i=>{const[a,n]=await Promise.all([this.getHinkalTreeRootHash(i),this.getAccessTokenTreeRootHash(i)]),s=BigInt(a)!==this.merkleTreeHinkalByChain[i].getRootHash()||BigInt(n)!==this.merkleTreeAccessTokenByChain[i].getRootHash();return{chainId:i,needsReset:s}}))).filter(i=>i.needsReset).map(i=>i.chainId);t.length>0&&(console.log("resetting merkle tree in resetMerkleTreesIfNecessary for chains:",t),await this.resetMerkle(t))}async getEthereumAddress(){const e=this.ethereumProviderAdapter??this.solanaProviderAdapter??this.tronProviderAdapter;if(!e)throw new Error("No provider adapter initialized");return e.getAddress()}getEthereumAddressByChain(e){return this.getProviderAdapter(e).getAddress()}async getRandomRelay(e,r=!1){return(await C.API.getIdleRelay(e,r)).relay}getGasPrice(e){const r=this.getProviderAdapter(e);if(!r)throw new Error("Illegal State of providerAdapter in Hinkal: no providerAdapter initialized");return r.getGasPrice(e)}getAPI(){return C.API}snapshotsClearInterval(){this.getSupportedChains().forEach(e=>{this.commitmentsSnapshotServiceByChain[e]?.intervalClear(),this.accessTokenSnapshotServiceByChain[e]?.intervalClear(),this.nullifierSnapshotServiceByChain[e]?.intervalClear(),this.approvalsSnapshotServiceByChain[e]?.intervalClear()})}checkTokenRegistry(e,r,t){if(o.isSolanaLike(e)){const{hinkalIdl:a,hinkalAddress:n,originalDeployer:s}=o.networkRegistry[e].contractData;if(!a||!n||!s)throw new Error("missing solana data");const h=this.getSolanaProgram(a),l=new P.PublicKey(s);return U.hinkalCheckSolanaTokenRegistry(h,l,r,t)}if(o.isTronLike(e))return B.hinkalCheckTronTokenRegistry(r,t,e);const i=this.getContractWithFetcher(e,S.ContractType.HinkalHelperContract);return B.hinkalCheckTokenRegistry(i,r,t)}getRecipientInfo(){return Q.getRecipientInfo(this)}getApprovedUtxos(e,r=!1){return w.getApprovedUtxos(this,e,r)}getApprovedUtxosForToken(e,r,t=!1){return w.getApprovedUtxosForToken(this,e,r,t)}async deposit(e,r,t=!0,i=!1){return T.hinkalDeposit(this,e,r,t,i)}async depositSolana(e,r){return m.hinkalSolanaDeposit(this,e,r)}async depositForOther(e,r,t,i=!0,a=!1){return T.hinkalDepositForOther(this,e,r,t,i,a)}async depositSolanaForOther(e,r,t){return m.hinkalSolanaDepositForOther(this,e,r,t)}async depositAndWithdraw(e,r,t,i,a,n,s,h=!0){const l=d.validateAndGetChainId([e]);return o.isSolanaLike(l)?he.hinkalSolanaDepositAndWithdraw(this,e,r,t,i,a,n,s):W.hinkalDepositAndWithdraw(this,e,r,t,i,a,n,s,h)}async claimUtxo(e,r,t,i){const a=d.validateAndGetChainId([e]);return o.isSolanaLike(a)?ve.hinkalSolanaClaimUtxo(this,e,r,t,i):ke.hinkalClaimUtxo(this,e,r,t,i)}async depositAndBridge(e,r,t,i,a,n,s=!0){return ge.hinkalDepositAndBridge(this,e,r,t,i,a,n,s)}async prooflessDeposit(e,r,t,i){const a=d.validateAndGetChainId(e);return o.isSolanaLike(a)?Pe.hinkalSolanaProoflessDeposit(this,e,r,t,i):ie.hinkalProoflessDeposit(this,e,r,t,i)}getSolanaProgram(e){if(!this.solanaProviderAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaProgram"in this.solanaProviderAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.solanaProviderAdapter.getSolanaProgram(e)}getSolanaPublicKey(){if(!this.solanaProviderAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaPublicKey"in this.solanaProviderAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.solanaProviderAdapter.getSolanaPublicKey()}async transfer(e,r,t,i,a,n){const s=d.validateAndGetChainId(e);return o.isSolanaLike(s)?ce.hinkalSolanaTransfer(this,e,r,t,i,a,n):se.hinkalTransfer(this,e,r,t,i,a,n)}async withdraw(e,r,t,i,a,n,s){const h=d.validateAndGetChainId(e);return o.isSolanaLike(h)?le.hinkalSolanaWithdraw(this,e,r,t,a,n,s):F.hinkalWithdraw(this,e,r,t,i,a,n,s)}async withdrawStuckUtxos(e,r){return ye.hinkalWithdrawStuckUtxos(this,e,r)}async swap(e,r,t,i,a,n,s){const h=d.validateAndGetChainId(e);return o.isSolanaLike(h)?this.swapSolana(e,r,i,a,n):x.hinkalSwap(this,e,r,t,i,a,n,s)}async swapSolana(e,r,t,i,a){const n=JSON.parse(t),s=BigInt(n.swapperAccountSalt),{instructionLists:h,addressLookupTableAccount:l}=n.data;return de.hinkalSolanaSwap(this,e,r,s,h,l,i,a)}async actionReceive(e,r,t,i,a,n){if(!a)throw new Error("subAccount is required");const s=d.validateAndGetChainId(e);return o.isSolanaLike(s)?H.hinkalSolanaProxyShield(this,e[0],r[0],a,void 0,n):Y.hinkalActionReceive(this,e,r,t,i,a,n)}async actionPrivateWallet(e,r,t,i,a,n,s,h,l,u,p=!1,c,g,v){return $.hinkalPrivateWallet(this,e,r,t,i,a,n,s,h,l,u,p,c,g,v)}async proxySwap(e,r,t,i,a,n,s,h,l=!1,u,p){const c=d.validateAndGetChainId(e);return o.isSolanaLike(c)?pe.hinkalSolanaProxySwap(this,e,r,i,n,s,h):ae.hinkalProxySwap(this,e,r,t,i,a,n,s,h,l,u,p)}async proxyToPrivate(e,r,t,i,a,n,s){const h=d.validateAndGetChainId(e);return o.isSolanaLike(h)?H.hinkalSolanaProxyShield(this,e[0],r[0],t,i,s):oe.hinkalProxyToPrivate(this,e,r,i,a,n,t,s)}async proxySend(e,r,t,i,a,n,s){const h=d.validateAndGetChainId(e);if(o.isSolanaLike(h))return ue.hinkalSolanaProxySend(this,e[0],r[0],t,i,s);const l=te.createTransaferEmporiumOpsBatch(this,h,e.map(c=>c.erc20TokenAddress),r,i),u=e.map((c,g)=>({token:c,amount:-1n*r[g]}));return await this.actionPrivateWallet(h,[],[],[],l,u,t,a,n,void 0,void 0,void 0,s,void 0)}async multiSendPrivateRecipients(e,r,t){return ne.hinkalMultiSendPrivateRecipients(this,e,r,t)}areMerkleTreeUpdatesDisabled(){return this.disableMerkleTreeUpdates}updateMerkleTreeUpdates(e){this.disableMerkleTreeUpdates=e}}exports.Hinkal=Ae;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("ethers"),k=require("../../types/hinkal.types.cjs"),S=require("../../types/ethereum-network.types.cjs"),U=require("./hinkalCheckSolanaTokenRegistry.cjs"),I=require("../../functions/web3/functionCalls/accessTokenCalls.cjs"),K=require("../../functions/web3/events/getShieldedBalance.cjs"),y=require("../crypto-keys/keys.cjs"),T=require("./hinkalDeposit.cjs"),W=require("./hinkalDepositAndWithdraw.cjs"),m=require("./hinkalSolanaDeposit.cjs"),x=require("./hinkalSwap.cjs"),F=require("./hinkalWithdraw.cjs"),N=require("./resetMerkleTrees.cjs"),M=require("../merkle-tree/MerkleTree.cjs"),_=require("../../error-handling/error-codes.constants.cjs"),R=require("../../crypto/poseidon.cjs"),o=require("../../constants/chains.constants.cjs");require("../../API/getServerURL.cjs");require("axios");require("../../constants/coingecko.constants.cjs");require("../../constants/server.constants.cjs");require("../http/HttpClient.cjs");const C=require("../../API/API.cjs");require("../../API/tenderly.api.cjs");require("../../constants/token-data/index.cjs");require("../../constants/contracts.constants.cjs");const O=require("../../constants/kyc.constants.cjs"),G=require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");require("../../constants/schedule.constants.cjs");require("../../constants/tokens.constants.cjs");const z=require("../../functions/utils/reloadPage.cjs"),j=require("../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs"),$=require("./hinkalPrivateWallet.cjs"),J=require("../../functions/utils/cacheDevice.utils.cjs"),V=require("../../functions/web3/getContractMetadata.cjs"),Q=require("./hinkalGetRecipientInfo.cjs"),w=require("../../functions/web3/events/getApprovedBalance.cjs"),X=require("./hinkalSignSubAccount.cjs"),B=require("./hinkalCheckTokenRegistry.cjs"),Y=require("./hinkalActionReceive.cjs"),Z=require("../TokenDBs/PrivateTokensDB.cjs");require("idb-keyval");const ee=require("../../functions/utils/erc20tokenFunctions.cjs");require("multiformats");const P=require("@solana/web3.js");require("@solana/spl-token");require("tronweb");const d=require("../../functions/utils/token-check.utils.cjs");require("async-mutex");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../types/circom-data.types.cjs");require("../../types/activities.types.cjs");const L=require("../../functions/pre-transaction/solana.cjs");require("tweetnacl");require("bs58");require("@coral-xyz/anchor");require("buffer");require("libsodium-wrappers");require("lodash");require("../../functions/utils/userAgent.cjs");require("circomlibjs-hinkal-fork");require("process");require("../../providers/EthersProviderAdapter.cjs");const re=require("../../providers/SolanaProviderAdapter.cjs");require("node-forge");require("../../API/enclaveUtxoCalls.cjs");require("../../functions/web3/events/getInputUtxoAndBalance.cjs");require("../../functions/web3/getTokenHolder.cjs");const te=require("../../functions/private-wallet/emporium.helpers.cjs"),ie=require("./hinkalProoflessDeposit.cjs"),ae=require("./hinkalProxySwap.cjs"),ne=require("./hinkalMultiSend.cjs"),se=require("./hinkalTransfer.cjs"),oe=require("./hinkalProxyToPrivate.cjs"),E=require("../../providers/TronProviderAdapter.cjs"),he=require("./hinkalSolanaDepositAndWithdraw.cjs"),le=require("./hinkalSolanaWithdraw.cjs"),ce=require("./hinkalSolanaTransfer.cjs"),de=require("./hinkalSolanaSwap.cjs"),ue=require("./hinkalSolanaProxySend.cjs"),pe=require("./hinkalSolanaProxySwap.cjs"),H=require("./hinkalSolanaProxyShield.cjs"),D=require("../../functions/web3/fetchSolanaMerkleTreeRootHash.cjs"),ge=require("./hinkalDepositAndBridge.cjs"),ke=require("./hinkalClaimUtxo.cjs"),Pe=require("./hinkalSolanaProoflessDeposit.cjs"),ve=require("./hinkalSolanaClaimUtxo.cjs"),ye=require("./hinkalWithdrawStuckUtxos.cjs");class Ae{ethereumProviderAdapter;solanaProviderAdapter;tronProviderAdapter;userKeys;signingMessage="Login to Hinkal Protocol";privateTransferSigningMessage="Login to Hinkal's Private Transfer App";merkleTreeHinkalByChain={};merkleTreeAccessTokenByChain={};nullifiersByChain={};encryptedOutputsByChain={};approvalsByChain={};commitmentsSnapshotServiceByChain={};nullifierSnapshotServiceByChain={};accessTokenSnapshotServiceByChain={};approvalsSnapshotServiceByChain={};utxoUtils;cacheDevice;generateProofRemotely;disableMerkleTreeUpdates;constructor(e){this.userKeys=new y.UserKeys(void 0),o.HINKAL_SUPPORTED_CHAINS.forEach(r=>{this.merkleTreeHinkalByChain[r]=M.MerkleTree.create(R.poseidonFunction,0n),this.merkleTreeAccessTokenByChain[r]=M.MerkleTree.create(R.poseidonFunction,0n),this.nullifiersByChain[r]=new Set,this.encryptedOutputsByChain[r]=[],this.approvalsByChain[r]=new Map}),this.generateProofRemotely=e?.generateProofRemotely??!0,this.utxoUtils=new j.MultiThreadedUtxoUtils,this.cacheDevice=J.createCacheDevice(e),this.disableMerkleTreeUpdates=e?.disableMerkleTreeUpdates??!1}async initProviderAdapter(e,r){const t=r instanceof re.SolanaProviderAdapter,i=r instanceof E.TronProviderAdapter;let a=o.chainIds.ethMainnet;t?a=o.chainIds.solanaMainnet:i&&(a=o.chainIds.tronMainnet),await this.updateProviderAdapter(a,r),t?this.solanaProviderAdapter?.initConnector(e):i?this.tronProviderAdapter?.initConnector(e):this.ethereumProviderAdapter?.initConnector(e);let n;t?n=await this.connectAndPatchProvider(!0,e):i?n=await r.connectAndPatchProvider(e):n=await this.connectAndPatchProvider(!1,e),await r.init(n),await this.setListeners()}getSigningMessage(e=k.LoginMessageMode.PROTOCOL){switch(e){case k.LoginMessageMode.PRIVATE_TRANSFER:return this.privateTransferSigningMessage;case k.LoginMessageMode.PROTOCOL:default:return this.signingMessage}}async initUserKeys(e=k.LoginMessageMode.PROTOCOL){const r=this.getSigningMessage(e);this.userKeys=new y.UserKeys(await this.getProviderAdapter().signMessage(r))}initUserKeysWithSignature(e){this.userKeys=new y.UserKeys(e)}async initUserKeysFromSeedPhrases(e){const r=e.join(" "),t=q.ethers.toUtf8Bytes(r),i=q.ethers.keccak256(t);this.userKeys=new y.UserKeys(i)}async resetMerkle(e){if(this.disableMerkleTreeUpdates)return;(e?.every(t=>this.isSelectedNetworkSupported(t))??!0)&&await N.resetMerkleTrees(this,e)}getProviderAdapter(e){let r=e,t;if(r||(this.ethereumProviderAdapter?r=o.chainIds.ethMainnet:this.solanaProviderAdapter?r=o.chainIds.solanaMainnet:r=o.chainIds.tronMainnet),o.isSolanaLike(r)?t=this.solanaProviderAdapter:o.isTronLike(r)?t=this.tronProviderAdapter:t=this.ethereumProviderAdapter,!t)throw new Error("ProviderAdapter is not initialized");return t}getTronWeb(){const e=this.tronProviderAdapter;if(!e)throw new Error("Tron provider adapter not initialized");if(!(e instanceof E.TronProviderAdapter))throw new Error("Tron provider adapter is not a TronProviderAdapter");const r=e.getTronWeb();if(!r)throw new Error("TronWeb not available");return r}getSupportedChains(){return this.ethereumProviderAdapter&&this.solanaProviderAdapter?o.WALLET_SUPPORTED_CHAINS:this.ethereumProviderAdapter?o.HINKAL_SUPPORTED_CHAINS.filter(e=>!o.isSolanaLike(e)&&!o.isTronLike(e)):this.solanaProviderAdapter?o.HINKAL_SUPPORTED_CHAINS.filter(e=>o.isSolanaLike(e)):this.tronProviderAdapter?o.HINKAL_SUPPORTED_CHAINS.filter(e=>o.isTronLike(e)):[]}async waitForTransaction(e,r,t=1){return!!await this.getProviderAdapter(e).waitForTransaction(e,r,t)}getContract(e,r,t=void 0){return this.getProviderAdapter(e).getContract(e,r,t)}getContractWithFetcherByChainId(e,r,t=void 0){return V.getContractWithFetcherByChainId(e,r,t)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,r,t){return await this.getProviderAdapter().signTypedData(e,r,t)}async signWithSubAccount(e,r,t,i){return X.hinkalSignSubAccount(e,r,t,i)}getContractWithSigner(e,r,t=""){return this.getProviderAdapter(e).getContractWithSigner(e,r,t)}getContractWithFetcher(e,r,t=""){return this.getProviderAdapter(e).getContractWithFetcher(e,r,t)}isSelectedNetworkSupported(e){return!!o.networkRegistry[e]}async switchNetwork(e){try{await this.getProviderAdapter().switchNetwork(e)}catch{throw new Error(_.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}isPermitterAvailable(e){return this.getProviderAdapter(e).isPermitterAvailable()}async connectAndPatchProvider(e,r){return await this.getProviderAdapter(e?o.chainIds.solanaMainnet:o.chainIds.ethMainnet).connectAndPatchProvider(r)}async disconnectFromConnector(){await this.ethereumProviderAdapter?.disconnectFromConnector(),await this.solanaProviderAdapter?.disconnectFromConnector(),await this.tronProviderAdapter?.disconnectFromConnector()}async resetProviderAdapters(){this.ethereumProviderAdapter=void 0,this.solanaProviderAdapter=void 0,this.tronProviderAdapter=void 0}async updateProviderAdapter(e,r){try{o.isSolanaLike(e)?(this.solanaProviderAdapter&&this.solanaProviderAdapter.release(),this.solanaProviderAdapter=r):o.isTronLike(e)?(this.tronProviderAdapter&&this.tronProviderAdapter.release(),this.tronProviderAdapter=r):(this.ethereumProviderAdapter&&this.ethereumProviderAdapter.release(),this.ethereumProviderAdapter=r)}catch(t){throw console.error(t),Error("updateProviderAdapter failed, please try again.")}}async setListeners(){this.ethereumProviderAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}}),this.solanaProviderAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}}),this.tronProviderAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}})}async onAccountChanged(){await this.ethereumProviderAdapter?.onAccountChanged(),await this.solanaProviderAdapter?.onAccountChanged(),await this.tronProviderAdapter?.onAccountChanged();const e=k.EventType.AccountChanged;typeof document<"u"?document?.dispatchEvent(new Event(e)):process?.emit("message",e,void 0)}async onChainChanged(e){e?await this.getProviderAdapter(e).onChainChanged(e):(await this.disconnectFromConnector(),z.reloadPage())}async monitorConnectedAddress(e){await C.API.monitor(await this.getEthereumAddressByChain(e))}async getBalances(e,r,t,i,a=!1,n,s=!1){return K.getShieldedBalance(this,e,r,t,i,a,this.generateProofRemotely,n,s)}async getApprovedBalances(e,r=!1,t=!1){return w.getApprovedBalance(this,e,r,t)}async getTotalBalance(e,r,t,i=!1,a,n=!1){const s=t??await this.getEthereumAddressByChain(e),h=r??this.userKeys,l=await this.getBalances(e,h.getShieldedPrivateKey(),h.getShieldedPublicKey(),s,i,a,n),u=!o.isSolanaLike(e)&&!n?await this.getApprovedBalances(e,i,a):new Map,p=G.isExtension?await Z.privateTokensDB.getPrivateTokens(e,s):ee.getErc20TokensForChain(e),c=[];return p.forEach(g=>{const v=g.erc20TokenAddress.toLowerCase(),A=l.get(v),f=u.get(v),b={token:g,balance:(A?.balance??0n)+(f?.balance??0n),timestamp:A?.timestamp||f?.timestamp||"0",nfts:A?.nfts||[]};c.push(b)}),c}async getStuckShieldedBalances(e,r,t){return(await this.getTotalBalance(e,r,t,!1,!1,!0)).filter(a=>a.balance>0n)}getSupportedPassportLinks(){return O.supportedPassportLinks}checkAccessToken(e,r){return I.checkHinkalAccessToken(this,e,r)}async getHinkalTreeRootHash(e){if(o.isSolanaLike(e)){const{hinkalIdl:t,hinkalAddress:i,originalDeployer:a}=o.networkRegistry[e].contractData;if(!t||!i||!a)throw new Error(`Missing Solana configuration for chain ${e}`);const n=new P.PublicKey(a),s=new P.PublicKey(i),h=L.getMerkleAccountPublicKey(s,n),l=this.getSolanaProgram(t);return D.fetchSolanaMerkleTreeRootHash(l,h)}return this.getContractWithFetcherByChainId(e,S.ContractType.HinkalContract).getRootHash()}async getAccessTokenTreeRootHash(e){if(o.isSolanaLike(e)){const{hinkalIdl:t,hinkalAddress:i,originalDeployer:a}=o.networkRegistry[e].contractData;if(!t||!i||!a)throw new Error(`Missing Solana configuration for chain ${e}`);const n=new P.PublicKey(a),s=new P.PublicKey(i),h=L.getAccessTokenMerkleAccountPublicKey(s,n),l=this.getSolanaProgram(t);return D.fetchSolanaMerkleTreeRootHash(l,h)}return this.getContractWithFetcherByChainId(e,S.ContractType.AccessTokenContract).getRootHash()}async resetMerkleTreesIfNecessary(e){const t=(await Promise.all((e??this.getSupportedChains()).map(async i=>{const[a,n]=await Promise.all([this.getHinkalTreeRootHash(i),this.getAccessTokenTreeRootHash(i)]),s=BigInt(a)!==this.merkleTreeHinkalByChain[i].getRootHash()||BigInt(n)!==this.merkleTreeAccessTokenByChain[i].getRootHash();return{chainId:i,needsReset:s}}))).filter(i=>i.needsReset).map(i=>i.chainId);t.length>0&&(console.log("resetting merkle tree in resetMerkleTreesIfNecessary for chains:",t),await this.resetMerkle(t))}async getEthereumAddress(){const e=this.ethereumProviderAdapter??this.solanaProviderAdapter??this.tronProviderAdapter;if(!e)throw new Error("No provider adapter initialized");return e.getAddress()}getEthereumAddressByChain(e){return this.getProviderAdapter(e).getAddress()}async getRandomRelay(e,r=!1){return(await C.API.getIdleRelay(e,r)).relay}getGasPrice(e){const r=this.getProviderAdapter(e);if(!r)throw new Error("Illegal State of providerAdapter in Hinkal: no providerAdapter initialized");return r.getGasPrice(e)}getAPI(){return C.API}snapshotsClearInterval(){this.getSupportedChains().forEach(e=>{this.commitmentsSnapshotServiceByChain[e]?.intervalClear(),this.accessTokenSnapshotServiceByChain[e]?.intervalClear(),this.nullifierSnapshotServiceByChain[e]?.intervalClear(),this.approvalsSnapshotServiceByChain[e]?.intervalClear()})}checkTokenRegistry(e,r,t){if(o.isSolanaLike(e)){const{hinkalIdl:a,hinkalAddress:n,originalDeployer:s}=o.networkRegistry[e].contractData;if(!a||!n||!s)throw new Error("missing solana data");const h=this.getSolanaProgram(a),l=new P.PublicKey(s);return U.hinkalCheckSolanaTokenRegistry(h,l,r,t)}if(o.isTronLike(e))return B.hinkalCheckTronTokenRegistry(r,t,e);const i=this.getContractWithFetcher(e,S.ContractType.HinkalHelperContract);return B.hinkalCheckTokenRegistry(i,r,t)}getRecipientInfo(){return Q.getRecipientInfo(this)}getApprovedUtxos(e,r=!1){return w.getApprovedUtxos(this,e,r)}getApprovedUtxosForToken(e,r,t=!1){return w.getApprovedUtxosForToken(this,e,r,t)}async deposit(e,r,t=!0,i=!1){return T.hinkalDeposit(this,e,r,t,i)}async depositSolana(e,r){return m.hinkalSolanaDeposit(this,e,r)}async depositForOther(e,r,t,i=!0,a=!1){return T.hinkalDepositForOther(this,e,r,t,i,a)}async depositSolanaForOther(e,r,t){return m.hinkalSolanaDepositForOther(this,e,r,t)}async depositAndWithdraw(e,r,t,i,a,n,s,h=!0){const l=d.validateAndGetChainId([e]);return o.isSolanaLike(l)?he.hinkalSolanaDepositAndWithdraw(this,e,r,t,i,a,n,s):W.hinkalDepositAndWithdraw(this,e,r,t,i,a,n,s,h)}async claimUtxo(e,r,t,i){const a=d.validateAndGetChainId([e]);return o.isSolanaLike(a)?ve.hinkalSolanaClaimUtxo(this,e,r,t,i):ke.hinkalClaimUtxo(this,e,r,t,i)}async depositAndBridge(e,r,t,i,a,n,s=!0){return ge.hinkalDepositAndBridge(this,e,r,t,i,a,n,s)}async prooflessDeposit(e,r,t,i){const a=d.validateAndGetChainId(e);return o.isSolanaLike(a)?Pe.hinkalSolanaProoflessDeposit(this,e,r,t,i):ie.hinkalProoflessDeposit(this,e,r,t,i)}getSolanaProgram(e){if(!this.solanaProviderAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaProgram"in this.solanaProviderAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.solanaProviderAdapter.getSolanaProgram(e)}getSolanaPublicKey(){if(!this.solanaProviderAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaPublicKey"in this.solanaProviderAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.solanaProviderAdapter.getSolanaPublicKey()}async transfer(e,r,t,i,a,n){const s=d.validateAndGetChainId(e);return o.isSolanaLike(s)?ce.hinkalSolanaTransfer(this,e,r,t,i,a,n):se.hinkalTransfer(this,e,r,t,i,a,n)}async withdraw(e,r,t,i,a,n,s){const h=d.validateAndGetChainId(e);return o.isSolanaLike(h)?le.hinkalSolanaWithdraw(this,e,r,t,a,n,s):F.hinkalWithdraw(this,e,r,t,i,a,n,s)}async withdrawStuckUtxos(e,r){return ye.hinkalWithdrawStuckUtxos(this,e,r)}async swap(e,r,t,i,a,n,s){const h=d.validateAndGetChainId(e);return o.isSolanaLike(h)?this.swapSolana(e,r,i,a,n):x.hinkalSwap(this,e,r,t,i,a,n,s)}async swapSolana(e,r,t,i,a){const n=JSON.parse(t),s=BigInt(n.swapperAccountSalt),{instructionLists:h,addressLookupTableAccount:l}=n.data;return de.hinkalSolanaSwap(this,e,r,s,h,l,i,a)}async actionReceive(e,r,t,i,a,n){if(!a)throw new Error("subAccount is required");const s=d.validateAndGetChainId(e);return o.isSolanaLike(s)?H.hinkalSolanaProxyShield(this,e[0],r[0],a,void 0,n):Y.hinkalActionReceive(this,e,r,t,i,a,n)}async actionPrivateWallet(e,r,t,i,a,n,s,h,l,u,p=!1,c,g,v){return $.hinkalPrivateWallet(this,e,r,t,i,a,n,s,h,l,u,p,c,g,v)}async proxySwap(e,r,t,i,a,n,s,h,l=!1,u,p){const c=d.validateAndGetChainId(e);return o.isSolanaLike(c)?pe.hinkalSolanaProxySwap(this,e,r,i,n,s,h):ae.hinkalProxySwap(this,e,r,t,i,a,n,s,h,l,u,p)}async proxyToPrivate(e,r,t,i,a,n,s){const h=d.validateAndGetChainId(e);return o.isSolanaLike(h)?H.hinkalSolanaProxyShield(this,e[0],r[0],t,i,s):oe.hinkalProxyToPrivate(this,e,r,i,a,n,t,s)}async proxySend(e,r,t,i,a,n,s){const h=d.validateAndGetChainId(e);if(o.isSolanaLike(h))return ue.hinkalSolanaProxySend(this,e[0],r[0],t,i,s);const l=te.createTransaferEmporiumOpsBatch(this,h,e.map(c=>c.erc20TokenAddress),r,i),u=e.map((c,g)=>({token:c,amount:-1n*r[g]}));return await this.actionPrivateWallet(h,[],[],[],l,u,t,a,n,void 0,void 0,void 0,s,void 0)}async multiSendPrivateRecipients(e,r,t){return ne.hinkalMultiSendPrivateRecipients(this,e,r,t)}areMerkleTreeUpdatesDisabled(){return this.disableMerkleTreeUpdates}updateMerkleTreeUpdates(e){this.disableMerkleTreeUpdates=e}}exports.Hinkal=Ae;
|
|
@@ -152,10 +152,8 @@ class Pr {
|
|
|
152
152
|
}
|
|
153
153
|
// If chainId is not provided, use the ethereum provider, if it is initialized. In other case, use the solana provider.
|
|
154
154
|
getProviderAdapter(e) {
|
|
155
|
-
let t = e;
|
|
156
|
-
t || (this.ethereumProviderAdapter ? t = c.ethMainnet : this.solanaProviderAdapter ? t = c.solanaMainnet : t = c.tronMainnet)
|
|
157
|
-
let r;
|
|
158
|
-
if (h(t) ? r = this.solanaProviderAdapter : v(t) ? r = this.tronProviderAdapter : r = this.ethereumProviderAdapter, !r)
|
|
155
|
+
let t = e, r;
|
|
156
|
+
if (t || (this.ethereumProviderAdapter ? t = c.ethMainnet : this.solanaProviderAdapter ? t = c.solanaMainnet : t = c.tronMainnet), h(t) ? r = this.solanaProviderAdapter : v(t) ? r = this.tronProviderAdapter : r = this.ethereumProviderAdapter, !r)
|
|
159
157
|
throw new Error("ProviderAdapter is not initialized");
|
|
160
158
|
return r;
|
|
161
159
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../../constants/protocol.constants.cjs"),B=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),C=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),O=require("../../functions/web3/events/getShieldedBalance.cjs"),U=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),q=require("../utxo/Utxo.cjs"),z=require("../../error-handling/error-codes.constants.cjs");require("../../types/circom-data.types.cjs");const h=require("../../types/ethereum-network.types.cjs");require("../../constants/chains.constants.cjs");const K=require("../../types/admin.types.cjs");require("../../types/activities.types.cjs");const H=require("../../functions/utils/addresses.cjs"),R=require("../../functions/pre-transaction/getKycAndSignatureData.cjs"),b=require("../../functions/utils/time.utils.cjs"),S=require("../../API/admin-calls.cjs"),I=require("../../functions/pre-transaction/constructAdminData.cjs"),M=require("../../functions/utils/token-check.utils.cjs"),f=async(t,n,e,s)=>{const c=await t.getEthereumAddressByChain(n),{patchAccessTokenMerkleTree:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../../constants/protocol.constants.cjs"),B=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),C=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),O=require("../../functions/web3/events/getShieldedBalance.cjs"),U=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),q=require("../utxo/Utxo.cjs"),z=require("../../error-handling/error-codes.constants.cjs");require("../../types/circom-data.types.cjs");const h=require("../../types/ethereum-network.types.cjs");require("../../constants/chains.constants.cjs");const K=require("../../types/admin.types.cjs");require("../../types/activities.types.cjs");const H=require("../../functions/utils/addresses.cjs"),R=require("../../functions/pre-transaction/getKycAndSignatureData.cjs"),b=require("../../functions/utils/time.utils.cjs"),S=require("../../API/admin-calls.cjs"),I=require("../../functions/pre-transaction/constructAdminData.cjs"),M=require("../../functions/utils/token-check.utils.cjs"),f=async(t,n,e,s)=>{const c=await t.getEthereumAddressByChain(n),{patchAccessTokenMerkleTree:r,signatureData:o}=await R.getKycAndSignatureData(t,n,e,s,c);console.log("hinkalDeposit s1",{patchAccessTokenMerkleTree:r,signatureData:o});const a=void 0;return{signatureData:o,externalActionData:{externalActionId:0n,externalAddress:c,externalActionMetadata:"0x00"},contractTransaction:a,contractToApprove:a,patchAccessTokenMerkleTree:r}},F=async(t,n,e,s)=>{const c=[...await O.addPaddingToUtxos(t,n,e,s)],r=[],o=b.getCurrentTimeInSeconds().toString();for(let a=0;a<e.length;a+=1){const{outputUtxos:i}=B.outputUtxoProcessing(t.userKeys,c[a],s[a],o);r.push(i)}return{inputUtxosArray:c,outputUtxosArray:r}},N=async(t,n,e,s=!0,c=!1)=>{const r=M.validateAndGetChainId(n),o=n.map(P=>P.erc20TokenAddress),[{externalActionData:a,contractTransaction:i,contractToApprove:x,patchAccessTokenMerkleTree:A,signatureData:u},{inputUtxosArray:p,outputUtxosArray:y}]=await Promise.all([f(t,r,o,e),F(t,r,o,e)]);console.log("hinkalDeposit a1",{patchAccessTokenMerkleTree:A,signatureData:u});const l=`swapperM${e.length.toString()}x${p[0].length}x1`,{zkCallData:m,circomData:D,dimData:T}=await C.constructZkProof("v1x1",t.merkleTreeHinkalByChain[r],t.merkleTreeAccessTokenByChain[r],p,y,t.userKeys,l,a.externalActionId,a.externalAddress,a.externalActionMetadata,t.generateProofRemotely,w.zeroAddress,r,void 0,void 0,void 0,A,void 0,void 0,void 0,t.getContractWithFetcher(r,h.ContractType.HinkalHelperContract),u),g=await U.transactCallDirect(t,r,e,n,m,D,T,x,i,s,c),v=I.constructAdminData(K.AdminTransactionType.Onboarding,r,o,e,await t.getEthereumAddress());return S.emitTxPublicData(v),g},$=async(t,n,e,s,c=!0,r=!1)=>{const o=M.validateAndGetChainId(n),a=n.map(d=>d.erc20TokenAddress),[i,x,A]=s.split(",");if(!H.isValidPrivateAddress(s))throw Error(z.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const u=a.map(d=>[new q.Utxo({amount:0n,erc20TokenAddress:d,shieldedPrivateKey:t.userKeys.getShieldedPrivateKey()}),new q.Utxo({amount:0n,erc20TokenAddress:d,shieldedPrivateKey:t.userKeys.getShieldedPrivateKey()})]),p=`swapperM${e.length.toString()}x${u[0].length}x1`,y=a.map((d,_)=>[new q.Utxo({amount:e[_],erc20TokenAddress:d,randomization:BigInt(i),stealthAddress:x,encryptionKey:A})]),{externalActionData:l,contractTransaction:m,contractToApprove:D,patchAccessTokenMerkleTree:T}=await f(t,o,a,e),{zkCallData:g,circomData:v,dimData:P}=await C.constructZkProof("v1x1",t.merkleTreeHinkalByChain[o],t.merkleTreeAccessTokenByChain[o],u,y,t.userKeys,p,l.externalActionId,l.externalAddress,l.externalActionMetadata,t.generateProofRemotely,w.zeroAddress,o,void 0,void 0,void 0,T,void 0,void 0,void 0,t.getContractWithFetcher(o,h.ContractType.HinkalHelperContract)),k=await U.transactCallDirect(t,o,e,n,g,v,P,D,m,c,r),E=I.constructAdminData(K.AdminTransactionType.PaymentLink,o,a,e,await t.getEthereumAddress());return S.emitTxPublicData(E),k};exports.hinkalDeposit=N;exports.hinkalDepositForOther=$;
|
|
@@ -16,112 +16,116 @@ import { getCurrentTimeInSeconds as b } from "../../functions/utils/time.utils.m
|
|
|
16
16
|
import { emitTxPublicData as M } from "../../API/admin-calls.mjs";
|
|
17
17
|
import { constructAdminData as E } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
18
18
|
import { validateAndGetChainId as S } from "../../functions/utils/token-check.utils.mjs";
|
|
19
|
-
const
|
|
20
|
-
const s = await t.getEthereumAddressByChain(n), { patchAccessTokenMerkleTree:
|
|
19
|
+
const h = async (t, n, e, i) => {
|
|
20
|
+
const s = await t.getEthereumAddressByChain(n), { patchAccessTokenMerkleTree: r, signatureData: o } = await $(
|
|
21
21
|
t,
|
|
22
22
|
n,
|
|
23
23
|
e,
|
|
24
24
|
i,
|
|
25
25
|
s
|
|
26
|
-
)
|
|
26
|
+
);
|
|
27
|
+
console.log("hinkalDeposit s1", { patchAccessTokenMerkleTree: r, signatureData: o });
|
|
28
|
+
const a = void 0;
|
|
27
29
|
return {
|
|
28
|
-
signatureData:
|
|
30
|
+
signatureData: o,
|
|
29
31
|
externalActionData: {
|
|
30
32
|
externalActionId: 0n,
|
|
31
33
|
externalAddress: s,
|
|
32
34
|
externalActionMetadata: "0x00"
|
|
33
35
|
},
|
|
34
|
-
contractTransaction:
|
|
35
|
-
contractToApprove:
|
|
36
|
-
patchAccessTokenMerkleTree:
|
|
36
|
+
contractTransaction: a,
|
|
37
|
+
contractToApprove: a,
|
|
38
|
+
patchAccessTokenMerkleTree: r
|
|
37
39
|
};
|
|
38
|
-
},
|
|
39
|
-
const s = [...await O(t, n, e, i)],
|
|
40
|
-
for (let
|
|
41
|
-
const { outputUtxos: c } = z(t.userKeys, s[
|
|
42
|
-
|
|
40
|
+
}, k = async (t, n, e, i) => {
|
|
41
|
+
const s = [...await O(t, n, e, i)], r = [], o = b().toString();
|
|
42
|
+
for (let a = 0; a < e.length; a += 1) {
|
|
43
|
+
const { outputUtxos: c } = z(t.userKeys, s[a], i[a], o);
|
|
44
|
+
r.push(c);
|
|
43
45
|
}
|
|
44
|
-
return { inputUtxosArray: s, outputUtxosArray:
|
|
46
|
+
return { inputUtxosArray: s, outputUtxosArray: r };
|
|
45
47
|
}, it = async (t, n, e, i = !0, s = !1) => {
|
|
46
|
-
const
|
|
47
|
-
{ externalActionData:
|
|
48
|
+
const r = S(n), o = n.map((g) => g.erc20TokenAddress), [
|
|
49
|
+
{ externalActionData: a, contractTransaction: c, contractToApprove: u, patchAccessTokenMerkleTree: l, signatureData: m },
|
|
48
50
|
{ inputUtxosArray: A, outputUtxosArray: x }
|
|
49
51
|
] = await Promise.all([
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
])
|
|
52
|
+
h(t, r, o, e),
|
|
53
|
+
k(t, r, o, e)
|
|
54
|
+
]);
|
|
55
|
+
console.log("hinkalDeposit a1", { patchAccessTokenMerkleTree: l, signatureData: m });
|
|
56
|
+
const p = `swapperM${e.length.toString()}x${A[0].length}x1`, { zkCallData: y, circomData: T, dimData: v } = await K(
|
|
53
57
|
"v1x1",
|
|
54
|
-
t.merkleTreeHinkalByChain[
|
|
55
|
-
t.merkleTreeAccessTokenByChain[
|
|
58
|
+
t.merkleTreeHinkalByChain[r],
|
|
59
|
+
t.merkleTreeAccessTokenByChain[r],
|
|
56
60
|
A,
|
|
57
61
|
x,
|
|
58
62
|
t.userKeys,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
p,
|
|
64
|
+
a.externalActionId,
|
|
65
|
+
a.externalAddress,
|
|
66
|
+
a.externalActionMetadata,
|
|
63
67
|
t.generateProofRemotely,
|
|
64
68
|
P,
|
|
65
|
-
|
|
69
|
+
r,
|
|
66
70
|
void 0,
|
|
67
71
|
void 0,
|
|
68
72
|
void 0,
|
|
69
|
-
|
|
73
|
+
l,
|
|
70
74
|
void 0,
|
|
71
75
|
void 0,
|
|
72
76
|
void 0,
|
|
73
|
-
t.getContractWithFetcher(
|
|
74
|
-
|
|
75
|
-
),
|
|
77
|
+
t.getContractWithFetcher(r, C.HinkalHelperContract),
|
|
78
|
+
m
|
|
79
|
+
), D = await U(
|
|
76
80
|
t,
|
|
77
|
-
|
|
81
|
+
r,
|
|
78
82
|
e,
|
|
79
83
|
// for volotile tokens: amountChanges != amountOfTokenToApprove
|
|
80
84
|
n,
|
|
81
85
|
y,
|
|
82
86
|
T,
|
|
83
87
|
v,
|
|
84
|
-
|
|
88
|
+
u,
|
|
85
89
|
c,
|
|
86
90
|
i,
|
|
87
91
|
s
|
|
88
|
-
),
|
|
92
|
+
), f = E(
|
|
89
93
|
I.Onboarding,
|
|
94
|
+
r,
|
|
90
95
|
o,
|
|
91
|
-
a,
|
|
92
96
|
e,
|
|
93
97
|
await t.getEthereumAddress()
|
|
94
98
|
);
|
|
95
|
-
return M(
|
|
96
|
-
}, st = async (t, n, e, i, s = !0,
|
|
97
|
-
const
|
|
99
|
+
return M(f), D;
|
|
100
|
+
}, st = async (t, n, e, i, s = !0, r = !1) => {
|
|
101
|
+
const o = S(n), a = n.map((d) => d.erc20TokenAddress), [c, u, l] = i.split(",");
|
|
98
102
|
if (!N(i))
|
|
99
103
|
throw Error(F.RECIPIENT_FORMAT_INCORRECT);
|
|
100
|
-
const
|
|
104
|
+
const m = a.map((d) => [
|
|
101
105
|
new w({ amount: 0n, erc20TokenAddress: d, shieldedPrivateKey: t.userKeys.getShieldedPrivateKey() }),
|
|
102
106
|
new w({ amount: 0n, erc20TokenAddress: d, shieldedPrivateKey: t.userKeys.getShieldedPrivateKey() })
|
|
103
|
-
]), A = `swapperM${e.length.toString()}x${
|
|
107
|
+
]), A = `swapperM${e.length.toString()}x${m[0].length}x1`, x = a.map((d, R) => [
|
|
104
108
|
new w({
|
|
105
|
-
amount: e[
|
|
109
|
+
amount: e[R],
|
|
106
110
|
erc20TokenAddress: d,
|
|
107
111
|
randomization: BigInt(c),
|
|
108
|
-
stealthAddress:
|
|
109
|
-
encryptionKey:
|
|
112
|
+
stealthAddress: u,
|
|
113
|
+
encryptionKey: l
|
|
110
114
|
})
|
|
111
|
-
]), { externalActionData:
|
|
115
|
+
]), { externalActionData: p, contractTransaction: y, contractToApprove: T, patchAccessTokenMerkleTree: v } = await h(t, o, a, e), { zkCallData: D, circomData: f, dimData: g } = await K(
|
|
112
116
|
"v1x1",
|
|
113
|
-
t.merkleTreeHinkalByChain[
|
|
114
|
-
t.merkleTreeAccessTokenByChain[
|
|
115
|
-
|
|
117
|
+
t.merkleTreeHinkalByChain[o],
|
|
118
|
+
t.merkleTreeAccessTokenByChain[o],
|
|
119
|
+
m,
|
|
116
120
|
x,
|
|
117
121
|
t.userKeys,
|
|
118
122
|
A,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
p.externalActionId,
|
|
124
|
+
p.externalAddress,
|
|
125
|
+
p.externalActionMetadata,
|
|
122
126
|
t.generateProofRemotely,
|
|
123
127
|
P,
|
|
124
|
-
|
|
128
|
+
o,
|
|
125
129
|
void 0,
|
|
126
130
|
void 0,
|
|
127
131
|
void 0,
|
|
@@ -129,27 +133,27 @@ const B = async (t, n, e, i) => {
|
|
|
129
133
|
void 0,
|
|
130
134
|
void 0,
|
|
131
135
|
void 0,
|
|
132
|
-
t.getContractWithFetcher(
|
|
133
|
-
),
|
|
136
|
+
t.getContractWithFetcher(o, C.HinkalHelperContract)
|
|
137
|
+
), B = await U(
|
|
134
138
|
t,
|
|
135
|
-
|
|
139
|
+
o,
|
|
136
140
|
e,
|
|
137
141
|
n,
|
|
138
|
-
f,
|
|
139
142
|
D,
|
|
143
|
+
f,
|
|
140
144
|
g,
|
|
141
145
|
T,
|
|
142
146
|
y,
|
|
143
147
|
s,
|
|
144
|
-
|
|
145
|
-
),
|
|
148
|
+
r
|
|
149
|
+
), H = E(
|
|
146
150
|
I.PaymentLink,
|
|
151
|
+
o,
|
|
147
152
|
a,
|
|
148
|
-
r,
|
|
149
153
|
e,
|
|
150
154
|
await t.getEthereumAddress()
|
|
151
155
|
);
|
|
152
|
-
return M(
|
|
156
|
+
return M(H), B;
|
|
153
157
|
};
|
|
154
158
|
export {
|
|
155
159
|
it as hinkalDeposit,
|
|
@@ -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("./shouldPatchAccessTokenMerkleTree.cjs"),g=require("./getSignatureDataForTransact.cjs"),l=async(e,t,c,n,o)=>{const{patchAccessTokenMerkleTree:a,kycRequired:r,hasAccessToken:s}=await i.shouldPatchAccessTokenMerkleTree(e,t,c,n);console.log("hinkalDeposit x1",{patchAccessTokenMerkleTree:a,kycRequired:r,hasAccessToken:s});const u=await g.getSignatureDataForTransact(t,o,e.userKeys,r,s);return{patchAccessTokenMerkleTree:a,signatureData:u}};exports.getKycAndSignatureData=l;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import { shouldPatchAccessTokenMerkleTree as
|
|
2
|
-
import { getSignatureDataForTransact as
|
|
3
|
-
const
|
|
4
|
-
const { patchAccessTokenMerkleTree:
|
|
1
|
+
import { shouldPatchAccessTokenMerkleTree as u } from "./shouldPatchAccessTokenMerkleTree.mjs";
|
|
2
|
+
import { getSignatureDataForTransact as g } from "./getSignatureDataForTransact.mjs";
|
|
3
|
+
const l = async (e, t, o, c, n) => {
|
|
4
|
+
const { patchAccessTokenMerkleTree: a, kycRequired: r, hasAccessToken: s } = await u(
|
|
5
5
|
e,
|
|
6
6
|
t,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
)
|
|
7
|
+
o,
|
|
8
|
+
c
|
|
9
|
+
);
|
|
10
|
+
console.log("hinkalDeposit x1", { patchAccessTokenMerkleTree: a, kycRequired: r, hasAccessToken: s });
|
|
11
|
+
const i = await g(
|
|
10
12
|
t,
|
|
11
|
-
|
|
13
|
+
n,
|
|
12
14
|
e.userKeys,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
r,
|
|
16
|
+
s
|
|
15
17
|
);
|
|
16
|
-
return { patchAccessTokenMerkleTree:
|
|
18
|
+
return { patchAccessTokenMerkleTree: a, signatureData: i };
|
|
17
19
|
};
|
|
18
20
|
export {
|
|
19
|
-
|
|
21
|
+
l as getKycAndSignatureData
|
|
20
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/chains.constants.cjs"),i=require("../../constants/protocol.constants.cjs"),ee=require("../../data-structures/utxo/Utxo.cjs"),ne=require("../web3/etherFunctions.cjs"),r=require("./common.snarkjs.cjs"),te=require("./generateCircomData.cjs"),ae=require("./generateZkProof.cjs"),se=require("../../types/hinkal.types.cjs"),oe=require("../utils/fees.utils.cjs"),b=require("../../data-structures/Hinkal/hinkalCheckTokenRegistry.cjs"),re=require("../../error-handling/logger.cjs"),ce=require("./getMerkleTreeSiblingsAndRootHashes.cjs"),ie=async(m,M,W,n,a,c,q,z,l,P,G,D=i.zeroAddress,d=T.chainIds.localhost,k=n.map(()=>!1),R=n.map(()=>0n),p=void 0,v=!1,s=void 0,g,u=void 0,J,y=i.defaultSignatureData,w)=>{const _=r.calcAmountChanges(n,a),A=n.map(e=>e[0].erc20TokenAddress),h=r.calcEncryptedOutputs(a),f=c.getShieldedPrivateKey(),O=ee.Utxo.findCorrectRandomization(ne.randomBigInt(31),f),C=T.isTronLike(d)?await b.hinkalCheckTronTokenRegistry(A,r.calcAmountChanges(n,a,!0),d):await b.hinkalCheckTokenRegistry(J??b.createHinkalHelperFromData(d),A,r.calcAmountChanges(n,a,!0)),Z=T.isTronLike(d)?v||C:v,Q=n.map(e=>e.map(t=>t.getConstructableParams()));console.log("hinkalDeposit sa1",{userKeys:c});const{inCommitmentSiblings:X,inCommitmentSiblingSides:Y,accessTokenSiblings:$,accessTokenSiblingSides:K,rootHashHinkal:B,rootHashAccessToken:F,inNullifiers:I}=await ce.getDataFromWorkers(d,M,W,c,Q,Z,C,k,m);console.log("hinkalDeposit y1",{userKeys:c,effectivePatchAccessTokenMerkleTree:Z,kycRequired:C});const j=r.buildOutCommitments(m,a,k),o={rootHashHinkal:B,shieldedPrivateKey:f,erc20TokenAddresses:A,inAmounts:n.map(e=>e.map(t=>t.amount.toString())),inTimeStamps:n.map(e=>e.map(t=>t.timeStamp)),inRandomizations:n.map(e=>e.map(t=>t.randomization)),inNullifiers:I,inCommitmentSiblings:X,inCommitmentSiblingSides:Y,outAmounts:a.map(e=>e.map(t=>t.amount.toString())),outTimeStamp:BigInt(a[0][0].timeStamp),outPublicKeys:a.map(e=>e.map(t=>t.getStealthAddress())),extraRandomization:O,amountChanges:_,outCommitments:j,rootHashAccessToken:F,accessTokenSiblings:$,accessTokenSiblingSides:K,calldataHash:0n},S=n.map(e=>e[0].tokenId??0),E=S.reduce((e,t)=>e+t,0)>0?S.length:0;E>0&&(o.tokenIds=S);const H=r.calcPublicSignalCount(q,o.erc20TokenAddresses,o.amountChanges,o.inNullifiers,o.outCommitments,E);if(!s){s=se.defaultHinkalLogicArgs(_.length,c),s.interactionAddress=l??i.zeroAddress;const e=c.getInHinkalAddress(s.interactionAddress);s.inHinkalAddress=e}if(m==="v1x1"){if(o.interactionAddress=s?.interactionAddress??l??i.zeroAddress,c.getInHinkalAddress(o.interactionAddress)!==s.inHinkalAddress)throw new Error("inHinkalAddress mismatch");o.externalApprovalAddresses=s.useApprovalUtxoData?.map(({externalApprovalAddresses:e})=>e)??[i.zeroAddress,i.zeroAddress,i.zeroAddress]}u||(u=oe.generateFeeStructure(R,n.map(e=>e[0].erc20TokenAddress)));const N=r.calcAmountChanges(n,a,!0);g||(g=r.getSlippageValues(N,s)),re.Logger.log({publicSignalCount:H}),o.calldataHash=r.createCallDataHash(m,H,D,l,z,P,h,R,p,g,k,s,u,y,w);const{zkCallData:L}=await ae.generateZkProof(m,d,q,o,G),V=r.calcStealthAddressStructure(O,f),U=te.generateCircomData(j,I,B,F,N,A,a,h,H,z,l,P,D,o.calldataHash,S,V,k,p,void 0,s,g,u,y,w),x={tokenNumber:n.length,nullifierAmount:n[0].length,outputAmount:a[0].length};return{zkCallData:L,circomData:U,dimData:x,encryptedOutputs:h}};exports.constructZkProof=ie;
|
|
@@ -1,134 +1,138 @@
|
|
|
1
|
-
import { isTronLike as
|
|
2
|
-
import { zeroAddress as
|
|
3
|
-
import { Utxo as
|
|
4
|
-
import { randomBigInt as
|
|
5
|
-
import { calcAmountChanges as
|
|
6
|
-
import { generateCircomData as
|
|
7
|
-
import { generateZkProof as
|
|
8
|
-
import { defaultHinkalLogicArgs as
|
|
9
|
-
import { generateFeeStructure as
|
|
10
|
-
import { hinkalCheckTronTokenRegistry as
|
|
11
|
-
import { Logger as
|
|
12
|
-
import { getDataFromWorkers as
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
1
|
+
import { isTronLike as W, chainIds as x } from "../../constants/chains.constants.mjs";
|
|
2
|
+
import { zeroAddress as s, defaultSignatureData as tt } from "../../constants/protocol.constants.mjs";
|
|
3
|
+
import { Utxo as at } from "../../data-structures/utxo/Utxo.mjs";
|
|
4
|
+
import { randomBigInt as et } from "../web3/etherFunctions.mjs";
|
|
5
|
+
import { calcAmountChanges as H, calcEncryptedOutputs as mt, buildOutCommitments as nt, calcPublicSignalCount as ot, getSlippageValues as it, createCallDataHash as rt, calcStealthAddressStructure as st } from "./common.snarkjs.mjs";
|
|
6
|
+
import { generateCircomData as dt } from "./generateCircomData.mjs";
|
|
7
|
+
import { generateZkProof as ct } from "./generateZkProof.mjs";
|
|
8
|
+
import { defaultHinkalLogicArgs as lt } from "../../types/hinkal.types.mjs";
|
|
9
|
+
import { generateFeeStructure as ft } from "../utils/fees.utils.mjs";
|
|
10
|
+
import { hinkalCheckTronTokenRegistry as kt, hinkalCheckTokenRegistry as St, createHinkalHelperFromData as pt } from "../../data-structures/Hinkal/hinkalCheckTokenRegistry.mjs";
|
|
11
|
+
import { Logger as Ht } from "../../error-handling/logger.mjs";
|
|
12
|
+
import { getDataFromWorkers as gt } from "./getMerkleTreeSiblingsAndRootHashes.mjs";
|
|
13
|
+
const yt = async (d, j, G, a, m, i, h, b, c, D, J, P = s, r = x.localhost, l = a.map(() => !1), z = a.map(() => 0n), v = void 0, w = !1, n = void 0, f, k = void 0, Q, R = tt, u) => {
|
|
14
|
+
const y = H(a, m), S = a.map((t) => t[0].erc20TokenAddress), g = mt(m), A = i.getShieldedPrivateKey(), B = at.findCorrectRandomization(et(31), A), T = W(r) ? await kt(S, H(a, m, !0), r) : await St(
|
|
15
|
+
Q ?? pt(r),
|
|
16
16
|
S,
|
|
17
|
-
|
|
18
|
-
),
|
|
17
|
+
H(a, m, !0)
|
|
18
|
+
), I = W(r) ? w || T : w, X = a.map((t) => t.map((e) => e.getConstructableParams()));
|
|
19
|
+
console.log("hinkalDeposit sa1", { userKeys: i });
|
|
20
|
+
const {
|
|
19
21
|
inCommitmentSiblings: Y,
|
|
20
22
|
inCommitmentSiblingSides: _,
|
|
21
23
|
accessTokenSiblings: $,
|
|
22
|
-
accessTokenSiblingSides:
|
|
23
|
-
rootHashHinkal:
|
|
24
|
-
rootHashAccessToken:
|
|
25
|
-
inNullifiers:
|
|
26
|
-
} = await
|
|
24
|
+
accessTokenSiblingSides: M,
|
|
25
|
+
rootHashHinkal: O,
|
|
26
|
+
rootHashAccessToken: E,
|
|
27
|
+
inNullifiers: F
|
|
28
|
+
} = await gt(
|
|
27
29
|
r,
|
|
28
|
-
W,
|
|
29
30
|
j,
|
|
30
|
-
|
|
31
|
+
G,
|
|
32
|
+
i,
|
|
31
33
|
X,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
I,
|
|
35
|
+
T,
|
|
34
36
|
l,
|
|
35
37
|
d
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
);
|
|
39
|
+
console.log("hinkalDeposit y1", { userKeys: i, effectivePatchAccessTokenMerkleTree: I, kycRequired: T });
|
|
40
|
+
const N = nt(d, m, l), o = {
|
|
41
|
+
rootHashHinkal: O,
|
|
42
|
+
shieldedPrivateKey: A,
|
|
39
43
|
erc20TokenAddresses: S,
|
|
40
|
-
inAmounts:
|
|
41
|
-
inTimeStamps:
|
|
42
|
-
inRandomizations:
|
|
43
|
-
inNullifiers:
|
|
44
|
+
inAmounts: a.map((t) => t.map((e) => e.amount.toString())),
|
|
45
|
+
inTimeStamps: a.map((t) => t.map((e) => e.timeStamp)),
|
|
46
|
+
inRandomizations: a.map((t) => t.map((e) => e.randomization)),
|
|
47
|
+
inNullifiers: F,
|
|
44
48
|
inCommitmentSiblings: Y,
|
|
45
49
|
inCommitmentSiblingSides: _,
|
|
46
|
-
outAmounts: m.map((
|
|
50
|
+
outAmounts: m.map((t) => t.map((e) => e.amount.toString())),
|
|
47
51
|
outTimeStamp: BigInt(m[0][0].timeStamp),
|
|
48
|
-
outPublicKeys: m.map((
|
|
49
|
-
extraRandomization:
|
|
50
|
-
amountChanges:
|
|
51
|
-
outCommitments:
|
|
52
|
-
rootHashAccessToken:
|
|
52
|
+
outPublicKeys: m.map((t) => t.map((e) => e.getStealthAddress())),
|
|
53
|
+
extraRandomization: B,
|
|
54
|
+
amountChanges: y,
|
|
55
|
+
outCommitments: N,
|
|
56
|
+
rootHashAccessToken: E,
|
|
53
57
|
accessTokenSiblings: $,
|
|
54
|
-
accessTokenSiblingSides:
|
|
58
|
+
accessTokenSiblingSides: M,
|
|
55
59
|
calldataHash: 0n
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
+
}, p = a.map((t) => t[0].tokenId ?? 0), Z = p.reduce((t, e) => t + e, 0) > 0 ? p.length : 0;
|
|
61
|
+
Z > 0 && (o.tokenIds = p);
|
|
62
|
+
const C = ot(
|
|
63
|
+
h,
|
|
60
64
|
o.erc20TokenAddresses,
|
|
61
65
|
o.amountChanges,
|
|
62
66
|
o.inNullifiers,
|
|
63
67
|
o.outCommitments,
|
|
64
|
-
|
|
68
|
+
Z
|
|
65
69
|
);
|
|
66
70
|
if (!n) {
|
|
67
|
-
n =
|
|
68
|
-
const
|
|
69
|
-
n.inHinkalAddress =
|
|
71
|
+
n = lt(y.length, i), n.interactionAddress = c ?? s;
|
|
72
|
+
const t = i.getInHinkalAddress(n.interactionAddress);
|
|
73
|
+
n.inHinkalAddress = t;
|
|
70
74
|
}
|
|
71
75
|
if (d === "v1x1") {
|
|
72
|
-
if (o.interactionAddress = n?.interactionAddress ?? c ??
|
|
76
|
+
if (o.interactionAddress = n?.interactionAddress ?? c ?? s, i.getInHinkalAddress(o.interactionAddress) !== n.inHinkalAddress)
|
|
73
77
|
throw new Error("inHinkalAddress mismatch");
|
|
74
78
|
o.externalApprovalAddresses = n.useApprovalUtxoData?.map(
|
|
75
|
-
({ externalApprovalAddresses:
|
|
76
|
-
) ?? [
|
|
79
|
+
({ externalApprovalAddresses: t }) => t
|
|
80
|
+
) ?? [s, s, s];
|
|
77
81
|
}
|
|
78
|
-
k || (k =
|
|
82
|
+
k || (k = ft(
|
|
79
83
|
z,
|
|
80
|
-
|
|
84
|
+
a.map((t) => t[0].erc20TokenAddress)
|
|
81
85
|
));
|
|
82
|
-
const
|
|
83
|
-
f || (f =
|
|
86
|
+
const q = H(a, m, !0);
|
|
87
|
+
f || (f = it(q, n)), Ht.log({ publicSignalCount: C }), o.calldataHash = rt(
|
|
84
88
|
d,
|
|
85
|
-
|
|
89
|
+
C,
|
|
86
90
|
P,
|
|
87
91
|
c,
|
|
88
92
|
b,
|
|
89
|
-
h,
|
|
90
|
-
A,
|
|
91
|
-
z,
|
|
92
93
|
D,
|
|
94
|
+
g,
|
|
95
|
+
z,
|
|
96
|
+
v,
|
|
93
97
|
f,
|
|
94
98
|
l,
|
|
95
99
|
n,
|
|
96
100
|
k,
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
R,
|
|
102
|
+
u
|
|
99
103
|
);
|
|
100
|
-
const { zkCallData:
|
|
104
|
+
const { zkCallData: K } = await ct(d, r, h, o, J), V = st(B, A), L = dt(
|
|
105
|
+
N,
|
|
101
106
|
F,
|
|
102
|
-
E,
|
|
103
|
-
I,
|
|
104
107
|
O,
|
|
105
|
-
|
|
108
|
+
E,
|
|
109
|
+
q,
|
|
106
110
|
S,
|
|
107
111
|
m,
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
g,
|
|
113
|
+
C,
|
|
110
114
|
b,
|
|
111
115
|
c,
|
|
112
|
-
|
|
116
|
+
D,
|
|
113
117
|
P,
|
|
114
118
|
o.calldataHash,
|
|
115
|
-
|
|
119
|
+
p,
|
|
116
120
|
V,
|
|
117
121
|
l,
|
|
118
|
-
|
|
122
|
+
v,
|
|
119
123
|
void 0,
|
|
120
124
|
n,
|
|
121
125
|
f,
|
|
122
126
|
k,
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
R,
|
|
128
|
+
u
|
|
125
129
|
), U = {
|
|
126
|
-
tokenNumber:
|
|
127
|
-
nullifierAmount:
|
|
130
|
+
tokenNumber: a.length,
|
|
131
|
+
nullifierAmount: a[0].length,
|
|
128
132
|
outputAmount: m[0].length
|
|
129
133
|
};
|
|
130
|
-
return { zkCallData:
|
|
134
|
+
return { zkCallData: K, circomData: L, dimData: U, encryptedOutputs: g };
|
|
131
135
|
};
|
|
132
136
|
export {
|
|
133
|
-
|
|
137
|
+
yt as constructZkProof
|
|
134
138
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../../data-structures/merkle-tree/MerkleTree.cjs"),C=require("../../data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../../data-structures/merkle-tree/MerkleTree.cjs"),C=require("../../data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.cjs"),g=require("../../webworker/performTaskWithWorker.cjs"),m=require("../../webworker/worker.registry.cjs"),h=require("../../webworker/zkProofWorker/zkProofWorker.types.cjs"),A=require("./fetchMerkleTreeSiblings.cjs"),H=require("../utils/amounts.utils.cjs"),P=require("../../crypto/poseidon.cjs"),W=require("../../constants/vite.constants.cjs"),_=require("./fetchOnChainRootHashes.cjs"),p=async(e,a)=>{const s=e.getRootHash();if(s===void 0)throw new Error("Root hash not available from patched merkle tree");const o=await g.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES,data:{accessKey:a,merkleTreeAccessTokenSerialized:e.toJSON()}}});return{accessTokenSiblings:o.accessTokenSiblings,accessTokenSiblingSides:o.accessTokenSiblingSides,rootHashAccessToken:s}},N=async(e,a,s,o,i,n)=>{console.log("hinkalDeposit sa5");const r=s.getAccessKey();console.log("hinkalDeposit sa6",{accessKey:r});const t=C.getPatchedAccessTokenMerkleTree(a,r,i,n),k=e.getRootHash();if(k===void 0)throw new Error("Root hash not available from hinkal merkle tree");let l,c;return W.isNode?(l=await p(t,r),c=await g.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.CALC_COMMITMENTS_SIBLING_AND_SIDES,data:{inputUtxosSerialized:o,merkleTreeSerialized:e.toJSON()}}})):[l,c]=await Promise.all([p(t,r),g.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.CALC_COMMITMENTS_SIBLING_AND_SIDES,data:{inputUtxosSerialized:o,merkleTreeSerialized:e.toJSON()}}})]),{inCommitmentSiblings:c.inCommitmentSiblings,inCommitmentSiblingSides:c.inCommitmentSiblingSides,accessTokenSiblings:l.accessTokenSiblings,accessTokenSiblingSides:l.accessTokenSiblingSides,rootHashHinkal:k,rootHashAccessToken:l.rootHashAccessToken}},R=async(e,a,s,o,i)=>{console.log("hinkalDeposit sa3");const n=a.getAccessKey();if(console.log("hinkalDeposit sa4",{accessKey:n}),!i||o){const k=u.MerkleTree.create(P.poseidonFunction,0n),l=C.getPatchedAccessTokenMerkleTree(k,n,o,i),[c,S]=await Promise.all([p(l,n),A.fetchMerkleTreeSiblings(e,s,n)]);return{inCommitmentSiblings:S.inCommitmentSiblings,inCommitmentSiblingSides:S.inCommitmentSiblingSides,accessTokenSiblings:c.accessTokenSiblings,accessTokenSiblingSides:c.accessTokenSiblingSides,rootHashHinkal:H.toBigInt(S.rootHashHinkal),rootHashAccessToken:c.rootHashAccessToken}}const t=await A.fetchMerkleTreeSiblings(e,s,n);return{inCommitmentSiblings:t.inCommitmentSiblings,inCommitmentSiblingSides:t.inCommitmentSiblingSides,accessTokenSiblings:t.accessTokenSiblings,accessTokenSiblingSides:t.accessTokenSiblingSides,rootHashHinkal:H.toBigInt(t.rootHashHinkal),rootHashAccessToken:H.toBigInt(t.rootHashAccessToken)}},I=async(e,a,s)=>{if(!a||!s)return!1;try{const o=a.getRootHash(),i=s.getRootHash();if(!o||!i)return!1;const{hinkalRootHash:n,accessTokenRootHash:r}=await _.fetchOnChainRootHashes(e);return o===n&&i===r}catch{return!1}},y=async(e,a,s,o,i,n,r)=>{const t=await I(e,n,r);return console.log("hinkalDeposit sa2",{isLocalFresh:t}),t?N(n,r,a,s,o,i):R(e,a,s,o,i)},M=async(e,a,s,o,i,n,r,t,k)=>{if(W.isNode){const{inCommitmentSiblings:l,inCommitmentSiblingSides:c,accessTokenSiblings:S,accessTokenSiblingSides:T,rootHashHinkal:b,rootHashAccessToken:d}=await y(e,o,i,n,r,a,s),f=await g.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS,data:{inputUtxosSerialized:i,onChainCreation:t,proverVersion:k}}});return{inCommitmentSiblings:l,inCommitmentSiblingSides:c,accessTokenSiblings:S,accessTokenSiblingSides:T,rootHashHinkal:b,rootHashAccessToken:d,inNullifiers:f}}else{const[{inCommitmentSiblings:l,inCommitmentSiblingSides:c,accessTokenSiblings:S,accessTokenSiblingSides:T,rootHashHinkal:b,rootHashAccessToken:d},f]=await Promise.all([y(e,o,i,n,r,a,s),g.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS,data:{inputUtxosSerialized:i,onChainCreation:t,proverVersion:k}}})]);return{inCommitmentSiblings:l,inCommitmentSiblingSides:c,accessTokenSiblings:S,accessTokenSiblingSides:T,rootHashHinkal:b,rootHashAccessToken:d,inNullifiers:f}}};exports.getDataFromWorkers=M;exports.getMerkleTreeSiblingsAndRootHashes=y;
|
|
@@ -2,22 +2,22 @@ import { MerkleTree as R } from "../../data-structures/merkle-tree/MerkleTree.mj
|
|
|
2
2
|
import { getPatchedAccessTokenMerkleTree as A } from "../../data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.mjs";
|
|
3
3
|
import { performTaskWithWorker as g } from "../../webworker/performTaskWithWorker.mjs";
|
|
4
4
|
import { WorkerVariant as k } from "../../webworker/worker.registry.mjs";
|
|
5
|
-
import { ZKProofWorkerActionType as
|
|
5
|
+
import { ZKProofWorkerActionType as h } from "../../webworker/zkProofWorker/zkProofWorker.types.mjs";
|
|
6
6
|
import { fetchMerkleTreeSiblings as C } from "./fetchMerkleTreeSiblings.mjs";
|
|
7
7
|
import { toBigInt as d } from "../utils/amounts.utils.mjs";
|
|
8
8
|
import { poseidonFunction as I } from "../../crypto/poseidon.mjs";
|
|
9
9
|
import { isNode as N } from "../../constants/vite.constants.mjs";
|
|
10
10
|
import { fetchOnChainRootHashes as _ } from "./fetchOnChainRootHashes.mjs";
|
|
11
|
-
const p = async (o,
|
|
11
|
+
const p = async (o, a) => {
|
|
12
12
|
const e = o.getRootHash();
|
|
13
13
|
if (e === void 0)
|
|
14
14
|
throw new Error("Root hash not available from patched merkle tree");
|
|
15
15
|
const s = await g({
|
|
16
16
|
type: k.ZKProof,
|
|
17
17
|
payload: {
|
|
18
|
-
type:
|
|
18
|
+
type: h.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES,
|
|
19
19
|
data: {
|
|
20
|
-
accessKey:
|
|
20
|
+
accessKey: a,
|
|
21
21
|
merkleTreeAccessTokenSerialized: o.toJSON()
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -27,117 +27,124 @@ const p = async (o, n) => {
|
|
|
27
27
|
accessTokenSiblingSides: s.accessTokenSiblingSides,
|
|
28
28
|
rootHashAccessToken: e
|
|
29
29
|
};
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
}, w = async (o, a, e, s, i, n) => {
|
|
31
|
+
console.log("hinkalDeposit sa5");
|
|
32
|
+
const c = e.getAccessKey();
|
|
33
|
+
console.log("hinkalDeposit sa6", { accessKey: c });
|
|
34
|
+
const t = A(
|
|
35
|
+
a,
|
|
33
36
|
c,
|
|
34
37
|
i,
|
|
35
|
-
|
|
38
|
+
n
|
|
36
39
|
), m = o.getRootHash();
|
|
37
40
|
if (m === void 0)
|
|
38
41
|
throw new Error("Root hash not available from hinkal merkle tree");
|
|
39
|
-
let
|
|
40
|
-
return N ? (
|
|
42
|
+
let r, l;
|
|
43
|
+
return N ? (r = await p(t, c), l = await g({
|
|
41
44
|
type: k.ZKProof,
|
|
42
45
|
payload: {
|
|
43
|
-
type:
|
|
46
|
+
type: h.CALC_COMMITMENTS_SIBLING_AND_SIDES,
|
|
44
47
|
data: { inputUtxosSerialized: s, merkleTreeSerialized: o.toJSON() }
|
|
45
48
|
}
|
|
46
|
-
})) : [
|
|
47
|
-
p(
|
|
49
|
+
})) : [r, l] = await Promise.all([
|
|
50
|
+
p(t, c),
|
|
48
51
|
g({
|
|
49
52
|
type: k.ZKProof,
|
|
50
53
|
payload: {
|
|
51
|
-
type:
|
|
54
|
+
type: h.CALC_COMMITMENTS_SIBLING_AND_SIDES,
|
|
52
55
|
data: { inputUtxosSerialized: s, merkleTreeSerialized: o.toJSON() }
|
|
53
56
|
}
|
|
54
57
|
})
|
|
55
58
|
]), {
|
|
56
|
-
inCommitmentSiblings:
|
|
57
|
-
inCommitmentSiblingSides:
|
|
58
|
-
accessTokenSiblings:
|
|
59
|
-
accessTokenSiblingSides:
|
|
59
|
+
inCommitmentSiblings: l.inCommitmentSiblings,
|
|
60
|
+
inCommitmentSiblingSides: l.inCommitmentSiblingSides,
|
|
61
|
+
accessTokenSiblings: r.accessTokenSiblings,
|
|
62
|
+
accessTokenSiblingSides: r.accessTokenSiblingSides,
|
|
60
63
|
rootHashHinkal: m,
|
|
61
|
-
rootHashAccessToken:
|
|
64
|
+
rootHashAccessToken: r.rootHashAccessToken
|
|
62
65
|
};
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
}, D = async (o, a, e, s, i) => {
|
|
67
|
+
console.log("hinkalDeposit sa3");
|
|
68
|
+
const n = a.getAccessKey();
|
|
69
|
+
if (console.log("hinkalDeposit sa4", { accessKey: n }), !i || s) {
|
|
70
|
+
const m = R.create(I, 0n), r = A(
|
|
67
71
|
m,
|
|
68
|
-
|
|
72
|
+
n,
|
|
69
73
|
s,
|
|
70
74
|
i
|
|
71
|
-
), [
|
|
72
|
-
p(
|
|
73
|
-
C(o, e,
|
|
75
|
+
), [l, S] = await Promise.all([
|
|
76
|
+
p(r, n),
|
|
77
|
+
C(o, e, n)
|
|
74
78
|
]);
|
|
75
79
|
return {
|
|
76
80
|
inCommitmentSiblings: S.inCommitmentSiblings,
|
|
77
81
|
inCommitmentSiblingSides: S.inCommitmentSiblingSides,
|
|
78
|
-
accessTokenSiblings:
|
|
79
|
-
accessTokenSiblingSides:
|
|
82
|
+
accessTokenSiblings: l.accessTokenSiblings,
|
|
83
|
+
accessTokenSiblingSides: l.accessTokenSiblingSides,
|
|
80
84
|
rootHashHinkal: d(S.rootHashHinkal),
|
|
81
|
-
rootHashAccessToken:
|
|
85
|
+
rootHashAccessToken: l.rootHashAccessToken
|
|
82
86
|
};
|
|
83
87
|
}
|
|
84
|
-
const
|
|
88
|
+
const t = await C(o, e, n);
|
|
85
89
|
return {
|
|
86
|
-
inCommitmentSiblings:
|
|
87
|
-
inCommitmentSiblingSides:
|
|
88
|
-
accessTokenSiblings:
|
|
89
|
-
accessTokenSiblingSides:
|
|
90
|
-
rootHashHinkal: d(
|
|
91
|
-
rootHashAccessToken: d(
|
|
90
|
+
inCommitmentSiblings: t.inCommitmentSiblings,
|
|
91
|
+
inCommitmentSiblingSides: t.inCommitmentSiblingSides,
|
|
92
|
+
accessTokenSiblings: t.accessTokenSiblings,
|
|
93
|
+
accessTokenSiblingSides: t.accessTokenSiblingSides,
|
|
94
|
+
rootHashHinkal: d(t.rootHashHinkal),
|
|
95
|
+
rootHashAccessToken: d(t.rootHashAccessToken)
|
|
92
96
|
};
|
|
93
|
-
},
|
|
94
|
-
if (!
|
|
97
|
+
}, L = async (o, a, e) => {
|
|
98
|
+
if (!a || !e)
|
|
95
99
|
return !1;
|
|
96
100
|
try {
|
|
97
|
-
const s =
|
|
101
|
+
const s = a.getRootHash(), i = e.getRootHash();
|
|
98
102
|
if (!s || !i)
|
|
99
103
|
return !1;
|
|
100
|
-
const { hinkalRootHash:
|
|
101
|
-
return s ===
|
|
104
|
+
const { hinkalRootHash: n, accessTokenRootHash: c } = await _(o);
|
|
105
|
+
return s === n && i === c;
|
|
102
106
|
} catch {
|
|
103
107
|
return !1;
|
|
104
108
|
}
|
|
105
|
-
}, y = async (o,
|
|
106
|
-
t,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
}, y = async (o, a, e, s, i, n, c) => {
|
|
110
|
+
const t = await L(o, n, c);
|
|
111
|
+
return console.log("hinkalDeposit sa2", { isLocalFresh: t }), t ? w(
|
|
112
|
+
n,
|
|
113
|
+
c,
|
|
114
|
+
a,
|
|
115
|
+
e,
|
|
116
|
+
s,
|
|
117
|
+
i
|
|
118
|
+
) : D(o, a, e, s, i);
|
|
119
|
+
}, v = async (o, a, e, s, i, n, c, t, m) => {
|
|
113
120
|
if (N) {
|
|
114
121
|
const {
|
|
115
|
-
inCommitmentSiblings:
|
|
116
|
-
inCommitmentSiblingSides:
|
|
122
|
+
inCommitmentSiblings: r,
|
|
123
|
+
inCommitmentSiblingSides: l,
|
|
117
124
|
accessTokenSiblings: S,
|
|
118
|
-
accessTokenSiblingSides:
|
|
125
|
+
accessTokenSiblingSides: b,
|
|
119
126
|
rootHashHinkal: T,
|
|
120
127
|
rootHashAccessToken: f
|
|
121
128
|
} = await y(
|
|
122
129
|
o,
|
|
123
130
|
s,
|
|
124
131
|
i,
|
|
125
|
-
t,
|
|
126
|
-
c,
|
|
127
132
|
n,
|
|
133
|
+
c,
|
|
134
|
+
a,
|
|
128
135
|
e
|
|
129
136
|
), H = await g({
|
|
130
137
|
type: k.ZKProof,
|
|
131
138
|
payload: {
|
|
132
|
-
type:
|
|
133
|
-
data: { inputUtxosSerialized: i, onChainCreation:
|
|
139
|
+
type: h.BUILD_IN_NULLIFIERS,
|
|
140
|
+
data: { inputUtxosSerialized: i, onChainCreation: t, proverVersion: m }
|
|
134
141
|
}
|
|
135
142
|
});
|
|
136
143
|
return {
|
|
137
|
-
inCommitmentSiblings:
|
|
138
|
-
inCommitmentSiblingSides:
|
|
144
|
+
inCommitmentSiblings: r,
|
|
145
|
+
inCommitmentSiblingSides: l,
|
|
139
146
|
accessTokenSiblings: S,
|
|
140
|
-
accessTokenSiblingSides:
|
|
147
|
+
accessTokenSiblingSides: b,
|
|
141
148
|
rootHashHinkal: T,
|
|
142
149
|
rootHashAccessToken: f,
|
|
143
150
|
inNullifiers: H
|
|
@@ -145,10 +152,10 @@ const p = async (o, n) => {
|
|
|
145
152
|
} else {
|
|
146
153
|
const [
|
|
147
154
|
{
|
|
148
|
-
inCommitmentSiblings:
|
|
149
|
-
inCommitmentSiblingSides:
|
|
155
|
+
inCommitmentSiblings: r,
|
|
156
|
+
inCommitmentSiblingSides: l,
|
|
150
157
|
accessTokenSiblings: S,
|
|
151
|
-
accessTokenSiblingSides:
|
|
158
|
+
accessTokenSiblingSides: b,
|
|
152
159
|
rootHashHinkal: T,
|
|
153
160
|
rootHashAccessToken: f
|
|
154
161
|
},
|
|
@@ -158,24 +165,24 @@ const p = async (o, n) => {
|
|
|
158
165
|
o,
|
|
159
166
|
s,
|
|
160
167
|
i,
|
|
161
|
-
t,
|
|
162
|
-
c,
|
|
163
168
|
n,
|
|
169
|
+
c,
|
|
170
|
+
a,
|
|
164
171
|
e
|
|
165
172
|
),
|
|
166
173
|
g({
|
|
167
174
|
type: k.ZKProof,
|
|
168
175
|
payload: {
|
|
169
|
-
type:
|
|
170
|
-
data: { inputUtxosSerialized: i, onChainCreation:
|
|
176
|
+
type: h.BUILD_IN_NULLIFIERS,
|
|
177
|
+
data: { inputUtxosSerialized: i, onChainCreation: t, proverVersion: m }
|
|
171
178
|
}
|
|
172
179
|
})
|
|
173
180
|
]);
|
|
174
181
|
return {
|
|
175
|
-
inCommitmentSiblings:
|
|
176
|
-
inCommitmentSiblingSides:
|
|
182
|
+
inCommitmentSiblings: r,
|
|
183
|
+
inCommitmentSiblingSides: l,
|
|
177
184
|
accessTokenSiblings: S,
|
|
178
|
-
accessTokenSiblingSides:
|
|
185
|
+
accessTokenSiblingSides: b,
|
|
179
186
|
rootHashHinkal: T,
|
|
180
187
|
rootHashAccessToken: f,
|
|
181
188
|
inNullifiers: H
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "h_test_1",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"homepage": "hinkal.io",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Hinkal Protocol"
|
|
@@ -36,6 +36,16 @@
|
|
|
36
36
|
"types": "./providers/prepareWagmiHinkal.d.ts",
|
|
37
37
|
"import": "./providers/prepareWagmiHinkal.mjs",
|
|
38
38
|
"default": "./providers/prepareWagmiHinkal.cjs"
|
|
39
|
+
},
|
|
40
|
+
"./providers/SolanaProviderAdapter": {
|
|
41
|
+
"types": "./providers/SolanaProviderAdapter.d.ts",
|
|
42
|
+
"import": "./providers/SolanaProviderAdapter.mjs",
|
|
43
|
+
"default": "./providers/SolanaProviderAdapter.cjs"
|
|
44
|
+
},
|
|
45
|
+
"./providers/TronProviderAdapter": {
|
|
46
|
+
"types": "./providers/TronProviderAdapter.d.ts",
|
|
47
|
+
"import": "./providers/TronProviderAdapter.mjs",
|
|
48
|
+
"default": "./providers/TronProviderAdapter.cjs"
|
|
39
49
|
}
|
|
40
50
|
},
|
|
41
51
|
"types": "./index.d.ts",
|
|
@@ -5,7 +5,7 @@ import { type Connector } from 'wagmi';
|
|
|
5
5
|
import { Call } from '../types/eip5792.types';
|
|
6
6
|
export declare class WagmiProviderAdapter implements IProviderAdapter<Connector> {
|
|
7
7
|
private connector;
|
|
8
|
-
|
|
8
|
+
chainId: number | undefined;
|
|
9
9
|
private originalProvider;
|
|
10
10
|
private fetchProviders;
|
|
11
11
|
private signer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("@solana/web3.js");require("circomlibjs-hinkal-fork");require("../constants/chains.constants.cjs");require("../error-handling/error-codes.constants.cjs");require("../data-structures/crypto-keys/keys.cjs");require("libsodium-wrappers");const q=require("../data-structures/Hinkal/Hinkal.cjs");require("../types/circom-data.types.cjs");require("../constants/vite.constants.cjs");require("node-forge");require("../data-structures/http/HttpClient.cjs");require("axios");require("../constants/token-data/index.cjs");require("../constants/tokens.constants.cjs");require("idb-keyval");require("../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../types/activities.types.cjs");require("../constants/server.constants.cjs");require("../API/getServerURL.cjs");require("tronweb");require("@coral-xyz/anchor");require("@solana/spl-token");require("tweetnacl");require("bs58");require("buffer");require("lodash");require("../API/enclaveUtxoCalls.cjs");require("../constants/contracts.constants.cjs");require("../constants/kyc.constants.cjs");require("../constants/coingecko.constants.cjs");require("../constants/reorg-depths.constants.cjs");require("../constants/addresses.constants.cjs");require("../constants/token.limits.constants.cjs");require("../constants/presale.constants.cjs");require("../constants/activity.constants.cjs");require("../constants/tasks.constants.cjs");require("../constants/events.constants.cjs");require("../constants/schedule.constants.cjs");require("../functions/utils/userAgent.cjs");require("multiformats");require("async-mutex");const a=require("../crypto/preProcessing.cjs");require("./EthersProviderAdapter.cjs");require("../functions/web3/events/getInputUtxoAndBalance.cjs");require("../functions/web3/events/getApprovedBalance.cjs");require("../functions/web3/getTokenHolder.cjs");require("../constants/save-depths.cjs");require("../API/tenderly.api.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("@solana/web3.js");require("circomlibjs-hinkal-fork");require("../constants/chains.constants.cjs");require("../error-handling/error-codes.constants.cjs");require("../data-structures/crypto-keys/keys.cjs");require("libsodium-wrappers");const q=require("../data-structures/Hinkal/Hinkal.cjs");require("../types/circom-data.types.cjs");require("../constants/vite.constants.cjs");require("node-forge");require("../data-structures/http/HttpClient.cjs");require("axios");require("../constants/token-data/index.cjs");require("../constants/tokens.constants.cjs");require("idb-keyval");require("../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../types/activities.types.cjs");require("../constants/server.constants.cjs");require("../API/getServerURL.cjs");require("tronweb");require("@coral-xyz/anchor");require("@solana/spl-token");require("tweetnacl");require("bs58");require("buffer");require("lodash");require("../API/enclaveUtxoCalls.cjs");require("../constants/contracts.constants.cjs");require("../constants/kyc.constants.cjs");require("../constants/coingecko.constants.cjs");require("../constants/reorg-depths.constants.cjs");require("../constants/addresses.constants.cjs");require("../constants/token.limits.constants.cjs");require("../constants/presale.constants.cjs");require("../constants/activity.constants.cjs");require("../constants/tasks.constants.cjs");require("../constants/events.constants.cjs");require("../constants/schedule.constants.cjs");require("../functions/utils/userAgent.cjs");require("multiformats");require("async-mutex");const a=require("../crypto/preProcessing.cjs");require("./EthersProviderAdapter.cjs");require("../functions/web3/events/getInputUtxoAndBalance.cjs");require("../functions/web3/events/getApprovedBalance.cjs");require("../functions/web3/getTokenHolder.cjs");require("../constants/save-depths.cjs");require("../API/tenderly.api.cjs");const t=require("./WagmiProviderAdapter.cjs"),n=async(i,u)=>{await a.preProcessing();const e=new q.Hinkal,r=t.default();return r.initConfig?.(u),await e.initProviderAdapter(i,r),await e.initUserKeys(),await e.resetMerkle(),e};exports.prepareWagmiHinkal=n;
|
|
@@ -47,12 +47,12 @@ import "../functions/web3/events/getApprovedBalance.mjs";
|
|
|
47
47
|
import "../functions/web3/getTokenHolder.mjs";
|
|
48
48
|
import "../constants/save-depths.mjs";
|
|
49
49
|
import "../API/tenderly.api.mjs";
|
|
50
|
-
import
|
|
51
|
-
const
|
|
50
|
+
import a from "./WagmiProviderAdapter.mjs";
|
|
51
|
+
const or = async (t, o) => {
|
|
52
52
|
await m();
|
|
53
|
-
const
|
|
54
|
-
return
|
|
53
|
+
const r = new p(), i = a();
|
|
54
|
+
return i.initConfig?.(o), await r.initProviderAdapter(t, i), await r.initUserKeys(), await r.resetMerkle(), r;
|
|
55
55
|
};
|
|
56
56
|
export {
|
|
57
|
-
|
|
57
|
+
or as prepareWagmiHinkal
|
|
58
58
|
};
|