Files
explore/ui/address/contract/methods/form/ContractMethodResultPublicClient.tsx
tom goriunovandGitHub e18e02c910 Contract interactions: estimated gas for write methods simulation (#3004)
* 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
2025-09-24 18:48:28 +02:00

37 lines
888 B
TypeScript

import React from 'react';
import { Alert } from 'toolkit/chakra/alert';
export interface Props {
data: unknown;
onSettle: () => void;
estimatedGas?: bigint;
}
const ContractMethodResultPublicClient = ({ data, estimatedGas, onSettle }: Props) => {
React.useEffect(() => {
onSettle();
}, [ onSettle ]);
if (data instanceof Error) {
return (
<Alert status="error" textStyle="sm" wordBreak="break-word" whiteSpace="pre-wrap">
{ 'shortMessage' in data && typeof data.shortMessage === 'string' ? data.shortMessage : data.message }
</Alert>
);
}
if (estimatedGas) {
return (
<Alert status="info" textStyle="sm" wordBreak="break-word" whiteSpace="pre-wrap">
Success. Estimated gas: { estimatedGas.toLocaleString() }
</Alert>
);
}
return null;
};
export default React.memo(ContractMethodResultPublicClient);