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

Upgrade version to 1.9.0 #179

Merged
merged 7 commits into from
Apr 22, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ainblockchain/ain-js",
"version": "1.8.0",
"version": "1.9.0",
"description": "",
"main": "lib/ain.js",
"scripts": {
Expand All @@ -13,7 +13,8 @@
"test_ain_raw": "jest ain_raw.test.ts",
"test_he": "jest he.test.ts",
"test_em": "jest event_manager.test.ts",
"docs": "yarn build && typedoc --plugin @mxssfd/typedoc-theme --theme my-theme --out docs"
"docs": "yarn build && typedoc --plugin @mxssfd/typedoc-theme --theme my-theme --out docs",
"postinstall": "patch-package"
},
"engines": {
"node": ">=16"
Expand Down Expand Up @@ -59,10 +60,13 @@
"browserify-cipher": "^1.0.1",
"eventemitter3": "^4.0.0",
"hdkey": "^1.1.1",
"is-in-browser": "^2.0.0",
"isomorphic-ws": "^5.0.0",
"lodash": "^4.17.20",
"node-seal": "^4.5.7",
"patch-package": "^8.0.0",
"pbkdf2": "^3.0.17",
"postinstall-postinstall": "^2.1.0",
"randombytes": "^2.1.0",
"scryptsy": "^2.1.0",
"semver": "^6.3.0",
Expand Down
18 changes: 18 additions & 0 deletions patches/isomorphic-ws+5.0.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/node_modules/isomorphic-ws/index.d.ts b/node_modules/isomorphic-ws/index.d.ts
index de923a9..7d56cf5 100644
--- a/node_modules/isomorphic-ws/index.d.ts
+++ b/node_modules/isomorphic-ws/index.d.ts
@@ -3,6 +3,9 @@
// Fix for https://github.com/heineiuo/isomorphic-ws/issues/8
// If there is still something wrong, welcome issue.

-import WebSocket = require('ws')
+// NOTE(jiyoung): comment out for original reference.
+// import WebSocket = require('ws')
+// export = WebSocket

-export = WebSocket
\ No newline at end of file
+import { WebSocket } from 'ws'
+export default WebSocket
\ No newline at end of file
9 changes: 6 additions & 3 deletions src/event-manager/event-channel-client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Ain from '../ain';
import * as WebSocket from 'isomorphic-ws';
import isBrowser from "is-in-browser";
import WebSocket from 'isomorphic-ws';
import { WebSocket as WebSocketBE } from 'ws';
import {
EventChannelMessageTypes,
EventChannelMessage,
Expand All @@ -21,7 +23,7 @@ export default class EventChannelClient {
/** The event callback manager object. */
private readonly _eventCallbackManager: EventCallbackManager;
/** The web socket client. */
private _ws?: WebSocket;
private _ws?: WebSocket | WebSocketBE;
/** The blockchain endpoint URL. */
private _endpointUrl?: string;
/** Whether it's connected or not. */
Expand Down Expand Up @@ -86,7 +88,8 @@ export default class EventChannelClient {
}

this._endpointUrl = url;
this._ws = new WebSocket(url);
// NOTE(platfowner): Fix WebSocket module import issue (see https://github.com/ainblockchain/ain-js/issues/177).
this._ws = isBrowser ? new WebSocket(url) : new WebSocketBE(url);
// NOTE(platfowner): A custom handshake timeout (see https://github.com/ainblockchain/ain-js/issues/171).
this.startHandshakeTimer(DEFAULT_HANDSHAKE_TIMEOUT_MS);

Expand Down
Loading
Loading