From aa79aa18cabebb61ba9235b69f23af8388b3565c Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Fri, 27 Oct 2023 16:32:52 +0100 Subject: [PATCH] add types in contract-selection component. unfold 2 important sections by default --- .../src/lib/solidity-compile-details.tsx | 1 + .../solidity-compiler/src/lib/contract-selection.tsx | 6 +++--- libs/remix-ui/solidity-compiler/src/lib/types/index.ts | 4 ++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libs/remix-ui/solidity-compile-details/src/lib/solidity-compile-details.tsx b/libs/remix-ui/solidity-compile-details/src/lib/solidity-compile-details.tsx index c11426e7c1..83d7ba1308 100644 --- a/libs/remix-ui/solidity-compile-details/src/lib/solidity-compile-details.tsx +++ b/libs/remix-ui/solidity-compile-details/src/lib/solidity-compile-details.tsx @@ -1,6 +1,7 @@ import { CopyToClipboard } from '@remix-ui/clipboard' import { CustomTooltip } from '@remix-ui/helper' import { TreeView, TreeViewItem } from '@remix-ui/tree-view' + import React from 'react' import { useIntl } from 'react-intl' diff --git a/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx b/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx index b56cc2afbe..a6436db88b 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx @@ -1,6 +1,6 @@ import React, {useState, useEffect} from 'react' // eslint-disable-line import {FormattedMessage, useIntl} from 'react-intl' -import {ContractSelectionProps} from './types' +import {ContractPropertyName, ContractSelectionProps} from './types' import {PublishToStorage} from '@remix-ui/publish-to-storage' // eslint-disable-line import {TreeView, TreeViewItem} from '@remix-ui/tree-view' // eslint-disable-line import {CopyToClipboard} from '@remix-ui/clipboard' // eslint-disable-line @@ -122,7 +122,7 @@ export const ContractSelection = (props: ContractSelectionProps) => { return ret } - const insertValue = (details, propertyName) => { + const insertValue = (details, propertyName: ContractPropertyName) => { let node if (propertyName === 'web3Deploy' || propertyName === 'name' || propertyName === 'Assembly') { node =
{details[propertyName]}
@@ -197,7 +197,7 @@ export const ContractSelection = (props: ContractSelectionProps) => { const log = (
- {Object.keys(contractProperties).map((propertyName, index) => { + {Object.keys(contractProperties).map((propertyName: ContractPropertyName, index) => { const copyDetails = ( diff --git a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts index d2d070b517..4b991c0f4c 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts @@ -53,3 +53,7 @@ export interface CompilationDetails { export interface ContractsFile { [currentFile: string]: CompilationDetails } + +export type ContractPropertyName = 'compilerInput' | 'name' | 'metadata' | 'bytecode' | 'abi' | 'storageLayout' + | 'web3Deploy' | 'metadataHash' | 'functionHashes' | 'gasEstimates' | 'devdoc' | 'userdoc' | 'Runtime Bytecode' + | 'Assembly'