@hinkal/common 0.2.16 → 0.2.18

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.
Files changed (66) hide show
  1. package/API/getWebsiteURL.d.ts +1 -1
  2. package/README.md +9 -2
  3. package/constants/chains.constants.cjs +1 -1
  4. package/constants/chains.constants.mjs +2 -2
  5. package/constants/mediaUrls.constants.cjs +1 -1
  6. package/constants/mediaUrls.constants.d.ts +2 -0
  7. package/constants/mediaUrls.constants.mjs +3 -1
  8. package/constants/vite.constants.cjs +1 -1
  9. package/constants/vite.constants.mjs +36 -13
  10. package/data-structures/Hinkal/Hinkal.cjs +1 -1
  11. package/data-structures/Hinkal/Hinkal.d.ts +1 -1
  12. package/data-structures/Hinkal/Hinkal.mjs +2 -2
  13. package/data-structures/Hinkal/IHinkal.d.ts +1 -1
  14. package/data-structures/Hinkal/hinkalApprove.d.ts +1 -1
  15. package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
  16. package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +136 -118
  17. package/data-structures/Hinkal/hinkalInsideTransact.d.ts +1 -1
  18. package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +1 -1
  19. package/data-structures/Hinkal/hinkalProxyToPrivate.d.ts +1 -1
  20. package/data-structures/Hinkal/hinkalSolanaSwap.d.ts +1 -1
  21. package/data-structures/Hinkal/hinkalSolanaTransfer.d.ts +1 -1
  22. package/data-structures/Hinkal/hinkalSolanaWithdraw.d.ts +1 -1
  23. package/data-structures/Hinkal/hinkalSwap.d.ts +1 -1
  24. package/data-structures/Hinkal/hinkalTransfer.d.ts +1 -1
  25. package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
  26. package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.d.ts +2 -2
  27. package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +59 -58
  28. package/error-handling/error-codes.constants.cjs +1 -1
  29. package/error-handling/error-codes.constants.d.ts +2 -0
  30. package/error-handling/error-codes.constants.mjs +3 -1
  31. package/functions/snarkjs/constructEmporiumProof.d.ts +2 -2
  32. package/functions/snarkjs/constructGeneralZkProof.d.ts +2 -2
  33. package/functions/snarkjs/generateCircomData.d.ts +1 -1
  34. package/functions/utils/enum.utils.cjs +1 -0
  35. package/functions/utils/enum.utils.mjs +14 -0
  36. package/functions/utils/getDataFromTransaction.d.ts +3 -3
  37. package/functions/web3/events/getInputUtxosEnclave.d.ts +1 -1
  38. package/functions/web3/functionCalls/approveToken.cjs +1 -1
  39. package/functions/web3/functionCalls/approveToken.mjs +51 -47
  40. package/functions/web3/functionCalls/recoverTransactionFromError.cjs +1 -0
  41. package/functions/web3/functionCalls/recoverTransactionFromError.d.ts +2 -0
  42. package/functions/web3/functionCalls/recoverTransactionFromError.mjs +23 -0
  43. package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
  44. package/functions/web3/functionCalls/transactCallDirect.mjs +45 -32
  45. package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
  46. package/functions/web3/functionCalls/transactCallRelayer.mjs +23 -22
  47. package/index.cjs +1 -1
  48. package/index.mjs +116 -115
  49. package/package.json +2 -2
  50. package/providers/WagmiProviderAdapter.cjs +1 -1
  51. package/providers/WagmiProviderAdapter.mjs +49 -56
  52. package/types/admin.types.cjs +1 -1
  53. package/types/admin.types.d.ts +3 -1
  54. package/types/admin.types.mjs +1 -1
  55. package/types/solana.types.d.ts +2 -0
  56. package/types/transactions.types.cjs +1 -1
  57. package/types/transactions.types.d.ts +4 -0
  58. package/types/transactions.types.mjs +5 -4
  59. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
  60. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
  61. package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
  62. package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
  63. package/webworker/viteWorkerURL.constant.cjs +3 -3
  64. package/webworker/viteWorkerURL.constant.mjs +3 -3
  65. package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
  66. package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +2 -2
@@ -1,3 +1,3 @@
1
- export declare const getHinkalLandingURL: () => "https://hinkal.pro" | "http://localhost:4230" | "https://hinkal-playground-landing.netlify.app" | "https://staging-hinkal-landing.netlify.app";
1
+ export declare const getHinkalLandingURL: () => "http://localhost:4230" | "https://hinkal-playground-landing.netlify.app" | "https://staging-hinkal-landing.netlify.app" | "https://hinkal.pro";
2
2
  export declare const getWalletOnboardingURL: () => "http://localhost:4118" | "https://hinkal-playground-onboarding.netlify.app" | "https://staging-hinkal-onboarding.netlify.app" | "https://onboarding.hinkal.pro";
3
3
  export declare const getRewardsURL: () => "http://localhost:4117" | "https://hinkal-playground.netlify.app" | "https://staging-hinkal-rewards.netlify.app" | "https://rewards.hinkal.pro";
package/README.md CHANGED
@@ -1,8 +1,15 @@
1
1
  # Hinkal SDK
2
2
 
3
- Hinkal is middleware and a set of smart contracts on EVM chains that use ZK-proofs and stealth addresses to enable compliant and private transactions on major dApps. Users can privately store assets and transact on platforms such as Uniswap, Pendle, Lido, Curve, and others.
3
+ Hinkal is a privacy middleware and smart-contract SDK for public blockchains that enables confidential transactions and settlement flows without changing wallets, custody, or chains.
4
+
5
+ The SDK allows wallets, dApps, and payment platforms to integrate protocol-level privacy on Ethereum, Solana, Polygon, Base, Arbitrum, and Optimis. It hides transaction history, wallet relationships, and asset flows on-chain while preserving public-chain finality and compliance.
6
+
7
+ With Hinkal SDK, developers can:
8
+ • Enable private sends between public wallets
9
+ • Perform confidential payouts and settlements
10
+ • Route transactions through Hinkal’s privacy contracts without exposing sender, recipient, or amounts
11
+ • Maintain non-custodial control with optional compliance visibility via viewing keys
4
12
 
5
- This SDK enables users to perform arbitrary smart contract interactions privately.
6
13
 
7
14
  ## Installation
