Skip to content

Commit

Permalink
[chore] Update dependencies (#1548)
Browse files Browse the repository at this point in the history
* update dependencies

* chore: bump dependencies

* chore: update dependencies and fix type errors

* chore: update dependencies

* remove redundant resolutions

* wip: try setting node options in package

* Trigger build

* update caniuse db

* fix: revert type casting

* chore: bump bridge version

* fix: xcm breaking changes

* fix: correct XCM adapter
  • Loading branch information
tomjeatt authored Sep 28, 2023
1 parent aba10b4 commit 6626850
Show file tree
Hide file tree
Showing 12 changed files with 2,525 additions and 558 deletions.
35 changes: 10 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"@craco/craco": "^6.1.1",
"@headlessui/react": "^1.1.1",
"@heroicons/react": "^2.0.18",
"@interlay/bridge": "^0.3.13",
"@interlay/interbtc-api": "2.4.3",
"@interlay/bridge": "^0.4.0",
"@interlay/interbtc-api": "2.5.1",
"@interlay/monetary-js": "0.7.3",
"@polkadot/api": "9.14.2",
"@polkadot/extension-dapp": "0.44.1",
"@polkadot/react-identicon": "^2.11.1",
"@polkadot/ui-keyring": "^2.9.7",
"@polkadot/api": "10.9.1",
"@polkadot/extension-dapp": "^0.46.5",
"@polkadot/react-identicon": "^3.6.2",
"@polkadot/ui-keyring": "^3.6.2",
"@reach/tooltip": "^0.16.0",
"@react-aria/accordion": "^3.0.0-alpha.14",
"@react-aria/breadcrumbs": "^3.5.3",
Expand Down Expand Up @@ -91,7 +91,7 @@
"@commitlint/cli": "^16.2.4",
"@commitlint/config-conventional": "^16.2.4",
"@open-wc/webpack-import-meta-loader": "^0.4.7",
"@polkadot/types": "9.14.2",
"@polkadot/types": "10.9.1",
"@react-types/grid": "^3.1.2",
"@react-types/shared": "^3.14.0",
"@storybook/addon-actions": "^6.5.9",
Expand Down Expand Up @@ -135,27 +135,12 @@
"webpack-bundle-analyzer": "^4.4.0"
},
"resolutions": {
"@acala-network/api": "5.1.2-7",
"@acala-network/eth-providers": "2.6.10",
"babel-loader": "8.1.0",
"bn.js": "4.12.0",
"react-error-overlay": "6.0.9",
"styled-components": "^5",
"@types/history": "^4.7.1",
"@polkadot/api": "^9.14.2",
"@polkadot/api-augment": "^9.14.2",
"@polkadot/api-base": "^9.14.2",
"@polkadot/api-contract": "^9.14.2",
"@polkadot/api-derive": "^9.14.2",
"@polkadot/rpc-augment": "^9.14.2",
"@polkadot/rpc-core": "^9.14.2",
"@polkadot/rpc-provider": "^9.14.2",
"@polkadot/types": "^9.14.2",
"@polkadot/types-augment": "^9.14.2",
"@polkadot/types-codec": "^9.14.2",
"@polkadot/types-create": "^9.14.2",
"@polkadot/types-known": "^9.14.2",
"@polkadot/types-support": "^9.14.2",
"@polkadot/util": "^10.2.4",
"@polkadot/util-crypto": "^10.2.4"
"@types/history": "^4.7.1"
},
"scripts": {
"start": "NODE_OPTIONS=--openssl-legacy-provider craco start",
Expand Down
9 changes: 4 additions & 5 deletions src/components/AccountSelect/AccountSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { InjectedAccountWithMeta } from '@polkadot/extension-inject/types';

import { Item, Select, SelectProps } from '@/component-library';
import { KeyringPair } from '@/lib/substrate';

import { AccountItem } from './AccountItem';

type AccountSelectProps = Omit<SelectProps<'modal', InjectedAccountWithMeta>, 'children' | 'type'>;
type AccountSelectProps = Omit<SelectProps<'modal', KeyringPair>, 'children' | 'type'>;

const AccountSelect = ({ ...props }: AccountSelectProps): JSX.Element => {
return (
<Select<'modal', InjectedAccountWithMeta> {...props} type='modal' modalTitle='Select Account' size='large'>
{(data: InjectedAccountWithMeta) => (
<Select<'modal', KeyringPair> {...props} type='modal' modalTitle='Select Account' size='large'>
{(data: KeyringPair) => (
<Item key={data.address} textValue={data.address}>
<AccountItem address={data.address} name={data.meta.name} />
</Item>
Expand Down
7 changes: 3 additions & 4 deletions src/components/AuthModal/AccountStep.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { InjectedAccountWithMeta } from '@polkadot/extension-inject/types';
import { mergeProps } from '@react-aria/utils';
import { useTranslation } from 'react-i18next';
import { useCopyToClipboard } from 'react-use';
Expand All @@ -14,7 +13,7 @@ import { StepComponentProps, withStep } from '@/utils/hocs/step';
import { StyledAccountItem, StyledCopyItem, StyledP } from './AuthModal.style';
import { AuthModalSteps } from './types';

type CopyAddressProps = { account: InjectedAccountWithMeta };
type CopyAddressProps = { account: KeyringPair };

const CopyAddress = ({ account }: CopyAddressProps) => {
const [, copy] = useCopyToClipboard();
Expand All @@ -36,11 +35,11 @@ const CopyAddress = ({ account }: CopyAddressProps) => {
};

type AccountStepProps = {
accounts: InjectedAccountWithMeta[];
accounts: KeyringPair[];
wallet: WalletData;
selectedAccount?: KeyringPair;
onChangeWallet?: () => void;
onSelectionChange: (account: InjectedAccountWithMeta) => void;
onSelectionChange: (account: KeyringPair) => void;
} & StepComponentProps;

const AccountComponent = ({
Expand Down
7 changes: 4 additions & 3 deletions src/components/AuthModal/AuthModal.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { InjectedAccountWithMeta, InjectedExtension } from '@polkadot/extension-inject/types';
import { InjectedExtension } from '@polkadot/extension-inject/types';
import { useEffect, useMemo, useState } from 'react';
import { TFunction, useTranslation } from 'react-i18next';

import { CTA, Modal, ModalBody, ModalFooter, ModalHeader, ModalProps } from '@/component-library';
import { useSubstrateSecureState } from '@/lib/substrate';
import { KeyringPair } from '@/lib/substrate';
import { WalletData } from '@/utils/constants/wallets';
import { findWallet } from '@/utils/helpers/wallet';

Expand All @@ -25,7 +26,7 @@ const getTitle = (t: TFunction, step: AuthModalSteps, extensions: InjectedExtens
};

type Props = {
onAccountSelect?: (account: InjectedAccountWithMeta) => void;
onAccountSelect?: (account: KeyringPair) => void;
onDisconnect?: () => void;
};

Expand Down Expand Up @@ -58,7 +59,7 @@ const AuthModal = ({ onAccountSelect, onDisconnect, isOpen, ...props }: AuthModa
setWallet(undefined);
};

const handleAccountSelection = (account: InjectedAccountWithMeta) => onAccountSelect?.(account);
const handleAccountSelection = (account: KeyringPair) => onAccountSelect?.(account);

const handleDisconnect = () => onDisconnect?.();

Expand Down
5 changes: 3 additions & 2 deletions src/config/relay-chains.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AcalaAdapter, KaruraAdapter } from '@interlay/bridge/build/adapters/acala';
import { AstarAdapter } from '@interlay/bridge/build/adapters/astar';
import { BifrostAdapter } from '@interlay/bridge/build/adapters/bifrost';
import { BifrostKusamaAdapter, BifrostPolkadotAdapter } from '@interlay/bridge/build/adapters/bifrost';
import { HydraAdapter } from '@interlay/bridge/build/adapters/hydradx';
import { InterlayAdapter, KintsugiAdapter } from '@interlay/bridge/build/adapters/interlay';
import { HeikoAdapter, ParallelAdapter } from '@interlay/bridge/build/adapters/parallel';
Expand Down Expand Up @@ -165,6 +165,7 @@ switch (process.env.REACT_APP_RELAY_CHAIN_NAME) {
XCM_ADAPTERS = {
interlay: new InterlayAdapter(),
acala: new AcalaAdapter(),
bifrost_polkadot: new BifrostPolkadotAdapter(),
astar: new AstarAdapter(),
hydra: new HydraAdapter(),
parallel: new ParallelAdapter(),
Expand Down Expand Up @@ -214,7 +215,7 @@ switch (process.env.REACT_APP_RELAY_CHAIN_NAME) {
kusama: new KusamaAdapter(),
karura: new KaruraAdapter(),
statemine: new StatemineAdapter(),
bifrost: new BifrostAdapter(),
bifrost: new BifrostKusamaAdapter(),
heiko: new HeikoAdapter()
};
SS58_PREFIX = 2;
Expand Down
1 change: 1 addition & 0 deletions src/hooks/api/xcm/xcm-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const XCMEndpoints: XCMEndpointsRecord = {
acala: ['wss://acala-rpc-1.aca-api.network', 'wss://acala-rpc-3.aca-api.network/ws', 'wss://acala-rpc.dwellir.com'],
astar: ['wss://rpc.astar.network', 'wss://astar-rpc.dwellir.com'],
bifrost: ['wss://bifrost-rpc.dwellir.com'],
bifrost_polkadot: ['wss://hk.p.bifrost-rpc.liebi.com/ws'],
heiko: ['wss://heiko-rpc.parallel.fi'],
hydra: ['wss://rpc.hydradx.cloud', 'wss://hydradx-rpc.dwellir.com'],
interlay: ['wss://api.interlay.io/parachain'],
Expand Down
5 changes: 2 additions & 3 deletions src/hooks/use-wallet.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { newAccountId } from '@interlay/interbtc-api';
import { InjectedAccountWithMeta } from '@polkadot/extension-inject/types';
import { AccountId } from '@polkadot/types/interfaces';
import { useCallback, useMemo } from 'react';
import { useSelector } from 'react-redux';

import { StoreType } from '@/common/types/util.types';
import { SS58_PREFIX } from '@/config/relay-chains';
import { useSubstrateSecureState } from '@/lib/substrate';
import { KeyringPair, useSubstrateSecureState } from '@/lib/substrate';

type UseWalletResult = {
isAuth: boolean;
account?: AccountId;
accounts: InjectedAccountWithMeta[];
accounts: KeyringPair[];
getRelayChainAddress: (address?: string) => string | undefined;
};

Expand Down
3 changes: 1 addition & 2 deletions src/legacy-components/Topbar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ArrowTopRightOnSquareIcon } from '@heroicons/react/24/outline';
import { Keyring } from '@polkadot/api';
import { InjectedAccountWithMeta } from '@polkadot/extension-inject/types';
import clsx from 'clsx';
import { useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'react-redux';
Expand Down Expand Up @@ -42,7 +41,7 @@ const Topbar = (): JSX.Element => {

const handleAccountModalClose = () => dispatch(showAccountModalAction(false));

const handleAccountSelect = (account: InjectedAccountWithMeta) => {
const handleAccountSelect = (account: KeyringPair) => {
const keyring = new Keyring({ type: 'sr25519', ss58Format: SS58_FORMAT });
const keyringAccount = keyring.addFromAddress(account.address, account.meta);
setSelectedAccount(keyringAccount);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/substrate/context/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const loadAccounts = async (api: ApiPromise, dispatch: Dispatch): Promise<void>
payload: theExtensions
});

const theAccounts = await web3Accounts({ ss58Format: constants.SS58_FORMAT });
const theAccounts = (await web3Accounts({ ss58Format: constants.SS58_FORMAT })) as KeyringPair[];
dispatch({
type: ActionType.SetAccounts,
payload: theAccounts
Expand Down
6 changes: 3 additions & 3 deletions src/lib/substrate/context/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiPromise } from '@polkadot/api';
import { InjectedAccountWithMeta, InjectedExtension } from '@polkadot/extension-inject/types';
import { InjectedExtension } from '@polkadot/extension-inject/types';
import { KeyringPair as PolkadotKeyringPair, KeyringPair$Meta } from '@polkadot/keyring/types';
import type { DefinitionRpcExt } from '@polkadot/types/types';
import { Keyring } from '@polkadot/ui-keyring/Keyring';
Expand Down Expand Up @@ -59,7 +59,7 @@ type Action =
| { type: ActionType.SetKeyringReady; payload: Keyring }
| { type: ActionType.SetKeyringError }
| { type: ActionType.SetSelectedAccount; payload: KeyringPair | undefined }
| { type: ActionType.SetAccounts; payload: Array<InjectedAccountWithMeta> }
| { type: ActionType.SetAccounts; payload: Array<KeyringPair> }
| { type: ActionType.SetExtensions; payload: Array<InjectedExtension> };

type Dispatch = (action: Action) => void;
Expand All @@ -73,7 +73,7 @@ type State = {
apiError: APIError | undefined;
apiStatus: ApiStatus;
selectedAccount: KeyringPair | undefined;
accounts: Array<InjectedAccountWithMeta>;
accounts: Array<KeyringPair>;
extensions: Array<InjectedExtension>;
};

Expand Down
3 changes: 1 addition & 2 deletions src/pages/Onboarding/Onboarding.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Keyring } from '@polkadot/api';
import { InjectedAccountWithMeta } from '@polkadot/extension-inject/types';
import { ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'react-redux';
Expand Down Expand Up @@ -45,7 +44,7 @@ const Onboarding = (): JSX.Element => {

const handleAccountModalClose = () => dispatch(showAccountModalAction(false));

const handleAccountSelect = (account: InjectedAccountWithMeta) => {
const handleAccountSelect = (account: KeyringPair) => {
const keyring = new Keyring({ type: 'sr25519', ss58Format: SS58_FORMAT });
const keyringAccount = keyring.addFromAddress(account.address, account.meta);
setSelectedAccount(keyringAccount);
Expand Down
Loading

2 comments on commit 6626850

@vercel
Copy link

@vercel vercel bot commented on 6626850 Sep 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 6626850 Sep 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.