tabContentType refactor

pull/5370/head
Joseph Izang 9 months ago committed by Aniket
parent 7830052aa1
commit 9b4f2f617a
  1. 22
      libs/remix-ui/vyper-compile-details/src/lib/vyperCompile.tsx

@ -10,12 +10,14 @@ const _paq = (window._paq = window._paq || [])
export interface VyperCompilationResult { export interface VyperCompilationResult {
status?: 'success' status?: 'success'
bytecode: string bytecode: string
bytecodeRuntime: string bytecodeRuntime: string | 'bytecode_runtime'
abi: ABIDescription[] abi: ABIDescription[]
ir: string ir: string
methodIdentifiers: { methodIdentifiers: {
[method: string]: string [method: string]: string
} }
compilerVersion: string
evmVersion: string
} }
export interface VyperCompileProps { export interface VyperCompileProps {
@ -24,15 +26,27 @@ export interface VyperCompileProps {
themeStyle?: any themeStyle?: any
} }
type tabContentType = {
tabHeadingText: string
tabPayload: string | ABIDescription[]
tabMemberType: keyof VyperCompilationResult | string
tabButtonText: () => string
eventKey: string
version?: string
evmVersion?: string
}
export default function VyperCompile({result, theme, themeStyle}: VyperCompileProps) { export default function VyperCompile({result, theme, themeStyle}: VyperCompileProps) {
const [active, setActive] = useState<keyof VyperCompilationResult>('abi') const [active, setActive] = useState<keyof VyperCompilationResult>('abi')
const tabContent = [ const tabContent: tabContentType[] = [
{ {
tabHeadingText: 'ABI', tabHeadingText: 'ABI',
tabPayload: result.abi, tabPayload: result.abi,
tabMemberType: 'abi', tabMemberType: 'abi',
tabButtonText: () => 'Copy ABI', tabButtonText: () => 'Copy ABI',
eventKey: 'abi' eventKey: 'abi',
version: result.compilerVersion,
evmVersion: result.evmVersion
}, },
{ {
tabHeadingText: 'Bytecode', tabHeadingText: 'Bytecode',
@ -69,7 +83,7 @@ export default function VyperCompile({result, theme, themeStyle}: VyperCompilePr
{content.eventKey === 'abi' ? ( {content.eventKey === 'abi' ? (
<div className="my-3"> <div className="my-3">
{JSON.stringify(content?.tabPayload)?.length > 1 ? <JSONTree {JSON.stringify(content?.tabPayload)?.length > 1 ? <JSONTree
src={content.tabPayload as ABIDescription[]} src={{...content.tabPayload as ABIDescription[], evmVersion: content.evmVersion, version: content.version } }
theme={theme} theme={theme}
style={themeStyle} style={themeStyle}
/> : null} /> : null}

Loading…
Cancel
Save