forked from nimiq/safe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnetwork-client.js
More file actions
33 lines (25 loc) · 805 Bytes
/
network-client.js
File metadata and controls
33 lines (25 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { NetworkClient as NimiqNetworkClient } from '../node_modules/@nimiq/network-client/dist/NetworkClient.standalone.es.js';
class NetworkClient {
static getInstance() {
this._instance = this._instance || new NetworkClient();
return this._instance;
}
/**
* @param {string} [endpoint]
*/
constructor(endpoint) {
this._isLaunched = false;
this._endpoint = endpoint;
this.client = new Promise(res => {
this.clientResolve = res;
});
}
async launch() {
if (this._isLaunched) return;
this._isLaunched = true;
const client = new NimiqNetworkClient(this._endpoint);
await client.init();
this.clientResolve(client);
}
}
export default NetworkClient.getInstance();