@broxus/js-bridge-essentials
Version:
Bridge JavaScript Essentials library
60 lines (59 loc) • 3.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SolTvmEventConfigurationUtils = void 0;
const js_core_1 = require("@broxus/js-core");
const contracts_1 = require("../../models/sol-tvm-event-configuration/contracts");
class SolTvmEventConfigurationUtils {
static deployEvent(provider, eventConfigurationAddress, params, args) {
return (0, contracts_1.solTvmEventConfigurationContract)(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.solTvmEventConfigurationContract)(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.solTvmEventConfigurationContract)(connection, eventConfigurationAddress)
.methods.getDetails({ answerId: 0 })
.call({ cachedState: state, responsible: true });
return ({
basicConfiguration: result._basicConfiguration,
meta: result._meta,
networkConfiguration: {
...result._networkConfiguration,
endTimestamp: Number(result._networkConfiguration.endTimestamp),
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.solTvmEventConfigurationContract)(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.solTvmEventConfigurationContract)(connection, eventConfigurationAddress).decodeEvent(args);
}
static decodeTransaction(connection, eventConfigurationAddress, args) {
return (0, contracts_1.solTvmEventConfigurationContract)(connection, eventConfigurationAddress).decodeTransaction(args);
}
static decodeTransactionEvents(connection, eventConfigurationAddress, transaction) {
return (0, contracts_1.solTvmEventConfigurationContract)(connection, eventConfigurationAddress).decodeTransactionEvents({ transaction });
}
}
exports.SolTvmEventConfigurationUtils = SolTvmEventConfigurationUtils;