@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
@@ -0,0 +1,214 @@
1
+ import { zeroAddress as d } from "../../constants/protocol.constants.mjs";
2
+ import { transactionErrorCodes as Z } from "../../error-handling/error-codes.constants.mjs";
3
+ import { constructEmporiumProof as $ } from "../../functions/snarkjs/constructEmporiumProof.mjs";
4
+ import { transactCallRelayerBatch as j } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
5
+ import { ExternalActionId as k } from "../../types/external-action.types.mjs";
6
+ import { Utxo as K } from "../utxo/Utxo.mjs";
7
+ import "../../types/circom-data.types.mjs";
8
+ import { ContractType as J } from "../../types/ethereum-network.types.mjs";
9
+ import "../../types/transactions.types.mjs";
10
+ import "../../types/activities.types.mjs";
11
+ import { getSignatureDataForTransact as Q } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
12
+ import { shouldPatchAccessTokenMerkleTree as X } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
13
+ import { getCurrentTimeInSeconds as tt } from "../../functions/utils/time.utils.mjs";
14
+ import { getFeeStructure as et } from "../../functions/pre-transaction/getFeeStructure.mjs";
15
+ import { hashEthereumAddress as ot } from "../../functions/utils/addresses.mjs";
16
+ import { networkRegistry as rt } from "../../constants/chains.constants.mjs";
17
+ import { SWAP_ROUTER_ADDRESSES as U } from "../../constants/addresses.constants.mjs";
18
+ import "ethers";
19
+ import "idb-keyval";
20
+ import "@solana/web3.js";
21
+ import "../http/HttpClient.mjs";
22
+ import "../../constants/vite.constants.mjs";
23
+ import { getERC20Token as st } from "../../functions/utils/erc20tokenFunctions.mjs";
24
+ import "../../functions/utils/convertIntegrationProviderToExternalActionId.mjs";
25
+ import "../../constants/server.constants.mjs";
26
+ import "../../API/getServerURL.mjs";
27
+ import "axios";
28
+ import { caseInsensitiveEqual as L } from "../../functions/utils/caseInsensitive.utils.mjs";
29
+ import "@coral-xyz/anchor";
30
+ import "circomlibjs-hinkal-fork";
31
+ import "@solana/spl-token";
32
+ import "ethers-v6h";
33
+ import "tweetnacl";
34
+ import "bs58";
35
+ import "buffer";
36
+ import "../../constants/token-data/index.mjs";
37
+ import "../../constants/contracts.constants.mjs";
38
+ import "../../constants/kyc.constants.mjs";
39
+ import "../../constants/coingecko.constants.mjs";
40
+ import "../../constants/reorg-depths.constants.mjs";
41
+ import "../../constants/token.limits.constants.mjs";
42
+ import "../../constants/presale.constants.mjs";
43
+ import "../../constants/activity.constants.mjs";
44
+ import "../../constants/tasks.constants.mjs";
45
+ import "../../constants/events.constants.mjs";
46
+ import "../../functions/utils/userAgent.mjs";
47
+ import { convertEmporiumOpToCallInfo as it } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
48
+ import "../crypto-keys/keys.mjs";
49
+ import "libsodium-wrappers";
50
+ import "multiformats";
51
+ import { validateAndGetChainId as mt } from "../../functions/utils/token-check.utils.mjs";
52
+ import "async-mutex";
53
+ import "process";
54
+ import "../../providers/EthersProviderAdapter.mjs";
55
+ import { hinkalDepositOnChainUtxos as N } from "./hinkalDepositOnChainUtxos.mjs";
56
+ import { createLifiBridgeOps as z } from "../../functions/private-wallet/emporium.helpers.mjs";
57
+ import { API as nt } from "../../API/API.mjs";
58
+ const at = async (t, e, i, u, A, a, r) => {
59
+ if (u.length === 0)
60
+ throw new Error("No recipients to bridge");
61
+ const m = i.erc20TokenAddress, { contractData: g } = rt[e], { emporiumAddress: n } = g;
62
+ if (!n)
63
+ throw Error("No Emporium Address");
64
+ const y = U[k.Lifi][e];
65
+ if (!y)
66
+ throw new Error(`LIFI not configured for chain ${e}`);
67
+ const E = await t.getRandomRelay(e);
68
+ if (!E)
69
+ throw Error(Z.RELAYER_NOT_AVAILABLE);
70
+ const h = await t.getEthereumAddressByChain(e), v = tt().toString(), f = t.generateProofRemotely ? 5 : 1, T = [];
71
+ for (let p = 0; p < u.length; p += f) {
72
+ const w = u.slice(p, p + f), o = await Promise.all(
73
+ w.map(async ({ utxo: s, nativeUtxo: c, bridgeAmount: C, quote: x, temporarySubAccount: R }) => {
74
+ await nt.addTemporaryWalletNonce(e, a, R.index);
75
+ const O = x.nativeFee > 0n && !L(m, d), l = [m], S = [-s.amount], D = [!1], P = new K({
76
+ amount: 0n,
77
+ erc20TokenAddress: m,
78
+ shieldedPrivateKey: t.userKeys.getShieldedPrivateKey(),
79
+ timeStamp: v,
80
+ tokenId: 0
81
+ }), F = [[s, P]], b = [[P]];
82
+ if (O && c) {
83
+ const B = new K({
84
+ amount: 0n,
85
+ erc20TokenAddress: d,
86
+ shieldedPrivateKey: t.userKeys.getShieldedPrivateKey(),
87
+ timeStamp: v,
88
+ tokenId: 0
89
+ });
90
+ l.push(d), S.push(-c.amount), D.push(!1), F.push([c, B]), b.push([B]);
91
+ }
92
+ const q = z(
93
+ t,
94
+ e,
95
+ R.ethAddress,
96
+ y,
97
+ m,
98
+ s.amount,
99
+ C,
100
+ x
101
+ ), { patchAccessTokenMerkleTree: _, kycRequired: H, hasAccessToken: W } = await X(
102
+ t,
103
+ e,
104
+ l,
105
+ S
106
+ ), M = await Q(
107
+ e,
108
+ h,
109
+ t.userKeys,
110
+ H,
111
+ W
112
+ ), { zkCallData: G, circomData: I, dimData: V, authorizationData: Y } = await $(
113
+ "v1x1",
114
+ t.merkleTreeHinkalByChain[e],
115
+ t.merkleTreeAccessTokenByChain[e],
116
+ l,
117
+ l.map(() => 0),
118
+ F,
119
+ b,
120
+ t.userKeys,
121
+ l.length,
122
+ F[0].length,
123
+ n,
124
+ q,
125
+ t.generateProofRemotely,
126
+ E ?? d,
127
+ e,
128
+ D,
129
+ void 0,
130
+ R.privateKey,
131
+ void 0,
132
+ _,
133
+ void 0,
134
+ A,
135
+ t.getContractWithFetcher(e, J.HinkalHelperContract),
136
+ M,
137
+ void 0,
138
+ !1
139
+ );
140
+ return { zkCallData: G, dimData: V, circomData: I, authorizationData: Y };
141
+ })
142
+ );
143
+ T.push(...o);
144
+ }
145
+ return j(e, T, a, r);
146
+ }, ue = async (t, e, i, u, A) => {
147
+ const a = e.erc20TokenAddress, r = mt([e]), m = ot(await t.getEthereumAddressByChain(r)), g = U[k.Lifi][r];
148
+ if (!g)
149
+ throw Error("LIFI router not configured");
150
+ let n;
151
+ if (A)
152
+ n = A;
153
+ else {
154
+ const o = i[0], c = z(
155
+ t,
156
+ r,
157
+ o.temporarySubAccount.ethAddress,
158
+ g,
159
+ a,
160
+ o.bridgeAmount,
161
+ o.bridgeAmount,
162
+ o.quote
163
+ ).map(
164
+ (C) => it(C, o.temporarySubAccount.ethAddress, r)
165
+ );
166
+ n = await et(r, a, [a], k.Emporium, c);
167
+ }
168
+ const y = {
169
+ feeToken: n.feeToken,
170
+ flatFee: 0n,
171
+ variableRate: 0n
172
+ }, h = i.reduce((o, s) => o + s.quote.nativeFee, 0n) > 0n && !L(a, d), v = i.map((o) => o.bridgeAmount), f = i.map((o) => o.recipientAddress), T = await N(
173
+ t,
174
+ r,
175
+ e,
176
+ v,
177
+ f,
178
+ n,
179
+ m
180
+ );
181
+ let p = [];
182
+ if (h) {
183
+ const o = st(d, r);
184
+ if (!o)
185
+ throw Error("No native token");
186
+ const s = i.map((c) => c.quote.nativeFee);
187
+ p = await N(
188
+ t,
189
+ r,
190
+ o,
191
+ s,
192
+ f,
193
+ y,
194
+ m
195
+ );
196
+ }
197
+ const w = i.map((o, s) => ({
198
+ ...o,
199
+ utxo: T[s].utxo,
200
+ nativeUtxo: h ? p[s]?.utxo : void 0
201
+ }));
202
+ return at(
203
+ t,
204
+ r,
205
+ e,
206
+ w,
207
+ n,
208
+ m,
209
+ u
210
+ );
211
+ };
212
+ export {
213
+ ue as hinkalDepositAndBridge
214
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../API/API.cjs"),o=r=>({async getAccessToken(){return a.API.getZkMeAccessToken()},async getUserAccounts(){return[await r.getEthereumAddress()]},async delegateTransaction(e){const s=await r.getProviderAdapter(),t={...e,chainId:Number(e.chainId),type:e.type?e.type:void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?e.maxPriorityFeePerGas:void 0,maxFeePerGas:e.maxFeePerGas?e.maxFeePerGas:void 0};return(await s.sendTransaction(t)).hash}});exports.getHinkalZkMeProvider=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../API/API.cjs"),n=r=>({async getAccessToken(){return a.API.getZkMeAccessToken()},async getUserAccounts(){return[await r.getEthereumAddress()]},async delegateTransaction(e){const s=r.getProviderAdapter(Number(e.chainId)),t={...e,chainId:Number(e.chainId),type:e.type?e.type:void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?e.maxPriorityFeePerGas:void 0,maxFeePerGas:e.maxFeePerGas?e.maxFeePerGas:void 0};return(await s.sendTransaction(t)).hash}});exports.getHinkalZkMeProvider=n;
@@ -1,20 +1,20 @@
1
- import { API as a } from "../../API/API.mjs";
1
+ import { API as t } from "../../API/API.mjs";
2
2
  const d = (r) => ({
3
3
  async getAccessToken() {
4
- return a.getZkMeAccessToken();
4
+ return t.getZkMeAccessToken();
5
5
  },
6
6
  async getUserAccounts() {
7
7
  return [await r.getEthereumAddress()];
8
8
  },
9
9
  async delegateTransaction(e) {
10
- const s = await r.getProviderAdapter(), t = {
10
+ const s = r.getProviderAdapter(Number(e.chainId)), a = {
11
11
  ...e,
12
12
  chainId: Number(e.chainId),
13
13
  type: e.type ? e.type : void 0,
14
14
  maxPriorityFeePerGas: e.maxPriorityFeePerGas ? e.maxPriorityFeePerGas : void 0,
15
15
  maxFeePerGas: e.maxFeePerGas ? e.maxFeePerGas : void 0
16
16
  };
17
- return (await s.sendTransaction(t)).hash;
17
+ return (await s.sendTransaction(a)).hash;
18
18
  }
19
19
  });
20
20
  export {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("../../constants/chains.constants.cjs"),k=require("../../error-handling/error-codes.constants.cjs");require("ethers");require("../../types/circom-data.types.cjs");const V=require("../../types/ethereum-network.types.cjs"),b=require("../../types/external-action.types.cjs"),j=require("../../types/hinkal.types.cjs");require("../../types/transactions.types.cjs");const G=require("../../types/admin.types.cjs");require("../../types/activities.types.cjs");require("../../constants/vite.constants.cjs");const Y=require("../../functions/snarkjs/constructEmporiumProof.cjs"),J=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),Q=require("../../functions/web3/events/getShieldedBalance.cjs"),X=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),Z=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),$=require("../../functions/utils/involves-permit2-op.cjs"),h=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),I=require("../../functions/utils/convertEmporiumOpToCallInfo.cjs"),ee=require("../../functions/pre-transaction/getFeeStructure.cjs"),re=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),te=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),oe=require("../../functions/pre-transaction/merge-with-fee-structure-emporium.cjs"),se=require("../../functions/utils/caseInsensitive.utils.cjs"),ie=require("../../functions/utils/time.utils.cjs"),ae=require("./handleAutoDepositBack.cjs"),ue=require("../crypto-keys/keys.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../http/HttpClient.cjs");require("axios");require("../../constants/token-data/index.cjs");const ne=require("../../functions/pre-transaction/constructAdminData.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("circomlibjs-hinkal-fork");require("@solana/spl-token");const ce=require("../../functions/pre-transaction/recipientUtxoProcessing.cjs"),le=require("../../functions/utils/addresses.cjs"),me=async(t,e,o,s,q,n,i,g,x,S,R,U=!1,_,T,c,d=!1)=>{if(c&&!le.isValidPrivateAddress(c.recipientInfo))throw Error(k.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const l=ue.UserKeys.getSignerAddressFromPrivateKey(e,g.privateKey),{contractData:F}=z.networkRegistry[e],{emporiumAddress:m}=F;if(!m)throw Error("No Emporium Address Provided");const p=S??await ee.getFeeStructure(e,x,o,b.ExternalActionId.Emporium,n.map(r=>I.convertEmporiumOpToCallInfo(r,l??"",e))),K=i.find(r=>se.caseInsensitiveEqual(r.token.erc20TokenAddress,p.feeToken))?.amount??0n;for(l&&await oe.mergeWithFeeStructureEmporium(t,e,l,n,o,s,p,K);q.length<o.length;)q.push(!1);const a=[...await Q.addPaddingToUtxos(t,e,o,s)],y=[],u=j.defaultHinkalLogicArgs(s.length,t.userKeys),f=ie.getCurrentTimeInSeconds().toString();for(let r=0;r<o.length;r+=1){const{outputUtxos:C}=J.outputUtxoProcessing(t.userKeys,a[r],s[r],f,void 0,!1);y.push(C);const{useApprovalUtxoData:D}=h.outputApprovalDataProcessing(t,e,a[r],s[r]);D&&(u.doPreTxApproval=!0,u.useApprovalUtxoData[r]=D,u.interactionAddress=m,u.inHinkalAddress=t.userKeys.getInHinkalAddress(m))}c&&ce.recipientUtxoProcessing(c,y,s,f);const E=R??await t.getRandomRelay(e,!d);if(!E)throw Error(k.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{patchAccessTokenMerkleTree:O,kycRequired:W,hasAccessToken:B}=await re.shouldPatchAccessTokenMerkleTree(t,e,o,s),H=await te.getSignatureDataForTransact(e,await t.getEthereumAddress(),t.userKeys,W,B),{zkCallData:w,circomData:A,dimData:P,authorizationData:v}=await Y.constructEmporiumProof("v1x1",t.merkleTreeHinkalByChain[e],t.merkleTreeAccessTokenByChain[e],o,o.map(()=>0),a,y,t.userKeys,s.length,a.length>0?a[0].length:0,m,n,t.generateProofRemotely,E,e,q,void 0,g,u,O,void 0,p,t.getContractWithFetcher(e,V.ContractType.HinkalHelperContract),H),L=$.uniswapWorkaround(n);if(d)return await X.estimateGasRelayer(e,w,P,A,v);const M=ne.constructAdminData(T,e,i.map(r=>r.token.erc20TokenAddress),i.map(r=>r.amount),await t.getEthereumAddress(),T===G.AdminTransactionType.PublicSwap?i.map(({token:r})=>r):void 0),N=await Z.transactCallRelayer(e,w,P,A,!1,L,v,M);return U&&ae.handleAutoDepositBack(t,e,l,g,p.feeToken,_,i,A),N};exports.hinkalPrivateWallet=me;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("../../constants/chains.constants.cjs"),S=require("../../error-handling/error-codes.constants.cjs");require("ethers");require("../../types/circom-data.types.cjs");const j=require("../../types/ethereum-network.types.cjs"),G=require("../../types/external-action.types.cjs"),Y=require("../../types/hinkal.types.cjs");require("../../types/transactions.types.cjs");const J=require("../../types/admin.types.cjs");require("../../types/activities.types.cjs");require("../../constants/vite.constants.cjs");const Q=require("../../functions/snarkjs/constructEmporiumProof.cjs"),X=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),Z=require("../../functions/web3/events/getShieldedBalance.cjs"),$=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),h=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),I=require("../../functions/utils/involves-permit2-op.cjs"),ee=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),re=require("../../functions/utils/convertEmporiumOpToCallInfo.cjs"),te=require("../../functions/pre-transaction/getFeeStructure.cjs"),oe=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),se=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),ie=require("../../functions/pre-transaction/merge-with-fee-structure-emporium.cjs"),ue=require("../../functions/utils/caseInsensitive.utils.cjs"),ae=require("../../functions/utils/time.utils.cjs"),ce=require("./handleAutoDepositBack.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../http/HttpClient.cjs");require("axios");require("../../constants/token-data/index.cjs");const ne=require("../../functions/pre-transaction/constructAdminData.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("circomlibjs-hinkal-fork");require("@solana/spl-token");const k=require("../AccountActions/AccountActions.cjs");require("buffer");const le=require("../../functions/pre-transaction/recipientUtxoProcessing.cjs"),Ae=require("../../functions/utils/addresses.cjs"),me=async(t,e,x,o,d,n,i,p,R,_,U,F=!1,B,y,l,T=!1)=>{if(l&&!Ae.isValidPrivateAddress(l.recipientInfo))throw Error(S.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const s=x.map(r=>r.erc20TokenAddress),u=k.AccountActions.getAddressFromSubAccount(e,p);if(!u)throw Error("Public account address is not available");const{contractData:O}=V.networkRegistry[e],{emporiumAddress:A}=O;if(!A)throw Error("No Emporium Address Provided");const m=_??await te.getFeeStructure(e,R,s,G.ExternalActionId.Emporium,n.map(r=>re.convertEmporiumOpToCallInfo(r,u??"",e))),W=i.find(r=>ue.caseInsensitiveEqual(r.token.erc20TokenAddress,m.feeToken))?.amount??0n;for(u&&await ie.mergeWithFeeStructureEmporium(t,e,u,n,s,o,m,W);d.length<s.length;)d.push(!1);const a=[...await Z.addPaddingToUtxos(t,e,s,o)],q=[],c=Y.defaultHinkalLogicArgs(o.length,t.userKeys),f=ae.getCurrentTimeInSeconds().toString();for(let r=0;r<s.length;r+=1){const{outputUtxos:z}=X.outputUtxoProcessing(t.userKeys,a[r],o[r],f,void 0,!1);q.push(z);const{useApprovalUtxoData:D}=ee.outputApprovalDataProcessing(t,e,a[r],o[r]);D&&(c.doPreTxApproval=!0,c.useApprovalUtxoData[r]=D,c.interactionAddress=A,c.inHinkalAddress=t.userKeys.getInHinkalAddress(A))}l&&le.recipientUtxoProcessing(l,q,o,f);const E=U??await t.getRandomRelay(e,!T);if(!E)throw Error(S.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{patchAccessTokenMerkleTree:H,kycRequired:K,hasAccessToken:b}=await oe.shouldPatchAccessTokenMerkleTree(t,e,s,o),C=await se.getSignatureDataForTransact(e,await t.getEthereumAddressByChain(e),t.userKeys,K,b),{zkCallData:w,circomData:g,dimData:P,authorizationData:v}=await Q.constructEmporiumProof("v1x1",t.merkleTreeHinkalByChain[e],t.merkleTreeAccessTokenByChain[e],s,s.map(()=>0),a,q,t.userKeys,o.length,a.length>0?a[0].length:0,A,n,t.generateProofRemotely,E,e,d,void 0,k.AccountActions.getPrivateKeyFromSubAccount(e,p),c,H,void 0,m,t.getContractWithFetcher(e,j.ContractType.HinkalHelperContract),C),L=I.uniswapWorkaround(n);if(T)return await $.estimateGasRelayer(e,w,P,g,v);const M=ne.constructAdminData(y,e,i.map(r=>r.token.erc20TokenAddress),i.map(r=>r.amount),await t.getEthereumAddressByChain(e),y===J.AdminTransactionType.PublicSwap?i.map(({token:r})=>r):void 0),N=await h.transactCallRelayer(e,w,P,g,!1,L,v,M);return F&&ce.handleAutoDepositBack(t,e,u,p,m.feeToken,B,i,g),N};exports.hinkalPrivateWallet=me;
@@ -1,6 +1,6 @@
1
1
  import { IHinkal } from './IHinkal';
2
2
  import { FeeStructure } from '../../types/hinkal.types';
3
- import { PrivateRecipientInfo, TokenChanges } from '../../types/token.types';
3
+ import { ERC20Token, PrivateRecipientInfo, TokenChanges } from '../../types/token.types';
4
4
  import { SubAccount } from '../../types/proxy.types';
5
5
  import { AdminTransactionType } from '../../types/admin.types';
6
- export declare const hinkalPrivateWallet: (hinkal: IHinkal, chainId: number, erc20Addresses: string[], deltaChanges: bigint[], onChainCreation: boolean[], ops: string[], emporiumTokenChanges: TokenChanges<bigint>[], subAccount: SubAccount, feeToken?: string, feeStructureOverride?: FeeStructure, relayOverride?: string, autoDepositBack?: boolean, maxGasInDollar?: string, action?: AdminTransactionType, privateRecipientInfo?: PrivateRecipientInfo, onlyGasEstimate?: boolean) => Promise<bigint | import('../../index.ts').RelayerTransaction>;
6
+ export declare const hinkalPrivateWallet: (hinkal: IHinkal, chainId: number, erc20Tokens: ERC20Token[], deltaChanges: bigint[], onChainCreation: boolean[], ops: string[], emporiumTokenChanges: TokenChanges<bigint>[], subAccount: SubAccount, feeToken?: string, feeStructureOverride?: FeeStructure, relayOverride?: string, autoDepositBack?: boolean, maxGasInDollar?: string, action?: AdminTransactionType, privateRecipientInfo?: PrivateRecipientInfo, onlyGasEstimate?: boolean) => Promise<bigint | import('../../index.ts').RelayerTransaction>;
@@ -1,4 +1,4 @@
1
- import { networkRegistry as V } from "../../constants/chains.constants.mjs";
1
+ import { networkRegistry as C } from "../../constants/chains.constants.mjs";
2
2
  import { transactionErrorCodes as R } from "../../error-handling/error-codes.constants.mjs";
3
3
  import "ethers";
4
4
  import "../../types/circom-data.types.mjs";
@@ -13,141 +13,145 @@ import { constructEmporiumProof as Q } from "../../functions/snarkjs/constructEm
13
13
  import { outputUtxoProcessing as X } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
14
14
  import { addPaddingToUtxos as Z } from "../../functions/web3/events/getShieldedBalance.mjs";
15
15
  import { estimateGasRelayer as $ } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
16
- import { transactCallRelayer as b } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
17
- import { uniswapWorkaround as C } from "../../functions/utils/involves-permit2-op.mjs";
18
- import { outputApprovalDataProcessing as I } from "../../functions/pre-transaction/outputApprovalDataProcessing.mjs";
19
- import { convertEmporiumOpToCallInfo as h } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
20
- import { getFeeStructure as tt } from "../../functions/pre-transaction/getFeeStructure.mjs";
21
- import { shouldPatchAccessTokenMerkleTree as rt } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
22
- import { getSignatureDataForTransact as ot } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
23
- import { mergeWithFeeStructureEmporium as et } from "../../functions/pre-transaction/merge-with-fee-structure-emporium.mjs";
24
- import { caseInsensitiveEqual as mt } from "../../functions/utils/caseInsensitive.utils.mjs";
25
- import { getCurrentTimeInSeconds as it } from "../../functions/utils/time.utils.mjs";
26
- import { handleAutoDepositBack as st } from "./handleAutoDepositBack.mjs";
27
- import { UserKeys as at } from "../crypto-keys/keys.mjs";
16
+ import { transactCallRelayer as I } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
17
+ import { uniswapWorkaround as h } from "../../functions/utils/involves-permit2-op.mjs";
18
+ import { outputApprovalDataProcessing as rr } from "../../functions/pre-transaction/outputApprovalDataProcessing.mjs";
19
+ import { convertEmporiumOpToCallInfo as tr } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
20
+ import { getFeeStructure as or } from "../../functions/pre-transaction/getFeeStructure.mjs";
21
+ import { shouldPatchAccessTokenMerkleTree as er } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
22
+ import { getSignatureDataForTransact as sr } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
23
+ import { mergeWithFeeStructureEmporium as mr } from "../../functions/pre-transaction/merge-with-fee-structure-emporium.mjs";
24
+ import { caseInsensitiveEqual as ir } from "../../functions/utils/caseInsensitive.utils.mjs";
25
+ import { getCurrentTimeInSeconds as ar } from "../../functions/utils/time.utils.mjs";
26
+ import { handleAutoDepositBack as pr } from "./handleAutoDepositBack.mjs";
28
27
  import "../../constants/server.constants.mjs";
29
28
  import "../../API/getServerURL.mjs";
30
29
  import "../http/HttpClient.mjs";
31
30
  import "axios";
32
31
  import "../../constants/token-data/index.mjs";
33
- import { constructAdminData as pt } from "../../functions/pre-transaction/constructAdminData.mjs";
32
+ import { constructAdminData as cr } from "../../functions/pre-transaction/constructAdminData.mjs";
34
33
  import "@coral-xyz/anchor";
35
34
  import "@solana/web3.js";
36
35
  import "circomlibjs-hinkal-fork";
37
36
  import "@solana/spl-token";
38
- import { recipientUtxoProcessing as ft } from "../../functions/pre-transaction/recipientUtxoProcessing.mjs";
39
- import { isValidPrivateAddress as ut } from "../../functions/utils/addresses.mjs";
40
- const bt = async (o, t, e, m, l, p, i, A, U, S, k, K = !1, F, y, f, T = !1) => {
41
- if (f && !ut(f.recipientInfo))
37
+ import { AccountActions as S } from "../AccountActions/AccountActions.mjs";
38
+ import "buffer";
39
+ import { recipientUtxoProcessing as ur } from "../../functions/pre-transaction/recipientUtxoProcessing.mjs";
40
+ import { isValidPrivateAddress as fr } from "../../functions/utils/addresses.mjs";
41
+ const Ir = async (o, r, k, e, A, c, m, l, U, F, B, H = !1, K, w, u, T = !1) => {
42
+ if (u && !fr(u.recipientInfo))
42
43
  throw Error(R.RECIPIENT_FORMAT_INCORRECT);
43
- const u = at.getSignerAddressFromPrivateKey(t, A.privateKey), { contractData: H } = V[t], { emporiumAddress: n } = H;
44
- if (!n)
44
+ const s = k.map((t) => t.erc20TokenAddress), i = S.getAddressFromSubAccount(r, l);
45
+ if (!i)
46
+ throw Error("Public account address is not available");
47
+ const { contractData: L } = C[r], { emporiumAddress: f } = L;
48
+ if (!f)
45
49
  throw Error("No Emporium Address Provided");
46
- const c = S ?? await tt(
47
- t,
50
+ const n = F ?? await or(
51
+ r,
48
52
  U,
49
- e,
53
+ s,
50
54
  j.Emporium,
51
- p.map((r) => h(r, u ?? "", t))
52
- ), L = i.find(
53
- (r) => mt(r.token.erc20TokenAddress, c.feeToken)
55
+ c.map((t) => tr(t, i ?? "", r))
56
+ ), W = m.find(
57
+ (t) => ir(t.token.erc20TokenAddress, n.feeToken)
54
58
  )?.amount ?? 0n;
55
- for (u && await et(
59
+ for (i && await mr(
56
60
  o,
57
- t,
58
- u,
59
- p,
60
- e,
61
- m,
61
+ r,
62
+ i,
62
63
  c,
63
- L
64
- ); l.length < e.length; )
65
- l.push(!1);
66
- const s = [...await Z(o, t, e, m)], g = [], a = G(m.length, o.userKeys), E = it().toString();
67
- for (let r = 0; r < e.length; r += 1) {
68
- const { outputUtxos: z } = X(
64
+ s,
65
+ e,
66
+ n,
67
+ W
68
+ ); A.length < s.length; )
69
+ A.push(!1);
70
+ const a = [...await Z(o, r, s, e)], d = [], p = G(e.length, o.userKeys), y = ar().toString();
71
+ for (let t = 0; t < s.length; t += 1) {
72
+ const { outputUtxos: V } = X(
69
73
  o.userKeys,
70
- s[r],
71
- m[r],
72
- E,
74
+ a[t],
75
+ e[t],
76
+ y,
73
77
  void 0,
74
78
  !1
75
79
  );
76
- g.push(z);
77
- const { useApprovalUtxoData: D } = I(o, t, s[r], m[r]);
78
- D && (a.doPreTxApproval = !0, a.useApprovalUtxoData[r] = D, a.interactionAddress = n, a.inHinkalAddress = o.userKeys.getInHinkalAddress(n));
80
+ d.push(V);
81
+ const { useApprovalUtxoData: D } = rr(o, r, a[t], e[t]);
82
+ D && (p.doPreTxApproval = !0, p.useApprovalUtxoData[t] = D, p.interactionAddress = f, p.inHinkalAddress = o.userKeys.getInHinkalAddress(f));
79
83
  }
80
- f && ft(f, g, m, E);
81
- const P = k ?? await o.getRandomRelay(t, !T);
82
- if (!P)
84
+ u && ur(u, d, e, y);
85
+ const E = B ?? await o.getRandomRelay(r, !T);
86
+ if (!E)
83
87
  throw Error(R.RELAYER_NOT_AVAILABLE);
84
- const { patchAccessTokenMerkleTree: W, kycRequired: B, hasAccessToken: N } = await rt(
88
+ const { patchAccessTokenMerkleTree: N, kycRequired: O, hasAccessToken: _ } = await er(
85
89
  o,
86
- t,
87
- e,
88
- m
89
- ), O = await ot(
90
- t,
91
- await o.getEthereumAddress(),
90
+ r,
91
+ s,
92
+ e
93
+ ), b = await sr(
94
+ r,
95
+ await o.getEthereumAddressByChain(r),
92
96
  o.userKeys,
93
- B,
94
- N
95
- ), { zkCallData: d, circomData: w, dimData: v, authorizationData: x } = await Q(
97
+ O,
98
+ _
99
+ ), { zkCallData: P, circomData: g, dimData: v, authorizationData: x } = await Q(
96
100
  "v1x1",
97
- o.merkleTreeHinkalByChain[t],
98
- o.merkleTreeAccessTokenByChain[t],
99
- e,
100
- e.map(() => 0),
101
+ o.merkleTreeHinkalByChain[r],
102
+ o.merkleTreeAccessTokenByChain[r],
101
103
  s,
102
- g,
104
+ s.map(() => 0),
105
+ a,
106
+ d,
103
107
  o.userKeys,
104
- m.length,
105
- s.length > 0 ? s[0].length : 0,
106
- n,
107
- p,
108
+ e.length,
109
+ a.length > 0 ? a[0].length : 0,
110
+ f,
111
+ c,
108
112
  o.generateProofRemotely,
109
- P,
110
- t,
111
- l,
112
- void 0,
113
+ E,
114
+ r,
113
115
  A,
114
- a,
115
- W,
116
116
  void 0,
117
- c,
118
- o.getContractWithFetcher(t, Y.HinkalHelperContract),
119
- O
120
- ), _ = C(p);
117
+ S.getPrivateKeyFromSubAccount(r, l),
118
+ p,
119
+ N,
120
+ void 0,
121
+ n,
122
+ o.getContractWithFetcher(r, Y.HinkalHelperContract),
123
+ b
124
+ ), M = h(c);
121
125
  if (T)
122
- return await $(t, d, v, w, x);
123
- const M = pt(
124
- y,
125
- t,
126
- i.map((r) => r.token.erc20TokenAddress),
127
- i.map((r) => r.amount),
128
- await o.getEthereumAddress(),
129
- y === J.PublicSwap ? i.map(({ token: r }) => r) : void 0
130
- ), q = await b(
131
- t,
132
- d,
133
- v,
126
+ return await $(r, P, v, g, x);
127
+ const q = cr(
134
128
  w,
129
+ r,
130
+ m.map((t) => t.token.erc20TokenAddress),
131
+ m.map((t) => t.amount),
132
+ await o.getEthereumAddressByChain(r),
133
+ w === J.PublicSwap ? m.map(({ token: t }) => t) : void 0
134
+ ), z = await I(
135
+ r,
136
+ P,
137
+ v,
138
+ g,
135
139
  !1,
136
- _,
140
+ M,
137
141
  x,
138
- M
142
+ q
139
143
  );
140
- return K && st(
144
+ return H && pr(
141
145
  o,
142
- t,
143
- u,
144
- A,
145
- c.feeToken,
146
- F,
146
+ r,
147
147
  i,
148
- w
149
- ), q;
148
+ l,
149
+ n.feeToken,
150
+ K,
151
+ m,
152
+ g
153
+ ), z;
150
154
  };
151
155
  export {
152
- bt as hinkalPrivateWallet
156
+ Ir as hinkalPrivateWallet
153
157
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("../../constants/addresses.constants.cjs"),h=require("../../functions/pre-transaction/getFeeStructure.cjs"),v=require("../../functions/private-wallet/emporium.swap.helpers.cjs"),P=require("../../functions/utils/convertEmporiumOpToCallInfo.cjs"),f=require("../../types/external-action.types.cjs"),C=require("../../error-handling/error-codes.constants.cjs"),I=require("../../constants/protocol.constants.cjs"),O=require("../crypto-keys/keys.cjs"),L=require("../../functions/utils/token-check.utils.cjs"),T=async(t,o,s,c,m,E,u,n,S,A=!1,_,w,p=!1)=>{if(!n)throw new Error("Fee token is required in hinkalProxySwap");const e=L.validateAndGetChainId(o),d=O.UserKeys.getSignerAddressFromPrivateKey(e,u.privateKey),a=o.map(r=>r.erc20TokenAddress),i=await t.getRandomRelay(e,!p);if(!i)throw Error(C.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const l=await v.createSwapToEmporiumOps(t,e,c,g.SWAP_ROUTER_ADDRESSES[c][e],m,a[0],s[0],s[1],a[1],E,d,i,!0),y=S??await h.getFeeStructure(e,n,a,f.ExternalActionId.Emporium,l.map(r=>P.convertEmporiumOpToCallInfo(r,d,e)),I.HINKAL_SWAP_VARIABLE_RATE),q=o.map((r,R)=>({token:r,amount:s[R]}));return t.actionPrivateWallet(e,[],[],[],l,q,u,n,y,i,A,_,w,void 0,p)};exports.hinkalProxySwap=T;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../constants/addresses.constants.cjs"),y=require("../../functions/pre-transaction/getFeeStructure.cjs"),P=require("../../functions/private-wallet/emporium.swap.helpers.cjs"),g=require("../../functions/utils/convertEmporiumOpToCallInfo.cjs"),v=require("../../types/external-action.types.cjs"),C=require("../../error-handling/error-codes.constants.cjs"),I=require("../../constants/protocol.constants.cjs"),O=require("../../functions/utils/token-check.utils.cjs"),L=require("../AccountActions/AccountActions.cjs"),T=async(t,o,s,u,A,m,p,n,E,S=!1,_,w,d=!1)=>{if(!n)throw new Error("Fee token is required in hinkalProxySwap");const r=O.validateAndGetChainId(o),a=L.AccountActions.getAddressFromSubAccount(r,p);if(!a)throw Error("Public account address is not available");const c=o.map(e=>e.erc20TokenAddress),i=await t.getRandomRelay(r,!d);if(!i)throw Error(C.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const l=await P.createSwapToEmporiumOps(t,r,u,f.SWAP_ROUTER_ADDRESSES[u][r],A,c[0],s[0],s[1],c[1],m,a,i,!0),q=E??await y.getFeeStructure(r,n,c,v.ExternalActionId.Emporium,l.map(e=>g.convertEmporiumOpToCallInfo(e,a,r)),I.HINKAL_SWAP_VARIABLE_RATE),h=o.map((e,R)=>({token:e,amount:s[R]}));return t.actionPrivateWallet(r,[],[],[],l,h,p,n,q,i,S,_,w,void 0,d)};exports.hinkalProxySwap=T;
@@ -1,61 +1,64 @@
1
- import { SWAP_ROUTER_ADDRESSES as v } from "../../constants/addresses.constants.mjs";
2
- import { getFeeStructure as I } from "../../functions/pre-transaction/getFeeStructure.mjs";
3
- import { createSwapToEmporiumOps as P } from "../../functions/private-wallet/emporium.swap.helpers.mjs";
4
- import { convertEmporiumOpToCallInfo as g } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
5
- import { ExternalActionId as h } from "../../types/external-action.types.mjs";
6
- import { transactionErrorCodes as L } from "../../error-handling/error-codes.constants.mjs";
7
- import { HINKAL_SWAP_VARIABLE_RATE as O } from "../../constants/protocol.constants.mjs";
8
- import { UserKeys as C } from "../crypto-keys/keys.mjs";
9
- import { validateAndGetChainId as K } from "../../functions/utils/token-check.utils.mjs";
10
- const q = async (t, e, a, s, E, A, n, i, S, w = !1, R, l, c = !1) => {
11
- if (!i)
1
+ import { SWAP_ROUTER_ADDRESSES as I } from "../../constants/addresses.constants.mjs";
2
+ import { getFeeStructure as P } from "../../functions/pre-transaction/getFeeStructure.mjs";
3
+ import { createSwapToEmporiumOps as v } from "../../functions/private-wallet/emporium.swap.helpers.mjs";
4
+ import { convertEmporiumOpToCallInfo as L } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
5
+ import { ExternalActionId as O } from "../../types/external-action.types.mjs";
6
+ import { transactionErrorCodes as g } from "../../error-handling/error-codes.constants.mjs";
7
+ import { HINKAL_SWAP_VARIABLE_RATE as y } from "../../constants/protocol.constants.mjs";
8
+ import { validateAndGetChainId as C } from "../../functions/utils/token-check.utils.mjs";
9
+ import { AccountActions as x } from "../AccountActions/AccountActions.mjs";
10
+ const H = async (t, a, i, p, f, E, c, e, u, l = !1, w, S, d = !1) => {
11
+ if (!e)
12
12
  throw new Error("Fee token is required in hinkalProxySwap");
13
- const r = K(e), d = C.getSignerAddressFromPrivateKey(r, n.privateKey), m = e.map((o) => o.erc20TokenAddress), p = await t.getRandomRelay(r, !c);
14
- if (!p)
15
- throw Error(L.RELAYER_NOT_AVAILABLE);
16
- const f = await P(
13
+ const r = C(a), m = x.getAddressFromSubAccount(r, c);
14
+ if (!m)
15
+ throw Error("Public account address is not available");
16
+ const n = a.map((o) => o.erc20TokenAddress), s = await t.getRandomRelay(r, !d);
17
+ if (!s)
18
+ throw Error(g.RELAYER_NOT_AVAILABLE);
19
+ const A = await v(
17
20
  t,
18
21
  r,
19
- s,
20
- v[s][r],
21
- E,
22
- m[0],
23
- a[0],
24
- a[1],
25
- m[1],
26
- A,
27
- d,
28
22
  p,
23
+ I[p][r],
24
+ f,
25
+ n[0],
26
+ i[0],
27
+ i[1],
28
+ n[1],
29
+ E,
30
+ m,
31
+ s,
29
32
  !0
30
- ), u = S ?? await I(
33
+ ), R = u ?? await P(
31
34
  r,
32
- i,
33
- m,
34
- h.Emporium,
35
- f.map((o) => g(o, d, r)),
36
- O
37
- ), y = e.map((o, _) => ({
35
+ e,
36
+ n,
37
+ O.Emporium,
38
+ A.map((o) => L(o, m, r)),
39
+ y
40
+ ), _ = a.map((o, h) => ({
38
41
  token: o,
39
- amount: a[_]
42
+ amount: i[h]
40
43
  }));
41
44
  return t.actionPrivateWallet(
42
45
  r,
43
46
  [],
44
47
  [],
45
48
  [],
46
- f,
47
- y,
48
- n,
49
- i,
50
- u,
51
- p,
52
- w,
49
+ A,
50
+ _,
51
+ c,
52
+ e,
53
53
  R,
54
+ s,
54
55
  l,
56
+ w,
57
+ S,
55
58
  void 0,
56
- c
59
+ d
57
60
  );
58
61
  };
59
62
  export {
60
- q as hinkalProxySwap
63
+ H as hinkalProxySwap
61
64
  };