Skip to content

Commit

Permalink
feat(refactor): Use re-exported @polkadot utils. (#2267)
Browse files Browse the repository at this point in the history
  • Loading branch information
rossbulat authored Oct 3, 2024
1 parent 2dd645a commit 63d0b55
Show file tree
Hide file tree
Showing 15 changed files with 189 additions and 208 deletions.
14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,17 @@
"@fortawesome/free-solid-svg-icons": "^6.5.2",
"@fortawesome/react-fontawesome": "^0.2.2",
"@ledgerhq/hw-transport-webhid": "^6.29.2",
"@polkadot-api/merkleize-metadata": "^1.1.2",
"@polkadot/api": "^12.2.3",
"@polkadot/rpc-provider": "^12.2.3",
"@polkadot/util": "^13.0.2",
"@polkadot/util-crypto": "^13.0.2",
"@polkadot-api/merkleize-metadata": "^1.1.4",
"@polkadot/api": "^14.0.1",
"@polkadot/rpc-provider": "^14.0.1",
"@polkawatch/ddp-client": "^2.0.16",
"@substrate/connect": "^1.1.0",
"@w3ux/extension-assets": "0.3.1",
"@w3ux/hooks": "1.1.0",
"@w3ux/react-connect-kit": "1.6.0",
"@w3ux/react-connect-kit": "^1.7.0",
"@w3ux/react-odometer": "1.1.0",
"@w3ux/react-polkicon": "1.2.0",
"@w3ux/utils": "0.7.0",
"@w3ux/react-polkicon": "1.3.0",
"@w3ux/utils": "0.9.0",
"@w3ux/validator-assets": "^0.2.0",
"@zondax/ledger-substrate": "^0.44.7",
"bignumber.js": "^9.1.2",
Expand Down
2 changes: 1 addition & 1 deletion src/consts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import { stringToU8a } from '@polkadot/util';
import { stringToU8a } from '@w3ux/utils/util';

/*
* Global Constants
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/Api/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */

import { stringToU8a } from '@polkadot/util';
import { stringToU8a } from '@w3ux/utils/util';
import BigNumber from 'bignumber.js';
import type {
APIActiveEra,
Expand Down
3 changes: 1 addition & 2 deletions src/contexts/Api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: GPL-3.0-only

import type { ApiPromise } from '@polkadot/api';
import type { U8aLike } from '@polkadot/util/types';
import type BigNumber from 'bignumber.js';
import type { ReactNode } from 'react';
import type { NetworkName } from '../../types';
Expand Down Expand Up @@ -31,7 +30,7 @@ export interface APIConstants {
epochDuration: BigNumber;
existentialDeposit: BigNumber;
fastUnstakeDeposit: BigNumber;
poolsPalletId: U8aLike;
poolsPalletId: number[] | Uint8Array | string;
}

export interface APINetworkMetrics {
Expand Down
2 changes: 1 addition & 1 deletion src/contexts/Pools/BondedPools/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import { u8aToString, u8aUnwrapBytes } from '@polkadot/util';
import { u8aToString, u8aUnwrapBytes } from '@w3ux/utils/util';
import { rmCommas, setStateWithRef, shuffle } from '@w3ux/utils';
import type { ReactNode } from 'react';
import { createContext, useContext, useRef, useState } from 'react';
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useBuildPayload/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { merkleizeMetadata } from '@polkadot-api/merkleize-metadata';
import type { ApiPromise } from '@polkadot/api';
import { objectSpread, u8aToHex } from '@polkadot/util';
import { objectSpread, u8aToHex } from '@w3ux/utils/util';
import type { AnyJson } from '@w3ux/types';
import { useApi } from 'contexts/Api';
import { useBalances } from 'contexts/Balances';
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useCreatePoolAccounts/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import { bnToU8a, u8aConcat } from '@polkadot/util';
import { bnToU8a, u8aConcat } from '@w3ux/utils/util';
import BigNumber from 'bignumber.js';
import { BN } from 'bn.js';
import { EmptyH256, ModPrefix, U32Opts } from 'consts';
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useValidatorFilters/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import { u8aToString, u8aUnwrapBytes } from '@polkadot/util';
import { u8aToString, u8aUnwrapBytes } from '@w3ux/utils/util';
import { useTranslation } from 'react-i18next';
import { useValidators } from 'contexts/Validators/ValidatorEntries';
import type { AnyFunction, AnyJson } from '@w3ux/types';
Expand Down
2 changes: 1 addition & 1 deletion src/library/Account/PoolAccount.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import { u8aToString, u8aUnwrapBytes } from '@polkadot/util';
import { u8aToString, u8aUnwrapBytes } from '@w3ux/utils/util';
import { ellipsisFn, remToUnit } from '@w3ux/utils';
import { useTranslation } from 'react-i18next';
import { useBondedPools } from 'contexts/Pools/BondedPools';
Expand Down
4 changes: 2 additions & 2 deletions src/library/QRCode/Display.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import { objectSpread } from '@polkadot/util';
import { xxhashAsHex } from '@polkadot/util-crypto';
import { objectSpread } from '@w3ux/utils/util';
import { xxhashAsHex } from '@w3ux/utils/util-crypto';
import type { ReactElement } from 'react';
import { memo, useEffect, useMemo, useRef, useState } from 'react';
import { DisplayWrapper } from './Wrappers.js';
Expand Down
3 changes: 1 addition & 2 deletions src/library/QRCode/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import type { HexString } from '@polkadot/util/types';
import type { CSSProperties } from 'react';

export interface FrameState {
Expand All @@ -12,7 +11,7 @@ export interface FrameState {
}

export interface ScanType {
signature: HexString;
signature: `0x${string}`;
}

export interface TimerState {
Expand Down
4 changes: 2 additions & 2 deletions src/library/QRCode/util.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import { isString, u8aConcat, u8aToU8a } from '@polkadot/util';
import { decodeAddress } from '@polkadot/util-crypto';
import { isString, u8aConcat, u8aToU8a } from '@w3ux/utils/util';
import { decodeAddress } from '@w3ux/utils/util-crypto';
import { CRYPTO_SR25519, FRAME_SIZE, SUBSTRATE_ID } from './constants.js';

const MULTIPART = new Uint8Array([0]);
Expand Down
2 changes: 1 addition & 1 deletion src/library/ValidatorList/ValidatorItem/Utils.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import { u8aToString, u8aUnwrapBytes } from '@polkadot/util';
import { u8aToString, u8aUnwrapBytes } from '@w3ux/utils/util';
import type BigNumber from 'bignumber.js';
import { MaxEraRewardPointsEras } from 'consts';
import type { AnyJson } from '@w3ux/types';
Expand Down
2 changes: 1 addition & 1 deletion src/modals/ManagePool/Forms/RenamePool/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only

import { faChevronLeft } from '@fortawesome/free-solid-svg-icons';
import { u8aToString, u8aUnwrapBytes } from '@polkadot/util';
import { u8aToString, u8aUnwrapBytes } from '@w3ux/utils/util';
import type { Dispatch, FormEvent, SetStateAction } from 'react';
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
Expand Down
Loading

0 comments on commit 63d0b55

Please sign in to comment.