Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #71 from paritytech/w3f-deploy-1.4.0
Browse files Browse the repository at this point in the history
v1.4.0
  • Loading branch information
miabarbir authored Apr 18, 2024
2 parents 4e9a3ab + b014bb0 commit c539124
Show file tree
Hide file tree
Showing 50 changed files with 852 additions and 1,363 deletions.
25 changes: 0 additions & 25 deletions CHANGELOG.md

This file was deleted.

29 changes: 29 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Changelog

## [1.4.0](https://github.com/paritytech/polkadot-staking-dashboard/compare/v1.3.1...v1.4.0) (2024-04-18)


### Features

* **refactor:** Network as arg for vault & ledger account API ([#2083](https://github.com/paritytech/polkadot-staking-dashboard/issues/2083)) ([6a01661](https://github.com/paritytech/polkadot-staking-dashboard/commit/6a01661ae6cc03eb8c8bc8bc0448b5435a583ca3))
* **refactor:** Use `stringToBigNumber` from `@w3ux/utils` ([#2085](https://github.com/paritytech/polkadot-staking-dashboard/issues/2085)) ([4425227](https://github.com/paritytech/polkadot-staking-dashboard/commit/44252276b95519fc87be89646917eb5fb55680f4))
* **refactor:** Use formatAccountSs58 util ([#2084](https://github.com/paritytech/polkadot-staking-dashboard/issues/2084)) ([ebcc9c6](https://github.com/paritytech/polkadot-staking-dashboard/commit/ebcc9c66babf6b2ce6b3959bf66041d899d2c795))
* **refactor:** VaultAccountsProvider to w3ux ([#2082](https://github.com/paritytech/polkadot-staking-dashboard/issues/2082)) ([a26cda7](https://github.com/paritytech/polkadot-staking-dashboard/commit/a26cda7597e05b53f846ae0e535163ca890e4783))


### Bug Fixes

* Fix free balances (Overview & Nominate) ([#2075](https://github.com/paritytech/polkadot-staking-dashboard/issues/2075)) ([44c6bcd](https://github.com/paritytech/polkadot-staking-dashboard/commit/44c6bcdd94b1bb15b8c80c6cd06bf3f6acc90aab))
* **manage-nominations:** Revert changes behavior in Manage nominations ([#2077](https://github.com/paritytech/polkadot-staking-dashboard/issues/2077)) ([a5bc9e9](https://github.com/paritytech/polkadot-staking-dashboard/commit/a5bc9e91dee0a4412b449158d8eeca34c5d20e05))
* **pools:** don't unsubscribe from ActivePools ([#2080](https://github.com/paritytech/polkadot-staking-dashboard/issues/2080)) ([7f3d3a6](https://github.com/paritytech/polkadot-staking-dashboard/commit/7f3d3a62425c0502291d13695bec435fb3f69b67))
* Search filters fix ([#2087](https://github.com/paritytech/polkadot-staking-dashboard/issues/2087)) ([adfd8ec](https://github.com/paritytech/polkadot-staking-dashboard/commit/adfd8ec5659082877fac872f841754d78296b449))
* Show border bottom only if dashboard tips is shown ([#2076](https://github.com/paritytech/polkadot-staking-dashboard/issues/2076)) ([459da24](https://github.com/paritytech/polkadot-staking-dashboard/commit/459da2477b5f1e032cf974ccb819be85a7a682be))
* use transient prop for styled components ([#2081](https://github.com/paritytech/polkadot-staking-dashboard/issues/2081)) ([f2a0d73](https://github.com/paritytech/polkadot-staking-dashboard/commit/f2a0d73a172d815cd8d12207320947b82a24dc99))


## [1.3.1](https://github.com/paritytech/polkadot-staking-dashboard/compare/v1.3.0...v1.3.1) (2024-04-09)


### Features

* **ux:** Simplify pool list, fetch performance on More ([#2070](https://github.com/paritytech/polkadot-staking-dashboard/issues/2070)) ([fb5008d](https://github.com/paritytech/polkadot-staking-dashboard/commit/fb5008d0ebae166943ee6b3749f4c350758c9315))


## [1.3.0](https://github.com/paritytech/polkadot-staking-dashboard/compare/v1.2.1...v1.3.0) (2024-04-08)


Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polkadot-staking-dashboard",
"version": "1.3.0",
"version": "1.4.0",
"type": "module",
"license": "GPL-3.0-only",
"scripts": {
Expand Down Expand Up @@ -36,10 +36,10 @@
"@substrate/connect": "0.7.35",
"@w3ux/extension-assets": "0.2.6",
"@w3ux/hooks": "^0.0.3",
"@w3ux/react-connect-kit": "0.1.8",
"@w3ux/react-connect-kit": "^0.1.16",
"@w3ux/react-odometer": "^0.0.3",
"@w3ux/react-polkicon": "^0.0.2",
"@w3ux/utils": "^0.0.2",
"@w3ux/react-polkicon": "^0.0.3",
"@w3ux/utils": "0.1.1",
"@w3ux/validator-assets": "^0.0.4",
"@zondax/ledger-substrate": "^0.41.4",
"bignumber.js": "^9.1.2",
Expand Down
19 changes: 7 additions & 12 deletions src/Providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {
ExtensionsProvider,
ExtensionAccountsProvider,
LedgerAccountsProvider,
VaultAccountsProvider,
} from '@w3ux/react-connect-kit';
import { FastUnstakeProvider } from 'contexts/FastUnstake';
import { FiltersProvider } from 'contexts/Filters';
import { LedgerHardwareProvider } from 'contexts/Hardware/Ledger/LedgerHardware';
import { VaultAccountsProvider } from 'contexts/Hardware/Vault/VaultAccounts';
import { LedgerHardwareProvider } from 'contexts/LedgerHardware';
import { HelpProvider } from 'contexts/Help';
import { MenuProvider } from 'contexts/Menu';
import { MigrateProvider } from 'contexts/Migrate';
Expand Down Expand Up @@ -48,17 +48,13 @@ import { OverlayProvider } from 'kits/Overlay/Provider';
import { JoinPoolsProvider } from 'contexts/Pools/JoinPools';

export const Providers = () => {
const {
network,
networkData: { ss58 },
} = useNetwork();
const { network } = useNetwork();
const { activeAccount, setActiveAccount } = useActiveAccounts();

// !! Provider order matters.
const providers: Provider[] = [
UIProvider,
[APIProvider, { network }],
VaultAccountsProvider,
LedgerHardwareProvider,
[
ExtensionsProvider,
Expand All @@ -67,20 +63,19 @@ export const Providers = () => {
[
ExtensionAccountsProvider,
{
ss58,
dappName: DappName,
network,
activeAccount,
setActiveAccount,
dappName: DappName,
// Successful extension enabled event.
setActiveAccount, // Successful extension enabled event.
onExtensionEnabled: (id: string) => {
registerSaEvent(`${network.toLowerCase()}_extension_connected`, {
id,
});
},
},
],
[LedgerAccountsProvider, { network }],
VaultAccountsProvider,
LedgerAccountsProvider,
ExternalAccountsProvider,
OtherAccountsProvider,
ImportedAccountsProvider,
Expand Down
6 changes: 3 additions & 3 deletions src/canvas/ManageNominations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const ManageNominations = () => {
// Default nominators, from canvas options.
const [defaultNominations, setDefaultNominations] =
useState<NominationSelectionWithResetCounter>({
nominations: options?.nominated || [],
nominations: [...(options?.nominated || [])],
reset: 0,
});

Expand All @@ -70,7 +70,7 @@ export const ManageNominations = () => {

// Handler for reverting nomination updates.
const handleRevertChanges = () => {
setNewNominations({ nominations: defaultNominations.nominations });
setNewNominations({ nominations: [...defaultNominations.nominations] });
setDefaultNominations({
nominations: defaultNominations.nominations,
reset: defaultNominations.reset + 1,
Expand Down Expand Up @@ -194,7 +194,7 @@ export const ManageNominations = () => {
set: handleSetupUpdate,
},
]}
nominations={defaultNominations}
nominations={newNominations}
/>
</CanvasFullScreenWrapper>
<CanvasSubmitTxFooter>
Expand Down
2 changes: 1 addition & 1 deletion src/config/ledger.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2024 @paritytech/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import type { LedgerApp } from 'contexts/Hardware/Ledger/types';
import type { LedgerApp } from 'contexts/LedgerHardware/types';
import KusamaSVG from 'img/appIcons/kusama.svg?react';
import PolkadotSVG from 'img/appIcons/polkadot.svg?react';

Expand Down
2 changes: 1 addition & 1 deletion src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { stringToU8a } from '@polkadot/util';
/*
* Global Constants
*/
export const AppVersion = '1.1.6';
export const AppVersion = '1.3.1';
export const DappName = 'Polkadot Staking Dashboard';
export const PolkadotUrl = 'https://polkadot.network/features/staking/';
export const ManualSigners = ['ledger', 'vault'];
Expand Down
10 changes: 9 additions & 1 deletion src/contexts/Connect/ImportedAccounts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type { ImportedAccountsContextInterface } from './types';
import { useOtherAccounts } from '../OtherAccounts';
import { BalancesController } from 'controllers/BalancesController';
import { useApi } from 'contexts/Api';
import { useNetwork } from 'contexts/Network';

export const ImportedAccountsContext =
createContext<ImportedAccountsContextInterface>(
Expand All @@ -30,8 +31,15 @@ export const ImportedAccountsProvider = ({
children: ReactNode;
}) => {
const { isReady, api } = useApi();
const {
networkData: { ss58 },
} = useNetwork();
const { otherAccounts } = useOtherAccounts();
const { extensionAccounts } = useExtensionAccounts();
const { getExtensionAccounts } = useExtensionAccounts();

// Get the imported extension accounts formatted with the current network's ss58 prefix.
const extensionAccounts = getExtensionAccounts(ss58);

const allAccounts = extensionAccounts.concat(otherAccounts);

// Stringify account addresses and account names to determine if they have changed. Ignore other properties including `signer` and `source`.
Expand Down
8 changes: 3 additions & 5 deletions src/contexts/Connect/OtherAccounts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

import type { ReactNode } from 'react';
import { createContext, useContext, useEffect, useRef, useState } from 'react';
import {
getLocalLedgerAccounts,
getLocalVaultAccounts,
} from 'contexts/Hardware/Utils';
import type { MaybeAddress, NetworkName } from 'types';
import { setStateWithRef } from '@w3ux/utils';
import { useNetwork } from 'contexts/Network';
Expand All @@ -22,6 +18,8 @@ import { useEventListener } from 'usehooks-ts';
import { useExtensionAccounts, useExtensions } from '@w3ux/react-connect-kit';
import type { ImportedAccount } from '@w3ux/react-connect-kit/types';
import { useEffectIgnoreInitial } from '@w3ux/hooks';
import { getLocalVaultAccounts } from '@w3ux/react-connect-kit/VaultAccountsProvider/utils';
import { getLocalLedgerAccounts } from '@w3ux/react-connect-kit/LedgerAccountsProvider/utils';

export const OtherAccountsContext =
createContext<OtherAccountsContextInterface>(defaultOtherAccountsContext);
Expand Down Expand Up @@ -197,7 +195,7 @@ export const OtherAccountsProvider = ({
// Finally, fetch any read-only accounts that have been added by `system` or `user`.
importLocalOtherAccounts(getLocalExternalAccounts);
}
}, [extensionAccountsSynced]);
}, [network, extensionAccountsSynced]);

// Account fetching complete, mark accounts as initialised. Does not include read only accounts.
useEffectIgnoreInitial(() => {
Expand Down
16 changes: 0 additions & 16 deletions src/contexts/Connect/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,3 @@ export const getActiveAccountLocal = (network: NetworkName, ss58: number) => {
}
return account;
};

// Formats an address with the supplied ss58 prefix.
export const formatAccountSs58 = (address: string, ss58: number) => {
try {
const keyring = new Keyring();
keyring.setSS58Format(ss58);
const formatted = keyring.addFromAddress(address).address;
if (formatted !== address) {
return formatted;
}

return null;
} catch (e) {
return null;
}
};
11 changes: 11 additions & 0 deletions src/contexts/Filters/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,14 @@ export const FiltersProvider = ({ children }: { children: ReactNode }) => {
if (o === 'default') {
newOrders = [...orders].filter((order) => order.key !== g);
} else if (orders.length) {
// Attempt to replace the order record if it exists.
newOrders = [...orders].map((order) =>
order.key !== g ? order : { ...order, order: o }
);
// If order for this key does not exist, add it.
if (newOrders.find(({ key }) => key === g) === undefined) {
newOrders.push({ key: g, order: o });
}
} else {
newOrders = [{ key: g, order: o }];
}
Expand All @@ -151,9 +156,15 @@ export const FiltersProvider = ({ children }: { children: ReactNode }) => {
const setSearchTerm = (g: string, t: string) => {
let newSearchTerms = [];
if (orders.length) {
// Attempt to replace the search term if it exists.
newSearchTerms = [...searchTerms].map((term) =>
term.key !== g ? term : { ...term, searchTerm: t }
);

// If search term for this key does not exist, add it.
if (newSearchTerms.find(({ key }) => key === g) === undefined) {
newSearchTerms.push({ key: g, searchTerm: t });
}
} else {
newSearchTerms = [{ key: g, searchTerm: t }];
}
Expand Down
Loading

0 comments on commit c539124

Please sign in to comment.