Эх сурвалжийг харах

pioneer: inject joy.types into app-js javascript playground

Mokhtar Naamani 4 жил өмнө
parent
commit
e6f8e1eef5

+ 10 - 1
pioneer/packages/app-js/src/Playground.tsx

@@ -18,6 +18,7 @@ import uiKeyring from '@polkadot/ui-keyring';
 import * as types from '@polkadot/types';
 import * as util from '@polkadot/util';
 import * as hashing from '@polkadot/util-crypto';
+import * as joy_types from '@joystream/types';
 
 import makeWrapper from './snippets/wrapping';
 import allSnippets from './snippets';
@@ -39,6 +40,10 @@ interface Injected {
   types: typeof types;
   util: typeof util;
   window: null;
+  joy: {
+    types: typeof joy_types,
+  },
+  decodeAddress: typeof uiKeyring.keyring.decodeAddress
 }
 
 interface Props extends AppProps, I18nProps, RouteComponentProps<{}> {
@@ -195,7 +200,11 @@ function Playground ({ className, history, match: { params: { base64 } }, t }: P
         : null,
       types,
       util,
-      window: null
+      window: null,
+      joy: {
+        types: joy_types
+      },
+      decodeAddress: uiKeyring.keyring.decodeAddress
     };
 
     await injectedRef.current.api.isReady;

+ 2 - 2
pioneer/packages/joy-election/src/Applicant.tsx

@@ -11,12 +11,12 @@ import CandidatePreview from './CandidatePreview';
 
 import translate from './translate';
 import { calcTotalStake } from '@polkadot/joy-utils/index';
-import { Stake } from '@joystream/types/council';
+import { ElectionStake } from '@joystream/types/council';
 
 type Props = ApiProps & I18nProps & {
   index: number;
   accountId: AccountId;
-  stake?: Stake;
+  stake?: ElectionStake;
 };
 
 class Applicant extends React.PureComponent<Props> {

+ 2 - 2
pioneer/packages/joy-election/src/ApplyForm.tsx

@@ -10,13 +10,13 @@ import { Balance } from '@polkadot/types/interfaces';
 import translate from './translate';
 import TxButton from '@polkadot/joy-utils/TxButton';
 import InputStake from '@polkadot/joy-utils/InputStake';
-import { Stake } from '@joystream/types/council';
+import { ElectionStake } from '@joystream/types/council';
 import { calcTotalStake, ZERO } from '@polkadot/joy-utils/index';
 import { MyAddressProps, withOnlyMembers } from '@polkadot/joy-utils/MyAccount';
 
 type Props = ApiProps & I18nProps & MyAddressProps & {
   minStake?: Balance;
-  alreadyStaked?: Stake;
+  alreadyStaked?: ElectionStake;
   myBalance?: Balance;
 };
 

+ 3 - 3
pioneer/packages/joy-utils/src/index.ts

@@ -7,7 +7,7 @@ import keyring from '@polkadot/ui-keyring';
 // Joystream Stake utils
 // --------------------------------------
 
-import { Stake, Backer } from '@joystream/types/council';
+import { ElectionStake, Backer } from '@joystream/types/council';
 
 // Substrate/Polkadot API utils
 // --------------------------------------
@@ -117,11 +117,11 @@ export function newOptionalText (str?: string): OptionalText {
   return new Option(Text, text);
 }
 
-export function calcTotalStake (stakes: Stake | Stake[] | undefined): BN {
+export function calcTotalStake (stakes: ElectionStake | ElectionStake[] | undefined): BN {
   if (typeof stakes === 'undefined') {
     return ZERO;
   }
-  const total = (stake: Stake) => stake.new.add(stake.transferred);
+  const total = (stake: ElectionStake) => stake.new.add(stake.transferred);
   try {
     if (Array.isArray(stakes)) {
       return stakes.reduce((accum, stake) => {

+ 2 - 2
types/src/council/index.ts

@@ -9,7 +9,7 @@ export type TransferableStake = {
     backing: Balance;
 };
 
-export type Stake = {
+export type ElectionStake = {
     new: Balance;
     transferred: Balance;
 };
@@ -65,7 +65,7 @@ export class Seats extends Vec.with(Seat) {}
 export type SealedVote = {
     voter: AccountId;
     commitment: Hash;
-    stake: Stake;
+    stake: ElectionStake;
     vote: Option<AccountId>;
 };
 

+ 17 - 0
types/src/index.ts

@@ -18,6 +18,23 @@ import { registerDiscoveryTypes } from "./discovery";
 import { registerMediaTypes } from "./media";
 import { registerProposalTypes } from "./proposals";
 
+export * from "./common";
+export * from "./members";
+export * from "./council";
+export * from "./roles";
+export * from "./forum";
+export * from "./stake";
+export * from "./mint";
+export * from "./recurring-rewards";
+// export * from "./hiring"; // name clashes with working-group
+export * from "./versioned-store";
+export * from "./versioned-store/permissions";
+// export * from "./content-working-group"; // clashes with content-working-group
+export * from "./working-group";
+export * from "./discovery";
+export * from "./media";
+export * from "./proposals";
+
 export function registerJoystreamTypes() {
   const typeRegistry = getTypeRegistry();