@hinkal/common 0.3.9 → 0.3.11

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 (275) hide show
  1. package/README.md +26 -10
  2. package/common/src/API/API.cjs +1 -1
  3. package/common/src/API/API.d.ts +4 -5
  4. package/common/src/API/API.mjs +79 -80
  5. package/common/src/API/callRelayer.d.ts +1 -0
  6. package/common/src/API/dashboardTransactionCalls.cjs +1 -1
  7. package/common/src/API/dashboardTransactionCalls.d.ts +4 -1
  8. package/common/src/API/dashboardTransactionCalls.mjs +2 -2
  9. package/common/src/API/enclaveRecipientInfoCalls.d.ts +0 -2
  10. package/common/src/API/enclaveSignatureCalls.cjs +1 -1
  11. package/common/src/API/enclaveSignatureCalls.d.ts +2 -1
  12. package/common/src/API/enclaveSignatureCalls.mjs +5 -8
  13. package/common/src/API/enclaveUtxoCalls.cjs +1 -1
  14. package/common/src/API/enclaveUtxoCalls.d.ts +12 -8
  15. package/common/src/API/enclaveUtxoCalls.mjs +17 -20
  16. package/common/src/API/privateSendRecipientInfoCalls.cjs +1 -1
  17. package/common/src/API/privateSendRecipientInfoCalls.d.ts +3 -6
  18. package/common/src/API/privateSendRecipientInfoCalls.mjs +12 -6
  19. package/common/src/API/scheduled-transactions-calls.cjs +1 -1
  20. package/common/src/API/scheduled-transactions-calls.d.ts +1 -5
  21. package/common/src/API/scheduled-transactions-calls.mjs +2 -6
  22. package/common/src/constants/bridging.constants.cjs +1 -1
  23. package/common/src/constants/bridging.constants.d.ts +1 -0
  24. package/common/src/constants/bridging.constants.mjs +1 -1
  25. package/common/src/constants/chains.constants.cjs +1 -1
  26. package/common/src/constants/chains.constants.d.ts +18 -17
  27. package/common/src/constants/chains.constants.mjs +108 -89
  28. package/common/src/constants/deploy-data/deploy-data-arbMainnet.json.cjs +1 -1
  29. package/common/src/constants/deploy-data/deploy-data-arbMainnet.json.mjs +2 -1
  30. package/common/src/constants/deploy-data/deploy-data-base.json.cjs +1 -1
  31. package/common/src/constants/deploy-data/deploy-data-base.json.mjs +2 -1
  32. package/common/src/constants/deploy-data/deploy-data-bnbMainnet.json.cjs +1 -1
  33. package/common/src/constants/deploy-data/deploy-data-bnbMainnet.json.mjs +2 -1
  34. package/common/src/constants/deploy-data/deploy-data-ethMainnet.json.cjs +1 -1
  35. package/common/src/constants/deploy-data/deploy-data-ethMainnet.json.mjs +2 -1
  36. package/common/src/constants/deploy-data/deploy-data-optimism.json.cjs +1 -1
  37. package/common/src/constants/deploy-data/deploy-data-optimism.json.mjs +2 -1
  38. package/common/src/constants/deploy-data/deploy-data-polygon.json.cjs +1 -1
  39. package/common/src/constants/deploy-data/deploy-data-polygon.json.mjs +2 -1
  40. package/common/src/constants/events.constants.cjs +1 -1
  41. package/common/src/constants/events.constants.mjs +1 -16
  42. package/common/src/constants/protocol.constants.cjs +1 -1
  43. package/common/src/constants/protocol.constants.d.ts +11 -8
  44. package/common/src/constants/protocol.constants.mjs +1 -1
  45. package/common/src/constants/server.constants.cjs +1 -1
  46. package/common/src/constants/server.constants.d.ts +1 -4
  47. package/common/src/constants/server.constants.mjs +1 -4
  48. package/common/src/constants/tx-confirmation.constants.cjs +1 -1
  49. package/common/src/constants/tx-confirmation.constants.d.ts +1 -0
  50. package/common/src/constants/tx-confirmation.constants.mjs +2 -2
  51. package/common/src/data-structures/Hinkal/Hinkal.cjs +1 -1
  52. package/common/src/data-structures/Hinkal/Hinkal.d.ts +8 -10
  53. package/common/src/data-structures/Hinkal/Hinkal.mjs +132 -160
  54. package/common/src/data-structures/Hinkal/IHinkal.d.ts +7 -10
  55. package/common/src/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
  56. package/common/src/data-structures/Hinkal/handleAutoDepositBack.mjs +23 -23
  57. package/common/src/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
  58. package/common/src/data-structures/Hinkal/hinkalActionReceive.mjs +1 -1
  59. package/common/src/data-structures/Hinkal/hinkalBridgePrivateToPrivate.cjs +1 -1
  60. package/common/src/data-structures/Hinkal/hinkalBridgePrivateToPrivate.mjs +57 -57
  61. package/common/src/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
  62. package/common/src/data-structures/Hinkal/hinkalDeposit.mjs +10 -10
  63. package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
  64. package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +19 -19
  65. package/common/src/data-structures/Hinkal/hinkalNearDepositAndBridge.cjs +1 -1
  66. package/common/src/data-structures/Hinkal/hinkalNearDepositAndBridge.mjs +3 -2
  67. package/common/src/data-structures/Hinkal/hinkalProxySend.cjs +1 -0
  68. package/common/src/data-structures/Hinkal/hinkalProxySend.d.ts +6 -0
  69. package/common/src/data-structures/Hinkal/hinkalProxySend.mjs +16 -0
  70. package/common/src/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
  71. package/common/src/data-structures/Hinkal/hinkalProxySwap.d.ts +1 -1
  72. package/common/src/data-structures/Hinkal/hinkalProxySwap.mjs +13 -12
  73. package/common/src/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
  74. package/common/src/data-structures/Hinkal/hinkalProxyToPrivate.mjs +1 -1
  75. package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
  76. package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +1 -1
  77. package/common/src/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
  78. package/common/src/data-structures/Hinkal/hinkalSolanaProxySwap.d.ts +1 -1
  79. package/common/src/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +9 -9
  80. package/common/src/data-structures/Hinkal/hinkalSolanaSponsoredShield.cjs +1 -1
  81. package/common/src/data-structures/Hinkal/hinkalSolanaSponsoredShield.d.ts +1 -1
  82. package/common/src/data-structures/Hinkal/hinkalSolanaSponsoredShield.mjs +15 -14
  83. package/common/src/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
  84. package/common/src/data-structures/Hinkal/hinkalSolanaSwap.mjs +44 -47
  85. package/common/src/data-structures/Hinkal/hinkalSolanaTransact.cjs +1 -1
  86. package/common/src/data-structures/Hinkal/hinkalSolanaTransact.mjs +2 -2
  87. package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
  88. package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.mjs +1 -1
  89. package/common/src/data-structures/Hinkal/hinkalTransact.cjs +1 -1
  90. package/common/src/data-structures/Hinkal/hinkalTransact.mjs +1 -1
  91. package/common/src/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
  92. package/common/src/data-structures/Hinkal/hinkalTransfer.mjs +4 -4
  93. package/common/src/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
  94. package/common/src/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +101 -94
  95. package/common/src/data-structures/Hinkal/index.d.ts +0 -1
  96. package/common/src/data-structures/IndexedDB/activity-db.cjs +1 -1
  97. package/common/src/data-structures/IndexedDB/activity-db.mjs +34 -34
  98. package/common/src/data-structures/IndexedDB/index.cjs +1 -1
  99. package/common/src/data-structures/IndexedDB/index.d.ts +1 -0
  100. package/common/src/data-structures/IndexedDB/index.mjs +1 -0
  101. package/common/src/data-structures/IndexedDB/scheduled-transactions-db.cjs +1 -0
  102. package/common/src/data-structures/IndexedDB/scheduled-transactions-db.d.ts +11 -0
  103. package/common/src/data-structures/IndexedDB/scheduled-transactions-db.mjs +34 -0
  104. package/common/src/data-structures/IndexedDB/signatures-db.cjs +1 -1
  105. package/common/src/data-structures/IndexedDB/signatures-db.mjs +11 -11
  106. package/common/src/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs +1 -1
  107. package/common/src/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.d.ts +1 -0
  108. package/common/src/data-structures/MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.mjs +6 -3
  109. package/common/src/data-structures/TokenDBs/PrivateTokensDB.cjs +1 -1
  110. package/common/src/data-structures/TokenDBs/PrivateTokensDB.mjs +18 -19
  111. package/common/src/data-structures/crypto-keys/keys.cjs +1 -1
  112. package/common/src/data-structures/crypto-keys/keys.d.ts +1 -0
  113. package/common/src/data-structures/crypto-keys/keys.mjs +3 -0
  114. package/common/src/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
  115. package/common/src/data-structures/event-service/evm/BlockchainEventEmitter.mjs +11 -11
  116. package/common/src/data-structures/event-service/helpers/ClientEventHelper.cjs +1 -1
  117. package/common/src/data-structures/event-service/helpers/ClientEventHelper.mjs +6 -6
  118. package/common/src/data-structures/private-balances/HinkalPrivateBalanceController.cjs +1 -1
  119. package/common/src/data-structures/private-balances/HinkalPrivateBalanceController.d.ts +1 -0
  120. package/common/src/data-structures/private-balances/HinkalPrivateBalanceController.mjs +79 -75
  121. package/common/src/data-structures/provider-adapter/IProviderAdapter.d.ts +1 -4
  122. package/common/src/data-structures/token-price-fetcher/TokenChecker.cjs +1 -1
  123. package/common/src/data-structures/token-price-fetcher/TokenChecker.d.ts +1 -0
  124. package/common/src/data-structures/token-price-fetcher/TokenChecker.mjs +1 -0
  125. package/common/src/error-handling/error-codes.constants.cjs +1 -1
  126. package/common/src/error-handling/error-codes.constants.d.ts +6 -0
  127. package/common/src/error-handling/error-codes.constants.mjs +10 -4
  128. package/common/src/functions/auto-deposit-back-helpers/get-gas-token-records.cjs +1 -1
  129. package/common/src/functions/auto-deposit-back-helpers/get-gas-token-records.mjs +7 -6
  130. package/common/src/functions/auto-deposit-back-helpers/select-gas-token.cjs +1 -1
  131. package/common/src/functions/auto-deposit-back-helpers/select-gas-token.mjs +8 -8
  132. package/common/src/functions/index.cjs +1 -1
  133. package/common/src/functions/index.mjs +1 -2
  134. package/common/src/functions/pre-transaction/getVolatileTransferAmount.cjs +1 -1
  135. package/common/src/functions/pre-transaction/getVolatileTransferAmount.mjs +13 -13
  136. package/common/src/functions/private-wallet/emporium.helpers.cjs +1 -1
  137. package/common/src/functions/private-wallet/emporium.helpers.mjs +13 -13
  138. package/common/src/functions/private-wallet/emporium.swap.helpers.cjs +1 -1
  139. package/common/src/functions/private-wallet/emporium.swap.helpers.mjs +13 -13
  140. package/common/src/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
  141. package/common/src/functions/snarkjs/constructGeneralZkProof.mjs +4 -4
  142. package/common/src/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
  143. package/common/src/functions/snarkjs/constructSolanaZkProof.mjs +5 -5
  144. package/common/src/functions/snarkjs/constructTxEnclave.cjs +1 -1
  145. package/common/src/functions/snarkjs/constructTxEnclave.d.ts +1 -1
  146. package/common/src/functions/snarkjs/constructTxEnclave.mjs +61 -133
  147. package/common/src/functions/snarkjs/constructTxEnclaveVerify.cjs +1 -0
  148. package/common/src/functions/snarkjs/constructTxEnclaveVerify.d.ts +5 -0
  149. package/common/src/functions/snarkjs/constructTxEnclaveVerify.mjs +295 -0
  150. package/common/src/functions/utils/addresses.cjs +1 -1
  151. package/common/src/functions/utils/addresses.d.ts +1 -0
  152. package/common/src/functions/utils/addresses.mjs +13 -12
  153. package/common/src/functions/utils/bridge-arrival.utils.cjs +1 -1
  154. package/common/src/functions/utils/bridge-arrival.utils.mjs +12 -11
  155. package/common/src/functions/utils/bridge-claimable-utxo.utils.cjs +1 -1
  156. package/common/src/functions/utils/bridge-claimable-utxo.utils.d.ts +1 -1
  157. package/common/src/functions/utils/bridge-claimable-utxo.utils.mjs +4 -4
  158. package/common/src/functions/utils/create-provider.cjs +1 -1
  159. package/common/src/functions/utils/create-provider.mjs +4 -1
  160. package/common/src/functions/utils/enclave-recipient-info-storage.cjs +1 -1
  161. package/common/src/functions/utils/enclave-recipient-info-storage.d.ts +4 -1
  162. package/common/src/functions/utils/enclave-recipient-info-storage.mjs +1 -0
  163. package/common/src/functions/utils/enclave-signature-storage.cjs +1 -1
  164. package/common/src/functions/utils/enclave-signature-storage.d.ts +1 -1
  165. package/common/src/functions/utils/enclave-signature-storage.mjs +3 -3
  166. package/common/src/functions/utils/enclave-utxo-storage.cjs +1 -1
  167. package/common/src/functions/utils/enclave-utxo-storage.d.ts +3 -3
  168. package/common/src/functions/utils/enclave-utxo-storage.mjs +8 -5
  169. package/common/src/functions/utils/encryptInputForEnclave.cjs +1 -1
  170. package/common/src/functions/utils/encryptInputForEnclave.d.ts +8 -0
  171. package/common/src/functions/utils/encryptInputForEnclave.mjs +43 -23
  172. package/common/src/functions/utils/erc20tokenFunctions.cjs +1 -1
  173. package/common/src/functions/utils/erc20tokenFunctions.mjs +2 -15
  174. package/common/src/functions/utils/fees.utils.cjs +1 -1
  175. package/common/src/functions/utils/fees.utils.mjs +6 -6
  176. package/common/src/functions/utils/index.cjs +1 -1
  177. package/common/src/functions/utils/index.d.ts +1 -0
  178. package/common/src/functions/utils/index.mjs +3 -3
  179. package/common/src/functions/utils/ipfs.d.ts +2 -3
  180. package/common/src/functions/utils/lifi.utils.d.ts +2 -0
  181. package/common/src/functions/utils/nearIntents.utils.cjs +1 -1
  182. package/common/src/functions/utils/nearIntents.utils.mjs +7 -7
  183. package/common/src/functions/utils/publicBalance.utils.cjs +1 -1
  184. package/common/src/functions/utils/publicBalance.utils.mjs +10 -10
  185. package/common/src/functions/utils/temporary-wallet-recovery.utils.cjs +1 -0
  186. package/common/src/functions/utils/temporary-wallet-recovery.utils.d.ts +7 -0
  187. package/common/src/functions/utils/temporary-wallet-recovery.utils.mjs +10 -0
  188. package/common/src/functions/utils/tron.utils.cjs +1 -1
  189. package/common/src/functions/utils/tron.utils.mjs +16 -29
  190. package/common/src/functions/utils/tx-confirmation.utils.cjs +1 -1
  191. package/common/src/functions/utils/tx-confirmation.utils.d.ts +1 -0
  192. package/common/src/functions/utils/tx-confirmation.utils.mjs +16 -13
  193. package/common/src/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
  194. package/common/src/functions/web3/events/getInputUtxoAndBalance.mjs +5 -5
  195. package/common/src/functions/web3/events/getInputUtxosEnclave.cjs +1 -1
  196. package/common/src/functions/web3/events/getInputUtxosEnclave.d.ts +1 -1
  197. package/common/src/functions/web3/events/getInputUtxosEnclave.mjs +19 -11
  198. package/common/src/functions/web3/events/getShieldedBalance.cjs +1 -1
  199. package/common/src/functions/web3/events/getShieldedBalance.d.ts +4 -4
  200. package/common/src/functions/web3/events/getShieldedBalance.mjs +113 -101
  201. package/common/src/functions/web3/functionCalls/transactCallDirectTron.cjs +1 -1
  202. package/common/src/functions/web3/functionCalls/transactCallDirectTron.mjs +16 -16
  203. package/common/src/providers/SolanaProviderAdapter.cjs +1 -1
  204. package/common/src/providers/SolanaProviderAdapter.d.ts +1 -4
  205. package/common/src/providers/SolanaProviderAdapter.mjs +3 -6
  206. package/common/src/providers/WagmiProviderAdapter.cjs +1 -1
  207. package/common/src/providers/WagmiProviderAdapter.mjs +5 -5
  208. package/common/src/types/cache.types.cjs +1 -1
  209. package/common/src/types/cache.types.d.ts +2 -1
  210. package/common/src/types/cache.types.mjs +1 -1
  211. package/common/src/types/enclaveApi.types.d.ts +2 -3
  212. package/common/src/types/ethereum-network.types.d.ts +1 -0
  213. package/common/src/types/events.types.d.ts +1 -0
  214. package/common/src/types/near-intents.types.d.ts +1 -0
  215. package/common/src/types/remote-proof.types.d.ts +5 -0
  216. package/common/src/types/remote-tx-build.types.d.ts +37 -4
  217. package/common/src/types/scheduled-transactions.types.d.ts +18 -0
  218. package/common/src/types/solana.types.d.ts +0 -3
  219. package/common/src/webworker/{logError-RKYfeI6h.js → logError-cvFNxc-0.js} +1 -1
  220. package/common/src/webworker/package.json +1 -2
  221. package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.cjs +1 -1
  222. package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.mjs +1 -1
  223. package/common/src/webworker/snarkjsWorkerNode.cjs +1 -1
  224. package/common/src/webworker/utxoWorker/utxoWorker.types.d.ts +4 -2
  225. package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.cjs +1 -1
  226. package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.mjs +1 -1
  227. package/common/src/webworker/utxoWorkerNode.cjs +1 -1
  228. package/common/src/webworker/viteWorkerURL.constant.cjs +3 -3
  229. package/common/src/webworker/viteWorkerURL.constant.mjs +3 -3
  230. package/common/src/webworker/workerProxy-BHzCZ9HT.js +1 -0
  231. package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.cjs +1 -1
  232. package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.mjs +1 -1
  233. package/common/src/webworker/zkProofWorkerNode.cjs +1 -1
  234. package/package.json +1 -2
  235. package/providers/prepareEthersHinkal.cjs +1 -1
  236. package/providers/prepareEthersHinkal.d.ts +1 -0
  237. package/providers/prepareEthersHinkal.mjs +2 -2
  238. package/providers/prepareSolanaHinkal.cjs +1 -1
  239. package/providers/prepareSolanaHinkal.d.ts +1 -0
  240. package/providers/prepareSolanaHinkal.mjs +2 -2
  241. package/providers/prepareTronHinkal.cjs +1 -1
  242. package/providers/prepareTronHinkal.d.ts +1 -0
  243. package/providers/prepareTronHinkal.mjs +2 -2
  244. package/providers/prepareWagmiHinkal.cjs +1 -1
  245. package/providers/prepareWagmiHinkal.d.ts +1 -0
  246. package/providers/prepareWagmiHinkal.mjs +2 -2
  247. package/services/Hinkal.cjs +1 -1
  248. package/services/Hinkal.d.ts +8 -2
  249. package/services/Hinkal.mjs +15 -4
  250. package/types/IHinkal.d.ts +8 -2
  251. package/common/src/API/evm-token-assets.cjs +0 -1
  252. package/common/src/API/evm-token-assets.mjs +0 -20
  253. package/common/src/API/getAnyRecipientInfo.d.ts +0 -1
  254. package/common/src/API/solana-nft-assets.cjs +0 -1
  255. package/common/src/API/solana-nft-assets.mjs +0 -11
  256. package/common/src/data-structures/Hinkal/hinkalSolanaSponsoredProxySend.d.ts +0 -5
  257. package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.cjs +0 -1
  258. package/common/src/data-structures/TokenDBs/AlchemyPublicTokensDB.mjs +0 -109
  259. package/common/src/data-structures/TokenDBs/ArcPublicTokensDB.cjs +0 -1
  260. package/common/src/data-structures/TokenDBs/ArcPublicTokensDB.mjs +0 -94
  261. package/common/src/data-structures/TokenDBs/EventsPublicTokensDB.cjs +0 -1
  262. package/common/src/data-structures/TokenDBs/EventsPublicTokensDB.mjs +0 -134
  263. package/common/src/data-structures/TokenDBs/PublicTokensDB.cjs +0 -1
  264. package/common/src/data-structures/TokenDBs/PublicTokensDB.mjs +0 -32
  265. package/common/src/data-structures/TokenDBs/TempoPublicTokensDB.cjs +0 -1
  266. package/common/src/data-structures/TokenDBs/TempoPublicTokensDB.mjs +0 -37
  267. package/common/src/data-structures/TokenDBs/TronPublicTokensDB.cjs +0 -1
  268. package/common/src/data-structures/TokenDBs/TronPublicTokensDB.mjs +0 -51
  269. package/common/src/data-structures/TokenDBs/index.cjs +0 -1
  270. package/common/src/data-structures/TokenDBs/index.mjs +0 -6
  271. package/common/src/functions/utils/ipfs.cjs +0 -1
  272. package/common/src/functions/utils/ipfs.mjs +0 -1
  273. package/common/src/functions/utils/reloadPage.cjs +0 -1
  274. package/common/src/functions/utils/reloadPage.mjs +0 -4
  275. package/common/src/webworker/workerProxy-COB7g4Qc.js +0 -1
