This repository was archived by the owner on Apr 8, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathconst.ts
More file actions
289 lines (237 loc) · 8.58 KB
/
const.ts
File metadata and controls
289 lines (237 loc) · 8.58 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
/**
* Fluence CLI
* Copyright (C) 2024 Fluence DAO
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Args, Flags } from "@oclif/core";
import {
getIsUnion,
CHAIN_ENV,
LOCAL_NET_DEFAULT_WALLET_KEY,
} from "../common.js";
export const CLI_NAME = "fluence";
export const CLI_NAME_FULL = "Fluence CLI";
export const NODE_JS_MAJOR_VERSION = 22;
export const FLT_SYMBOL = "FLT";
export const PT_SYMBOL = "USDC";
export const MAX_TOKEN_AMOUNT_KEYWORD = "max";
export const VCPU_PER_CU = 2;
export const DEFAULT_NUMBER_OF_COMPUTE_UNITS_ON_PEER = 1;
export type FluenceEnv = (typeof CHAIN_ENV)[number];
export const isFluenceEnv = getIsUnion(CHAIN_ENV);
export const FLUENCE_ENVS_OLD = ["stage", "dar", "kras", "local"] as const;
export type FluenceEnvOld = (typeof FLUENCE_ENVS_OLD)[number];
export const isFluenceEnvOld = getIsUnion(FLUENCE_ENVS_OLD);
export function fluenceOldEnvToNewEnv(env: FluenceEnvOld): FluenceEnv {
return (
{
stage: "stage",
dar: "testnet",
kras: "mainnet",
local: "local",
} as const satisfies Record<FluenceEnvOld, FluenceEnv>
)[env];
}
export const TCP_PORT_START = 977;
export const WEB_SOCKET_PORT_START = 999;
export const HTTP_PORT_START = 918;
export const DEFAULT_AQUAVM_POOL_SIZE = 2;
export const DEFAULT_NUMBER_OF_LOCAL_NET_PEERS = 3;
export const JSON_EXT = "json";
export const YAML_EXT = "yaml";
export const YML_EXT = "yml";
export const CLI_CONNECTOR_DIR_NAME = "cli-connector";
export const DOT_FLUENCE_DIR_NAME = ".fluence";
export const SCHEMAS_DIR_NAME = "schemas";
export const COUNTLY_DIR_NAME = "countly";
export const SECRETS_DIR_NAME = "secrets";
export const BACKUPS_DIR_NAME = "backups";
export const PROVIDER_CONFIG_FILE_NAME = `provider`;
export const PROVIDER_SECRETS_CONFIG_FILE_NAME = `provider-secrets`;
export const PROVIDER_ARTIFACTS_CONFIG_FILE_NAME = `provider-artifacts`;
export const USER_CONFIG_FILE_NAME = `config`;
export const ENV_CONFIG_FILE_NAME = `env`;
const DOCKER_COMPOSE_FILE_NAME = `docker-compose`;
export const PROVIDER_CONFIG_FULL_FILE_NAME = `${PROVIDER_CONFIG_FILE_NAME}.${YAML_EXT}`;
export const PROVIDER_SECRETS_CONFIG_FULL_FILE_NAME = `${PROVIDER_SECRETS_CONFIG_FILE_NAME}.${YAML_EXT}`;
export const PROVIDER_ARTIFACTS_CONFIG_FULL_FILE_NAME = `${PROVIDER_ARTIFACTS_CONFIG_FILE_NAME}.${YAML_EXT}`;
export const USER_CONFIG_FULL_FILE_NAME = `${USER_CONFIG_FILE_NAME}.${YAML_EXT}`;
export const ENV_CONFIG_FULL_FILE_NAME = `${ENV_CONFIG_FILE_NAME}.${YAML_EXT}`;
export const DOCKER_COMPOSE_FULL_FILE_NAME = `${DOCKER_COMPOSE_FILE_NAME}.${YAML_EXT}`;
export const GITIGNORE_FILE_NAME = ".gitignore";
export const AUTO_GENERATED = "auto-generated";
export const NO_INPUT_FLAG_NAME = "no-input";
export const NO_INPUT_FLAG = {
[NO_INPUT_FLAG_NAME]: Flags.boolean({
default: false,
description: "Don't interactively ask for any input from the user",
}),
} as const;
const fluenceEnvFlagAndArg = {
description: "Fluence Environment to use when running the command",
helpValue: `<${CHAIN_ENV.join(" | ")}>`,
};
export const ENV_FLAG_NAME = "env";
const ENV_FLAG = {
[ENV_FLAG_NAME]: Flags.string(fluenceEnvFlagAndArg),
};
export const ENV_ARG_NAME = "ENV";
export const ENV_ARG = {
[ENV_ARG_NAME]: Args.string(fluenceEnvFlagAndArg),
};
export const ALL_FLAG_VALUE = "all";
export const PEER_NAMES_FLAG_NAME = "peer-names";
const PEER_NAMES_FLAG_CONFIG = {
description: `Comma-separated names of peers from ${PROVIDER_CONFIG_FULL_FILE_NAME}. To use all of your peers: --${PEER_NAMES_FLAG_NAME} ${ALL_FLAG_VALUE}`,
helpValue: "<peer-1,peer-2>",
};
const PEER_NAMES_FLAG = {
[PEER_NAMES_FLAG_NAME]: Flags.string(PEER_NAMES_FLAG_CONFIG),
};
export const PEERS_FLAG_NAME = "peers";
export const PEERS_FLAG = {
[PEERS_FLAG_NAME]: Flags.integer({
description: `Number of peers to generate when a new ${PROVIDER_CONFIG_FULL_FILE_NAME} is created`,
}),
};
export const OFFER_FLAG_NAME = "offers";
export const OFFER_IDS_FLAG_NAME = "offer-ids";
export const SINGLE_OFFER_FLAG_NAME = "offer";
export const SINGLE_OFFER_ID_FLAG_NAME = "offer-id";
const OFFER_FLAG_OBJECT = {
description: `Comma-separated list of offer names. To use all of your offers: --${OFFER_FLAG_NAME} ${ALL_FLAG_VALUE}`,
helpValue: "<offer-1,offer-2>",
};
const SINGLE_OFFER_FLAG_OBJECT = {
description: `Offer name. Can't be used together with --offer flag`,
helpValue: "<offer>",
};
export const SINGLE_OFFER_FLAG = {
[SINGLE_OFFER_FLAG_NAME]: Flags.string(SINGLE_OFFER_FLAG_OBJECT),
};
export const OFFER_FLAG = {
[OFFER_FLAG_NAME]: Flags.string(OFFER_FLAG_OBJECT),
};
export const OFFER_FLAGS = {
[OFFER_FLAG_NAME]: Flags.string({
...OFFER_FLAG_OBJECT,
exclusive: [OFFER_IDS_FLAG_NAME],
}),
[OFFER_IDS_FLAG_NAME]: Flags.string({
description: `Comma-separated list of offer ids. Can't be used together with --${OFFER_FLAG_NAME} flag`,
helpValue: "<id-1,id-2>",
exclusive: [OFFER_FLAG_NAME],
}),
};
export const SINGLE_OFFER_FLAGS = {
[SINGLE_OFFER_FLAG_NAME]: Flags.string({
...SINGLE_OFFER_FLAG_OBJECT,
exclusive: [SINGLE_OFFER_ID_FLAG_NAME],
}),
[SINGLE_OFFER_ID_FLAG_NAME]: Flags.string({
description: `Offer id. Can't be used together with --${SINGLE_OFFER_FLAG_NAME} flag`,
helpValue: "<id>",
exclusive: [SINGLE_OFFER_FLAG_NAME],
}),
};
export const PEER_AND_OFFER_NAMES_FLAGS = {
...PEER_NAMES_FLAG,
...OFFER_FLAG,
};
export type PeerAndOfferNameFlags = {
[PEER_NAMES_FLAG_NAME]?: string | undefined;
[OFFER_FLAG_NAME]?: string | undefined;
};
export const PRIV_KEY_FLAG_NAME = "priv-key";
export const PRIV_KEY_FLAG = {
[PRIV_KEY_FLAG_NAME]: Flags.string({
description: `!WARNING! for debug purposes only. Passing private keys through flags is unsecure. On local env ${LOCAL_NET_DEFAULT_WALLET_KEY} is used by default when CLI is used in non-interactive mode`,
helpValue: "<private-key>",
}),
};
export const ADDRESS_FLAG_NAME = "address";
export const PROVIDER_ADDRESS_FLAG_NAME = "provider";
export const ADDRESS_FLAG = {
[ADDRESS_FLAG_NAME]: Flags.string({
description: "Provider address",
helpValue: "<address>",
}),
};
export const CLUSTER_ADDRESS_FLAG = {
[ADDRESS_FLAG_NAME]: Flags.string({
description: "Address derived from Cluster private key",
helpValue: "<address>",
}),
};
export const PROVIDER_ADDRESS_FLAG = {
[PROVIDER_ADDRESS_FLAG_NAME]: Flags.string({
description:
"Provider address. In case using managmenent address to sign transactions",
helpValue: "<address>",
}),
};
export const CHAIN_FLAGS = {
...ENV_FLAG,
...PRIV_KEY_FLAG,
};
export const DEAL_IDS_FLAG_NAME = "deal-ids";
export const DEAL_IDS_FLAG = {
[DEAL_IDS_FLAG_NAME]: Flags.string({
description: `Comma-separated deal ids`,
helpValue: "<id-1,id-2>",
}),
};
export const DOCKER_COMPOSE_FLAGS = {
flags: Flags.string({
description: "Space separated flags to pass to `docker compose`",
helpValue: "<--flag arg>",
}),
};
export const CC_IDS_FLAG_NAME = "cc-ids";
export const CC_FLAGS = {
[PEER_NAMES_FLAG_NAME]: Flags.string({
...PEER_NAMES_FLAG_CONFIG,
exclusive: [CC_IDS_FLAG_NAME],
}),
[CC_IDS_FLAG_NAME]: Flags.string({
description: "Comma separated capacity commitment IDs",
exclusive: [PEER_NAMES_FLAG_NAME],
}),
...OFFER_FLAG,
};
export const CC_FINISH_FORCE_FLAG = {
force: Flags.boolean({
description: "Allow finish Active CC",
}),
};
export const FINISH_COMMITMENT_FLAG_NAME = "finish";
export const JSON_FLAG = {
json: Flags.boolean({
description: "Output JSON",
}),
};
export const RECOMMENDED_GITIGNORE_CONTENT = `.idea
.DS_Store
/${DOT_FLUENCE_DIR_NAME}/${SECRETS_DIR_NAME}
/${DOT_FLUENCE_DIR_NAME}/${PROVIDER_SECRETS_CONFIG_FULL_FILE_NAME}
/${DOT_FLUENCE_DIR_NAME}/${SCHEMAS_DIR_NAME}
.terraform
.terraform.lock.hcl
`;
export const IS_TTY = Boolean(process.stdout.isTTY && process.stdin.isTTY);
export const IS_DEVELOPMENT = process.env["NODE_ENV"] === "development";
export const DEFAULT_CC_STAKER_REWARD = 20;
export const DEFAULT_CC_DURATION = "100 days";
export const DURATION_EXAMPLE =
"in human-readable format. Example: 1 months 1 days";