@moosty/lisk-connection-provider
Advanced tools
Comparing version 0.0.4 to 0.0.6
@@ -5,9 +5,12 @@ import { SubscribeMethods } from "../types"; | ||
blockchain: any; | ||
v1: any; | ||
private _events; | ||
id: number; | ||
_setConnections: (connection: any, blockchain: any) => void; | ||
_setConnections: (connection: any, blockchain: any, v1: any) => void; | ||
getState: () => "connected" | "disconnected" | "connecting" | "init"; | ||
getStateBlockchain: () => "connected" | "disconnected" | "connecting" | "init"; | ||
getStateV1: () => "connected" | "disconnected" | "connecting" | "init"; | ||
isConnected: () => any; | ||
isBlockchainConnected: () => any; | ||
isV1Connected: () => any; | ||
subscribe: (method: SubscribeMethods) => void; | ||
@@ -14,0 +17,0 @@ emit: (method: SubscribeMethods, data: object) => void; |
@@ -8,5 +8,6 @@ "use strict"; | ||
this.id = 0; | ||
this._setConnections = (connection, blockchain) => { | ||
this._setConnections = (connection, blockchain, v1) => { | ||
this.connection = connection; | ||
this.blockchain = blockchain; | ||
this.v1 = v1; | ||
}; | ||
@@ -19,2 +20,5 @@ this.getState = () => { | ||
}; | ||
this.getStateV1 = () => { | ||
return this.v1 ? this.v1.connected ? "connected" : this.v1.disconnected ? "disconnected" : "connecting" : "init"; | ||
}; | ||
this.isConnected = () => { | ||
@@ -26,2 +30,5 @@ return this.connection?.connected || false; | ||
}; | ||
this.isV1Connected = () => { | ||
return this.v1?.connected || false; | ||
}; | ||
this.subscribe = async (method) => { | ||
@@ -28,0 +35,0 @@ throw new Error(`Method not implemented yet`); |
@@ -6,7 +6,7 @@ import { ConnectionController } from "./ConnectionController"; | ||
subscribe: (method: SubscribeMethods) => void; | ||
get: (method: GetMethods, params: object) => Promise<object>; | ||
get: (method: GetMethods, params: object, v1?: boolean) => Promise<object>; | ||
getMore: (method: GetMethods, params: { | ||
offset?: number; | ||
limit?: number; | ||
}) => Promise<object>; | ||
}, v1?: boolean) => Promise<object>; | ||
} |
@@ -20,7 +20,7 @@ "use strict"; | ||
}; | ||
this.get = async (method, params) => { | ||
this.get = async (method, params, v1 = false) => { | ||
if (this.isConnected()) { | ||
this.id++; | ||
return await helpers_1.ws({ | ||
socket: this.connection, requests: [{ | ||
socket: !v1 || !this.isV1Connected() ? this.connection : this.v1, requests: [{ | ||
"jsonrpc": "2.0", | ||
@@ -35,3 +35,3 @@ "id": this.id, | ||
}; | ||
this.getMore = async (method, params) => { | ||
this.getMore = async (method, params, v1 = false) => { | ||
if (this.isConnected()) { | ||
@@ -53,7 +53,7 @@ const requests = []; | ||
} | ||
return await helpers_1.ws({ socket: this.connection, requests }); | ||
return await helpers_1.ws({ socket: !v1 || !this.isV1Connected() ? this.connection : this.v1, requests }); | ||
} | ||
return {}; | ||
}; | ||
this._setConnections(socket_io_client_1.io(`${host}/rpc-v2`, { transports: ["websocket"] }), socket_io_client_1.io(`${host}/blockchain`, { transports: ["websocket"] })); | ||
this._setConnections(socket_io_client_1.io(`${host}/rpc-v2`, { transports: ["websocket"] }), socket_io_client_1.io(`${host}/blockchain`, { transports: ["websocket"] }), socket_io_client_1.io(`${host}/rpc-v1`, { transports: ["websocket"] })); | ||
} | ||
@@ -60,0 +60,0 @@ } |
{ | ||
"name": "@moosty/lisk-connection-provider", | ||
"version": "0.0.4", | ||
"version": "0.0.6", | ||
"description": "Lisk connection provider component to connect react to Lisk endpoints", | ||
@@ -37,3 +37,3 @@ "author": "Moosty <info@moosty.com>", | ||
}, | ||
"gitHead": "f3caebd3d7f9eea6cc206f316b410ade28b87136" | ||
"gitHead": "f0d9c42fe4f5fd67501c683380c176314c6464f0" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39051
407