@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.
- package/API/API.cjs +1 -1
- package/API/API.d.ts +6 -1
- package/API/API.mjs +48 -41
- package/API/enclaveCalls.cjs +1 -1
- package/API/enclaveCalls.mjs +5 -4
- package/API/index.d.ts +1 -0
- package/API/proxyAccountsCalls.cjs +1 -1
- package/API/proxyAccountsCalls.d.ts +7 -2
- package/API/proxyAccountsCalls.mjs +26 -20
- package/API/temporaryWalletCalls.cjs +1 -0
- package/API/temporaryWalletCalls.d.ts +13 -0
- package/API/temporaryWalletCalls.mjs +20 -0
- package/API/unspent-utxos-calls.cjs +1 -1
- package/API/unspent-utxos-calls.d.ts +1 -1
- package/API/unspent-utxos-calls.mjs +16 -14
- package/README.md +36 -13
- package/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.d.ts +1 -1
- package/constants/chains.constants.mjs +69 -51
- package/constants/deploy-data/deploy-data-solana.json.cjs +1 -1
- package/constants/deploy-data/deploy-data-solana.json.mjs +28 -2
- package/constants/kyc.constants.cjs +1 -1
- package/constants/kyc.constants.mjs +39 -40
- package/constants/mediaUrls.constants.cjs +1 -1
- package/constants/mediaUrls.constants.d.ts +1 -0
- package/constants/mediaUrls.constants.mjs +2 -1
- package/constants/server.constants.cjs +1 -1
- package/constants/server.constants.d.ts +6 -1
- package/constants/server.constants.mjs +37 -32
- package/constants/token-data/polygonRegistry.json.cjs +1 -1
- package/constants/token-data/polygonRegistry.json.mjs +4 -4
- package/constants/token-data/polygonRegistryFixed.json.cjs +1 -1
- package/constants/token-data/polygonRegistryFixed.json.mjs +4 -4
- package/data-structures/AccountActions/AccountActions.cjs +1 -0
- package/data-structures/AccountActions/AccountActions.d.ts +18 -0
- package/data-structures/AccountActions/AccountActions.mjs +78 -0
- package/data-structures/AccountActions/index.d.ts +1 -0
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.cjs +1 -1
- package/data-structures/ApprovalDBs/EventsPublicApprovalsDB.mjs +68 -71
- package/data-structures/BlockchainEvent/BlockchainEvent.cjs +1 -0
- package/data-structures/BlockchainEvent/BlockchainEvent.d.ts +14 -0
- package/data-structures/BlockchainEvent/BlockchainEvent.mjs +41 -0
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +14 -8
- package/data-structures/Hinkal/Hinkal.mjs +215 -179
- package/data-structures/Hinkal/IHinkal.d.ts +9 -6
- package/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.mjs +47 -48
- package/data-structures/Hinkal/hinkalActionReceive.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionReceive.mjs +25 -22
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.cjs +1 -1
- package/data-structures/Hinkal/hinkalCheckTokenRegistry.mjs +12 -12
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +63 -63
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +60 -147
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -0
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +4 -0
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +103 -0
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -0
- package/data-structures/Hinkal/hinkalDepostAndBridge.d.ts +4 -0
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +214 -0
- package/data-structures/Hinkal/hinkalGetZkMeProvider.cjs +1 -1
- package/data-structures/Hinkal/hinkalGetZkMeProvider.mjs +4 -4
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.d.ts +2 -2
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +103 -99
- package/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxySwap.mjs +44 -41
- package/data-structures/Hinkal/hinkalProxyToPrivate.cjs +1 -1
- package/data-structures/Hinkal/hinkalProxyToPrivate.mjs +31 -28
- package/data-structures/Hinkal/hinkalSignSubAccount.cjs +1 -1
- package/data-structures/Hinkal/hinkalSignSubAccount.mjs +16 -13
- package/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDeposit.mjs +34 -34
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +67 -65
- package/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySend.mjs +35 -32
- package/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +59 -56
- package/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +35 -32
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +10 -10
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +25 -25
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +34 -30
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +43 -39
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +47 -43
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +50 -46
- package/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/data-structures/Hinkal/resetMerkleTrees.mjs +36 -34
- package/data-structures/IndexedDB/activity-db.cjs +1 -1
- package/data-structures/IndexedDB/activity-db.d.ts +1 -0
- package/data-structures/IndexedDB/activity-db.mjs +86 -70
- package/data-structures/IndexedDB/balances-db.cjs +1 -1
- package/data-structures/IndexedDB/balances-db.mjs +33 -30
- package/data-structures/IndexedDB/contact-db.cjs +1 -1
- package/data-structures/IndexedDB/contact-db.mjs +9 -6
- package/data-structures/PublicBalance/PublicBalanceWatcher.cjs +1 -0
- package/data-structures/PublicBalance/PublicBalanceWatcher.d.ts +20 -0
- package/data-structures/PublicBalance/PublicBalanceWatcher.mjs +124 -0
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.cjs +1 -0
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.d.ts +15 -0
- package/data-structures/PublicBalance/SolanaPublicBalancerWatcher.mjs +64 -0
- package/data-structures/PublicBalance/index.d.ts +2 -0
- package/data-structures/TokenDBs/EventsPublicTokensDB.cjs +1 -1
- package/data-structures/TokenDBs/EventsPublicTokensDB.mjs +77 -78
- package/data-structures/crypto-keys/keys.cjs +1 -1
- package/data-structures/crypto-keys/keys.d.ts +0 -11
- package/data-structures/crypto-keys/keys.mjs +47 -107
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.d.ts +3 -2
- package/data-structures/event-service/evm/AbstractAccessTokenSnapshotService.mjs +9 -9
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.d.ts +3 -2
- package/data-structures/event-service/evm/AbstractApprovalsSnapshotService.mjs +5 -5
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.d.ts +3 -2
- package/data-structures/event-service/evm/AbstractCommitmentsSnapshotService.mjs +6 -6
- package/data-structures/event-service/evm/AbstractEventService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractEventService.d.ts +3 -2
- package/data-structures/event-service/evm/AbstractEventService.mjs +16 -19
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.d.ts +3 -3
- package/data-structures/event-service/evm/AbstractNullifierSnapshotService.mjs +6 -5
- package/data-structures/event-service/evm/AbstractSnapshotService.d.ts +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/evm/BlockchainEventEmitter.d.ts +7 -4
- package/data-structures/event-service/evm/BlockchainEventEmitter.mjs +35 -34
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.d.ts +11 -0
- package/data-structures/event-service/evm/ClientBlockchainEventEmitter.mjs +21 -0
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.d.ts +6 -0
- package/data-structures/event-service/evm/PollingBlockchainEventEmitter.mjs +16 -0
- package/data-structures/event-service/helpers/ClientEventHelper.cjs +1 -0
- package/data-structures/event-service/helpers/ClientEventHelper.d.ts +11 -0
- package/data-structures/event-service/helpers/ClientEventHelper.mjs +26 -0
- package/data-structures/event-service/helpers/PollingEventHelper.cjs +1 -0
- package/data-structures/event-service/helpers/PollingEventHelper.d.ts +5 -0
- package/data-structures/event-service/helpers/PollingEventHelper.mjs +14 -0
- package/data-structures/event-service/index.d.ts +4 -0
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.d.ts +3 -2
- package/data-structures/event-service/solana/AbstractSolanaAccessTokenSnapshotService.mjs +6 -6
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.d.ts +4 -3
- package/data-structures/event-service/solana/AbstractSolanaCommitmentsSnapshotService.mjs +8 -8
- package/data-structures/event-service/solana/AbstractSolanaEventService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaEventService.d.ts +3 -10
- package/data-structures/event-service/solana/AbstractSolanaEventService.mjs +5 -5
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.d.ts +3 -2
- package/data-structures/event-service/solana/AbstractSolanaNullifierSnapshotService.mjs +1 -1
- package/data-structures/event-service/solana/AbstractSolanaSnapshotService.d.ts +1 -1
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.d.ts +11 -0
- package/data-structures/event-service/solana/ClientSolanaBlockchainEventEmitter.mjs +22 -0
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.cjs +1 -0
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.d.ts +6 -0
- package/data-structures/event-service/solana/PollingSolanaBlockchainEventEmitter.mjs +16 -0
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.cjs +1 -1
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.d.ts +8 -14
- package/data-structures/event-service/solana/SolanaBlockchainEventEmitter.mjs +68 -67
- package/data-structures/index.d.ts +3 -0
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientAccessTokenSnapshotService.mjs +5 -2
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientApprovalsSnapshotService.mjs +5 -2
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientCommitmentsSnapshotService.mjs +5 -2
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/evm-snapshots/ClientNullifierSnapshotService.mjs +5 -2
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaAccessTokenSnapshotService.mjs +5 -2
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaCommitmentsSnapshotService.mjs +5 -2
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/solana-snapshots/ClientSolanaNullifierSnapshotService.mjs +5 -2
- package/data-structures/utxo/Utxo.cjs +1 -1
- package/data-structures/utxo/Utxo.d.ts +1 -0
- package/data-structures/utxo/Utxo.mjs +18 -4
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.mjs +2 -2
- package/functions/pre-transaction/getSolanaCalldataHash.cjs +1 -1
- package/functions/pre-transaction/getSolanaCalldataHash.mjs +22 -22
- package/functions/pre-transaction/sendV0Transaction.cjs +1 -1
- package/functions/pre-transaction/sendV0Transaction.mjs +53 -50
- package/functions/pre-transaction/solana.cjs +1 -1
- package/functions/pre-transaction/solana.mjs +93 -93
- package/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/functions/private-wallet/emporium.helpers.d.ts +3 -2
- package/functions/private-wallet/emporium.helpers.mjs +118 -93
- package/functions/snarkjs/constructEmporiumProof.cjs +1 -1
- package/functions/snarkjs/constructEmporiumProof.d.ts +1 -2
- package/functions/snarkjs/constructEmporiumProof.mjs +89 -89
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/functions/snarkjs/constructSolanaZkProof.mjs +6 -2
- package/functions/utils/bytes32.utils.cjs +1 -1
- package/functions/utils/bytes32.utils.mjs +8 -7
- package/functions/utils/create-provider.cjs +1 -1
- package/functions/utils/create-provider.d.ts +1 -1
- package/functions/utils/create-provider.mjs +13 -9
- package/functions/utils/index.d.ts +0 -1
- package/functions/utils/prepareHinkal.cjs +1 -1
- package/functions/utils/prepareHinkal.d.ts +6 -7
- package/functions/utils/prepareHinkal.mjs +45 -53
- package/functions/utils/publicBalance.utils.cjs +1 -1
- package/functions/utils/publicBalance.utils.mjs +49 -54
- package/functions/utils/socket.utils.cjs +1 -0
- package/functions/utils/socket.utils.d.ts +1 -0
- package/functions/utils/socket.utils.mjs +12 -0
- package/functions/utils/string.utils.cjs +1 -1
- package/functions/utils/string.utils.d.ts +1 -0
- package/functions/utils/string.utils.mjs +18 -14
- package/functions/utils/walletBalances.utils.cjs +1 -1
- package/functions/utils/walletBalances.utils.d.ts +1 -1
- package/functions/utils/walletBalances.utils.mjs +4 -4
- package/functions/web3/crypto.cjs +1 -0
- package/functions/web3/crypto.d.ts +1 -0
- package/functions/web3/crypto.mjs +7 -0
- package/functions/web3/events/getApprovedBalance.cjs +1 -1
- package/functions/web3/events/getApprovedBalance.mjs +14 -14
- package/functions/web3/events/getInputUtxoAndBalance.cjs +1 -1
- package/functions/web3/events/getInputUtxoAndBalance.mjs +61 -59
- package/functions/web3/events/getTransactionLogEvents.cjs +1 -1
- package/functions/web3/events/getTransactionLogEvents.mjs +32 -32
- package/functions/web3/fetchSolanaMerkleTreeRootHash.cjs +1 -1
- package/functions/web3/fetchSolanaMerkleTreeRootHash.mjs +6 -3
- package/functions/web3/functionCalls/approveToken.cjs +1 -1
- package/functions/web3/functionCalls/approveToken.mjs +17 -17
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +16 -16
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +13 -11
- package/functions/web3/getContractMetadata.cjs +1 -1
- package/functions/web3/getContractMetadata.mjs +17 -22
- package/functions/web3/getTokenHolder.cjs +1 -1
- package/functions/web3/getTokenHolder.mjs +20 -20
- package/functions/web3/index.d.ts +1 -0
- package/index.cjs +1 -1
- package/index.mjs +913 -890
- package/package.json +3 -2
- package/providers/EthersProviderAdapter.cjs +1 -1
- package/providers/EthersProviderAdapter.mjs +2 -5
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +11 -4
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +11 -4
- package/types/activities.types.d.ts +2 -0
- package/types/bridging-tx.types.d.ts +17 -0
- package/types/cache.types.cjs +1 -1
- package/types/cache.types.d.ts +5 -1
- package/types/cache.types.mjs +1 -1
- package/types/ethereum-network.types.d.ts +1 -0
- package/types/events.types.cjs +1 -0
- package/types/events.types.d.ts +9 -0
- package/types/events.types.mjs +5 -0
- package/types/index.d.ts +2 -0
- package/types/proxy.types.d.ts +11 -4
- package/types/sandbox.types.d.ts +2 -0
- package/types/solana.types.d.ts +8 -0
- package/types/token.types.d.ts +5 -0
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/functions/kyc/authentoHelper.cjs +0 -1
- package/functions/kyc/authentoHelper.d.ts +0 -12
- package/functions/kyc/authentoHelper.mjs +0 -30
- package/functions/utils/get-hinkal-approvals.cjs +0 -1
- package/functions/utils/get-hinkal-approvals.d.ts +0 -3
- package/functions/utils/get-hinkal-approvals.mjs +0 -38
|
@@ -30,46 +30,46 @@ import "../../constants/events.constants.mjs";
|
|
|
30
30
|
import { shouldPatchAccessTokenMerkleTree as j } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
31
31
|
import { ethers as J } from "ethers";
|
|
32
32
|
import { validateAndGetChainId as Q } from "../../functions/utils/token-check.utils.mjs";
|
|
33
|
-
const
|
|
33
|
+
const Ct = async (r, m, e, c, A, g, p = !1) => {
|
|
34
34
|
if (p)
|
|
35
35
|
throw new Error("onlyGasEstimate is not supported for Solana withdraw");
|
|
36
|
-
const
|
|
36
|
+
const t = Q(m), o = m.map((U) => U.erc20TokenAddress), w = await r.getEthereumAddressByChain(t), { originalDeployer: d, hinkalIdl: l } = Z[t].contractData;
|
|
37
37
|
if (!d || !l)
|
|
38
38
|
throw new Error("missing data");
|
|
39
|
-
const { userKeys: f, merkleTreeAccessTokenByChain: h, merkleTreeHinkalByChain: T } =
|
|
39
|
+
const { userKeys: f, merkleTreeAccessTokenByChain: h, merkleTreeHinkalByChain: T } = r, i = g ?? await _(t, A, o, b.Transact);
|
|
40
40
|
e[0] -= i.flatFee;
|
|
41
41
|
const { patchAccessTokenMerkleTree: S, kycRequired: E, hasAccessToken: R } = await j(
|
|
42
|
-
t,
|
|
43
42
|
r,
|
|
43
|
+
t,
|
|
44
44
|
o,
|
|
45
45
|
e
|
|
46
46
|
);
|
|
47
47
|
if (o.length > 1)
|
|
48
48
|
throw new Error("Solana Withdraw: Only one mint address is supported");
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
const a = [...await L(r, t, o, e, 6)][0], k = M().toString(), { outputUtxos: s } = z(
|
|
50
|
+
r.userKeys,
|
|
51
|
+
a,
|
|
52
52
|
e[0],
|
|
53
53
|
k,
|
|
54
54
|
void 0,
|
|
55
55
|
!1
|
|
56
|
-
), n = await
|
|
56
|
+
), n = await r.getRandomRelay(t, !p);
|
|
57
57
|
if (!n)
|
|
58
58
|
throw Error(W.RELAYER_NOT_AVAILABLE);
|
|
59
|
-
const v = H.findCorrectRandomization(V(31),
|
|
59
|
+
const v = H.findCorrectRandomization(V(31), r.userKeys.getShieldedPrivateKey()), u = {
|
|
60
60
|
tokenNumber: o.length,
|
|
61
|
-
nullifierAmount:
|
|
62
|
-
outputAmount:
|
|
63
|
-
}, x =
|
|
64
|
-
|
|
61
|
+
nullifierAmount: a.length,
|
|
62
|
+
outputAmount: s.length
|
|
63
|
+
}, x = r.getSolanaProgram(l), I = q([s])[0][0], y = Array.from(J.utils.arrayify(I)), { proofAArr: B, proofBArr: P, proofCArr: C, publicInputsArr: K } = await G(
|
|
64
|
+
r.generateProofRemotely,
|
|
65
65
|
d,
|
|
66
|
-
T[
|
|
67
|
-
h[
|
|
66
|
+
T[t],
|
|
67
|
+
h[t],
|
|
68
68
|
f,
|
|
69
69
|
x,
|
|
70
70
|
[o[0]],
|
|
71
|
-
[s],
|
|
72
71
|
[a],
|
|
72
|
+
[s],
|
|
73
73
|
v,
|
|
74
74
|
i.flatFee,
|
|
75
75
|
i.variableRate,
|
|
@@ -77,22 +77,22 @@ const Kt = async (t, m, e, c, A, g, p = !1) => {
|
|
|
77
77
|
n,
|
|
78
78
|
u,
|
|
79
79
|
[y],
|
|
80
|
-
|
|
80
|
+
t,
|
|
81
81
|
S
|
|
82
|
-
),
|
|
82
|
+
), O = o[0] === D, F = {
|
|
83
83
|
recipient: c,
|
|
84
|
-
mint:
|
|
84
|
+
mint: O ? void 0 : o[0]
|
|
85
85
|
}, N = {
|
|
86
|
-
proofAArr:
|
|
87
|
-
proofBArr:
|
|
88
|
-
proofCArr:
|
|
89
|
-
publicInputsArr:
|
|
86
|
+
proofAArr: B,
|
|
87
|
+
proofBArr: P,
|
|
88
|
+
proofCArr: C,
|
|
89
|
+
publicInputsArr: K,
|
|
90
90
|
encryptedOutputs: [y],
|
|
91
91
|
relayerFee: i.flatFee.toString(),
|
|
92
92
|
dimensions: u
|
|
93
93
|
};
|
|
94
94
|
return Y({
|
|
95
|
-
chainId:
|
|
95
|
+
chainId: t,
|
|
96
96
|
relayAddress: n,
|
|
97
97
|
functionName: "transact",
|
|
98
98
|
args: N,
|
|
@@ -104,5 +104,5 @@ const Kt = async (t, m, e, c, A, g, p = !1) => {
|
|
|
104
104
|
});
|
|
105
105
|
};
|
|
106
106
|
export {
|
|
107
|
-
|
|
107
|
+
Ct as hinkalSolanaWithdraw
|
|
108
108
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("../../error-handling/error-codes.constants.cjs"),L=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),M=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),B=require("../../functions/web3/events/getShieldedBalance.cjs"),H=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),K=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),N=require("../../functions/pre-transaction/getFeeStructure.cjs"),W=require("../../functions/pre-transaction/merge-with-fee-structure.cjs"),G=require("../../types/external-action.types.cjs"),b=require("../../types/hinkal.types.cjs"),O=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),V=require("../../types/ethereum-network.types.cjs"),Z=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),$=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),j=require("../../functions/pre-transaction/getExternalSwapAddress.cjs"),z=require("../../functions/utils/time.utils.cjs"),Y=require("../../constants/protocol.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../http/HttpClient.cjs");require("axios");require("../../constants/vite.constants.cjs");require("ethers");require("../../constants/token-data/index.cjs");require("../../constants/chains.constants.cjs");const J=require("../../functions/pre-transaction/constructAdminData.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("circomlibjs-hinkal-fork");require("@solana/spl-token");require("../crypto-keys/keys.cjs");const Q=require("../../functions/utils/token-check.utils.cjs"),X=async(r,n,a,u,h,S,m,w,l=!1,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("../../error-handling/error-codes.constants.cjs"),L=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),M=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),B=require("../../functions/web3/events/getShieldedBalance.cjs"),H=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),K=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),N=require("../../functions/pre-transaction/getFeeStructure.cjs"),W=require("../../functions/pre-transaction/merge-with-fee-structure.cjs"),G=require("../../types/external-action.types.cjs"),b=require("../../types/hinkal.types.cjs"),O=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),V=require("../../types/ethereum-network.types.cjs"),Z=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),$=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),j=require("../../functions/pre-transaction/getExternalSwapAddress.cjs"),z=require("../../functions/utils/time.utils.cjs"),Y=require("../../constants/protocol.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../http/HttpClient.cjs");require("axios");require("../../constants/vite.constants.cjs");require("ethers");require("../../constants/token-data/index.cjs");require("../../constants/chains.constants.cjs");const J=require("../../functions/pre-transaction/constructAdminData.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("circomlibjs-hinkal-fork");require("@solana/spl-token");require("ethers-v6h");require("tweetnacl");require("bs58");require("buffer");require("../crypto-keys/keys.cjs");const Q=require("../../functions/utils/token-check.utils.cjs"),X=async(r,n,a,u,h,S,m,w,l=!1,C=!1)=>{const e=Q.validateAndGetChainId(n),s=n.map(t=>t.erc20TokenAddress),d=await r.getEthereumAddressByChain(e),q=m??await N.getFeeStructure(e,S,s,G.ExternalActionId.Transact,void 0,Y.HINKAL_SWAP_VARIABLE_RATE);W.mergeWithFeeStructure(e,s,a,q);const f=j.getExternalSwapAddress(e,u),i={externalActionId:u,externalAddress:f,externalActionMetadata:h},o=[...await B.addPaddingToUtxos(r,e,s,a)],v=`swapperM${a.length.toString()}x${o[0].length}x1`,D=[!1,!0,!1].slice(0,a.length),g=[],c=b.defaultHinkalLogicArgs(a.length,r.userKeys),R=z.getCurrentTimeInSeconds().toString();for(let t=0;t<s.length;t+=1){const{outputUtxos:F}=L.outputUtxoProcessing(r.userKeys,o[t],a[t],R,void 0,!1);g.push(F);const{useApprovalUtxoData:T}=O.outputApprovalDataProcessing(r,e,o[t],a[t]);T&&(c.useApprovalUtxoData[t]=T,c.doPreTxApproval=!0)}const p=await r.getRandomRelay(e,!l);if(!p)throw Error(I.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{patchAccessTokenMerkleTree:P,kycRequired:E,hasAccessToken:_}=await Z.shouldPatchAccessTokenMerkleTree(r,e,s,a),k=await $.getSignatureDataForTransact(e,d,r.userKeys,E,_),{zkCallData:A,circomData:y,dimData:x}=await M.constructZkProof("v1x1",r.merkleTreeHinkalByChain[e],r.merkleTreeAccessTokenByChain[e],o,g,r.userKeys,v,i.externalActionId,i.externalAddress,i.externalActionMetadata,r.generateProofRemotely,p,e,D,void 0,void 0,P,c,void 0,q,r.getContractWithFetcher(e,V.ContractType.HinkalHelperContract),k);if(l)return await H.estimateGasRelayer(e,A,x,y);const U=J.constructAdminData(w,e,s,a,d,n);return await K.transactCallRelayer(e,A,x,y,C,void 0,void 0,U)};exports.hinkalSwap=X;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { transactionErrorCodes as
|
|
2
|
-
import { outputUtxoProcessing as
|
|
3
|
-
import { constructZkProof as
|
|
1
|
+
import { transactionErrorCodes as K } from "../../error-handling/error-codes.constants.mjs";
|
|
2
|
+
import { outputUtxoProcessing as M } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
3
|
+
import { constructZkProof as _ } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
4
4
|
import { addPaddingToUtxos as F } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
5
5
|
import { estimateGasRelayer as k } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
6
6
|
import { transactCallRelayer as N } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
@@ -31,10 +31,14 @@ import "@coral-xyz/anchor";
|
|
|
31
31
|
import "@solana/web3.js";
|
|
32
32
|
import "circomlibjs-hinkal-fork";
|
|
33
33
|
import "@solana/spl-token";
|
|
34
|
+
import "ethers-v6h";
|
|
35
|
+
import "tweetnacl";
|
|
36
|
+
import "bs58";
|
|
37
|
+
import "buffer";
|
|
34
38
|
import "../crypto-keys/keys.mjs";
|
|
35
39
|
import { validateAndGetChainId as Q } from "../../functions/utils/token-check.utils.mjs";
|
|
36
|
-
const
|
|
37
|
-
const t = Q(s), a = s.map((
|
|
40
|
+
const Nt = async (r, s, e, c, T, v, w, C, n = !1, h = !1) => {
|
|
41
|
+
const t = Q(s), a = s.map((o) => o.erc20TokenAddress), d = await r.getEthereumAddressByChain(t), f = w ?? await W(
|
|
38
42
|
t,
|
|
39
43
|
v,
|
|
40
44
|
a,
|
|
@@ -42,40 +46,40 @@ const _t = async (r, s, o, n, T, v, w, C, p = !1, R = !1) => {
|
|
|
42
46
|
void 0,
|
|
43
47
|
j
|
|
44
48
|
);
|
|
45
|
-
V(t, a,
|
|
46
|
-
const
|
|
47
|
-
externalActionId:
|
|
48
|
-
externalAddress:
|
|
49
|
+
V(t, a, e, f);
|
|
50
|
+
const R = Z(t, c), m = {
|
|
51
|
+
externalActionId: c,
|
|
52
|
+
externalAddress: R,
|
|
49
53
|
externalActionMetadata: T
|
|
50
|
-
}, i = [...await F(r, t, a,
|
|
51
|
-
for (let
|
|
52
|
-
const { outputUtxos:
|
|
54
|
+
}, i = [...await F(r, t, a, e)], D = `swapperM${e.length.toString()}x${i[0].length}x1`, E = [!1, !0, !1].slice(0, e.length), u = [], p = q(e.length, r.userKeys), S = b().toString();
|
|
55
|
+
for (let o = 0; o < a.length; o += 1) {
|
|
56
|
+
const { outputUtxos: H } = M(
|
|
53
57
|
r.userKeys,
|
|
54
|
-
i[
|
|
55
|
-
o
|
|
58
|
+
i[o],
|
|
59
|
+
e[o],
|
|
56
60
|
S,
|
|
57
61
|
void 0,
|
|
58
62
|
!1
|
|
59
63
|
);
|
|
60
|
-
u.push(
|
|
61
|
-
const { useApprovalUtxoData: y } = z(r, t, i[
|
|
62
|
-
y && (
|
|
64
|
+
u.push(H);
|
|
65
|
+
const { useApprovalUtxoData: y } = z(r, t, i[o], e[o]);
|
|
66
|
+
y && (p.useApprovalUtxoData[o] = y, p.doPreTxApproval = !0);
|
|
63
67
|
}
|
|
64
|
-
const g = await r.getRandomRelay(t, !
|
|
68
|
+
const g = await r.getRandomRelay(t, !n);
|
|
65
69
|
if (!g)
|
|
66
|
-
throw Error(
|
|
70
|
+
throw Error(K.RELAYER_NOT_AVAILABLE);
|
|
67
71
|
const { patchAccessTokenMerkleTree: P, kycRequired: I, hasAccessToken: L } = await O(
|
|
68
72
|
r,
|
|
69
73
|
t,
|
|
70
74
|
a,
|
|
71
|
-
|
|
75
|
+
e
|
|
72
76
|
), U = await Y(
|
|
73
77
|
t,
|
|
74
78
|
d,
|
|
75
79
|
r.userKeys,
|
|
76
80
|
I,
|
|
77
81
|
L
|
|
78
|
-
), { zkCallData: l, circomData: A, dimData: x } = await
|
|
82
|
+
), { zkCallData: l, circomData: A, dimData: x } = await _(
|
|
79
83
|
"v1x1",
|
|
80
84
|
r.merkleTreeHinkalByChain[t],
|
|
81
85
|
r.merkleTreeAccessTokenByChain[t],
|
|
@@ -83,9 +87,9 @@ const _t = async (r, s, o, n, T, v, w, C, p = !1, R = !1) => {
|
|
|
83
87
|
u,
|
|
84
88
|
r.userKeys,
|
|
85
89
|
D,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
m.externalActionId,
|
|
91
|
+
m.externalAddress,
|
|
92
|
+
m.externalActionMetadata,
|
|
89
93
|
r.generateProofRemotely,
|
|
90
94
|
g,
|
|
91
95
|
t,
|
|
@@ -93,26 +97,26 @@ const _t = async (r, s, o, n, T, v, w, C, p = !1, R = !1) => {
|
|
|
93
97
|
void 0,
|
|
94
98
|
void 0,
|
|
95
99
|
P,
|
|
96
|
-
|
|
100
|
+
p,
|
|
97
101
|
void 0,
|
|
98
102
|
f,
|
|
99
103
|
r.getContractWithFetcher(t, G.HinkalHelperContract),
|
|
100
104
|
U
|
|
101
105
|
);
|
|
102
|
-
if (
|
|
106
|
+
if (n)
|
|
103
107
|
return await k(t, l, x, A);
|
|
104
|
-
const
|
|
108
|
+
const B = J(C, t, a, e, d, s);
|
|
105
109
|
return await N(
|
|
106
110
|
t,
|
|
107
111
|
l,
|
|
108
112
|
x,
|
|
109
113
|
A,
|
|
110
|
-
|
|
114
|
+
h,
|
|
111
115
|
void 0,
|
|
112
116
|
void 0,
|
|
113
|
-
|
|
117
|
+
B
|
|
114
118
|
);
|
|
115
119
|
};
|
|
116
120
|
export {
|
|
117
|
-
|
|
121
|
+
Nt as hinkalSwap
|
|
118
122
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../../error-handling/error-codes.constants.cjs"),k=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),N=require("../../functions/web3/events/getShieldedBalance.cjs"),F=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),M=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),U=require("../../functions/pre-transaction/getFeeStructure.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../../error-handling/error-codes.constants.cjs"),k=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),N=require("../../functions/web3/events/getShieldedBalance.cjs"),F=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),M=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),U=require("../../functions/pre-transaction/getFeeStructure.cjs"),B=require("../../functions/pre-transaction/merge-with-fee-structure.cjs");require("../../types/circom-data.types.cjs");const L=require("../../types/ethereum-network.types.cjs"),V=require("../../types/external-action.types.cjs"),H=require("../../types/hinkal.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");const K=require("../../functions/pre-transaction/outputUtxoProcessing.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../http/HttpClient.cjs");require("axios");require("../../constants/vite.constants.cjs");require("ethers");require("../../constants/token-data/index.cjs");const O=require("../../constants/protocol.constants.cjs");require("../../constants/chains.constants.cjs");const G=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),W=require("../../functions/pre-transaction/getVolatileTransferAmount.cjs"),b=require("../../functions/pre-transaction/constructAdminData.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("circomlibjs-hinkal-fork");require("@solana/spl-token");require("ethers-v6h");require("tweetnacl");require("bs58");require("buffer");require("../crypto-keys/keys.cjs");const Z=require("../../functions/utils/time.utils.cjs"),$=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),j=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),z=require("../../functions/utils/addresses.cjs"),Y=require("../../functions/utils/token-check.utils.cjs"),J=async(t,s,E,l,h,x,C,f=!1)=>{const e=Y.validateAndGetChainId(s);if(!z.isValidPrivateAddress(l))throw Error(d.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const a=s.map(r=>r.erc20TokenAddress),o=await W.modifyVolatileTokenAmountChanges(e,s,E),A=-o[0]*(10000n-O.HINKAL_PRIVATE_SEND_VARIABLE_RATE)/10000n;if(A<=0n)throw Error(d.transactionErrorCodes.RECIPIENT_AMOUNT_INVALID);const q=x??await U.getFeeStructure(e,h,a,V.ExternalActionId.Transact);if(B.mergeWithFeeStructure(e,a,o,q),!s[0])throw Error("Transfer Action: No Token Found");const i=await t.getRandomRelay(e,!0),c={externalActionId:0n,externalAddress:i??await t.getEthereumAddressByChain(e),externalActionMetadata:"0x00"},n=[...await N.addPaddingToUtxos(t,e,a,o)],w=`swapperM${o.length}x${n[0].length}x2`,g=[],u=H.defaultHinkalLogicArgs(o.length,t.userKeys),R=Z.getCurrentTimeInSeconds().toString();for(let r=0;r<a.length;r+=1){const{outputUtxos:S}=K.outputUtxoProcessing(t.userKeys,n[r],o[r],R,void 0,!1,l,r===0?A:0n);g.push(S);const{useApprovalUtxoData:y}=G.outputApprovalDataProcessing(t,e,n[r],o[r]);y&&(u.useApprovalUtxoData[r]=y,u.doPreTxApproval=!0)}if(!i)throw Error(d.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{patchAccessTokenMerkleTree:v,kycRequired:I,hasAccessToken:_}=await $.shouldPatchAccessTokenMerkleTree(t,e,a,o),D=await j.getSignatureDataForTransact(e,await t.getEthereumAddressByChain(e),t.userKeys,I,_),{zkCallData:m,circomData:p,dimData:T}=await k.constructZkProof("v1x1",t.merkleTreeHinkalByChain[e],t.merkleTreeAccessTokenByChain[e],n,g,t.userKeys,w,c.externalActionId,c.externalAddress,c.externalActionMetadata,t.generateProofRemotely,i,e,void 0,void 0,void 0,v,u,void 0,q,t.getContractWithFetcher(e,L.ContractType.HinkalHelperContract),D);if(f)return await F.estimateGasRelayer(e,m,T,p);const P=b.constructAdminData(C,e,a,o,await t.getEthereumAddressByChain(e));return await M.transactCallRelayer(e,m,T,p,void 0,void 0,void 0,P)};exports.hinkalTransfer=J;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { transactionErrorCodes as p } from "../../error-handling/error-codes.constants.mjs";
|
|
2
2
|
import { constructZkProof as S } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
3
3
|
import { addPaddingToUtxos as U } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
4
|
-
import { estimateGasRelayer as
|
|
5
|
-
import { transactCallRelayer as
|
|
6
|
-
import { getFeeStructure as
|
|
7
|
-
import { mergeWithFeeStructure as
|
|
4
|
+
import { estimateGasRelayer as B } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
5
|
+
import { transactCallRelayer as M } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
6
|
+
import { getFeeStructure as F } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
7
|
+
import { mergeWithFeeStructure as V } from "../../functions/pre-transaction/merge-with-fee-structure.mjs";
|
|
8
8
|
import "../../types/circom-data.types.mjs";
|
|
9
|
-
import { ContractType as
|
|
10
|
-
import { ExternalActionId as
|
|
11
|
-
import { defaultHinkalLogicArgs as
|
|
9
|
+
import { ContractType as H } from "../../types/ethereum-network.types.mjs";
|
|
10
|
+
import { ExternalActionId as K } from "../../types/external-action.types.mjs";
|
|
11
|
+
import { defaultHinkalLogicArgs as k } from "../../types/hinkal.types.mjs";
|
|
12
12
|
import "../../types/transactions.types.mjs";
|
|
13
13
|
import "../../types/activities.types.mjs";
|
|
14
14
|
import { outputUtxoProcessing as O } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
@@ -28,33 +28,37 @@ import "@coral-xyz/anchor";
|
|
|
28
28
|
import "@solana/web3.js";
|
|
29
29
|
import "circomlibjs-hinkal-fork";
|
|
30
30
|
import "@solana/spl-token";
|
|
31
|
+
import "ethers-v6h";
|
|
32
|
+
import "tweetnacl";
|
|
33
|
+
import "bs58";
|
|
34
|
+
import "buffer";
|
|
31
35
|
import "../crypto-keys/keys.mjs";
|
|
32
36
|
import { getCurrentTimeInSeconds as z } from "../../functions/utils/time.utils.mjs";
|
|
33
37
|
import { shouldPatchAccessTokenMerkleTree as Y } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
34
38
|
import { getSignatureDataForTransact as Z } from "../../functions/pre-transaction/getSignatureDataForTransact.mjs";
|
|
35
39
|
import { isValidPrivateAddress as b } from "../../functions/utils/addresses.mjs";
|
|
36
40
|
import { validateAndGetChainId as j } from "../../functions/utils/token-check.utils.mjs";
|
|
37
|
-
const
|
|
38
|
-
const
|
|
41
|
+
const Kt = async (r, i, E, d, y, C, w, I = !1) => {
|
|
42
|
+
const t = j(i);
|
|
39
43
|
if (!b(d))
|
|
40
44
|
throw Error(p.RECIPIENT_FORMAT_INCORRECT);
|
|
41
|
-
const a = i.map((o) => o.erc20TokenAddress), e = await $(
|
|
45
|
+
const a = i.map((o) => o.erc20TokenAddress), e = await $(t, i, E), u = -e[0] * (10000n - G) / 10000n;
|
|
42
46
|
if (u <= 0n)
|
|
43
47
|
throw Error(p.RECIPIENT_AMOUNT_INVALID);
|
|
44
|
-
const A =
|
|
45
|
-
if (
|
|
48
|
+
const A = C ?? await F(t, y, a, K.Transact);
|
|
49
|
+
if (V(t, a, e, A), !i[0])
|
|
46
50
|
throw Error("Transfer Action: No Token Found");
|
|
47
|
-
const n = await
|
|
51
|
+
const n = await r.getRandomRelay(t, !0), m = {
|
|
48
52
|
externalActionId: 0n,
|
|
49
|
-
externalAddress: n ?? await
|
|
53
|
+
externalAddress: n ?? await r.getEthereumAddressByChain(t),
|
|
50
54
|
externalActionMetadata: "0x00"
|
|
51
|
-
}, s = [...await U(
|
|
55
|
+
}, s = [...await U(r, t, a, e)], h = `swapperM${e.length}x${s[0].length}x2`, f = [], c = k(e.length, r.userKeys), R = z().toString();
|
|
52
56
|
for (let o = 0; o < a.length; o += 1) {
|
|
53
57
|
const { outputUtxos: L } = O(
|
|
54
|
-
|
|
58
|
+
r.userKeys,
|
|
55
59
|
s[o],
|
|
56
60
|
e[o],
|
|
57
|
-
|
|
61
|
+
R,
|
|
58
62
|
void 0,
|
|
59
63
|
!1,
|
|
60
64
|
d,
|
|
@@ -62,57 +66,57 @@ const Ft = async (t, i, E, d, w, y, I, C = !1) => {
|
|
|
62
66
|
// first token is which is sent to recipient
|
|
63
67
|
);
|
|
64
68
|
f.push(L);
|
|
65
|
-
const { useApprovalUtxoData: x } = W(
|
|
69
|
+
const { useApprovalUtxoData: x } = W(r, t, s[o], e[o]);
|
|
66
70
|
x && (c.useApprovalUtxoData[o] = x, c.doPreTxApproval = !0);
|
|
67
71
|
}
|
|
68
72
|
if (!n)
|
|
69
73
|
throw Error(p.RELAYER_NOT_AVAILABLE);
|
|
70
|
-
const { patchAccessTokenMerkleTree:
|
|
71
|
-
t,
|
|
74
|
+
const { patchAccessTokenMerkleTree: v, kycRequired: D, hasAccessToken: P } = await Y(
|
|
72
75
|
r,
|
|
76
|
+
t,
|
|
73
77
|
a,
|
|
74
78
|
e
|
|
75
79
|
), N = await Z(
|
|
76
|
-
|
|
77
|
-
await
|
|
78
|
-
|
|
80
|
+
t,
|
|
81
|
+
await r.getEthereumAddressByChain(t),
|
|
82
|
+
r.userKeys,
|
|
79
83
|
D,
|
|
80
84
|
P
|
|
81
85
|
), { zkCallData: l, circomData: g, dimData: T } = await S(
|
|
82
86
|
"v1x1",
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
r.merkleTreeHinkalByChain[t],
|
|
88
|
+
r.merkleTreeAccessTokenByChain[t],
|
|
85
89
|
s,
|
|
86
90
|
f,
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
r.userKeys,
|
|
92
|
+
h,
|
|
89
93
|
m.externalActionId,
|
|
90
94
|
m.externalAddress,
|
|
91
95
|
m.externalActionMetadata,
|
|
92
|
-
|
|
96
|
+
r.generateProofRemotely,
|
|
93
97
|
n,
|
|
94
|
-
|
|
98
|
+
t,
|
|
95
99
|
void 0,
|
|
96
100
|
void 0,
|
|
97
101
|
void 0,
|
|
98
|
-
|
|
102
|
+
v,
|
|
99
103
|
c,
|
|
100
104
|
void 0,
|
|
101
105
|
A,
|
|
102
|
-
|
|
106
|
+
r.getContractWithFetcher(t, H.HinkalHelperContract),
|
|
103
107
|
N
|
|
104
108
|
);
|
|
105
|
-
if (
|
|
106
|
-
return await
|
|
109
|
+
if (I)
|
|
110
|
+
return await B(t, l, T, g);
|
|
107
111
|
const _ = q(
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
w,
|
|
113
|
+
t,
|
|
110
114
|
a,
|
|
111
115
|
e,
|
|
112
|
-
await
|
|
116
|
+
await r.getEthereumAddressByChain(t)
|
|
113
117
|
);
|
|
114
|
-
return await
|
|
115
|
-
|
|
118
|
+
return await M(
|
|
119
|
+
t,
|
|
116
120
|
l,
|
|
117
121
|
T,
|
|
118
122
|
g,
|
|
@@ -123,5 +127,5 @@ const Ft = async (t, i, E, d, w, y, I, C = !1) => {
|
|
|
123
127
|
);
|
|
124
128
|
};
|
|
125
129
|
export {
|
|
126
|
-
|
|
130
|
+
Kt as hinkalTransfer
|
|
127
131
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("../../constants/protocol.constants.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("../../constants/protocol.constants.cjs"),B=require("../../error-handling/error-codes.constants.cjs"),I=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),M=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),R=require("../../functions/web3/events/getShieldedBalance.cjs"),W=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),L=require("../../functions/web3/functionCalls/transactCallDirect.cjs"),N=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),H=require("../../types/external-action.types.cjs"),K=require("../../types/hinkal.types.cjs"),G=require("../../functions/pre-transaction/outputApprovalDataProcessing.cjs"),V=require("../../functions/pre-transaction/getFeeStructure.cjs"),b=require("../../functions/pre-transaction/merge-with-fee-structure.cjs");require("../../types/circom-data.types.cjs");const z=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");const Z=require("../../functions/pre-transaction/getSignatureDataForTransact.cjs"),$=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs");require("../../constants/server.constants.cjs");require("../../API/getServerURL.cjs");require("../http/HttpClient.cjs");require("axios");require("../../constants/vite.constants.cjs");require("ethers");require("../../constants/token-data/index.cjs");require("../../constants/chains.constants.cjs");const j=require("../../functions/pre-transaction/getVolatileTransferAmount.cjs"),Y=require("../../functions/pre-transaction/constructAdminData.cjs");require("@coral-xyz/anchor");require("@solana/web3.js");require("circomlibjs-hinkal-fork");require("@solana/spl-token");require("ethers-v6h");require("tweetnacl");require("bs58");require("buffer");require("../crypto-keys/keys.cjs");const J=require("../../functions/utils/time.utils.cjs"),Q=require("../../functions/utils/token-check.utils.cjs"),X=async(t,n,y,w,s,T,C,v,p=!1)=>{const e=Q.validateAndGetChainId(n),a=n.map(r=>r.erc20TokenAddress),o=await j.modifyVolatileTokenAmountChanges(e,n,y);let c;s||(c=C??await V.getFeeStructure(e,T,a,H.ExternalActionId.Transact),b.mergeWithFeeStructure(e,a,o,c));const u=n[0];if(!u)throw Error("Deposit Action: No Token Found");const d={externalActionId:0n,externalAddress:w,externalActionMetadata:"0x00"},i=[...await R.addPaddingToUtxos(t,e,a,o)],D=`swapperM${o.length.toString()}x${i[0].length}x1`,m=[],l=K.defaultHinkalLogicArgs(o.length,t.userKeys),S=J.getCurrentTimeInSeconds().toString();for(let r=0;r<a.length;r+=1){const{outputUtxos:_}=I.outputUtxoProcessing(t.userKeys,i[r],o[r],S,void 0,!1);m.push(_);const{useApprovalUtxoData:h}=G.outputApprovalDataProcessing(t,e,i[r],o[r]);h&&(l.useApprovalUtxoData[r]=h,l.doPreTxApproval=!0)}const x=await t.getRandomRelay(e,!p);if(!s&&!x)throw Error(B.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{patchAccessTokenMerkleTree:E,kycRequired:P,hasAccessToken:k}=await $.shouldPatchAccessTokenMerkleTree(t,e,a,o),f=await Z.getSignatureDataForTransact(e,await t.getEthereumAddressByChain(e),t.userKeys,P,k),{zkCallData:q,circomData:A,dimData:g}=await M.constructZkProof("v1x1",t.merkleTreeHinkalByChain[e],t.merkleTreeAccessTokenByChain[e],i,m,t.userKeys,D,d.externalActionId,d.externalAddress,d.externalActionMetadata,t.generateProofRemotely,s?U.zeroAddress:x,e,void 0,void 0,void 0,E,l,void 0,c,t.getContractWithFetcher(e,z.ContractType.HinkalHelperContract),f,s?await t.getEthereumAddressByChain(e):void 0);if(p)return await W.estimateGasRelayer(e,q,g,A);if(s){if(!u)throw Error("Withdraw Action: No Token Found");return await L.transactCallDirect(t,e,o[0],u,q,A,g)}const F=Y.constructAdminData(v,e,a,o,await t.getEthereumAddressByChain(e));return await N.transactCallRelayer(e,q,g,A,void 0,void 0,void 0,F)};exports.hinkalWithdraw=X;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { zeroAddress as
|
|
2
|
-
import { transactionErrorCodes as
|
|
3
|
-
import { outputUtxoProcessing as
|
|
4
|
-
import { constructZkProof as
|
|
5
|
-
import { addPaddingToUtxos as
|
|
6
|
-
import { estimateGasRelayer as
|
|
7
|
-
import { transactCallDirect as
|
|
8
|
-
import { transactCallRelayer as
|
|
1
|
+
import { zeroAddress as L } from "../../constants/protocol.constants.mjs";
|
|
2
|
+
import { transactionErrorCodes as M } from "../../error-handling/error-codes.constants.mjs";
|
|
3
|
+
import { outputUtxoProcessing as H } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
4
|
+
import { constructZkProof as K } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
5
|
+
import { addPaddingToUtxos as N } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
6
|
+
import { estimateGasRelayer as R } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
7
|
+
import { transactCallDirect as W } from "../../functions/web3/functionCalls/transactCallDirect.mjs";
|
|
8
|
+
import { transactCallRelayer as k } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
9
9
|
import { ExternalActionId as z } from "../../types/external-action.types.mjs";
|
|
10
10
|
import { defaultHinkalLogicArgs as V } from "../../types/hinkal.types.mjs";
|
|
11
11
|
import { outputApprovalDataProcessing as _ } from "../../functions/pre-transaction/outputApprovalDataProcessing.mjs";
|
|
@@ -31,62 +31,66 @@ import "@coral-xyz/anchor";
|
|
|
31
31
|
import "@solana/web3.js";
|
|
32
32
|
import "circomlibjs-hinkal-fork";
|
|
33
33
|
import "@solana/spl-token";
|
|
34
|
+
import "ethers-v6h";
|
|
35
|
+
import "tweetnacl";
|
|
36
|
+
import "bs58";
|
|
37
|
+
import "buffer";
|
|
34
38
|
import "../crypto-keys/keys.mjs";
|
|
35
39
|
import { getCurrentTimeInSeconds as J } from "../../functions/utils/time.utils.mjs";
|
|
36
40
|
import { validateAndGetChainId as Q } from "../../functions/utils/token-check.utils.mjs";
|
|
37
|
-
const
|
|
38
|
-
const
|
|
41
|
+
const kt = async (r, s, T, h, i, v, y, C, f = !1) => {
|
|
42
|
+
const t = Q(s), a = s.map((o) => o.erc20TokenAddress), e = await b(t, s, T);
|
|
39
43
|
let n;
|
|
40
|
-
i || (n =
|
|
44
|
+
i || (n = y ?? await $(t, v, a, z.Transact), q(t, a, e, n));
|
|
41
45
|
const c = s[0];
|
|
42
46
|
if (!c)
|
|
43
47
|
throw Error("Deposit Action: No Token Found");
|
|
44
48
|
const p = {
|
|
45
49
|
externalActionId: 0n,
|
|
46
|
-
externalAddress:
|
|
50
|
+
externalAddress: h,
|
|
47
51
|
externalActionMetadata: "0x00"
|
|
48
|
-
}, m = [...await
|
|
52
|
+
}, m = [...await N(r, t, a, e)], D = `swapperM${e.length.toString()}x${m[0].length}x1`, l = [], d = V(e.length, r.userKeys), E = J().toString();
|
|
49
53
|
for (let o = 0; o < a.length; o += 1) {
|
|
50
|
-
const { outputUtxos:
|
|
51
|
-
|
|
54
|
+
const { outputUtxos: F } = H(
|
|
55
|
+
r.userKeys,
|
|
52
56
|
m[o],
|
|
53
57
|
e[o],
|
|
54
58
|
E,
|
|
55
59
|
void 0,
|
|
56
60
|
!1
|
|
57
61
|
);
|
|
58
|
-
l.push(
|
|
59
|
-
const { useApprovalUtxoData: w } = _(
|
|
62
|
+
l.push(F);
|
|
63
|
+
const { useApprovalUtxoData: w } = _(r, t, m[o], e[o]);
|
|
60
64
|
w && (d.useApprovalUtxoData[o] = w, d.doPreTxApproval = !0);
|
|
61
65
|
}
|
|
62
|
-
const x = await
|
|
66
|
+
const x = await r.getRandomRelay(t, !f);
|
|
63
67
|
if (!i && !x)
|
|
64
|
-
throw Error(
|
|
68
|
+
throw Error(M.RELAYER_NOT_AVAILABLE);
|
|
65
69
|
const { patchAccessTokenMerkleTree: S, kycRequired: I, hasAccessToken: P } = await Z(
|
|
66
|
-
t,
|
|
67
70
|
r,
|
|
71
|
+
t,
|
|
68
72
|
a,
|
|
69
73
|
e
|
|
70
74
|
), U = await Y(
|
|
71
|
-
|
|
72
|
-
await
|
|
73
|
-
|
|
75
|
+
t,
|
|
76
|
+
await r.getEthereumAddressByChain(t),
|
|
77
|
+
r.userKeys,
|
|
74
78
|
I,
|
|
75
79
|
P
|
|
76
|
-
), { zkCallData: u, circomData: A, dimData: g } = await
|
|
80
|
+
), { zkCallData: u, circomData: A, dimData: g } = await K(
|
|
77
81
|
"v1x1",
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
r.merkleTreeHinkalByChain[t],
|
|
83
|
+
r.merkleTreeAccessTokenByChain[t],
|
|
80
84
|
m,
|
|
81
85
|
l,
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
r.userKeys,
|
|
87
|
+
D,
|
|
84
88
|
p.externalActionId,
|
|
85
89
|
p.externalAddress,
|
|
86
90
|
p.externalActionMetadata,
|
|
87
|
-
|
|
88
|
-
i ?
|
|
89
|
-
|
|
91
|
+
r.generateProofRemotely,
|
|
92
|
+
i ? L : x,
|
|
93
|
+
t,
|
|
90
94
|
void 0,
|
|
91
95
|
void 0,
|
|
92
96
|
void 0,
|
|
@@ -94,35 +98,35 @@ const Nt = async (t, s, T, v, i, D, h, y, f = !1) => {
|
|
|
94
98
|
d,
|
|
95
99
|
void 0,
|
|
96
100
|
n,
|
|
97
|
-
|
|
101
|
+
r.getContractWithFetcher(t, G.HinkalHelperContract),
|
|
98
102
|
U,
|
|
99
|
-
i ? await
|
|
103
|
+
i ? await r.getEthereumAddressByChain(t) : void 0
|
|
100
104
|
);
|
|
101
105
|
if (f)
|
|
102
|
-
return await
|
|
106
|
+
return await R(t, u, g, A);
|
|
103
107
|
if (i) {
|
|
104
108
|
if (!c)
|
|
105
109
|
throw Error("Withdraw Action: No Token Found");
|
|
106
|
-
return await
|
|
110
|
+
return await W(r, t, e[0], c, u, A, g);
|
|
107
111
|
}
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
112
|
+
const B = j(
|
|
113
|
+
C,
|
|
114
|
+
t,
|
|
111
115
|
a,
|
|
112
116
|
e,
|
|
113
|
-
await
|
|
117
|
+
await r.getEthereumAddressByChain(t)
|
|
114
118
|
);
|
|
115
|
-
return await
|
|
116
|
-
|
|
119
|
+
return await k(
|
|
120
|
+
t,
|
|
117
121
|
u,
|
|
118
122
|
g,
|
|
119
123
|
A,
|
|
120
124
|
void 0,
|
|
121
125
|
void 0,
|
|
122
126
|
void 0,
|
|
123
|
-
|
|
127
|
+
B
|
|
124
128
|
);
|
|
125
129
|
};
|
|
126
130
|
export {
|
|
127
|
-
|
|
131
|
+
kt as hinkalWithdraw
|
|
128
132
|
};
|