@@ -4,15 +4,15 @@ import { gasErrorCodes as r, transactionErrorCodes as i } from "../../error-hand
4
4
  import { getAmountInToken as a } from "../../functions/web3/etherFunctions.mjs";
5
5
  import { waitLittle as ee } from "../../functions/utils/time.utils.mjs";
6
6
  import { ErrorWithRelayerTransaction as o } from "../../error-handling/customErrors/ErrorWithTx.mjs";
7
- import { ExternalActionId as s } from "../../types/external-action.types.mjs";
8
- import { TransactionStatus as c } from "../../types/transactions.types.mjs";
9
- import { AdminTransactionType as l } from "../../types/admin.types.mjs";
10
- import { ActivityTypes as u } from "../../types/activities.types.mjs";
11
- import { TransactionRequestType as d } from "../../types/transaction.types.mjs";
12
- import { MessagesFromOffscreen as f } from "../../types/offscreen.types.mjs";
7
+ import { Logger as s } from "../../error-handling/logger.mjs";
8
+ import { ExternalActionId as c } from "../../types/external-action.types.mjs";
9
+ import { TransactionStatus as l } from "../../types/transactions.types.mjs";
10
+ import { AdminTransactionType as u } from "../../types/admin.types.mjs";
11
+ import { ActivityTypes as d } from "../../types/activities.types.mjs";
12
+ import { TransactionRequestType as f } from "../../types/transaction.types.mjs";
13
+ import { MessagesFromOffscreen as p } from "../../types/offscreen.types.mjs";
13
14
  import "../../types/index.mjs";
14
- import { API as p } from "../../API/API.mjs";
15
- import { Logger as m } from "../../error-handling/logger.mjs";
15
+ import { API as m } from "../../API/API.mjs";
16
16
  import { getErc20TokenFromAPI as h, getErc20TokensBySymbolsFromAPI as g } from "../../functions/utils/erc20tokenFunctions.mjs";
17
17
  import { getErrorMessageFromTransactionRequest as _ } from "../../error-handling/get-error.message.mjs";
18
18
  import "../../error-handling/index.mjs";
