Explorar el Código

Remove needless files after rebase

Leszek Wiesner hace 4 años
padre
commit
7985419b43

+ 0 - 17
pioneer/packages/joy-proposals/src/Proposal/Error.tsx

@@ -1,17 +0,0 @@
-import React from "react";
-import { Container, Message } from "semantic-ui-react";
-
-type ErrorProps = {
-  error: any;
-};
-export default function Error({ error }: ErrorProps) {
-  console.error(error);
-  return (
-    <Container style={{ display: "flex", justifyContent: "center", alignItems: "center" }}>
-      <Message negative>
-        <Message.Header>Oops! We got an error!</Message.Header>
-        <p>{error.message}</p>
-      </Message>
-    </Container>
-  );
-}

+ 0 - 14
pioneer/packages/joy-proposals/src/Proposal/Loading.tsx

@@ -1,14 +0,0 @@
-import React from "react";
-import { Loader, Container } from "semantic-ui-react";
-
-type LoadingProps = {
-  text: string;
-};
-
-export default function Loading({ text }: LoadingProps) {
-  return (
-    <Container style={{ display: "flex", justifyContent: "center", alignItems: "center" }}>
-      <Loader active>{text}</Loader>
-    </Container>
-  );
-}

+ 0 - 20
pioneer/packages/joy-proposals/src/Proposal/PromiseComponent.tsx

@@ -1,20 +0,0 @@
-import React from 'react';
-import Loading from "./Loading";
-import Error from "./Error";
-
-type PromiseComponentProps = {
-  loading: boolean,
-  error: any,
-  message: string,
-}
-const PromiseComponent: React.FunctionComponent<PromiseComponentProps> = ({ loading, error, message, children }) => {
-  if (loading && !error) {
-    return <Loading text={ message } />;
-  } else if (error) {
-    return <Error error={error} />;
-  }
-
-  return <>{ children }</>;
-}
-
-export default PromiseComponent;

+ 0 - 23
pioneer/packages/joy-proposals/src/runtime/TransportContext.tsx

@@ -1,23 +0,0 @@
-import React, { createContext, useContext } from "react";
-import { ApiContext } from "@polkadot/react-api";
-import { ApiProps } from "@polkadot/react-api/types";
-import { SubstrateTransport } from "./transport.substrate";
-import { MockTransport } from "./transport.mock";
-import { Transport } from "./transport";
-
-const TransportContext = createContext<Transport>((null as unknown) as Transport);
-
-export function MockProvider({ children }: { children: React.PropsWithChildren<{}> }) {
-  return <TransportContext.Provider value={new MockTransport()}>{children}</TransportContext.Provider>;
-}
-
-export function SubstrateProvider({ children }: { children: React.PropsWithChildren<{}> }) {
-  const api: ApiProps = useContext(ApiContext);
-  const transport = new SubstrateTransport(api);
-
-  return <TransportContext.Provider value={transport}>{children}</TransportContext.Provider>;
-}
-
-export function useTransport() {
-  return useContext(TransportContext) as SubstrateTransport;
-}

+ 0 - 66
pioneer/packages/joy-proposals/src/runtime/cache.ts

