@kapa123456789/sdk 0.0.24 → 0.0.25
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/common/src/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/common/src/data-structures/Hinkal/Hinkal.d.ts +4 -0
- package/common/src/data-structures/Hinkal/Hinkal.mjs +10 -2
- package/common/src/data-structures/Hinkal/HinkalPrivateBalanceController.cjs +1 -0
- package/common/src/data-structures/Hinkal/HinkalPrivateBalanceController.d.ts +19 -0
- package/common/src/data-structures/Hinkal/HinkalPrivateBalanceController.mjs +239 -0
- package/common/src/data-structures/Hinkal/IHinkal.d.ts +3 -0
- package/common/src/data-structures/Hinkal/index.d.ts +1 -0
- package/common/src/data-structures/IndexedDB/index.cjs +1 -1
- package/common/src/data-structures/IndexedDB/index.d.ts +1 -0
- package/common/src/data-structures/IndexedDB/index.mjs +1 -0
- package/common/src/data-structures/IndexedDB/key-val-store.cjs +1 -0
- package/common/src/data-structures/IndexedDB/key-val-store.d.ts +6 -0
- package/common/src/data-structures/IndexedDB/key-val-store.mjs +41 -0
- package/common/src/data-structures/IndexedDB/prices-db.cjs +1 -1
- package/common/src/data-structures/IndexedDB/prices-db.mjs +18 -17
- package/common/src/data-structures/IndexedDB/private-balances-db.cjs +1 -1
- package/common/src/data-structures/IndexedDB/private-balances-db.mjs +10 -11
- package/common/src/functions/web3/events/balanceChangedHandler.d.ts +1 -1
- package/common/src/types/balances.types.d.ts +22 -0
- package/common/src/webworker/package.json +1 -1
- package/package.json +1 -1
- package/services/Hinkal.cjs +1 -1
- package/services/Hinkal.d.ts +3 -3
- package/services/Hinkal.mjs +9 -7
- package/types/IHinkal.d.ts +4 -3
- package/types/balances.types.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../functions/utils/serialize.utils.cjs`),t=require(`../../constants/vite.constants.cjs`),n=require(`../../constants/chains.constants.cjs`),r=require(`../../types/hinkal.types.cjs`),i=require(`../../types/ethereum-network.types.cjs`),a=require(`../../crypto/poseidon.cjs`),o=require(`../../functions/pre-transaction/solana.cjs`),s=require(`./hinkalCheckSolanaTokenRegistry.cjs`),c=require(`../../functions/web3/functionCalls/accessTokenCalls.cjs`),l=require(`../../error-handling/error-codes.constants.cjs`),u=require(`../../functions/utils/erc20tokenFunctions.cjs`),d=require(`../crypto-keys/keys.cjs`),f=require(`../../API/API.cjs`),p=require(`../../functions/utils/token-check.utils.cjs`),m=require(`../TokenDBs/PrivateTokensDB.cjs`),ee=require(`../../functions/web3/events/getShieldedBalance.cjs`),h=require(`../../constants/kyc.constants.cjs`),g=require(`../../functions/utils/reloadPage.cjs`),te=require(`../../functions/utils/cacheDevice.utils.cjs`),_=require(`../../functions/web3/getContractMetadata.cjs`),v=require(`../../providers/SolanaProviderAdapter.cjs`),y=require(`./hinkalCheckTokenRegistry.cjs`),b=require(`../merkle-tree/MerkleTree.cjs`);require(`../merkle-tree/index.cjs`);const x=require(`../../functions/web3/fetchSolanaMerkleTreeRootHash.cjs`),S=require(`./hinkalDeposit.cjs`),C=require(`../../functions/private-wallet/emporium.helpers.cjs`);require(`../../API/index.cjs`);const w=require(`../../functions/kyc/checkTokenLimitsUSD.cjs`),T=require(`./hinkalDepositAndWithdraw.cjs`),E=require(`./hinkalSolanaDeposit.cjs`),D=require(`./hinkalSwap.cjs`),O=require(`./hinkalWithdraw.cjs`),k=require(`./resetMerkleTrees.cjs`),A=require(`../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs`),j=require(`./hinkalPrivateWallet.cjs`),M=require(`./hinkalGetRecipientInfo.cjs`),N=require(`./hinkalSignSubAccount.cjs`),P=require(`./hinkalActionReceive.cjs`);require(`../TokenDBs/index.cjs`);const F=require(`./hinkalProoflessDeposit.cjs`),I=require(`./hinkalProxySwap.cjs`),L=require(`./hinkalMultiSend.cjs`),ne=require(`./hinkalTransfer.cjs`),R=require(`./hinkalProxyToPrivate.cjs`),z=require(`../../providers/TronProviderAdapter.cjs`),B=require(`./hinkalSolanaDepositAndWithdraw.cjs`),V=require(`./hinkalSolanaWithdraw.cjs`),H=require(`./hinkalSolanaTransfer.cjs`),U=require(`./hinkalSolanaSwap.cjs`),W=require(`./hinkalSolanaProxySend.cjs`),G=require(`./hinkalSolanaProxySwap.cjs`),K=require(`./hinkalSolanaProxyShield.cjs`),q=require(`./hinkalDepositAndBridge.cjs`),J=require(`./hinkalClaimUtxo.cjs`),Y=require(`./hinkalSolanaProoflessDeposit.cjs`),X=require(`./hinkalSolanaClaimUtxo.cjs`),Z=require(`./hinkalWithdrawStuckUtxos.cjs`);let Q=require(`ethers`),$=require(`@solana/web3.js`);var re=class{ethereumProviderAdapter;solanaProviderAdapter;tronProviderAdapter;userKeys;signingMessage=`Login to Hinkal Protocol`;privateTransferSigningMessage=`Login to Hinkal's Private Transfer App`;merkleTreeHinkalByChain={};merkleTreeAccessTokenByChain={};nullifiersByChain={};encryptedOutputsByChain={};commitmentsSnapshotServiceByChain={};nullifierSnapshotServiceByChain={};accessTokenSnapshotServiceByChain={};utxoUtils;lastCallState=new Map;cacheDevice;generateProofRemotely;disableMerkleTreeUpdates;constructor(e){this.userKeys=new d.UserKeys(void 0),n.HINKAL_SUPPORTED_CHAINS.forEach(e=>{this.merkleTreeHinkalByChain[e]=b.MerkleTree.create(a.poseidonFunction,0n),this.merkleTreeAccessTokenByChain[e]=b.MerkleTree.create(a.poseidonFunction,0n),this.nullifiersByChain[e]=new Set,this.encryptedOutputsByChain[e]=[]}),this.generateProofRemotely=e?.generateProofRemotely??!0,this.utxoUtils=new A.MultiThreadedUtxoUtils,this.cacheDevice=te.createCacheDevice(e),this.disableMerkleTreeUpdates=e?.disableMerkleTreeUpdates??!1}enforceRateLimit(t,n,r=1e3){let i=Date.now(),a=e.CustomJSONStringify(n),o=this.lastCallState.get(t);if(o&&o.argsKey===a&&i-o.timestamp<r)throw Error(`${t} was already called with the same arguments`);this.lastCallState.set(t,{timestamp:i,argsKey:a})}getProviderAdapter(e){let t=e;t||=this.ethereumProviderAdapter?n.chainIds.ethMainnet:this.solanaProviderAdapter?n.chainIds.solanaMainnet:n.chainIds.tronMainnet;let r;if(r=n.isSolanaLike(t)?this.solanaProviderAdapter:n.isTronLike(t)?this.tronProviderAdapter:this.ethereumProviderAdapter,!r)throw Error(`ProviderAdapter is not initialized`);return r}async initProviderAdapter(e,t){let r=n.chainIds.ethMainnet;t instanceof v.SolanaProviderAdapter?r=n.chainIds.solanaMainnet:t instanceof z.TronProviderAdapter&&(r=n.currentTronChainId),await this.updateProviderAdapter(r,t),t.initConnector(e);let i=await t.connectAndPatchProvider(e);await t.init(i),await this.setListeners()}getSigningMessage(e=r.LoginMessageMode.PROTOCOL){switch(e){case r.LoginMessageMode.PRIVATE_TRANSFER:return this.privateTransferSigningMessage;case r.LoginMessageMode.PROTOCOL:default:return this.signingMessage}}async initUserKeys(e=r.LoginMessageMode.PROTOCOL){let t=this.getSigningMessage(e);this.userKeys=new d.UserKeys(await this.getProviderAdapter().signMessage(t))}initUserKeysWithSignature(e){this.userKeys=new d.UserKeys(e)}async initUserKeysFromSeedPhrases(e){let t=e.join(` `),n=Q.ethers.toUtf8Bytes(t),r=Q.ethers.keccak256(n);this.userKeys=new d.UserKeys(r)}async resetMerkle(e){this.disableMerkleTreeUpdates||(e?.every(e=>this.isSelectedNetworkSupported(e))??!0)&&await k.resetMerkleTrees(this,e)}getTronWeb(){let e=this.tronProviderAdapter;if(!e)throw Error(`Tron provider adapter not initialized`);if(!(e instanceof z.TronProviderAdapter))throw Error(`Tron provider adapter is not a TronProviderAdapter`);let t=e.getTronWeb();if(!t)throw Error(`TronWeb not available`);return t}getSupportedChains(){return this.ethereumProviderAdapter&&this.solanaProviderAdapter?n.WALLET_SUPPORTED_CHAINS:this.ethereumProviderAdapter?n.HINKAL_SUPPORTED_CHAINS.filter(e=>!n.isSolanaLike(e)&&!n.isTronLike(e)):this.solanaProviderAdapter?n.HINKAL_SUPPORTED_CHAINS.filter(e=>n.isSolanaLike(e)):this.tronProviderAdapter?n.HINKAL_SUPPORTED_CHAINS.filter(e=>n.isTronLike(e)):[]}async waitForTransaction(e,t,n=1){return!!await this.getProviderAdapter(e).waitForTransaction(e,t,n)}getContract(e,t,n=void 0){return this.getProviderAdapter(e).getContract(e,t,n)}getContractWithFetcherByChainId(e,t,n=void 0){return _.getContractWithFetcherByChainId(e,t,n)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,t,n){return await this.getProviderAdapter().signTypedData(e,t,n)}async signWithSubAccount(e,t,n,r){return N.hinkalSignSubAccount(e,t,n,r)}getContractWithSigner(e,t,n=``){return this.getProviderAdapter(e).getContractWithSigner(e,t,n)}getContractWithFetcher(e,t,n=``){return this.getProviderAdapter(e).getContractWithFetcher(e,t,n)}isSelectedNetworkSupported(e){return!!n.networkRegistry[e]}async switchNetwork(e){try{await this.getProviderAdapter().switchNetwork(e)}catch{throw Error(l.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}isPermitterAvailable(e){return this.getProviderAdapter(e).isPermitterAvailable()}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,t){try{n.isSolanaLike(e)?(this.solanaProviderAdapter&&this.solanaProviderAdapter.release(),this.solanaProviderAdapter=t):n.isTronLike(e)?(this.tronProviderAdapter&&this.tronProviderAdapter.release(),this.tronProviderAdapter=t):(this.ethereumProviderAdapter&&this.ethereumProviderAdapter.release(),this.ethereumProviderAdapter=t)}catch(e){throw console.error(e),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();let e=r.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(),g.reloadPage())}async monitorConnectedAddress(e){await f.API.monitor(await this.getEthereumAddressByChain(e))}async getBalances(e,t,n,r,i=!1,a,o=!1){return ee.getShieldedBalance(this,e,t,n,r,i,this.generateProofRemotely,a,o)}async getTotalBalance(e,n,r,i=!1,a,o=!1){let s=r??await this.getEthereumAddressByChain(e),c=n??this.userKeys,l=await this.getBalances(e,c.getShieldedPrivateKey(),c.getShieldedPublicKey(),s,i,a,o),d=t.isExtension?await m.privateTokensDB.getPrivateTokens(e,s):u.getErc20TokensForChain(e),f=[];return d.forEach(e=>{let t=e.erc20TokenAddress.toLowerCase(),n=l.get(t),r={token:e,balance:n?.balance??0n,timestamp:n?.timestamp||`0`,nfts:n?.nfts||[]};f.push(r)}),f}async getStuckShieldedBalances(e,t,n,r=!1,i=!1){return(await this.getTotalBalance(e,t,n,r,i,!0)).filter(e=>e.balance>0n)}getSupportedPassportLinks(){return h.supportedPassportLinks}checkAccessToken(e,t){return c.checkHinkalAccessToken(this,e,t)}checkExternalTokenLimitsUSD(e,t,n){return w.checkTokenLimitsUSD(e,t,n)}async getHinkalTreeRootHash(e){if(n.isSolanaLike(e)){let{hinkalIdl:t,hinkalAddress:r,originalDeployer:i}=n.networkRegistry[e].contractData;if(!t||!r||!i)throw Error(`Missing Solana configuration for chain ${e}`);let a=new $.PublicKey(i),s=o.getMerkleAccountPublicKey(new $.PublicKey(r),a);return x.fetchSolanaMerkleTreeRootHash(this.getSolanaProgram(t),s)}return this.getContractWithFetcherByChainId(e,i.ContractType.HinkalContract).getRootHash()}async getAccessTokenTreeRootHash(e){if(n.isSolanaLike(e)){let{hinkalIdl:t,hinkalAddress:r,originalDeployer:i}=n.networkRegistry[e].contractData;if(!t||!r||!i)throw Error(`Missing Solana configuration for chain ${e}`);let a=new $.PublicKey(i),s=o.getAccessTokenMerkleAccountPublicKey(new $.PublicKey(r),a);return x.fetchSolanaMerkleTreeRootHash(this.getSolanaProgram(t),s)}return this.getContractWithFetcherByChainId(e,i.ContractType.AccessTokenContract).getRootHash()}async resetMerkleTreesIfNecessary(e){let t=(await Promise.all((e??this.getSupportedChains()).map(async e=>{let[t,n]=await Promise.all([this.getHinkalTreeRootHash(e),this.getAccessTokenTreeRootHash(e)]);return{chainId:e,needsReset:BigInt(t)!==this.merkleTreeHinkalByChain[e].getRootHash()||BigInt(n)!==this.merkleTreeAccessTokenByChain[e].getRootHash()}}))).filter(e=>e.needsReset).map(e=>e.chainId);t.length>0&&(console.log(`resetting merkle tree in resetMerkleTreesIfNecessary for chains:`,t),await this.resetMerkle(t))}async getEthereumAddress(){let e=this.ethereumProviderAdapter??this.solanaProviderAdapter??this.tronProviderAdapter;if(!e)throw Error(`No provider adapter initialized`);return e.getAddress()}getEthereumAddressByChain(e){return this.getProviderAdapter(e).getAddress()}async getRandomRelay(e,t=!1){return(await f.API.getIdleRelay(e,t)).relay}getGasPrice(e){let t=this.getProviderAdapter(e);if(!t)throw Error(`Illegal State of providerAdapter in Hinkal: no providerAdapter initialized`);return t.getGasPrice(e)}getAPI(){return f.API}snapshotsClearInterval(){this.getSupportedChains().forEach(e=>{this.commitmentsSnapshotServiceByChain[e]?.intervalClear(),this.accessTokenSnapshotServiceByChain[e]?.intervalClear(),this.nullifierSnapshotServiceByChain[e]?.intervalClear()})}checkTokenRegistry(e,t,r){if(n.isSolanaLike(e)){let{hinkalIdl:i,hinkalAddress:a,originalDeployer:o}=n.networkRegistry[e].contractData;if(!i||!a||!o)throw Error(`missing solana data`);return s.hinkalCheckSolanaTokenRegistry(this.getSolanaProgram(i),new $.PublicKey(o),t,r)}return n.isTronLike(e)?y.hinkalCheckTronTokenRegistry(t,r,e):y.hinkalCheckTokenRegistry(this.getContractWithFetcher(e,i.ContractType.HinkalHelperContract),t,r)}getRecipientInfo(){return M.getRecipientInfo(this)}async deposit(e,t,n=!0,r=!1){return S.hinkalDeposit(this,e,t,n,r)}async depositSolana(e,t){return E.hinkalSolanaDeposit(this,e,t)}async depositForOther(e,t,n,r=!0,i=!1){return this.enforceRateLimit(this.depositForOther.name,[e,t,n]),S.hinkalDepositForOther(this,e,t,n,r,i)}async depositSolanaForOther(e,t,n){return this.enforceRateLimit(this.depositSolanaForOther.name,[e,t,n]),E.hinkalSolanaDepositForOther(this,e,t,n)}async depositAndWithdraw(e,t,r,i,a,o,s,c,l=!0){return n.isSolanaLike(p.validateAndGetChainId([e]))?B.hinkalSolanaDepositAndWithdraw(this,e,t,r,i,a,o,s,c):T.hinkalDepositAndWithdraw(this,e,t,r,i,a,o,s,c,l)}async claimUtxo(e,t,r,i){return n.isSolanaLike(p.validateAndGetChainId([e]))?X.hinkalSolanaClaimUtxo(this,e,t,r,i):J.hinkalClaimUtxo(this,e,t,r,i)}async depositAndBridge(e,t,n,r,i,a,o,s=!0){return q.hinkalDepositAndBridge(this,e,t,n,r,i,a,o,s)}async prooflessDeposit(e,t,r,i){return n.isSolanaLike(p.validateAndGetChainId(e))?Y.hinkalSolanaProoflessDeposit(this,e,t,r,i):F.hinkalProoflessDeposit(this,e,t,r,i)}getSolanaProgram(e){if(!this.solanaProviderAdapter)throw Error(`No provider adapter initialized`);if(!(`getSolanaProgram`in this.solanaProviderAdapter))throw Error(`Current provider adapter is not a Solana provider adapter`);return this.solanaProviderAdapter.getSolanaProgram(e)}getSolanaPublicKey(){if(!this.solanaProviderAdapter)throw Error(`No provider adapter initialized`);if(!(`getSolanaPublicKey`in this.solanaProviderAdapter))throw Error(`Current provider adapter is not a Solana provider adapter`);return this.solanaProviderAdapter.getSolanaPublicKey()}async transfer(e,t,r,i,a,o){return n.isSolanaLike(p.validateAndGetChainId(e))?H.hinkalSolanaTransfer(this,e,t,r,i,a,o):ne.hinkalTransfer(this,e,t,r,i,a,o)}async withdraw(e,t,r,i,a,o,s){return n.isSolanaLike(p.validateAndGetChainId(e))?V.hinkalSolanaWithdraw(this,e,t,r,a,o,s):O.hinkalWithdraw(this,e,t,r,i,a,o,s)}async withdrawStuckUtxos(e,t){return Z.hinkalWithdrawStuckUtxos(this,e,t)}async swap(e,t,r,i,a,o,s){return n.isSolanaLike(p.validateAndGetChainId(e))?this.swapSolana(e,t,i,a,o):D.hinkalSwap(this,e,t,r,i,a,o,s)}async swapSolana(e,t,n,r,i){let a=JSON.parse(n),o=BigInt(a.swapperAccountSalt),{instructionLists:s,addressLookupTableAccount:c}=a.data;return U.hinkalSolanaSwap(this,e,t,o,s,c,r,i)}async actionReceive(e,t,r,i,a,o){if(!a)throw Error(`subAccount is required`);return n.isSolanaLike(p.validateAndGetChainId(e))?K.hinkalSolanaProxyShield(this,e[0],t[0],a,void 0,o):P.hinkalActionReceive(this,e,t,r,i,a,o)}async actionPrivateWallet(e,t,n,r,i,a,o,s,c,l,u=!1,d,f,p){return this.enforceRateLimit(this.actionPrivateWallet.name,[e,t,n,r,i,a,o,s,c,p]),j.hinkalPrivateWallet(this,e,t,n,r,i,a,o,s,c,l,u,d,f,p)}async proxySwap(e,t,r,i,a,o,s,c,l=!1,u,d){return n.isSolanaLike(p.validateAndGetChainId(e))?G.hinkalSolanaProxySwap(this,e,t,i,o,r,s,c,d):I.hinkalProxySwap(this,e,t,r,i,a,o,s,c,l,u,d)}async proxyToPrivate(e,t,r,i,a,o,s){return n.isSolanaLike(p.validateAndGetChainId(e))?(this.enforceRateLimit(this.proxyToPrivate.name,[e[0],t[0],r,i]),K.hinkalSolanaProxyShield(this,e[0],t[0],r,i,s)):R.hinkalProxyToPrivate(this,e,t,i,a,o,r,s)}async proxySend(e,t,r,i,a,o,s){let c=p.validateAndGetChainId(e);if(n.isSolanaLike(c))return W.hinkalSolanaProxySend(this,e[0],t[0],r,i,s);let l=C.createTransaferEmporiumOpsBatch(this,c,e.map(e=>e.erc20TokenAddress),t,i),u=e.map((e,n)=>({token:e,amount:-1n*t[n]}));return await this.actionPrivateWallet(c,[],[],[],l,u,r,a,o,void 0,void 0,void 0,s,void 0)}async multiSendPrivateRecipients(e,t,n){return this.enforceRateLimit(this.multiSendPrivateRecipients.name,[e,t,n]),L.hinkalMultiSendPrivateRecipients(this,e,t,n)}areMerkleTreeUpdatesDisabled(){return this.disableMerkleTreeUpdates}updateMerkleTreeUpdates(e){this.disableMerkleTreeUpdates=e}};exports.Hinkal=re;
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../functions/utils/serialize.utils.cjs`),t=require(`../../constants/vite.constants.cjs`),n=require(`../../constants/chains.constants.cjs`),r=require(`../../types/hinkal.types.cjs`),i=require(`../../types/ethereum-network.types.cjs`),a=require(`../../crypto/poseidon.cjs`),o=require(`../../functions/pre-transaction/solana.cjs`),s=require(`./hinkalCheckSolanaTokenRegistry.cjs`),c=require(`../../functions/web3/functionCalls/accessTokenCalls.cjs`),l=require(`../../error-handling/error-codes.constants.cjs`),u=require(`../../functions/utils/erc20tokenFunctions.cjs`),d=require(`../crypto-keys/keys.cjs`),f=require(`../../API/API.cjs`),p=require(`../../functions/utils/token-check.utils.cjs`),m=require(`../TokenDBs/PrivateTokensDB.cjs`),ee=require(`../../functions/web3/events/getShieldedBalance.cjs`),h=require(`../../constants/kyc.constants.cjs`),g=require(`../../functions/utils/reloadPage.cjs`),te=require(`../../functions/utils/cacheDevice.utils.cjs`),_=require(`../../functions/web3/getContractMetadata.cjs`),v=require(`../../providers/SolanaProviderAdapter.cjs`),y=require(`./hinkalCheckTokenRegistry.cjs`),b=require(`../merkle-tree/MerkleTree.cjs`);require(`../merkle-tree/index.cjs`);const x=require(`../../functions/web3/fetchSolanaMerkleTreeRootHash.cjs`),S=require(`./hinkalDeposit.cjs`),C=require(`../../functions/private-wallet/emporium.helpers.cjs`);require(`../../API/index.cjs`);const w=require(`../../functions/kyc/checkTokenLimitsUSD.cjs`),T=require(`./hinkalDepositAndWithdraw.cjs`),E=require(`./hinkalSolanaDeposit.cjs`),D=require(`./hinkalSwap.cjs`),O=require(`./hinkalWithdraw.cjs`),k=require(`./resetMerkleTrees.cjs`),A=require(`../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs`),j=require(`./hinkalPrivateWallet.cjs`),M=require(`./hinkalGetRecipientInfo.cjs`),N=require(`./hinkalSignSubAccount.cjs`),P=require(`./hinkalActionReceive.cjs`);require(`../TokenDBs/index.cjs`);const F=require(`./hinkalProoflessDeposit.cjs`),I=require(`./hinkalProxySwap.cjs`),L=require(`./hinkalMultiSend.cjs`),ne=require(`./hinkalTransfer.cjs`),R=require(`./hinkalProxyToPrivate.cjs`),z=require(`../../providers/TronProviderAdapter.cjs`),B=require(`./hinkalSolanaDepositAndWithdraw.cjs`),V=require(`./hinkalSolanaWithdraw.cjs`),H=require(`./hinkalSolanaTransfer.cjs`),U=require(`./hinkalSolanaSwap.cjs`),W=require(`./hinkalSolanaProxySend.cjs`),G=require(`./hinkalSolanaProxySwap.cjs`),K=require(`./hinkalSolanaProxyShield.cjs`),q=require(`./hinkalDepositAndBridge.cjs`),J=require(`./hinkalClaimUtxo.cjs`),Y=require(`./hinkalSolanaProoflessDeposit.cjs`),X=require(`./hinkalSolanaClaimUtxo.cjs`),Z=require(`./hinkalWithdrawStuckUtxos.cjs`),re=require(`./HinkalPrivateBalanceController.cjs`);let Q=require(`ethers`),$=require(`@solana/web3.js`);var ie=class{ethereumProviderAdapter;solanaProviderAdapter;tronProviderAdapter;userKeys;signingMessage=`Login to Hinkal Protocol`;privateTransferSigningMessage=`Login to Hinkal's Private Transfer App`;merkleTreeHinkalByChain={};merkleTreeAccessTokenByChain={};nullifiersByChain={};encryptedOutputsByChain={};commitmentsSnapshotServiceByChain={};nullifierSnapshotServiceByChain={};accessTokenSnapshotServiceByChain={};utxoUtils;lastCallState=new Map;cacheDevice;generateProofRemotely;disableMerkleTreeUpdates;privateBalances=new re.HinkalPrivateBalanceController(this);constructor(e){this.userKeys=new d.UserKeys(void 0),n.HINKAL_SUPPORTED_CHAINS.forEach(e=>{this.merkleTreeHinkalByChain[e]=b.MerkleTree.create(a.poseidonFunction,0n),this.merkleTreeAccessTokenByChain[e]=b.MerkleTree.create(a.poseidonFunction,0n),this.nullifiersByChain[e]=new Set,this.encryptedOutputsByChain[e]=[]}),this.generateProofRemotely=e?.generateProofRemotely??!0,this.utxoUtils=new A.MultiThreadedUtxoUtils,this.cacheDevice=te.createCacheDevice(e),this.disableMerkleTreeUpdates=e?.disableMerkleTreeUpdates??!1}enforceRateLimit(t,n,r=1e3){let i=Date.now(),a=e.CustomJSONStringify(n),o=this.lastCallState.get(t);if(o&&o.argsKey===a&&i-o.timestamp<r)throw Error(`${t} was already called with the same arguments`);this.lastCallState.set(t,{timestamp:i,argsKey:a})}getProviderAdapter(e){let t=e;t||=this.ethereumProviderAdapter?n.chainIds.ethMainnet:this.solanaProviderAdapter?n.chainIds.solanaMainnet:n.chainIds.tronMainnet;let r;if(r=n.isSolanaLike(t)?this.solanaProviderAdapter:n.isTronLike(t)?this.tronProviderAdapter:this.ethereumProviderAdapter,!r)throw Error(`ProviderAdapter is not initialized`);return r}async initProviderAdapter(e,t){let r=n.chainIds.ethMainnet;t instanceof v.SolanaProviderAdapter?r=n.chainIds.solanaMainnet:t instanceof z.TronProviderAdapter&&(r=n.currentTronChainId),await this.updateProviderAdapter(r,t),t.initConnector(e);let i=await t.connectAndPatchProvider(e);await t.init(i),await this.setListeners()}getSigningMessage(e=r.LoginMessageMode.PROTOCOL){switch(e){case r.LoginMessageMode.PRIVATE_TRANSFER:return this.privateTransferSigningMessage;case r.LoginMessageMode.PROTOCOL:default:return this.signingMessage}}async initUserKeys(e=r.LoginMessageMode.PROTOCOL){let t=this.getSigningMessage(e);this.userKeys=new d.UserKeys(await this.getProviderAdapter().signMessage(t))}initUserKeysWithSignature(e){this.userKeys=new d.UserKeys(e)}async initUserKeysFromSeedPhrases(e){let t=e.join(` `),n=Q.ethers.toUtf8Bytes(t),r=Q.ethers.keccak256(n);this.userKeys=new d.UserKeys(r)}async resetMerkle(e){this.disableMerkleTreeUpdates||(e?.every(e=>this.isSelectedNetworkSupported(e))??!0)&&await k.resetMerkleTrees(this,e)}getTronWeb(){let e=this.tronProviderAdapter;if(!e)throw Error(`Tron provider adapter not initialized`);if(!(e instanceof z.TronProviderAdapter))throw Error(`Tron provider adapter is not a TronProviderAdapter`);let t=e.getTronWeb();if(!t)throw Error(`TronWeb not available`);return t}getSupportedChains(){return this.ethereumProviderAdapter&&this.solanaProviderAdapter?n.WALLET_SUPPORTED_CHAINS:this.ethereumProviderAdapter?n.HINKAL_SUPPORTED_CHAINS.filter(e=>!n.isSolanaLike(e)&&!n.isTronLike(e)):this.solanaProviderAdapter?n.HINKAL_SUPPORTED_CHAINS.filter(e=>n.isSolanaLike(e)):this.tronProviderAdapter?n.HINKAL_SUPPORTED_CHAINS.filter(e=>n.isTronLike(e)):[]}async waitForTransaction(e,t,n=1){return!!await this.getProviderAdapter(e).waitForTransaction(e,t,n)}getContract(e,t,n=void 0){return this.getProviderAdapter(e).getContract(e,t,n)}getContractWithFetcherByChainId(e,t,n=void 0){return _.getContractWithFetcherByChainId(e,t,n)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,t,n){return await this.getProviderAdapter().signTypedData(e,t,n)}async signWithSubAccount(e,t,n,r){return N.hinkalSignSubAccount(e,t,n,r)}getContractWithSigner(e,t,n=``){return this.getProviderAdapter(e).getContractWithSigner(e,t,n)}getContractWithFetcher(e,t,n=``){return this.getProviderAdapter(e).getContractWithFetcher(e,t,n)}isSelectedNetworkSupported(e){return!!n.networkRegistry[e]}async switchNetwork(e){try{await this.getProviderAdapter().switchNetwork(e)}catch{throw Error(l.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}isPermitterAvailable(e){return this.getProviderAdapter(e).isPermitterAvailable()}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,t){try{n.isSolanaLike(e)?(this.solanaProviderAdapter&&this.solanaProviderAdapter.release(),this.solanaProviderAdapter=t):n.isTronLike(e)?(this.tronProviderAdapter&&this.tronProviderAdapter.release(),this.tronProviderAdapter=t):(this.ethereumProviderAdapter&&this.ethereumProviderAdapter.release(),this.ethereumProviderAdapter=t)}catch(e){throw console.error(e),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();let e=r.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(),g.reloadPage())}async monitorConnectedAddress(e){await f.API.monitor(await this.getEthereumAddressByChain(e))}async getBalances(e,t,n,r,i=!1,a,o=!1){return ee.getShieldedBalance(this,e,t,n,r,i,this.generateProofRemotely,a,o)}async getTotalBalance(e,n,r,i=!1,a,o=!1){let s=r??await this.getEthereumAddressByChain(e),c=n??this.userKeys,l=await this.getBalances(e,c.getShieldedPrivateKey(),c.getShieldedPublicKey(),s,i,a,o),d=t.isExtension?await m.privateTokensDB.getPrivateTokens(e,s):u.getErc20TokensForChain(e),f=[];return d.forEach(e=>{let t=e.erc20TokenAddress.toLowerCase(),n=l.get(t),r={token:e,balance:n?.balance??0n,timestamp:n?.timestamp||`0`,nfts:n?.nfts||[]};f.push(r)}),f}async getStuckShieldedBalances(e,t,n,r=!1,i=!1){return(await this.getTotalBalance(e,t,n,r,i,!0)).filter(e=>e.balance>0n)}get privateBalancesWithUSD(){return this.privateBalances.getSnapshot()}onPrivateBalancesWithUSDChange(e){return this.privateBalances.onPrivateBalancesWithUSDChange(e)}getSupportedPassportLinks(){return h.supportedPassportLinks}checkAccessToken(e,t){return c.checkHinkalAccessToken(this,e,t)}checkExternalTokenLimitsUSD(e,t,n){return w.checkTokenLimitsUSD(e,t,n)}async getHinkalTreeRootHash(e){if(n.isSolanaLike(e)){let{hinkalIdl:t,hinkalAddress:r,originalDeployer:i}=n.networkRegistry[e].contractData;if(!t||!r||!i)throw Error(`Missing Solana configuration for chain ${e}`);let a=new $.PublicKey(i),s=o.getMerkleAccountPublicKey(new $.PublicKey(r),a);return x.fetchSolanaMerkleTreeRootHash(this.getSolanaProgram(t),s)}return this.getContractWithFetcherByChainId(e,i.ContractType.HinkalContract).getRootHash()}async getAccessTokenTreeRootHash(e){if(n.isSolanaLike(e)){let{hinkalIdl:t,hinkalAddress:r,originalDeployer:i}=n.networkRegistry[e].contractData;if(!t||!r||!i)throw Error(`Missing Solana configuration for chain ${e}`);let a=new $.PublicKey(i),s=o.getAccessTokenMerkleAccountPublicKey(new $.PublicKey(r),a);return x.fetchSolanaMerkleTreeRootHash(this.getSolanaProgram(t),s)}return this.getContractWithFetcherByChainId(e,i.ContractType.AccessTokenContract).getRootHash()}async resetMerkleTreesIfNecessary(e){let t=(await Promise.all((e??this.getSupportedChains()).map(async e=>{let[t,n]=await Promise.all([this.getHinkalTreeRootHash(e),this.getAccessTokenTreeRootHash(e)]);return{chainId:e,needsReset:BigInt(t)!==this.merkleTreeHinkalByChain[e].getRootHash()||BigInt(n)!==this.merkleTreeAccessTokenByChain[e].getRootHash()}}))).filter(e=>e.needsReset).map(e=>e.chainId);t.length>0&&(console.log(`resetting merkle tree in resetMerkleTreesIfNecessary for chains:`,t),await this.resetMerkle(t))}async getEthereumAddress(){let e=this.ethereumProviderAdapter??this.solanaProviderAdapter??this.tronProviderAdapter;if(!e)throw Error(`No provider adapter initialized`);return e.getAddress()}getEthereumAddressByChain(e){return this.getProviderAdapter(e).getAddress()}async getRandomRelay(e,t=!1){return(await f.API.getIdleRelay(e,t)).relay}getGasPrice(e){let t=this.getProviderAdapter(e);if(!t)throw Error(`Illegal State of providerAdapter in Hinkal: no providerAdapter initialized`);return t.getGasPrice(e)}getAPI(){return f.API}snapshotsClearInterval(){this.getSupportedChains().forEach(e=>{this.commitmentsSnapshotServiceByChain[e]?.intervalClear(),this.accessTokenSnapshotServiceByChain[e]?.intervalClear(),this.nullifierSnapshotServiceByChain[e]?.intervalClear()})}checkTokenRegistry(e,t,r){if(n.isSolanaLike(e)){let{hinkalIdl:i,hinkalAddress:a,originalDeployer:o}=n.networkRegistry[e].contractData;if(!i||!a||!o)throw Error(`missing solana data`);return s.hinkalCheckSolanaTokenRegistry(this.getSolanaProgram(i),new $.PublicKey(o),t,r)}return n.isTronLike(e)?y.hinkalCheckTronTokenRegistry(t,r,e):y.hinkalCheckTokenRegistry(this.getContractWithFetcher(e,i.ContractType.HinkalHelperContract),t,r)}getRecipientInfo(){return M.getRecipientInfo(this)}async deposit(e,t,n=!0,r=!1){return S.hinkalDeposit(this,e,t,n,r)}async depositSolana(e,t){return E.hinkalSolanaDeposit(this,e,t)}async depositForOther(e,t,n,r=!0,i=!1){return this.enforceRateLimit(this.depositForOther.name,[e,t,n]),S.hinkalDepositForOther(this,e,t,n,r,i)}async depositSolanaForOther(e,t,n){return this.enforceRateLimit(this.depositSolanaForOther.name,[e,t,n]),E.hinkalSolanaDepositForOther(this,e,t,n)}async depositAndWithdraw(e,t,r,i,a,o,s,c,l=!0){return n.isSolanaLike(p.validateAndGetChainId([e]))?B.hinkalSolanaDepositAndWithdraw(this,e,t,r,i,a,o,s,c):T.hinkalDepositAndWithdraw(this,e,t,r,i,a,o,s,c,l)}async claimUtxo(e,t,r,i){return n.isSolanaLike(p.validateAndGetChainId([e]))?X.hinkalSolanaClaimUtxo(this,e,t,r,i):J.hinkalClaimUtxo(this,e,t,r,i)}async depositAndBridge(e,t,n,r,i,a,o,s=!0){return q.hinkalDepositAndBridge(this,e,t,n,r,i,a,o,s)}async prooflessDeposit(e,t,r,i){return n.isSolanaLike(p.validateAndGetChainId(e))?Y.hinkalSolanaProoflessDeposit(this,e,t,r,i):F.hinkalProoflessDeposit(this,e,t,r,i)}getSolanaProgram(e){if(!this.solanaProviderAdapter)throw Error(`No provider adapter initialized`);if(!(`getSolanaProgram`in this.solanaProviderAdapter))throw Error(`Current provider adapter is not a Solana provider adapter`);return this.solanaProviderAdapter.getSolanaProgram(e)}getSolanaPublicKey(){if(!this.solanaProviderAdapter)throw Error(`No provider adapter initialized`);if(!(`getSolanaPublicKey`in this.solanaProviderAdapter))throw Error(`Current provider adapter is not a Solana provider adapter`);return this.solanaProviderAdapter.getSolanaPublicKey()}async transfer(e,t,r,i,a,o){return n.isSolanaLike(p.validateAndGetChainId(e))?H.hinkalSolanaTransfer(this,e,t,r,i,a,o):ne.hinkalTransfer(this,e,t,r,i,a,o)}async withdraw(e,t,r,i,a,o,s){return n.isSolanaLike(p.validateAndGetChainId(e))?V.hinkalSolanaWithdraw(this,e,t,r,a,o,s):O.hinkalWithdraw(this,e,t,r,i,a,o,s)}async withdrawStuckUtxos(e,t){return Z.hinkalWithdrawStuckUtxos(this,e,t)}async swap(e,t,r,i,a,o,s){return n.isSolanaLike(p.validateAndGetChainId(e))?this.swapSolana(e,t,i,a,o):D.hinkalSwap(this,e,t,r,i,a,o,s)}async swapSolana(e,t,n,r,i){let a=JSON.parse(n),o=BigInt(a.swapperAccountSalt),{instructionLists:s,addressLookupTableAccount:c}=a.data;return U.hinkalSolanaSwap(this,e,t,o,s,c,r,i)}async actionReceive(e,t,r,i,a,o){if(!a)throw Error(`subAccount is required`);return n.isSolanaLike(p.validateAndGetChainId(e))?K.hinkalSolanaProxyShield(this,e[0],t[0],a,void 0,o):P.hinkalActionReceive(this,e,t,r,i,a,o)}async actionPrivateWallet(e,t,n,r,i,a,o,s,c,l,u=!1,d,f,p){return this.enforceRateLimit(this.actionPrivateWallet.name,[e,t,n,r,i,a,o,s,c,p]),j.hinkalPrivateWallet(this,e,t,n,r,i,a,o,s,c,l,u,d,f,p)}async proxySwap(e,t,r,i,a,o,s,c,l=!1,u,d){return n.isSolanaLike(p.validateAndGetChainId(e))?G.hinkalSolanaProxySwap(this,e,t,i,o,r,s,c,d):I.hinkalProxySwap(this,e,t,r,i,a,o,s,c,l,u,d)}async proxyToPrivate(e,t,r,i,a,o,s){return n.isSolanaLike(p.validateAndGetChainId(e))?(this.enforceRateLimit(this.proxyToPrivate.name,[e[0],t[0],r,i]),K.hinkalSolanaProxyShield(this,e[0],t[0],r,i,s)):R.hinkalProxyToPrivate(this,e,t,i,a,o,r,s)}async proxySend(e,t,r,i,a,o,s){let c=p.validateAndGetChainId(e);if(n.isSolanaLike(c))return W.hinkalSolanaProxySend(this,e[0],t[0],r,i,s);let l=C.createTransaferEmporiumOpsBatch(this,c,e.map(e=>e.erc20TokenAddress),t,i),u=e.map((e,n)=>({token:e,amount:-1n*t[n]}));return await this.actionPrivateWallet(c,[],[],[],l,u,r,a,o,void 0,void 0,void 0,s,void 0)}async multiSendPrivateRecipients(e,t,n){return this.enforceRateLimit(this.multiSendPrivateRecipients.name,[e,t,n]),L.hinkalMultiSendPrivateRecipients(this,e,t,n)}areMerkleTreeUpdatesDisabled(){return this.disableMerkleTreeUpdates}updateMerkleTreeUpdates(e){this.disableMerkleTreeUpdates=e}};exports.Hinkal=ie;
|
|
@@ -19,6 +19,7 @@ import { Idl, Program } from '@coral-xyz/anchor';
|
|
|
19
19
|
import { PublicKey } from '@solana/web3.js';
|
|
20
20
|
import { BridgeRecipient } from '../../types/bridging-tx.types';
|
|
21
21
|
import { Utxo } from '../utxo/Utxo';
|
|
22
|
+
import { PrivateBalancesState } from '../../types/balances.types';
|
|
22
23
|
export declare class Hinkal<ConnectorType> implements IHinkal {
|
|
23
24
|
private ethereumProviderAdapter?;
|
|
24
25
|
private solanaProviderAdapter?;
|
|
@@ -38,6 +39,7 @@ export declare class Hinkal<ConnectorType> implements IHinkal {
|
|
|
38
39
|
cacheDevice: ICacheDevice;
|
|
39
40
|
generateProofRemotely: boolean;
|
|
40
41
|
private disableMerkleTreeUpdates;
|
|
42
|
+
private readonly privateBalances;
|
|
41
43
|
constructor(hinkalConfig?: HinkalConfig);
|
|
42
44
|
private enforceRateLimit;
|
|
43
45
|
getProviderAdapter(chainId?: number): IProviderAdapter<ConnectorType>;
|
|
@@ -70,6 +72,8 @@ export declare class Hinkal<ConnectorType> implements IHinkal {
|
|
|
70
72
|
getBalances(chainId: number, passedShieldedPrivateKey: string, passedShieldedPublicKey: string, ethAddress: string, resetCacheBefore?: boolean, updateTokensListBefore?: boolean, useBlockedUtxos?: boolean): Promise<Map<string, TokenBalance>>;
|
|
71
73
|
getTotalBalance(chainId: number, _userKeys?: UserKeys, _ethAddress?: string, resetCacheBefore?: boolean, updateTokensListBefore?: boolean, useBlockedUtxos?: boolean): Promise<TokenBalance[]>;
|
|
72
74
|
getStuckShieldedBalances(chainId: number, _userKeys?: UserKeys, _ethAddress?: string, resetCacheBefore?: boolean, updateTokensListBefore?: boolean): Promise<TokenBalance[]>;
|
|
75
|
+
get privateBalancesWithUSD(): PrivateBalancesState;
|
|
76
|
+
onPrivateBalancesWithUSDChange(callback: (state: PrivateBalancesState) => void): () => void;
|
|
73
77
|
getSupportedPassportLinks(): string[];
|
|
74
78
|
checkAccessToken(chainId: number, accessKeyOverride?: string): Promise<boolean>;
|
|
75
79
|
checkExternalTokenLimitsUSD(chainId: number, tokenAddresses: string[], amounts: bigint[]): Promise<boolean>;
|
|
@@ -56,10 +56,11 @@ import { hinkalClaimUtxo as de } from "./hinkalClaimUtxo.mjs";
|
|
|
56
56
|
import { hinkalSolanaProoflessDeposit as Z } from "./hinkalSolanaProoflessDeposit.mjs";
|
|
57
57
|
import { hinkalSolanaClaimUtxo as fe } from "./hinkalSolanaClaimUtxo.mjs";
|
|
58
58
|
import { hinkalWithdrawStuckUtxos as pe } from "./hinkalWithdrawStuckUtxos.mjs";
|
|
59
|
+
import { HinkalPrivateBalanceController as me } from "./HinkalPrivateBalanceController.mjs";
|
|
59
60
|
import { ethers as Q } from "ethers";
|
|
60
61
|
import { PublicKey as $ } from "@solana/web3.js";
|
|
61
62
|
//#region libs/shared/common/src/data-structures/Hinkal/Hinkal.ts
|
|
62
|
-
var
|
|
63
|
+
var he = class {
|
|
63
64
|
ethereumProviderAdapter;
|
|
64
65
|
solanaProviderAdapter;
|
|
65
66
|
tronProviderAdapter;
|
|
@@ -78,6 +79,7 @@ var me = class {
|
|
|
78
79
|
cacheDevice;
|
|
79
80
|
generateProofRemotely;
|
|
80
81
|
disableMerkleTreeUpdates;
|
|
82
|
+
privateBalances = new me(this);
|
|
81
83
|
constructor(e) {
|
|
82
84
|
this.userKeys = new _(void 0), n.forEach((e) => {
|
|
83
85
|
this.merkleTreeHinkalByChain[e] = D.create(f, 0n), this.merkleTreeAccessTokenByChain[e] = D.create(f, 0n), this.nullifiersByChain[e] = /* @__PURE__ */ new Set(), this.encryptedOutputsByChain[e] = [];
|
|
@@ -239,6 +241,12 @@ var me = class {
|
|
|
239
241
|
async getStuckShieldedBalances(e, t, n, r = !1, i = !1) {
|
|
240
242
|
return (await this.getTotalBalance(e, t, n, r, i, !0)).filter((e) => e.balance > 0n);
|
|
241
243
|
}
|
|
244
|
+
get privateBalancesWithUSD() {
|
|
245
|
+
return this.privateBalances.getSnapshot();
|
|
246
|
+
}
|
|
247
|
+
onPrivateBalancesWithUSDChange(e) {
|
|
248
|
+
return this.privateBalances.onPrivateBalancesWithUSDChange(e);
|
|
249
|
+
}
|
|
242
250
|
getSupportedPassportLinks() {
|
|
243
251
|
return b;
|
|
244
252
|
}
|
|
@@ -422,4 +430,4 @@ var me = class {
|
|
|
422
430
|
}
|
|
423
431
|
};
|
|
424
432
|
//#endregion
|
|
425
|
-
export {
|
|
433
|
+
export { he as Hinkal };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../types/balances.types.cjs`),t=require(`../../functions/web3/etherFunctions.cjs`),n=require(`../../functions/utils/upToDateState.cjs`),r=require(`../../error-handling/logger.cjs`),i=require(`../../functions/utils/string.utils.cjs`),a=require(`../../functions/utils/token-check.utils.cjs`),o=require(`../../functions/web3/events/balanceChangedHandler.cjs`),s=require(`../IndexedDB/private-balances-db.cjs`),c=require(`../IndexedDB/prices-db.cjs`);var l=(e,t)=>{switch(t.type){case`SET_BALANCES`:{let n=e[t.chainId];if(t.balances===void 0){let n={...e};return delete n[t.chainId],Object.keys(n).length>0?n:{}}if(n===void 0)return{...e,[t.chainId]:t.balances};let r=t.balances,i=r.filter(e=>!n.some(t=>a.isSameERC20Token(e.token,t.token))),o=n.map(e=>({...e,balance:r.find(t=>a.isSameERC20Token(t.token,e.token))?.balance??0n})).filter(e=>e.balance>0n);return o=[...o,...i],{...e,[t.chainId]:o}}case`SET_USD_BALANCES`:{let n=e[t.chainId];if(n===void 0||t.balances===void 0)return e;let r=t.balances,i=n.map(e=>({...e,usdValue:r.find(t=>a.isSameERC20Token(t.token,e.token))?.usdValue??0}));return{...e,[t.chainId]:i}}case`CLEAR_BALANCES`:{if(t.chainId===void 0)return{};let n={...e};return delete n[t.chainId],Object.keys(n).length>0?n:{}}case`SET_LOADING`:{let n=e[t.chainId];if(n===void 0)return e;if(n.length===0&&t.newValue)return{...e,[t.chainId]:void 0};let r=n.map(e=>({...e,isBalanceLoading:t.newValue}));return{...e,[t.chainId]:r}}case`SET_USD_LOADING`:{let n=e[t.chainId];if(n===void 0)return e;let r=n.map(e=>({...e,isUsdValueLoading:t.newValue}));return{...e,[t.chainId]:r}}default:return e}},u=class{privateBalancesState={};privateBalancesListeners=new Set;constructor(e){this.hinkal=e,o.subscribeToBalanceChange(e=>{this.applyRefreshFromBalanceChangeEvent(e).catch(e=>{r.Logger.error(`Private balance refresh from balance change failed:`,e)})})}getSnapshot(){return this.privateBalancesState}onPrivateBalancesWithUSDChange(e){return this.privateBalancesListeners.add(e),()=>this.privateBalancesListeners.delete(e)}async applyRefreshFromBalanceChangeEvent(t){if(!t){await this.refreshInternal(e.PrivateBalanceUpdateType.FreshWithoutLoader);return}let{updateType:n,balanceChangeState:r,chainIdToUpdate:i,resetCacheBefore:a,updateTokensListBefore:o}=t;await this.refreshInternal(n,r,a,o,i)}dispatch(e){this.privateBalancesState=l(this.privateBalancesState,e);let t=this.privateBalancesState;this.privateBalancesListeners.forEach(e=>e(t))}async getAddressAndChain(e){return{ethAdd:e?.ethereumAddress??await this.hinkal.getEthereumAddress(),userKeys:e?.userKeys??this.hinkal.userKeys}}async hasCache(e,t){return await s.privateBalancesStorage.getBalancesByWallet(e,t)!==void 0}async getBalancesWithUsdValues(e,n){try{if(!n)return[];let r=e.map(e=>e.token.erc20TokenAddress);if(!r.length)return[];let i=await c.pricesStorage.getAndUpdatePrices(n,r),a=new Map(r.map((e,t)=>[e,i[t]]));return[...e.map(e=>{try{let n=e.token.erc20TokenAddress,r=a.get(n)??0,i=e.balance,o=Number(t.getAmountInToken(e.token,i))*r;return{...e,usdValue:o}}catch{return{...e,usdValue:0}}})]}catch{return r.Logger.log(`Error fetching private token balances`),[]}}handleCached=async(e,a)=>{try{await n.checkAddressNotUpdated(this.hinkal,e),this.dispatch({type:`SET_BALANCES`,chainId:a,balances:void 0});let r=await s.privateBalancesStorage.getBalancesByWallet(e,a),o=await c.pricesStorage.getPrices();if(await n.checkAddressNotUpdated(this.hinkal,e),!r||(this.dispatch({type:`SET_BALANCES`,chainId:a,balances:r}),!o))return;let l=r.map(e=>{let n=i.getTokenStateKey(e.token.erc20TokenAddress,a);return{...e,usdValue:o[n]?Number(t.getAmountInToken(e.token,e.balance))*o[n]:0}});this.dispatch({type:`SET_USD_BALANCES`,chainId:a,balances:l})}catch(e){r.Logger.error(`Error refreshing cached private balance:`,e)}};handleFresh=async(e,t,i,a,o,c)=>{let l=o;try{await n.checkAddressNotUpdated(this.hinkal,e);let r=await this.hasCache(e,t);await n.checkAddressNotUpdated(this.hinkal,e),l=o||!r,l&&this.dispatch({type:`SET_LOADING`,chainId:t,newValue:!0}),await n.checkAddressNotUpdated(this.hinkal,e),a&&await this.hinkal.resetMerkle([t]);let u=await this.hinkal.getTotalBalance(t,i,e,a,c);await n.checkAddressNotUpdated(this.hinkal,e);let d=u.filter(e=>e.balance>0n);this.dispatch({type:`SET_BALANCES`,chainId:t,balances:d}),await s.privateBalancesStorage.setBalances(e,t,d),await n.checkAddressNotUpdated(this.hinkal,e),l&&(this.dispatch({type:`SET_USD_LOADING`,chainId:t,newValue:!0}),this.dispatch({type:`SET_LOADING`,chainId:t,newValue:!1})),await n.checkAddressNotUpdated(this.hinkal,e);let f=await this.getBalancesWithUsdValues(d,t);await n.checkAddressNotUpdated(this.hinkal,e),f.length>0&&this.dispatch({type:`SET_USD_BALANCES`,chainId:t,balances:f})}catch(e){r.Logger.error(`Error refreshing private balance:`,e)}finally{l&&(this.dispatch({type:`SET_LOADING`,chainId:t,newValue:!1}),this.dispatch({type:`SET_USD_LOADING`,chainId:t,newValue:!1}))}};getSupportedChainsToUpdate(e){let t=this.hinkal.getSupportedChains();return e?t.includes(e)?[e]:[]:t}async refreshInternal(t=e.PrivateBalanceUpdateType.FreshWithoutLoader,n,r=!1,i=!1,a){let{ethAdd:o,userKeys:s}=await this.getAddressAndChain(n);!o||!s?.getShieldedPublicKey()||await Promise.all(this.getSupportedChainsToUpdate(a).map(async n=>{switch(t){case e.PrivateBalanceUpdateType.OnlyCache:await this.handleCached(o,n);break;case e.PrivateBalanceUpdateType.Fresh:await this.handleFresh(o,n,s,r,!0,i);break;case e.PrivateBalanceUpdateType.FreshWithoutLoader:await this.handleFresh(o,n,s,r,!1,i);break;default:break}}))}};exports.HinkalPrivateBalanceController=u;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PrivateBalancesState } from '../../types/balances.types';
|
|
2
|
+
import { IHinkal } from './IHinkal';
|
|
3
|
+
export declare class HinkalPrivateBalanceController {
|
|
4
|
+
private readonly hinkal;
|
|
5
|
+
private privateBalancesState;
|
|
6
|
+
private readonly privateBalancesListeners;
|
|
7
|
+
constructor(hinkal: IHinkal);
|
|
8
|
+
getSnapshot(): PrivateBalancesState;
|
|
9
|
+
onPrivateBalancesWithUSDChange(callback: (state: PrivateBalancesState) => void): () => void;
|
|
10
|
+
private applyRefreshFromBalanceChangeEvent;
|
|
11
|
+
private dispatch;
|
|
12
|
+
private getAddressAndChain;
|
|
13
|
+
private hasCache;
|
|
14
|
+
private getBalancesWithUsdValues;
|
|
15
|
+
private handleCached;
|
|
16
|
+
private handleFresh;
|
|
17
|
+
private getSupportedChainsToUpdate;
|
|
18
|
+
private refreshInternal;
|
|
19
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { PrivateBalanceUpdateType as e } from "../../types/balances.types.mjs";
|
|
2
|
+
import { getAmountInToken as t } from "../../functions/web3/etherFunctions.mjs";
|
|
3
|
+
import { checkAddressNotUpdated as n } from "../../functions/utils/upToDateState.mjs";
|
|
4
|
+
import { Logger as r } from "../../error-handling/logger.mjs";
|
|
5
|
+
import { getTokenStateKey as i } from "../../functions/utils/string.utils.mjs";
|
|
6
|
+
import { isSameERC20Token as a } from "../../functions/utils/token-check.utils.mjs";
|
|
7
|
+
import { subscribeToBalanceChange as o } from "../../functions/web3/events/balanceChangedHandler.mjs";
|
|
8
|
+
import { privateBalancesStorage as s } from "../IndexedDB/private-balances-db.mjs";
|
|
9
|
+
import { pricesStorage as c } from "../IndexedDB/prices-db.mjs";
|
|
10
|
+
//#region libs/shared/common/src/data-structures/Hinkal/HinkalPrivateBalanceController.ts
|
|
11
|
+
var l = (e, t) => {
|
|
12
|
+
switch (t.type) {
|
|
13
|
+
case "SET_BALANCES": {
|
|
14
|
+
let n = e[t.chainId];
|
|
15
|
+
if (t.balances === void 0) {
|
|
16
|
+
let n = { ...e };
|
|
17
|
+
return delete n[t.chainId], Object.keys(n).length > 0 ? n : {};
|
|
18
|
+
}
|
|
19
|
+
if (n === void 0) return {
|
|
20
|
+
...e,
|
|
21
|
+
[t.chainId]: t.balances
|
|
22
|
+
};
|
|
23
|
+
let r = t.balances, i = r.filter((e) => !n.some((t) => a(e.token, t.token))), o = n.map((e) => ({
|
|
24
|
+
...e,
|
|
25
|
+
balance: r.find((t) => a(t.token, e.token))?.balance ?? 0n
|
|
26
|
+
})).filter((e) => e.balance > 0n);
|
|
27
|
+
return o = [...o, ...i], {
|
|
28
|
+
...e,
|
|
29
|
+
[t.chainId]: o
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
case "SET_USD_BALANCES": {
|
|
33
|
+
let n = e[t.chainId];
|
|
34
|
+
if (n === void 0 || t.balances === void 0) return e;
|
|
35
|
+
let r = t.balances, i = n.map((e) => ({
|
|
36
|
+
...e,
|
|
37
|
+
usdValue: r.find((t) => a(t.token, e.token))?.usdValue ?? 0
|
|
38
|
+
}));
|
|
39
|
+
return {
|
|
40
|
+
...e,
|
|
41
|
+
[t.chainId]: i
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
case "CLEAR_BALANCES": {
|
|
45
|
+
if (t.chainId === void 0) return {};
|
|
46
|
+
let n = { ...e };
|
|
47
|
+
return delete n[t.chainId], Object.keys(n).length > 0 ? n : {};
|
|
48
|
+
}
|
|
49
|
+
case "SET_LOADING": {
|
|
50
|
+
let n = e[t.chainId];
|
|
51
|
+
if (n === void 0) return e;
|
|
52
|
+
if (n.length === 0 && t.newValue) return {
|
|
53
|
+
...e,
|
|
54
|
+
[t.chainId]: void 0
|
|
55
|
+
};
|
|
56
|
+
let r = n.map((e) => ({
|
|
57
|
+
...e,
|
|
58
|
+
isBalanceLoading: t.newValue
|
|
59
|
+
}));
|
|
60
|
+
return {
|
|
61
|
+
...e,
|
|
62
|
+
[t.chainId]: r
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
case "SET_USD_LOADING": {
|
|
66
|
+
let n = e[t.chainId];
|
|
67
|
+
if (n === void 0) return e;
|
|
68
|
+
let r = n.map((e) => ({
|
|
69
|
+
...e,
|
|
70
|
+
isUsdValueLoading: t.newValue
|
|
71
|
+
}));
|
|
72
|
+
return {
|
|
73
|
+
...e,
|
|
74
|
+
[t.chainId]: r
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
default: return e;
|
|
78
|
+
}
|
|
79
|
+
}, u = class {
|
|
80
|
+
privateBalancesState = {};
|
|
81
|
+
privateBalancesListeners = /* @__PURE__ */ new Set();
|
|
82
|
+
constructor(e) {
|
|
83
|
+
this.hinkal = e, o((e) => {
|
|
84
|
+
this.applyRefreshFromBalanceChangeEvent(e).catch((e) => {
|
|
85
|
+
r.error("Private balance refresh from balance change failed:", e);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
getSnapshot() {
|
|
90
|
+
return this.privateBalancesState;
|
|
91
|
+
}
|
|
92
|
+
onPrivateBalancesWithUSDChange(e) {
|
|
93
|
+
return this.privateBalancesListeners.add(e), () => this.privateBalancesListeners.delete(e);
|
|
94
|
+
}
|
|
95
|
+
async applyRefreshFromBalanceChangeEvent(t) {
|
|
96
|
+
if (!t) {
|
|
97
|
+
await this.refreshInternal(e.FreshWithoutLoader);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
let { updateType: n, balanceChangeState: r, chainIdToUpdate: i, resetCacheBefore: a, updateTokensListBefore: o } = t;
|
|
101
|
+
await this.refreshInternal(n, r, a, o, i);
|
|
102
|
+
}
|
|
103
|
+
dispatch(e) {
|
|
104
|
+
this.privateBalancesState = l(this.privateBalancesState, e);
|
|
105
|
+
let t = this.privateBalancesState;
|
|
106
|
+
this.privateBalancesListeners.forEach((e) => e(t));
|
|
107
|
+
}
|
|
108
|
+
async getAddressAndChain(e) {
|
|
109
|
+
return {
|
|
110
|
+
ethAdd: e?.ethereumAddress ?? await this.hinkal.getEthereumAddress(),
|
|
111
|
+
userKeys: e?.userKeys ?? this.hinkal.userKeys
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async hasCache(e, t) {
|
|
115
|
+
return await s.getBalancesByWallet(e, t) !== void 0;
|
|
116
|
+
}
|
|
117
|
+
async getBalancesWithUsdValues(e, n) {
|
|
118
|
+
try {
|
|
119
|
+
if (!n) return [];
|
|
120
|
+
let r = e.map((e) => e.token.erc20TokenAddress);
|
|
121
|
+
if (!r.length) return [];
|
|
122
|
+
let i = await c.getAndUpdatePrices(n, r), a = new Map(r.map((e, t) => [e, i[t]]));
|
|
123
|
+
return [...e.map((e) => {
|
|
124
|
+
try {
|
|
125
|
+
let n = e.token.erc20TokenAddress, r = a.get(n) ?? 0, i = e.balance, o = Number(t(e.token, i)) * r;
|
|
126
|
+
return {
|
|
127
|
+
...e,
|
|
128
|
+
usdValue: o
|
|
129
|
+
};
|
|
130
|
+
} catch {
|
|
131
|
+
return {
|
|
132
|
+
...e,
|
|
133
|
+
usdValue: 0
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
})];
|
|
137
|
+
} catch {
|
|
138
|
+
return r.log("Error fetching private token balances"), [];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
handleCached = async (e, a) => {
|
|
142
|
+
try {
|
|
143
|
+
await n(this.hinkal, e), this.dispatch({
|
|
144
|
+
type: "SET_BALANCES",
|
|
145
|
+
chainId: a,
|
|
146
|
+
balances: void 0
|
|
147
|
+
});
|
|
148
|
+
let r = await s.getBalancesByWallet(e, a), o = await c.getPrices();
|
|
149
|
+
if (await n(this.hinkal, e), !r || (this.dispatch({
|
|
150
|
+
type: "SET_BALANCES",
|
|
151
|
+
chainId: a,
|
|
152
|
+
balances: r
|
|
153
|
+
}), !o)) return;
|
|
154
|
+
let l = r.map((e) => {
|
|
155
|
+
let n = i(e.token.erc20TokenAddress, a);
|
|
156
|
+
return {
|
|
157
|
+
...e,
|
|
158
|
+
usdValue: o[n] ? Number(t(e.token, e.balance)) * o[n] : 0
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
this.dispatch({
|
|
162
|
+
type: "SET_USD_BALANCES",
|
|
163
|
+
chainId: a,
|
|
164
|
+
balances: l
|
|
165
|
+
});
|
|
166
|
+
} catch (e) {
|
|
167
|
+
r.error("Error refreshing cached private balance:", e);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
handleFresh = async (e, t, i, a, o, c) => {
|
|
171
|
+
let l = o;
|
|
172
|
+
try {
|
|
173
|
+
await n(this.hinkal, e);
|
|
174
|
+
let r = await this.hasCache(e, t);
|
|
175
|
+
await n(this.hinkal, e), l = o || !r, l && this.dispatch({
|
|
176
|
+
type: "SET_LOADING",
|
|
177
|
+
chainId: t,
|
|
178
|
+
newValue: !0
|
|
179
|
+
}), await n(this.hinkal, e), a && await this.hinkal.resetMerkle([t]);
|
|
180
|
+
let u = await this.hinkal.getTotalBalance(t, i, e, a, c);
|
|
181
|
+
await n(this.hinkal, e);
|
|
182
|
+
let d = u.filter((e) => e.balance > 0n);
|
|
183
|
+
this.dispatch({
|
|
184
|
+
type: "SET_BALANCES",
|
|
185
|
+
chainId: t,
|
|
186
|
+
balances: d
|
|
187
|
+
}), await s.setBalances(e, t, d), await n(this.hinkal, e), l && (this.dispatch({
|
|
188
|
+
type: "SET_USD_LOADING",
|
|
189
|
+
chainId: t,
|
|
190
|
+
newValue: !0
|
|
191
|
+
}), this.dispatch({
|
|
192
|
+
type: "SET_LOADING",
|
|
193
|
+
chainId: t,
|
|
194
|
+
newValue: !1
|
|
195
|
+
})), await n(this.hinkal, e);
|
|
196
|
+
let f = await this.getBalancesWithUsdValues(d, t);
|
|
197
|
+
await n(this.hinkal, e), f.length > 0 && this.dispatch({
|
|
198
|
+
type: "SET_USD_BALANCES",
|
|
199
|
+
chainId: t,
|
|
200
|
+
balances: f
|
|
201
|
+
});
|
|
202
|
+
} catch (e) {
|
|
203
|
+
r.error("Error refreshing private balance:", e);
|
|
204
|
+
} finally {
|
|
205
|
+
l && (this.dispatch({
|
|
206
|
+
type: "SET_LOADING",
|
|
207
|
+
chainId: t,
|
|
208
|
+
newValue: !1
|
|
209
|
+
}), this.dispatch({
|
|
210
|
+
type: "SET_USD_LOADING",
|
|
211
|
+
chainId: t,
|
|
212
|
+
newValue: !1
|
|
213
|
+
}));
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
getSupportedChainsToUpdate(e) {
|
|
217
|
+
let t = this.hinkal.getSupportedChains();
|
|
218
|
+
return e ? t.includes(e) ? [e] : [] : t;
|
|
219
|
+
}
|
|
220
|
+
async refreshInternal(t = e.FreshWithoutLoader, n, r = !1, i = !1, a) {
|
|
221
|
+
let { ethAdd: o, userKeys: s } = await this.getAddressAndChain(n);
|
|
222
|
+
!o || !s?.getShieldedPublicKey() || await Promise.all(this.getSupportedChainsToUpdate(a).map(async (n) => {
|
|
223
|
+
switch (t) {
|
|
224
|
+
case e.OnlyCache:
|
|
225
|
+
await this.handleCached(o, n);
|
|
226
|
+
break;
|
|
227
|
+
case e.Fresh:
|
|
228
|
+
await this.handleFresh(o, n, s, r, !0, i);
|
|
229
|
+
break;
|
|
230
|
+
case e.FreshWithoutLoader:
|
|
231
|
+
await this.handleFresh(o, n, s, r, !1, i);
|
|
232
|
+
break;
|
|
233
|
+
default: break;
|
|
234
|
+
}
|
|
235
|
+
}));
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
//#endregion
|
|
239
|
+
export { u as HinkalPrivateBalanceController };
|
|
@@ -17,6 +17,7 @@ import { AdminTransactionType } from '../../types/admin.types';
|
|
|
17
17
|
import { Idl, Program } from '@coral-xyz/anchor';
|
|
18
18
|
import { PublicKey } from '@solana/web3.js';
|
|
19
19
|
import { BridgeRecipient } from '../../types/bridging-tx.types';
|
|
20
|
+
import { PrivateBalancesState } from '../../types/balances.types';
|
|
20
21
|
import { Utxo } from '../utxo/Utxo';
|
|
21
22
|
import { TronWeb } from 'tronweb';
|
|
22
23
|
export interface IHinkal<ConnectorType = unknown> {
|
|
@@ -36,6 +37,8 @@ export interface IHinkal<ConnectorType = unknown> {
|
|
|
36
37
|
getBalances(chainId: number, passedShieldedPrivateKey: string, passedShieldedPublicKey: string, ethAddress: string, resetCacheBefore?: boolean, updateTokensListBefore?: boolean): Promise<Map<string, TokenBalance>>;
|
|
37
38
|
getTotalBalance(chainId: number, userKeys?: UserKeys, ethAddress?: string, resetCacheBefore?: boolean, updateTokensListBefore?: boolean, useBlockedUtxos?: boolean): Promise<TokenBalance[]>;
|
|
38
39
|
getStuckShieldedBalances(chainId: number, userKeys?: UserKeys, ethAddress?: string, resetCacheBefore?: boolean, updateTokensListBefore?: boolean): Promise<TokenBalance[]>;
|
|
40
|
+
privateBalancesWithUSD: PrivateBalancesState;
|
|
41
|
+
onPrivateBalancesWithUSDChange(callback: (state: PrivateBalancesState) => void): () => void;
|
|
39
42
|
getSupportedPassportLinks(): string[];
|
|
40
43
|
checkAccessToken(chainId: number, accessKeyOverride?: string): Promise<boolean>;
|
|
41
44
|
checkExternalTokenLimitsUSD(chainId: number, tokenAddresses: string[], amounts: bigint[]): Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`./activity-db.cjs`),require(`./balances-db.cjs`),require(`./private-balances-db.cjs`),require(`./prices-db.cjs`),require(`./contact-db.cjs`),require(`./signatures-db.cjs`),require(`./pay-activity-db.cjs`);
|
|
1
|
+
require(`./key-val-store.cjs`),require(`./activity-db.cjs`),require(`./balances-db.cjs`),require(`./private-balances-db.cjs`),require(`./prices-db.cjs`),require(`./contact-db.cjs`),require(`./signatures-db.cjs`),require(`./pay-activity-db.cjs`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../functions/utils/serialize.utils.cjs`),t=require(`../cacheDevices/FileCacheDevice.cjs`);var n=()=>typeof globalThis<`u`&&`indexedDB`in globalThis&&globalThis.indexedDB!=null,r=class{idbPromise=null;idb(){return this.idbPromise||=import(`idb-keyval`),this.idbPromise}async get(e){let{get:t}=await this.idb();return t(e)}async set(e,t){let{set:n}=await this.idb();await n(e,t)}async update(e,t){let{update:n}=await this.idb(),r;return await n(e,e=>(r=t(e),r)),r}},i=class{device;constructor(){let e=require(`path`);this.device=new t.FileCacheDevice(!0,e.resolve(process.cwd(),`hinkalKeyValCache.json`))}async get(t){let n=this.device.get(t);if(n)return e.CustomJSONParse(n)}async set(t,n){this.device.set(t,e.CustomJSONStringify(n))}async update(e,t){let n=t(await this.get(e));return await this.set(e,n),n}},a=n()?new r:new i;exports.keyValStore=a;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { __require as e } from "../../../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { CustomJSONParse as t, CustomJSONStringify as n } from "../../functions/utils/serialize.utils.mjs";
|
|
3
|
+
import { FileCacheDevice as r } from "../cacheDevices/FileCacheDevice.mjs";
|
|
4
|
+
//#region libs/shared/common/src/data-structures/IndexedDB/key-val-store.ts
|
|
5
|
+
var i = () => typeof globalThis < "u" && "indexedDB" in globalThis && globalThis.indexedDB != null, a = class {
|
|
6
|
+
idbPromise = null;
|
|
7
|
+
idb() {
|
|
8
|
+
return this.idbPromise ||= import("idb-keyval"), this.idbPromise;
|
|
9
|
+
}
|
|
10
|
+
async get(e) {
|
|
11
|
+
let { get: t } = await this.idb();
|
|
12
|
+
return t(e);
|
|
13
|
+
}
|
|
14
|
+
async set(e, t) {
|
|
15
|
+
let { set: n } = await this.idb();
|
|
16
|
+
await n(e, t);
|
|
17
|
+
}
|
|
18
|
+
async update(e, t) {
|
|
19
|
+
let { update: n } = await this.idb(), r;
|
|
20
|
+
return await n(e, (e) => (r = t(e), r)), r;
|
|
21
|
+
}
|
|
22
|
+
}, o = class {
|
|
23
|
+
device;
|
|
24
|
+
constructor() {
|
|
25
|
+
let t = e("path");
|
|
26
|
+
this.device = new r(!0, t.resolve(process.cwd(), "hinkalKeyValCache.json"));
|
|
27
|
+
}
|
|
28
|
+
async get(e) {
|
|
29
|
+
let n = this.device.get(e);
|
|
30
|
+
if (n) return t(n);
|
|
31
|
+
}
|
|
32
|
+
async set(e, t) {
|
|
33
|
+
this.device.set(e, n(t));
|
|
34
|
+
}
|
|
35
|
+
async update(e, t) {
|
|
36
|
+
let n = t(await this.get(e));
|
|
37
|
+
return await this.set(e, n), n;
|
|
38
|
+
}
|
|
39
|
+
}, s = i() ? new a() : new o();
|
|
40
|
+
//#endregion
|
|
41
|
+
export { s as keyValStore };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require(`../../API/API.cjs`),t=require(`../../functions/utils/string.utils.cjs`),n=require(`./key-val-store.cjs`);var r=new class{tokenPricesRecordLabel=`tokenPrices`;async getPrices(){return n.keyValStore.get(this.tokenPricesRecordLabel)}async updatePrices(r,i){if(!i.length)return[];let{prices:a}=await e.API.getTokenPrices(r,i);return await n.keyValStore.update(this.tokenPricesRecordLabel,(e={})=>{let n={...e};return a.forEach((e,a)=>{n[t.getTokenStateKey(i[a],r)]=e}),n}),a}async getAndUpdatePrices(e,n){let r=await this.getPrices(),i=Array(n.length).fill(0);if(!r)i=await this.updatePrices(e,n);else{let a=[],o=[];n.forEach((n,s)=>{let c=t.getTokenStateKey(n,e);r[c]?i[s]=r[c]:(a.push(n),o.push(s))});let s=await this.updatePrices(e,a);o.forEach((e,t)=>{i[e]=s[t]})}return i}async updateCachedPricesByChain(r){let i=await this.getPrices();if(!i||Object.keys(i).length===0)return;let a=Object.entries(i).filter(([e])=>{let[,t]=e.split(`-`);return parseInt(t,10)===r}).map(([e])=>e.split(`-`)[0]);if(a.length===0)return;let{prices:o}=await e.API.getTokenPrices(r,a);await n.keyValStore.update(this.tokenPricesRecordLabel,(e={})=>{let n={...e};return o.forEach((e,i)=>{let o=t.getTokenStateKey(a[i],r);n[o]=e}),n})}};exports.pricesStorage=r;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { API as e } from "../../API/API.mjs";
|
|
2
2
|
import { getTokenStateKey as t } from "../../functions/utils/string.utils.mjs";
|
|
3
|
-
import {
|
|
4
|
-
new class {
|
|
3
|
+
import { keyValStore as n } from "./key-val-store.mjs";
|
|
4
|
+
var r = new class {
|
|
5
5
|
tokenPricesRecordLabel = "tokenPrices";
|
|
6
6
|
async getPrices() {
|
|
7
|
-
return
|
|
7
|
+
return n.get(this.tokenPricesRecordLabel);
|
|
8
8
|
}
|
|
9
|
-
async updatePrices(
|
|
9
|
+
async updatePrices(r, i) {
|
|
10
10
|
if (!i.length) return [];
|
|
11
|
-
let { prices: a } = await e.getTokenPrices(
|
|
12
|
-
return await
|
|
13
|
-
let
|
|
11
|
+
let { prices: a } = await e.getTokenPrices(r, i);
|
|
12
|
+
return await n.update(this.tokenPricesRecordLabel, (e = {}) => {
|
|
13
|
+
let n = { ...e };
|
|
14
14
|
return a.forEach((e, a) => {
|
|
15
|
-
|
|
16
|
-
}),
|
|
15
|
+
n[t(i[a], r)] = e;
|
|
16
|
+
}), n;
|
|
17
17
|
}), a;
|
|
18
18
|
}
|
|
19
19
|
async getAndUpdatePrices(e, n) {
|
|
@@ -32,22 +32,23 @@ new class {
|
|
|
32
32
|
}
|
|
33
33
|
return i;
|
|
34
34
|
}
|
|
35
|
-
async updateCachedPricesByChain(
|
|
35
|
+
async updateCachedPricesByChain(r) {
|
|
36
36
|
let i = await this.getPrices();
|
|
37
37
|
if (!i || Object.keys(i).length === 0) return;
|
|
38
38
|
let a = Object.entries(i).filter(([e]) => {
|
|
39
39
|
let [, t] = e.split("-");
|
|
40
|
-
return parseInt(t, 10) ===
|
|
40
|
+
return parseInt(t, 10) === r;
|
|
41
41
|
}).map(([e]) => e.split("-")[0]);
|
|
42
42
|
if (a.length === 0) return;
|
|
43
|
-
let { prices: o } = await e.getTokenPrices(
|
|
44
|
-
await
|
|
45
|
-
let
|
|
43
|
+
let { prices: o } = await e.getTokenPrices(r, a);
|
|
44
|
+
await n.update(this.tokenPricesRecordLabel, (e = {}) => {
|
|
45
|
+
let n = { ...e };
|
|
46
46
|
return o.forEach((e, i) => {
|
|
47
|
-
let o = t(a[i],
|
|
48
|
-
|
|
49
|
-
}),
|
|
47
|
+
let o = t(a[i], r);
|
|
48
|
+
n[o] = e;
|
|
49
|
+
}), n;
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
}();
|
|
53
53
|
//#endregion
|
|
54
|
+
export { r as pricesStorage };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require(`../../functions/utils/string.utils.cjs`),t=require(`./key-val-store.cjs`);var n=new class{balancesRecordLabel=`privateWalletsBalances`;async getBalances(){return t.keyValStore.get(this.balancesRecordLabel)}async getBalancesByWallet(t,n){let r=await this.getBalances();if(r)return r[e.getStateKey(t,n,!0)]}async setBalances(n,r,i){let a=e.getStateKey(n,r,!0);await t.keyValStore.update(this.balancesRecordLabel,(e={})=>({...e,[a]:i}))}};exports.privateBalancesStorage=n;
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { getStateKey as e } from "../../functions/utils/string.utils.mjs";
|
|
2
|
-
import {
|
|
3
|
-
new class {
|
|
2
|
+
import { keyValStore as t } from "./key-val-store.mjs";
|
|
3
|
+
var n = new class {
|
|
4
4
|
balancesRecordLabel = "privateWalletsBalances";
|
|
5
5
|
async getBalances() {
|
|
6
|
-
return
|
|
6
|
+
return t.get(this.balancesRecordLabel);
|
|
7
7
|
}
|
|
8
8
|
async getBalancesByWallet(t, n) {
|
|
9
9
|
let r = await this.getBalances();
|
|
10
10
|
if (r) return r[e(t, n, !0)];
|
|
11
11
|
}
|
|
12
|
-
async setBalances(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
});
|
|
12
|
+
async setBalances(n, r, i) {
|
|
13
|
+
let a = e(n, r, !0);
|
|
14
|
+
await t.update(this.balancesRecordLabel, (e = {}) => ({
|
|
15
|
+
...e,
|
|
16
|
+
[a]: i
|
|
17
|
+
}));
|
|
20
18
|
}
|
|
21
19
|
}();
|
|
22
20
|
//#endregion
|
|
21
|
+
export { n as privateBalancesStorage };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PrivateBalanceUpdateEventType } from '../../../types';
|
|
2
|
-
type BalanceChangeListener = (detail
|
|
2
|
+
type BalanceChangeListener = (detail?: PrivateBalanceUpdateEventType) => void;
|
|
3
3
|
export declare const subscribeToBalanceChange: (listener: BalanceChangeListener) => (() => void);
|
|
4
4
|
export declare const balanceChangedHandler: (detail: PrivateBalanceUpdateEventType) => void;
|
|
5
5
|
export {};
|
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
import { UserKeys } from '../data-structures/crypto-keys/keys';
|
|
2
|
+
import { TokenBalanceWithUsdValue } from './token.types';
|
|
3
|
+
export type PrivateBalancesState = Record<number, TokenBalanceWithUsdValue[] | undefined>;
|
|
4
|
+
export type PrivateBalancesAction = {
|
|
5
|
+
type: 'SET_BALANCES';
|
|
6
|
+
chainId: number;
|
|
7
|
+
balances: TokenBalanceWithUsdValue[] | undefined;
|
|
8
|
+
} | {
|
|
9
|
+
type: 'SET_USD_BALANCES';
|
|
10
|
+
chainId: number;
|
|
11
|
+
balances: TokenBalanceWithUsdValue[] | undefined;
|
|
12
|
+
} | {
|
|
13
|
+
type: 'CLEAR_BALANCES';
|
|
14
|
+
chainId?: number;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'SET_LOADING';
|
|
17
|
+
chainId: number;
|
|
18
|
+
newValue: boolean;
|
|
19
|
+
} | {
|
|
20
|
+
type: 'SET_USD_LOADING';
|
|
21
|
+
chainId: number;
|
|
22
|
+
newValue: boolean;
|
|
23
|
+
};
|
|
2
24
|
export declare enum PrivateBalanceUpdateType {
|
|
3
25
|
OnlyCache = "ONLY_CACHE",
|
|
4
26
|
Fresh = "FRESH",
|
package/package.json
CHANGED
package/services/Hinkal.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../common/src/constants/chains.constants.cjs`),t=require(`../common/src/types/hinkal.types.cjs`);require(`../common/src/types/index.cjs`);const n=require(`../common/src/
|
|
1
|
+
const e=require(`../common/src/constants/chains.constants.cjs`),t=require(`../common/src/types/hinkal.types.cjs`);require(`../common/src/types/index.cjs`);const n=require(`../common/src/data-structures/Hinkal/Hinkal.cjs`);var r=class{hinkalCommon;constructor(e){this.hinkalCommon=new n.Hinkal(e)}getProviderAdapter(e){return this.hinkalCommon.getProviderAdapter(e)}initProviderAdapter(e,t){return this.hinkalCommon.initProviderAdapter(e,t)}initUserKeys(e=t.LoginMessageMode.PROTOCOL){return this.hinkalCommon.initUserKeys(e)}initUserKeysWithSignature(e){return this.hinkalCommon.initUserKeysWithSignature(e)}initUserKeysFromSeedPhrases(e){return this.hinkalCommon.initUserKeysFromSeedPhrases(e)}resetProviderAdapters(){return this.hinkalCommon.resetProviderAdapters()}disconnectFromConnector(){return this.hinkalCommon.disconnectFromConnector()}signMessage(e){return this.hinkalCommon.signMessage(e)}signTypedData(e,t,n){return this.hinkalCommon.signTypedData(e,t,n)}getSupportedChains(){return this.hinkalCommon.getSupportedChains()}isSelectedNetworkSupported(e){return this.hinkalCommon.isSelectedNetworkSupported(e)}switchNetwork(t){let n=e.networkRegistry[t];if(!n)throw Error(`Network with chainId ${t} not supported`);return this.hinkalCommon.switchNetwork(n)}resetMerkle(e){return this.hinkalCommon.resetMerkle(e)}resetMerkleTreesIfNecessary(e){return this.hinkalCommon.resetMerkleTreesIfNecessary(e)}get privateBalancesWithUSD(){return this.hinkalCommon.privateBalancesWithUSD}onPrivateBalancesWithUSDChange(e){return this.hinkalCommon.onPrivateBalancesWithUSDChange(e)}getTotalBalance(e,t=!1,n=!1){return this.hinkalCommon.getTotalBalance(e,void 0,void 0,t,n)}getStuckShieldedBalances(e,t=!1,n=!1){return this.hinkalCommon.getStuckShieldedBalances(e,void 0,void 0,t,n)}monitorConnectedAddress(e){return this.hinkalCommon.monitorConnectedAddress(e)}getSupportedPassportLinks(){return this.hinkalCommon.getSupportedPassportLinks()}checkAccessToken(e,t){return this.hinkalCommon.checkAccessToken(e,t)}waitForTransaction(e,t,n){return this.hinkalCommon.waitForTransaction(e,t,n)}getSolanaPublicKey(){return this.hinkalCommon.getSolanaPublicKey()}getEthereumAddress(){return this.hinkalCommon.getEthereumAddress()}getEthereumAddressByChain(e){return this.hinkalCommon.getEthereumAddressByChain(e)}getRecipientInfo(){return this.hinkalCommon.getRecipientInfo()}getShieldedPublicKey(){return this.hinkalCommon.userKeys.getShieldedPublicKey()}prooflessDeposit(e,t,n){return this.hinkalCommon.prooflessDeposit(e,t,n)}deposit(e,t,n,r){return this.hinkalCommon.deposit(e,t,n,r)}depositSolana(e,t){return this.hinkalCommon.depositSolana(e,t)}depositForOther(e,t,n,r,i){return this.hinkalCommon.depositForOther(e,t,n,r,i)}depositSolanaForOther(e,t,n){return this.hinkalCommon.depositSolanaForOther(e,t,n)}depositAndWithdraw(e,t,n,r,i,a){return this.hinkalCommon.depositAndWithdraw(e,t,n,r,i,void 0,void 0,void 0,a)}depositAndBridge(e,t,n,r,i){return this.hinkalCommon.depositAndBridge(e,t,n,r,void 0,void 0,void 0,i)}claimUtxo(e,t,n){return this.hinkalCommon.claimUtxo(e,t,n)}transfer(e,t,n,r,i){return this.hinkalCommon.transfer(e,t,n,r,i)}withdraw(e,t,n,r,i,a){return this.hinkalCommon.withdraw(e,t,n,r,i,a)}withdrawStuckUtxos(e,t){return this.hinkalCommon.withdrawStuckUtxos(e,t)}swap(e,t,n,r,i,a){return this.hinkalCommon.swap(e,t,n,r,i,a)}actionPrivateWallet(e,t,n,r,i,a,o,s,c){return this.hinkalCommon.actionPrivateWallet(e,t,n,r,i,a,o,s,c)}proxySwap(e,t,n,r,i,a,o,s){return this.hinkalCommon.proxySwap(e,t,n,r,i,a,o,s)}proxyToPrivate(e,t,n,r,i,a){return this.hinkalCommon.proxyToPrivate(e,t,n,r,i,a)}proxySend(e,t,n,r,i,a){return this.hinkalCommon.proxySend(e,t,n,r,i,a)}};exports.Hinkal=r;
|
package/services/Hinkal.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { BridgeRecipient, ERC20Token, ExternalActionId, FeeStructure, HinkalConfig, LoginMessageMode, StealthAddressStructure, SubAccount, TokenBalance, TokenChanges } from '../common/src/types';
|
|
1
|
+
import { BridgeRecipient, ERC20Token, ExternalActionId, FeeStructure, HinkalConfig, LoginMessageMode, StealthAddressStructure, SubAccount, TokenBalance, TokenChanges, PrivateBalancesState } from '../common/src/types';
|
|
2
2
|
import { ethers, TypedDataDomain, TypedDataField } from 'ethers';
|
|
3
3
|
import { Utxo } from '../common/src/data-structures/utxo/Utxo';
|
|
4
4
|
import { PublicKey } from '@solana/web3.js';
|
|
5
5
|
import { IHinkal, IProviderAdapter } from '../types';
|
|
6
|
-
import { PrivateBalanceUpdateEventType } from '../types/balances.types';
|
|
7
6
|
export declare class Hinkal<ConnectorType> implements IHinkal<ConnectorType> {
|
|
8
7
|
private readonly hinkalCommon;
|
|
9
8
|
constructor(hinkalConfig?: HinkalConfig);
|
|
@@ -21,7 +20,8 @@ export declare class Hinkal<ConnectorType> implements IHinkal<ConnectorType> {
|
|
|
21
20
|
switchNetwork(chainId: number): Promise<unknown>;
|
|
22
21
|
resetMerkle(chainIdsToReset?: number[]): Promise<void>;
|
|
23
22
|
resetMerkleTreesIfNecessary(chainIdsToCheck?: number[]): Promise<void>;
|
|
24
|
-
|
|
23
|
+
get privateBalancesWithUSD(): PrivateBalancesState;
|
|
24
|
+
onPrivateBalancesWithUSDChange(callback: (state: PrivateBalancesState) => void): () => void;
|
|
25
25
|
getTotalBalance(chainId: number, resetCacheBefore?: boolean, updateTokensListBefore?: boolean): Promise<TokenBalance[]>;
|
|
26
26
|
getStuckShieldedBalances(chainId: number, resetCacheBefore?: boolean, updateTokensListBefore?: boolean): Promise<TokenBalance[]>;
|
|
27
27
|
monitorConnectedAddress(chainId: number): Promise<void>;
|
package/services/Hinkal.mjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { networkRegistry as e } from "../common/src/constants/chains.constants.mjs";
|
|
2
2
|
import { LoginMessageMode as t } from "../common/src/types/hinkal.types.mjs";
|
|
3
3
|
import "../common/src/types/index.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { Hinkal as r } from "../common/src/data-structures/Hinkal/Hinkal.mjs";
|
|
4
|
+
import { Hinkal as n } from "../common/src/data-structures/Hinkal/Hinkal.mjs";
|
|
6
5
|
//#region libs/shared/sdk/src/services/Hinkal.ts
|
|
7
|
-
var
|
|
6
|
+
var r = class {
|
|
8
7
|
hinkalCommon;
|
|
9
8
|
constructor(e) {
|
|
10
|
-
this.hinkalCommon = new
|
|
9
|
+
this.hinkalCommon = new n(e);
|
|
11
10
|
}
|
|
12
11
|
getProviderAdapter(e) {
|
|
13
12
|
return this.hinkalCommon.getProviderAdapter(e);
|
|
@@ -53,8 +52,11 @@ var i = class {
|
|
|
53
52
|
resetMerkleTreesIfNecessary(e) {
|
|
54
53
|
return this.hinkalCommon.resetMerkleTreesIfNecessary(e);
|
|
55
54
|
}
|
|
56
|
-
|
|
57
|
-
return
|
|
55
|
+
get privateBalancesWithUSD() {
|
|
56
|
+
return this.hinkalCommon.privateBalancesWithUSD;
|
|
57
|
+
}
|
|
58
|
+
onPrivateBalancesWithUSDChange(e) {
|
|
59
|
+
return this.hinkalCommon.onPrivateBalancesWithUSDChange(e);
|
|
58
60
|
}
|
|
59
61
|
getTotalBalance(e, t = !1, n = !1) {
|
|
60
62
|
return this.hinkalCommon.getTotalBalance(e, void 0, void 0, t, n);
|
|
@@ -139,4 +141,4 @@ var i = class {
|
|
|
139
141
|
}
|
|
140
142
|
};
|
|
141
143
|
//#endregion
|
|
142
|
-
export {
|
|
144
|
+
export { r as Hinkal };
|
package/types/IHinkal.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { BridgeRecipient, ERC20Token, ExternalActionId, FeeStructure, LoginMessageMode, StealthAddressStructure, SubAccount, TokenBalance, TokenChanges } from '../common/src/types';
|
|
1
|
+
import { PrivateBalancesState, BridgeRecipient, ERC20Token, ExternalActionId, FeeStructure, LoginMessageMode, StealthAddressStructure, SubAccount, TokenBalance, TokenChanges } from '../common/src/types';
|
|
2
2
|
import { ethers, TypedDataDomain, TypedDataField } from 'ethers';
|
|
3
3
|
import { Utxo } from '../common/src/data-structures/utxo/Utxo';
|
|
4
4
|
import { PublicKey } from '@solana/web3.js';
|
|
5
5
|
import { IProviderAdapter } from './IProviderAdapter';
|
|
6
|
-
import { PrivateBalanceUpdateEventType } from './balances.types';
|
|
7
6
|
export interface IHinkal<ConnectorType = unknown> {
|
|
8
7
|
getProviderAdapter(chainId?: number): IProviderAdapter;
|
|
9
8
|
initProviderAdapter(connector: ConnectorType, providerAdapter: IProviderAdapter<ConnectorType>): Promise<void>;
|
|
@@ -19,7 +18,9 @@ export interface IHinkal<ConnectorType = unknown> {
|
|
|
19
18
|
switchNetwork(chainId: number): Promise<unknown>;
|
|
20
19
|
resetMerkle(chainIdsToReset?: number[]): Promise<void>;
|
|
21
20
|
resetMerkleTreesIfNecessary(chainIdsToCheck?: number[]): Promise<void>;
|
|
22
|
-
|
|
21
|
+
privateBalancesWithUSD: PrivateBalancesState;
|
|
22
|
+
/** Returns unsubscribe. Multiple listeners supported. */
|
|
23
|
+
onPrivateBalancesWithUSDChange(callback: (state: PrivateBalancesState) => void): () => void;
|
|
23
24
|
getTotalBalance(chainId: number, resetCacheBefore?: boolean, updateTokensListBefore?: boolean): Promise<TokenBalance[]>;
|
|
24
25
|
getStuckShieldedBalances(chainId: number, resetCacheBefore?: boolean, updateTokensListBefore?: boolean): Promise<TokenBalance[]>;
|
|
25
26
|
monitorConnectedAddress(chainId: number): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { PrivateBalanceUpdateEventType as CommonPrivateBalanceUpdateEventType } from '../common/src/types';
|
|
2
2
|
export { PrivateBalanceUpdateType } from '../common/src/types';
|
|
3
|
-
export type { TokenBalance } from '../common/src/types';
|
|
3
|
+
export type { PrivateBalancesState, TokenBalance } from '../common/src/types';
|
|
4
4
|
export type PrivateBalanceUpdateEventType = Omit<CommonPrivateBalanceUpdateEventType, 'balanceChangeState'>;
|