UNPKG

@broxus/js-bridge-essentials

Version:

Bridge JavaScript Essentials library

67 lines (66 loc) 3.22 kB
import { getFullContractState } from '@broxus/js-core'; import { tvmTvmBaseEventContract } from '../../models/tvm-tvm-base-event/contracts'; export var TvmTvmBaseEventStatus; (function (TvmTvmBaseEventStatus) { TvmTvmBaseEventStatus["Initializing"] = "0"; TvmTvmBaseEventStatus["Pending"] = "1"; TvmTvmBaseEventStatus["Confirmed"] = "2"; TvmTvmBaseEventStatus["Rejected"] = "3"; TvmTvmBaseEventStatus["Cancelled"] = "4"; TvmTvmBaseEventStatus["LimitReached"] = "5"; TvmTvmBaseEventStatus["LiquidityRequested"] = "6"; TvmTvmBaseEventStatus["LiquidityProvided"] = "7"; TvmTvmBaseEventStatus["Verified"] = "8"; })(TvmTvmBaseEventStatus || (TvmTvmBaseEventStatus = {})); export class TvmTvmBaseEventUtils { static async getDetails(connection, eventAddress, cachedState) { const state = cachedState ?? await getFullContractState(connection, eventAddress); const result = await tvmTvmBaseEventContract(connection, eventAddress) .methods.getDetails({ answerId: 0 }) .call({ cachedState: state, responsible: true }); return { eventInitData: { chainId: result._eventInitData.chainId, configuration: result._eventInitData.configuration, msgHash: result._eventInitData.msgHash, }, initializer: result._initializer, meta: result._meta, status: result._status, }; } static async getEventInitData(connection, eventAddress, cachedState) { const state = cachedState ?? await getFullContractState(connection, eventAddress); const result = await tvmTvmBaseEventContract(connection, eventAddress) .methods.getEventInitData({ answerId: 0 }) .call({ cachedState: state, responsible: true }); return { chainId: result.value0.chainId, configuration: result.value0.configuration, msgHash: result.value0.msgHash, }; } static async nonce(connection, eventAddress, cachedState) { const state = cachedState ?? await getFullContractState(connection, eventAddress); const result = await tvmTvmBaseEventContract(connection, eventAddress) .methods.nonce() .call({ cachedState: state }); return result.nonce; } static async eventInitialBalance(connection, eventAddress, cachedState) { const state = cachedState ?? await getFullContractState(connection, eventAddress); const result = await tvmTvmBaseEventContract(connection, eventAddress) .methods.eventInitialBalance() .call({ cachedState: state }); return result.eventInitialBalance; } static decodeEvent(connection, eventAddress, args) { return tvmTvmBaseEventContract(connection, eventAddress).decodeEvent(args); } static decodeTransaction(connection, eventAddress, args) { return tvmTvmBaseEventContract(connection, eventAddress).decodeTransaction(args); } static decodeTransactionEvents(connection, eventAddress, transaction) { return tvmTvmBaseEventContract(connection, eventAddress).decodeTransactionEvents({ transaction }); } }