@eth-sdk/query
Advanced tools
Comparing version
@@ -129,3 +129,3 @@ import BN from 'bn.js'; | ||
value?: TQuantity; | ||
data: TData; | ||
data?: TData; | ||
nonce?: TQuantity; | ||
@@ -132,0 +132,0 @@ } |
@@ -108,3 +108,3 @@ "use strict"; | ||
value: utils_1.toHex(value, null), | ||
data: utils_1.toHex(data, null), | ||
data: utils_1.toHex(data, '0x'), | ||
nonce: utils_1.toHex(nonce, null), | ||
@@ -111,0 +111,0 @@ })); |
@@ -5,3 +5,2 @@ import { BehaviorSubject } from 'rxjs'; | ||
private endpoint; | ||
private options; | ||
private readonly fetch; | ||
@@ -8,0 +7,0 @@ constructor(endpoint: string, options?: HttpProvider.IOptions); |
@@ -7,6 +7,5 @@ "use strict"; | ||
this.endpoint = endpoint; | ||
this.options = options; | ||
this.fetch = typeof fetch !== 'undefined' | ||
? fetch | ||
: this.options.fetch; | ||
: options.fetch; | ||
if (!this.fetch) { | ||
@@ -13,0 +12,0 @@ new Error('fetch not found. Please use `node-fetch` via options.fetch'); |
@@ -11,2 +11,3 @@ import { BehaviorSubject } from 'rxjs'; | ||
error$: BehaviorSubject<any>; | ||
private readonly webSocketConstructor; | ||
private readonly options; | ||
@@ -34,6 +35,7 @@ private connection; | ||
export declare namespace WebSocketProvider { | ||
interface IWebSocketConstructor { | ||
new (url: string, protocols?: string | string[]): WebSocket; | ||
} | ||
interface IOptions { | ||
webSocketConstructor?: { | ||
new (url: string, protocols?: string | string[]): WebSocket; | ||
}; | ||
webSocketConstructor?: any; | ||
connect?: boolean; | ||
@@ -40,0 +42,0 @@ reconnectTime?: number; |
@@ -16,6 +16,9 @@ "use strict"; | ||
this.reconnectTimeout = null; | ||
this.options = Object.assign({ webSocketConstructor: typeof WebSocket !== 'undefined' ? WebSocket : null, connect: false, reconnectTime: WebSocketProvider.DEFAULT_RECONNECT_TIME, requestTimeout: WebSocketProvider.DEFAULT_REQUEST_TIMEOUT }, options); | ||
if (!this.options.webSocketConstructor) { | ||
this.webSocketConstructor = typeof WebSocket !== 'undefined' | ||
? WebSocket | ||
: this.options.webSocketConstructor; | ||
if (!this.webSocketConstructor) { | ||
throw new Error('please setup options.webSocketConstructor'); | ||
} | ||
this.options = Object.assign(Object.assign({ connect: false, reconnectTime: WebSocketProvider.DEFAULT_RECONNECT_TIME, requestTimeout: WebSocketProvider.DEFAULT_REQUEST_TIMEOUT }, options), { webSocketConstructor: null }); | ||
this | ||
@@ -125,4 +128,3 @@ .state$ | ||
}; | ||
const { webSocketConstructor } = this.options; | ||
this.connection = new webSocketConstructor(this.endpoint); | ||
this.connection = new this.webSocketConstructor(this.endpoint); | ||
this.connection.addEventListener('open', openHandler); | ||
@@ -129,0 +131,0 @@ this.connection.addEventListener('error', errorHandler); |
{ | ||
"name": "@eth-sdk/query", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Eth sdk query", | ||
@@ -30,3 +30,3 @@ "author": { | ||
"dependencies": { | ||
"@eth-sdk/utils": "^0.1.1", | ||
"@eth-sdk/utils": "^0.1.2", | ||
"@types/bn.js": "^4.11.5", | ||
@@ -33,0 +33,0 @@ "@types/node": "^12.0.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
75223
0.06%1239
0.16%Updated