From c4357f7f2a43b72a6b98302de26cdb2f18978286 Mon Sep 17 00:00:00 2001 From: Jaco Date: Sat, 8 May 2021 08:12:31 +0300 Subject: [PATCH] Use registerNext for parachains (#5221) * Use registerNext for parachains * Update packages/page-parachains/src/Parathreads/RegisterThread.tsx --- .../src/Parathreads/RegisterThread.tsx | 39 ++++++++++++++----- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/packages/page-parachains/src/Parathreads/RegisterThread.tsx b/packages/page-parachains/src/Parathreads/RegisterThread.tsx index c8ce7422a9..51c12b29dd 100644 --- a/packages/page-parachains/src/Parathreads/RegisterThread.tsx +++ b/packages/page-parachains/src/Parathreads/RegisterThread.tsx @@ -2,11 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 import type BN from 'bn.js'; +import type { ParaId } from '@polkadot/types/interfaces'; import React, { useCallback, useState } from 'react'; import { InputAddress, InputFile, InputNumber, Modal, TxButton } from '@polkadot/react-components'; -import { useApi } from '@polkadot/react-hooks'; +import { useApi, useCall } from '@polkadot/react-hooks'; import { BN_ZERO, compactAddLength } from '@polkadot/util'; import { useTranslation } from '../translate'; @@ -21,6 +22,7 @@ function RegisterThread ({ className, onClose }: Props): React.ReactElement(null); const [paraId, setParaId] = useState(); + const nextParaId = useCall(api.query.registrar?.nextFreeParaId); const [wasm, setWasm] = useState(null); const [genesisState, setGenesisState] = useState(null); @@ -50,15 +52,28 @@ function RegisterThread ({ className, onClose }: Props): React.ReactElement ('The id of this parachain as known on the network')}> - ('parachain id')} - onChange={setParaId} - /> + {api.tx.registrar.registerNext + ? ( + ('parachain id')} + /> + ) + : ( + ('parachain id')} + onChange={setParaId} + /> + ) + } ('The WASM validation function for this parachain.')}> ('The compiled runtime WASM for the parachain you wish to register.')} isError={!wasm} label={t('code')} @@ -78,10 +93,14 @@ function RegisterThread ({ className, onClose }: Props): React.ReactElement