Move usePreimage to react-hooks (#8796)
* Move usePreimage to react-hooks * Adjust import * Additional
This commit is contained in:
parent
55fea392f3
commit
8edbedd5a5
@ -6,10 +6,9 @@ import type { HexString } from '@polkadot/util/types';
|
||||
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
import usePreimage from '@polkadot/app-preimages/usePreimage';
|
||||
import { getProposalThreshold } from '@polkadot/apps-config';
|
||||
import { Button, Input, InputAddress, Modal, TxButton } from '@polkadot/react-components';
|
||||
import { useApi, useCollectiveInstance, useToggle } from '@polkadot/react-hooks';
|
||||
import { useApi, useCollectiveInstance, usePreimage, useToggle } from '@polkadot/react-hooks';
|
||||
import { isFunction, isHex } from '@polkadot/util';
|
||||
|
||||
import { useTranslation } from '../translate';
|
||||
|
||||
@ -8,9 +8,8 @@ import type { HexString } from '@polkadot/util/types';
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import usePreimage from '@polkadot/app-preimages/usePreimage';
|
||||
import { CallExpander } from '@polkadot/react-components';
|
||||
import { useApi } from '@polkadot/react-hooks';
|
||||
import { useApi, usePreimage } from '@polkadot/react-hooks';
|
||||
|
||||
import { useTranslation } from '../translate';
|
||||
import ExternalCell from './ExternalCell';
|
||||
|
||||
@ -6,9 +6,8 @@ import type { HexString } from '@polkadot/util/types';
|
||||
|
||||
import React, { useCallback, useState } from 'react';
|
||||
|
||||
import usePreimage from '@polkadot/app-preimages/usePreimage';
|
||||
import { Input, InputAddress, InputBalance, Modal, TxButton } from '@polkadot/react-components';
|
||||
import { useApi, useCall } from '@polkadot/react-hooks';
|
||||
import { useApi, useCall, usePreimage } from '@polkadot/react-hooks';
|
||||
import { Available } from '@polkadot/react-query';
|
||||
import { isFunction, isHex } from '@polkadot/util';
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/app-preimages authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Preimage } from '../types';
|
||||
import type { Preimage } from '@polkadot/react-hooks/types';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/app-preimages authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Preimage } from '../types';
|
||||
import type { Preimage } from '@polkadot/react-hooks/types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
|
||||
@ -5,9 +5,9 @@ import type { HexString } from '@polkadot/util/types';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { usePreimage } from '@polkadot/react-hooks';
|
||||
import { formatNumber } from '@polkadot/util';
|
||||
|
||||
import usePreimage from '../usePreimage';
|
||||
import Call from './Call';
|
||||
import Free from './Free';
|
||||
import Hash from './Hash';
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
// Copyright 2017-2023 @polkadot/app-preimages authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Bytes } from '@polkadot/types';
|
||||
import type { Call } from '@polkadot/types/interfaces';
|
||||
import type { PalletPreimageRequestStatus } from '@polkadot/types/lookup';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
|
||||
export interface PreimageDeposit {
|
||||
amount: BN;
|
||||
who: string;
|
||||
}
|
||||
|
||||
export interface PreimageStatus {
|
||||
count: number;
|
||||
deposit?: PreimageDeposit;
|
||||
isCompleted: boolean;
|
||||
proposalHash: HexString;
|
||||
proposalLength?: BN;
|
||||
registry: Registry;
|
||||
status: PalletPreimageRequestStatus | null;
|
||||
}
|
||||
|
||||
export interface PreimageBytes {
|
||||
bytes?: Bytes | null;
|
||||
proposal?: Call | null;
|
||||
proposalError?: string | null;
|
||||
proposalWarning?: string | null;
|
||||
}
|
||||
|
||||
export interface Preimage extends PreimageBytes, PreimageStatus {
|
||||
// just the interfaces above
|
||||
}
|
||||
@ -9,8 +9,8 @@ import type { Referendum, ReferendumProps as Props } from '../types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
import usePreimage, { getPreimageHash } from '@polkadot/app-preimages/usePreimage';
|
||||
import { CallExpander, Progress } from '@polkadot/react-components';
|
||||
import { getPreimageHash, usePreimage } from '@polkadot/react-hooks/usePreimage';
|
||||
|
||||
import { useTranslation } from '../translate';
|
||||
import Deposits from './Deposits';
|
||||
|
||||
@ -10,9 +10,8 @@ import type { PalletReferenda, TrackDescription } from '../types';
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import usePreimage from '@polkadot/app-preimages/usePreimage';
|
||||
import { Button, Dropdown, Input, InputAddress, InputBalance, InputNumber, Modal, ToggleGroup, TxButton } from '@polkadot/react-components';
|
||||
import { useApi, useBestNumber, useToggle } from '@polkadot/react-hooks';
|
||||
import { useApi, useBestNumber, usePreimage, useToggle } from '@polkadot/react-hooks';
|
||||
import Params from '@polkadot/react-params';
|
||||
import { Available } from '@polkadot/react-query';
|
||||
import { getTypeDef } from '@polkadot/types/create';
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
import type { TFunction } from 'react-i18next';
|
||||
import type { ApiPromise } from '@polkadot/api';
|
||||
import type { Preimage } from '@polkadot/app-preimages/types';
|
||||
import type { Preimage } from '@polkadot/react-hooks/types';
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { PalletVote, TrackInfo } from '../types';
|
||||
|
||||
|
||||
@ -7,8 +7,8 @@ import type { ScheduledExt } from './types';
|
||||
import React from 'react';
|
||||
|
||||
import Hash from '@polkadot/app-preimages/Preimages/Hash';
|
||||
import usePreimage from '@polkadot/app-preimages/usePreimage';
|
||||
import { CallExpander } from '@polkadot/react-components';
|
||||
import { usePreimage } from '@polkadot/react-hooks';
|
||||
import { BlockToTime } from '@polkadot/react-query';
|
||||
import { formatNumber } from '@polkadot/util';
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ import React from 'react';
|
||||
|
||||
import Call from '@polkadot/app-preimages/Preimages/Call';
|
||||
import Hash from '@polkadot/app-preimages/Preimages/Hash';
|
||||
import usePreimage from '@polkadot/app-preimages/usePreimage';
|
||||
import { usePreimage } from '@polkadot/react-hooks';
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
|
||||
@ -58,6 +58,7 @@ export { useOwnStashInfos } from './useOwnStashInfos';
|
||||
export { useOutsideClick } from './useOutsideClick';
|
||||
export { useParaApi } from './useParaApi';
|
||||
export { usePopupWindow } from './usePopupWindow';
|
||||
export { usePreimage } from './usePreimage';
|
||||
export { useProxies } from './useProxies';
|
||||
export { useIsParasLinked, useParaEndpoints } from './useParaEndpoints';
|
||||
export { usePassword } from './usePassword';
|
||||
|
||||
@ -5,9 +5,13 @@ import type { ApiPromise } from '@polkadot/api';
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/types';
|
||||
import type { DeriveAccountFlags, DeriveAccountRegistration } from '@polkadot/api-derive/types';
|
||||
import type { DisplayedJudgement } from '@polkadot/react-components/types';
|
||||
import type { Bytes } from '@polkadot/types';
|
||||
import type { AccountId, Balance, BlockNumber, Call, Exposure, Hash, RewardDestination, SessionIndex, StakingLedger, ValidatorPrefs } from '@polkadot/types/interfaces';
|
||||
import type { IExtrinsic } from '@polkadot/types/types';
|
||||
import type { PalletPreimageRequestStatus } from '@polkadot/types/lookup';
|
||||
import type { IExtrinsic, Registry } from '@polkadot/types/types';
|
||||
import type { KeyringJson$Meta } from '@polkadot/ui-keyring/types';
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
|
||||
export type CallParam = any;
|
||||
|
||||
@ -167,3 +171,29 @@ export interface BatchOptions {
|
||||
max?: number;
|
||||
type?: BatchType;
|
||||
}
|
||||
|
||||
export interface PreimageDeposit {
|
||||
amount: BN;
|
||||
who: string;
|
||||
}
|
||||
|
||||
export interface PreimageStatus {
|
||||
count: number;
|
||||
deposit?: PreimageDeposit;
|
||||
isCompleted: boolean;
|
||||
proposalHash: HexString;
|
||||
proposalLength?: BN;
|
||||
registry: Registry;
|
||||
status: PalletPreimageRequestStatus | null;
|
||||
}
|
||||
|
||||
export interface PreimageBytes {
|
||||
bytes?: Bytes | null;
|
||||
proposal?: Call | null;
|
||||
proposalError?: string | null;
|
||||
proposalWarning?: string | null;
|
||||
}
|
||||
|
||||
export interface Preimage extends PreimageBytes, PreimageStatus {
|
||||
// just the interfaces above
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2023 @polkadot/app-preimages authors & contributors
|
||||
// Copyright 2017-2023 @polkadot/react-hooks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiPromise } from '@polkadot/api';
|
||||
@ -203,4 +203,4 @@ function usePreimageImpl (hashOrBounded?: Hash | HexString | FrameSupportPreimag
|
||||
);
|
||||
}
|
||||
|
||||
export default createNamedHook('usePreimage', usePreimageImpl);
|
||||
export const usePreimage = createNamedHook('usePreimage', usePreimageImpl);
|
||||
Loading…
Reference in New Issue
Block a user