Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show broken tx #1063

Merged
merged 12 commits into from
Jan 30, 2024
5 changes: 5 additions & 0 deletions .changeset/twelve-lemons-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'fuels-wallet': patch
---

Add an error message for a failed simulated tx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { cssObj } from '@fuel-ui/css';
import { Alert, Button } from '@fuel-ui/react';
import { TransactionStatus } from 'fuels';
import { useAssets } from '~/systems/Asset';
import { Layout, ConnectInfo } from '~/systems/Core';
import { TopBarType } from '~/systems/Core/components/Layout/TopBar';
Expand All @@ -25,12 +26,27 @@ export function TransactionRequest() {
title={ctx.input.title}
headerText="Requesting a transaction from:"
/>
<Alert status="warning" css={styles.alert}>
<Alert.Title>Confirm before approving</Alert.Title>
<Alert.Description>
Carefully check if all the details in your transaction are correct
</Alert.Description>
</Alert>
{txResult?.status === TransactionStatus.failure ? (
<Alert status="error" css={styles.alert}>
<Alert.Title>
Simulating your transaction resulted in an error
</Alert.Title>
<Alert.Description>
{`Carefully check if all the details in your transaction are correct. ${
txResult?.operations.length
? `Operations: ${txResult?.operations}`
: ''
}`}
</Alert.Description>
</Alert>
) : (
<Alert status="warning" css={styles.alert}>
<Alert.Title>Confirm before approving</Alert.Title>
<Alert.Description>
Carefully check if all the details in your transaction are correct
</Alert.Description>
</Alert>
)}
</>
);

Expand Down Expand Up @@ -91,6 +107,7 @@ export function TransactionRequest() {
intent="primary"
onPress={handlers.approve}
isLoading={ctx.isLoading || status('sending')}
isDisabled={txResult?.status === TransactionStatus.failure}
>
Approve
</Button>
Expand Down
11 changes: 11 additions & 0 deletions packages/app/src/systems/Transaction/services/transaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
hexlify,
processGqlReceipt,
BN,
TransactionStatus,
} from 'fuels';
import { isEth } from '~/systems/Asset/utils/asset';
import { db, uniqueId, WalletLockedCustom } from '~/systems/Core';
Expand Down Expand Up @@ -189,6 +190,16 @@ export class TxService {
maxInputs,
});

// Workaround until https://github.com/FuelLabs/fuels-ts/issues/1674 is fixed
transactionSummary.isStatusFailure = transactionSummary.receipts.some(
(receipt) => {
return receipt.type === 3;
}
);
if (transactionSummary.isStatusFailure) {
transactionSummary.status = TransactionStatus.failure;
}

return transactionSummary;
}

Expand Down
Loading