Skip to content

Commit

Permalink
chore: Format/InputFields -> Inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Bulat committed Jun 13, 2024
1 parent 55a627d commit 0ccb0a2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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));
};

// ------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/routes/Chain/ChainState/StorageItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/routes/Chain/Extrinsics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/routes/Chain/Inputs/index.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -304,7 +304,7 @@ export const useInput = () => {
{...inputArgConfig}
value={
getInputArgsAtKey(tabId, namespace, inputKey) ||
FormatInputFields.defaultValue(form)
Inputs.defaultValue(form)
}
/>
);
Expand Down Expand Up @@ -373,7 +373,7 @@ export const useInput = () => {
label={label || 'Value'}
value={
getInputArgsAtKey(tabId, namespace, inputKey) ||
FormatInputFields.defaultValue(form)
Inputs.defaultValue(form)
}
numeric={form === 'number'}
/>
Expand Down

0 comments on commit 0ccb0a2

Please sign in to comment.