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

add WebSocketProvider #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ Installing and Importing

```javascript
// JavaScript
const { JsonRpcProvider } = require("@ethers-ancillary/exchain");
const { JsonRpcProvider, WebSocketProvider } = require("@ethers-ancillary/exchain");

// TypeScript
import { JsonRpcProvider } from "@ethers-ancillary/exchain";
import { JsonRpcProvider, WebSocketProvider } from "@ethers-ancillary/exchain";
```

**Browser**
Expand All @@ -34,7 +34,7 @@ core library (i.e. ethers.esm.min.js) and import using:

```html
<script type="module">
import { JsonRpcProvider } from "./exchain.esm.js";
import { JsonRpcProvider, WebSocketProvider } from "./exchain.esm.js";
</script>
```

Expand Down
1 change: 0 additions & 1 deletion dist/ethers.esm.min.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/ethers.umd.min.js

This file was deleted.

21 changes: 20 additions & 1 deletion dist/exchain.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3022,5 +3022,24 @@ class StaticJsonRpcProvider extends JsonRpcProvider {
});
}
}
class WebSocketProvider extends providers.WebSocketProvider {
static getFormatter() {
console.log("Using mine");
if (defaultFormatter == null) {
defaultFormatter = new Formatter();
}
return defaultFormatter;
}
static getNetwork(networkish) {
const network = getNetwork((networkish == null) ? "exchain" : networkish);
if (network == null) {
return logger.throwError(`unknown network: ${JSON.stringify(network)}`, utils.Logger.errors.UNSUPPORTED_OPERATION, {
operation: "getNetwork",
value: networkish
});
}
return network;
}
}

export { JsonRpcProvider, StaticJsonRpcProvider, getNetwork };
export { JsonRpcProvider, StaticJsonRpcProvider, WebSocketProvider, getNetwork };
8 changes: 4 additions & 4 deletions dist/exchain.esm.min.js

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions dist/exchain.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -3026,9 +3026,29 @@
});
}
}
class WebSocketProvider extends ethers.providers.WebSocketProvider {
static getFormatter() {
console.log("Using mine");
if (defaultFormatter == null) {
defaultFormatter = new Formatter();
}
return defaultFormatter;
}
static getNetwork(networkish) {
const network = getNetwork((networkish == null) ? "exchain" : networkish);
if (network == null) {
return logger.throwError(`unknown network: ${JSON.stringify(network)}`, ethers.utils.Logger.errors.UNSUPPORTED_OPERATION, {
operation: "getNetwork",
value: networkish
});
}
return network;
}
}

exports.JsonRpcProvider = JsonRpcProvider;
exports.StaticJsonRpcProvider = StaticJsonRpcProvider;
exports.WebSocketProvider = WebSocketProvider;
exports.getNetwork = getNetwork;

Object.defineProperty(exports, '__esModule', { value: true });
Expand Down
2 changes: 1 addition & 1 deletion dist/exchain.umd.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib.esm/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { JsonRpcProvider, StaticJsonRpcProvider } from "./json-rpc-provider";
import { JsonRpcProvider, StaticJsonRpcProvider, WebSocketProvider } from "./json-rpc-provider";
import { getNetwork } from "./networks";
export { JsonRpcProvider, StaticJsonRpcProvider, getNetwork, };
export { JsonRpcProvider, StaticJsonRpcProvider, WebSocketProvider, getNetwork, };
4 changes: 2 additions & 2 deletions lib.esm/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib.esm/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 61 additions & 4 deletions lib.esm/index.tests.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading