@metamask/providers
Advanced tools
Comparing version 11.1.2 to 12.0.0
@@ -9,2 +9,8 @@ # Changelog | ||
## [12.0.0] | ||
### Changed | ||
- **BREAKING**: Replace `eth-rpc-errors`@`^4.0.2` with `@metamask/rpc-errors`@`6.0.0` ([#277](https://github.com/MetaMask/providers/pull/277)) | ||
- **BREAKING**: Replace `json-rpc-engine`@`^6.1.0` with `@metamask/json-rpc-engine`@`7.1.1` ([#277](https://github.com/MetaMask/providers/pull/277)) | ||
- Upgrade `@metamask/utils` from `^6.2.0` to `^8.1.0` ([#277](https://github.com/MetaMask/providers/pull/277)) | ||
## [11.1.2] | ||
@@ -236,3 +242,4 @@ ### Changed | ||
[Unreleased]: https://github.com/MetaMask/providers/compare/v11.1.2...HEAD | ||
[Unreleased]: https://github.com/MetaMask/providers/compare/v12.0.0...HEAD | ||
[12.0.0]: https://github.com/MetaMask/providers/compare/v11.1.2...v12.0.0 | ||
[11.1.2]: https://github.com/MetaMask/providers/compare/v11.1.1...v11.1.2 | ||
@@ -239,0 +246,0 @@ [11.1.1]: https://github.com/MetaMask/providers/compare/v11.1.0...v11.1.1 |
@@ -0,7 +1,8 @@ | ||
import { JsonRpcEngine, JsonRpcMiddleware } from '@metamask/json-rpc-engine'; | ||
import SafeEventEmitter from '@metamask/safe-event-emitter'; | ||
import { JsonRpcEngine, JsonRpcId, JsonRpcVersion, JsonRpcMiddleware } from 'json-rpc-engine'; | ||
import { JsonRpcId, JsonRpcVersion2, JsonRpcParams, Json } from '@metamask/utils'; | ||
import { ConsoleLike, Maybe } from './utils'; | ||
export declare type UnvalidatedJsonRpcRequest = { | ||
id?: JsonRpcId; | ||
jsonrpc?: JsonRpcVersion; | ||
jsonrpc?: JsonRpcVersion2; | ||
method: string; | ||
@@ -20,6 +21,6 @@ params?: unknown; | ||
/** | ||
* `json-rpc-engine` middleware. The middleware will be inserted in the given | ||
* `@metamask/json-rpc-engine` middleware. The middleware will be inserted in the given | ||
* order immediately after engine initialization. | ||
*/ | ||
rpcMiddleware?: JsonRpcMiddleware<unknown, unknown>[]; | ||
rpcMiddleware?: JsonRpcMiddleware<JsonRpcParams, Json>[]; | ||
}; | ||
@@ -26,0 +27,0 @@ export declare type RequestArguments = { |
@@ -7,6 +7,6 @@ "use strict"; | ||
exports.BaseProvider = void 0; | ||
const json_rpc_engine_1 = require("@metamask/json-rpc-engine"); | ||
const rpc_errors_1 = require("@metamask/rpc-errors"); | ||
const safe_event_emitter_1 = __importDefault(require("@metamask/safe-event-emitter")); | ||
const eth_rpc_errors_1 = require("eth-rpc-errors"); | ||
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal")); | ||
const json_rpc_engine_1 = require("json-rpc-engine"); | ||
const messages_1 = __importDefault(require("./messages")); | ||
@@ -84,3 +84,3 @@ const utils_1 = require("./utils"); | ||
if (!args || typeof args !== 'object' || Array.isArray(args)) { | ||
throw eth_rpc_errors_1.ethErrors.rpc.invalidRequest({ | ||
throw rpc_errors_1.rpcErrors.invalidRequest({ | ||
message: messages_1.default.errors.invalidRequestArgs(), | ||
@@ -92,3 +92,3 @@ data: args, | ||
if (typeof method !== 'string' || method.length === 0) { | ||
throw eth_rpc_errors_1.ethErrors.rpc.invalidRequest({ | ||
throw rpc_errors_1.rpcErrors.invalidRequest({ | ||
message: messages_1.default.errors.invalidRequestMethod(), | ||
@@ -101,3 +101,3 @@ data: args, | ||
(typeof params !== 'object' || params === null)) { | ||
throw eth_rpc_errors_1.ethErrors.rpc.invalidRequest({ | ||
throw rpc_errors_1.rpcErrors.invalidRequest({ | ||
message: messages_1.default.errors.invalidRequestParams(), | ||
@@ -205,3 +205,3 @@ data: args, | ||
if (isRecoverable) { | ||
error = new eth_rpc_errors_1.EthereumRpcError(1013, // Try again later | ||
error = new rpc_errors_1.JsonRpcError(1013, // Try again later | ||
errorMessage ?? messages_1.default.errors.disconnected()); | ||
@@ -211,3 +211,3 @@ this._log.debug(error); | ||
else { | ||
error = new eth_rpc_errors_1.EthereumRpcError(1011, // Internal error | ||
error = new rpc_errors_1.JsonRpcError(1011, // Internal error | ||
errorMessage ?? messages_1.default.errors.permanentlyDisconnected()); | ||
@@ -214,0 +214,0 @@ this._log.error(error); |
/// <reference types="node" /> | ||
import type { JsonRpcRequest, JsonRpcResponse } from 'json-rpc-engine'; | ||
import type { Json, JsonRpcRequest, JsonRpcResponse } from '@metamask/utils'; | ||
import type { Duplex } from 'stream'; | ||
import type { UnvalidatedJsonRpcRequest } from './BaseProvider'; | ||
import { UnvalidatedJsonRpcRequest } from './BaseProvider'; | ||
import { AbstractStreamProvider, StreamProviderOptions } from './StreamProvider'; | ||
export declare type SendSyncJsonRpcRequest = { | ||
method: 'eth_accounts' | 'eth_coinbase' | 'eth_uninstallFilter' | 'net_version'; | ||
} & JsonRpcRequest<unknown>; | ||
} & JsonRpcRequest; | ||
export declare type MetaMaskInpageProviderOptions = { | ||
@@ -62,3 +62,3 @@ /** | ||
*/ | ||
sendAsync(payload: JsonRpcRequest<unknown>, callback: (error: Error | null, result?: JsonRpcResponse<unknown>) => void): void; | ||
sendAsync(payload: JsonRpcRequest, callback: (error: Error | null, result?: JsonRpcResponse<Json>) => void): void; | ||
/** | ||
@@ -108,3 +108,3 @@ * We override the following event methods so that we can warn consumers | ||
*/ | ||
send<T>(method: string, params?: T[]): Promise<JsonRpcResponse<T>>; | ||
send<T extends Json>(method: string, params?: T[]): Promise<JsonRpcResponse<T>>; | ||
/** | ||
@@ -118,3 +118,3 @@ * Submits an RPC request per the given JSON-RPC request object. | ||
*/ | ||
send<T>(payload: JsonRpcRequest<unknown>, callback: (error: Error | null, result?: JsonRpcResponse<T>) => void): void; | ||
send<T extends Json>(payload: JsonRpcRequest, callback: (error: Error | null, result?: JsonRpcResponse<T>) => void): void; | ||
/** | ||
@@ -128,3 +128,3 @@ * Accepts a JSON-RPC request object, and synchronously returns the cached result | ||
*/ | ||
send<T>(payload: SendSyncJsonRpcRequest): JsonRpcResponse<T>; | ||
send<T extends Json>(payload: SendSyncJsonRpcRequest): JsonRpcResponse<T>; | ||
/** | ||
@@ -138,3 +138,3 @@ * Internal backwards compatibility method, used in send. | ||
protected _sendSync(payload: SendSyncJsonRpcRequest): { | ||
id: import("json-rpc-engine").JsonRpcId; | ||
id: string | number | null; | ||
jsonrpc: "2.0"; | ||
@@ -141,0 +141,0 @@ result: string | boolean | string[] | null; |
@@ -7,3 +7,3 @@ "use strict"; | ||
exports.MetaMaskInpageProvider = exports.MetaMaskInpageProviderStreamName = void 0; | ||
const eth_rpc_errors_1 = require("eth-rpc-errors"); | ||
const rpc_errors_1 = require("@metamask/rpc-errors"); | ||
const messages_1 = __importDefault(require("./messages")); | ||
@@ -269,3 +269,3 @@ const siteMetadata_1 = require("./siteMetadata"); | ||
if (!Array.isArray(requests)) { | ||
throw eth_rpc_errors_1.ethErrors.rpc.invalidRequest({ | ||
throw rpc_errors_1.rpcErrors.invalidRequest({ | ||
message: 'Batch requests must be made with an array of request objects.', | ||
@@ -272,0 +272,0 @@ data: requests, |
@@ -1,2 +0,3 @@ | ||
import type { JsonRpcMiddleware } from 'json-rpc-engine'; | ||
import type { JsonRpcMiddleware } from '@metamask/json-rpc-engine'; | ||
import type { Json, JsonRpcParams } from '@metamask/utils'; | ||
import type { ConsoleLike } from '../utils'; | ||
@@ -9,2 +10,2 @@ /** | ||
*/ | ||
export declare function createRpcWarningMiddleware(log: ConsoleLike): JsonRpcMiddleware<unknown, unknown>; | ||
export declare function createRpcWarningMiddleware(log: ConsoleLike): JsonRpcMiddleware<JsonRpcParams, Json>; |
@@ -1,2 +0,2 @@ | ||
import { JsonRpcEngine } from 'json-rpc-engine'; | ||
import { JsonRpcEngine } from '@metamask/json-rpc-engine'; | ||
import { ConsoleLike } from './utils'; | ||
@@ -3,0 +3,0 @@ /** |
/// <reference types="node" /> | ||
import type { JsonRpcMiddleware } from '@metamask/json-rpc-engine'; | ||
import SafeEventEmitter from '@metamask/safe-event-emitter'; | ||
import type { JsonRpcMiddleware } from 'json-rpc-engine'; | ||
import { Json, JsonRpcParams } from '@metamask/utils'; | ||
import type { Duplex } from 'stream'; | ||
@@ -14,3 +15,3 @@ import { BaseProvider, BaseProviderOptions } from './BaseProvider'; | ||
events: SafeEventEmitter; | ||
middleware: JsonRpcMiddleware<unknown, unknown>; | ||
middleware: JsonRpcMiddleware<JsonRpcParams, Json>; | ||
stream: Duplex; | ||
@@ -17,0 +18,0 @@ }; |
@@ -1,2 +0,3 @@ | ||
import { JsonRpcMiddleware, PendingJsonRpcResponse } from 'json-rpc-engine'; | ||
import { JsonRpcMiddleware } from '@metamask/json-rpc-engine'; | ||
import { Json, JsonRpcParams, PendingJsonRpcResponse } from '@metamask/utils'; | ||
export declare type Maybe<T> = Partial<T> | null | undefined; | ||
@@ -10,6 +11,6 @@ export declare type ConsoleLike = Pick<Console, 'log' | 'warn' | 'error' | 'debug' | 'info' | 'trace'>; | ||
* @param logger - The logger to use in the error middleware. | ||
* @returns An array of json-rpc-engine middleware functions. | ||
* @returns An array of @metamask/json-rpc-engine middleware functions. | ||
*/ | ||
export declare const getDefaultExternalMiddleware: (logger?: ConsoleLike) => JsonRpcMiddleware<unknown, unknown>[]; | ||
export declare const getRpcPromiseCallback: (resolve: (value?: any) => void, reject: (error?: Error) => void, unwrapResult?: boolean) => (error: Error, response: PendingJsonRpcResponse<unknown>) => void; | ||
export declare const getDefaultExternalMiddleware: (logger?: ConsoleLike) => JsonRpcMiddleware<JsonRpcParams, Json>[]; | ||
export declare const getRpcPromiseCallback: (resolve: (value?: any) => void, reject: (error?: Error) => void, unwrapResult?: boolean) => (error: Error, response: PendingJsonRpcResponse<Json>) => void; | ||
/** | ||
@@ -16,0 +17,0 @@ * Checks whether the given chain ID is valid, meaning if it is non-empty, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NOOP = exports.isValidNetworkVersion = exports.isValidChainId = exports.getRpcPromiseCallback = exports.getDefaultExternalMiddleware = exports.EMITTED_NOTIFICATIONS = void 0; | ||
const eth_rpc_errors_1 = require("eth-rpc-errors"); | ||
const json_rpc_engine_1 = require("json-rpc-engine"); | ||
const json_rpc_engine_1 = require("@metamask/json-rpc-engine"); | ||
const rpc_errors_1 = require("@metamask/rpc-errors"); | ||
const createRpcWarningMiddleware_1 = require("./middleware/createRpcWarningMiddleware"); | ||
@@ -17,3 +17,3 @@ // Constants | ||
* @param logger - The logger to use in the error middleware. | ||
* @returns An array of json-rpc-engine middleware functions. | ||
* @returns An array of @metamask/json-rpc-engine middleware functions. | ||
*/ | ||
@@ -31,3 +31,3 @@ const getDefaultExternalMiddleware = (logger = console) => [ | ||
* @param log - The logging API to use. | ||
* @returns A json-rpc-engine middleware function. | ||
* @returns A @metamask/json-rpc-engine middleware function. | ||
*/ | ||
@@ -38,3 +38,3 @@ function createErrorMiddleware(log) { | ||
if (typeof request.method !== 'string' || !request.method) { | ||
response.error = eth_rpc_errors_1.ethErrors.rpc.invalidRequest({ | ||
response.error = rpc_errors_1.rpcErrors.invalidRequest({ | ||
message: `The request 'method' must be a non-empty string.`, | ||
@@ -41,0 +41,0 @@ data: request, |
{ | ||
"name": "@metamask/providers", | ||
"version": "11.1.2", | ||
"version": "12.0.0", | ||
"description": "A JavaScript Ethereum provider that connects to the wallet over a stream.", | ||
@@ -40,10 +40,11 @@ "keywords": [ | ||
"dependencies": { | ||
"@metamask/json-rpc-engine": "^7.1.1", | ||
"@metamask/object-multiplex": "^1.1.0", | ||
"@metamask/rpc-errors": "^6.0.0", | ||
"@metamask/safe-event-emitter": "^3.0.0", | ||
"@metamask/utils": "^8.1.0", | ||
"detect-browser": "^5.2.0", | ||
"eth-rpc-errors": "^4.0.2", | ||
"extension-port-stream": "^2.1.1", | ||
"fast-deep-equal": "^3.1.3", | ||
"is-stream": "^2.0.0", | ||
"json-rpc-engine": "^6.1.0", | ||
"json-rpc-middleware-stream": "^4.2.1", | ||
@@ -50,0 +51,0 @@ "pump": "^3.0.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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
187032
1849
12
+ Added@metamask/rpc-errors@^6.0.0
+ Added@metamask/utils@^8.1.0
+ Added@ethereumjs/common@3.2.0(transitive)
+ Added@ethereumjs/rlp@4.0.1(transitive)
+ Added@ethereumjs/tx@4.2.0(transitive)
+ Added@ethereumjs/util@8.1.0(transitive)
+ Added@metamask/json-rpc-engine@7.3.3(transitive)
+ Added@metamask/rpc-errors@6.4.0(transitive)
+ Added@metamask/superstruct@3.1.0(transitive)
+ Added@metamask/utils@8.5.09.3.0(transitive)
+ Added@noble/curves@1.4.2(transitive)
+ Added@noble/hashes@1.4.01.5.0(transitive)
+ Added@scure/base@1.1.9(transitive)
+ Added@scure/bip32@1.4.0(transitive)
+ Added@scure/bip39@1.3.0(transitive)
+ Added@types/debug@4.1.12(transitive)
+ Added@types/ms@0.7.34(transitive)
+ Addedcrc-32@1.2.2(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addedethereum-cryptography@2.2.1(transitive)
+ Addedmicro-ftch@0.3.1(transitive)
+ Addedms@2.1.3(transitive)
+ Addedpony-cause@2.1.11(transitive)
+ Addedsemver@7.6.3(transitive)
+ Addeduuid@9.0.1(transitive)
- Removedeth-rpc-errors@^4.0.2
- Removedjson-rpc-engine@^6.1.0