8
15
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./deploy-data/deploy-data-bnbMainnet.json.cjs"),d=require("./deploy-data/deploy-data-arbMainnet.json.cjs"),h=require("./deploy-data/deploy-data-ethMainnet.json.cjs"),u=require("./deploy-data/deploy-data-optimism.json.cjs"),m=require("./deploy-data/deploy-data-polygon.json.cjs"),b=require("./deploy-data/deploy-data-avalanche.json.cjs"),y=require("./deploy-data/deploy-data-base.json.cjs"),A=require("./deploy-data/deploy-data-localhost.json.cjs"),f=require("./deploy-data/deploy-data-arcTestnet.json.cjs"),c=require("./deploy-data/deploy-data-solana.json.cjs"),r=require("./vite.constants.cjs"),t={polygon:137,arbMainnet:42161,ethMainnet:1,avalanche:43114,bnbMainnet:56,optimism:10,base:8453,bnbTestnet:97,polygonMumbai:80001,mainnetSepolia:11155111,optimismSepolia:11155420,localhost:31337,hardhat:31337,arcTestnet:5042002,solanaMainnet:501,solanaLocalnet:102},D="4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",n=t.ethMainnet,s=a=>!![t.localhost].includes(a),E=a=>a?s(a)?n:a:n,i="X4IiEZsSzGOrJq8tzq7Y3",e=r.isNotProduction?i:"XzUgeU8YiIIzkD7j2GWnTsFUck7wGgK9",F="https://mainnet.helius-rpc.com/?api-key=24718f72-c710-45d6-853e-d447cf530579",o={[t.ethMainnet]:{name:"Ethereum",chainId:t.ethMainnet,rpcUrl:"https://rpc.ankr.com/eth",fetchRpcUrl:`https://eth-mainnet.g.alchemy.com/v2/${e}`,supported:!0,contractData:h.default,quoterV2Address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",uniswapV3FactoryAddress:"0x1F98431c8aD98523631AE4a59f267346ea31F984",priority:1,privateMempoolRpcUrl:"https://relay.flashbots.net"},[t.arbMainnet]:{name:"Arbitrum",chainId:t.arbMainnet,rpcUrl:"https://endpoints.omniatech.io/v1/arbitrum/one/public",fetchRpcUrl:`https://arb-mainnet.g.alchemy.com/v2/${e}`,supported:!0,contractData:d.default,quoterV2Address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",uniswapV3FactoryAddress:"0x1F98431c8aD98523631AE4a59f267346ea31F984",priority:2},[t.optimism]:{name:"Optimism",chainId:t.optimism,rpcUrl:"https://optimism-mainnet.infura.io/v3/c26b99456bb6464bb498926ff5162903",fetchRpcUrl:`https://opt-mainnet.g.alchemy.com/v2/${e}`,supported:!0,contractData:u.default,quoterV2Address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",uniswapV3FactoryAddress:"0x1F98431c8aD98523631AE4a59f267346ea31F984",priority:3},[t.polygon]:{name:"Polygon",chainId:t.polygon,rpcUrl:"https://polygon-rpc.com",fetchRpcUrl:`https://polygon-mainnet.g.alchemy.com/v2/${e}`,supported:!0,contractData:m.default,quoterV2Address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",uniswapV3FactoryAddress:"0x1F98431c8aD98523631AE4a59f267346ea31F984",priority:4,maxPageSize:1e6},[t.avalanche]:{name:"Avalanche",chainId:t.avalanche,rpcUrl:"https://api.avax.network/ext/bc/C/rpc",fetchRpcUrl:`https://avax-mainnet.g.alchemy.com/v2/${e}`,supported:!0,contractData:b.default,quoterV2Address:"0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F",uniswapV3FactoryAddress:"0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD",priority:5},[t.bnbMainnet]:{name:"BNB Chain",chainId:t.bnbMainnet,rpcUrl:"https://bsc-dataseed.binance.org",fetchRpcUrl:`https://bnb-mainnet.g.alchemy.com/v2/${e}`,supported:!0,contractData:l.default,quoterV2Address:"0x78D78E420Da98ad378D7799bE8f4AF69033EB077",uniswapV3FactoryAddress:"0xdB1d10011AD0Ff90774D0C6Bb92e5C5c8b4461F7",priority:6},[t.base]:{name:"Base",chainId:t.base,rpcUrl:"https://mainnet.base.org/",fetchRpcUrl:`https://base-mainnet.g.alchemy.com/v2/${e}`,supported:!0,contractData:y.default,quoterV2Address:"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",uniswapV3FactoryAddress:"0x33128a8fC17869897dcE68Ed026d694621f6FDfD",priority:7},[t.arcTestnet]:{name:"Arc Testnet",chainId:t.arcTestnet,rpcUrl:`https://arc-testnet.g.alchemy.com/v2/${e}`,fetchRpcUrl:`https://arc-testnet.g.alchemy.com/v2/${e}`,supported:!0,contractData:f.default,priority:8,maxPageSize:9999},[t.solanaMainnet]:{name:"Solana",chainId:t.solanaMainnet,rpcUrl:"https://api.mainnet-beta.solana.com",fetchRpcUrl:"https://wider-side-sunset.solana-mainnet.quiknode.pro/61054262c1a2b13dd570243c5fdd017c05cf7fe1",supported:!0,contractData:c.default,priority:8},[t.solanaLocalnet]:{name:"Solana Localnet",chainId:t.solanaLocalnet,rpcUrl:"http://127.0.0.1:8899",fetchRpcUrl:"http://127.0.0.1:8899",supported:!0,contractData:c.default,priority:9},...r.isDevelopment?{}:{}},L={name:"Localhost",chainId:t.localhost,rpcUrl:"http://127.0.0.1:8545",fetchRpcUrl:"http://127.0.0.1:8545",supported:!0,contractData:A.default,quoterV2Address:o[n].quoterV2Address,uniswapV3FactoryAddress:o[n].uniswapV3FactoryAddress,priority:7};r.isDevelopment&&(o[t.localhost]=L);var p=(a=>(a.Mainnet="Mainnet",a.Testnet="Testnet",a.Local="Local",a))(p||{});const I={Mainnet:[t.polygon,t.arbMainnet,t.ethMainnet,t.bnbMainnet,t.optimism,t.avalanche,t.base],Testnet:[t.bnbTestnet,t.polygonMumbai,t.arcTestnet],Local:[t.localhost]},M=a=>[t.optimism,t.base].includes(a),U=a=>[t.solanaMainnet,t.solanaLocalnet].includes(a),g=t.ethMainnet,T=[t.ethMainnet,t.optimism,t.base,t.polygon,t.arbMainnet,t.arcTestnet,t.solanaMainnet];exports.ALCHEMY_API_KEY=e;exports.ALCHEMY_TEST_KEY=i;exports.EthereumNetworkType=p;exports.HELIUS_RPC_URL=F;exports.WALLET_INITIAL_CHAIN_ID=g;exports.WALLET_SUPPORTED_CHAINS=T;exports.chainIds=t;exports.chainIdsByType=I;exports.getNonLocalhostChainId=E;exports.isLocalNetwork=s;exports.isOptimismLike=M;exports.isSolanaLike=U;exports.localhostNetwork=n;exports.networkRegistry=o;exports.solanaChainIdStr=D;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./deploy-data/deploy-data-bnbMainnet.json.cjs"),d=require("./deploy-data/deploy-data-arbMainnet.json.cjs"),h=require("./deploy-data/deploy-data-ethMainnet.json.cjs"),u=require("./deploy-data/deploy-data-optimism.json.cjs"),m=require("./deploy-data/deploy-data-polygon.json.cjs"),b=require("./deploy-data/deploy-data-avalanche.json.cjs"),y=require("./deploy-data/deploy-data-base.json.cjs"),A=require("./deploy-data/deploy-data-localhost.json.cjs"),f=require("./deploy-data/deploy-data-arcTestnet.json.cjs"),c=require("./deploy-data/deploy-data-solana.json.cjs"),r=require("./vite.constants.cjs"),t={polygon:137,arbMainnet:42161,ethMainnet:1,avalanche:43114,bnbMainnet:56,optimism:10,base:8453,bnbTestnet:97,polygonMumbai:80001,mainnetSepolia:11155111,optimismSepolia:11155420,localhost:31337,hardhat:31337,arcTestnet:5042002,solanaMainnet:501,solanaLocalnet:102},D="4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",n=t.ethMainnet,s=a=>!![t.localhost].includes(a),E=a=>a?s(a)?n:a:n,i="X4IiEZsSzGOrJq8tzq7Y3",e=r.isNotProduction?i:"XzUgeU8YiIIzkD7j2GWnTsFUck7wGgK9",F="https://mainnet.helius-rpc.com/?api-key=24718f72-c710-45d6-853e-d447cf530579",o={[t.ethMainnet]:{name:"Ethereum",chainId:t.ethMainnet,rpcUrl:"https://rpc.ankr.com/eth",fetchRpcUrl:`https://eth-mainnet.g.alchemy.com/v2/${e}`,supported:!0,contractData:h.default,quoterV2Address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",uniswapV3FactoryAddress:"0x1F98431c8aD98523631AE4a59f267346ea31F984",priority:1,privateMempoolRpcUrl:"https://relay.flashbots.net"},[t.arbMainnet]:{name:"Arbitrum",chainId:t.arbMainnet,rpcUrl:"https://endpoints.omniatech.io/v1/arbitrum/one/public",fetchRpcUrl:`https://arb-mainnet.g.alchemy.com/v2/${e}`,supported:!0,contractData:d.default,quoterV2Address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",uniswapV3FactoryAddress:"0x1F98431c8aD98523631AE4a59f267346ea31F984",priority:2},[t.optimism]:{name:"Optimism",chainId:t.optimism,rpcUrl:"https://optimism-mainnet.infura.io/v3/c26b99456bb6464bb498926ff5162903",fetchRpcUrl:`https://opt-mainnet.g.alchemy.com/v2/${e}`,supported:!0,contractData:u.default,quoterV2Address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",uniswapV3FactoryAddress:"0x1F98431c8aD98523631AE4a59f267346ea31F984",priority:3},[t.polygon]:{name:"Polygon",chainId:t.polygon,rpcUrl:"https://polygon-rpc.com",fetchRpcUrl:`https://polygon-mainnet.g.alchemy.com/v2/${e}`,supported:!0,contractData:m.default,quoterV2Address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",uniswapV3FactoryAddress:"0x1F98431c8aD98523631AE4a59f267346ea31F984",priority:4,maxPageSize:1e6},[t.avalanche]:{name:"Avalanche",chainId:t.avalanche,rpcUrl:"https://api.avax.network/ext/bc/C/rpc",fetchRpcUrl:`https://avax-mainnet.g.alchemy.com/v2/${e}`,supported:!0,contractData:b.default,quoterV2Address:"0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F",uniswapV3FactoryAddress:"0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD",priority:5},[t.bnbMainnet]:{name:"BNB Chain",chainId:t.bnbMainnet,rpcUrl:"https://bsc-dataseed.binance.org",fetchRpcUrl:`https://bnb-mainnet.g.alchemy.com/v2/${e}`,supported:!0,contractData:l.default,quoterV2Address:"0x78D78E420Da98ad378D7799bE8f4AF69033EB077",uniswapV3FactoryAddress:"0xdB1d10011AD0Ff90774D0C6Bb92e5C5c8b4461F7",priority:6},[t.base]:{name:"Base",chainId:t.base,rpcUrl:"https://mainnet.base.org/",fetchRpcUrl:`https://base-mainnet.g.alchemy.com/v2/${e}`,supported:!0,contractData:y.default,quoterV2Address:"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",uniswapV3FactoryAddress:"0x33128a8fC17869897dcE68Ed026d694621f6FDfD",priority:7},[t.arcTestnet]:{name:"Arc Testnet",chainId:t.arcTestnet,rpcUrl:`https://arc-testnet.g.alchemy.com/v2/${e}`,fetchRpcUrl:`https://arc-testnet.g.alchemy.com/v2/${e}`,supported:!0,contractData:f.default,priority:8,maxPageSize:9999},[t.solanaMainnet]:{name:"Solana",chainId:t.solanaMainnet,rpcUrl:"https://api.mainnet-beta.solana.com",fetchRpcUrl:"https://wider-side-sunset.solana-mainnet.quiknode.pro/61054262c1a2b13dd570243c5fdd017c05cf7fe1",supported:!0,contractData:c.default,priority:8},[t.solanaLocalnet]:{name:"Solana Localnet",chainId:t.solanaLocalnet,rpcUrl:"http://127.0.0.1:8899",fetchRpcUrl:"http://127.0.0.1:8899",supported:!0,contractData:c.default,priority:9},...r.isDevelopment?{}:{}},L={name:"Localhost",chainId:t.localhost,rpcUrl:"http://127.0.0.1:8545",fetchRpcUrl:"http://127.0.0.1:8545",supported:!0,contractData:A.default,quoterV2Address:o[n].quoterV2Address,uniswapV3FactoryAddress:o[n].uniswapV3FactoryAddress,priority:7};r.isDevelopment&&(o[t.localhost]=L);var p=(a=>(a.Mainnet="Mainnet",a.Testnet="Testnet",a.Local="Local",a))(p||{});const I={Mainnet:[t.polygon,t.arbMainnet,t.ethMainnet,t.bnbMainnet,t.optimism,t.avalanche,t.base],Testnet:[t.bnbTestnet,t.polygonMumbai,t.arcTestnet],Local:[t.localhost]},M=a=>[t.optimism,t.base].includes(a),U=a=>[t.solanaMainnet,t.solanaLocalnet].includes(a),g=t.ethMainnet,T=[t.ethMainnet,t.optimism,t.base,t.polygon,t.arbMainnet,t.arcTestnet];exports.ALCHEMY_API_KEY=e;exports.ALCHEMY_TEST_KEY=i;exports.EthereumNetworkType=p;exports.HELIUS_RPC_URL=F;exports.WALLET_INITIAL_CHAIN_ID=g;exports.WALLET_SUPPORTED_CHAINS=T;exports.chainIds=t;exports.chainIdsByType=I;exports.getNonLocalhostChainId=E;exports.isLocalNetwork=s;exports.isOptimismLike=M;exports.isSolanaLike=U;exports.localhostNetwork=n;exports.networkRegistry=o;exports.solanaChainIdStr=D;
@@ -171,8 +171,8 @@ const S = {
171
171
  t.base,
172
172
  t.polygon,
173
173
  t.arbMainnet,
174
- t.arcTestnet,
175
- t.solanaMainnet
174
+ t.arcTestnet
175
+ // chainIds.solanaMainnet,
176
176
  ];
