mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-11 11:34:26 +00:00
Fix metamask reject error (#957)
This commit is contained in:
parent
0017d5f075
commit
3f4837c7c5
@ -9,7 +9,7 @@ import {
|
|||||||
isValidSignMessage,
|
isValidSignMessage,
|
||||||
isValidGetAccounts,
|
isValidGetAccounts,
|
||||||
isValidGetNetVersion
|
isValidGetNetVersion
|
||||||
} from '../../validators';
|
} from 'libs/validators';
|
||||||
|
|
||||||
export default class Web3Node extends RPCNode {
|
export default class Web3Node extends RPCNode {
|
||||||
public client: Web3Client;
|
public client: Web3Client;
|
||||||
|
@ -192,8 +192,17 @@ function isValidResult(response: JsonRpcResponse, schemaFormat): boolean {
|
|||||||
|
|
||||||
function formatErrors(response: JsonRpcResponse, apiType: string) {
|
function formatErrors(response: JsonRpcResponse, apiType: string) {
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
|
// Metamask errors are sometimes full-blown stacktraces, no bueno. Instead,
|
||||||
|
// We'll just take the first line of it, and the last thing after all of
|
||||||
|
// the colons. An example error message would be:
|
||||||
|
// "Error: Metamask Sign Tx Error: User rejected the signature."
|
||||||
|
const lines = response.error.message.split('\n');
|
||||||
|
if (lines.length > 2) {
|
||||||
|
return lines[0].split(':').pop();
|
||||||
|
} else {
|
||||||
return `${response.error.message} ${response.error.data || ''}`;
|
return `${response.error.message} ${response.error.data || ''}`;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return `Invalid ${apiType} Error`;
|
return `Invalid ${apiType} Error`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user