Files
explore/ui/address/contract/methods/form/ContractMethodResultPublicClient.tsx

37 lines
867 B
TypeScript

import React from 'react';
import { Alert } from '@luxfi/ui/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" className="text-sm break-words whitespace-pre-wrap">
{ 'shortMessage' in data && typeof data.shortMessage === 'string' ? data.shortMessage : data.message }
</Alert>
);
}
if (estimatedGas) {
return (
<Alert status="info" className="text-sm break-words whitespace-pre-wrap">
Success. Estimated gas: { estimatedGas.toLocaleString() }
</Alert>
);
}
return null;
};
export default React.memo(ContractMethodResultPublicClient);