UNPKG

@broxus/js-bridge-essentials

Version:

Bridge JavaScript Essentials library

81 lines (80 loc) 3.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TokenTransferTvmEvmEventUtils = exports.TokenTransferTvmEvmStatus = void 0; const js_core_1 = require("@broxus/js-core"); const contracts_1 = require("../../models/token-transfer-tvm-evm-event/contracts"); var TokenTransferTvmEvmStatus; (function (TokenTransferTvmEvmStatus) { TokenTransferTvmEvmStatus["Initializing"] = "0"; TokenTransferTvmEvmStatus["Pending"] = "1"; TokenTransferTvmEvmStatus["Confirmed"] = "2"; TokenTransferTvmEvmStatus["Rejected"] = "3"; })(TokenTransferTvmEvmStatus || (exports.TokenTransferTvmEvmStatus = TokenTransferTvmEvmStatus = {})); /** * @deprecated Use TvmEvmBaseEventUtils instead */ class TokenTransferTvmEvmEventUtils { static async getEventInitData(connection, eventAddress, cachedState) { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, eventAddress); const result = await (0, contracts_1.tokenTransferTvmEvmEventContract)(connection, eventAddress) .methods.getEventInitData({ answerId: 0 }) .call({ cachedState: state, responsible: true }); return { configuration: result.value0.configuration, staking: result.value0.staking, voteData: { eventData: result.value0.voteData.eventData, eventTimestamp: Number(result.value0.voteData.eventTimestamp), eventTransactionLt: result.value0.voteData.eventTransactionLt, }, }; } static async getDecodedData(connection, eventAddress, cachedState) { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, eventAddress); const result = await (0, contracts_1.tokenTransferTvmEvmEventContract)(connection, eventAddress) .methods.getDecodedData({ answerId: 0 }) .call({ cachedState: state, responsible: true }); return { addr: result.addr, chainId: result.chainId, ethereumAddress: result.ethereum_address, ownerAddress: result.owner_address, tokens: result.tokens, wid: result.wid, }; } static async getDetails(connection, eventAddress, cachedState) { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, eventAddress); const result = await (0, contracts_1.tokenTransferTvmEvmEventContract)(connection, eventAddress) .methods.getDetails({ answerId: 0 }) .call({ cachedState: state, responsible: true }); return { balance: result.balance, confirms: result._confirms, empty: result.empty, eventInitData: { configuration: result._eventInitData.configuration, staking: result._eventInitData.staking, voteData: { eventData: result._eventInitData.voteData.eventData, eventTimestamp: Number(result._eventInitData.voteData.eventTimestamp), eventTransactionLt: result._eventInitData.voteData.eventTransactionLt, }, }, initializer: result._initializer, meta: result._meta, rejects: result._rejects, requiredVotes: Number(result._requiredVotes), signatures: result._signatures, status: result._status, }; } static async roundNumber(connection, eventAddress, cachedState) { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, eventAddress); const result = await (0, contracts_1.tokenTransferTvmEvmEventContract)(connection, eventAddress) .methods.round_number() .call({ cachedState: state }); return Number(result.round_number); } } exports.TokenTransferTvmEvmEventUtils = TokenTransferTvmEvmEventUtils;