@hinkal/common 0.3.13 → 0.3.14
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/README.md +67 -4
- package/common/src/API/API.cjs +1 -1
- package/common/src/API/API.d.ts +0 -2
- package/common/src/API/API.mjs +92 -94
- package/common/src/API/admin-calls.cjs +1 -1
- package/common/src/API/admin-calls.d.ts +2 -1
- package/common/src/API/admin-calls.mjs +1 -0
- package/common/src/API/evm-token-assets.cjs +1 -1
- package/common/src/API/evm-token-assets.mjs +2 -13
- package/common/src/API/get-token-price-chart-data.cjs +1 -1
- package/common/src/API/get-token-price-chart-data.mjs +2 -2
- package/common/src/API/getTokenPrice.cjs +1 -1
- package/common/src/API/getTokenPrice.mjs +2 -2
- package/common/src/API/index.cjs +1 -1
- package/common/src/API/index.d.ts +1 -0
- package/common/src/API/index.mjs +1 -0
- package/common/src/API/privacy-score-calls.cjs +1 -1
- package/common/src/API/privacy-score-calls.mjs +2 -2
- package/common/src/API/receiveVaultCalls.cjs +1 -1
- package/common/src/API/receiveVaultCalls.d.ts +4 -2
- package/common/src/API/receiveVaultCalls.mjs +8 -4
- package/common/src/constants/chains.constants.cjs +1 -1
- package/common/src/constants/chains.constants.d.ts +2 -0
- package/common/src/constants/chains.constants.mjs +106 -93
- package/common/src/constants/coingecko.constants.cjs +1 -1
- package/common/src/constants/coingecko.constants.d.ts +2 -0
- package/common/src/constants/coingecko.constants.mjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-arbMainnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-arbMainnet.json.mjs +2 -1
- package/common/src/constants/deploy-data/deploy-data-arcTestnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-arcTestnet.json.mjs +3 -2
- package/common/src/constants/deploy-data/deploy-data-base.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-base.json.mjs +2 -1
- package/common/src/constants/deploy-data/deploy-data-bnbMainnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-bnbMainnet.json.mjs +2 -1
- package/common/src/constants/deploy-data/deploy-data-ethMainnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-ethMainnet.json.mjs +2 -1
- package/common/src/constants/deploy-data/deploy-data-polygon.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-polygon.json.mjs +2 -1
- package/common/src/constants/deploy-data/deploy-data-solanaDevnet.json.cjs +1 -0
- package/common/src/constants/deploy-data/deploy-data-solanaDevnet.json.mjs +6 -0
- package/common/src/constants/deploy-data/deploy-data-tempo.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-tempo.json.mjs +2 -1
- package/common/src/constants/deploy-data/deploy-data-tronMainnet.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-tronMainnet.json.mjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-tronNile.json.cjs +1 -1
- package/common/src/constants/deploy-data/deploy-data-tronNile.json.mjs +1 -1
- package/common/src/constants/deploy-data/index.cjs +1 -1
- package/common/src/constants/deploy-data/index.d.ts +2 -1
- package/common/src/constants/deploy-data/index.mjs +7 -6
- package/common/src/constants/deploy-data/shared-deploy-data-evm.json.cjs +1 -1
- package/common/src/constants/deploy-data/shared-deploy-data-evm.json.mjs +1 -1
- package/common/src/constants/deploy-data/shared-deploy-data-solana.json.cjs +1 -1
- package/common/src/constants/deploy-data/shared-deploy-data-solana.json.mjs +1 -1
- package/common/src/constants/deploy-data/shared-deploy-data-tron.json.cjs +1 -1
- package/common/src/constants/deploy-data/shared-deploy-data-tron.json.mjs +1 -1
- package/common/src/constants/index.cjs +1 -1
- package/common/src/constants/index.mjs +1 -1
- package/common/src/constants/protocol.constants.cjs +2 -2
- package/common/src/constants/protocol.constants.d.ts +0 -2
- package/common/src/constants/protocol.constants.mjs +2 -2
- package/common/src/constants/save-depths.cjs +1 -1
- package/common/src/constants/save-depths.d.ts +1 -0
- package/common/src/constants/save-depths.mjs +1 -0
- package/common/src/constants/server.constants.cjs +1 -1
- package/common/src/constants/server.constants.d.ts +8 -6
- package/common/src/constants/server.constants.mjs +8 -6
- package/common/src/constants/tokens.constants.cjs +1 -1
- package/common/src/constants/tokens.constants.mjs +1 -1
- package/common/src/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/common/src/data-structures/Hinkal/Hinkal.d.ts +4 -4
- package/common/src/data-structures/Hinkal/Hinkal.mjs +37 -37
- package/common/src/data-structures/Hinkal/IHinkal.d.ts +4 -4
- package/common/src/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/common/src/data-structures/Hinkal/handleAutoDepositBack.mjs +5 -5
- package/common/src/data-structures/Hinkal/hinkalBridgePrivateToPrivate.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalBridgePrivateToPrivate.mjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndBridge.mjs +55 -54
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +60 -57
- package/common/src/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalPrivateWallet.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalPrivateWallet.mjs +29 -29
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.utils.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProoflessDeposit.utils.mjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProxySwap.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalProxySwap.mjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultAccount.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultAccount.mjs +7 -15
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultCreate.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultCreate.d.ts +2 -2
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultCreate.mjs +24 -28
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultRecover.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultRecover.mjs +47 -40
- package/common/src/data-structures/Hinkal/hinkalReceiveVaultSettle.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDeposit.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDeposit.mjs +22 -42
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +72 -70
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySend.mjs +9 -9
- package/common/src/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +15 -15
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySwap.d.ts +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +47 -45
- package/common/src/data-structures/Hinkal/hinkalSolanaReceiveVault.cjs +1 -0
- package/common/src/data-structures/Hinkal/hinkalSolanaReceiveVault.d.ts +5 -0
- package/common/src/data-structures/Hinkal/hinkalSolanaReceiveVault.mjs +60 -0
- package/common/src/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalWithdraw.mjs +35 -26
- package/common/src/data-structures/Hinkal/index.d.ts +1 -0
- package/common/src/data-structures/Hinkal/resetMerkleTrees.cjs +1 -1
- package/common/src/data-structures/Hinkal/resetMerkleTrees.mjs +13 -13
- package/common/src/error-handling/error-codes.constants.cjs +1 -1
- package/common/src/error-handling/error-codes.constants.d.ts +2 -0
- package/common/src/error-handling/error-codes.constants.mjs +2 -0
- package/common/src/error-handling/get-error.message.cjs +1 -1
- package/common/src/error-handling/get-error.message.mjs +10 -1
- package/common/src/functions/index.cjs +1 -1
- package/common/src/functions/index.mjs +6 -2
- package/common/src/functions/pre-transaction/addressTableLookup.d.ts +1 -0
- package/common/src/functions/pre-transaction/calculateSolanaNullifierCount.cjs +1 -1
- package/common/src/functions/pre-transaction/calculateSolanaNullifierCount.mjs +7 -7
- package/common/src/functions/pre-transaction/constructAdminData.cjs +1 -1
- package/common/src/functions/pre-transaction/constructAdminData.mjs +4 -3
- package/common/src/functions/pre-transaction/sendV0Transaction.cjs +1 -1
- package/common/src/functions/pre-transaction/sendV0Transaction.d.ts +1 -0
- package/common/src/functions/pre-transaction/sendV0Transaction.mjs +22 -2
- package/common/src/functions/private-wallet/emporium.helpers.cjs +1 -1
- package/common/src/functions/private-wallet/emporium.helpers.mjs +15 -15
- package/common/src/functions/snarkjs/fetchOnChainRootHashes.cjs +1 -1
- package/common/src/functions/snarkjs/fetchOnChainRootHashes.mjs +6 -6
- package/common/src/functions/utils/addresses.cjs +1 -1
- package/common/src/functions/utils/addresses.d.ts +4 -0
- package/common/src/functions/utils/addresses.mjs +17 -17
- package/common/src/functions/utils/admin-dimensions.cjs +1 -0
- package/common/src/functions/utils/admin-dimensions.d.ts +4 -0
- package/common/src/functions/utils/admin-dimensions.mjs +206 -0
- package/common/src/functions/utils/create-provider.cjs +1 -1
- package/common/src/functions/utils/create-provider.mjs +5 -1
- package/common/src/functions/utils/fees.utils.cjs +1 -1
- package/common/src/functions/utils/fees.utils.d.ts +2 -0
- package/common/src/functions/utils/fees.utils.mjs +31 -33
- package/common/src/functions/utils/gas-token.utils.cjs +1 -0
- package/common/src/functions/utils/gas-token.utils.d.ts +3 -0
- package/common/src/functions/utils/gas-token.utils.mjs +7 -0
- package/common/src/functions/utils/getUtxosFromReceiptSolana.d.ts +9 -4
- package/common/src/functions/utils/index.cjs +1 -1
- package/common/src/functions/utils/index.d.ts +4 -0
- package/common/src/functions/utils/index.mjs +5 -1
- package/common/src/functions/utils/publicBalance.utils.cjs +1 -1
- package/common/src/functions/utils/publicBalance.utils.mjs +7 -7
- package/common/src/functions/utils/receive-vault-account.utils.cjs +1 -1
- package/common/src/functions/utils/receive-vault-account.utils.d.ts +2 -1
- package/common/src/functions/utils/receive-vault-account.utils.mjs +16 -15
- package/common/src/functions/utils/receive-vault-scan.utils.cjs +1 -1
- package/common/src/functions/utils/receive-vault-scan.utils.mjs +37 -42
- package/common/src/functions/utils/receive-vault-solana.utils.cjs +1 -0
- package/common/src/functions/utils/receive-vault-solana.utils.d.ts +8 -0
- package/common/src/functions/utils/receive-vault-solana.utils.mjs +45 -0
- package/common/src/functions/utils/receive-vault.utils.cjs +2 -2
- package/common/src/functions/utils/receive-vault.utils.d.ts +13 -11
- package/common/src/functions/utils/receive-vault.utils.mjs +97 -82
- package/common/src/functions/utils/token-check.utils.d.ts +1 -0
- package/common/src/functions/utils/wallet-token-discovery.utils.cjs +1 -1
- package/common/src/functions/utils/wallet-token-discovery.utils.d.ts +5 -0
- package/common/src/functions/utils/wallet-token-discovery.utils.mjs +25 -31
- package/common/src/functions/web3/getContractMetadata.cjs +1 -1
- package/common/src/functions/web3/getContractMetadata.mjs +6 -6
- package/common/src/functions/web3/index.cjs +1 -1
- package/common/src/functions/web3/index.mjs +1 -1
- package/common/src/types/admin.types.cjs +1 -1
- package/common/src/types/admin.types.d.ts +64 -9
- package/common/src/types/admin.types.mjs +10 -2
- package/common/src/types/connector.types.d.ts +1 -0
- package/common/src/types/ethereum-network.types.d.ts +1 -0
- package/common/src/types/external-action.types.cjs +1 -1
- package/common/src/types/external-action.types.d.ts +2 -1
- package/common/src/types/external-action.types.mjs +1 -1
- package/common/src/types/receive-vault.types.cjs +1 -1
- package/common/src/types/receive-vault.types.d.ts +15 -20
- package/common/src/types/receive-vault.types.mjs +4 -2
- package/common/src/webworker/{logError-BeXPKuv9.js → logError-C-ej_TX9.js} +1 -1
- package/common/src/webworker/package.json +1 -1
- package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/snarkjsWorkerNode.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/utxoWorkerNode.cjs +1 -1
- package/common/src/webworker/viteWorkerURL.constant.cjs +3 -3
- package/common/src/webworker/viteWorkerURL.constant.mjs +3 -3
- package/common/src/webworker/workerProxy-CE-rYA3W.js +1 -0
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/zkProofWorkerNode.cjs +1 -1
- package/index.cjs +1 -1
- package/index.mjs +3 -2
- package/internal/monitorConnectedAddress.cjs +1 -1
- package/internal/monitorConnectedAddress.d.ts +1 -1
- package/internal/monitorConnectedAddress.mjs +1 -3
- package/package.json +1 -1
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +1 -1
- package/providers/prepareSolanaHinkal.cjs +1 -1
- package/providers/prepareSolanaHinkal.mjs +1 -1
- package/providers/prepareTronHinkal.cjs +1 -1
- package/providers/prepareTronHinkal.mjs +1 -1
- package/providers/prepareWagmiHinkal.cjs +1 -1
- package/providers/prepareWagmiHinkal.mjs +1 -1
- package/services/Hinkal.cjs +1 -1
- package/services/Hinkal.d.ts +6 -2
- package/services/Hinkal.mjs +74 -51
- package/types/IHinkal.d.ts +6 -1
- package/types/index.cjs +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.mjs +2 -0
- package/types/receive-vault.types.cjs +1 -0
- package/types/receive-vault.types.d.ts +14 -0
- package/types/receive-vault.types.mjs +2 -0
- package/common/src/API/getOdosPriceForToken.cjs +0 -1
- package/common/src/API/getOdosPriceForToken.d.ts +0 -1
- package/common/src/API/getOdosPriceForToken.mjs +0 -14
- package/common/src/webworker/workerProxy-DF35H7vU.js +0 -1
|
@@ -1,60 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { getEvmWalletTokenAddresses as d, getTronWalletTokenAddresses as f } from "./wallet-token-discovery.utils.mjs";
|
|
1
|
+
import { isSolanaLike as e } from "../../constants/chains.constants.mjs";
|
|
2
|
+
import { Logger as t } from "../../error-handling/logger.mjs";
|
|
3
|
+
import { addressEqual as n, normalizeAddress as r } from "./addresses.mjs";
|
|
4
|
+
import { ReceiveVaultBlockReason as i } from "../../types/receive-vault.types.mjs";
|
|
5
|
+
import { receiveVaultChainsForNetwork as a } from "./receive-vault.utils.mjs";
|
|
6
|
+
import { getErc20TokenFromAPI as o, isArcNativeToken as s } from "./erc20tokenFunctions.mjs";
|
|
7
|
+
import { getPublicBalanceByTokenAddress as c } from "./publicBalance.utils.mjs";
|
|
8
|
+
import { getSolanaWalletTokenHoldings as l } from "./wallet-token-discovery.utils.mjs";
|
|
10
9
|
//#region libs/shared/common/src/functions/utils/receive-vault-scan.utils.ts
|
|
11
|
-
var
|
|
10
|
+
var u = async (e, t, n) => await c(t, r(t, e), r(t, n)) ?? 0n, d = async (e, n) => {
|
|
12
11
|
try {
|
|
13
|
-
return await (
|
|
14
|
-
} catch (
|
|
15
|
-
return
|
|
12
|
+
return await l(e, n);
|
|
13
|
+
} catch (n) {
|
|
14
|
+
return t.error(`receive-vault scan: token discovery failed for chain ${e}`, n), [];
|
|
16
15
|
}
|
|
17
|
-
},
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
i(e, o, s, r);
|
|
33
|
-
});
|
|
16
|
+
}, f = async (t, o) => {
|
|
17
|
+
let s = /* @__PURE__ */ new Map(), c = (e, t, n, i) => {
|
|
18
|
+
let a = `${t}:${r(t, e.vaultAddress)}:${r(t, n)}`;
|
|
19
|
+
s.set(a, {
|
|
20
|
+
record: e,
|
|
21
|
+
chainId: t,
|
|
22
|
+
token: n,
|
|
23
|
+
reason: i
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
return await Promise.all(t.map(async (t) => {
|
|
27
|
+
await Promise.all(a(t.network).filter(e).map(async (e) => {
|
|
28
|
+
(await d(e, t.vaultAddress)).filter(({ is2022Program: e }) => e).forEach(({ token: n }) => c(t, e, n, i.NotShieldable));
|
|
34
29
|
}));
|
|
35
|
-
})),
|
|
36
|
-
let r =
|
|
37
|
-
r &&
|
|
38
|
-
}), [...
|
|
39
|
-
},
|
|
30
|
+
})), o.forEach((e) => {
|
|
31
|
+
let r = t.find((t) => n(e.chainId, t.vaultAddress, e.vaultAddress));
|
|
32
|
+
r && c(r, e.chainId, e.token, i.RiskySender);
|
|
33
|
+
}), [...s.values()];
|
|
34
|
+
}, p = async (e, n) => {
|
|
40
35
|
try {
|
|
41
|
-
return (await Promise.all((await
|
|
36
|
+
return (await Promise.all((await f(e, n)).map(async (e) => {
|
|
42
37
|
try {
|
|
43
|
-
let [t, n] = await Promise.all([
|
|
44
|
-
return t && !
|
|
38
|
+
let [t, n] = await Promise.all([o(e.chainId, e.token), u(e.record.vaultAddress, e.chainId, e.token)]);
|
|
39
|
+
return t && !s(t) && n > 0n ? {
|
|
45
40
|
record: e.record,
|
|
46
41
|
token: t,
|
|
47
42
|
amount: n,
|
|
48
43
|
reason: e.reason
|
|
49
44
|
} : void 0;
|
|
50
|
-
} catch (
|
|
51
|
-
|
|
45
|
+
} catch (n) {
|
|
46
|
+
t.error(`receive-vault scan: balance lookup failed for chain ${e.chainId} token ${e.token}`, n);
|
|
52
47
|
return;
|
|
53
48
|
}
|
|
54
49
|
}))).filter((e) => !!e);
|
|
55
50
|
} catch (e) {
|
|
56
|
-
return
|
|
51
|
+
return t.log("Error fetching vault's blocked balances", e), [];
|
|
57
52
|
}
|
|
58
53
|
};
|
|
59
54
|
//#endregion
|
|
60
|
-
export {
|
|
55
|
+
export { p as getReceiveVaultBlockedFunds };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../../_virtual/_rolldown/runtime.cjs`);let t=require(`ethers`),n=require(`@solana/web3.js`),r=require(`bs58`);r=e.__toESM(r);let i=require(`tweetnacl`);i=e.__toESM(i);var a=Buffer.from(`hinkal_receive_vault`),o=Buffer.from(`HINKAL_RECEIVE_OUTPUT`),s=Buffer.from(`HINKAL_RECEIVE_RECOVER`),c=Buffer.from(`hinkal_receive_recovery`),l=e=>t.ethers.getBytes(e),u=e=>{if(e<0n||e>255n)throw Error(`receive vault: version must fit in u8`);return Uint8Array.of(Number(e))},d=e=>t.ethers.getBytes(t.ethers.toBeHex(e,32)),f=e=>l(t.ethers.sha256(t.ethers.concat([d(e.recipient.H0x),d(e.recipient.H0y),d(e.recipient.H1x),d(e.recipient.H1y),d(e.recipient.stealthAddress),new n.PublicKey(e.owner).toBytes(),u(e.version)]))),p=(e,t,r)=>n.PublicKey.findProgramAddressSync([a,new n.PublicKey(r).toBytes(),Buffer.from(f(e))],new n.PublicKey(t))[0].toBase58(),m=(e,t,r)=>n.PublicKey.findProgramAddressSync([c,new n.PublicKey(t).toBytes(),Buffer.from(r)],new n.PublicKey(e))[0],h=(e,r,i,a)=>l(t.ethers.sha256(t.ethers.concat([o,new n.PublicKey(e).toBytes(),new n.PublicKey(r).toBytes(),new n.PublicKey(i).toBytes(),t.ethers.sha256(a)]))),g=(e,r,i,a,o,c)=>{if(c<0n||c>9223372036854775807n)throw Error(`receive vault: invalid deadline`);let u=new Uint8Array(8);return new DataView(u.buffer).setBigInt64(0,c,!0),l(t.ethers.sha256(t.ethers.concat([s,new n.PublicKey(e).toBytes(),new n.PublicKey(r).toBytes(),new n.PublicKey(i).toBytes(),new n.PublicKey(a).toBytes(),new n.PublicKey(o).toBytes(),u])))},_=(e,t)=>r.default.encode(i.default.sign.detached(t,e.secretKey));exports.computeSolanaReceiveVaultAddress=p,exports.computeSolanaRecoveryMarkerAddress=m,exports.getSolanaReceiveVaultOutputDigest=h,exports.getSolanaReceiveVaultParamsHash=f,exports.getSolanaReceiveVaultRecoveryDigest=g,exports.signSolanaReceiveVaultDigest=_;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Keypair, PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { ReceiveVaultParams } from '../../types/receive-vault.types';
|
|
3
|
+
export declare const getSolanaReceiveVaultParamsHash: (params: ReceiveVaultParams) => Uint8Array;
|
|
4
|
+
export declare const computeSolanaReceiveVaultAddress: (params: ReceiveVaultParams, programId: string, originalDeployer: string) => string;
|
|
5
|
+
export declare const computeSolanaRecoveryMarkerAddress: (programId: string, originalDeployer: string, digest: Uint8Array) => PublicKey;
|
|
6
|
+
export declare const getSolanaReceiveVaultOutputDigest: (programId: string, originalDeployer: string, vault: string, encryptedOutput: string) => Uint8Array;
|
|
7
|
+
export declare const getSolanaReceiveVaultRecoveryDigest: (programId: string, originalDeployer: string, vault: string, mint: string, to: string, deadline: bigint) => Uint8Array;
|
|
8
|
+
export declare const signSolanaReceiveVaultDigest: (owner: Keypair, digest: Uint8Array) => string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ethers as e } from "ethers";
|
|
2
|
+
import { PublicKey as t } from "@solana/web3.js";
|
|
3
|
+
import n from "bs58";
|
|
4
|
+
import r from "tweetnacl";
|
|
5
|
+
//#region libs/shared/common/src/functions/utils/receive-vault-solana.utils.ts
|
|
6
|
+
var i = Buffer.from("hinkal_receive_vault"), a = Buffer.from("HINKAL_RECEIVE_OUTPUT"), o = Buffer.from("HINKAL_RECEIVE_RECOVER"), s = Buffer.from("hinkal_receive_recovery"), c = (t) => e.getBytes(t), l = (e) => {
|
|
7
|
+
if (e < 0n || e > 255n) throw Error("receive vault: version must fit in u8");
|
|
8
|
+
return Uint8Array.of(Number(e));
|
|
9
|
+
}, u = (t) => e.getBytes(e.toBeHex(t, 32)), d = (n) => c(e.sha256(e.concat([
|
|
10
|
+
u(n.recipient.H0x),
|
|
11
|
+
u(n.recipient.H0y),
|
|
12
|
+
u(n.recipient.H1x),
|
|
13
|
+
u(n.recipient.H1y),
|
|
14
|
+
u(n.recipient.stealthAddress),
|
|
15
|
+
new t(n.owner).toBytes(),
|
|
16
|
+
l(n.version)
|
|
17
|
+
]))), f = (e, n, r) => t.findProgramAddressSync([
|
|
18
|
+
i,
|
|
19
|
+
new t(r).toBytes(),
|
|
20
|
+
Buffer.from(d(e))
|
|
21
|
+
], new t(n))[0].toBase58(), p = (e, n, r) => t.findProgramAddressSync([
|
|
22
|
+
s,
|
|
23
|
+
new t(n).toBytes(),
|
|
24
|
+
Buffer.from(r)
|
|
25
|
+
], new t(e))[0], m = (n, r, i, o) => c(e.sha256(e.concat([
|
|
26
|
+
a,
|
|
27
|
+
new t(n).toBytes(),
|
|
28
|
+
new t(r).toBytes(),
|
|
29
|
+
new t(i).toBytes(),
|
|
30
|
+
e.sha256(o)
|
|
31
|
+
]))), h = (n, r, i, a, s, l) => {
|
|
32
|
+
if (l < 0n || l > 9223372036854775807n) throw Error("receive vault: invalid deadline");
|
|
33
|
+
let u = new Uint8Array(8);
|
|
34
|
+
return new DataView(u.buffer).setBigInt64(0, l, !0), c(e.sha256(e.concat([
|
|
35
|
+
o,
|
|
36
|
+
new t(n).toBytes(),
|
|
37
|
+
new t(r).toBytes(),
|
|
38
|
+
new t(i).toBytes(),
|
|
39
|
+
new t(a).toBytes(),
|
|
40
|
+
new t(s).toBytes(),
|
|
41
|
+
u
|
|
42
|
+
])));
|
|
43
|
+
}, g = (e, t) => n.encode(r.sign.detached(t, e.secretKey));
|
|
44
|
+
//#endregion
|
|
45
|
+
export { f as computeSolanaReceiveVaultAddress, p as computeSolanaRecoveryMarkerAddress, m as getSolanaReceiveVaultOutputDigest, d as getSolanaReceiveVaultParamsHash, h as getSolanaReceiveVaultRecoveryDigest, g as signSolanaReceiveVaultDigest };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../data-structures/crypto-keys/keys.cjs`),r=require(`../../data-structures/utxo/Utxo.cjs`),i=require(`./tron.utils.cjs`);require(`../../data-structures/crypto-keys/index.cjs`);let
|
|
2
|
-
32`),
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../data-structures/crypto-keys/keys.cjs`),r=require(`../../data-structures/utxo/Utxo.cjs`),i=require(`./tron.utils.cjs`),a=require(`../../types/ethereum-network.types.cjs`),o=require(`../../types/receive-vault.types.cjs`);require(`../../data-structures/crypto-keys/index.cjs`);const s=require(`../web3/getContractMetadata.cjs`),c=require(`./receive-vault-solana.utils.cjs`);let l=require(`ethers`),u=require(`@solana/web3.js`);var d=`HINKAL_RECEIVE_V1`,f=`HINKAL_RECEIVE_RECOVERY_V1`,p=`HINKAL_RECEIVE_SOLANA_OWNER_V1`,m=`HINKAL_RECEIVE_RECOVER`,h=`HINKAL_RECEIVE_OUTPUT`,g=`HINKAL_RECEIVE_ACCOUNT_V1`,_=`HINKAL_RECEIVE_VAULT_ACCOUNT`,v=e=>s.getContractWithFetcherByChainId(e,a.ContractType.ReceiveVaultFactoryContract),y=new Map,b=(e,t)=>{let n=l.ethers.keccak256(l.ethers.toUtf8Bytes(`${f}:${e.getShieldedPrivateKey()}:${t.index}`));return new l.ethers.Wallet(n)},x=(e,t)=>u.Keypair.fromSeed(l.ethers.getBytes(l.ethers.keccak256(l.ethers.toUtf8Bytes(`${p}:${e.getShieldedPrivateKey()}:${t.index}`)))),S=t=>{let n=e.networkRegistry[t]?.contractData?.originalDeployer;if(!n)throw Error(`receive vault: no original deployer on chain ${t}`);return n},C=e=>n.UserKeys.getEncryptionKeyPair(e.getShieldedPrivateKey()).publicKey,w=(e,i)=>{let a=e.getShieldedPrivateKey(),s=BigInt(l.ethers.keccak256(l.ethers.toUtf8Bytes(`${d}:${a}:${i.index}`))),c=new r.Utxo({amount:0n,erc20TokenAddress:t.zeroAddress,nullifyingKey:a,randomization:n.UserKeys.findCorrectRandomization(s,a),spendingPublicKey:e.getSpendingKeyPair().pubSpendingBJJPoint}),{H0:u}=c;if(!u)throw Error(`receive vault: H0 is not set`);let f=n.UserKeys.getH1FromH0(u,a),p=i.network===o.ReceiveVaultNetwork.Solana?x(e,i).publicKey.toBase58():b(e,i).address;return{recipient:{H0x:u[0],H0y:u[1],H1x:f[0],H1y:f[1],stealthAddress:BigInt(c.getStealthAddress())},owner:p,version:BigInt(i.version)}},T=e=>l.ethers.AbiCoder.defaultAbiCoder().encode([`tuple(tuple(uint256,uint256,uint256,uint256,uint256),address,uint256)`],[[[e.recipient.H0x,e.recipient.H0y,e.recipient.H1x,e.recipient.H1y,e.recipient.stealthAddress],e.owner,e.version]]),E=t=>e.isTronLike(t)?`0x41`:`0xff`,D=e=>[[e.recipient.H0x,e.recipient.H0y,e.recipient.H1x,e.recipient.H1y,e.recipient.stealthAddress],e.owner,e.version],O=(e,t,n,r)=>l.ethers.getAddress(l.ethers.dataSlice(l.ethers.solidityPackedKeccak256([`bytes1`,`address`,`bytes32`,`bytes32`],[E(r),i.addressToHexFormat(t),l.ethers.keccak256(T(e)),n]),12)),k=t=>(e.isSolanaLike(t)?e.networkRegistry[t]?.contractData?.hinkalAddress:e.networkRegistry[t]?.contractData?.receiveVaultFactoryAddress)||void 0,A=e=>!!k(e),j=t=>e.isSolanaLike(t)?o.ReceiveVaultNetwork.Solana:e.isTronLike(t)?o.ReceiveVaultNetwork.Tron:o.ReceiveVaultNetwork.Evm,M=t=>e.FRONT_END_SUPPORTED_CHAINS.filter(e=>A(e)&&j(e)===t),N=e=>{let[t]=M(e);if(t===void 0)throw Error(`receive vault: no supported chain for network ${e}`);return t},P=async(e,t)=>{let n=`${e}:${t}`,r=y.get(n);if(r)return r;let i=await v(e).vaultInitCodeHash(t);return y.set(n,i),i},F=async e=>e===o.ReceiveVaultNetwork.Solana?0n:await v(N(e)).vaultVersionCount()-1n,I=async(t,n)=>{let r=k(n);if(!r)throw Error(`receive vault: no factory on chain ${n}`);if(e.isSolanaLike(n))return c.computeSolanaReceiveVaultAddress(t,r,S(n));let a=O(t,r,await P(n,t.version),n);return e.isTronLike(n)?i.evmHexToTronBase58Address(a):a},L=async(e,t)=>({...t,vaultAddress:await I(w(e,t),N(t.network))}),R=e=>({recipient:{H0x:e.recipient.H0x.toString(),H0y:e.recipient.H0y.toString(),H1x:e.recipient.H1x.toString(),H1y:e.recipient.H1y.toString(),stealthAddress:e.recipient.stealthAddress.toString()},owner:e.owner,version:e.version.toString()}),z=e=>new l.ethers.Wallet(l.ethers.keccak256(l.ethers.toUtf8Bytes(`${g}:${e.getShieldedPrivateKey()}`))),B=e=>z(e).address,V=(e,t)=>l.ethers.keccak256(l.ethers.solidityPacked([`string`,`address`,`uint256`],[_,e,t])),H=async(e,t)=>{let n=z(e),r=V(n.address,t);return{accountKey:n.address,deadline:t.toString(),signature:await n.signMessage(l.ethers.getBytes(r))}},U=(e,t,n,r)=>l.ethers.keccak256(l.ethers.solidityPacked([`string`,`uint256`,`address`,`address`,`bytes32`],[h,BigInt(e),i.addressToHexFormat(t),i.addressToHexFormat(n),l.ethers.keccak256(r)])),W=async(t,n,r,i)=>{let a=k(i);if(!a)throw Error(`receive vault: no factory on chain ${i}`);if(e.isSolanaLike(i)){let e=c.getSolanaReceiveVaultOutputDigest(a,S(i),n.vaultAddress,r);return c.signSolanaReceiveVaultDigest(x(t,n),e)}let o=U(i,a,n.vaultAddress,r);return b(t,n).signMessage(l.ethers.getBytes(o))},G=(t,n,r,a,o,s)=>{let c=l.ethers.keccak256(l.ethers.solidityPacked([`string`,`uint256`,`address`,`address`,`address`,`address`,`uint256`],[m,BigInt(t),i.addressToHexFormat(n),i.addressToHexFormat(r),i.addressToHexFormat(a),i.addressToHexFormat(o),s]));return e.isTronLike(t)?l.ethers.keccak256(l.ethers.concat([l.ethers.toUtf8Bytes(`TRON Signed Message:
|
|
2
|
+
32`),c])):c},K=async(t,n,r,i,a,o)=>{let s=k(i);if(!s)throw Error(`receive vault: no factory on chain ${i}`);if(e.isSolanaLike(i)){let e=c.getSolanaReceiveVaultRecoveryDigest(s,S(i),n.vaultAddress,r,a,o);return c.signSolanaReceiveVaultDigest(x(t,n),e)}let u=G(i,s,n.vaultAddress,r,a,o),d=b(t,n);return e.isTronLike(i)?new l.ethers.SigningKey(d.privateKey).sign(u).serialized:d.signMessage(l.ethers.getBytes(u))};exports.buildReceiveVaultRecord=L,exports.computeReceiveVaultAddress=O,exports.encodeReceiveVaultParams=T,exports.getReceiveVaultAccountKey=B,exports.getReceiveVaultAddress=I,exports.getReceiveVaultCanonicalChainId=N,exports.getReceiveVaultCurrentVersion=F,exports.getReceiveVaultEncryptionKey=C,exports.getReceiveVaultFactoryAddress=k,exports.getReceiveVaultInitCodeHash=P,exports.getReceiveVaultOutputDigest=U,exports.getReceiveVaultParams=w,exports.getReceiveVaultRecoveryDigest=G,exports.getReceiveVaultRecoveryWallet=b,exports.getReceiveVaultSolanaOwner=x,exports.getSolanaOriginalDeployer=S,exports.isReceiveVaultSupported=A,exports.receiveVaultChainsForNetwork=M,exports.receiveVaultNetworkOf=j,exports.receiveVaultParamsToTuple=D,exports.serializeReceiveVaultParams=R,exports.signReceiveVaultAccount=H,exports.signReceiveVaultOutput=W,exports.signReceiveVaultRecovery=K;
|
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
|
+
import { Keypair } from '@solana/web3.js';
|
|
2
3
|
import { UserKeys } from '../../data-structures/crypto-keys';
|
|
3
|
-
import { ReceiveVaultAccountProof, ReceiveVaultParams, ReceiveVaultRecord } from '../../types/receive-vault.types';
|
|
4
|
+
import { ReceiveVaultAccountProof, ReceiveVaultNetwork, ReceiveVaultParams, ReceiveVaultRecord } from '../../types/receive-vault.types';
|
|
4
5
|
export type ReceiveVaultTerms = Omit<ReceiveVaultRecord, 'vaultAddress'>;
|
|
5
|
-
/** A ceiling, not a price: the relayer still charges what the settlement costs. It only has to stay
|
|
6
|
-
* above that while gas moves under an unspent address. */
|
|
7
|
-
export declare const getReceiveVaultFeeCeiling: (quotedFlatFee: bigint) => bigint;
|
|
8
|
-
export declare const getReceiveVaultExpiry: () => bigint;
|
|
9
6
|
export declare const getReceiveVaultRecoveryWallet: (userKeys: UserKeys, terms: ReceiveVaultTerms) => ethers.Wallet;
|
|
7
|
+
export declare const getReceiveVaultSolanaOwner: (userKeys: UserKeys, terms: ReceiveVaultTerms) => Keypair;
|
|
8
|
+
export declare const getSolanaOriginalDeployer: (chainId: number) => string;
|
|
10
9
|
export declare const getReceiveVaultEncryptionKey: (userKeys: UserKeys) => string;
|
|
11
10
|
export declare const getReceiveVaultParams: (userKeys: UserKeys, terms: ReceiveVaultTerms) => ReceiveVaultParams;
|
|
12
11
|
export declare const encodeReceiveVaultParams: (params: ReceiveVaultParams) => string;
|
|
13
|
-
export declare const receiveVaultParamsToTuple: (params: ReceiveVaultParams) => (string |
|
|
12
|
+
export declare const receiveVaultParamsToTuple: (params: ReceiveVaultParams) => (string | bigint | bigint[])[];
|
|
14
13
|
export declare const computeReceiveVaultAddress: (params: ReceiveVaultParams, factoryAddress: string, initCodeHash: string, chainId: number) => string;
|
|
15
14
|
export declare const getReceiveVaultFactoryAddress: (chainId: number) => string | undefined;
|
|
16
|
-
export declare const getReceiveVaultInitCodeHash: (chainId: number) => string;
|
|
17
15
|
export declare const isReceiveVaultSupported: (chainId: number) => boolean;
|
|
18
|
-
export declare const
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const
|
|
16
|
+
export declare const receiveVaultNetworkOf: (chainId: number) => ReceiveVaultNetwork;
|
|
17
|
+
export declare const receiveVaultChainsForNetwork: (network: ReceiveVaultNetwork) => number[];
|
|
18
|
+
export declare const getReceiveVaultCanonicalChainId: (network: ReceiveVaultNetwork) => number;
|
|
19
|
+
export declare const getReceiveVaultInitCodeHash: (chainId: number, version: bigint) => Promise<string>;
|
|
20
|
+
export declare const getReceiveVaultCurrentVersion: (network: ReceiveVaultNetwork) => Promise<bigint>;
|
|
21
|
+
export declare const getReceiveVaultAddress: (params: ReceiveVaultParams, chainId: number) => Promise<string>;
|
|
22
|
+
export declare const buildReceiveVaultRecord: (userKeys: UserKeys, terms: ReceiveVaultTerms) => Promise<ReceiveVaultRecord>;
|
|
21
23
|
export declare const serializeReceiveVaultParams: (params: ReceiveVaultParams) => ReceiveVaultParams<string>;
|
|
22
24
|
export declare const deserializeReceiveVaultParams: (params: ReceiveVaultParams<string>) => ReceiveVaultParams;
|
|
23
25
|
export declare const getReceiveVaultRecipientInfo: (params: ReceiveVaultParams, encryptionKey: string) => string;
|
|
24
26
|
export declare const getReceiveVaultAccountKey: (userKeys: UserKeys) => string;
|
|
25
27
|
export declare const signReceiveVaultAccount: (userKeys: UserKeys, deadline: bigint) => Promise<ReceiveVaultAccountProof>;
|
|
26
28
|
export declare const getReceiveVaultOutputDigest: (chainId: number, factoryAddress: string, vault: string, encryptedOutput: string) => string;
|
|
27
|
-
export declare const signReceiveVaultOutput: (userKeys: UserKeys, record: ReceiveVaultRecord, encryptedOutput: string) => Promise<string>;
|
|
29
|
+
export declare const signReceiveVaultOutput: (userKeys: UserKeys, record: ReceiveVaultRecord, encryptedOutput: string, chainId: number) => Promise<string>;
|
|
28
30
|
export declare const getReceiveVaultRecoveryDigest: (chainId: number, factoryAddress: string, vault: string, token: string, to: string, deadline: bigint) => string;
|
|
29
31
|
export declare const signReceiveVaultRecovery: (userKeys: UserKeys, record: ReceiveVaultRecord, token: string, chainId: number, to: string, deadline: bigint) => Promise<string>;
|
|
@@ -1,39 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { UserKeys as
|
|
4
|
-
import { Utxo as
|
|
5
|
-
import { addressToHexFormat as
|
|
1
|
+
import { FRONT_END_SUPPORTED_CHAINS as e, isSolanaLike as t, isTronLike as n, networkRegistry as r } from "../../constants/chains.constants.mjs";
|
|
2
|
+
import { zeroAddress as i } from "../../constants/protocol.constants.mjs";
|
|
3
|
+
import { UserKeys as a } from "../../data-structures/crypto-keys/keys.mjs";
|
|
4
|
+
import { Utxo as o } from "../../data-structures/utxo/Utxo.mjs";
|
|
5
|
+
import { addressToHexFormat as s, evmHexToTronBase58Address as c } from "./tron.utils.mjs";
|
|
6
|
+
import { ContractType as l } from "../../types/ethereum-network.types.mjs";
|
|
7
|
+
import { ReceiveVaultNetwork as u } from "../../types/receive-vault.types.mjs";
|
|
6
8
|
import "../../data-structures/crypto-keys/index.mjs";
|
|
7
|
-
import {
|
|
9
|
+
import { getContractWithFetcherByChainId as d } from "../web3/getContractMetadata.mjs";
|
|
10
|
+
import { computeSolanaReceiveVaultAddress as f, getSolanaReceiveVaultOutputDigest as p, getSolanaReceiveVaultRecoveryDigest as m, signSolanaReceiveVaultDigest as h } from "./receive-vault-solana.utils.mjs";
|
|
11
|
+
import { ethers as g } from "ethers";
|
|
12
|
+
import { Keypair as _ } from "@solana/web3.js";
|
|
8
13
|
//#region libs/shared/common/src/functions/utils/receive-vault.utils.ts
|
|
9
|
-
var
|
|
10
|
-
let n =
|
|
11
|
-
return new
|
|
12
|
-
},
|
|
13
|
-
let
|
|
14
|
+
var v = "HINKAL_RECEIVE_V1", y = "HINKAL_RECEIVE_RECOVERY_V1", b = "HINKAL_RECEIVE_SOLANA_OWNER_V1", x = "HINKAL_RECEIVE_RECOVER", S = "HINKAL_RECEIVE_OUTPUT", C = "HINKAL_RECEIVE_ACCOUNT_V1", w = "HINKAL_RECEIVE_VAULT_ACCOUNT", T = (e) => d(e, l.ReceiveVaultFactoryContract), E = /* @__PURE__ */ new Map(), D = (e, t) => {
|
|
15
|
+
let n = g.keccak256(g.toUtf8Bytes(`${y}:${e.getShieldedPrivateKey()}:${t.index}`));
|
|
16
|
+
return new g.Wallet(n);
|
|
17
|
+
}, O = (e, t) => _.fromSeed(g.getBytes(g.keccak256(g.toUtf8Bytes(`${b}:${e.getShieldedPrivateKey()}:${t.index}`)))), k = (e) => {
|
|
18
|
+
let t = r[e]?.contractData?.originalDeployer;
|
|
19
|
+
if (!t) throw Error(`receive vault: no original deployer on chain ${e}`);
|
|
20
|
+
return t;
|
|
21
|
+
}, A = (e) => a.getEncryptionKeyPair(e.getShieldedPrivateKey()).publicKey, j = (e, t) => {
|
|
22
|
+
let n = e.getShieldedPrivateKey(), r = BigInt(g.keccak256(g.toUtf8Bytes(`${v}:${n}:${t.index}`))), s = new o({
|
|
14
23
|
amount: 0n,
|
|
15
|
-
erc20TokenAddress:
|
|
24
|
+
erc20TokenAddress: i,
|
|
16
25
|
nullifyingKey: n,
|
|
17
|
-
randomization:
|
|
26
|
+
randomization: a.findCorrectRandomization(r, n),
|
|
18
27
|
spendingPublicKey: e.getSpendingKeyPair().pubSpendingBJJPoint
|
|
19
|
-
}), { H0:
|
|
20
|
-
if (!
|
|
21
|
-
let
|
|
28
|
+
}), { H0: c } = s;
|
|
29
|
+
if (!c) throw Error("receive vault: H0 is not set");
|
|
30
|
+
let l = a.getH1FromH0(c, n), d = t.network === u.Solana ? O(e, t).publicKey.toBase58() : D(e, t).address;
|
|
22
31
|
return {
|
|
23
32
|
recipient: {
|
|
24
|
-
H0x:
|
|
25
|
-
H0y:
|
|
26
|
-
H1x:
|
|
27
|
-
H1y:
|
|
28
|
-
stealthAddress: BigInt(
|
|
33
|
+
H0x: c[0],
|
|
34
|
+
H0y: c[1],
|
|
35
|
+
H1x: l[0],
|
|
36
|
+
H1y: l[1],
|
|
37
|
+
stealthAddress: BigInt(s.getStealthAddress())
|
|
29
38
|
},
|
|
30
|
-
owner:
|
|
31
|
-
|
|
32
|
-
maxFlatFee: BigInt(t.maxFlatFee),
|
|
33
|
-
maxVariableRate: Number(i),
|
|
34
|
-
expiry: BigInt(t.expiry)
|
|
39
|
+
owner: d,
|
|
40
|
+
version: BigInt(t.version)
|
|
35
41
|
};
|
|
36
|
-
},
|
|
42
|
+
}, M = (e) => g.AbiCoder.defaultAbiCoder().encode(["tuple(tuple(uint256,uint256,uint256,uint256,uint256),address,uint256)"], [[
|
|
37
43
|
[
|
|
38
44
|
e.recipient.H0x,
|
|
39
45
|
e.recipient.H0y,
|
|
@@ -42,11 +48,8 @@ var d = "HINKAL_RECEIVE_V1", f = "HINKAL_RECEIVE_RECOVERY_V1", p = "HINKAL_RECEI
|
|
|
42
48
|
e.recipient.stealthAddress
|
|
43
49
|
],
|
|
44
50
|
e.owner,
|
|
45
|
-
e.
|
|
46
|
-
|
|
47
|
-
e.maxVariableRate,
|
|
48
|
-
e.expiry
|
|
49
|
-
]]), w = (t) => e(t) ? "0x41" : "0xff", T = (e) => [
|
|
51
|
+
e.version
|
|
52
|
+
]]), N = (e) => n(e) ? "0x41" : "0xff", P = (e) => [
|
|
50
53
|
[
|
|
51
54
|
e.recipient.H0x,
|
|
52
55
|
e.recipient.H0y,
|
|
@@ -55,29 +58,36 @@ var d = "HINKAL_RECEIVE_V1", f = "HINKAL_RECEIVE_RECOVERY_V1", p = "HINKAL_RECEI
|
|
|
55
58
|
e.recipient.stealthAddress
|
|
56
59
|
],
|
|
57
60
|
e.owner,
|
|
58
|
-
e.
|
|
59
|
-
|
|
60
|
-
e.maxVariableRate,
|
|
61
|
-
e.expiry
|
|
62
|
-
], E = (e, t, n, r) => u.getAddress(u.dataSlice(u.solidityPackedKeccak256([
|
|
61
|
+
e.version
|
|
62
|
+
], F = (e, t, n, r) => g.getAddress(g.dataSlice(g.solidityPackedKeccak256([
|
|
63
63
|
"bytes1",
|
|
64
64
|
"address",
|
|
65
65
|
"bytes32",
|
|
66
66
|
"bytes32"
|
|
67
67
|
], [
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
N(r),
|
|
69
|
+
s(t),
|
|
70
|
+
g.keccak256(M(e)),
|
|
71
71
|
n
|
|
72
|
-
]), 12)),
|
|
73
|
-
let
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
]), 12)), I = (e) => (t(e) ? r[e]?.contractData?.hinkalAddress : r[e]?.contractData?.receiveVaultFactoryAddress) || void 0, L = (e) => !!I(e), R = (e) => t(e) ? u.Solana : n(e) ? u.Tron : u.Evm, z = (t) => e.filter((e) => L(e) && R(e) === t), B = (e) => {
|
|
73
|
+
let [t] = z(e);
|
|
74
|
+
if (t === void 0) throw Error(`receive vault: no supported chain for network ${e}`);
|
|
75
|
+
return t;
|
|
76
|
+
}, V = async (e, t) => {
|
|
77
|
+
let n = `${e}:${t}`, r = E.get(n);
|
|
78
|
+
if (r) return r;
|
|
79
|
+
let i = await T(e).vaultInitCodeHash(t);
|
|
80
|
+
return E.set(n, i), i;
|
|
81
|
+
}, H = async (e) => e === u.Solana ? 0n : await T(B(e)).vaultVersionCount() - 1n, U = async (e, r) => {
|
|
82
|
+
let i = I(r);
|
|
83
|
+
if (!i) throw Error(`receive vault: no factory on chain ${r}`);
|
|
84
|
+
if (t(r)) return f(e, i, k(r));
|
|
85
|
+
let a = F(e, i, await V(r, e.version), r);
|
|
86
|
+
return n(r) ? c(a) : a;
|
|
87
|
+
}, W = async (e, t) => ({
|
|
78
88
|
...t,
|
|
79
|
-
vaultAddress:
|
|
80
|
-
}),
|
|
89
|
+
vaultAddress: await U(j(e, t), B(t.network))
|
|
90
|
+
}), G = (e) => ({
|
|
81
91
|
recipient: {
|
|
82
92
|
H0x: e.recipient.H0x.toString(),
|
|
83
93
|
H0y: e.recipient.H0y.toString(),
|
|
@@ -86,44 +96,45 @@ var d = "HINKAL_RECEIVE_V1", f = "HINKAL_RECEIVE_RECOVERY_V1", p = "HINKAL_RECEI
|
|
|
86
96
|
stealthAddress: e.recipient.stealthAddress.toString()
|
|
87
97
|
},
|
|
88
98
|
owner: e.owner,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
maxVariableRate: e.maxVariableRate,
|
|
92
|
-
expiry: e.expiry.toString()
|
|
93
|
-
}), I = (e) => new u.Wallet(u.keccak256(u.toUtf8Bytes(`${h}:${e.getShieldedPrivateKey()}`))), L = (e) => I(e).address, R = (e, t) => u.keccak256(u.solidityPacked([
|
|
99
|
+
version: e.version.toString()
|
|
100
|
+
}), K = (e) => new g.Wallet(g.keccak256(g.toUtf8Bytes(`${C}:${e.getShieldedPrivateKey()}`))), q = (e) => K(e).address, J = (e, t) => g.keccak256(g.solidityPacked([
|
|
94
101
|
"string",
|
|
95
102
|
"address",
|
|
96
103
|
"uint256"
|
|
97
104
|
], [
|
|
98
|
-
|
|
105
|
+
w,
|
|
99
106
|
e,
|
|
100
107
|
t
|
|
101
|
-
])),
|
|
102
|
-
let n =
|
|
108
|
+
])), Y = async (e, t) => {
|
|
109
|
+
let n = K(e), r = J(n.address, t);
|
|
103
110
|
return {
|
|
104
111
|
accountKey: n.address,
|
|
105
112
|
deadline: t.toString(),
|
|
106
|
-
signature: await n.signMessage(
|
|
113
|
+
signature: await n.signMessage(g.getBytes(r))
|
|
107
114
|
};
|
|
108
|
-
},
|
|
115
|
+
}, X = (e, t, n, r) => g.keccak256(g.solidityPacked([
|
|
109
116
|
"string",
|
|
110
117
|
"uint256",
|
|
111
118
|
"address",
|
|
112
119
|
"address",
|
|
113
120
|
"bytes32"
|
|
114
121
|
], [
|
|
115
|
-
|
|
122
|
+
S,
|
|
116
123
|
BigInt(e),
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
])),
|
|
121
|
-
let
|
|
122
|
-
if (!
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
s(t),
|
|
125
|
+
s(n),
|
|
126
|
+
g.keccak256(r)
|
|
127
|
+
])), Z = async (e, n, r, i) => {
|
|
128
|
+
let a = I(i);
|
|
129
|
+
if (!a) throw Error(`receive vault: no factory on chain ${i}`);
|
|
130
|
+
if (t(i)) {
|
|
131
|
+
let t = p(a, k(i), n.vaultAddress, r);
|
|
132
|
+
return h(O(e, n), t);
|
|
133
|
+
}
|
|
134
|
+
let o = X(i, a, n.vaultAddress, r);
|
|
135
|
+
return D(e, n).signMessage(g.getBytes(o));
|
|
136
|
+
}, Q = (e, t, r, i, a, o) => {
|
|
137
|
+
let c = g.keccak256(g.solidityPacked([
|
|
127
138
|
"string",
|
|
128
139
|
"uint256",
|
|
129
140
|
"address",
|
|
@@ -132,20 +143,24 @@ var d = "HINKAL_RECEIVE_V1", f = "HINKAL_RECEIVE_RECOVERY_V1", p = "HINKAL_RECEI
|
|
|
132
143
|
"address",
|
|
133
144
|
"uint256"
|
|
134
145
|
], [
|
|
135
|
-
|
|
136
|
-
BigInt(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
146
|
+
x,
|
|
147
|
+
BigInt(e),
|
|
148
|
+
s(t),
|
|
149
|
+
s(r),
|
|
150
|
+
s(i),
|
|
151
|
+
s(a),
|
|
141
152
|
o
|
|
142
153
|
]));
|
|
143
|
-
return e
|
|
144
|
-
},
|
|
145
|
-
let
|
|
146
|
-
if (!
|
|
147
|
-
|
|
148
|
-
|
|
154
|
+
return n(e) ? g.keccak256(g.concat([g.toUtf8Bytes("TRON Signed Message:\n32"), c])) : c;
|
|
155
|
+
}, $ = async (e, r, i, a, o, s) => {
|
|
156
|
+
let c = I(a);
|
|
157
|
+
if (!c) throw Error(`receive vault: no factory on chain ${a}`);
|
|
158
|
+
if (t(a)) {
|
|
159
|
+
let t = m(c, k(a), r.vaultAddress, i, o, s);
|
|
160
|
+
return h(O(e, r), t);
|
|
161
|
+
}
|
|
162
|
+
let l = Q(a, c, r.vaultAddress, i, o, s), u = D(e, r);
|
|
163
|
+
return n(a) ? new g.SigningKey(u.privateKey).sign(l).serialized : u.signMessage(g.getBytes(l));
|
|
149
164
|
};
|
|
150
165
|
//#endregion
|
|
151
|
-
export {
|
|
166
|
+
export { W as buildReceiveVaultRecord, F as computeReceiveVaultAddress, M as encodeReceiveVaultParams, q as getReceiveVaultAccountKey, U as getReceiveVaultAddress, B as getReceiveVaultCanonicalChainId, H as getReceiveVaultCurrentVersion, A as getReceiveVaultEncryptionKey, I as getReceiveVaultFactoryAddress, V as getReceiveVaultInitCodeHash, X as getReceiveVaultOutputDigest, j as getReceiveVaultParams, Q as getReceiveVaultRecoveryDigest, D as getReceiveVaultRecoveryWallet, O as getReceiveVaultSolanaOwner, k as getSolanaOriginalDeployer, L as isReceiveVaultSupported, z as receiveVaultChainsForNetwork, R as receiveVaultNetworkOf, P as receiveVaultParamsToTuple, G as serializeReceiveVaultParams, Y as signReceiveVaultAccount, Z as signReceiveVaultOutput, $ as signReceiveVaultRecovery };
|
|
@@ -2,3 +2,4 @@ import { ERC20Token } from '../../types/token.types';
|
|
|
2
2
|
export declare const checkTokensForShielding: (chainId: number, erc20Addresses: string[]) => Promise<string[]>;
|
|
3
3
|
export declare const validateAndGetChainId: (tokens: ERC20Token[]) => number;
|
|
4
4
|
export declare const isSameERC20Token: (a?: ERC20Token, b?: ERC20Token) => boolean;
|
|
5
|
+
export declare const getTokenKey: (token: ERC20Token) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`);require(`../../data-structures/http/index.cjs`),require(`./tron.utils.cjs`);const n=require(`./create-provider.cjs`);require(`./publicBalance.utils.cjs`),require(`../../API/evm-token-assets.cjs`);let r=require(`@solana/web3.js`),i=require(`@solana/spl-token`);var a=async(a,o)=>{let{rpcUrl:s}=e.networkRegistry[a],c=n.createCustomSolanaConnection(s),l=await c.getBalance(new r.PublicKey(o)),[u,d]=await Promise.all([c.getParsedTokenAccountsByOwner(new r.PublicKey(o),{programId:i.TOKEN_PROGRAM_ID}),c.getParsedTokenAccountsByOwner(new r.PublicKey(o),{programId:i.TOKEN_2022_PROGRAM_ID})]),f=[...u.value.map(e=>({account:e,is2022Program:!1})),...d.value.map(e=>({account:e,is2022Program:!0}))].filter(({account:e})=>BigInt(e.account.data.parsed.info.tokenAmount.amount)>0n).map(({account:e,is2022Program:t})=>({token:e.account.data.parsed.info.mint,is2022Program:t}));l>0&&f.unshift({token:t.solanaNativeAddress,is2022Program:!1});let p=new Set;return f.filter(({token:e})=>p.has(e)?!1:(p.add(e),!0))};exports.getSolanaWalletTokenHoldings=a;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export declare const getEvmWalletTokenAddresses: (chainId: number, walletAddress: string) => Promise<string[]>;
|
|
2
|
+
export type SolanaWalletTokenHolding = {
|
|
3
|
+
token: string;
|
|
4
|
+
is2022Program: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const getSolanaWalletTokenHoldings: (chainId: number, walletAddress: string) => Promise<SolanaWalletTokenHolding[]>;
|
|
2
7
|
export declare const getSolanaWalletTokenAddresses: (chainId: number, walletAddress: string) => Promise<string[]>;
|
|
3
8
|
export declare const getWalletTokenAddresses: (chainId: number, walletAddress: string) => Promise<string[]>;
|
|
4
9
|
export declare const getTronWalletTokenAddresses: (walletAddress: string, chainId: number) => Promise<string[]>;
|
|
@@ -1,36 +1,30 @@
|
|
|
1
|
-
import "../../constants/chains.constants.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { httpClient as t } from "../../data-structures/http/HttpClient.mjs";
|
|
1
|
+
import { networkRegistry as e } from "../../constants/chains.constants.mjs";
|
|
2
|
+
import { solanaNativeAddress as t } from "../../constants/protocol.constants.mjs";
|
|
4
3
|
import "../../data-structures/http/index.mjs";
|
|
5
|
-
import
|
|
6
|
-
import "./create-provider.mjs";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import "@solana/web3.js";
|
|
10
|
-
import "@solana/spl-token";
|
|
4
|
+
import "./tron.utils.mjs";
|
|
5
|
+
import { createCustomSolanaConnection as n } from "./create-provider.mjs";
|
|
6
|
+
import "./publicBalance.utils.mjs";
|
|
7
|
+
import "../../API/evm-token-assets.mjs";
|
|
8
|
+
import { PublicKey as r } from "@solana/web3.js";
|
|
9
|
+
import { TOKEN_2022_PROGRAM_ID as i, TOKEN_PROGRAM_ID as a } from "@solana/spl-token";
|
|
11
10
|
//#region libs/shared/common/src/functions/utils/wallet-token-discovery.utils.ts
|
|
12
|
-
var
|
|
13
|
-
let [r,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
var o = async (o, s) => {
|
|
12
|
+
let { rpcUrl: c } = e[o], l = n(c), u = await l.getBalance(new r(s)), [d, f] = await Promise.all([l.getParsedTokenAccountsByOwner(new r(s), { programId: a }), l.getParsedTokenAccountsByOwner(new r(s), { programId: i })]), p = [...d.value.map((e) => ({
|
|
13
|
+
account: e,
|
|
14
|
+
is2022Program: !1
|
|
15
|
+
})), ...f.value.map((e) => ({
|
|
16
|
+
account: e,
|
|
17
|
+
is2022Program: !0
|
|
18
|
+
}))].filter(({ account: e }) => BigInt(e.account.data.parsed.info.tokenAmount.amount) > 0n).map(({ account: e, is2022Program: t }) => ({
|
|
19
|
+
token: e.account.data.parsed.info.mint,
|
|
20
|
+
is2022Program: t
|
|
21
|
+
}));
|
|
22
|
+
u > 0 && p.unshift({
|
|
23
|
+
token: t,
|
|
24
|
+
is2022Program: !1
|
|
17
25
|
});
|
|
18
|
-
let
|
|
19
|
-
return
|
|
20
|
-
(!s[e.contractAddress] || BigInt(e.tokenBalance) > 0n) && (s[e.contractAddress] = e);
|
|
21
|
-
}), Object.keys(s);
|
|
22
|
-
}, c = 200, l = async (e, i) => {
|
|
23
|
-
let a = `${r(i)}/v1/accounts/${e}/transactions/trc20?only_to=true&limit=${c}`, o = ((await t.get(a))?.data ?? []).map((e) => e.token_info?.address).filter((e) => !!e).map(n);
|
|
24
|
-
return Array.from(new Set(o));
|
|
25
|
-
}, u = async (a, o) => {
|
|
26
|
-
let s = i(a), c = `${r(o)}/v1/accounts/${s}`, u = (await t.get(c))?.data?.[0];
|
|
27
|
-
if (!u) return l(s, o);
|
|
28
|
-
let d = [];
|
|
29
|
-
return u.balance && u.balance > 0 && d.push(e), (u.trc20 ?? []).forEach((e) => {
|
|
30
|
-
Object.entries(e).forEach(([e, t]) => {
|
|
31
|
-
BigInt(t) > 0n && d.push(n(e));
|
|
32
|
-
});
|
|
33
|
-
}), Array.from(new Set(d));
|
|
26
|
+
let m = /* @__PURE__ */ new Set();
|
|
27
|
+
return p.filter(({ token: e }) => m.has(e) ? !1 : (m.add(e), !0));
|
|
34
28
|
};
|
|
35
29
|
//#endregion
|
|
36
|
-
export {
|
|
30
|
+
export { o as getSolanaWalletTokenHoldings };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../error-handling/error-codes.constants.cjs`),n=require(`../utils/tron.utils.cjs`),r=require(
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/chains.constants.cjs`),t=require(`../../error-handling/error-codes.constants.cjs`),n=require(`../utils/tron.utils.cjs`),r=require(`../../constants/contracts.constants.cjs`),i=require(`../utils/create-provider.cjs`);let a=require(`ethers`);var o=(n,i)=>{let a=e.networkRegistry[i];if(!a)throw Error(t.transactionErrorCodes.UNSUPPORTED_NETWORK);let o=r.contractMetadataMapping[n];if(!o)throw Error(`Unsupported contractType: ${n}`);return o(a.contractData)},s=(e,t,r,i)=>{let s=o(e,t);if(!s.abi)throw Error(`No ABI configured for contractType: ${e}`);if(s.address&&r)throw Error(`Overriding address is not supported for contractType: ${e}`);let c=s.address??r;if(!c)throw Error(`No contractAddress configured for contractType: ${e}`);return new a.ethers.Contract(n.addressToHexFormat(c),s.abi,i)},c=(e,t,n=void 0)=>s(t,e,n,i.createJsonRpcProvider(e));exports.getContract=s,exports.getContractMetadata=o,exports.getContractWithFetcherByChainId=c;
|