Skip to content

Commit

Permalink
fix: Allow optional jsonRpcStreamName for inpage provider (#390)
Browse files Browse the repository at this point in the history
* fix: Allow optional `jsonRpcStreamName` for inpage provider

The `MetaMaskInpageProvider` type was mistakenly typed to require the
`jsonRpcStreamName` as a constructor parameter, despite the author
clearly intending this to be optional. This type error was fixed.

This type error motivated a different bug, which is that validation for
`jsonRpcStreamName` was added to `initializeInapgeProvider` in #381,
constituting an undocumented breaking change (currently blocking us
from updating this package in `metamask-extension`). This validation
has been removed now that it's no longer needed.

Fixes #389

* Update test coverage
  • Loading branch information
Gudahtt authored Nov 27, 2024
1 parent 82d2779 commit b8e6186
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ const baseConfig = {
// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
branches: 64.35,
branches: 64.65,
functions: 65.65,
lines: 65.21,
statements: 65.32,
lines: 65.51,
statements: 65.61,
},
},

Expand Down
2 changes: 1 addition & 1 deletion src/MetaMaskInpageProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type MetaMaskInpageProviderOptions = {
shouldSendMetadata?: boolean;

jsonRpcStreamName?: string | undefined;
} & Partial<Omit<StreamProviderOptions, 'rpcMiddleware'>>;
} & Partial<Omit<StreamProviderOptions, 'rpcMiddleware' | 'jsonRpcStreamName'>>;

type SentWarningsState = {
// methods
Expand Down
3 changes: 0 additions & 3 deletions src/initializeInpageProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ export function initializeProvider({
shouldSetOnWindow = true,
shouldShimWeb3 = false,
}: InitializeProviderOptions): MetaMaskInpageProvider {
if (!jsonRpcStreamName) {
throw new Error('Required paramater: jsonRpcStreamName');
}
const provider = new MetaMaskInpageProvider(connectionStream, {
jsonRpcStreamName,
logger,
Expand Down

0 comments on commit b8e6186

Please sign in to comment.