diff --git a/packages/react-hooks/src/index.ts b/packages/react-hooks/src/index.ts index 04bcd81dcc..8c4306889b 100644 --- a/packages/react-hooks/src/index.ts +++ b/packages/react-hooks/src/index.ts @@ -67,5 +67,4 @@ export { useTreasury } from './useTreasury'; export { useTxBatch } from './useTxBatch'; export { useVotingStatus } from './useVotingStatus'; export { useWeight } from './useWeight'; -export { useWeightFee } from './useWeightFee'; export { useWindowSize } from './useWindowSize'; diff --git a/packages/react-hooks/src/useWeightFee.ts b/packages/react-hooks/src/useWeightFee.ts deleted file mode 100644 index 109cb088ec..0000000000 --- a/packages/react-hooks/src/useWeightFee.ts +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2017-2022 @polkadot/app-democracy authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -import type { ApiPromise } from '@polkadot/api'; -import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces'; - -import { useMemo } from 'react'; - -import { BN, BN_BILLION, BN_ZERO, bnToBn, isUndefined } from '@polkadot/util'; - -import { createNamedHook } from './createNamedHook'; -import { useApi } from './useApi'; - -function useWeightFeeImpl (weight: BN | number, apiOverride?: ApiPromise | null): BN { - const { api } = useApi(); - - return useMemo( - () => isUndefined(apiOverride) || apiOverride - ? ((apiOverride || api).consts.transactionPayment?.weightToFee || []).reduce((acc, { coeffFrac, coeffInteger, degree, negative }: WeightToFeeCoefficient): BN => { - const w = bnToBn(weight).pow(degree); - const frac = coeffFrac.mul(w).div(BN_BILLION); - const integer = coeffInteger.mul(w); - - if (negative.isTrue) { - acc.isub(frac); - acc.isub(integer); - } else { - acc.iadd(frac); - acc.iadd(integer); - } - - return acc; - }, new BN(0)) - : BN_ZERO, - [api, apiOverride, weight] - ); -} - -export const useWeightFee = createNamedHook('useWeightFee', useWeightFeeImpl);