mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* Contract interactions: simulate transactions and output gas price Resolves #2910 * prevent form with tuples and arrays from being submitted without required fields * update screenshots * add simulate button to receive method
55 lines
1.3 KiB
TypeScript
55 lines
1.3 KiB
TypeScript
import React from 'react';
|
|
import type { AbiFunction } from 'viem';
|
|
|
|
import type { AbiFallback, ResultViewMode } from '../types';
|
|
|
|
import { Alert } from 'toolkit/chakra/alert';
|
|
|
|
import ResultItem from './resultPublicClient/Item';
|
|
|
|
export interface Props {
|
|
data: unknown;
|
|
abiItem: AbiFunction | AbiFallback;
|
|
onSettle: () => void;
|
|
mode: ResultViewMode;
|
|
}
|
|
|
|
const ContractMethodOutput = ({ data, abiItem, onSettle, mode }: Props) => {
|
|
React.useEffect(() => {
|
|
if (mode === 'result') {
|
|
onSettle();
|
|
}
|
|
}, [ onSettle, mode ]);
|
|
|
|
const formattedData = (() => {
|
|
return abiItem && abiItem.outputs.length > 1 && Array.isArray(data) ? data : [ data ];
|
|
})();
|
|
|
|
return (
|
|
<Alert
|
|
status="info"
|
|
flexDir="column"
|
|
color={ mode === 'preview' ? 'gray.500' : undefined }
|
|
textStyle="sm"
|
|
descriptionProps={{
|
|
flexDir: 'column',
|
|
alignItems: 'flex-start',
|
|
rowGap: 2,
|
|
whiteSpace: 'break-spaces',
|
|
wordBreak: 'break-all',
|
|
}}
|
|
>
|
|
{ abiItem.outputs.map((output, index) => (
|
|
<ResultItem
|
|
key={ index }
|
|
abiParameter={ output }
|
|
data={ formattedData[index] }
|
|
mode={ mode }
|
|
/>
|
|
)) }
|
|
</Alert>
|
|
);
|
|
};
|
|
|
|
export default React.memo(ContractMethodOutput);
|