@broxus/js-bridge-essentials
Version:
Bridge JavaScript Essentials library
30 lines (29 loc) • 1.61 kB
JavaScript
import { getFullContractState } from '@broxus/js-core';
import { nativeProxyContract } from '../../models/native-proxy/contracts';
export class NativeProxyUtils {
static async getConfiguration(connection, proxyAddress, cachedState) {
const state = cachedState ?? await getFullContractState(connection, proxyAddress);
return nativeProxyContract(connection, proxyAddress)
.methods.getConfiguration({ answerId: 0 })
.call({ cachedState: state, responsible: true });
}
static async getTvmEvmConfiguration(connection, proxyAddress, cachedState) {
const result = await NativeProxyUtils.getConfiguration(connection, proxyAddress, cachedState);
return result.value0.everscaleConfiguration;
}
static async getSolTvmConfiguration(connection, proxyAddress, cachedState) {
const result = await NativeProxyUtils.getConfiguration(connection, proxyAddress, cachedState);
return result.value1.solanaConfiguration;
}
static async getTvmSolConfiguration(connection, proxyAddress, cachedState) {
const result = await NativeProxyUtils.getConfiguration(connection, proxyAddress, cachedState);
return result.value1.everscaleConfiguration;
}
static async getDexMiddleware(connection, proxyAddress, cachedState) {
const state = cachedState ?? await getFullContractState(connection, proxyAddress);
const result = await nativeProxyContract(connection, proxyAddress)
.methods.dex_middleware()
.call({ cachedState: state });
return result.dex_middleware;
}
}