|
@@ -214,26 +214,26 @@ const App = (props: {}) => {
|
|
// getTokenomics().then((tokenomics) => save(`tokenomics`, tokenomics));
|
|
// getTokenomics().then((tokenomics) => save(`tokenomics`, tokenomics));
|
|
|
|
|
|
// let { status, councils } = this.state;
|
|
// let { status, councils } = this.state;
|
|
- // status.election = await updateElection(api);
|
|
|
|
- // if (status.election?.stage) getElectionStatus(api);
|
|
|
|
|
|
+ // let _status = status;
|
|
|
|
+ // _status.election = await updateElection(api);
|
|
|
|
+ // if (_status.election?.stage) getElectionStatus(api);
|
|
// councils.forEach((c) => {
|
|
// councils.forEach((c) => {
|
|
// if (c?.round > status.council) status.council = c;
|
|
// if (c?.round > status.council) status.council = c;
|
|
// });
|
|
// });
|
|
|
|
|
|
- // let hash: string = await api.rpc.chain.getBlockHash(1);
|
|
|
|
- // if (hash)
|
|
|
|
- // status.startTime = (await api.query.timestamp.now.at(hash)).toNumber();
|
|
|
|
|
|
+ let hash: string = await api.rpc.chain.getBlockHash(1);
|
|
|
|
+ if (hash)
|
|
|
|
+ _status.startTime = (await api.query.timestamp.now.at(hash)).toJSON();
|
|
|
|
|
|
- const nextMemberId = await await api.query.members.nextMemberId();
|
|
|
|
- // setMembers(nextMemberId - 1);
|
|
|
|
- setProposals(await get.proposalCount(api));
|
|
|
|
- setPosts(await get.currentPostId(api));
|
|
|
|
- setThreads(await get.currentThreadId(api));
|
|
|
|
- setCategories(await get.currentCategoryId(api));
|
|
|
|
- // status.proposalPosts = await api.query.proposalsDiscussion.postCount();
|
|
|
|
|
|
+ console.log(`NextMemberID: `, (await api.query.members.nextMemberId()).toJSON());
|
|
|
|
+ console.log(`ProposalCount: `, await get.proposalCount(api));
|
|
|
|
+ console.log(`CurrentPostId: `, await get.currentPostId(api));
|
|
|
|
+ console.log(`CurrentThreadId: `, await get.currentThreadId(api));
|
|
|
|
+ console.log(`CurrentCategoryId: `, await get.currentCategoryId(api));
|
|
|
|
+ _status.proposalPosts = await api.query.proposalsDiscussion.postCount();
|
|
|
|
|
|
await updateEra(api, status.era).then(async (era) => {
|
|
await updateEra(api, status.era).then(async (era) => {
|
|
- let _status = {era: 0, lastReward:0, validatorStake: 0}
|
|
|
|
|
|
+ // let _status = {era: 0, lastReward:0, validatorStake: 0}
|
|
_status.era = era;
|
|
_status.era = era;
|
|
_status.lastReward = await getLastReward(api, era);
|
|
_status.lastReward = await getLastReward(api, era);
|
|
_status.validatorStake = await getTotalStake(api, era);
|
|
_status.validatorStake = await getTotalStake(api, era);
|
|
@@ -243,9 +243,36 @@ const App = (props: {}) => {
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
- // return status;
|
|
|
|
|
|
+ setStatus(_status)
|
|
|
|
+ save("status", _status);
|
|
|
|
+ // return status;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ const getElectionStatus = async (api: ApiPromise): Promise<any> => {
|
|
|
|
+ getCouncilSize(api).then((councilSize) => {
|
|
|
|
+ let _election = election;
|
|
|
|
+ _election.councilSize = councilSize;
|
|
|
|
+
|
|
|
|
+ setElection(_election);
|
|
|
|
+ save("election", _election);
|
|
|
|
+ });
|
|
|
|
+ getVotes(api).then((votes) => {
|
|
|
|
+ let _election = election;
|
|
|
|
+ _election.votes = votes;
|
|
|
|
+
|
|
|
|
+ setElection(_election);
|
|
|
|
+ save("election", election);
|
|
|
|
+ });
|
|
|
|
+ getCouncilApplicants(api).then((applicants) => {
|
|
|
|
+ let _election = election;
|
|
|
|
+ _election.applicants = applicants;
|
|
|
|
+
|
|
|
|
+ setElection(_election);
|
|
|
|
+ save("election", election);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
const updateEra = async (api: ApiPromise, old: number) => {
|
|
const updateEra = async (api: ApiPromise, old: number) => {
|
|
const era = Number(await api.query.staking.currentEra());
|
|
const era = Number(await api.query.staking.currentEra());
|
|
if (era === old)
|
|
if (era === old)
|