@@ -1,66 +0,0 @@
-// Set does not do a deep equal when adding elements, so try to only use strings or another primitive for K
-
-export default class Cache<K, T extends { id: K }> extends Map<K, T> {
-  protected neverClear: Set<K>;
-
-  constructor(
-    objects: Iterable<readonly [K, T]>,
-    protected loaderFn: (ids: K[]) => Promise<T[]>,
-    neverClear: K[] | Set<K> = [],
-    public name?: string
-  ) {
-    super(objects);
-    this.name = name;
-    this.neverClear = new Set(neverClear);
-    this.loaderFn = loaderFn;
-  }
-
-  forceClear(): void {
-    const prevCacheSize = this.size;
-    this.clear();
-    console.info(`Removed all ${prevCacheSize} entries from ${this.name}, including ${this.neverClear}`);
-  }
-
-  clearExcept(keepIds: K[] | Set<K>, force: boolean = false): void {
-    const prevCacheSize = this.size;
-    const keepIdsSet = force ? new Set(keepIds) : new Set([...keepIds, ...this.neverClear]);
-
-    for (let key of this.keys()) {
-      if (!keepIdsSet.has(key)) {
-        this.delete(key);
-      }
-    }
-
-    console.info(`Removed ${prevCacheSize - this.size} entries out of ${prevCacheSize} from ${this.name}`);
-  }
-
-  clear(): void {
-    this.clearExcept([]);
-  }
-
-  async load(ids: K[], force: boolean = false): Promise<T[]> {
-    const idsNotInCache: K[] = [];
-    const cachedObjects: T[] = [];
-
-    ids.forEach(id => {
-      let objFromCache = this.get(id);
-      if (objFromCache && !force) {
-        cachedObjects.push(objFromCache);
-      } else {
-        idsNotInCache.push(id);
-      }
-    });
-
-    let loadedObjects: T[] = [];
-
-    if (idsNotInCache.length > 0) {
-      loadedObjects = await this.loaderFn(idsNotInCache);
-      loadedObjects.forEach(obj => {
-        const id = obj.id;
-        this.set(id, obj);
-      });
-    }
-
-    return [...cachedObjects, ...loadedObjects];
-  }
-}

+ 0 - 4
pioneer/packages/joy-proposals/src/runtime/index.ts

@@ -1,4 +0,0 @@
-export { ParsedProposal, ProposalType, ProposalVote, IStorageRoleParameters, StorageRoleParameters } from "./transport";
-export { SubstrateTransport } from "./transport.substrate";
-export { MockTransport } from "./transport.mock";
-export { SubstrateProvider, useTransport } from "./TransportContext";

+ 0 - 16
pioneer/packages/joy-proposals/src/runtime/transport.mock.ts

@@ -1,16 +0,0 @@
-import { Transport, ParsedProposal } from "./transport";
-
-function delay(ms: number) {
-  return new Promise(resolve => setTimeout(resolve, ms));
-}
-
-export class MockTransport extends Transport {
-  constructor() {
-    super();
-  }
-
-  async proposals() {
-    await delay(Math.random() * 2000);
-    return Promise.all((Array.from({ length: 5 }, (_, i) => "Not implemented") as unknown) as ParsedProposal[]);
-  }
-}

+ 0 - 328
pioneer/packages/joy-proposals/src/runtime/transport.substrate.ts

