Browse Source

Merge 'development' and fix conflicts

Leszek Wiesner 4 years ago
parent
commit
148ba86dbe

+ 37 - 0
.github/workflows/pioneer-pr.yml

@@ -0,0 +1,37 @@
+name: Pioneer-PR
+on: [pull_request, push]
+
+jobs:
+  pioneer_build_code:
+    name: Pioneer Build Code
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        node-version: [12.x]
+    steps:
+    - uses: actions/checkout@v1
+    - name: Use Node.js ${{ matrix.node-version }}
+      uses: actions/setup-node@v1
+      with:
+        node-version: ${{ matrix.node-version }}
+    - name: build
+      run: |
+        yarn install --frozen-lockfile
+        yarn workspace pioneer run build:code
+
+  pioneer_build_i18n:
+    name: Pioneer Build i18n
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        node-version: [12.x]
+    steps:
+    - uses: actions/checkout@v1
+    - name: Use Node.js ${{ matrix.node-version }}
+      uses: actions/setup-node@v1
+      with:
+        node-version: ${{ matrix.node-version }}
+    - name: build
+      run: |
+        yarn install --frozen-lockfile
+        yarn workspace pioneer run build:i18n

+ 2 - 41
.travis.yml

@@ -16,20 +16,12 @@ matrix:
   include:
     - os: linux
       env: TARGET=x86_64-unknown-linux-gnu
-  # Removed all other plaftorm builds sice the repo is growing in terms of activitly
-  # and CI checks are taking long to start due to concurrent number of jobs
-  # one job should be sufficient for doing all manners of checks and unit nets. Will defer
-  # building all platform binanires and wasm blob to a different system.
 
 install:
   - rustup install nightly-2020-05-23
   - rustup target add wasm32-unknown-unknown --toolchain nightly-2020-05-23
   # travis installs rust using rustup with the "minimal" profile so these tools are not installed by default
   - rustup component add rustfmt
-  # choosing to add clippy for the nightly toolchain only
-  # becuase we want to run it with nighly to avoid having to set BUILD_DUMMY_WASM_BINARY=0
-  # setting that variable requires changing it in a later run of cargo bulid to ensure runtime/build.rs
-  # actually builds the runtime .. the behaviour is a bit odd so choosing to avoid messing with it.
   - rustup component add clippy
 
 before_script:
@@ -37,38 +29,7 @@ before_script:
 
 script:
   # we set release as build type for all steps to benefit from already compiled packages in prior steps
-  # skipping clippy ...
   - BUILD_DUMMY_WASM_BINARY=1 cargo clippy --release --target=${TARGET} -- -D warnings
   - BUILD_DUMMY_WASM_BINARY=1 cargo test --release --verbose --all --target=${TARGET}
