@hinkal/common 0.2.32 → 0.2.34
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/constants/bridging.constants.cjs +1 -1
- package/constants/bridging.constants.d.ts +1 -1
- package/constants/bridging.constants.mjs +6 -5
- package/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.d.ts +11 -1
- package/constants/chains.constants.mjs +86 -18
- package/constants/protocol.constants.cjs +1 -1
- package/constants/protocol.constants.d.ts +1 -0
- package/constants/protocol.constants.mjs +2 -2
- package/constants/token-data/ERC20Registry.cjs +1 -1
- package/constants/token-data/ERC20Registry.mjs +49 -14
- package/constants/token-data/avalancheRegistry.json.cjs +1 -0
- package/constants/token-data/avalancheRegistry.json.mjs +44 -0
- package/constants/token-data/bnbMainnetRegistry.json.cjs +1 -0
- package/constants/token-data/bnbMainnetRegistry.json.mjs +44 -0
- package/constants/token-data/cronosRegistry.json.cjs +1 -0
- package/constants/token-data/cronosRegistry.json.mjs +44 -0
- package/constants/token-data/hyperEvmRegistry.json.cjs +1 -0
- package/constants/token-data/hyperEvmRegistry.json.mjs +36 -0
- package/constants/token-data/index.cjs +1 -1
- package/constants/token-data/index.d.ts +57 -1
- package/constants/token-data/index.mjs +9 -2
- package/constants/token-data/inkRegistry.json.cjs +1 -0
- package/constants/token-data/inkRegistry.json.mjs +28 -0
- package/constants/token-data/monadRegistry.json.cjs +1 -0
- package/constants/token-data/monadRegistry.json.mjs +36 -0
- package/constants/token-data/plasmaRegistry.json.cjs +1 -0
- package/constants/token-data/plasmaRegistry.json.mjs +28 -0
- package/constants/tokens.constants.cjs +1 -1
- package/constants/tokens.constants.mjs +8 -1
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +1 -1
- package/data-structures/Hinkal/Hinkal.mjs +1 -1
- package/data-structures/Hinkal/IHinkal.d.ts +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.cjs +1 -1
- package/data-structures/Hinkal/handleAutoDepositBack.mjs +15 -15
- package/data-structures/Hinkal/hinkalClaimUtxo.cjs +1 -1
- package/data-structures/Hinkal/hinkalClaimUtxo.mjs +33 -35
- package/data-structures/Hinkal/hinkalDepositAndBridge.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndBridge.mjs +43 -49
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +38 -40
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +21 -26
- package/data-structures/Hinkal/hinkalSolanaClaimUtxo.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaClaimUtxo.mjs +62 -64
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +49 -50
- package/data-structures/Hinkal/hinkalSolanaProxySend.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySend.mjs +7 -7
- package/data-structures/Hinkal/hinkalSolanaProxyShield.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxyShield.mjs +9 -9
- package/data-structures/Hinkal/hinkalSolanaProxySwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaProxySwap.mjs +8 -8
- package/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaSwap.mjs +50 -51
- package/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaTransfer.mjs +45 -46
- package/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +38 -39
- package/data-structures/Hinkal/hinkalSwap.cjs +1 -1
- package/data-structures/Hinkal/hinkalSwap.mjs +18 -19
- package/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/data-structures/Hinkal/hinkalTransfer.mjs +21 -22
- package/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdraw.mjs +24 -25
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +39 -41
- package/error-handling/error-codes.constants.cjs +1 -1
- package/error-handling/error-codes.constants.d.ts +2 -0
- package/error-handling/error-codes.constants.mjs +2 -0
- package/error-handling/get-error.message.cjs +1 -1
- package/error-handling/get-error.message.mjs +2 -1
- package/functions/index.cjs +1 -1
- package/functions/index.mjs +7 -6
- package/functions/pre-transaction/buildCommitmentValidationData.cjs +1 -1
- package/functions/pre-transaction/buildCommitmentValidationData.d.ts +12 -2
- package/functions/pre-transaction/buildCommitmentValidationData.mjs +43 -36
- package/functions/pre-transaction/sendV0Transaction.cjs +1 -1
- package/functions/pre-transaction/sendV0Transaction.d.ts +2 -2
- package/functions/pre-transaction/sendV0Transaction.mjs +63 -58
- package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.d.ts +1 -0
- package/functions/snarkjs/constructGeneralZkProof.mjs +6 -5
- package/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/functions/snarkjs/constructSolanaZkProof.d.ts +1 -0
- package/functions/snarkjs/constructSolanaZkProof.mjs +35 -34
- package/functions/snarkjs/generateMainAndCommitmentZkProof.cjs +1 -0
- package/functions/snarkjs/generateMainAndCommitmentZkProof.d.ts +11 -0
- package/functions/snarkjs/generateMainAndCommitmentZkProof.mjs +16 -0
- package/functions/snarkjs/generateZkProof.cjs +1 -1
- package/functions/snarkjs/generateZkProof.d.ts +3 -3
- package/functions/snarkjs/generateZkProof.mjs +5 -9
- package/functions/snarkjs/generateZkProofEnclave.cjs +1 -1
- package/functions/snarkjs/generateZkProofEnclave.d.ts +2 -2
- package/functions/snarkjs/generateZkProofEnclave.mjs +8 -8
- package/functions/snarkjs/generateZkProofSelf.cjs +1 -1
- package/functions/snarkjs/generateZkProofSelf.mjs +5 -5
- package/functions/snarkjs/index.cjs +1 -1
- package/functions/snarkjs/index.d.ts +1 -0
- package/functions/snarkjs/index.mjs +1 -0
- package/functions/snarkjs/verifyCommitmentValidationData.cjs +1 -1
- package/functions/snarkjs/verifyCommitmentValidationData.mjs +5 -5
- package/functions/utils/customEnclaveFunctionsRegister.d.ts +3 -3
- package/functions/utils/index.cjs +1 -1
- package/functions/utils/index.mjs +5 -5
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +1 -1
- package/index.cjs +1 -1
- package/index.mjs +316 -315
- package/package.json +2 -2
- package/webworker/{logError-fCJ4HXQz.js → logError-DZiJbbaT.js} +1 -1
- package/webworker/package.json +2 -2
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.mjs +1 -1
- package/webworker/snarkjsWorkerNode.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.mjs +1 -1
- package/webworker/utxoWorkerNode.cjs +1 -1
- package/webworker/viteWorkerURL.constant.cjs +3 -3
- package/webworker/viteWorkerURL.constant.mjs +3 -3
- package/webworker/workerFactory.cjs +1 -1
- package/webworker/workerFactory.mjs +2 -2
- package/webworker/{workerProxy-BNBqYien.js → workerProxy-DQJE57Ye.js} +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.mjs +1 -1
- package/webworker/zkProofWorkerNode.cjs +1 -1
|
@@ -1146,4 +1146,60 @@ declare const solanaLocalnetRegistry: {
|
|
|
1146
1146
|
decimals: number;
|
|
1147
1147
|
logoURI: string;
|
|
1148
1148
|
}[];
|
|
1149
|
-
|
|
1149
|
+
declare const bnbMainnetRegistry: {
|
|
1150
|
+
chainId: number;
|
|
1151
|
+
erc20TokenAddress: string;
|
|
1152
|
+
name: string;
|
|
1153
|
+
symbol: string;
|
|
1154
|
+
decimals: number;
|
|
1155
|
+
logoURI: string;
|
|
1156
|
+
}[];
|
|
1157
|
+
declare const plasmaRegistry: {
|
|
1158
|
+
chainId: number;
|
|
1159
|
+
erc20TokenAddress: string;
|
|
1160
|
+
name: string;
|
|
1161
|
+
symbol: string;
|
|
1162
|
+
decimals: number;
|
|
1163
|
+
logoURI: string;
|
|
1164
|
+
}[];
|
|
1165
|
+
declare const avalancheRegistry: {
|
|
1166
|
+
chainId: number;
|
|
1167
|
+
erc20TokenAddress: string;
|
|
1168
|
+
name: string;
|
|
1169
|
+
symbol: string;
|
|
1170
|
+
decimals: number;
|
|
1171
|
+
logoURI: string;
|
|
1172
|
+
}[];
|
|
1173
|
+
declare const monadRegistry: {
|
|
1174
|
+
chainId: number;
|
|
1175
|
+
erc20TokenAddress: string;
|
|
1176
|
+
name: string;
|
|
1177
|
+
symbol: string;
|
|
1178
|
+
decimals: number;
|
|
1179
|
+
logoURI: string;
|
|
1180
|
+
}[];
|
|
1181
|
+
declare const cronosRegistry: {
|
|
1182
|
+
chainId: number;
|
|
1183
|
+
erc20TokenAddress: string;
|
|
1184
|
+
name: string;
|
|
1185
|
+
symbol: string;
|
|
1186
|
+
decimals: number;
|
|
1187
|
+
logoURI: string;
|
|
1188
|
+
}[];
|
|
1189
|
+
declare const inkRegistry: {
|
|
1190
|
+
chainId: number;
|
|
1191
|
+
erc20TokenAddress: string;
|
|
1192
|
+
name: string;
|
|
1193
|
+
symbol: string;
|
|
1194
|
+
decimals: number;
|
|
1195
|
+
logoURI: string;
|
|
1196
|
+
}[];
|
|
1197
|
+
declare const hyperEvmRegistry: {
|
|
1198
|
+
chainId: number;
|
|
1199
|
+
erc20TokenAddress: string;
|
|
1200
|
+
name: string;
|
|
1201
|
+
symbol: string;
|
|
1202
|
+
decimals: number;
|
|
1203
|
+
logoURI: string;
|
|
1204
|
+
}[];
|
|
1205
|
+
export { ethMainnetRegistryFixed, arbMainnetRegistryFixed, polygonRegistryFixed, optimismRegistryFixed, baseRegistryFixed, ethMainnetRegistry, arbMainnetRegistry, polygonRegistry, optimismRegistry, baseRegistry, localhostRegistry, solanaMainnetRegistry, solanaLocalnetRegistry, arcTestnetRegistry, bnbMainnetRegistry, plasmaRegistry, avalancheRegistry, monadRegistry, cronosRegistry, inkRegistry, hyperEvmRegistry, };
|
|
@@ -12,8 +12,15 @@ import u from "./baseRegistry.json.mjs";
|
|
|
12
12
|
import d from "./localhostRegistry.json.mjs";
|
|
13
13
|
import f from "./solanaMainnetRegistry.json.mjs";
|
|
14
14
|
import p from "./solanaLocalnetRegistry.json.mjs";
|
|
15
|
+
import m from "./bnbMainnetRegistry.json.mjs";
|
|
16
|
+
import h from "./plasmaRegistry.json.mjs";
|
|
17
|
+
import g from "./avalancheRegistry.json.mjs";
|
|
18
|
+
import _ from "./monadRegistry.json.mjs";
|
|
19
|
+
import v from "./cronosRegistry.json.mjs";
|
|
20
|
+
import y from "./inkRegistry.json.mjs";
|
|
21
|
+
import b from "./hyperEvmRegistry.json.mjs";
|
|
15
22
|
import "./ERC20Registry.mjs";
|
|
16
23
|
//#region libs/shared/common/src/constants/token-data/index.ts
|
|
17
|
-
var
|
|
24
|
+
var x = t.networkRegistry, S = n.networkRegistry, C = r.networkRegistry, w = i.networkRegistry, T = a.networkRegistry, E = o.networkRegistry, D = s.networkRegistry, O = c.networkRegistry, k = l.networkRegistry, A = u.networkRegistry, j = d.networkRegistry, M = e.networkRegistry, N = f.networkRegistry, P = p.networkRegistry, F = m.networkRegistry, I = h.networkRegistry, L = g.networkRegistry, R = _.networkRegistry, z = v.networkRegistry, B = y.networkRegistry, V = b.networkRegistry;
|
|
18
25
|
//#endregion
|
|
19
|
-
export {
|
|
26
|
+
export { D as arbMainnetRegistry, S as arbMainnetRegistryFixed, M as arcTestnetRegistry, L as avalancheRegistry, A as baseRegistry, T as baseRegistryFixed, F as bnbMainnetRegistry, z as cronosRegistry, E as ethMainnetRegistry, x as ethMainnetRegistryFixed, V as hyperEvmRegistry, B as inkRegistry, j as localhostRegistry, R as monadRegistry, k as optimismRegistry, w as optimismRegistryFixed, I as plasmaRegistry, O as polygonRegistry, C as polygonRegistryFixed, P as solanaLocalnetRegistry, N as solanaMainnetRegistry };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={networkRegistry:[{chainId:57073,erc20TokenAddress:`0x0000000000000000000000000000000000000000`,name:`Ethereum`,symbol:`ETH`,decimals:18,logoURI:`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png`},{chainId:57073,erc20TokenAddress:`0x2D270e6886d130D724215A266106e6832161EAEd`,name:`USD Coin`,symbol:`USDC`,decimals:6,logoURI:`https://storage.googleapis.com/hinkal-s3-assets/token-logos/USDc.avif`},{chainId:57073,erc20TokenAddress:`0x4200000000000000000000000000000000000006`,name:`Wrapped Ether`,symbol:`WETH`,decimals:18,logoURI:`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png`}]};exports.default=e;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var e = { networkRegistry: [
|
|
2
|
+
{
|
|
3
|
+
chainId: 57073,
|
|
4
|
+
erc20TokenAddress: "0x0000000000000000000000000000000000000000",
|
|
5
|
+
name: "Ethereum",
|
|
6
|
+
symbol: "ETH",
|
|
7
|
+
decimals: 18,
|
|
8
|
+
logoURI: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
chainId: 57073,
|
|
12
|
+
erc20TokenAddress: "0x2D270e6886d130D724215A266106e6832161EAEd",
|
|
13
|
+
name: "USD Coin",
|
|
14
|
+
symbol: "USDC",
|
|
15
|
+
decimals: 6,
|
|
16
|
+
logoURI: "https://storage.googleapis.com/hinkal-s3-assets/token-logos/USDc.avif"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
chainId: 57073,
|
|
20
|
+
erc20TokenAddress: "0x4200000000000000000000000000000000000006",
|
|
21
|
+
name: "Wrapped Ether",
|
|
22
|
+
symbol: "WETH",
|
|
23
|
+
decimals: 18,
|
|
24
|
+
logoURI: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png"
|
|
25
|
+
}
|
|
26
|
+
] };
|
|
27
|
+
//#endregion
|
|
28
|
+
export { e as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={networkRegistry:[{chainId:143,erc20TokenAddress:`0x0000000000000000000000000000000000000000`,name:`Monad`,symbol:`MON`,decimals:18,logoURI:`https://static.debank.com/image/monad_token/logo_url/monad/9df1611d238781f78045fba9101359a3.png`},{chainId:143,erc20TokenAddress:`0x754704Bc059F8C67012fEd69BC8A327a5aafb603`,name:`USD Coin`,symbol:`USDC`,decimals:6,logoURI:`https://storage.googleapis.com/hinkal-s3-assets/token-logos/USDc.avif`},{chainId:143,erc20TokenAddress:`0xe7cd86e13AC4309349F30B3435a9d337750fC82D`,name:`Tether USD (USDT0)`,symbol:`USDT`,decimals:6,logoURI:`https://storage.googleapis.com/hinkal-s3-assets/token-logos/USDT.avif`},{chainId:143,erc20TokenAddress:`0xEE8c0E9f1BFFb4Eb878d8f15f368A02a35481242`,name:`Wrapped Ether`,symbol:`WETH`,decimals:18,logoURI:`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png`}]};exports.default=e;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var e = { networkRegistry: [
|
|
2
|
+
{
|
|
3
|
+
chainId: 143,
|
|
4
|
+
erc20TokenAddress: "0x0000000000000000000000000000000000000000",
|
|
5
|
+
name: "Monad",
|
|
6
|
+
symbol: "MON",
|
|
7
|
+
decimals: 18,
|
|
8
|
+
logoURI: "https://static.debank.com/image/monad_token/logo_url/monad/9df1611d238781f78045fba9101359a3.png"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
chainId: 143,
|
|
12
|
+
erc20TokenAddress: "0x754704Bc059F8C67012fEd69BC8A327a5aafb603",
|
|
13
|
+
name: "USD Coin",
|
|
14
|
+
symbol: "USDC",
|
|
15
|
+
decimals: 6,
|
|
16
|
+
logoURI: "https://storage.googleapis.com/hinkal-s3-assets/token-logos/USDc.avif"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
chainId: 143,
|
|
20
|
+
erc20TokenAddress: "0xe7cd86e13AC4309349F30B3435a9d337750fC82D",
|
|
21
|
+
name: "Tether USD (USDT0)",
|
|
22
|
+
symbol: "USDT",
|
|
23
|
+
decimals: 6,
|
|
24
|
+
logoURI: "https://storage.googleapis.com/hinkal-s3-assets/token-logos/USDT.avif"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
chainId: 143,
|
|
28
|
+
erc20TokenAddress: "0xEE8c0E9f1BFFb4Eb878d8f15f368A02a35481242",
|
|
29
|
+
name: "Wrapped Ether",
|
|
30
|
+
symbol: "WETH",
|
|
31
|
+
decimals: 18,
|
|
32
|
+
logoURI: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png"
|
|
33
|
+
}
|
|
34
|
+
] };
|
|
35
|
+
//#endregion
|
|
36
|
+
export { e as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={networkRegistry:[{chainId:9745,erc20TokenAddress:`0x0000000000000000000000000000000000000000`,name:`Plasma`,symbol:`XPL`,decimals:18,logoURI:`https://s2.coinmarketcap.com/static/img/coins/64x64/36645.png`},{chainId:9745,erc20TokenAddress:`0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb`,name:`Tether USD (USDT0)`,symbol:`USDT`,decimals:6,logoURI:`https://storage.googleapis.com/hinkal-s3-assets/token-logos/USDT.avif`},{chainId:9745,erc20TokenAddress:`0x9895D81bB462A195b4922ED7De0e3ACD007c32CB`,name:`Wrapped Ether`,symbol:`WETH`,decimals:18,logoURI:`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png`}]};exports.default=e;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var e = { networkRegistry: [
|
|
2
|
+
{
|
|
3
|
+
chainId: 9745,
|
|
4
|
+
erc20TokenAddress: "0x0000000000000000000000000000000000000000",
|
|
5
|
+
name: "Plasma",
|
|
6
|
+
symbol: "XPL",
|
|
7
|
+
decimals: 18,
|
|
8
|
+
logoURI: "https://s2.coinmarketcap.com/static/img/coins/64x64/36645.png"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
chainId: 9745,
|
|
12
|
+
erc20TokenAddress: "0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb",
|
|
13
|
+
name: "Tether USD (USDT0)",
|
|
14
|
+
symbol: "USDT",
|
|
15
|
+
decimals: 6,
|
|
16
|
+
logoURI: "https://storage.googleapis.com/hinkal-s3-assets/token-logos/USDT.avif"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
chainId: 9745,
|
|
20
|
+
erc20TokenAddress: "0x9895D81bB462A195b4922ED7De0e3ACD007c32CB",
|
|
21
|
+
name: "Wrapped Ether",
|
|
22
|
+
symbol: "WETH",
|
|
23
|
+
decimals: 18,
|
|
24
|
+
logoURI: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png"
|
|
25
|
+
}
|
|
26
|
+
] };
|
|
27
|
+
//#endregion
|
|
28
|
+
export { e as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./chains.constants.cjs`);var t=[`DAI`,`MATIC`,`USDC`,`USDT`,`WETH`,`stETH`],n=[`ETH`,`POL`,`SOL`],r=[`SOL`,`USDC`,`USDT`],i={[e.chainIds.ethMainnet]:`ETH`,[e.chainIds.arbMainnet]:`ETH`,[e.chainIds.optimism]:`ETH`,[e.chainIds.optimismTest]:`ETH`,[e.chainIds.base]:`ETH`,[e.chainIds.arcTestnet]:`ETH`,[e.chainIds.sepoliaTestnet]:`ETH`,[e.chainIds.polygon]:`POL`,[e.chainIds.solanaMainnet]:`SOL`,[e.chainIds.solanaLocalnet]:`SOL`};exports.NativeTokenSymbols=n,exports.PopularTokenSymbols=t,exports.SOLANA_PAY_DASHBOARD_SUPPORTED_TOKEN_SYMBOLS=r,exports.chainNativeTokenSymbol=i;
|
|
1
|
+
const e=require(`./chains.constants.cjs`);var t=[`DAI`,`MATIC`,`USDC`,`USDT`,`WETH`,`stETH`],n=[`ETH`,`POL`,`SOL`],r=[`SOL`,`USDC`,`USDT`],i={[e.chainIds.ethMainnet]:`ETH`,[e.chainIds.arbMainnet]:`ETH`,[e.chainIds.optimism]:`ETH`,[e.chainIds.optimismTest]:`ETH`,[e.chainIds.base]:`ETH`,[e.chainIds.arcTestnet]:`ETH`,[e.chainIds.sepoliaTestnet]:`ETH`,[e.chainIds.polygon]:`POL`,[e.chainIds.solanaMainnet]:`SOL`,[e.chainIds.solanaLocalnet]:`SOL`,[e.chainIds.bnbMainnet]:`BNB`,[e.chainIds.avalanche]:`AVAX`,[e.chainIds.cronos]:`CRO`,[e.chainIds.monad]:`MON`,[e.chainIds.plasma]:`XPL`,[e.chainIds.ink]:`ETH`,[e.chainIds.hyperEvm]:`HYPE`};exports.NativeTokenSymbols=n,exports.PopularTokenSymbols=t,exports.SOLANA_PAY_DASHBOARD_SUPPORTED_TOKEN_SYMBOLS=r,exports.chainNativeTokenSymbol=i;
|
|
@@ -25,7 +25,14 @@ var t = [
|
|
|
25
25
|
[e.sepoliaTestnet]: "ETH",
|
|
26
26
|
[e.polygon]: "POL",
|
|
27
27
|
[e.solanaMainnet]: "SOL",
|
|
28
|
-
[e.solanaLocalnet]: "SOL"
|
|
28
|
+
[e.solanaLocalnet]: "SOL",
|
|
29
|
+
[e.bnbMainnet]: "BNB",
|
|
30
|
+
[e.avalanche]: "AVAX",
|
|
31
|
+
[e.cronos]: "CRO",
|
|
32
|
+
[e.monad]: "MON",
|
|
33
|
+
[e.plasma]: "XPL",
|
|
34
|
+
[e.ink]: "ETH",
|
|
35
|
+
[e.hyperEvm]: "HYPE"
|
|
29
36
|
};
|
|
30
37
|
//#endregion
|
|
31
38
|
export { n as NativeTokenSymbols, t as PopularTokenSymbols, r as SOLANA_PAY_DASHBOARD_SUPPORTED_TOKEN_SYMBOLS, i as chainNativeTokenSymbol };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../types/ethereum-network.types.cjs`),t=require(`../../functions/utils/serialize.utils.cjs`),n=require(`../../constants/vite.constants.cjs`),r=require(`../../constants/chains.constants.cjs`),i=require(`../../types/hinkal.types.cjs`),a=require(`../../API/API.cjs`),o=require(`../../constants/kyc.constants.cjs`),s=require(`../../error-handling/error-codes.constants.cjs`),c=require(`../../functions/utils/erc20tokenFunctions.cjs`);require(`../../API/index.cjs`);const l=require(`../../crypto/poseidon.cjs`),u=require(`../crypto-keys/keys.cjs`),d=require(`../../functions/utils/token-check.utils.cjs`),f=require(`../TokenDBs/PrivateTokensDB.cjs`),p=require(`../../functions/web3/events/getShieldedBalance.cjs`),m=require(`../../functions/pre-transaction/solana.cjs`),h=require(`../../functions/web3/getContractMetadata.cjs`),g=require(`../../functions/utils/reloadPage.cjs`),_=require(`../../functions/utils/cacheDevice.utils.cjs`),v=require(`../../providers/SolanaProviderAdapter.cjs`),y=require(`../../functions/utils/enclave-signature-storage.cjs`),b=require(`../../functions/utils/mnemonics.cjs`),x=require(`../../functions/web3/fetchSolanaMerkleTreeRootHash.cjs`),S=require(`../../functions/private-wallet/emporium.helpers.cjs`),C=require(`./hinkalDeposit.cjs`),w=require(`../../functions/kyc/checkTokenLimitsUSD.cjs`),T=require(`./hinkalDepositAndWithdraw.cjs`),E=require(`./hinkalSolanaDeposit.cjs`),D=require(`./hinkalSwap.cjs`),O=require(`./hinkalWithdraw.cjs`),k=require(`../merkle-tree/MerkleTree.cjs`);require(`../merkle-tree/index.cjs`);const A=require(`./resetMerkleTrees.cjs`),j=require(`../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs`),M=require(`./hinkalPrivateWallet.cjs`),N=require(`./hinkalGetRecipientInfo.cjs`),P=require(`./hinkalSignSubAccount.cjs`),F=require(`./hinkalActionReceive.cjs`);require(`../TokenDBs/index.cjs`);const I=require(`./hinkalProoflessDeposit.cjs`),ee=require(`./hinkalProxySwap.cjs`),L=require(`./hinkalMultiSend.cjs`),R=require(`./hinkalTransfer.cjs`),z=require(`./hinkalProxyToPrivate.cjs`),B=require(`../../providers/TronProviderAdapter.cjs`),V=require(`./hinkalSolanaDepositAndWithdraw.cjs`),H=require(`./hinkalSolanaWithdraw.cjs`),U=require(`./hinkalSolanaTransfer.cjs`),W=require(`./hinkalSolanaSwap.cjs`),G=require(`./hinkalSolanaProxySend.cjs`),K=require(`./hinkalSolanaProxySwap.cjs`),q=require(`./hinkalSolanaProxyShield.cjs`),J=require(`./hinkalDepositAndBridge.cjs`),Y=require(`./hinkalClaimUtxo.cjs`),X=require(`./hinkalSolanaProoflessDeposit.cjs`),Z=require(`./hinkalSolanaClaimUtxo.cjs`),Q=require(`./hinkalWithdrawStuckUtxos.cjs`);let $=require(`@solana/web3.js`);var te=class{ethereumProviderAdapter;solanaProviderAdapter;tronProviderAdapter;userKeys;signingMessage=`Login to Hinkal Protocol`;privateTransferSigningMessage=`Login to Hinkal's Private Transfer App`;merkleTreeHinkalByChain={};nullifiersByChain={};encryptedOutputsByChain={};commitmentsSnapshotServiceByChain={};nullifierSnapshotServiceByChain={};utxoUtils;lastCallState=new Map;cacheDevice;generateProofRemotely;disableMerkleTreeUpdates;constructor(e){this.userKeys=new u.UserKeys(void 0),e?.tronChainOverride&&r.setHinkalTronChainId(e.tronChainOverride),r.HINKAL_SUPPORTED_CHAINS.forEach(e=>{this.merkleTreeHinkalByChain[e]=k.MerkleTree.create(l.poseidonFunction,0n),this.nullifiersByChain[e]=new Set,this.encryptedOutputsByChain[e]=[]}),this.generateProofRemotely=e?.generateProofRemotely??!0,this.utxoUtils=new j.MultiThreadedUtxoUtils,this.cacheDevice=_.createCacheDevice(e),this.disableMerkleTreeUpdates=e?.disableMerkleTreeUpdates??!1}enforceRateLimit(e,n,r=1e3){let i=Date.now(),a=t.CustomJSONStringify(n),o=this.lastCallState.get(e);if(o&&o.argsKey===a&&i-o.timestamp<r)throw Error(`${e} was already called with the same arguments`);this.lastCallState.set(e,{timestamp:i,argsKey:a})}getProviderAdapter(e){let t=e;t||=this.ethereumProviderAdapter?r.chainIds.ethMainnet:this.solanaProviderAdapter?r.currentSolanaChainId:r.chainIds.tronMainnet;let n;if(n=r.isSolanaLike(t)?this.solanaProviderAdapter:r.isTronLike(t)?this.tronProviderAdapter:this.ethereumProviderAdapter,!n)throw Error(`ProviderAdapter is not initialized`);return n}async initProviderAdapter(e,t){let n=r.chainIds.ethMainnet;t instanceof v.SolanaProviderAdapter?n=r.currentSolanaChainId:t instanceof B.TronProviderAdapter&&(n=r.currentTronChainId),await this.updateProviderAdapter(n,t),t.initConnector(e);let i=await t.connectAndPatchProvider(e);await t.init(i),await this.setListeners()}getSigningMessage(e=i.LoginMessageMode.PROTOCOL){switch(e){case i.LoginMessageMode.PRIVATE_TRANSFER:return this.privateTransferSigningMessage;case i.LoginMessageMode.PROTOCOL:default:return this.signingMessage}}async signHinkalMessage(e=i.LoginMessageMode.PROTOCOL){let t=this.getSigningMessage(e);return this.getProviderAdapter().signMessage(t)}async initUserKeys(e=i.LoginMessageMode.PROTOCOL){this.userKeys=new u.UserKeys(await this.signHinkalMessage(e))}initUserKeysWithSignature(e){this.userKeys=new u.UserKeys(e)}async initUserKeysFromSeedPhrases(e){let t=b.generateHashFromSeedPhrases(e);this.userKeys=new u.UserKeys(t)}async storeAndGetInitialSignature(e,t,n){let r=await this.getEthereumAddress();if(!r)throw Error(`Connected address not found`);return await y.storeAndGetSignatureFromEnclave(r,e,t,n)}async resetMerkle(e){this.disableMerkleTreeUpdates||(e?.every(e=>this.isSelectedNetworkSupported(e))??!0)&&await A.resetMerkleTrees(this,e)}getTronWeb(){let e=this.tronProviderAdapter;if(!e)throw Error(`Tron provider adapter not initialized`);if(!(e instanceof B.TronProviderAdapter))throw Error(`Tron provider adapter is not a TronProviderAdapter`);let t=e.getTronWeb();if(!t)throw Error(`TronWeb not available`);return t}getSupportedChains(){return this.ethereumProviderAdapter&&this.solanaProviderAdapter?r.WALLET_SUPPORTED_CHAINS:this.ethereumProviderAdapter?r.HINKAL_SUPPORTED_CHAINS.filter(e=>!r.isSolanaLike(e)&&!r.isTronLike(e)):this.solanaProviderAdapter?r.HINKAL_SUPPORTED_CHAINS.filter(e=>r.isSolanaLike(e)):this.tronProviderAdapter?[r.currentTronChainId]:[]}async waitForTransaction(e,t,n=1){return!!await this.getProviderAdapter(e).waitForTransaction(e,t,n)}getContract(e,t,n=void 0){return this.getProviderAdapter(e).getContract(e,t,n)}getContractWithFetcherByChainId(e,t,n=void 0){return h.getContractWithFetcherByChainId(e,t,n)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,t,n){return await this.getProviderAdapter().signTypedData(e,t,n)}async signWithSubAccount(e,t,n,r){return P.hinkalSignSubAccount(e,t,n,r)}getContractWithSigner(e,t,n=``){return this.getProviderAdapter(e).getContractWithSigner(e,t,n)}getContractWithFetcher(e,t,n=``){return this.getProviderAdapter(e).getContractWithFetcher(e,t,n)}isSelectedNetworkSupported(e){return!!r.networkRegistry[e]}async switchNetwork(e){let t=this.getProviderAdapter(),n=t.getChainId(),i=n!==void 0&&r.isSameOnchainNetwork(e.chainId,n);if(!(e.chainId===n||i))try{await t.switchNetwork(e)}catch{throw Error(s.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}isPermitterAvailable(e){return this.getProviderAdapter(e).isPermitterAvailable()}async disconnectFromConnector(){await this.ethereumProviderAdapter?.disconnectFromConnector(),await this.solanaProviderAdapter?.disconnectFromConnector(),await this.tronProviderAdapter?.disconnectFromConnector()}async resetProviderAdapters(){this.ethereumProviderAdapter=void 0,this.solanaProviderAdapter=void 0,this.tronProviderAdapter=void 0}async updateProviderAdapter(e,t){try{r.isSolanaLike(e)?(this.solanaProviderAdapter&&this.solanaProviderAdapter.release(),this.solanaProviderAdapter=t):r.isTronLike(e)?(this.tronProviderAdapter&&this.tronProviderAdapter.release(),this.tronProviderAdapter=t):(this.ethereumProviderAdapter&&this.ethereumProviderAdapter.release(),this.ethereumProviderAdapter=t)}catch(e){throw console.error(e),Error(`updateProviderAdapter failed, please try again.`)}}async setListeners(){this.ethereumProviderAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}}),this.solanaProviderAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}}),this.tronProviderAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}})}async onAccountChanged(){await this.ethereumProviderAdapter?.onAccountChanged(),await this.solanaProviderAdapter?.onAccountChanged(),await this.tronProviderAdapter?.onAccountChanged();let e=i.EventType.AccountChanged;typeof document<`u`?document?.dispatchEvent(new Event(e)):process?.emit(`message`,e,void 0)}async onChainChanged(e){e?await this.getProviderAdapter(e).onChainChanged(e):(await this.disconnectFromConnector(),g.reloadPage())}async monitorConnectedAddress(e){await a.API.monitor(await this.getEthereumAddressByChain(e))}async getBalances(e,t,n,r,i=!1,a,o=!1){return p.getShieldedBalance(this,e,t,n,r,i,this.generateProofRemotely,a,o)}async getTotalBalance(e,t,r,i=!1,a,o=!1){let s=r??await this.getEthereumAddressByChain(e),l=t??this.userKeys,u=await this.getBalances(e,l.getShieldedPrivateKey(),l.getShieldedPublicKey(),s,i,a,o),d=n.isExtension?await f.privateTokensDB.getPrivateTokens(e,s):c.getErc20TokensForChain(e),p=[];return d.forEach(e=>{let t=e.erc20TokenAddress.toLowerCase(),n=u.get(t),r={token:e,balance:n?.balance??0n,timestamp:n?.timestamp||`0`,nfts:n?.nfts||[]};p.push(r)}),p}async getStuckShieldedBalances(e,t,n){return(await this.getTotalBalance(e,t,n,!1,!1,!0)).filter(e=>e.balance>0n)}getSupportedPassportLinks(){return o.supportedPassportLinks}checkAccessToken(e,t){return Promise.resolve(!0)}checkExternalTokenLimitsUSD(e,t,n){return w.checkTokenLimitsUSD(e,t,n)}async getHinkalTreeRootHash(t){if(r.isSolanaLike(t)){let{hinkalIdl:e,hinkalAddress:n,originalDeployer:i}=r.networkRegistry[t].contractData;if(!e||!n||!i)throw Error(`Missing Solana configuration for chain ${t}`);let a=new $.PublicKey(i),o=m.getMerkleAccountPublicKey(new $.PublicKey(n),a);return x.fetchSolanaMerkleTreeRootHash(this.getSolanaProgram(e),o)}return this.getContractWithFetcherByChainId(t,e.ContractType.HinkalContract).getRootHash()}async resetMerkleTreesIfNecessary(e){let t=(await Promise.all((e??this.getSupportedChains()).map(async e=>{let t=await this.getHinkalTreeRootHash(e);return{chainId:e,needsReset:BigInt(t)!==this.merkleTreeHinkalByChain[e].getRootHash()}}))).filter(e=>e.needsReset).map(e=>e.chainId);t.length>0&&(console.log(`resetting merkle tree in resetMerkleTreesIfNecessary for chains:`,t),await this.resetMerkle(t))}async getEthereumAddress(){let e=this.ethereumProviderAdapter??this.solanaProviderAdapter??this.tronProviderAdapter;if(!e)throw Error(`No provider adapter initialized`);return e.getAddress()}getEthereumAddressByChain(e){return this.getProviderAdapter(e).getAddress()}async getRandomRelay(e,t=!1){return(await a.API.getIdleRelay(e,t)).relay}getGasPrice(e){let t=this.getProviderAdapter(e);if(!t)throw Error(`Illegal State of providerAdapter in Hinkal: no providerAdapter initialized`);return t.getGasPrice(e)}getAPI(){return a.API}snapshotsClearInterval(){this.getSupportedChains().forEach(e=>{this.commitmentsSnapshotServiceByChain[e]?.intervalClear(),this.nullifierSnapshotServiceByChain[e]?.intervalClear()})}getRecipientInfo(){return N.getRecipientInfo(this)}async deposit(e,t,n=!0,r=!1){return C.hinkalDeposit(this,e,t,n,r)}async depositSolana(e,t,n=!1){return E.hinkalSolanaDeposit(this,e,t,n)}async depositForOther(e,t,n,r=!0,i=!1,a){return this.enforceRateLimit(this.depositForOther.name,[e,t,n]),C.hinkalDepositForOther(this,e,t,n,r,i,a)}async depositSolanaForOther(e,t,n,r=!1,i){return this.enforceRateLimit(this.depositSolanaForOther.name,[e,t,n]),E.hinkalSolanaDepositForOther(this,e,t,n,r,i)}async depositAndWithdraw(e,t,n,i,a,o,s,c,l=!0){return r.isSolanaLike(d.validateAndGetChainId([e]))?V.hinkalSolanaDepositAndWithdraw(this,e,t,n,i,a,o,s,c):T.hinkalDepositAndWithdraw(this,e,t,n,i,a,o,s,c,l)}async claimUtxo(e,t,n,i){return r.isSolanaLike(d.validateAndGetChainId([e]))?Z.hinkalSolanaClaimUtxo(this,e,t,i,n):Y.hinkalClaimUtxo(this,e,t,i,n)}async depositAndBridge(e,t,n,r,i,a,o,s=!0){return J.hinkalDepositAndBridge(this,e,t,n,r,i,a,o,s)}async prooflessDeposit(e,t,n,i,a=!1){return r.isSolanaLike(d.validateAndGetChainId(e))?X.hinkalSolanaProoflessDeposit(this,e,t,n,i,a):I.hinkalProoflessDeposit(this,e,t,n,i,a)}async prooflessDepositWithPublicFee(e,t,n,i,a){let o=d.validateAndGetChainId([e]);return r.isSolanaLike(o)?E.hinkalSolanaProoflessDepositWithPublicFee(this,e,t,n,i,a):I.hinkalProoflessDepositWithPublicFee(this,o,e,t,n,i,a)}getSolanaProgram(e){if(!this.solanaProviderAdapter)throw Error(`No provider adapter initialized`);if(!(`getSolanaProgram`in this.solanaProviderAdapter))throw Error(`Current provider adapter is not a Solana provider adapter`);return this.solanaProviderAdapter.getSolanaProgram(e)}getSolanaPublicKey(){if(!this.solanaProviderAdapter)throw Error(`No provider adapter initialized`);if(!(`getSolanaPublicKey`in this.solanaProviderAdapter))throw Error(`Current provider adapter is not a Solana provider adapter`);return this.solanaProviderAdapter.getSolanaPublicKey()}async transfer(e,t,n,i,a,o){return this.enforceRateLimit(this.transfer.name,[e,t,n]),r.isSolanaLike(d.validateAndGetChainId(e))?U.hinkalSolanaTransfer(this,e,t,n,i,a,o):R.hinkalTransfer(this,e,t,n,i,a,o)}async withdraw(e,t,n,i,a,o,s){return r.isSolanaLike(d.validateAndGetChainId(e))?H.hinkalSolanaWithdraw(this,e,t,n,a,o,s):O.hinkalWithdraw(this,e,t,n,i,a,o,s)}async withdrawStuckUtxos(e,t){return Q.hinkalWithdrawStuckUtxos(this,e,t)}async swap(e,t,n,i,a,o,s){return r.isSolanaLike(d.validateAndGetChainId(e))?this.swapSolana(e,t,i,a,o,s):D.hinkalSwap(this,e,t,n,i,a,o,s)}async swapSolana(e,t,n,r,i,a){let o=JSON.parse(n),s=BigInt(o.swapperAccountSalt),{instructionLists:c,addressLookupTableAccount:l}=o.data;return W.hinkalSolanaSwap(this,e,t,s,c,l,r,i,a)}async actionReceive(e,t,n,i,a,o){if(!a)throw Error(`subAccount is required`);return r.isSolanaLike(d.validateAndGetChainId(e))?q.hinkalSolanaProxyShield(this,e[0],t[0],a,void 0,o):F.hinkalActionReceive(this,e,t,n,i,a,o)}async actionPrivateWallet(e,t,n,r,i,a,o,s,c,l,u=!1,d,f,p){return this.enforceRateLimit(this.actionPrivateWallet.name,[e,t,n,r,i,a,o,s,c,p]),M.hinkalPrivateWallet(this,e,t,n,r,i,a,o,s,c,l,u,d,f,p)}async proxySwap(e,t,n,i,a,o,s,c,l=!1,u,f){return r.isSolanaLike(d.validateAndGetChainId(e))?K.hinkalSolanaProxySwap(this,e,t,i,o,n,s,c,f):ee.hinkalProxySwap(this,e,t,n,i,a,o,s,c,l,u,f)}async proxyToPrivate(e,t,n,i,a,o,s){return r.isSolanaLike(d.validateAndGetChainId(e))?(this.enforceRateLimit(this.proxyToPrivate.name,[e[0],t[0],n,i]),q.hinkalSolanaProxyShield(this,e[0],t[0],n,i,s)):z.hinkalProxyToPrivate(this,e,t,i,a,o,n,s)}async proxySend(e,t,n,i,a,o,s){let c=d.validateAndGetChainId(e);if(r.isSolanaLike(c))return G.hinkalSolanaProxySend(this,e[0],t[0],n,i,s);let l=S.createTransaferEmporiumOpsBatch(this,c,e.map(e=>e.erc20TokenAddress),t,i),u=e.map((e,n)=>({token:e,amount:-1n*t[n]}));return await this.actionPrivateWallet(c,[],[],[],l,u,n,a,o,void 0,void 0,void 0,s,void 0)}async multiSendPrivateRecipients(e,t,n){return this.enforceRateLimit(this.multiSendPrivateRecipients.name,[e,t,n]),L.hinkalMultiSendPrivateRecipients(this,e,t,n)}areMerkleTreeUpdatesDisabled(){return this.disableMerkleTreeUpdates}updateMerkleTreeUpdates(e){this.disableMerkleTreeUpdates=e}};exports.Hinkal=te;
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../types/ethereum-network.types.cjs`),t=require(`../../functions/utils/serialize.utils.cjs`),n=require(`../../constants/vite.constants.cjs`),r=require(`../../constants/chains.constants.cjs`),i=require(`../../types/hinkal.types.cjs`),a=require(`../../API/API.cjs`),o=require(`../../constants/kyc.constants.cjs`),s=require(`../../error-handling/error-codes.constants.cjs`),c=require(`../../functions/utils/erc20tokenFunctions.cjs`);require(`../../API/index.cjs`);const l=require(`../../crypto/poseidon.cjs`),u=require(`../crypto-keys/keys.cjs`),d=require(`../../functions/utils/token-check.utils.cjs`),f=require(`../TokenDBs/PrivateTokensDB.cjs`),p=require(`../../functions/web3/events/getShieldedBalance.cjs`),m=require(`../../functions/pre-transaction/solana.cjs`),h=require(`../../functions/web3/getContractMetadata.cjs`),g=require(`../../functions/utils/reloadPage.cjs`),_=require(`../../functions/utils/cacheDevice.utils.cjs`),v=require(`../../providers/SolanaProviderAdapter.cjs`),y=require(`../../functions/utils/enclave-signature-storage.cjs`),b=require(`../../functions/utils/mnemonics.cjs`),x=require(`../../functions/web3/fetchSolanaMerkleTreeRootHash.cjs`),S=require(`../../functions/private-wallet/emporium.helpers.cjs`),C=require(`./hinkalDeposit.cjs`),w=require(`../../functions/kyc/checkTokenLimitsUSD.cjs`),T=require(`./hinkalDepositAndWithdraw.cjs`),E=require(`./hinkalSolanaDeposit.cjs`),D=require(`./hinkalSwap.cjs`),O=require(`./hinkalWithdraw.cjs`),k=require(`../merkle-tree/MerkleTree.cjs`);require(`../merkle-tree/index.cjs`);const A=require(`./resetMerkleTrees.cjs`),j=require(`../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs`),M=require(`./hinkalPrivateWallet.cjs`),N=require(`./hinkalGetRecipientInfo.cjs`),P=require(`./hinkalSignSubAccount.cjs`),F=require(`./hinkalActionReceive.cjs`);require(`../TokenDBs/index.cjs`);const I=require(`./hinkalProoflessDeposit.cjs`),ee=require(`./hinkalProxySwap.cjs`),L=require(`./hinkalMultiSend.cjs`),R=require(`./hinkalTransfer.cjs`),z=require(`./hinkalProxyToPrivate.cjs`),B=require(`../../providers/TronProviderAdapter.cjs`),V=require(`./hinkalSolanaDepositAndWithdraw.cjs`),H=require(`./hinkalSolanaWithdraw.cjs`),U=require(`./hinkalSolanaTransfer.cjs`),W=require(`./hinkalSolanaSwap.cjs`),G=require(`./hinkalSolanaProxySend.cjs`),K=require(`./hinkalSolanaProxySwap.cjs`),q=require(`./hinkalSolanaProxyShield.cjs`),J=require(`./hinkalDepositAndBridge.cjs`),Y=require(`./hinkalClaimUtxo.cjs`),X=require(`./hinkalSolanaProoflessDeposit.cjs`),Z=require(`./hinkalSolanaClaimUtxo.cjs`),Q=require(`./hinkalWithdrawStuckUtxos.cjs`);let $=require(`@solana/web3.js`);var te=class{ethereumProviderAdapter;solanaProviderAdapter;tronProviderAdapter;userKeys;signingMessage=`Login to Hinkal Protocol`;privateTransferSigningMessage=`Login to Hinkal's Private Transfer App`;merkleTreeHinkalByChain={};nullifiersByChain={};encryptedOutputsByChain={};commitmentsSnapshotServiceByChain={};nullifierSnapshotServiceByChain={};utxoUtils;lastCallState=new Map;cacheDevice;generateProofRemotely;disableMerkleTreeUpdates;constructor(e){this.userKeys=new u.UserKeys(void 0),e?.tronChainOverride&&r.setHinkalTronChainId(e.tronChainOverride),r.HINKAL_SUPPORTED_CHAINS.forEach(e=>{this.merkleTreeHinkalByChain[e]=k.MerkleTree.create(l.poseidonFunction,0n),this.nullifiersByChain[e]=new Set,this.encryptedOutputsByChain[e]=[]}),this.generateProofRemotely=e?.generateProofRemotely??!0,this.utxoUtils=new j.MultiThreadedUtxoUtils,this.cacheDevice=_.createCacheDevice(e),this.disableMerkleTreeUpdates=e?.disableMerkleTreeUpdates??!1}enforceRateLimit(e,n,r=1e3){let i=Date.now(),a=t.CustomJSONStringify(n),o=this.lastCallState.get(e);if(o&&o.argsKey===a&&i-o.timestamp<r)throw Error(`${e} was already called with the same arguments`);this.lastCallState.set(e,{timestamp:i,argsKey:a})}getProviderAdapter(e){let t=e;t||=this.ethereumProviderAdapter?r.chainIds.ethMainnet:this.solanaProviderAdapter?r.currentSolanaChainId:r.chainIds.tronMainnet;let n;if(n=r.isSolanaLike(t)?this.solanaProviderAdapter:r.isTronLike(t)?this.tronProviderAdapter:this.ethereumProviderAdapter,!n)throw Error(`ProviderAdapter is not initialized`);return n}async initProviderAdapter(e,t){let n=r.chainIds.ethMainnet;t instanceof v.SolanaProviderAdapter?n=r.currentSolanaChainId:t instanceof B.TronProviderAdapter&&(n=r.currentTronChainId),await this.updateProviderAdapter(n,t),t.initConnector(e);let i=await t.connectAndPatchProvider(e);await t.init(i),await this.setListeners()}getSigningMessage(e=i.LoginMessageMode.PROTOCOL){switch(e){case i.LoginMessageMode.PRIVATE_TRANSFER:return this.privateTransferSigningMessage;case i.LoginMessageMode.PROTOCOL:default:return this.signingMessage}}async signHinkalMessage(e=i.LoginMessageMode.PROTOCOL){let t=this.getSigningMessage(e);return this.getProviderAdapter().signMessage(t)}async initUserKeys(e=i.LoginMessageMode.PROTOCOL){this.userKeys=new u.UserKeys(await this.signHinkalMessage(e))}initUserKeysWithSignature(e){this.userKeys=new u.UserKeys(e)}async initUserKeysFromSeedPhrases(e){let t=b.generateHashFromSeedPhrases(e);this.userKeys=new u.UserKeys(t)}async storeAndGetInitialSignature(e,t,n){let r=await this.getEthereumAddress();if(!r)throw Error(`Connected address not found`);return await y.storeAndGetSignatureFromEnclave(r,e,t,n)}async resetMerkle(e){this.disableMerkleTreeUpdates||(e?.every(e=>this.isSelectedNetworkSupported(e))??!0)&&await A.resetMerkleTrees(this,e)}getTronWeb(){let e=this.tronProviderAdapter;if(!e)throw Error(`Tron provider adapter not initialized`);if(!(e instanceof B.TronProviderAdapter))throw Error(`Tron provider adapter is not a TronProviderAdapter`);let t=e.getTronWeb();if(!t)throw Error(`TronWeb not available`);return t}getSupportedChains(){return this.ethereumProviderAdapter&&this.solanaProviderAdapter?r.WALLET_SUPPORTED_CHAINS:this.ethereumProviderAdapter?r.HINKAL_SUPPORTED_CHAINS.filter(e=>!r.isSolanaLike(e)&&!r.isTronLike(e)):this.solanaProviderAdapter?r.HINKAL_SUPPORTED_CHAINS.filter(e=>r.isSolanaLike(e)):this.tronProviderAdapter?[r.currentTronChainId]:[]}async waitForTransaction(e,t,n=1){return!!await this.getProviderAdapter(e).waitForTransaction(e,t,n)}getContract(e,t,n=void 0){return this.getProviderAdapter(e).getContract(e,t,n)}getContractWithFetcherByChainId(e,t,n=void 0){return h.getContractWithFetcherByChainId(e,t,n)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,t,n){return await this.getProviderAdapter().signTypedData(e,t,n)}async signWithSubAccount(e,t,n,r){return P.hinkalSignSubAccount(e,t,n,r)}getContractWithSigner(e,t,n=``){return this.getProviderAdapter(e).getContractWithSigner(e,t,n)}getContractWithFetcher(e,t,n=``){return this.getProviderAdapter(e).getContractWithFetcher(e,t,n)}isSelectedNetworkSupported(e){return!!r.networkRegistry[e]}async switchNetwork(e){let t=this.getProviderAdapter(),n=t.getChainId(),i=n!==void 0&&r.isSameOnchainNetwork(e.chainId,n);if(!(e.chainId===n||i))try{await t.switchNetwork(e)}catch{throw Error(s.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}isPermitterAvailable(e){return this.getProviderAdapter(e).isPermitterAvailable()}async disconnectFromConnector(){await this.ethereumProviderAdapter?.disconnectFromConnector(),await this.solanaProviderAdapter?.disconnectFromConnector(),await this.tronProviderAdapter?.disconnectFromConnector()}async resetProviderAdapters(){this.ethereumProviderAdapter=void 0,this.solanaProviderAdapter=void 0,this.tronProviderAdapter=void 0}async updateProviderAdapter(e,t){try{r.isSolanaLike(e)?(this.solanaProviderAdapter&&this.solanaProviderAdapter.release(),this.solanaProviderAdapter=t):r.isTronLike(e)?(this.tronProviderAdapter&&this.tronProviderAdapter.release(),this.tronProviderAdapter=t):(this.ethereumProviderAdapter&&this.ethereumProviderAdapter.release(),this.ethereumProviderAdapter=t)}catch(e){throw console.error(e),Error(`updateProviderAdapter failed, please try again.`)}}async setListeners(){this.ethereumProviderAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}}),this.solanaProviderAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}}),this.tronProviderAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}})}async onAccountChanged(){await this.ethereumProviderAdapter?.onAccountChanged(),await this.solanaProviderAdapter?.onAccountChanged(),await this.tronProviderAdapter?.onAccountChanged();let e=i.EventType.AccountChanged;typeof document<`u`?document?.dispatchEvent(new Event(e)):process?.emit(`message`,e,void 0)}async onChainChanged(e){e?await this.getProviderAdapter(e).onChainChanged(e):(await this.disconnectFromConnector(),g.reloadPage())}async monitorConnectedAddress(e){await a.API.monitor(await this.getEthereumAddressByChain(e))}async getBalances(e,t,n,r,i=!1,a,o=!1){return p.getShieldedBalance(this,e,t,n,r,i,this.generateProofRemotely,a,o)}async getTotalBalance(e,t,r,i=!1,a,o=!1){let s=r??await this.getEthereumAddressByChain(e),l=t??this.userKeys,u=await this.getBalances(e,l.getShieldedPrivateKey(),l.getShieldedPublicKey(),s,i,a,o),d=n.isExtension?await f.privateTokensDB.getPrivateTokens(e,s):c.getErc20TokensForChain(e),p=[];return d.forEach(e=>{let t=e.erc20TokenAddress.toLowerCase(),n=u.get(t),r={token:e,balance:n?.balance??0n,timestamp:n?.timestamp||`0`,nfts:n?.nfts||[]};p.push(r)}),p}async getStuckShieldedBalances(e,t,n){return(await this.getTotalBalance(e,t,n,!1,!1,!0)).filter(e=>e.balance>0n)}getSupportedPassportLinks(){return o.supportedPassportLinks}checkAccessToken(e,t){return Promise.resolve(!0)}checkExternalTokenLimitsUSD(e,t,n){return w.checkTokenLimitsUSD(e,t,n)}async getHinkalTreeRootHash(t){if(r.isSolanaLike(t)){let{hinkalIdl:e,hinkalAddress:n,originalDeployer:i}=r.networkRegistry[t].contractData;if(!e||!n||!i)throw Error(`Missing Solana configuration for chain ${t}`);let a=new $.PublicKey(i),o=m.getMerkleAccountPublicKey(new $.PublicKey(n),a);return x.fetchSolanaMerkleTreeRootHash(this.getSolanaProgram(e),o)}return this.getContractWithFetcherByChainId(t,e.ContractType.HinkalContract).getRootHash()}async resetMerkleTreesIfNecessary(e){let t=(await Promise.all((e??this.getSupportedChains()).map(async e=>{let t=await this.getHinkalTreeRootHash(e);return{chainId:e,needsReset:BigInt(t)!==this.merkleTreeHinkalByChain[e].getRootHash()}}))).filter(e=>e.needsReset).map(e=>e.chainId);t.length>0&&(console.log(`resetting merkle tree in resetMerkleTreesIfNecessary for chains:`,t),await this.resetMerkle(t))}async getEthereumAddress(){let e=this.ethereumProviderAdapter??this.solanaProviderAdapter??this.tronProviderAdapter;if(!e)throw Error(`No provider adapter initialized`);return e.getAddress()}getEthereumAddressByChain(e){return this.getProviderAdapter(e).getAddress()}async getRandomRelay(e,t=!1){return(await a.API.getIdleRelay(e,t)).relay}getGasPrice(e){let t=this.getProviderAdapter(e);if(!t)throw Error(`Illegal State of providerAdapter in Hinkal: no providerAdapter initialized`);return t.getGasPrice(e)}getAPI(){return a.API}snapshotsClearInterval(){this.getSupportedChains().forEach(e=>{this.commitmentsSnapshotServiceByChain[e]?.intervalClear(),this.nullifierSnapshotServiceByChain[e]?.intervalClear()})}getRecipientInfo(){return N.getRecipientInfo(this)}async deposit(e,t,n=!0,r=!1){return C.hinkalDeposit(this,e,t,n,r)}async depositSolana(e,t,n=!1){return E.hinkalSolanaDeposit(this,e,t,n)}async depositForOther(e,t,n,r=!0,i=!1,a){return this.enforceRateLimit(this.depositForOther.name,[e,t,n]),C.hinkalDepositForOther(this,e,t,n,r,i,a)}async depositSolanaForOther(e,t,n,r=!1,i){return this.enforceRateLimit(this.depositSolanaForOther.name,[e,t,n]),E.hinkalSolanaDepositForOther(this,e,t,n,r,i)}async depositAndWithdraw(e,t,n,i,a,o,s,c,l=!0){return r.isSolanaLike(d.validateAndGetChainId([e]))?V.hinkalSolanaDepositAndWithdraw(this,e,t,n,i,a,o,s,c):T.hinkalDepositAndWithdraw(this,e,t,n,i,a,o,s,c,l)}async claimUtxo(e,t,n,i){return r.isSolanaLike(d.validateAndGetChainId([e]))?Z.hinkalSolanaClaimUtxo(this,e,t,n,i):Y.hinkalClaimUtxo(this,e,t,n,i)}async depositAndBridge(e,t,n,r,i,a,o,s=!0){return J.hinkalDepositAndBridge(this,e,t,n,r,i,a,o,s)}async prooflessDeposit(e,t,n,i,a=!1){return r.isSolanaLike(d.validateAndGetChainId(e))?X.hinkalSolanaProoflessDeposit(this,e,t,n,i,a):I.hinkalProoflessDeposit(this,e,t,n,i,a)}async prooflessDepositWithPublicFee(e,t,n,i,a){let o=d.validateAndGetChainId([e]);return r.isSolanaLike(o)?E.hinkalSolanaProoflessDepositWithPublicFee(this,e,t,n,i,a):I.hinkalProoflessDepositWithPublicFee(this,o,e,t,n,i,a)}getSolanaProgram(e){if(!this.solanaProviderAdapter)throw Error(`No provider adapter initialized`);if(!(`getSolanaProgram`in this.solanaProviderAdapter))throw Error(`Current provider adapter is not a Solana provider adapter`);return this.solanaProviderAdapter.getSolanaProgram(e)}getSolanaPublicKey(){if(!this.solanaProviderAdapter)throw Error(`No provider adapter initialized`);if(!(`getSolanaPublicKey`in this.solanaProviderAdapter))throw Error(`Current provider adapter is not a Solana provider adapter`);return this.solanaProviderAdapter.getSolanaPublicKey()}async transfer(e,t,n,i,a,o){return this.enforceRateLimit(this.transfer.name,[e,t,n]),r.isSolanaLike(d.validateAndGetChainId(e))?U.hinkalSolanaTransfer(this,e,t,n,i,a,o):R.hinkalTransfer(this,e,t,n,i,a,o)}async withdraw(e,t,n,i,a,o,s){return r.isSolanaLike(d.validateAndGetChainId(e))?H.hinkalSolanaWithdraw(this,e,t,n,a,o,s):O.hinkalWithdraw(this,e,t,n,i,a,o,s)}async withdrawStuckUtxos(e,t){return Q.hinkalWithdrawStuckUtxos(this,e,t)}async swap(e,t,n,i,a,o,s){return r.isSolanaLike(d.validateAndGetChainId(e))?this.swapSolana(e,t,i,a,o,s):D.hinkalSwap(this,e,t,n,i,a,o,s)}async swapSolana(e,t,n,r,i,a){let o=JSON.parse(n),s=BigInt(o.swapperAccountSalt),{instructionLists:c,addressLookupTableAccount:l}=o.data;return W.hinkalSolanaSwap(this,e,t,s,c,l,r,i,a)}async actionReceive(e,t,n,i,a,o){if(!a)throw Error(`subAccount is required`);return r.isSolanaLike(d.validateAndGetChainId(e))?q.hinkalSolanaProxyShield(this,e[0],t[0],a,void 0,o):F.hinkalActionReceive(this,e,t,n,i,a,o)}async actionPrivateWallet(e,t,n,r,i,a,o,s,c,l,u=!1,d,f,p){return this.enforceRateLimit(this.actionPrivateWallet.name,[e,t,n,r,i,a,o,s,c,p]),M.hinkalPrivateWallet(this,e,t,n,r,i,a,o,s,c,l,u,d,f,p)}async proxySwap(e,t,n,i,a,o,s,c,l=!1,u,f){return r.isSolanaLike(d.validateAndGetChainId(e))?K.hinkalSolanaProxySwap(this,e,t,i,o,n,s,c,f):ee.hinkalProxySwap(this,e,t,n,i,a,o,s,c,l,u,f)}async proxyToPrivate(e,t,n,i,a,o,s){return r.isSolanaLike(d.validateAndGetChainId(e))?(this.enforceRateLimit(this.proxyToPrivate.name,[e[0],t[0],n,i]),q.hinkalSolanaProxyShield(this,e[0],t[0],n,i,s)):z.hinkalProxyToPrivate(this,e,t,i,a,o,n,s)}async proxySend(e,t,n,i,a,o,s){let c=d.validateAndGetChainId(e);if(r.isSolanaLike(c))return G.hinkalSolanaProxySend(this,e[0],t[0],n,i,s);let l=S.createTransaferEmporiumOpsBatch(this,c,e.map(e=>e.erc20TokenAddress),t,i),u=e.map((e,n)=>({token:e,amount:-1n*t[n]}));return await this.actionPrivateWallet(c,[],[],[],l,u,n,a,o,void 0,void 0,void 0,s,void 0)}async multiSendPrivateRecipients(e,t,n){return this.enforceRateLimit(this.multiSendPrivateRecipients.name,[e,t,n]),L.hinkalMultiSendPrivateRecipients(this,e,t,n)}areMerkleTreeUpdatesDisabled(){return this.disableMerkleTreeUpdates}updateMerkleTreeUpdates(e){this.disableMerkleTreeUpdates=e}};exports.Hinkal=te;
|
|
@@ -88,7 +88,7 @@ export declare class Hinkal<ConnectorType> implements IHinkal {
|
|
|
88
88
|
depositForOther(erc20Tokens: ERC20Token[], amountChanges: bigint[], recipientInfo: string, preEstimateGas?: boolean, returnTxData?: boolean, action?: AdminTransactionType): Promise<ethers.TransactionResponse | ethers.TransactionRequest | string | TronWebTypes.Transaction<TronWebTypes.TriggerSmartContract>>;
|
|
89
89
|
depositSolanaForOther(amount: bigint, token: ERC20Token, recipientInfo: string, returnTxData?: boolean, action?: AdminTransactionType): Promise<string>;
|
|
90
90
|
depositAndWithdraw(erc20Token: ERC20Token, recipientAmounts: bigint[], recipientAddresses: string[], txCompletionTime?: number, feeStructureOverride?: FeeStructure, ref?: string, action?: AdminTransactionType, dashboardAccountId?: string, preEstimateGas?: boolean): Promise<string>;
|
|
91
|
-
claimUtxo(erc20Token: ERC20Token, utxo: Utxo,
|
|
91
|
+
claimUtxo(erc20Token: ERC20Token, utxo: Utxo, feeStructureOverride?: FeeStructure, claimableSignature?: string): Promise<string>;
|
|
92
92
|
depositAndBridge(erc20Token: ERC20Token, recipientBridges: BridgeRecipient[], txCompletionTime?: number, feeStructureOverride?: FeeStructure, ref?: string, action?: AdminTransactionType, dashboardAccountId?: string, preEstimateGas?: boolean): Promise<string>;
|
|
93
93
|
prooflessDeposit(erc20Tokens: ERC20Token[], amountChanges: bigint[], stealthAddressStructures?: StealthAddressStructure[], action?: AdminTransactionType, returnTxData?: boolean): Promise<string | ethers.TransactionRequest | TronWebTypes.Transaction<TronWebTypes.TriggerSmartContract>>;
|
|
94
94
|
prooflessDepositWithPublicFee(erc20Token: ERC20Token, amounts: bigint[], stealthAddressStructures: StealthAddressStructure[], feeAmount: bigint, action?: AdminTransactionType): Promise<string>;
|
|
@@ -323,7 +323,7 @@ var he = class {
|
|
|
323
323
|
return l(_([e])) ? ae(this, e, t, n, r, i, a, o, s) : M(this, e, t, n, r, i, a, o, s, c);
|
|
324
324
|
}
|
|
325
325
|
async claimUtxo(e, t, n, r) {
|
|
326
|
-
return l(_([e])) ? pe(this, e, t,
|
|
326
|
+
return l(_([e])) ? pe(this, e, t, n, r) : de(this, e, t, n, r);
|
|
327
327
|
}
|
|
328
328
|
async depositAndBridge(e, t, n, r, i, a, o, s = !0) {
|
|
329
329
|
return ue(this, e, t, n, r, i, a, o, s);
|
|
@@ -50,7 +50,7 @@ export interface IHinkal<ConnectorType = unknown> {
|
|
|
50
50
|
getRecipientInfo(): string;
|
|
51
51
|
deposit(erc20Tokens: ERC20Token[], amountChanges: bigint[], preEstimateGas?: boolean, returnTxData?: boolean): Promise<ethers.TransactionResponse | ethers.TransactionRequest | string | TronWebTypes.Transaction<TronWebTypes.TriggerSmartContract>>;
|
|
52
52
|
depositForOther(erc20Tokens: ERC20Token[], amountChanges: bigint[], recepinetInfo: string, preEstimateGas?: boolean, returnTxData?: boolean, action?: AdminTransactionType): Promise<ethers.TransactionResponse | ethers.TransactionRequest | string | TronWebTypes.Transaction<TronWebTypes.TriggerSmartContract>>;
|
|
53
|
-
claimUtxo(erc20Token: ERC20Token, utxo: Utxo,
|
|
53
|
+
claimUtxo(erc20Token: ERC20Token, utxo: Utxo, feeStructureOverride?: FeeStructure, claimableSignature?: string): Promise<string>;
|
|
54
54
|
depositAndWithdraw(erc20Token: ERC20Token, recipientAmounts: bigint[], recipientAddresses: string[], txCompletionTime?: number, feeStructureOverride?: FeeStructure, ref?: string, action?: AdminTransactionType, dashboardAccountId?: string, preEstimateGas?: boolean): Promise<string>;
|
|
55
55
|
depositAndBridge(erc20Token: ERC20Token, recipientBridges: BridgeRecipient[], txCompletionTime?: number, feeStructureOverride?: FeeStructure, ref?: string, action?: AdminTransactionType, dashboardAccountId?: string, preEstimateGas?: boolean): Promise<string>;
|
|
56
56
|
prooflessDeposit(erc20Tokens: ERC20Token[], amountChanges: bigint[], stealthAddressStructures?: StealthAddressStructure[], action?: AdminTransactionType, returnTxData?: boolean): Promise<string | ethers.TransactionRequest | TronWebTypes.Transaction<TronWebTypes.TriggerSmartContract>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../types/external-action.types.cjs`),t=require(`../../constants/chains.constants.cjs`),n=require(`../../types/transactions.types.cjs`),r=require(`../../types/admin.types.cjs`),i=require(`../../types/activities.types.cjs`),a=require(`../../types/transaction.types.cjs`),o=require(`../../types/offscreen.types.cjs`);require(`../../types/index.cjs`);const s=require(`../../functions/utils/caseInsensitive.utils.cjs`),c=require(`../../API/API.cjs`),l=require(`../../error-handling/error-codes.constants.cjs`),u=require(`../../functions/web3/etherFunctions.cjs`),d=require(`../../functions/utils/erc20tokenFunctions.cjs`),f=require(`../../functions/utils/time.utils.cjs`),p=require(`../../error-handling/customErrors/ErrorWithTx.cjs`),m=require(`../../error-handling/logger.cjs`),h=require(`../../
|
|
1
|
+
const e=require(`../../types/external-action.types.cjs`),t=require(`../../constants/chains.constants.cjs`),n=require(`../../types/transactions.types.cjs`),r=require(`../../types/admin.types.cjs`),i=require(`../../types/activities.types.cjs`),a=require(`../../types/transaction.types.cjs`),o=require(`../../types/offscreen.types.cjs`);require(`../../types/index.cjs`);const s=require(`../../functions/utils/caseInsensitive.utils.cjs`),c=require(`../../API/API.cjs`),l=require(`../../error-handling/error-codes.constants.cjs`),u=require(`../../functions/web3/etherFunctions.cjs`),d=require(`../../functions/utils/erc20tokenFunctions.cjs`),f=require(`../../functions/utils/time.utils.cjs`),p=require(`../../error-handling/customErrors/ErrorWithTx.cjs`),m=require(`../../error-handling/logger.cjs`),h=require(`../../error-handling/get-error.message.cjs`);require(`../../error-handling/index.cjs`);const g=require(`../../functions/pre-transaction/getVolatileTransferAmount.cjs`),_=require(`../../functions/utils/create-provider.cjs`),v=require(`../../functions/pre-transaction/getFeeStructure.cjs`),y=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),b=require(`../../functions/utils/postToOffscreen.cjs`),x=require(`../../functions/utils/fees.utils.cjs`),S=require(`../../functions/private-wallet/emporium.helpers.cjs`),C=require(`../../functions/auto-deposit-back-helpers/get-tokens-to-deposit-back.cjs`),w=require(`../../functions/auto-deposit-back-helpers/get-gas-token-records.cjs`),T=require(`../../functions/auto-deposit-back-helpers/select-gas-token.cjs`),ee=require(`../../functions/auto-deposit-back-helpers/update-hinkal.cjs`);require(`../../functions/index.cjs`);const E=require(`../IndexedDB/activity-db.cjs`);require(`../IndexedDB/index.cjs`);var D=3*1e3,O=13*1e3,k=async(k,A,j,M,N,P,F,I)=>{if(!j||F.length===0)return;let L;try{let a=_.createJsonRpcProvider(A);await f.waitLittle(A===t.chainIds.ethMainnet?O:D);let p=await C.getTokensToDepositBack(F,N,j,a);if(!p.length){b.postToOffscreen(o.MessagesFromOffscreen.AutoShieldTxStatus,{message:l.transactionErrorCodes.AUTO_SHIELD_SKIPPED});return}let m=x.getGasTokenSymbols(A).map(e=>d.getERC20TokenBySymbol(e,A)).filter(e=>e!==void 0),{prices:h}=await c.API.getTokenPrices(A,m.map(e=>e.erc20TokenAddress)),R=new Map(h.map((e,t)=>[m[t].erc20TokenAddress.toLowerCase(),e])),z=p.map(({token:e})=>e),B=p.map(({balance:e})=>e),V=z.map(({erc20TokenAddress:e})=>e),H=S.createTransaferEmporiumOpsBatch(k,A,V,await g.modifyVolatileTokenAmountChanges(A,z,B,j)),U=await v.getFeeStructure(A,N,V,e.ExternalActionId.Emporium,H.map(e=>y.convertEmporiumOpToCallInfo(e,j,A))),{flatFee:W}=U??{},G=d.getERC20Token(U.feeToken,A);if(!G)return;let K=u.getAmountInToken(G,W),q=(R.get(G.erc20TokenAddress.toLowerCase())??0)*Number(K),J=await T.selectGasToken(N,q,A,z,H,await w.getGasTokenRecords(m,A,k,j,a,R),U,V,j);if(!J)return;let{feeToken:Y,feeStructure:X}=J??{};if(P&&Number(P)<q){b.postToOffscreen(o.MessagesFromOffscreen.AutoShieldTxStatus,{message:l.gasErrorCodes.GAS_PRICE_EXCEEDS_AUTOSHIELD_LIMIT});return}let Z=z.findIndex(e=>s.caseInsensitiveEqual(e.erc20TokenAddress,Y));Z!==-1&&(B[Z]-=X?.flatFee??0n);let{hinkalAddress:Q}=t.networkRegistry[A].contractData,$={activityType:i.ActivityTypes.AUTO_SHIELD,chainId:A,from:j,to:Q,gasInDollar:q.toString(),tokensReceive:z.map((e,t)=>({amount:u.getAmountInToken(e,B[t]),token:e}))};L=await E.activityStorage.saveTxRequest($),b.postToOffscreen(o.MessagesFromOffscreen.AutoShieldTxStatus,{status:n.TransactionStatus.Loading}),ee.updateHinkal(I,A,k);let te={id:0,success:!0,txHash:await k.actionReceive(z,B,Y,X,M,r.AdminTransactionType.AutoShield)};await E.activityStorage.updatePendingTransactions(te,L),b.postToOffscreen(o.MessagesFromOffscreen.AutoShieldTxStatus,{status:n.TransactionStatus.Confirmed,activityRequest:$})}catch(e){let t;e instanceof p.ErrorWithRelayerTransaction&&(t=e.txHash);let r={error:e,id:0,success:!1,...t?{erroredTx:t}:{}};L&&await E.activityStorage.updatePendingTransactions(r,L),b.postToOffscreen(o.MessagesFromOffscreen.AutoShieldTxStatus,{status:n.TransactionStatus.Failed,error:h.getErrorMessageFromTransactionRequest(e,a.TransactionRequestType.ReceiveFromShieldedAccount)}),m.Logger.error(`Error in auto deposit back:`,e)}};exports.handleAutoDepositBack=k;
|
|
@@ -11,13 +11,13 @@ import { API as l } from "../../API/API.mjs";
|
|
|
11
11
|
import { gasErrorCodes as u, transactionErrorCodes as d } from "../../error-handling/error-codes.constants.mjs";
|
|
12
12
|
import { getAmountInToken as f } from "../../functions/web3/etherFunctions.mjs";
|
|
13
13
|
import { getERC20Token as p, getERC20TokenBySymbol as m } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
14
|
-
import { waitLittle as
|
|
15
|
-
import { ErrorWithRelayerTransaction as
|
|
16
|
-
import { Logger as
|
|
17
|
-
import {
|
|
18
|
-
import { getErrorMessageFromTransactionRequest as v } from "../../error-handling/get-error.message.mjs";
|
|
14
|
+
import { waitLittle as ee } from "../../functions/utils/time.utils.mjs";
|
|
15
|
+
import { ErrorWithRelayerTransaction as h } from "../../error-handling/customErrors/ErrorWithTx.mjs";
|
|
16
|
+
import { Logger as g } from "../../error-handling/logger.mjs";
|
|
17
|
+
import { getErrorMessageFromTransactionRequest as _ } from "../../error-handling/get-error.message.mjs";
|
|
19
18
|
import "../../error-handling/index.mjs";
|
|
20
|
-
import { modifyVolatileTokenAmountChanges as
|
|
19
|
+
import { modifyVolatileTokenAmountChanges as v } from "../../functions/pre-transaction/getVolatileTransferAmount.mjs";
|
|
20
|
+
import { createJsonRpcProvider as y } from "../../functions/utils/create-provider.mjs";
|
|
21
21
|
import { getFeeStructure as b } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
22
22
|
import { convertEmporiumOpToCallInfo as x } from "../../functions/utils/convertEmporiumOpToCallInfo.mjs";
|
|
23
23
|
import { postToOffscreen as S } from "../../functions/utils/postToOffscreen.mjs";
|
|
@@ -35,16 +35,16 @@ var te = 3 * 1e3, ne = 13 * 1e3, A = async (A, j, M, N, P, F, I, L) => {
|
|
|
35
35
|
if (!M || I.length === 0) return;
|
|
36
36
|
let R;
|
|
37
37
|
try {
|
|
38
|
-
let o =
|
|
39
|
-
await
|
|
40
|
-
let
|
|
41
|
-
if (!
|
|
38
|
+
let o = y(j);
|
|
39
|
+
await ee(j === t.ethMainnet ? ne : te);
|
|
40
|
+
let h = await T(I, P, M, o);
|
|
41
|
+
if (!h.length) {
|
|
42
42
|
S(s.AutoShieldTxStatus, { message: d.AUTO_SHIELD_SKIPPED });
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
|
-
let
|
|
45
|
+
let g = C(j).map((e) => m(e, j)).filter((e) => e !== void 0), { prices: _ } = await l.getTokenPrices(j, g.map((e) => e.erc20TokenAddress)), z = new Map(_.map((e, t) => [g[t].erc20TokenAddress.toLowerCase(), e])), B = h.map(({ token: e }) => e), V = h.map(({ balance: e }) => e), H = B.map(({ erc20TokenAddress: e }) => e), U = w(A, j, H, await v(j, B, V, M)), W = await b(j, P, H, e.Emporium, U.map((e) => x(e, M, j))), { flatFee: G } = W ?? {}, K = p(W.feeToken, j);
|
|
46
46
|
if (!K) return;
|
|
47
|
-
let q = f(K, G), J = (z.get(K.erc20TokenAddress.toLowerCase()) ?? 0) * Number(q), Y = await D(P, J, j, B, U, await E(
|
|
47
|
+
let q = f(K, G), J = (z.get(K.erc20TokenAddress.toLowerCase()) ?? 0) * Number(q), Y = await D(P, J, j, B, U, await E(g, j, A, M, o, z), W, H, M);
|
|
48
48
|
if (!Y) return;
|
|
49
49
|
let { feeToken: X, feeStructure: Z } = Y ?? {};
|
|
50
50
|
if (F && Number(F) < J) {
|
|
@@ -76,7 +76,7 @@ var te = 3 * 1e3, ne = 13 * 1e3, A = async (A, j, M, N, P, F, I, L) => {
|
|
|
76
76
|
});
|
|
77
77
|
} catch (e) {
|
|
78
78
|
let t;
|
|
79
|
-
e instanceof
|
|
79
|
+
e instanceof h && (t = e.txHash);
|
|
80
80
|
let n = {
|
|
81
81
|
error: e,
|
|
82
82
|
id: 0,
|
|
@@ -85,8 +85,8 @@ var te = 3 * 1e3, ne = 13 * 1e3, A = async (A, j, M, N, P, F, I, L) => {
|
|
|
85
85
|
};
|
|
86
86
|
R && await k.updatePendingTransactions(n, R), S(s.AutoShieldTxStatus, {
|
|
87
87
|
status: r.Failed,
|
|
88
|
-
error:
|
|
89
|
-
}),
|
|
88
|
+
error: _(e, o.ReceiveFromShieldedAccount)
|
|
89
|
+
}), g.error("Error in auto deposit back:", e);
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
92
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../types/external-action.types.cjs`),t=require(`../../constants/chains.constants.cjs`),n=require(`../../constants/protocol.constants.cjs`),r=require(`../../functions/utils/caseInsensitive.utils.cjs`),i=require(`../../error-handling/error-codes.constants.cjs`),a=require(`../crypto-keys/keys.cjs`),o=require(`../../functions/utils/time.utils.cjs`),s=require(`../utxo/Utxo.cjs`),c=require(`../../functions/utils/tron.utils.cjs`),l=require(`../../functions/utils/token-check.utils.cjs`),u=require(`../../functions/pre-transaction/outputUtxoProcessing.cjs`),d=require(`../../functions/pre-transaction/getFeeStructure.cjs`),f=require(`../../functions/
|
|
1
|
+
const e=require(`../../types/external-action.types.cjs`),t=require(`../../constants/chains.constants.cjs`),n=require(`../../constants/protocol.constants.cjs`),r=require(`../../functions/utils/caseInsensitive.utils.cjs`),i=require(`../../error-handling/error-codes.constants.cjs`),a=require(`../crypto-keys/keys.cjs`),o=require(`../../functions/utils/time.utils.cjs`),s=require(`../utxo/Utxo.cjs`),c=require(`../../functions/utils/tron.utils.cjs`),l=require(`../../functions/utils/token-check.utils.cjs`),u=require(`../../functions/pre-transaction/outputUtxoProcessing.cjs`),d=require(`../../functions/pre-transaction/getFeeStructure.cjs`),f=require(`../../functions/snarkjs/constructGeneralZkProof.cjs`),p=require(`../../functions/web3/functionCalls/transactCallRelayer.cjs`);var m=async(m,h,g,_,v)=>{let y=l.validateAndGetChainId([h]),b=t.isTronLike(y),x=h.erc20TokenAddress,S=c.addressToHexFormat(await m.getEthereumAddressByChain(y));if(!r.caseInsensitiveEqual(x,g.erc20TokenAddress))throw Error(`Off-chain UTXO token mismatch`);let C=v?new a.UserKeys(v):new a.UserKeys(g.nullifyingKey,g.nullifyingKey);if(!g.nullifyingKey&&!v)throw Error(`Claimable UTXO nullifyingKey is missing`);let w=C.getShieldedPrivateKey();if(g.nullifyingKey&&g.nullifyingKey!==w)throw Error(`Claimable UTXO key mismatch`);let T=m.getRecipientInfo(),E=s.Utxo.createFrom(g,{nullifyingKey:w}),D=new s.Utxo({amount:0n,erc20TokenAddress:E.erc20TokenAddress,mintAddress:E.mintAddress,nullifyingKey:w,...E.isNewStyle?{spendingPublicKey:C.getSpendingKeyPair().pubSpendingBJJPoint,isNewStyle:!0}:{isNewStyle:!1}}),O=_??await d.getFeeStructure(y,x,[x],e.ExternalActionId.Transact);if(!r.caseInsensitiveEqual(O.feeToken,x))throw Error(`Claim fee token mismatch: fee must be paid from claimed UTXO token`);let k=O.variableRate>0n?O.variableRate:n.HINKAL_PRIVATE_SEND_VARIABLE_RATE;if(E.amount<=O.flatFee)throw Error(i.transactionErrorCodes.INSUFFICIENT_FUNDS_TO_TRANSACT);let A=E.amount-O.flatFee,j=A*k/10000n,M=A-j;if(M<=0n)throw Error(i.transactionErrorCodes.RECIPIENT_AMOUNT_INVALID);let N={feeToken:O.feeToken,flatFee:O.flatFee+j,variableRate:0n},P=[-E.amount],F=await m.getRandomRelay(y,!0);if(!F)throw Error(i.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let I={externalActionId:0n,externalAddress:F??S,externalActionMetadata:`0x00`},L=[[E,D]],R=[],z=o.getCurrentTimeInSeconds().toString(),{outputUtxos:B}=u.outputUtxoProcessing(C,L[0],P[0],z,!0,T,M);R.push(B);let{zkCallData:V,circomData:H,dimData:U,commitmentValidationData:W}=await f.constructZkProof(m.merkleTreeHinkalByChain[y],L,R,C,I.externalActionId,I.externalAddress,I.externalActionMetadata,m.generateProofRemotely,N,F,y);return p.transactCallRelayer(y,V,U,H,W,void 0,void 0,void 0,await c.reorderZkCallData(b,V,U,H))};exports.hinkalClaimUtxo=m;
|
|
@@ -10,47 +10,45 @@ import { addressToHexFormat as c, reorderZkCallData as l } from "../../functions
|
|
|
10
10
|
import { validateAndGetChainId as u } from "../../functions/utils/token-check.utils.mjs";
|
|
11
11
|
import { outputUtxoProcessing as d } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
12
12
|
import { getFeeStructure as f } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
13
|
-
import {
|
|
14
|
-
import "../../functions/
|
|
15
|
-
import { constructZkProof as m } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
16
|
-
import { transactCallRelayer as h } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
13
|
+
import { constructZkProof as p } from "../../functions/snarkjs/constructGeneralZkProof.mjs";
|
|
14
|
+
import { transactCallRelayer as m } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
17
15
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalClaimUtxo.ts
|
|
18
|
-
var
|
|
19
|
-
let
|
|
20
|
-
if (!r(
|
|
21
|
-
let
|
|
22
|
-
if (!
|
|
23
|
-
let
|
|
24
|
-
if (
|
|
25
|
-
let
|
|
16
|
+
var h = async (h, g, _, v, y) => {
|
|
17
|
+
let b = u([g]), x = t(b), S = g.erc20TokenAddress, C = c(await h.getEthereumAddressByChain(b));
|
|
18
|
+
if (!r(S, _.erc20TokenAddress)) throw Error("Off-chain UTXO token mismatch");
|
|
19
|
+
let w = y ? new a(y) : new a(_.nullifyingKey, _.nullifyingKey);
|
|
20
|
+
if (!_.nullifyingKey && !y) throw Error("Claimable UTXO nullifyingKey is missing");
|
|
21
|
+
let T = w.getShieldedPrivateKey();
|
|
22
|
+
if (_.nullifyingKey && _.nullifyingKey !== T) throw Error("Claimable UTXO key mismatch");
|
|
23
|
+
let E = h.getRecipientInfo(), D = s.createFrom(_, { nullifyingKey: T }), O = new s({
|
|
26
24
|
amount: 0n,
|
|
27
|
-
erc20TokenAddress:
|
|
28
|
-
mintAddress:
|
|
29
|
-
nullifyingKey:
|
|
30
|
-
...
|
|
31
|
-
spendingPublicKey:
|
|
25
|
+
erc20TokenAddress: D.erc20TokenAddress,
|
|
26
|
+
mintAddress: D.mintAddress,
|
|
27
|
+
nullifyingKey: T,
|
|
28
|
+
...D.isNewStyle ? {
|
|
29
|
+
spendingPublicKey: w.getSpendingKeyPair().pubSpendingBJJPoint,
|
|
32
30
|
isNewStyle: !0
|
|
33
31
|
} : { isNewStyle: !1 }
|
|
34
|
-
}),
|
|
35
|
-
if (!r(
|
|
36
|
-
let
|
|
37
|
-
if (
|
|
38
|
-
let
|
|
39
|
-
if (
|
|
40
|
-
let
|
|
41
|
-
feeToken:
|
|
42
|
-
flatFee:
|
|
32
|
+
}), k = v ?? await f(b, S, [S], e.Transact);
|
|
33
|
+
if (!r(k.feeToken, S)) throw Error("Claim fee token mismatch: fee must be paid from claimed UTXO token");
|
|
34
|
+
let A = k.variableRate > 0n ? k.variableRate : n;
|
|
35
|
+
if (D.amount <= k.flatFee) throw Error(i.INSUFFICIENT_FUNDS_TO_TRANSACT);
|
|
36
|
+
let j = D.amount - k.flatFee, M = j * A / 10000n, N = j - M;
|
|
37
|
+
if (N <= 0n) throw Error(i.RECIPIENT_AMOUNT_INVALID);
|
|
38
|
+
let P = {
|
|
39
|
+
feeToken: k.feeToken,
|
|
40
|
+
flatFee: k.flatFee + M,
|
|
43
41
|
variableRate: 0n
|
|
44
|
-
},
|
|
45
|
-
if (!
|
|
46
|
-
let
|
|
42
|
+
}, F = [-D.amount], I = await h.getRandomRelay(b, !0);
|
|
43
|
+
if (!I) throw Error(i.RELAYER_NOT_AVAILABLE);
|
|
44
|
+
let L = {
|
|
47
45
|
externalActionId: 0n,
|
|
48
|
-
externalAddress:
|
|
46
|
+
externalAddress: I ?? C,
|
|
49
47
|
externalActionMetadata: "0x00"
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
let
|
|
53
|
-
return
|
|
48
|
+
}, R = [[D, O]], z = [], B = o().toString(), { outputUtxos: V } = d(w, R[0], F[0], B, !0, E, N);
|
|
49
|
+
z.push(V);
|
|
50
|
+
let { zkCallData: H, circomData: U, dimData: W, commitmentValidationData: G } = await p(h.merkleTreeHinkalByChain[b], R, z, w, L.externalActionId, L.externalAddress, L.externalActionMetadata, h.generateProofRemotely, P, I, b);
|
|
51
|
+
return m(b, H, W, U, G, void 0, void 0, void 0, await l(x, H, W, U));
|
|
54
52
|
};
|
|
55
53
|
//#endregion
|
|
56
|
-
export {
|
|
54
|
+
export { h as hinkalClaimUtxo };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../types/external-action.types.cjs`),t=require(`../../constants/chains.constants.cjs`),n=require(`../../constants/protocol.constants.cjs`),r=require(`../../types/scheduled-transactions.types.cjs`);require(`../../types/index.cjs`);const i=require(`../../functions/utils/caseInsensitive.utils.cjs`),a=require(`../../functions/utils/addresses.cjs`),o=require(`../../API/API.cjs`),s=require(`../../constants/addresses.constants.cjs`),c=require(`../../error-handling/error-codes.constants.cjs`),l=require(`../../functions/utils/erc20tokenFunctions.cjs`),u=require(`../../functions/utils/time.utils.cjs`),d=require(`../utxo/Utxo.cjs`),f=require(`../../functions/utils/token-check.utils.cjs`),p=require(`../../functions/pre-transaction/constructAdminData.cjs`),m=require(`../../functions/pre-transaction/getFeeStructure.cjs`),h=require(`../../functions/pre-transaction/waitForDepositedUtxosInMerkleTree.cjs`),g=require(`../../functions/
|
|
1
|
+
const e=require(`../../types/external-action.types.cjs`),t=require(`../../constants/chains.constants.cjs`),n=require(`../../constants/protocol.constants.cjs`),r=require(`../../types/scheduled-transactions.types.cjs`);require(`../../types/index.cjs`);const i=require(`../../functions/utils/caseInsensitive.utils.cjs`),a=require(`../../functions/utils/addresses.cjs`),o=require(`../../API/API.cjs`),s=require(`../../constants/addresses.constants.cjs`),c=require(`../../error-handling/error-codes.constants.cjs`),l=require(`../../functions/utils/erc20tokenFunctions.cjs`),u=require(`../../functions/utils/time.utils.cjs`),d=require(`../utxo/Utxo.cjs`),f=require(`../../functions/utils/token-check.utils.cjs`),p=require(`../../functions/pre-transaction/constructAdminData.cjs`),m=require(`../../functions/pre-transaction/getFeeStructure.cjs`),h=require(`../../functions/pre-transaction/waitForDepositedUtxosInMerkleTree.cjs`),g=require(`../../functions/utils/convertEmporiumOpToCallInfo.cjs`),_=require(`../../functions/utils/fees.utils.cjs`);require(`../../functions/utils/index.cjs`);const v=require(`../../functions/private-wallet/emporium.helpers.cjs`),y=require(`../../functions/snarkjs/constructGeneralZkProof.cjs`),b=require(`../../functions/web3/functionCalls/transactCallRelayer.cjs`),x=require(`../../API/deposit-and-withdraw-status-calls.cjs`),S=require(`./hinkalDepositOnChainUtxos.cjs`);require(`../../functions/index.cjs`);var C=async(a,l,f,m,h,g,S,C,w,T,E)=>{if(m.length===0)throw Error(`No recipients to bridge`);let D=f.erc20TokenAddress,{contractData:O}=t.networkRegistry[l],{emporiumAddress:k}=O;if(!k)throw Error(`No Emporium Address`);let A=s.SWAP_ROUTER_ADDRESSES[e.ExternalActionId.Lifi][l];if(!A)throw Error(`LIFI not configured for chain ${l}`);let j=await a.getRandomRelay(l);if(!j)throw Error(c.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let M=await a.getEthereumAddressByChain(l),N=u.getCurrentTimeInSeconds().toString(),P=a.generateProofRemotely?5:1,F=[];for(let t=0;t<m.length;t+=P){let r=m.slice(t,t+P),s=await Promise.all(r.map(async({utxo:t,nativeUtxo:r,bridgeAmount:s,quote:c,temporarySubAccount:u,recipientAddress:m})=>{await o.API.addTemporaryWalletNonce(l,g,u.index);let b=c.nativeFee>0n&&!i.caseInsensitiveEqual(D,n.zeroAddress),x=[D],S=[-t.amount],C=[!1],w=new d.Utxo({amount:0n,erc20TokenAddress:D,nullifyingKey:a.userKeys.getShieldedPrivateKey(),timeStamp:N,...t.isNewStyle?{spendingPublicKey:a.userKeys.getSpendingKeyPair().pubSpendingBJJPoint,isNewStyle:!0}:{isNewStyle:!1}}),E=[[t,w]],O=[[w]];if(b&&r){let e=new d.Utxo({amount:0n,erc20TokenAddress:n.zeroAddress,nullifyingKey:a.userKeys.getShieldedPrivateKey(),timeStamp:N,...r.isNewStyle?{spendingPublicKey:a.userKeys.getSpendingKeyPair().pubSpendingBJJPoint,isNewStyle:!0}:{isNewStyle:!1}});x.push(n.zeroAddress),S.push(-r.amount),C.push(!1),E.push([r,e]),O.push([e])}let P=v.createLifiBridgeOps(a,l,u.ethAddress,A,D,t.amount,s,c),F=await _.calculateModifiedFeeStructure(l,f,s,h),I=p.constructAdminData(T,l,x,[-t.amount],M),[{zkCallData:L,circomData:R,dimData:z,commitmentValidationData:B},V]=await Promise.all([y.constructZkProof(a.merkleTreeHinkalByChain[l],E,O,a.userKeys,e.ExternalActionId.Emporium,k,P,a.generateProofRemotely,F,j??n.zeroAddress,l,C,void 0,void 0,u.privateKey),v.getAuthorizationDataIfNeeded(l,u.privateKey)]);return{zkCallData:L,dimData:z,circomData:R,commitmentValidationData:B,authorizationData:V,recipientAddress:m,adminData:I}}));F.push(...s)}await x.safeUpdateDepositAndWithdrawStatus({id:S,chainId:l,hashedEthereumAddress:g,phase:r.DepositAndWithdrawPhase.BEFORE_SCHEDULE_WITHDRAW});let I=await b.transactCallRelayerBatch(l,F,g,C,w,E);return await x.safeUpdateDepositAndWithdrawStatus({id:S,chainId:l,hashedEthereumAddress:g,phase:r.DepositAndWithdrawPhase.AFTER_SCHEDULE_WITHDRAW,scheduleId:I}),I},w=async(t,r,o,c,u,d,p,_,y=!0)=>{let b=r.erc20TokenAddress,x=f.validateAndGetChainId([r]),w=_?a.hashString(_):void 0,T=a.hashEthereumAddress(await t.getEthereumAddressByChain(x)),E=s.SWAP_ROUTER_ADDRESSES[e.ExternalActionId.Lifi][x];if(!E)throw Error(`LIFI router not configured`);let D;if(u)D=u;else{let r=o[0],i=v.createLifiBridgeOps(t,x,r.temporarySubAccount.ethAddress,E,b,r.bridgeAmount,r.bridgeAmount,r.quote).map(e=>g.convertEmporiumOpToCallInfo(e,r.temporarySubAccount.ethAddress,x));D=await m.getFeeStructure(x,b,[b],e.ExternalActionId.Emporium,i,n.PAY_SEND_VARIABLE_RATE)}let O={feeToken:D.feeToken,flatFee:0n,variableRate:0n},k=o.reduce((e,t)=>e+t.quote.nativeFee,0n)>0n&&!i.caseInsensitiveEqual(b,n.zeroAddress),A=o.map(e=>e.bridgeAmount),j=o.map(e=>e.recipientAddress),{userDepositedUtxos:M,statusId:N,depositTxHash:P}=await S.hinkalDepositOnChainUtxos(t,x,r,A,j,D,T,y),F=[];if(k){let e=l.getERC20Token(n.zeroAddress,x);if(!e)throw Error(`No native token`);let{userDepositedUtxos:r}=await S.hinkalDepositOnChainUtxos(t,x,e,o.map(e=>e.quote.nativeFee),j,O,T,y);F=r}return await h.waitForDepositedUtxosInMerkleTree(t,x,[...M,...F]),await C(t,x,r,o.map((e,t)=>({...e,utxo:M[t].utxo,nativeUtxo:k?F[t]?.utxo:void 0})),D,T,N,c,d,p,w),P};exports.hinkalDepositAndBridge=w;
|