@@ -1,328 +0,0 @@
-import {
-  Transport,
-  ParsedProposal,
-  ProposalType,
-  ProposalTypes,
-  ParsedMember,
-  ProposalVote,
-  IStorageRoleParameters
-} from "./transport";
-import { Proposal, ProposalId, Seats, VoteKind, ElectionParameters } from "@joystream/types/proposals";
-import { MemberId, Profile, ActorInRole, RoleKeys, Role } from "@joystream/types/members";
-import { ApiProps } from "@polkadot/react-api/types";
-import { u32, u128, Vec, Option } from "@polkadot/types/";
-import { Balance, Moment, AccountId, BlockNumber, BalanceOf } from "@polkadot/types/interfaces";
-import { ApiPromise } from "@polkadot/api";
-
-import { FIRST_MEMBER_ID } from "@polkadot/joy-members/constants";
-
-import { includeKeys, calculateStake, calculateMetaFromType, splitOnUpperCase } from "../utils";
-import { MintId, Mint } from "@joystream/types/mint";
-import { LeadId } from "@joystream/types/content-working-group";
-
-export class SubstrateTransport extends Transport {
-  protected api: ApiPromise;
-
-  constructor(api: ApiProps) {
-    super();
-
-    if (!api) {
-      throw new Error("Cannot create SubstrateTransport: A Substrate API is required");
-    } else if (!api.isApiReady) {
-      throw new Error("Cannot create a SubstrateTransport: The Substrate API is not ready yet.");
-    }
-
-    this.api = api.api;
-  }
-
-  get proposalsEngine() {
-    return this.api.query.proposalsEngine;
-  }
-
-  get proposalsCodex() {
-    return this.api.query.proposalsCodex;
-  }
-
-  get members() {
-    return this.api.query.members;
-  }
-
-  get council() {
-    return this.api.query.council;
-  }
-
-  get councilElection() {
-    return this.api.query.councilElection;
-  }
-
-  get actors() {
-    return this.api.query.actors;
-  }
-
-  get contentWorkingGroup() {
-    return this.api.query.contentWorkingGroup;
-  }
-
-  get minting() {
-    return this.api.query.minting;
-  }
-
-  totalIssuance() {
-    return this.api.query.balances.totalIssuance<Balance>();
-  }
-
-  async blockHash(height: number): Promise<string> {
-    const blockHash = await this.api.rpc.chain.getBlockHash(height);
-
-    return blockHash.toString();
-  }
-
-  async blockTimestamp(height: number): Promise<Date> {
-    const blockTime = (await this.api.query.timestamp.now.at(await this.blockHash(height))) as Moment;
-
-    return new Date(blockTime.toNumber());
-  }
-
-  proposalCount() {
-    return this.proposalsEngine.proposalCount<u32>();
-  }
-
-  rawProposalById(id: ProposalId) {
-    return this.proposalsEngine.proposals<Proposal>(id);
-  }
-
-  proposalDetailsById(id: ProposalId) {
-    return this.proposalsCodex.proposalDetailsByProposalId(id);
-  }
-
-  memberProfile(id: MemberId | number): Promise<Option<Profile>> {
-    return this.members.memberProfile(id) as Promise<Option<Profile>>;
-  }
-
-  async cancellationFee(): Promise<number> {
-    return ((await this.api.consts.proposalsEngine.cancellationFee) as BalanceOf).toNumber();
-  }
-
-  async proposalById(id: ProposalId): Promise<ParsedProposal> {
-    const rawDetails = (await this.proposalDetailsById(id)).toJSON() as { [k: string]: any };
-    const type = Object.keys(rawDetails)[0] as ProposalType;
-    const details = Array.isArray(rawDetails[type]) ? rawDetails[type] : [rawDetails[type]];
-    const rawProposal = await this.rawProposalById(id);
-    const proposer = (await this.memberProfile(rawProposal.proposerId)).toJSON() as ParsedMember;
-    const proposal = rawProposal.toJSON() as {
-      title: string;
-      description: string;
-      parameters: any;
-      votingResults: any;
-      proposerId: number;
-      status: any;
-    };
-    const createdAtBlock = rawProposal.createdAt;
-    const createdAt = await this.blockTimestamp(createdAtBlock.toNumber());
-    const cancellationFee = await this.cancellationFee();
-
-    return {
-      id,
-      ...proposal,
-      details,
-      type,
-      proposer,
-      createdAtBlock: createdAtBlock.toJSON(),
-      createdAt,
-      cancellationFee
-    };
-  }
-
-  async proposalsIds() {
-    const total: number = (await this.proposalCount()).toNumber();
-    return Array.from({ length: total }, (_, i) => new ProposalId(i + 1));
-  }
-
-  async proposals() {
-    const ids = await this.proposalsIds();
-    return Promise.all(ids.map(id => this.proposalById(id)));
-  }
-
-  async activeProposals() {
-    const activeProposalIds = await this.proposalsEngine.activeProposalIds<ProposalId[]>();
-
-    return Promise.all(activeProposalIds.map(id => this.proposalById(id)));
-  }
-
-  async proposedBy(member: MemberId) {
-    const proposals = await this.proposals();
-    return proposals.filter(({ proposerId }) => member.eq(proposerId));
-  }
-
-  async proposalDetails(id: ProposalId) {
-    return this.proposalsCodex.proposalDetailsByProposalId(id);
-  }
-
-  async councilMembers(): Promise<(ParsedMember & { memberId: MemberId })[]> {
-    const council = (await this.council.activeCouncil()) as Seats;
-    return Promise.all(
-      council.map(async seat => {
-        const memberIds = (await this.members.memberIdsByControllerAccountId(seat.member)) as Vec<MemberId>;
-        const member = (await this.memberProfile(memberIds[0])).toJSON() as ParsedMember;
-        return {
-          ...member,
-          memberId: memberIds[0]
-        };
-      })
-    );
-  }
-
-  async voteByProposalAndMember(proposalId: ProposalId, voterId: MemberId): Promise<VoteKind | null> {
-    const vote = await this.proposalsEngine.voteExistsByProposalByVoter<VoteKind>(proposalId, voterId);
-    const hasVoted = (await this.proposalsEngine.voteExistsByProposalByVoter.size(proposalId, voterId)).toNumber();
-    return hasVoted ? vote : null;
-  }
-
-  async votes(proposalId: ProposalId): Promise<ProposalVote[]> {
-    const councilMembers = await this.councilMembers();
-    return Promise.all(
-      councilMembers.map(async member => {
-        const vote = await this.voteByProposalAndMember(proposalId, member.memberId);
-        return {
-          vote,
-          member
-        };
-      })
-    );
-  }
-
-  async fetchProposalMethodsFromCodex(includeKey: string) {
-    const methods = includeKeys(this.proposalsCodex, includeKey);
-    // methods = [proposalTypeVotingPeriod...]
-    return methods.reduce(async (prevProm, method) => {
-      const obj = await prevProm;
-      const period = (await this.proposalsCodex[method]()) as u32;
-      // setValidatorCountProposalVotingPeriod to SetValidatorCount
-      const key = splitOnUpperCase(method)
-        .slice(0, -3)
-        .map((w, i) => (i === 0 ? w.slice(0, 1).toUpperCase() + w.slice(1) : w))
-        .join("") as ProposalType;
-
-      return { ...obj, [`${key}`]: period.toNumber() };
-    }, Promise.resolve({}) as Promise<{ [k in ProposalType]: number }>);
-  }
-
-  async proposalTypesGracePeriod(): Promise<{ [k in ProposalType]: number }> {
-    return this.fetchProposalMethodsFromCodex("GracePeriod");
-  }
-
-  async proposalTypesVotingPeriod(): Promise<{ [k in ProposalType]: number }> {
-    return this.fetchProposalMethodsFromCodex("VotingPeriod");
-  }
-
-  async parametersFromProposalType(type: ProposalType) {
-    const votingPeriod = (await this.proposalTypesVotingPeriod())[type];
-    const gracePeriod = (await this.proposalTypesGracePeriod())[type];
-    const issuance = (await this.totalIssuance()).toNumber();
-    const stake = calculateStake(type, issuance);
-    const meta = calculateMetaFromType(type);
-    // Currently it's same for all types, but this will change soon
-    const cancellationFee = await this.cancellationFee();
-    return {
-      type,
-      votingPeriod,
-      gracePeriod,
-      stake,
-      cancellationFee,
-      ...meta
-    };
-  }
-
-  async proposalsTypesParameters() {
-    return Promise.all(ProposalTypes.map(type => this.parametersFromProposalType(type)));
-  }
-
-  async bestBlock() {
-    return await this.api.derive.chain.bestNumber();
-  }
-
-  async storageProviders(): Promise<AccountId[]> {
-    const providers = (await this.actors.accountIdsByRole(RoleKeys.StorageProvider)) as Vec<AccountId>;
-    return providers.toArray();
-  }
-
-  async membersExceptCouncil(): Promise<{ id: number; profile: Profile }[]> {
-    // Council members to filter out
-    const activeCouncil = (await this.council.activeCouncil()) as Seats;
-    const membersCount = ((await this.members.membersCreated()) as MemberId).toNumber();
-    const profiles: { id: number; profile: Profile }[] = [];
-    for (let id = FIRST_MEMBER_ID.toNumber(); id < membersCount; ++id) {
-      const profile = (await this.memberProfile(new MemberId(id))).unwrapOr(null);
-      if (
-        !profile ||
-        // Filter out council members
-        activeCouncil.some(
-          seat =>
-            seat.member.toString() === profile.controller_account.toString() ||
-            seat.member.toString() === profile.root_account.toString()
-        )
-      ) {
-        continue;
-      }
-      profiles.push({ id, profile });
-    }
-
-    return profiles;
-  }
-
-  async storageRoleParameters(): Promise<IStorageRoleParameters> {
-    const params = (
-      await this.api.query.actors.parameters(RoleKeys.StorageProvider)
-    ).toJSON() as IStorageRoleParameters;
-    return params;
-  }
-
-  async maxValidatorCount(): Promise<number> {
-    const count = ((await this.api.query.staking.validatorCount()) as u32).toNumber();
-    return count;
-  }
-
-  async electionParameters(): Promise<ElectionParameters> {
-    const announcing_period = (await this.councilElection.announcingPeriod()) as BlockNumber;
-    const voting_period = (await this.councilElection.votingPeriod()) as BlockNumber;
-    const revealing_period = (await this.councilElection.revealingPeriod()) as BlockNumber;
-    const new_term_duration = (await this.councilElection.newTermDuration()) as BlockNumber;
-    const min_council_stake = (await this.councilElection.minCouncilStake()) as Balance;
-    const min_voting_stake = (await this.councilElection.minVotingStake()) as Balance;
-    const candidacy_limit = (await this.councilElection.candidacyLimit()) as u32;
-    const council_size = (await this.councilElection.councilSize()) as u32;
-
-    return new ElectionParameters({
-      announcing_period,
-      voting_period,
-      revealing_period,
-      new_term_duration,
-      min_council_stake,
-      min_voting_stake,
-      candidacy_limit,
-      council_size
-    });
-  }
-
-  async WGMintCap(): Promise<number> {
-    const WGMintId = (await this.contentWorkingGroup.mint()) as MintId;
-    const WGMint = (await this.minting.mints(WGMintId)) as Vec<Mint>;
-    return (WGMint[0].get("capacity") as u128).toNumber();
-  }
-
-  async WGLead(): Promise<{ id: number; profile: Profile } | null> {
-    const optLeadId = (await this.contentWorkingGroup.currentLeadId()) as Option<LeadId>;
-    const leadId = optLeadId.unwrapOr(null);
-
-    if (!leadId) return null;
-
-    const actorInRole = new ActorInRole({
-      role: new Role(RoleKeys.CuratorLead),
-      actor_id: leadId
-    });
-    const memberId = (await this.members.membershipIdByActorInRole(actorInRole)) as MemberId;
-    const profile = (await this.memberProfile(memberId)).unwrapOr(null);
-
-    return profile && { id: memberId.toNumber(), profile };
-  }
-}

