Commit 01e266df authored by tom's avatar tom

update format for call output

parent 05e389dd
...@@ -13,7 +13,7 @@ function getBg(props: StyleFunctionProps) { ...@@ -13,7 +13,7 @@ function getBg(props: StyleFunctionProps) {
const { theme, colorScheme: c } = props; const { theme, colorScheme: c } = props;
const darkBg = transparentize(`${ c }.200`, 0.16)(theme); const darkBg = transparentize(`${ c }.200`, 0.16)(theme);
return { return {
light: `colors.${ c }.100`, light: `colors.${ c }.${ c === 'red' ? '50' : '100' }`,
dark: darkBg, dark: darkBg,
}; };
} }
......
import { Box, Button, chakra, Flex, Icon, Text } from '@chakra-ui/react'; import { Box, Button, chakra, Flex, Grid, Icon, Text } from '@chakra-ui/react';
// import _fromPairs from 'lodash/fromPairs'; // import _fromPairs from 'lodash/fromPairs';
import React from 'react'; import React from 'react';
import type { SubmitHandler } from 'react-hook-form'; import type { SubmitHandler } from 'react-hook-form';
...@@ -136,62 +136,65 @@ const ContractMethodCallable = <T extends SmartContractMethod>({ data, onSubmit, ...@@ -136,62 +136,65 @@ const ContractMethodCallable = <T extends SmartContractMethod>({ data, onSubmit,
<FormProvider { ...formApi }> <FormProvider { ...formApi }>
<chakra.form <chakra.form
noValidate noValidate
display="grid"
columnGap={ 3 }
rowGap={{ base: 2, lg: 3 }}
gridTemplateColumns={{ base: 'minmax(0, 1fr)', lg: 'minmax(min-content, 250px) minmax(0, 1fr)' }}
onSubmit={ formApi.handleSubmit(onFormSubmit) } onSubmit={ formApi.handleSubmit(onFormSubmit) }
onChange={ handleFormChange } onChange={ handleFormChange }
> >
{ inputs.map((input, index) => { <Grid
const fieldName = getFormFieldName(input.name, index); columnGap={ 3 }
rowGap={{ base: 2, lg: 3 }}
gridTemplateColumns={{ base: 'minmax(0, 1fr)', lg: 'minmax(min-content, 250px) minmax(0, 1fr)' }}
mb={ 3 }
_empty={{ display: 'none' }}
>
{ inputs.map((input, index) => {
const fieldName = getFormFieldName(input.name, index);
if (input.type === 'tuple' && input.components) {
return (
<React.Fragment key={ fieldName }>
{ index !== 0 && <><Box h={{ base: 0, lg: 3 }}/><div/></> }
<Box
fontWeight={ 500 }
lineHeight="20px"
py={{ lg: '6px' }}
fontSize="sm"
wordBreak="break-word"
>
{ input.name } ({ input.type })
</Box>
<div/>
{ input.components.map((component, componentIndex) => {
const fieldName = getFormFieldName(component.name, componentIndex, input.name);
return (
<ContractMethodCallableRow
key={ fieldName }
fieldName={ fieldName }
argName={ component.name }
argType={ component.type }
isDisabled={ isLoading }
onChange={ handleFormChange }
isGrouped
/>
);
}) }
{ index !== inputs.length - 1 && <><Box h={{ base: 0, lg: 3 }}/><div/></> }
</React.Fragment>
);
}
if (input.type === 'tuple' && input.components) {
return ( return (
<React.Fragment key={ fieldName }> <ContractMethodCallableRow
{ index !== 0 && <><Box h={{ base: 0, lg: 3 }}/><div/></> } key={ fieldName }
<Box fieldName={ fieldName }
fontWeight={ 500 } argName={ input.name }
lineHeight="20px" argType={ input.type }
py={{ lg: '6px' }} isDisabled={ isLoading }
fontSize="sm" onChange={ handleFormChange }
wordBreak="break-word" />
>
{ input.name } ({ input.type })
</Box>
<div/>
{ input.components.map((component, componentIndex) => {
const fieldName = getFormFieldName(component.name, componentIndex, input.name);
return (
<ContractMethodCallableRow
key={ fieldName }
fieldName={ fieldName }
argName={ component.name }
argType={ component.type }
isDisabled={ isLoading }
onChange={ handleFormChange }
isGrouped
/>
);
}) }
{ index !== inputs.length - 1 && <><Box h={{ base: 0, lg: 3 }}/><div/></> }
</React.Fragment>
); );
} }) }
</Grid>
return (
<ContractMethodCallableRow
key={ fieldName }
fieldName={ fieldName }
argName={ input.name }
argType={ input.type }
isDisabled={ isLoading }
onChange={ handleFormChange }
/>
);
}) }
<div/>
<Button <Button
isLoading={ isLoading } isLoading={ isLoading }
loadingText={ isWrite ? 'Write' : 'Read' } loadingText={ isWrite ? 'Write' : 'Read' }
...@@ -207,9 +210,9 @@ const ContractMethodCallable = <T extends SmartContractMethod>({ data, onSubmit, ...@@ -207,9 +210,9 @@ const ContractMethodCallable = <T extends SmartContractMethod>({ data, onSubmit,
</chakra.form> </chakra.form>
</FormProvider> </FormProvider>
{ 'outputs' in data && !isWrite && data.outputs.length > 0 && ( { 'outputs' in data && !isWrite && data.outputs.length > 0 && (
<Flex mt={ 3 }> <Flex mt={ 3 } fontSize="sm">
<Icon as={ arrowIcon } boxSize={ 5 } mr={ 1 }/> <Icon as={ arrowIcon } boxSize={ 5 } mr={ 1 }/>
<Text>{ data.outputs.map(({ type }) => type).join(', ') }</Text> <Text>{ data.outputs.map(({ type, name }) => [ name, type ].join(' ')).join(', ') }</Text>
</Flex> </Flex>
) } ) }
{ result && <ResultComponent item={ data } result={ result } onSettle={ handleTxSettle }/> } { result && <ResultComponent item={ data } result={ result } onSettle={ handleTxSettle }/> }
......
...@@ -85,7 +85,7 @@ const ContractMethodsAccordionItem = <T extends SmartContractMethod>({ data, ind ...@@ -85,7 +85,7 @@ const ContractMethodsAccordionItem = <T extends SmartContractMethod>({ data, ind
<AccordionIcon/> <AccordionIcon/>
</AccordionButton> </AccordionButton>
</Element> </Element>
<AccordionPanel pb={ 4 } px={ 0 }> <AccordionPanel pb={ 4 } pr={ 0 } pl="28px">
{ renderContent(data, index, id) } { renderContent(data, index, id) }
</AccordionPanel> </AccordionPanel>
</AccordionItem> </AccordionItem>
......
...@@ -82,7 +82,6 @@ const ContractWriteResultDumb = ({ result, onSettle, txInfo }: Props) => { ...@@ -82,7 +82,6 @@ const ContractWriteResultDumb = ({ result, onSettle, txInfo }: Props) => {
return ( return (
<Box <Box
fontSize="sm" fontSize="sm"
pl={ 3 }
mt={ 3 } mt={ 3 }
alignItems="center" alignItems="center"
whiteSpace="pre-wrap" whiteSpace="pre-wrap"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment