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

Passing configuration options to JSON stream middleware #223

Merged
merged 4 commits into from Oct 7, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -50,7 +50,7 @@
"fast-deep-equal": "^2.0.1",
"is-stream": "^2.0.0",
"json-rpc-engine": "^6.1.0",
"json-rpc-middleware-stream": "^3.0.0",
"json-rpc-middleware-stream": "^4.0.0",
"pump": "^3.0.0",
"webextension-polyfill-ts": "^0.25.0"
},
Expand Down
4 changes: 3 additions & 1 deletion src/StreamProvider.ts
Expand Up @@ -71,7 +71,9 @@ export abstract class AbstractStreamProvider extends BaseProvider {
);

// Set up RPC connection
this._jsonRpcConnection = createStreamMiddleware();
this._jsonRpcConnection = createStreamMiddleware({
retryOnMessage: 'METAMASK_EXTENSION_STREAM_CONNECT',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this message sent? Just trying to understand the whole solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message is sent from contentScript when extension stream is connected https://github.com/MetaMask/metamask-extension/blob/develop/app/scripts/contentscript.js#L395

});
pump(
this._jsonRpcConnection.stream,
mux.createStream(jsonRpcStreamName) as unknown as Duplex,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -3490,10 +3490,10 @@ json-rpc-engine@^6.1.0:
"@metamask/safe-event-emitter" "^2.0.0"
eth-rpc-errors "^4.0.2"

json-rpc-middleware-stream@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/json-rpc-middleware-stream/-/json-rpc-middleware-stream-3.0.0.tgz#8540331d884f36b9e0ad31054cc68ac6b5a89b52"
integrity sha512-JmZmlehE0xF3swwORpLHny/GvW3MZxCsb2uFNBrn8TOqMqivzCfz232NSDLLOtIQlrPlgyEjiYpyzyOPFOzClw==
json-rpc-middleware-stream@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/json-rpc-middleware-stream/-/json-rpc-middleware-stream-4.0.0.tgz#54de6f57d795525547219c1581858962618adeeb"
integrity sha512-+s8ps2cO+zmw21W7TA9wVD/5fwNi4C2O7NzLxlrEDrfzNcs3YX76Qw2fXuQLKVFeP654CIa6nkfqkFU9o7x/3g==
dependencies:
"@metamask/safe-event-emitter" "^2.0.0"
readable-stream "^2.3.3"
Expand Down