@broxus/js-core
Version:
MobX-based JavaScript Core library
24 lines (23 loc) • 1.17 kB
JavaScript
import { stakingAccountContract } from '../../models/staking-account/contracts';
import { getFullContractState } from '../../utils';
export class StakingAccountUtils {
static async getDetails(connection, stakingAccountAddress, cachedState) {
const state = cachedState ?? await getFullContractState(connection, stakingAccountAddress);
const result = await 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 getFullContractState(connection, stakingAccountAddress);
const result = await 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),
}));
}
}