+ 0 - 79
pioneer/packages/joy-proposals/src/runtime/transport.ts

@@ -1,79 +0,0 @@
-import { ProposalId, VoteKind } from "@joystream/types/proposals";
-import { MemberId } from "@joystream/types/members";
-export const ProposalTypes = [
-  "Text",
-  "RuntimeUpgrade",
-  "SetElectionParameters",
-  "Spending",
-  "SetLead",
-  "SetContentWorkingGroupMintCapacity",
-  "EvictStorageProvider",
-  "SetValidatorCount",
-  "SetStorageRoleParameters"
-] as const;
-
-export type ProposalType = typeof ProposalTypes[number];
-
-export type ParsedMember = {
-  about: string;
-  avatar_uri: string;
-  handle: string;
-  registered_at_block: number;
-  registered_at_time: number;
-  roles: any[];
-  entry: { [k: string]: any };
-  root_account: string;
-  controller_account: string;
-  subscription: any;
-  suspended: boolean;
-};
-
-export type ParsedProposal = {
-  id: ProposalId;
-  type: ProposalType;
-  title: string;
-  description: string;
-  status: any;
-  proposer: ParsedMember;
-  proposerId: number;
-  createdAtBlock: number;
-  createdAt: Date;
-  details: any[];
-  votingResults: any;
-  parameters: {
-    approvalQuorumPercentage: number;
-    approvalThresholdPercentage: number;
-    gracePeriod: number;
-    requiredStake: number;
-    slashingQuorumPercentage: number;
-    slashingThresholdPercentage: number;
-    votingPeriod: number;
-  };
-  cancellationFee: number;
-};
-
-export const StorageRoleParameters = [
-  "min_stake",
-  "min_actors",
-  "max_actors",
-  "reward",
-  "reward_period",
-  "bonding_period",
-  "unbonding_period",
-  "min_service_period",
-  "startup_grace_period",
-  "entry_request_fee"
-] as const;
-
-export type IStorageRoleParameters = {
-  [k in typeof StorageRoleParameters[number]]: number;
-};
-
-export type ProposalVote = {
-  vote: VoteKind | null;
-  member: ParsedMember & { memberId: MemberId };
-};
-
-export abstract class Transport {
-  abstract proposals(): Promise<ParsedProposal[]>;
-}

