mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
37 lines
867 B
TypeScript
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);
|