@hinkal/common 0.2.19 → 0.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. package/API/API.cjs +1 -1
  2. package/API/API.d.ts +6 -1
  3. package/API/API.mjs +48 -41
  4. package/API/enclaveCalls.cjs +1 -1
  5. package/API/enclaveCalls.mjs +5 -4
  6. package/API/index.d.ts +1 -0
  7. package/API/proxyAccountsCalls.cjs +1 -1
  8. package/API/proxyAccountsCalls.d.ts +7 -2
  9. package/API/proxyAccountsCalls.mjs +26 -20
  10. package/API/temporaryWalletCalls.cjs +1 -0
  11. package/API/temporaryWalletCalls.d.ts +13 -0
  12. package/API/temporaryWalletCalls.mjs +20 -0
  13. package/API/unspent-utxos-calls.cjs +1 -1
  14. package/API/unspent-utxos-calls.d.ts +1 -1
  15. package/API/unspent-utxos-calls.mjs +16 -14
  16. package/README.md +36 -13
  17. package/constants/chains.constants.cjs +1 -1
  18. package/constants/chains.constants.d.ts +1 -1
  19. package/constants/chains.constants.mjs +69 -51
  20. package/constants/deploy-data/deploy-data-solana.json.cjs +1 -1
  21. package/constants/deploy-data/deploy-data-solana.json.mjs +28 -2
  22. package/constants/kyc.constants.cjs +1 -1
  23. package/constants/kyc.constants.mjs +39 -40
  24. package/constants/mediaUrls.constants.cjs +1 -1
  25. package/constants/mediaUrls.constants.d.ts +1 -0
  26. package/constants/mediaUrls.constants.mjs +2 -1
  27. package/constants/server.constants.cjs +1 -1
  28. package/constants/server.constants.d.ts +6 -1
  29. package/constants/server.constants.mjs +37 -32
  30. package/constants/token-data/polygonRegistry.json.cjs +1 -1
  31. package/constants/token-data/polygonRegistry.json.mjs +4 -4
  32. package/constants/token-data/polygonRegistryFixed.json.cjs +1 -1
  33. package/constants/token-data/polygonRegistryFixed.json.mjs +4 -4
  34. package/data-structures/AccountActions/AccountActions.cjs +1 -0
  35. package/data-structures/AccountActions/AccountActions.d.ts +18 -0
  36. package/data-structures/AccountActions/AccountActions.mjs +78 -0
  37. package/data-structures/AccountActions/index.d.ts +1 -0
  38. package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
  39. package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +68 -71
  40. package/data-structures/BlockchainEvent/BlockchainEvent.cjs +1 -0
  41. package/data-structures/BlockchainEvent/BlockchainEvent.d.ts +14 -0
  42. package/data-structures/BlockchainEvent/BlockchainEvent.mjs +41 -0
  43. package/data-structures/Hinkal/Hinkal.cjs +1 -1
  44. package/data-structures/Hinkal/Hinkal.d.ts +14 -8
  45. package/data-structures/Hinkal/Hinkal.mjs +215 -179
  46. package/data-structures/Hinkal/IHinkal.d.ts +9 -6
  47. package/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
  48. package/data-structures/Hinkal/handleAutoDepositBack.mjs +47 -48
  49. package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
  50. package/data-structures/Hinkal/hinkalActionReceive.mjs +25 -22
  51. package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
  52. package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +12 -12
  53. package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
  54. package/data-structures/Hinkal/hinkalDeposit.mjs +63 -63
  55. package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
  56. package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +60 -147
  57. package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -0
  58. package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +4 -0
  59. package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +103 -0
  60. package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -0
  61. package/data-structures/Hinkal/hinkalDepostAndBridge.d.ts +4 -0
  62. package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +214 -0
  63. package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
  64. package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +4 -4
  65. package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
  66. package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +2 -2
  67. package/data-structures/Hinkal/hinkalPrivateWallet.mjs +103 -99
  68. package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
  69. package/data-structures/Hinkal/hinkalProxySwap.mjs +44 -41
  70. package/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
  71. package/data-structures/Hinkal/hinkalProxyToPrivate.mjs +31 -28
  72. package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -1
  73. package/data-structures/Hinkal/hinkalSignSubAccount.mjs +16 -13
  74. package/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
  75. package/data-structures/Hinkal/hinkalSolanaDeposit.mjs +34 -34
  76. package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
  77. package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +67 -65
  78. package/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
  79. package/data-structures/Hinkal/hinkalSolanaProxySend.mjs +35 -32
  80. package/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
  81. package/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +59 -56
  82. package/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
  83. package/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +35 -32
  84. package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
  85. package/data-structures/Hinkal/hinkalSolanaSwap.mjs +10 -10
  86. package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
  87. package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +25 -25
  88. package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
  89. package/data-structures/Hinkal/hinkalSwap.mjs +34 -30
  90. package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
  91. package/data-structures/Hinkal/hinkalTransfer.mjs +43 -39
  92. package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
  93. package/data-structures/Hinkal/hinkalWithdraw.mjs +47 -43
  94. package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
  95. package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +50 -46
  96. package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
  97. package/data-structures/Hinkal/resetMerkleTrees.mjs +36 -34
  98. package/data-structures/IndexedDB/activity-db.cjs +1 -1
  99. package/data-structures/IndexedDB/activity-db.d.ts +1 -0
  100. package/data-structures/IndexedDB/activity-db.mjs +86 -70
  101. package/data-structures/IndexedDB/balances-db.cjs +1 -1
  102. package/data-structures/IndexedDB/balances-db.mjs +33 -30
  103. package/data-structures/IndexedDB/contact-db.cjs +1 -1
  104. package/data-structures/IndexedDB/contact-db.mjs +9 -6
  105. package/data-structures/PublicBalance/PublicBalanceWatcher.cjs +1 -0
  106. package/data-structures/PublicBalance/PublicBalanceWatcher.d.ts +20 -0
  107. package/data-structures/PublicBalance/PublicBalanceWatcher.mjs +124 -0
  108. package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.cjs +1 -0
  109. package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.d.ts +15 -0
  110. package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.mjs +64 -0
  111. package/data-structures/PublicBalance/index.d.ts +2 -0
  112. package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
  113. package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +77 -78
  114. package/data-structures/crypto-keys/keys.cjs +1 -1
  115. package/data-structures/crypto-keys/keys.d.ts +0 -11
  116. package/data-structures/crypto-keys/keys.mjs +47 -107
  117. package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.cjs +1 -1
  118. package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.d.ts +3 -2
  119. package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.mjs +9 -9
  120. package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.cjs +1 -1
  121. package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.d.ts +3 -2
  122. package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.mjs +5 -5
  123. package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.cjs +1 -1
  124. package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.d.ts +3 -2
  125. package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.mjs +6 -6
  126. package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
  127. package/data-structures/event-service/evm/AbstractEventService.d.ts +3 -2
  128. package/data-structures/event-service/evm/AbstractEventService.mjs +16 -19
  129. package/data-structures/event-service/evm/AbstractNullifierSnapshotService.cjs +1 -1
  130. package/data-structures/event-service/evm/AbstractNullifierSnapshotService.d.ts +3 -3
  131. package/data-structures/event-service/evm/AbstractNullifierSnapshotService.mjs +6 -5
  132. package/data-structures/event-service/evm/AbstractSnapshotService.d.ts +1 -1
  133. package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
  134. package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +7 -4
  135. package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +35 -34
  136. package/data-structures/event-service/evm/ClientBlockchainEventEmitter.cjs +1 -0
  137. package/data-structures/event-service/evm/ClientBlockchainEventEmitter.d.ts +11 -0
  138. package/data-structures/event-service/evm/ClientBlockchainEventEmitter.mjs +21 -0
  139. package/data-structures/event-service/evm/PollingBlockchainEventEmitter.cjs +1 -0
  140. package/data-structures/event-service/evm/PollingBlockchainEventEmitter.d.ts +6 -0
  141. package/data-structures/event-service/evm/PollingBlockchainEventEmitter.mjs +16 -0
  142. package/data-structures/event-service/helpers/ClientEventHelper.cjs +1 -0
  143. package/data-structures/event-service/helpers/ClientEventHelper.d.ts +11 -0
  144. package/data-structures/event-service/helpers/ClientEventHelper.mjs +26 -0
  145. package/data-structures/event-service/helpers/PollingEventHelper.cjs +1 -0
  146. package/data-structures/event-service/helpers/PollingEventHelper.d.ts +5 -0
  147. package/data-structures/event-service/helpers/PollingEventHelper.mjs +14 -0
  148. package/data-structures/event-service/index.d.ts +4 -0
  149. package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.cjs +1 -1
  150. package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.d.ts +3 -2
  151. package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.mjs +6 -6
  152. package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.cjs +1 -1
  153. package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.d.ts +4 -3
  154. package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.mjs +8 -8
  155. package/data-structures/event-service/solana/AbstractSolanaEventService.cjs +1 -1
  156. package/data-structures/event-service/solana/AbstractSolanaEventService.d.ts +3 -10
  157. package/data-structures/event-service/solana/AbstractSolanaEventService.mjs +5 -5
  158. package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -1
  159. package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.d.ts +3 -2
  160. package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.mjs +1 -1
  161. package/data-structures/event-service/solana/AbstractSolanaSnapshotService.d.ts +1 -1
  162. package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.cjs +1 -0
  163. package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.d.ts +11 -0
  164. package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.mjs +22 -0
  165. package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.cjs +1 -0
  166. package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.d.ts +6 -0
  167. package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.mjs +16 -0
  168. package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.cjs +1 -1
  169. package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +8 -14
  170. package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.mjs +68 -67
  171. package/data-structures/index.d.ts +3 -0
  172. package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
  173. package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +5 -2
  174. package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
  175. package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +5 -2
  176. package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs +1 -1
  177. package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs +5 -2
  178. package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs +1 -1
  179. package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs +5 -2
  180. package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs +1 -1
  181. package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.mjs +5 -2
  182. package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs +1 -1
  183. package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs +5 -2
  184. package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs +1 -1
  185. package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs +5 -2
  186. package/data-structures/utxo/Utxo.cjs +1 -1
  187. package/data-structures/utxo/Utxo.d.ts +1 -0
  188. package/data-structures/utxo/Utxo.mjs +18 -4
  189. package/error-handling/error-codes.constants.cjs +1 -1
  190. package/error-handling/error-codes.constants.mjs +2 -2
  191. package/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -1
  192. package/functions/pre-transaction/getSolanaCalldataHash.mjs +22 -22
  193. package/functions/pre-transaction/sendV0Transaction.cjs +1 -1
  194. package/functions/pre-transaction/sendV0Transaction.mjs +53 -50
  195. package/functions/pre-transaction/solana.cjs +1 -1
  196. package/functions/pre-transaction/solana.mjs +93 -93
  197. package/functions/private-wallet/emporium.helpers.cjs +1 -1
  198. package/functions/private-wallet/emporium.helpers.d.ts +3 -2
  199. package/functions/private-wallet/emporium.helpers.mjs +118 -93
  200. package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
  201. package/functions/snarkjs/constructEmporiumProof.d.ts +1 -2
  202. package/functions/snarkjs/constructEmporiumProof.mjs +89 -89
  203. package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
  204. package/functions/snarkjs/constructSolanaZkProof.mjs +6 -2
  205. package/functions/utils/bytes32.utils.cjs +1 -1
  206. package/functions/utils/bytes32.utils.mjs +8 -7
  207. package/functions/utils/create-provider.cjs +1 -1
  208. package/functions/utils/create-provider.d.ts +1 -1
  209. package/functions/utils/create-provider.mjs +13 -9
  210. package/functions/utils/index.d.ts +0 -1
  211. package/functions/utils/prepareHinkal.cjs +1 -1
  212. package/functions/utils/prepareHinkal.d.ts +6 -7
  213. package/functions/utils/prepareHinkal.mjs +45 -53
  214. package/functions/utils/publicBalance.utils.cjs +1 -1
  215. package/functions/utils/publicBalance.utils.mjs +49 -54
  216. package/functions/utils/socket.utils.cjs +1 -0
  217. package/functions/utils/socket.utils.d.ts +1 -0
  218. package/functions/utils/socket.utils.mjs +12 -0
  219. package/functions/utils/string.utils.cjs +1 -1
  220. package/functions/utils/string.utils.d.ts +1 -0
  221. package/functions/utils/string.utils.mjs +18 -14
  222. package/functions/utils/walletBalances.utils.cjs +1 -1
  223. package/functions/utils/walletBalances.utils.d.ts +1 -1
  224. package/functions/utils/walletBalances.utils.mjs +4 -4
  225. package/functions/web3/crypto.cjs +1 -0
  226. package/functions/web3/crypto.d.ts +1 -0
  227. package/functions/web3/crypto.mjs +7 -0
  228. package/functions/web3/events/getApprovedBalance.cjs +1 -1
  229. package/functions/web3/events/getApprovedBalance.mjs +14 -14
  230. package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
  231. package/functions/web3/events/getInputUtxoAndBalance.mjs +61 -59
  232. package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
  233. package/functions/web3/events/getTransactionLogEvents.mjs +32 -32
  234. package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
  235. package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +6 -3
  236. package/functions/web3/functionCalls/approveToken.cjs +1 -1
  237. package/functions/web3/functionCalls/approveToken.mjs +17 -17
  238. package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
  239. package/functions/web3/functionCalls/transactCallDirect.mjs +16 -16
  240. package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
  241. package/functions/web3/functionCalls/transactCallRelayer.mjs +13 -11
  242. package/functions/web3/getContractMetadata.cjs +1 -1
  243. package/functions/web3/getContractMetadata.mjs +17 -22
  244. package/functions/web3/getTokenHolder.cjs +1 -1
  245. package/functions/web3/getTokenHolder.mjs +20 -20
  246. package/functions/web3/index.d.ts +1 -0
  247. package/index.cjs +1 -1
  248. package/index.mjs +913 -890
  249. package/package.json +3 -2
  250. package/providers/EthersProviderAdapter.cjs +1 -1
  251. package/providers/EthersProviderAdapter.mjs +2 -5
  252. package/providers/prepareEthersHinkal.cjs +1 -1
  253. package/providers/prepareEthersHinkal.mjs +11 -4
  254. package/providers/prepareWagmiHinkal.cjs +1 -1
  255. package/providers/prepareWagmiHinkal.mjs +11 -4
  256. package/types/activities.types.d.ts +2 -0
  257. package/types/bridging-tx.types.d.ts +17 -0
  258. package/types/cache.types.cjs +1 -1
  259. package/types/cache.types.d.ts +5 -1
  260. package/types/cache.types.mjs +1 -1
  261. package/types/ethereum-network.types.d.ts +1 -0
  262. package/types/events.types.cjs +1 -0
  263. package/types/events.types.d.ts +9 -0
  264. package/types/events.types.mjs +5 -0
  265. package/types/index.d.ts +2 -0
  266. package/types/proxy.types.d.ts +11 -4
  267. package/types/sandbox.types.d.ts +2 -0
  268. package/types/solana.types.d.ts +8 -0
  269. package/types/token.types.d.ts +5 -0
  270. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
  271. package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
  272. package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
  273. package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
  274. package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
  275. package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
  276. package/functions/kyc/authentoHelper.cjs +0 -1
  277. package/functions/kyc/authentoHelper.d.ts +0 -12
  278. package/functions/kyc/authentoHelper.mjs +0 -30
  279. package/functions/utils/get-hinkal-approvals.cjs +0 -1
  280. package/functions/utils/get-hinkal-approvals.d.ts +0 -3
  281. package/functions/utils/get-hinkal-approvals.mjs +0 -38
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("../../error-handling/error-codes.constants.cjs"),A=require("../../functions/utils/addresses.cjs"),C=require("../../functions/pre-transaction/getVolatileTransferAmount.cjs"),f=require("../../functions/private-wallet/emporium.helpers.cjs"),q=require("../../functions/pre-transaction/getFeeStructure.cjs"),g=require("../../types/external-action.types.cjs"),T=require("../../functions/utils/convertEmporiumOpToCallInfo.cjs"),w=require("../crypto-keys/keys.cjs"),I=require("../../functions/utils/token-check.utils.cjs"),O=async(n,r,l,d,o,m,i,p,v=!1)=>{if(!i)throw Error("hinkalProxyToPrivate: subAccount should be provided");if(!o)throw new Error("Fee token is required in hinkalProxyToPrivate");if(!A.isValidPrivateAddress(d))throw Error(E.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const e=I.validateAndGetChainId(r),u=w.UserKeys.getSignerAddressFromPrivateKey(e,i.privateKey),s=r.map(t=>t.erc20TokenAddress),a=await C.modifyVolatileTokenAmountChanges(e,r,l,u),c=f.createTransaferEmporiumOpsBatch(n,e,s,a),h=m??await q.getFeeStructure(e,o,s,g.ExternalActionId.Emporium,c.map(t=>T.convertEmporiumOpToCallInfo(t,u,e))),y=r.map((t,P)=>({token:t,amount:-1n*a[P]}));return n.actionPrivateWallet(e,[s[0]],[0n],[!1],c,y,i,o,h,void 0,void 0,void 0,p,{recipientInfo:d,amount:a[0],token:r[0]},v)};exports.hinkalProxyToPrivate=O;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("../../error-handling/error-codes.constants.cjs"),f=require("../../functions/utils/addresses.cjs"),C=require("../../functions/pre-transaction/getVolatileTransferAmount.cjs"),q=require("../../functions/private-wallet/emporium.helpers.cjs"),y=require("../../functions/pre-transaction/getFeeStructure.cjs"),g=require("../../types/external-action.types.cjs"),w=require("../../functions/utils/convertEmporiumOpToCallInfo.cjs"),T=require("../../functions/utils/token-check.utils.cjs"),I=require("../AccountActions/AccountActions.cjs"),O=async(s,r,l,c,o,m,n,p,A=!1)=>{if(!n)throw Error("hinkalProxyToPrivate: subAccount should be provided");if(!o)throw new Error("Fee token is required in hinkalProxyToPrivate");if(!f.isValidPrivateAddress(c))throw Error(P.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const e=T.validateAndGetChainId(r),i=I.AccountActions.getAddressFromSubAccount(e,n);if(!i)throw Error("Public account address is not available");const u=r.map(t=>t.erc20TokenAddress),a=await C.modifyVolatileTokenAmountChanges(e,r,l,i),d=q.createTransaferEmporiumOpsBatch(s,e,u,a),h=m??await y.getFeeStructure(e,o,u,g.ExternalActionId.Emporium,d.map(t=>w.convertEmporiumOpToCallInfo(t,i,e))),v=r.map((t,E)=>({token:t,amount:-1n*a[E]}));return s.actionPrivateWallet(e,[r[0]],[0n],[!1],d,v,n,o,h,void 0,void 0,void 0,p,{recipientInfo:c,amount:a[0],token:r[0]},A)};exports.hinkalProxyToPrivate=O;
@@ -1,47 +1,50 @@
1
- import { transactionErrorCodes as P } from "../../error-handling/error-codes.constants.mjs";
2
- import { isValidPrivateAddress as A } from "../../functions/utils/addresses.mjs";
3
- import { modifyVolatileTokenAmountChanges as y } from "../../functions/pre-transaction/getVolatileTransferAmount.mjs";
1
+ import { transactionErrorCodes as E } from "../../error-handling/error-codes.constants.mjs";
2
+ import { isValidPrivateAddress as P } from "../../functions/utils/addresses.mjs";
3
+ import { modifyVolatileTokenAmountChanges as w } from "../../functions/pre-transaction/getVolatileTransferAmount.mjs";
4
4
  import { createTransaferEmporiumOpsBatch as C } from "../../functions/private-wallet/emporium.helpers.mjs";
5
- import { getFeeStructure as w } from "../../functions/pre-transaction/getFeeStructure.mjs";
6
- import { ExternalActionId as I } from "../../types/external-action.types.mjs";
7
- import { convertEmporiumOpToCallInfo as g } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
8
- import { UserKeys as x } from "../crypto-keys/keys.mjs";
5
+ import { getFeeStructure as I } from "../../functions/pre-transaction/getFeeStructure.mjs";
6
+ import { ExternalActionId as x } from "../../types/external-action.types.mjs";
7
+ import { convertEmporiumOpToCallInfo as y } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
9
8
  import { validateAndGetChainId as O } from "../../functions/utils/token-check.utils.mjs";
10
- const q = async (n, o, l, s, e, f, i, c, u = !1) => {
9
+ import { AccountActions as g } from "../AccountActions/AccountActions.mjs";
10
+ const B = async (n, r, l, s, a, p, i, u, f = !1) => {
11
11
  if (!i)
12
12
  throw Error("hinkalProxyToPrivate: subAccount should be provided");
13
- if (!e)
13
+ if (!a)
14
14
  throw new Error("Fee token is required in hinkalProxyToPrivate");
15
- if (!A(s))
16
- throw Error(P.RECIPIENT_FORMAT_INCORRECT);
17
- const r = O(o), d = x.getSignerAddressFromPrivateKey(r, i.privateKey), a = o.map((t) => t.erc20TokenAddress), m = await y(r, o, l, d), p = C(n, r, a, m), v = f ?? await w(
18
- r,
19
- e,
15
+ if (!P(s))
16
+ throw Error(E.RECIPIENT_FORMAT_INCORRECT);
17
+ const o = O(r), e = g.getAddressFromSubAccount(o, i);
18
+ if (!e)
19
+ throw Error("Public account address is not available");
20
+ const d = r.map((t) => t.erc20TokenAddress), m = await w(o, r, l, e), c = C(n, o, d, m), h = p ?? await I(
21
+ o,
20
22
  a,
21
- I.Emporium,
22
- p.map((t) => g(t, d, r))
23
- ), h = o.map((t, E) => ({
23
+ d,
24
+ x.Emporium,
25
+ c.map((t) => y(t, e, o))
26
+ ), v = r.map((t, A) => ({
24
27
  token: t,
25
- amount: -1n * m[E]
28
+ amount: -1n * m[A]
26
29
  }));
27
30
  return n.actionPrivateWallet(
28
- r,
29
- [a[0]],
31
+ o,
32
+ [r[0]],
30
33
  [0n],
31
34
  [!1],
32
- p,
33
- h,
34
- i,
35
- e,
35
+ c,
36
36
  v,
37
+ i,
38
+ a,
39
+ h,
37
40
  void 0,
38
41
  void 0,
39
42
  void 0,
40
- c,
41
- { recipientInfo: s, amount: m[0], token: o[0] },
42
- u
43
+ u,
44
+ { recipientInfo: s, amount: m[0], token: r[0] },
45
+ f
43
46
  );
44
47
  };
45
48
  export {
46
- q as hinkalProxyToPrivate
49
+ B as hinkalProxyToPrivate
47
50
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../crypto-keys/keys.cjs"),n=async(i,t,e,s)=>{let r;if(e)r=await a.UserKeys.signTypedDataFromPrivateKey(i,s.privateKey,e.domain,e.types,e.value);else{if(!t)throw Error("dataHash must be provided if typedData is not provided");r=await a.UserKeys.signMessageFromPrivateKey(i,s.privateKey,t)}return r};exports.hinkalSignSubAccount=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../AccountActions/AccountActions.cjs"),a=async(e,n,t,c)=>{let i;const o=r.AccountActions.getPrivateKeyFromSubAccount(e,c);if(!o)throw Error("Private key is not available");if(t)i=await r.AccountActions.signTypedDataFromPrivateKey(e,o,t.domain,t.types,t.value);else{if(!n)throw Error("dataHash must be provided if typedData is not provided");i=await r.AccountActions.signMessageFromPrivateKey(e,o,n)}return i};exports.hinkalSignSubAccount=a;
@@ -1,21 +1,24 @@
1
- import { UserKeys as o } from "../crypto-keys/keys.mjs";
2
- const n = async (i, t, e, a) => {
3
- let r;
4
- if (e)
5
- r = await o.signTypedDataFromPrivateKey(
1
+ import { AccountActions as o } from "../AccountActions/AccountActions.mjs";
2
+ const u = async (t, a, r, n) => {
3
+ let e;
4
+ const i = o.getPrivateKeyFromSubAccount(t, n);
5
+ if (!i)
6
+ throw Error("Private key is not available");
7
+ if (r)
8
+ e = await o.signTypedDataFromPrivateKey(
9
+ t,
6
10
  i,
7
- a.privateKey,
8
- e.domain,
9
- e.types,
10
- e.value
11
+ r.domain,
12
+ r.types,
13
+ r.value
11
14
  );
12
15
  else {
13
- if (!t)
16
+ if (!a)
14
17
  throw Error("dataHash must be provided if typedData is not provided");
15
- r = await o.signMessageFromPrivateKey(i, a.privateKey, t);
18
+ e = await o.signMessageFromPrivateKey(t, i, a);
16
19
  }
17
- return r;
20
+ return e;
18
21
  };
19
22
  export {
20
- n as hinkalSignSubAccount
23
+ u as hinkalSignSubAccount
21
24
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("../utxo/Utxo.cjs"),M=require("../../functions/utils/solanaMint.utils.cjs"),z=require("../../functions/web3/etherFunctions.cjs"),N=require("../../constants/chains.constants.cjs"),K=require("../../constants/protocol.constants.cjs"),d=require("@solana/web3.js"),_=require("../../functions/snarkjs/common.snarkjs.cjs"),G=require("@coral-xyz/anchor"),E=require("../../functions/utils/addresses.cjs"),H=require("../../error-handling/error-codes.constants.cjs"),i=require("../../functions/pre-transaction/solana.cjs");require("../../API/getServerURL.cjs");require("axios");require("../../constants/coingecko.constants.cjs");require("../../constants/server.constants.cjs");require("../http/HttpClient.cjs");const L=require("../../API/API.cjs");require("../../API/tenderly.api.cjs");require("../../constants/token-data/index.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");const B=require("./hinkalCheckSolanaTokenRegistry.cjs"),O=require("../../functions/web3/signAndSendSerializedTransaction.cjs"),x=require("../../functions/utils/token-check.utils.cjs"),F=async(e,r,a,n)=>{const o=x.validateAndGetChainId([a]),c=a.erc20TokenAddress,{hinkalIdl:m,hinkalAddress:y,originalDeployer:g}=N.networkRegistry[o].contractData;if(!m)throw new Error("No IDL configured for Solana program on this network");if(!g)throw new Error("missing original deployer");const l=e.getSolanaProgram(m),D=e.getSolanaPublicKey(),t=new d.PublicKey(g),S=new d.PublicKey(y),{mintPublicKey:s}=M.formatMintAddress(c),u=s.toString(),h=i.getStorageAccountPublicKey(S,t),P=i.getStorageVaultPublicKey(S,t),f=i.getMerkleAccountPublicKey(S,t),p=i.buildAnchorStealthAddressStructure(n);if(await B.hinkalCheckSolanaTokenRegistry(l,new d.PublicKey(t),[c],[r])){const{serializedTransaction:q,blockhash:T,lastValidBlockHeight:I}=await L.API.generateProoflessDepositLimitless({amount:r.toString(),payer:e.getSolanaPublicKey().toBase58(),ethereumAddress:await e.getEthereumAddress(),mint:c,stealthAddressStructure:p,chainId:o}),{wallet:b}=l.provider;if(!b)throw new Error("missing wallet");return O.signAndSendSerializedTransaction(l.provider,q,T,I)}const k=i.getTokenLimitStorageAccountPublicKey(l.programId,t,s),v=u===K.solanaNativeAddress?null:s,w=u===K.solanaNativeAddress?null:void 0;return l.methods.prooflessDeposit(new G.BN(r.toString()),p).accounts({mint:v,signer:D,signerAta:w,originalDeployer:t,storageAccount:h,storageVault:P,merkleAccount:f,tokenLimitStorage:k,storageVaultAta:w,accessTokenOwner:null}).rpc()},$=async(e,r,a)=>{const n=e.userKeys.getShieldedPrivateKey(),o=V.Utxo.findCorrectRandomization(z.randomBigInt(31),n),c=_.calcStealthAddressStructure(o,n);return F(e,r,a,c)},J=async(e,r,a,n)=>{if(!E.isValidPrivateAddress(n))throw Error(H.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const o=E.constructStealthAddressStructure(n);return F(e,r,a,o)},Q=async(e,r,a)=>{const n=x.validateAndGetChainId([a]),o=a.erc20TokenAddress,{hinkalIdl:c,hinkalAddress:m,originalDeployer:y}=N.networkRegistry[n].contractData;if(!c)throw new Error("No IDL configured for Solana program on this network");if(!y)throw new Error("missing original deployer");const g=e.userKeys.getShieldedPrivateKey(),l=V.Utxo.findCorrectRandomization(z.randomBigInt(31),g),D=_.calcStealthAddressStructure(l,g),t=e.getSolanaProgram(c),S=e.getSolanaPublicKey(),s=new d.PublicKey(y),u=new d.PublicKey(m),{mintPublicKey:h}=M.formatMintAddress(o),P=h.toString(),f=i.getStorageAccountPublicKey(u,s),p=i.getStorageVaultPublicKey(u,s),C=i.getMerkleAccountPublicKey(u,s),k=i.buildAnchorStealthAddressStructure(D),v=r.reduce((A,R)=>A+R,0n),w=await B.hinkalCheckSolanaTokenRegistry(t,new d.PublicKey(s),[o],[v]),q=r.map(A=>`${A}`);if(w){const{serializedTransaction:A,blockhash:R,lastValidBlockHeight:j}=await L.API.generateMultiPaymentDepositLimitless({amounts:q,payer:e.getSolanaPublicKey().toBase58(),ethereumAddress:await e.getEthereumAddress(),mint:o,stealthAddressStructure:k,chainId:n}),{wallet:U}=t.provider;if(!U)throw new Error("missing wallet");return O.signAndSendSerializedTransaction(t.provider,A,R,j)}const T=i.getTokenLimitStorageAccountPublicKey(t.programId,s,h),I=P===K.solanaNativeAddress?null:h,b=P===K.solanaNativeAddress?null:void 0;return t.methods.multiPaymentDeposit(q,k).accounts({mint:I,signer:S,signerAta:b,originalDeployer:s,storageAccount:f,storageVault:p,merkleAccount:C,tokenLimitStorage:T,storageVaultAta:b,accessTokenOwner:null}).rpc()};exports.hinkalSolanaDeposit=$;exports.hinkalSolanaDepositForOther=J;exports.hinkalSolanaMultiPaymentDeposit=Q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("../utxo/Utxo.cjs"),M=require("../../functions/utils/solanaMint.utils.cjs"),z=require("../../functions/web3/etherFunctions.cjs"),B=require("../../constants/chains.constants.cjs"),K=require("../../constants/protocol.constants.cjs"),d=require("@solana/web3.js"),N=require("../../functions/snarkjs/common.snarkjs.cjs"),G=require("@coral-xyz/anchor"),E=require("../../functions/utils/addresses.cjs"),H=require("../../error-handling/error-codes.constants.cjs"),i=require("../../functions/pre-transaction/solana.cjs");require("../../API/getServerURL.cjs");require("axios");require("../../constants/coingecko.constants.cjs");require("../../constants/server.constants.cjs");require("../http/HttpClient.cjs");const _=require("../../API/API.cjs");require("../../API/tenderly.api.cjs");require("../../constants/token-data/index.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");const L=require("./hinkalCheckSolanaTokenRegistry.cjs"),O=require("../../functions/web3/signAndSendSerializedTransaction.cjs"),x=require("../../functions/utils/token-check.utils.cjs"),F=async(e,o,a,r)=>{const n=x.validateAndGetChainId([a]),c=a.erc20TokenAddress,{hinkalIdl:A,hinkalAddress:m,originalDeployer:g}=B.networkRegistry[n].contractData;if(!A)throw new Error("No IDL configured for Solana program on this network");if(!g)throw new Error("missing original deployer");const l=e.getSolanaProgram(A),D=e.getSolanaPublicKey(),t=new d.PublicKey(g),h=new d.PublicKey(m),{mintPublicKey:s}=M.formatMintAddress(c),u=s.toString(),S=i.getStorageAccountPublicKey(h,t),P=i.getStorageVaultPublicKey(h,t),f=i.getMerkleAccountPublicKey(h,t),p=i.buildAnchorStealthAddressStructure(r);if(await L.hinkalCheckSolanaTokenRegistry(l,new d.PublicKey(t),[c],[o])){const{serializedTransaction:q,blockhash:T,lastValidBlockHeight:I}=await _.API.generateProoflessDepositLimitless({amount:o.toString(),payer:e.getSolanaPublicKey().toBase58(),ethereumAddress:await e.getEthereumAddressByChain(n),mint:c,stealthAddressStructure:p,chainId:n}),{wallet:b}=l.provider;if(!b)throw new Error("missing wallet");return O.signAndSendSerializedTransaction(l.provider,q,T,I)}const k=i.getTokenLimitStorageAccountPublicKey(l.programId,t,s),v=u===K.solanaNativeAddress?null:s,w=u===K.solanaNativeAddress?null:void 0;return l.methods.prooflessDeposit(new G.BN(o.toString()),p).accounts({mint:v,signer:D,signerAta:w,originalDeployer:t,storageAccount:S,storageVault:P,merkleAccount:f,tokenLimitStorage:k,storageVaultAta:w,accessTokenOwner:null}).rpc()},$=async(e,o,a)=>{const r=e.userKeys.getShieldedPrivateKey(),n=V.Utxo.findCorrectRandomization(z.randomBigInt(31),r),c=N.calcStealthAddressStructure(n,r);return F(e,o,a,c)},J=async(e,o,a,r)=>{if(!E.isValidPrivateAddress(r))throw Error(H.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const n=E.constructStealthAddressStructure(r);return F(e,o,a,n)},Q=async(e,o,a)=>{const r=x.validateAndGetChainId([a]),n=a.erc20TokenAddress,{hinkalIdl:c,hinkalAddress:A,originalDeployer:m}=B.networkRegistry[r].contractData;if(!c)throw new Error("No IDL configured for Solana program on this network");if(!m)throw new Error("missing original deployer");const g=e.userKeys.getShieldedPrivateKey(),l=V.Utxo.findCorrectRandomization(z.randomBigInt(31),g),D=N.calcStealthAddressStructure(l,g),t=e.getSolanaProgram(c),h=e.getSolanaPublicKey(),s=new d.PublicKey(m),u=new d.PublicKey(A),{mintPublicKey:S}=M.formatMintAddress(n),P=S.toString(),f=i.getStorageAccountPublicKey(u,s),p=i.getStorageVaultPublicKey(u,s),C=i.getMerkleAccountPublicKey(u,s),k=i.buildAnchorStealthAddressStructure(D),v=o.reduce((y,R)=>y+R,0n),w=await L.hinkalCheckSolanaTokenRegistry(t,new d.PublicKey(s),[n],[v]),q=o.map(y=>`${y}`);if(w){const{serializedTransaction:y,blockhash:R,lastValidBlockHeight:j}=await _.API.generateMultiPaymentDepositLimitless({amounts:q,payer:e.getSolanaPublicKey().toBase58(),ethereumAddress:await e.getEthereumAddressByChain(r),mint:n,stealthAddressStructure:k,chainId:r}),{wallet:U}=t.provider;if(!U)throw new Error("missing wallet");return O.signAndSendSerializedTransaction(t.provider,y,R,j)}const T=i.getTokenLimitStorageAccountPublicKey(t.programId,s,S),I=P===K.solanaNativeAddress?null:S,b=P===K.solanaNativeAddress?null:void 0;return t.methods.multiPaymentDeposit(q,k).accounts({mint:I,signer:h,signerAta:b,originalDeployer:s,storageAccount:f,storageVault:p,merkleAccount:C,tokenLimitStorage:T,storageVaultAta:b,accessTokenOwner:null}).rpc()};exports.hinkalSolanaDeposit=$;exports.hinkalSolanaDepositForOther=J;exports.hinkalSolanaMultiPaymentDeposit=Q;
@@ -1,10 +1,10 @@
1
- import { Utxo as V } from "../utxo/Utxo.mjs";
2
- import { formatMintAddress as C } from "../../functions/utils/solanaMint.utils.mjs";
3
- import { randomBigInt as z } from "../../functions/web3/etherFunctions.mjs";
4
- import { networkRegistry as L } from "../../constants/chains.constants.mjs";
1
+ import { Utxo as C } from "../utxo/Utxo.mjs";
2
+ import { formatMintAddress as V } from "../../functions/utils/solanaMint.utils.mjs";
3
+ import { randomBigInt as B } from "../../functions/web3/etherFunctions.mjs";
4
+ import { networkRegistry as z } from "../../constants/chains.constants.mjs";
5
5
  import { solanaNativeAddress as K } from "../../constants/protocol.constants.mjs";
6
6
  import { PublicKey as d } from "@solana/web3.js";
7
- import { calcStealthAddressStructure as B } from "../../functions/snarkjs/common.snarkjs.mjs";
7
+ import { calcStealthAddressStructure as L } from "../../functions/snarkjs/common.snarkjs.mjs";
8
8
  import { BN as J } from "@coral-xyz/anchor";
9
9
  import { isValidPrivateAddress as Q, constructStealthAddressStructure as W } from "../../functions/utils/addresses.mjs";
10
10
  import { transactionErrorCodes as X } from "../../error-handling/error-codes.constants.mjs";
@@ -30,85 +30,85 @@ import "../../constants/events.constants.mjs";
30
30
  import { hinkalCheckSolanaTokenRegistry as H } from "./hinkalCheckSolanaTokenRegistry.mjs";
31
31
  import { signAndSendSerializedTransaction as _ } from "../../functions/web3/signAndSendSerializedTransaction.mjs";
32
32
  import { validateAndGetChainId as G } from "../../functions/utils/token-check.utils.mjs";
33
- const U = async (t, o, s, e) => {
34
- const n = G([s]), a = s.erc20TokenAddress, { hinkalIdl: h, hinkalAddress: S, originalDeployer: m } = L[n].contractData;
33
+ const U = async (t, n, s, o) => {
34
+ const e = G([s]), a = s.erc20TokenAddress, { hinkalIdl: h, hinkalAddress: S, originalDeployer: m } = z[e].contractData;
35
35
  if (!h)
36
36
  throw new Error("No IDL configured for Solana program on this network");
37
37
  if (!m)
38
38
  throw new Error("missing original deployer");
39
- const c = t.getSolanaProgram(h), D = t.getSolanaPublicKey(), r = new d(m), u = new d(S), { mintPublicKey: i } = C(a), l = i.toString(), g = N(u, r), A = M(u, r), b = O(u, r), y = x(e);
39
+ const c = t.getSolanaProgram(h), D = t.getSolanaPublicKey(), r = new d(m), u = new d(S), { mintPublicKey: i } = V(a), l = i.toString(), g = N(u, r), y = M(u, r), b = O(u, r), A = x(o);
40
40
  if (await H(
41
41
  c,
42
42
  new d(r),
43
43
  [a],
44
- [o]
44
+ [n]
45
45
  )) {
46
46
  const { serializedTransaction: P, blockhash: E, lastValidBlockHeight: I } = await F.generateProoflessDepositLimitless({
47
- amount: o.toString(),
47
+ amount: n.toString(),
48
48
  payer: t.getSolanaPublicKey().toBase58(),
49
- ethereumAddress: await t.getEthereumAddress(),
49
+ ethereumAddress: await t.getEthereumAddressByChain(e),
50
50
  mint: a,
51
- stealthAddressStructure: y,
52
- chainId: n
51
+ stealthAddressStructure: A,
52
+ chainId: e
53
53
  }), { wallet: k } = c.provider;
54
54
  if (!k)
55
55
  throw new Error("missing wallet");
56
56
  return _(c.provider, P, E, I);
57
57
  }
58
58
  const w = q(c.programId, r, i), v = l === K ? null : i, f = l === K ? null : void 0;
59
- return c.methods.prooflessDeposit(new J(o.toString()), y).accounts({
59
+ return c.methods.prooflessDeposit(new J(n.toString()), A).accounts({
60
60
  mint: v,
61
61
  signer: D,
62
62
  signerAta: f,
63
63
  originalDeployer: r,
64
64
  storageAccount: g,
65
- storageVault: A,
65
+ storageVault: y,
66
66
  merkleAccount: b,
67
67
  tokenLimitStorage: w,
68
68
  storageVaultAta: f,
69
69
  accessTokenOwner: null
70
70
  }).rpc();
71
- }, Tt = async (t, o, s) => {
72
- const e = t.userKeys.getShieldedPrivateKey(), n = V.findCorrectRandomization(z(31), e), a = B(n, e);
73
- return U(t, o, s, a);
74
- }, Vt = async (t, o, s, e) => {
75
- if (!Q(e))
71
+ }, Tt = async (t, n, s) => {
72
+ const o = t.userKeys.getShieldedPrivateKey(), e = C.findCorrectRandomization(B(31), o), a = L(e, o);
73
+ return U(t, n, s, a);
74
+ }, Ct = async (t, n, s, o) => {
75
+ if (!Q(o))
76
76
  throw Error(X.RECIPIENT_FORMAT_INCORRECT);
77
- const n = W(e);
78
- return U(t, o, s, n);
79
- }, Ct = async (t, o, s) => {
80
- const e = G([s]), n = s.erc20TokenAddress, { hinkalIdl: a, hinkalAddress: h, originalDeployer: S } = L[e].contractData;
77
+ const e = W(o);
78
+ return U(t, n, s, e);
79
+ }, Vt = async (t, n, s) => {
80
+ const o = G([s]), e = s.erc20TokenAddress, { hinkalIdl: a, hinkalAddress: h, originalDeployer: S } = z[o].contractData;
81
81
  if (!a)
82
82
  throw new Error("No IDL configured for Solana program on this network");
83
83
  if (!S)
84
84
  throw new Error("missing original deployer");
85
- const m = t.userKeys.getShieldedPrivateKey(), c = V.findCorrectRandomization(z(31), m), D = B(c, m), r = t.getSolanaProgram(a), u = t.getSolanaPublicKey(), i = new d(S), l = new d(h), { mintPublicKey: g } = C(n), A = g.toString(), b = N(l, i), y = M(l, i), T = O(l, i), w = x(D), v = o.reduce((p, R) => p + R, 0n), f = await H(
85
+ const m = t.userKeys.getShieldedPrivateKey(), c = C.findCorrectRandomization(B(31), m), D = L(c, m), r = t.getSolanaProgram(a), u = t.getSolanaPublicKey(), i = new d(S), l = new d(h), { mintPublicKey: g } = V(e), y = g.toString(), b = N(l, i), A = M(l, i), T = O(l, i), w = x(D), v = n.reduce((p, R) => p + R, 0n), f = await H(
86
86
  r,
87
87
  new d(i),
88
- [n],
88
+ [e],
89
89
  [v]
90
- ), P = o.map((p) => `${p}`);
90
+ ), P = n.map((p) => `${p}`);
91
91
  if (f) {
92
92
  const { serializedTransaction: p, blockhash: R, lastValidBlockHeight: $ } = await F.generateMultiPaymentDepositLimitless({
93
93
  amounts: P,
94
94
  payer: t.getSolanaPublicKey().toBase58(),
95
- ethereumAddress: await t.getEthereumAddress(),
96
- mint: n,
95
+ ethereumAddress: await t.getEthereumAddressByChain(o),
96
+ mint: e,
97
97
  stealthAddressStructure: w,
98
- chainId: e
98
+ chainId: o
99
99
  }), { wallet: j } = r.provider;
100
100
  if (!j)
101
101
  throw new Error("missing wallet");
102
102
  return _(r.provider, p, R, $);
103
103
  }
104
- const E = q(r.programId, i, g), I = A === K ? null : g, k = A === K ? null : void 0;
104
+ const E = q(r.programId, i, g), I = y === K ? null : g, k = y === K ? null : void 0;
105
105
  return r.methods.multiPaymentDeposit(P, w).accounts({
106
106
  mint: I,
107
107
  signer: u,
108
108
  signerAta: k,
109
109
  originalDeployer: i,
110
110
  storageAccount: b,
111
- storageVault: y,
111
+ storageVault: A,
112
112
  merkleAccount: T,
113
113
  tokenLimitStorage: E,
114
114
  storageVaultAta: k,
@@ -117,6 +117,6 @@ const U = async (t, o, s, e) => {
117
117
  };
118
118
  export {
119
119
  Tt as hinkalSolanaDeposit,
120
- Vt as hinkalSolanaDepositForOther,
121
- Ct as hinkalSolanaMultiPaymentDeposit
120
+ Ct as hinkalSolanaDepositForOther,
121
+ Vt as hinkalSolanaMultiPaymentDeposit
122
122
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("../../functions/web3/etherFunctions.cjs"),F=require("../utxo/Utxo.cjs"),W=require("../../error-handling/error-codes.constants.cjs"),$=require("ethers");require("idb-keyval");const L=require("../../constants/chains.constants.cjs");require("../crypto-keys/keys.cjs");require("node-forge");require("../../constants/vite.constants.cjs");require("libsodium-wrappers");require("../http/HttpClient.cjs");require("axios");const M=require("../../functions/utils/solanaMint.utils.cjs"),z=require("@solana/web3.js"),Z=require("../../functions/utils/addresses.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../../constants/token-data/index.cjs");const B=require("../../constants/protocol.constants.cjs"),G=require("../../API/API.cjs"),X=require("../../functions/utils/token-check.utils.cjs");require("async-mutex");require("../../types/circom-data.types.cjs");const Y=require("../../types/external-action.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");require("../../functions/web3/events/getApprovedBalance.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");const x=require("../../functions/pre-transaction/solana.cjs");require("@solana/spl-token");const J=require("@coral-xyz/anchor");require("../../functions/utils/userAgent.cjs");const Q=require("../../functions/utils/time.utils.cjs");require("circomlibjs-hinkal-fork");require("multiformats");require("../../API/tenderly.api.cjs");require("process");require("buffer");require("../../providers/EthersProviderAdapter.cjs");const ee=require("../../functions/utils/fees.utils.cjs");require("../../functions/web3/getTokenHolder.cjs");const te=require("../../functions/web3/signAndSendSerializedTransaction.cjs"),H=require("../../functions/snarkjs/common.snarkjs.cjs"),re=require("./hinkalCheckSolanaTokenRegistry.cjs"),oe=require("../../functions/utils/getUtxosFromReceiptSolana.cjs"),ne=require("../../functions/snarkjs/constructSolanaZkProof.cjs"),se=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),ie=require("../../functions/pre-transaction/getFeeStructure.cjs"),ae=async(e,t,q,l,d,A)=>{const i=q.erc20TokenAddress,n=l.map(r=>r+ee.calculateTotalFee(r,A)),{hinkalIdl:m,hinkalAddress:g,originalDeployer:h}=L.networkRegistry[t].contractData;if(!m)throw new Error("No IDL configured for Solana program on this network");if(!h)throw new Error("missing original deployer");const y=e.userKeys.getShieldedPrivateKey(),C=F.Utxo.findCorrectRandomization(V.randomBigInt(31),y),K=H.calcStealthAddressStructure(C,y),o=e.getSolanaProgram(m),I=e.getSolanaPublicKey(),s=new z.PublicKey(h),w=new z.PublicKey(g),{mintPublicKey:S}=M.formatMintAddress(i),f=S.toString(),U=x.getStorageAccountPublicKey(w,s),D=x.getStorageVaultPublicKey(w,s),R=x.getMerkleAccountPublicKey(w,s),P=x.buildAnchorStealthAddressStructure(K),k=n.reduce((r,a)=>r+a,0n),_=await re.hinkalCheckSolanaTokenRegistry(o,new z.PublicKey(s),[i],[k]),b=n.map(r=>`${r}`);let p="";if(_){const{serializedTransaction:r,blockhash:a,lastValidBlockHeight:c}=await G.API.generateMultiPaymentDepositLimitless({amounts:b,payer:e.getSolanaPublicKey().toBase58(),ethereumAddress:await e.getEthereumAddress(),mint:i,stealthAddressStructure:P,chainId:t}),{wallet:u}=o.provider;if(!u)throw new Error("missing wallet");p=await te.signAndSendSerializedTransaction(o.provider,r,a,c)}else{const r=x.getTokenLimitStorageAccountPublicKey(o.programId,s,S),a=f===B.solanaNativeAddress?null:S,c=f===B.solanaNativeAddress?null:void 0;p=await o.methods.multiPaymentDeposit(b.map(O=>new J.BN(O)),P).accounts({mint:a,signer:I,signerAta:c,originalDeployer:s,storageAccount:U,storageVault:D,merkleAccount:R,tokenLimitStorage:r,storageVaultAta:c,accessTokenOwner:null}).rpc();const u=await o.provider.connection.getLatestBlockhash();await o.provider.connection.confirmTransaction({blockhash:u.blockhash,lastValidBlockHeight:u.lastValidBlockHeight,signature:p},"confirmed")}const T=await o.provider.connection.getTransaction(p,{commitment:"confirmed",maxSupportedTransactionVersion:0});if(!T)throw new Error("Transaction missing");const N=oe.getUtxosFromReceiptSolana(T,o,e.userKeys),E=[],v=[...N];return d.forEach((r,a)=>{const c=n[a],u=v.find(j=>j.amount===c);if(!u)throw new Error(`Could not find newly created UTXO with amount ${c} for recipient ${r}.`);E.push({recipientAddress:r,utxo:u});const O=v.indexOf(u);v.splice(O,1)}),E},ce=async(e,t,q,l,d,A,i)=>{const n=q.erc20TokenAddress;if(l.length===0)throw new Error("userDepositedUtxos must not be empty");const{hinkalIdl:m,originalDeployer:g}=L.networkRegistry[t].contractData;if(!g||!m)throw new Error("missing data");const h=e.getSolanaProgram(m),y=await e.getRandomRelay(t,!0);if(!y)throw new Error(W.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const C=Q.getCurrentTimeInSeconds().toString(),K=e.generateProofRemotely?5:1,o=[];for(let s=0;s<l.length;s+=K){const w=l.slice(s,s+K),S=await Promise.all(w.map(async({recipientAddress:f,utxo:U})=>{const{compressedAddress:D}=M.formatMintAddress(B.solanaNativeAddress),R=new F.Utxo({amount:0n,mintAddress:n,erc20TokenAddress:D,shieldedPrivateKey:e.userKeys.getShieldedPrivateKey(),timeStamp:C,tokenId:0}),P=[U,R],k=[R],_=F.Utxo.findCorrectRandomization(V.randomBigInt(31),e.userKeys.getShieldedPrivateKey()),b={tokenNumber:1,nullifierAmount:P.length,outputAmount:k.length},p=H.calcEncryptedOutputs([k])[0][0],T=Array.from($.ethers.utils.arrayify(p)),{proofAArr:N,proofBArr:E,proofCArr:v,publicInputsArr:r}=await ne.constructSolanaZkProof(e.generateProofRemotely,g,e.merkleTreeHinkalByChain[t],e.merkleTreeAccessTokenByChain[t],e.userKeys,h,[n],[P],[k],_,d.flatFee,d.variableRate,f,y,b,[T],t,void 0,void 0,void 0,void 0,void 0,!1),a=n===B.solanaNativeAddress,c={recipient:f,mint:a?void 0:n};return{relayAddress:y,functionName:"transact",chainId:t,args:{proofAArr:N,proofBArr:E,proofCArr:v,publicInputsArr:r,encryptedOutputs:[T],relayerFee:d.flatFee.toString(),dimensions:b},accounts:c}}));o.push(...S)}return await se.solanaTransactCallRelayerBatch(t,o,A,i)},ue=async(e,t,q,l,d,A)=>{const i=X.validateAndGetChainId([t]),n=t.erc20TokenAddress,m=Z.hashEthereumAddress(await e.getEthereumAddress()),g=A??await ie.getFeeStructure(i,n,[n],Y.ExternalActionId.Transact,[],0n),h=await ae(e,i,t,q,l,g);return ce(e,i,t,h,g,m,d)};exports.hinkalSolanaDepositAndWithdraw=ue;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("../../functions/web3/etherFunctions.cjs");require("../../functions/web3/events/getInputUtxoAndBalance.cjs");require("../../constants/token-data/index.cjs");const B=require("../../constants/protocol.constants.cjs"),L=require("../../constants/chains.constants.cjs"),F=require("../utxo/Utxo.cjs"),W=require("../../error-handling/error-codes.constants.cjs");require("idb-keyval");const $=require("../../API/API.cjs");require("../../constants/vite.constants.cjs");const Z=require("../../functions/utils/token-check.utils.cjs");require("async-mutex");const M=require("../../functions/utils/solanaMint.utils.cjs");require("../../types/circom-data.types.cjs");const G=require("../../types/external-action.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");require("../../functions/web3/events/getApprovedBalance.cjs");const X=require("ethers"),z=require("@solana/web3.js");require("../http/HttpClient.cjs");require("../../functions/utils/convertIntegrationProviderToExternalActionId.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("axios");const Y=require("../../functions/utils/addresses.cjs"),x=require("../../functions/pre-transaction/solana.cjs");require("@solana/spl-token");require("ethers-v6h");require("tweetnacl");require("bs58");const J=require("@coral-xyz/anchor");require("buffer");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");require("../../functions/utils/userAgent.cjs");const Q=require("../../functions/utils/time.utils.cjs");require("circomlibjs-hinkal-fork");require("../crypto-keys/keys.cjs");require("libsodium-wrappers");require("multiformats");require("process");require("../../providers/EthersProviderAdapter.cjs");const ee=require("../../functions/utils/fees.utils.cjs");require("../../functions/web3/getTokenHolder.cjs");const te=require("../../functions/web3/signAndSendSerializedTransaction.cjs"),H=require("../../functions/snarkjs/common.snarkjs.cjs"),re=require("./hinkalCheckSolanaTokenRegistry.cjs"),oe=require("../../functions/utils/getUtxosFromReceiptSolana.cjs"),ne=require("../../functions/snarkjs/constructSolanaZkProof.cjs"),se=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),ie=require("../../functions/pre-transaction/getFeeStructure.cjs"),ae=async(e,t,p,l,d,A)=>{const i=p.erc20TokenAddress,n=l.map(r=>r+ee.calculateTotalFee(r,A)),{hinkalIdl:m,hinkalAddress:g,originalDeployer:h}=L.networkRegistry[t].contractData;if(!m)throw new Error("No IDL configured for Solana program on this network");if(!h)throw new Error("missing original deployer");const y=e.userKeys.getShieldedPrivateKey(),C=F.Utxo.findCorrectRandomization(I.randomBigInt(31),y),K=H.calcStealthAddressStructure(C,y),o=e.getSolanaProgram(m),V=e.getSolanaPublicKey(),s=new z.PublicKey(h),w=new z.PublicKey(g),{mintPublicKey:S}=M.formatMintAddress(i),f=S.toString(),U=x.getStorageAccountPublicKey(w,s),D=x.getStorageVaultPublicKey(w,s),R=x.getMerkleAccountPublicKey(w,s),P=x.buildAnchorStealthAddressStructure(K),k=n.reduce((r,a)=>r+a,0n),_=await re.hinkalCheckSolanaTokenRegistry(o,new z.PublicKey(s),[i],[k]),b=n.map(r=>`${r}`);let q="";if(_){const{serializedTransaction:r,blockhash:a,lastValidBlockHeight:c}=await $.API.generateMultiPaymentDepositLimitless({amounts:b,payer:e.getSolanaPublicKey().toBase58(),ethereumAddress:await e.getEthereumAddressByChain(t),mint:i,stealthAddressStructure:P,chainId:t}),{wallet:u}=o.provider;if(!u)throw new Error("missing wallet");q=await te.signAndSendSerializedTransaction(o.provider,r,a,c)}else{const r=x.getTokenLimitStorageAccountPublicKey(o.programId,s,S),a=f===B.solanaNativeAddress?null:S,c=f===B.solanaNativeAddress?null:void 0;q=await o.methods.multiPaymentDeposit(b.map(O=>new J.BN(O)),P).accounts({mint:a,signer:V,signerAta:c,originalDeployer:s,storageAccount:U,storageVault:D,merkleAccount:R,tokenLimitStorage:r,storageVaultAta:c,accessTokenOwner:null}).rpc();const u=await o.provider.connection.getLatestBlockhash();await o.provider.connection.confirmTransaction({blockhash:u.blockhash,lastValidBlockHeight:u.lastValidBlockHeight,signature:q},"confirmed")}const T=await o.provider.connection.getTransaction(q,{commitment:"confirmed",maxSupportedTransactionVersion:0});if(!T)throw new Error("Transaction missing");const N=oe.getUtxosFromReceiptSolana(T,o,e.userKeys),E=[],v=[...N];return d.forEach((r,a)=>{const c=n[a],u=v.find(j=>j.amount===c);if(!u)throw new Error(`Could not find newly created UTXO with amount ${c} for recipient ${r}.`);E.push({recipientAddress:r,utxo:u});const O=v.indexOf(u);v.splice(O,1)}),E},ce=async(e,t,p,l,d,A,i)=>{const n=p.erc20TokenAddress;if(l.length===0)throw new Error("userDepositedUtxos must not be empty");const{hinkalIdl:m,originalDeployer:g}=L.networkRegistry[t].contractData;if(!g||!m)throw new Error("missing data");const h=e.getSolanaProgram(m),y=await e.getRandomRelay(t,!0);if(!y)throw new Error(W.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const C=Q.getCurrentTimeInSeconds().toString(),K=e.generateProofRemotely?5:1,o=[];for(let s=0;s<l.length;s+=K){const w=l.slice(s,s+K),S=await Promise.all(w.map(async({recipientAddress:f,utxo:U})=>{const{compressedAddress:D}=M.formatMintAddress(B.solanaNativeAddress),R=new F.Utxo({amount:0n,mintAddress:n,erc20TokenAddress:D,shieldedPrivateKey:e.userKeys.getShieldedPrivateKey(),timeStamp:C,tokenId:0}),P=[U,R],k=[R],_=F.Utxo.findCorrectRandomization(I.randomBigInt(31),e.userKeys.getShieldedPrivateKey()),b={tokenNumber:1,nullifierAmount:P.length,outputAmount:k.length},q=H.calcEncryptedOutputs([k])[0][0],T=Array.from(X.ethers.utils.arrayify(q)),{proofAArr:N,proofBArr:E,proofCArr:v,publicInputsArr:r}=await ne.constructSolanaZkProof(e.generateProofRemotely,g,e.merkleTreeHinkalByChain[t],e.merkleTreeAccessTokenByChain[t],e.userKeys,h,[n],[P],[k],_,d.flatFee,d.variableRate,f,y,b,[T],t,void 0,void 0,void 0,void 0,void 0,!1),a=n===B.solanaNativeAddress,c={recipient:f,mint:a?void 0:n};return{relayAddress:y,functionName:"transact",chainId:t,args:{proofAArr:N,proofBArr:E,proofCArr:v,publicInputsArr:r,encryptedOutputs:[T],relayerFee:d.flatFee.toString(),dimensions:b},accounts:c}}));o.push(...S)}return await se.solanaTransactCallRelayerBatch(t,o,A,i)},ue=async(e,t,p,l,d,A)=>{const i=Z.validateAndGetChainId([t]),n=t.erc20TokenAddress,m=Y.hashEthereumAddress(await e.getEthereumAddressByChain(i)),g=A??await ie.getFeeStructure(i,n,[n],G.ExternalActionId.Transact,[],0n),h=await ae(e,i,t,p,l,g);return ce(e,i,t,h,g,m,d)};exports.hinkalSolanaDepositAndWithdraw=ue;
@@ -1,30 +1,36 @@
1
- import { randomBigInt as F } from "../../functions/web3/etherFunctions.mjs";
1
+ import { randomBigInt as I } from "../../functions/web3/etherFunctions.mjs";
2
+ import "../../functions/web3/events/getInputUtxoAndBalance.mjs";
3
+ import "../../constants/token-data/index.mjs";
4
+ import { solanaNativeAddress as R } from "../../constants/protocol.constants.mjs";
5
+ import { networkRegistry as H } from "../../constants/chains.constants.mjs";
2
6
  import { Utxo as N } from "../utxo/Utxo.mjs";
3
7
  import { transactionErrorCodes as W } from "../../error-handling/error-codes.constants.mjs";
4
- import { ethers as _ } from "ethers";
5
8
  import "idb-keyval";
6
- import { networkRegistry as H } from "../../constants/chains.constants.mjs";
7
- import "../crypto-keys/keys.mjs";
8
- import "node-forge";
9
+ import { API as _ } from "../../API/API.mjs";
9
10
  import "../../constants/vite.constants.mjs";
10
- import "libsodium-wrappers";
11
- import "../http/HttpClient.mjs";
12
- import "axios";
13
- import { formatMintAddress as M } from "../../functions/utils/solanaMint.utils.mjs";
14
- import { PublicKey as L } from "@solana/web3.js";
15
- import { hashEthereumAddress as q } from "../../functions/utils/addresses.mjs";
16
- import "../../constants/server.constants.mjs";
17
- import "../../API/getServerURL.mjs";
18
- import "../../constants/token-data/index.mjs";
19
- import { solanaNativeAddress as B } from "../../constants/protocol.constants.mjs";
20
- import { API as G } from "../../API/API.mjs";
21
- import { validateAndGetChainId as X } from "../../functions/utils/token-check.utils.mjs";
11
+ import { validateAndGetChainId as q } from "../../functions/utils/token-check.utils.mjs";
22
12
  import "async-mutex";
13
+ import { formatMintAddress as M } from "../../functions/utils/solanaMint.utils.mjs";
23
14
  import "../../types/circom-data.types.mjs";
24
- import { ExternalActionId as Y } from "../../types/external-action.types.mjs";
15
+ import { ExternalActionId as G } from "../../types/external-action.types.mjs";
25
16
  import "../../types/transactions.types.mjs";
26
17
  import "../../types/activities.types.mjs";
27
18
  import "../../functions/web3/events/getApprovedBalance.mjs";
19
+ import { ethers as X } from "ethers";
20
+ import { PublicKey as L } from "@solana/web3.js";
21
+ import "../http/HttpClient.mjs";
22
+ import "../../functions/utils/convertIntegrationProviderToExternalActionId.mjs";
23
+ import "../../constants/server.constants.mjs";
24
+ import "../../API/getServerURL.mjs";
25
+ import "axios";
26
+ import { hashEthereumAddress as Y } from "../../functions/utils/addresses.mjs";
27
+ import { getStorageAccountPublicKey as Z, getStorageVaultPublicKey as j, getMerkleAccountPublicKey as J, buildAnchorStealthAddressStructure as Q, getTokenLimitStorageAccountPublicKey as tt } from "../../functions/pre-transaction/solana.mjs";
28
+ import "@solana/spl-token";
29
+ import "ethers-v6h";
30
+ import "tweetnacl";
31
+ import "bs58";
32
+ import { BN as ot } from "@coral-xyz/anchor";
33
+ import "buffer";
28
34
  import "../../constants/contracts.constants.mjs";
29
35
  import "../../constants/kyc.constants.mjs";
30
36
  import "../../constants/coingecko.constants.mjs";
@@ -35,68 +41,64 @@ import "../../constants/presale.constants.mjs";
35
41
  import "../../constants/activity.constants.mjs";
36
42
  import "../../constants/tasks.constants.mjs";
37
43
  import "../../constants/events.constants.mjs";
38
- import "../../functions/utils/convertIntegrationProviderToExternalActionId.mjs";
39
- import { getStorageAccountPublicKey as Z, getStorageVaultPublicKey as j, getMerkleAccountPublicKey as J, buildAnchorStealthAddressStructure as Q, getTokenLimitStorageAccountPublicKey as tt } from "../../functions/pre-transaction/solana.mjs";
40
- import "@solana/spl-token";
41
- import { BN as ot } from "@coral-xyz/anchor";
42
44
  import "../../functions/utils/userAgent.mjs";
43
45
  import { getCurrentTimeInSeconds as rt } from "../../functions/utils/time.utils.mjs";
44
46
  import "circomlibjs-hinkal-fork";
47
+ import "../crypto-keys/keys.mjs";
48
+ import "libsodium-wrappers";
45
49
  import "multiformats";
46
- import "../../API/tenderly.api.mjs";
47
50
  import "process";
48
- import "buffer";
49
51
  import "../../providers/EthersProviderAdapter.mjs";
50
52
  import { calculateTotalFee as et } from "../../functions/utils/fees.utils.mjs";
51
53
  import "../../functions/web3/getTokenHolder.mjs";
52
- import { signAndSendSerializedTransaction as nt } from "../../functions/web3/signAndSendSerializedTransaction.mjs";
53
- import { calcStealthAddressStructure as it, calcEncryptedOutputs as st } from "../../functions/snarkjs/common.snarkjs.mjs";
54
+ import { signAndSendSerializedTransaction as it } from "../../functions/web3/signAndSendSerializedTransaction.mjs";
55
+ import { calcStealthAddressStructure as nt, calcEncryptedOutputs as st } from "../../functions/snarkjs/common.snarkjs.mjs";
54
56
  import { hinkalCheckSolanaTokenRegistry as at } from "./hinkalCheckSolanaTokenRegistry.mjs";
55
57
  import { getUtxosFromReceiptSolana as ct } from "../../functions/utils/getUtxosFromReceiptSolana.mjs";
56
58
  import { constructSolanaZkProof as mt } from "../../functions/snarkjs/constructSolanaZkProof.mjs";
57
59
  import { solanaTransactCallRelayerBatch as lt } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
58
60
  import { getFeeStructure as dt } from "../../functions/pre-transaction/getFeeStructure.mjs";
59
- const pt = async (t, o, y, l, d, w) => {
60
- const s = y.erc20TokenAddress, n = l.map((r) => r + et(r, w)), { hinkalIdl: p, hinkalAddress: u, originalDeployer: g } = H[o].contractData;
61
+ const pt = async (t, o, h, l, d, w) => {
62
+ const s = h.erc20TokenAddress, i = l.map((r) => r + et(r, w)), { hinkalIdl: p, hinkalAddress: u, originalDeployer: g } = H[o].contractData;
61
63
  if (!p)
62
64
  throw new Error("No IDL configured for Solana program on this network");
63
65
  if (!g)
64
66
  throw new Error("missing original deployer");
65
- const f = t.userKeys.getShieldedPrivateKey(), D = N.findCorrectRandomization(F(31), f), E = it(D, f), e = t.getSolanaProgram(p), I = t.getSolanaPublicKey(), i = new L(g), A = new L(u), { mintPublicKey: S } = M(s), P = S.toString(), C = Z(A, i), U = j(A, i), K = J(A, i), T = Q(E), v = n.reduce((r, c) => r + c, 0n), O = await at(
67
+ const f = t.userKeys.getShieldedPrivateKey(), C = N.findCorrectRandomization(I(31), f), E = nt(C, f), e = t.getSolanaProgram(p), F = t.getSolanaPublicKey(), n = new L(g), A = new L(u), { mintPublicKey: S } = M(s), P = S.toString(), D = Z(A, n), U = j(A, n), K = J(A, n), T = Q(E), v = i.reduce((r, c) => r + c, 0n), O = await at(
66
68
  e,
67
- new L(i),
69
+ new L(n),
68
70
  [s],
69
71
  [v]
70
- ), b = n.map((r) => `${r}`);
71
- let h = "";
72
+ ), b = i.map((r) => `${r}`);
73
+ let y = "";
72
74
  if (O) {
73
- const { serializedTransaction: r, blockhash: c, lastValidBlockHeight: a } = await G.generateMultiPaymentDepositLimitless({
75
+ const { serializedTransaction: r, blockhash: c, lastValidBlockHeight: a } = await _.generateMultiPaymentDepositLimitless({
74
76
  amounts: b,
75
77
  payer: t.getSolanaPublicKey().toBase58(),
76
- ethereumAddress: await t.getEthereumAddress(),
78
+ ethereumAddress: await t.getEthereumAddressByChain(o),
77
79
  mint: s,
78
80
  stealthAddressStructure: T,
79
81
  chainId: o
80
82
  }), { wallet: m } = e.provider;
81
83
  if (!m)
82
84
  throw new Error("missing wallet");
83
- h = await nt(
85
+ y = await it(
84
86
  e.provider,
85
87
  r,
86
88
  c,
87
89
  a
88
90
  );
89
91
  } else {
90
- const r = tt(e.programId, i, S), c = P === B ? null : S, a = P === B ? null : void 0;
91
- h = await e.methods.multiPaymentDeposit(
92
+ const r = tt(e.programId, n, S), c = P === R ? null : S, a = P === R ? null : void 0;
93
+ y = await e.methods.multiPaymentDeposit(
92
94
  b.map((z) => new ot(z)),
93
95
  T
94
96
  ).accounts({
95
97
  mint: c,
96
- signer: I,
98
+ signer: F,
97
99
  signerAta: a,
98
- originalDeployer: i,
99
- storageAccount: C,
100
+ originalDeployer: n,
101
+ storageAccount: D,
100
102
  storageVault: U,
101
103
  merkleAccount: K,
102
104
  tokenLimitStorage: r,
@@ -108,31 +110,31 @@ const pt = async (t, o, y, l, d, w) => {
108
110
  {
109
111
  blockhash: m.blockhash,
110
112
  lastValidBlockHeight: m.lastValidBlockHeight,
111
- signature: h
113
+ signature: y
112
114
  },
113
115
  "confirmed"
114
116
  );
115
117
  }
116
- const x = await e.provider.connection.getTransaction(h, {
118
+ const x = await e.provider.connection.getTransaction(y, {
117
119
  commitment: "confirmed",
118
120
  maxSupportedTransactionVersion: 0
119
121
  });
120
122
  if (!x)
121
123
  throw new Error("Transaction missing");
122
- const V = ct(x, e, t.userKeys), R = [], k = [...V];
124
+ const V = ct(x, e, t.userKeys), B = [], k = [...V];
123
125
  return d.forEach((r, c) => {
124
- const a = n[c], m = k.find(($) => $.amount === a);
126
+ const a = i[c], m = k.find(($) => $.amount === a);
125
127
  if (!m)
126
128
  throw new Error(`Could not find newly created UTXO with amount ${a} for recipient ${r}.`);
127
- R.push({
129
+ B.push({
128
130
  recipientAddress: r,
129
131
  utxo: m
130
132
  });
131
133
  const z = k.indexOf(m);
132
134
  k.splice(z, 1);
133
- }), R;
134
- }, ut = async (t, o, y, l, d, w, s) => {
135
- const n = y.erc20TokenAddress;
135
+ }), B;
136
+ }, ut = async (t, o, h, l, d, w, s) => {
137
+ const i = h.erc20TokenAddress;
136
138
  if (l.length === 0)
137
139
  throw new Error("userDepositedUtxos must not be empty");
138
140
  const { hinkalIdl: p, originalDeployer: u } = H[o].contractData;
@@ -141,32 +143,32 @@ const pt = async (t, o, y, l, d, w) => {
141
143
  const g = t.getSolanaProgram(p), f = await t.getRandomRelay(o, !0);
142
144
  if (!f)
143
145
  throw new Error(W.RELAYER_NOT_AVAILABLE);
144
- const D = rt().toString(), E = t.generateProofRemotely ? 5 : 1, e = [];
145
- for (let i = 0; i < l.length; i += E) {
146
- const A = l.slice(i, i + E), S = await Promise.all(
147
- A.map(async ({ recipientAddress: P, utxo: C }) => {
148
- const { compressedAddress: U } = M(B), K = new N({
146
+ const C = rt().toString(), E = t.generateProofRemotely ? 5 : 1, e = [];
147
+ for (let n = 0; n < l.length; n += E) {
148
+ const A = l.slice(n, n + E), S = await Promise.all(
149
+ A.map(async ({ recipientAddress: P, utxo: D }) => {
150
+ const { compressedAddress: U } = M(R), K = new N({
149
151
  amount: 0n,
150
- mintAddress: n,
152
+ mintAddress: i,
151
153
  erc20TokenAddress: U,
152
154
  shieldedPrivateKey: t.userKeys.getShieldedPrivateKey(),
153
- timeStamp: D,
155
+ timeStamp: C,
154
156
  tokenId: 0
155
- }), T = [C, K], v = [K], O = N.findCorrectRandomization(
156
- F(31),
157
+ }), T = [D, K], v = [K], O = N.findCorrectRandomization(
158
+ I(31),
157
159
  t.userKeys.getShieldedPrivateKey()
158
160
  ), b = {
159
161
  tokenNumber: 1,
160
162
  nullifierAmount: T.length,
161
163
  outputAmount: v.length
162
- }, h = st([v])[0][0], x = Array.from(_.utils.arrayify(h)), { proofAArr: V, proofBArr: R, proofCArr: k, publicInputsArr: r } = await mt(
164
+ }, y = st([v])[0][0], x = Array.from(X.utils.arrayify(y)), { proofAArr: V, proofBArr: B, proofCArr: k, publicInputsArr: r } = await mt(
163
165
  t.generateProofRemotely,
164
166
  u,
165
167
  t.merkleTreeHinkalByChain[o],
166
168
  t.merkleTreeAccessTokenByChain[o],
167
169
  t.userKeys,
168
170
  g,
169
- [n],
171
+ [i],
170
172
  [T],
171
173
  [v],
172
174
  O,
@@ -185,7 +187,7 @@ const pt = async (t, o, y, l, d, w) => {
185
187
  !1
186
188
  ), a = {
187
189
  recipient: P,
188
- mint: n === B ? void 0 : n
190
+ mint: i === R ? void 0 : i
189
191
  };
190
192
  return {
191
193
  relayAddress: f,
@@ -193,7 +195,7 @@ const pt = async (t, o, y, l, d, w) => {
193
195
  chainId: o,
194
196
  args: {
195
197
  proofAArr: V,
196
- proofBArr: R,
198
+ proofBArr: B,
197
199
  proofCArr: k,
198
200
  publicInputsArr: r,
199
201
  encryptedOutputs: [x],
@@ -212,12 +214,12 @@ const pt = async (t, o, y, l, d, w) => {
212
214
  w,
213
215
  s
214
216
  );
215
- }, Ao = async (t, o, y, l, d, w) => {
216
- const s = X([o]), n = o.erc20TokenAddress, p = q(await t.getEthereumAddress()), u = w ?? await dt(s, n, [n], Y.Transact, [], 0n), g = await pt(
217
+ }, Po = async (t, o, h, l, d, w) => {
218
+ const s = q([o]), i = o.erc20TokenAddress, p = Y(await t.getEthereumAddressByChain(s)), u = w ?? await dt(s, i, [i], G.Transact, [], 0n), g = await pt(
217
219
  t,
218
220
  s,
219
221
  o,
220
- y,
222
+ h,
221
223
  l,
222
224
  u
223
225
  );
@@ -232,5 +234,5 @@ const pt = async (t, o, y, l, d, w) => {
232
234
  );
233
235
  };
234
236
  export {
235
- Ao as hinkalSolanaDepositAndWithdraw
237
+ Po as hinkalSolanaDepositAndWithdraw
236
238
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@solana/web3.js"),P=require("../../constants/chains.constants.cjs"),y=require("../../functions/pre-transaction/sendV0Transaction.cjs"),f=require("../../functions/pre-transaction/solanaTransfer.utils.cjs"),h=require("../crypto-keys/keys.cjs"),g=require("../../functions/utils/create-provider.cjs"),w=require("../../functions/utils/token-check.utils.cjs"),S=async(e,a,r,o)=>{const n=w.validateAndGetChainId([e]),t=h.UserKeys.getSignerAddressFromPrivateKey(n,r.privateKey),{fetchRpcUrl:s}=P.networkRegistry[n];if(!s)throw new Error("RPC URL not found for the specified chain ID");const i=g.createCustomSolanaConnection(s),c=new u.PublicKey(t),{instructions:d,programId:l}=await f.buildSolanaTransferInstructions(i,c,new u.PublicKey(o),e,a);return{connection:i,chainId:n,senderAddress:t,senderPublickey:c,programId:l,instructions:d}},b=async(e,a,r,o,n=!1)=>{if(n)throw new Error("onlyGasEstimate is not supported for Solana proxy send");const{connection:t,chainId:s,senderAddress:i,senderPublickey:c,programId:d,instructions:l}=await S(e,a,r,o);return y.sendProxyV0Transaction({connection:t,chainId:s,subAccount:r,payerPublicKey:c,instructions:l,convertParams:{fromAddress:i,toAddress:o,programAddress:d.toString()}})},p=async(e,a,r,o)=>{const{connection:n,senderPublickey:t,instructions:s}=await S(e,a,r,o);return y.serializeProxyV0Transaction(n,t,s)};exports.getSolanaProxySendSerializedTransaction=p;exports.hinkalSolanaProxySend=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@solana/web3.js"),P=require("../../constants/chains.constants.cjs"),y=require("../../functions/pre-transaction/sendV0Transaction.cjs"),b=require("../../functions/pre-transaction/solanaTransfer.utils.cjs"),f=require("../../functions/utils/create-provider.cjs"),h=require("../../functions/utils/token-check.utils.cjs"),w=require("../AccountActions/AccountActions.cjs"),S=async(r,a,o,t)=>{const n=h.validateAndGetChainId([r]),e=w.AccountActions.getAddressFromSubAccount(n,o);if(!e)throw Error("Public account address is not available");const{fetchRpcUrl:s}=P.networkRegistry[n];if(!s)throw new Error("RPC URL not found for the specified chain ID");const i=f.createCustomSolanaConnection(s),c=new u.PublicKey(e),{instructions:d,programId:l}=await b.buildSolanaTransferInstructions(i,c,new u.PublicKey(t),r,a);return{connection:i,chainId:n,senderAddress:e,senderPublickey:c,programId:l,instructions:d}},g=async(r,a,o,t,n=!1)=>{if(n)throw new Error("onlyGasEstimate is not supported for Solana proxy send");const{connection:e,chainId:s,senderAddress:i,senderPublickey:c,programId:d,instructions:l}=await S(r,a,o,t);return y.sendProxyV0Transaction({connection:e,chainId:s,subAccount:o,payerPublicKey:c,instructions:l,convertParams:{fromAddress:i,toAddress:t,programAddress:d.toString()}})},A=async(r,a,o,t)=>{const{connection:n,senderPublickey:e,instructions:s}=await S(r,a,o,t);return y.serializeProxyV0Transaction(n,e,s)};exports.getSolanaProxySendSerializedTransaction=A;exports.hinkalSolanaProxySend=g;