+ 0 - 273
pioneer/packages/joy-proposals/src/utils.ts

@@ -1,273 +0,0 @@
-import { useState, useEffect, useCallback } from "react";
-import { ProposalType } from "./runtime";
-import { Category } from "./Proposal/ChooseProposalType";
-import { useTransport, ParsedProposal, ProposalVote } from "./runtime";
-import { ProposalId } from "@joystream/types/proposals";
-
-type ProposalMeta = {
-  description: string;
-  category: Category;
-  image: string;
-  approvalQuorum: number;
-  approvalThreshold: number;
-  slashingQuorum: number;
-  slashingThreshold: number;
-}
-
-export function includeKeys<T extends { [k: string]: any }>(obj: T, ...allowedKeys: string[]) {
-  return Object.keys(obj).filter(objKey => {
-    return allowedKeys.reduce(
-      (hasAllowed: boolean, allowedKey: string) => hasAllowed || objKey.includes(allowedKey),
-      false
-    );
-  });
-}
-
-export function splitOnUpperCase(str: string) {
-  return str.split(/(?=[A-Z])/);
-}
-
-export function slugify(str: string) {
-  return splitOnUpperCase(str)
-    .map(w => w.toLowerCase())
-    .join("-")
-    .trim();
-}
-
-export function snakeCaseToCamelCase(str: string) {
-  return str
-    .split('_')
-    .map((w, i) => i ? w[0].toUpperCase() + w.substr(1) : w)
-    .join('');
-}
-
-export function camelCaseToSnakeCase(str: string) {
-  return splitOnUpperCase(str)
-    .map(w => w[0].toLocaleLowerCase() + w.substr(1))
-    .join('_');
-}
-
-export function usePromise<T>(promise: () => Promise<T>, defaultValue: T): [T, any, boolean, () => Promise<void|null>] {
-  const [state, setState] = useState<{
-    value: T;
-    error: any;
-    isPending: boolean;
-  }>({ value: defaultValue, error: null, isPending: true });
-
-  let isSubscribed = true;
-  const execute = useCallback(() => {
-    return promise()
-      .then(value => (isSubscribed ? setState({ value, error: null, isPending: false }) : null))
-      .catch(error => (isSubscribed ? setState({ value: defaultValue, error: error, isPending: false }) : null));
-  }, [promise]);
-
-  useEffect(() => {
-    execute();
-    return () => {
-      isSubscribed = false;
-    };
-  }, []);
-
-  const { value, error, isPending } = state;
-  return [value, error, isPending, execute];
-}
-
-// Take advantage of polkadot api subscriptions to re-fetch proposal data and votes
-// each time there is some runtime change in the proposal
-export const useProposalSubscription = (id: ProposalId) => {
-  const transport = useTransport();
-  // State holding an "unsubscribe method"
-  const [unsubscribeProposal, setUnsubscribeProposal] = useState<(() => void) | null>(null);
-
-  const [proposal, proposalError, proposalLoading, refreshProposal] = usePromise<ParsedProposal>(
-    () => transport.proposalById(id),
-    {} as ParsedProposal
-  );
-
-  const [votes, votesError, votesLoading, refreshVotes] = usePromise<ProposalVote[]>(
-    () => transport.votes(id),
-    []
-  );
-
-  // Function to re-fetch the data using transport
-  const refreshProposalData = () => {
-    refreshProposal();
-    refreshVotes();
-  }
-
-  useEffect(() => {
-    // onMount...
-    let unmounted = false;
-    // Create the subscription
-    transport.proposalsEngine.proposals(id, refreshProposalData)
-      .then(unsubscribe => {
-        if (!unmounted) {
-          setUnsubscribeProposal(() => unsubscribe);
-        }
-        else {
-          unsubscribe(); // If already unmounted - unsubscribe immedietally!
-        }
-      });
-    return () => {
-      // onUnmount...
-      // Clean the subscription
-      unmounted = true;
-      if (unsubscribeProposal !== null) unsubscribeProposal();
-    }
-  }, []);
-
-  return {
-    proposal: { data: proposal, error: proposalError, loading: proposalLoading },
-    votes: { data: votes, error: votesError, loading: votesLoading }
-  }
-};
-
-
-export function calculateStake(type: ProposalType, issuance: number) {
-  let stake = NaN;
-  switch (type) {
-    case "EvictStorageProvider": {
-      stake = 25000;
-      break;
-    }
-    case "Text":
-      stake = 25000;
-      break;
-    case "SetStorageRoleParameters":
-      stake = 100000;
-      break;
-    case "SetValidatorCount":
-      stake = 100000;
-      break;
-    case "SetLead":
-      stake = 50000;
-      break;
-    case "SetContentWorkingGroupMintCapacity":
-      stake = 50000;
-      break;
-    case "Spending": {
-      stake = 25000;
-      break;
-    }
-    case "SetElectionParameters": {
-      stake = 200000;
-      break;
-    }
-    case "RuntimeUpgrade": {
-      stake = 1000000;
-      break;
-    }
-    default: {
-      throw new Error(`Proposal Type is invalid. Got ${type}. Can't calculate issuance.`);
-    }
-  }
-  return stake;
-}
-
-export function calculateMetaFromType(type: ProposalType): ProposalMeta {
-  const image = "";
-  switch (type) {
-    case "EvictStorageProvider": {
-      return {
-        description: "Evicting Storage Provider Proposal",
-        category: "Storage",
-        image,
-        approvalQuorum: 50,
-        approvalThreshold: 75,
-        slashingQuorum: 60,
-        slashingThreshold: 80,
-      }
-    }
-    case "Text": {
-      return {
-        description: "Signal Proposal",
-        category: "Other",
-        image,
-        approvalQuorum: 60,
-        approvalThreshold: 80,
-        slashingQuorum: 60,
-        slashingThreshold: 80,
-      }
-    }
-    case "SetStorageRoleParameters": {
-      return {
-        description: "Set Storage Role Params Proposal",
-        category: "Storage",
-        image,
-        approvalQuorum: 66,
-        approvalThreshold: 80,
-        slashingQuorum: 60,
-        slashingThreshold: 80,
-      }
-    }
-    case "SetValidatorCount": {
-      return {
-        description: "Set Max Validator Count Proposal",
-        category: "Validators",
-        image,
-        approvalQuorum: 66,
-        approvalThreshold: 80,
-        slashingQuorum: 60,
-        slashingThreshold: 80,
-      }
-    }
-    case "SetLead": {
-      return {
-        description: "Set Lead Proposal",
-        category: "Content Working Group",
-        image,
-        approvalQuorum: 60,
-        approvalThreshold: 75,
-        slashingQuorum: 60,
-        slashingThreshold: 80,
-      }
-    }
-    case "SetContentWorkingGroupMintCapacity": {
-      return {
-        description: "Set WG Mint Capacity Proposal",
-        category: "Content Working Group",
-        image,
-        approvalQuorum: 60,
-        approvalThreshold: 75,
-        slashingQuorum: 60,
-        slashingThreshold: 80,
-      }
-    }
-    case "Spending": {
-      return {
-        description: "Spending Proposal",
-        category: "Other",
-        image,
-        approvalQuorum: 60,
-        approvalThreshold: 80,
-        slashingQuorum: 60,
-        slashingThreshold: 80,
-      }
-    }
-    case "SetElectionParameters": {
-      return {
-        description: "Set Election Parameters Proposal",
-        category: "Council",
-        image,
-        approvalQuorum: 66,
-        approvalThreshold: 80,
-        slashingQuorum: 60,
-        slashingThreshold: 80,
-      }
-    }
-    case "RuntimeUpgrade": {
-      return {
-        description: "Runtime Upgrade Proposal",
-        category: "Other",
-        image,
-        approvalQuorum: 80,
-        approvalThreshold: 100,
-        slashingQuorum: 60,
-        slashingThreshold: 80,
-      }
-    }
-    default: {
-      throw new Error("'Proposal Type is invalid. Can't calculate metadata.");
-    }
-  }
-}