3
0

2 Ревизии 0ef70ad5a4 ... 6aa2fe5625

Автор SHA1 Съобщение Дата
  Joystream Stats 6aa2fe5625 drop unused преди 2 години
  Joystream Stats 18fd8a36a7 Olympia: remove what broke преди 2 години
променени са 6 файла, в които са добавени 60 реда и са изтрити 219 реда
  1. 43 132
      api.ts
  2. 0 33
      content.ts
  3. 2 21
      index.ts
  4. 9 20
      rewards.ts
  5. 0 1
      storage.ts
  6. 6 12
      types.ts

+ 43 - 132
api.ts

@@ -4,7 +4,6 @@ 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, StorageKey } from "@polkadot/types";
 import { Option, u32, u64, Vec, StorageKey } from "@polkadot/types";
-import type { Codec, Observable } from "@polkadot/types/types";
 import {
 import {
   AccountId,
   AccountId,
   AccountInfo,
   AccountInfo,
@@ -13,43 +12,22 @@ import {
   BlockNumber,
   BlockNumber,
   EraIndex,
   EraIndex,
   EventRecord,
   EventRecord,
+  Exposure,
   Hash,
   Hash,
-  Moment,
 } from "@polkadot/types/interfaces";
 } from "@polkadot/types/interfaces";
 import { SignedBlock } from "@polkadot/types/interfaces/runtime";
 import { SignedBlock } from "@polkadot/types/interfaces/runtime";
 import { types } from "@joystream/types";
 import { types } from "@joystream/types";
-import { PostId, ThreadId } from "@joystream/types/common";
+import { MemberId, PostId, ThreadId } from "@joystream/types/common";
 import { CategoryId, Category, Thread, Post } from "@joystream/types/forum";
 import { CategoryId, Category, Thread, Post } from "@joystream/types/forum";
-import {
-  ElectionStage,
-  ElectionStake,
-  SealedVote,
-  Seats,
-} from "@joystream/types/council";
-import {
-  MemberId,
-  Membership,
-  PaidMembershipTerms,
-  PaidTermId,
-} from "@joystream/types/members";
-import { Mint, MintId } from "@joystream/types/mint";
-import {
-  Proposal,
-  ProposalId,
-  DiscussionPost,
-  SpendingParams,
-  VoteKind,
-} from "@joystream/types/proposals";
-import { Stake, StakeId } from "@joystream/types/stake";
-import {
-  RewardRelationship,
-  RewardRelationshipId,
-} from "@joystream/types/recurring-rewards";
+import { CouncilStage } from "@joystream/types/council";
+import { Membership } from "@joystream/types/members";
+import { ProposalId, DiscussionPost } from "@joystream/types/proposals";
 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";
 
 
-export const connectApi = async (url: string = "ws://localhost:9944"): Promise<ApiPromise> => {
+export const connectApi = async (
+  url: string = "ws://localhost:9944"
+): Promise<ApiPromise> => {
   const provider = new WsProvider(url);
   const provider = new WsProvider(url);
   return await ApiPromise.create({ provider, types });
   return await ApiPromise.create({ provider, types });
 };
 };
@@ -97,13 +75,16 @@ export const getEraStake = async (
 ): Promise<number> =>
 ): Promise<number> =>
   (await api.query.staking.erasTotalStake.at(hash, era)).toNumber();
   (await api.query.staking.erasTotalStake.at(hash, era)).toNumber();
 
 
