From 54bc1183a1c4ce51fd132223e9a7a35635462e04 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Fri, 9 Apr 2021 21:12:03 +0300 Subject: [PATCH] Cater for compressed wasm (#5048) --- .../src/Parathreads/RegisterThread.tsx | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/page-parachains/src/Parathreads/RegisterThread.tsx b/packages/page-parachains/src/Parathreads/RegisterThread.tsx index fddaa22680..c8ce7422a9 100644 --- a/packages/page-parachains/src/Parathreads/RegisterThread.tsx +++ b/packages/page-parachains/src/Parathreads/RegisterThread.tsx @@ -5,7 +5,7 @@ import type BN from 'bn.js'; import React, { useCallback, useState } from 'react'; -import { InputAddress, InputFile, InputNumber, InputWasm, Modal, TxButton } from '@polkadot/react-components'; +import { InputAddress, InputFile, InputNumber, Modal, TxButton } from '@polkadot/react-components'; import { useApi } from '@polkadot/react-hooks'; import { BN_ZERO, compactAddLength } from '@polkadot/util'; @@ -16,17 +16,12 @@ interface Props { onClose: () => void; } -interface CodeState { - isWasmValid: boolean; - wasm: Uint8Array | null; -} - function RegisterThread ({ className, onClose }: Props): React.ReactElement { const { t } = useTranslation(); const { api } = useApi(); const [accountId, setAccountId] = useState(null); const [paraId, setParaId] = useState(); - const [{ isWasmValid, wasm }, setWasm] = useState({ isWasmValid: false, wasm: null }); + const [wasm, setWasm] = useState(null); const [genesisState, setGenesisState] = useState(null); const _setGenesisState = useCallback( @@ -35,7 +30,7 @@ function RegisterThread ({ className, onClose }: Props): React.ReactElement setWasm({ isWasmValid, wasm }), + (data: Uint8Array) => setWasm(compactAddLength(data)), [] ); @@ -63,12 +58,11 @@ function RegisterThread ({ className, onClose }: Props): React.ReactElement ('The WASM validation function for this parachain.')}> - ('The compiled runtime WASM for the parachain you wish to register.')} - isError={!isWasmValid} + isError={!wasm} label={t('code')} onChange={_setWasm} - placeholder={wasm && !isWasmValid && t('The code is not recognized as being in valid WASM format')} /> ('The genesis state for this parachain.')}> @@ -84,7 +78,7 @@ function RegisterThread ({ className, onClose }: Props): React.ReactElement