From 0ccb0a2bca5def60fe67aa93ce9034a6558750d4 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Thu, 13 Jun 2024 22:00:41 +0700 Subject: [PATCH] chore: Format/InputFields -> Inputs --- .../Scraper/{Format/InputFields.ts => Inputs.ts} | 16 ++++++++-------- src/routes/Chain/ChainState/StorageItems.tsx | 4 ++-- src/routes/Chain/Extrinsics/index.tsx | 4 ++-- src/routes/Chain/Inputs/index.tsx | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) rename src/model/Scraper/{Format/InputFields.ts => Inputs.ts} (94%) diff --git a/src/model/Scraper/Format/InputFields.ts b/src/model/Scraper/Inputs.ts similarity index 94% rename from src/model/Scraper/Format/InputFields.ts rename to src/model/Scraper/Inputs.ts index 563aff18..5b59b119 100644 --- a/src/model/Scraper/Format/InputFields.ts +++ b/src/model/Scraper/Inputs.ts @@ -2,10 +2,10 @@ // SPDX-License-Identifier: GPL-3.0-only import type { AnyJson } from '@w3ux/types'; -import type { PalletItemScraped } from '../types'; -import { getShortLabel } from './Utils'; +import type { PalletItemScraped } from './types'; +import { getShortLabel } from './Format/Utils'; -export class FormatInputFields { +export class Inputs { // The raw input config to format. #rawConfig: PalletItemScraped; @@ -19,18 +19,18 @@ export class FormatInputFields { // Formats `rawConfig` data into an input structure. format = () => { - const { argTypes } = this.#rawConfig; + let { argTypes } = this.#rawConfig; // if there are no arg types, (no args to format) return an empty object. if (!argTypes) { return {}; } - const result = Array.isArray(argTypes) - ? argTypes.map((argType) => this.getTypeInput(argType)) - : this.getTypeInput(argTypes); + if (!Array.isArray(argTypes)) { + argTypes = [argTypes]; + } - return result; + return argTypes.map((argType: AnyJson) => this.getTypeInput(argType)); }; // ------------------------------------------------------ diff --git a/src/routes/Chain/ChainState/StorageItems.tsx b/src/routes/Chain/ChainState/StorageItems.tsx index 5bc416e0..a2baff58 100644 --- a/src/routes/Chain/ChainState/StorageItems.tsx +++ b/src/routes/Chain/ChainState/StorageItems.tsx @@ -6,7 +6,7 @@ import { PalletList } from '../PalletList'; import { PalletScraper } from 'model/Scraper/Pallet'; import { useChainUi } from 'contexts/ChainUi'; import { ChainStateList } from './ChainStateList'; -import { FormatInputFields } from 'model/Scraper/Format/InputFields'; +import { Inputs } from 'model/Scraper/Inputs'; import { useActiveTab } from 'contexts/ActiveTab'; import type { PalletData } from './types'; import { EncodedDetails } from './EncodedDetails'; @@ -74,7 +74,7 @@ export const StorageItemsInner = () => { // Get input markup for the active storage item. const inputForm = activePallet !== null && activeItem !== null && !!activeListItem - ? new FormatInputFields(activeListItem).format() + ? new Inputs(activeListItem).format() : null; // Handle storage item query submission. diff --git a/src/routes/Chain/Extrinsics/index.tsx b/src/routes/Chain/Extrinsics/index.tsx index fec519cc..767346aa 100644 --- a/src/routes/Chain/Extrinsics/index.tsx +++ b/src/routes/Chain/Extrinsics/index.tsx @@ -9,7 +9,7 @@ import { Header } from './Header'; import { useActiveTab } from 'contexts/ActiveTab'; import { useMemo } from 'react'; import type { PalletData } from '../ChainState/types'; -import { FormatInputFields } from 'model/Scraper/Format/InputFields'; +import { Inputs } from 'model/Scraper/Inputs'; import { InputForm } from '../InputForm'; import { SelectFormWrapper, SenderWrapper } from 'library/Inputs/Wrappers'; import { FlexWrapper } from 'routes/Common/Wrappers'; @@ -93,7 +93,7 @@ export const ExtrinsicsInner = () => { // Get input markup for the active call item. const inputForm = activePallet !== null && activeItem !== null && !!activeListItem - ? new FormatInputFields(activeListItem).format() + ? new Inputs(activeListItem).format() : null; // Transaction is submittable once from address has been defined. diff --git a/src/routes/Chain/Inputs/index.tsx b/src/routes/Chain/Inputs/index.tsx index 7b29394c..8f2b99b5 100644 --- a/src/routes/Chain/Inputs/index.tsx +++ b/src/routes/Chain/Inputs/index.tsx @@ -1,7 +1,7 @@ // Copyright 2024 @polkadot-cloud/polkadot-developer-console authors & contributors // SPDX-License-Identifier: GPL-3.0-only -import { FormatInputFields } from 'model/Scraper/Format/InputFields'; +import { Inputs } from 'model/Scraper/Inputs'; import type { AnyJson } from '@w3ux/types'; import type { ReactNode } from 'react'; import { Fragment } from 'react'; @@ -304,7 +304,7 @@ export const useInput = () => { {...inputArgConfig} value={ getInputArgsAtKey(tabId, namespace, inputKey) || - FormatInputFields.defaultValue(form) + Inputs.defaultValue(form) } /> ); @@ -373,7 +373,7 @@ export const useInput = () => { label={label || 'Value'} value={ getInputArgsAtKey(tabId, namespace, inputKey) || - FormatInputFields.defaultValue(form) + Inputs.defaultValue(form) } numeric={form === 'number'} />