Bump dev (incl. eslint fixes) (#2502)

This commit is contained in:
Jaco Greeff 2020-04-01 21:31:36 +02:00 committed by GitHub
parent b2175acb4f
commit 9a6c55a40b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
147 changed files with 438 additions and 401 deletions

View File

@ -42,28 +42,28 @@ module.exports = {
'!packages/*/src/i18n/**', '!packages/*/src/i18n/**',
'!**/node_modules/**' '!**/node_modules/**'
], ],
output: './',
options: { options: {
debug: true, debug: true,
defaultLng: 'en',
defaultNs: 'ui',
func: { 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: { trans: {
component: '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 transform
}; };

View File

@ -14,8 +14,8 @@ const internalModules = findPackages()
module.exports = Object.assign({}, config, { module.exports = Object.assign({}, config, {
moduleNameMapper: { moduleNameMapper: {
...internalModules, ...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: [ transformIgnorePatterns: [
'<rootDir>/node_modules/(?!edgeware-node-types/.*)' '<rootDir>/node_modules/(?!edgeware-node-types/.*)'

View File

@ -36,7 +36,7 @@
"@babel/core": "^7.9.0", "@babel/core": "^7.9.0",
"@babel/register": "^7.9.0", "@babel/register": "^7.9.0",
"@babel/runtime": "^7.9.2", "@babel/runtime": "^7.9.2",
"@polkadot/dev": "^0.52.1", "@polkadot/dev": "^0.52.3",
"@polkadot/ts": "^0.3.14", "@polkadot/ts": "^0.3.14",
"@types/bn.js": "^4.11.6", "@types/bn.js": "^4.11.6",
"@types/chart.js": "^2.9.16", "@types/chart.js": "^2.9.16",

View File

@ -4,9 +4,8 @@
export default { export default {
Address: 'GenericAddress', Address: 'GenericAddress',
Keys: 'SessionKeys5',
// previous substrate versions
BalanceLock: 'BalanceLockTo212', BalanceLock: 'BalanceLockTo212',
Keys: 'SessionKeys5',
ReferendumInfo: 'ReferendumInfoTo239', ReferendumInfo: 'ReferendumInfoTo239',
StakingLedger: 'StakingLedgerTo223' StakingLedger: 'StakingLedgerTo223'
}; };

View File

@ -2,6 +2,9 @@
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details. // of the Apache-2.0 license. See the LICENSE file for details.
// structs need to be in order
/* eslint-disable sort-keys */
export default { export default {
// chain-specific // chain-specific
AnchorData: { AnchorData: {

View File

@ -2,6 +2,9 @@
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details. // of the Apache-2.0 license. See the LICENSE file for details.
// structs need to be in order
/* eslint-disable sort-keys */
export default { export default {
Address: 'GenericAddress', Address: 'GenericAddress',
Difficulty: 'U256', Difficulty: 'U256',

View File

@ -2,6 +2,9 @@
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details. // 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 // 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 // certain things easier such as providing metadata + types to external signers
export default { export default {

View File

@ -2,6 +2,9 @@
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details. // of the Apache-2.0 license. See the LICENSE file for details.
// structs need to be in order
/* eslint-disable sort-keys */
export default { export default {
Address: 'AccountId', Address: 'AccountId',
LookupSource: 'AccountId' LookupSource: 'AccountId'

View File

@ -22,7 +22,7 @@ const availableExtensions: Record<Browser, Extension[]> = [
} }
].reduce((available: Record<Browser, Extension[]>, { browsers, desc, name }): Record<Browser, Extension[]> => { ].reduce((available: Record<Browser, Extension[]>, { browsers, desc, name }): Record<Browser, Extension[]> => {
Object.entries(browsers).forEach(([browser, link]): void => { 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; return available;

View File

@ -5,21 +5,21 @@
import BN from 'bn.js'; import BN from 'bn.js';
export default { export default {
isActive: true,
chains: { chains: {
Edgeware: 'edgeware', Edgeware: 'edgeware',
Kusama: 'kusama', Kusama: 'kusama',
'Kusama CC3': '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: { paths: {
council: 'proposal/councilmotion', council: 'proposal/councilmotion',
proposal: 'proposal/democracyproposal', proposal: 'proposal/democracyproposal',
referendum: 'proposal/referendum', referendum: 'proposal/referendum',
treasury: 'proposal/treasuryproposal' 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()}`;
} }
}; };

View File

@ -5,7 +5,6 @@
import BN from 'bn.js'; import BN from 'bn.js';
export default { export default {
isActive: true,
chains: { chains: {
Edgeware: 'edgeware', Edgeware: 'edgeware',
Kulupu: 'kulupu', Kulupu: 'kulupu',
@ -13,6 +12,9 @@ export default {
'Kusama CC3': 'kusama', 'Kusama CC3': 'kusama',
Westend: 'westend' Westend: 'westend'
}, },
create: (chain: string, path: string, data: BN | number | string): string =>
`https://polkascan.io/pre/${chain}/${path}/${data.toString()}`,
isActive: true,
paths: { paths: {
address: 'module/account', address: 'module/account',
block: 'system/block', block: 'system/block',
@ -21,7 +23,5 @@ export default {
proposal: 'democracy/proposal', proposal: 'democracy/proposal',
referendum: 'democracy/referendum', referendum: 'democracy/referendum',
treasury: 'treasury/proposal' treasury: 'treasury/proposal'
}, }
create: (chain: string, path: string, data: BN | number | string): string =>
`https://polkascan.io/pre/${chain}/${path}/${data.toString()}`
}; };

View File

@ -5,16 +5,16 @@
import BN from 'bn.js'; import BN from 'bn.js';
export default { export default {
isActive: false,
chains: { chains: {
Kusama: 'kusama', Kusama: 'kusama',
'Kusama CC3': 'kusama' 'Kusama CC3': 'kusama'
}, },
create: (chain: string, path: string, data: BN | number | string): string =>
`https://${chain}.subscan.io/${path}/${data.toString()}`,
isActive: false,
paths: { paths: {
address: 'account', address: 'account',
block: 'block', block: 'block',
extrinsic: 'extrinsic' extrinsic: 'extrinsic'
}, }
create: (chain: string, path: string, data: BN | number | string): string =>
`https://${chain}.subscan.io/${path}/${data.toString()}`
}; };

View File

@ -41,10 +41,10 @@ const nodeLogos: Record<string, any> = [
// overrides when we pass an explicit logo name // overrides when we pass an explicit logo name
const namedLogos: Record<string, any> = { const namedLogos: Record<string, any> = {
centrifuge: nodeCentrifuge,
empty: emptyLogo,
edgeware: nodeEdgeware,
alexander: nodePolkadot, alexander: nodePolkadot,
centrifuge: nodeCentrifuge,
edgeware: nodeEdgeware,
empty: emptyLogo,
kusama: chainKusama, kusama: chainKusama,
polkadot: nodePolkadot, polkadot: nodePolkadot,
substrate: nodeSubstrate, substrate: nodeSubstrate,

View File

@ -9,7 +9,6 @@ import Council, { useCounter } from '@polkadot/app-council';
export default ([ export default ([
{ {
Component: Council, Component: Council,
useCounter,
display: { display: {
needsApi: [ needsApi: [
[ [
@ -22,6 +21,7 @@ export default ([
defaultValue: 'Council' defaultValue: 'Council'
}, },
icon: 'building', icon: 'building',
name: 'council' name: 'council',
useCounter
} }
] as Routes); ] as Routes);

View File

@ -9,7 +9,6 @@ import Democracy, { useCounter } from '@polkadot/app-democracy';
export default ([ export default ([
{ {
Component: Democracy, Component: Democracy,
useCounter,
display: { display: {
needsApi: [ needsApi: [
'tx.democracy.notePreimage' 'tx.democracy.notePreimage'
@ -19,6 +18,7 @@ export default ([
defaultValue: 'Democracy' defaultValue: 'Democracy'
}, },
icon: 'calendar check', icon: 'calendar check',
name: 'democracy' name: 'democracy',
useCounter
} }
] as Routes); ] as Routes);

View File

@ -10,7 +10,6 @@ import Staking, { useCounter } from '@polkadot/app-staking';
export default ([ export default ([
{ {
Component: Staking, Component: Staking,
useCounter,
display: { display: {
needsApi: [ needsApi: [
['tx.staking.bond'] ['tx.staking.bond']
@ -21,5 +20,6 @@ export default ([
}, },
icon: 'certificate', icon: 'certificate',
name: 'staking' name: 'staking'
} },
useCounter
] as Routes); ] as Routes);

View File

@ -9,7 +9,6 @@ import TechComm, { useCounter } from '@polkadot/app-tech-comm';
export default ([ export default ([
{ {
Component: TechComm, Component: TechComm,
useCounter,
display: { display: {
needsApi: [ needsApi: [
'query.technicalCommittee.members' 'query.technicalCommittee.members'
@ -19,6 +18,7 @@ export default ([
defaultValue: 'Tech. comm.' defaultValue: 'Tech. comm.'
}, },
icon: 'microchip', icon: 'microchip',
name: 'techcomm' name: 'techcomm',
useCounter
} }
] as Routes); ] as Routes);

View File

@ -9,7 +9,6 @@ import Treasury, { useCounter } from '@polkadot/app-treasury';
export default ([ export default ([
{ {
Component: Treasury, Component: Treasury,
useCounter,
display: { display: {
needsAccounts: true, needsAccounts: true,
needsApi: [ needsApi: [
@ -20,6 +19,7 @@ export default ([
defaultValue: 'Treasury' defaultValue: 'Treasury'
}, },
icon: 'gem', icon: 'gem',
name: 'treasury' name: 'treasury',
useCounter
} }
] as Routes); ] as Routes);

View File

@ -15,7 +15,7 @@
"dependencies": { "dependencies": {
"@babel/polyfill": "^7.8.7", "@babel/polyfill": "^7.8.7",
"@babel/runtime": "^7.9.2", "@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-components": "0.40.0-beta.224",
"@polkadot/react-signer": "0.40.0-beta.224", "@polkadot/react-signer": "0.40.0-beta.224",
"query-string": "^6.11.1" "query-string": "^6.11.1"

View File

@ -41,8 +41,8 @@ function filterEvents (allAccounts: string[], t: (key: string, opts?: object) =>
return { return {
account, account,
action: `${section}.${method}`, action: `${section}.${method}`,
status: 'event', message: t('transfer received'),
message: t('transfer received') status: 'event'
}; };
} }
} else if (section === 'democracy') { } else if (section === 'democracy') {
@ -50,12 +50,12 @@ function filterEvents (allAccounts: string[], t: (key: string, opts?: object) =>
return { return {
action: `${section}.${method}`, action: `${section}.${method}`,
status: 'event',
message: t('update on #{{index}}', { message: t('update on #{{index}}', {
replace: { replace: {
index index
} }
}) }),
status: 'event'
}; };
} }

View File

@ -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) { if (isHidden) {
return false; return false;
} else if (needsAccounts && !hasAccounts) { } else if (needsAccounts && !hasAccounts) {
@ -73,7 +73,7 @@ function checkVisible (name: string, { api, isApiReady, isApiConnected }: ApiPro
return notFound.length === 0; return notFound.length === 0;
} }
function Item ({ route, isCollapsed, onClick }: Props): React.ReactElement<Props> | null { function Item ({ isCollapsed, onClick, route }: Props): React.ReactElement<Props> | null {
const { t } = useTranslation(); const { t } = useTranslation();
const { allAccounts, hasAccounts } = useAccounts(); const { allAccounts, hasAccounts } = useAccounts();
const apiProps = useApi(); const apiProps = useApi();

View File

@ -1,9 +1,9 @@
/* eslint-disable @typescript-eslint/camelcase */
/* eslint-disable @typescript-eslint/no-var-requires */
// Copyright 2017-2020 @polkadot/apps authors & contributors // Copyright 2017-2020 @polkadot/apps authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details. // of the Apache-2.0 license. See the LICENSE file for details.
/* eslint-disable @typescript-eslint/camelcase */
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
@ -39,21 +39,11 @@ function createWebpack ({ alias = {}, context, name = 'index' }) {
: null // 'webpack-plugin-serve/client' : null // 'webpack-plugin-serve/client'
].filter((entry) => entry), ].filter((entry) => entry),
mode: ENV, 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: { module: {
rules: [ rules: [
{ {
test: /\.css$/,
exclude: /(node_modules)/, exclude: /(node_modules)/,
test: /\.css$/,
use: [ use: [
isProd isProd
? MiniCssExtractPlugin.loader ? MiniCssExtractPlugin.loader
@ -67,8 +57,8 @@ function createWebpack ({ alias = {}, context, name = 'index' }) {
] ]
}, },
{ {
test: /\.css$/,
include: /node_modules/, include: /node_modules/,
test: /\.css$/,
use: [ use: [
isProd isProd
? MiniCssExtractPlugin.loader ? MiniCssExtractPlugin.loader
@ -77,8 +67,8 @@ function createWebpack ({ alias = {}, context, name = 'index' }) {
] ]
}, },
{ {
test: /\.(js|ts|tsx)$/,
exclude: /(node_modules)/, exclude: /(node_modules)/,
test: /\.(js|ts|tsx)$/,
use: [ use: [
require.resolve('thread-loader'), require.resolve('thread-loader'),
{ {
@ -100,9 +90,9 @@ function createWebpack ({ alias = {}, context, name = 'index' }) {
{ {
loader: require.resolve('url-loader'), loader: require.resolve('url-loader'),
options: { options: {
esModule: false,
limit: 10000, limit: 10000,
name: 'static/[name].[hash:8].[ext]', name: 'static/[name].[hash:8].[ext]'
esModule: false
} }
} }
] ]
@ -113,8 +103,8 @@ function createWebpack ({ alias = {}, context, name = 'index' }) {
{ {
loader: require.resolve('file-loader'), loader: require.resolve('file-loader'),
options: { 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', runtimeChunk: 'single',
splitChunks: { splitChunks: {
cacheGroups: { cacheGroups: {
polkadotJs: {
chunks: 'initial',
enforce: true,
name: 'polkadotjs',
test: /node_modules\/(@polkadot\/wasm-crypto)/
},
vendorOther: { vendorOther: {
chunks: 'initial', chunks: 'initial',
enforce: true, enforce: true,
@ -143,16 +139,16 @@ function createWebpack ({ alias = {}, context, name = 'index' }) {
enforce: true, enforce: true,
name: 'react', name: 'react',
test: /node_modules\/(chart|i18next|react|semantic-ui)/ 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: { performance: {
hints: false hints: false
}, },
@ -166,9 +162,9 @@ function createWebpack ({ alias = {}, context, name = 'index' }) {
} }
}), }),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
PAGE_TITLE: 'Polkadot/Substrate Portal',
inject: true, inject: true,
template: path.join(context, `${hasPublic ? 'public/' : ''}${name}.html`), template: path.join(context, `${hasPublic ? 'public/' : ''}${name}.html`)
PAGE_TITLE: 'Polkadot/Substrate Portal'
}), }),
new webpack.optimize.SplitChunksPlugin(), new webpack.optimize.SplitChunksPlugin(),
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
@ -179,11 +175,15 @@ function createWebpack ({ alias = {}, context, name = 'index' }) {
: new WebpackPluginServe({ : new WebpackPluginServe({
hmr: false, // switch off, Chrome WASM memory leak hmr: false, // switch off, Chrome WASM memory leak
liveReload: false, // explict off, overrides hmr liveReload: false, // explict off, overrides hmr
progress: false, // since we have hmr off, disable
port: 3000, port: 3000,
progress: false, // since we have hmr off, disable
static: path.join(process.cwd(), '/build') static: path.join(process.cwd(), '/build')
}) })
]).filter((plugin) => plugin), ]).filter((plugin) => plugin),
resolve: {
alias,
extensions: ['.js', '.jsx', '.ts', '.tsx']
},
watch: !isProd, watch: !isProd,
watchOptions: { watchOptions: {
ignored: ['.yarn', /build/, /node_modules/] ignored: ['.yarn', /build/, /node_modules/]
@ -192,10 +192,10 @@ function createWebpack ({ alias = {}, context, name = 'index' }) {
} }
module.exports = createWebpack({ module.exports = createWebpack({
context: __dirname,
alias: findPackages().reduce((alias, { dir, name }) => { alias: findPackages().reduce((alias, { dir, name }) => {
alias[name] = path.resolve(__dirname, `../${dir}/src`); alias[name] = path.resolve(__dirname, `../${dir}/src`);
return alias; return alias;
}, {}) }, {}),
context: __dirname
}); });

View File

@ -13,7 +13,7 @@
"dependencies": { "dependencies": {
"@babel/runtime": "^7.9.2", "@babel/runtime": "^7.9.2",
"@polkadot/react-components": "0.40.0-beta.224", "@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", "@polkadot/vanitygen": "^0.11.0-beta.12",
"detect-browser": "^5.0.0", "detect-browser": "^5.0.0",
"file-saver": "^2.0.2" "file-saver": "^2.0.2"

View File

@ -38,7 +38,7 @@ function Banner ({ className }: Props): React.ReactElement<Props> | null {
yourBrowser: stringUpperFirst(browserName) yourBrowser: stringUpperFirst(browserName)
} }
})}</p> })}</p>
<ul>{availableExtensions[browserName].map(({ desc, name, link }): React.ReactNode => ( <ul>{availableExtensions[browserName].map(({ desc, link, name }): React.ReactNode => (
<li key={name}> <li key={name}>
<a <a
href={link} href={link}

View File

@ -97,8 +97,8 @@ function generateSeed (_seed: string | undefined | null, derivePath: string, see
derivePath, derivePath,
isSeedValid: true, isSeedValid: true,
pairType, pairType,
seedType, seed,
seed seedType
}; };
} }
@ -123,8 +123,8 @@ function updateAddress (seed: string, derivePath: string, seedType: SeedType, pa
derivePath, derivePath,
isSeedValid, isSeedValid,
pairType, pairType,
seedType, seed,
seed seedType
}; };
} }
@ -167,11 +167,11 @@ function Create ({ className, onClose, onStatusChange, seed: propsSeed, type: pr
const isValid = !!address && !deriveError && isNameValid && isPassValid && isPass2Valid && isSeedValid; const isValid = !!address && !deriveError && isNameValid && isPassValid && isPass2Valid && isSeedValid;
const seedOpt = useMemo(() => ( const seedOpt = useMemo(() => (
isDevelopment isDevelopment
? [{ value: 'dev', text: t('Development') }] ? [{ text: t('Development'), value: 'dev' }]
: [] : []
).concat( ).concat(
{ value: 'bip', text: t('Mnemonic') }, { text: t('Mnemonic'), value: 'bip' },
{ value: 'raw', text: t('Raw seed') } { text: t('Raw seed'), value: 'raw' }
), [isDevelopment, t]); ), [isDevelopment, t]);
const _onChangePass = (password: string): void => const _onChangePass = (password: string): void =>

View File

@ -56,7 +56,7 @@ function Create ({ onClose, onStatusChange }: Props): React.ReactElement<Props>
} }
try { try {
keyring.saveAddress(address, { name: name.trim(), genesisHash: keyring.genesisHash, tags: [] }); keyring.saveAddress(address, { genesisHash: keyring.genesisHash, name: name.trim(), tags: [] });
status.account = address; status.account = address;
status.status = address ? 'success' : 'error'; status.status = address ? 'success' : 'error';

View File

@ -220,9 +220,9 @@ class VanityApp extends TxComponent<Props, State> {
return { return {
elapsed, elapsed,
matches: newMatches,
keyCount: newKeyCount, keyCount: newKeyCount,
keyTime: newKeyTime keyTime: newKeyTime,
matches: newMatches
}; };
} }
); );

View File

@ -90,7 +90,7 @@ class ABI extends React.PureComponent<Props, State> {
private renderInputFile (): React.ReactNode { private renderInputFile (): React.ReactNode {
const { className, help, isDisabled, isRequired, label, t } = this.props; const { className, help, isDisabled, isRequired, label, t } = this.props;
const { isAbiValid, isEmpty, isError, errorText } = this.state; const { errorText, isAbiValid, isEmpty, isError } = this.state;
return ( return (
<div className={className}> <div className={className}>
@ -168,10 +168,10 @@ class ABI extends React.PureComponent<Props, State> {
console.error(error); console.error(error);
this.setState({ this.setState({
errorText: error,
isAbiValid: false, isAbiValid: false,
isEmpty: false, isEmpty: false,
isError: true, isError: true
errorText: error
}, (): void => onChange(null, null)); }, (): void => onChange(null, null));
} }
} }

View File

@ -56,7 +56,7 @@ class CodeRow extends Row<Props, State> {
this.state = this.createState(); this.state = this.createState();
} }
public static getDerivedStateFromProps ({ code: { json }, accounts_info }: Props, prevState: State): State | null { public static getDerivedStateFromProps ({ accounts_info, code: { json } }: Props, prevState: State): State | null {
const codeHash = json.codeHash || DEFAULT_HASH; const codeHash = json.codeHash || DEFAULT_HASH;
const name = json.name || DEFAULT_NAME; const name = json.name || DEFAULT_NAME;
const tags = json.tags || []; const tags = json.tags || [];

View File

@ -88,9 +88,10 @@ class Upload extends ContractModal<Props, State> {
} }
private onAddWasm = (wasm: Uint8Array, name: string): void => { private onAddWasm = (wasm: Uint8Array, name: string): void => {
const isWasmValid = wasm.subarray(0, 4).toString() === '0,97,115,109'; // '\0asm' this.setState({
isWasmValid: wasm.subarray(0, 4).toString() === '0,97,115,109', // '\0asm'
this.setState({ wasm: compactAddLength(wasm), isWasmValid }); wasm: compactAddLength(wasm)
});
this.onChangeName(name); this.onChangeName(name);
} }

View File

@ -30,8 +30,8 @@ interface State {
class ValidateCode extends React.PureComponent<Props, State> { class ValidateCode extends React.PureComponent<Props, State> {
public state: State = { public state: State = {
isStored: false, isStored: false,
isValidHex: false, isValid: false,
isValid: false isValidHex: false
}; };
public static getDerivedStateFromProps ({ codeHash, contracts_codeStorage, onChange }: Props): State { public static getDerivedStateFromProps ({ codeHash, contracts_codeStorage, onChange }: Props): State {
@ -44,8 +44,8 @@ class ValidateCode extends React.PureComponent<Props, State> {
return { return {
isStored, isStored,
isValidHex, isValid,
isValid isValidHex
}; };
} }

View File

@ -29,9 +29,9 @@ class Add extends ContractModal<Props, State> {
this.defaultState = { this.defaultState = {
...this.defaultState, ...this.defaultState,
address: null, address: null,
name: 'New Contract',
isAddressValid: false, isAddressValid: false,
isNameValid: true isNameValid: true,
name: 'New Contract'
}; };
this.state = this.defaultState; this.state = this.defaultState;
this.headerText = props.t('Add an existing contract'); this.headerText = props.t('Add an existing contract');
@ -71,7 +71,7 @@ class Add extends ContractModal<Props, State> {
protected renderButtons = (): React.ReactNode => { protected renderButtons = (): React.ReactNode => {
const { t } = this.props; const { t } = this.props;
const { isAddressValid, isAbiValid, isNameValid } = this.state; const { isAbiValid, isAddressValid, isNameValid } = this.state;
const isValid = isNameValid && isAddressValid && isAbiValid; const isValid = isNameValid && isAddressValid && isAbiValid;
return ( return (
@ -96,7 +96,7 @@ class Add extends ContractModal<Props, State> {
private onAdd = (): void => { private onAdd = (): void => {
const { api } = this.props; const { api } = this.props;
const status: Partial<ActionStatus> = { action: 'create' }; const status: Partial<ActionStatus> = { action: 'create' };
const { address, abi, name, tags } = this.state; const { abi, address, name, tags } = this.state;
if (!address || !abi || !name) { if (!address || !abi || !name) {
return; return;
@ -104,12 +104,12 @@ class Add extends ContractModal<Props, State> {
try { try {
const json = { const json = {
name,
tags,
contract: { contract: {
abi, abi,
genesisHash: api.genesisHash.toHex() genesisHash: api.genesisHash.toHex()
} },
name,
tags
}; };
keyring.saveContract(address, json); keyring.saveContract(address, json);

View File

@ -32,7 +32,7 @@ interface Props extends BareProps {
function Call (props: Props): React.ReactElement<Props> | null { function Call (props: Props): React.ReactElement<Props> | null {
const { t } = useTranslation(); const { t } = useTranslation();
const { className, isOpen, callContract, callMessageIndex, onChangeCallContractAddress, onChangeCallMessageIndex, onClose } = props; const { callContract, callMessageIndex, className, isOpen, onChangeCallContractAddress, onChangeCallMessageIndex, onClose } = props;
const hasRpc = callContract?.hasRpcContractsCall; const hasRpc = callContract?.hasRpcContractsCall;
const callMessage = callContract?.getMessage(isNull(callMessageIndex) ? undefined : callMessageIndex); const callMessage = callContract?.getMessage(isNull(callMessageIndex) ? undefined : callMessageIndex);

View File

@ -17,7 +17,7 @@ interface Props {
} }
function Outcome (props: Props): React.ReactElement<Props> | null { function Outcome (props: Props): React.ReactElement<Props> | null {
const { className, onClear, outcome: { message, origin, output, params, isSuccess, time } } = props; const { className, onClear, outcome: { isSuccess, message, origin, output, params, time } } = props;
const dateTime = new Date(time); const dateTime = new Date(time);
return ( return (

View File

@ -50,8 +50,8 @@ class Deploy extends ContractModal<Props, State> {
this.defaultState = { this.defaultState = {
...this.defaultState, ...this.defaultState,
constructorIndex: -1,
constructOptions: [], constructOptions: [],
constructorIndex: -1,
endowment: new BN(ENDOWMENT), endowment: new BN(ENDOWMENT),
gasLimit: new BN(GAS_LIMIT), gasLimit: new BN(GAS_LIMIT),
isHashValid: false, isHashValid: false,
@ -80,9 +80,9 @@ class Deploy extends ContractModal<Props, State> {
}; };
} else { } else {
return { return {
constructorIndex: -1,
constructOptions: [] as ConstructOptions,
abi: null, abi: null,
constructOptions: [] as ConstructOptions,
constructorIndex: -1,
contractAbi: null, contractAbi: null,
isAbiSupplied: false, isAbiSupplied: false,
isAbiValid: false, isAbiValid: false,
@ -101,9 +101,9 @@ class Deploy extends ContractModal<Props, State> {
return { return {
codeHash, codeHash,
isAbiSupplied: !!contractAbi, isAbiSupplied: !!contractAbi,
name: `${json.name} (instance)`,
isHashValid: true, isHashValid: true,
isNameValid: true, isNameValid: true,
name: `${json.name} (instance)`,
...Deploy.getContractAbiState(json.abi, contractAbi, Math.max(constructorIndex, 0)) ...Deploy.getContractAbiState(json.abi, contractAbi, Math.max(constructorIndex, 0))
}; };
} }
@ -116,8 +116,8 @@ class Deploy extends ContractModal<Props, State> {
const constructorIndex = Math.max(ci, 0); const constructorIndex = Math.max(ci, 0);
if (!contractAbi || constructorIndex < 0 || constructorIndex >= contractAbi.constructors.length) { if (!contractAbi || constructorIndex < 0 || constructorIndex >= contractAbi.constructors.length) {
return { return {
constructorIndex: -1,
constructOptions: [], constructOptions: [],
constructorIndex: -1,
params: [] params: []
}; };
} }
@ -139,15 +139,15 @@ class Deploy extends ContractModal<Props, State> {
}); });
return { return {
constructorIndex,
constructOptions, constructOptions,
constructorIndex,
params: createValues(constructor.args) params: createValues(constructor.args)
}; };
} }
protected renderContent = (): React.ReactNode => { protected renderContent = (): React.ReactNode => {
const { t } = this.props; const { t } = this.props;
const { codeHash, constructorIndex, constructOptions, contractAbi, endowment, isAbiSupplied, isBusy, isHashValid } = this.state; const { codeHash, constructOptions, constructorIndex, contractAbi, endowment, isAbiSupplied, isBusy, isHashValid } = this.state;
const codeOptions = store.getAllCode().map(({ json: { codeHash, name } }): { text: string; value: string } => ({ const codeOptions = store.getAllCode().map(({ json: { codeHash, name } }): { text: string; value: string } => ({
text: `${name} (${codeHash})`, text: `${name} (${codeHash})`,
@ -303,11 +303,11 @@ class Deploy extends ContractModal<Props, State> {
} }
keyring.saveContract(address.toString(), { keyring.saveContract(address.toString(), {
name,
contract: { contract: {
abi, abi,
genesisHash: api.genesisHash.toHex() genesisHash: api.genesisHash.toHex()
}, },
name,
tags tags
}); });

View File

@ -91,10 +91,10 @@ function MessageSignature ({ message: { args, mutates, name, returnType }, param
{mutates && ( {mutates && (
<> <>
<Icon <Icon
className="mutates" className='mutates'
data-for={`mutates-${name}`} data-for={`mutates-${name}`}
data-tip data-tip
name="database" name='database'
/> />
{withTooltip && ( {withTooltip && (
<Tooltip <Tooltip

View File

@ -191,7 +191,7 @@ class ContractModal<P extends ContractModalProps, S extends ContractModalState>
} }
protected onChangeName = (name: string): void => { protected onChangeName = (name: string): void => {
this.setState({ name, isNameValid: name.length !== 0 }); this.setState({ isNameValid: name.length !== 0, name });
} }
protected onChangeGas = (gasLimit: BN | undefined): void => { protected onChangeGas = (gasLimit: BN | undefined): void => {

View File

@ -76,10 +76,10 @@ class Store extends EventEmitter {
try { try {
const abi = json.abi ? JSON.parse(json.abi) : null; const abi = json.abi ? JSON.parse(json.abi) : null;
this.allCode[json.codeHash] = { this.allCode[json.codeHash] = {
json,
contractAbi: abi contractAbi: abi
? new Abi(registry, abi) ? new Abi(registry, abi)
: undefined : undefined,
json
}; };
this.emit('new-code'); this.emit('new-code');

View File

@ -23,11 +23,11 @@ function ProposeExternal ({ className, isMember, members }: Props): React.ReactE
const [isVisible, toggleVisible] = useToggle(); const [isVisible, toggleVisible] = useToggle();
const [accountId, setAcountId] = useState<string | null>(null); const [accountId, setAcountId] = useState<string | null>(null);
const [proposal, setProposal] = useState<SubmittableExtrinsic<'promise'> | null>(null); const [proposal, setProposal] = useState<SubmittableExtrinsic<'promise'> | null>(null);
const [{ isHashValid, hash }, setHash] = useState<{ isHashValid: boolean; hash?: string }>({ isHashValid: false, hash: '' }); const [{ hash, isHashValid }, setHash] = useState<{ hash?: string; isHashValid: boolean }>({ hash: '', isHashValid: false });
const threshold = Math.ceil((members.length || 0) * 0.5); const threshold = Math.ceil((members.length || 0) * 0.5);
const _onChangeHash = useCallback( const _onChangeHash = useCallback(
(hash?: string): void => setHash({ isHashValid: isHex(hash, 256), hash }), (hash?: string): void => setHash({ hash, isHashValid: isHex(hash, 256) }),
[] []
); );

View File

@ -18,7 +18,7 @@ interface Props {
voters?: AccountId[]; voters?: AccountId[];
} }
function Candidate ({ className, address, balance, isPrime, voters }: Props): React.ReactElement<Props> { function Candidate ({ address, balance, className, isPrime, voters }: Props): React.ReactElement<Props> {
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (

View File

@ -12,7 +12,7 @@ function SubmitCandidacy (): React.ReactElement {
const { api } = useApi(); const { api } = useApi();
const { t } = useTranslation(); const { t } = useTranslation();
const [accountId, setAcountId] = useState<string | null>(null); const [accountId, setAcountId] = useState<string | null>(null);
const { isOpen, onOpen, onClose } = useModal(); const { isOpen, onClose, onOpen } = useModal();
return ( return (
<> <>

View File

@ -23,7 +23,7 @@ function Summary ({ bestNumber, className, electionsInfo }: Props): React.ReactE
return null; return null;
} }
const { members, candidateCount, desiredSeats, runnersUp, termDuration, voteCount } = electionsInfo; const { candidateCount, desiredSeats, members, runnersUp, termDuration, voteCount } = electionsInfo;
return ( return (
<SummaryBox className={className}> <SummaryBox className={className}>

View File

@ -29,8 +29,8 @@ class Vote extends TxModal<Props, State> {
this.defaultState = { this.defaultState = {
...this.defaultState, ...this.defaultState,
votes: [], voteValue: new BN(0),
voteValue: new BN(0) votes: []
}; };
this.state = { this.state = {
@ -50,13 +50,13 @@ class Vote extends TxModal<Props, State> {
: 'elections.vote'; : 'elections.vote';
protected txParams = (): [boolean[] | null, VoteIndex, BN | null] | [string[], BN] => { protected txParams = (): [boolean[] | null, VoteIndex, BN | null] | [string[], BN] => {
const { votes, voteValue } = this.state; const { voteValue, votes } = this.state;
return [votes, voteValue]; return [votes, voteValue];
} }
protected isDisabled = (): boolean => { protected isDisabled = (): boolean => {
const { accountId, votes, voteValue } = this.state; const { accountId, voteValue, votes } = this.state;
return !accountId || votes.length === 0 || voteValue.lten(0); return !accountId || votes.length === 0 || voteValue.lten(0);
} }

View File

@ -15,8 +15,8 @@ function transform (allAccounts: string[], queryMembers: [AccountId, Balance][])
const members = queryMembers.map((accountId): string => accountId.toString()); const members = queryMembers.map((accountId): string => accountId.toString());
return { return {
members, isMember: members.some((accountId): boolean => allAccounts.includes(accountId)),
isMember: members.some((accountId): boolean => allAccounts.includes(accountId)) members
}; };
} }

View File

@ -23,18 +23,18 @@ interface Props {
const ZERO_HASH = blake2AsHex(''); const ZERO_HASH = blake2AsHex('');
function PreImage ({ className, isImminent: propsIsImminent, imageHash, onClose }: Props): React.ReactElement<Props> { function PreImage ({ className, imageHash, isImminent: propsIsImminent, onClose }: Props): React.ReactElement<Props> {
const { t } = useTranslation(); const { t } = useTranslation();
const { apiDefaultTxSudo } = useApi(); const { apiDefaultTxSudo } = useApi();
const [accountId, setAccountId] = useState<string | null>(null); const [accountId, setAccountId] = useState<string | null>(null);
const [isImminent, setIsImminent] = useState(propsIsImminent || false); const [isImminent, setIsImminent] = useState(propsIsImminent || false);
const [{ encodedProposal, encodedHash }, setHash] = useState<{ encodedProposal: string; encodedHash: string }>({ encodedProposal: '', encodedHash: ZERO_HASH }); const [{ encodedHash, encodedProposal }, setHash] = useState<{ encodedHash: string; encodedProposal: string }>({ encodedHash: ZERO_HASH, encodedProposal: '' });
const [proposal, setProposal] = useState<any>(); const [proposal, setProposal] = useState<any>();
useEffect((): void => { useEffect((): void => {
const encodedProposal = (proposal as SubmittableExtrinsic)?.method.toHex() || ''; const encodedProposal = (proposal as SubmittableExtrinsic)?.method.toHex() || '';
setHash({ encodedProposal, encodedHash: blake2AsHex(encodedProposal) }); setHash({ encodedHash: blake2AsHex(encodedProposal), encodedProposal });
}, [proposal]); }, [proposal]);
const isMatched = imageHash const isMatched = imageHash

View File

@ -20,7 +20,7 @@ interface Props {
value: DeriveProposal; value: DeriveProposal;
} }
function Proposal ({ className, value: { balance, index, image, imageHash, proposer, seconds } }: Props): React.ReactElement<Props> { function Proposal ({ className, value: { balance, image, imageHash, index, proposer, seconds } }: Props): React.ReactElement<Props> {
const { t } = useTranslation(); const { t } = useTranslation();
const seconding = seconds.filter((_address, index): boolean => index !== 0); const seconding = seconds.filter((_address, index): boolean => index !== 0);

View File

@ -19,10 +19,10 @@ function Propose ({ className, onClose }: Props): React.ReactElement<Props> {
const { t } = useTranslation(); const { t } = useTranslation();
const [accountId, setAccountId] = useState<string | null>(null); const [accountId, setAccountId] = useState<string | null>(null);
const [balance, setBalance] = useState<BN | undefined>(); const [balance, setBalance] = useState<BN | undefined>();
const [{ isHashValid, hash }, setHash] = useState<{ isHashValid: boolean; hash?: string }>({ isHashValid: false, hash: '' }); const [{ hash, isHashValid }, setHash] = useState<{ hash?: string; isHashValid: boolean }>({ hash: '', isHashValid: false });
const _onChangeHash = useCallback( const _onChangeHash = useCallback(
(hash?: string): void => setHash({ isHashValid: isHex(hash, 256), hash }), (hash?: string): void => setHash({ hash, isHashValid: isHex(hash, 256) }),
[] []
); );

View File

@ -23,7 +23,7 @@ interface Props {
value: DeriveReferendumExt; value: DeriveReferendumExt;
} }
function Referendum ({ className, value: { allAye, allNay, image, imageHash, index, status, isPassing, voteCountAye, voteCountNay, votedAye, votedNay } }: Props): React.ReactElement<Props> | null { function Referendum ({ className, value: { allAye, allNay, image, imageHash, index, isPassing, status, voteCountAye, voteCountNay, votedAye, votedNay } }: Props): React.ReactElement<Props> | null {
const { t } = useTranslation(); const { t } = useTranslation();
const { api } = useApi(); const { api } = useApi();
const bestNumber = useCall<BlockNumber>(api.derive.chain.bestNumber, []); const bestNumber = useCall<BlockNumber>(api.derive.chain.bestNumber, []);

View File

@ -44,8 +44,8 @@ function Summary (): React.ReactElement<{}> {
<CardSummary <CardSummary
label={t('launch period')} label={t('launch period')}
progress={{ progress={{
value: bestNumber.mod(api.consts.democracy.launchPeriod).addn(1),
total: api.consts.democracy.launchPeriod, total: api.consts.democracy.launchPeriod,
value: bestNumber.mod(api.consts.democracy.launchPeriod).addn(1),
withTime: true withTime: true
}} }}
/> />

View File

@ -18,7 +18,7 @@ interface Props {
value?: Extrinsic[] | null; value?: Extrinsic[] | null;
} }
function Extrinsics ({ className, blockNumber, events, label, value }: Props): React.ReactElement<Props> { function Extrinsics ({ blockNumber, className, events, label, value }: Props): React.ReactElement<Props> {
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (

View File

@ -63,7 +63,7 @@ function calcWidth (children: LinkArray): number {
// counts the height of a specific node // counts the height of a specific node
function calcHeight (children: LinkArray): number { function calcHeight (children: LinkArray): number {
return children.reduce((max, { hdr, arr }): number => { return children.reduce((max, { arr, hdr }): number => {
hdr.height = hdr.isEmpty hdr.height = hdr.isEmpty
? 0 ? 0
: 1 + calcHeight(arr); : 1 + calcHeight(arr);

View File

@ -20,18 +20,15 @@ interface State {
} }
function stateFromValue (value: string): State { function stateFromValue (value: string): State {
const isValidHex = isHex(value, 256);
const isNumber = !isValidHex && /^\d+$/.test(value);
return { return {
value, isValid: isHex(value, 256) || /^\d+$/.test(value),
isValid: isValidHex || isNumber value
}; };
} }
function Query ({ className, value: propsValue }: Props): React.ReactElement<Props> { function Query ({ className, value: propsValue }: Props): React.ReactElement<Props> {
const { t } = useTranslation(); const { t } = useTranslation();
const [{ value, isValid }, setState] = useState(stateFromValue(propsValue || '')); const [{ isValid, value }, setState] = useState(stateFromValue(propsValue || ''));
const _setHash = (value: string): void => setState(stateFromValue(value)); const _setHash = (value: string): void => setState(stateFromValue(value));
const _onQuery = (): void => { const _onQuery = (): void => {

View File

@ -34,7 +34,7 @@ class Selection extends TxComponent<Props, State> {
public render (): React.ReactNode { public render (): React.ReactNode {
const { apiDefaultTxSudo, t } = this.props; const { apiDefaultTxSudo, t } = this.props;
const { isValid, isValidUnsigned, accountId } = this.state; const { accountId, isValid, isValidUnsigned } = this.state;
const extrinsic = this.getExtrinsic() || apiDefaultTxSudo('0x00'); const extrinsic = this.getExtrinsic() || apiDefaultTxSudo('0x00');
return ( return (
@ -91,10 +91,10 @@ class Selection extends TxComponent<Props, State> {
); );
return { return {
method, accountId,
isValid, isValid,
isValidUnsigned: !!method, isValidUnsigned: !!method,
accountId method
}; };
} }
); );

View File

@ -16,7 +16,7 @@ interface Props extends I18nProps {
onForget: (id: string) => void; onForget: (id: string) => void;
} }
function AssetCard ({ className, assetId, name, onForget, onSaveName, t }: Props): React.ReactElement<Props> { function AssetCard ({ assetId, className, name, onForget, onSaveName, t }: Props): React.ReactElement<Props> {
const _onForget = (): void => onForget(assetId); const _onForget = (): void => onForget(assetId);
const _onSaveName = (name: string): void => onSaveName(assetId, name); const _onSaveName = (name: string): void => onSaveName(assetId, name);

View File

@ -42,9 +42,9 @@ function Transfer ({ assets, className, onClose, recipientId: propRecipientId, s
// build up our list of options via assets // build up our list of options via assets
useEffect((): void => { useEffect((): void => {
setOptions(Object.entries(assets || {}).map(([id, name]): Option => ({ setOptions(Object.entries(assets || {}).map(([value, name]): Option => ({
value: id, text: `${name} (${value})`,
text: `${name} (${id})` value
}))); })));
}, [assets]); }, [assets]);

View File

@ -26,8 +26,6 @@ subject.subscribe((assets): void =>
); );
export default { export default {
getAssets: (): AssetsSubjectInfo[] =>
Object.entries(subject.getValue()).map(([id, name]): AssetsSubjectInfo => ({ id, name })),
add: (id: string, name: string): void => { add: (id: string, name: string): void => {
const assets = subject.getValue(); const assets = subject.getValue();
subject.next({ subject.next({
@ -35,6 +33,8 @@ export default {
[id]: name [id]: name
}); });
}, },
getAssets: (): AssetsSubjectInfo[] =>
Object.entries(subject.getValue()).map(([id, name]): AssetsSubjectInfo => ({ id, name })),
remove: (id: string): void => { remove: (id: string): void => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
const { [id]: ignore, ...assets } = subject.getValue(); const { [id]: ignore, ...assets } = subject.getValue();

View File

@ -8,7 +8,7 @@ export const STORE_EXAMPLES = 'polkadot-app-js-examples';
export const STORE_SELECTED = 'polkadot-app-js-selected'; export const STORE_SELECTED = 'polkadot-app-js-selected';
export const CUSTOM_LABEL: StrictLabelProps = { export const CUSTOM_LABEL: StrictLabelProps = {
color: 'orange',
children: 'Custom', children: 'Custom',
color: 'orange',
size: 'tiny' size: 'tiny'
}; };

View File

@ -4,6 +4,9 @@
import { Snippet } from '@polkadot/app-js/types'; import { Snippet } from '@polkadot/app-js/types';
// We must fix this :(
/* eslint-disable sort-keys */
export const constsStakingParameters: Snippet = { export const constsStakingParameters: Snippet = {
value: 'constsStakingParameters', value: 'constsStakingParameters',
text: 'Get staking parameters', text: 'Get staking parameters',

View File

@ -4,6 +4,9 @@
import { Snippet } from '@polkadot/app-js/types'; import { Snippet } from '@polkadot/app-js/types';
// We must fix this :(
/* eslint-disable sort-keys */
export const extrinsicMakeTransfer: Snippet = { export const extrinsicMakeTransfer: Snippet = {
value: 'extrinsicMakeTransfer', value: 'extrinsicMakeTransfer',
text: 'Make transfer and listen to events', text: 'Make transfer and listen to events',

View File

@ -4,6 +4,9 @@
import { Snippet } from '@polkadot/app-js/types'; import { Snippet } from '@polkadot/app-js/types';
// We must fix this :(
/* eslint-disable sort-keys */
export const rpcNetworkAuthoring: Snippet = { export const rpcNetworkAuthoring: Snippet = {
value: 'rpcNetworkAuthoring', value: 'rpcNetworkAuthoring',
text: 'Get authoring information', text: 'Get authoring information',

View File

@ -4,6 +4,9 @@
import { Snippet } from '@polkadot/app-js/types'; import { Snippet } from '@polkadot/app-js/types';
// We must fix this :(
/* eslint-disable sort-keys */
export const storageGetInfo: Snippet = { export const storageGetInfo: Snippet = {
value: 'storageGetInfo', value: 'storageGetInfo',
text: 'Get chain state information', text: 'Get chain state information',

View File

@ -35,7 +35,7 @@ const ONE_THOUSAND = new BN(1000);
function Register ({ nextFreeId = ONE_THOUSAND, sudoKey }: Props): React.ReactElement<Props> | null { function Register ({ nextFreeId = ONE_THOUSAND, sudoKey }: Props): React.ReactElement<Props> | null {
const { t } = useTranslation(); const { t } = useTranslation();
const { api } = useApi(); const { api } = useApi();
const { isOpen, onOpen, onClose } = useModal(); const { isOpen, onClose, onOpen } = useModal();
const onSendRef = useRef<() => void>(); const onSendRef = useRef<() => void>();
const isWasmValidRef = useRef(false); const isWasmValidRef = useRef(false);

View File

@ -17,7 +17,7 @@ interface Props {
parachain: DeriveParachainFull; parachain: DeriveParachainFull;
} }
function Details ({ parachain: { heads, info, id } }: Props): React.ReactElement<Props> { function Details ({ parachain: { heads, id, info } }: Props): React.ReactElement<Props> {
const { t } = useTranslation(); const { t } = useTranslation();
const { api } = useApi(); const { api } = useApi();

View File

@ -31,7 +31,7 @@ function DispatchQueue ({ className, dispatchQueue = [] }: Props): React.ReactEl
: ( : (
<> <>
{ {
dispatchQueue.map(({ origin, data }): React.ReactNode => { dispatchQueue.map(({ data, origin }): React.ReactNode => {
return ( return (
<Card <Card
className='queue-message' className='queue-message'

View File

@ -24,13 +24,13 @@ interface Props extends ComponentProps {
paraInfoRef: React.MutableRefObject<DeriveParachainInfo | null>; paraInfoRef: React.MutableRefObject<DeriveParachainInfo | null>;
} }
function Parachain ({ className, basePath, isMine, paraInfoRef, sudoKey }: Props): React.ReactElement<Props> { function Parachain ({ basePath, className, isMine, paraInfoRef, sudoKey }: Props): React.ReactElement<Props> {
const { t } = useTranslation(); const { t } = useTranslation();
const history = useHistory(); const history = useHistory();
const { api } = useApi(); const { api } = useApi();
const { id } = useParams(); const { id } = useParams();
const [isMenuOpen, toggleMenu] = useToggle(); const [isMenuOpen, toggleMenu] = useToggle();
const { isOpen: isDeregisterOpen, onOpen: onDeregisterOpen, onClose: onDeregisterClose } = useModal(); const { isOpen: isDeregisterOpen, onClose: onDeregisterClose, onOpen: onDeregisterOpen } = useModal();
const parachain = useCall<DeriveParachainFull | null>(api.derive.parachains.info as any, [id || null]); const parachain = useCall<DeriveParachainFull | null>(api.derive.parachains.info as any, [id || null]);
if (isUndefined(parachain)) { if (isUndefined(parachain)) {

View File

@ -17,7 +17,7 @@ interface Props {
isBig?: boolean; isBig?: boolean;
} }
function ParachainInfo ({ children, className, isBig, info }: Props): React.ReactElement<Props> { function ParachainInfo ({ children, className, info, isBig }: Props): React.ReactElement<Props> {
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (

View File

@ -100,15 +100,15 @@ function Developer ({ className, onStatusChange }: Props): React.ReactElement<Pr
store.set('types', types); store.set('types', types);
setIsTypesValid(true); setIsTypesValid(true);
onStatusChange({ onStatusChange({
status: 'success', action: t('Your custom types have been added'),
action: t('Your custom types have been added') status: 'success'
}); });
} catch (error) { } catch (error) {
console.error(error); console.error(error);
setIsTypesValid(false); setIsTypesValid(false);
onStatusChange({ onStatusChange({
status: 'error', action: t(`Error saving your custom types. ${error.message}`),
action: t(`Error saving your custom types. ${error.message}`) status: 'error'
}); });
} }
}; };

View File

@ -35,8 +35,8 @@ function General ({ className, isModalContent, onClose }: Props): React.ReactEle
}, [t]); }, [t]);
const translateLanguages = useMemo((): Option[] => { const translateLanguages = useMemo((): Option[] => {
return availableLanguages.map(({ text, value, withI18n }) => ({ return availableLanguages.map(({ text, value, withI18n }) => ({
value, text: withI18n ? t(text as string) : text,
text: withI18n ? t(text as string) : text value
})); }));
}, [t]); }, [t]);
@ -69,7 +69,7 @@ function General ({ className, isModalContent, onClose }: Props): React.ReactEle
[settings] [settings]
); );
const { icon, i18nLang, ledgerConn, prefix, uiMode } = settings; const { i18nLang, icon, ledgerConn, prefix, uiMode } = settings;
return ( return (
<div className={className}> <div className={className}>

View File

@ -11,7 +11,7 @@ interface Props extends BareProps {
color: string; color: string;
} }
function ChainColorIndicator ({ color, className }: Props): React.ReactElement<Props> { function ChainColorIndicator ({ className, color }: Props): React.ReactElement<Props> {
return ( return (
<div <div
className={className} className={className}

View File

@ -31,12 +31,12 @@ function getRandomColor (): string {
} }
const initialState = { const initialState = {
decimals: 0,
prefix: 0,
unit: 'UNIT',
title: '',
color: '#FFFFFF', color: '#FFFFFF',
genesisHash: '' decimals: 0,
genesisHash: '',
prefix: 0,
title: '',
unit: 'UNIT'
}; };
function NetworkSpecs ({ chainInfo, className }: Props): React.ReactElement<Props> { function NetworkSpecs ({ chainInfo, className }: Props): React.ReactElement<Props> {
@ -58,10 +58,10 @@ function NetworkSpecs ({ chainInfo, className }: Props): React.ReactElement<Prop
chainInfo && setNetworkSpecs({ chainInfo && setNetworkSpecs({
color: chainInfo.color || getRandomColor(), color: chainInfo.color || getRandomColor(),
decimals: chainInfo.tokenDecimals, decimals: chainInfo.tokenDecimals,
genesisHash: chainInfo.genesisHash,
prefix: chainInfo.ss58Format, prefix: chainInfo.ss58Format,
unit: chainInfo.tokenSymbol,
title: systemChain, title: systemChain,
genesisHash: chainInfo.genesisHash unit: chainInfo.tokenSymbol
}); });
}, [chainInfo, systemChain]); }, [chainInfo, systemChain]);

View File

@ -88,7 +88,7 @@ function filterAll (api: ApiPromise, all: ExtensionKnown[]): Extensions {
} }
export default function useExtensions (): Extensions { export default function useExtensions (): Extensions {
const { api, isApiReady, isDevelopment, extensions } = useApi(); const { api, extensions, isApiReady, isDevelopment } = useApi();
const [all, setAll] = useState<ExtensionKnown[] | undefined>(); const [all, setAll] = useState<ExtensionKnown[] | undefined>();
const [state, setState] = useState<Extensions>({ count: 0 }); const [state, setState] = useState<Extensions>({ count: 0 });
const [trigger, setTrigger] = useState(0); const [trigger, setTrigger] = useState(0);

View File

@ -12,7 +12,7 @@ interface Props {
value: Bid; value: Bid;
} }
function BidRow ({ value: { who, kind, value } }: Props): React.ReactElement<Props> { function BidRow ({ value: { kind, value, who } }: Props): React.ReactElement<Props> {
return ( return (
<tr> <tr>
<td className='all top'> <td className='all top'>

View File

@ -60,7 +60,7 @@ function InjectKeys ({ onClose }: Props): React.ReactElement<Props> | null {
const _onSubmit = useCallback( const _onSubmit = useCallback(
(): void => queueRpc({ (): void => queueRpc({
rpc: { section: 'author', method: 'insertKey' } as any, rpc: { method: 'insertKey', section: 'author' } as any,
values: [keyType, suri, publicKey] values: [keyType, suri, publicKey]
}), }),
[keyType, publicKey, queueRpc, suri] [keyType, publicKey, queueRpc, suri]

View File

@ -24,7 +24,7 @@ interface Props {
const MAX_NOMINEES = 16; const MAX_NOMINEES = 16;
function Nominate ({ className, controllerId, nominees, onClose, next, stakingOverview, stashId }: Props): React.ReactElement<Props> | null { function Nominate ({ className, controllerId, next, nominees, onClose, stakingOverview, stashId }: Props): React.ReactElement<Props> | null {
const { t } = useTranslation(); const { t } = useTranslation();
const [favorites] = useFavorites(STORE_FAVS_BASE); const [favorites] = useFavorites(STORE_FAVS_BASE);
const [validators, setValidators] = useState<string[]>([]); const [validators, setValidators] = useState<string[]>([]);

View File

@ -122,8 +122,8 @@ class Unbond extends TxComponent<Props, State> {
const { maxUnbond = prevState.maxUnbond, maxBalance = prevState.maxBalance } = newState; const { maxUnbond = prevState.maxUnbond, maxBalance = prevState.maxBalance } = newState;
return { return {
maxUnbond, maxBalance,
maxBalance maxUnbond
}; };
}); });
} }

View File

@ -120,7 +120,7 @@ function Account ({ allStashes, className, isOwnStash, next, onUpdateType, rewar
const balancesAll = useCall<DeriveBalancesAll>(api.derive.balances.all as any, [stashId]); const balancesAll = useCall<DeriveBalancesAll>(api.derive.balances.all as any, [stashId]);
const stakingAccount = useCall<DeriveStakingAccount>(api.derive.staking.account as any, [stashId]); const stakingAccount = useCall<DeriveStakingAccount>(api.derive.staking.account as any, [stashId]);
const [[payoutRewards, payoutEras, payoutTotal], setStakingRewards] = useState<[DeriveStakerReward[], EraIndex[], BN]>([[], [], new BN(0)]); const [[payoutRewards, payoutEras, payoutTotal], setStakingRewards] = useState<[DeriveStakerReward[], EraIndex[], BN]>([[], [], new BN(0)]);
const [{ controllerId, destination, destinationId, hexSessionIdQueue, hexSessionIdNext, isLoading, isOwnController, isStashNominating, isStashValidating, nominees, sessionIds, validatorPrefs }, setStakeState] = useState<StakeState>({ controllerId: null, destinationId: 0, hexSessionIdNext: null, hexSessionIdQueue: null, isLoading: true, isOwnController: false, isStashNominating: false, isStashValidating: false, sessionIds: [] }); const [{ controllerId, destination, destinationId, hexSessionIdNext, hexSessionIdQueue, isLoading, isOwnController, isStashNominating, isStashValidating, nominees, sessionIds, validatorPrefs }, setStakeState] = useState<StakeState>({ controllerId: null, destinationId: 0, hexSessionIdNext: null, hexSessionIdQueue: null, isLoading: true, isOwnController: false, isStashNominating: false, isStashValidating: false, sessionIds: [] });
const [activeNoms, setActiveNoms] = useState<string[]>([]); const [activeNoms, setActiveNoms] = useState<string[]>([]);
const inactiveNoms = useInactives(stashId, nominees); const inactiveNoms = useInactives(stashId, nominees);
const [isBondExtraOpen, toggleBondExtra] = useToggle(); const [isBondExtraOpen, toggleBondExtra] = useToggle();

View File

@ -50,7 +50,7 @@ function expandInfo ({ exposure, validatorPrefs }: DeriveStakingQuery): StakingS
let stakeOwn: BN | undefined; let stakeOwn: BN | undefined;
if (exposure) { if (exposure) {
nominators = exposure.others.map(({ who, value }): [string, Balance] => [who.toString(), value.unwrap()]); nominators = exposure.others.map(({ value, who }): [string, Balance] => [who.toString(), value.unwrap()]);
stakeTotal = exposure.total.unwrap(); stakeTotal = exposure.total.unwrap();
stakeOwn = exposure.own.unwrap(); stakeOwn = exposure.own.unwrap();
stakeOther = stakeTotal.sub(stakeOwn); stakeOther = stakeTotal.sub(stakeOwn);
@ -75,7 +75,7 @@ function checkVisibility (api: ApiPromise, address: string, filterName: string,
if (filterLower) { if (filterLower) {
if (accountInfo) { if (accountInfo) {
const { identity, nickname, accountId, accountIndex } = accountInfo; const { accountId, accountIndex, identity, nickname } = accountInfo;
if (accountId?.toString().includes(filterName) || accountIndex?.toString().includes(filterName)) { if (accountId?.toString().includes(filterName) || accountIndex?.toString().includes(filterName)) {
isVisible = true; isVisible = true;
@ -104,7 +104,7 @@ function Address ({ address, className, filterName, hasQueries, isAuthor, isElec
const { api } = useApi(); const { api } = useApi();
const accountInfo = useCall<DeriveAccountInfo>(api.derive.accounts.info as any, [address]); const accountInfo = useCall<DeriveAccountInfo>(api.derive.accounts.info as any, [address]);
const stakingInfo = useCall<DeriveStakingQuery>(isMain && api.derive.staking.query as any, [address]); const stakingInfo = useCall<DeriveStakingQuery>(isMain && api.derive.staking.query as any, [address]);
const [{ commission, nominators, stakeOwn, stakeOther }, setStakingState] = useState<StakingState>({ nominators: [] }); const [{ commission, nominators, stakeOther, stakeOwn }, setStakingState] = useState<StakingState>({ nominators: [] });
const [isVisible, setIsVisible] = useState(true); const [isVisible, setIsVisible] = useState(true);
useEffect((): void => { useEffect((): void => {

View File

@ -19,7 +19,7 @@ interface Props extends BareProps {
stakingOverview?: DeriveStakingOverview; stakingOverview?: DeriveStakingOverview;
} }
function Overview ({ className, hasQueries, isIntentions, recentlyOnline, next, setNominators, stakingOverview }: Props): React.ReactElement<Props> { function Overview ({ className, hasQueries, isIntentions, next, recentlyOnline, setNominators, stakingOverview }: Props): React.ReactElement<Props> {
const { byAuthor, lastBlockAuthors } = useContext(BlockAuthorsContext); const { byAuthor, lastBlockAuthors } = useContext(BlockAuthorsContext);
return ( return (

View File

@ -97,9 +97,9 @@ function extractInfo (allAccounts: string[], amount: BN = new BN(0), electedInfo
const validators = sortValidators( const validators = sortValidators(
electedInfo.info.map(({ accountId, exposure: _exposure, validatorPrefs }): ValidatorInfo => { electedInfo.info.map(({ accountId, exposure: _exposure, validatorPrefs }): ValidatorInfo => {
const exposure = _exposure || { const exposure = _exposure || {
total: createType(registry, 'Compact<Balance>'), others: createType(registry, 'Vec<IndividualExposure>'),
own: createType(registry, 'Compact<Balance>'), own: createType(registry, 'Compact<Balance>'),
others: createType(registry, 'Vec<IndividualExposure>') total: createType(registry, 'Compact<Balance>')
}; };
const prefs = (validatorPrefs as (ValidatorPrefs | ValidatorPrefsTo196)) || { const prefs = (validatorPrefs as (ValidatorPrefs | ValidatorPrefsTo196)) || {
commission: createType(registry, 'Compact<Perbill>') commission: createType(registry, 'Compact<Perbill>')
@ -132,11 +132,11 @@ function extractInfo (allAccounts: string[], amount: BN = new BN(0), electedInfo
bondOwn, bondOwn,
bondShare: 0, bondShare: 0,
bondTotal, bondTotal,
commissionPer: (((prefs as ValidatorPrefs).commission?.unwrap() || new BN(0)).toNumber() / 10_000_000),
isCommission: !!(prefs as ValidatorPrefs).commission, isCommission: !!(prefs as ValidatorPrefs).commission,
isFavorite: favorites.includes(key), isFavorite: favorites.includes(key),
isNominating, isNominating,
key, key,
commissionPer: (((prefs as ValidatorPrefs).commission?.unwrap() || new BN(0)).toNumber() / 10_000_000),
numNominators: exposure.others.length, numNominators: exposure.others.length,
rankBondOther: 0, rankBondOther: 0,
rankBondOwn: 0, rankBondOwn: 0,
@ -183,11 +183,11 @@ function Targets ({ className }: Props): React.ReactElement<Props> {
const [_amount, setAmount] = useState<BN | undefined>(new BN(1_000)); const [_amount, setAmount] = useState<BN | undefined>(new BN(1_000));
const electedInfo = useCall<DeriveStakingElected>(api.derive.staking.electedInfo, []); const electedInfo = useCall<DeriveStakingElected>(api.derive.staking.electedInfo, []);
const [favorites, toggleFavorite] = useFavorites(STORE_FAVS_BASE); const [favorites, toggleFavorite] = useFavorites(STORE_FAVS_BASE);
const [{ nominators, validators, sorted, totalStaked }, setWorkable] = useState<AllInfo>({ nominators: [], validators: [] }); const [{ nominators, sorted, totalStaked, validators }, setWorkable] = useState<AllInfo>({ nominators: [], validators: [] });
const [{ sortBy, sortFromMax }, setSortBy] = useState<{ sortBy: SortBy; sortFromMax: boolean }>({ sortBy: 'rankOverall', sortFromMax: true }); const [{ sortBy, sortFromMax }, setSortBy] = useState<{ sortBy: SortBy; sortFromMax: boolean }>({ sortBy: 'rankOverall', sortFromMax: true });
const amount = useDebounce(_amount); const amount = useDebounce(_amount);
const labels = useMemo( const labels = useMemo(
(): Record<string, string> => ({ rankComm: t('commission'), rankBondTotal: t('total stake'), rankBondOwn: t('own stake'), rankBondOther: t('other stake'), rankOverall: t('profit/era est') }), (): Record<string, string> => ({ rankBondOther: t('other stake'), rankBondOwn: t('own stake'), rankBondTotal: t('total stake'), rankComm: t('commission'), rankOverall: t('profit/era est') }),
[t] [t]
); );
@ -207,7 +207,7 @@ function Targets ({ className }: Props): React.ReactElement<Props> {
const { nominators, totalStaked, validators } = extractInfo(allAccounts, amount, electedInfo, favorites, lastReward); const { nominators, totalStaked, validators } = extractInfo(allAccounts, amount, electedInfo, favorites, lastReward);
const sorted = sort(sortBy, sortFromMax, validators); const sorted = sort(sortBy, sortFromMax, validators);
setWorkable({ nominators, totalStaked, sorted, validators }); setWorkable({ nominators, sorted, totalStaked, validators });
} }
}, [allAccounts, amount, electedInfo, favorites, lastReward, sortBy, sortFromMax]); }, [allAccounts, amount, electedInfo, favorites, lastReward, sortBy, sortFromMax]);

View File

@ -61,16 +61,16 @@ function typeToString ({ creator: { meta: { modifier, type } } }: StorageEntryPr
function createComponent (type: string, Component: React.ComponentType<any>, defaultProps: DefaultProps, renderHelper: ComponentRenderer): { Component: React.ComponentType<any>; render: (createComponent: RenderFn) => React.ComponentType<any>; refresh: (swallowErrors: boolean, contentShorten: boolean) => React.ComponentType<any> } { function createComponent (type: string, Component: React.ComponentType<any>, defaultProps: DefaultProps, renderHelper: ComponentRenderer): { Component: React.ComponentType<any>; render: (createComponent: RenderFn) => React.ComponentType<any>; refresh: (swallowErrors: boolean, contentShorten: boolean) => React.ComponentType<any> } {
return { return {
Component, Component,
// In order to replace the default component during runtime we can provide a RenderFn to create a new 'plugged' component
render: (createComponent: RenderFn): React.ComponentType<any> =>
renderHelper(createComponent, defaultProps),
// In order to modify the parameters which are used to render the default component, we can use this method // In order to modify the parameters which are used to render the default component, we can use this method
refresh: (swallowErrors: boolean, contentShorten: boolean): React.ComponentType<any> => refresh: (swallowErrors: boolean, contentShorten: boolean): React.ComponentType<any> =>
renderHelper( renderHelper(
(value: any): React.ReactNode => (value: any): React.ReactNode =>
<pre>{valueToText(type, value, swallowErrors, contentShorten)}</pre>, <pre>{valueToText(type, value, swallowErrors, contentShorten)}</pre>,
defaultProps defaultProps
) ),
// In order to replace the default component during runtime we can provide a RenderFn to create a new 'plugged' component
render: (createComponent: RenderFn): React.ComponentType<any> =>
renderHelper(createComponent, defaultProps)
}; };
} }

View File

@ -87,7 +87,7 @@ function Modules ({ onAdd }: Props): React.ReactElement<Props> {
_onChangeValues([]); _onChangeValues([]);
}; };
const { creator: { method, section, meta } } = key; const { creator: { meta, method, section } } = key;
return ( return (
<section className='storage--actionrow'> <section className='storage--actionrow'>

View File

@ -26,13 +26,13 @@ interface State {
class Propose extends TxComponent<Props, State> { class Propose extends TxComponent<Props, State> {
public state: State = { public state: State = {
method: null, isValid: false,
isValid: false method: null
}; };
public render (): React.ReactNode { public render (): React.ReactNode {
const { apiDefaultTxSudo, isMine, sudoKey, t } = this.props; const { apiDefaultTxSudo, isMine, sudoKey, t } = this.props;
const { method, isValid } = this.state; const { isValid, method } = this.state;
return isMine return isMine
? ( ? (
@ -71,11 +71,10 @@ class Propose extends TxComponent<Props, State> {
this.setState( this.setState(
(prevState: State): State => { (prevState: State): State => {
const { method = prevState.method } = newState; const { method = prevState.method } = newState;
const isValid = !!method;
return { return {
method, isValid: !!method,
isValid method
}; };
} }
); );

View File

@ -16,7 +16,7 @@ import { useTranslation } from './translate';
function SudoApp ({ basePath }: Props): React.ReactElement<Props> { function SudoApp ({ basePath }: Props): React.ReactElement<Props> {
const { t } = useTranslation(); const { t } = useTranslation();
const { allAccounts, sudoKey, isMine } = useSudo(); const { allAccounts, isMine, sudoKey } = useSudo();
const items = useMemo(() => [ const items = useMemo(() => [
{ {
isRoot: true, isRoot: true,

View File

@ -19,7 +19,7 @@ interface Props {
function Propose ({ isMember, members }: Props): React.ReactElement<Props> { function Propose ({ isMember, members }: Props): React.ReactElement<Props> {
const { t } = useTranslation(); const { t } = useTranslation();
const { apiDefaultTxSudo } = useApi(); const { apiDefaultTxSudo } = useApi();
const { isOpen, onOpen, onClose } = useModal(); const { isOpen, onClose, onOpen } = useModal();
const [accountId, setAcountId] = useState<string | null>(null); const [accountId, setAcountId] = useState<string | null>(null);
const [proposal, setProposal] = useState<SubmittableExtrinsic<'promise'> | null>(null); const [proposal, setProposal] = useState<SubmittableExtrinsic<'promise'> | null>(null);
const [[threshold, hasThreshold], setThreshold] = useState<[BN | null, boolean]>([ const [[threshold, hasThreshold], setThreshold] = useState<[BN | null, boolean]>([

View File

@ -26,7 +26,7 @@ function Results ({ queue = [] }: Props): React.ReactElement<Props> | null {
return ( return (
<section className='rpc--Results'> <section className='rpc--Results'>
{filtered.map(({ error, id, result, rpc: { section, method } }): React.ReactNode => ( {filtered.map(({ error, id, result, rpc: { method, section } }): React.ReactNode => (
<Output <Output
isError={!!error} isError={!!error}
key={id} key={id}

View File

@ -31,8 +31,8 @@ const defaultMethod = jsonrpc.author.submitExtrinsic;
class Selection extends TxComponent<Props, State> { class Selection extends TxComponent<Props, State> {
public state: State = { public state: State = {
isValid: false,
accountId: null, accountId: null,
isValid: false,
rpc: defaultMethod, rpc: defaultMethod,
values: [] values: []
}; };
@ -75,16 +75,16 @@ class Selection extends TxComponent<Props, State> {
private nextState (newState: Partial<State>): void { private nextState (newState: Partial<State>): void {
this.setState( this.setState(
(prevState: State): State => { (prevState: State): State => {
const { rpc = prevState.rpc, accountId = prevState.accountId, values = prevState.values } = newState; const { accountId = prevState.accountId, rpc = prevState.rpc, values = prevState.values } = newState;
const reqCount = rpc.params.reduce((count, { isOptional }): number => count + (isOptional ? 0 : 1), 0); const reqCount = rpc.params.reduce((count, { isOptional }): number => count + (isOptional ? 0 : 1), 0);
const isValid = values.reduce((isValid, value): boolean => { const isValid = values.reduce((isValid, value): boolean => {
return isValid && value.isValid === true; return isValid && value.isValid === true;
}, reqCount <= values.length); }, reqCount <= values.length);
return { return {
accountId,
isValid, isValid,
rpc, rpc,
accountId,
values values
}; };
} }

View File

@ -13,7 +13,7 @@ import Selection from './Selection';
function RpcApp (): React.ReactElement { function RpcApp (): React.ReactElement {
return ( return (
<QueueConsumer> <QueueConsumer>
{({ txqueue, queueRpc }: QueueProps): React.ReactNode => ( {({ queueRpc, txqueue }: QueueProps): React.ReactNode => (
<> <>
<Selection queueRpc={queueRpc} /> <Selection queueRpc={queueRpc} />
<Results queue={txqueue} /> <Results queue={txqueue} />

View File

@ -37,9 +37,9 @@ function Verify (): React.ReactElement<{}> {
const { t } = useTranslation(); const { t } = useTranslation();
const [{ cryptoType, isValid }, setValidity] = useState<{ cryptoType: CryptoTypes; isValid: boolean }>({ cryptoType: 'unknown', isValid: false }); const [{ cryptoType, isValid }, setValidity] = useState<{ cryptoType: CryptoTypes; isValid: boolean }>({ cryptoType: 'unknown', isValid: false });
const [{ data, isHexData }, setData] = useState<{ data: string; isHexData: boolean }>({ data: '', isHexData: false }); const [{ data, isHexData }, setData] = useState<{ data: string; isHexData: boolean }>({ data: '', isHexData: false });
const [{ publicKey, isValidPk }, setPublicKey] = useState<{ publicKey: Uint8Array | null; isValidPk: boolean }>({ publicKey: null, isValidPk: false }); const [{ isValidPk, publicKey }, setPublicKey] = useState<{ isValidPk: boolean; publicKey: Uint8Array | null }>({ isValidPk: false, publicKey: null });
const [{ signature, isValidSignature }, setSignature] = useState<{ signature: string; isValidSignature: boolean }>({ signature: '', isValidSignature: false }); const [{ isValidSignature, signature }, setSignature] = useState<{ isValidSignature: boolean; signature: string }>({ isValidSignature: false, signature: '' });
const [cryptoOptions] = useState([{ value: 'unknown', text: t('Crypto not detected') }].concat(uiSettings.availableCryptos as any[])); const [cryptoOptions] = useState([{ text: t('Crypto not detected'), value: 'unknown' }].concat(uiSettings.availableCryptos as any[]));
useEffect((): void => { useEffect((): void => {
let cryptoType: CryptoTypes = 'unknown'; let cryptoType: CryptoTypes = 'unknown';
@ -87,14 +87,14 @@ function Verify (): React.ReactElement<{}> {
console.error(err); console.error(err);
} }
setPublicKey({ publicKey, isValidPk: !!publicKey && publicKey.length === 32 }); setPublicKey({ isValidPk: !!publicKey && publicKey.length === 32, publicKey });
}; };
const _onChangeData = (data: string): void => const _onChangeData = (data: string): void =>
setData({ data, isHexData: isHex(data) }); setData({ data, isHexData: isHex(data) });
const _onChangeSignature = (signature: string): void => const _onChangeSignature = (signature: string): void =>
setSignature({ signature, isValidSignature: isHex(signature) && signature.length === 130 }); setSignature({ isValidSignature: isHex(signature) && signature.length === 130, signature });
return ( return (
<div className='toolbox--Verify'> <div className='toolbox--Verify'>
@ -126,7 +126,7 @@ function Verify (): React.ReactElement<{}> {
<AlignedIcon <AlignedIcon
color={isValid ? 'green' : (isValidSignature ? 'red' : undefined)} color={isValid ? 'green' : (isValidSignature ? 'red' : undefined)}
name={isValid ? 'check circle' : (isValidSignature ? 'exclamation circle' : 'help circle')} name={isValid ? 'check circle' : (isValidSignature ? 'exclamation circle' : 'help circle')}
size="big" size='big'
/> />
</div> </div>
<Input <Input

View File

@ -29,8 +29,8 @@ function Submission ({ councilProposals, id, isDisabled }: Props): React.ReactEl
const [councilType, setCouncilType] = useState('reject'); const [councilType, setCouncilType] = useState('reject');
const [hasProposals, setHasProposals] = useState(true); const [hasProposals, setHasProposals] = useState(true);
const councilTypeOpt = useMemo(() => [ const councilTypeOpt = useMemo(() => [
{ value: 'accept', text: t('Acceptance proposal to council') }, { text: t('Acceptance proposal to council'), value: 'accept' },
{ value: 'reject', text: t('Rejection proposal to council') } { text: t('Rejection proposal to council'), value: 'reject' }
], [t]); ], [t]);
useEffect((): void => { useEffect((): void => {

View File

@ -28,7 +28,7 @@ function Voting ({ councilProposals, isDisabled }: Props): React.ReactElement<Pr
const [councilOpts, setCouncilOpts] = useState<Option[]>([]); const [councilOpts, setCouncilOpts] = useState<Option[]>([]);
const [councilOptId, setCouncilOptId] = useState<number>(0); const [councilOptId, setCouncilOptId] = useState<number>(0);
const [accountId, setAccountId] = useState<string | null>(null); const [accountId, setAccountId] = useState<string | null>(null);
const [{ councilId, councilHash }, setCouncilInfo] = useState<{ councilId: ProposalIndex | null; councilHash: Hash | null }>({ councilId: null, councilHash: null }); const [{ councilHash, councilId }, setCouncilInfo] = useState<{ councilHash: Hash | null; councilId: ProposalIndex | null }>({ councilHash: null, councilId: null });
const [isOpen, toggleOpen] = useToggle(); const [isOpen, toggleOpen] = useToggle();
const [voteValue, setVoteValue] = useState(true); const [voteValue, setVoteValue] = useState(true);
@ -53,10 +53,10 @@ function Voting ({ councilProposals, isDisabled }: Props): React.ReactElement<Pr
const councilProp = councilProposals.find(({ votes }): boolean => !!(votes?.index.eq(optionId))); const councilProp = councilProposals.find(({ votes }): boolean => !!(votes?.index.eq(optionId)));
if (councilProp && councilProp.votes) { if (councilProp && councilProp.votes) {
setCouncilInfo({ councilId: councilProp.votes.index, councilHash: councilProp.hash }); setCouncilInfo({ councilHash: councilProp.hash, councilId: councilProp.votes.index });
setCouncilOptId(councilOptId); setCouncilOptId(councilOptId);
} else { } else {
setCouncilInfo({ councilId: null, councilHash: null }); setCouncilInfo({ councilHash: null, councilId: null });
} }
}; };

View File

@ -32,7 +32,7 @@
"dependencies": { "dependencies": {
"@babel/runtime": "^7.9.2", "@babel/runtime": "^7.9.2",
"@polkadot/api": "^1.9.1", "@polkadot/api": "^1.9.1",
"@polkadot/extension-dapp": "^0.24.0-beta.3", "@polkadot/extension-dapp": "^0.24.0-beta.4",
"rxjs-compat": "^6.5.4" "rxjs-compat": "^6.5.4"
} }
} }

View File

@ -285,7 +285,7 @@ export default function withCall<P extends ApiProps> (endpoint: string, {
} }
public render (): React.ReactNode { public render (): React.ReactNode {
const { callUpdated, callUpdatedAt, callResult } = this.state; const { callResult, callUpdated, callUpdatedAt } = this.state;
const _props = { const _props = {
...this.props, ...this.props,
callUpdated, callUpdated,

View File

@ -75,7 +75,7 @@ export default function withObservable<T, P> (observable: Observable<P>, { callO
public render (): React.ReactNode { public render (): React.ReactNode {
const { children } = this.props; const { children } = this.props;
const { callUpdated, callUpdatedAt, callResult } = this.state; const { callResult, callUpdated, callUpdatedAt } = this.state;
const _props = { const _props = {
...defaultProps, ...defaultProps,
...this.props, ...this.props,

View File

@ -10,24 +10,24 @@ module.exports = {
devtool: isProd ? 'source-map' : 'cheap-eval-source-map', devtool: isProd ? 'source-map' : 'cheap-eval-source-map',
entry: './src/demo.tsx', entry: './src/demo.tsx',
mode: ENV, mode: ENV,
output: {
path: __dirname,
filename: './demo.js'
},
resolve: {
alias: {},
extensions: ['.js', '.jsx', '.ts', '.tsx']
},
module: { module: {
rules: [ rules: [
{ {
test: /\.(js|ts|tsx)$/,
exclude: /(node_modules)/, exclude: /(node_modules)/,
test: /\.(js|ts|tsx)$/,
use: { use: {
loader: 'babel-loader' loader: 'babel-loader'
} }
} }
] ]
}, },
plugins: [] output: {
filename: './demo.js',
path: __dirname
},
plugins: [],
resolve: {
alias: {},
extensions: ['.js', '.jsx', '.ts', '.tsx']
}
}; };

View File

@ -13,10 +13,10 @@
"@babel/runtime": "^7.9.2", "@babel/runtime": "^7.9.2",
"@polkadot/keyring": "^2.7.1", "@polkadot/keyring": "^2.7.1",
"@polkadot/react-api": "0.40.0-beta.224", "@polkadot/react-api": "0.40.0-beta.224",
"@polkadot/react-identicon": "^0.52.0-beta.21", "@polkadot/react-identicon": "^0.52.0-beta.22",
"@polkadot/react-query": "0.40.0-beta.224", "@polkadot/react-query": "0.40.0-beta.224",
"@polkadot/ui-keyring": "^0.52.0-beta.21", "@polkadot/ui-keyring": "^0.52.0-beta.22",
"@polkadot/ui-settings": "^0.52.0-beta.21", "@polkadot/ui-settings": "^0.52.0-beta.22",
"chart.js": "^2.9.3", "chart.js": "^2.9.3",
"codeflask": "^1.4.1", "codeflask": "^1.4.1",
"i18next": "^19.3.3", "i18next": "^19.3.3",

View File

@ -20,12 +20,12 @@ interface Props extends BareProps {
} }
const JUDGEMENT_ENUM = [ const JUDGEMENT_ENUM = [
{ value: 0, text: 'Unknown' }, { text: 'Unknown', value: 0 },
{ value: 1, text: 'Fee paid' }, { text: 'Fee paid', value: 1 },
{ value: 2, text: 'Reasonable' }, { text: 'Reasonable', value: 2 },
{ value: 3, text: 'Known good' }, { text: 'Known good', value: 3 },
{ value: 4, text: 'Out of date' }, { text: 'Out of date', value: 4 },
{ value: 5, text: 'Low quality' } { text: 'Low quality', value: 5 }
]; ];
function AccountNameJudgement ({ address, registrars, toggleJudgement }: Props): React.ReactElement<Props> { function AccountNameJudgement ({ address, registrars, toggleJudgement }: Props): React.ReactElement<Props> {

View File

@ -26,7 +26,7 @@ export const styles = `
${proposedActionStyles} ${proposedActionStyles}
`; `;
function ActionItem ({ className, children, accessory, idNumber, proposal, expandNested }: Props): React.ReactElement<Props> { function ActionItem ({ accessory, children, className, expandNested, idNumber, proposal }: Props): React.ReactElement<Props> {
return ( return (
<Card className={className}> <Card className={className}>
<div className='ui--Row'> <div className='ui--Row'>

View File

@ -129,7 +129,7 @@ function calcBonded (stakingInfo?: DeriveStakingAccount, bonded?: boolean | BN[]
return [own, other]; return [own, other];
} }
function renderExtended ({ balancesAll, address, withExtended }: Props, t: (key: string) => string): React.ReactNode { function renderExtended ({ address, balancesAll, withExtended }: Props, t: (key: string) => string): React.ReactNode {
const extendedDisplay = withExtended === true const extendedDisplay = withExtended === true
? DEFAULT_EXTENDED ? DEFAULT_EXTENDED
: withExtended || undefined; : withExtended || undefined;
@ -343,7 +343,7 @@ function renderBalances (props: Props, allAccounts: string[], t: (key: string) =
function AddressInfo (props: Props): React.ReactElement<Props> { function AddressInfo (props: Props): React.ReactElement<Props> {
const { t } = useTranslation(); const { t } = useTranslation();
const { allAccounts } = useAccounts(); const { allAccounts } = useAccounts();
const { className, children, extraInfo, withBalanceToggle, withHexSessionId } = props; const { children, className, extraInfo, withBalanceToggle, withHexSessionId } = props;
return ( return (
<div className={`ui--AddressInfo ${className} ${withBalanceToggle ? 'ui--AddressInfo-expander' : ''}`}> <div className={`ui--AddressInfo ${className} ${withBalanceToggle ? 'ui--AddressInfo-expander' : ''}`}>

View File

@ -50,8 +50,8 @@ const EMPTY_INFO: DeriveAccountInfo = {
}, },
isCouncil: false, isCouncil: false,
isSociety: false, isSociety: false,
isTechCommittee: false, isSudo: false,
isSudo: false isTechCommittee: false
}; };
class AddressRow extends Row<ApiProps & Props, State> { class AddressRow extends Row<ApiProps & Props, State> {

View File

@ -15,7 +15,7 @@ export interface Props extends BareProps {
params?: AccountId | AccountIndex | Address | string | Uint8Array | null; params?: AccountId | AccountIndex | Address | string | Uint8Array | null;
} }
function AvailableDisplay ({ params, className, label, style }: Props): React.ReactElement<Props> | null { function AvailableDisplay ({ className, label, params, style }: Props): React.ReactElement<Props> | null {
if (!params) { if (!params) {
return null; return null;
} }

Some files were not shown because too many files have changed in this diff Show More