177
177
  export {
178
178
  e as ALCHEMY_API_KEY,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t={GITHUB:"https://github.com/Novelty-Today/privacy-first-mixer",TWITTER:"https://x.com/hinkal_protocol/",TELEGRAM:"https://t.me/hinkal_protocol/",DOCS:"/Whitepaper.pdf",AUDIT:"/Hinkal_final_Secure3_Audit_Report.pdf",AIPRISE:"https://aiprise.com/",DEMO:"https://www.loom.com/share/a03b147d930d4efdbb993b6bf72746ca",POLY_SCAN:"https://polygonscan.com/",ETH_SCAN:"https://etherscan.io/",BSC_SCAN:"https://bscscan.com/",ARB_SCAN:"https://arbiscan.io/",SNOW_TRACE:"https://snowtrace.io/",OPTIMISM_SCAN:"https://optimistic.etherscan.io/",ETHER_SCAN:"https://etherscan.io/",AVAX_SCAN:"https://snowtrace.io/",BASE_SCAN:"https://basescan.org/",MUMBAI_SCAN:"https://mumbai.polygonscan.com/",SOL_SCAN:"https://solscan.io/",OPENSEA_TEST:"https://testnets.opensea.io/",LINKTREE:"https://linktr.ee/hinkal_protocol",DISCORD:"https://discord.gg/xYGJTJbZy7",LINKEDIN:"https://www.linkedin.com/company/hinkal-protocol/",ARC_TESTNET_EXPLORER:"https://testnet.arcscan.app/",BLOG_WHITE:"https://x.com/hinkal_protocol/articles",DEFILAMA_WHITE:"https://defillama.com/protocol/hinkal",SOCIOGRAM_WHITE:"https://sociogram.org/Hinkal",HINKAL_DAPP:"https://app.hinkal.pro/",HINKAL_REWARDS:"https://rewards.hinkal.pro/",HINKAL_DOCS:"https://hinkal-team.gitbook.io/hinkal-protocol/",HINKAL_MEDIA_KIT:"https://hinkal.notion.site/Hinkal-Brand-Media-Kit-1bacbfea03a98051af40c8122158fa7a?pvs=73",LANDING_PAGE_URL:"https://hinkal.pro"};exports.mediaUrls=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t={GITHUB:"https://github.com/Novelty-Today/privacy-first-mixer",TWITTER:"https://x.com/hinkal_protocol/",TELEGRAM:"https://t.me/hinkal_protocol/",DOCS:"/Whitepaper.pdf",AUDIT:"/Hinkal_final_Secure3_Audit_Report.pdf",AIPRISE:"https://aiprise.com/",DEMO:"https://www.loom.com/share/a03b147d930d4efdbb993b6bf72746ca",POLY_SCAN:"https://polygonscan.com/",ETH_SCAN:"https://etherscan.io/",BSC_SCAN:"https://bscscan.com/",ARB_SCAN:"https://arbiscan.io/",SNOW_TRACE:"https://snowtrace.io/",OPTIMISM_SCAN:"https://optimistic.etherscan.io/",ETHER_SCAN:"https://etherscan.io/",AVAX_SCAN:"https://snowtrace.io/",BASE_SCAN:"https://basescan.org/",MUMBAI_SCAN:"https://mumbai.polygonscan.com/",SOL_SCAN:"https://solscan.io/",OPENSEA_TEST:"https://testnets.opensea.io/",LINKTREE:"https://linktr.ee/hinkal_protocol",DISCORD:"https://discord.gg/xYGJTJbZy7",LINKEDIN:"https://www.linkedin.com/company/hinkal-protocol/",ARC_TESTNET_EXPLORER:"https://testnet.arcscan.app/",BLOG_WHITE:"https://x.com/hinkal_protocol/articles",DEFILAMA_WHITE:"https://defillama.com/protocol/hinkal",SOCIOGRAM_WHITE:"https://sociogram.org/Hinkal",HINKAL_DAPP:"https://app.hinkal.pro/",HINKAL_PRIVATE_SEND:"https://send.hinkal.io",HINKAL_REWARDS:"https://rewards.hinkal.pro/",HINKAL_DOCS:"https://hinkal-team.gitbook.io/hinkal-protocol/",HINKAL_MEDIA_KIT:"https://hinkal.notion.site/Hinkal-Brand-Media-Kit-1bacbfea03a98051af40c8122158fa7a?pvs=73",LANDING_PAGE_URL:"https://hinkal.io",HINKAL_SDK:"https://www.npmjs.com/package/@hinkal/common"};exports.mediaUrls=t;
@@ -26,8 +26,10 @@ export declare const mediaUrls: {
26
26
  DEFILAMA_WHITE: string;
27
27
  SOCIOGRAM_WHITE: string;
28
28
  HINKAL_DAPP: string;
29
+ HINKAL_PRIVATE_SEND: string;
29
30
  HINKAL_REWARDS: string;
30
31
  HINKAL_DOCS: string;
31
32
  HINKAL_MEDIA_KIT: string;
32
33
  LANDING_PAGE_URL: string;
34
+ HINKAL_SDK: string;
33
35
  };
@@ -26,10 +26,12 @@ const t = {
26
26
  DEFILAMA_WHITE: "https://defillama.com/protocol/hinkal",
27
27
  SOCIOGRAM_WHITE: "https://sociogram.org/Hinkal",
28
28
  HINKAL_DAPP: "https://app.hinkal.pro/",
29
+ HINKAL_PRIVATE_SEND: "https://send.hinkal.io",
29
30
  HINKAL_REWARDS: "https://rewards.hinkal.pro/",
30
31
  HINKAL_DOCS: "https://hinkal-team.gitbook.io/hinkal-protocol/",
31
32
  HINKAL_MEDIA_KIT: "https://hinkal.notion.site/Hinkal-Brand-Media-Kit-1bacbfea03a98051af40c8122158fa7a?pvs=73",
32
- LANDING_PAGE_URL: "https://hinkal.pro"
33
+ LANDING_PAGE_URL: "https://hinkal.io",
34
+ HINKAL_SDK: "https://www.npmjs.com/package/@hinkal/common"
33
35
  };
34
36
  export {
35
37
  t as mediaUrls
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var n=(o=>(o.DEVELOPMENT="development",o.PLAYGROUND="playground",o.PRODUCTION="production",o.STAGING="staging",o))(n||{});const c=typeof process<"u"&&process?.release?.name==="node",t=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,p=!t&&typeof window<"u"&&window.origin==="null",l=typeof __webpack_require__<"u",u=typeof window<"u"&&window?.location?.protocol==="chrome-extension:",a=()=>"production",e=a(),i=e==="development",s=e==="playground",d=e==="staging",r=d||i||s,g=r||c&&e==="production";exports.DEPLOYMENT_MODE=n;exports.deploymentMode=e;exports.isDevelopment=i;exports.isExtension=u;exports.isNode=t;exports.isNotClientProduction=g;exports.isNotProduction=r;exports.isPlayground=s;exports.isSandbox=p;exports.isStaging=d;exports.isWebpack=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../functions/utils/enum.utils.cjs");var t=(e=>(e.DEVELOPMENT="development",e.PLAYGROUND="playground",e.PRODUCTION="production",e.STAGING="staging",e))(t||{});const i={development:["localhost","192.","127."],playground:["playground"],staging:["working","staging"]},r=typeof process<"u"&&process?.release?.name==="node",u=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,y=!u&&typeof window<"u"&&window.origin==="null",m=typeof __webpack_require__<"u",f=typeof window<"u"&&window?.location?.protocol==="chrome-extension:";function s(e,o){return o.some(g=>e.includes(g))}const v=()=>(require("dotenv").config({path:"DOTENV_OVERRIDE"in process.env?process.env.DOTENV_OVERRIDE:void 0}),d.toEnumValue(t,process.env.DEPLOYMENT_MODE)||"development"),w=()=>{if(!r&&typeof window>"u")return;if(r)return v();if(window?.location?.protocol==="chrome-extension:"){const o=d.toEnumValue(t,WALLET_DEPLOYMENT_MODE);return o||"staging"}const e=window?.location?.host;return s(e,i.development)?"development":s(e,i.playground)?"playground":s(e,i.staging)?"staging":"production"},n=w(),c=n==="development",l=n==="playground",p=n==="staging",a=p||c||l,E=a||r&&n==="production";exports.DEPLOYMENT_MODE=t;exports.deploymentMode=n;exports.isDevelopment=c;exports.isExtension=f;exports.isNode=u;exports.isNotClientProduction=E;exports.isNotProduction=a;exports.isPlayground=l;exports.isSandbox=y;exports.isStaging=p;exports.isWebpack=m;
@@ -1,15 +1,38 @@
1
- var e = /* @__PURE__ */ ((o) => (o.DEVELOPMENT = "development", o.PLAYGROUND = "playground", o.PRODUCTION = "production", o.STAGING = "staging", o))(e || {});
2
- const s = typeof process < "u" && process?.release?.name === "node", t = typeof process < "u" && process.versions != null && process.versions.node != null, u = !t && typeof window < "u" && window.origin === "null", l = typeof __webpack_require__ < "u", a = typeof window < "u" && window?.location?.protocol === "chrome-extension:", i = () => "production", n = i(), d = n === "development", r = n === "playground", c = n === "staging", p = c || d || r, g = p || s && n === "production";
1
+ import { toEnumValue as d } from "../functions/utils/enum.utils.mjs";
2
+ var s = /* @__PURE__ */ ((e) => (e.DEVELOPMENT = "development", e.PLAYGROUND = "playground", e.PRODUCTION = "production", e.STAGING = "staging", e))(s || {});
3
+ const t = {
4
+ development: ["localhost", "192.", "127."],
5
+ playground: ["playground"],
6
+ staging: ["working", "staging"]
7
+ }, r = typeof process < "u" && process?.release?.name === "node", p = typeof process < "u" && process.versions != null && process.versions.node != null, v = !p && typeof window < "u" && window.origin === "null", w = typeof __webpack_require__ < "u", D = typeof window < "u" && window?.location?.protocol === "chrome-extension:";
8
+ function i(e, n) {
9
+ return n.some((c) => e.includes(c));
10
+ }
11
+ const u = () => (require("dotenv").config({
12
+ // allow overriding .env file path, see startServer.sh script for explenation on why it is needed
13
+ path: "DOTENV_OVERRIDE" in process.env ? process.env.DOTENV_OVERRIDE : void 0
14
+ }), d(s, process.env.DEPLOYMENT_MODE) || "development"), l = () => {
15
+ if (!r && typeof window > "u")
16
+ return;
17
+ if (r)
18
+ return u();
19
+ if (window?.location?.protocol === "chrome-extension:") {
20
+ const n = d(s, WALLET_DEPLOYMENT_MODE);
21
+ return n || "staging";
22
+ }
23
+ const e = window?.location?.host;
24
+ return i(e, t.development) ? "development" : i(e, t.playground) ? "playground" : i(e, t.staging) ? "staging" : "production";
25
+ }, o = l(), g = o === "development", a = o === "playground", f = o === "staging", m = f || g || a, E = m || r && o === "production";
3
26
  export {
4
- e as DEPLOYMENT_MODE,
5
- n as deploymentMode,
6
- d as isDevelopment,
7
- a as isExtension,
8
- t as isNode,
9
- g as isNotClientProduction,
10
- p as isNotProduction,
11
- r as isPlayground,
12
- u as isSandbox,
13
- c as isStaging,
14
- l as isWebpack
27
+ s as DEPLOYMENT_MODE,
28
+ o as deploymentMode,
29
+ g as isDevelopment,
30
+ D as isExtension,
31
+ p as isNode,
32
+ E as isNotClientProduction,
33
+ m as isNotProduction,
34
+ a as isPlayground,
35
+ v as isSandbox,
36
+ f as isStaging,
37
+ w as isWebpack
15
38
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../types/hinkal.types.cjs"),S=require("../../types/ethereum-network.types.cjs"),x=require("./hinkalCheckSolanaTokenRegistry.cjs"),m=require("../../functions/web3/functionCalls/accessTokenCalls.cjs"),W=require("../../functions/web3/events/getShieldedBalance.cjs"),w=require("../crypto-keys/keys.cjs"),I=require("./hinkalDeposit.cjs"),K=require("./hinkalDepositAndWithdraw.cjs"),A=require("./hinkalSolanaDeposit.cjs"),U=require("./hinkalSwap.cjs"),L=require("./hinkalWithdraw.cjs"),B=require("./hinkalWithdrawStuckUtxos.cjs"),N=require("./resetMerkleTrees.cjs"),M=require("../merkle-tree/MerkleTree.cjs");require("ethers");const R=require("../../error-handling/error-codes.constants.cjs"),F=require("../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const h=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 _=require("../../constants/vite.constants.cjs"),P=require("../../API/API.cjs");require("../../constants/token-data/index.cjs");require("../../constants/contracts.constants.cjs");const O=require("../../constants/kyc.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("../../API/tenderly.api.cjs");const j=require("../../functions/utils/reloadPage.cjs"),z=require("../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs"),$=require("./hinkalPrivateWallet.cjs"),J=require("../../functions/utils/cacheFunctions.cjs"),Q=require("../../functions/utils/cacheDevice.utils.cjs"),V=require("../../functions/web3/getContractMetadata.cjs"),X=require("./hinkalGetRecipientInfo.cjs"),Y=require("./hinkalApprove.cjs"),Z=require("./hinkalInsideTransact.cjs"),v=require("../../functions/web3/events/getApprovedBalance.cjs"),C=require("../../functions/web3/functionCalls/inHinkalApprovalCalls.cjs"),G=require("./hinkalSignSubAccount.cjs"),ee=require("./hinkalCheckTokenRegistry.cjs"),te=require("./hinkalActionReceive.cjs"),re=require("./hinkalActionFundApproveAndTransact.cjs"),ie=require("../TokenDBs/PrivateTokensDB.cjs");require("idb-keyval");const ae=require("../../functions/utils/erc20tokenFunctions.cjs");require("multiformats");const g=require("@solana/web3.js");require("@solana/spl-token");require("async-mutex");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");const E=require("../../functions/pre-transaction/solana.cjs");require("@coral-xyz/anchor");require("../../functions/utils/userAgent.cjs");require("../../functions/utils/mutexes.utils.cjs");require("node-forge");require("../../functions/web3/getTokenHolder.cjs");const ne=require("../../functions/private-wallet/emporium.helpers.cjs"),se=require("./hinkalProoflessDeposit.cjs"),oe=require("./hinkalProxySwap.cjs"),ce=require("./hinkalMultiSend.cjs"),he=require("./hinkalTransfer.cjs"),le=require("./hinkalProxyToPrivate.cjs"),de=require("./hinkalSolanaDepositAndWithdraw.cjs"),pe=require("./hinkalSolanaWithdraw.cjs"),ue=require("./hinkalSolanaTransfer.cjs"),ge=require("./hinkalSolanaSwap.cjs"),ke=require("./hinkalSolanaProxySend.cjs"),ve=require("./hinkalSolanaProxySwap.cjs"),D=require("./hinkalSolanaProxyShield.cjs"),H=require("../../functions/web3/fetchSolanaMerkleTreeRootHash.cjs");class ye{providerAdapter;userKeys;signingMessage="Login to Hinkal Protocol";privateTransferSigningMessage="Login to Hinkal's Private Transfer App";merkleTreeHinkal;merkleTreeAccessToken;nullifiers;encryptedOutputs;approvals;commitmentsSnapshotService;nullifierSnapshotService;accessTokenSnapshotService;approvalsSnapshotService;utxoUtils;cacheDevice;generateProofRemotely;disableMerkleTreeUpdates;constructor(e){this.userKeys=new w.UserKeys(void 0),this.merkleTreeHinkal=M.MerkleTree.create(F.poseidonFunction,0n),this.merkleTreeAccessToken=M.MerkleTree.create(F.poseidonFunction,0n),this.nullifiers=new Set,this.encryptedOutputs=[],this.approvals=new Map,this.generateProofRemotely=e?.generateProofRemotely??!1,this.utxoUtils=new z.MultiThreadedUtxoUtils,this.cacheDevice=Q.createCacheDevice(e),this.disableMerkleTreeUpdates=e?.disableMerkleTreeUpdates??!1}async initProviderAdapter(e,t){await this.updateProviderAdapter(t),this.providerAdapter?.initConnector(e);const r=await this.connectAndPatchProvider(e);await t.init(r),await this.setListeners()}async initUserKeys(e=!1){const t=e?this.privateTransferSigningMessage:this.signingMessage;this.userKeys=new w.UserKeys(await this.getProviderAdapter().signMessage(t))}async initUserKeysWithPassword(e){this.userKeys=new w.UserKeys(e)}async resetMerkle(){this.disableMerkleTreeUpdates||this.isSelectedNetworkSupported()&&await N.resetMerkleTrees(this)}getProviderAdapter(){if(!this.providerAdapter)throw new Error("ProviderAdapter is not initialized");return this.providerAdapter}async waitForTransaction(e,t=1){return!!await this.providerAdapter?.waitForTransaction(e,t)}getContractMetadata(e,t){return this.getProviderAdapter().getContractMetadata(e,t)}getContract(e,t=void 0,r){return this.getProviderAdapter().getContract(e,t,r)}getContractWithFetcherByChainId(e,t,r=void 0){return V.getContractWithFetcherByChainId(e,t,r)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,t,r){return await this.getProviderAdapter().signTypedData(e,t,r)}async signWithSubAccount(e,t,r){return G.hinkalSignSubAccount(this,e,t,r)}getContractWithSigner(e,t=""){return this.getProviderAdapter().getContractWithSigner(e,t)}getContractWithFetcher(e,t=""){return this.getProviderAdapter().getContractWithFetcher(e,t)}getContractWithFetcherForEthereum(e,t){return this.getProviderAdapter().getContractWithFetcherForEthereum(e,t)}isSelectedNetworkSupported(){return!!h.networkRegistry[this.getCurrentChainId()]}async switchNetwork(e){try{await this.getProviderAdapter().switchNetwork(e)}catch{throw new Error(R.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}async switchAccount(e){await this.getProviderAdapter().switchAccount(e)}getCurrentChainId(){const{chainId:e}=this.getProviderAdapter();if(!e)throw new Error("Illegal State: no chainId");return e}getSelectedNetwork(){return this.providerAdapter?.getSelectedNetwork()}isPermitterAvailable(){return this.getProviderAdapter().isPermitterAvailable()}async connectAndPatchProvider(e){return await this.getProviderAdapter().connectAndPatchProvider(e)}async disconnectFromConnector(){await this.getProviderAdapter().disconnectFromConnector()}async updateProviderAdapter(e){try{this.providerAdapter&&this.providerAdapter.release(),this.providerAdapter=e}catch(t){throw console.error(t),Error("updateProviderAdapter failed, please try again.")}}async setListeners(){this.providerAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}})}async onAccountChanged(){await this.getProviderAdapter().onAccountChanged();const e=T.EventType.AccountChanged;typeof document<"u"?document?.dispatchEvent(new Event(e)):process?.emit("message",e,void 0)}async onChainChanged(e){if(e){await this.getProviderAdapter().onChainChanged(e);const t=T.EventType.NetworkChange;typeof document<"u"?document.dispatchEvent(new Event(t)):process?.emit("message",t,void 0)}else await this.disconnectFromConnector(),j.reloadPage()}async monitorConnectedAddress(){const e=this.getCurrentChainId();h.isSolanaLike(e)||await P.API.monitor(await this.getEthereumAddress(),e)}async getBalances(e,t,r,i,a=!1,s,n=!1){return W.getShieldedBalance(this,e,t,r,i,a,this.generateProofRemotely,s,n)}async getApprovedBalances(e=!1,t=!1){return v.getApprovedBalance(this,e,t)}async getTotalBalance(e,t,r,i=!1,a,s=!1){const n=e??this.getCurrentChainId(),o=r??await this.getEthereumAddress(),c=t??this.userKeys,d=await this.getBalances(n,c.getShieldedPrivateKey(),c.getShieldedPublicKey(),o,i,a,s),p=!h.isSolanaLike(n)&&!s?await this.getApprovedBalances(i,a):new Map,l=_.isExtension?await ie.privateTokensDB.getPrivateTokens(n,o):ae.getErc20TokensForChain(n),u=[];return l.forEach(k=>{const f=k.erc20TokenAddress.toLowerCase(),y=d.get(f),q=p.get(f),b={token:k,balance:(y?.balance??0n)+(q?.balance??0n),timestamp:y?.timestamp||q?.timestamp||"0",nfts:y?.nfts||[]};u.push(b)}),u}async getStuckShieldedBalances(e,t){return(await this.getTotalBalance(e,void 0,t,!1,!1,!0)).filter(i=>i.balance>0n)}getSupportedPassportLinks(){return O.supportedPassportLinks}checkAccessToken(){return m.checkHinkalAccessToken(this)}async mintHinkalAccessToken(e,t){return m.mintAccessToken(this,e,t)}async getHinkalTreeRootHash(){const e=this.getCurrentChainId();if(h.isSolanaLike(e)){const{hinkalIdl:r,hinkalAddress:i,originalDeployer:a}=h.networkRegistry[e].contractData;if(!r||!i||!a)throw new Error(`Missing Solana configuration for chain ${e}`);const s=new g.PublicKey(a),n=new g.PublicKey(i),o=E.getMerkleAccountPublicKey(n,s),c=this.getSolanaProgram(r);return H.fetchSolanaMerkleTreeRootHash(c,o)}return this.getContractWithFetcher(S.ContractType.HinkalContract).getRootHash()}async getAccessTokenTreeRootHash(){const e=this.getCurrentChainId();if(h.isSolanaLike(e)){const{hinkalIdl:r,hinkalAddress:i,originalDeployer:a}=h.networkRegistry[e].contractData;if(!r||!i||!a)throw new Error(`Missing Solana configuration for chain ${e}`);const s=new g.PublicKey(a),n=new g.PublicKey(i),o=E.getAccessTokenMerkleAccountPublicKey(n,s),c=this.getSolanaProgram(r);return H.fetchSolanaMerkleTreeRootHash(c,o)}return this.getContractWithFetcher(S.ContractType.AccessTokenContract).getRootHash()}async resetMerkleTreesIfNecessary(){if(!this.isSelectedNetworkSupported())throw new Error(R.transactionErrorCodes.UNSUPPORTED_NETWORK);const[e,t]=await Promise.all([this.getHinkalTreeRootHash(),this.getAccessTokenTreeRootHash()]);(e.toBigInt()!==this.merkleTreeHinkal.getRootHash()||t.toBigInt()!==this.merkleTreeAccessToken.getRootHash())&&(console.log("resetting merkle tree in resetMerkleTreesIfNecessary"),await this.resetMerkle())}async getEventsFromHinkal(){await Promise.all([this.accessTokenSnapshotService?.retrieveEventsFromLatestBlock(),this.commitmentsSnapshotService?.retrieveEventsFromLatestBlock(),this.nullifierSnapshotService?.retrieveEventsFromLatestBlock(),this.approvalsSnapshotService?.retrieveEventsFromLatestBlock()])}getEthereumAddress(){return this.getProviderAdapter().getAddress()}async getRandomRelay(e=!1){const t=this.getCurrentChainId();return(await P.API.getIdleRelay(t,e)).relay}getGasPrice(){if(!this.providerAdapter?.chainId)throw new Error("Illegal State of providerAdapter in Hinkal: no chainId");return this.providerAdapter.getGasPrice()}getAPI(){return P.API}resetCache(){J.resetCache(this,this.getCurrentChainId(),this.userKeys.getShieldedPublicKey())}snapshotsClearInterval(){this.commitmentsSnapshotService?.intervalClear(),this.accessTokenSnapshotService?.intervalClear(),this.nullifierSnapshotService?.intervalClear(),this.approvalsSnapshotService?.intervalClear()}checkTokenRegistry(e,t){const r=this.getCurrentChainId();if(h.isSolanaLike(r)){const{hinkalIdl:a,hinkalAddress:s,originalDeployer:n}=h.networkRegistry[r].contractData;if(!a||!s||!n)throw new Error("missing solana data");const o=this.getSolanaProgram(a),c=new g.PublicKey(n);return x.hinkalCheckSolanaTokenRegistry(o,c,e,t)}const i=this.getContractWithFetcher(S.ContractType.HinkalHelperContract);return ee.hinkalCheckTokenRegistry(i,e,t)}getRecipientInfo(){return X.getRecipientInfo(this)}async getInteractionApprovals(e){return await C.getInteractionApprovals(this,e)}getApprovedUtxos(e=!1){return v.getApprovedUtxos(this,e)}getApprovedUtxosForToken(e,t=!1){return v.getApprovedUtxosForToken(this,e,t)}getMyApprovalAmountForInteraction(e,t){return v.getMyApprovalAmountForInteraction(this,e,t)}async checkExistingApprovalFromHinkal(e,t){return await C.checkExistingApprovalFromHinkal(this,e,t)}async getBufferEntry(e,t,r){return C.getBufferEntry(this,e,t,r)}async deposit(e,t){return I.hinkalDeposit(this,e,t)}async depositForOther(e,t,r){return I.hinkalDepositForOther(this,e,t,r)}async depositAndWithdraw(e,t,r,i,a){return h.isSolanaLike(this.getCurrentChainId())?de.hinkalSolanaDepositAndWithdraw(this,e.erc20TokenAddress,t,r,i,a):K.hinkalDepositAndWithdraw(this,e,t,r,i,a)}async prooflessDeposit(e,t,r){return se.hinkalProoflessDeposit(this,e,t,r)}getSolanaProgram(e){if(!this.providerAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaProgram"in this.providerAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.providerAdapter.getSolanaProgram(e)}getSolanaPublicKey(){if(!this.providerAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaPublicKey"in this.providerAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.providerAdapter.getSolanaPublicKey()}async depositSolana(e,t){return A.hinkalSolanaDeposit(this,e,t)}async depositSolanaForOther(e,t,r){return A.hinkalSolanaDepositForOther(this,e,t,r)}async solanaMultiPaymentDeposit(e,t){return A.hinkalSolanaMultiPaymentDeposit(this,e,t)}async transfer(e,t,r,i,a,s,n=!1){return h.isSolanaLike(this.getCurrentChainId())?ue.hinkalSolanaTransfer(this,e,t,r,i,a,n):he.hinkalTransfer(this,e,t,r,i,a,s,n)}async withdraw(e,t,r,i,a,s,n,o=!1){return h.isSolanaLike(this.getCurrentChainId())?pe.hinkalSolanaWithdraw(this,e.map(c=>c.erc20TokenAddress),t,r,a,s,o):L.hinkalWithdraw(this,e,t,r,i,a,s,n,o)}async withdrawStuckUtxos(e,t,r){return B.hinkalWithdrawStuckUtxos(this,e,t,r)}async swap(e,t,r,i,a,s,n,o=!1,c=!1){return h.isSolanaLike(this.getCurrentChainId())?this.swapSolana(e,t,i,a,s,o):U.hinkalSwap(this,e,t,r,i,a,s,n,o,c)}async swapSolana(e,t,r,i,a,s=!1){const n=JSON.parse(r),{instructionLists:o,addressLookupTableAccount:c}=n.data;return ge.hinkalSolanaSwap(this,e,t,o,c,i,a,s)}async actionReceive(e,t,r,i,a,s,n=!1){if(!a)throw new Error("subAccount is required");return h.isSolanaLike(this.getCurrentChainId())?D.hinkalSolanaProxyShield(this,e[0],t[0],a,void 0,n):te.hinkalActionReceive(this,e,t,r,i,a,s,n)}async actionFundApproveAndTransact(e,t,r,i,a,s,n,o,c=!1,d,p,l){return re.hinkalActionFundApproveAndTransact(this,e,t,r,i,a,s,n,o,c,d,p,l)}async actionPrivateWallet(e,t,r,i,a,s,n,o,c,d=!1,p,l,u,k=!1){return $.hinkalPrivateWallet(this,e,t,r,i,a,s,n,o,c,d,p,l,u,k)}async approve(e,t,r,i,a,s=!1){return Y.hinkalApprove(this,e,t,r,i,a,s)}async hinkalInsideTransact(e,t,r,i,a,s,n,o,c,d=!1){return Z.hinkalInsideTransact(this,e,t,r,i,a,s,n,o,c,d)}async proxySwap(e,t,r,i,a,s,n,o,c=!1,d,p,l=!1){return h.isSolanaLike(this.getCurrentChainId())?ve.hinkalSolanaProxySwap(this,e,t,i,s,n,o,l):oe.hinkalProxySwap(this,e,t,r,i,a,s,n,o,c,d,p,l)}async proxyToPrivate(e,t,r,i,a,s,n,o=!1){return h.isSolanaLike(this.getCurrentChainId())?D.hinkalSolanaProxyShield(this,e[0],t[0],r,i,o):le.hinkalProxyToPrivate(this,e,t,i,a,s,r,n,o)}async proxySend(e,t,r,i,a,s,n,o=!1){if(h.isSolanaLike(this.getCurrentChainId()))return ke.hinkalSolanaProxySend(this,e[0],t[0],r,i,o);const c=ne.createTransaferEmporiumOpsBatch(this,e.map(l=>l.erc20TokenAddress),t,i),d=e.map((l,u)=>({token:l,amount:-1n*t[u]}));return await this.actionPrivateWallet([],[],[],c,d,r,a,s,void 0,void 0,void 0,n,void 0,o)}async multiSendPrivateRecipients(e,t,r){return ce.hinkalMultiSendPrivateRecipients(this,e,t,r)}areMerkleTreeUpdatesDisabled(){return this.disableMerkleTreeUpdates}updateMerkleTreeUpdates(e){this.disableMerkleTreeUpdates=e}}exports.Hinkal=ye;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../types/hinkal.types.cjs"),S=require("../../types/ethereum-network.types.cjs"),x=require("./hinkalCheckSolanaTokenRegistry.cjs"),m=require("../../functions/web3/functionCalls/accessTokenCalls.cjs"),W=require("../../functions/web3/events/getShieldedBalance.cjs"),w=require("../crypto-keys/keys.cjs"),I=require("./hinkalDeposit.cjs"),K=require("./hinkalDepositAndWithdraw.cjs"),A=require("./hinkalSolanaDeposit.cjs"),U=require("./hinkalSwap.cjs"),L=require("./hinkalWithdraw.cjs"),B=require("./hinkalWithdrawStuckUtxos.cjs"),N=require("./resetMerkleTrees.cjs"),M=require("../merkle-tree/MerkleTree.cjs");require("ethers");const R=require("../../error-handling/error-codes.constants.cjs"),F=require("../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const h=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 _=require("../../constants/vite.constants.cjs"),P=require("../../API/API.cjs");require("../../constants/token-data/index.cjs");require("../../constants/contracts.constants.cjs");const O=require("../../constants/kyc.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("../../API/tenderly.api.cjs");const j=require("../../functions/utils/reloadPage.cjs"),z=require("../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs"),$=require("./hinkalPrivateWallet.cjs"),J=require("../../functions/utils/cacheFunctions.cjs"),Q=require("../../functions/utils/cacheDevice.utils.cjs"),V=require("../../functions/web3/getContractMetadata.cjs"),X=require("./hinkalGetRecipientInfo.cjs"),Y=require("./hinkalApprove.cjs"),Z=require("./hinkalInsideTransact.cjs"),v=require("../../functions/web3/events/getApprovedBalance.cjs"),C=require("../../functions/web3/functionCalls/inHinkalApprovalCalls.cjs"),G=require("./hinkalSignSubAccount.cjs"),ee=require("./hinkalCheckTokenRegistry.cjs"),te=require("./hinkalActionReceive.cjs"),re=require("./hinkalActionFundApproveAndTransact.cjs"),ie=require("../TokenDBs/PrivateTokensDB.cjs");require("idb-keyval");const ae=require("../../functions/utils/erc20tokenFunctions.cjs");require("multiformats");const g=require("@solana/web3.js");require("@solana/spl-token");require("async-mutex");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");const E=require("../../functions/pre-transaction/solana.cjs");require("@coral-xyz/anchor");require("../../functions/utils/userAgent.cjs");require("../../functions/utils/mutexes.utils.cjs");require("node-forge");require("../../functions/web3/getTokenHolder.cjs");const ne=require("../../functions/private-wallet/emporium.helpers.cjs"),se=require("./hinkalProoflessDeposit.cjs"),oe=require("./hinkalProxySwap.cjs"),ce=require("./hinkalMultiSend.cjs"),he=require("./hinkalTransfer.cjs"),le=require("./hinkalProxyToPrivate.cjs"),de=require("./hinkalSolanaDepositAndWithdraw.cjs"),pe=require("./hinkalSolanaWithdraw.cjs"),ue=require("./hinkalSolanaTransfer.cjs"),ge=require("./hinkalSolanaSwap.cjs"),ke=require("./hinkalSolanaProxySend.cjs"),ve=require("./hinkalSolanaProxySwap.cjs"),D=require("./hinkalSolanaProxyShield.cjs"),H=require("../../functions/web3/fetchSolanaMerkleTreeRootHash.cjs");class ye{providerAdapter;userKeys;signingMessage="Login to Hinkal Protocol";privateTransferSigningMessage="Login to Hinkal's Private Transfer App";merkleTreeHinkal;merkleTreeAccessToken;nullifiers;encryptedOutputs;approvals;commitmentsSnapshotService;nullifierSnapshotService;accessTokenSnapshotService;approvalsSnapshotService;utxoUtils;cacheDevice;generateProofRemotely;disableMerkleTreeUpdates;constructor(e){this.userKeys=new w.UserKeys(void 0),this.merkleTreeHinkal=M.MerkleTree.create(F.poseidonFunction,0n),this.merkleTreeAccessToken=M.MerkleTree.create(F.poseidonFunction,0n),this.nullifiers=new Set,this.encryptedOutputs=[],this.approvals=new Map,this.generateProofRemotely=e?.generateProofRemotely??!1,this.utxoUtils=new z.MultiThreadedUtxoUtils,this.cacheDevice=Q.createCacheDevice(e),this.disableMerkleTreeUpdates=e?.disableMerkleTreeUpdates??!1}async initProviderAdapter(e,t){await this.updateProviderAdapter(t),this.providerAdapter?.initConnector(e);const r=await this.connectAndPatchProvider(e);await t.init(r),await this.setListeners()}async initUserKeys(e=!1){const t=e?this.privateTransferSigningMessage:this.signingMessage;this.userKeys=new w.UserKeys(await this.getProviderAdapter().signMessage(t))}async initUserKeysWithPassword(e){this.userKeys=new w.UserKeys(e)}async resetMerkle(){this.disableMerkleTreeUpdates||this.isSelectedNetworkSupported()&&await N.resetMerkleTrees(this)}getProviderAdapter(){if(!this.providerAdapter)throw new Error("ProviderAdapter is not initialized");return this.providerAdapter}async waitForTransaction(e,t=1){return!!await this.providerAdapter?.waitForTransaction(e,t)}getContractMetadata(e,t){return this.getProviderAdapter().getContractMetadata(e,t)}getContract(e,t=void 0,r){return this.getProviderAdapter().getContract(e,t,r)}getContractWithFetcherByChainId(e,t,r=void 0){return V.getContractWithFetcherByChainId(e,t,r)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,t,r){return await this.getProviderAdapter().signTypedData(e,t,r)}async signWithSubAccount(e,t,r){return G.hinkalSignSubAccount(this,e,t,r)}getContractWithSigner(e,t=""){return this.getProviderAdapter().getContractWithSigner(e,t)}getContractWithFetcher(e,t=""){return this.getProviderAdapter().getContractWithFetcher(e,t)}getContractWithFetcherForEthereum(e,t){return this.getProviderAdapter().getContractWithFetcherForEthereum(e,t)}isSelectedNetworkSupported(){return!!h.networkRegistry[this.getCurrentChainId()]}async switchNetwork(e){try{await this.getProviderAdapter().switchNetwork(e)}catch{throw new Error(R.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}async switchAccount(e){await this.getProviderAdapter().switchAccount(e)}getCurrentChainId(){const{chainId:e}=this.getProviderAdapter();if(!e)throw new Error("Illegal State: no chainId");return e}getSelectedNetwork(){return this.providerAdapter?.getSelectedNetwork()}isPermitterAvailable(){return this.getProviderAdapter().isPermitterAvailable()}async connectAndPatchProvider(e){return await this.getProviderAdapter().connectAndPatchProvider(e)}async disconnectFromConnector(){await this.getProviderAdapter().disconnectFromConnector()}async updateProviderAdapter(e){try{this.providerAdapter&&this.providerAdapter.release(),this.providerAdapter=e}catch(t){throw console.error(t),Error("updateProviderAdapter failed, please try again.")}}async setListeners(){this.providerAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}})}async onAccountChanged(){await this.getProviderAdapter().onAccountChanged();const e=T.EventType.AccountChanged;typeof document<"u"?document?.dispatchEvent(new Event(e)):process?.emit("message",e,void 0)}async onChainChanged(e){if(e){await this.getProviderAdapter().onChainChanged(e);const t=T.EventType.NetworkChange;typeof document<"u"?document.dispatchEvent(new Event(t)):process?.emit("message",t,void 0)}else await this.disconnectFromConnector(),j.reloadPage()}async monitorConnectedAddress(){const e=this.getCurrentChainId();h.isSolanaLike(e)||await P.API.monitor(await this.getEthereumAddress(),e)}async getBalances(e,t,r,i,a=!1,s,n=!1){return W.getShieldedBalance(this,e,t,r,i,a,this.generateProofRemotely,s,n)}async getApprovedBalances(e=!1,t=!1){return v.getApprovedBalance(this,e,t)}async getTotalBalance(e,t,r,i=!1,a,s=!1){const n=e??this.getCurrentChainId(),o=r??await this.getEthereumAddress(),c=t??this.userKeys,d=await this.getBalances(n,c.getShieldedPrivateKey(),c.getShieldedPublicKey(),o,i,a,s),p=!h.isSolanaLike(n)&&!s?await this.getApprovedBalances(i,a):new Map,l=_.isExtension?await ie.privateTokensDB.getPrivateTokens(n,o):ae.getErc20TokensForChain(n),u=[];return l.forEach(k=>{const f=k.erc20TokenAddress.toLowerCase(),y=d.get(f),q=p.get(f),b={token:k,balance:(y?.balance??0n)+(q?.balance??0n),timestamp:y?.timestamp||q?.timestamp||"0",nfts:y?.nfts||[]};u.push(b)}),u}async getStuckShieldedBalances(e,t){return(await this.getTotalBalance(e,void 0,t,!1,!1,!0)).filter(i=>i.balance>0n)}getSupportedPassportLinks(){return O.supportedPassportLinks}checkAccessToken(){return m.checkHinkalAccessToken(this)}async mintHinkalAccessToken(e,t){return m.mintAccessToken(this,e,t)}async getHinkalTreeRootHash(){const e=this.getCurrentChainId();if(h.isSolanaLike(e)){const{hinkalIdl:r,hinkalAddress:i,originalDeployer:a}=h.networkRegistry[e].contractData;if(!r||!i||!a)throw new Error(`Missing Solana configuration for chain ${e}`);const s=new g.PublicKey(a),n=new g.PublicKey(i),o=E.getMerkleAccountPublicKey(n,s),c=this.getSolanaProgram(r);return H.fetchSolanaMerkleTreeRootHash(c,o)}return this.getContractWithFetcher(S.ContractType.HinkalContract).getRootHash()}async getAccessTokenTreeRootHash(){const e=this.getCurrentChainId();if(h.isSolanaLike(e)){const{hinkalIdl:r,hinkalAddress:i,originalDeployer:a}=h.networkRegistry[e].contractData;if(!r||!i||!a)throw new Error(`Missing Solana configuration for chain ${e}`);const s=new g.PublicKey(a),n=new g.PublicKey(i),o=E.getAccessTokenMerkleAccountPublicKey(n,s),c=this.getSolanaProgram(r);return H.fetchSolanaMerkleTreeRootHash(c,o)}return this.getContractWithFetcher(S.ContractType.AccessTokenContract).getRootHash()}async resetMerkleTreesIfNecessary(){if(!this.isSelectedNetworkSupported())throw new Error(R.transactionErrorCodes.UNSUPPORTED_NETWORK);const[e,t]=await Promise.all([this.getHinkalTreeRootHash(),this.getAccessTokenTreeRootHash()]);(e.toBigInt()!==this.merkleTreeHinkal.getRootHash()||t.toBigInt()!==this.merkleTreeAccessToken.getRootHash())&&(console.log("resetting merkle tree in resetMerkleTreesIfNecessary"),await this.resetMerkle())}async getEventsFromHinkal(){await Promise.all([this.accessTokenSnapshotService?.retrieveEventsFromLatestBlock(),this.commitmentsSnapshotService?.retrieveEventsFromLatestBlock(),this.nullifierSnapshotService?.retrieveEventsFromLatestBlock(),this.approvalsSnapshotService?.retrieveEventsFromLatestBlock()])}getEthereumAddress(){return this.getProviderAdapter().getAddress()}async getRandomRelay(e=!1){const t=this.getCurrentChainId();return(await P.API.getIdleRelay(t,e)).relay}getGasPrice(){if(!this.providerAdapter?.chainId)throw new Error("Illegal State of providerAdapter in Hinkal: no chainId");return this.providerAdapter.getGasPrice()}getAPI(){return P.API}resetCache(){J.resetCache(this,this.getCurrentChainId(),this.userKeys.getShieldedPublicKey())}snapshotsClearInterval(){this.commitmentsSnapshotService?.intervalClear(),this.accessTokenSnapshotService?.intervalClear(),this.nullifierSnapshotService?.intervalClear(),this.approvalsSnapshotService?.intervalClear()}checkTokenRegistry(e,t){const r=this.getCurrentChainId();if(h.isSolanaLike(r)){const{hinkalIdl:a,hinkalAddress:s,originalDeployer:n}=h.networkRegistry[r].contractData;if(!a||!s||!n)throw new Error("missing solana data");const o=this.getSolanaProgram(a),c=new g.PublicKey(n);return x.hinkalCheckSolanaTokenRegistry(o,c,e,t)}const i=this.getContractWithFetcher(S.ContractType.HinkalHelperContract);return ee.hinkalCheckTokenRegistry(i,e,t)}getRecipientInfo(){return X.getRecipientInfo(this)}async getInteractionApprovals(e){return await C.getInteractionApprovals(this,e)}getApprovedUtxos(e=!1){return v.getApprovedUtxos(this,e)}getApprovedUtxosForToken(e,t=!1){return v.getApprovedUtxosForToken(this,e,t)}getMyApprovalAmountForInteraction(e,t){return v.getMyApprovalAmountForInteraction(this,e,t)}async checkExistingApprovalFromHinkal(e,t){return await C.checkExistingApprovalFromHinkal(this,e,t)}async getBufferEntry(e,t,r){return C.getBufferEntry(this,e,t,r)}async deposit(e,t){return I.hinkalDeposit(this,e,t)}async depositForOther(e,t,r){return I.hinkalDepositForOther(this,e,t,r)}async depositAndWithdraw(e,t,r,i,a){return h.isSolanaLike(this.getCurrentChainId())?de.hinkalSolanaDepositAndWithdraw(this,e.erc20TokenAddress,t,r,i,a):K.hinkalDepositAndWithdraw(this,e,t,r,i,a)}async prooflessDeposit(e,t,r){return se.hinkalProoflessDeposit(this,e,t,r)}getSolanaProgram(e){if(!this.providerAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaProgram"in this.providerAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.providerAdapter.getSolanaProgram(e)}getSolanaPublicKey(){if(!this.providerAdapter)throw new Error("No provider adapter initialized");if(!("getSolanaPublicKey"in this.providerAdapter))throw new Error("Current provider adapter is not a Solana provider adapter");return this.providerAdapter.getSolanaPublicKey()}async depositSolana(e,t){return A.hinkalSolanaDeposit(this,e,t)}async depositSolanaForOther(e,t,r){return A.hinkalSolanaDepositForOther(this,e,t,r)}async solanaMultiPaymentDeposit(e,t){return A.hinkalSolanaMultiPaymentDeposit(this,e,t)}async transfer(e,t,r,i,a,s,n=!1){return h.isSolanaLike(this.getCurrentChainId())?ue.hinkalSolanaTransfer(this,e,t,r,i,a,n):he.hinkalTransfer(this,e,t,r,i,a,s,n)}async withdraw(e,t,r,i,a,s,n,o=!1){return h.isSolanaLike(this.getCurrentChainId())?pe.hinkalSolanaWithdraw(this,e.map(c=>c.erc20TokenAddress),t,r,a,s,o):L.hinkalWithdraw(this,e,t,r,i,a,s,n,o)}async withdrawStuckUtxos(e,t){return B.hinkalWithdrawStuckUtxos(this,e,t)}async swap(e,t,r,i,a,s,n,o=!1,c=!1){return h.isSolanaLike(this.getCurrentChainId())?this.swapSolana(e,t,i,a,s,o):U.hinkalSwap(this,e,t,r,i,a,s,n,o,c)}async swapSolana(e,t,r,i,a,s=!1){const n=JSON.parse(r),{instructionLists:o,addressLookupTableAccount:c}=n.data;return ge.hinkalSolanaSwap(this,e,t,o,c,i,a,s)}async actionReceive(e,t,r,i,a,s,n=!1){if(!a)throw new Error("subAccount is required");return h.isSolanaLike(this.getCurrentChainId())?D.hinkalSolanaProxyShield(this,e[0],t[0],a,void 0,n):te.hinkalActionReceive(this,e,t,r,i,a,s,n)}async actionFundApproveAndTransact(e,t,r,i,a,s,n,o,c=!1,d,p,l){return re.hinkalActionFundApproveAndTransact(this,e,t,r,i,a,s,n,o,c,d,p,l)}async actionPrivateWallet(e,t,r,i,a,s,n,o,c,d=!1,p,l,u,k=!1){return $.hinkalPrivateWallet(this,e,t,r,i,a,s,n,o,c,d,p,l,u,k)}async approve(e,t,r,i,a,s=!1){return Y.hinkalApprove(this,e,t,r,i,a,s)}async hinkalInsideTransact(e,t,r,i,a,s,n,o,c,d=!1){return Z.hinkalInsideTransact(this,e,t,r,i,a,s,n,o,c,d)}async proxySwap(e,t,r,i,a,s,n,o,c=!1,d,p,l=!1){return h.isSolanaLike(this.getCurrentChainId())?ve.hinkalSolanaProxySwap(this,e,t,i,s,n,o,l):oe.hinkalProxySwap(this,e,t,r,i,a,s,n,o,c,d,p,l)}async proxyToPrivate(e,t,r,i,a,s,n,o=!1){return h.isSolanaLike(this.getCurrentChainId())?D.hinkalSolanaProxyShield(this,e[0],t[0],r,i,o):le.hinkalProxyToPrivate(this,e,t,i,a,s,r,n,o)}async proxySend(e,t,r,i,a,s,n,o=!1){if(h.isSolanaLike(this.getCurrentChainId()))return ke.hinkalSolanaProxySend(this,e[0],t[0],r,i,o);const c=ne.createTransaferEmporiumOpsBatch(this,e.map(l=>l.erc20TokenAddress),t,i),d=e.map((l,u)=>({token:l,amount:-1n*t[u]}));return await this.actionPrivateWallet([],[],[],c,d,r,a,s,void 0,void 0,void 0,n,void 0,o)}async multiSendPrivateRecipients(e,t,r){return ce.hinkalMultiSendPrivateRecipients(this,e,t,r)}areMerkleTreeUpdatesDisabled(){return this.disableMerkleTreeUpdates}updateMerkleTreeUpdates(e){this.disableMerkleTreeUpdates=e}}exports.Hinkal=ye;
@@ -102,7 +102,7 @@ export declare class Hinkal<ConnectorType> implements IHinkal {
102
102
  solanaMultiPaymentDeposit(amounts: bigint[], mintAddress: string): Promise<string>;
103
103
  transfer(erc20Tokens: ERC20Token[], amountChanges: bigint[], recipientAddress: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
104
104
  withdraw(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], recipientAddress: string, isRelayerOff: boolean, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<ethers.ContractTransaction | RelayerTransaction | bigint>;
105
- withdrawStuckUtxos(erc20Token: ERC20Token, recipientAddress: string, action?: AdminTransactionType): Promise<RelayerTransaction[]>;
105
+ withdrawStuckUtxos(erc20Token: ERC20Token, recipientAddress: string): Promise<RelayerTransaction[]>;
106
106
  swap(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], externalActionId: ExternalActionId, swapData: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean, withPrivateMempool?: boolean): Promise<RelayerTransaction | bigint>;
107
107
  swapSolana(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], swapData: string, feeToken?: string, feeStructureOverride?: FeeStructure, onlyGasEstimate?: boolean): Promise<RelayerTransaction>;
108
108
  actionReceive(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], feeToken?: string, feeStructureOverride?: FeeStructure, subAccount?: SubAccount, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
@@ -455,8 +455,8 @@ class sr {
455
455
  s
456
456
  );
457
457
  }
458
- async withdrawStuckUtxos(e, t, r) {
459
- return _(this, e, t, r);
458
+ async withdrawStuckUtxos(e, t) {
459
+ return _(this, e, t);
460
460
  }
461
461
  async swap(e, t, r, i, a, n, o, s = !1, c = !1) {
462
462
  return h(this.getCurrentChainId()) ? this.swapSolana(e, t, i, a, n, s) : L(
@@ -70,7 +70,7 @@ export interface IHinkal<ConnectorType = unknown> {
70
70
  depositSolanaForOther(amount: bigint, mintAddress: string, recipientInfo: string): Promise<string>;
71
71
  transfer(erc20Tokens: ERC20Token[], amountChanges: bigint[], recipientAddress: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
72
72
  withdraw(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], recipientAddress: string, isRelayerOff: boolean, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean): Promise<ethers.ContractTransaction | RelayerTransaction | bigint>;
73
- withdrawStuckUtxos(erc20Token: ERC20Token, recipientAddress: string, action?: AdminTransactionType): Promise<RelayerTransaction[]>;
73
+ withdrawStuckUtxos(erc20Token: ERC20Token, recipientAddress: string): Promise<RelayerTransaction[]>;
74
74
  swap(erc20Tokens: ERC20Token[], deltaAmounts: bigint[], externalActionId: ExternalActionId, swapData: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean, withPrivateMempool?: boolean): Promise<RelayerTransaction | bigint>;
75
75
  getProviderAdapter(): IProviderAdapter;
76
76
  initUserKeys(isPrivateTransfer?: boolean): Promise<void>;
@@ -1,3 +1,3 @@
1
1
  import { IHinkal } from './IHinkal';
2
2
  import { FeeStructure } from '../../types/hinkal.types';
3
- export declare const hinkalApprove: (hinkal: IHinkal, erc20Addresses: string[], approvalAmount: bigint, approvedTo: string, feeToken?: string, feeStructureOverride?: FeeStructure, onlyGasEstimate?: boolean) => Promise<bigint | import("../..").RelayerTransaction>;
3
+ export declare const hinkalApprove: (hinkal: IHinkal, erc20Addresses: string[], approvalAmount: bigint, approvedTo: string, feeToken?: string, feeStructureOverride?: FeeStructure, onlyGasEstimate?: boolean) => Promise<bigint | import('../../index.ts').RelayerTransaction>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("ethers"),b=require("../../constants/protocol.constants.cjs"),Z=require("../../error-handling/error-codes.constants.cjs"),$=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),K=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),L=require("../../functions/web3/events/getShieldedBalance.cjs"),N=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),j=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),O=require("../../types/external-action.types.cjs"),G=require("../utxo/Utxo.cjs");require("../../types/circom-data.types.cjs");const f=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");const _=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),H=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),V=require("../../functions/utils/time.utils.cjs"),X=require("../../functions/utils/getUtxosFromReceipt.utils.cjs"),Y=require("../../functions/pre-transaction/getFeeStructure.cjs"),J=require("../../functions/utils/fees.utils.cjs"),Q=require("../../API/unspent-utxos-calls.cjs"),ee=require("../../functions/utils/addresses.cjs"),te=async(e,r,n,l,p,h)=>{const s=r.erc20TokenAddress,o=n.map(t=>t+J.calculateTotalFee(t,p)),c=[s],a=[0n],i=[!0],{patchAccessTokenMerkleTree:m,kycRequired:d,hasAccessToken:v}=await H.shouldPatchAccessTokenMerkleTree(e,c,a),S=await _.getSignatureDataForTransact(e.getCurrentChainId(),await e.getEthereumAddress(),e.userKeys,d,v),u=[...await L.addPaddingToUtxos(e,c,a)],A=[];for(let t=0;t<u.length;t+=1){const{outputUtxos:C}=$.outputUtxoProcessing(e.userKeys,u[t],a[t]);A.push(C)}const E=o.reduce((t,C)=>t+C,0n),T=B.ethers.utils.defaultAbiCoder.encode(["uint256[]"],[o]),w=e.getContractWithSigner(f.ContractType.HinkalWrapper),y=e.getContractWithSigner(f.ContractType.DepositOnChainUtxos),{zkCallData:I,circomData:x,dimData:P}=await K.constructZkProof("v1x1",e.merkleTreeHinkal,e.merkleTreeAccessToken,u,A,e.userKeys,`swapperM1x${u[0].length}x1`,O.ExternalActionId.DepositOnChainUtxos,y.address,T,e.generateProofRemotely,b.zeroAddress,e.getCurrentChainId(),i,void 0,void 0,void 0,m,void 0,void 0,void 0,e.getContractWithFetcher(f.ContractType.HinkalHelperContract),S,w.address,!1),R=await(await N.transactCallDirect(e,E,r,I,x,P,y,w)).wait(),q=X.getUtxosFromReceipt(R,e,s),U=[],g=[...q];l.forEach((t,C)=>{const F=o[C],k=g.find(z=>z.amount===F);if(!k)throw new Error(`Could not find newly created UTXO with amount ${F} for recipient ${t}.`);U.push({recipientAddress:t,utxo:k});const W=g.indexOf(k);g.splice(W,1)});const D=e.getCurrentChainId();return await Q.storeUnspentUtxos(D,{hashedEthereumAddress:h,chainId:D,utxos:q}),U},re=async(e,r,n,l,p,h)=>{if(n.length===0)throw new Error("userDepositedUtxos must not be empty");const s=r.erc20TokenAddress,o=await e.getRandomRelay();if(!o)throw Error(Z.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const c=await e.getEthereumAddress(),a=V.getCurrentTimeInSeconds().toString(),i=e.generateProofRemotely?5:1,m=[];for(let d=0;d<n.length;d+=i){const v=n.slice(d,d+i),S=await Promise.all(v.map(async({recipientAddress:u,utxo:A})=>{const E=[-A.amount],T=new G.Utxo({amount:0n,erc20TokenAddress:s,shieldedPrivateKey:e.userKeys.getShieldedPrivateKey(),timeStamp:a,tokenId:0}),w=[[A,T]],y=[[T]],I=`swapperM1x${w[0].length}x1`,x={externalActionId:0n,externalAddress:u,externalActionMetadata:"0x00"},{patchAccessTokenMerkleTree:P,kycRequired:M,hasAccessToken:R}=await H.shouldPatchAccessTokenMerkleTree(e,[s],E),q=await _.getSignatureDataForTransact(e.getCurrentChainId(),c,e.userKeys,M,R),{zkCallData:U,circomData:g,dimData:D}=await K.constructZkProof("v1x1",e.merkleTreeHinkal,e.merkleTreeAccessToken,w,y,e.userKeys,I,x.externalActionId,x.externalAddress,x.externalActionMetadata,e.generateProofRemotely,o??b.zeroAddress,e.getCurrentChainId(),void 0,void 0,void 0,void 0,P,void 0,void 0,l,e.getContractWithFetcher(f.ContractType.HinkalHelperContract),q,void 0,!1);return{zkCallData:U,dimData:D,circomData:g}}));m.push(...S)}return j.transactCallRelayerBatch(e.getCurrentChainId(),m,p,h)},se=async(e,r,n,l,p,h)=>{const s=r.erc20TokenAddress,o=e.getCurrentChainId(),c=ee.hashEthereumAddress(await e.getEthereumAddress()),a=h??await Y.getFeeStructure(o,s,[s],O.ExternalActionId.Transact),i=await te(e,r,n,l,a,c);return re(e,r,i,a,c,p)};exports.hinkalDepositAndWithdraw=se;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("ethers"),F=require("../../constants/protocol.constants.cjs"),j=require("../../error-handling/error-codes.constants.cjs"),G=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),_=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),V=require("../../functions/web3/events/getShieldedBalance.cjs"),X=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),Y=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),K=require("../../types/external-action.types.cjs"),J=require("../utxo/Utxo.cjs");require("../../types/circom-data.types.cjs");const v=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");const H=require("../../types/admin.types.cjs");require("../../types/activities.types.cjs");const W=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),z=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),Q=require("../../functions/utils/time.utils.cjs"),tt=require("../../functions/utils/getUtxosFromReceipt.utils.cjs"),et=require("../../functions/pre-transaction/getFeeStructure.cjs"),rt=require("../../functions/utils/fees.utils.cjs"),st=require("../../API/unspent-utxos-calls.cjs"),ot=require("../../functions/utils/addresses.cjs"),B=require("../../functions/pre-transaction/constructAdminData.cjs"),nt=require("../../API/admin-calls.cjs"),at=async(t,o,i,p,m,A)=>{const r=o.erc20TokenAddress,d=await t.getEthereumAddress(),s=i.map(e=>e+rt.calculateTotalFee(e,m)),n=[r],a=[0n],w=[!0],{patchAccessTokenMerkleTree:u,kycRequired:I,hasAccessToken:P}=await z.shouldPatchAccessTokenMerkleTree(t,n,a),S=await W.getSignatureDataForTransact(t.getCurrentChainId(),d,t.userKeys,I,P),c=[...await V.addPaddingToUtxos(t,n,a)],T=[];for(let e=0;e<c.length;e+=1){const{outputUtxos:g}=G.outputUtxoProcessing(t.userKeys,c[e],a[e]);T.push(g)}const h=s.reduce((e,g)=>e+g,0n),y=N.ethers.utils.defaultAbiCoder.encode(["uint256[]"],[s]),D=t.getContractWithSigner(v.ContractType.HinkalWrapper),q=t.getContractWithSigner(v.ContractType.DepositOnChainUtxos),{zkCallData:C,circomData:E,dimData:R}=await _.constructZkProof("v1x1",t.merkleTreeHinkal,t.merkleTreeAccessToken,c,T,t.userKeys,`swapperM1x${c[0].length}x1`,K.ExternalActionId.DepositOnChainUtxos,q.address,y,t.generateProofRemotely,F.zeroAddress,t.getCurrentChainId(),w,void 0,void 0,void 0,u,void 0,void 0,void 0,t.getContractWithFetcher(v.ContractType.HinkalHelperContract),S,D.address,!1),k=await(await X.transactCallDirect(t,h,o,C,E,R,q,D)).wait(),U=tt.getUtxosFromReceipt(k,t,r),f=[],x=[...U];p.forEach((e,g)=>{const b=s[g],M=x.find(L=>L.amount===b);if(!M)throw new Error(`Could not find newly created UTXO with amount ${b} for recipient ${e}.`);f.push({recipientAddress:e,utxo:M});const $=x.indexOf(M);x.splice($,1)});const l=t.getCurrentChainId();await st.storeUnspentUtxos(l,{hashedEthereumAddress:A,chainId:l,utxos:U});const Z=B.constructAdminData(H.AdminTransactionType.DepositOnChainUtxos,l,n,[h],d);return nt.emitTxPublicData(l,Z),f},ct=async(t,o,i,p,m,A)=>{if(i.length===0)throw new Error("userDepositedUtxos must not be empty");const r=o.erc20TokenAddress,d=await t.getRandomRelay();if(!d)throw Error(j.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const s=await t.getEthereumAddress(),n=Q.getCurrentTimeInSeconds().toString(),a=t.generateProofRemotely?5:1,w=[];for(let u=0;u<i.length;u+=a){const I=i.slice(u,u+a),P=await Promise.all(I.map(async({recipientAddress:S,utxo:c})=>{const T=[-c.amount],h=new J.Utxo({amount:0n,erc20TokenAddress:r,shieldedPrivateKey:t.userKeys.getShieldedPrivateKey(),timeStamp:n,tokenId:0}),y=[[c,h]],D=[[h]],q=`swapperM1x${y[0].length}x1`,C={externalActionId:0n,externalAddress:S,externalActionMetadata:"0x00"},{patchAccessTokenMerkleTree:E,kycRequired:R,hasAccessToken:O}=await z.shouldPatchAccessTokenMerkleTree(t,[r],T),k=await W.getSignatureDataForTransact(t.getCurrentChainId(),s,t.userKeys,R,O),U=B.constructAdminData(H.AdminTransactionType.WithdrawOnChainUtxos,t.getCurrentChainId(),[r],[-c.amount],s),{zkCallData:f,circomData:x,dimData:l}=await _.constructZkProof("v1x1",t.merkleTreeHinkal,t.merkleTreeAccessToken,y,D,t.userKeys,q,C.externalActionId,C.externalAddress,C.externalActionMetadata,t.generateProofRemotely,d??F.zeroAddress,t.getCurrentChainId(),void 0,void 0,void 0,void 0,E,void 0,void 0,p,t.getContractWithFetcher(v.ContractType.HinkalHelperContract),k,void 0,!1);return{zkCallData:f,dimData:l,circomData:x,adminData:U}}));w.push(...P)}return Y.transactCallRelayerBatch(t.getCurrentChainId(),w,m,A)},it=async(t,o,i,p,m,A)=>{const r=o.erc20TokenAddress,d=t.getCurrentChainId(),s=ot.hashEthereumAddress(await t.getEthereumAddress()),n=A??await et.getFeeStructure(d,r,[r],K.ExternalActionId.Transact),a=await at(t,o,i,p,n,s);return ct(t,o,a,n,s,m)};exports.hinkalDepositAndWithdraw=it;