|
@@ -43,12 +43,9 @@ import {
|
|
RewardRelationshipId,
|
|
RewardRelationshipId,
|
|
} from "@joystream/types/recurring-rewards";
|
|
} from "@joystream/types/recurring-rewards";
|
|
import { WorkerId, Worker } from "@joystream/types/working-group";
|
|
import { WorkerId, Worker } from "@joystream/types/working-group";
|
|
-import {
|
|
|
|
- ProposalOf,
|
|
|
|
- ProposalDetailsOf
|
|
|
|
-} from "@joystream/types/augment/types";
|
|
|
|
|
|
+import { ProposalOf, ProposalDetailsOf } from "@joystream/types/augment/types";
|
|
|
|
|
|
-import {WorkerOf, } from "@joystream/types/augment-codec/all";
|
|
|
|
|
|
+import { WorkerOf } from "@joystream/types/augment-codec/all";
|
|
|
|
|
|
// blocks
|
|
// blocks
|
|
export const getBlock = (api: ApiPromise, hash: Hash): Promise<SignedBlock> =>
|
|
export const getBlock = (api: ApiPromise, hash: Hash): Promise<SignedBlock> =>
|
|
@@ -61,10 +58,6 @@ export const getBlockHash = (
|
|
try {
|
|
try {
|
|
return api.rpc.chain.getBlockHash(block);
|
|
return api.rpc.chain.getBlockHash(block);
|
|
} catch (e) {
|
|
} catch (e) {
|
|
- console.error(`BlockHash: ${block}`);
|
|
|
|
- //const head =
|
|
|
|
- //return api.query.system.blockHash(head)
|
|
|
|
- //return api.query.system.parentHash()
|
|
|
|
return api.rpc.chain.getFinalizedHead();
|
|
return api.rpc.chain.getFinalizedHead();
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -122,7 +115,7 @@ export const getCouncils = async (
|
|
const end = Number(await api.query.council.termEndsAt.at(hash));
|
|
const end = Number(await api.query.council.termEndsAt.at(hash));
|
|
if (end === lastEnd) continue;
|
|
if (end === lastEnd) continue;
|
|
lastEnd = end;
|
|
lastEnd = end;
|
|
- starts.push(end - d[3] + 1);
|
|
|
|
|
|
+ starts.push(end - d[3]);
|
|
}
|
|
}
|
|
|
|
|
|
// index by round: each start is the end of the previous term
|
|
// index by round: each start is the end of the previous term
|
|
@@ -132,7 +125,7 @@ export const getCouncils = async (
|
|
const hash = await getBlockHash(api, start);
|
|
const hash = await getBlockHash(api, start);
|
|
const round = await getCouncilRound(api, hash);
|
|
const round = await getCouncilRound(api, hash);
|
|
const isLast = index === starts.length - 1;
|
|
const isLast = index === starts.length - 1;
|
|
- const end = isLast ? start + d[4] : starts[index + 1] - 1;
|
|
|
|
|
|
+ const end = isLast ? start + d[4] - 1 : starts[index + 1] - 1;
|
|
rounds[round] = { start, round, end };
|
|
rounds[round] = { start, round, end };
|
|
})
|
|
})
|
|
);
|
|
);
|
|
@@ -287,7 +280,7 @@ export const getAccounts = async (
|
|
const entries = await api.query.system.account.entries();
|
|
const entries = await api.query.system.account.entries();
|
|
for (const account of entries) {
|
|
for (const account of entries) {
|
|
const accountId = String(account[0].toHuman());
|
|
const accountId = String(account[0].toHuman());
|
|
- const balance = (account[1].data.toJSON() as unknown) as AccountData;
|
|
|
|
|
|
+ const balance = account[1].data.toJSON() as unknown as AccountData;
|
|
accounts.push({ accountId, balance });
|
|
accounts.push({ accountId, balance });
|
|
}
|
|
}
|
|
return accounts;
|
|
return accounts;
|
|
@@ -359,9 +352,11 @@ export const getProposalCount = async (
|
|
api: ApiPromise,
|
|
api: ApiPromise,
|
|
hash?: Hash
|
|
hash?: Hash
|
|
): Promise<number> =>
|
|
): Promise<number> =>
|
|
- ((await (hash
|
|
|
|
- ? api.query.proposalsEngine.proposalCount.at(hash)
|
|
|
|
- : api.query.proposalsEngine.proposalCount())) as u32).toNumber();
|
|
|
|
|
|
+ (
|
|
|
|
+ (await (hash
|
|
|
|
+ ? api.query.proposalsEngine.proposalCount.at(hash)
|
|
|
|
+ : api.query.proposalsEngine.proposalCount())) as u32
|
|
|
|
+ ).toNumber();
|
|
|
|
|
|
export const getProposalInfo = async (
|
|
export const getProposalInfo = async (
|
|
api: ApiPromise,
|
|
api: ApiPromise,
|
|
@@ -436,9 +431,8 @@ export const getProposalVotes = async (
|
|
id: ProposalId | number
|
|
id: ProposalId | number
|
|
): Promise<{ memberId: number; vote: string }[]> => {
|
|
): Promise<{ memberId: number; vote: string }[]> => {
|
|
let votes: { memberId: number; vote: string }[] = [];
|
|
let votes: { memberId: number; vote: string }[] = [];
|
|
- const entries = await api.query.proposalsEngine.voteExistsByProposalByVoter.entries(
|
|
|
|
- id
|
|
|
|
- );
|
|
|
|
|
|
+ const entries =
|
|
|
|
+ await api.query.proposalsEngine.voteExistsByProposalByVoter.entries(id);
|
|
entries.forEach((entry: any) => {
|
|
entries.forEach((entry: any) => {
|
|
const memberId = entry[0].args[1].toJSON();
|
|
const memberId = entry[0].args[1].toJSON();
|
|
const vote = entry[1].toString();
|
|
const vote = entry[1].toString();
|
|
@@ -475,19 +469,21 @@ export const getValidatorCount = async (
|
|
export const getValidators = async (
|
|
export const getValidators = async (
|
|
api: ApiPromise,
|
|
api: ApiPromise,
|
|
hash: Hash
|
|
hash: Hash
|
|
-): Promise<AccountId[]> =>
|
|
|
|
- ((await api.query.staking.snapshotValidators.at(hash)) as Option<
|
|
|
|
- Vec<AccountId>
|
|
|
|
- >).unwrap();
|
|
|
|
|
|
+): Promise<AccountId[]> => {
|
|
|
|
+ const snapshot = (await api.query.staking.snapshotValidators.at(
|
|
|
|
+ hash
|
|
|
|
+ )) as Option<Vec<AccountId>>;
|
|
|
|
+ return snapshot.isSome ? snapshot.unwrap() : [];
|
|
|
|
+};
|
|
|
|
|
|
// media
|
|
// media
|
|
export const getNextEntity = async (
|
|
export const getNextEntity = async (
|
|
api: ApiPromise,
|
|
api: ApiPromise,
|
|
hash: Hash
|
|
hash: Hash
|
|
): Promise<number> =>
|
|
): Promise<number> =>
|
|
- ((await api.query.contentDirectory.nextEntityId.at(
|
|
|
|
- hash
|
|
|
|
- )) as EntityId).toNumber();
|
|
|
|
|
|
+ (
|
|
|
|
+ (await api.query.contentDirectory.nextEntityId.at(hash)) as EntityId
|
|
|
|
+ ).toNumber();
|
|
|
|
|
|
export const getNextChannel = async (
|
|
export const getNextChannel = async (
|
|
api: ApiPromise,
|
|
api: ApiPromise,
|
|
@@ -508,7 +504,7 @@ export const getEntity = (
|
|
export const getDataObjects = async (
|
|
export const getDataObjects = async (
|
|
api: ApiPromise
|
|
api: ApiPromise
|
|
): Promise<Map<ContentId, DataObject>> =>
|
|
): Promise<Map<ContentId, DataObject>> =>
|
|
- ((await api.query.dataDirectory.dataByContentId.entries()) as unknown) as Map<
|
|
|
|
|
|
+ (await api.query.dataDirectory.dataByContentId.entries()) as unknown as Map<
|
|
ContentId,
|
|
ContentId,
|
|
DataObject
|
|
DataObject
|
|
>;
|
|
>;
|