@broxus/js-core
Version:
MobX-based JavaScript Core library
28 lines (27 loc) • 1.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StakingAccountUtils = void 0;
const contracts_1 = require("../../models/staking-account/contracts");
const utils_1 = require("../../utils");
class StakingAccountUtils {
static async getDetails(connection, stakingAccountAddress, cachedState) {
const state = cachedState ?? await (0, utils_1.getFullContractState)(connection, stakingAccountAddress);
const result = await (0, contracts_1.stakingAccountContract)(connection, stakingAccountAddress)
.methods.getDetails({ answerId: 0 })
.call({ cachedState: state, responsible: true });
return result.value0;
}
static async withdrawRequests(connection, stakingAccountAddress, cachedState) {
const state = cachedState ?? await (0, utils_1.getFullContractState)(connection, stakingAccountAddress);
const result = await (0, contracts_1.stakingAccountContract)(connection, stakingAccountAddress)
.methods.withdrawRequests()
.call({ cachedState: state });
return result.withdrawRequests.map(([nonce, data]) => ({
amount: data.amount,
nonce,
timestamp: Number(data.timestamp),
unlockTime: Number(data.unlockTime),
}));
}
}
exports.StakingAccountUtils = StakingAccountUtils;