Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase master #33

Merged
merged 5 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr-any.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
continue-on-error: true
strategy:
matrix:
step: ['lint', 'test', 'build:code', 'build:i18n', 'build:electron']
step: ['lint', 'test', 'build:code']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
7 changes: 6 additions & 1 deletion packages/apps-config/src/endpoints/development.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import type { TFunction } from '../types.js';
import type { LinkOption } from './types.js';

import { nodesAvailPNG } from '../ui/logos/nodes/index.js';

export const CUSTOM_ENDPOINT_KEY = 'polkadot-app-custom-endpoints';

interface EnvWindow {
Expand Down Expand Up @@ -71,7 +73,10 @@ export function createDev (t: TFunction): LinkOption[] {
info: 'local',
text: t('rpc.dev.local', 'Local Node', { ns: 'apps-config' }),
textBy: '127.0.0.1:9944',
ui: {},
ui: {
color: '#1B1E26',
logo: nodesAvailPNG
},
value: 'ws://127.0.0.1:9944'
}
];
Expand Down
2 changes: 0 additions & 2 deletions packages/apps-config/src/endpoints/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import type { EndpointOption } from './types.js';

// import { chains3dpassSVG, chainsAcalaSVG, chainsAlephSVG, chainsBrainstormPNG, chainsCreditcoinTestPNG, chainsDebioSVG, chainsEquilibriumSVG, chainsFerrumPNG, chainsFragnovaPNG, chainsJurPNG, chainsKintsugiPNG, chainsLogionPNG, chainsMyriadPNG, chainsShidenPNG, chainsSkyekiwiPNG, chainsTanglePNG } from '../ui/logos/chains/index.js';
// import { nodesAjunaPNG, nodesArcticPNG, nodesAresGladiosSVG, nodesAutomataPNG, nodesBifrostSVG, nodesBitcountryPNG, nodesCereSVG, nodesCessPNG, nodesCloverSVG, nodesCrustMaxwellSVG, nodesCurioSVG, nodesDatahighwayPNG, nodesDockPNG, nodesDolphinSVG, nodesDotmogSVG, nodesEdgewareWhitePNG, nodesEncointerBlueSVG, nodesFantourPNG, nodesGalitalLogoPNG, nodesGamepowerSVG, nodesGeekSVG, nodesInterlaySVG, nodesIpsePNG, nodesJazPNG, nodesJupiterSVG, nodesKarmachainSVG, nodesKhalaSVG, nodesKiltPNG, nodesKlugPNG, nodesKylinPNG, nodesLaminarCircleSVG, nodesLitentryPNG, nodesMantaPNG, nodesMathSVG, nodesMinixPNG, nodesMoonbaseAlphaSVG, nodesMybankPNG, nodesNftmartPNG, nodesNodleSVG, nodesOpalLogoPNG, nodesOpportunityPNG, nodesPangoroSVG, nodesPhalaSVG, nodesPhoenixPNG, nodesPichiuPNG, nodesPolkadexSVG, nodesPolkafoundrySVG, nodesPolymeshSVG, nodesPontemSVG, nodesPrismPNG, nodesRealisPNG, nodesRiochainSVG, nodesSherpaxPNG, nodesSoonsocialPNG, nodesSoraSubstrateSVG, nodesSubdaoPNG, nodesSubgameSVG, nodesSubspacePNG, nodesSubstrateHexagonSVG, nodesTernoaSVG, nodesThebifrostPNG, nodesUniartsPNG, nodesUniqueSVG, nodesUnitnetworkPNG, nodesWeb3gamesSVG, nodesZCloakSVG } from '../ui/logos/nodes/index.js';

// export * from './testingRelayRococo.js';
// export * from './testingRelayWestend.js';

import { nodesAvailPNG } from '../ui/logos/nodes/index.js';
import config from '../variables/config.js';

Expand Down
8 changes: 4 additions & 4 deletions packages/apps-config/src/variables/config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright 2017-2023 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0

const LCURL = process.env['LCURL'] as string || 'https://kate.avail.tools'
const TESTNETURL = process.env['TESTNETURL'] as `wss://${string}` || 'wss://kate.avail.tools/ws'
const LCURL = process.env.LCURL as string || 'https://kate.avail.tools';
const TESTNETURL = process.env.TESTNETURL as `wss://${string}` || 'wss://kate.avail.tools/ws';

