From bf9dd55dedbcade87045d33d980add3b2b032ddd Mon Sep 17 00:00:00 2001 From: Jimmy Chu Date: Wed, 20 Oct 2021 14:33:26 +0800 Subject: [PATCH] Remove warning --- packages/react-api/src/ApiSigner.ts | 20 +++++++++++-------- packages/react-params/src/Param/Amount.tsx | 9 +++++---- .../react-params/src/Param/VoteThreshold.tsx | 11 +++++----- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/packages/react-api/src/ApiSigner.ts b/packages/react-api/src/ApiSigner.ts index e77252f51d0..752b73747f3 100644 --- a/packages/react-api/src/ApiSigner.ts +++ b/packages/react-api/src/ApiSigner.ts @@ -4,12 +4,11 @@ import { SubmittableResult } from '@polkadot/api'; import { Signer, SignerResult } from '@polkadot/api/types'; -import { ClassOf } from '@polkadot/types'; +// import { ClassOf } from '@polkadot/types'; import { Hash } from '@polkadot/types/interfaces'; import { SignerPayloadJSON } from '@polkadot/types/types'; - import { QueueTxMessageSetStatus, QueueTxPayloadAdd, QueueTxStatus } from './Status/types'; -import { registry } from '.'; +// import { registry } from '.'; export default class ApiSigner implements Signer { readonly #queuePayload: QueueTxPayloadAdd; @@ -34,10 +33,15 @@ export default class ApiSigner implements Signer { } public update (id: number, result: Hash | SubmittableResult): void { - if (result instanceof ClassOf(registry, 'Hash')) { - this.#queueSetTxStatus(id, 'sent', result.toHex()); - } else { - this.#queueSetTxStatus(id, result.status.type.toLowerCase() as QueueTxStatus, status); - } + // if (result instanceof ClassOf(registry, 'Hash')) { + // this.#queueSetTxStatus(id, 'sent', result.toHex()); + // } else { + // this.#queueSetTxStatus(id, result.status.type.toLowerCase() as QueueTxStatus, status); + // } + this.#queueSetTxStatus( + id, + (result as SubmittableResult).status.type.toLowerCase() as QueueTxStatus, + status + ); } } diff --git a/packages/react-params/src/Param/Amount.tsx b/packages/react-params/src/Param/Amount.tsx index a107b1a3555..a30a2487118 100644 --- a/packages/react-params/src/Param/Amount.tsx +++ b/packages/react-params/src/Param/Amount.tsx @@ -8,7 +8,7 @@ import { Props } from '@canvas-ui/react-components/types'; import BN from 'bn.js'; import React, { useCallback, useMemo } from 'react'; -import { ClassOf } from '@polkadot/types'; +// import { ClassOf } from '@polkadot/types'; import { bnToBn, formatNumber, isUndefined } from '@polkadot/util'; import Bare from './Bare'; @@ -16,9 +16,10 @@ import Bare from './Bare'; function Amount ({ className = '', defaultValue: { value }, isDisabled, isError, label, onChange, onEnter, type, withLabel }: Props): React.ReactElement { const defaultValue = useMemo( () => isDisabled - ? value instanceof ClassOf(registry, 'AccountIndex') - ? value.toString() - : formatNumber(value as number) + // ? value instanceof ClassOf(registry, 'AccountIndex') + // ? value.toString() + // : formatNumber(value as number) + ? formatNumber(value as number) : bnToBn((value as number) || 0).toString(), [isDisabled, value] ); diff --git a/packages/react-params/src/Param/VoteThreshold.tsx b/packages/react-params/src/Param/VoteThreshold.tsx index bea8434679e..9228b996bfb 100644 --- a/packages/react-params/src/Param/VoteThreshold.tsx +++ b/packages/react-params/src/Param/VoteThreshold.tsx @@ -2,12 +2,12 @@ // and @canvas-ui/react-params authors & contributors // SPDX-License-Identifier: Apache-2.0 -import { registry } from '@canvas-ui/react-api'; +// import { registry } from '@canvas-ui/react-api'; import { Dropdown } from '@canvas-ui/react-components'; import { Props } from '@canvas-ui/react-components/types'; import React, { useCallback } from 'react'; -import { ClassOf } from '@polkadot/types'; +// import { ClassOf } from '@polkadot/types'; import { bnToBn } from '@polkadot/util'; import Bare from './Bare'; @@ -28,9 +28,10 @@ function VoteThresholdParam ({ className = '', defaultValue: { value }, isDisabl [onChange] ); - const defaultValue = value instanceof ClassOf(registry, 'VoteThreshold') - ? value.toNumber() - : bnToBn(value as number).toNumber(); + // const defaultValue = value instanceof ClassOf(registry, 'VoteThreshold') + // ? value.toNumber() + // : bnToBn(value as number).toNumber(); + const defaultValue = bnToBn(value as number).toNumber(); return (