@metamask/rpc-errors
Advanced tools
Comparing version
@@ -9,2 +9,10 @@ # Changelog | ||
## [6.0.0] | ||
### Changed | ||
- Make Data type-parameter optional in JsonRpcError ([#102](https://github.com/MetaMask/rpc-errors/pull/102)) | ||
### Fixed | ||
- **BREAKING**: `undefined` is now not recognized as valid JSON value | ||
- Update dependency `@metamask/utils` from `^5.0.0` to `^8.0.0` ([#101](https://github.com/MetaMask/rpc-errors/pull/101)) | ||
## [5.1.1] | ||
@@ -118,3 +126,4 @@ ### Fixed | ||
[Unreleased]: https://github.com/MetaMask/rpc-errors/compare/v5.1.1...HEAD | ||
[Unreleased]: https://github.com/MetaMask/rpc-errors/compare/v6.0.0...HEAD | ||
[6.0.0]: https://github.com/MetaMask/rpc-errors/compare/v5.1.1...v6.0.0 | ||
[5.1.1]: https://github.com/MetaMask/rpc-errors/compare/v5.1.0...v5.1.1 | ||
@@ -121,0 +130,0 @@ [5.1.0]: https://github.com/MetaMask/rpc-errors/compare/v5.0.0...v5.1.0 |
@@ -40,4 +40,4 @@ export declare const dummyData: { | ||
}; | ||
export declare const validError2: import("..").JsonRpcError<import("..").DataWithOptionalCause>; | ||
export declare const validError3: import("..").JsonRpcError<import("..").DataWithOptionalCause>; | ||
export declare const validError2: import("..").JsonRpcError<import("../utils").OptionalDataWithOptionalCause>; | ||
export declare const validError3: import("..").JsonRpcError<import("../utils").OptionalDataWithOptionalCause>; | ||
export declare const validError4: import("..").JsonRpcError<{ | ||
@@ -44,0 +44,0 @@ foo: string; |
import { JsonRpcError as SerializedJsonRpcError } from '@metamask/utils'; | ||
import { DataWithOptionalCause } from './utils'; | ||
import type { OptionalDataWithOptionalCause } from './utils'; | ||
export type { SerializedJsonRpcError }; | ||
@@ -10,3 +10,3 @@ /** | ||
*/ | ||
export declare class JsonRpcError<T extends DataWithOptionalCause> extends Error { | ||
export declare class JsonRpcError<T extends OptionalDataWithOptionalCause> extends Error { | ||
code: number; | ||
@@ -33,3 +33,3 @@ data?: T; | ||
*/ | ||
export declare class EthereumProviderError<T extends DataWithOptionalCause> extends JsonRpcError<T> { | ||
export declare class EthereumProviderError<T extends OptionalDataWithOptionalCause> extends JsonRpcError<T> { | ||
/** | ||
@@ -36,0 +36,0 @@ * Create an Ethereum Provider JSON-RPC error. |
import { JsonRpcError, EthereumProviderError } from './classes'; | ||
import { DataWithOptionalCause } from './utils'; | ||
type EthereumErrorOptions<T extends DataWithOptionalCause> = { | ||
import { OptionalDataWithOptionalCause } from './utils'; | ||
type EthereumErrorOptions<T extends OptionalDataWithOptionalCause> = { | ||
message?: string; | ||
data?: T; | ||
}; | ||
type ServerErrorOptions<T extends DataWithOptionalCause> = { | ||
type ServerErrorOptions<T extends OptionalDataWithOptionalCause> = { | ||
code: number; | ||
} & EthereumErrorOptions<T>; | ||
type CustomErrorArg<T extends DataWithOptionalCause> = ServerErrorOptions<T>; | ||
type JsonRpcErrorsArg<T extends DataWithOptionalCause> = EthereumErrorOptions<T> | string; | ||
type CustomErrorArg<T extends OptionalDataWithOptionalCause> = ServerErrorOptions<T>; | ||
type JsonRpcErrorsArg<T extends OptionalDataWithOptionalCause> = EthereumErrorOptions<T> | string; | ||
export declare const rpcErrors: { | ||
@@ -19,3 +19,3 @@ /** | ||
*/ | ||
parse: <T extends DataWithOptionalCause>(arg?: JsonRpcErrorsArg<T> | undefined) => JsonRpcError<T>; | ||
parse: <T extends OptionalDataWithOptionalCause>(arg?: JsonRpcErrorsArg<T> | undefined) => JsonRpcError<T>; | ||
/** | ||
@@ -27,3 +27,3 @@ * Get a JSON RPC 2.0 Invalid Request (-32600) error. | ||
*/ | ||
invalidRequest: <T_1 extends DataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_1> | undefined) => JsonRpcError<T_1>; | ||
invalidRequest: <T_1 extends OptionalDataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_1> | undefined) => JsonRpcError<T_1>; | ||
/** | ||
@@ -35,3 +35,3 @@ * Get a JSON RPC 2.0 Invalid Params (-32602) error. | ||
*/ | ||
invalidParams: <T_2 extends DataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_2> | undefined) => JsonRpcError<T_2>; | ||
invalidParams: <T_2 extends OptionalDataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_2> | undefined) => JsonRpcError<T_2>; | ||
/** | ||
@@ -43,3 +43,3 @@ * Get a JSON RPC 2.0 Method Not Found (-32601) error. | ||
*/ | ||
methodNotFound: <T_3 extends DataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_3> | undefined) => JsonRpcError<T_3>; | ||
methodNotFound: <T_3 extends OptionalDataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_3> | undefined) => JsonRpcError<T_3>; | ||
/** | ||
@@ -51,3 +51,3 @@ * Get a JSON RPC 2.0 Internal (-32603) error. | ||
*/ | ||
internal: <T_4 extends DataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_4> | undefined) => JsonRpcError<T_4>; | ||
internal: <T_4 extends OptionalDataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_4> | undefined) => JsonRpcError<T_4>; | ||
/** | ||
@@ -61,3 +61,3 @@ * Get a JSON RPC 2.0 Server error. | ||
*/ | ||
server: <T_5 extends DataWithOptionalCause>(opts: ServerErrorOptions<T_5>) => JsonRpcError<T_5>; | ||
server: <T_5 extends OptionalDataWithOptionalCause>(opts: ServerErrorOptions<T_5>) => JsonRpcError<T_5>; | ||
/** | ||
@@ -69,3 +69,3 @@ * Get an Ethereum JSON RPC Invalid Input (-32000) error. | ||
*/ | ||
invalidInput: <T_6 extends DataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_6> | undefined) => JsonRpcError<T_6>; | ||
invalidInput: <T_6 extends OptionalDataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_6> | undefined) => JsonRpcError<T_6>; | ||
/** | ||
@@ -77,3 +77,3 @@ * Get an Ethereum JSON RPC Resource Not Found (-32001) error. | ||
*/ | ||
resourceNotFound: <T_7 extends DataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_7> | undefined) => JsonRpcError<T_7>; | ||
resourceNotFound: <T_7 extends OptionalDataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_7> | undefined) => JsonRpcError<T_7>; | ||
/** | ||
@@ -85,3 +85,3 @@ * Get an Ethereum JSON RPC Resource Unavailable (-32002) error. | ||
*/ | ||
resourceUnavailable: <T_8 extends DataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_8> | undefined) => JsonRpcError<T_8>; | ||
resourceUnavailable: <T_8 extends OptionalDataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_8> | undefined) => JsonRpcError<T_8>; | ||
/** | ||
@@ -93,3 +93,3 @@ * Get an Ethereum JSON RPC Transaction Rejected (-32003) error. | ||
*/ | ||
transactionRejected: <T_9 extends DataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_9> | undefined) => JsonRpcError<T_9>; | ||
transactionRejected: <T_9 extends OptionalDataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_9> | undefined) => JsonRpcError<T_9>; | ||
/** | ||
@@ -101,3 +101,3 @@ * Get an Ethereum JSON RPC Method Not Supported (-32004) error. | ||
*/ | ||
methodNotSupported: <T_10 extends DataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_10> | undefined) => JsonRpcError<T_10>; | ||
methodNotSupported: <T_10 extends OptionalDataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_10> | undefined) => JsonRpcError<T_10>; | ||
/** | ||
@@ -109,3 +109,3 @@ * Get an Ethereum JSON RPC Limit Exceeded (-32005) error. | ||
*/ | ||
limitExceeded: <T_11 extends DataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_11> | undefined) => JsonRpcError<T_11>; | ||
limitExceeded: <T_11 extends OptionalDataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_11> | undefined) => JsonRpcError<T_11>; | ||
}; | ||
@@ -119,3 +119,3 @@ export declare const providerErrors: { | ||
*/ | ||
userRejectedRequest: <T extends DataWithOptionalCause>(arg?: JsonRpcErrorsArg<T> | undefined) => EthereumProviderError<T>; | ||
userRejectedRequest: <T extends OptionalDataWithOptionalCause>(arg?: JsonRpcErrorsArg<T> | undefined) => EthereumProviderError<T>; | ||
/** | ||
@@ -127,3 +127,3 @@ * Get an Ethereum Provider Unauthorized (4100) error. | ||
*/ | ||
unauthorized: <T_1 extends DataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_1> | undefined) => EthereumProviderError<T_1>; | ||
unauthorized: <T_1 extends OptionalDataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_1> | undefined) => EthereumProviderError<T_1>; | ||
/** | ||
@@ -135,3 +135,3 @@ * Get an Ethereum Provider Unsupported Method (4200) error. | ||
*/ | ||
unsupportedMethod: <T_2 extends DataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_2> | undefined) => EthereumProviderError<T_2>; | ||
unsupportedMethod: <T_2 extends OptionalDataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_2> | undefined) => EthereumProviderError<T_2>; | ||
/** | ||
@@ -143,3 +143,3 @@ * Get an Ethereum Provider Not Connected (4900) error. | ||
*/ | ||
disconnected: <T_3 extends DataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_3> | undefined) => EthereumProviderError<T_3>; | ||
disconnected: <T_3 extends OptionalDataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_3> | undefined) => EthereumProviderError<T_3>; | ||
/** | ||
@@ -151,3 +151,3 @@ * Get an Ethereum Provider Chain Not Connected (4901) error. | ||
*/ | ||
chainDisconnected: <T_4 extends DataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_4> | undefined) => EthereumProviderError<T_4>; | ||
chainDisconnected: <T_4 extends OptionalDataWithOptionalCause>(arg?: JsonRpcErrorsArg<T_4> | undefined) => EthereumProviderError<T_4>; | ||
/** | ||
@@ -159,4 +159,4 @@ * Get a custom Ethereum Provider error. | ||
*/ | ||
custom: <T_5 extends DataWithOptionalCause>(opts: CustomErrorArg<T_5>) => EthereumProviderError<T_5>; | ||
custom: <T_5 extends OptionalDataWithOptionalCause>(opts: CustomErrorArg<T_5>) => EthereumProviderError<T_5>; | ||
}; | ||
export {}; |
@@ -11,4 +11,11 @@ import { Json, JsonRpcError as SerializedJsonRpcError } from '@metamask/utils'; | ||
[key: string]: Json | unknown; | ||
cause: unknown; | ||
cause?: unknown; | ||
}; | ||
/** | ||
* A data object, that must be either: | ||
* | ||
* - A valid DataWithOptionalCause value. | ||
* - undefined. | ||
*/ | ||
export type OptionalDataWithOptionalCause = undefined | DataWithOptionalCause; | ||
export declare const JSON_RPC_SERVER_ERROR_MESSAGE = "Unspecified server error."; | ||
@@ -15,0 +22,0 @@ /** |
{ | ||
"name": "@metamask/rpc-errors", | ||
"version": "5.1.1", | ||
"version": "6.0.0", | ||
"description": "Ethereum RPC and Provider errors.", | ||
@@ -39,3 +39,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@metamask/utils": "^5.0.0", | ||
"@metamask/utils": "^8.0.0", | ||
"fast-safe-stringify": "^2.0.6" | ||
@@ -42,0 +42,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
91756
1.49%1019
0.69%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
Updated