Skip to content

Commit

Permalink
Merge pull request #179 from ainblockchain/release/v1.9.0
Browse files Browse the repository at this point in the history
Upgrade version to 1.9.0
  • Loading branch information
platfowner authored Apr 22, 2024
2 parents 2671a45 + 5823db8 commit daa4259
Show file tree
Hide file tree
Showing 4 changed files with 261 additions and 8 deletions.
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

0 comments on commit daa4259

Please sign in to comment.