fix: allow error message data from wallet to be displayed (#2157)
This commit is contained in:
parent
5a4c5d800e
commit
72cec2ebcb
@ -242,6 +242,16 @@ export class JsonRpcConnector implements VegaConnector {
|
||||
encodedTransaction: encodeTransaction(transaction),
|
||||
});
|
||||
|
||||
if ('error' in result) {
|
||||
// In the case of sending a tx, error code 3001 indicates that the
|
||||
// user rejected the tx. Returning null will allow the dialog to close immediately
|
||||
if (result.error.code === 3001) {
|
||||
return null;
|
||||
} else {
|
||||
throw this.wrapError(result.error);
|
||||
}
|
||||
}
|
||||
|
||||
const parsedResult = SendTransactionSchema.safeParse(result);
|
||||
|
||||
if (parsedResult.success) {
|
||||
@ -252,12 +262,6 @@ export class JsonRpcConnector implements VegaConnector {
|
||||
signature: parsedResult.data.result.transaction.signature.value,
|
||||
};
|
||||
} else {
|
||||
// In the case of sending a tx, return null instead of throwing
|
||||
// this indicates to the app that the user rejected the tx rather
|
||||
// than it being a true error
|
||||
if ('error' in result && result.error.code === 3001) {
|
||||
return null;
|
||||
}
|
||||
throw ClientErrors.INVALID_RESPONSE;
|
||||
}
|
||||
}
|
||||
|
@ -108,9 +108,10 @@ export const VegaDialog = ({ transaction }: VegaDialogProps) => {
|
||||
if (transaction.status === VegaTxStatus.Error) {
|
||||
content = (
|
||||
<div data-testid={transaction.status}>
|
||||
<p>{transaction.error && transaction.error.message}</p>
|
||||
{transaction.error && transaction.error.data && (
|
||||
<p>{transaction.error.data}</p>
|
||||
{transaction.error && (
|
||||
<p>
|
||||
{transaction.error.message}: {transaction.error.data}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user