-  - BUILD_DUMMY_WASM_BINARY=0 WASM_BUILD_TOOLCHAIN=nightly-2020-05-23 cargo build --release --target=${TARGET} -p joystream-node
-  - ls -l ./target/${TARGET}/release/wbuild/joystream-node-runtime/
-
-before_deploy:
-  - cp ./target/${TARGET}/release/joystream-node .
-  - FILENAME=`./joystream-node --version | sed -e "s/ /-/g"`
-  - tar -cf ${FILENAME}.tar ./joystream-node
-  - gzip ${FILENAME}.tar
-  - export ASSET=${FILENAME}.tar.gz
-
-deploy:
-  - provider: releases
-    api_key:
-      secure: FfxZGQexxAGT0Skbctl1FuqmEvNHejPDPtNG8Du1ACSGjS7Y+M6o/aPqE6HL158AmddOgndsIPR+HM7VfMDAUMkLTbOhv3nMpDBZu1h25vwk+jHOM65tm5LWUu/ROWBpaAQiG7NKrvtfkNfbNBSETsEbWBt/DPrhlIfSbgsXBFDiid7uRrCiwvDUJ097/EUOJ9OVUrk+O4ebSzfIfKPGPtRU2rQQ0eNX7yX3TCm3jbQm/kplkQNRL9mnAJNxtKuvuko4LqZ6jN4XLoLTHUMjO7E0r6wXVB4GVjA4HA214eLlQD6BhgTbWMDxKgWyuKzPG+2GLKyluSSn0RurSl8tYryXKxKxuN3H1FX9r23a8AzGtpRACJtIePC2YmPuQRSnz2Bw8jlSP2WPLJtXGD036J/wVMj6W9TROm7IBigiC7QlqAqCYNByOnoKyhRCgYyAJZb0Jpa3qWaFhA6b6gCGhyH85QCcrc0q6JAB3oqH8Wfm/K2HVzBobmKaSFu5DpwInNnUXnLWGVzhSt3oCq6ld773izReGdLJtLC2vaJ9rZVaVw29s9M662EEuAGgaVLO/sinZJFeIIaCF4i4zUXwXSLIdfKXGOR0ZibkyT2FS6qPGvl/lLN5IREzD7v/rV8htGMLmw4jpPLNskvRjCHX42ewRRYdMvZzQQOAvSlWcsw=
-    file: ${ASSET}
-    on:
-      tags: true
-      repo: Joystream/joystream
-    draft: true
-    overwrite: true
-    skip_cleanup: true
-  - provider: releases
-    api_key:
-      secure: FfxZGQexxAGT0Skbctl1FuqmEvNHejPDPtNG8Du1ACSGjS7Y+M6o/aPqE6HL158AmddOgndsIPR+HM7VfMDAUMkLTbOhv3nMpDBZu1h25vwk+jHOM65tm5LWUu/ROWBpaAQiG7NKrvtfkNfbNBSETsEbWBt/DPrhlIfSbgsXBFDiid7uRrCiwvDUJ097/EUOJ9OVUrk+O4ebSzfIfKPGPtRU2rQQ0eNX7yX3TCm3jbQm/kplkQNRL9mnAJNxtKuvuko4LqZ6jN4XLoLTHUMjO7E0r6wXVB4GVjA4HA214eLlQD6BhgTbWMDxKgWyuKzPG+2GLKyluSSn0RurSl8tYryXKxKxuN3H1FX9r23a8AzGtpRACJtIePC2YmPuQRSnz2Bw8jlSP2WPLJtXGD036J/wVMj6W9TROm7IBigiC7QlqAqCYNByOnoKyhRCgYyAJZb0Jpa3qWaFhA6b6gCGhyH85QCcrc0q6JAB3oqH8Wfm/K2HVzBobmKaSFu5DpwInNnUXnLWGVzhSt3oCq6ld773izReGdLJtLC2vaJ9rZVaVw29s9M662EEuAGgaVLO/sinZJFeIIaCF4i4zUXwXSLIdfKXGOR0ZibkyT2FS6qPGvl/lLN5IREzD7v/rV8htGMLmw4jpPLNskvRjCHX42ewRRYdMvZzQQOAvSlWcsw=
-    file: ${ASSET}
-    on:
-      branch: development
-      repo: Joystream/joystream
-    draft: true
-    prerelease: true
-    overwrite: true
-    skip_cleanup: true
+  - TRIGGER_WASM_BUILD=1 WASM_BUILD_TOOLCHAIN=nightly-2020-05-23 cargo build --release --target=${TARGET} -p joystream-node
+  - ls -l ./target/${TARGET}/release/wbuild/joystream-node-runtime/

+ 1 - 1
package.json

@@ -6,7 +6,7 @@
 		"test": "yarn && yarn workspaces run test",
 		"test-migration": "yarn && yarn workspaces run test-migration",
 		"postinstall": "yarn workspace @joystream/types build",
