UNPKG

@broxus/js-bridge-essentials

Version:

Bridge JavaScript Essentials library

63 lines (62 loc) 3.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EvmTvmEventConfigurationUtils = void 0; const js_core_1 = require("@broxus/js-core"); const contracts_1 = require("../../models/evm-tvm-event-configuration/contracts"); class EvmTvmEventConfigurationUtils { static deployEvent(provider, eventConfigurationAddress, params, args) { return (0, contracts_1.evmTvmEventConfigurationContract)(provider, eventConfigurationAddress) .methods.deployEvent({ eventVoteData: params.eventVoteData }) .sendDelayed({ bounce: true, ...args }); } static async deriveEventAddress(connection, eventConfigurationAddress, params, cachedState) { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, eventConfigurationAddress); const result = await (0, contracts_1.evmTvmEventConfigurationContract)(connection, eventConfigurationAddress) .methods.deriveEventAddress({ answerId: 0, eventVoteData: params.eventVoteData, }) .call({ cachedState: state, responsible: true }); return result.eventContract; } static async getDetails(connection, eventConfigurationAddress, cachedState) { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, eventConfigurationAddress); const result = await (0, contracts_1.evmTvmEventConfigurationContract)(connection, eventConfigurationAddress) .methods.getDetails({ answerId: 0 }) .call({ cachedState: state, responsible: true }); return ({ basicConfiguration: result._basicConfiguration, meta: result._meta, networkConfiguration: { chainId: result._networkConfiguration.chainId, endBlockNumber: Number(result._networkConfiguration.endBlockNumber), eventBlocksToConfirm: Number(result._networkConfiguration.eventBlocksToConfirm), eventEmitter: result._networkConfiguration.eventEmitter, proxy: result._networkConfiguration.proxy, startBlockNumber: Number(result._networkConfiguration.startBlockNumber), }, }); } static async getFlags(connection, eventConfigurationAddress, cachedState) { try { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, eventConfigurationAddress); const result = await (0, contracts_1.evmTvmEventConfigurationContract)(connection, eventConfigurationAddress) .methods.getFlags({ answerId: 0 }) .call({ cachedState: state, responsible: true }); return result._flags; } catch { return '0'; } } static decodeEvent(connection, eventConfigurationAddress, args) { return (0, contracts_1.evmTvmEventConfigurationContract)(connection, eventConfigurationAddress).decodeEvent(args); } static decodeTransaction(connection, eventConfigurationAddress, args) { return (0, contracts_1.evmTvmEventConfigurationContract)(connection, eventConfigurationAddress).decodeTransaction(args); } static decodeTransactionEvents(connection, eventConfigurationAddress, transaction) { return (0, contracts_1.evmTvmEventConfigurationContract)(connection, eventConfigurationAddress).decodeTransactionEvents({ transaction }); } } exports.EvmTvmEventConfigurationUtils = EvmTvmEventConfigurationUtils;