@leofcoin/launch-chain 0.4.19 → 0.4.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/exports/index.d.ts +8 -8
- package/exports/index.js +24 -28
- package/package.json +6 -5
- package/exports/src/index.d.ts +0 -38
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# launch-chain
|
|
2
2
|
|
|
3
3
|
> launch chain & peernet (reuses exposed transports when already running)
|
|
4
4
|
|
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
```js
|
|
8
8
|
import launch from '@leofcoin/launch-chain'
|
|
9
9
|
|
|
10
|
-
const { chain, endpoints, mode } = await launch(
|
|
10
|
+
const { chain, endpoints, mode } = await launch(
|
|
11
|
+
{ mode: 'direct' },
|
|
12
|
+
process.env.LEOFCOIN_PASSWORD
|
|
13
|
+
)
|
|
11
14
|
// chain is undefined when mode is remote
|
|
12
15
|
// endpoints contain urls to connect to the desired remote
|
|
13
16
|
// when mode is remote means an instance is already running
|
|
@@ -21,7 +24,7 @@ const { chain, endpoints, mode } = await launch()
|
|
|
21
24
|
```js
|
|
22
25
|
{
|
|
23
26
|
network: 'leofcoin:peach',
|
|
24
|
-
stars: ['wss://
|
|
27
|
+
stars: ['wss://star.leofcoin.org'],
|
|
25
28
|
forceRemote: false, // when set to true only tries to connect to an external/local exposed node
|
|
26
29
|
ws: {
|
|
27
30
|
port: 4040,
|
package/exports/index.d.ts
CHANGED
|
@@ -3,15 +3,15 @@ import WSClient from '@leofcoin/endpoint-clients/ws';
|
|
|
3
3
|
import HttpClient from '@leofcoin/endpoint-clients/http';
|
|
4
4
|
type launchMode = 'direct' | 'remote' | 'server';
|
|
5
5
|
type endpointReturns = {
|
|
6
|
-
http
|
|
7
|
-
ws
|
|
6
|
+
http: string[];
|
|
7
|
+
ws: string[];
|
|
8
8
|
};
|
|
9
9
|
type clientReturns = {
|
|
10
|
-
http
|
|
11
|
-
ws
|
|
10
|
+
http: HttpClient[];
|
|
11
|
+
ws: WSClient[];
|
|
12
12
|
};
|
|
13
13
|
type launchReturn = {
|
|
14
|
-
chain
|
|
14
|
+
chain?: Chain;
|
|
15
15
|
mode: launchMode;
|
|
16
16
|
endpoints: endpointReturns;
|
|
17
17
|
clients: clientReturns;
|
|
@@ -23,8 +23,8 @@ type endpointOptions = {
|
|
|
23
23
|
type launchOptions = {
|
|
24
24
|
network?: string;
|
|
25
25
|
networkVersion?: string;
|
|
26
|
-
stars
|
|
27
|
-
forceRemote
|
|
26
|
+
stars?: string[];
|
|
27
|
+
forceRemote?: boolean;
|
|
28
28
|
mode?: launchMode;
|
|
29
29
|
ws?: endpointOptions[] | undefined;
|
|
30
30
|
http?: endpointOptions[] | undefined;
|
|
@@ -34,5 +34,5 @@ type launchOptions = {
|
|
|
34
34
|
* @param {object} options { ws: boolean || {url: string, port: number}, http: boolean || {url: string, port: number}, network}
|
|
35
35
|
* @returns '{ mode: string, endpoints: object, chain}'
|
|
36
36
|
*/
|
|
37
|
-
declare const launch: (
|
|
37
|
+
declare const launch: (input: launchOptions | undefined, password: string) => Promise<launchReturn>;
|
|
38
38
|
export { launch as default };
|
package/exports/index.js
CHANGED
|
@@ -72,11 +72,8 @@ const getWS = async (url, networkVersion) => {
|
|
|
72
72
|
* @param {object} options { ws: boolean || {url: string, port: number}, http: boolean || {url: string, port: number}, network}
|
|
73
73
|
* @returns '{ mode: string, endpoints: object, chain}'
|
|
74
74
|
*/
|
|
75
|
-
const launch = async (
|
|
76
|
-
|
|
77
|
-
options = defaultOptions;
|
|
78
|
-
else
|
|
79
|
-
options = { ...defaultOptions, ...options };
|
|
75
|
+
const launch = async (input = {}, password) => {
|
|
76
|
+
const options = { ...defaultOptions, ...input };
|
|
80
77
|
const clients = {
|
|
81
78
|
http: [],
|
|
82
79
|
ws: []
|
|
@@ -89,19 +86,22 @@ const launch = async (options, password) => {
|
|
|
89
86
|
if (options.mode === 'remote') {
|
|
90
87
|
if (options.http) {
|
|
91
88
|
for (const endpoint of options.http) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
89
|
+
const url = endpoint.url ?? `http://localhost:${endpoint.port}`;
|
|
90
|
+
const client = await getHttp(url, options.networkVersion);
|
|
91
|
+
if (client) {
|
|
92
|
+
endpoints.http.push(url);
|
|
93
|
+
clients.http.push(client);
|
|
94
|
+
}
|
|
97
95
|
}
|
|
98
96
|
}
|
|
99
97
|
if (options.ws) {
|
|
100
98
|
for (const endpoint of options.ws) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
const url = endpoint.url ?? `ws://localhost:${endpoint.port}`;
|
|
100
|
+
const client = await getWS(url, options.networkVersion);
|
|
101
|
+
if (client) {
|
|
102
|
+
endpoints.ws.push(url);
|
|
103
|
+
clients.ws.push(client);
|
|
104
|
+
}
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
if (endpoints.http.length === 0 && endpoints.ws.length === 0)
|
|
@@ -117,11 +117,10 @@ const launch = async (options, password) => {
|
|
|
117
117
|
const importee = await import('@leofcoin/endpoints/ws');
|
|
118
118
|
const wsServer = importee.default;
|
|
119
119
|
for (const endpoint of options.ws) {
|
|
120
|
-
|
|
121
|
-
endpoint.url = `ws://localhost:${endpoint.port}`;
|
|
120
|
+
const url = endpoint.url ?? `ws://localhost:${endpoint.port}`;
|
|
122
121
|
await wsServer(chain, endpoint.port, options.networkVersion);
|
|
123
|
-
endpoints.ws.push(
|
|
124
|
-
const client = await getWS(
|
|
122
|
+
endpoints.ws.push(url);
|
|
123
|
+
const client = await getWS(url, options.networkVersion);
|
|
125
124
|
client && clients.ws.push(client);
|
|
126
125
|
}
|
|
127
126
|
}
|
|
@@ -129,11 +128,10 @@ const launch = async (options, password) => {
|
|
|
129
128
|
const importee = await import('@leofcoin/endpoints/http');
|
|
130
129
|
const httpServer = importee.default;
|
|
131
130
|
for (const endpoint of options.http) {
|
|
132
|
-
|
|
133
|
-
endpoint.url = `http://localhost:${endpoint.port}`;
|
|
131
|
+
const url = endpoint.url ?? `http://localhost:${endpoint.port}`;
|
|
134
132
|
await httpServer(chain, endpoint.port, options.networkVersion);
|
|
135
|
-
endpoints.http.push(
|
|
136
|
-
const client = await getHttp(
|
|
133
|
+
endpoints.http.push(url);
|
|
134
|
+
const client = await getHttp(url, options.networkVersion);
|
|
137
135
|
client && clients.http.push(client);
|
|
138
136
|
}
|
|
139
137
|
}
|
|
@@ -148,20 +146,18 @@ const launch = async (options, password) => {
|
|
|
148
146
|
const importee = await import('@leofcoin/endpoints/ws');
|
|
149
147
|
const wsServer = importee.default;
|
|
150
148
|
for (const endpoint of options.ws) {
|
|
151
|
-
|
|
152
|
-
endpoint.url = `ws://localhost:${endpoint.port}`;
|
|
149
|
+
const url = endpoint.url ?? `ws://localhost:${endpoint.port}`;
|
|
153
150
|
await wsServer(chain, endpoint.port, options.networkVersion);
|
|
154
|
-
endpoints.ws.push(
|
|
151
|
+
endpoints.ws.push(url);
|
|
155
152
|
}
|
|
156
153
|
}
|
|
157
154
|
if (options.http) {
|
|
158
155
|
const importee = await import('@leofcoin/endpoints/http');
|
|
159
156
|
const httpServer = importee.default;
|
|
160
157
|
for (const endpoint of options.http) {
|
|
161
|
-
|
|
162
|
-
endpoint.url = `http://localhost:${endpoint.port}`;
|
|
158
|
+
const url = endpoint.url ?? `http://localhost:${endpoint.port}`;
|
|
163
159
|
await httpServer(chain, endpoint.port, options.networkVersion);
|
|
164
|
-
endpoints.http.push(
|
|
160
|
+
endpoints.http.push(url);
|
|
165
161
|
}
|
|
166
162
|
}
|
|
167
163
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/launch-chain",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.20",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
"type": "module",
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "rollup -c",
|
|
17
|
-
"test": "
|
|
17
|
+
"test": "node --test test/*.test.js"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "
|
|
21
|
+
"url": "https://github.com/leofcoin/monorepo.git",
|
|
22
|
+
"directory": "packages/launch-chain"
|
|
22
23
|
},
|
|
23
24
|
"keywords": [],
|
|
24
25
|
"author": "",
|
|
@@ -26,9 +27,9 @@
|
|
|
26
27
|
"bugs": {
|
|
27
28
|
"url": "https://github.com/leofcoin/launch-chain/issues"
|
|
28
29
|
},
|
|
29
|
-
"homepage": "https://github.com/leofcoin/launch-chain#readme",
|
|
30
|
+
"homepage": "https://github.com/leofcoin/monorepo/tree/main/packages/launch-chain#readme",
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@leofcoin/chain": "^1.10.
|
|
32
|
+
"@leofcoin/chain": "^1.10.11",
|
|
32
33
|
"@leofcoin/endpoint-clients": "^0.3.15",
|
|
33
34
|
"@leofcoin/endpoints": "^0.4.8",
|
|
34
35
|
"@leofcoin/networks": "^1.1.30"
|
package/exports/src/index.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import Chain from '@leofcoin/chain/chain';
|
|
2
|
-
import WSClient from '@leofcoin/endpoint-clients/ws';
|
|
3
|
-
import HttpClient from '@leofcoin/endpoint-clients/http';
|
|
4
|
-
type launchMode = 'direct' | 'remote' | 'server';
|
|
5
|
-
type endpointReturns = {
|
|
6
|
-
http?: string[];
|
|
7
|
-
ws?: string[];
|
|
8
|
-
};
|
|
9
|
-
type clientReturns = {
|
|
10
|
-
http?: HttpClient[];
|
|
11
|
-
ws?: WSClient[];
|
|
12
|
-
};
|
|
13
|
-
type launchReturn = {
|
|
14
|
-
chain: Chain;
|
|
15
|
-
mode: launchMode;
|
|
16
|
-
endpoints: endpointReturns;
|
|
17
|
-
clients: clientReturns;
|
|
18
|
-
};
|
|
19
|
-
type endpointOptions = {
|
|
20
|
-
port: number;
|
|
21
|
-
url?: string;
|
|
22
|
-
};
|
|
23
|
-
type launchOptions = {
|
|
24
|
-
network?: string;
|
|
25
|
-
networkVersion?: string;
|
|
26
|
-
stars: string[];
|
|
27
|
-
forceRemote: boolean;
|
|
28
|
-
mode?: launchMode;
|
|
29
|
-
ws?: endpointOptions[] | undefined;
|
|
30
|
-
http?: endpointOptions[] | undefined;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
* @param {object} options { ws: boolean || {url: string, port: number}, http: boolean || {url: string, port: number}, network}
|
|
35
|
-
* @returns '{ mode: string, endpoints: object, chain}'
|
|
36
|
-
*/
|
|
37
|
-
declare const launch: (options: launchOptions, password: string) => Promise<launchReturn>;
|
|
38
|
-
export { launch as default };
|