-    "cargo-checks": "devops/git-hooks/pre-commit && devops/git-hooks/pre-push",
+		"cargo-checks": "devops/git-hooks/pre-commit && devops/git-hooks/pre-push",
 		"cargo-build": "scripts/cargo-build.sh"
 	},
 	"workspaces": [

+ 3 - 4
pioneer/packages/joy-proposals/src/Proposal/ProposalTypePreview.tsx

@@ -5,7 +5,7 @@ import { Item, Icon, Button, Label } from 'semantic-ui-react';
 
 import { Category } from './ChooseProposalType';
 import { ProposalType } from '@polkadot/joy-utils/types/proposals';
-import { slugify, splitOnUpperCase } from '@polkadot/joy-utils/functions/misc';
+import _ from 'lodash';
 import styled from 'styled-components';
 import useVoteStyles from './useVoteStyles';
 import { formatBalance } from '@polkadot/util';
@@ -46,7 +46,6 @@ const CreateButton = styled(Button)`
 export type ProposalTypeInfo = {
   type: ProposalType;
   category: Category;
-  image: string;
   description: string;
   stake: number;
   cancellationFee?: number;
@@ -88,7 +87,7 @@ export default function ProposalTypePreview (props: ProposalTypePreviewProps) {
 
   const handleClick = () => {
     if (!props.history) return;
-    props.history.push(`/proposals/new/${slugify(type)}`);
+    props.history.push(`/proposals/new/${_.kebabCase(type)}`);
   };
 
   return (
@@ -98,7 +97,7 @@ export default function ProposalTypePreview (props: ProposalTypePreviewProps) {
         <Item.Image size="tiny" src={image} />
       */}
       <Item.Content>
-        <Item.Header>{splitOnUpperCase(type).join(' ')}</Item.Header>
+        <Item.Header>{_.startCase(type)}</Item.Header>
         <Item.Description>{description}</Item.Description>
         <div className="proposal-details">
           <ProposalTypeDetail

+ 2 - 2
pioneer/packages/joy-proposals/src/forms/GenericProposalForm.tsx

@@ -14,7 +14,7 @@ import { CallProps } from '@polkadot/react-api/types';
 import { Balance, Event } from '@polkadot/types/interfaces';
 import { RouteComponentProps } from 'react-router';
 import { ProposalType } from '@polkadot/joy-utils/types/proposals';
-import { calculateStake } from '@polkadot/joy-utils/functions/proposals';
+import proposalsConsts from '@polkadot/joy-utils/consts/proposals';
 import { formatBalance } from '@polkadot/util';
 import './forms.css';
 import { ProposalId } from '@joystream/types/proposals';
@@ -124,7 +124,7 @@ export const GenericProposalForm: React.FunctionComponent<GenericFormInnerProps>
   const requiredStake: number | undefined =
     balances_totalIssuance &&
     proposalType &&
-    calculateStake(proposalType);
+    proposalsConsts[proposalType].stake;
 
   return (
     <div className="Forms">

+ 2 - 2
pioneer/packages/joy-proposals/src/forms/SetCouncilParamsForm.tsx

@@ -18,7 +18,7 @@ import { withFormContainer } from './FormContainer';
 import { createType } from '@polkadot/types';
 import './forms.css';
 import { useTransport, usePromise } from '@polkadot/joy-utils/react/hooks';
-import { snakeCaseToCamelCase } from '@polkadot/joy-utils/functions/misc';
+import _ from 'lodash';
 import { ElectionParameters } from '@joystream/types/proposals';
 import { PromiseComponent } from '@polkadot/joy-utils/react/components';
 
@@ -84,7 +84,7 @@ const SetCouncilParamsForm: React.FunctionComponent<FormInnerProps> = props => {
         'council_size'
       ] as const;
       fieldsToPopulate.forEach(field => {
-        const camelCaseField = snakeCaseToCamelCase(field) as keyof FormValues;
+        const camelCaseField = _.camelCase(field) as keyof FormValues;
         setFieldValue(camelCaseField, councilParams[field].toString());
         fetchedPlaceholders[camelCaseField] = councilParams[field].toString();
       });

+ 0 - 9
pioneer/packages/joy-proposals/src/stories/data/ProposalTypesInfo.mock.ts

@@ -5,7 +5,6 @@ const MockProposalTypesInfo: ProposalTypeInfo[] = [
   {
     type: 'Text',
     category: Categories.other,
-    image: 'https://react.semantic-ui.com/images/wireframe/image.png',
     description:
         'Change the total reward across all validators in a given block.' +
         'This is not the direct reward, but base reward for Pallet staking module.' +
@@ -22,7 +21,6 @@ const MockProposalTypesInfo: ProposalTypeInfo[] = [
   {
     type: 'Spending',
     category: Categories.other,
-    image: 'https://react.semantic-ui.com/images/wireframe/image.png',
     description:
         'Change the total reward across all validators in a given block.' +
         'This is not the direct reward, but base reward for Pallet staking module.' +
@@ -39,7 +37,6 @@ const MockProposalTypesInfo: ProposalTypeInfo[] = [
   {
     type: 'RuntimeUpgrade',
     category: Categories.other,
-    image: 'https://react.semantic-ui.com/images/wireframe/image.png',
     description:
         'Change the total reward across all validators in a given block.' +
         'This is not the direct reward, but base reward for Pallet staking module.' +
@@ -56,7 +53,6 @@ const MockProposalTypesInfo: ProposalTypeInfo[] = [
   {
     type: 'EvictStorageProvider',
     category: Categories.storage,
-    image: 'https://react.semantic-ui.com/images/wireframe/image.png',
     description:
         'Change the total reward across all validators in a given block.' +
         'This is not the direct reward, but base reward for Pallet staking module.' +
@@ -73,7 +69,6 @@ const MockProposalTypesInfo: ProposalTypeInfo[] = [
   {
     type: 'SetStorageRoleParameters',
     category: Categories.storage,
-    image: 'https://react.semantic-ui.com/images/wireframe/image.png',
     description:
         'Change the total reward across all validators in a given block.' +
         'This is not the direct reward, but base reward for Pallet staking module.' +
@@ -90,7 +85,6 @@ const MockProposalTypesInfo: ProposalTypeInfo[] = [
   {
     type: 'SetValidatorCount',
     category: Categories.validators,
-    image: 'https://react.semantic-ui.com/images/wireframe/image.png',
     description:
         'Change the total reward across all validators in a given block.' +
         'This is not the direct reward, but base reward for Pallet staking module.' +
@@ -107,7 +101,6 @@ const MockProposalTypesInfo: ProposalTypeInfo[] = [
   {
     type: 'SetContentWorkingGroupMintCapacity',
     category: Categories.cwg,
-    image: 'https://react.semantic-ui.com/images/wireframe/image.png',
     description:
         'Change the total reward across all validators in a given block.' +
         'This is not the direct reward, but base reward for Pallet staking module.' +
@@ -124,7 +117,6 @@ const MockProposalTypesInfo: ProposalTypeInfo[] = [
   {
     type: 'SetLead',
     category: Categories.cwg,
-    image: 'https://react.semantic-ui.com/images/wireframe/image.png',
     description:
         'Change the total reward across all validators in a given block.' +
         'This is not the direct reward, but base reward for Pallet staking module.' +
@@ -141,7 +133,6 @@ const MockProposalTypesInfo: ProposalTypeInfo[] = [
   {
     type: 'SetElectionParameters',
     category: Categories.council,
-    image: 'https://react.semantic-ui.com/images/wireframe/image.png',
     description:
         'Change the total reward across all validators in a given block.' +
         'This is not the direct reward, but base reward for Pallet staking module.' +

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

@@ -0,0 +1,87 @@
+import { ProposalType, ProposalMeta } from '../types/proposals';
+
+const metadata: { [k in ProposalType]: ProposalMeta } = {
+  EvictStorageProvider: {
+    description: 'Evicting Storage Provider Proposal',
+    category: 'Storage',
+    stake: 25000,
+    approvalQuorum: 50,
+    approvalThreshold: 75,
+    slashingQuorum: 60,
+    slashingThreshold: 80
+  },
+  Text: {
+    description: 'Signal Proposal',
+    category: 'Other',
+    stake: 25000,
+    approvalQuorum: 60,
+    approvalThreshold: 80,
+    slashingQuorum: 60,
+    slashingThreshold: 80
+  },
+  SetStorageRoleParameters: {
+    description: 'Set Storage Role Params Proposal',
+    category: 'Storage',
+    stake: 100000,
+    approvalQuorum: 66,
+    approvalThreshold: 80,
+    slashingQuorum: 60,
+    slashingThreshold: 80
+  },
+  SetValidatorCount: {
+    description: 'Set Max Validator Count Proposal',
+    category: 'Validators',
+    stake: 100000,
+    approvalQuorum: 66,
+    approvalThreshold: 80,
+    slashingQuorum: 60,
+    slashingThreshold: 80
+  },
+  SetLead: {
+    description: 'Set Lead Proposal',
+    category: 'Content Working Group',
+    stake: 50000,
+    approvalQuorum: 60,
+    approvalThreshold: 75,
+    slashingQuorum: 60,
+    slashingThreshold: 80
+  },
+  SetContentWorkingGroupMintCapacity: {
+    description: 'Set WG Mint Capacity Proposal',
+    category: 'Content Working Group',
+    stake: 50000,
+    approvalQuorum: 60,
+    approvalThreshold: 75,
+    slashingQuorum: 60,
+    slashingThreshold: 80
+  },
+  Spending: {
+    description: 'Spending Proposal',
+    category: 'Other',
+    stake: 25000,
+    approvalQuorum: 60,
+    approvalThreshold: 80,
+    slashingQuorum: 60,
+    slashingThreshold: 80
+  },
+  SetElectionParameters: {
+    description: 'Set Election Parameters Proposal',
+    category: 'Council',
+    stake: 200000,
+    approvalQuorum: 66,
+    approvalThreshold: 80,
+    slashingQuorum: 60,
+    slashingThreshold: 80
+  },
+  RuntimeUpgrade: {
+    description: 'Runtime Upgrade Proposal',
+    category: 'Other',
+    stake: 1000000,
+    approvalQuorum: 80,
+    approvalThreshold: 100,
+    slashingQuorum: 60,
+    slashingThreshold: 80
+  }
+};
+
+export default metadata;

+ 0 - 24
pioneer/packages/joy-utils/src/functions/misc.ts

@@ -6,27 +6,3 @@ export function includeKeys<T extends { [k: string]: any }> (obj: T, ...allowedK
     );
   });
 }
-
-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('_');
-}

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

@@ -1,152 +0,0 @@
-import { ProposalType, ProposalMeta } from '../types/proposals';
-
-// TODO: Those may actually be const objects (now that we don't need total issuance etc.)
-
-export function calculateStake (type: ProposalType) {
-  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}.`);
-    }
-  }
-  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.");
-    }
-  }
-}

