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

Fix 4902 (unsupportedChain) error getting wrapped as -32603 & Fork eth-rpc-errors #954

Merged
merged 5 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/wallet-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"clsx": "^1.2.1",
"eth-block-tracker": "6.1.0",
"eth-json-rpc-filters": "5.1.0",
"eth-rpc-errors": "4.0.3",
"eventemitter3": "^5.0.1",
"json-rpc-engine": "6.1.0",
"keccak": "^3.0.3",
Expand Down
158 changes: 0 additions & 158 deletions packages/wallet-sdk/src/errors.ts

This file was deleted.

119 changes: 119 additions & 0 deletions packages/wallet-sdk/src/errors/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
interface ErrorCodes {
readonly rpc: {
readonly invalidInput: -32000;
readonly resourceNotFound: -32001;
readonly resourceUnavailable: -32002;
readonly transactionRejected: -32003;
readonly methodNotSupported: -32004;
readonly limitExceeded: -32005;
readonly parse: -32700;
readonly invalidRequest: -32600;
readonly methodNotFound: -32601;
readonly invalidParams: -32602;
readonly internal: -32603;
};
readonly provider: {
readonly userRejectedRequest: 4001;
readonly unauthorized: 4100;
readonly unsupportedMethod: 4200;
readonly disconnected: 4900;
readonly chainDisconnected: 4901;
readonly unsupportedChain: 4902;
};
}

export const standardErrorCodes: ErrorCodes = {
rpc: {
invalidInput: -32000,
resourceNotFound: -32001,
resourceUnavailable: -32002,
transactionRejected: -32003,
methodNotSupported: -32004,
limitExceeded: -32005,
parse: -32700,
invalidRequest: -32600,
methodNotFound: -32601,
invalidParams: -32602,
internal: -32603,
},
provider: {
userRejectedRequest: 4001,
unauthorized: 4100,
unsupportedMethod: 4200,
disconnected: 4900,
chainDisconnected: 4901,
unsupportedChain: 4902,
},
};

export const errorValues = {
'-32700': {
standard: 'JSON RPC 2.0',
message:
'Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.',
},
'-32600': {
standard: 'JSON RPC 2.0',
message: 'The JSON sent is not a valid Request object.',
},
'-32601': {
standard: 'JSON RPC 2.0',
message: 'The method does not exist / is not available.',
},
'-32602': {
standard: 'JSON RPC 2.0',
message: 'Invalid method parameter(s).',
},
'-32603': {
standard: 'JSON RPC 2.0',
message: 'Internal JSON-RPC error.',
},
'-32000': {
standard: 'EIP-1474',
message: 'Invalid input.',
},
'-32001': {
standard: 'EIP-1474',
message: 'Resource not found.',
},
'-32002': {
standard: 'EIP-1474',
message: 'Resource unavailable.',
},
'-32003': {
standard: 'EIP-1474',
message: 'Transaction rejected.',
},
'-32004': {
standard: 'EIP-1474',
message: 'Method not supported.',
},
'-32005': {
standard: 'EIP-1474',
message: 'Request limit exceeded.',
},
'4001': {
standard: 'EIP-1193',
message: 'User rejected the request.',
},
'4100': {
standard: 'EIP-1193',
message: 'The requested account and/or method has not been authorized by the user.',
},
'4200': {
standard: 'EIP-1193',
message: 'The requested method is not supported by this Ethereum provider.',
},
'4900': {
standard: 'EIP-1193',
message: 'The provider is disconnected from all chains.',
},
'4901': {
standard: 'EIP-1193',
message: 'The provider is disconnected from the specified chain.',
},
'4902': {
standard: 'EIP-3085',
message: 'Unrecognized chain ID.',
},
};
Loading