UNPKG

@broxus/js-bridge-essentials

Version:

Bridge JavaScript Essentials library

83 lines (82 loc) 4.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TokenTransferTvmSolEventUtils = exports.TokenTransferTvmSolStatus = void 0; const js_core_1 = require("@broxus/js-core"); const contracts_1 = require("../../models/token-transfer-tvm-sol-event/contracts"); var TokenTransferTvmSolStatus; (function (TokenTransferTvmSolStatus) { TokenTransferTvmSolStatus["Initializing"] = "0"; TokenTransferTvmSolStatus["Pending"] = "1"; TokenTransferTvmSolStatus["Confirmed"] = "2"; TokenTransferTvmSolStatus["Rejected"] = "3"; })(TokenTransferTvmSolStatus || (exports.TokenTransferTvmSolStatus = TokenTransferTvmSolStatus = {})); /** * @deprecated Use TvmSolBaseEventUtils instead */ class TokenTransferTvmSolEventUtils { static async getEventInitData(connection, eventAddress, cachedState) { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, eventAddress); const result = await (0, contracts_1.tokenTransferTvmSolEventContract)(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, executeAccounts: result.value0.voteData.executeAccounts, executePayloadAccounts: result.value0.voteData.executePayloadAccounts, executePayloadNeeded: result.value0.voteData.executePayloadNeeded, }, }; } static async getDecodedData(connection, eventAddress, cachedState) { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, eventAddress); const result = await (0, contracts_1.tokenTransferTvmSolEventContract)(connection, eventAddress) .methods.getDecodedData({ answerId: 0 }) .call({ cachedState: state, responsible: true }); return { senderAddress: result.senderAddress, solanaOwnerAddress: result.solanaOwnerAddress, tokens: result.tokens, }; } static async getDetails(connection, eventAddress, cachedState) { const state = cachedState ?? await (0, js_core_1.getFullContractState)(connection, eventAddress); const result = await (0, contracts_1.tokenTransferTvmSolEventContract)(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, executeAccounts: result._eventInitData.voteData.executeAccounts, executePayloadAccounts: result._eventInitData.voteData.executePayloadAccounts, executePayloadNeeded: result._eventInitData.voteData.executePayloadNeeded, }, }, initializer: result._initializer, meta: result._meta, rejects: result._rejects, requiredVotes: Number(result._requiredVotes), 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.tokenTransferTvmSolEventContract)(connection, eventAddress) .methods.round_number() .call({ cachedState: state }); return Number(result.round_number); } } exports.TokenTransferTvmSolEventUtils = TokenTransferTvmSolEventUtils;