fix: allow error message data from wallet to be displayed (#2157)

This commit is contained in:
Matthew Russell 2022-11-18 02:24:04 -06:00 committed by GitHub
parent 5a4c5d800e
commit 72cec2ebcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 9 deletions

View File

@ -242,6 +242,16 @@ export class JsonRpcConnector implements VegaConnector {
encodedTransaction: encodeTransaction(transaction), 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); const parsedResult = SendTransactionSchema.safeParse(result);
if (parsedResult.success) { if (parsedResult.success) {
@ -252,12 +262,6 @@ export class JsonRpcConnector implements VegaConnector {
signature: parsedResult.data.result.transaction.signature.value, signature: parsedResult.data.result.transaction.signature.value,
}; };
} else { } 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; throw ClientErrors.INVALID_RESPONSE;
} }
} }

View File

@ -108,9 +108,10 @@ export const VegaDialog = ({ transaction }: VegaDialogProps) => {
if (transaction.status === VegaTxStatus.Error) { if (transaction.status === VegaTxStatus.Error) {
content = ( content = (
<div data-testid={transaction.status}> <div data-testid={transaction.status}>
<p>{transaction.error && transaction.error.message}</p> {transaction.error && (
{transaction.error && transaction.error.data && ( <p>
<p>{transaction.error.data}</p> {transaction.error.message}: {transaction.error.data}
</p>
)} )}
</div> </div>
); );