UNPKG

@broxus/js-bridge-essentials

Version:

Bridge JavaScript Essentials library

104 lines (103 loc) 5.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NativeProxyV8Utils = void 0; const js_core_1 = require("@broxus/js-core"); const contracts_1 = require("../../models/native-proxy/contracts"); class NativeProxyV8Utils { static async deployTokenFee(provider, proxyAddress, params, args) { return (0, contracts_1.nativeProxyV8Contract)(provider, proxyAddress) .methods.deployTokenFee({ _remainingGasTo: (0, js_core_1.resolveTvmAddress)(params.remainingGasTo), _token: (0, js_core_1.resolveTvmAddress)(params.tokenAddress), }) .sendDelayed({ amount: (0, js_core_1.toInt)(6.6, js_core_1.DEFAULT_NATIVE_CURRENCY_DECIMALS), bounce: true, from: (0, js_core_1.resolveTvmAddress)(params.remainingGasTo), ...args, }); } static async getExpectedTokenFeeAddress(connection, proxyAddress, tokenAddress, cachedState) { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, proxyAddress); const result = await (0, contracts_1.nativeProxyV8Contract)(connection, proxyAddress) .methods.getExpectedTokenFeeAddress({ _token: (0, js_core_1.resolveTvmAddress)(tokenAddress), answerId: 0, }) .call({ cachedState: state, responsible: true }); return result.value0; } static async getDailyLimits(connection, proxyAddress, tokenAddress, cachedState) { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, proxyAddress); const result = await (0, contracts_1.nativeProxyV8Contract)(connection, proxyAddress) .methods.getDailyLimits({ _token: (0, js_core_1.resolveTvmAddress)(tokenAddress), answerId: 0, }) .call({ cachedState: state, responsible: true }); return { dailyIncomingVolume: result.value0.dailyIncomingVolume, dailyOutgoingVolume: result.value0.dailyOutgoingVolume, dayStartTimestamp: Number(result.value0.dayStartTimestamp), incomingLimit: result.value0.incomingLimit, outgoingLimit: result.value0.outgoingLimit, }; } static async getTvmDefaultFee(connection, proxyAddress, cachedState) { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, proxyAddress); return (0, contracts_1.nativeProxyV8Contract)(connection, proxyAddress) .methods.getTvmDefaultFee({ answerId: 0 }) .call({ cachedState: state, responsible: true }); } static async getTvmFees(connection, proxyAddress, cachedState) { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, proxyAddress); const result = await (0, contracts_1.nativeProxyV8Contract)(connection, proxyAddress) .methods.getTvmFees({ answerId: 0 }) .call({ cachedState: state, responsible: true }); return new Map(result.value0.flat(0).map(([addr, value]) => [addr.toString(), value])); } static async getTvmTokenFee(connection, proxyAddress, tokenAddress, cachedState) { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, proxyAddress); return (0, contracts_1.nativeProxyV8Contract)(connection, proxyAddress) .methods.getTvmTokenFee({ _token: (0, js_core_1.resolveTvmAddress)(tokenAddress), answerId: 0, }) .call({ cachedState: state, responsible: true }); } static async getConfiguration(connection, proxyAddress, cachedState) { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, proxyAddress); return (0, contracts_1.nativeProxyV8Contract)(connection, proxyAddress) .methods.getConfiguration({ answerId: 0 }) .call({ cachedState: state, responsible: true }); } static async getTvmEvmConfiguration(connection, proxyAddress, cachedState) { const result = await NativeProxyV8Utils.getConfiguration(connection, proxyAddress, cachedState); return result.value0.everscaleConfiguration; } static async getSolTvmConfiguration(connection, proxyAddress, cachedState) { const result = await NativeProxyV8Utils.getConfiguration(connection, proxyAddress, cachedState); return result.value1.solanaConfiguration; } static async getTvmSolConfiguration(connection, proxyAddress, cachedState) { const result = await NativeProxyV8Utils.getConfiguration(connection, proxyAddress, cachedState); return result.value1.everscaleConfiguration; } static async getDexMiddleware(connection, proxyAddress, cachedState) { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, proxyAddress); const result = await (0, contracts_1.nativeProxyV8Contract)(connection, proxyAddress) .methods.dex_middleware() .call({ cachedState: state }); return result.dex_middleware; } static decodeEvent(connection, eventConfigurationAddress, args) { return (0, contracts_1.nativeProxyV8Contract)(connection, eventConfigurationAddress).decodeEvent(args); } static decodeTransaction(connection, eventConfigurationAddress, args) { return (0, contracts_1.nativeProxyV8Contract)(connection, eventConfigurationAddress).decodeTransaction(args); } static decodeTransactionEvents(connection, eventConfigurationAddress, transaction) { return (0, contracts_1.nativeProxyV8Contract)(connection, eventConfigurationAddress).decodeTransactionEvents({ transaction }); } } exports.NativeProxyV8Utils = NativeProxyV8Utils;