diff --git a/i18next-scanner.config.js b/i18next-scanner.config.js index 70ae37c3d2..4e81ba4d22 100644 --- a/i18next-scanner.config.js +++ b/i18next-scanner.config.js @@ -42,28 +42,28 @@ module.exports = { '!packages/*/src/i18n/**', '!**/node_modules/**' ], - output: './', options: { debug: true, + defaultLng: 'en', + defaultNs: 'ui', func: { - list: ['t', 'i18next.t', 'i18n.t'], - extensions: ['.tsx', '.ts'] + extensions: ['.tsx', '.ts'], + list: ['t', 'i18next.t', 'i18n.t'] + }, + keySeparator: false, // key separator + lngs: ['en'], + ns: findPackages().map(({ dir }) => dir.replace('page-', 'app-')), + nsSeparator: false, // namespace separator + resource: { + jsonIndent: 2, + lineEnding: '\n', + loadPath: 'packages/apps/public/locales/{{lng}}/{{ns}}.json', + savePath: 'packages/apps/public/locales/{{lng}}/{{ns}}.json' }, trans: { component: 'Trans' - }, - lngs: ['en'], - defaultLng: 'en', - ns: findPackages().map(({ dir }) => dir.replace('page-', 'app-')), - defaultNs: 'ui', - resource: { - loadPath: 'packages/apps/public/locales/{{lng}}/{{ns}}.json', - savePath: 'packages/apps/public/locales/{{lng}}/{{ns}}.json', - jsonIndent: 2, - lineEnding: '\n' - }, - nsSeparator: false, // namespace separator - keySeparator: false // key separator + } }, + output: './', transform }; diff --git a/jest.config.js b/jest.config.js index b7c5f74416..6f5f24aaa6 100644 --- a/jest.config.js +++ b/jest.config.js @@ -14,8 +14,8 @@ const internalModules = findPackages() module.exports = Object.assign({}, config, { moduleNameMapper: { ...internalModules, - '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': 'empty/object', - '\\.(css|less)$': 'empty/object' + '\\.(css|less)$': 'empty/object', + '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': 'empty/object' }, transformIgnorePatterns: [ '/node_modules/(?!edgeware-node-types/.*)' diff --git a/package.json b/package.json index c0157598c4..a33e6513ad 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "@babel/core": "^7.9.0", "@babel/register": "^7.9.0", "@babel/runtime": "^7.9.2", - "@polkadot/dev": "^0.52.1", + "@polkadot/dev": "^0.52.3", "@polkadot/ts": "^0.3.14", "@types/bn.js": "^4.11.6", "@types/chart.js": "^2.9.16", diff --git a/packages/apps-config/src/api/chain/westend.ts b/packages/apps-config/src/api/chain/westend.ts index 65a08893e7..f12e0ba270 100644 --- a/packages/apps-config/src/api/chain/westend.ts +++ b/packages/apps-config/src/api/chain/westend.ts @@ -4,9 +4,8 @@ export default { Address: 'GenericAddress', - Keys: 'SessionKeys5', - // previous substrate versions BalanceLock: 'BalanceLockTo212', + Keys: 'SessionKeys5', ReferendumInfo: 'ReferendumInfoTo239', StakingLedger: 'StakingLedgerTo223' }; diff --git a/packages/apps-config/src/api/spec/centrifuge-chain.ts b/packages/apps-config/src/api/spec/centrifuge-chain.ts index 4ca9caa20d..77214220c7 100644 --- a/packages/apps-config/src/api/spec/centrifuge-chain.ts +++ b/packages/apps-config/src/api/spec/centrifuge-chain.ts @@ -2,6 +2,9 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +// structs need to be in order +/* eslint-disable sort-keys */ + export default { // chain-specific AnchorData: { diff --git a/packages/apps-config/src/api/spec/kulupu.ts b/packages/apps-config/src/api/spec/kulupu.ts index 67f765fd75..7a866e86f7 100644 --- a/packages/apps-config/src/api/spec/kulupu.ts +++ b/packages/apps-config/src/api/spec/kulupu.ts @@ -2,6 +2,9 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +// structs need to be in order +/* eslint-disable sort-keys */ + export default { Address: 'GenericAddress', Difficulty: 'U256', diff --git a/packages/apps-config/src/api/spec/kusama.ts b/packages/apps-config/src/api/spec/kusama.ts index 06543337fa..b5995a0f9e 100644 --- a/packages/apps-config/src/api/spec/kusama.ts +++ b/packages/apps-config/src/api/spec/kusama.ts @@ -2,6 +2,9 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +// structs need to be in order +/* eslint-disable sort-keys */ + // technically these don't need to be here, the API injects them - however it does make // certain things easier such as providing metadata + types to external signers export default { diff --git a/packages/apps-config/src/api/spec/node-template.ts b/packages/apps-config/src/api/spec/node-template.ts index 8167251330..8556c23f71 100644 --- a/packages/apps-config/src/api/spec/node-template.ts +++ b/packages/apps-config/src/api/spec/node-template.ts @@ -2,6 +2,9 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +// structs need to be in order +/* eslint-disable sort-keys */ + export default { Address: 'AccountId', LookupSource: 'AccountId' diff --git a/packages/apps-config/src/extensions/index.ts b/packages/apps-config/src/extensions/index.ts index 908a938c04..82417a2e2e 100644 --- a/packages/apps-config/src/extensions/index.ts +++ b/packages/apps-config/src/extensions/index.ts @@ -22,7 +22,7 @@ const availableExtensions: Record = [ } ].reduce((available: Record, { browsers, desc, name }): Record => { Object.entries(browsers).forEach(([browser, link]): void => { - available[browser as 'chrome'].push({ link, desc, name }); + available[browser as 'chrome'].push({ desc, link, name }); }); return available; diff --git a/packages/apps-config/src/links/commonwealth.ts b/packages/apps-config/src/links/commonwealth.ts index 32085d6f67..969549540a 100644 --- a/packages/apps-config/src/links/commonwealth.ts +++ b/packages/apps-config/src/links/commonwealth.ts @@ -5,21 +5,21 @@ import BN from 'bn.js'; export default { - isActive: true, chains: { Edgeware: 'edgeware', Kusama: 'kusama', 'Kusama CC3': 'kusama' }, + create: (chain: string, path: string, data: BN | number | string, hash?: string): string => { + const withHash = path === 'proposal/councilmotion'; + + return `https://commonwealth.im/${chain}/${path}/${withHash ? hash : data.toString()}`; + }, + isActive: true, paths: { council: 'proposal/councilmotion', proposal: 'proposal/democracyproposal', referendum: 'proposal/referendum', treasury: 'proposal/treasuryproposal' - }, - create: (chain: string, path: string, data: BN | number | string, hash?: string): string => { - const withHash = path === 'proposal/councilmotion'; - - return `https://commonwealth.im/${chain}/${path}/${withHash ? hash : data.toString()}`; } }; diff --git a/packages/apps-config/src/links/polkascan.ts b/packages/apps-config/src/links/polkascan.ts index 016fcc0f55..b2c1378581 100644 --- a/packages/apps-config/src/links/polkascan.ts +++ b/packages/apps-config/src/links/polkascan.ts @@ -5,7 +5,6 @@ import BN from 'bn.js'; export default { - isActive: true, chains: { Edgeware: 'edgeware', Kulupu: 'kulupu', @@ -13,6 +12,9 @@ export default { 'Kusama CC3': 'kusama', Westend: 'westend' }, + create: (chain: string, path: string, data: BN | number | string): string => + `https://polkascan.io/pre/${chain}/${path}/${data.toString()}`, + isActive: true, paths: { address: 'module/account', block: 'system/block', @@ -21,7 +23,5 @@ export default { proposal: 'democracy/proposal', referendum: 'democracy/referendum', treasury: 'treasury/proposal' - }, - create: (chain: string, path: string, data: BN | number | string): string => - `https://polkascan.io/pre/${chain}/${path}/${data.toString()}` + } }; diff --git a/packages/apps-config/src/links/subscan.ts b/packages/apps-config/src/links/subscan.ts index 69d485f25c..0c3758615f 100644 --- a/packages/apps-config/src/links/subscan.ts +++ b/packages/apps-config/src/links/subscan.ts @@ -5,16 +5,16 @@ import BN from 'bn.js'; export default { - isActive: false, chains: { Kusama: 'kusama', 'Kusama CC3': 'kusama' }, + create: (chain: string, path: string, data: BN | number | string): string => + `https://${chain}.subscan.io/${path}/${data.toString()}`, + isActive: false, paths: { address: 'account', block: 'block', extrinsic: 'extrinsic' - }, - create: (chain: string, path: string, data: BN | number | string): string => - `https://${chain}.subscan.io/${path}/${data.toString()}` + } }; diff --git a/packages/apps-config/src/ui/logos/index.ts b/packages/apps-config/src/ui/logos/index.ts index b310e47fb3..8ef308ace5 100644 --- a/packages/apps-config/src/ui/logos/index.ts +++ b/packages/apps-config/src/ui/logos/index.ts @@ -41,10 +41,10 @@ const nodeLogos: Record = [ // overrides when we pass an explicit logo name const namedLogos: Record = { - centrifuge: nodeCentrifuge, - empty: emptyLogo, - edgeware: nodeEdgeware, alexander: nodePolkadot, + centrifuge: nodeCentrifuge, + edgeware: nodeEdgeware, + empty: emptyLogo, kusama: chainKusama, polkadot: nodePolkadot, substrate: nodeSubstrate, diff --git a/packages/apps-routing/src/council.ts b/packages/apps-routing/src/council.ts index b69f76cdad..21cb0840bb 100644 --- a/packages/apps-routing/src/council.ts +++ b/packages/apps-routing/src/council.ts @@ -9,7 +9,6 @@ import Council, { useCounter } from '@polkadot/app-council'; export default ([ { Component: Council, - useCounter, display: { needsApi: [ [ @@ -22,6 +21,7 @@ export default ([ defaultValue: 'Council' }, icon: 'building', - name: 'council' + name: 'council', + useCounter } ] as Routes); diff --git a/packages/apps-routing/src/democracy.ts b/packages/apps-routing/src/democracy.ts index 899f3dd01a..c6ff04e2a4 100644 --- a/packages/apps-routing/src/democracy.ts +++ b/packages/apps-routing/src/democracy.ts @@ -9,7 +9,6 @@ import Democracy, { useCounter } from '@polkadot/app-democracy'; export default ([ { Component: Democracy, - useCounter, display: { needsApi: [ 'tx.democracy.notePreimage' @@ -19,6 +18,7 @@ export default ([ defaultValue: 'Democracy' }, icon: 'calendar check', - name: 'democracy' + name: 'democracy', + useCounter } ] as Routes); diff --git a/packages/apps-routing/src/staking.ts b/packages/apps-routing/src/staking.ts index becbf1f751..3cba9121c3 100644 --- a/packages/apps-routing/src/staking.ts +++ b/packages/apps-routing/src/staking.ts @@ -10,7 +10,6 @@ import Staking, { useCounter } from '@polkadot/app-staking'; export default ([ { Component: Staking, - useCounter, display: { needsApi: [ ['tx.staking.bond'] @@ -21,5 +20,6 @@ export default ([ }, icon: 'certificate', name: 'staking' - } + }, + useCounter ] as Routes); diff --git a/packages/apps-routing/src/techcomm.ts b/packages/apps-routing/src/techcomm.ts index fd49398200..79f6f8d46f 100644 --- a/packages/apps-routing/src/techcomm.ts +++ b/packages/apps-routing/src/techcomm.ts @@ -9,7 +9,6 @@ import TechComm, { useCounter } from '@polkadot/app-tech-comm'; export default ([ { Component: TechComm, - useCounter, display: { needsApi: [ 'query.technicalCommittee.members' @@ -19,6 +18,7 @@ export default ([ defaultValue: 'Tech. comm.' }, icon: 'microchip', - name: 'techcomm' + name: 'techcomm', + useCounter } ] as Routes); diff --git a/packages/apps-routing/src/treasury.ts b/packages/apps-routing/src/treasury.ts index b2ebdd9e66..e49800c375 100644 --- a/packages/apps-routing/src/treasury.ts +++ b/packages/apps-routing/src/treasury.ts @@ -9,7 +9,6 @@ import Treasury, { useCounter } from '@polkadot/app-treasury'; export default ([ { Component: Treasury, - useCounter, display: { needsAccounts: true, needsApi: [ @@ -20,6 +19,7 @@ export default ([ defaultValue: 'Treasury' }, icon: 'gem', - name: 'treasury' + name: 'treasury', + useCounter } ] as Routes); diff --git a/packages/apps/package.json b/packages/apps/package.json index b4fd30c99d..8dd06b9bf5 100644 --- a/packages/apps/package.json +++ b/packages/apps/package.json @@ -15,7 +15,7 @@ "dependencies": { "@babel/polyfill": "^7.8.7", "@babel/runtime": "^7.9.2", - "@polkadot/dev": "^0.52.1", + "@polkadot/dev": "^0.52.3", "@polkadot/react-components": "0.40.0-beta.224", "@polkadot/react-signer": "0.40.0-beta.224", "query-string": "^6.11.1" diff --git a/packages/apps/src/Content/Status.tsx b/packages/apps/src/Content/Status.tsx index 80a0407609..fdc3689591 100644 --- a/packages/apps/src/Content/Status.tsx +++ b/packages/apps/src/Content/Status.tsx @@ -41,8 +41,8 @@ function filterEvents (allAccounts: string[], t: (key: string, opts?: object) => return { account, action: `${section}.${method}`, - status: 'event', - message: t('transfer received') + message: t('transfer received'), + status: 'event' }; } } else if (section === 'democracy') { @@ -50,12 +50,12 @@ function filterEvents (allAccounts: string[], t: (key: string, opts?: object) => return { action: `${section}.${method}`, - status: 'event', message: t('update on #{{index}}', { replace: { index } - }) + }), + status: 'event' }; } diff --git a/packages/apps/src/SideBar/Item.tsx b/packages/apps/src/SideBar/Item.tsx index e5f97b6423..1a89a88049 100644 --- a/packages/apps/src/SideBar/Item.tsx +++ b/packages/apps/src/SideBar/Item.tsx @@ -44,7 +44,7 @@ function hasEndpoint (api: ApiPromise, endpoint: string): boolean { } } -function checkVisible (name: string, { api, isApiReady, isApiConnected }: ApiProps, hasAccounts: boolean, hasSudo: boolean, { isHidden, needsAccounts, needsApi, needsSudo }: Route['display']): boolean { +function checkVisible (name: string, { api, isApiConnected, isApiReady }: ApiProps, hasAccounts: boolean, hasSudo: boolean, { isHidden, needsAccounts, needsApi, needsSudo }: Route['display']): boolean { if (isHidden) { return false; } else if (needsAccounts && !hasAccounts) { @@ -73,7 +73,7 @@ function checkVisible (name: string, { api, isApiReady, isApiConnected }: ApiPro return notFound.length === 0; } -function Item ({ route, isCollapsed, onClick }: Props): React.ReactElement | null { +function Item ({ isCollapsed, onClick, route }: Props): React.ReactElement | null { const { t } = useTranslation(); const { allAccounts, hasAccounts } = useAccounts(); const apiProps = useApi(); diff --git a/packages/apps/webpack.config.js b/packages/apps/webpack.config.js index 07b91f9f2a..b910ba811e 100644 --- a/packages/apps/webpack.config.js +++ b/packages/apps/webpack.config.js @@ -1,9 +1,9 @@ -/* eslint-disable @typescript-eslint/camelcase */ -/* eslint-disable @typescript-eslint/no-var-requires */ // Copyright 2017-2020 @polkadot/apps authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +/* eslint-disable @typescript-eslint/camelcase */ + const fs = require('fs'); const path = require('path'); const webpack = require('webpack'); @@ -39,21 +39,11 @@ function createWebpack ({ alias = {}, context, name = 'index' }) { : null // 'webpack-plugin-serve/client' ].filter((entry) => entry), mode: ENV, - output: { - chunkFilename: '[name].[chunkhash:8].js', - filename: '[name].[hash:8].js', - globalObject: '(typeof self !== \'undefined\' ? self : this)', - path: path.join(context, 'build') - }, - resolve: { - alias, - extensions: ['.js', '.jsx', '.ts', '.tsx'] - }, module: { rules: [ { - test: /\.css$/, exclude: /(node_modules)/, + test: /\.css$/, use: [ isProd ? MiniCssExtractPlugin.loader @@ -67,8 +57,8 @@ function createWebpack ({ alias = {}, context, name = 'index' }) { ] }, { - test: /\.css$/, include: /node_modules/, + test: /\.css$/, use: [ isProd ? MiniCssExtractPlugin.loader @@ -77,8 +67,8 @@ function createWebpack ({ alias = {}, context, name = 'index' }) { ] }, { - test: /\.(js|ts|tsx)$/, exclude: /(node_modules)/, + test: /\.(js|ts|tsx)$/, use: [ require.resolve('thread-loader'), { @@ -100,9 +90,9 @@ function createWebpack ({ alias = {}, context, name = 'index' }) { { loader: require.resolve('url-loader'), options: { + esModule: false, limit: 10000, - name: 'static/[name].[hash:8].[ext]', - esModule: false + name: 'static/[name].[hash:8].[ext]' } } ] @@ -113,8 +103,8 @@ function createWebpack ({ alias = {}, context, name = 'index' }) { { loader: require.resolve('file-loader'), options: { - name: 'static/[name].[hash:8].[ext]', - esModule: false + esModule: false, + name: 'static/[name].[hash:8].[ext]' } } ] @@ -132,6 +122,12 @@ function createWebpack ({ alias = {}, context, name = 'index' }) { runtimeChunk: 'single', splitChunks: { cacheGroups: { + polkadotJs: { + chunks: 'initial', + enforce: true, + name: 'polkadotjs', + test: /node_modules\/(@polkadot\/wasm-crypto)/ + }, vendorOther: { chunks: 'initial', enforce: true, @@ -143,16 +139,16 @@ function createWebpack ({ alias = {}, context, name = 'index' }) { enforce: true, name: 'react', test: /node_modules\/(chart|i18next|react|semantic-ui)/ - }, - polkadotJs: { - chunks: 'initial', - enforce: true, - name: 'polkadotjs', - test: /node_modules\/(@polkadot\/wasm-(crypto|dalek-ed25519|schnorrkel))/ } } } }, + output: { + chunkFilename: '[name].[chunkhash:8].js', + filename: '[name].[hash:8].js', + globalObject: '(typeof self !== \'undefined\' ? self : this)', + path: path.join(context, 'build') + }, performance: { hints: false }, @@ -166,9 +162,9 @@ function createWebpack ({ alias = {}, context, name = 'index' }) { } }), new HtmlWebpackPlugin({ + PAGE_TITLE: 'Polkadot/Substrate Portal', inject: true, - template: path.join(context, `${hasPublic ? 'public/' : ''}${name}.html`), - PAGE_TITLE: 'Polkadot/Substrate Portal' + template: path.join(context, `${hasPublic ? 'public/' : ''}${name}.html`) }), new webpack.optimize.SplitChunksPlugin(), new MiniCssExtractPlugin({ @@ -179,11 +175,15 @@ function createWebpack ({ alias = {}, context, name = 'index' }) { : new WebpackPluginServe({ hmr: false, // switch off, Chrome WASM memory leak liveReload: false, // explict off, overrides hmr - progress: false, // since we have hmr off, disable port: 3000, + progress: false, // since we have hmr off, disable static: path.join(process.cwd(), '/build') }) ]).filter((plugin) => plugin), + resolve: { + alias, + extensions: ['.js', '.jsx', '.ts', '.tsx'] + }, watch: !isProd, watchOptions: { ignored: ['.yarn', /build/, /node_modules/] @@ -192,10 +192,10 @@ function createWebpack ({ alias = {}, context, name = 'index' }) { } module.exports = createWebpack({ - context: __dirname, alias: findPackages().reduce((alias, { dir, name }) => { alias[name] = path.resolve(__dirname, `../${dir}/src`); return alias; - }, {}) + }, {}), + context: __dirname }); diff --git a/packages/page-accounts/package.json b/packages/page-accounts/package.json index ed0849850f..949ceed455 100644 --- a/packages/page-accounts/package.json +++ b/packages/page-accounts/package.json @@ -13,7 +13,7 @@ "dependencies": { "@babel/runtime": "^7.9.2", "@polkadot/react-components": "0.40.0-beta.224", - "@polkadot/react-qr": "^0.52.0-beta.21", + "@polkadot/react-qr": "^0.52.0-beta.22", "@polkadot/vanitygen": "^0.11.0-beta.12", "detect-browser": "^5.0.0", "file-saver": "^2.0.2" diff --git a/packages/page-accounts/src/Accounts/Banner.tsx b/packages/page-accounts/src/Accounts/Banner.tsx index fb835c7f92..712e8d8877 100644 --- a/packages/page-accounts/src/Accounts/Banner.tsx +++ b/packages/page-accounts/src/Accounts/Banner.tsx @@ -38,7 +38,7 @@ function Banner ({ className }: Props): React.ReactElement | null { yourBrowser: stringUpperFirst(browserName) } })}

-