@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
|
@@ -1,55 +1,58 @@
|
|
|
1
|
-
import { PublicKey as
|
|
1
|
+
import { PublicKey as m } from "@solana/web3.js";
|
|
2
2
|
import { networkRegistry as f } from "../../constants/chains.constants.mjs";
|
|
3
|
-
import { sendProxyV0Transaction as
|
|
3
|
+
import { sendProxyV0Transaction as y, serializeProxyV0Transaction as p } from "../../functions/pre-transaction/sendV0Transaction.mjs";
|
|
4
4
|
import { buildSolanaTransferInstructions as P } from "../../functions/pre-transaction/solanaTransfer.utils.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
const
|
|
9
|
-
const
|
|
5
|
+
import { createCustomSolanaConnection as S } from "../../functions/utils/create-provider.mjs";
|
|
6
|
+
import { validateAndGetChainId as w } from "../../functions/utils/token-check.utils.mjs";
|
|
7
|
+
import { AccountActions as h } from "../AccountActions/AccountActions.mjs";
|
|
8
|
+
const u = async (r, a, t, e) => {
|
|
9
|
+
const n = w([r]), o = h.getAddressFromSubAccount(n, t);
|
|
10
|
+
if (!o)
|
|
11
|
+
throw Error("Public account address is not available");
|
|
12
|
+
const { fetchRpcUrl: s } = f[n];
|
|
10
13
|
if (!s)
|
|
11
14
|
throw new Error("RPC URL not found for the specified chain ID");
|
|
12
|
-
const
|
|
13
|
-
|
|
15
|
+
const i = S(s), c = new m(o), { instructions: d, programId: l } = await P(
|
|
16
|
+
i,
|
|
14
17
|
c,
|
|
15
|
-
new
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
new m(e),
|
|
19
|
+
r,
|
|
20
|
+
a
|
|
18
21
|
);
|
|
19
22
|
return {
|
|
20
|
-
connection:
|
|
21
|
-
chainId:
|
|
22
|
-
senderAddress:
|
|
23
|
+
connection: i,
|
|
24
|
+
chainId: n,
|
|
25
|
+
senderAddress: o,
|
|
23
26
|
senderPublickey: c,
|
|
24
|
-
programId:
|
|
27
|
+
programId: l,
|
|
25
28
|
instructions: d
|
|
26
29
|
};
|
|
27
|
-
},
|
|
28
|
-
if (
|
|
30
|
+
}, E = async (r, a, t, e, n = !1) => {
|
|
31
|
+
if (n)
|
|
29
32
|
throw new Error("onlyGasEstimate is not supported for Solana proxy send");
|
|
30
|
-
const { connection:
|
|
31
|
-
return
|
|
32
|
-
connection:
|
|
33
|
+
const { connection: o, chainId: s, senderAddress: i, senderPublickey: c, programId: d, instructions: l } = await u(r, a, t, e);
|
|
34
|
+
return y({
|
|
35
|
+
connection: o,
|
|
33
36
|
chainId: s,
|
|
34
|
-
subAccount:
|
|
37
|
+
subAccount: t,
|
|
35
38
|
payerPublicKey: c,
|
|
36
|
-
instructions:
|
|
39
|
+
instructions: l,
|
|
37
40
|
convertParams: {
|
|
38
|
-
fromAddress:
|
|
41
|
+
fromAddress: i,
|
|
39
42
|
toAddress: e,
|
|
40
43
|
programAddress: d.toString()
|
|
41
44
|
}
|
|
42
45
|
});
|
|
43
|
-
},
|
|
44
|
-
const { connection:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
}, R = async (r, a, t, e) => {
|
|
47
|
+
const { connection: n, senderPublickey: o, instructions: s } = await u(
|
|
48
|
+
r,
|
|
49
|
+
a,
|
|
50
|
+
t,
|
|
48
51
|
e
|
|
49
52
|
);
|
|
50
|
-
return
|
|
53
|
+
return p(n, o, s);
|
|
51
54
|
};
|
|
52
55
|
export {
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
R as getSolanaProxySendSerializedTransaction,
|
|
57
|
+
E as hinkalSolanaProxySend
|
|
55
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@solana/spl-token"),h=require("@solana/web3.js"),f=require("../../constants/chains.constants.cjs"),b=require("../../constants/protocol.constants.cjs"),N=require("../../functions/utils/solanaMint.utils.cjs"),T=require("../../functions/utils/addresses.cjs"),O=require("../../error-handling/error-codes.constants.cjs"),A=require("../../functions/pre-transaction/solana.cjs"),V=require("@coral-xyz/anchor"),k=require("../../functions/pre-transaction/sendV0Transaction.cjs"),M=require("../../functions/utils/create-provider.cjs"),q=require("../../functions/utils/token-check.utils.cjs"),G=require("../AccountActions/AccountActions.cjs"),L=async({program:o,mintPublicKey:r,mintAddressString:e,tokenAmount:n,anchorStealthStructure:i,senderPublickey:d,originalDeployer:t,storageAccount:s,storageVault:c})=>{const u=new V.BN(n.toString()),l=A.getTokenLimitStorageAccountPublicKey(o.programId,t,r),g=e===b.solanaNativeAddress?null:r,a=e===b.solanaNativeAddress?null:void 0;return o.methods.prooflessDeposit(u,i).accounts({mint:g,signer:d,signerAta:a,originalDeployer:t,storageAccount:s,storageVault:c,tokenLimitStorage:l,storageVaultAta:a,accessTokenOwner:null}).instruction()},E=async(o,r,e,n,i,d)=>{const t=d??o.getRecipientInfo();if(!T.isValidPrivateAddress(t))throw Error(O.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);const s=G.AccountActions.getAddressFromSubAccount(r,i);if(!s)throw Error("Public account address is not available");const{hinkalIdl:c,hinkalAddress:u,originalDeployer:l}=f.networkRegistry[r].contractData;if(!c)throw new Error("No IDL configured for Solana program on this network");if(!l)throw new Error("missing original deployer");const g=o.getSolanaProgram(c),a=new h.PublicKey(l),S=new h.PublicKey(u),y=new h.PublicKey(s),{erc20TokenAddress:I}=e,{fetchRpcUrl:P}=f.networkRegistry[r];if(!P)throw new Error("RPC URL not found for the specified chain ID");const R=M.createCustomSolanaConnection(P),{mintPublicKey:w}=N.formatMintAddress(I),_=w.toString(),m=A.getStorageAccountPublicKey(S,a),C=A.getStorageVaultPublicKey(S,a),v=T.constructStealthAddressStructure(t),x=A.buildAnchorStealthAddressStructure(v),D=await L({program:g,mintPublicKey:w,mintAddressString:_,tokenAmount:n,anchorStealthStructure:x,senderPublickey:y,originalDeployer:a,storageAccount:m,storageVault:C}),K=e.is2022Program?p.TOKEN_2022_PROGRAM_ID:p.TOKEN_PROGRAM_ID;return{connection:R,senderAddress:s,senderPublickey:y,instructions:[D],storageAccount:m,programId:K}},z=async(o,r,e,n,i,d=!1)=>{if(d)throw new Error("onlyGasEstimate is not supported for Solana proxy shield");if(!n)throw new Error("subAccount is required");const t=q.validateAndGetChainId([r]),{connection:s,senderPublickey:c,instructions:u,senderAddress:l,storageAccount:g,programId:a}=await E(o,t,r,e,n,i),S=i||g.toString();return k.sendProxyV0Transaction({connection:s,chainId:t,subAccount:n,payerPublicKey:c,instructions:u,convertParams:{fromAddress:l,toAddress:S,programAddress:a.toString()}})},j=async(o,r,e,n,i)=>{const d=q.validateAndGetChainId([r]),{connection:t,senderPublickey:s,instructions:c}=await E(o,d,r,e,n,i);return k.serializeProxyV0Transaction(t,s,c)};exports.getSolanaProxyShieldSerializedTransaction=j;exports.hinkalSolanaProxyShield=z;
|
|
@@ -1,100 +1,103 @@
|
|
|
1
|
-
import { TOKEN_2022_PROGRAM_ID as
|
|
2
|
-
import { PublicKey as
|
|
3
|
-
import { networkRegistry as
|
|
1
|
+
import { TOKEN_2022_PROGRAM_ID as K, TOKEN_PROGRAM_ID as N } from "@solana/spl-token";
|
|
2
|
+
import { PublicKey as f } from "@solana/web3.js";
|
|
3
|
+
import { networkRegistry as y } from "../../constants/chains.constants.mjs";
|
|
4
4
|
import { solanaNativeAddress as P } from "../../constants/protocol.constants.mjs";
|
|
5
|
-
import { formatMintAddress as
|
|
6
|
-
import { isValidPrivateAddress as
|
|
7
|
-
import { transactionErrorCodes as
|
|
8
|
-
import { getStorageAccountPublicKey as G, getStorageVaultPublicKey as L, buildAnchorStealthAddressStructure as M, getTokenLimitStorageAccountPublicKey as
|
|
9
|
-
import { BN as
|
|
10
|
-
import { sendProxyV0Transaction as
|
|
11
|
-
import {
|
|
12
|
-
import { createCustomSolanaConnection as j } from "../../functions/utils/create-provider.mjs";
|
|
5
|
+
import { formatMintAddress as O } from "../../functions/utils/solanaMint.utils.mjs";
|
|
6
|
+
import { isValidPrivateAddress as V, constructStealthAddressStructure as _ } from "../../functions/utils/addresses.mjs";
|
|
7
|
+
import { transactionErrorCodes as v } from "../../error-handling/error-codes.constants.mjs";
|
|
8
|
+
import { getStorageAccountPublicKey as G, getStorageVaultPublicKey as L, buildAnchorStealthAddressStructure as M, getTokenLimitStorageAccountPublicKey as z } from "../../functions/pre-transaction/solana.mjs";
|
|
9
|
+
import { BN as F } from "@coral-xyz/anchor";
|
|
10
|
+
import { sendProxyV0Transaction as U, serializeProxyV0Transaction as q } from "../../functions/pre-transaction/sendV0Transaction.mjs";
|
|
11
|
+
import { createCustomSolanaConnection as B } from "../../functions/utils/create-provider.mjs";
|
|
13
12
|
import { validateAndGetChainId as w } from "../../functions/utils/token-check.utils.mjs";
|
|
13
|
+
import { AccountActions as j } from "../AccountActions/AccountActions.mjs";
|
|
14
14
|
const H = async ({
|
|
15
15
|
program: t,
|
|
16
16
|
mintPublicKey: r,
|
|
17
17
|
mintAddressString: n,
|
|
18
18
|
tokenAmount: e,
|
|
19
|
-
anchorStealthStructure:
|
|
19
|
+
anchorStealthStructure: i,
|
|
20
20
|
senderPublickey: d,
|
|
21
21
|
originalDeployer: o,
|
|
22
|
-
storageAccount:
|
|
23
|
-
storageVault:
|
|
22
|
+
storageAccount: s,
|
|
23
|
+
storageVault: c
|
|
24
24
|
}) => {
|
|
25
|
-
const
|
|
26
|
-
return t.methods.prooflessDeposit(
|
|
27
|
-
mint:
|
|
25
|
+
const u = new F(e.toString()), l = z(t.programId, o, r), m = n === P ? null : r, a = n === P ? null : void 0;
|
|
26
|
+
return t.methods.prooflessDeposit(u, i).accounts({
|
|
27
|
+
mint: m,
|
|
28
28
|
signer: d,
|
|
29
|
-
signerAta:
|
|
29
|
+
signerAta: a,
|
|
30
30
|
originalDeployer: o,
|
|
31
|
-
storageAccount:
|
|
32
|
-
storageVault:
|
|
31
|
+
storageAccount: s,
|
|
32
|
+
storageVault: c,
|
|
33
33
|
tokenLimitStorage: l,
|
|
34
|
-
storageVaultAta:
|
|
34
|
+
storageVaultAta: a,
|
|
35
35
|
accessTokenOwner: null
|
|
36
36
|
}).instruction();
|
|
37
|
-
}, E = async (t, r, n, e,
|
|
37
|
+
}, E = async (t, r, n, e, i, d) => {
|
|
38
38
|
const o = d ?? t.getRecipientInfo();
|
|
39
|
-
if (!
|
|
40
|
-
throw Error(
|
|
41
|
-
const
|
|
42
|
-
if (!
|
|
39
|
+
if (!V(o))
|
|
40
|
+
throw Error(v.RECIPIENT_FORMAT_INCORRECT);
|
|
41
|
+
const s = j.getAddressFromSubAccount(r, i);
|
|
42
|
+
if (!s)
|
|
43
|
+
throw Error("Public account address is not available");
|
|
44
|
+
const { hinkalIdl: c, hinkalAddress: u, originalDeployer: l } = y[r].contractData;
|
|
45
|
+
if (!c)
|
|
43
46
|
throw new Error("No IDL configured for Solana program on this network");
|
|
44
47
|
if (!l)
|
|
45
48
|
throw new Error("missing original deployer");
|
|
46
|
-
const
|
|
47
|
-
if (!
|
|
49
|
+
const m = t.getSolanaProgram(c), a = new f(l), g = new f(u), p = new f(s), { erc20TokenAddress: b } = n, { fetchRpcUrl: A } = y[r];
|
|
50
|
+
if (!A)
|
|
48
51
|
throw new Error("RPC URL not found for the specified chain ID");
|
|
49
|
-
const
|
|
50
|
-
program:
|
|
51
|
-
mintPublicKey:
|
|
52
|
-
mintAddressString:
|
|
52
|
+
const I = B(A), { mintPublicKey: S } = O(b), R = S.toString(), h = G(g, a), T = L(g, a), k = _(o), C = M(k), D = await H({
|
|
53
|
+
program: m,
|
|
54
|
+
mintPublicKey: S,
|
|
55
|
+
mintAddressString: R,
|
|
53
56
|
tokenAmount: e,
|
|
54
|
-
anchorStealthStructure:
|
|
55
|
-
senderPublickey:
|
|
56
|
-
originalDeployer:
|
|
57
|
-
storageAccount:
|
|
58
|
-
storageVault:
|
|
59
|
-
}),
|
|
57
|
+
anchorStealthStructure: C,
|
|
58
|
+
senderPublickey: p,
|
|
59
|
+
originalDeployer: a,
|
|
60
|
+
storageAccount: h,
|
|
61
|
+
storageVault: T
|
|
62
|
+
}), x = n.is2022Program ? K : N;
|
|
60
63
|
return {
|
|
61
|
-
connection:
|
|
62
|
-
senderAddress:
|
|
63
|
-
senderPublickey:
|
|
64
|
-
instructions: [
|
|
65
|
-
storageAccount:
|
|
66
|
-
programId:
|
|
64
|
+
connection: I,
|
|
65
|
+
senderAddress: s,
|
|
66
|
+
senderPublickey: p,
|
|
67
|
+
instructions: [D],
|
|
68
|
+
storageAccount: h,
|
|
69
|
+
programId: x
|
|
67
70
|
};
|
|
68
|
-
}, ir = async (t, r, n, e,
|
|
71
|
+
}, ir = async (t, r, n, e, i, d = !1) => {
|
|
69
72
|
if (d)
|
|
70
73
|
throw new Error("onlyGasEstimate is not supported for Solana proxy shield");
|
|
71
74
|
if (!e)
|
|
72
75
|
throw new Error("subAccount is required");
|
|
73
|
-
const o = w([r]), { connection:
|
|
74
|
-
return
|
|
75
|
-
connection:
|
|
76
|
+
const o = w([r]), { connection: s, senderPublickey: c, instructions: u, senderAddress: l, storageAccount: m, programId: a } = await E(t, o, r, n, e, i), g = i || m.toString();
|
|
77
|
+
return U({
|
|
78
|
+
connection: s,
|
|
76
79
|
chainId: o,
|
|
77
80
|
subAccount: e,
|
|
78
|
-
payerPublicKey:
|
|
79
|
-
instructions:
|
|
81
|
+
payerPublicKey: c,
|
|
82
|
+
instructions: u,
|
|
80
83
|
convertParams: {
|
|
81
84
|
fromAddress: l,
|
|
82
85
|
toAddress: g,
|
|
83
|
-
programAddress:
|
|
86
|
+
programAddress: a.toString()
|
|
84
87
|
}
|
|
85
88
|
});
|
|
86
|
-
},
|
|
87
|
-
const d = w([r]), { connection: o, senderPublickey:
|
|
89
|
+
}, cr = async (t, r, n, e, i) => {
|
|
90
|
+
const d = w([r]), { connection: o, senderPublickey: s, instructions: c } = await E(
|
|
88
91
|
t,
|
|
89
92
|
d,
|
|
90
93
|
r,
|
|
91
94
|
n,
|
|
92
95
|
e,
|
|
93
|
-
|
|
96
|
+
i
|
|
94
97
|
);
|
|
95
|
-
return q(o,
|
|
98
|
+
return q(o, s, c);
|
|
96
99
|
};
|
|
97
100
|
export {
|
|
98
|
-
|
|
101
|
+
cr as getSolanaProxyShieldSerializedTransaction,
|
|
99
102
|
ir as hinkalSolanaProxyShield
|
|
100
103
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@solana/web3.js");require("../../constants/token-data/index.cjs");const T=require("../../constants/chains.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/server.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");const f=require("../../functions/pre-transaction/sendV0Transaction.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@solana/web3.js");require("../../constants/token-data/index.cjs");const T=require("../../constants/chains.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/server.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");const f=require("../../functions/pre-transaction/sendV0Transaction.cjs"),E=require("../../functions/pre-transaction/getFeeStructure.cjs"),x=require("../../types/external-action.types.cjs"),I=require("../../error-handling/error-codes.constants.cjs"),K=require("../../functions/pre-transaction/solanaTransfer.utils.cjs"),R=require("../../functions/utils/create-provider.cjs"),v=require("../../functions/utils/token-check.utils.cjs"),C=require("../AccountActions/AccountActions.cjs"),q=async(s,n,u)=>{const o=C.AccountActions.getAddressFromSubAccount(s,u);if(!o)throw Error("Public account address is not available");const{fetchRpcUrl:a}=T.networkRegistry[s];if(!a)throw new Error("RPC URL not found for the specified chain ID");const i=R.createCustomSolanaConnection(a),l=JSON.parse(n),{addressLookupTableAccount:d,instructionLists:e}=l.data,w=await Promise.all(d.map(async r=>{const t=await i.getAddressLookupTable(new c.PublicKey(r));if(!t.value)throw new Error(`Failed to fetch lookup table: ${r}`);return t.value}));if(e.length===0)throw new Error("No instructions found");const p=e.map(r=>new c.TransactionInstruction({keys:r.accounts.map(t=>({pubkey:new c.PublicKey(t.pubkey),isSigner:t.isSigner,isWritable:t.isWritable})),programId:new c.PublicKey(r.programId),data:Buffer.from(r.data,"base64")}));return{connection:i,walletAddress:o,walletPublicKey:new c.PublicKey(o),lookupTableAccounts:w,instructions:p,instructionLists:e}},L=async(s,n,u,o,a,i,l,d=!1)=>{if(d)throw new Error("onlyGasEstimate is not supported for Solana proxy swap");const e=v.validateAndGetChainId(n),w=n[1],p=u[1],r=l??await E.getFeeStructure(e,i,n.map(k=>k.erc20TokenAddress),x.ExternalActionId.Emporium),t=p*r.variableRate/10000n,{connection:y,walletAddress:b,walletPublicKey:A,instructions:P,lookupTableAccounts:m,instructionLists:g}=await q(e,o,a),S=await s.getRandomRelay(e);if(!S)throw Error(I.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{instructions:h}=await K.buildSolanaTransferInstructions(y,A,new c.PublicKey(S),w,t);return f.sendProxyV0Transaction({connection:y,chainId:e,subAccount:a,payerPublicKey:A,instructions:[...P,...h],lookupTableAccounts:m,convertParams:{fromAddress:b,toAddress:b,programAddress:g[0].programId}})},_=async(s,n,u)=>{const{connection:o,walletPublicKey:a,instructions:i,lookupTableAccounts:l}=await q(s,n,u);return f.serializeProxyV0Transaction(o,a,i,l)};exports.getSolanaProxySwapSerializedTransaction=_;exports.hinkalSolanaProxySwap=L;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PublicKey as
|
|
1
|
+
import { PublicKey as m, TransactionInstruction as E } from "@solana/web3.js";
|
|
2
2
|
import "../../constants/token-data/index.mjs";
|
|
3
3
|
import { networkRegistry as T } from "../../constants/chains.constants.mjs";
|
|
4
4
|
import "../../constants/contracts.constants.mjs";
|
|
@@ -15,19 +15,22 @@ import "../../constants/tasks.constants.mjs";
|
|
|
15
15
|
import "../../constants/events.constants.mjs";
|
|
16
16
|
import { sendProxyV0Transaction as x, serializeProxyV0Transaction as I } from "../../functions/pre-transaction/sendV0Transaction.mjs";
|
|
17
17
|
import { getFeeStructure as R } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
18
|
-
import { ExternalActionId as
|
|
19
|
-
import { transactionErrorCodes as
|
|
20
|
-
import { buildSolanaTransferInstructions as
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
const A = async (
|
|
25
|
-
const
|
|
18
|
+
import { ExternalActionId as L } from "../../types/external-action.types.mjs";
|
|
19
|
+
import { transactionErrorCodes as v } from "../../error-handling/error-codes.constants.mjs";
|
|
20
|
+
import { buildSolanaTransferInstructions as C } from "../../functions/pre-transaction/solanaTransfer.utils.mjs";
|
|
21
|
+
import { createCustomSolanaConnection as K } from "../../functions/utils/create-provider.mjs";
|
|
22
|
+
import { validateAndGetChainId as F } from "../../functions/utils/token-check.utils.mjs";
|
|
23
|
+
import { AccountActions as N } from "../AccountActions/AccountActions.mjs";
|
|
24
|
+
const A = async (i, n, c) => {
|
|
25
|
+
const a = N.getAddressFromSubAccount(i, c);
|
|
26
|
+
if (!a)
|
|
27
|
+
throw Error("Public account address is not available");
|
|
28
|
+
const { fetchRpcUrl: e } = T[i];
|
|
26
29
|
if (!e)
|
|
27
30
|
throw new Error("RPC URL not found for the specified chain ID");
|
|
28
|
-
const s =
|
|
29
|
-
|
|
30
|
-
const r = await s.getAddressLookupTable(new
|
|
31
|
+
const s = K(e), l = JSON.parse(n), { addressLookupTableAccount: p, instructionLists: o } = l.data, u = await Promise.all(
|
|
32
|
+
p.map(async (t) => {
|
|
33
|
+
const r = await s.getAddressLookupTable(new m(t));
|
|
31
34
|
if (!r.value)
|
|
32
35
|
throw new Error(`Failed to fetch lookup table: ${t}`);
|
|
33
36
|
return r.value;
|
|
@@ -37,36 +40,36 @@ const A = async (a, n, c) => {
|
|
|
37
40
|
throw new Error("No instructions found");
|
|
38
41
|
const d = o.map((t) => new E({
|
|
39
42
|
keys: t.accounts.map((r) => ({
|
|
40
|
-
pubkey: new
|
|
43
|
+
pubkey: new m(r.pubkey),
|
|
41
44
|
isSigner: r.isSigner,
|
|
42
45
|
isWritable: r.isWritable
|
|
43
46
|
})),
|
|
44
|
-
programId: new
|
|
47
|
+
programId: new m(t.programId),
|
|
45
48
|
data: Buffer.from(t.data, "base64")
|
|
46
49
|
}));
|
|
47
50
|
return {
|
|
48
51
|
connection: s,
|
|
49
|
-
walletAddress:
|
|
50
|
-
walletPublicKey: new
|
|
52
|
+
walletAddress: a,
|
|
53
|
+
walletPublicKey: new m(a),
|
|
51
54
|
lookupTableAccounts: u,
|
|
52
55
|
instructions: d,
|
|
53
56
|
instructionLists: o
|
|
54
57
|
};
|
|
55
|
-
},
|
|
56
|
-
if (
|
|
58
|
+
}, ao = async (i, n, c, a, e, s, l, p = !1) => {
|
|
59
|
+
if (p)
|
|
57
60
|
throw new Error("onlyGasEstimate is not supported for Solana proxy swap");
|
|
58
|
-
const o =
|
|
61
|
+
const o = F(n), u = n[1], d = c[1], t = l ?? await R(
|
|
59
62
|
o,
|
|
60
63
|
s,
|
|
61
64
|
n.map((k) => k.erc20TokenAddress),
|
|
62
|
-
|
|
63
|
-
), r = d * t.variableRate / 10000n, { connection: w, walletAddress: f, walletPublicKey: y, instructions: S, lookupTableAccounts:
|
|
65
|
+
L.Emporium
|
|
66
|
+
), r = d * t.variableRate / 10000n, { connection: w, walletAddress: f, walletPublicKey: y, instructions: S, lookupTableAccounts: h, instructionLists: P } = await A(o, a, e), b = await i.getRandomRelay(o);
|
|
64
67
|
if (!b)
|
|
65
|
-
throw Error(
|
|
66
|
-
const { instructions:
|
|
68
|
+
throw Error(v.RELAYER_NOT_AVAILABLE);
|
|
69
|
+
const { instructions: g } = await C(
|
|
67
70
|
w,
|
|
68
71
|
y,
|
|
69
|
-
new
|
|
72
|
+
new m(b),
|
|
70
73
|
u,
|
|
71
74
|
r
|
|
72
75
|
);
|
|
@@ -75,23 +78,23 @@ const A = async (a, n, c) => {
|
|
|
75
78
|
chainId: o,
|
|
76
79
|
subAccount: e,
|
|
77
80
|
payerPublicKey: y,
|
|
78
|
-
instructions: [...S, ...
|
|
79
|
-
lookupTableAccounts:
|
|
81
|
+
instructions: [...S, ...g],
|
|
82
|
+
lookupTableAccounts: h,
|
|
80
83
|
convertParams: {
|
|
81
84
|
fromAddress: f,
|
|
82
85
|
toAddress: f,
|
|
83
86
|
programAddress: P[0].programId
|
|
84
87
|
}
|
|
85
88
|
});
|
|
86
|
-
},
|
|
87
|
-
const { connection:
|
|
88
|
-
|
|
89
|
+
}, eo = async (i, n, c) => {
|
|
90
|
+
const { connection: a, walletPublicKey: e, instructions: s, lookupTableAccounts: l } = await A(
|
|
91
|
+
i,
|
|
89
92
|
n,
|
|
90
93
|
c
|
|
91
94
|
);
|
|
92
|
-
return I(
|
|
95
|
+
return I(a, e, s, l);
|
|
93
96
|
};
|
|
94
97
|
export {
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
eo as getSolanaProxySwapSerializedTransaction,
|
|
99
|
+
ao as hinkalSolanaProxySwap
|
|
97
100
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");const ne=require("../../types/external-action.types.cjs"),y=require("../../constants/protocol.constants.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");const se=require("../../types/cache.types.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");const ne=require("../../types/external-action.types.cjs"),y=require("../../constants/protocol.constants.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");const se=require("../../types/cache.types.cjs"),ae=require("../../functions/web3/events/getShieldedBalance.cjs"),ce=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),ie=require("../../functions/utils/time.utils.cjs"),ue=require("../../functions/pre-transaction/getFeeStructure.cjs"),le=require("../../functions/snarkjs/common.snarkjs.cjs"),de=require("../../constants/chains.constants.cjs"),c=require("@solana/web3.js"),m=require("../../functions/pre-transaction/solana.cjs"),pe=require("../../functions/snarkjs/constructSolanaZkProof.cjs"),ge=require("../utxo/Utxo.cjs"),S=require("../../functions/web3/etherFunctions.cjs"),Ae=require("../../functions/pre-transaction/convert-okx-instructions.cjs"),ye=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),me=require("../../error-handling/error-codes.constants.cjs"),Se=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),we=require("ethers"),fe=require("../../functions/utils/token-check.utils.cjs"),Pe=async(t,o,n,w,K,x,v,E,R=!1)=>{if(R)throw new Error("onlyGasEstimate is not supported for Solana swap");const r=fe.validateAndGetChainId(o),f=new c.PublicKey(y.solanaNativeAddress),{hinkalAddress:_,originalDeployer:i,hinkalIdl:P}=de.networkRegistry[r].contractData;if(!i||!P)throw new Error("No IDL configured for Solana program on this network");const u=new c.PublicKey(i),l=new c.PublicKey(_),s=o.map(e=>e.erc20TokenAddress),{userKeys:h,merkleTreeAccessTokenByChain:F,merkleTreeHinkalByChain:N}=t,C=t.getSolanaProgram(P),a=E??await ue.getFeeStructure(r,v,s,ne.ExternalActionId.Transact),{patchAccessTokenMerkleTree:O,kycRequired:B,hasAccessToken:U}=await Se.shouldPatchAccessTokenMerkleTree(t,r,s,n);n[1]-=a.flatFee;const D=a.variableRate.toString(),L=Number(t.cacheDevice.get(se.StorageKeys.SLIPPAGE_PERCENTAGE)??0),d=o[1],G=S.getAmountInToken(d,n[1]),M=Number(G)*L/100;n[1]-=S.getAmountInWei(d,M.toFixed(d.decimals));const p=[...await ae.addPaddingToUtxos(t,r,s,n,6)],V=ie.getCurrentTimeInSeconds().toString(),j=t.userKeys.getShieldedPrivateKey(),g=[];for(let e=0;e<s.length;e+=1){const{outputUtxos:oe}=ce.outputUtxoProcessing(t.userKeys,p[e],n[e],V,void 0,!1);g.push([oe[0]])}const W=ge.Utxo.findCorrectRandomization(S.randomBigInt(31),j),k={tokenNumber:2,nullifierAmount:p[0].length,outputAmount:1},z=[!1,!0].slice(0,n.length),A=await t.getRandomRelay(r,!0);if(!A)throw Error(me.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const q=le.calcEncryptedOutputs(g).map(e=>[...we.ethers.utils.arrayify(e[0])]),b=m.getSwapperAccountPublicKeyFromSalt(l,u,w),{remainingAccounts:T,hinkalInstructions:I}=Ae.convertOKXToHinkalInstructions(K,b),{proofAArr:H,proofBArr:Z,proofCArr:X,publicInputsArr:Y}=await pe.constructSolanaZkProof(t.generateProofRemotely,i,N[r],F[r],h,C,s,p,g,W,a.flatFee,a.variableRate,f.toString(),A,k,q,r,O,z,w,I,T),J=m.getStorageAccountPublicKey(l,u),Q=m.getStorageVaultPublicKey(l,u),$=o[0].erc20TokenAddress!==y.solanaNativeAddress?new c.PublicKey(o[0].erc20TokenAddress):null,ee=o[1].erc20TokenAddress!==y.solanaNativeAddress?new c.PublicKey(o[1].erc20TokenAddress):null,te={recipient:f.toString(),storageAccount:J.toString(),storageVault:Q.toString(),swapperAccount:b.toString(),mintFrom:$?.toString()??null,mintTo:ee?.toString()??null,remainingAccounts:T.map(e=>({pubkey:e.pubkey.toString(),isSigner:e.isSigner,isWritable:e.isWritable})),addressLookupTableAccount:x},re={encryptedOutputs:q,proofAArr:H,proofBArr:Z,proofCArr:X,publicInputsArr:Y,relayerFee:a.flatFee.toString(),variableRate:D,dimensions:k,hinkalInstructions:I.map(e=>({accountIndexes:[...e.accountIndexes],data:[...e.data],programIndex:e.programIndex}))};return ye.solanaTransactCallRelayer({chainId:r,relayAddress:A,functionName:"swap",args:re,accounts:te,solanaAccessTokenData:!U&&B?{ethereumAddress:await t.getEthereumAddressByChain(r),accessKey:h.getAccessKey()}:void 0})};exports.hinkalSolanaSwap=Pe;
|
|
@@ -21,20 +21,20 @@ import { transactionErrorCodes as It } from "../../error-handling/error-codes.co
|
|
|
21
21
|
import { shouldPatchAccessTokenMerkleTree as Tt } from "../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.mjs";
|
|
22
22
|
import { ethers as Pt } from "ethers";
|
|
23
23
|
import { validateAndGetChainId as bt } from "../../functions/utils/token-check.utils.mjs";
|
|
24
|
-
const Yt = async (o, e, n, f,
|
|
24
|
+
const Yt = async (o, e, n, f, h, E, x, K, R = !1) => {
|
|
25
25
|
if (R)
|
|
26
26
|
throw new Error("onlyGasEstimate is not supported for Solana swap");
|
|
27
27
|
const r = bt(e), y = new i(A), { hinkalAddress: v, originalDeployer: c, hinkalIdl: S } = mt[r].contractData;
|
|
28
28
|
if (!c || !S)
|
|
29
29
|
throw new Error("No IDL configured for Solana program on this network");
|
|
30
|
-
const m = new i(c), p = new i(v), s = e.map((t) => t.erc20TokenAddress), { userKeys: w, merkleTreeAccessTokenByChain: F, merkleTreeHinkalByChain: N } = o,
|
|
30
|
+
const m = new i(c), p = new i(v), s = e.map((t) => t.erc20TokenAddress), { userKeys: w, merkleTreeAccessTokenByChain: F, merkleTreeHinkalByChain: N } = o, B = o.getSolanaProgram(S), a = K ?? await it(r, x, s, rt.Transact), { patchAccessTokenMerkleTree: D, kycRequired: O, hasAccessToken: C } = await Tt(
|
|
31
31
|
o,
|
|
32
32
|
r,
|
|
33
33
|
s,
|
|
34
34
|
n
|
|
35
35
|
);
|
|
36
36
|
n[1] -= a.flatFee;
|
|
37
|
-
const
|
|
37
|
+
const U = a.variableRate.toString(), L = Number(o.cacheDevice.get(et.SLIPPAGE_PERCENTAGE) ?? 0), u = e[1], G = At(u, n[1]), V = Number(G) * L / 100;
|
|
38
38
|
n[1] -= ft(u, V.toFixed(u.decimals));
|
|
39
39
|
const l = [...await nt(o, r, s, n, 6)], W = at().toString(), _ = o.userKeys.getShieldedPrivateKey(), d = [];
|
|
40
40
|
for (let t = 0; t < s.length; t += 1) {
|
|
@@ -55,13 +55,13 @@ const Yt = async (o, e, n, f, E, h, x, K, R = !1) => {
|
|
|
55
55
|
}, H = [!1, !0].slice(0, n.length), g = await o.getRandomRelay(r, !0);
|
|
56
56
|
if (!g)
|
|
57
57
|
throw Error(It.RELAYER_NOT_AVAILABLE);
|
|
58
|
-
const T = ct(d).map((t) => [...Pt.utils.arrayify(t[0])]), P = pt(p, m, f), { remainingAccounts: b, hinkalInstructions: k } = St(
|
|
58
|
+
const T = ct(d).map((t) => [...Pt.utils.arrayify(t[0])]), P = pt(p, m, f), { remainingAccounts: b, hinkalInstructions: k } = St(h, P), { proofAArr: M, proofBArr: q, proofCArr: X, publicInputsArr: Y } = await dt(
|
|
59
59
|
o.generateProofRemotely,
|
|
60
60
|
c,
|
|
61
61
|
N[r],
|
|
62
62
|
F[r],
|
|
63
63
|
w,
|
|
64
|
-
|
|
64
|
+
B,
|
|
65
65
|
s,
|
|
66
66
|
l,
|
|
67
67
|
d,
|
|
@@ -73,7 +73,7 @@ const Yt = async (o, e, n, f, E, h, x, K, R = !1) => {
|
|
|
73
73
|
I,
|
|
74
74
|
T,
|
|
75
75
|
r,
|
|
76
|
-
|
|
76
|
+
D,
|
|
77
77
|
H,
|
|
78
78
|
f,
|
|
79
79
|
k,
|
|
@@ -90,7 +90,7 @@ const Yt = async (o, e, n, f, E, h, x, K, R = !1) => {
|
|
|
90
90
|
isSigner: t.isSigner,
|
|
91
91
|
isWritable: t.isWritable
|
|
92
92
|
})),
|
|
93
|
-
addressLookupTableAccount:
|
|
93
|
+
addressLookupTableAccount: E
|
|
94
94
|
}, tt = {
|
|
95
95
|
encryptedOutputs: T,
|
|
96
96
|
proofAArr: M,
|
|
@@ -98,7 +98,7 @@ const Yt = async (o, e, n, f, E, h, x, K, R = !1) => {
|
|
|
98
98
|
proofCArr: X,
|
|
99
99
|
publicInputsArr: Y,
|
|
100
100
|
relayerFee: a.flatFee.toString(),
|
|
101
|
-
variableRate:
|
|
101
|
+
variableRate: U,
|
|
102
102
|
dimensions: I,
|
|
103
103
|
hinkalInstructions: k.map((t) => ({
|
|
104
104
|
accountIndexes: [...t.accountIndexes],
|
|
@@ -112,8 +112,8 @@ const Yt = async (o, e, n, f, E, h, x, K, R = !1) => {
|
|
|
112
112
|
functionName: "swap",
|
|
113
113
|
args: tt,
|
|
114
114
|
accounts: $,
|
|
115
|
-
solanaAccessTokenData: !
|
|
116
|
-
ethereumAddress: await o.
|
|
115
|
+
solanaAccessTokenData: !C && O ? {
|
|
116
|
+
ethereumAddress: await o.getEthereumAddressByChain(r),
|
|
117
117
|
accessKey: w.getAccessKey()
|
|
118
118
|
} : void 0
|
|
119
119
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");const K=require("../../types/external-action.types.cjs"),b=require("../../constants/protocol.constants.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");const N=require("../../functions/web3/events/getShieldedBalance.cjs"),M=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),D=require("../../functions/utils/time.utils.cjs"),L=require("../../error-handling/error-codes.constants.cjs"),W=require("../../functions/pre-transaction/getFeeStructure.cjs"),j=require("../../functions/snarkjs/common.snarkjs.cjs"),z=require("../../functions/snarkjs/constructSolanaZkProof.cjs"),Z=require("../utxo/Utxo.cjs"),G=require("../../functions/web3/etherFunctions.cjs"),H=require("../../functions/web3/functionCalls/transactCallRelayer.cjs");require("../../constants/token-data/index.cjs");const V=require("../../constants/chains.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/server.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");const Y=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),J=require("ethers"),Q=require("../../functions/utils/token-check.utils.cjs"),X=async(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../types/circom-data.types.cjs");const K=require("../../types/external-action.types.cjs"),b=require("../../constants/protocol.constants.cjs");require("../../types/transactions.types.cjs");require("../../types/activities.types.cjs");const N=require("../../functions/web3/events/getShieldedBalance.cjs"),M=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),D=require("../../functions/utils/time.utils.cjs"),L=require("../../error-handling/error-codes.constants.cjs"),W=require("../../functions/pre-transaction/getFeeStructure.cjs"),j=require("../../functions/snarkjs/common.snarkjs.cjs"),z=require("../../functions/snarkjs/constructSolanaZkProof.cjs"),Z=require("../utxo/Utxo.cjs"),G=require("../../functions/web3/etherFunctions.cjs"),H=require("../../functions/web3/functionCalls/transactCallRelayer.cjs");require("../../constants/token-data/index.cjs");const V=require("../../constants/chains.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/server.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/reorg-depths.constants.cjs");require("../../constants/addresses.constants.cjs");require("../../constants/token.limits.constants.cjs");require("../../constants/presale.constants.cjs");require("../../constants/activity.constants.cjs");require("../../constants/tasks.constants.cjs");require("../../constants/events.constants.cjs");const Y=require("../../functions/pre-transaction/shouldPatchAccessTokenMerkleTree.cjs"),J=require("ethers"),Q=require("../../functions/utils/token-check.utils.cjs"),X=async(r,c,o,u,m,g,l=!1)=>{if(l)throw new Error("onlyGasEstimate is not supported for Solana withdraw");const e=Q.validateAndGetChainId(c),t=c.map(U=>U.erc20TokenAddress),h=await r.getEthereumAddressByChain(e),{originalDeployer:d,hinkalIdl:q}=V.networkRegistry[e].contractData;if(!d||!q)throw new Error("missing data");const{userKeys:y,merkleTreeAccessTokenByChain:f,merkleTreeHinkalByChain:w}=r,s=g??await W.getFeeStructure(e,m,t,K.ExternalActionId.Transact);o[0]-=s.flatFee;const{patchAccessTokenMerkleTree:S,kycRequired:T,hasAccessToken:k}=await Y.shouldPatchAccessTokenMerkleTree(r,e,t,o);if(t.length>1)throw new Error("Solana Withdraw: Only one mint address is supported");const n=[...await N.addPaddingToUtxos(r,e,t,o,6)][0],R=D.getCurrentTimeInSeconds().toString(),{outputUtxos:a}=M.outputUtxoProcessing(r.userKeys,n,o[0],R,void 0,!1),i=await r.getRandomRelay(e,!l);if(!i)throw Error(L.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const E=Z.Utxo.findCorrectRandomization(G.randomBigInt(31),r.userKeys.getShieldedPrivateKey()),p={tokenNumber:t.length,nullifierAmount:n.length,outputAmount:a.length},P=r.getSolanaProgram(q),x=j.calcEncryptedOutputs([a])[0][0],A=Array.from(J.ethers.utils.arrayify(x)),{proofAArr:v,proofBArr:C,proofCArr:_,publicInputsArr:B}=await z.constructSolanaZkProof(r.generateProofRemotely,d,w[e],f[e],y,P,[t[0]],[n],[a],E,s.flatFee,s.variableRate,u,i,p,[A],e,S),I=t[0]===b.solanaNativeAddress,F={recipient:u,mint:I?void 0:t[0]},O={proofAArr:v,proofBArr:C,proofCArr:_,publicInputsArr:B,encryptedOutputs:[A],relayerFee:s.flatFee.toString(),dimensions:p};return H.solanaTransactCallRelayer({chainId:e,relayAddress:i,functionName:"transact",args:O,accounts:F,solanaAccessTokenData:!k&&T?{ethereumAddress:h,accessKey:y.getAccessKey()}:void 0})};exports.hinkalSolanaWithdraw=X;
|