|
@@ -3,7 +3,7 @@ import moment from "moment";
|
|
|
|
|
|
// types
|
|
|
import { AccountBalance, ElectionInfo, Round, ProposalDetail } from "./types";
|
|
|
-import { Option, u32, u64, Vec } from "@polkadot/types";
|
|
|
+import { Option, u32, u64, Vec, StorageKey } from "@polkadot/types";
|
|
|
import type { Codec, Observable } from "@polkadot/types/types";
|
|
|
import {
|
|
|
AccountId,
|
|
@@ -67,6 +67,8 @@ export const getBlockHash = (
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+export const getHead = (api: ApiPromise) => api.derive.chain.bestNumber();
|
|
|
+
|
|
|
export const getTimestamp = async (
|
|
|
api: ApiPromise,
|
|
|
hash: Hash
|
|
@@ -223,6 +225,16 @@ export const getCouncilElectionDurations = async (
|
|
|
return durations;
|
|
|
};
|
|
|
|
|
|
+export const getCommitments = (api: ApiPromise, hash: Hash): Promise<Hash[]> =>
|
|
|
+ api.query.councilElection.commitments.at(hash);
|
|
|
+
|
|
|
+export const getCommitment = (
|
|
|
+ api: ApiPromise,
|
|
|
+ blockHash: Hash,
|
|
|
+ voteHash: Hash
|
|
|
+): Promise<SealedVote> =>
|
|
|
+ api.query.councilElection.votes.at(blockHash, voteHash);
|
|
|
+
|
|
|
// working groups
|
|
|
export const getNextWorker = async (
|
|
|
api: ApiPromise,
|
|
@@ -456,6 +468,11 @@ export const getProposalPost = async (
|
|
|
postId
|
|
|
)) as DiscussionPost;
|
|
|
|
|
|
+export const getProposalPosts = (
|
|
|
+ api: ApiPromise
|
|
|
+): Promise<[StorageKey<any>, DiscussionPost][]> =>
|
|
|
+ api.query.proposalsDiscussion.postThreadIdByPostId.entries();
|
|
|
+
|
|
|
export const getProposalPostCount = async (api: ApiPromise): Promise<number> =>
|
|
|
Number((await api.query.proposalsDiscussion.postCount()) as u64);
|
|
|
|