UNPKG

@broxus/js-bridge-essentials

Version:

Bridge JavaScript Essentials library

58 lines (57 loc) 3.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TonEvmEventConfigurationUtils = void 0; const js_core_1 = require("@broxus/js-core"); const contracts_1 = require("../../models/ton-evm-event-configuration/contracts"); class TonEvmEventConfigurationUtils { static deployEvent(provider, eventConfigurationAddress, params, args) { return (0, contracts_1.tonEvmEventConfigurationContract)(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.tonEvmEventConfigurationContract)(connection, eventConfigurationAddress) .methods.deriveEventAddress({ _eventVoteData: params.eventVoteData, answerId: 0 }) .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.tonEvmEventConfigurationContract)(connection, eventConfigurationAddress) .methods.getDetails({ answerId: 0 }) .call({ cachedState: state, responsible: true }); return { basicConfiguration: result._basicConfiguration, meta: result._meta, networkConfiguration: { endTimestamp: Number(result._networkConfiguration.endTimestamp), eventEmitter: result._networkConfiguration.eventEmitter, proxy: result._networkConfiguration.proxy, startTimestamp: Number(result._networkConfiguration.startTimestamp), }, }; } static async getFlags(connection, eventConfigurationAddress, cachedState) { try { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, eventConfigurationAddress); const result = await (0, contracts_1.tonEvmEventConfigurationContract)(connection, eventConfigurationAddress) .methods.getFlags({ answerId: 0 }) .call({ cachedState: state, responsible: true }); return result._flags; } catch { return undefined; } } static decodeEvent(connection, eventConfigurationAddress, args) { return (0, contracts_1.tonEvmEventConfigurationContract)(connection, eventConfigurationAddress).decodeEvent(args); } static decodeTransaction(connection, eventConfigurationAddress, args) { return (0, contracts_1.tonEvmEventConfigurationContract)(connection, eventConfigurationAddress).decodeTransaction(args); } static decodeTransactionEvents(connection, eventConfigurationAddress, transaction) { return (0, contracts_1.tonEvmEventConfigurationContract)(connection, eventConfigurationAddress).decodeTransactionEvents({ transaction }); } } exports.TonEvmEventConfigurationUtils = TonEvmEventConfigurationUtils;