@@ -37,24 +37,24 @@ var k = 3 * 1e3, ne = 13 * 1e3, A = async (A, j, M, N, P, F, I, L) => {
37
37
  try {
38
38
  let o = v(j);
39
39
  await ee(j === e.ethMainnet ? ne : k);
40
- let d = await w(I, P, M, o);
41
- if (!d.length) {
42
- S(f.AutoShieldTxStatus, { message: i.AUTO_SHIELD_SKIPPED });
40
+ let s = await w(I, P, M, o);
41
+ if (!s.length) {
42
+ S(p.AutoShieldTxStatus, { message: i.AUTO_SHIELD_SKIPPED });
43
43
  return;
44
44
  }
45
- let m = (await g(await C(j), j)).filter((e) => e !== void 0), { prices: _ } = await p.getTokenPrices(j, m.map((e) => e.erc20TokenAddress)), z = new Map(_.map((e, t) => [m[t].erc20TokenAddress.toLowerCase(), e])), B = d.map(({ token: e }) => e), V = d.map(({ balance: e }) => e), H = B.map(({ erc20TokenAddress: e }) => e), U = b(A, j, H, await te(j, B, V, M)), W = await y(j, P, H, s.Emporium, U.map((e) => x(e, M, j))), { flatFee: G } = W ?? {}, K = await h(j, W.feeToken);
45
+ let f = (await g(await C(j), j)).filter((e) => e !== void 0), { prices: _ } = await m.getTokenPrices(j, f.map((e) => e.erc20TokenAddress)), z = new Map(_.map((e, t) => [f[t].erc20TokenAddress.toLowerCase(), e])), B = s.map(({ token: e }) => e), V = s.map(({ balance: e }) => e), H = B.map(({ erc20TokenAddress: e }) => e), U = b(A, j, H, await te(j, B, V, M)), W = await y(j, P, H, c.Emporium, U.map((e) => x(e, M, j))), { flatFee: G } = W ?? {}, K = await h(j, W.feeToken);
46
46
  if (!K) return;
47
- let q = a(K, G), J = (z.get(K.erc20TokenAddress.toLowerCase()) ?? 0) * Number(q), Y = await E(P, J, j, B, U, await T(m, j, A, M, o, z), W, H, M);
47
+ let q = a(K, G), J = (z.get(K.erc20TokenAddress.toLowerCase()) ?? 0) * Number(q), Y = await E(P, J, j, B, U, await T(f, j, A, M, o, z), W, H, M);
48
48
  if (!Y) return;
49
49
  let { feeToken: X, feeStructure: Z } = Y ?? {};
50
50
  if (F && Number(F) < J) {
51
- S(f.AutoShieldTxStatus, { message: r.GAS_PRICE_EXCEEDS_AUTOSHIELD_LIMIT });
51
+ S(p.AutoShieldTxStatus, { message: r.GAS_PRICE_EXCEEDS_AUTOSHIELD_LIMIT });
52
52
  return;
53
53
  }
54
54
  let Q = B.findIndex((e) => n(e.erc20TokenAddress, X));
55
55
  Q !== -1 && (V[Q] -= Z?.flatFee ?? 0n);
56
56
  let { hinkalAddress: re } = t[j].contractData, $ = {
57
- activityType: u.AUTO_SHIELD,
57
+ activityType: d.AUTO_SHIELD,
58
58
  chainId: j,
59
59
  from: M,
60
60
  to: re,
@@ -64,15 +64,15 @@ var k = 3 * 1e3, ne = 13 * 1e3, A = async (A, j, M, N, P, F, I, L) => {
64
64
  token: e
65
65
  }))
66
66
  };
67
- if (R = await O.saveTxRequest($), S(f.AutoShieldTxStatus, { status: c.Loading }), L) D(j, A, L.inputNullifiers?.flat(), L.outCommitments?.flat(), L.encryptedOutputs?.flat());
67
+ if (R = await O.saveTxRequest($), S(p.AutoShieldTxStatus, { status: l.Loading }), L) D(j, A, L.inputNullifiers?.flat(), L.outCommitments?.flat(), L.encryptedOutputs?.flat());
68
68
  else if (!A.generateProofRemotely) throw Error("Circomdata should be passed if tx is done locally");
69
69
  let ie = {
70
70
  id: 0,
71
71
  success: !0,
72
- txHash: await A.actionReceive(B, V, X, Z, N, l.AutoShield)
72
+ txHash: await A.actionReceive(B, V, X, Z, N, u.AutoShield)
73
73
  };
74
- await O.updatePendingTransactions(ie, R), S(f.AutoShieldTxStatus, {
75
- status: c.Confirmed,
74
+ await O.updatePendingTransactions(ie, R), S(p.AutoShieldTxStatus, {
75
+ status: l.Confirmed,
76
76
  activityRequest: $
77
77
  });
78
78
  } catch (e) {
@@ -84,10 +84,10 @@ var k = 3 * 1e3, ne = 13 * 1e3, A = async (A, j, M, N, P, F, I, L) => {
84
84
  success: !1,
85
85
  ...t ? { erroredTx: t } : {}
86
86
  };
87
- R && await O.updatePendingTransactions(n, R), S(f.AutoShieldTxStatus, {
88
- status: c.Failed,
89
- error: _(e, d.ReceiveFromShieldedAccount)
90
- }), m.error("Error in auto deposit back:", e);
87
+ R && await O.updatePendingTransactions(n, R), S(p.AutoShieldTxStatus, {
88
+ status: l.Failed,
89
+ error: _(e, f.ReceiveFromShieldedAccount)
90
+ }), s.error("Error in auto deposit back:", e);
91
91
  }
92
92
  };
93
93
  //#endregion
@@ -1 +1 @@
1
- require(`../../constants/protocol.constants.cjs`);const e=require(`../../types/external-action.types.cjs`),t=require(`../../functions/utils/token-check.utils.cjs`),n=require(`../../functions/pre-transaction/getVolatileTransferAmount.cjs`),r=require(`../AccountActions/AccountActions.cjs`),i=require(`../../functions/pre-transaction/getFeeStructure.cjs`),a=require(`../../functions/private-wallet/emporium.helpers.cjs`),o=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),s=require(`../../functions/utils/fees.utils.cjs`);var c=async(c,l,u,d,f,p,m)=>{if(!p)throw Error(`hinkalActionReceive: subAccount should be provided`);if(!d)throw Error(`Fee token is required in hinkalActionReceive`);let h=t.validateAndGetChainId(l),g=r.AccountActions.getAddressFromSubAccount(h,p);if(!g)throw Error(`Public account address is not available`);let _=l.map(e=>e.erc20TokenAddress),v=await n.modifyVolatileTokenAmountChanges(h,l,u,g),y=a.createTransaferEmporiumOpsBatch(c,h,_,v),b=await s.calculateModifiedFeeStructureForTokens(h,l,v,f??await i.getFeeStructure(h,d,_,e.ExternalActionId.Emporium,y.map(e=>o.convertEmporiumOpToCallInfo(e,g,h)),10n)),x=l.map((e,t)=>({token:e,amount:-1n*v[t]}));return c.actionPrivateWallet(h,l,v,v.map(()=>!1),y,x,p,d,b,void 0,void 0,void 0,m,void 0)};exports.hinkalActionReceive=c;
1
+ require(`../../constants/protocol.constants.cjs`);const e=require(`../../types/external-action.types.cjs`),t=require(`../../functions/utils/token-check.utils.cjs`),n=require(`../../functions/pre-transaction/getVolatileTransferAmount.cjs`),r=require(`../AccountActions/AccountActions.cjs`),i=require(`../../functions/pre-transaction/getFeeStructure.cjs`),a=require(`../../functions/private-wallet/emporium.helpers.cjs`),o=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),s=require(`../../functions/utils/fees.utils.cjs`);var c=async(c,l,u,d,f,p,m)=>{if(!p)throw Error(`hinkalActionReceive: subAccount should be provided`);if(!d)throw Error(`Fee token is required in hinkalActionReceive`);let h=t.validateAndGetChainId(l),g=r.AccountActions.getAddressFromSubAccount(h,p);if(!g)throw Error(`Public account address is not available`);let _=l.map(e=>e.erc20TokenAddress),v=await n.modifyVolatileTokenAmountChanges(h,l,u,g),y=a.createTransaferEmporiumOpsBatch(c,h,_,v),b=await s.calculateModifiedFeeStructureForTokens(h,l,v,f??await i.getFeeStructure(h,d,_,e.ExternalActionId.Emporium,y.map(e=>o.convertEmporiumOpToCallInfo(e,g,h)),25n)),x=l.map((e,t)=>({token:e,amount:-1n*v[t]}));return c.actionPrivateWallet(h,l,v,v.map(()=>!1),y,x,p,d,b,void 0,void 0,void 0,m,void 0)};exports.hinkalActionReceive=c;
@@ -13,7 +13,7 @@ var c = async (c, l, u, d, f, p, m) => {
13
13
  if (!d) throw Error("Fee token is required in hinkalActionReceive");
14
14
  let h = t(l), g = r.getAddressFromSubAccount(h, p);
15
15
  if (!g) throw Error("Public account address is not available");
16
- let _ = l.map((e) => e.erc20TokenAddress), v = await n(h, l, u, g), y = a(c, h, _, v), b = await s(h, l, v, f ?? await i(h, d, _, e.Emporium, y.map((e) => o(e, g, h)), 10n)), x = l.map((e, t) => ({
16
+ let _ = l.map((e) => e.erc20TokenAddress), v = await n(h, l, u, g), y = a(c, h, _, v), b = await s(h, l, v, f ?? await i(h, d, _, e.Emporium, y.map((e) => o(e, g, h)), 25n)), x = l.map((e, t) => ({
17
17
  token: e,
18
18
  amount: -1n * v[t]
19
19
  }));
@@ -1 +1 @@
1
- const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../functions/utils/caseInsensitive.utils.cjs`),r=require(`../../error-handling/error-codes.constants.cjs`),i=require(`../../functions/web3/etherFunctions.cjs`),a=require(`../../functions/utils/addresses.cjs`),o=require(`../../types/external-action.types.cjs`),s=require(`../../types/token.types.cjs`),c=require(`../../API/API.cjs`),l=require(`../../functions/utils/erc20tokenFunctions.cjs`),u=require(`../AccountActions/AccountActions.cjs`),d=require(`../../functions/pre-transaction/getFeeStructure.cjs`),f=require(`../../functions/private-wallet/emporium.helpers.cjs`),p=require(`../../constants/addresses.constants.cjs`),m=require(`../../constants/bridging.constants.cjs`),h=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),g=require(`../../functions/utils/fees.utils.cjs`),_=require(`../../functions/utils/enclave-utxo-storage.cjs`),v=require(`../../functions/utils/bridge-arrival.utils.cjs`),y=require(`../../functions/utils/temp-wallet.utils.cjs`),b=require(`../../API/callNearIntentsAPI.cjs`),x=require(`../../functions/utils/nearIntents.utils.cjs`),S=require(`../../functions/web3/lifiAPI.cjs`),C=require(`../../functions/utils/bridge-claimable-utxo.utils.cjs`);var w=async(e,r,d,m,h,g,_,v)=>{let{chainId:b}=r,x=d.chainId,C=r.erc20TokenAddress,w=p.SWAP_ROUTER_ADDRESSES[o.ExternalActionId.Lifi][b];if(!w)throw Error(`LIFI not configured for chain ${b}`);let T=i.randomBigInt(6),{sourceSubAccount:E,destinationSubAccount:D}=y.deriveBridgeTempWallets(e,b,x,T),O=u.AccountActions.getAddressFromSubAccount(b,E),k=u.AccountActions.getAddressFromSubAccount(x,D);if(!O||!k)throw Error(`Missing temp wallet address for LIFI bridge`);let{lifiDataValue:A,outSwapAmountValue:j,extraNativeTokenFee:M}=await S.getLifiPrice(r,d,m,h,O,k),N={calldata:A,expectedAmount:j,nativeFee:M},P=i.getAmountInWei(r,m),F=Array.from(new Set([b,x])),I=a.hashEthereumAddress(await e.getEthereumAddress());await Promise.all(F.map(e=>c.API.addTemporaryWalletNonce(e,I,Number(T),s.TemporaryWalletRecoveryDestination.Confidential)));let L=n.caseInsensitiveEqual(C,t.zeroAddress),R=N.nativeFee>0n&&!L,z=L?P+N.nativeFee:P,B=[r],V=[-z];if(R){let e=await l.getErc20TokenFromAPI(b,t.zeroAddress);if(!e)throw Error(`Native token not found for bridge fee`);B.push(e),V.push(-N.nativeFee)}let H=f.createLifiBridgeOps(e,b,O,w,C,z,P,N),U=B.map((e,t)=>({token:e,amount:V[t]}));return{tempSubAccount:D,sourceTxHash:await e.actionPrivateWallet(b,B,V,V.map(()=>!1),H,U,E,g??C,_,void 0,!1,void 0,v,void 0),expectedAmount:N.expectedAmount}},T=async(e,t,n,r,o,l,d,f)=>{let p=n.chainId,h=i.randomBigInt(6),g=y.buildTempSubAccountForChain(e,p,h),_=u.AccountActions.getAddressFromSubAccount(p,g);if(!_)throw Error(`Missing temp wallet address for NEAR bridge`);let v=a.hashEthereumAddress(await e.getEthereumAddress());await c.API.addTemporaryWalletNonce(p,v,Number(h),s.TemporaryWalletRecoveryDestination.Confidential);let[S,C]=await Promise.all([x.resolveNearAssetId(t.chainId,t.erc20TokenAddress),x.resolveNearAssetId(p,n.erc20TokenAddress)]),w=i.getAmountInWei(t,r),T=new Date(Date.now()+m.NEAR_BRIDGE_QUOTE_DEADLINE_BUFFER_MS).toISOString(),{quote:E}=await b.getNearIntentsQuote({dry:!1,swapType:`EXACT_INPUT`,slippageTolerance:Math.round(o*1e4)||100,originAsset:S,depositType:`ORIGIN_CHAIN`,destinationAsset:C,amount:w.toString(),recipient:_,recipientType:`DESTINATION_CHAIN`,refundTo:e.userKeys.getNearIntentsAccountId(),refundType:`INTENTS`,deadline:T});if(!E.depositAddress)throw Error(`NEAR Intents quote returned no deposit address`);let D=await e.withdraw([t],[-w],E.depositAddress,!1,l??t.erc20TokenAddress,d,void 0,f);return{tempSubAccount:g,sourceTxHash:typeof D==`string`?D:D.hash,expectedAmount:BigInt(E.amountOut)}},E=async(n,i,a,s,c)=>{let l=i.chainId,p=i.erc20TokenAddress,m=u.AccountActions.getAddressFromSubAccount(l,a);if(!m)throw Error(`Missing temp wallet address for bridge shield`);let{recipientInfo:v,claimable:y}=C.resolveBridgeRecipient(n,c);if(y&&await _.storeClaimableKeyInEnclave(await n.getEthereumAddressByChain(l),y.ethAddress,y.keys.getShieldedPrivateKey(),l,y.signature),e.isSolanaLike(l))return C.hinkalSolanaShieldBridged(n,i,a,s,v);let b=f.createTransaferEmporiumOpsBatch(n,l,[p],[s]),x=await g.calculateModifiedFeeStructure(l,i,s,await d.getFeeStructure(l,p,[p],o.ExternalActionId.Emporium,b.map(e=>h.convertEmporiumOpToCallInfo(e,m,l)),t.PAY_SEND_VARIABLE_RATE)),S=s-g.calculateTotalFee(s,x);if(S<=0n)throw Error(r.transactionErrorCodes.INSUFFICIENT_FUNDS_TO_TRANSACT);return{destTxHash:await n.proxyToPrivate([i],[S],a,v,x.feeToken,x),shieldedAmount:S}},D=async(t,n,r,i,a,o=m.DEFAULT_BRIDGING_SLIPPAGE_DECIMAL,s,c,l)=>{let{tempSubAccount:d,sourceTxHash:f,expectedAmount:p}=e.isNearIntentsBridgeSource(n.chainId)?await T(t,n,r,i,o,s,c,l):await w(t,n,r,i,o,s,c,l),h=u.AccountActions.getAddressFromSubAccount(r.chainId,d);if(!h)throw Error(`Missing temp wallet address for bridge`);let{destTxHash:g,shieldedAmount:_}=await E(t,r,d,await v.waitForBridgeArrival(r.chainId,h,r.erc20TokenAddress,p,o),a);return{sourceTxHash:f,destTxHash:g,destinationTokenAmount:_.toString()}};exports.hinkalBridgePrivateToPrivate=D;
1
+ const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../functions/utils/caseInsensitive.utils.cjs`),r=require(`../../error-handling/error-codes.constants.cjs`),i=require(`../../functions/web3/etherFunctions.cjs`),a=require(`../../functions/utils/addresses.cjs`),o=require(`../../types/external-action.types.cjs`),s=require(`../../types/token.types.cjs`),c=require(`../../API/API.cjs`),l=require(`../../functions/utils/erc20tokenFunctions.cjs`),u=require(`../AccountActions/AccountActions.cjs`),d=require(`../../functions/pre-transaction/getFeeStructure.cjs`),f=require(`../../functions/private-wallet/emporium.helpers.cjs`),p=require(`../../constants/addresses.constants.cjs`),m=require(`../../constants/bridging.constants.cjs`),h=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),g=require(`../../functions/utils/fees.utils.cjs`),_=require(`../../functions/utils/enclave-utxo-storage.cjs`),v=require(`../../functions/utils/bridge-arrival.utils.cjs`),y=require(`../../functions/utils/temp-wallet.utils.cjs`),b=require(`../../API/callNearIntentsAPI.cjs`),x=require(`../../functions/utils/nearIntents.utils.cjs`),S=require(`../../functions/web3/lifiAPI.cjs`),C=require(`../../functions/utils/bridge-claimable-utxo.utils.cjs`);var w=async(e,r,d,m,h,g,_,v)=>{let{chainId:b}=r,x=d.chainId,C=r.erc20TokenAddress,w=p.SWAP_ROUTER_ADDRESSES[o.ExternalActionId.Lifi][b];if(!w)throw Error(`LIFI not configured for chain ${b}`);let T=i.randomBigInt(6),{sourceSubAccount:E,destinationSubAccount:D}=y.deriveBridgeTempWallets(e,b,x,T),O=u.AccountActions.getAddressFromSubAccount(b,E),k=u.AccountActions.getAddressFromSubAccount(x,D);if(!O||!k)throw Error(`Missing temp wallet address for LIFI bridge`);let{lifiDataValue:A,outSwapAmountValue:j,extraNativeTokenFee:M}=await S.getLifiPrice(r,d,m,h,O,k),N={calldata:A,expectedAmount:j,nativeFee:M},P=i.getAmountInWei(r,m),F=Array.from(new Set([b,x])),I=a.hashEthereumAddress(await e.getEthereumAddress());await Promise.all(F.map(e=>c.API.addTemporaryWalletNonce(e,I,Number(T),s.TemporaryWalletRecoveryDestination.Confidential)));let L=n.caseInsensitiveEqual(C,t.zeroAddress),R=N.nativeFee>0n&&!L,z=L?P+N.nativeFee:P,B=[r],V=[-z];if(R){let e=await l.getErc20TokenFromAPI(b,t.zeroAddress);if(!e)throw Error(`Native token not found for bridge fee`);B.push(e),V.push(-N.nativeFee)}let H=f.createLifiBridgeOps(e,b,O,w,C,z,P,N),U=B.map((e,t)=>({token:e,amount:V[t]}));return{tempSubAccount:D,sourceTxHash:await e.actionPrivateWallet(b,B,V,V.map(()=>!1),H,U,E,g??C,_,void 0,!1,void 0,v,void 0),expectedAmount:N.expectedAmount}},T=async(e,t,n,r,o,l,d,f)=>{let p=n.chainId,h=i.randomBigInt(6),g=y.buildTempSubAccountForChain(e,p,h),_=u.AccountActions.getAddressFromSubAccount(p,g);if(!_)throw Error(`Missing temp wallet address for NEAR bridge`);let v=a.hashEthereumAddress(await e.getEthereumAddress());await c.API.addTemporaryWalletNonce(p,v,Number(h),s.TemporaryWalletRecoveryDestination.Confidential);let[S,C]=await Promise.all([x.resolveNearAssetId(t.chainId,t.erc20TokenAddress),x.resolveNearAssetId(p,n.erc20TokenAddress)]),w=i.getAmountInWei(t,r),T=new Date(Date.now()+m.NEAR_BRIDGE_QUOTE_DEADLINE_BUFFER_MS).toISOString(),{quote:E}=await b.getNearIntentsQuote({dry:!1,swapType:`EXACT_INPUT`,slippageTolerance:Math.round(o*1e4)||100,originAsset:S,depositType:`ORIGIN_CHAIN`,destinationAsset:C,amount:w.toString(),recipient:_,recipientType:`DESTINATION_CHAIN`,refundTo:e.userKeys.getNearIntentsAccountId(),refundType:`INTENTS`,deadline:T});if(!E.depositAddress)throw Error(`NEAR Intents quote returned no deposit address`);let D=await e.withdraw([t],[-w],E.depositAddress,!1,l??t.erc20TokenAddress,d,void 0,f);return{tempSubAccount:g,sourceTxHash:typeof D==`string`?D:D.hash,expectedAmount:BigInt(E.amountOut)}},E=async(n,i,a,s,c)=>{let l=i.chainId,p=i.erc20TokenAddress,m=u.AccountActions.getAddressFromSubAccount(l,a);if(!m)throw Error(`Missing temp wallet address for bridge shield`);let{recipientInfo:v,claimable:y}=C.resolveBridgeRecipient(n,c);if(y&&await _.storeClaimableKeyInEnclave(await n.getEthereumAddressByChain(l),y.ethAddress,y.keys.getShieldedPrivateKey(),l,y.signature,n.userKeys.getSignature()),e.isSolanaLike(l))return C.hinkalSolanaShieldBridged(n,i,a,s,v,t.HINKAL_SHIELD_VARIABLE_RATE);let b=f.createTransaferEmporiumOpsBatch(n,l,[p],[s]),x=await g.calculateModifiedFeeStructure(l,i,s,await d.getFeeStructure(l,p,[p],o.ExternalActionId.Emporium,b.map(e=>h.convertEmporiumOpToCallInfo(e,m,l)),t.HINKAL_PRIVATE_SEND_VARIABLE_RATE)),S=s-g.calculateTotalFee(s,x);if(S<=0n)throw Error(r.transactionErrorCodes.INSUFFICIENT_FUNDS_TO_TRANSACT);return{destTxHash:await n.proxyToPrivate([i],[S],a,v,x.feeToken,x),shieldedAmount:S}},D=async(t,n,r,i,a,o=m.DEFAULT_BRIDGING_SLIPPAGE_DECIMAL,s,c,l)=>{let{tempSubAccount:d,sourceTxHash:f,expectedAmount:p}=e.isNearIntentsBridgeSource(n.chainId)?await T(t,n,r,i,o,s,c,l):await w(t,n,r,i,o,s,c,l),h=u.AccountActions.getAddressFromSubAccount(r.chainId,d);if(!h)throw Error(`Missing temp wallet address for bridge`);let{destTxHash:g,shieldedAmount:_}=await E(t,r,d,await v.waitForBridgeArrival(r.chainId,h,r.erc20TokenAddress,p,o),a);return{sourceTxHash:f,destTxHash:g,destinationTokenAmount:_.toString()}};exports.hinkalBridgePrivateToPrivate=D;
@@ -1,64 +1,64 @@
1
1
  import { isNearIntentsBridgeSource as e, isSolanaLike as t } from "../../constants/chains.constants.mjs";
2
- import { PAY_SEND_VARIABLE_RATE as n, zeroAddress as r } from "../../constants/protocol.constants.mjs";
3
- import { caseInsensitiveEqual as i } from "../../functions/utils/caseInsensitive.utils.mjs";
4
- import { transactionErrorCodes as a } from "../../error-handling/error-codes.constants.mjs";
5
- import { getAmountInWei as o, randomBigInt as s } from "../../functions/web3/etherFunctions.mjs";
6
- import { hashEthereumAddress as c } from "../../functions/utils/addresses.mjs";
7
- import { ExternalActionId as l } from "../../types/external-action.types.mjs";
8
- import { TemporaryWalletRecoveryDestination as u } from "../../types/token.types.mjs";
9
- import { API as d } from "../../API/API.mjs";
10
- import { getErc20TokenFromAPI as f } from "../../functions/utils/erc20tokenFunctions.mjs";
11
- import { AccountActions as p } from "../AccountActions/AccountActions.mjs";
12
- import { getFeeStructure as m } from "../../functions/pre-transaction/getFeeStructure.mjs";
13
- import { createLifiBridgeOps as h, createTransaferEmporiumOpsBatch as g } from "../../functions/private-wallet/emporium.helpers.mjs";
14
- import { SWAP_ROUTER_ADDRESSES as _ } from "../../constants/addresses.constants.mjs";
15
- import { DEFAULT_BRIDGING_SLIPPAGE_DECIMAL as v, NEAR_BRIDGE_QUOTE_DEADLINE_BUFFER_MS as y } from "../../constants/bridging.constants.mjs";
16
- import { convertEmporiumOpToCallInfo as b } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
17
- import { calculateModifiedFeeStructure as x, calculateTotalFee as S } from "../../functions/utils/fees.utils.mjs";
18
- import { storeClaimableKeyInEnclave as C } from "../../functions/utils/enclave-utxo-storage.mjs";
19
- import { waitForBridgeArrival as w } from "../../functions/utils/bridge-arrival.utils.mjs";
20
- import { buildTempSubAccountForChain as T, deriveBridgeTempWallets as E } from "../../functions/utils/temp-wallet.utils.mjs";
21
- import { getNearIntentsQuote as D } from "../../API/callNearIntentsAPI.mjs";
22
- import { resolveNearAssetId as O } from "../../functions/utils/nearIntents.utils.mjs";
23
- import { getLifiPrice as k } from "../../functions/web3/lifiAPI.mjs";
24
- import { hinkalSolanaShieldBridged as A, resolveBridgeRecipient as j } from "../../functions/utils/bridge-claimable-utxo.utils.mjs";
2
+ import { HINKAL_PRIVATE_SEND_VARIABLE_RATE as n, HINKAL_SHIELD_VARIABLE_RATE as r, zeroAddress as i } from "../../constants/protocol.constants.mjs";
3
+ import { caseInsensitiveEqual as a } from "../../functions/utils/caseInsensitive.utils.mjs";
4
+ import { transactionErrorCodes as o } from "../../error-handling/error-codes.constants.mjs";
5
+ import { getAmountInWei as s, randomBigInt as c } from "../../functions/web3/etherFunctions.mjs";
6
+ import { hashEthereumAddress as l } from "../../functions/utils/addresses.mjs";
7
+ import { ExternalActionId as u } from "../../types/external-action.types.mjs";
8
+ import { TemporaryWalletRecoveryDestination as d } from "../../types/token.types.mjs";
9
+ import { API as f } from "../../API/API.mjs";
10
+ import { getErc20TokenFromAPI as p } from "../../functions/utils/erc20tokenFunctions.mjs";
11
+ import { AccountActions as m } from "../AccountActions/AccountActions.mjs";
12
+ import { getFeeStructure as h } from "../../functions/pre-transaction/getFeeStructure.mjs";
13
+ import { createLifiBridgeOps as g, createTransaferEmporiumOpsBatch as _ } from "../../functions/private-wallet/emporium.helpers.mjs";
14
+ import { SWAP_ROUTER_ADDRESSES as v } from "../../constants/addresses.constants.mjs";
15
+ import { DEFAULT_BRIDGING_SLIPPAGE_DECIMAL as y, NEAR_BRIDGE_QUOTE_DEADLINE_BUFFER_MS as b } from "../../constants/bridging.constants.mjs";
16
+ import { convertEmporiumOpToCallInfo as x } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
17
+ import { calculateModifiedFeeStructure as S, calculateTotalFee as C } from "../../functions/utils/fees.utils.mjs";
18
+ import { storeClaimableKeyInEnclave as w } from "../../functions/utils/enclave-utxo-storage.mjs";
19
+ import { waitForBridgeArrival as T } from "../../functions/utils/bridge-arrival.utils.mjs";
20
+ import { buildTempSubAccountForChain as E, deriveBridgeTempWallets as D } from "../../functions/utils/temp-wallet.utils.mjs";
21
+ import { getNearIntentsQuote as O } from "../../API/callNearIntentsAPI.mjs";
22
+ import { resolveNearAssetId as k } from "../../functions/utils/nearIntents.utils.mjs";
23
+ import { getLifiPrice as A } from "../../functions/web3/lifiAPI.mjs";
24
+ import { hinkalSolanaShieldBridged as j, resolveBridgeRecipient as M } from "../../functions/utils/bridge-claimable-utxo.utils.mjs";
25
25
  //#region libs/shared/common/src/data-structures/Hinkal/hinkalBridgePrivateToPrivate.ts
26
- var M = async (e, t, n, a, m, g, v, y) => {
27
- let { chainId: b } = t, x = n.chainId, S = t.erc20TokenAddress, C = _[l.Lifi][b];
26
+ var N = async (e, t, n, r, o, h, _, y) => {
27
+ let { chainId: b } = t, x = n.chainId, S = t.erc20TokenAddress, C = v[u.Lifi][b];
28
28
  if (!C) throw Error(`LIFI not configured for chain ${b}`);
29
- let w = s(6), { sourceSubAccount: T, destinationSubAccount: D } = E(e, b, x, w), O = p.getAddressFromSubAccount(b, T), A = p.getAddressFromSubAccount(x, D);
30
- if (!O || !A) throw Error("Missing temp wallet address for LIFI bridge");
31
- let { lifiDataValue: j, outSwapAmountValue: M, extraNativeTokenFee: N } = await k(t, n, a, m, O, A), P = {
29
+ let w = c(6), { sourceSubAccount: T, destinationSubAccount: E } = D(e, b, x, w), O = m.getAddressFromSubAccount(b, T), k = m.getAddressFromSubAccount(x, E);
30
+ if (!O || !k) throw Error("Missing temp wallet address for LIFI bridge");
31
+ let { lifiDataValue: j, outSwapAmountValue: M, extraNativeTokenFee: N } = await A(t, n, r, o, O, k), P = {
32
32
  calldata: j,
33
33
  expectedAmount: M,
34
34
  nativeFee: N
35
- }, F = o(t, a), I = Array.from(new Set([b, x])), L = c(await e.getEthereumAddress());
36
- await Promise.all(I.map((e) => d.addTemporaryWalletNonce(e, L, Number(w), u.Confidential)));
37
- let R = i(S, r), z = P.nativeFee > 0n && !R, B = R ? F + P.nativeFee : F, V = [t], H = [-B];
35
+ }, F = s(t, r), I = Array.from(new Set([b, x])), L = l(await e.getEthereumAddress());
36
+ await Promise.all(I.map((e) => f.addTemporaryWalletNonce(e, L, Number(w), d.Confidential)));
37
+ let R = a(S, i), z = P.nativeFee > 0n && !R, B = R ? F + P.nativeFee : F, V = [t], H = [-B];
38
38
  if (z) {
39
- let e = await f(b, r);
39
+ let e = await p(b, i);
40
40
  if (!e) throw Error("Native token not found for bridge fee");
41
41
  V.push(e), H.push(-P.nativeFee);
42
42
  }
43
- let U = h(e, b, O, C, S, B, F, P), W = V.map((e, t) => ({
43
+ let U = g(e, b, O, C, S, B, F, P), W = V.map((e, t) => ({
44
44
  token: e,
45
45
  amount: H[t]
46
46
  }));
47
47
  return {
48
- tempSubAccount: D,
49
- sourceTxHash: await e.actionPrivateWallet(b, V, H, H.map(() => !1), U, W, T, g ?? S, v, void 0, !1, void 0, y, void 0),
48
+ tempSubAccount: E,
49
+ sourceTxHash: await e.actionPrivateWallet(b, V, H, H.map(() => !1), U, W, T, h ?? S, _, void 0, !1, void 0, y, void 0),
50
50
  expectedAmount: P.expectedAmount
51
51
  };
52
- }, N = async (e, t, n, r, i, a, l, f) => {
53
- let m = n.chainId, h = s(6), g = T(e, m, h), _ = p.getAddressFromSubAccount(m, g);
52
+ }, P = async (e, t, n, r, i, a, o, u) => {
53
+ let p = n.chainId, h = c(6), g = E(e, p, h), _ = m.getAddressFromSubAccount(p, g);
54
54
  if (!_) throw Error("Missing temp wallet address for NEAR bridge");
55
- let v = c(await e.getEthereumAddress());
56
- await d.addTemporaryWalletNonce(m, v, Number(h), u.Confidential);
57
- let [b, x] = await Promise.all([O(t.chainId, t.erc20TokenAddress), O(m, n.erc20TokenAddress)]), S = o(t, r), C = new Date(Date.now() + y).toISOString(), { quote: w } = await D({
55
+ let v = l(await e.getEthereumAddress());
56
+ await f.addTemporaryWalletNonce(p, v, Number(h), d.Confidential);
57
+ let [y, x] = await Promise.all([k(t.chainId, t.erc20TokenAddress), k(p, n.erc20TokenAddress)]), S = s(t, r), C = new Date(Date.now() + b).toISOString(), { quote: w } = await O({
58
58
  dry: !1,
59
59
  swapType: "EXACT_INPUT",
60
60
  slippageTolerance: Math.round(i * 1e4) || 100,
61
- originAsset: b,
61
+ originAsset: y,
62
62
  depositType: "ORIGIN_CHAIN",
63
63
  destinationAsset: x,
64
64
  amount: S.toString(),
@@ -69,27 +69,27 @@ var M = async (e, t, n, a, m, g, v, y) => {
69
69
  deadline: C
70
70
  });
71
71
  if (!w.depositAddress) throw Error("NEAR Intents quote returned no deposit address");
72
- let E = await e.withdraw([t], [-S], w.depositAddress, !1, a ?? t.erc20TokenAddress, l, void 0, f);
72
+ let T = await e.withdraw([t], [-S], w.depositAddress, !1, a ?? t.erc20TokenAddress, o, void 0, u);
73
73
  return {
74
74
  tempSubAccount: g,
75
- sourceTxHash: typeof E == "string" ? E : E.hash,
75
+ sourceTxHash: typeof T == "string" ? T : T.hash,
76
76
  expectedAmount: BigInt(w.amountOut)
77
77
  };
78
- }, P = async (e, r, i, o, s) => {
79
- let c = r.chainId, u = r.erc20TokenAddress, d = p.getAddressFromSubAccount(c, i);
80
- if (!d) throw Error("Missing temp wallet address for bridge shield");
81
- let { recipientInfo: f, claimable: h } = j(e, s);
82
- if (h && await C(await e.getEthereumAddressByChain(c), h.ethAddress, h.keys.getShieldedPrivateKey(), c, h.signature), t(c)) return A(e, r, i, o, f);
83
- let _ = g(e, c, [u], [o]), v = await x(c, r, o, await m(c, u, [u], l.Emporium, _.map((e) => b(e, d, c)), n)), y = o - S(o, v);
84
- if (y <= 0n) throw Error(a.INSUFFICIENT_FUNDS_TO_TRANSACT);
78
+ }, F = async (e, i, a, s, c) => {
79
+ let l = i.chainId, d = i.erc20TokenAddress, f = m.getAddressFromSubAccount(l, a);
80
+ if (!f) throw Error("Missing temp wallet address for bridge shield");
81
+ let { recipientInfo: p, claimable: g } = M(e, c);
82
+ if (g && await w(await e.getEthereumAddressByChain(l), g.ethAddress, g.keys.getShieldedPrivateKey(), l, g.signature, e.userKeys.getSignature()), t(l)) return j(e, i, a, s, p, r);
83
+ let v = _(e, l, [d], [s]), y = await S(l, i, s, await h(l, d, [d], u.Emporium, v.map((e) => x(e, f, l)), n)), b = s - C(s, y);
84
+ if (b <= 0n) throw Error(o.INSUFFICIENT_FUNDS_TO_TRANSACT);
85
85
  return {
86
- destTxHash: await e.proxyToPrivate([r], [y], i, f, v.feeToken, v),
87
- shieldedAmount: y
86
+ destTxHash: await e.proxyToPrivate([i], [b], a, p, y.feeToken, y),
87
+ shieldedAmount: b
88
88
  };
89
- }, F = async (t, n, r, i, a, o = v, s, c, l) => {
90
- let { tempSubAccount: u, sourceTxHash: d, expectedAmount: f } = e(n.chainId) ? await N(t, n, r, i, o, s, c, l) : await M(t, n, r, i, o, s, c, l), m = p.getAddressFromSubAccount(r.chainId, u);
91
- if (!m) throw Error("Missing temp wallet address for bridge");
92
- let { destTxHash: h, shieldedAmount: g } = await P(t, r, u, await w(r.chainId, m, r.erc20TokenAddress, f, o), a);
89
+ }, I = async (t, n, r, i, a, o = y, s, c, l) => {
90
+ let { tempSubAccount: u, sourceTxHash: d, expectedAmount: f } = e(n.chainId) ? await P(t, n, r, i, o, s, c, l) : await N(t, n, r, i, o, s, c, l), p = m.getAddressFromSubAccount(r.chainId, u);
91
+ if (!p) throw Error("Missing temp wallet address for bridge");
92
+ let { destTxHash: h, shieldedAmount: g } = await F(t, r, u, await T(r.chainId, p, r.erc20TokenAddress, f, o), a);
93
93
  return {
94
94
  sourceTxHash: d,
95
95
  destTxHash: h,
@@ -97,4 +97,4 @@ var M = async (e, t, n, a, m, g, v, y) => {
97
97
  };
98
98
  };
99
99
  //#endregion
100
- export { F as hinkalBridgePrivateToPrivate };
100
+ export { I as hinkalBridgePrivateToPrivate };
@@ -1 +1 @@
1
- const e=require(`../../error-handling/error-codes.constants.cjs`),t=require(`../../functions/utils/addresses.cjs`),n=require(`../../functions/utils/tron.utils.cjs`),r=require(`../../types/transact.types.cjs`),i=require(`../../functions/utils/token-check.utils.cjs`),a=require(`../../functions/pre-transaction/constructAdminData.cjs`),o=require(`./hinkalTransact.cjs`),s=require(`../../API/admin-calls.cjs`);var c=async(e,t,a,s=!0,c=!1)=>{let l=i.validateAndGetChainId(t);return o.hinkalTransact(e,{chainId:l,erc20Addresses:t.map(e=>e.erc20TokenAddress),amountChanges:a,externalAddress:n.addressToHexFormat(await e.getEthereumAddressByChain(l)),submit:{mode:r.SubmitMode.Self,erc20Tokens:t,approvalAmounts:a,preEstimateGas:s,returnTxData:c}})},l=async(c,l,u,d,f=!0,p=!1,m)=>{if(d.length===0)throw Error(`recipientInfos must not be empty`);if(u.length!==d.length)throw Error(`amountsByRecipient must have one entry per recipientInfo`);let h=i.validateAndGetChainId(l),g=l.map(e=>e.erc20TokenAddress);d.forEach((n,r)=>{if(!t.isValidPrivateAddress(n))throw Error(e.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);if(u[r].length!==g.length)throw Error(`Each amountsByRecipient entry must have one amount per erc20Token`)});let _=g.map((e,t)=>u.reduce((e,n)=>e+n[t],0n)),v=n.addressToHexFormat(await c.getEthereumAddressByChain(h)),y=await o.hinkalTransact(c,{chainId:h,erc20Addresses:g,amountChanges:_.map(()=>0n),externalAddress:v,recipientAddress:d,recipientAmounts:u,forceEmptyUtxos:!0,submit:{mode:r.SubmitMode.Self,erc20Tokens:l,approvalAmounts:_,preEstimateGas:f,returnTxData:p}});return s.emitTxPublicData(a.constructAdminData(m,h,g,_,await c.getEthereumAddress())),y},u=async(e,t,n,r,i=!0,a=!1,o)=>l(e,t,[n],[r],i,a,o);exports.hinkalDeposit=c,exports.hinkalDepositForOther=u;
1
+ const e=require(`../../error-handling/error-codes.constants.cjs`),t=require(`../../functions/utils/tron.utils.cjs`),n=require(`../../functions/utils/addresses.cjs`),r=require(`../../types/transact.types.cjs`),i=require(`../../functions/utils/token-check.utils.cjs`),a=require(`../../functions/pre-transaction/constructAdminData.cjs`),o=require(`./hinkalTransact.cjs`),s=require(`../../API/admin-calls.cjs`);var c=async(e,n,a,s=!0,c=!1)=>{let l=i.validateAndGetChainId(n);return o.hinkalTransact(e,{chainId:l,erc20Addresses:n.map(e=>e.erc20TokenAddress),amountChanges:a,externalAddress:t.addressToHexFormat(await e.getEthereumAddressByChain(l)),submit:{mode:r.SubmitMode.Self,erc20Tokens:n,approvalAmounts:a,preEstimateGas:s,returnTxData:c}})},l=async(c,l,u,d,f=!0,p=!1,m)=>{if(d.length===0)throw Error(`recipientInfos must not be empty`);if(u.length!==d.length)throw Error(`amountsByRecipient must have one entry per recipientInfo`);let h=i.validateAndGetChainId(l),g=l.map(e=>e.erc20TokenAddress);d.forEach((t,r)=>{if(!n.isValidPrivateAddress(t))throw Error(e.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);if(u[r].length!==g.length)throw Error(`Each amountsByRecipient entry must have one amount per erc20Token`)});let _=g.map((e,t)=>u.reduce((e,n)=>e+n[t],0n)),v=t.addressToHexFormat(await c.getEthereumAddressByChain(h)),y=await o.hinkalTransact(c,{chainId:h,erc20Addresses:g,amountChanges:_.map(()=>0n),externalAddress:v,recipientAddress:d,recipientAmounts:u,forceEmptyUtxos:!0,submit:{mode:r.SubmitMode.Self,erc20Tokens:l,approvalAmounts:_,preEstimateGas:f,returnTxData:p}});return s.emitTxPublicData(a.constructAdminData(m,h,g,_,await c.getEthereumAddress())),y},u=async(e,t,n,r,i=!0,a=!1,o)=>l(e,t,[n],[r],i,a,o);exports.hinkalDeposit=c,exports.hinkalDepositForOther=u;
@@ -1,22 +1,22 @@
1
1
  import { transactionErrorCodes as e } from "../../error-handling/error-codes.constants.mjs";
2
- import { isValidPrivateAddress as t } from "../../functions/utils/addresses.mjs";
3
- import { addressToHexFormat as n } from "../../functions/utils/tron.utils.mjs";
2
+ import { addressToHexFormat as t } from "../../functions/utils/tron.utils.mjs";
3
+ import { isValidPrivateAddress as n } from "../../functions/utils/addresses.mjs";
4
4
  import { SubmitMode as r } from "../../types/transact.types.mjs";
5
5
  import { validateAndGetChainId as i } from "../../functions/utils/token-check.utils.mjs";
6
6
  import { constructAdminData as a } from "../../functions/pre-transaction/constructAdminData.mjs";
7
7
  import { hinkalTransact as o } from "./hinkalTransact.mjs";
8
8
  import { emitTxPublicData as s } from "../../API/admin-calls.mjs";
9
9
  //#region libs/shared/common/src/data-structures/Hinkal/hinkalDeposit.ts
10
- var c = async (e, t, a, s = !0, c = !1) => {
11
- let l = i(t);
10
+ var c = async (e, n, a, s = !0, c = !1) => {
11
+ let l = i(n);
12
12
  return o(e, {
13
13
  chainId: l,
14
- erc20Addresses: t.map((e) => e.erc20TokenAddress),
14
+ erc20Addresses: n.map((e) => e.erc20TokenAddress),
15
15
  amountChanges: a,
16
- externalAddress: n(await e.getEthereumAddressByChain(l)),
16
+ externalAddress: t(await e.getEthereumAddressByChain(l)),
17
17
  submit: {
18
18
  mode: r.Self,
19
- erc20Tokens: t,
19
+ erc20Tokens: n,
20
20
  approvalAmounts: a,
21
21
  preEstimateGas: s,
22
22
  returnTxData: c
@@ -26,11 +26,11 @@ var c = async (e, t, a, s = !0, c = !1) => {
26
26
  if (d.length === 0) throw Error("recipientInfos must not be empty");
27
27
  if (u.length !== d.length) throw Error("amountsByRecipient must have one entry per recipientInfo");
28
28
  let h = i(l), g = l.map((e) => e.erc20TokenAddress);
29
- d.forEach((n, r) => {
30
- if (!t(n)) throw Error(e.RECIPIENT_FORMAT_INCORRECT);
29
+ d.forEach((t, r) => {
30
+ if (!n(t)) throw Error(e.RECIPIENT_FORMAT_INCORRECT);
31
31
  if (u[r].length !== g.length) throw Error("Each amountsByRecipient entry must have one amount per erc20Token");
32
32
  });
33
- let _ = g.map((e, t) => u.reduce((e, n) => e + n[t], 0n)), v = n(await c.getEthereumAddressByChain(h)), y = await o(c, {
33
+ let _ = g.map((e, t) => u.reduce((e, n) => e + n[t], 0n)), v = t(await c.getEthereumAddressByChain(h)), y = await o(c, {
34
34
  chainId: h,
35
35
  erc20Addresses: g,
36
36
  amountChanges: _.map(() => 0n),
@@ -1 +1 @@
1
- require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../functions/utils/caseInsensitive.utils.cjs`),r=require(`../../error-handling/error-codes.constants.cjs`),i=require(`../utxo/Utxo.cjs`),a=require(`../../functions/utils/addresses.cjs`),o=require(`../../functions/utils/tron.utils.cjs`),s=require(`../../types/external-action.types.cjs`),c=require(`../../types/transact.types.cjs`),l=require(`../../functions/utils/token-check.utils.cjs`),u=require(`../crypto-keys/encryptDecryptUtxo.cjs`),d=require(`../../functions/pre-transaction/constructAdminData.cjs`),f=require(`../../functions/pre-transaction/getFeeStructure.cjs`),p=require(`../../functions/pre-transaction/speculativeUtxo.cjs`),m=require(`../../functions/web3/functionCalls/transactCallDirectTron.cjs`),h=require(`../../functions/web3/functionCalls/transactCallRelayer.cjs`),g=require(`./hinkalTransact.cjs`);require(`../../functions/index.cjs`);const _=require(`./hinkalDepositOnChainUtxos.cjs`);let v=require(`ethers`);var y=async(e,a,s,l,u,f,m,h)=>{if(l.length===0)throw Error(`userDepositedUtxos must not be empty`);let _=s.erc20TokenAddress,[v,y]=await Promise.all([e.getRandomRelay(a),e.getEthereumAddressByChain(a)]);if(!v)throw Error(r.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let b=e.generateProofRemotely?5:1,x=[],S=o.addressToHexFormat(y);for(let r=0;r<l.length;r+=b){let s=l.slice(r,r+b),y=await Promise.all(s.map(async({recipientAddress:s,utxo:l},y)=>{let b=r+y,x=o.addressToHexFormat(s),C=n.caseInsensitiveEqual(l.erc20TokenAddress,_)?l:i.Utxo.createFrom(l,{erc20TokenAddress:_}),w=d.constructAdminData(f,a,[_],[-l.amount],S),{zkCallData:T,circomData:E,dimData:D,commitmentValidationData:O,tronProofSignature:k}=await g.hinkalTransact(e,{chainId:a,erc20Addresses:[_],amountChanges:[-l.amount],externalAddress:x,feeStructure:u,relay:v??t.zeroAddress,inputUtxos:[[C]],useBlockedUtxos:!0,speculative:h&&{pendingLeaves:h,inputUtxos:[[p.toSpeculativeUtxo(C)]]},submit:{mode:c.SubmitMode.ProofOnly},skipLock:!0});return{zkCallData:T,dimData:D,circomData:E,commitmentValidationData:O,adminData:w,recipientAddress:s,tronProofSignature:k,destinationChainId:m?.chainId,destinationTokenAddress:m?.tokenAddress,destinationTokenAmount:m?.tokenAmounts?.[b]}}));x.push(...y)}return x},b=async(e,t,n,r,i)=>{let{chainId:a,hashedEthereumAddress:o,feeStructure:s,action:c,destination:l}=i,{txCompletionTime:u,ref:d,hashedDashboardAccountId:f,preEstimateGas:p}=i,m=n.map(e=>e+s.flatFee),g=await _.prepareDepositOnChainUtxos(e,a,[t],[m]),{depositedUtxos:v,pendingLeaves:b}=g,x=v[0].map((e,t)=>({recipientAddress:r[t],utxo:e})),[S,C]=await Promise.all([_.submitDepositOnChainUtxos(e,g,p),y(e,a,t,x,s,c,l,b)]);return{depositTxHash:S,scheduleId:await h.transactCallRelayerBatch(a,C,o,u,d,f,S)}},x=async(e,t,n,r,i)=>{let{chainId:a,ethereumAddress:s,hashedEthereumAddress:l,feeStructure:d,action:f,destination:p}=i,{txCompletionTime:_,ref:b,hashedDashboardAccountId:x,preEstimateGas:S}=i,C=n.map(e=>e+d.flatFee),w=C.reduce((e,t)=>e+t,0n),T=await g.hinkalTransact(e,{chainId:a,erc20Addresses:[t.erc20TokenAddress],amountChanges:[w],externalAddress:s,selfOutputAmounts:C,createBlockedUtxos:!0,forceEmptyUtxos:!0,submit:{mode:c.SubmitMode.ProofOnly}}),E=T.circomData.encryptedOutputs?.[0];if(!E||E.length!==C.length)throw Error(`Deposit proof is missing encryptedOutputs for the deposited UTXOs`);let D=E.map((t,n)=>({recipientAddress:r[n],utxo:u.decryptUtxo(v.ethers.getBytes(t),e.userKeys)})),O=T.circomData.outCommitments.flat().map(e=>BigInt(e)).filter(e=>e!==0n).map(e=>e.toString()),[k,A]=await Promise.all([(async()=>{o.swapTronBCoordinate(T.zkCallData);let n=await m.transactCallDirectTron(e,a,w,t,T.zkCallData,T.circomData,T.dimData,void 0,void 0,S,T.tronProofSignature);if(!n)throw Error(`Deposit transaction hash not found`);return n})(),y(e,a,t,D,d,f,p,O)]);return{depositTxHash:k,scheduleId:await h.transactCallRelayerBatch(a,A,l,_,b,x,k)}},S=async(t,n,r,i,c,u,d,p,m,h=!0,g)=>{let _=l.validateAndGetChainId([n]),v=n.erc20TokenAddress,y=o.addressToHexFormat(await t.getEthereumAddressByChain(_)),S={chainId:_,ethereumAddress:y,hashedEthereumAddress:a.hashEthereumAddress(y),feeStructure:u??await f.getFeeStructure(_,v,[v],s.ExternalActionId.Transact,[],10n),txCompletionTime:c,ref:d,action:p,hashedDashboardAccountId:m?a.hashString(m):void 0,preEstimateGas:h,destination:g};if(!e.isTronLike(_))return b(t,n,r,i,S);if(r.length>4)throw Error(`Tron supports at most 4 recipients per deposit - no circuit emits more outputs`);return x(t,n,r,i,S)};exports.hinkalDepositAndWithdraw=S;
1
+ require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../functions/utils/caseInsensitive.utils.cjs`),r=require(`../../error-handling/error-codes.constants.cjs`),i=require(`../utxo/Utxo.cjs`),a=require(`../../functions/utils/tron.utils.cjs`),o=require(`../../functions/utils/addresses.cjs`),s=require(`../../types/external-action.types.cjs`),c=require(`../../types/transact.types.cjs`),l=require(`../../functions/utils/token-check.utils.cjs`),u=require(`../crypto-keys/encryptDecryptUtxo.cjs`),d=require(`../../functions/pre-transaction/constructAdminData.cjs`),f=require(`../../functions/pre-transaction/getFeeStructure.cjs`),p=require(`../../functions/pre-transaction/speculativeUtxo.cjs`),m=require(`../../functions/web3/functionCalls/transactCallDirectTron.cjs`),h=require(`../../functions/web3/functionCalls/transactCallRelayer.cjs`),g=require(`./hinkalTransact.cjs`);require(`../../functions/index.cjs`);const _=require(`./hinkalDepositOnChainUtxos.cjs`);let v=require(`ethers`);var y=async(e,o,s,l,u,f,m,h)=>{if(l.length===0)throw Error(`userDepositedUtxos must not be empty`);let _=s.erc20TokenAddress,[v,y]=await Promise.all([e.getRandomRelay(o),e.getEthereumAddressByChain(o)]);if(!v)throw Error(r.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let b=e.generateProofRemotely?5:1,x=[],S=a.addressToHexFormat(y);for(let r=0;r<l.length;r+=b){let s=l.slice(r,r+b),y=await Promise.all(s.map(async({recipientAddress:s,utxo:l},y)=>{let b=r+y,x=a.addressToHexFormat(s),C=n.caseInsensitiveEqual(l.erc20TokenAddress,_)?l:i.Utxo.createFrom(l,{erc20TokenAddress:_}),w=d.constructAdminData(f,o,[_],[-l.amount],S),{zkCallData:T,circomData:E,dimData:D,commitmentValidationData:O,tronProofSignature:k}=await g.hinkalTransact(e,{chainId:o,erc20Addresses:[_],amountChanges:[-l.amount],externalAddress:x,feeStructure:u,relay:v??t.zeroAddress,inputUtxos:[[C]],useBlockedUtxos:!0,speculative:h&&{pendingLeaves:h,inputUtxos:[[p.toSpeculativeUtxo(C)]]},submit:{mode:c.SubmitMode.ProofOnly},skipLock:!0});return{zkCallData:T,dimData:D,circomData:E,commitmentValidationData:O,adminData:w,recipientAddress:s,tronProofSignature:k,destinationChainId:m?.chainId,destinationTokenAddress:m?.tokenAddress,destinationTokenAmount:m?.tokenAmounts?.[b]}}));x.push(...y)}return x},b=async(e,t,n,r,i)=>{let{chainId:a,hashedEthereumAddress:o,feeStructure:s,action:c,destination:l}=i,{txCompletionTime:u,ref:d,hashedDashboardAccountId:f,preEstimateGas:p}=i,m=n.map(e=>e+s.flatFee),g=await _.prepareDepositOnChainUtxos(e,a,[t],[m]),{depositedUtxos:v,pendingLeaves:b}=g,x=v[0].map((e,t)=>({recipientAddress:r[t],utxo:e})),[S,C]=await Promise.all([_.submitDepositOnChainUtxos(e,g,p),y(e,a,t,x,s,c,l,b)]);return{depositTxHash:S,scheduleId:await h.transactCallRelayerBatch(a,C,o,u,d,f,S)}},x=async(e,t,n,r,i)=>{let{chainId:o,ethereumAddress:s,hashedEthereumAddress:l,feeStructure:d,action:f,destination:p}=i,{txCompletionTime:_,ref:b,hashedDashboardAccountId:x,preEstimateGas:S}=i,C=n.map(e=>e+d.flatFee),w=C.reduce((e,t)=>e+t,0n),T=await g.hinkalTransact(e,{chainId:o,erc20Addresses:[t.erc20TokenAddress],amountChanges:[w],externalAddress:s,selfOutputAmounts:C,createBlockedUtxos:!0,forceEmptyUtxos:!0,submit:{mode:c.SubmitMode.ProofOnly}}),E=T.circomData.encryptedOutputs?.[0];if(!E||E.length!==C.length)throw Error(`Deposit proof is missing encryptedOutputs for the deposited UTXOs`);let D=E.map((t,n)=>({recipientAddress:r[n],utxo:u.decryptUtxo(v.ethers.getBytes(t),e.userKeys)})),O=T.circomData.outCommitments.flat().map(e=>BigInt(e)).filter(e=>e!==0n).map(e=>e.toString()),[k,A]=await Promise.all([(async()=>{a.swapTronBCoordinate(T.zkCallData);let n=await m.transactCallDirectTron(e,o,w,t,T.zkCallData,T.circomData,T.dimData,void 0,void 0,S,T.tronProofSignature);if(!n)throw Error(`Deposit transaction hash not found`);return n})(),y(e,o,t,D,d,f,p,O)]);return{depositTxHash:k,scheduleId:await h.transactCallRelayerBatch(o,A,l,_,b,x,k)}},S=async(t,n,r,i,c,u,d,p,m,h=!0,g)=>{let _=l.validateAndGetChainId([n]),v=n.erc20TokenAddress,y=a.addressToHexFormat(await t.getEthereumAddressByChain(_)),S={chainId:_,ethereumAddress:y,hashedEthereumAddress:o.hashEthereumAddress(y),feeStructure:u??await f.getFeeStructure(_,v,[v],s.ExternalActionId.Transact,[],25n),txCompletionTime:c,ref:d,action:p,hashedDashboardAccountId:m?o.hashString(m):void 0,preEstimateGas:h,destination:g};if(!e.isTronLike(_))return b(t,n,r,i,S);if(r.length>4)throw Error(`Tron supports at most 4 recipients per deposit - no circuit emits more outputs`);return x(t,n,r,i,S)};exports.hinkalDepositAndWithdraw=S;
@@ -3,8 +3,8 @@ import { zeroAddress as t } from "../../constants/protocol.constants.mjs";
3
3
  import { caseInsensitiveEqual as n } from "../../functions/utils/caseInsensitive.utils.mjs";
4
4
  import { transactionErrorCodes as r } from "../../error-handling/error-codes.constants.mjs";
5
5
  import { Utxo as i } from "../utxo/Utxo.mjs";
6
- import { hashEthereumAddress as a, hashString as o } from "../../functions/utils/addresses.mjs";
7
- import { addressToHexFormat as s, swapTronBCoordinate as c } from "../../functions/utils/tron.utils.mjs";
6
+ import { addressToHexFormat as a, swapTronBCoordinate as o } from "../../functions/utils/tron.utils.mjs";
7
+ import { hashEthereumAddress as s, hashString as c } from "../../functions/utils/addresses.mjs";
8
8
  import { ExternalActionId as l } from "../../types/external-action.types.mjs";
9
9
  import { SubmitMode as u } from "../../types/transact.types.mjs";
10
10
  import { validateAndGetChainId as d } from "../../functions/utils/token-check.utils.mjs";
@@ -19,15 +19,15 @@ import "../../functions/index.mjs";
19
19
  import { prepareDepositOnChainUtxos as y, submitDepositOnChainUtxos as b } from "./hinkalDepositOnChainUtxos.mjs";
20
20
  import { ethers as x } from "ethers";
21
21
  //#region libs/shared/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.ts
22
- var S = async (e, a, o, c, l, d, f, m) => {
22
+ var S = async (e, o, s, c, l, d, f, m) => {
23
23
  if (c.length === 0) throw Error("userDepositedUtxos must not be empty");
24
- let g = o.erc20TokenAddress, [_, y] = await Promise.all([e.getRandomRelay(a), e.getEthereumAddressByChain(a)]);
24
+ let g = s.erc20TokenAddress, [_, y] = await Promise.all([e.getRandomRelay(o), e.getEthereumAddressByChain(o)]);
25
25
  if (!_) throw Error(r.RELAYER_NOT_AVAILABLE);
26
- let b = e.generateProofRemotely ? 5 : 1, x = [], S = s(y);
26
+ let b = e.generateProofRemotely ? 5 : 1, x = [], S = a(y);
27
27
  for (let r = 0; r < c.length; r += b) {
28
- let o = c.slice(r, r + b), y = await Promise.all(o.map(async ({ recipientAddress: o, utxo: c }, y) => {
29
- let b = r + y, x = s(o), C = n(c.erc20TokenAddress, g) ? c : i.createFrom(c, { erc20TokenAddress: g }), w = p(d, a, [g], [-c.amount], S), { zkCallData: T, circomData: E, dimData: D, commitmentValidationData: O, tronProofSignature: k } = await v(e, {
30
- chainId: a,
28
+ let s = c.slice(r, r + b), y = await Promise.all(s.map(async ({ recipientAddress: s, utxo: c }, y) => {
29
+ let b = r + y, x = a(s), C = n(c.erc20TokenAddress, g) ? c : i.createFrom(c, { erc20TokenAddress: g }), w = p(d, o, [g], [-c.amount], S), { zkCallData: T, circomData: E, dimData: D, commitmentValidationData: O, tronProofSignature: k } = await v(e, {
30
+ chainId: o,
31
31
  erc20Addresses: [g],
32
32
  amountChanges: [-c.amount],
33
33
  externalAddress: x,
@@ -48,7 +48,7 @@ var S = async (e, a, o, c, l, d, f, m) => {
48
48
  circomData: E,
49
49
  commitmentValidationData: O,
50
50
  adminData: w,
51
- recipientAddress: o,
51
+ recipientAddress: s,
52
52
  tronProofSignature: k,
53
53
  destinationChainId: f?.chainId,
54
54
  destinationTokenAddress: f?.tokenAddress,
@@ -68,11 +68,11 @@ var S = async (e, a, o, c, l, d, f, m) => {
68
68
  scheduleId: await _(a, w, o, u, d, f, C)
69
69
  };
70
70
  }, w = async (e, t, n, r, i) => {
71
- let { chainId: a, ethereumAddress: o, hashedEthereumAddress: s, feeStructure: l, action: d, destination: p } = i, { txCompletionTime: m, ref: h, hashedDashboardAccountId: y, preEstimateGas: b } = i, C = n.map((e) => e + l.flatFee), w = C.reduce((e, t) => e + t, 0n), T = await v(e, {
71
+ let { chainId: a, ethereumAddress: s, hashedEthereumAddress: c, feeStructure: l, action: d, destination: p } = i, { txCompletionTime: m, ref: h, hashedDashboardAccountId: y, preEstimateGas: b } = i, C = n.map((e) => e + l.flatFee), w = C.reduce((e, t) => e + t, 0n), T = await v(e, {
72
72
  chainId: a,
73
73
  erc20Addresses: [t.erc20TokenAddress],
74
74
  amountChanges: [w],
75
- externalAddress: o,
75
+ externalAddress: s,
76
76
  selfOutputAmounts: C,
77
77
  createBlockedUtxos: !0,
78
78
  forceEmptyUtxos: !0,
@@ -83,25 +83,25 @@ var S = async (e, a, o, c, l, d, f, m) => {
83
83
  recipientAddress: r[n],
84
84
  utxo: f(x.getBytes(t), e.userKeys)
85
85
  })), O = T.circomData.outCommitments.flat().map((e) => BigInt(e)).filter((e) => e !== 0n).map((e) => e.toString()), [k, A] = await Promise.all([(async () => {
86
- c(T.zkCallData);
86
+ o(T.zkCallData);
87
87
  let n = await g(e, a, w, t, T.zkCallData, T.circomData, T.dimData, void 0, void 0, b, T.tronProofSignature);
88
88
  if (!n) throw Error("Deposit transaction hash not found");
89
89
  return n;
90
90
  })(), S(e, a, t, D, l, d, p, O)]);
91
91
  return {
92
92
  depositTxHash: k,
93
- scheduleId: await _(a, A, s, m, h, y, k)
93
+ scheduleId: await _(a, A, c, m, h, y, k)
94
94
  };
95
- }, T = async (t, n, r, i, c, u, f, p, h, g = !0, _) => {
96
- let v = d([n]), y = n.erc20TokenAddress, b = s(await t.getEthereumAddressByChain(v)), x = {
95
+ }, T = async (t, n, r, i, o, u, f, p, h, g = !0, _) => {
96
+ let v = d([n]), y = n.erc20TokenAddress, b = a(await t.getEthereumAddressByChain(v)), x = {
97
97
  chainId: v,
98
98
  ethereumAddress: b,
99
- hashedEthereumAddress: a(b),
100
- feeStructure: u ?? await m(v, y, [y], l.Transact, [], 10n),
101
- txCompletionTime: c,
99
+ hashedEthereumAddress: s(b),
100
+ feeStructure: u ?? await m(v, y, [y], l.Transact, [], 25n),
101
+ txCompletionTime: o,
102
102
  ref: f,
103
103
  action: p,
104
- hashedDashboardAccountId: h ? o(h) : void 0,
104
+ hashedDashboardAccountId: h ? c(h) : void 0,
105
105
  preEstimateGas: g,
106
106
  destination: _
107
107
  };
@@ -1 +1 @@
1
- const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/time.utils.cjs`),n=require(`../../functions/utils/token-check.utils.cjs`),r=require(`../../constants/bridging.constants.cjs`),i=require(`../../API/callNearIntentsAPI.cjs`),a=require(`../../functions/utils/nearIntents.utils.cjs`),o=require(`./hinkalDepositAndWithdraw.cjs`),s=require(`./hinkalSolanaDepositAndWithdraw.cjs`);var c=async(c,l,u,d,f,p,m,h,g,_)=>{if(u.length!==d.length)throw Error(`recipientAmounts and recipientAddresses length mismatch`);if(u.length===0)throw Error(`No recipients to bridge`);let v=n.validateAndGetChainId([l]),y=t.secondsToMs(p),b=new Date(y+r.NEAR_BRIDGE_QUOTE_DEADLINE_BUFFER_MS).toISOString(),x=await Promise.all(d.map(async(e,t)=>{let n=u[t],{quote:r}=await i.getNearIntentsQuote({dry:!1,swapType:`EXACT_INPUT`,slippageTolerance:f.slippageBps??100,originAsset:f.originAsset,depositType:`ORIGIN_CHAIN`,destinationAsset:f.destinationAsset,amount:n.toString(),recipient:e,recipientType:`DESTINATION_CHAIN`,refundTo:c.userKeys.getNearIntentsAccountId(),refundType:`INTENTS`,deadline:b});if(!r.depositAddress)throw Error(`NEAR Intents quote returned no deposit address for recipient ${e}`);if(r.deadline&&new Date(r.deadline).getTime()<y)throw Error(`Bridge quote expires before the scheduled execution time. Choose a sooner time.`);return{destinationRecipient:e,amount:n,depositAddress:r.depositAddress,quote:r}})),S=m??await a.buildNearBridgeFeeStructure(v,l,x[0].depositAddress),C=x.map(e=>e.amount),w=x.map(e=>e.depositAddress),T={chainId:f.destinationChainId===v?void 0:f.destinationChainId,tokenAddress:f.destinationTokenAddress,tokenAmounts:x.map(e=>e.quote.amountOut)},E;return e.isSolanaLike(v)?{depositTxHash:E}=await s.hinkalSolanaDepositAndWithdraw(c,l,C,w,p,S,h,g,_,x.map(e=>e.destinationRecipient),T):{depositTxHash:E}=await o.hinkalDepositAndWithdraw(c,l,C,w,p,S,h,g,_,void 0,T),{depositTxHash:E,legs:x}};exports.hinkalNearDepositAndBridge=c;
1
+ const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/time.utils.cjs`),n=require(`../../functions/utils/token-check.utils.cjs`),r=require(`../../constants/bridging.constants.cjs`),i=require(`../../API/callNearIntentsAPI.cjs`),a=require(`../../functions/utils/nearIntents.utils.cjs`),o=require(`./hinkalDepositAndWithdraw.cjs`),s=require(`./hinkalSolanaDepositAndWithdraw.cjs`);var c=async(c,l,u,d,f,p,m,h,g,_)=>{if(u.length!==d.length)throw Error(`recipientAmounts and recipientAddresses length mismatch`);if(u.length===0)throw Error(`No recipients to bridge`);let v=n.validateAndGetChainId([l]),y=t.secondsToMs(p),b=new Date(y+r.NEAR_BRIDGE_QUOTE_DEADLINE_BUFFER_MS).toISOString(),x=await Promise.all(d.map(async(e,t)=>{let n=u[t],{quote:r}=await i.getNearIntentsQuote({dry:!1,swapType:`EXACT_INPUT`,slippageTolerance:f.slippageBps??100,originAsset:f.originAsset,depositType:`ORIGIN_CHAIN`,destinationAsset:f.destinationAsset,amount:n.toString(),recipient:e,recipientType:`DESTINATION_CHAIN`,refundTo:c.userKeys.getNearIntentsAccountId(),refundType:`INTENTS`,deadline:b});if(!r.depositAddress)throw Error(`NEAR Intents quote returned no deposit address for recipient ${e}`);if(r.deadline&&new Date(r.deadline).getTime()<y)throw Error(`Bridge quote expires before the scheduled execution time. Choose a sooner time.`);return{destinationRecipient:e,amount:n,depositAddress:r.depositAddress,quote:r}})),S=m??await a.buildNearBridgeFeeStructure(v,l,x[0].depositAddress),C=x.map(e=>e.amount),w=x.map(e=>e.depositAddress),T={chainId:f.destinationChainId===v?void 0:f.destinationChainId,tokenAddress:f.destinationTokenAddress,tokenAmounts:x.map(e=>e.quote.amountOut)},E,D;return e.isSolanaLike(v)?{depositTxHash:E,scheduleId:D}=await s.hinkalSolanaDepositAndWithdraw(c,l,C,w,p,S,h,g,_,x.map(e=>e.destinationRecipient),T):{depositTxHash:E,scheduleId:D}=await o.hinkalDepositAndWithdraw(c,l,C,w,p,S,h,g,_,void 0,T),{depositTxHash:E,scheduleId:D,legs:x}};exports.hinkalNearDepositAndBridge=c;
@@ -37,9 +37,10 @@ var c = async (c, l, u, d, f, p, m, h, g, _) => {
37
37
  chainId: f.destinationChainId === v ? void 0 : f.destinationChainId,
38
38
  tokenAddress: f.destinationTokenAddress,
39
39
  tokenAmounts: x.map((e) => e.quote.amountOut)
40
- }, E;
41
- return e(v) ? {depositTxHash: E} = await s(c, l, C, w, p, S, h, g, _, x.map((e) => e.destinationRecipient), T) : {depositTxHash: E} = await o(c, l, C, w, p, S, h, g, _, void 0, T), {
40
+ }, E, D;
41
+ return e(v) ? {depositTxHash: E, scheduleId: D} = await s(c, l, C, w, p, S, h, g, _, x.map((e) => e.destinationRecipient), T) : {depositTxHash: E, scheduleId: D} = await o(c, l, C, w, p, S, h, g, _, void 0, T), {
42
42
  depositTxHash: E,
43
+ scheduleId: D,
43
44
  legs: x
44
45
  };
45
46
  };
@@ -0,0 +1 @@
1
+ const e=require(`../../constants/chains.constants.cjs`),t=require(`../../functions/utils/token-check.utils.cjs`),n=require(`../../functions/private-wallet/emporium.helpers.cjs`),r=require(`./hinkalSolanaProxySend.cjs`);var i=async(i,a,o,s,c,l,u,d)=>{let f=t.validateAndGetChainId(a);if(e.isSolanaLike(f))return r.hinkalSolanaProxySend(i,a[0],o[0],s,c,d);let p=n.createTransaferEmporiumOpsBatch(i,f,a.map(e=>e.erc20TokenAddress),o,c),m=a.map((e,t)=>({token:e,amount:-1n*o[t]}));return await i.actionPrivateWallet(f,[],[],[],p,m,s,l,u,void 0,void 0,void 0,d,void 0)};exports.hinkalProxySend=i;
@@ -0,0 +1,6 @@
1
+ import { FeeStructure } from '../../types/hinkal.types';
2
+ import { ERC20Token } from '../../types/token.types';
3
+ import { SubAccount } from '../../types/proxy.types';
4
+ import { AdminTransactionType } from '../../types/admin.types';
5
+ import { IHinkal } from './IHinkal';
6
+ export declare const hinkalProxySend: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amounts: bigint[], subAccount: SubAccount, recipientAddress: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType) => Promise<string>;
@@ -0,0 +1,16 @@
1
+ import { isSolanaLike as e } from "../../constants/chains.constants.mjs";
2
+ import { validateAndGetChainId as t } from "../../functions/utils/token-check.utils.mjs";
3
+ import { createTransaferEmporiumOpsBatch as n } from "../../functions/private-wallet/emporium.helpers.mjs";
4
+ import { hinkalSolanaProxySend as r } from "./hinkalSolanaProxySend.mjs";
5
+ //#region libs/shared/common/src/data-structures/Hinkal/hinkalProxySend.ts
6
+ var i = async (i, a, o, s, c, l, u, d) => {
7
+ let f = t(a);
8
+ if (e(f)) return r(i, a[0], o[0], s, c, d);
9
+ let p = n(i, f, a.map((e) => e.erc20TokenAddress), o, c), m = a.map((e, t) => ({
10
+ token: e,
11
+ amount: -1n * o[t]
12
+ }));
13
+ return await i.actionPrivateWallet(f, [], [], [], p, m, s, l, u, void 0, void 0, void 0, d, void 0);
14
+ };
15
+ //#endregion
16
+ export { i as hinkalProxySend };
@@ -1 +1 @@
1
- require(`../../constants/protocol.constants.cjs`);const e=require(`../../error-handling/error-codes.constants.cjs`),t=require(`../../types/external-action.types.cjs`),n=require(`../../functions/utils/token-check.utils.cjs`),r=require(`../AccountActions/AccountActions.cjs`),i=require(`../../functions/pre-transaction/getFeeStructure.cjs`),a=require(`../../constants/addresses.constants.cjs`),o=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),s=require(`../../functions/private-wallet/emporium.swap.helpers.cjs`);var c=async(c,l,u,d,f,p,m,h,g,_=!1,v,y)=>{if(!h)throw Error(`Fee token is required in hinkalProxySwap`);let b=n.validateAndGetChainId(l),x=r.AccountActions.getAddressFromSubAccount(b,m);if(!x)throw Error(`Public account address is not available`);let S=l.map(e=>e.erc20TokenAddress),C=await c.getRandomRelay(b,!0);if(!C)throw Error(e.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let w=await s.createSwapToEmporiumOps(c,b,d,a.SWAP_ROUTER_ADDRESSES[d][b],f,S[0],u[0],u[1],S[1],p,x,C,!0),T=g??await i.getFeeStructure(b,h,S,t.ExternalActionId.Emporium,w.map(e=>o.convertEmporiumOpToCallInfo(e,x,b)),35n),E=l.map((e,t)=>({token:e,amount:u[t]}));return c.actionPrivateWallet(b,[],[],[],w,E,m,h,T,C,_,v,y,void 0)};exports.hinkalProxySwap=c;
1
+ require(`../../constants/protocol.constants.cjs`);const e=require(`../../error-handling/error-codes.constants.cjs`),t=require(`../../types/external-action.types.cjs`),n=require(`../../functions/utils/token-check.utils.cjs`),r=require(`../AccountActions/AccountActions.cjs`),i=require(`../../functions/pre-transaction/getFeeStructure.cjs`),a=require(`../../constants/addresses.constants.cjs`),o=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),s=require(`../../functions/utils/fees.utils.cjs`),c=require(`../../functions/private-wallet/emporium.swap.helpers.cjs`);var l=async(l,u,d,f,p,m,h,g,_,v=!1,y,b,x,S)=>{if(!g)throw Error(`Fee token is required in hinkalProxySwap`);let C=n.validateAndGetChainId(u),w=r.AccountActions.getAddressFromSubAccount(C,h);if(!w)throw Error(`Public account address is not available`);let T=u.map(e=>e.erc20TokenAddress),E=await l.getRandomRelay(C,!0);if(!E)throw Error(e.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let D=await c.createSwapToEmporiumOps(l,C,f,a.SWAP_ROUTER_ADDRESSES[f][C],p,T[0],d[0],d[1],T[1],m,w,E,!0),O=_??await i.getFeeStructure(C,g,T,t.ExternalActionId.Emporium,D.map(e=>o.convertEmporiumOpToCallInfo(e,w,C)),35n),k=u.map((e,t)=>({token:e,amount:d[t]})),A=x&&S!==void 0?await s.calculateModifiedFeeStructure(C,x,S,O):O;return l.actionPrivateWallet(C,[],[],[],D,k,h,g,A,E,v,y,b,void 0)};exports.hinkalProxySwap=l;
@@ -4,4 +4,4 @@ import { FeeStructure } from '../../types/hinkal.types';
4
4
  import { IHinkal } from './IHinkal';
5
5
  import { SubAccount } from '../../types/proxy.types';
6
6
  import { AdminTransactionType } from '../../types/admin.types';
7
- export declare const hinkalProxySwap: (hinkal: IHinkal, erc20Tokens: ERC20Token[], deltaAmounts: bigint[], externalActionId: ExternalActionId, data: string, isTheSameChainSwap: boolean, subAccount: SubAccount, feeToken?: string, feeStructureOverride?: FeeStructure, autoDepositBack?: boolean, maxGasInDollar?: string, action?: AdminTransactionType) => Promise<string>;
7
+ export declare const hinkalProxySwap: (hinkal: IHinkal, erc20Tokens: ERC20Token[], deltaAmounts: bigint[], externalActionId: ExternalActionId, data: string, isTheSameChainSwap: boolean, subAccount: SubAccount, feeToken?: string, feeStructureOverride?: FeeStructure, autoDepositBack?: boolean, maxGasInDollar?: string, action?: AdminTransactionType, bridgedToken?: ERC20Token, bridgedTokenAmount?: bigint) => Promise<string>;
@@ -6,19 +6,20 @@ import { AccountActions as r } from "../AccountActions/AccountActions.mjs";
6
6
  import { getFeeStructure as i } from "../../functions/pre-transaction/getFeeStructure.mjs";
7
7
  import { SWAP_ROUTER_ADDRESSES as a } from "../../constants/addresses.constants.mjs";
8
8
  import { convertEmporiumOpToCallInfo as o } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
9
- import { createSwapToEmporiumOps as s } from "../../functions/private-wallet/emporium.swap.helpers.mjs";
9
+ import { calculateModifiedFeeStructure as s } from "../../functions/utils/fees.utils.mjs";
10
+ import { createSwapToEmporiumOps as c } from "../../functions/private-wallet/emporium.swap.helpers.mjs";
10
11
  //#region libs/shared/common/src/data-structures/Hinkal/hinkalProxySwap.ts
11
- var c = async (c, l, u, d, f, p, m, h, g, _ = !1, v, y) => {
12
- if (!h) throw Error("Fee token is required in hinkalProxySwap");
13
- let b = n(l), x = r.getAddressFromSubAccount(b, m);
14
- if (!x) throw Error("Public account address is not available");
15
- let S = l.map((e) => e.erc20TokenAddress), C = await c.getRandomRelay(b, !0);
16
- if (!C) throw Error(e.RELAYER_NOT_AVAILABLE);
17
- let w = await s(c, b, d, a[d][b], f, S[0], u[0], u[1], S[1], p, x, C, !0), T = g ?? await i(b, h, S, t.Emporium, w.map((e) => o(e, x, b)), 35n), E = l.map((e, t) => ({
12
+ var l = async (l, u, d, f, p, m, h, g, _, v = !1, y, b, x, S) => {
13
+ if (!g) throw Error("Fee token is required in hinkalProxySwap");
14
+ let C = n(u), w = r.getAddressFromSubAccount(C, h);
15
+ if (!w) throw Error("Public account address is not available");
16
+ let T = u.map((e) => e.erc20TokenAddress), E = await l.getRandomRelay(C, !0);
17
+ if (!E) throw Error(e.RELAYER_NOT_AVAILABLE);
18
+ let D = await c(l, C, f, a[f][C], p, T[0], d[0], d[1], T[1], m, w, E, !0), O = _ ?? await i(C, g, T, t.Emporium, D.map((e) => o(e, w, C)), 35n), k = u.map((e, t) => ({
18
19
  token: e,
19
- amount: u[t]
20
- }));
21
- return c.actionPrivateWallet(b, [], [], [], w, E, m, h, T, C, _, v, y, void 0);
20
+ amount: d[t]
21
+ })), A = x && S !== void 0 ? await s(C, x, S, O) : O;
22
+ return l.actionPrivateWallet(C, [], [], [], D, k, h, g, A, E, v, y, b, void 0);
22
23
  };
23
24
  //#endregion
24
- export { c as hinkalProxySwap };
25
+ export { l as hinkalProxySwap };