fix: wallet errors incorrectly showing as user rejections (#1737)
This commit is contained in:
parent
cb92a30015
commit
dee0b016eb
@ -254,7 +254,7 @@ export class JsonRpcConnector implements VegaConnector {
|
|||||||
} else {
|
} else {
|
||||||
// In the case of sending a tx, return null instead of throwing
|
// In the case of sending a tx, return null instead of throwing
|
||||||
// this indicates to the app that the user rejected the tx rather
|
// this indicates to the app that the user rejected the tx rather
|
||||||
// than it being a true erroor
|
// than it being a true error
|
||||||
if ('error' in result && result.error.code === 3001) {
|
if ('error' in result && result.error.code === 3001) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -162,42 +162,37 @@ export class RestConnector implements VegaConnector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async sendTx(pubKey: string, transaction: Transaction) {
|
async sendTx(pubKey: string, transaction: Transaction) {
|
||||||
try {
|
const body = {
|
||||||
const body = {
|
pubKey,
|
||||||
pubKey,
|
propagate: true,
|
||||||
propagate: true,
|
...transaction,
|
||||||
...transaction,
|
};
|
||||||
};
|
const res = await this.request(Endpoints.Command, {
|
||||||
const res = await this.request(Endpoints.Command, {
|
method: 'post',
|
||||||
method: 'post',
|
body: JSON.stringify(body),
|
||||||
body: JSON.stringify(body),
|
headers: {
|
||||||
headers: {
|
authorization: `Bearer ${this.token}`,
|
||||||
authorization: `Bearer ${this.token}`,
|
},
|
||||||
},
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// User rejected
|
// User rejected
|
||||||
if (res.status === 401) {
|
if (res.status === 401) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res.error) {
|
|
||||||
throw new WalletError(res.error, 1, res.details);
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = TransactionResponseSchema.parse(res.data);
|
|
||||||
|
|
||||||
// Make return value match that of v2 service
|
|
||||||
return {
|
|
||||||
transactionHash: data.txHash,
|
|
||||||
signature: data.tx.signature.value,
|
|
||||||
receivedAt: data.receivedAt,
|
|
||||||
sentAt: data.sentAt,
|
|
||||||
};
|
|
||||||
} catch (err) {
|
|
||||||
Sentry.captureException(err);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (res.error) {
|
||||||
|
throw new WalletError(res.error, 1, res.details);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = TransactionResponseSchema.parse(res.data);
|
||||||
|
|
||||||
|
// Make return value match that of v2 service
|
||||||
|
return {
|
||||||
|
transactionHash: data.txHash,
|
||||||
|
signature: data.tx.signature.value,
|
||||||
|
receivedAt: data.receivedAt,
|
||||||
|
sentAt: data.sentAt,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Parse more complex error object into a single string */
|
/** Parse more complex error object into a single string */
|
||||||
|
Loading…
Reference in New Issue
Block a user