+ 5 - 7
pioneer/packages/joy-utils/src/transport/proposals.ts

@@ -13,8 +13,9 @@ import { MemberId } from '@joystream/types/members';
 import { u32 } from '@polkadot/types/';
 import { BalanceOf } from '@polkadot/types/interfaces';
 
-import { includeKeys, splitOnUpperCase } from '../functions/misc';
-import { calculateStake, calculateMetaFromType } from '../functions/proposals';
+import { includeKeys } from '../functions/misc';
+import _ from 'lodash';
+import proposalsConsts from '../consts/proposals';
 
 import { ApiPromise } from '@polkadot/api';
 import MembersTransport from './members';
@@ -135,7 +136,7 @@ export default class ProposalsTransport extends BaseTransport {
       const obj = await prevProm;
       const period = (await this.proposalsCodex[method]()) as u32;
       // setValidatorCountProposalVotingPeriod to SetValidatorCount
-      const key = splitOnUpperCase(method)
+      const key = _.words(_.startCase(method))
         .slice(0, -3)
         .map((w, i) => (i === 0 ? w.slice(0, 1).toUpperCase() + w.slice(1) : w))
         .join('') as ProposalType;
@@ -155,17 +156,14 @@ export default class ProposalsTransport extends BaseTransport {
   async parametersFromProposalType (type: ProposalType) {
     const votingPeriod = (await this.proposalTypesVotingPeriod())[type];
     const gracePeriod = (await this.proposalTypesGracePeriod())[type];
-    const stake = calculateStake(type);
-    const meta = calculateMetaFromType(type);
     // Currently it's same for all types, but this will change soon
     const cancellationFee = this.cancellationFee();
     return {
       type,
       votingPeriod,
       gracePeriod,
-      stake,
       cancellationFee,
-      ...meta
+      ...proposalsConsts[type]
     };
   }
 

+ 1 - 1
pioneer/packages/joy-utils/src/types/proposals.ts

@@ -58,7 +58,7 @@ export type Category = typeof Categories[keyof typeof Categories];
 export type ProposalMeta = {
   description: string;
   category: Category;
-  image: string;
+  stake: number;
   approvalQuorum: number;
   approvalThreshold: number;
   slashingQuorum: number;