-// council
-export const getCouncil = async (api: ApiPromise): Promise<Seats> =>
-  (await api.query.council.activeCouncil()) as Seats;
-
-export const getCouncilAt = (api: ApiPromise, hash: Hash): Promise<Seats> =>
-  api.query.council.activeCouncil.at(hash);
+export const getStake = async (
+  api: ApiPromise,
+  accountId: AccountId,
+  hash?: Hash
+): Promise<Exposure> =>
+  (await (hash
+    ? api.query.staking.erasStakers.at(hash, accountId)
+    : api.query.staking.erasStakers(accountId))) as Exposure;
 
 
+// council
 export const getCouncils = async (
 export const getCouncils = async (
   api: ApiPromise,
   api: ApiPromise,
   head: number
   head: number
@@ -154,11 +135,13 @@ export const getCouncilRound = async (
     ? ((await api.query.councilElection.round.at(hash)) as u32).toNumber()
     ? ((await api.query.councilElection.round.at(hash)) as u32).toNumber()
     : ((await api.query.councilElection.round()) as u32).toNumber();
     : ((await api.query.councilElection.round()) as u32).toNumber();
 
 
-export const getCouncilElectionStage = async (
+export const getCouncilElectionStage = (api: ApiPromise, hash: Hash) =>
+  getCouncilStage(api, hash); // deprecated
+export const getCouncilStage = async (
   api: ApiPromise,
   api: ApiPromise,
   hash: Hash
   hash: Hash
-): Promise<ElectionStage> =>
-  (await api.query.councilElection.stage.at(hash)) as ElectionStage;
+): Promise<CouncilStage> =>
+  (await api.query.councilElection.stage.at(hash)) as CouncilStage;
 
 
 export const getCouncilTermEnd = async (
 export const getCouncilTermEnd = async (
   api: ApiPromise,
   api: ApiPromise,
@@ -172,7 +155,7 @@ export const getCouncilElectionStatus = async (
 ): Promise<ElectionInfo> => {
 ): Promise<ElectionInfo> => {
   const durations = await getCouncilElectionDurations(api, hash);
   const durations = await getCouncilElectionDurations(api, hash);
   const round = await getCouncilRound(api, hash);
   const round = await getCouncilRound(api, hash);
-  const stage: ElectionStage = await getCouncilElectionStage(api, hash);
+  const stage: CouncilStage = await getCouncilStage(api, hash);
   const stageEndsAt: number = Number(stage.value as BlockNumber);
   const stageEndsAt: number = Number(stage.value as BlockNumber);
   const termEndsAt: number = await getCouncilTermEnd(api, hash);
   const termEndsAt: number = await getCouncilTermEnd(api, hash);
   return { round, stageEndsAt, termEndsAt, stage, durations };
   return { round, stageEndsAt, termEndsAt, stage, durations };
@@ -187,14 +170,7 @@ export const getCouncilSize = async (
 export const getCouncilApplicants = (
 export const getCouncilApplicants = (
   api: ApiPromise,
   api: ApiPromise,
   hash: Hash
   hash: Hash
-): Promise<Vec<AccountId>> => api.query.councilElection.applicants.at(hash);
-
-export const getCouncilApplicantStakes = (
-  api: ApiPromise,
-  hash: Hash,
-  applicant: AccountId
-): Promise<ElectionStake> =>
-  api.query.councilElection.applicantStakes.at(hash, applicant);
+): Promise<Vec<AccountId>> => api.query.council.applicants.at(hash);
 
 
 export const getCouncilCommitments = (
 export const getCouncilCommitments = (
   api: ApiPromise,
   api: ApiPromise,
@@ -215,7 +191,7 @@ const getCouncilElectionPeriod = (
   api: ApiPromise,
   api: ApiPromise,
   hash: Hash,
   hash: Hash,
   period: string
   period: string
-): Promise<BlockNumber> => api.query.councilElection[period].at(hash);
+): Promise<BlockNumber> => api.query.council[period].at(hash);
 
 
 export const getCouncilElectionDurations = async (
 export const getCouncilElectionDurations = async (
   api: ApiPromise,
   api: ApiPromise,
@@ -234,16 +210,6 @@ 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,
@@ -257,7 +223,7 @@ export const getWorker = (
   group: string,
   group: string,
   hash: Hash,
   hash: Hash,
   id: number
   id: number
-): Promise<WorkerOf> => api.query[group].workerById.at(hash, id);
+): Promise<Worker> => api.query[group].workerById.at(hash, id);
 
 
 export const getWorkers = async (
 export const getWorkers = async (
   api: ApiPromise,
   api: ApiPromise,
@@ -265,42 +231,6 @@ export const getWorkers = async (
   hash: Hash
   hash: Hash
 ): Promise<number> => Number(await api.query[group].activeWorkerCount.at(hash));
 ): Promise<number> => Number(await api.query[group].activeWorkerCount.at(hash));
 
 
-export const getStake = async (
-  api: ApiPromise,
-  id: StakeId | number,
-  hash?: Hash
-): Promise<Stake> =>
-  (await (hash
-    ? api.query.stake.stakes.at(hash, id)
-    : api.query.stake.stakes(id))) as Stake;
-
-export const getWorkerReward = (
-  api: ApiPromise,
-  hash: Hash,
-  id: RewardRelationshipId | number
-): Promise<RewardRelationship> =>
-  api.query.recurringRewards.rewardRelationships.at(hash, id);
-
-// mints
-export const getCouncilMint = (api: ApiPromise, hash: Hash): Promise<MintId> =>
-  api.query.council.councilMint.at(hash);
-
-export const getGroupMint = async (
-  api: ApiPromise,
-  group: string
-): Promise<MintId> => (await api.query[group].mint()) as MintId;
-
-export const getMintsCreated = async (
-  api: ApiPromise,
-  hash: Hash
-): Promise<number> => parseInt(await api.query.minting.mintsCreated.at(hash));
-
-export const getMint = (
-  api: ApiPromise,
-  hash: Hash,
-  id: MintId | number
-): Promise<Mint> => api.query.minting.mints.at(hash, id);
-
 // members
 // members
 export const getAccounts = async (
 export const getAccounts = async (
   api: ApiPromise
   api: ApiPromise
@@ -350,7 +280,7 @@ export const getMemberHandle = async (
   api: ApiPromise,
   api: ApiPromise,
   id: MemberId
   id: MemberId
 ): Promise<string> =>
 ): Promise<string> =>
-  getMember(api, id).then((member: Membership) => String(member.handle));
+  getMember(api, id).then((member: Membership) => String(member.handle_hash));
 
 
 export const getMemberHandleByAccount = async (
 export const getMemberHandleByAccount = async (
   api: ApiPromise,
   api: ApiPromise,
@@ -434,39 +364,31 @@ export const getProposal = async (
   id: ProposalId
   id: ProposalId
 ): Promise<ProposalDetail> => {
 ): Promise<ProposalDetail> => {
   const proposal: ProposalOf = await getProposalInfo(api, id);
   const proposal: ProposalOf = await getProposalInfo(api, id);
-  const status: { [key: string]: any } = proposal.status;
+  const {
+    parameters,
+    proposerId,
+    activatedAt,
+    status,
+    votingResults,
+    exactExecutionBlock,
+    //nrOfCouncilConfirmations,
+    //stakingAccountId,
+  } = proposal;
   const stage: string = status.isActive ? "Active" : "Finalized";
   const stage: string = status.isActive ? "Active" : "Finalized";
-  const { finalizedAt, proposalStatus } = status[`as${stage}`];
-  const result: string = proposalStatus
-    ? (proposalStatus.isApproved && "Approved") ||
-      (proposalStatus.isCanceled && "Canceled") ||
-      (proposalStatus.isExpired && "Expired") ||
-      (proposalStatus.isRejected && "Rejected") ||
-      (proposalStatus.isSlashed && "Slashed") ||
-      (proposalStatus.isVetoed && "Vetoed")
-    : "Pending";
-  const exec = proposalStatus ? proposalStatus["Approved"] : null;
-
-  const { description, parameters, proposerId, votingResults } = proposal;
   const member: Membership = await getMember(api, proposerId);
   const member: Membership = await getMember(api, proposerId);
-  const author = String(member ? member.handle : proposerId);
-  const title = String(proposal.title.toHuman());
+  const author = String(member ? member.handle_hash : proposerId);
+  //const title = String(proposal.title.toHuman());
   const type: string = await getProposalType(api, id);
   const type: string = await getProposalType(api, id);
-  const args: string[] = [String(id), title, type, stage, result, author];
+  const args: string[] = [String(id), ``, type, stage, ``, author];
   const message = formatProposalMessage(args);
   const message = formatProposalMessage(args);
-  const created: number = Number(proposal.createdAt);
 
 
   return {
   return {
     id: Number(id),
     id: Number(id),
-    title,
-    created,
-    finalizedAt,
+    activatedAt: +activatedAt,
+    executedAt: +exactExecutionBlock,
     parameters: JSON.stringify(parameters),
     parameters: JSON.stringify(parameters),
     message,
     message,
-    stage,
-    result,
-    exec,
-    description: description.toHuman(),
+    status,
     votes: votingResults,
     votes: votingResults,
     type,
     type,
     author,
     author,
@@ -539,25 +461,14 @@ export const getValidators = async (
   return snapshot.isSome ? snapshot.unwrap() : [];
   return snapshot.isSome ? snapshot.unwrap() : [];
 };
 };
 
 
-export const getPaidMembershipTermsById = (
-  api: ApiPromise,
-  hash: Hash,
-  id: PaidTermId | number
-): Promise<PaidMembershipTerms> =>
-  api.query.members.paidMembershipTermsById.at(hash, id);
-
 export {
 export {
   getChannel,
   getChannel,
   getChannelCategory,
   getChannelCategory,
   getCuratorGroup,
   getCuratorGroup,
-  getPerson,
-  getPlaylist,
-  getSeries,
   getVideo,
   getVideo,
   getVideoCategory,
   getVideoCategory,
   getNextChannel,
   getNextChannel,
   getNextChannelCategory,
   getNextChannelCategory,
-  getNextChannelOwnershipTransferRequestId,
   getNextCuratorGroup,
   getNextCuratorGroup,
   getNextPerson,
   getNextPerson,
   getNextPlaylist,
   getNextPlaylist,

+ 0 - 33
content.ts

@@ -5,18 +5,8 @@ import {
   Channel,
   Channel,
   ChannelCategory,
   ChannelCategory,
   ChannelCategoryId,
   ChannelCategoryId,
-  ChannelOwnershipTransferRequest,
-  ChannelOwnershipTransferRequestId,
-  Person,
-  PersonId,
-  Playlist,
-  PlaylistId,
-  Series,
-  SeriesId,
   Video,
   Video,
   VideoId,
   VideoId,
-  VideoCategory,
-  VideoCategoryId,
 } from "@joystream/types/content";
 } from "@joystream/types/content";
 import { ChannelId } from "@joystream/types/storage";
 import { ChannelId } from "@joystream/types/storage";
 import { Hash } from "@polkadot/types/interfaces";
 import { Hash } from "@polkadot/types/interfaces";
@@ -48,21 +38,6 @@ export const getVideoCategory = (
   id: VideoId | number
   id: VideoId | number
 ): Promise<Video> => api.query.content.videoCategoryById(id) as Promise<Video>;
 ): Promise<Video> => api.query.content.videoCategoryById(id) as Promise<Video>;
 
 
-export const getPerson = (
-  api: ApiPromise,
-  id: PersonId | number
-): Promise<Person> => api.query.content.personById(id) as Promise<Person>;
-
-export const getPlaylist = (
-  api: ApiPromise,
-  id: PlaylistId | number
-): Promise<Playlist> => api.query.content.playlistById(id) as Promise<Playlist>;
-
-export const getSeries = (
-  api: ApiPromise,
-  id: SeriesId | number
-): Promise<Series> => api.query.content.seriesById(id) as Promise<Series>;
-
 export const getNextChannel = (
 export const getNextChannel = (
   api: ApiPromise,
   api: ApiPromise,
   hash?: Hash
   hash?: Hash
@@ -79,14 +54,6 @@ export const getNextChannelCategory = (
     ? api.query.content.nextChannelCategoryId.at(hash)
     ? api.query.content.nextChannelCategoryId.at(hash)
     : (api.query.content.nextChannelCategoryId() as Promise<ChannelCategoryId>);
     : (api.query.content.nextChannelCategoryId() as Promise<ChannelCategoryId>);
 
 
-export const getNextChannelOwnershipTransferRequestId = (
-  api: ApiPromise,
-  hash?: Hash
-): Promise<ChannelOwnershipTransferRequestId> =>
-  hash
-    ? api.query.content.nextChannelOwnershipTransferRequestId.at(hash)
-    : (api.query.content.nextChannelOwnershipTransferRequestId() as Promise<ChannelOwnershipTransferRequestId>);
-
 export const getNextCuratorGroup = (
 export const getNextCuratorGroup = (
   api: ApiPromise,
   api: ApiPromise,
   hash?: Hash
   hash?: Hash

+ 2 - 21
index.ts

@@ -1,6 +1,4 @@
 import { CacheEvent } from "./types";
 import { CacheEvent } from "./types";
-import { Mint, MintId } from "@joystream/types/mint";
-import { Moment } from "@polkadot/types/interfaces";
 
 
 export const sum = (a: number[]) =>
 export const sum = (a: number[]) =>
   a.reduce((s: number, i: number) => s + i, 0);
   a.reduce((s: number, i: number) => s + i, 0);
@@ -13,15 +11,12 @@ export const getPercent = (value1: number, value2: number): number => {
 export const momentToString = (timestamp: number) =>
 export const momentToString = (timestamp: number) =>
   new Date(timestamp).toLocaleDateString("en-US");
   new Date(timestamp).toLocaleDateString("en-US");
 
 
-export const getTotalMinted = (mint: Mint) =>
-  Number(mint.getField("total_minted").toString());
-
 export const eventStats = (blockEventsCache: Map<number, CacheEvent[]>) => {
 export const eventStats = (blockEventsCache: Map<number, CacheEvent[]>) => {
   let sections: {
   let sections: {
     [key: string]: { [key: string]: [{ key: number; data: any }] };
     [key: string]: { [key: string]: [{ key: number; data: any }] };
   } = {};
   } = {};
   for (let [key, blockEvents] of blockEventsCache) {
   for (let [key, blockEvents] of blockEventsCache) {
-    blockEvents.map(({ section, method, data }) => {
+    blockEvents.forEach(({ section, method, data }) => {
       if (!sections[section]) sections[section] = {};
       if (!sections[section]) sections[section] = {};
       if (sections[section][method])
       if (sections[section][method])
         sections[section][method].push({ key, data });
         sections[section][method].push({ key, data });
@@ -47,31 +42,22 @@ export {
   getEvents,
   getEvents,
   getEra,
   getEra,
   getEraStake,
   getEraStake,
-  getCouncil,
-  getCouncilAt,
   getCouncils,
   getCouncils,
   getCouncilRound,
   getCouncilRound,
+  getCouncilStage,
   getCouncilElectionStage,
   getCouncilElectionStage,
   getCouncilTermEnd,
   getCouncilTermEnd,
   getCouncilElectionStatus,
   getCouncilElectionStatus,
   getCouncilSize,
   getCouncilSize,
   getCouncilApplicants,
   getCouncilApplicants,
-  getCouncilApplicantStakes,
   getCouncilCommitments,
   getCouncilCommitments,
   getCouncilPayoutInterval,
   getCouncilPayoutInterval,
   getCouncilPayout,
   getCouncilPayout,
   getCouncilElectionDurations,
   getCouncilElectionDurations,
-  getCommitments,
-  getCommitment,
   getNextWorker,
   getNextWorker,
   getWorker,
   getWorker,
   getWorkers,
   getWorkers,
   getStake,
   getStake,
-  getWorkerReward,
-  getCouncilMint,
-  getGroupMint,
-  getMintsCreated,
-  getMint,
   getAccounts,
   getAccounts,
   getAccount,
   getAccount,
   getNextMember,
   getNextMember,
@@ -98,21 +84,16 @@ export {
   getProposalThreadCount,
   getProposalThreadCount,
   getValidatorCount,
   getValidatorCount,
   getValidators,
   getValidators,
-  getPaidMembershipTermsById,
 } from "./api";
 } from "./api";
 
 
 export {
 export {
   getChannel,
   getChannel,
   getChannelCategory,
   getChannelCategory,
   getCuratorGroup,
   getCuratorGroup,
-  getPerson,
-  getPlaylist,
-  getSeries,
   getVideo,
   getVideo,
   getVideoCategory,
   getVideoCategory,
   getNextChannel,
   getNextChannel,
   getNextChannelCategory,
   getNextChannelCategory,
-  getNextChannelOwnershipTransferRequestId,
   getNextCuratorGroup,
   getNextCuratorGroup,
   getNextPerson,
   getNextPerson,
   getNextPlaylist,
   getNextPlaylist,

+ 9 - 20
rewards.ts

@@ -5,36 +5,28 @@ import { Bounty, CacheEvent, WorkerReward, SpendingProposal } from "./types";
 import { AccountId, Balance } from "@polkadot/types/interfaces";
 import { AccountId, Balance } from "@polkadot/types/interfaces";
 import { Hash } from "@polkadot/types/interfaces";
 import { Hash } from "@polkadot/types/interfaces";
 import { Membership } from "@joystream/types/members";
 import { Membership } from "@joystream/types/members";
-import { Mint, MintId } from "@joystream/types/mint";
 import {
 import {
   Proposal,
   Proposal,
   ProposalId,
   ProposalId,
   SpendingParams,
   SpendingParams,
 } from "@joystream/types/proposals";
 } from "@joystream/types/proposals";
 import { ProposalDetails, ProposalOf } from "@joystream/types/augment/types";
 import { ProposalDetails, ProposalOf } from "@joystream/types/augment/types";
-import { Stake } from "@joystream/types/stake";
-import {
-  RewardRelationship,
-  RewardRelationshipId,
-} from "@joystream/types/recurring-rewards";
 
 
 // lib
 // lib
-import { getPercent, getTotalMinted } from "./";
+import { getPercent } from "./";
 import {
 import {
   getBlock,
   getBlock,
   getBlockHash,
   getBlockHash,
-  getMint,
   getNextWorker,
   getNextWorker,
   getMember,
   getMember,
   getWorker,
   getWorker,
-  getWorkerReward,
   getProposalInfo,
   getProposalInfo,
   getProposalDetails,
   getProposalDetails,
   getStake,
   getStake,
   getValidators,
   getValidators,
   getValidatorCount,
   getValidatorCount,
 } from "./api";
 } from "./api";
-import { WorkerOf } from "@joystream/types/augment-codec/all";
+import { Worker } from "@joystream/types/augment-codec/all";
 import { ProposalDetailsOf } from "@joystream/types/augment/types";
 import { ProposalDetailsOf } from "@joystream/types/augment/types";
 
 
 export const filterMethods = {
 export const filterMethods = {
@@ -57,16 +49,17 @@ export const getWorkerRewards = async (
   const nextWorkerId = await getNextWorker(api, group, hash);
   const nextWorkerId = await getNextWorker(api, group, hash);
 
 
   for (let id = 0; id < nextWorkerId; ++id) {
   for (let id = 0; id < nextWorkerId; ++id) {
-    const worker: WorkerOf = await getWorker(api, group, hash, id);
+    const worker: Worker = await getWorker(api, group, hash, id);
 
 
     const account = worker.role_account_id as AccountId;
     const account = worker.role_account_id as AccountId;
     const memberId = worker.member_id;
     const memberId = worker.member_id;
     const member: Membership = await getMember(api, memberId, hash);
     const member: Membership = await getMember(api, memberId, hash);
-    const handle = member ? String(member.handle) : account.toString();
+    const handle = member ? String(member.handle_hash) : account.toString();
     const status = worker.is_active ? `active` : `inactive`;
     const status = worker.is_active ? `active` : `inactive`;
 
 
     // fetch reward and stake
     // fetch reward and stake
     const w: WorkerReward = { id, status, handle, account, memberId };
     const w: WorkerReward = { id, status, handle, account, memberId };
+    /**
     if (worker.role_stake_profile.isSome) {
     if (worker.role_stake_profile.isSome) {
       const roleStakeProfile = worker.role_stake_profile.unwrap();
       const roleStakeProfile = worker.role_stake_profile.unwrap();
       w.stake = await getStake(api, roleStakeProfile.stake_id);
       w.stake = await getStake(api, roleStakeProfile.stake_id);
@@ -75,7 +68,7 @@ export const getWorkerRewards = async (
     if (worker.reward_relationship.isSome) {
     if (worker.reward_relationship.isSome) {
       const id: RewardRelationshipId = worker.reward_relationship.unwrap();
       const id: RewardRelationshipId = worker.reward_relationship.unwrap();
       w.reward = await getWorkerReward(api, hash, id);
       w.reward = await getWorkerReward(api, hash, id);
-    }
+    } **/
     workers.push(w);
     workers.push(w);
   }
   }
   return workers;
   return workers;
@@ -128,18 +121,14 @@ export const getFinalizedSpendingProposals = async (
       const proposalId = event.data[0] as ProposalId;
       const proposalId = event.data[0] as ProposalId;
       const id = +proposalId;
       const id = +proposalId;
       const proposalInfo: ProposalOf = await getProposalInfo(api, proposalId);
       const proposalInfo: ProposalOf = await getProposalInfo(api, proposalId);
-      const finalizedData = proposalInfo.status.asFinalized;
       const details: ProposalDetailsOf = await getProposalDetails(
       const details: ProposalDetailsOf = await getProposalDetails(
         api,
         api,
         proposalId
         proposalId
       );
       );
-      if (!finalizedData.proposalStatus.isApproved || !details.isSpending)
-        continue;
-      let approvedData = finalizedData.proposalStatus.asApproved;
-      if (!approvedData.isExecuted) continue;
+      if (!proposalInfo.status || !details.isFundingRequest) continue;
       if (spendingProposals.some((proposal) => +proposal.id === +id)) continue;
       if (spendingProposals.some((proposal) => +proposal.id === +id)) continue;
-      const title = String(proposalInfo.title.toHuman());
-      const amount = +details.asSpending[0];
+      const title = ``; //String(proposalInfo.title.toHuman());
+      const amount = 0;
 
 
       console.log(`Spent ${amount.toFixed().padStart(8)} on ${id} ${title}`);
       console.log(`Spent ${amount.toFixed().padStart(8)} on ${id} ${title}`);
       spendingProposals.push({ id, title, amount });
       spendingProposals.push({ id, title, amount });

+ 0 - 1
storage.ts

@@ -1,5 +1,4 @@
 import { ApiPromise } from "@polkadot/api";
 import { ApiPromise } from "@polkadot/api";
-import type { ITuple } from "@polkadot/types/types";
 import {
 import {
   Bag,
   Bag,
   BagId,
   BagId,

+ 6 - 12
types.ts

@@ -1,8 +1,6 @@
 import { AccountId, AccountData } from "@polkadot/types/interfaces";
 import { AccountId, AccountData } from "@polkadot/types/interfaces";
 import { GenericEventData } from "@polkadot/types/generic/Event";
 import { GenericEventData } from "@polkadot/types/generic/Event";
-import { MemberId } from "@joystream/types/members";
-import { Stake } from "@joystream/types/stake";
-import { RewardRelationship } from "@joystream/types/recurring-rewards";
+import { MemberId } from "@joystream/types/common";
 import { VotingResults } from "@joystream/types/augment/all";
 import { VotingResults } from "@joystream/types/augment/all";
 
 
 export interface AccountBalance {
 export interface AccountBalance {
@@ -24,16 +22,12 @@ export interface Vote {
 }
 }
 
 
 export interface ProposalDetail {
 export interface ProposalDetail {
-  created: number;
-  finalizedAt: number;
+  activatedAt: number;
+  executedAt: number;
   message: { tg: string; discord: string };
   message: { tg: string; discord: string };
   parameters: string; // ProposalParameters
   parameters: string; // ProposalParameters
-  stage: any;
-  result: string;
-  exec: any;
+  status: any;
   id: number;
   id: number;
-  title: string;
-  description: any;
   votes: VotingResults;
   votes: VotingResults;
   type: string;
   type: string;
   votesByAccount?: Vote[];
   votesByAccount?: Vote[];
@@ -84,8 +78,8 @@ export interface WorkerReward {
   memberId: MemberId;
   memberId: MemberId;
   account: AccountId;
   account: AccountId;
   handle: string;
   handle: string;
-  stake?: Stake;
-  reward?: RewardRelationship;
+  stake?: any;
+  reward?: any;
   status: string;
   status: string;
 }
 }