@broxus/js-bridge-essentials
Version:
Bridge JavaScript Essentials library
54 lines (53 loc) • 2.94 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TonNativeProxyV2Utils = void 0;
const js_core_1 = require("@broxus/js-core");
const contracts_1 = require("../../models/ton-native-proxy/contracts");
class TonNativeProxyV2Utils {
static async getExpectedTokenFeeAddress(connection, proxyAddress, tokenAddress, cachedState) {
const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, proxyAddress);
const result = await (0, contracts_1.tonNativeProxyV2Contract)(connection, proxyAddress)
.methods.getExpectedTokenFeeAddress({
_token: (0, js_core_1.resolveTvmAddress)(tokenAddress),
answerId: 0,
})
.call({ cachedState: state, responsible: true });
return result.value0;
}
static async getTvmTokenFee(connection, proxyAddress, tokenAddress, cachedState) {
const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, proxyAddress);
return (0, contracts_1.tonNativeProxyV2Contract)(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.tonNativeProxyV2Contract)(connection, proxyAddress)
.methods.getConfiguration({ answerId: 0 })
.call({ cachedState: state, responsible: true });
}
static async getTonEvmConfiguration(connection, proxyAddress, cachedState) {
const result = await TonNativeProxyV2Utils.getConfiguration(connection, proxyAddress, cachedState);
return result.value0.tvmConfiguration;
}
static async getDexMiddleware(connection, proxyAddress, cachedState) {
const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, proxyAddress);
const result = await (0, contracts_1.tonNativeProxyV2Contract)(connection, proxyAddress)
.methods.dex_middleware()
.call({ cachedState: state });
return result.dex_middleware;
}
static decodeEvent(connection, proxyAddress, args) {
return (0, contracts_1.tonNativeProxyV2Contract)(connection, proxyAddress).decodeEvent(args);
}
static decodeTransaction(connection, proxyAddress, args) {
return (0, contracts_1.tonNativeProxyV2Contract)(connection, proxyAddress).decodeTransaction(args);
}
static decodeTransactionEvents(connection, proxyAddress, transaction) {
return (0, contracts_1.tonNativeProxyV2Contract)(connection, proxyAddress).decodeTransactionEvents({ transaction });
}
}
exports.TonNativeProxyV2Utils = TonNativeProxyV2Utils;