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