const config = {
LCURL,
TESTNETURL
}
};

export default config
export default config;
22 changes: 11 additions & 11 deletions packages/apps/src/Endpoints/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import { Button, Input, Sidebar, styled } from '@polkadot/react-components';
import { settings } from '@polkadot/ui-settings';
import { isAscii } from '@polkadot/util';

import config from '../../../apps-config/src/variables/config.js';
import { useTranslation } from '../translate.js';
import GroupDisplay from './Group.js';

import config from '../../../apps-config/src/variables/config.js';

interface Props {
className?: string;
offset?: number | string;
Expand All @@ -40,7 +39,7 @@ interface LcUrlState {

const STORAGE_AFFINITIES = 'network:affinities';

function isValidUrl(url: string): boolean {
function isValidUrl (url: string): boolean {
return (
// some random length... we probably want to parse via some lib
(url.length >= 7) &&
Expand All @@ -49,7 +48,7 @@ function isValidUrl(url: string): boolean {
);
}

function isValidHttpUrl(url: string): boolean {
function isValidHttpUrl (url: string): boolean {
return (
// some random length... we probably want to parse via some lib
(url.length >= 7) &&
Expand All @@ -58,7 +57,7 @@ function isValidHttpUrl(url: string): boolean {
);
}

function combineEndpoints(endpoints: LinkOption[]): Group[] {
function combineEndpoints (endpoints: LinkOption[]): Group[] {
return endpoints.reduce((result: Group[], e): Group[] => {
if (e.isHeader) {
result.push({ header: e.text, isDevelopment: e.isDevelopment, isSpaced: e.isSpaced, networks: [] });
Expand All @@ -85,7 +84,7 @@ function combineEndpoints(endpoints: LinkOption[]): Group[] {
}, []);
}

function getCustomEndpoints(): string[] {
function getCustomEndpoints (): string[] {
try {
const storedAsset = localStorage.getItem(CUSTOM_ENDPOINT_KEY);

Expand All @@ -100,7 +99,7 @@ function getCustomEndpoints(): string[] {
return [];
}

function extractUrlState(apiUrl: string, groups: Group[]): UrlState {
function extractUrlState (apiUrl: string, groups: Group[]): UrlState {
let groupIndex = groups.findIndex(({ networks }) =>
networks.some(({ providers }) =>
providers.some(({ url }) => url === apiUrl)
Expand All @@ -119,7 +118,7 @@ function extractUrlState(apiUrl: string, groups: Group[]): UrlState {
};
}

function extractLcUrlState(lcUrl: string | null, groups: Group[]): LcUrlState {
function extractLcUrlState (lcUrl: string | null, groups: Group[]): LcUrlState {
let lcGroupIndex = groups.findIndex(({ networks }) =>
networks.some(({ providers }) =>
providers.some(({ url }) => url === lcUrl)
Expand All @@ -132,6 +131,7 @@ function extractLcUrlState(lcUrl: string | null, groups: Group[]): LcUrlState {

if (lcUrl === null) {
const lcU = `${config.LCURL}/json-rpc`;

lcUrl = lcU;
}

Expand All @@ -142,7 +142,7 @@ function extractLcUrlState(lcUrl: string | null, groups: Group[]): LcUrlState {
};
}

function loadAffinities(groups: Group[]): Record<string, string> {
function loadAffinities (groups: Group[]): Record<string, string> {
return Object
.entries<string>(store.get(STORAGE_AFFINITIES) as Record<string, string> || {})
.filter(([network, apiUrl]) =>
Expand All @@ -158,7 +158,7 @@ function loadAffinities(groups: Group[]): Record<string, string> {
}), {});
}

function isSwitchDisabled(hasUrlChanged: boolean, apiUrl: string, isUrlValid: boolean): boolean {
function isSwitchDisabled (hasUrlChanged: boolean, apiUrl: string, isUrlValid: boolean): boolean {
if (!hasUrlChanged) {
return true;
} else if (apiUrl.startsWith('light://')) {
Expand All @@ -170,7 +170,7 @@ function isSwitchDisabled(hasUrlChanged: boolean, apiUrl: string, isUrlValid: bo
return true;
}

function Endpoints({ className = '', offset, onClose }: Props): React.ReactElement<Props> {
function Endpoints ({ className = '', offset, onClose }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const linkOptions = createWsEndpoints(t);
const [groups, setGroups] = useState(() => combineEndpoints(linkOptions));
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/src/initSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { assert } from '@polkadot/util';

import config from '../../apps-config/src/variables/config.js';

function networkOrUrl(apiUrl: string, lcUrl: string): void {
function networkOrUrl (apiUrl: string, lcUrl: string): void {
if (apiUrl.startsWith('light://')) {
console.log('Light endpoint=', apiUrl.replace('light://', ''));
} else {
Expand All @@ -21,7 +21,7 @@ function networkOrUrl(apiUrl: string, lcUrl: string): void {
console.log('LC endpoint=', lcUrl);
}

function getApiUrl(): string {
function getApiUrl (): string {
// we split here so that both these forms are allowed
// - http://localhost:3000/?rpc=wss://substrate-rpc.parity.io/#/explorer
// - http://localhost:3000/#/explorer?rpc=wss://substrate-rpc.parity.io
Expand Down
81 changes: 39 additions & 42 deletions packages/page-accounts/src/Accounts/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,45 @@ function Summary ({ balance, className }: Props) {

return (
<SummaryBox className={className}>
<CardSummary label={t<string>('total balance')}>
<FormatBalance
className={balance ? '' : '--tmp'}
value={balance?.total || 1}
/>
</CardSummary>
<CardSummary
className='media--900'
label={t<string>('total transferrable')}
>
<FormatBalance
className={balance ? '' : '--tmp'}
value={balance?.transferrable || 1}
/>
</CardSummary>
<CardSummary label={t<string>('total locked')}>
<FormatBalance
className={balance ? '' : '--tmp'}
value={balance?.locked || 1}
/>
</CardSummary>
{balance?.bonded.gtn(0) &&
<CardSummary
className='media--1100'
label={t<string>('bonded')}
>
<FormatBalance value={balance.bonded} />
</CardSummary>}
{balance?.redeemable.gtn(0) &&
<CardSummary
className='media--1500'
label={t<string>('redeemable')}
>
<FormatBalance value={balance.redeemable} />
</CardSummary>}
{balance?.unbonding.gtn(0) &&
<CardSummary
className='media--1300'
label={t<string>('unbonding')}
>
<FormatBalance value={balance.unbonding} />
</CardSummary>}
{balance && (
<>
{balance.total.gtn(0) &&
<CardSummary label={t<string>('total balance')}>
<FormatBalance value={balance.total} />
</CardSummary>}
{balance.transferrable.gtn(0) &&
<CardSummary
className='media--900'
label={t<string>('total transferrable')}
>
<FormatBalance value={balance.transferrable} />
</CardSummary>}
{balance.locked.gtn(0) &&
<CardSummary label={t<string>('total locked')}>
<FormatBalance value={balance.locked} />
</CardSummary>}
{balance.bonded.gtn(0) &&
<CardSummary
className='media--1100'
label={t<string>('bonded')}
>
<FormatBalance value={balance.bonded} />
</CardSummary>}
{balance.redeemable.gtn(0) &&
<CardSummary
className='media--1500'
label={t<string>('redeemable')}
>
<FormatBalance value={balance.redeemable} />
</CardSummary>}
{balance.unbonding.gtn(0) &&
<CardSummary
className='media--1300'
label={t<string>('unbonding')}
>
<FormatBalance value={balance.unbonding} />
</CardSummary>}
</>)}
</SummaryBox>
);
}
Expand Down
40 changes: 18 additions & 22 deletions packages/page-accounts/src/Accounts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'

import { Button, FilterInput, SortDropdown, styled, SummaryBox, Table } from '@polkadot/react-components';
import { getAccountCryptoType } from '@polkadot/react-components/util';
import { useAccounts, useApi, useDelegations, useFavorites, useIpfs, useLedger, useNextTick, useProxies, useToggle } from '@polkadot/react-hooks';
import { useAccounts, useApi, useDelegations, useFavorites, useLedger, useNextTick, useProxies, useToggle } from '@polkadot/react-hooks';
import { keyring } from '@polkadot/ui-keyring';
import { settings } from '@polkadot/ui-settings';
// import { settings } from '@polkadot/ui-settings';
import { BN_ZERO, isFunction } from '@polkadot/util';

import CreateModal from '../modals/Create.js';
Expand Down Expand Up @@ -89,9 +89,9 @@ function groupAccounts (accounts: SortedAccount[]): Record<GroupName, string[]>

function Overview ({ className = '', onStatusChange }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { api, isElectron } = useApi();
const { api } = useApi();
const { allAccounts, hasAccounts } = useAccounts();
const { isIpfs } = useIpfs();
// const { isIpfs } = useIpfs();
const { isLedgerEnabled } = useLedger();
const [isCreateOpen, toggleCreate] = useToggle();
const [isImportOpen, toggleImport] = useToggle();
Expand Down Expand Up @@ -143,10 +143,10 @@ function Overview ({ className = '', onStatusChange }: Props): React.ReactElemen
[]
);

const canStoreAccounts = useMemo(
() => isElectron || (!isIpfs && settings.get().storage === 'on'),
[isElectron, isIpfs]
);
// const canStoreAccounts = useMemo(
// () => isElectron || (!isIpfs && settings.get().storage === 'on'),
// [isElectron, isIpfs]
// );

// We use favorites only to check if it includes some element,
// so Object is better than array for that because hashmap access is O(1).
Expand Down Expand Up @@ -333,20 +333,16 @@ function Overview ({ className = '', onStatusChange }: Props): React.ReactElemen
/>
</section>
<Button.Group>
{canStoreAccounts && (
<>
<Button
icon='plus'
label={t<string>('Account')}
onClick={toggleCreate}
/>
<Button
icon='sync'
label={t<string>('From JSON')}
onClick={toggleImport}
/>
</>
)}
<Button
icon='plus'
label={t<string>('Account')}
onClick={toggleCreate}
/>
<Button
icon='sync'
label={t<string>('From JSON')}
onClick={toggleImport}
/>
<Button
icon='qrcode'
label={t<string>('From Qr')}
Expand Down
6 changes: 3 additions & 3 deletions packages/page-explorer/src/BlockInfo/ByHash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { HeaderExtended } from '@polkadot/api-derive/types';
import type { KeyedEvent } from '@polkadot/react-hooks/ctx/types';
import type { EventRecord, RuntimeVersionPartial, SignedBlock } from '@polkadot/types/interfaces';

import axios from 'axios';
import React, { useEffect, useMemo, useState } from 'react';
import { Link } from 'react-router-dom';

Expand All @@ -13,16 +14,14 @@ import { useApi, useIsMountedRef } from '@polkadot/react-hooks';
import { convertWeight } from '@polkadot/react-hooks/useWeight';
import { formatNumber } from '@polkadot/util';

import config from '../../../apps-config/src/variables/config.js';
import Events from '../Events.js';
import { useTranslation } from '../translate.js';
import Extrinsics from './Extrinsics.js';
import Justifications from './Justifications.js';
import Logs from './Logs.js';
import Summary from './Summary.js';

import axios from 'axios';
import config from '../../../apps-config/src/variables/config.js';

interface Props {
className?: string;
error?: Error | null;
Expand Down Expand Up @@ -132,6 +131,7 @@ function BlockByHash ({ className = '', error, value }: Props): React.ReactEleme
return;
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
setConfidence(v.data.confidence);
}).catch((_) => {
setConfidence('ℹ️ Make sure Light Client runs on ' + LightClientURI);
Expand Down
7 changes: 4 additions & 3 deletions packages/react-components/src/Inspect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ interface Inspected {
value: string;
}

function formatInspect({ inner = [], name = '', outer = [] }: Inspect, result: Inspected[] = []): Inspected[] {
function formatInspect ({ inner = [], name = '', outer = [] }: Inspect, result: Inspected[] = []): Inspected[] {
if (outer.length) {
const value = new Array<string>(outer.length);

for (let i = 0; i < outer.length; i++) {
if (name !== "appId") {
if (name !== 'appId') {
value[i] = u8aToHex(outer[i], undefined, false);
} else {
const hexAppId = u8aToHex(outer[i], undefined, false);
const appId = parseInt(hexAppId, 16) >> 2;

value[i] = appId.toString();
}
}
Expand All @@ -48,7 +49,7 @@ function formatInspect({ inner = [], name = '', outer = [] }: Inspect, result: I
return result;
}

function DecodedInspect({ className, hex, inspect, label }: Props): React.ReactElement<Props> | null {
function DecodedInspect ({ className, hex, inspect, label }: Props): React.ReactElement<Props> | null {
const { t } = useTranslation();
const { createLink } = useApi();
const formatted = useMemo(
Expand Down
Loading