@broxus/js-core
Version:
MobX-based JavaScript Core library
70 lines (69 loc) • 3.81 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.VoteEscrowDaoRootUtils = void 0;
const constants_1 = require("../../constants");
const contacts_1 = require("../../models/vote-escrow-dao-root/contacts");
const utils_1 = require("../../utils");
class VoteEscrowDaoRootUtils {
static async propose(provider, daoRootAddress, params, args) {
return (0, contacts_1.voteEscrowDaoRootContract)(provider, daoRootAddress)
.methods.propose({
answerId: 0,
description: params.description,
ethActions: params.evmActions ?? [],
tonActions: params.tvmActions ?? [],
})
.sendDelayed({
amount: (0, utils_1.toInt)(0.5, constants_1.DEFAULT_NATIVE_CURRENCY_DECIMALS),
...args,
});
}
static async calcTvmActionsValue(connection, daoRootAddress, params, cachedState) {
const cache = cachedState || (await (0, utils_1.getFullContractState)(connection, daoRootAddress));
const result = await (0, contacts_1.voteEscrowDaoRootContract)(connection, daoRootAddress)
.methods.calcTonActionsValue({ actions: params.actions })
.call({ cachedState: cache });
return result.totalValue;
}
static async getVoteEscrowRoot(connection, daoRootAddress, cachedState) {
const cache = cachedState || (await (0, utils_1.getFullContractState)(connection, daoRootAddress));
const result = await (0, contacts_1.voteEscrowDaoRootContract)(connection, daoRootAddress)
.methods.getVoteEscrowRoot({ answerId: 0 })
.call({ cachedState: cache, responsible: true });
return result.value0;
}
static async expectedProposalAddress(connection, daoRootAddress, proposalId, cachedState) {
const cache = cachedState || (await (0, utils_1.getFullContractState)(connection, daoRootAddress));
const result = await (0, contacts_1.voteEscrowDaoRootContract)(connection, daoRootAddress)
.methods.expectedProposalAddress({ answerId: 0, proposalId })
.call({ cachedState: cache, responsible: true });
return result.value0;
}
static async expectedVoteEscrowAccountAddress(connection, daoRootAddress, accountOwner, cachedState) {
const cache = cachedState || (await (0, utils_1.getFullContractState)(connection, daoRootAddress));
const result = await (0, contacts_1.voteEscrowDaoRootContract)(connection, daoRootAddress)
.methods.expectedVoteEscrowAccountAddress({
accountOwner: (0, utils_1.resolveTvmAddress)(accountOwner),
answerId: 0,
})
.call({ cachedState: cache, responsible: true });
return result.value0;
}
static async proposalConfiguration(connection, daoRootAddress, cachedState) {
const cache = cachedState || (await (0, utils_1.getFullContractState)(connection, daoRootAddress));
const result = await (0, contacts_1.voteEscrowDaoRootContract)(connection, daoRootAddress)
.methods.proposalConfiguration()
.call({ cachedState: cache });
return result.proposalConfiguration;
}
static decodeEvent(connection, daoRootAddress, args) {
return (0, contacts_1.voteEscrowDaoRootContract)(connection, daoRootAddress).decodeEvent(args);
}
static decodeTransaction(connection, daoRootAddress, args) {
return (0, contacts_1.voteEscrowDaoRootContract)(connection, daoRootAddress).decodeTransaction(args);
}
static decodeTransactionEvents(connection, daoRootAddress, transaction) {
return (0, contacts_1.voteEscrowDaoRootContract)(connection, daoRootAddress).decodeTransactionEvents({ transaction });
}
}
exports.VoteEscrowDaoRootUtils = VoteEscrowDaoRootUtils;