UNPKG

@broxus/js-bridge-essentials

Version:

Bridge JavaScript Essentials library

53 lines (52 loc) 3.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TvmSolEventConfigurationUtils = void 0; const js_core_1 = require("@broxus/js-core"); const contracts_1 = require("../../models/tvm-sol-event-configuration/contracts"); class TvmSolEventConfigurationUtils { static deployEvent(provider, eventConfigurationAddress, params, args) { return (0, contracts_1.tvmSolEventConfigurationContract)(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.tvmSolEventConfigurationContract)(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.tvmSolEventConfigurationContract)(connection, eventConfigurationAddress) .methods.getDetails({ answerId: 0 }) .call({ cachedState: state, responsible: true }); return ({ basicConfiguration: result._basicConfiguration, meta: result._meta, networkConfiguration: result._networkConfiguration, }); } static async getFlags(connection, eventConfigurationAddress, cachedState) { try { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, eventConfigurationAddress); const result = await (0, contracts_1.tvmSolEventConfigurationContract)(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.tvmSolEventConfigurationContract)(connection, eventConfigurationAddress).decodeEvent(args); } static decodeTransaction(connection, eventConfigurationAddress, args) { return (0, contracts_1.tvmSolEventConfigurationContract)(connection, eventConfigurationAddress).decodeTransaction(args); } static decodeTransactionEvents(connection, eventConfigurationAddress, transaction) { return (0, contracts_1.tvmSolEventConfigurationContract)(connection, eventConfigurationAddress).decodeTransactionEvents({ transaction }); } } exports.TvmSolEventConfigurationUtils = TvmSolEventConfigurationUtils;