@shelby-protocol/cli 0.0.14 → 0.0.16
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/bin/entry.js +2349 -473
- package/package.json +8 -4
package/bin/entry.js
CHANGED
|
@@ -1,14 +1,519 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
|
|
28
|
+
// assets/hasura_metadata.txt
|
|
29
|
+
var require_hasura_metadata = __commonJS({
|
|
30
|
+
"assets/hasura_metadata.txt"(exports, module) {
|
|
31
|
+
module.exports = '{\n "resource_version": 15,\n "metadata": {\n "version": 3,\n "sources": [\n {\n "name": "processordb",\n "kind": "postgres",\n "tables": [\n {\n "table": {\n "name": "blob_activities",\n "schema": "public"\n },\n "select_permissions": [\n {\n "role": "anonymous",\n "permission": {\n "columns": [\n "transaction_hash",\n "event_index",\n "transaction_version",\n "blob_name",\n "event_type",\n "timestamp"\n ],\n "filter": {},\n "limit": 100,\n "allow_aggregations": true\n },\n "comment": ""\n }\n ]\n },\n {\n "table": {\n "name": "blobs",\n "schema": "public"\n },\n "array_relationships": [\n {\n "name": "placement_group_slots",\n "using": {\n "manual_configuration": {\n "column_mapping": {\n "placement_group": "placement_group"\n },\n "insertion_order": null,\n "remote_table": {\n "name": "placement_group_slots",\n "schema": "public"\n }\n }\n }\n }\n ],\n "select_permissions": [\n {\n "role": "anonymous",\n "permission": {\n "columns": [\n "owner",\n "placement_group",\n "slice_address",\n "created_at",\n "expires_at",\n "is_deleted",\n "is_written",\n "num_chunksets",\n "size",\n "updated_at",\n "blob_commitment",\n "blob_name"\n ],\n "filter": {},\n "limit": 200,\n "allow_aggregations": true\n },\n "comment": ""\n }\n ]\n },\n {\n "table": {\n "name": "placement_group_slots",\n "schema": "public"\n },\n "select_permissions": [\n {\n "role": "anonymous",\n "permission": {\n "columns": [\n "placement_group",\n "storage_provider",\n "slot_index",\n "updated_at",\n "status"\n ],\n "filter": {}\n },\n "comment": ""\n }\n ]\n },\n {\n "table": {\n "name": "processor_status",\n "schema": "public"\n },\n "select_permissions": [\n {\n "role": "anonymous",\n "permission": {\n "columns": [\n "last_success_version",\n "last_transaction_timestamp",\n "last_updated"\n ],\n "filter": {},\n "limit": 10\n }\n }\n ]\n }\n ],\n "configuration": {\n "connection_info": {\n "database_url": {\n "from_env": "PROCESSOR_DATABASE_URL"\n },\n "isolation_level": "read-committed",\n "pool_settings": {\n "connection_lifetime": 600,\n "max_connections": 120\n },\n "use_prepared_statements": false\n }\n }\n }\n ]\n }\n}';
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// assets/shelby_internal.txt
|
|
36
|
+
var require_shelby_internal = __commonJS({
|
|
37
|
+
"assets/shelby_internal.txt"(exports, module) {
|
|
38
|
+
module.exports = `# This common_config is designed to work with the localnet setup in ts-cibuild.sh
|
|
39
|
+
common_config:
|
|
40
|
+
health_check_port: 7654
|
|
41
|
+
write_rate_limit_config:
|
|
42
|
+
num_bytes: 500000000
|
|
43
|
+
num_seconds: 300
|
|
44
|
+
transaction_stream_config:
|
|
45
|
+
# The node and its txn stream run on the host. In a Linux Docker environment,
|
|
46
|
+
# docker.host.internal is not normally available and you have to use
|
|
47
|
+
# 172.17.0.1 instead, but we add a hosts entry when running the containers to
|
|
48
|
+
# make it available.
|
|
49
|
+
indexer_grpc_data_service_address: "http://host.docker.internal:50051"
|
|
50
|
+
auth_token: notusedforlocalnet
|
|
51
|
+
request_name_header: "remapping-processor"
|
|
52
|
+
db_config:
|
|
53
|
+
# The domain we use is the name of the database in the localnet Docker network. The
|
|
54
|
+
# remapping processor needs its own database, so we use "postgres" rather than the
|
|
55
|
+
# "local_testnet" database used by the localnet's core processors. We use port 5432
|
|
56
|
+
# because that's the port postgres runs at inside the Docker network, even though we
|
|
57
|
+
# expose it to the outside world at 5433.
|
|
58
|
+
postgres_connection_string: postgresql://postgres:postgres@local-testnet-postgres:5432/postgres
|
|
59
|
+
custom_config:
|
|
60
|
+
db_schema:
|
|
61
|
+
blob_activities:
|
|
62
|
+
blob_name:
|
|
63
|
+
column_type:
|
|
64
|
+
column_type: "string"
|
|
65
|
+
type: "move_type"
|
|
66
|
+
default_value: null
|
|
67
|
+
is_index: false
|
|
68
|
+
is_nullable: false
|
|
69
|
+
is_option: false
|
|
70
|
+
is_primary_key: false
|
|
71
|
+
is_vec: false
|
|
72
|
+
event_index:
|
|
73
|
+
column_type:
|
|
74
|
+
column_type: "event_index"
|
|
75
|
+
type: "event_metadata"
|
|
76
|
+
default_value: null
|
|
77
|
+
is_index: false
|
|
78
|
+
is_nullable: false
|
|
79
|
+
is_option: false
|
|
80
|
+
is_primary_key: true
|
|
81
|
+
is_vec: false
|
|
82
|
+
event_type:
|
|
83
|
+
column_type:
|
|
84
|
+
column_type: "event_type"
|
|
85
|
+
type: "event_metadata"
|
|
86
|
+
default_value: null
|
|
87
|
+
is_index: false
|
|
88
|
+
is_nullable: false
|
|
89
|
+
is_option: false
|
|
90
|
+
is_primary_key: true
|
|
91
|
+
is_vec: false
|
|
92
|
+
timestamp:
|
|
93
|
+
column_type:
|
|
94
|
+
column_type: "timestamp"
|
|
95
|
+
type: "transaction_metadata"
|
|
96
|
+
default_value: null
|
|
97
|
+
is_index: false
|
|
98
|
+
is_nullable: false
|
|
99
|
+
is_option: false
|
|
100
|
+
is_primary_key: false
|
|
101
|
+
is_vec: false
|
|
102
|
+
transaction_hash:
|
|
103
|
+
column_type:
|
|
104
|
+
column_type: "hash"
|
|
105
|
+
type: "transaction_metadata"
|
|
106
|
+
default_value: null
|
|
107
|
+
is_index: false
|
|
108
|
+
is_nullable: false
|
|
109
|
+
is_option: false
|
|
110
|
+
is_primary_key: true
|
|
111
|
+
is_vec: false
|
|
112
|
+
transaction_version:
|
|
113
|
+
column_type:
|
|
114
|
+
column_type: "version"
|
|
115
|
+
type: "transaction_metadata"
|
|
116
|
+
default_value: null
|
|
117
|
+
is_index: false
|
|
118
|
+
is_nullable: false
|
|
119
|
+
is_option: false
|
|
120
|
+
is_primary_key: false
|
|
121
|
+
is_vec: false
|
|
122
|
+
blobs:
|
|
123
|
+
blob_commitment:
|
|
124
|
+
column_type:
|
|
125
|
+
column_type: "string"
|
|
126
|
+
type: "move_type"
|
|
127
|
+
default_value: null
|
|
128
|
+
is_index: false
|
|
129
|
+
is_nullable: false
|
|
130
|
+
is_option: false
|
|
131
|
+
is_primary_key: false
|
|
132
|
+
is_vec: false
|
|
133
|
+
blob_name:
|
|
134
|
+
column_type:
|
|
135
|
+
column_type: "string"
|
|
136
|
+
type: "move_type"
|
|
137
|
+
default_value: null
|
|
138
|
+
is_index: false
|
|
139
|
+
is_nullable: false
|
|
140
|
+
is_option: false
|
|
141
|
+
is_primary_key: true
|
|
142
|
+
is_vec: false
|
|
143
|
+
created_at:
|
|
144
|
+
column_type:
|
|
145
|
+
column_type: "u64"
|
|
146
|
+
type: "move_type"
|
|
147
|
+
default_value: null
|
|
148
|
+
is_index: false
|
|
149
|
+
is_nullable: false
|
|
150
|
+
is_option: false
|
|
151
|
+
is_primary_key: false
|
|
152
|
+
is_vec: false
|
|
153
|
+
expires_at:
|
|
154
|
+
column_type:
|
|
155
|
+
column_type: "u64"
|
|
156
|
+
type: "move_type"
|
|
157
|
+
default_value: null
|
|
158
|
+
is_index: false
|
|
159
|
+
is_nullable: false
|
|
160
|
+
is_option: false
|
|
161
|
+
is_primary_key: false
|
|
162
|
+
is_vec: false
|
|
163
|
+
is_deleted:
|
|
164
|
+
column_type:
|
|
165
|
+
column_type: "u8"
|
|
166
|
+
type: "move_type"
|
|
167
|
+
default_value: null
|
|
168
|
+
is_index: false
|
|
169
|
+
is_nullable: false
|
|
170
|
+
is_option: false
|
|
171
|
+
is_primary_key: false
|
|
172
|
+
is_vec: false
|
|
173
|
+
is_written:
|
|
174
|
+
column_type:
|
|
175
|
+
column_type: "u8"
|
|
176
|
+
type: "move_type"
|
|
177
|
+
default_value: null
|
|
178
|
+
is_index: false
|
|
179
|
+
is_nullable: false
|
|
180
|
+
is_option: false
|
|
181
|
+
is_primary_key: false
|
|
182
|
+
is_vec: false
|
|
183
|
+
num_chunksets:
|
|
184
|
+
column_type:
|
|
185
|
+
column_type: "u32"
|
|
186
|
+
type: "move_type"
|
|
187
|
+
default_value: null
|
|
188
|
+
is_index: false
|
|
189
|
+
is_nullable: false
|
|
190
|
+
is_option: false
|
|
191
|
+
is_primary_key: false
|
|
192
|
+
is_vec: false
|
|
193
|
+
owner:
|
|
194
|
+
column_type:
|
|
195
|
+
column_type: "address"
|
|
196
|
+
type: "move_type"
|
|
197
|
+
default_value: null
|
|
198
|
+
is_index: true
|
|
199
|
+
is_nullable: false
|
|
200
|
+
is_option: false
|
|
201
|
+
is_primary_key: false
|
|
202
|
+
is_vec: false
|
|
203
|
+
placement_group:
|
|
204
|
+
column_type:
|
|
205
|
+
column_type: "address"
|
|
206
|
+
type: "move_type"
|
|
207
|
+
default_value: null
|
|
208
|
+
is_index: false
|
|
209
|
+
is_nullable: false
|
|
210
|
+
is_option: false
|
|
211
|
+
is_primary_key: false
|
|
212
|
+
is_vec: false
|
|
213
|
+
size:
|
|
214
|
+
column_type:
|
|
215
|
+
column_type: "u64"
|
|
216
|
+
type: "move_type"
|
|
217
|
+
default_value: null
|
|
218
|
+
is_index: false
|
|
219
|
+
is_nullable: false
|
|
220
|
+
is_option: false
|
|
221
|
+
is_primary_key: false
|
|
222
|
+
is_vec: false
|
|
223
|
+
slice_address:
|
|
224
|
+
column_type:
|
|
225
|
+
column_type: "address"
|
|
226
|
+
type: "move_type"
|
|
227
|
+
default_value: null
|
|
228
|
+
is_index: false
|
|
229
|
+
is_nullable: false
|
|
230
|
+
is_option: false
|
|
231
|
+
is_primary_key: false
|
|
232
|
+
is_vec: false
|
|
233
|
+
updated_at:
|
|
234
|
+
column_type:
|
|
235
|
+
column_type: "u64"
|
|
236
|
+
type: "move_type"
|
|
237
|
+
default_value: null
|
|
238
|
+
is_index: false
|
|
239
|
+
is_nullable: false
|
|
240
|
+
is_option: false
|
|
241
|
+
is_primary_key: false
|
|
242
|
+
is_vec: false
|
|
243
|
+
placement_group_slots:
|
|
244
|
+
placement_group:
|
|
245
|
+
column_type:
|
|
246
|
+
column_type: "address"
|
|
247
|
+
type: "move_type"
|
|
248
|
+
default_value: null
|
|
249
|
+
is_index: false
|
|
250
|
+
is_nullable: false
|
|
251
|
+
is_option: false
|
|
252
|
+
is_primary_key: true
|
|
253
|
+
is_vec: false
|
|
254
|
+
slot_index:
|
|
255
|
+
column_type:
|
|
256
|
+
column_type: "u64"
|
|
257
|
+
type: "move_type"
|
|
258
|
+
default_value: null
|
|
259
|
+
is_index: false
|
|
260
|
+
is_nullable: false
|
|
261
|
+
is_option: false
|
|
262
|
+
is_primary_key: true
|
|
263
|
+
is_vec: false
|
|
264
|
+
status:
|
|
265
|
+
column_type:
|
|
266
|
+
column_type: "string"
|
|
267
|
+
type: "move_type"
|
|
268
|
+
default_value: null
|
|
269
|
+
is_index: false
|
|
270
|
+
is_nullable: false
|
|
271
|
+
is_option: false
|
|
272
|
+
is_primary_key: false
|
|
273
|
+
is_vec: false
|
|
274
|
+
storage_provider:
|
|
275
|
+
column_type:
|
|
276
|
+
column_type: "address"
|
|
277
|
+
type: "move_type"
|
|
278
|
+
default_value: null
|
|
279
|
+
is_index: false
|
|
280
|
+
is_nullable: false
|
|
281
|
+
is_option: false
|
|
282
|
+
is_primary_key: false
|
|
283
|
+
is_vec: false
|
|
284
|
+
updated_at:
|
|
285
|
+
column_type:
|
|
286
|
+
column_type: "u64"
|
|
287
|
+
type: "move_type"
|
|
288
|
+
default_value: null
|
|
289
|
+
is_index: false
|
|
290
|
+
is_nullable: false
|
|
291
|
+
is_option: false
|
|
292
|
+
is_primary_key: false
|
|
293
|
+
is_vec: false
|
|
294
|
+
events:
|
|
295
|
+
0xc63d6a5efb0080a6029403131715bd4971e1149f7cc099aac69bb0069b3ddbf5::blob_metadata::BlobDeletedEvent:
|
|
296
|
+
constant_values:
|
|
297
|
+
- column: "is_deleted"
|
|
298
|
+
table: "blobs"
|
|
299
|
+
value: 1
|
|
300
|
+
event_fields:
|
|
301
|
+
$.blob_name:
|
|
302
|
+
- column: "blob_name"
|
|
303
|
+
table: "blobs"
|
|
304
|
+
- column: "blob_name"
|
|
305
|
+
table: "blob_activities"
|
|
306
|
+
$.deleted_at_micros:
|
|
307
|
+
- column: "updated_at"
|
|
308
|
+
table: "blobs"
|
|
309
|
+
event_metadata:
|
|
310
|
+
account_address: []
|
|
311
|
+
creation_number: []
|
|
312
|
+
event_index:
|
|
313
|
+
- column: "event_index"
|
|
314
|
+
table: "blob_activities"
|
|
315
|
+
event_type:
|
|
316
|
+
- column: "event_type"
|
|
317
|
+
table: "blob_activities"
|
|
318
|
+
sequence_number: []
|
|
319
|
+
0xc63d6a5efb0080a6029403131715bd4971e1149f7cc099aac69bb0069b3ddbf5::blob_metadata::BlobExpirationExtendedEvent:
|
|
320
|
+
constant_values: []
|
|
321
|
+
event_fields:
|
|
322
|
+
$.blob_name:
|
|
323
|
+
- column: "blob_name"
|
|
324
|
+
table: "blobs"
|
|
325
|
+
- column: "blob_name"
|
|
326
|
+
table: "blob_activities"
|
|
327
|
+
$.new_expiration_micros:
|
|
328
|
+
- column: "expires_at"
|
|
329
|
+
table: "blobs"
|
|
330
|
+
$.updated_at_micros:
|
|
331
|
+
- column: "updated_at"
|
|
332
|
+
table: "blobs"
|
|
333
|
+
event_metadata:
|
|
334
|
+
account_address: []
|
|
335
|
+
creation_number: []
|
|
336
|
+
event_index:
|
|
337
|
+
- column: "event_index"
|
|
338
|
+
table: "blob_activities"
|
|
339
|
+
event_type:
|
|
340
|
+
- column: "event_type"
|
|
341
|
+
table: "blob_activities"
|
|
342
|
+
sequence_number: []
|
|
343
|
+
0xc63d6a5efb0080a6029403131715bd4971e1149f7cc099aac69bb0069b3ddbf5::blob_metadata::BlobRegisteredEvent:
|
|
344
|
+
constant_values:
|
|
345
|
+
- column: "is_deleted"
|
|
346
|
+
table: "blobs"
|
|
347
|
+
value: 0
|
|
348
|
+
- column: "is_written"
|
|
349
|
+
table: "blobs"
|
|
350
|
+
value: 0
|
|
351
|
+
event_fields:
|
|
352
|
+
$.blob_commitment:
|
|
353
|
+
- column: "blob_commitment"
|
|
354
|
+
table: "blobs"
|
|
355
|
+
$.blob_name:
|
|
356
|
+
- column: "blob_name"
|
|
357
|
+
table: "blobs"
|
|
358
|
+
- column: "blob_name"
|
|
359
|
+
table: "blob_activities"
|
|
360
|
+
$.blob_size:
|
|
361
|
+
- column: "size"
|
|
362
|
+
table: "blobs"
|
|
363
|
+
$.chunkset_count:
|
|
364
|
+
- column: "num_chunksets"
|
|
365
|
+
table: "blobs"
|
|
366
|
+
$.creation_micros:
|
|
367
|
+
- column: "created_at"
|
|
368
|
+
table: "blobs"
|
|
369
|
+
- column: "updated_at"
|
|
370
|
+
table: "blobs"
|
|
371
|
+
$.expiration_micros:
|
|
372
|
+
- column: "expires_at"
|
|
373
|
+
table: "blobs"
|
|
374
|
+
$.owner:
|
|
375
|
+
- column: "owner"
|
|
376
|
+
table: "blobs"
|
|
377
|
+
$.placement_group_address:
|
|
378
|
+
- column: "placement_group"
|
|
379
|
+
table: "blobs"
|
|
380
|
+
$.slice_address:
|
|
381
|
+
- column: "slice_address"
|
|
382
|
+
table: "blobs"
|
|
383
|
+
event_metadata:
|
|
384
|
+
account_address: []
|
|
385
|
+
creation_number: []
|
|
386
|
+
event_index:
|
|
387
|
+
- column: "event_index"
|
|
388
|
+
table: "blob_activities"
|
|
389
|
+
event_type:
|
|
390
|
+
- column: "event_type"
|
|
391
|
+
table: "blob_activities"
|
|
392
|
+
sequence_number: []
|
|
393
|
+
0xc63d6a5efb0080a6029403131715bd4971e1149f7cc099aac69bb0069b3ddbf5::blob_metadata::BlobWrittenEvent:
|
|
394
|
+
constant_values:
|
|
395
|
+
- column: "is_written"
|
|
396
|
+
table: "blobs"
|
|
397
|
+
value: 1
|
|
398
|
+
event_fields:
|
|
399
|
+
$.blob_name:
|
|
400
|
+
- column: "blob_name"
|
|
401
|
+
table: "blobs"
|
|
402
|
+
- column: "blob_name"
|
|
403
|
+
table: "blob_activities"
|
|
404
|
+
$.written_at_micros:
|
|
405
|
+
- column: "updated_at"
|
|
406
|
+
table: "blobs"
|
|
407
|
+
event_metadata:
|
|
408
|
+
account_address: []
|
|
409
|
+
creation_number: []
|
|
410
|
+
event_index:
|
|
411
|
+
- column: "event_index"
|
|
412
|
+
table: "blob_activities"
|
|
413
|
+
event_type:
|
|
414
|
+
- column: "event_type"
|
|
415
|
+
table: "blob_activities"
|
|
416
|
+
sequence_number: []
|
|
417
|
+
0xc63d6a5efb0080a6029403131715bd4971e1149f7cc099aac69bb0069b3ddbf5::placement_group::StorageProviderActivatedEvent:
|
|
418
|
+
constant_values:
|
|
419
|
+
- column: "status"
|
|
420
|
+
table: "placement_group_slots"
|
|
421
|
+
value: "active"
|
|
422
|
+
event_fields:
|
|
423
|
+
$.activated_at:
|
|
424
|
+
- column: "updated_at"
|
|
425
|
+
table: "placement_group_slots"
|
|
426
|
+
$.placement_group_address:
|
|
427
|
+
- column: "placement_group"
|
|
428
|
+
table: "placement_group_slots"
|
|
429
|
+
$.slot_index:
|
|
430
|
+
- column: "slot_index"
|
|
431
|
+
table: "placement_group_slots"
|
|
432
|
+
$.storage_provider_address:
|
|
433
|
+
- column: "storage_provider"
|
|
434
|
+
table: "placement_group_slots"
|
|
435
|
+
event_metadata:
|
|
436
|
+
account_address: []
|
|
437
|
+
creation_number: []
|
|
438
|
+
event_index: []
|
|
439
|
+
event_type: []
|
|
440
|
+
sequence_number: []
|
|
441
|
+
0xc63d6a5efb0080a6029403131715bd4971e1149f7cc099aac69bb0069b3ddbf5::placement_group::StorageProviderAssignedEvent:
|
|
442
|
+
constant_values:
|
|
443
|
+
- column: "status"
|
|
444
|
+
table: "placement_group_slots"
|
|
445
|
+
value: "joining"
|
|
446
|
+
event_fields:
|
|
447
|
+
$.assigned_at:
|
|
448
|
+
- column: "updated_at"
|
|
449
|
+
table: "placement_group_slots"
|
|
450
|
+
$.placement_group_address:
|
|
451
|
+
- column: "placement_group"
|
|
452
|
+
table: "placement_group_slots"
|
|
453
|
+
$.slot_index:
|
|
454
|
+
- column: "slot_index"
|
|
455
|
+
table: "placement_group_slots"
|
|
456
|
+
$.storage_provider_address:
|
|
457
|
+
- column: "storage_provider"
|
|
458
|
+
table: "placement_group_slots"
|
|
459
|
+
event_metadata:
|
|
460
|
+
account_address: []
|
|
461
|
+
creation_number: []
|
|
462
|
+
event_index: []
|
|
463
|
+
event_type: []
|
|
464
|
+
sequence_number: []
|
|
465
|
+
0xc63d6a5efb0080a6029403131715bd4971e1149f7cc099aac69bb0069b3ddbf5::placement_group::StorageProviderLeftEvent:
|
|
466
|
+
constant_values:
|
|
467
|
+
- column: "status"
|
|
468
|
+
table: "placement_group_slots"
|
|
469
|
+
value: "left"
|
|
470
|
+
event_fields:
|
|
471
|
+
$.left_at:
|
|
472
|
+
- column: "updated_at"
|
|
473
|
+
table: "placement_group_slots"
|
|
474
|
+
$.placement_group_address:
|
|
475
|
+
- column: "placement_group"
|
|
476
|
+
table: "placement_group_slots"
|
|
477
|
+
$.slot_index:
|
|
478
|
+
- column: "slot_index"
|
|
479
|
+
table: "placement_group_slots"
|
|
480
|
+
$.storage_provider_address:
|
|
481
|
+
- column: "storage_provider"
|
|
482
|
+
table: "placement_group_slots"
|
|
483
|
+
event_metadata:
|
|
484
|
+
account_address: []
|
|
485
|
+
creation_number: []
|
|
486
|
+
event_index: []
|
|
487
|
+
event_type: []
|
|
488
|
+
sequence_number: []
|
|
489
|
+
payload: {}
|
|
490
|
+
transaction_metadata:
|
|
491
|
+
block_height: []
|
|
492
|
+
epoch: []
|
|
493
|
+
hash:
|
|
494
|
+
- column: "transaction_hash"
|
|
495
|
+
table: "blob_activities"
|
|
496
|
+
timestamp:
|
|
497
|
+
- column: "timestamp"
|
|
498
|
+
table: "blob_activities"
|
|
499
|
+
version:
|
|
500
|
+
- column: "transaction_version"
|
|
501
|
+
table: "blob_activities"
|
|
502
|
+
`;
|
|
503
|
+
}
|
|
504
|
+
});
|
|
2
505
|
|
|
3
506
|
// src/cli.tsx
|
|
4
|
-
import { Command } from "commander";
|
|
507
|
+
import { Command } from "@commander-js/extra-typings";
|
|
5
508
|
|
|
6
509
|
// package.json
|
|
7
|
-
var
|
|
510
|
+
var name = "@shelby-protocol/cli";
|
|
511
|
+
var version = "0.0.16";
|
|
8
512
|
|
|
9
513
|
// src/commands/account.tsx
|
|
10
514
|
import readline from "readline";
|
|
11
515
|
import { Account as Account3, AptosApiError as AptosApiError2, Ed25519PrivateKey as Ed25519PrivateKey4 } from "@aptos-labs/ts-sdk";
|
|
516
|
+
import { Option } from "@commander-js/extra-typings";
|
|
12
517
|
|
|
13
518
|
// ../../packages/sdk/dist/chunk-RBFWGDMY.mjs
|
|
14
519
|
import { AptosConfig, Network } from "@aptos-labs/ts-sdk";
|
|
@@ -228,10 +733,10 @@ var GraphQLError = class _GraphQLError extends Error {
|
|
|
228
733
|
*/
|
|
229
734
|
constructor(message, ...rawArgs) {
|
|
230
735
|
var _this$nodes, _nodeLocations$, _ref;
|
|
231
|
-
const { nodes, source, positions, path:
|
|
736
|
+
const { nodes, source, positions, path: path10, originalError, extensions } = toNormalizedOptions(rawArgs);
|
|
232
737
|
super(message);
|
|
233
738
|
this.name = "GraphQLError";
|
|
234
|
-
this.path =
|
|
739
|
+
this.path = path10 !== null && path10 !== void 0 ? path10 : void 0;
|
|
235
740
|
this.originalError = originalError !== null && originalError !== void 0 ? originalError : void 0;
|
|
236
741
|
this.nodes = undefinedIfEmpty(
|
|
237
742
|
Array.isArray(nodes) ? nodes : nodes ? [nodes] : void 0
|
|
@@ -1277,9 +1782,9 @@ function formatArray(array, seenValues) {
|
|
|
1277
1782
|
function getObjectTag(object) {
|
|
1278
1783
|
const tag = Object.prototype.toString.call(object).replace(/^\[object /, "").replace(/]$/, "");
|
|
1279
1784
|
if (tag === "Object" && typeof object.constructor === "function") {
|
|
1280
|
-
const
|
|
1281
|
-
if (typeof
|
|
1282
|
-
return
|
|
1785
|
+
const name2 = object.constructor.name;
|
|
1786
|
+
if (typeof name2 === "string" && name2 !== "") {
|
|
1787
|
+
return name2;
|
|
1283
1788
|
}
|
|
1284
1789
|
}
|
|
1285
1790
|
return tag;
|
|
@@ -1326,13 +1831,13 @@ spurious results.`);
|
|
|
1326
1831
|
|
|
1327
1832
|
// ../../node_modules/.pnpm/graphql@16.11.0/node_modules/graphql/language/source.mjs
|
|
1328
1833
|
var Source = class {
|
|
1329
|
-
constructor(body,
|
|
1834
|
+
constructor(body, name2 = "GraphQL request", locationOffset = {
|
|
1330
1835
|
line: 1,
|
|
1331
1836
|
column: 1
|
|
1332
1837
|
}) {
|
|
1333
1838
|
typeof body === "string" || devAssert(false, `Body must be a string. Received: ${inspect(body)}.`);
|
|
1334
1839
|
this.body = body;
|
|
1335
|
-
this.name =
|
|
1840
|
+
this.name = name2;
|
|
1336
1841
|
this.locationOffset = locationOffset;
|
|
1337
1842
|
this.locationOffset.line > 0 || devAssert(
|
|
1338
1843
|
false,
|
|
@@ -1482,14 +1987,14 @@ var Parser = class {
|
|
|
1482
1987
|
});
|
|
1483
1988
|
}
|
|
1484
1989
|
const operation = this.parseOperationType();
|
|
1485
|
-
let
|
|
1990
|
+
let name2;
|
|
1486
1991
|
if (this.peek(TokenKind.NAME)) {
|
|
1487
|
-
|
|
1992
|
+
name2 = this.parseName();
|
|
1488
1993
|
}
|
|
1489
1994
|
return this.node(start, {
|
|
1490
1995
|
kind: Kind.OPERATION_DEFINITION,
|
|
1491
1996
|
operation,
|
|
1492
|
-
name,
|
|
1997
|
+
name: name2,
|
|
1493
1998
|
variableDefinitions: this.parseVariableDefinitions(),
|
|
1494
1999
|
directives: this.parseDirectives(false),
|
|
1495
2000
|
selectionSet: this.parseSelectionSet()
|
|
@@ -1576,17 +2081,17 @@ var Parser = class {
|
|
|
1576
2081
|
const start = this._lexer.token;
|
|
1577
2082
|
const nameOrAlias = this.parseName();
|
|
1578
2083
|
let alias;
|
|
1579
|
-
let
|
|
2084
|
+
let name2;
|
|
1580
2085
|
if (this.expectOptionalToken(TokenKind.COLON)) {
|
|
1581
2086
|
alias = nameOrAlias;
|
|
1582
|
-
|
|
2087
|
+
name2 = this.parseName();
|
|
1583
2088
|
} else {
|
|
1584
|
-
|
|
2089
|
+
name2 = nameOrAlias;
|
|
1585
2090
|
}
|
|
1586
2091
|
return this.node(start, {
|
|
1587
2092
|
kind: Kind.FIELD,
|
|
1588
2093
|
alias,
|
|
1589
|
-
name,
|
|
2094
|
+
name: name2,
|
|
1590
2095
|
arguments: this.parseArguments(false),
|
|
1591
2096
|
directives: this.parseDirectives(false),
|
|
1592
2097
|
selectionSet: this.peek(TokenKind.BRACE_L) ? this.parseSelectionSet() : void 0
|
|
@@ -1604,11 +2109,11 @@ var Parser = class {
|
|
|
1604
2109
|
*/
|
|
1605
2110
|
parseArgument(isConst = false) {
|
|
1606
2111
|
const start = this._lexer.token;
|
|
1607
|
-
const
|
|
2112
|
+
const name2 = this.parseName();
|
|
1608
2113
|
this.expectToken(TokenKind.COLON);
|
|
1609
2114
|
return this.node(start, {
|
|
1610
2115
|
kind: Kind.ARGUMENT,
|
|
1611
|
-
name,
|
|
2116
|
+
name: name2,
|
|
1612
2117
|
value: this.parseValueLiteral(isConst)
|
|
1613
2118
|
});
|
|
1614
2119
|
}
|
|
@@ -1803,11 +2308,11 @@ var Parser = class {
|
|
|
1803
2308
|
*/
|
|
1804
2309
|
parseObjectField(isConst) {
|
|
1805
2310
|
const start = this._lexer.token;
|
|
1806
|
-
const
|
|
2311
|
+
const name2 = this.parseName();
|
|
1807
2312
|
this.expectToken(TokenKind.COLON);
|
|
1808
2313
|
return this.node(start, {
|
|
1809
2314
|
kind: Kind.OBJECT_FIELD,
|
|
1810
|
-
name,
|
|
2315
|
+
name: name2,
|
|
1811
2316
|
value: this.parseValueLiteral(isConst)
|
|
1812
2317
|
});
|
|
1813
2318
|
}
|
|
@@ -1931,12 +2436,12 @@ var Parser = class {
|
|
|
1931
2436
|
const start = this._lexer.token;
|
|
1932
2437
|
const description = this.parseDescription();
|
|
1933
2438
|
this.expectKeyword("scalar");
|
|
1934
|
-
const
|
|
2439
|
+
const name2 = this.parseName();
|
|
1935
2440
|
const directives = this.parseConstDirectives();
|
|
1936
2441
|
return this.node(start, {
|
|
1937
2442
|
kind: Kind.SCALAR_TYPE_DEFINITION,
|
|
1938
2443
|
description,
|
|
1939
|
-
name,
|
|
2444
|
+
name: name2,
|
|
1940
2445
|
directives
|
|
1941
2446
|
});
|
|
1942
2447
|
}
|
|
@@ -1949,14 +2454,14 @@ var Parser = class {
|
|
|
1949
2454
|
const start = this._lexer.token;
|
|
1950
2455
|
const description = this.parseDescription();
|
|
1951
2456
|
this.expectKeyword("type");
|
|
1952
|
-
const
|
|
2457
|
+
const name2 = this.parseName();
|
|
1953
2458
|
const interfaces = this.parseImplementsInterfaces();
|
|
1954
2459
|
const directives = this.parseConstDirectives();
|
|
1955
2460
|
const fields = this.parseFieldsDefinition();
|
|
1956
2461
|
return this.node(start, {
|
|
1957
2462
|
kind: Kind.OBJECT_TYPE_DEFINITION,
|
|
1958
2463
|
description,
|
|
1959
|
-
name,
|
|
2464
|
+
name: name2,
|
|
1960
2465
|
interfaces,
|
|
1961
2466
|
directives,
|
|
1962
2467
|
fields
|
|
@@ -1989,7 +2494,7 @@ var Parser = class {
|
|
|
1989
2494
|
parseFieldDefinition() {
|
|
1990
2495
|
const start = this._lexer.token;
|
|
1991
2496
|
const description = this.parseDescription();
|
|
1992
|
-
const
|
|
2497
|
+
const name2 = this.parseName();
|
|
1993
2498
|
const args = this.parseArgumentDefs();
|
|
1994
2499
|
this.expectToken(TokenKind.COLON);
|
|
1995
2500
|
const type = this.parseTypeReference();
|
|
@@ -1997,7 +2502,7 @@ var Parser = class {
|
|
|
1997
2502
|
return this.node(start, {
|
|
1998
2503
|
kind: Kind.FIELD_DEFINITION,
|
|
1999
2504
|
description,
|
|
2000
|
-
name,
|
|
2505
|
+
name: name2,
|
|
2001
2506
|
arguments: args,
|
|
2002
2507
|
type,
|
|
2003
2508
|
directives
|
|
@@ -2020,7 +2525,7 @@ var Parser = class {
|
|
|
2020
2525
|
parseInputValueDef() {
|
|
2021
2526
|
const start = this._lexer.token;
|
|
2022
2527
|
const description = this.parseDescription();
|
|
2023
|
-
const
|
|
2528
|
+
const name2 = this.parseName();
|
|
2024
2529
|
this.expectToken(TokenKind.COLON);
|
|
2025
2530
|
const type = this.parseTypeReference();
|
|
2026
2531
|
let defaultValue;
|
|
@@ -2031,7 +2536,7 @@ var Parser = class {
|
|
|
2031
2536
|
return this.node(start, {
|
|
2032
2537
|
kind: Kind.INPUT_VALUE_DEFINITION,
|
|
2033
2538
|
description,
|
|
2034
|
-
name,
|
|
2539
|
+
name: name2,
|
|
2035
2540
|
type,
|
|
2036
2541
|
defaultValue,
|
|
2037
2542
|
directives
|
|
@@ -2045,14 +2550,14 @@ var Parser = class {
|
|
|
2045
2550
|
const start = this._lexer.token;
|
|
2046
2551
|
const description = this.parseDescription();
|
|
2047
2552
|
this.expectKeyword("interface");
|
|
2048
|
-
const
|
|
2553
|
+
const name2 = this.parseName();
|
|
2049
2554
|
const interfaces = this.parseImplementsInterfaces();
|
|
2050
2555
|
const directives = this.parseConstDirectives();
|
|
2051
2556
|
const fields = this.parseFieldsDefinition();
|
|
2052
2557
|
return this.node(start, {
|
|
2053
2558
|
kind: Kind.INTERFACE_TYPE_DEFINITION,
|
|
2054
2559
|
description,
|
|
2055
|
-
name,
|
|
2560
|
+
name: name2,
|
|
2056
2561
|
interfaces,
|
|
2057
2562
|
directives,
|
|
2058
2563
|
fields
|
|
@@ -2066,13 +2571,13 @@ var Parser = class {
|
|
|
2066
2571
|
const start = this._lexer.token;
|
|
2067
2572
|
const description = this.parseDescription();
|
|
2068
2573
|
this.expectKeyword("union");
|
|
2069
|
-
const
|
|
2574
|
+
const name2 = this.parseName();
|
|
2070
2575
|
const directives = this.parseConstDirectives();
|
|
2071
2576
|
const types = this.parseUnionMemberTypes();
|
|
2072
2577
|
return this.node(start, {
|
|
2073
2578
|
kind: Kind.UNION_TYPE_DEFINITION,
|
|
2074
2579
|
description,
|
|
2075
|
-
name,
|
|
2580
|
+
name: name2,
|
|
2076
2581
|
directives,
|
|
2077
2582
|
types
|
|
2078
2583
|
});
|
|
@@ -2093,13 +2598,13 @@ var Parser = class {
|
|
|
2093
2598
|
const start = this._lexer.token;
|
|
2094
2599
|
const description = this.parseDescription();
|
|
2095
2600
|
this.expectKeyword("enum");
|
|
2096
|
-
const
|
|
2601
|
+
const name2 = this.parseName();
|
|
2097
2602
|
const directives = this.parseConstDirectives();
|
|
2098
2603
|
const values = this.parseEnumValuesDefinition();
|
|
2099
2604
|
return this.node(start, {
|
|
2100
2605
|
kind: Kind.ENUM_TYPE_DEFINITION,
|
|
2101
2606
|
description,
|
|
2102
|
-
name,
|
|
2607
|
+
name: name2,
|
|
2103
2608
|
directives,
|
|
2104
2609
|
values
|
|
2105
2610
|
});
|
|
@@ -2122,12 +2627,12 @@ var Parser = class {
|
|
|
2122
2627
|
parseEnumValueDefinition() {
|
|
2123
2628
|
const start = this._lexer.token;
|
|
2124
2629
|
const description = this.parseDescription();
|
|
2125
|
-
const
|
|
2630
|
+
const name2 = this.parseEnumValueName();
|
|
2126
2631
|
const directives = this.parseConstDirectives();
|
|
2127
2632
|
return this.node(start, {
|
|
2128
2633
|
kind: Kind.ENUM_VALUE_DEFINITION,
|
|
2129
2634
|
description,
|
|
2130
|
-
name,
|
|
2635
|
+
name: name2,
|
|
2131
2636
|
directives
|
|
2132
2637
|
});
|
|
2133
2638
|
}
|
|
@@ -2154,13 +2659,13 @@ var Parser = class {
|
|
|
2154
2659
|
const start = this._lexer.token;
|
|
2155
2660
|
const description = this.parseDescription();
|
|
2156
2661
|
this.expectKeyword("input");
|
|
2157
|
-
const
|
|
2662
|
+
const name2 = this.parseName();
|
|
2158
2663
|
const directives = this.parseConstDirectives();
|
|
2159
2664
|
const fields = this.parseInputFieldsDefinition();
|
|
2160
2665
|
return this.node(start, {
|
|
2161
2666
|
kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
|
2162
2667
|
description,
|
|
2163
|
-
name,
|
|
2668
|
+
name: name2,
|
|
2164
2669
|
directives,
|
|
2165
2670
|
fields
|
|
2166
2671
|
});
|
|
@@ -2246,14 +2751,14 @@ var Parser = class {
|
|
|
2246
2751
|
const start = this._lexer.token;
|
|
2247
2752
|
this.expectKeyword("extend");
|
|
2248
2753
|
this.expectKeyword("scalar");
|
|
2249
|
-
const
|
|
2754
|
+
const name2 = this.parseName();
|
|
2250
2755
|
const directives = this.parseConstDirectives();
|
|
2251
2756
|
if (directives.length === 0) {
|
|
2252
2757
|
throw this.unexpected();
|
|
2253
2758
|
}
|
|
2254
2759
|
return this.node(start, {
|
|
2255
2760
|
kind: Kind.SCALAR_TYPE_EXTENSION,
|
|
2256
|
-
name,
|
|
2761
|
+
name: name2,
|
|
2257
2762
|
directives
|
|
2258
2763
|
});
|
|
2259
2764
|
}
|
|
@@ -2267,7 +2772,7 @@ var Parser = class {
|
|
|
2267
2772
|
const start = this._lexer.token;
|
|
2268
2773
|
this.expectKeyword("extend");
|
|
2269
2774
|
this.expectKeyword("type");
|
|
2270
|
-
const
|
|
2775
|
+
const name2 = this.parseName();
|
|
2271
2776
|
const interfaces = this.parseImplementsInterfaces();
|
|
2272
2777
|
const directives = this.parseConstDirectives();
|
|
2273
2778
|
const fields = this.parseFieldsDefinition();
|
|
@@ -2276,7 +2781,7 @@ var Parser = class {
|
|
|
2276
2781
|
}
|
|
2277
2782
|
return this.node(start, {
|
|
2278
2783
|
kind: Kind.OBJECT_TYPE_EXTENSION,
|
|
2279
|
-
name,
|
|
2784
|
+
name: name2,
|
|
2280
2785
|
interfaces,
|
|
2281
2786
|
directives,
|
|
2282
2787
|
fields
|
|
@@ -2292,7 +2797,7 @@ var Parser = class {
|
|
|
2292
2797
|
const start = this._lexer.token;
|
|
2293
2798
|
this.expectKeyword("extend");
|
|
2294
2799
|
this.expectKeyword("interface");
|
|
2295
|
-
const
|
|
2800
|
+
const name2 = this.parseName();
|
|
2296
2801
|
const interfaces = this.parseImplementsInterfaces();
|
|
2297
2802
|
const directives = this.parseConstDirectives();
|
|
2298
2803
|
const fields = this.parseFieldsDefinition();
|
|
@@ -2301,7 +2806,7 @@ var Parser = class {
|
|
|
2301
2806
|
}
|
|
2302
2807
|
return this.node(start, {
|
|
2303
2808
|
kind: Kind.INTERFACE_TYPE_EXTENSION,
|
|
2304
|
-
name,
|
|
2809
|
+
name: name2,
|
|
2305
2810
|
interfaces,
|
|
2306
2811
|
directives,
|
|
2307
2812
|
fields
|
|
@@ -2316,7 +2821,7 @@ var Parser = class {
|
|
|
2316
2821
|
const start = this._lexer.token;
|
|
2317
2822
|
this.expectKeyword("extend");
|
|
2318
2823
|
this.expectKeyword("union");
|
|
2319
|
-
const
|
|
2824
|
+
const name2 = this.parseName();
|
|
2320
2825
|
const directives = this.parseConstDirectives();
|
|
2321
2826
|
const types = this.parseUnionMemberTypes();
|
|
2322
2827
|
if (directives.length === 0 && types.length === 0) {
|
|
@@ -2324,7 +2829,7 @@ var Parser = class {
|
|
|
2324
2829
|
}
|
|
2325
2830
|
return this.node(start, {
|
|
2326
2831
|
kind: Kind.UNION_TYPE_EXTENSION,
|
|
2327
|
-
name,
|
|
2832
|
+
name: name2,
|
|
2328
2833
|
directives,
|
|
2329
2834
|
types
|
|
2330
2835
|
});
|
|
@@ -2338,7 +2843,7 @@ var Parser = class {
|
|
|
2338
2843
|
const start = this._lexer.token;
|
|
2339
2844
|
this.expectKeyword("extend");
|
|
2340
2845
|
this.expectKeyword("enum");
|
|
2341
|
-
const
|
|
2846
|
+
const name2 = this.parseName();
|
|
2342
2847
|
const directives = this.parseConstDirectives();
|
|
2343
2848
|
const values = this.parseEnumValuesDefinition();
|
|
2344
2849
|
if (directives.length === 0 && values.length === 0) {
|
|
@@ -2346,7 +2851,7 @@ var Parser = class {
|
|
|
2346
2851
|
}
|
|
2347
2852
|
return this.node(start, {
|
|
2348
2853
|
kind: Kind.ENUM_TYPE_EXTENSION,
|
|
2349
|
-
name,
|
|
2854
|
+
name: name2,
|
|
2350
2855
|
directives,
|
|
2351
2856
|
values
|
|
2352
2857
|
});
|
|
@@ -2360,7 +2865,7 @@ var Parser = class {
|
|
|
2360
2865
|
const start = this._lexer.token;
|
|
2361
2866
|
this.expectKeyword("extend");
|
|
2362
2867
|
this.expectKeyword("input");
|
|
2363
|
-
const
|
|
2868
|
+
const name2 = this.parseName();
|
|
2364
2869
|
const directives = this.parseConstDirectives();
|
|
2365
2870
|
const fields = this.parseInputFieldsDefinition();
|
|
2366
2871
|
if (directives.length === 0 && fields.length === 0) {
|
|
@@ -2368,7 +2873,7 @@ var Parser = class {
|
|
|
2368
2873
|
}
|
|
2369
2874
|
return this.node(start, {
|
|
2370
2875
|
kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,
|
|
2371
|
-
name,
|
|
2876
|
+
name: name2,
|
|
2372
2877
|
directives,
|
|
2373
2878
|
fields
|
|
2374
2879
|
});
|
|
@@ -2384,7 +2889,7 @@ var Parser = class {
|
|
|
2384
2889
|
const description = this.parseDescription();
|
|
2385
2890
|
this.expectKeyword("directive");
|
|
2386
2891
|
this.expectToken(TokenKind.AT);
|
|
2387
|
-
const
|
|
2892
|
+
const name2 = this.parseName();
|
|
2388
2893
|
const args = this.parseArgumentDefs();
|
|
2389
2894
|
const repeatable = this.expectOptionalKeyword("repeatable");
|
|
2390
2895
|
this.expectKeyword("on");
|
|
@@ -2392,7 +2897,7 @@ var Parser = class {
|
|
|
2392
2897
|
return this.node(start, {
|
|
2393
2898
|
kind: Kind.DIRECTIVE_DEFINITION,
|
|
2394
2899
|
description,
|
|
2395
|
-
name,
|
|
2900
|
+
name: name2,
|
|
2396
2901
|
arguments: args,
|
|
2397
2902
|
repeatable,
|
|
2398
2903
|
locations
|
|
@@ -2435,9 +2940,9 @@ var Parser = class {
|
|
|
2435
2940
|
*/
|
|
2436
2941
|
parseDirectiveLocation() {
|
|
2437
2942
|
const start = this._lexer.token;
|
|
2438
|
-
const
|
|
2439
|
-
if (Object.prototype.hasOwnProperty.call(DirectiveLocation,
|
|
2440
|
-
return
|
|
2943
|
+
const name2 = this.parseName();
|
|
2944
|
+
if (Object.prototype.hasOwnProperty.call(DirectiveLocation, name2.value)) {
|
|
2945
|
+
return name2;
|
|
2441
2946
|
}
|
|
2442
2947
|
throw this.unexpected(start);
|
|
2443
2948
|
}
|
|
@@ -2799,14 +3304,14 @@ function visit(root, visitor, visitorKeys = QueryDocumentKeys) {
|
|
|
2799
3304
|
let node = root;
|
|
2800
3305
|
let key = void 0;
|
|
2801
3306
|
let parent = void 0;
|
|
2802
|
-
const
|
|
3307
|
+
const path10 = [];
|
|
2803
3308
|
const ancestors = [];
|
|
2804
3309
|
do {
|
|
2805
3310
|
index++;
|
|
2806
3311
|
const isLeaving = index === keys.length;
|
|
2807
3312
|
const isEdited = isLeaving && edits.length !== 0;
|
|
2808
3313
|
if (isLeaving) {
|
|
2809
|
-
key = ancestors.length === 0 ? void 0 :
|
|
3314
|
+
key = ancestors.length === 0 ? void 0 : path10[path10.length - 1];
|
|
2810
3315
|
node = parent;
|
|
2811
3316
|
parent = ancestors.pop();
|
|
2812
3317
|
if (isEdited) {
|
|
@@ -2840,20 +3345,20 @@ function visit(root, visitor, visitorKeys = QueryDocumentKeys) {
|
|
|
2840
3345
|
if (node === null || node === void 0) {
|
|
2841
3346
|
continue;
|
|
2842
3347
|
}
|
|
2843
|
-
|
|
3348
|
+
path10.push(key);
|
|
2844
3349
|
}
|
|
2845
3350
|
let result;
|
|
2846
3351
|
if (!Array.isArray(node)) {
|
|
2847
3352
|
var _enterLeaveMap$get, _enterLeaveMap$get2;
|
|
2848
3353
|
isNode(node) || devAssert(false, `Invalid AST Node: ${inspect(node)}.`);
|
|
2849
3354
|
const visitFn = isLeaving ? (_enterLeaveMap$get = enterLeaveMap.get(node.kind)) === null || _enterLeaveMap$get === void 0 ? void 0 : _enterLeaveMap$get.leave : (_enterLeaveMap$get2 = enterLeaveMap.get(node.kind)) === null || _enterLeaveMap$get2 === void 0 ? void 0 : _enterLeaveMap$get2.enter;
|
|
2850
|
-
result = visitFn === null || visitFn === void 0 ? void 0 : visitFn.call(visitor, node, key, parent,
|
|
3355
|
+
result = visitFn === null || visitFn === void 0 ? void 0 : visitFn.call(visitor, node, key, parent, path10, ancestors);
|
|
2851
3356
|
if (result === BREAK) {
|
|
2852
3357
|
break;
|
|
2853
3358
|
}
|
|
2854
3359
|
if (result === false) {
|
|
2855
3360
|
if (!isLeaving) {
|
|
2856
|
-
|
|
3361
|
+
path10.pop();
|
|
2857
3362
|
continue;
|
|
2858
3363
|
}
|
|
2859
3364
|
} else if (result !== void 0) {
|
|
@@ -2862,7 +3367,7 @@ function visit(root, visitor, visitorKeys = QueryDocumentKeys) {
|
|
|
2862
3367
|
if (isNode(result)) {
|
|
2863
3368
|
node = result;
|
|
2864
3369
|
} else {
|
|
2865
|
-
|
|
3370
|
+
path10.pop();
|
|
2866
3371
|
continue;
|
|
2867
3372
|
}
|
|
2868
3373
|
}
|
|
@@ -2872,7 +3377,7 @@ function visit(root, visitor, visitorKeys = QueryDocumentKeys) {
|
|
|
2872
3377
|
edits.push([key, node]);
|
|
2873
3378
|
}
|
|
2874
3379
|
if (isLeaving) {
|
|
2875
|
-
|
|
3380
|
+
path10.pop();
|
|
2876
3381
|
} else {
|
|
2877
3382
|
var _node$kind;
|
|
2878
3383
|
stack = {
|
|
@@ -2950,8 +3455,8 @@ var printDocASTReducer = {
|
|
|
2950
3455
|
leave: ({ selections }) => block(selections)
|
|
2951
3456
|
},
|
|
2952
3457
|
Field: {
|
|
2953
|
-
leave({ alias, name, arguments: args, directives, selectionSet }) {
|
|
2954
|
-
const prefix = wrap("", alias, ": ") +
|
|
3458
|
+
leave({ alias, name: name2, arguments: args, directives, selectionSet }) {
|
|
3459
|
+
const prefix = wrap("", alias, ": ") + name2;
|
|
2955
3460
|
let argsLine = prefix + wrap("(", join(args, ", "), ")");
|
|
2956
3461
|
if (argsLine.length > MAX_LINE_LENGTH) {
|
|
2957
3462
|
argsLine = prefix + wrap("(\n", indent(join(args, "\n")), "\n)");
|
|
@@ -2960,11 +3465,11 @@ var printDocASTReducer = {
|
|
|
2960
3465
|
}
|
|
2961
3466
|
},
|
|
2962
3467
|
Argument: {
|
|
2963
|
-
leave: ({ name, value }) =>
|
|
3468
|
+
leave: ({ name: name2, value }) => name2 + ": " + value
|
|
2964
3469
|
},
|
|
2965
3470
|
// Fragments
|
|
2966
3471
|
FragmentSpread: {
|
|
2967
|
-
leave: ({ name, directives }) => "..." +
|
|
3472
|
+
leave: ({ name: name2, directives }) => "..." + name2 + wrap(" ", join(directives, " "))
|
|
2968
3473
|
},
|
|
2969
3474
|
InlineFragment: {
|
|
2970
3475
|
leave: ({ typeCondition, directives, selectionSet }) => join(
|
|
@@ -2978,9 +3483,9 @@ var printDocASTReducer = {
|
|
|
2978
3483
|
)
|
|
2979
3484
|
},
|
|
2980
3485
|
FragmentDefinition: {
|
|
2981
|
-
leave: ({ name, typeCondition, variableDefinitions, directives, selectionSet }) => (
|
|
3486
|
+
leave: ({ name: name2, typeCondition, variableDefinitions, directives, selectionSet }) => (
|
|
2982
3487
|
// or removed in the future.
|
|
2983
|
-
`fragment ${
|
|
3488
|
+
`fragment ${name2}${wrap("(", join(variableDefinitions, ", "), ")")} on ${typeCondition} ${wrap("", join(directives, " "), " ")}` + selectionSet
|
|
2984
3489
|
)
|
|
2985
3490
|
},
|
|
2986
3491
|
// Value
|
|
@@ -3009,15 +3514,15 @@ var printDocASTReducer = {
|
|
|
3009
3514
|
leave: ({ fields }) => "{" + join(fields, ", ") + "}"
|
|
3010
3515
|
},
|
|
3011
3516
|
ObjectField: {
|
|
3012
|
-
leave: ({ name, value }) =>
|
|
3517
|
+
leave: ({ name: name2, value }) => name2 + ": " + value
|
|
3013
3518
|
},
|
|
3014
3519
|
// Directive
|
|
3015
3520
|
Directive: {
|
|
3016
|
-
leave: ({ name, arguments: args }) => "@" +
|
|
3521
|
+
leave: ({ name: name2, arguments: args }) => "@" + name2 + wrap("(", join(args, ", "), ")")
|
|
3017
3522
|
},
|
|
3018
3523
|
// Type
|
|
3019
3524
|
NamedType: {
|
|
3020
|
-
leave: ({ name }) =>
|
|
3525
|
+
leave: ({ name: name2 }) => name2
|
|
3021
3526
|
},
|
|
3022
3527
|
ListType: {
|
|
3023
3528
|
leave: ({ type }) => "[" + type + "]"
|
|
@@ -3033,13 +3538,13 @@ var printDocASTReducer = {
|
|
|
3033
3538
|
leave: ({ operation, type }) => operation + ": " + type
|
|
3034
3539
|
},
|
|
3035
3540
|
ScalarTypeDefinition: {
|
|
3036
|
-
leave: ({ description, name, directives }) => wrap("", description, "\n") + join(["scalar",
|
|
3541
|
+
leave: ({ description, name: name2, directives }) => wrap("", description, "\n") + join(["scalar", name2, join(directives, " ")], " ")
|
|
3037
3542
|
},
|
|
3038
3543
|
ObjectTypeDefinition: {
|
|
3039
|
-
leave: ({ description, name, interfaces, directives, fields }) => wrap("", description, "\n") + join(
|
|
3544
|
+
leave: ({ description, name: name2, interfaces, directives, fields }) => wrap("", description, "\n") + join(
|
|
3040
3545
|
[
|
|
3041
3546
|
"type",
|
|
3042
|
-
|
|
3547
|
+
name2,
|
|
3043
3548
|
wrap("implements ", join(interfaces, " & ")),
|
|
3044
3549
|
join(directives, " "),
|
|
3045
3550
|
block(fields)
|
|
@@ -3048,19 +3553,19 @@ var printDocASTReducer = {
|
|
|
3048
3553
|
)
|
|
3049
3554
|
},
|
|
3050
3555
|
FieldDefinition: {
|
|
3051
|
-
leave: ({ description, name, arguments: args, type, directives }) => wrap("", description, "\n") +
|
|
3556
|
+
leave: ({ description, name: name2, arguments: args, type, directives }) => wrap("", description, "\n") + name2 + (hasMultilineItems(args) ? wrap("(\n", indent(join(args, "\n")), "\n)") : wrap("(", join(args, ", "), ")")) + ": " + type + wrap(" ", join(directives, " "))
|
|
3052
3557
|
},
|
|
3053
3558
|
InputValueDefinition: {
|
|
3054
|
-
leave: ({ description, name, type, defaultValue, directives }) => wrap("", description, "\n") + join(
|
|
3055
|
-
[
|
|
3559
|
+
leave: ({ description, name: name2, type, defaultValue, directives }) => wrap("", description, "\n") + join(
|
|
3560
|
+
[name2 + ": " + type, wrap("= ", defaultValue), join(directives, " ")],
|
|
3056
3561
|
" "
|
|
3057
3562
|
)
|
|
3058
3563
|
},
|
|
3059
3564
|
InterfaceTypeDefinition: {
|
|
3060
|
-
leave: ({ description, name, interfaces, directives, fields }) => wrap("", description, "\n") + join(
|
|
3565
|
+
leave: ({ description, name: name2, interfaces, directives, fields }) => wrap("", description, "\n") + join(
|
|
3061
3566
|
[
|
|
3062
3567
|
"interface",
|
|
3063
|
-
|
|
3568
|
+
name2,
|
|
3064
3569
|
wrap("implements ", join(interfaces, " & ")),
|
|
3065
3570
|
join(directives, " "),
|
|
3066
3571
|
block(fields)
|
|
@@ -3069,22 +3574,22 @@ var printDocASTReducer = {
|
|
|
3069
3574
|
)
|
|
3070
3575
|
},
|
|
3071
3576
|
UnionTypeDefinition: {
|
|
3072
|
-
leave: ({ description, name, directives, types }) => wrap("", description, "\n") + join(
|
|
3073
|
-
["union",
|
|
3577
|
+
leave: ({ description, name: name2, directives, types }) => wrap("", description, "\n") + join(
|
|
3578
|
+
["union", name2, join(directives, " "), wrap("= ", join(types, " | "))],
|
|
3074
3579
|
" "
|
|
3075
3580
|
)
|
|
3076
3581
|
},
|
|
3077
3582
|
EnumTypeDefinition: {
|
|
3078
|
-
leave: ({ description, name, directives, values }) => wrap("", description, "\n") + join(["enum",
|
|
3583
|
+
leave: ({ description, name: name2, directives, values }) => wrap("", description, "\n") + join(["enum", name2, join(directives, " "), block(values)], " ")
|
|
3079
3584
|
},
|
|
3080
3585
|
EnumValueDefinition: {
|
|
3081
|
-
leave: ({ description, name, directives }) => wrap("", description, "\n") + join([
|
|
3586
|
+
leave: ({ description, name: name2, directives }) => wrap("", description, "\n") + join([name2, join(directives, " ")], " ")
|
|
3082
3587
|
},
|
|
3083
3588
|
InputObjectTypeDefinition: {
|
|
3084
|
-
leave: ({ description, name, directives, fields }) => wrap("", description, "\n") + join(["input",
|
|
3589
|
+
leave: ({ description, name: name2, directives, fields }) => wrap("", description, "\n") + join(["input", name2, join(directives, " "), block(fields)], " ")
|
|
3085
3590
|
},
|
|
3086
3591
|
DirectiveDefinition: {
|
|
3087
|
-
leave: ({ description, name, arguments: args, repeatable, locations }) => wrap("", description, "\n") + "directive @" +
|
|
3592
|
+
leave: ({ description, name: name2, arguments: args, repeatable, locations }) => wrap("", description, "\n") + "directive @" + name2 + (hasMultilineItems(args) ? wrap("(\n", indent(join(args, "\n")), "\n)") : wrap("(", join(args, ", "), ")")) + (repeatable ? " repeatable" : "") + " on " + join(locations, " | ")
|
|
3088
3593
|
},
|
|
3089
3594
|
SchemaExtension: {
|
|
3090
3595
|
leave: ({ directives, operationTypes }) => join(
|
|
@@ -3093,13 +3598,13 @@ var printDocASTReducer = {
|
|
|
3093
3598
|
)
|
|
3094
3599
|
},
|
|
3095
3600
|
ScalarTypeExtension: {
|
|
3096
|
-
leave: ({ name, directives }) => join(["extend scalar",
|
|
3601
|
+
leave: ({ name: name2, directives }) => join(["extend scalar", name2, join(directives, " ")], " ")
|
|
3097
3602
|
},
|
|
3098
3603
|
ObjectTypeExtension: {
|
|
3099
|
-
leave: ({ name, interfaces, directives, fields }) => join(
|
|
3604
|
+
leave: ({ name: name2, interfaces, directives, fields }) => join(
|
|
3100
3605
|
[
|
|
3101
3606
|
"extend type",
|
|
3102
|
-
|
|
3607
|
+
name2,
|
|
3103
3608
|
wrap("implements ", join(interfaces, " & ")),
|
|
3104
3609
|
join(directives, " "),
|
|
3105
3610
|
block(fields)
|
|
@@ -3108,10 +3613,10 @@ var printDocASTReducer = {
|
|
|
3108
3613
|
)
|
|
3109
3614
|
},
|
|
3110
3615
|
InterfaceTypeExtension: {
|
|
3111
|
-
leave: ({ name, interfaces, directives, fields }) => join(
|
|
3616
|
+
leave: ({ name: name2, interfaces, directives, fields }) => join(
|
|
3112
3617
|
[
|
|
3113
3618
|
"extend interface",
|
|
3114
|
-
|
|
3619
|
+
name2,
|
|
3115
3620
|
wrap("implements ", join(interfaces, " & ")),
|
|
3116
3621
|
join(directives, " "),
|
|
3117
3622
|
block(fields)
|
|
@@ -3120,10 +3625,10 @@ var printDocASTReducer = {
|
|
|
3120
3625
|
)
|
|
3121
3626
|
},
|
|
3122
3627
|
UnionTypeExtension: {
|
|
3123
|
-
leave: ({ name, directives, types }) => join(
|
|
3628
|
+
leave: ({ name: name2, directives, types }) => join(
|
|
3124
3629
|
[
|
|
3125
3630
|
"extend union",
|
|
3126
|
-
|
|
3631
|
+
name2,
|
|
3127
3632
|
join(directives, " "),
|
|
3128
3633
|
wrap("= ", join(types, " | "))
|
|
3129
3634
|
],
|
|
@@ -3131,10 +3636,10 @@ var printDocASTReducer = {
|
|
|
3131
3636
|
)
|
|
3132
3637
|
},
|
|
3133
3638
|
EnumTypeExtension: {
|
|
3134
|
-
leave: ({ name, directives, values }) => join(["extend enum",
|
|
3639
|
+
leave: ({ name: name2, directives, values }) => join(["extend enum", name2, join(directives, " "), block(values)], " ")
|
|
3135
3640
|
},
|
|
3136
3641
|
InputObjectTypeExtension: {
|
|
3137
|
-
leave: ({ name, directives, fields }) => join(["extend input",
|
|
3642
|
+
leave: ({ name: name2, directives, fields }) => join(["extend input", name2, join(directives, " "), block(fields)], " ")
|
|
3138
3643
|
}
|
|
3139
3644
|
};
|
|
3140
3645
|
function join(maybeArray, separator = "") {
|
|
@@ -3342,7 +3847,7 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
3342
3847
|
};
|
|
3343
3848
|
}
|
|
3344
3849
|
|
|
3345
|
-
// ../../packages/sdk/dist/chunk-
|
|
3850
|
+
// ../../packages/sdk/dist/chunk-HFGEQP5N.mjs
|
|
3346
3851
|
import { Network as Network3 } from "@aptos-labs/ts-sdk";
|
|
3347
3852
|
|
|
3348
3853
|
// ../../node_modules/.pnpm/graphql-request@7.2.0_graphql@16.11.0/node_modules/graphql-request/build/legacy/classes/ClientError.js
|
|
@@ -3378,9 +3883,9 @@ var HeadersInitToPlainObject = (headers) => {
|
|
|
3378
3883
|
if (headers instanceof Headers) {
|
|
3379
3884
|
oHeaders = HeadersInstanceToPlainObject(headers);
|
|
3380
3885
|
} else if (Array.isArray(headers)) {
|
|
3381
|
-
headers.forEach(([
|
|
3382
|
-
if (
|
|
3383
|
-
oHeaders[
|
|
3886
|
+
headers.forEach(([name2, value]) => {
|
|
3887
|
+
if (name2 && value !== void 0) {
|
|
3888
|
+
oHeaders[name2] = value;
|
|
3384
3889
|
}
|
|
3385
3890
|
});
|
|
3386
3891
|
} else if (headers) {
|
|
@@ -3644,8 +4149,8 @@ var createFetcher = (method) => async (params) => {
|
|
|
3644
4149
|
initResolved = initNew;
|
|
3645
4150
|
}
|
|
3646
4151
|
if (searchParams) {
|
|
3647
|
-
searchParams.forEach((value,
|
|
3648
|
-
url.searchParams.append(
|
|
4152
|
+
searchParams.forEach((value, name2) => {
|
|
4153
|
+
url.searchParams.append(name2, value);
|
|
3649
4154
|
});
|
|
3650
4155
|
}
|
|
3651
4156
|
const $fetch = params.fetch ?? fetch;
|
|
@@ -3857,7 +4362,7 @@ var parseRequestArgs = (documentOrOptions, variables, requestHeaders) => {
|
|
|
3857
4362
|
};
|
|
3858
4363
|
};
|
|
3859
4364
|
|
|
3860
|
-
// ../../packages/sdk/dist/chunk-
|
|
4365
|
+
// ../../packages/sdk/dist/chunk-HFGEQP5N.mjs
|
|
3861
4366
|
function createShelbyIndexerClient(baseUrl, options) {
|
|
3862
4367
|
const graphqlClient = new GraphQLClient(baseUrl, options);
|
|
3863
4368
|
return getSdk(graphqlClient);
|
|
@@ -3969,10 +4474,10 @@ function isReadableStream(value) {
|
|
|
3969
4474
|
function toUint8Array(view) {
|
|
3970
4475
|
return view instanceof Uint8Array ? view : new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
|
|
3971
4476
|
}
|
|
3972
|
-
function buildRequestUrl(
|
|
4477
|
+
function buildRequestUrl(path10, baseUrl) {
|
|
3973
4478
|
const baseHasSlash = baseUrl.endsWith("/");
|
|
3974
4479
|
const safeBase = baseHasSlash ? baseUrl : `${baseUrl}/`;
|
|
3975
|
-
const safePath =
|
|
4480
|
+
const safePath = path10.replace(/^\/+/, "");
|
|
3976
4481
|
return new URL(safePath, safeBase);
|
|
3977
4482
|
}
|
|
3978
4483
|
function getBlobNameSuffix(blobName) {
|
|
@@ -4162,11 +4667,11 @@ function buildClayConfig(input) {
|
|
|
4162
4667
|
// ../../packages/sdk/dist/chunk-FIFKKWXV.mjs
|
|
4163
4668
|
import { AccountAddress as AccountAddress2 } from "@aptos-labs/ts-sdk";
|
|
4164
4669
|
import { z } from "zod";
|
|
4165
|
-
var BlobNameSchema = z.string().min(1, "Blob name path parameter cannot be empty.").max(1024, "Blob name cannot exceed 1024 characters.").refine((
|
|
4670
|
+
var BlobNameSchema = z.string().min(1, "Blob name path parameter cannot be empty.").max(1024, "Blob name cannot exceed 1024 characters.").refine((name2) => !name2.endsWith("/"), {
|
|
4166
4671
|
message: "Blob name cannot end with a slash"
|
|
4167
4672
|
});
|
|
4168
4673
|
|
|
4169
|
-
// ../../packages/sdk/dist/chunk-
|
|
4674
|
+
// ../../packages/sdk/dist/chunk-7P3P3D3X.mjs
|
|
4170
4675
|
import { AccountAddress as AccountAddress3 } from "@aptos-labs/ts-sdk";
|
|
4171
4676
|
function encodeURIComponentKeepSlashes(str) {
|
|
4172
4677
|
return encodeURIComponent(str).replace(/%2F/g, "/");
|
|
@@ -4558,7 +5063,7 @@ function validatePrePaddedChunkset(chunkset, expectedSize, chunksetIdx) {
|
|
|
4558
5063
|
return chunkset;
|
|
4559
5064
|
}
|
|
4560
5065
|
|
|
4561
|
-
// ../../packages/sdk/dist/chunk-
|
|
5066
|
+
// ../../packages/sdk/dist/chunk-HDYY6NS4.mjs
|
|
4562
5067
|
import {
|
|
4563
5068
|
AccountAddress as AccountAddress5,
|
|
4564
5069
|
Aptos as Aptos2,
|
|
@@ -4623,7 +5128,7 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
4623
5128
|
try {
|
|
4624
5129
|
const rawMetadata = await this.aptos.view({
|
|
4625
5130
|
payload: {
|
|
4626
|
-
function: `${this.deployer.toString()}::
|
|
5131
|
+
function: `${this.deployer.toString()}::blob_metadata::get_blob_metadata`,
|
|
4627
5132
|
functionArguments: [
|
|
4628
5133
|
createBlobKey({
|
|
4629
5134
|
account: params.account,
|
|
@@ -4757,10 +5262,10 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
4757
5262
|
orderBy
|
|
4758
5263
|
});
|
|
4759
5264
|
const activityTypeMapping = {
|
|
4760
|
-
[`${this.deployer.toStringLong()}::
|
|
4761
|
-
[`${this.deployer.toStringLong()}::
|
|
4762
|
-
[`${this.deployer.toStringLong()}::
|
|
4763
|
-
[`${this.deployer.toStringLong()}::
|
|
5265
|
+
[`${this.deployer.toStringLong()}::blob_metadata::BlobRegisteredEvent`]: "register_blob",
|
|
5266
|
+
[`${this.deployer.toStringLong()}::blob_metadata::BlobDeletedEvent`]: "delete_blob",
|
|
5267
|
+
[`${this.deployer.toStringLong()}::blob_metadata::BlobExpirationExtendedEvent`]: "extend_blob_expiration",
|
|
5268
|
+
[`${this.deployer.toStringLong()}::blob_metadata::BlobWrittenEvent`]: "write_blob"
|
|
4764
5269
|
};
|
|
4765
5270
|
return blob_activities.map(
|
|
4766
5271
|
(activity) => ({
|
|
@@ -4859,6 +5364,63 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
4859
5364
|
})
|
|
4860
5365
|
};
|
|
4861
5366
|
}
|
|
5367
|
+
/**
|
|
5368
|
+
* Registers multiple blobs on the blockchain by writing their merkle roots and metadata.
|
|
5369
|
+
*
|
|
5370
|
+
* @param params.account - The account that is signing and paying for the transaction.
|
|
5371
|
+
* @param params.expirationMicros - The expiration time of the blobs in microseconds.
|
|
5372
|
+
* @param params.blobs - The blobs to register.
|
|
5373
|
+
* @param params.blobs.blobName - The name/path of the blob (e.g. "foo/bar.txt").
|
|
5374
|
+
* @param params.blobs.blobSize - The size of the blob in bytes.
|
|
5375
|
+
* @param params.blobs.blobMerkleRoot - The merkle root of the blob commitments as a hex string.
|
|
5376
|
+
* @param params.options - Optional transaction building options.
|
|
5377
|
+
* @param params.options.chunksetSizeBytes - Custom chunkset size (defaults to DEFAULT_CHUNKSET_SIZE_BYTES).
|
|
5378
|
+
* @param params.options.build - Additional Aptos transaction building options.
|
|
5379
|
+
*
|
|
5380
|
+
* @returns An object containing the pending transaction.
|
|
5381
|
+
*
|
|
5382
|
+
* @example
|
|
5383
|
+
* ```typescript
|
|
5384
|
+
* const provider = await ClayErasureCodingProvider.create();
|
|
5385
|
+
* const blobCommitments = await generateCommitments(provider, data);
|
|
5386
|
+
*
|
|
5387
|
+
* const { transaction } = await client.batchRegisterBlobs({
|
|
5388
|
+
* account: signer,
|
|
5389
|
+
* expirationMicros: Date.now() * 1000 + 3600_000_000, // 1 hour from now in microseconds
|
|
5390
|
+
* blobs: [
|
|
5391
|
+
* {
|
|
5392
|
+
* blobName: "foo/bar.txt",
|
|
5393
|
+
* blobSize: data.length,
|
|
5394
|
+
* blobMerkleRoot: blobCommitments.blob_merkle_root,
|
|
5395
|
+
* },
|
|
5396
|
+
* ],
|
|
5397
|
+
* });
|
|
5398
|
+
* ```
|
|
5399
|
+
*/
|
|
5400
|
+
async batchRegisterBlobs(params) {
|
|
5401
|
+
const chunksetSize = params.options?.chunksetSizeBytes ?? DEFAULT_CHUNKSET_SIZE_BYTES;
|
|
5402
|
+
const transaction = await this.aptos.transaction.build.simple({
|
|
5403
|
+
...params.options?.build,
|
|
5404
|
+
sender: params.account.accountAddress,
|
|
5405
|
+
data: _ShelbyBlobClient.createBatchRegisterBlobsPayload({
|
|
5406
|
+
deployer: this.deployer,
|
|
5407
|
+
account: params.account.accountAddress,
|
|
5408
|
+
expirationMicros: params.expirationMicros,
|
|
5409
|
+
blobs: params.blobs.map((blob) => ({
|
|
5410
|
+
blobName: blob.blobName,
|
|
5411
|
+
blobSize: blob.blobSize,
|
|
5412
|
+
blobMerkleRoot: blob.blobMerkleRoot,
|
|
5413
|
+
numChunksets: expectedTotalChunksets(blob.blobSize, chunksetSize)
|
|
5414
|
+
}))
|
|
5415
|
+
})
|
|
5416
|
+
});
|
|
5417
|
+
return {
|
|
5418
|
+
transaction: await this.aptos.signAndSubmitTransaction({
|
|
5419
|
+
signer: params.account,
|
|
5420
|
+
transaction
|
|
5421
|
+
})
|
|
5422
|
+
};
|
|
5423
|
+
}
|
|
4862
5424
|
/**
|
|
4863
5425
|
* Creates a transaction payload to register a blob on the blockchain.
|
|
4864
5426
|
* This is a static helper method for constructing the Move function call payload.
|
|
@@ -4877,7 +5439,7 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
4877
5439
|
*/
|
|
4878
5440
|
static createRegisterBlobPayload(params) {
|
|
4879
5441
|
return {
|
|
4880
|
-
function: `${(params.deployer ?? SHELBY_DEPLOYER).toString()}::
|
|
5442
|
+
function: `${(params.deployer ?? SHELBY_DEPLOYER).toString()}::blob_metadata::register_blob`,
|
|
4881
5443
|
functionArguments: [
|
|
4882
5444
|
params.blobName,
|
|
4883
5445
|
params.expirationMicros,
|
|
@@ -4921,7 +5483,7 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
4921
5483
|
blobSizes.push(blob.blobSize);
|
|
4922
5484
|
});
|
|
4923
5485
|
return {
|
|
4924
|
-
function: `${(params.deployer ?? SHELBY_DEPLOYER).toString()}::
|
|
5486
|
+
function: `${(params.deployer ?? SHELBY_DEPLOYER).toString()}::blob_metadata::register_multiple_blobs`,
|
|
4925
5487
|
functionArguments: [
|
|
4926
5488
|
blobNames,
|
|
4927
5489
|
params.expirationMicros,
|
|
@@ -4947,16 +5509,155 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
4947
5509
|
*/
|
|
4948
5510
|
static createDeleteBlobPayload(params) {
|
|
4949
5511
|
return {
|
|
4950
|
-
function: `${(params.deployer ?? SHELBY_DEPLOYER).toString()}::
|
|
5512
|
+
function: `${(params.deployer ?? SHELBY_DEPLOYER).toString()}::blob_metadata::delete_blob`,
|
|
4951
5513
|
functionArguments: [params.blobNameSuffix]
|
|
4952
5514
|
};
|
|
4953
5515
|
}
|
|
4954
5516
|
};
|
|
4955
5517
|
|
|
4956
|
-
// ../../packages/sdk/dist/chunk-
|
|
5518
|
+
// ../../packages/sdk/dist/chunk-AUGZMI6U.mjs
|
|
4957
5519
|
import {
|
|
4958
5520
|
Aptos as Aptos3
|
|
4959
5521
|
} from "@aptos-labs/ts-sdk";
|
|
5522
|
+
|
|
5523
|
+
// ../../node_modules/.pnpm/yocto-queue@1.2.1/node_modules/yocto-queue/index.js
|
|
5524
|
+
var Node = class {
|
|
5525
|
+
value;
|
|
5526
|
+
next;
|
|
5527
|
+
constructor(value) {
|
|
5528
|
+
this.value = value;
|
|
5529
|
+
}
|
|
5530
|
+
};
|
|
5531
|
+
var Queue = class {
|
|
5532
|
+
#head;
|
|
5533
|
+
#tail;
|
|
5534
|
+
#size;
|
|
5535
|
+
constructor() {
|
|
5536
|
+
this.clear();
|
|
5537
|
+
}
|
|
5538
|
+
enqueue(value) {
|
|
5539
|
+
const node = new Node(value);
|
|
5540
|
+
if (this.#head) {
|
|
5541
|
+
this.#tail.next = node;
|
|
5542
|
+
this.#tail = node;
|
|
5543
|
+
} else {
|
|
5544
|
+
this.#head = node;
|
|
5545
|
+
this.#tail = node;
|
|
5546
|
+
}
|
|
5547
|
+
this.#size++;
|
|
5548
|
+
}
|
|
5549
|
+
dequeue() {
|
|
5550
|
+
const current = this.#head;
|
|
5551
|
+
if (!current) {
|
|
5552
|
+
return;
|
|
5553
|
+
}
|
|
5554
|
+
this.#head = this.#head.next;
|
|
5555
|
+
this.#size--;
|
|
5556
|
+
return current.value;
|
|
5557
|
+
}
|
|
5558
|
+
peek() {
|
|
5559
|
+
if (!this.#head) {
|
|
5560
|
+
return;
|
|
5561
|
+
}
|
|
5562
|
+
return this.#head.value;
|
|
5563
|
+
}
|
|
5564
|
+
clear() {
|
|
5565
|
+
this.#head = void 0;
|
|
5566
|
+
this.#tail = void 0;
|
|
5567
|
+
this.#size = 0;
|
|
5568
|
+
}
|
|
5569
|
+
get size() {
|
|
5570
|
+
return this.#size;
|
|
5571
|
+
}
|
|
5572
|
+
*[Symbol.iterator]() {
|
|
5573
|
+
let current = this.#head;
|
|
5574
|
+
while (current) {
|
|
5575
|
+
yield current.value;
|
|
5576
|
+
current = current.next;
|
|
5577
|
+
}
|
|
5578
|
+
}
|
|
5579
|
+
*drain() {
|
|
5580
|
+
while (this.#head) {
|
|
5581
|
+
yield this.dequeue();
|
|
5582
|
+
}
|
|
5583
|
+
}
|
|
5584
|
+
};
|
|
5585
|
+
|
|
5586
|
+
// ../../node_modules/.pnpm/p-limit@7.1.1/node_modules/p-limit/index.js
|
|
5587
|
+
function pLimit(concurrency) {
|
|
5588
|
+
validateConcurrency(concurrency);
|
|
5589
|
+
const queue = new Queue();
|
|
5590
|
+
let activeCount = 0;
|
|
5591
|
+
const resumeNext = () => {
|
|
5592
|
+
if (activeCount < concurrency && queue.size > 0) {
|
|
5593
|
+
activeCount++;
|
|
5594
|
+
queue.dequeue()();
|
|
5595
|
+
}
|
|
5596
|
+
};
|
|
5597
|
+
const next = () => {
|
|
5598
|
+
activeCount--;
|
|
5599
|
+
resumeNext();
|
|
5600
|
+
};
|
|
5601
|
+
const run = async (function_, resolve3, arguments_) => {
|
|
5602
|
+
const result = (async () => function_(...arguments_))();
|
|
5603
|
+
resolve3(result);
|
|
5604
|
+
try {
|
|
5605
|
+
await result;
|
|
5606
|
+
} catch {
|
|
5607
|
+
}
|
|
5608
|
+
next();
|
|
5609
|
+
};
|
|
5610
|
+
const enqueue = (function_, resolve3, arguments_) => {
|
|
5611
|
+
new Promise((internalResolve) => {
|
|
5612
|
+
queue.enqueue(internalResolve);
|
|
5613
|
+
}).then(run.bind(void 0, function_, resolve3, arguments_));
|
|
5614
|
+
if (activeCount < concurrency) {
|
|
5615
|
+
resumeNext();
|
|
5616
|
+
}
|
|
5617
|
+
};
|
|
5618
|
+
const generator = (function_, ...arguments_) => new Promise((resolve3) => {
|
|
5619
|
+
enqueue(function_, resolve3, arguments_);
|
|
5620
|
+
});
|
|
5621
|
+
Object.defineProperties(generator, {
|
|
5622
|
+
activeCount: {
|
|
5623
|
+
get: () => activeCount
|
|
5624
|
+
},
|
|
5625
|
+
pendingCount: {
|
|
5626
|
+
get: () => queue.size
|
|
5627
|
+
},
|
|
5628
|
+
clearQueue: {
|
|
5629
|
+
value() {
|
|
5630
|
+
queue.clear();
|
|
5631
|
+
}
|
|
5632
|
+
},
|
|
5633
|
+
concurrency: {
|
|
5634
|
+
get: () => concurrency,
|
|
5635
|
+
set(newConcurrency) {
|
|
5636
|
+
validateConcurrency(newConcurrency);
|
|
5637
|
+
concurrency = newConcurrency;
|
|
5638
|
+
queueMicrotask(() => {
|
|
5639
|
+
while (activeCount < concurrency && queue.size > 0) {
|
|
5640
|
+
resumeNext();
|
|
5641
|
+
}
|
|
5642
|
+
});
|
|
5643
|
+
}
|
|
5644
|
+
},
|
|
5645
|
+
map: {
|
|
5646
|
+
async value(array, function_) {
|
|
5647
|
+
const promises = array.map((value, index) => this(function_, value, index));
|
|
5648
|
+
return Promise.all(promises);
|
|
5649
|
+
}
|
|
5650
|
+
}
|
|
5651
|
+
});
|
|
5652
|
+
return generator;
|
|
5653
|
+
}
|
|
5654
|
+
function validateConcurrency(concurrency) {
|
|
5655
|
+
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
|
5656
|
+
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
|
5657
|
+
}
|
|
5658
|
+
}
|
|
5659
|
+
|
|
5660
|
+
// ../../packages/sdk/dist/chunk-AUGZMI6U.mjs
|
|
4960
5661
|
var ShelbyClient = class {
|
|
4961
5662
|
/**
|
|
4962
5663
|
* The coordination client is used to interact with the Aptos blockchain which handles the commitments
|
|
@@ -5086,6 +5787,89 @@ var ShelbyClient = class {
|
|
|
5086
5787
|
blobData: params.blobData
|
|
5087
5788
|
});
|
|
5088
5789
|
}
|
|
5790
|
+
/**
|
|
5791
|
+
* Uploads a batch of blobs to the Shelby network.
|
|
5792
|
+
* This method handles the complete upload flow including commitment generation,
|
|
5793
|
+
* blockchain registration, and storage upload.
|
|
5794
|
+
*
|
|
5795
|
+
* @param params.blobs - The blobs to upload.
|
|
5796
|
+
* @param params.blobs.blobData - The raw data to upload as a Uint8Array.
|
|
5797
|
+
* @param params.blobs.blobName - The name/path of the blob (e.g. "folder/file.txt").
|
|
5798
|
+
* @param params.expirationMicros - The expiration time in microseconds since Unix epoch.
|
|
5799
|
+
* @param params.signer - The account that signs and pays for the transaction.
|
|
5800
|
+
* @param params.options - Optional upload configuration.
|
|
5801
|
+
* @param params.options.chunksetSizeBytes - Custom chunkset size.
|
|
5802
|
+
* @param params.options.build - Additional Aptos transaction options.
|
|
5803
|
+
*
|
|
5804
|
+
* @returns The transaction and generated blob commitments (when implemented).
|
|
5805
|
+
*
|
|
5806
|
+
* @example
|
|
5807
|
+
* ```typescript
|
|
5808
|
+
* await client.batchUpload({
|
|
5809
|
+
* blobs: [
|
|
5810
|
+
* { blobData: Buffer.from("Hello, World!"), blobName: "hello.txt" },
|
|
5811
|
+
* { blobData: Buffer.from("Hello, World 2!"), blobName: "hello2.txt" },
|
|
5812
|
+
* ],
|
|
5813
|
+
* expirationMicros: Date.now() * 1000 + 86400_000_000 // 24 hours from now
|
|
5814
|
+
* });
|
|
5815
|
+
* ```
|
|
5816
|
+
*/
|
|
5817
|
+
async batchUpload(params) {
|
|
5818
|
+
const existingBlobs = await this.coordination.getBlobs({
|
|
5819
|
+
where: {
|
|
5820
|
+
blob_name: {
|
|
5821
|
+
_in: params.blobs.map(
|
|
5822
|
+
(blob) => createBlobKey({
|
|
5823
|
+
account: params.signer.accountAddress,
|
|
5824
|
+
blobName: blob.blobName
|
|
5825
|
+
})
|
|
5826
|
+
)
|
|
5827
|
+
}
|
|
5828
|
+
}
|
|
5829
|
+
});
|
|
5830
|
+
const blobsToRegister = params.blobs.filter(
|
|
5831
|
+
(blob) => !existingBlobs.some(
|
|
5832
|
+
(existingBlob) => existingBlob.name === createBlobKey({
|
|
5833
|
+
account: params.signer.accountAddress,
|
|
5834
|
+
blobName: blob.blobName
|
|
5835
|
+
})
|
|
5836
|
+
)
|
|
5837
|
+
);
|
|
5838
|
+
if (blobsToRegister.length > 0) {
|
|
5839
|
+
const provider = await this.getProvider();
|
|
5840
|
+
const blobCommitments = await Promise.all(
|
|
5841
|
+
blobsToRegister.map(
|
|
5842
|
+
async (blob) => generateCommitments(provider, blob.blobData)
|
|
5843
|
+
)
|
|
5844
|
+
);
|
|
5845
|
+
const { transaction: pendingRegisterBlobTransaction } = await this.coordination.batchRegisterBlobs({
|
|
5846
|
+
account: params.signer,
|
|
5847
|
+
expirationMicros: params.expirationMicros,
|
|
5848
|
+
blobs: blobsToRegister.map((blob, index) => ({
|
|
5849
|
+
blobName: blob.blobName,
|
|
5850
|
+
blobSize: blob.blobData.length,
|
|
5851
|
+
blobMerkleRoot: blobCommitments[index].blob_merkle_root
|
|
5852
|
+
})),
|
|
5853
|
+
options: params.options
|
|
5854
|
+
});
|
|
5855
|
+
await this.coordination.aptos.waitForTransaction({
|
|
5856
|
+
transactionHash: pendingRegisterBlobTransaction.hash,
|
|
5857
|
+
options: { waitForIndexer: true }
|
|
5858
|
+
});
|
|
5859
|
+
}
|
|
5860
|
+
const limit = pLimit(3);
|
|
5861
|
+
await Promise.all(
|
|
5862
|
+
params.blobs.map(
|
|
5863
|
+
(blob) => limit(
|
|
5864
|
+
() => this.rpc.putBlob({
|
|
5865
|
+
account: params.signer.accountAddress,
|
|
5866
|
+
blobName: blob.blobName,
|
|
5867
|
+
blobData: blob.blobData
|
|
5868
|
+
})
|
|
5869
|
+
)
|
|
5870
|
+
)
|
|
5871
|
+
);
|
|
5872
|
+
}
|
|
5089
5873
|
/**
|
|
5090
5874
|
* Downloads a blob from the Shelby RPC node.
|
|
5091
5875
|
*
|
|
@@ -5106,17 +5890,52 @@ var ShelbyClient = class {
|
|
|
5106
5890
|
async download(params) {
|
|
5107
5891
|
return await this.rpc.getBlob(params);
|
|
5108
5892
|
}
|
|
5893
|
+
/**
|
|
5894
|
+
*
|
|
5895
|
+
* Funds an account with ShelbyUSD tokens.
|
|
5896
|
+
*
|
|
5897
|
+
* @param params.address - The address to fund.
|
|
5898
|
+
* @param params.amount - The amount to fund.
|
|
5899
|
+
* @returns The transaction hash of the funded account.
|
|
5900
|
+
*
|
|
5901
|
+
* @example
|
|
5902
|
+
* ```typescript
|
|
5903
|
+
* const hash = await client.fundAccount({
|
|
5904
|
+
* address: "0x1",
|
|
5905
|
+
* amount: 100000000,
|
|
5906
|
+
* });
|
|
5907
|
+
* ```
|
|
5908
|
+
*/
|
|
5909
|
+
async fundAccount(params) {
|
|
5910
|
+
const { address, amount } = params;
|
|
5911
|
+
try {
|
|
5912
|
+
const faucet = this.config.faucet ?? "https://faucet.shelbynet.shelby.xyz/fund?asset=shelbyusd";
|
|
5913
|
+
const response = await fetch(`${faucet}`, {
|
|
5914
|
+
method: "POST",
|
|
5915
|
+
body: JSON.stringify({ address, amount }),
|
|
5916
|
+
headers: {
|
|
5917
|
+
"Content-Type": "application/json"
|
|
5918
|
+
}
|
|
5919
|
+
});
|
|
5920
|
+
if (!response.ok) {
|
|
5921
|
+
throw new Error("Failed to fund account");
|
|
5922
|
+
}
|
|
5923
|
+
return response.json();
|
|
5924
|
+
} catch (error) {
|
|
5925
|
+
throw new Error("Failed to fund account: " + error);
|
|
5926
|
+
}
|
|
5927
|
+
}
|
|
5109
5928
|
};
|
|
5110
5929
|
|
|
5111
|
-
// ../../packages/sdk/dist/chunk-
|
|
5930
|
+
// ../../packages/sdk/dist/chunk-GZJ5IOCG.mjs
|
|
5112
5931
|
var ShelbyNodeClient = class extends ShelbyClient {
|
|
5113
5932
|
};
|
|
5114
5933
|
|
|
5115
5934
|
// ../../packages/sdk/dist/chunk-7P6ASYW6.mjs
|
|
5116
|
-
var
|
|
5935
|
+
var __defProp2 = Object.defineProperty;
|
|
5117
5936
|
var __export = (target, all) => {
|
|
5118
|
-
for (var
|
|
5119
|
-
|
|
5937
|
+
for (var name2 in all)
|
|
5938
|
+
__defProp2(target, name2, { get: all[name2], enumerable: true });
|
|
5120
5939
|
};
|
|
5121
5940
|
|
|
5122
5941
|
// ../../packages/sdk/dist/chunk-A4IG6GSE.mjs
|
|
@@ -5215,10 +6034,10 @@ var reed_solomon_erasure_bg_default = __toBinaryNode("AGFzbQEAAAAB/oCAgAASYAJ/fw
|
|
|
5215
6034
|
var DEFAULT_CHUNK_SIZE_BYTES2 = 2 * 1024 * 1024;
|
|
5216
6035
|
|
|
5217
6036
|
// src/commands/account.tsx
|
|
5218
|
-
import
|
|
6037
|
+
import chalk2 from "chalk";
|
|
5219
6038
|
import { filesize } from "filesize";
|
|
5220
6039
|
import { render } from "ink";
|
|
5221
|
-
import { z as
|
|
6040
|
+
import { z as z11 } from "zod";
|
|
5222
6041
|
|
|
5223
6042
|
// src/components/AccountWizard.tsx
|
|
5224
6043
|
import { Box, Text } from "ink";
|
|
@@ -5226,8 +6045,8 @@ import TextInput from "ink-text-input";
|
|
|
5226
6045
|
import { useEffect, useState } from "react";
|
|
5227
6046
|
|
|
5228
6047
|
// src/utils/config.ts
|
|
5229
|
-
import
|
|
5230
|
-
import
|
|
6048
|
+
import os2 from "os";
|
|
6049
|
+
import path2 from "path";
|
|
5231
6050
|
import {
|
|
5232
6051
|
Aptos as Aptos4,
|
|
5233
6052
|
AptosConfig as AptosConfig3,
|
|
@@ -5235,9 +6054,9 @@ import {
|
|
|
5235
6054
|
Ed25519PrivateKey,
|
|
5236
6055
|
NetworkToNetworkName
|
|
5237
6056
|
} from "@aptos-labs/ts-sdk";
|
|
5238
|
-
import
|
|
5239
|
-
import
|
|
5240
|
-
import { z as
|
|
6057
|
+
import fs2 from "fs-extra";
|
|
6058
|
+
import YAML2 from "yaml";
|
|
6059
|
+
import { z as z7 } from "zod";
|
|
5241
6060
|
|
|
5242
6061
|
// src/schemas/AptosNetworkSchema.ts
|
|
5243
6062
|
import { z as z4 } from "zod";
|
|
@@ -5268,111 +6087,150 @@ var ShelbyNetworkSchema = z5.object({
|
|
|
5268
6087
|
deployer_address: z5.string().optional()
|
|
5269
6088
|
});
|
|
5270
6089
|
|
|
5271
|
-
// src/utils/
|
|
5272
|
-
import
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
import
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
function createContextForNetwork(network) {
|
|
5283
|
-
return {
|
|
5284
|
-
aptos_network: {
|
|
5285
|
-
name: network,
|
|
5286
|
-
fullnode: NetworkToNodeAPI[network],
|
|
5287
|
-
faucet: NetworkToFaucetAPI[network],
|
|
5288
|
-
indexer: NetworkToIndexerAPI[network],
|
|
5289
|
-
pepper: NetworkToPepperAPI[network],
|
|
5290
|
-
prover: NetworkToProverAPI[network]
|
|
5291
|
-
},
|
|
5292
|
-
shelby_network: {
|
|
5293
|
-
rpc_endpoint: NetworkToShelbyRPCBaseUrl[network]
|
|
5294
|
-
}
|
|
5295
|
-
};
|
|
5296
|
-
}
|
|
5297
|
-
|
|
5298
|
-
// src/utils/constants.ts
|
|
5299
|
-
var DEFAULT_CONFIG_PATH = "~/.shelby/config.yaml";
|
|
5300
|
-
var DEFAULT_CONFIG = {
|
|
5301
|
-
contexts: {
|
|
5302
|
-
[Network7.LOCAL]: {
|
|
5303
|
-
...createContextForNetwork(Network7.LOCAL),
|
|
5304
|
-
// Override shelby_network for local
|
|
5305
|
-
shelby_network: { rpc_endpoint: "http://localhost:9090/" }
|
|
5306
|
-
},
|
|
5307
|
-
[Network7.SHELBYNET]: createContextForNetwork(Network7.SHELBYNET)
|
|
5308
|
-
},
|
|
5309
|
-
accounts: {},
|
|
5310
|
-
default_context: Network7.SHELBYNET,
|
|
5311
|
-
default_account: ""
|
|
6090
|
+
// src/utils/global-config.ts
|
|
6091
|
+
import os from "os";
|
|
6092
|
+
import path from "path";
|
|
6093
|
+
import fs from "fs-extra";
|
|
6094
|
+
import YAML from "yaml";
|
|
6095
|
+
import { z as z6 } from "zod";
|
|
6096
|
+
var GlobalConfigSchema = z6.object({
|
|
6097
|
+
config_location_behavior: z6.enum(["global", "walk"])
|
|
6098
|
+
});
|
|
6099
|
+
var DEFAULT_GLOBAL_CONFIG = {
|
|
6100
|
+
config_location_behavior: "global"
|
|
5312
6101
|
};
|
|
5313
|
-
var
|
|
5314
|
-
|
|
6102
|
+
var GLOBAL_CONFIG_PATH = path.join(
|
|
6103
|
+
os.homedir(),
|
|
6104
|
+
".shelby",
|
|
6105
|
+
"global-config.yaml"
|
|
5315
6106
|
);
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
symbol: "APT",
|
|
5320
|
-
asset: APTOS_COIN,
|
|
5321
|
-
decimals: DEFAULT_DECIMALS
|
|
5322
|
-
},
|
|
5323
|
-
{
|
|
5324
|
-
symbol: SHELBYUSD_TOKEN_NAME,
|
|
5325
|
-
asset: SHELBYUSD_FA_METADATA_ADDRESS,
|
|
5326
|
-
fallbackDecimals: DEFAULT_DECIMALS
|
|
6107
|
+
function loadGlobalConfig() {
|
|
6108
|
+
if (!fs.existsSync(GLOBAL_CONFIG_PATH)) {
|
|
6109
|
+
return DEFAULT_GLOBAL_CONFIG;
|
|
5327
6110
|
}
|
|
5328
|
-
|
|
6111
|
+
const raw = fs.readFileSync(GLOBAL_CONFIG_PATH, "utf8");
|
|
6112
|
+
let parsed;
|
|
6113
|
+
try {
|
|
6114
|
+
parsed = YAML.parse(raw);
|
|
6115
|
+
} catch {
|
|
6116
|
+
throw new Error("Invalid global config file");
|
|
6117
|
+
}
|
|
6118
|
+
try {
|
|
6119
|
+
return GlobalConfigSchema.parse(parsed);
|
|
6120
|
+
} catch (err) {
|
|
6121
|
+
throw new Error(
|
|
6122
|
+
`Invalid global config file at ${GLOBAL_CONFIG_PATH}: ${err.message}`
|
|
6123
|
+
);
|
|
6124
|
+
}
|
|
6125
|
+
}
|
|
6126
|
+
function saveGlobalConfig(config) {
|
|
6127
|
+
fs.mkdirpSync(path.dirname(GLOBAL_CONFIG_PATH));
|
|
6128
|
+
GlobalConfigSchema.parse(config);
|
|
6129
|
+
fs.writeFileSync(GLOBAL_CONFIG_PATH, YAML.stringify(config), "utf8");
|
|
6130
|
+
}
|
|
5329
6131
|
|
|
5330
6132
|
// src/utils/config.ts
|
|
5331
|
-
var ContextSchema =
|
|
5332
|
-
api_key:
|
|
6133
|
+
var ContextSchema = z7.object({
|
|
6134
|
+
api_key: z7.string().optional(),
|
|
5333
6135
|
aptos_network: AptosNetworkSchema,
|
|
5334
6136
|
shelby_network: ShelbyNetworkSchema.optional()
|
|
5335
6137
|
});
|
|
5336
|
-
var AccountNameSchema =
|
|
6138
|
+
var AccountNameSchema = z7.string().min(1, "Account name cannot be empty").regex(
|
|
5337
6139
|
/^[a-zA-Z0-9_-]+$/,
|
|
5338
6140
|
"Account name must contain only alphanumeric characters, underscores, and hyphens"
|
|
5339
6141
|
);
|
|
5340
|
-
var ConfigSchema =
|
|
5341
|
-
contexts:
|
|
5342
|
-
accounts:
|
|
6142
|
+
var ConfigSchema = z7.object({
|
|
6143
|
+
contexts: z7.record(ContextSchema),
|
|
6144
|
+
accounts: z7.record(
|
|
5343
6145
|
AccountNameSchema,
|
|
5344
|
-
|
|
5345
|
-
address:
|
|
5346
|
-
private_key:
|
|
6146
|
+
z7.object({
|
|
6147
|
+
address: z7.string().optional(),
|
|
6148
|
+
private_key: z7.string({ message: "private_key must be provided" })
|
|
5347
6149
|
})
|
|
5348
6150
|
),
|
|
5349
|
-
default_context:
|
|
6151
|
+
default_context: z7.string(),
|
|
5350
6152
|
// Can be empty string if no account is set up
|
|
5351
|
-
default_account:
|
|
6153
|
+
default_account: z7.string()
|
|
5352
6154
|
});
|
|
6155
|
+
function getPathForNewConfig() {
|
|
6156
|
+
const globalConfig = loadGlobalConfig();
|
|
6157
|
+
if (globalConfig.config_location_behavior === "global") {
|
|
6158
|
+
return path2.join(os2.homedir(), ".shelby", "config.yaml");
|
|
6159
|
+
}
|
|
6160
|
+
return path2.join(process.cwd(), ".shelby", "config.yaml");
|
|
6161
|
+
}
|
|
6162
|
+
function loadConfigOrExit(configFile) {
|
|
6163
|
+
let configPath;
|
|
6164
|
+
try {
|
|
6165
|
+
configPath = resolveConfigPath(configFile ?? findExistingConfigPath());
|
|
6166
|
+
if (!fs2.existsSync(configPath)) {
|
|
6167
|
+
console.error("\u274C No configuration file found");
|
|
6168
|
+
console.error(
|
|
6169
|
+
" Please run `shelby init` to create a configuration file."
|
|
6170
|
+
);
|
|
6171
|
+
process.exit(1);
|
|
6172
|
+
}
|
|
6173
|
+
return { configPath, config: loadConfig(configPath) };
|
|
6174
|
+
} catch (err) {
|
|
6175
|
+
console.error("\u274C Failed to load configuration file");
|
|
6176
|
+
if (configPath !== void 0) {
|
|
6177
|
+
console.error(` Path: ${configPath}`);
|
|
6178
|
+
}
|
|
6179
|
+
console.error("");
|
|
6180
|
+
console.error(
|
|
6181
|
+
` Error: ${err instanceof Error ? err.message : String(err)}`
|
|
6182
|
+
);
|
|
6183
|
+
console.error("");
|
|
6184
|
+
console.error(
|
|
6185
|
+
" Please fix the configuration file or run `shelby init` to recreate it."
|
|
6186
|
+
);
|
|
6187
|
+
process.exit(1);
|
|
6188
|
+
}
|
|
6189
|
+
}
|
|
6190
|
+
function findExistingConfigPath() {
|
|
6191
|
+
const globalConfig = loadGlobalConfig();
|
|
6192
|
+
const homeConfig = path2.join(os2.homedir(), ".shelby", "config.yaml");
|
|
6193
|
+
if (globalConfig.config_location_behavior === "global") {
|
|
6194
|
+
return homeConfig;
|
|
6195
|
+
}
|
|
6196
|
+
const foundPath = walkConfigPath(process.cwd());
|
|
6197
|
+
if (foundPath) {
|
|
6198
|
+
const homeDir = os2.homedir();
|
|
6199
|
+
const displayPath = foundPath.startsWith(homeDir) ? foundPath.replace(homeDir, "~") : path2.relative(process.cwd(), foundPath);
|
|
6200
|
+
console.log(`\u{1F4C1} Using config found by walking up to ${displayPath}`);
|
|
6201
|
+
return foundPath;
|
|
6202
|
+
}
|
|
6203
|
+
console.log(
|
|
6204
|
+
`\u{1F4C1} Could not find config by walking up. Using config file at ${homeConfig.replace(os2.homedir(), "~")}`
|
|
6205
|
+
);
|
|
6206
|
+
return homeConfig;
|
|
6207
|
+
}
|
|
6208
|
+
function walkConfigPath(startDir) {
|
|
6209
|
+
let currentDir = path2.resolve(startDir);
|
|
6210
|
+
while (true) {
|
|
6211
|
+
const candidate = path2.join(currentDir, ".shelby", "config.yaml");
|
|
6212
|
+
if (fs2.existsSync(candidate)) {
|
|
6213
|
+
return candidate;
|
|
6214
|
+
}
|
|
6215
|
+
const parent = path2.dirname(currentDir);
|
|
6216
|
+
if (parent === currentDir) {
|
|
6217
|
+
return null;
|
|
6218
|
+
}
|
|
6219
|
+
currentDir = parent;
|
|
6220
|
+
}
|
|
6221
|
+
}
|
|
5353
6222
|
function resolveConfigPath(configPath) {
|
|
5354
6223
|
if (configPath.startsWith("~")) {
|
|
5355
|
-
return
|
|
6224
|
+
return path2.join(os2.homedir(), configPath.slice(1));
|
|
5356
6225
|
}
|
|
5357
6226
|
return configPath;
|
|
5358
6227
|
}
|
|
5359
|
-
function
|
|
5360
|
-
const resolvedPath = resolveConfigPath(configPath);
|
|
5361
|
-
return fs.existsSync(resolvedPath);
|
|
5362
|
-
}
|
|
5363
|
-
function loadConfig(configPath = DEFAULT_CONFIG_PATH) {
|
|
6228
|
+
function loadConfig(configPath) {
|
|
5364
6229
|
const resolvedPath = resolveConfigPath(configPath);
|
|
5365
|
-
const
|
|
5366
|
-
if (!fs.existsSync(resolvedPath)) {
|
|
5367
|
-
fs.mkdirpSync(dir);
|
|
5368
|
-
const yamlText = YAML.stringify(DEFAULT_CONFIG);
|
|
5369
|
-
fs.writeFileSync(resolvedPath, yamlText, "utf8");
|
|
5370
|
-
return DEFAULT_CONFIG;
|
|
5371
|
-
}
|
|
5372
|
-
const raw = fs.readFileSync(resolvedPath, "utf8");
|
|
6230
|
+
const raw = fs2.readFileSync(resolvedPath, "utf8");
|
|
5373
6231
|
let parsed;
|
|
5374
6232
|
try {
|
|
5375
|
-
parsed =
|
|
6233
|
+
parsed = YAML2.parse(raw);
|
|
5376
6234
|
} catch {
|
|
5377
6235
|
throw new Error("Invalid config file");
|
|
5378
6236
|
}
|
|
@@ -5382,17 +6240,17 @@ function loadConfig(configPath = DEFAULT_CONFIG_PATH) {
|
|
|
5382
6240
|
throw new Error(`Invalid config file: ${err.message}`);
|
|
5383
6241
|
}
|
|
5384
6242
|
}
|
|
5385
|
-
function saveConfig(config, configPath
|
|
6243
|
+
function saveConfig(config, configPath) {
|
|
5386
6244
|
const resolvedPath = resolveConfigPath(configPath);
|
|
5387
|
-
|
|
6245
|
+
fs2.mkdirpSync(path2.dirname(resolvedPath));
|
|
5388
6246
|
ConfigSchema.parse(config);
|
|
5389
|
-
|
|
6247
|
+
fs2.writeFileSync(resolvedPath, YAML2.stringify(config), "utf8");
|
|
5390
6248
|
}
|
|
5391
6249
|
function getCurrentContext(config, contextName) {
|
|
5392
|
-
const
|
|
5393
|
-
const context = config.contexts[
|
|
6250
|
+
const name2 = contextName || config.default_context;
|
|
6251
|
+
const context = config.contexts[name2];
|
|
5394
6252
|
if (!context) {
|
|
5395
|
-
throw new Error(`Context '${
|
|
6253
|
+
throw new Error(`Context '${name2}' not found in config`);
|
|
5396
6254
|
}
|
|
5397
6255
|
return {
|
|
5398
6256
|
api_key: context.api_key,
|
|
@@ -5401,19 +6259,23 @@ function getCurrentContext(config, contextName) {
|
|
|
5401
6259
|
};
|
|
5402
6260
|
}
|
|
5403
6261
|
function getCurrentAccount(config, accountName) {
|
|
5404
|
-
const
|
|
5405
|
-
if (!
|
|
5406
|
-
throw new Error(
|
|
6262
|
+
const name2 = accountName || config.default_account;
|
|
6263
|
+
if (!name2) {
|
|
6264
|
+
throw new Error(
|
|
6265
|
+
`Account with name '${name2}' not found in config. Set --account to a valid account name.`
|
|
6266
|
+
);
|
|
5407
6267
|
}
|
|
5408
|
-
const account = config.accounts[
|
|
6268
|
+
const account = config.accounts[name2];
|
|
5409
6269
|
if (!account) {
|
|
5410
|
-
throw new Error(
|
|
5411
|
-
|
|
6270
|
+
throw new Error(
|
|
6271
|
+
`Account '${name2}' not found in config. Set --account to a valid account name.`
|
|
6272
|
+
);
|
|
6273
|
+
}
|
|
5412
6274
|
let privateKey;
|
|
5413
6275
|
if (account.private_key) {
|
|
5414
6276
|
privateKey = account.private_key;
|
|
5415
6277
|
} else {
|
|
5416
|
-
throw new Error(`No private key found for account '${
|
|
6278
|
+
throw new Error(`No private key found for account '${name2}'`);
|
|
5417
6279
|
}
|
|
5418
6280
|
return {
|
|
5419
6281
|
address: account.address,
|
|
@@ -5424,11 +6286,11 @@ function getCurrentAccount(config, accountName) {
|
|
|
5424
6286
|
};
|
|
5425
6287
|
}
|
|
5426
6288
|
function getAptosSettingsFromContext(context) {
|
|
5427
|
-
const { name, api_key, ...options } = context.aptos_network;
|
|
6289
|
+
const { name: name2, api_key, ...options } = context.aptos_network;
|
|
5428
6290
|
const activeApiKey = api_key || context.api_key;
|
|
5429
6291
|
return {
|
|
5430
6292
|
...options,
|
|
5431
|
-
network: NetworkToNetworkName[
|
|
6293
|
+
network: NetworkToNetworkName[name2],
|
|
5432
6294
|
clientConfig: { API_KEY: activeApiKey }
|
|
5433
6295
|
};
|
|
5434
6296
|
}
|
|
@@ -5457,7 +6319,7 @@ function getCurrentShelbyConfig(config, opts = { context: config.default_context
|
|
|
5457
6319
|
const selectedContext = config.contexts[context ?? config.default_context];
|
|
5458
6320
|
if (!selectedContext) {
|
|
5459
6321
|
throw new Error(
|
|
5460
|
-
`Context '${context ?? config.default_context}' not found in config
|
|
6322
|
+
`Context '${context ?? config.default_context}' not found in config. Set --context to a valid context name.`
|
|
5461
6323
|
);
|
|
5462
6324
|
}
|
|
5463
6325
|
const shelby = getShelbyConfigFromContext(selectedContext);
|
|
@@ -5465,13 +6327,13 @@ function getCurrentShelbyConfig(config, opts = { context: config.default_context
|
|
|
5465
6327
|
}
|
|
5466
6328
|
|
|
5467
6329
|
// src/utils/account.ts
|
|
5468
|
-
function validateAccountName(
|
|
5469
|
-
const parsed = AccountNameSchema.safeParse(
|
|
5470
|
-
if (!parsed.success ||
|
|
6330
|
+
function validateAccountName(name2, config) {
|
|
6331
|
+
const parsed = AccountNameSchema.safeParse(name2);
|
|
6332
|
+
if (!parsed.success || name2.length === 0) {
|
|
5471
6333
|
return parsed.error?.errors[0]?.message || "Account name must be a non-empty string containing only letters, numbers, underscores, or hyphens.";
|
|
5472
6334
|
}
|
|
5473
|
-
if (config?.accounts[
|
|
5474
|
-
return `Account '${
|
|
6335
|
+
if (config?.accounts[name2]) {
|
|
6336
|
+
return `Account '${name2}' already exists. Choose a different name.`;
|
|
5475
6337
|
}
|
|
5476
6338
|
return void 0;
|
|
5477
6339
|
}
|
|
@@ -5484,7 +6346,7 @@ import {
|
|
|
5484
6346
|
Secp256k1PrivateKey,
|
|
5485
6347
|
SigningSchemeInput
|
|
5486
6348
|
} from "@aptos-labs/ts-sdk";
|
|
5487
|
-
import { z as
|
|
6349
|
+
import { z as z8 } from "zod";
|
|
5488
6350
|
function generateEd25519Account() {
|
|
5489
6351
|
const account = Account.generate({
|
|
5490
6352
|
scheme: SigningSchemeInput.Ed25519,
|
|
@@ -5504,7 +6366,7 @@ function isValidAddress(address) {
|
|
|
5504
6366
|
return AccountAddress6.isValid({ input: address }).valid;
|
|
5505
6367
|
}
|
|
5506
6368
|
var ED25519_NAME = "ed25519";
|
|
5507
|
-
var SignatureSchemeSchema =
|
|
6369
|
+
var SignatureSchemeSchema = z8.enum([ED25519_NAME]);
|
|
5508
6370
|
|
|
5509
6371
|
// src/components/AccountWizard.tsx
|
|
5510
6372
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -5516,33 +6378,33 @@ var AccountWizard = ({
|
|
|
5516
6378
|
const [step, setStep] = useState(
|
|
5517
6379
|
initialName ? "address" : "name"
|
|
5518
6380
|
);
|
|
5519
|
-
const [
|
|
6381
|
+
const [name2, setName] = useState(initialName || "");
|
|
5520
6382
|
const [nameError, setNameError] = useState(null);
|
|
5521
6383
|
const [address, setAddress] = useState("");
|
|
5522
6384
|
const [privateKey, setPrivateKey] = useState("");
|
|
5523
6385
|
useEffect(() => {
|
|
5524
6386
|
if (step === "done") {
|
|
5525
6387
|
onComplete({
|
|
5526
|
-
name,
|
|
6388
|
+
name: name2,
|
|
5527
6389
|
address: address || void 0,
|
|
5528
6390
|
privateKey
|
|
5529
6391
|
});
|
|
5530
6392
|
}
|
|
5531
|
-
}, [onComplete, step,
|
|
6393
|
+
}, [onComplete, step, name2, address, privateKey]);
|
|
5532
6394
|
if (step === "name") {
|
|
5533
6395
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
5534
6396
|
/* @__PURE__ */ jsx(Text, { children: "Account name?" }),
|
|
5535
6397
|
/* @__PURE__ */ jsx(
|
|
5536
6398
|
TextInput,
|
|
5537
6399
|
{
|
|
5538
|
-
value:
|
|
6400
|
+
value: name2,
|
|
5539
6401
|
onChange: (value) => {
|
|
5540
6402
|
setName(value);
|
|
5541
6403
|
const error = validateAccountName(value, config);
|
|
5542
6404
|
setNameError(error || null);
|
|
5543
6405
|
},
|
|
5544
6406
|
onSubmit: () => {
|
|
5545
|
-
const error = validateAccountName(
|
|
6407
|
+
const error = validateAccountName(name2, config);
|
|
5546
6408
|
if (error) {
|
|
5547
6409
|
setNameError(error);
|
|
5548
6410
|
return;
|
|
@@ -5626,7 +6488,7 @@ function AptosNetworkNameSelector({
|
|
|
5626
6488
|
onSelect
|
|
5627
6489
|
}) {
|
|
5628
6490
|
const items = [
|
|
5629
|
-
...shelbyNetworks.map((
|
|
6491
|
+
...shelbyNetworks.map((name2) => ({ label: name2, value: name2 })),
|
|
5630
6492
|
...additionalItems
|
|
5631
6493
|
];
|
|
5632
6494
|
return /* @__PURE__ */ jsx3(
|
|
@@ -5646,11 +6508,11 @@ import { useEffect as useEffect3, useState as useState4 } from "react";
|
|
|
5646
6508
|
|
|
5647
6509
|
// src/components/ContextReviewWizard.tsx
|
|
5648
6510
|
import {
|
|
5649
|
-
NetworkToFaucetAPI
|
|
5650
|
-
NetworkToIndexerAPI
|
|
5651
|
-
NetworkToNodeAPI
|
|
5652
|
-
NetworkToPepperAPI
|
|
5653
|
-
NetworkToProverAPI
|
|
6511
|
+
NetworkToFaucetAPI,
|
|
6512
|
+
NetworkToIndexerAPI,
|
|
6513
|
+
NetworkToNodeAPI,
|
|
6514
|
+
NetworkToPepperAPI,
|
|
6515
|
+
NetworkToProverAPI
|
|
5654
6516
|
} from "@aptos-labs/ts-sdk";
|
|
5655
6517
|
import { Box as Box4, Text as Text4 } from "ink";
|
|
5656
6518
|
import SelectInput2 from "ink-select-input";
|
|
@@ -5662,9 +6524,9 @@ var APTOS_CONFIG_FIELDS = [
|
|
|
5662
6524
|
type: "select",
|
|
5663
6525
|
key: "name",
|
|
5664
6526
|
label: "Network Name",
|
|
5665
|
-
items: shelbyNetworks.map((
|
|
5666
|
-
label:
|
|
5667
|
-
value:
|
|
6527
|
+
items: shelbyNetworks.map((name2) => ({
|
|
6528
|
+
label: name2,
|
|
6529
|
+
value: name2
|
|
5668
6530
|
}))
|
|
5669
6531
|
},
|
|
5670
6532
|
{
|
|
@@ -5732,7 +6594,7 @@ var SHELBY_CONFIG_FIELDS = [
|
|
|
5732
6594
|
import { Box as Box3, Text as Text3 } from "ink";
|
|
5733
6595
|
import TextInput2 from "ink-text-input";
|
|
5734
6596
|
import { useState as useState2 } from "react";
|
|
5735
|
-
import
|
|
6597
|
+
import z9 from "zod";
|
|
5736
6598
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
5737
6599
|
function FormTextInput({
|
|
5738
6600
|
type,
|
|
@@ -5762,7 +6624,7 @@ function FormTextInput({
|
|
|
5762
6624
|
return;
|
|
5763
6625
|
}
|
|
5764
6626
|
if (value2) {
|
|
5765
|
-
if (type === "url" && !
|
|
6627
|
+
if (type === "url" && !z9.string().url().safeParse(value2).success) {
|
|
5766
6628
|
setError("The field must be a valid URL");
|
|
5767
6629
|
return;
|
|
5768
6630
|
}
|
|
@@ -5823,11 +6685,11 @@ var ContextReviewWizard = ({
|
|
|
5823
6685
|
return void 0;
|
|
5824
6686
|
}
|
|
5825
6687
|
const fallbackValue = {
|
|
5826
|
-
fullnode:
|
|
5827
|
-
indexer:
|
|
5828
|
-
faucet:
|
|
5829
|
-
pepper:
|
|
5830
|
-
prover:
|
|
6688
|
+
fullnode: NetworkToNodeAPI[aptosNetwork.name],
|
|
6689
|
+
indexer: NetworkToIndexerAPI[aptosNetwork.name],
|
|
6690
|
+
faucet: NetworkToFaucetAPI[aptosNetwork.name],
|
|
6691
|
+
pepper: NetworkToPepperAPI[aptosNetwork.name],
|
|
6692
|
+
prover: NetworkToProverAPI[aptosNetwork.name]
|
|
5831
6693
|
}[key];
|
|
5832
6694
|
return fallbackValue ? { value: fallbackValue, source: "default" } : void 0;
|
|
5833
6695
|
};
|
|
@@ -6063,7 +6925,7 @@ var CreateContextWizard = ({
|
|
|
6063
6925
|
onComplete
|
|
6064
6926
|
}) => {
|
|
6065
6927
|
const [step, setStep] = useState4("name");
|
|
6066
|
-
const [
|
|
6928
|
+
const [name2, setName] = useState4("");
|
|
6067
6929
|
const [apiKey, setApiKey] = useState4("");
|
|
6068
6930
|
const [shelbyNetwork, setShelbyNetwork] = useState4(
|
|
6069
6931
|
{}
|
|
@@ -6074,12 +6936,12 @@ var CreateContextWizard = ({
|
|
|
6074
6936
|
const validatedAptosNetwork = AptosNetworkSchema.parse(aptosNetwork);
|
|
6075
6937
|
const validatedShelbyNetwork = ShelbyNetworkSchema.parse(shelbyNetwork);
|
|
6076
6938
|
onComplete({
|
|
6077
|
-
name,
|
|
6939
|
+
name: name2,
|
|
6078
6940
|
apiKey: apiKey || void 0,
|
|
6079
6941
|
shelbyNetwork: validatedShelbyNetwork,
|
|
6080
6942
|
aptosNetwork: validatedAptosNetwork
|
|
6081
6943
|
});
|
|
6082
|
-
}, [step,
|
|
6944
|
+
}, [step, name2, apiKey, shelbyNetwork, aptosNetwork, onComplete]);
|
|
6083
6945
|
if (step === "name") {
|
|
6084
6946
|
return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", children: [
|
|
6085
6947
|
/* @__PURE__ */ jsx6(Text5, { children: "Context name?" }),
|
|
@@ -6088,7 +6950,7 @@ var CreateContextWizard = ({
|
|
|
6088
6950
|
{
|
|
6089
6951
|
placeholder: "Enter context name",
|
|
6090
6952
|
required: true,
|
|
6091
|
-
value:
|
|
6953
|
+
value: name2,
|
|
6092
6954
|
onChange: setName,
|
|
6093
6955
|
onSubmit: () => setStep("api-key")
|
|
6094
6956
|
}
|
|
@@ -6162,6 +7024,66 @@ import {
|
|
|
6162
7024
|
AccountAddress as AccountAddress7,
|
|
6163
7025
|
AptosApiError
|
|
6164
7026
|
} from "@aptos-labs/ts-sdk";
|
|
7027
|
+
|
|
7028
|
+
// src/utils/constants.ts
|
|
7029
|
+
import { APTOS_COIN, Network as Network7 } from "@aptos-labs/ts-sdk";
|
|
7030
|
+
|
|
7031
|
+
// src/utils/context-helpers.ts
|
|
7032
|
+
import {
|
|
7033
|
+
NetworkToFaucetAPI as NetworkToFaucetAPI2,
|
|
7034
|
+
NetworkToIndexerAPI as NetworkToIndexerAPI2,
|
|
7035
|
+
NetworkToNodeAPI as NetworkToNodeAPI2,
|
|
7036
|
+
NetworkToPepperAPI as NetworkToPepperAPI2,
|
|
7037
|
+
NetworkToProverAPI as NetworkToProverAPI2
|
|
7038
|
+
} from "@aptos-labs/ts-sdk";
|
|
7039
|
+
function createContextForNetwork(network) {
|
|
7040
|
+
return {
|
|
7041
|
+
aptos_network: {
|
|
7042
|
+
name: network,
|
|
7043
|
+
fullnode: NetworkToNodeAPI2[network],
|
|
7044
|
+
faucet: NetworkToFaucetAPI2[network],
|
|
7045
|
+
indexer: NetworkToIndexerAPI2[network],
|
|
7046
|
+
pepper: NetworkToPepperAPI2[network],
|
|
7047
|
+
prover: NetworkToProverAPI2[network]
|
|
7048
|
+
},
|
|
7049
|
+
shelby_network: {
|
|
7050
|
+
rpc_endpoint: NetworkToShelbyRPCBaseUrl[network]
|
|
7051
|
+
}
|
|
7052
|
+
};
|
|
7053
|
+
}
|
|
7054
|
+
|
|
7055
|
+
// src/utils/constants.ts
|
|
7056
|
+
var DEFAULT_CONFIG = {
|
|
7057
|
+
contexts: {
|
|
7058
|
+
[Network7.LOCAL]: {
|
|
7059
|
+
...createContextForNetwork(Network7.LOCAL),
|
|
7060
|
+
// Override shelby_network for local
|
|
7061
|
+
shelby_network: { rpc_endpoint: "http://localhost:9090/" }
|
|
7062
|
+
},
|
|
7063
|
+
[Network7.SHELBYNET]: createContextForNetwork(Network7.SHELBYNET)
|
|
7064
|
+
},
|
|
7065
|
+
accounts: {},
|
|
7066
|
+
default_context: Network7.SHELBYNET,
|
|
7067
|
+
default_account: ""
|
|
7068
|
+
};
|
|
7069
|
+
var STANDARD_CONTEXT_NAMES = Object.keys(DEFAULT_CONFIG.contexts).join(
|
|
7070
|
+
", "
|
|
7071
|
+
);
|
|
7072
|
+
var DEFAULT_DECIMALS = 8;
|
|
7073
|
+
var BALANCE_TARGETS = [
|
|
7074
|
+
{
|
|
7075
|
+
symbol: "APT",
|
|
7076
|
+
asset: APTOS_COIN,
|
|
7077
|
+
decimals: DEFAULT_DECIMALS
|
|
7078
|
+
},
|
|
7079
|
+
{
|
|
7080
|
+
symbol: SHELBYUSD_TOKEN_NAME,
|
|
7081
|
+
asset: SHELBYUSD_FA_METADATA_ADDRESS,
|
|
7082
|
+
fallbackDecimals: DEFAULT_DECIMALS
|
|
7083
|
+
}
|
|
7084
|
+
];
|
|
7085
|
+
|
|
7086
|
+
// src/utils/balance.ts
|
|
6165
7087
|
var InvalidAccountAddressError = class extends Error {
|
|
6166
7088
|
constructor(address) {
|
|
6167
7089
|
super(
|
|
@@ -6318,6 +7240,158 @@ function assetTypeToString(asset) {
|
|
|
6318
7240
|
return AccountAddress7.from(asset).toString();
|
|
6319
7241
|
}
|
|
6320
7242
|
|
|
7243
|
+
// src/utils/cache.ts
|
|
7244
|
+
import path3 from "path";
|
|
7245
|
+
import fs3 from "fs-extra";
|
|
7246
|
+
var Cache = class {
|
|
7247
|
+
cachePath;
|
|
7248
|
+
schema;
|
|
7249
|
+
constructor(cacheFileName, schema) {
|
|
7250
|
+
this.cachePath = resolveConfigPath(`~/.shelby/${cacheFileName}`);
|
|
7251
|
+
this.schema = schema;
|
|
7252
|
+
}
|
|
7253
|
+
/**
|
|
7254
|
+
* Read data from cache
|
|
7255
|
+
* Returns null if cache doesn't exist or fails validation
|
|
7256
|
+
*/
|
|
7257
|
+
read() {
|
|
7258
|
+
try {
|
|
7259
|
+
if (!fs3.existsSync(this.cachePath)) {
|
|
7260
|
+
return null;
|
|
7261
|
+
}
|
|
7262
|
+
const data = fs3.readFileSync(this.cachePath, "utf-8");
|
|
7263
|
+
const parsed = JSON.parse(data);
|
|
7264
|
+
const result = this.schema.safeParse(parsed);
|
|
7265
|
+
if (!result.success) {
|
|
7266
|
+
return null;
|
|
7267
|
+
}
|
|
7268
|
+
return result.data;
|
|
7269
|
+
} catch {
|
|
7270
|
+
return null;
|
|
7271
|
+
}
|
|
7272
|
+
}
|
|
7273
|
+
/**
|
|
7274
|
+
* Write data to cache
|
|
7275
|
+
* Data is validated before writing
|
|
7276
|
+
*/
|
|
7277
|
+
write(data) {
|
|
7278
|
+
try {
|
|
7279
|
+
const validated = this.schema.parse(data);
|
|
7280
|
+
const cacheDir = path3.dirname(this.cachePath);
|
|
7281
|
+
fs3.mkdirpSync(cacheDir);
|
|
7282
|
+
fs3.writeFileSync(
|
|
7283
|
+
this.cachePath,
|
|
7284
|
+
JSON.stringify(validated, null, 2),
|
|
7285
|
+
"utf-8"
|
|
7286
|
+
);
|
|
7287
|
+
return true;
|
|
7288
|
+
} catch {
|
|
7289
|
+
return false;
|
|
7290
|
+
}
|
|
7291
|
+
}
|
|
7292
|
+
/**
|
|
7293
|
+
* Delete the cache file
|
|
7294
|
+
*/
|
|
7295
|
+
clear() {
|
|
7296
|
+
try {
|
|
7297
|
+
if (fs3.existsSync(this.cachePath)) {
|
|
7298
|
+
fs3.unlinkSync(this.cachePath);
|
|
7299
|
+
}
|
|
7300
|
+
return true;
|
|
7301
|
+
} catch {
|
|
7302
|
+
return false;
|
|
7303
|
+
}
|
|
7304
|
+
}
|
|
7305
|
+
/**
|
|
7306
|
+
* Check if cache exists
|
|
7307
|
+
*/
|
|
7308
|
+
exists() {
|
|
7309
|
+
return fs3.existsSync(this.cachePath);
|
|
7310
|
+
}
|
|
7311
|
+
/**
|
|
7312
|
+
* Get the resolved cache file path
|
|
7313
|
+
*/
|
|
7314
|
+
getPath() {
|
|
7315
|
+
return this.cachePath;
|
|
7316
|
+
}
|
|
7317
|
+
};
|
|
7318
|
+
|
|
7319
|
+
// src/utils/check-version.ts
|
|
7320
|
+
import boxen from "boxen";
|
|
7321
|
+
import chalk from "chalk";
|
|
7322
|
+
import { getLatestVersion } from "fast-npm-meta";
|
|
7323
|
+
import * as semver from "semver";
|
|
7324
|
+
import { z as z10 } from "zod";
|
|
7325
|
+
var CHECK_INTERVAL = 1e3 * 60 * 60 * 24;
|
|
7326
|
+
var NOTIFY_INTERVAL = CHECK_INTERVAL;
|
|
7327
|
+
var VersionCacheSchema = z10.object({
|
|
7328
|
+
lastChecked: z10.number(),
|
|
7329
|
+
latestVersion: z10.string(),
|
|
7330
|
+
lastNotified: z10.number().optional()
|
|
7331
|
+
});
|
|
7332
|
+
var versionCache = new Cache("version-check.json", VersionCacheSchema);
|
|
7333
|
+
async function fetchLatestVersion() {
|
|
7334
|
+
try {
|
|
7335
|
+
const result = await getLatestVersion(name, { throw: false });
|
|
7336
|
+
if ("error" in result) {
|
|
7337
|
+
return null;
|
|
7338
|
+
}
|
|
7339
|
+
return result.version;
|
|
7340
|
+
} catch {
|
|
7341
|
+
return null;
|
|
7342
|
+
}
|
|
7343
|
+
}
|
|
7344
|
+
function displayUpdateNotification(latestVersion) {
|
|
7345
|
+
const message = [
|
|
7346
|
+
`Update available ${chalk.dim(version)} \u2192 ${chalk.green(
|
|
7347
|
+
latestVersion
|
|
7348
|
+
)}`,
|
|
7349
|
+
"",
|
|
7350
|
+
`Run ${chalk.cyan(`npm install -g ${name}`)} to update`
|
|
7351
|
+
].join("\n");
|
|
7352
|
+
console.log(
|
|
7353
|
+
"\n" + boxen(message, {
|
|
7354
|
+
padding: 1,
|
|
7355
|
+
margin: 1,
|
|
7356
|
+
borderStyle: "round",
|
|
7357
|
+
borderColor: "yellow"
|
|
7358
|
+
}) + "\n"
|
|
7359
|
+
);
|
|
7360
|
+
}
|
|
7361
|
+
async function checkForUpdates(force = false) {
|
|
7362
|
+
try {
|
|
7363
|
+
const now = Date.now();
|
|
7364
|
+
const cache = versionCache.read();
|
|
7365
|
+
const shouldUseCache = cache && !force && now - cache.lastChecked < CHECK_INTERVAL;
|
|
7366
|
+
if (shouldUseCache) {
|
|
7367
|
+
if (semver.gt(cache.latestVersion, version)) {
|
|
7368
|
+
const shouldNotify = !cache.lastNotified || now - cache.lastNotified >= NOTIFY_INTERVAL;
|
|
7369
|
+
if (shouldNotify) {
|
|
7370
|
+
displayUpdateNotification(cache.latestVersion);
|
|
7371
|
+
versionCache.write({ ...cache, lastNotified: now });
|
|
7372
|
+
}
|
|
7373
|
+
}
|
|
7374
|
+
return;
|
|
7375
|
+
}
|
|
7376
|
+
const latestVersion = await fetchLatestVersion();
|
|
7377
|
+
if (!latestVersion) return;
|
|
7378
|
+
const isUpdateAvailable = semver.gt(latestVersion, version);
|
|
7379
|
+
versionCache.write({
|
|
7380
|
+
lastChecked: now,
|
|
7381
|
+
latestVersion,
|
|
7382
|
+
lastNotified: isUpdateAvailable ? now : cache?.lastNotified
|
|
7383
|
+
});
|
|
7384
|
+
if (isUpdateAvailable) {
|
|
7385
|
+
displayUpdateNotification(latestVersion);
|
|
7386
|
+
}
|
|
7387
|
+
} catch (err) {
|
|
7388
|
+
console.error("Unable to check for updates", err);
|
|
7389
|
+
}
|
|
7390
|
+
}
|
|
7391
|
+
async function checkForUpdatesAsync() {
|
|
7392
|
+
await checkForUpdates();
|
|
7393
|
+
}
|
|
7394
|
+
|
|
6321
7395
|
// src/utils/erasure.ts
|
|
6322
7396
|
var providerPromise;
|
|
6323
7397
|
function getErasureCodingProvider() {
|
|
@@ -6328,9 +7402,9 @@ function getErasureCodingProvider() {
|
|
|
6328
7402
|
}
|
|
6329
7403
|
|
|
6330
7404
|
// src/utils/paths.ts
|
|
6331
|
-
import
|
|
7405
|
+
import path4 from "path";
|
|
6332
7406
|
function endsWithDirectorySeparator(filePath) {
|
|
6333
|
-
return filePath.endsWith("/") || filePath.endsWith("\\") || filePath.endsWith(
|
|
7407
|
+
return filePath.endsWith("/") || filePath.endsWith("\\") || filePath.endsWith(path4.sep);
|
|
6334
7408
|
}
|
|
6335
7409
|
function normBlobName(pathModule, inputDirectoryName, filename, blobPrefix) {
|
|
6336
7410
|
const blobNameWithoutInputDir = pathModule.relative(
|
|
@@ -6343,7 +7417,7 @@ function normBlobName(pathModule, inputDirectoryName, filename, blobPrefix) {
|
|
|
6343
7417
|
);
|
|
6344
7418
|
const blobNameNormalized = pathModule.normalize(blobNameWithPrefix);
|
|
6345
7419
|
const parts = blobNameNormalized.split(pathModule.sep);
|
|
6346
|
-
return
|
|
7420
|
+
return path4.posix.join(...parts);
|
|
6347
7421
|
}
|
|
6348
7422
|
function denormBlobName(pathModule, blobPrefix, blobName, outputPrefix) {
|
|
6349
7423
|
if (!pathModule.isAbsolute(outputPrefix)) {
|
|
@@ -6577,7 +7651,7 @@ function createResponsiveTable(options) {
|
|
|
6577
7651
|
|
|
6578
7652
|
// src/utils/version.ts
|
|
6579
7653
|
import { execSync } from "child_process";
|
|
6580
|
-
import
|
|
7654
|
+
import semver2 from "semver";
|
|
6581
7655
|
var MIN_APTOS_CLI_VERSION = "7.8.0";
|
|
6582
7656
|
var MIN_NODE_VERSION = "22.0.0";
|
|
6583
7657
|
function getNodeVersion() {
|
|
@@ -6585,7 +7659,7 @@ function getNodeVersion() {
|
|
|
6585
7659
|
}
|
|
6586
7660
|
function getNodeVersionInfo(minVersion = MIN_NODE_VERSION) {
|
|
6587
7661
|
const version2 = getNodeVersion();
|
|
6588
|
-
const meetsRequirement =
|
|
7662
|
+
const meetsRequirement = semver2.gte(version2, minVersion);
|
|
6589
7663
|
return { version: version2, meetsRequirement };
|
|
6590
7664
|
}
|
|
6591
7665
|
function getAptosCliVersion() {
|
|
@@ -6601,15 +7675,15 @@ function getAptosCliVersion() {
|
|
|
6601
7675
|
}
|
|
6602
7676
|
function getAptosCliVersionInfo(minVersion = MIN_APTOS_CLI_VERSION) {
|
|
6603
7677
|
const version2 = getAptosCliVersion();
|
|
6604
|
-
const meetsRequirement = version2 ?
|
|
7678
|
+
const meetsRequirement = version2 ? semver2.gte(version2, minVersion) : false;
|
|
6605
7679
|
return { version: version2, meetsRequirement };
|
|
6606
7680
|
}
|
|
6607
7681
|
|
|
6608
7682
|
// src/components/InitWizard.tsx
|
|
6609
7683
|
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
6610
7684
|
var InitWizard = ({
|
|
6611
|
-
existingConfig,
|
|
6612
7685
|
configPath,
|
|
7686
|
+
existingConfig,
|
|
6613
7687
|
onComplete,
|
|
6614
7688
|
onCancel
|
|
6615
7689
|
}) => {
|
|
@@ -6696,7 +7770,7 @@ var InitWizard = ({
|
|
|
6696
7770
|
] }),
|
|
6697
7771
|
/* @__PURE__ */ jsxs6(Text6, { color: "cyan", children: [
|
|
6698
7772
|
" ",
|
|
6699
|
-
configPath
|
|
7773
|
+
configPath
|
|
6700
7774
|
] }),
|
|
6701
7775
|
/* @__PURE__ */ jsxs6(Text6, { color: "red", children: [
|
|
6702
7776
|
"\n",
|
|
@@ -7083,10 +8157,10 @@ var handleError = (error) => {
|
|
|
7083
8157
|
|
|
7084
8158
|
// src/commands/account.tsx
|
|
7085
8159
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
7086
|
-
var CreateAccountOptionsSchema =
|
|
7087
|
-
name:
|
|
7088
|
-
privateKey:
|
|
7089
|
-
address:
|
|
8160
|
+
var CreateAccountOptionsSchema = z11.object({
|
|
8161
|
+
name: z11.string().optional(),
|
|
8162
|
+
privateKey: z11.string().optional(),
|
|
8163
|
+
address: z11.string().optional(),
|
|
7090
8164
|
scheme: SignatureSchemeSchema.optional()
|
|
7091
8165
|
});
|
|
7092
8166
|
var allSchemes = SignatureSchemeSchema.options.join(", ");
|
|
@@ -7113,33 +8187,29 @@ async function promptForAccountName(config) {
|
|
|
7113
8187
|
return answer;
|
|
7114
8188
|
}
|
|
7115
8189
|
}
|
|
7116
|
-
var ListAccountOptionsSchema =
|
|
7117
|
-
var UseAccountOptionsSchema =
|
|
7118
|
-
accountName:
|
|
8190
|
+
var ListAccountOptionsSchema = z11.object({});
|
|
8191
|
+
var UseAccountOptionsSchema = z11.object({
|
|
8192
|
+
accountName: z11.string()
|
|
7119
8193
|
});
|
|
7120
|
-
var DeleteAccountOptionsSchema =
|
|
7121
|
-
accountName:
|
|
8194
|
+
var DeleteAccountOptionsSchema = z11.object({
|
|
8195
|
+
accountName: z11.string()
|
|
7122
8196
|
});
|
|
7123
8197
|
function accountCommand(program) {
|
|
7124
8198
|
const account = program.command("account").description("Manage signing accounts (addresses & keys)");
|
|
7125
|
-
account.command("create").description("Create a new account").option("--name <account-name>", "Name of the account").
|
|
7126
|
-
|
|
7127
|
-
|
|
8199
|
+
account.command("create").description("Create a new account").option("--name <account-name>", "Name of the account").addOption(
|
|
8200
|
+
new Option(
|
|
8201
|
+
"--scheme <signature-scheme>",
|
|
8202
|
+
"Signature scheme of the private key"
|
|
8203
|
+
).choices(Object.values(SignatureSchemeSchema.Enum))
|
|
7128
8204
|
).option("--private-key <key>", "Raw private key").option(
|
|
7129
8205
|
"--address <account-address>",
|
|
7130
8206
|
"Aptos account address (hex-encoded)"
|
|
7131
8207
|
).action(async (options) => {
|
|
7132
8208
|
CreateAccountOptionsSchema.parse(options);
|
|
7133
|
-
const { name, privateKey, address, scheme } = options;
|
|
7134
|
-
const configPath =
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
config = loadConfig(configPath);
|
|
7138
|
-
} catch (err) {
|
|
7139
|
-
throw new Error(
|
|
7140
|
-
`${err.message}. Please ensure you've first initialized the config by doing \`shelby init\``
|
|
7141
|
-
);
|
|
7142
|
-
}
|
|
8209
|
+
const { name: name2, privateKey, address, scheme } = options;
|
|
8210
|
+
const { config, configPath } = loadConfigOrExit(
|
|
8211
|
+
program.opts().configFile
|
|
8212
|
+
);
|
|
7143
8213
|
const targetName = options.name ?? null;
|
|
7144
8214
|
if (privateKey && !scheme) {
|
|
7145
8215
|
console.error(
|
|
@@ -7147,7 +8217,9 @@ function accountCommand(program) {
|
|
|
7147
8217
|
);
|
|
7148
8218
|
process.exit(1);
|
|
7149
8219
|
}
|
|
7150
|
-
if (scheme && !SignatureSchemeSchema.
|
|
8220
|
+
if (scheme && !Object.values(SignatureSchemeSchema.Enum).includes(
|
|
8221
|
+
scheme
|
|
8222
|
+
)) {
|
|
7151
8223
|
console.error(
|
|
7152
8224
|
`\u274C Unsupported signature scheme. Only "${allSchemes}" is supported.`
|
|
7153
8225
|
);
|
|
@@ -7189,20 +8261,20 @@ function accountCommand(program) {
|
|
|
7189
8261
|
/* @__PURE__ */ jsx10(
|
|
7190
8262
|
AccountWizard,
|
|
7191
8263
|
{
|
|
7192
|
-
initialName:
|
|
8264
|
+
initialName: name2,
|
|
7193
8265
|
config,
|
|
7194
8266
|
onComplete: ({
|
|
7195
|
-
name:
|
|
8267
|
+
name: name3,
|
|
7196
8268
|
address: address2,
|
|
7197
8269
|
privateKey: privateKey2
|
|
7198
8270
|
}) => {
|
|
7199
|
-
config.accounts[
|
|
8271
|
+
config.accounts[name3] = {
|
|
7200
8272
|
private_key: privateKey2,
|
|
7201
8273
|
address: address2
|
|
7202
8274
|
};
|
|
7203
8275
|
saveConfig(config, configPath);
|
|
7204
8276
|
console.log(
|
|
7205
|
-
`\u2705 Account ${
|
|
8277
|
+
`\u2705 Account ${name3} saved to ${resolveConfigPath(configPath)}`
|
|
7206
8278
|
);
|
|
7207
8279
|
unmount();
|
|
7208
8280
|
}
|
|
@@ -7215,14 +8287,7 @@ function accountCommand(program) {
|
|
|
7215
8287
|
}
|
|
7216
8288
|
});
|
|
7217
8289
|
account.command("list").description("List all accounts in a table view").action(() => {
|
|
7218
|
-
const
|
|
7219
|
-
let config;
|
|
7220
|
-
try {
|
|
7221
|
-
config = loadConfig(configPath);
|
|
7222
|
-
} catch (err) {
|
|
7223
|
-
console.error(`Error listing accounts: ${err.message}`);
|
|
7224
|
-
process.exit(1);
|
|
7225
|
-
}
|
|
8290
|
+
const { config } = loadConfigOrExit(program.opts().configFile);
|
|
7226
8291
|
const accounts = Object.entries(config.accounts);
|
|
7227
8292
|
if (accounts.length === 0) {
|
|
7228
8293
|
console.log("No accounts found.");
|
|
@@ -7238,9 +8303,9 @@ function accountCommand(program) {
|
|
|
7238
8303
|
padding: 12
|
|
7239
8304
|
// Account for borders (4) + cell padding (6) + margin
|
|
7240
8305
|
});
|
|
7241
|
-
for (const [
|
|
7242
|
-
const isDefault =
|
|
7243
|
-
const displayName =
|
|
8306
|
+
for (const [name2, { address, private_key }] of accounts) {
|
|
8307
|
+
const isDefault = name2 === config.default_account ? " (default)" : "";
|
|
8308
|
+
const displayName = name2 + isDefault;
|
|
7244
8309
|
const maskedKey = private_key ? `${private_key.slice(0, 20)}...` : "";
|
|
7245
8310
|
const row = [displayName, address || "", maskedKey];
|
|
7246
8311
|
table.push(row.map((cell, i) => wrapCell(cell, i)));
|
|
@@ -7248,9 +8313,10 @@ function accountCommand(program) {
|
|
|
7248
8313
|
console.log(table.toString());
|
|
7249
8314
|
});
|
|
7250
8315
|
account.command("use").description("Set the default account").argument("<account-name>", "Name of the account to use").action((accountName) => {
|
|
7251
|
-
const configPath = program.opts().configFile;
|
|
7252
8316
|
try {
|
|
7253
|
-
const config =
|
|
8317
|
+
const { config, configPath } = loadConfigOrExit(
|
|
8318
|
+
program.opts().configFile
|
|
8319
|
+
);
|
|
7254
8320
|
if (!config.accounts[accountName]) {
|
|
7255
8321
|
console.error(`Error: Account '${accountName}' not found`);
|
|
7256
8322
|
process.exit(1);
|
|
@@ -7264,9 +8330,10 @@ function accountCommand(program) {
|
|
|
7264
8330
|
}
|
|
7265
8331
|
});
|
|
7266
8332
|
account.command("delete").description("Delete an account").argument("<account-name>", "Name of the account to delete").action((accountName) => {
|
|
7267
|
-
const configPath = program.opts().configFile;
|
|
7268
8333
|
try {
|
|
7269
|
-
const config =
|
|
8334
|
+
const { config, configPath } = loadConfigOrExit(
|
|
8335
|
+
program.opts().configFile
|
|
8336
|
+
);
|
|
7270
8337
|
if (!config.accounts[accountName]) {
|
|
7271
8338
|
console.error(`Error: Account '${accountName}' not found`);
|
|
7272
8339
|
process.exit(1);
|
|
@@ -7292,8 +8359,7 @@ function accountCommand(program) {
|
|
|
7292
8359
|
"-a, --account <account-name>",
|
|
7293
8360
|
"Name of the account to list blobs for"
|
|
7294
8361
|
).action(async () => {
|
|
7295
|
-
const
|
|
7296
|
-
const config = loadConfig(configPath);
|
|
8362
|
+
const { config } = loadConfigOrExit(program.opts().configFile);
|
|
7297
8363
|
try {
|
|
7298
8364
|
const accountName = program.opts().account || config.default_account;
|
|
7299
8365
|
const shelbyConfig = getCurrentShelbyConfig(config, {
|
|
@@ -7372,8 +8438,7 @@ function accountCommand(program) {
|
|
|
7372
8438
|
try {
|
|
7373
8439
|
const globalOpts = program.opts();
|
|
7374
8440
|
verbose = Boolean(globalOpts.verbose);
|
|
7375
|
-
const
|
|
7376
|
-
const config = loadConfig(configPath);
|
|
8441
|
+
const { config } = loadConfigOrExit(globalOpts.configFile);
|
|
7377
8442
|
const contextName = globalOpts.context || config.default_context;
|
|
7378
8443
|
const context = getCurrentContext(config, contextName);
|
|
7379
8444
|
const aptos = getAptosFromContext(context);
|
|
@@ -7424,16 +8489,16 @@ function accountCommand(program) {
|
|
|
7424
8489
|
console.log("\n\u{1F464} Account Information");
|
|
7425
8490
|
console.log("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
7426
8491
|
if (!addressArg && accountName) {
|
|
7427
|
-
console.log(`\u{1F3F7}\uFE0F Alias: ${
|
|
8492
|
+
console.log(`\u{1F3F7}\uFE0F Alias: ${chalk2.cyan(accountName)}`);
|
|
7428
8493
|
}
|
|
7429
|
-
console.log(`\u{1F310} Context: ${
|
|
8494
|
+
console.log(`\u{1F310} Context: ${chalk2.magenta(contextName)}`);
|
|
7430
8495
|
console.log("");
|
|
7431
|
-
console.log(`\u{1F511} Address: ${
|
|
8496
|
+
console.log(`\u{1F511} Address: ${chalk2.dim(targetAddress)}`);
|
|
7432
8497
|
console.log(
|
|
7433
|
-
`\u{1F517} Aptos Explorer: ${
|
|
8498
|
+
`\u{1F517} Aptos Explorer: ${chalk2.blueBright.underline(aptosExplorerUrl)}`
|
|
7434
8499
|
);
|
|
7435
8500
|
console.log(
|
|
7436
|
-
`\u{1F5C2}\uFE0F Shelby Explorer: ${
|
|
8501
|
+
`\u{1F5C2}\uFE0F Shelby Explorer: ${chalk2.blueBright.underline(shelbyExplorerUrl)}`
|
|
7437
8502
|
);
|
|
7438
8503
|
console.log("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
7439
8504
|
console.log("\n\u{1F4B0} Balance:\n");
|
|
@@ -7483,21 +8548,21 @@ function accountCommand(program) {
|
|
|
7483
8548
|
}
|
|
7484
8549
|
|
|
7485
8550
|
// src/commands/commitment.ts
|
|
7486
|
-
import * as
|
|
8551
|
+
import * as fs4 from "fs";
|
|
7487
8552
|
import * as fsP from "fs/promises";
|
|
7488
8553
|
import { Readable } from "stream";
|
|
7489
|
-
import { z as
|
|
7490
|
-
var CommitmentOptionsSchema =
|
|
7491
|
-
input:
|
|
7492
|
-
async (
|
|
7493
|
-
const stat4 = await fsP.stat(
|
|
8554
|
+
import { z as z12 } from "zod";
|
|
8555
|
+
var CommitmentOptionsSchema = z12.object({
|
|
8556
|
+
input: z12.string().nonempty("`--input` is required").refine(
|
|
8557
|
+
async (path10) => {
|
|
8558
|
+
const stat4 = await fsP.stat(path10);
|
|
7494
8559
|
return stat4.isFile();
|
|
7495
8560
|
},
|
|
7496
8561
|
{
|
|
7497
8562
|
message: "`--input` must be a file"
|
|
7498
8563
|
}
|
|
7499
8564
|
),
|
|
7500
|
-
output:
|
|
8565
|
+
output: z12.string().nonempty("`--output` is required")
|
|
7501
8566
|
});
|
|
7502
8567
|
function commitmentCommand(program) {
|
|
7503
8568
|
program.command("commitment <input> <output>").description(
|
|
@@ -7507,7 +8572,7 @@ function commitmentCommand(program) {
|
|
|
7507
8572
|
input,
|
|
7508
8573
|
output
|
|
7509
8574
|
});
|
|
7510
|
-
const inputFile =
|
|
8575
|
+
const inputFile = fs4.createReadStream(validatedOptions.input);
|
|
7511
8576
|
const provider = await getErasureCodingProvider();
|
|
7512
8577
|
const commitment = await generateCommitments(
|
|
7513
8578
|
provider,
|
|
@@ -7517,31 +8582,110 @@ function commitmentCommand(program) {
|
|
|
7517
8582
|
});
|
|
7518
8583
|
}
|
|
7519
8584
|
|
|
8585
|
+
// src/commands/config.tsx
|
|
8586
|
+
import fs5 from "fs-extra";
|
|
8587
|
+
import YAML3 from "yaml";
|
|
8588
|
+
function configCommand(program) {
|
|
8589
|
+
const config = program.command("config").description("Manage CLI configuration");
|
|
8590
|
+
config.command("set-global-config").description(
|
|
8591
|
+
"Set global configuration, such as where to load the .shelby/config.yaml file from"
|
|
8592
|
+
).requiredOption(
|
|
8593
|
+
"--config-location-behavior <behavior>",
|
|
8594
|
+
"Config location. If set to 'global', the CLI will load the config from ~/.shelby/config.yaml. If set to 'walk', the CLI will try to load the config from .shelby/config.yaml, then its parents, and finally the global ~/.shelby/config.yaml"
|
|
8595
|
+
).action((options) => {
|
|
8596
|
+
const behavior = options.configLocationBehavior;
|
|
8597
|
+
if (behavior !== "global" && behavior !== "walk") {
|
|
8598
|
+
console.error(
|
|
8599
|
+
"\u274C Error: --config-location-behavior must be either 'global' or 'walk'"
|
|
8600
|
+
);
|
|
8601
|
+
process.exit(1);
|
|
8602
|
+
}
|
|
8603
|
+
const globalConfig = {
|
|
8604
|
+
config_location_behavior: behavior
|
|
8605
|
+
};
|
|
8606
|
+
try {
|
|
8607
|
+
saveGlobalConfig(globalConfig);
|
|
8608
|
+
console.log(
|
|
8609
|
+
`\u2705 Global config updated: config_location_behavior = '${behavior}'`
|
|
8610
|
+
);
|
|
8611
|
+
console.log(
|
|
8612
|
+
behavior === "global" ? " The CLI will now load the config from ~/.shelby/config.yaml" : " The CLI will now try to load the config from .shelby/config.yaml, its parents, and finally the global .shelby/config.yaml"
|
|
8613
|
+
);
|
|
8614
|
+
} catch (err) {
|
|
8615
|
+
console.error(
|
|
8616
|
+
`\u274C Error saving global config: ${err instanceof Error ? err.message : String(err)}`
|
|
8617
|
+
);
|
|
8618
|
+
process.exit(1);
|
|
8619
|
+
}
|
|
8620
|
+
});
|
|
8621
|
+
config.command("describe-global-config").description("Describe the current global configuration").action(() => {
|
|
8622
|
+
try {
|
|
8623
|
+
const globalConfig = loadGlobalConfig();
|
|
8624
|
+
console.log("Global config:");
|
|
8625
|
+
console.log(
|
|
8626
|
+
` config_location_behavior: ${globalConfig.config_location_behavior}`
|
|
8627
|
+
);
|
|
8628
|
+
console.log(
|
|
8629
|
+
globalConfig.config_location_behavior === "global" ? " Loading config from: ~/.shelby/config.yaml" : " Loading config from: .shelby/config.yaml, its parents, and finally the global .shelby/config.yaml"
|
|
8630
|
+
);
|
|
8631
|
+
} catch (err) {
|
|
8632
|
+
console.error(
|
|
8633
|
+
`\u274C Error loading global config: ${err instanceof Error ? err.message : String(err)}`
|
|
8634
|
+
);
|
|
8635
|
+
process.exit(1);
|
|
8636
|
+
}
|
|
8637
|
+
});
|
|
8638
|
+
config.command("get-global-config").description("Display the global config file content as YAML").action(() => {
|
|
8639
|
+
try {
|
|
8640
|
+
if (!fs5.existsSync(GLOBAL_CONFIG_PATH)) {
|
|
8641
|
+
console.log("No global config file found.");
|
|
8642
|
+
console.log(`Expected location: ${GLOBAL_CONFIG_PATH}`);
|
|
8643
|
+
return;
|
|
8644
|
+
}
|
|
8645
|
+
const content = fs5.readFileSync(GLOBAL_CONFIG_PATH, "utf8");
|
|
8646
|
+
const parsed = YAML3.parse(content);
|
|
8647
|
+
const prettyYaml = YAML3.stringify(parsed, {
|
|
8648
|
+
indent: 2,
|
|
8649
|
+
lineWidth: 0
|
|
8650
|
+
});
|
|
8651
|
+
console.log(`Global config file: ${GLOBAL_CONFIG_PATH}`);
|
|
8652
|
+
console.log("");
|
|
8653
|
+
console.log(prettyYaml.trim());
|
|
8654
|
+
} catch (err) {
|
|
8655
|
+
console.error(
|
|
8656
|
+
`\u274C Error reading global config file: ${err instanceof Error ? err.message : String(err)}`
|
|
8657
|
+
);
|
|
8658
|
+
console.error(` Path: ${GLOBAL_CONFIG_PATH}`);
|
|
8659
|
+
process.exit(1);
|
|
8660
|
+
}
|
|
8661
|
+
});
|
|
8662
|
+
}
|
|
8663
|
+
|
|
7520
8664
|
// src/commands/context.tsx
|
|
7521
8665
|
import { render as render2 } from "ink";
|
|
7522
|
-
import { z as
|
|
8666
|
+
import { z as z14 } from "zod";
|
|
7523
8667
|
|
|
7524
8668
|
// src/utils/commands.ts
|
|
7525
|
-
import
|
|
7526
|
-
var AptosCommandOptionsSchema =
|
|
7527
|
-
aptosNetwork:
|
|
8669
|
+
import z13 from "zod";
|
|
8670
|
+
var AptosCommandOptionsSchema = z13.object({
|
|
8671
|
+
aptosNetwork: z13.string().optional(),
|
|
7528
8672
|
// predefined network name
|
|
7529
|
-
aptosFullnode:
|
|
7530
|
-
aptosFaucet:
|
|
7531
|
-
aptosIndexer:
|
|
7532
|
-
aptosPepper:
|
|
7533
|
-
aptosProver:
|
|
7534
|
-
aptosApiKey:
|
|
8673
|
+
aptosFullnode: z13.string().url().optional(),
|
|
8674
|
+
aptosFaucet: z13.string().url().optional(),
|
|
8675
|
+
aptosIndexer: z13.string().url().optional(),
|
|
8676
|
+
aptosPepper: z13.string().url().optional(),
|
|
8677
|
+
aptosProver: z13.string().url().optional(),
|
|
8678
|
+
aptosApiKey: z13.string().optional()
|
|
7535
8679
|
});
|
|
7536
8680
|
var addAptosCommandOptions = (context) => context.option(
|
|
7537
8681
|
"--aptos-network <network>",
|
|
7538
8682
|
`Aptos network (${shelbyNetworks.join(", ")})`
|
|
7539
8683
|
).option("--aptos-fullnode <url>", "Aptos fullnode URL").option("--aptos-faucet <url>", "Aptos faucet URL").option("--aptos-indexer <url>", "Aptos indexer URL").option("--aptos-pepper <url>", "Aptos pepper URL").option("--aptos-prover <url>", "Aptos prover URL").option("--aptos-api-key <key>", "Aptos API key");
|
|
7540
|
-
var ShelbyCommandOptionsSchema =
|
|
8684
|
+
var ShelbyCommandOptionsSchema = z13.object({
|
|
7541
8685
|
shelbyRpcEndpoint: EndpointSchema.optional(),
|
|
7542
8686
|
shelbyIndexerEndpoint: EndpointSchema.optional(),
|
|
7543
|
-
shelbyRpcApiKey:
|
|
7544
|
-
shelbyIndexerApiKey:
|
|
8687
|
+
shelbyRpcApiKey: z13.string().optional(),
|
|
8688
|
+
shelbyIndexerApiKey: z13.string().optional()
|
|
7545
8689
|
});
|
|
7546
8690
|
var addShelbyCommandOptions = (context) => context.option("--shelby-rpc-endpoint <url>", "Shelby RPC endpoint").option("--shelby-indexer-endpoint <url>", "Shelby indexer endpoint").option("--shelby-rpc-api-key <key>", "Shelby RPC API key").option("--shelby-indexer-api-key <key>", "Shelby indexer API key");
|
|
7547
8691
|
|
|
@@ -7578,16 +8722,18 @@ function getShelbyNetworkFromOptions(options) {
|
|
|
7578
8722
|
indexer_api_key: options.shelbyIndexerApiKey
|
|
7579
8723
|
};
|
|
7580
8724
|
}
|
|
7581
|
-
var CreateContextOptionsSchema =
|
|
7582
|
-
var UpdateContextOptionsSchema =
|
|
8725
|
+
var CreateContextOptionsSchema = z14.object({ name: z14.string().optional() }).merge(AptosCommandOptionsSchema).merge(ShelbyCommandOptionsSchema);
|
|
8726
|
+
var UpdateContextOptionsSchema = z14.object({}).merge(ShelbyCommandOptionsSchema).merge(AptosCommandOptionsSchema);
|
|
7583
8727
|
function contextCommand(program) {
|
|
7584
8728
|
const context = program.command("context").description("Manage network contexts (Shelby RPC & Aptos endpoints)");
|
|
7585
8729
|
addShelbyCommandOptions(addAptosCommandOptions(context.command("create"))).description("Create a new context").option("--name <context-name>", "Name of the context").action((options) => {
|
|
7586
8730
|
CreateContextOptionsSchema.parse(options);
|
|
7587
|
-
const { name } = options;
|
|
8731
|
+
const { name: name2 } = options;
|
|
7588
8732
|
const aptosNetwork = getAptosNetworkFromOptions(options);
|
|
7589
8733
|
const shelbyNetwork = getShelbyNetworkFromOptions(options);
|
|
7590
|
-
const configPath =
|
|
8734
|
+
const configPath = resolveConfigPath(
|
|
8735
|
+
program.opts().configFile ?? findExistingConfigPath()
|
|
8736
|
+
);
|
|
7591
8737
|
let config;
|
|
7592
8738
|
try {
|
|
7593
8739
|
config = loadConfig(configPath);
|
|
@@ -7595,8 +8741,8 @@ function contextCommand(program) {
|
|
|
7595
8741
|
config = {
|
|
7596
8742
|
contexts: {},
|
|
7597
8743
|
accounts: {},
|
|
7598
|
-
default_context:
|
|
7599
|
-
default_account:
|
|
8744
|
+
default_context: name2 || DEFAULT_CONTEXT,
|
|
8745
|
+
default_account: DEFAULT_ACCOUNT
|
|
7600
8746
|
};
|
|
7601
8747
|
}
|
|
7602
8748
|
const hasShelbyNetworkChanges = Object.values(shelbyNetwork).some(
|
|
@@ -7605,10 +8751,10 @@ function contextCommand(program) {
|
|
|
7605
8751
|
const hasAptosNetworkChanges = Object.values(aptosNetwork).some(
|
|
7606
8752
|
(value) => value !== void 0
|
|
7607
8753
|
);
|
|
7608
|
-
if (
|
|
8754
|
+
if (name2 && (hasAptosNetworkChanges || hasShelbyNetworkChanges)) {
|
|
7609
8755
|
const validatedAptosNetwork = AptosNetworkSchema.parse(aptosNetwork);
|
|
7610
8756
|
const validatedShelbyNetwork = ShelbyNetworkSchema.parse(shelbyNetwork);
|
|
7611
|
-
config.contexts[
|
|
8757
|
+
config.contexts[name2] = {
|
|
7612
8758
|
shelby_network: {
|
|
7613
8759
|
...validatedShelbyNetwork,
|
|
7614
8760
|
// This is to ensure there are no trailing slashes
|
|
@@ -7620,7 +8766,7 @@ function contextCommand(program) {
|
|
|
7620
8766
|
aptos_network: validatedAptosNetwork
|
|
7621
8767
|
};
|
|
7622
8768
|
saveConfig(config, configPath);
|
|
7623
|
-
console.log(`\u2705 Context '${
|
|
8769
|
+
console.log(`\u2705 Context '${name2}' created successfully`);
|
|
7624
8770
|
return;
|
|
7625
8771
|
}
|
|
7626
8772
|
const { unmount } = render2(
|
|
@@ -7628,18 +8774,18 @@ function contextCommand(program) {
|
|
|
7628
8774
|
CreateContextWizard,
|
|
7629
8775
|
{
|
|
7630
8776
|
onComplete: ({
|
|
7631
|
-
name:
|
|
8777
|
+
name: name3,
|
|
7632
8778
|
apiKey,
|
|
7633
8779
|
shelbyNetwork: shelbyNetwork2,
|
|
7634
8780
|
aptosNetwork: aptosNetwork2
|
|
7635
8781
|
}) => {
|
|
7636
|
-
config.contexts[
|
|
8782
|
+
config.contexts[name3] = {
|
|
7637
8783
|
api_key: apiKey,
|
|
7638
8784
|
shelby_network: shelbyNetwork2,
|
|
7639
8785
|
aptos_network: aptosNetwork2
|
|
7640
8786
|
};
|
|
7641
8787
|
saveConfig(config, configPath);
|
|
7642
|
-
console.log(`\u2705 Context '${
|
|
8788
|
+
console.log(`\u2705 Context '${name3}' created successfully`);
|
|
7643
8789
|
unmount();
|
|
7644
8790
|
process.exit(0);
|
|
7645
8791
|
}
|
|
@@ -7651,14 +8797,9 @@ function contextCommand(program) {
|
|
|
7651
8797
|
UpdateContextOptionsSchema.parse(options);
|
|
7652
8798
|
const aptosNetwork = getAptosNetworkFromOptions(options);
|
|
7653
8799
|
const shelbyNetwork = getShelbyNetworkFromOptions(options);
|
|
7654
|
-
const configPath =
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
config = loadConfig(configPath);
|
|
7658
|
-
} catch (error) {
|
|
7659
|
-
console.error(`Error loading config: ${error.message}`);
|
|
7660
|
-
process.exit(1);
|
|
7661
|
-
}
|
|
8800
|
+
const { config, configPath } = loadConfigOrExit(
|
|
8801
|
+
program.opts().configFile
|
|
8802
|
+
);
|
|
7662
8803
|
const currentContext = config.contexts[contextName];
|
|
7663
8804
|
if (!currentContext) {
|
|
7664
8805
|
console.error(`Error: Context '${contextName}' not found`);
|
|
@@ -7721,14 +8862,7 @@ function contextCommand(program) {
|
|
|
7721
8862
|
);
|
|
7722
8863
|
});
|
|
7723
8864
|
context.command("list").description("List all contexts in a table").action(() => {
|
|
7724
|
-
const
|
|
7725
|
-
let config;
|
|
7726
|
-
try {
|
|
7727
|
-
config = loadConfig(configPath);
|
|
7728
|
-
} catch (err) {
|
|
7729
|
-
console.error(`Error listing contexts: ${err.message}`);
|
|
7730
|
-
process.exit(1);
|
|
7731
|
-
}
|
|
8865
|
+
const { config } = loadConfigOrExit(program.opts().configFile);
|
|
7732
8866
|
if (Object.keys(config.contexts).length === 0) {
|
|
7733
8867
|
console.log("No contexts found.");
|
|
7734
8868
|
process.exit(0);
|
|
@@ -7805,9 +8939,10 @@ function contextCommand(program) {
|
|
|
7805
8939
|
console.log(shelbyConfigTable.toString());
|
|
7806
8940
|
});
|
|
7807
8941
|
context.command("use").description("Set the default context").argument("<context-name>", "Name of the context to use").action((contextName) => {
|
|
7808
|
-
const configPath =
|
|
8942
|
+
const { config, configPath } = loadConfigOrExit(
|
|
8943
|
+
program.opts().configFile
|
|
8944
|
+
);
|
|
7809
8945
|
try {
|
|
7810
|
-
const config = loadConfig(configPath);
|
|
7811
8946
|
if (!config.contexts[contextName]) {
|
|
7812
8947
|
console.error(`Error: Context '${contextName}' not found`);
|
|
7813
8948
|
process.exit(1);
|
|
@@ -7821,9 +8956,10 @@ function contextCommand(program) {
|
|
|
7821
8956
|
}
|
|
7822
8957
|
});
|
|
7823
8958
|
context.command("delete").description("Delete a context").argument("<context-name>", "Name of the context to delete").action((contextName) => {
|
|
7824
|
-
const configPath =
|
|
8959
|
+
const { config, configPath } = loadConfigOrExit(
|
|
8960
|
+
program.opts().configFile
|
|
8961
|
+
);
|
|
7825
8962
|
try {
|
|
7826
|
-
const config = loadConfig(configPath);
|
|
7827
8963
|
if (!config.contexts[contextName]) {
|
|
7828
8964
|
console.error(`Error: Context '${contextName}' not found`);
|
|
7829
8965
|
process.exit(1);
|
|
@@ -7849,22 +8985,22 @@ function contextCommand(program) {
|
|
|
7849
8985
|
|
|
7850
8986
|
// src/commands/download.tsx
|
|
7851
8987
|
import * as fsS from "fs";
|
|
7852
|
-
import * as
|
|
7853
|
-
import * as
|
|
8988
|
+
import * as fs6 from "fs/promises";
|
|
8989
|
+
import * as path5 from "path";
|
|
7854
8990
|
import { Readable as Readable2, Transform } from "stream";
|
|
7855
8991
|
import { pipeline } from "stream/promises";
|
|
7856
8992
|
import ora from "ora";
|
|
7857
|
-
import { z as
|
|
7858
|
-
var denormBlobName2 = (a, b, c) => denormBlobName(
|
|
7859
|
-
var DownloadOptionsSchema =
|
|
7860
|
-
source:
|
|
8993
|
+
import { z as z15 } from "zod";
|
|
8994
|
+
var denormBlobName2 = (a, b, c) => denormBlobName(path5, a, b, c);
|
|
8995
|
+
var DownloadOptionsSchema = z15.object({
|
|
8996
|
+
source: z15.string({
|
|
7861
8997
|
required_error: "\n\u274C Missing Required Argument\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n\u26A0\uFE0F Missing source blob name or prefix (first argument)\n\n\u{1F4A1} Usage:\n shelby download <source-blob-name> <destination-path> [options]\n\n\u{1F4DD} Examples:\n shelby download my-blob.txt ./myfile.txt\n shelby download my-folder/ ./my-folder/ -r\n"
|
|
7862
8998
|
}).min(1, "Source blob name or directory prefix is required").describe("Blob name or directory prefix to download"),
|
|
7863
|
-
destination:
|
|
8999
|
+
destination: z15.string({
|
|
7864
9000
|
required_error: "\n\u274C Missing Required Argument\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n\u26A0\uFE0F Missing destination path (second argument)\n\n\u{1F4A1} Usage:\n shelby download <source-blob-name> <destination-path> [options]\n\n\u{1F4DD} Example:\n shelby download my-blob.txt ./myfile.txt\n"
|
|
7865
9001
|
}).min(1, "`destination` must be a valid filepath").describe("Local path where to save the downloaded content"),
|
|
7866
|
-
recursive:
|
|
7867
|
-
force:
|
|
9002
|
+
recursive: z15.boolean().default(false).describe("Download assuming canonical directory layout and recurse"),
|
|
9003
|
+
force: z15.boolean().default(false).describe("Overwrite the destination if it already exists")
|
|
7868
9004
|
}).refine(
|
|
7869
9005
|
(data) => {
|
|
7870
9006
|
if (data.recursive) {
|
|
@@ -7937,9 +9073,9 @@ var DownloadOptionsSchema = z13.object({
|
|
|
7937
9073
|
}
|
|
7938
9074
|
);
|
|
7939
9075
|
async function validateOutput(options) {
|
|
7940
|
-
const parentDir =
|
|
9076
|
+
const parentDir = path5.dirname(options.destination);
|
|
7941
9077
|
try {
|
|
7942
|
-
const parentStats = await
|
|
9078
|
+
const parentStats = await fs6.stat(parentDir);
|
|
7943
9079
|
if (!parentStats.isDirectory()) {
|
|
7944
9080
|
throw new Error(
|
|
7945
9081
|
`Parent path '${parentDir}' exists but is not a directory. Cannot create destination ${options.recursive ? "directory" : "file"} '${options.destination}'.`
|
|
@@ -7956,7 +9092,7 @@ async function validateOutput(options) {
|
|
|
7956
9092
|
if (options.force) return;
|
|
7957
9093
|
let outputStats;
|
|
7958
9094
|
try {
|
|
7959
|
-
outputStats = await
|
|
9095
|
+
outputStats = await fs6.stat(options.destination);
|
|
7960
9096
|
} catch (error) {
|
|
7961
9097
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
7962
9098
|
return;
|
|
@@ -7975,7 +9111,7 @@ async function validateOutput(options) {
|
|
|
7975
9111
|
);
|
|
7976
9112
|
}
|
|
7977
9113
|
if (options.recursive) {
|
|
7978
|
-
const entries = await
|
|
9114
|
+
const entries = await fs6.readdir(options.destination);
|
|
7979
9115
|
if (entries.length > 0) {
|
|
7980
9116
|
throw new Error(
|
|
7981
9117
|
`Directory '${options.destination}' exists and is not empty. Use --force to overwrite or choose an empty directory.`
|
|
@@ -8042,12 +9178,12 @@ async function createFileList(options, nodeClient, account) {
|
|
|
8042
9178
|
async function createOutputDirectories(fileList) {
|
|
8043
9179
|
const uniqueDirectories = /* @__PURE__ */ new Set();
|
|
8044
9180
|
for (const fileEntry of fileList) {
|
|
8045
|
-
const parentDir =
|
|
9181
|
+
const parentDir = path5.dirname(fileEntry.filename);
|
|
8046
9182
|
uniqueDirectories.add(parentDir);
|
|
8047
9183
|
}
|
|
8048
9184
|
for (const dir of uniqueDirectories) {
|
|
8049
9185
|
try {
|
|
8050
|
-
await
|
|
9186
|
+
await fs6.mkdir(dir, { recursive: true });
|
|
8051
9187
|
} catch (error) {
|
|
8052
9188
|
throw new Error(
|
|
8053
9189
|
`Failed to create directory '${dir}': ${error instanceof Error ? error.message : error}`
|
|
@@ -8073,8 +9209,9 @@ function createProgressTransform(totalBytes, reporter) {
|
|
|
8073
9209
|
function downloadCommand(program) {
|
|
8074
9210
|
program.command("download").description("Download a file or directory from Shelby RPC").argument("[source]", "Source blob name or prefix").argument("[destination]", "Destination path").option(
|
|
8075
9211
|
"-r, --recursive",
|
|
8076
|
-
"Download assuming canonical directory layout using '/' as separators. Produces a directory."
|
|
8077
|
-
|
|
9212
|
+
"Download assuming canonical directory layout using '/' as separators. Produces a directory.",
|
|
9213
|
+
false
|
|
9214
|
+
).option("-f, --force", "Overwrite the destination", false).action(
|
|
8078
9215
|
async (source, destination, rawOptions) => {
|
|
8079
9216
|
let options;
|
|
8080
9217
|
try {
|
|
@@ -8084,7 +9221,7 @@ function downloadCommand(program) {
|
|
|
8084
9221
|
destination
|
|
8085
9222
|
});
|
|
8086
9223
|
} catch (error) {
|
|
8087
|
-
if (error instanceof
|
|
9224
|
+
if (error instanceof z15.ZodError) {
|
|
8088
9225
|
const firstIssue = error.issues[0];
|
|
8089
9226
|
if (firstIssue) {
|
|
8090
9227
|
console.log(firstIssue.message);
|
|
@@ -8098,7 +9235,7 @@ function downloadCommand(program) {
|
|
|
8098
9235
|
}
|
|
8099
9236
|
process.exit(1);
|
|
8100
9237
|
}
|
|
8101
|
-
options.destination =
|
|
9238
|
+
options.destination = path5.resolve(options.destination);
|
|
8102
9239
|
let config;
|
|
8103
9240
|
let spinner;
|
|
8104
9241
|
const handleSigint = () => {
|
|
@@ -8106,8 +9243,7 @@ function downloadCommand(program) {
|
|
|
8106
9243
|
process.exit(1);
|
|
8107
9244
|
};
|
|
8108
9245
|
try {
|
|
8109
|
-
|
|
8110
|
-
config = loadConfig(configPath);
|
|
9246
|
+
({ config } = loadConfigOrExit(program.opts().configFile));
|
|
8111
9247
|
const shelbyConfig = getCurrentShelbyConfig(config, {
|
|
8112
9248
|
context: program.opts().context
|
|
8113
9249
|
});
|
|
@@ -8127,13 +9263,13 @@ function downloadCommand(program) {
|
|
|
8127
9263
|
console.log("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
8128
9264
|
for (let i = 0; i < fileList.length; i++) {
|
|
8129
9265
|
const fileEntry = fileList[i];
|
|
8130
|
-
const blobBaseName =
|
|
9266
|
+
const blobBaseName = path5.basename(fileEntry.blobname);
|
|
8131
9267
|
console.log(`${i + 1}. ${blobBaseName} \u2192 ${fileEntry.filename}`);
|
|
8132
9268
|
}
|
|
8133
9269
|
console.log();
|
|
8134
9270
|
if (options.force) {
|
|
8135
9271
|
console.log(`--force was set, so deleting ${options.destination}`);
|
|
8136
|
-
await
|
|
9272
|
+
await fs6.rm(options.destination, { recursive: true, force: true });
|
|
8137
9273
|
}
|
|
8138
9274
|
process.removeAllListeners("SIGINT");
|
|
8139
9275
|
process.on("SIGINT", handleSigint);
|
|
@@ -8151,7 +9287,7 @@ function downloadCommand(program) {
|
|
|
8151
9287
|
const formatProgressPercent = () => totalSize > 0 ? (100 * (amountDownloaded / totalSize)).toFixed(2) : "0.00";
|
|
8152
9288
|
for (const fileEntry of fileList) {
|
|
8153
9289
|
const out = fsS.createWriteStream(fileEntry.filename);
|
|
8154
|
-
const fileName =
|
|
9290
|
+
const fileName = path5.basename(fileEntry.blobname);
|
|
8155
9291
|
const { readable } = await nodeClient.rpc.getBlob({
|
|
8156
9292
|
account: activeAccount.accountAddress,
|
|
8157
9293
|
blobName: fileEntry.blobname
|
|
@@ -8241,18 +9377,28 @@ function downloadCommand(program) {
|
|
|
8241
9377
|
|
|
8242
9378
|
// src/commands/faucet.tsx
|
|
8243
9379
|
import { Network as Network9 } from "@aptos-labs/ts-sdk";
|
|
9380
|
+
import { Option as Option2 } from "@commander-js/extra-typings";
|
|
8244
9381
|
import { execaSync } from "execa";
|
|
8245
|
-
import { z as
|
|
8246
|
-
var FaucetOptionsSchema =
|
|
8247
|
-
network:
|
|
8248
|
-
open:
|
|
9382
|
+
import { z as z16 } from "zod";
|
|
9383
|
+
var FaucetOptionsSchema = z16.object({
|
|
9384
|
+
network: z16.enum([Network9.SHELBYNET]).optional(),
|
|
9385
|
+
open: z16.boolean().optional().default(true)
|
|
8249
9386
|
});
|
|
8250
9387
|
function faucetCommand(program) {
|
|
8251
|
-
program.command("faucet").description("Open the Shelby faucet web page to request tokens").
|
|
9388
|
+
program.command("faucet").description("Open the Shelby faucet web page to request tokens").addOption(
|
|
9389
|
+
new Option2(
|
|
9390
|
+
"--network <network>",
|
|
9391
|
+
"Network to request tokens for (shelbynet)"
|
|
9392
|
+
).choices(Object.values(Network9))
|
|
9393
|
+
).addOption(
|
|
9394
|
+
new Option2(
|
|
9395
|
+
"--no-open",
|
|
9396
|
+
"Don't automatically open browser, just print the URL"
|
|
9397
|
+
)
|
|
9398
|
+
).action((options) => {
|
|
8252
9399
|
try {
|
|
8253
9400
|
const validatedOptions = FaucetOptionsSchema.parse(options);
|
|
8254
|
-
const
|
|
8255
|
-
const config = loadConfig(configPath);
|
|
9401
|
+
const { config } = loadConfigOrExit(program.opts().configFile);
|
|
8256
9402
|
const accountName = program.opts().account || config.default_account;
|
|
8257
9403
|
const { account } = getCurrentAccount(config, accountName);
|
|
8258
9404
|
const network = validatedOptions.network || Network9.SHELBYNET;
|
|
@@ -8316,9 +9462,9 @@ function openBrowser(url) {
|
|
|
8316
9462
|
}
|
|
8317
9463
|
|
|
8318
9464
|
// src/commands/init.tsx
|
|
8319
|
-
import
|
|
9465
|
+
import path6 from "path";
|
|
8320
9466
|
import { Network as Network10 } from "@aptos-labs/ts-sdk";
|
|
8321
|
-
import
|
|
9467
|
+
import fs7 from "fs-extra";
|
|
8322
9468
|
import { render as render3 } from "ink";
|
|
8323
9469
|
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
8324
9470
|
function initCommand(program) {
|
|
@@ -8339,10 +9485,10 @@ function initCommand(program) {
|
|
|
8339
9485
|
);
|
|
8340
9486
|
process.exit(1);
|
|
8341
9487
|
}
|
|
8342
|
-
const configPath =
|
|
9488
|
+
const configPath = getPathForNewConfig();
|
|
8343
9489
|
const resolvedPath = resolveConfigPath(configPath);
|
|
8344
9490
|
const accountName = program.opts().account;
|
|
8345
|
-
const hasExistingConfig =
|
|
9491
|
+
const hasExistingConfig = fs7.existsSync(resolvedPath);
|
|
8346
9492
|
let existingConfigValid = false;
|
|
8347
9493
|
if (hasExistingConfig) {
|
|
8348
9494
|
try {
|
|
@@ -8359,7 +9505,7 @@ function initCommand(program) {
|
|
|
8359
9505
|
}
|
|
8360
9506
|
}
|
|
8361
9507
|
if (options.setupDefault) {
|
|
8362
|
-
if (
|
|
9508
|
+
if (fs7.existsSync(resolvedPath)) {
|
|
8363
9509
|
console.error(
|
|
8364
9510
|
`\u274C Refusing to overwrite existing config at ${resolvedPath}. Remove it first or run 'shelby init' interactively.`
|
|
8365
9511
|
);
|
|
@@ -8447,12 +9593,12 @@ function cloneContexts(contexts) {
|
|
|
8447
9593
|
return JSON.parse(JSON.stringify(contexts));
|
|
8448
9594
|
}
|
|
8449
9595
|
function ensureConfigDir(resolvedPath) {
|
|
8450
|
-
|
|
9596
|
+
fs7.mkdirpSync(path6.dirname(resolvedPath));
|
|
8451
9597
|
}
|
|
8452
9598
|
|
|
8453
9599
|
// src/commands/upload.tsx
|
|
8454
|
-
import * as
|
|
8455
|
-
import * as
|
|
9600
|
+
import * as fs8 from "fs/promises";
|
|
9601
|
+
import * as path7 from "path";
|
|
8456
9602
|
import { Aptos as Aptos5, AptosConfig as AptosConfig4 } from "@aptos-labs/ts-sdk";
|
|
8457
9603
|
import * as chrono from "chrono-node";
|
|
8458
9604
|
import { glob } from "glob";
|
|
@@ -8460,7 +9606,7 @@ import ignore from "ignore";
|
|
|
8460
9606
|
import { Box as Box7, render as render4, Text as Text7 } from "ink";
|
|
8461
9607
|
import SelectInput4 from "ink-select-input";
|
|
8462
9608
|
import ora2 from "ora";
|
|
8463
|
-
import { z as
|
|
9609
|
+
import { z as z17 } from "zod";
|
|
8464
9610
|
|
|
8465
9611
|
// src/utils/commander-helpers.ts
|
|
8466
9612
|
function createExitOverrideHandler(commandName, requiredArgs, requiredOptions, exampleUsage, warningMessage) {
|
|
@@ -8511,8 +9657,8 @@ function createExitOverrideHandler(commandName, requiredArgs, requiredOptions, e
|
|
|
8511
9657
|
|
|
8512
9658
|
// src/commands/upload.tsx
|
|
8513
9659
|
import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
8514
|
-
var normBlobName2 = (i, f, b) => normBlobName(
|
|
8515
|
-
var flexibleDateSchema =
|
|
9660
|
+
var normBlobName2 = (i, f, b) => normBlobName(path7, i, f, b);
|
|
9661
|
+
var flexibleDateSchema = z17.string().transform((val, ctx) => {
|
|
8516
9662
|
const now = /* @__PURE__ */ new Date();
|
|
8517
9663
|
let parsedDate = null;
|
|
8518
9664
|
if (/^\d+$/.test(val)) {
|
|
@@ -8535,7 +9681,7 @@ var flexibleDateSchema = z15.string().transform((val, ctx) => {
|
|
|
8535
9681
|
}
|
|
8536
9682
|
if (!parsedDate || Number.isNaN(parsedDate.getTime())) {
|
|
8537
9683
|
ctx.addIssue({
|
|
8538
|
-
code:
|
|
9684
|
+
code: z17.ZodIssueCode.custom,
|
|
8539
9685
|
message: `
|
|
8540
9686
|
\u274C Upload Failed
|
|
8541
9687
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
@@ -8549,11 +9695,11 @@ var flexibleDateSchema = z15.string().transform((val, ctx) => {
|
|
|
8549
9695
|
|
|
8550
9696
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`
|
|
8551
9697
|
});
|
|
8552
|
-
return
|
|
9698
|
+
return z17.NEVER;
|
|
8553
9699
|
}
|
|
8554
9700
|
if (parsedDate.getTime() <= now.getTime()) {
|
|
8555
9701
|
ctx.addIssue({
|
|
8556
|
-
code:
|
|
9702
|
+
code: z17.ZodIssueCode.custom,
|
|
8557
9703
|
message: `
|
|
8558
9704
|
\u274C Upload Failed
|
|
8559
9705
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
@@ -8565,26 +9711,26 @@ var flexibleDateSchema = z15.string().transform((val, ctx) => {
|
|
|
8565
9711
|
|
|
8566
9712
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`
|
|
8567
9713
|
});
|
|
8568
|
-
return
|
|
9714
|
+
return z17.NEVER;
|
|
8569
9715
|
}
|
|
8570
9716
|
return parsedDate;
|
|
8571
9717
|
});
|
|
8572
|
-
var UploadOptionsSchema =
|
|
8573
|
-
source:
|
|
9718
|
+
var UploadOptionsSchema = z17.object({
|
|
9719
|
+
source: z17.string({
|
|
8574
9720
|
required_error: '\n\u274C Missing Required Argument\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n\u26A0\uFE0F Missing source file or directory path (first argument)\n\n\u{1F4A1} Usage:\n shelby upload <source-file-or-directory> <destination-blob-name> [options]\n\n\u{1F4DD} Examples:\n shelby upload ./myfile.txt my-blob.txt -e tomorrow\n shelby upload ./my-folder/ my-folder/ -r -e "next week"\n\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
|
|
8575
9721
|
}).min(1, "Source file or directory path is required"),
|
|
8576
|
-
destination:
|
|
9722
|
+
destination: z17.string({
|
|
8577
9723
|
required_error: "\n\u274C Missing Required Argument\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n\u26A0\uFE0F Missing destination blob name (second argument)\n\n\u{1F4A1} Usage:\n shelby upload <source-file-or-directory> <destination-blob-name> [options]\n\n\u{1F4DD} Example:\n shelby upload ./myfile.txt files/my-blob.txt -e tomorrow\n\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"
|
|
8578
9724
|
}).min(1, "Destination blob name is required"),
|
|
8579
9725
|
expiration: flexibleDateSchema,
|
|
8580
|
-
recursive:
|
|
8581
|
-
assumeYes:
|
|
8582
|
-
outputCommitments:
|
|
9726
|
+
recursive: z17.boolean().optional().default(false),
|
|
9727
|
+
assumeYes: z17.boolean().optional().default(false),
|
|
9728
|
+
outputCommitments: z17.string().optional()
|
|
8583
9729
|
}).superRefine(async (data, ctx) => {
|
|
8584
|
-
const stats = await
|
|
9730
|
+
const stats = await fs8.stat(data.source);
|
|
8585
9731
|
if (!stats.isFile() && !stats.isDirectory()) {
|
|
8586
9732
|
ctx.addIssue({
|
|
8587
|
-
code:
|
|
9733
|
+
code: z17.ZodIssueCode.custom,
|
|
8588
9734
|
message: "\n\u274C Upload Failed\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n\u26A0\uFE0F Source path must be a file or directory\n\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
|
|
8589
9735
|
path: ["source"]
|
|
8590
9736
|
});
|
|
@@ -8593,7 +9739,7 @@ var UploadOptionsSchema = z15.object({
|
|
|
8593
9739
|
if (stats.isDirectory()) {
|
|
8594
9740
|
if (!data.destination.endsWith("/")) {
|
|
8595
9741
|
ctx.addIssue({
|
|
8596
|
-
code:
|
|
9742
|
+
code: z17.ZodIssueCode.custom,
|
|
8597
9743
|
message: `
|
|
8598
9744
|
\u274C Upload Failed
|
|
8599
9745
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
@@ -8611,7 +9757,7 @@ var UploadOptionsSchema = z15.object({
|
|
|
8611
9757
|
const blobNameResult = BlobNameSchema.safeParse(data.destination);
|
|
8612
9758
|
if (!blobNameResult.success) {
|
|
8613
9759
|
ctx.addIssue({
|
|
8614
|
-
code:
|
|
9760
|
+
code: z17.ZodIssueCode.custom,
|
|
8615
9761
|
message: `
|
|
8616
9762
|
\u274C Upload Failed
|
|
8617
9763
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
@@ -8628,7 +9774,7 @@ var UploadOptionsSchema = z15.object({
|
|
|
8628
9774
|
}
|
|
8629
9775
|
});
|
|
8630
9776
|
async function buildGitignoreMap(root) {
|
|
8631
|
-
const resolvedRoot =
|
|
9777
|
+
const resolvedRoot = path7.resolve(root);
|
|
8632
9778
|
const gitignoreMap = /* @__PURE__ */ new Map();
|
|
8633
9779
|
const ensureMatcher = (dir) => {
|
|
8634
9780
|
const existing = gitignoreMap.get(dir);
|
|
@@ -8648,8 +9794,8 @@ async function buildGitignoreMap(root) {
|
|
|
8648
9794
|
});
|
|
8649
9795
|
for (const gitignorePath of gitignoreFiles) {
|
|
8650
9796
|
try {
|
|
8651
|
-
const contents = await
|
|
8652
|
-
const directory =
|
|
9797
|
+
const contents = await fs8.readFile(gitignorePath, "utf8");
|
|
9798
|
+
const directory = path7.dirname(gitignorePath);
|
|
8653
9799
|
ensureMatcher(directory).add(contents);
|
|
8654
9800
|
} catch (error) {
|
|
8655
9801
|
if (error instanceof Error && Object.hasOwn(error, "code") && // biome-ignore lint/suspicious/noExplicitAny: node fs error type
|
|
@@ -8663,13 +9809,13 @@ async function buildGitignoreMap(root) {
|
|
|
8663
9809
|
}
|
|
8664
9810
|
function collectDirectoriesFromRoot(root, filePath) {
|
|
8665
9811
|
const directories = [];
|
|
8666
|
-
let current =
|
|
9812
|
+
let current = path7.dirname(filePath);
|
|
8667
9813
|
while (true) {
|
|
8668
9814
|
directories.push(current);
|
|
8669
9815
|
if (current === root) {
|
|
8670
9816
|
break;
|
|
8671
9817
|
}
|
|
8672
|
-
const parent =
|
|
9818
|
+
const parent = path7.dirname(current);
|
|
8673
9819
|
if (parent === current) {
|
|
8674
9820
|
break;
|
|
8675
9821
|
}
|
|
@@ -8685,7 +9831,7 @@ function shouldIgnorePath(gitignoreMap, root, filePath) {
|
|
|
8685
9831
|
if (!matcher) {
|
|
8686
9832
|
continue;
|
|
8687
9833
|
}
|
|
8688
|
-
const relative2 =
|
|
9834
|
+
const relative2 = path7.relative(directory, filePath).split(path7.sep).join("/");
|
|
8689
9835
|
const result = matcher.test(relative2);
|
|
8690
9836
|
if (result.ignored) {
|
|
8691
9837
|
ignored = true;
|
|
@@ -8697,7 +9843,7 @@ function shouldIgnorePath(gitignoreMap, root, filePath) {
|
|
|
8697
9843
|
return ignored;
|
|
8698
9844
|
}
|
|
8699
9845
|
async function createFilelist(options) {
|
|
8700
|
-
const stats = await
|
|
9846
|
+
const stats = await fs8.stat(options.source);
|
|
8701
9847
|
if (stats.isFile()) {
|
|
8702
9848
|
const blobname = normBlobName2(
|
|
8703
9849
|
options.source,
|
|
@@ -8717,7 +9863,7 @@ async function createFilelist(options) {
|
|
|
8717
9863
|
`${options.source} is a directory. Use --recursive to upload directories.`
|
|
8718
9864
|
);
|
|
8719
9865
|
}
|
|
8720
|
-
const sourceRoot =
|
|
9866
|
+
const sourceRoot = path7.resolve(options.source);
|
|
8721
9867
|
const gitignoreMap = await buildGitignoreMap(sourceRoot);
|
|
8722
9868
|
const fileList = [];
|
|
8723
9869
|
const result = await glob("**/*", {
|
|
@@ -8730,7 +9876,7 @@ async function createFilelist(options) {
|
|
|
8730
9876
|
if (shouldIgnorePath(gitignoreMap, sourceRoot, file)) {
|
|
8731
9877
|
continue;
|
|
8732
9878
|
}
|
|
8733
|
-
const stats2 = await
|
|
9879
|
+
const stats2 = await fs8.stat(file);
|
|
8734
9880
|
if (!stats2.isFile()) {
|
|
8735
9881
|
continue;
|
|
8736
9882
|
}
|
|
@@ -8753,9 +9899,10 @@ function uploadCommand(program) {
|
|
|
8753
9899
|
const uploadCmd = program.command("upload").description("Upload a file or directory to the shelby RPC in the config.").argument("[source]", "Source file or directory path").argument("[destination]", "Destination blob name").requiredOption(
|
|
8754
9900
|
"-e, --expiration <datetime>",
|
|
8755
9901
|
'Expiration date/time (required). Examples: "tomorrow", "in 2 days", "next Friday", "2025-12-31", UNIX timestamp'
|
|
8756
|
-
).option("-r, --recursive", "If uploading a directory, recurse").option(
|
|
9902
|
+
).option("-r, --recursive", "If uploading a directory, recurse", false).option(
|
|
8757
9903
|
"--assume-yes",
|
|
8758
|
-
"Do not prompt interactively, assume yes for any questions"
|
|
9904
|
+
"Do not prompt interactively, assume yes for any questions",
|
|
9905
|
+
false
|
|
8759
9906
|
).option(
|
|
8760
9907
|
"--output-commitments <filename>",
|
|
8761
9908
|
"Location to store commitments computed as as part of the upload"
|
|
@@ -8773,16 +9920,16 @@ function uploadCommand(program) {
|
|
|
8773
9920
|
)
|
|
8774
9921
|
);
|
|
8775
9922
|
uploadCmd.action(
|
|
8776
|
-
async (source, destination,
|
|
8777
|
-
let
|
|
9923
|
+
async (source, destination, rawOptions) => {
|
|
9924
|
+
let options;
|
|
8778
9925
|
try {
|
|
8779
|
-
|
|
8780
|
-
...
|
|
9926
|
+
options = await UploadOptionsSchema.parseAsync({
|
|
9927
|
+
...rawOptions,
|
|
8781
9928
|
source,
|
|
8782
9929
|
destination
|
|
8783
9930
|
});
|
|
8784
9931
|
} catch (error) {
|
|
8785
|
-
if (error instanceof
|
|
9932
|
+
if (error instanceof z17.ZodError) {
|
|
8786
9933
|
const firstIssue = error.issues[0];
|
|
8787
9934
|
if (firstIssue) {
|
|
8788
9935
|
console.log(firstIssue.message);
|
|
@@ -8795,16 +9942,9 @@ function uploadCommand(program) {
|
|
|
8795
9942
|
}
|
|
8796
9943
|
process.exit(1);
|
|
8797
9944
|
}
|
|
8798
|
-
const
|
|
8799
|
-
let config;
|
|
8800
|
-
try {
|
|
8801
|
-
config = loadConfig(configPath);
|
|
8802
|
-
} catch (error) {
|
|
8803
|
-
console.error(`Error: ${error.message}`);
|
|
8804
|
-
process.exit(1);
|
|
8805
|
-
}
|
|
9945
|
+
const { config } = loadConfigOrExit(program.opts().configFile);
|
|
8806
9946
|
const start = performance.now();
|
|
8807
|
-
const filelist = await createFilelist(
|
|
9947
|
+
const filelist = await createFilelist(options);
|
|
8808
9948
|
const timeToCreateFilelist = ((performance.now() - start) / 1e3).toFixed(
|
|
8809
9949
|
5
|
|
8810
9950
|
);
|
|
@@ -8821,10 +9961,10 @@ function uploadCommand(program) {
|
|
|
8821
9961
|
`\u{1F9EE} Filelist created (${filelist.length} ${filelist.length === 1 ? "entry" : "entries"})`
|
|
8822
9962
|
);
|
|
8823
9963
|
console.log(`\u23F1\uFE0F Took: ${timeToCreateFilelist}s`);
|
|
8824
|
-
if (
|
|
9964
|
+
if (options.assumeYes) {
|
|
8825
9965
|
console.log("\u2699\uFE0F Flag: --assume-yes (auto-confirmed)");
|
|
8826
9966
|
}
|
|
8827
|
-
if (!
|
|
9967
|
+
if (!options.assumeYes) {
|
|
8828
9968
|
const shouldContinue = await new Promise((resolve3) => {
|
|
8829
9969
|
const { unmount } = render4(
|
|
8830
9970
|
/* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", children: [
|
|
@@ -8865,7 +10005,7 @@ function uploadCommand(program) {
|
|
|
8865
10005
|
};
|
|
8866
10006
|
process.removeAllListeners("SIGINT");
|
|
8867
10007
|
process.on("SIGINT", handleSigint);
|
|
8868
|
-
const expireUsec =
|
|
10008
|
+
const expireUsec = options.expiration.getTime() * 1e3;
|
|
8869
10009
|
const expirationDate = new Date(expireUsec / 1e3);
|
|
8870
10010
|
const formattedExpiration = expirationDate.toLocaleDateString("en-US", {
|
|
8871
10011
|
year: "numeric",
|
|
@@ -8894,11 +10034,11 @@ function uploadCommand(program) {
|
|
|
8894
10034
|
const formatProgressPercent = () => totalSize > 0 ? (100 * (amountUploaded / totalSize)).toFixed(2) : "0.00";
|
|
8895
10035
|
let filesProcessed = 0;
|
|
8896
10036
|
for (const entry of filelist) {
|
|
8897
|
-
const fileName =
|
|
10037
|
+
const fileName = path7.basename(entry.filename);
|
|
8898
10038
|
const fileProgress = isSingleFile ? `(${formatProgressPercent()}%)` : `(${filesProcessed}/${filelist.length} files, ${formatProgressPercent()}%)`;
|
|
8899
10039
|
spinner.text = `\u{1F4D6} Reading ${fileName}... ${fileProgress}`;
|
|
8900
10040
|
try {
|
|
8901
|
-
const blobData = await
|
|
10041
|
+
const blobData = await fs8.readFile(entry.filename);
|
|
8902
10042
|
if (blobData.length !== entry.sizeBytes) {
|
|
8903
10043
|
throw new Error(
|
|
8904
10044
|
`Size of file ${entry.filename} changed after initial scan. Original size was ${entry.sizeBytes} but it is now ${blobData.length}`
|
|
@@ -8918,7 +10058,7 @@ function uploadCommand(program) {
|
|
|
8918
10058
|
spinner.text = `\u{1F517} Generating commitments for ${fileName}... ${fileProgress}`;
|
|
8919
10059
|
const provider = await getErasureCodingProvider();
|
|
8920
10060
|
const blobCommitments = await generateCommitments(provider, blobData);
|
|
8921
|
-
if (
|
|
10061
|
+
if (options.outputCommitments) {
|
|
8922
10062
|
outputCommitments[entry.filename] = blobCommitments;
|
|
8923
10063
|
}
|
|
8924
10064
|
spinner.text = `\u{1F517} Registering ${fileName} on L1... ${fileProgress}`;
|
|
@@ -8927,7 +10067,7 @@ function uploadCommand(program) {
|
|
|
8927
10067
|
blobName: entry.blobname,
|
|
8928
10068
|
blobMerkleRoot: blobCommitments.blob_merkle_root,
|
|
8929
10069
|
size: blobData.length,
|
|
8930
|
-
expirationMicros:
|
|
10070
|
+
expirationMicros: options.expiration.getTime() * 1e3
|
|
8931
10071
|
});
|
|
8932
10072
|
const registerTransactionHash = pendingRegisterBlobTransaction.hash;
|
|
8933
10073
|
if (!firstTransactionHash) {
|
|
@@ -8950,9 +10090,9 @@ function uploadCommand(program) {
|
|
|
8950
10090
|
process.exit(1);
|
|
8951
10091
|
}
|
|
8952
10092
|
}
|
|
8953
|
-
if (
|
|
8954
|
-
await
|
|
8955
|
-
|
|
10093
|
+
if (options.outputCommitments) {
|
|
10094
|
+
await fs8.writeFile(
|
|
10095
|
+
options.outputCommitments,
|
|
8956
10096
|
JSON.stringify(outputCommitments)
|
|
8957
10097
|
);
|
|
8958
10098
|
}
|
|
@@ -8982,37 +10122,772 @@ function uploadCommand(program) {
|
|
|
8982
10122
|
);
|
|
8983
10123
|
}
|
|
8984
10124
|
|
|
8985
|
-
// src/
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
|
|
10125
|
+
// src/commands/localnet/start.tsx
|
|
10126
|
+
import fs10 from "fs";
|
|
10127
|
+
import path9 from "path";
|
|
10128
|
+
import Dockerode from "dockerode";
|
|
10129
|
+
import { execa } from "execa";
|
|
10130
|
+
import ora3 from "ora";
|
|
10131
|
+
import { parse as parse2, stringify } from "yaml";
|
|
10132
|
+
|
|
10133
|
+
// src/commands/localnet/assets.ts
|
|
10134
|
+
import "fs";
|
|
10135
|
+
import "path";
|
|
10136
|
+
import "url";
|
|
10137
|
+
var hasuraMetadataContent;
|
|
10138
|
+
var nciConfigContent;
|
|
10139
|
+
if (true) {
|
|
10140
|
+
hasuraMetadataContent = (await Promise.resolve().then(() => __toESM(require_hasura_metadata(), 1))).default;
|
|
10141
|
+
nciConfigContent = (await Promise.resolve().then(() => __toESM(require_shelby_internal(), 1))).default;
|
|
10142
|
+
} else {
|
|
10143
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10144
|
+
const __dirname = path8.dirname(__filename);
|
|
10145
|
+
const assetsDir = path8.resolve(__dirname, "../../../assets");
|
|
10146
|
+
hasuraMetadataContent = fs9.readFileSync(
|
|
10147
|
+
path8.join(assetsDir, "hasura_metadata.txt"),
|
|
10148
|
+
"utf-8"
|
|
10149
|
+
);
|
|
10150
|
+
nciConfigContent = fs9.readFileSync(
|
|
10151
|
+
path8.join(assetsDir, "shelby_internal.txt"),
|
|
10152
|
+
"utf-8"
|
|
10153
|
+
);
|
|
10154
|
+
}
|
|
10155
|
+
|
|
10156
|
+
// src/commands/localnet/common.ts
|
|
10157
|
+
var LOCALNET_NAME = "shelby-localnet";
|
|
10158
|
+
var MOUNT_DIR = "/mounted";
|
|
10159
|
+
var debugEnabled = false;
|
|
10160
|
+
function setDebugEnabled(enabled) {
|
|
10161
|
+
debugEnabled = enabled;
|
|
10162
|
+
}
|
|
10163
|
+
function debug(message) {
|
|
10164
|
+
if (debugEnabled) {
|
|
10165
|
+
console.log(`\u{1F50D} ${message}`);
|
|
10166
|
+
}
|
|
10167
|
+
}
|
|
10168
|
+
|
|
10169
|
+
// src/commands/localnet/docker.ts
|
|
10170
|
+
var SHELBY_LOCALNET_NETWORK = "shelby-localnet-network";
|
|
10171
|
+
var restart = "no";
|
|
10172
|
+
var shelbyPostgres = "shelby-postgres";
|
|
10173
|
+
var shelbyAptosLocalnetIndexerApi = "shelby-aptos-localnet-indexer-api";
|
|
10174
|
+
var shelbyAptosLocalnet = "shelby-aptos-localnet";
|
|
10175
|
+
var shelbyNciProcessor = "shelby-nci-processor";
|
|
10176
|
+
var shelbyNciApi = "shelby-nci-api";
|
|
10177
|
+
var shelbyRpc = "shelby-rpc";
|
|
10178
|
+
var corePostgresDatabase = "shelby_aptos_localnet";
|
|
10179
|
+
var nciPostgresDatabase = "postgres";
|
|
10180
|
+
var aptosNodePort = 8080;
|
|
10181
|
+
var mountDirEnvVar = {
|
|
10182
|
+
MOUNT_DIR
|
|
10183
|
+
};
|
|
10184
|
+
function createDockerCompose({
|
|
10185
|
+
hostDataPath,
|
|
10186
|
+
shelbyRepoWithSlash,
|
|
10187
|
+
tags,
|
|
10188
|
+
skipNci,
|
|
10189
|
+
skipRpc,
|
|
10190
|
+
ports,
|
|
10191
|
+
additionalAptosLocalnetArgs
|
|
10192
|
+
}) {
|
|
10193
|
+
const coreHasuraDbString = `postgresql://postgres:postgres@${shelbyPostgres}:${ports.postgres}/${corePostgresDatabase}`;
|
|
10194
|
+
const nciHasuraDbString = `postgresql://postgres:postgres@${shelbyPostgres}:${ports.postgres}/postgres`;
|
|
10195
|
+
const services = {
|
|
10196
|
+
[shelbyPostgres]: {
|
|
10197
|
+
image: "postgres:17",
|
|
10198
|
+
container_name: shelbyPostgres,
|
|
10199
|
+
networks: [SHELBY_LOCALNET_NETWORK],
|
|
10200
|
+
environment: {
|
|
10201
|
+
POSTGRES_HOST_AUTH_METHOD: "trust",
|
|
10202
|
+
PGPORT: ports.postgres.toString(),
|
|
10203
|
+
POSTGRES_DB: corePostgresDatabase
|
|
10204
|
+
},
|
|
10205
|
+
healthcheck: {
|
|
10206
|
+
test: [
|
|
10207
|
+
"CMD",
|
|
10208
|
+
"pg_isready",
|
|
10209
|
+
"-U",
|
|
10210
|
+
"postgres",
|
|
10211
|
+
"-d",
|
|
10212
|
+
corePostgresDatabase
|
|
10213
|
+
],
|
|
10214
|
+
interval: "1s",
|
|
10215
|
+
timeout: "2s",
|
|
10216
|
+
retries: 30,
|
|
10217
|
+
start_period: "30s"
|
|
10218
|
+
},
|
|
10219
|
+
ports: [`${ports.postgres}:${ports.postgres}`],
|
|
10220
|
+
restart,
|
|
10221
|
+
volumes: [`${hostDataPath}/postgres:/var/lib/postgresql/data`]
|
|
10222
|
+
},
|
|
10223
|
+
// Hasura GraphQL API for the core Aptos localnet indexer.
|
|
10224
|
+
[shelbyAptosLocalnetIndexerApi]: createHasuraService(
|
|
10225
|
+
shelbyAptosLocalnetIndexerApi,
|
|
10226
|
+
coreHasuraDbString,
|
|
10227
|
+
ports.coreIndexerApi,
|
|
10228
|
+
{
|
|
10229
|
+
[shelbyPostgres]: {
|
|
10230
|
+
condition: "service_healthy"
|
|
10231
|
+
}
|
|
10232
|
+
},
|
|
10233
|
+
{
|
|
10234
|
+
INDEXER_V2_POSTGRES_URL: coreHasuraDbString
|
|
10235
|
+
},
|
|
10236
|
+
tags.hasura
|
|
10237
|
+
),
|
|
10238
|
+
// Aptos localnet with pre-deployed Shelby contracts.
|
|
10239
|
+
[shelbyAptosLocalnet]: {
|
|
10240
|
+
command: [
|
|
10241
|
+
"--bind-to",
|
|
10242
|
+
"0.0.0.0",
|
|
10243
|
+
// This flag is what causes the CLI to run the processors and apply the Hasura
|
|
10244
|
+
// metadata. It won't run postgres or Hasura itself like normal because of the
|
|
10245
|
+
// --use-host-postgres and --existing-hasura-url flags.
|
|
10246
|
+
"--with-indexer-api",
|
|
10247
|
+
"--use-host-postgres",
|
|
10248
|
+
"--host-postgres-host",
|
|
10249
|
+
// We route via the Docker network, not the host (host.docker.internal).
|
|
10250
|
+
shelbyPostgres,
|
|
10251
|
+
"--host-postgres-port",
|
|
10252
|
+
ports.postgres.toString(),
|
|
10253
|
+
"--postgres-database",
|
|
10254
|
+
corePostgresDatabase,
|
|
10255
|
+
"--existing-hasura-url",
|
|
10256
|
+
`http://${shelbyAptosLocalnetIndexerApi}:${ports.coreIndexerApi}`,
|
|
10257
|
+
"--faucet-port",
|
|
10258
|
+
ports.faucet.toString(),
|
|
10259
|
+
"--txn-stream-port",
|
|
10260
|
+
ports.txnStream.toString(),
|
|
10261
|
+
"--indexer-api-port",
|
|
10262
|
+
ports.coreIndexerApi.toString(),
|
|
10263
|
+
"--ready-server-listen-port",
|
|
10264
|
+
ports.localnetReadiness.toString(),
|
|
10265
|
+
...additionalAptosLocalnetArgs
|
|
10266
|
+
],
|
|
10267
|
+
container_name: shelbyAptosLocalnet,
|
|
10268
|
+
depends_on: {
|
|
10269
|
+
[shelbyAptosLocalnetIndexerApi]: {
|
|
10270
|
+
condition: "service_healthy"
|
|
10271
|
+
},
|
|
10272
|
+
[shelbyPostgres]: {
|
|
10273
|
+
condition: "service_healthy"
|
|
10274
|
+
}
|
|
10275
|
+
},
|
|
10276
|
+
environment: { ...mountDirEnvVar },
|
|
10277
|
+
healthcheck: {
|
|
10278
|
+
test: [
|
|
10279
|
+
"CMD",
|
|
10280
|
+
"curl",
|
|
10281
|
+
"-f",
|
|
10282
|
+
`http://localhost:${ports.localnetReadiness}/`
|
|
10283
|
+
],
|
|
10284
|
+
interval: "1s",
|
|
10285
|
+
timeout: "3s",
|
|
10286
|
+
retries: 60,
|
|
10287
|
+
start_period: "10s"
|
|
10288
|
+
},
|
|
10289
|
+
image: `${shelbyRepoWithSlash}shelby/aptos-localnet:${tags.aptosLocalnet}`,
|
|
10290
|
+
networks: [SHELBY_LOCALNET_NETWORK],
|
|
10291
|
+
ports: [
|
|
10292
|
+
`${aptosNodePort}:${aptosNodePort}`,
|
|
10293
|
+
`${ports.localnetReadiness}:${ports.localnetReadiness}`,
|
|
10294
|
+
`${ports.faucet}:${ports.faucet}`,
|
|
10295
|
+
`${ports.txnStream}:${ports.txnStream}`
|
|
10296
|
+
],
|
|
10297
|
+
restart,
|
|
10298
|
+
volumes: [`${hostDataPath}:${MOUNT_DIR}`]
|
|
10299
|
+
}
|
|
10300
|
+
};
|
|
10301
|
+
if (!skipNci) {
|
|
10302
|
+
services[shelbyNciProcessor] = {
|
|
10303
|
+
command: [
|
|
10304
|
+
"/usr/local/bin/remapping-processor",
|
|
10305
|
+
"--config-path",
|
|
10306
|
+
`${MOUNT_DIR}/nci/shelby_internal.yaml`
|
|
10307
|
+
],
|
|
10308
|
+
container_name: shelbyNciProcessor,
|
|
10309
|
+
depends_on: {
|
|
10310
|
+
[shelbyPostgres]: {
|
|
10311
|
+
condition: "service_healthy"
|
|
10312
|
+
},
|
|
10313
|
+
[shelbyAptosLocalnet]: {
|
|
10314
|
+
condition: "service_healthy"
|
|
10315
|
+
}
|
|
10316
|
+
},
|
|
10317
|
+
environment: { ...mountDirEnvVar },
|
|
10318
|
+
healthcheck: {
|
|
10319
|
+
test: [
|
|
10320
|
+
"CMD-SHELL",
|
|
10321
|
+
`timeout 1 bash -c 'echo > /dev/tcp/localhost/${ports.nciProcessorMetrics}'`
|
|
10322
|
+
],
|
|
10323
|
+
interval: "2s",
|
|
10324
|
+
timeout: "4s",
|
|
10325
|
+
retries: 10,
|
|
10326
|
+
start_period: "10s"
|
|
10327
|
+
},
|
|
10328
|
+
image: `aptoslabs/aptos-nocode-processors:${tags.nciProcessor}`,
|
|
10329
|
+
networks: [SHELBY_LOCALNET_NETWORK],
|
|
10330
|
+
// We don't build the image for arm at the moment, so we force amd64.
|
|
10331
|
+
platform: "linux/amd64",
|
|
10332
|
+
ports: [`${ports.nciProcessorMetrics}:${ports.nciProcessorMetrics}`],
|
|
10333
|
+
restart,
|
|
10334
|
+
volumes: [`${hostDataPath}:${MOUNT_DIR}`]
|
|
10335
|
+
};
|
|
10336
|
+
services[shelbyNciApi] = createHasuraService(
|
|
10337
|
+
shelbyNciApi,
|
|
10338
|
+
nciHasuraDbString,
|
|
10339
|
+
ports.nciIndexerApi,
|
|
10340
|
+
{
|
|
10341
|
+
[shelbyPostgres]: {
|
|
10342
|
+
condition: "service_healthy"
|
|
10343
|
+
},
|
|
10344
|
+
[shelbyAptosLocalnet]: {
|
|
10345
|
+
condition: "service_healthy"
|
|
10346
|
+
},
|
|
10347
|
+
[shelbyNciProcessor]: {
|
|
10348
|
+
condition: "service_healthy"
|
|
10349
|
+
}
|
|
10350
|
+
},
|
|
10351
|
+
{
|
|
10352
|
+
// This corresponds to from_env in the Hasura metadata.
|
|
10353
|
+
PROCESSOR_DATABASE_URL: nciHasuraDbString
|
|
10354
|
+
},
|
|
10355
|
+
tags.hasura
|
|
10356
|
+
);
|
|
10357
|
+
}
|
|
10358
|
+
if (!skipRpc) {
|
|
10359
|
+
services[shelbyRpc] = {
|
|
10360
|
+
container_name: shelbyRpc,
|
|
10361
|
+
depends_on: {
|
|
10362
|
+
// For now this uses its own sqlite database.
|
|
10363
|
+
[shelbyAptosLocalnet]: {
|
|
10364
|
+
condition: "service_healthy"
|
|
10365
|
+
}
|
|
10366
|
+
},
|
|
10367
|
+
environment: {
|
|
10368
|
+
PORT: ports.rpc.toString(),
|
|
10369
|
+
APTOS_LOCAL_NODE_API_URL: `http://${shelbyAptosLocalnet}:${aptosNodePort}/v1`,
|
|
10370
|
+
...mountDirEnvVar
|
|
10371
|
+
},
|
|
10372
|
+
healthcheck: {
|
|
10373
|
+
// TODO: Do a better healthcheck when one is available.
|
|
10374
|
+
test: ["CMD", "curl", "-f", `http://localhost:${ports.rpc}/metrics`],
|
|
10375
|
+
interval: "1s"
|
|
10376
|
+
},
|
|
10377
|
+
image: `${shelbyRepoWithSlash}shelby/rpc:${tags.rpc}`,
|
|
10378
|
+
networks: [SHELBY_LOCALNET_NETWORK],
|
|
10379
|
+
ports: [`${ports.rpc}:${ports.rpc}`],
|
|
10380
|
+
restart,
|
|
10381
|
+
volumes: [`${hostDataPath}/rpc:${MOUNT_DIR}`]
|
|
10382
|
+
};
|
|
10383
|
+
}
|
|
10384
|
+
return {
|
|
10385
|
+
services,
|
|
10386
|
+
networks: {
|
|
10387
|
+
[SHELBY_LOCALNET_NETWORK]: {
|
|
10388
|
+
name: SHELBY_LOCALNET_NETWORK,
|
|
10389
|
+
driver: "bridge"
|
|
10390
|
+
}
|
|
10391
|
+
}
|
|
10392
|
+
};
|
|
10393
|
+
}
|
|
10394
|
+
async function cleanupLocalnet(dockerode) {
|
|
10395
|
+
const labelKey = "com.docker.compose.project";
|
|
10396
|
+
const labelValue = LOCALNET_NAME;
|
|
10397
|
+
const labelFilter = `${labelKey}=${labelValue}`;
|
|
10398
|
+
const filters = JSON.stringify({ label: [labelFilter] });
|
|
10399
|
+
const deletedItems = [];
|
|
10400
|
+
const containers = await dockerode.listContainers({ all: true, filters });
|
|
10401
|
+
for (const info of containers) {
|
|
10402
|
+
debug(`Deleting container ${info.Names.join(",")}...`);
|
|
10403
|
+
const container = await dockerode.getContainer(info.Id);
|
|
10404
|
+
await container.remove({ force: true });
|
|
10405
|
+
debug(`Deleted container ${info.Names.join(",")}`);
|
|
10406
|
+
deletedItems.push(...info.Names);
|
|
10407
|
+
}
|
|
10408
|
+
const networks = await dockerode.listNetworks({ filters });
|
|
10409
|
+
for (const info of networks) {
|
|
10410
|
+
debug(`Deleting network ${info.Name}...`);
|
|
10411
|
+
const network = await dockerode.getNetwork(info.Id);
|
|
10412
|
+
await network.remove();
|
|
10413
|
+
debug(`Deleted network ${info.Name}`);
|
|
10414
|
+
deletedItems.push(info.Name);
|
|
10415
|
+
}
|
|
10416
|
+
return deletedItems;
|
|
10417
|
+
}
|
|
10418
|
+
function createHasuraService(containerName, dbString, port, dependsOn, extraEnvironment, hasuraTag) {
|
|
10419
|
+
return {
|
|
10420
|
+
container_name: containerName,
|
|
10421
|
+
depends_on: dependsOn,
|
|
10422
|
+
environment: {
|
|
10423
|
+
HASURA_GRAPHQL_CONSOLE_ASSETS_DIR: "/srv/console-assets",
|
|
10424
|
+
HASURA_GRAPHQL_DEV_MODE: "true",
|
|
10425
|
+
HASURA_GRAPHQL_ENABLE_CONSOLE: "true",
|
|
10426
|
+
HASURA_GRAPHQL_METADATA_DATABASE_URL: dbString,
|
|
10427
|
+
PG_DATABASE_URL: dbString,
|
|
10428
|
+
HASURA_GRAPHQL_SERVER_PORT: port.toString(),
|
|
10429
|
+
...extraEnvironment
|
|
10430
|
+
},
|
|
10431
|
+
healthcheck: {
|
|
10432
|
+
interval: "1s",
|
|
10433
|
+
retries: 30,
|
|
10434
|
+
start_period: "10s",
|
|
10435
|
+
test: ["CMD", "curl", "-f", `http://localhost:${port}/healthz`],
|
|
10436
|
+
timeout: "3s"
|
|
10437
|
+
},
|
|
10438
|
+
image: `hasura/graphql-engine:${hasuraTag}`,
|
|
10439
|
+
networks: [SHELBY_LOCALNET_NETWORK],
|
|
10440
|
+
ports: [`${port}:${port}`],
|
|
10441
|
+
restart
|
|
10442
|
+
};
|
|
10443
|
+
}
|
|
10444
|
+
|
|
10445
|
+
// src/commands/localnet/hasura.ts
|
|
10446
|
+
async function makeHasuraMetadataRequest(url, type, args) {
|
|
10447
|
+
const metadataUrl = new URL("/v1/metadata", url);
|
|
10448
|
+
const payload = {
|
|
10449
|
+
type,
|
|
10450
|
+
args: args || {}
|
|
10451
|
+
};
|
|
10452
|
+
const response = await fetch(metadataUrl.toString(), {
|
|
10453
|
+
method: "POST",
|
|
10454
|
+
headers: {
|
|
10455
|
+
"Content-Type": "application/json"
|
|
10456
|
+
},
|
|
10457
|
+
body: JSON.stringify(payload)
|
|
10458
|
+
});
|
|
10459
|
+
if (!response.ok) {
|
|
10460
|
+
const responseBody = await response.text();
|
|
10461
|
+
throw new Error(
|
|
10462
|
+
`Hasura metadata request failed: ${response.status} ${response.statusText}
|
|
10463
|
+
Response body: ${responseBody}`
|
|
10464
|
+
);
|
|
10465
|
+
}
|
|
10466
|
+
return await response.json();
|
|
10467
|
+
}
|
|
10468
|
+
async function applyHasuraMetadata(url, metadataContent) {
|
|
10469
|
+
const metadataJson = JSON.parse(metadataContent);
|
|
10470
|
+
const response = await makeHasuraMetadataRequest(
|
|
10471
|
+
url,
|
|
10472
|
+
"replace_metadata",
|
|
10473
|
+
metadataJson
|
|
10474
|
+
);
|
|
10475
|
+
if (response.is_consistent === true) {
|
|
10476
|
+
return;
|
|
10477
|
+
}
|
|
10478
|
+
throw new Error(
|
|
10479
|
+
`Failed to apply Hasura metadata consistently. Response: ${JSON.stringify(response, null, 2)}`
|
|
10480
|
+
);
|
|
10481
|
+
}
|
|
10482
|
+
async function confirmHasuraMetadataApplied(url) {
|
|
10483
|
+
const response = await makeHasuraMetadataRequest(url, "export_metadata");
|
|
10484
|
+
if (response.sources && Array.isArray(response.sources) && response.sources.length > 0) {
|
|
10485
|
+
return;
|
|
10486
|
+
}
|
|
10487
|
+
throw new Error(
|
|
10488
|
+
`Hasura metadata has not been applied yet. Response: ${JSON.stringify(response, null, 2)}`
|
|
10489
|
+
);
|
|
10490
|
+
}
|
|
10491
|
+
async function applyAndConfirmHasuraMetadata(url, metadataContent, maxRetries = 6, retryDelayMs = 2500) {
|
|
10492
|
+
let lastError = null;
|
|
10493
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
8989
10494
|
try {
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
10495
|
+
await applyHasuraMetadata(url, metadataContent);
|
|
10496
|
+
await confirmHasuraMetadataApplied(url);
|
|
10497
|
+
return;
|
|
10498
|
+
} catch (error) {
|
|
10499
|
+
lastError = error;
|
|
10500
|
+
if (attempt < maxRetries) {
|
|
10501
|
+
await new Promise((resolve3) => setTimeout(resolve3, retryDelayMs));
|
|
10502
|
+
}
|
|
8993
10503
|
}
|
|
8994
10504
|
}
|
|
8995
|
-
|
|
8996
|
-
|
|
10505
|
+
throw new Error(
|
|
10506
|
+
`Failed to apply Hasura metadata after ${maxRetries} attempts: ${lastError?.message}`
|
|
10507
|
+
);
|
|
10508
|
+
}
|
|
10509
|
+
|
|
10510
|
+
// src/commands/localnet/start.tsx
|
|
10511
|
+
function parsePort(value) {
|
|
10512
|
+
const port = Number.parseInt(value.trim(), 10);
|
|
10513
|
+
if (Number.isNaN(port)) {
|
|
10514
|
+
console.error(`Invalid port: ${value}`);
|
|
10515
|
+
process.exit(1);
|
|
10516
|
+
}
|
|
10517
|
+
if (port === 0) {
|
|
10518
|
+
console.error("We cannot handle port = 0 right now, sorry!");
|
|
10519
|
+
process.exit(1);
|
|
10520
|
+
}
|
|
10521
|
+
return port;
|
|
10522
|
+
}
|
|
10523
|
+
function localnetStartCommand(program) {
|
|
10524
|
+
program.command("start").description("Start a Shelby localnet (without SPs at the moment)").option("-d, --debug", "Enable debug logging", false).option("-f", "Follow logs after starting", false).option(
|
|
10525
|
+
"--additional-aptos-localnet-args <args>",
|
|
10526
|
+
"Additional arguments to pass to Aptos localnet",
|
|
10527
|
+
""
|
|
10528
|
+
).option(
|
|
10529
|
+
"--data-path <path>",
|
|
10530
|
+
"Directory where localnet data will be stored (default: .shelby location based on global config)",
|
|
10531
|
+
path9.join(path9.dirname(findExistingConfigPath()), "localnet")
|
|
10532
|
+
).option("--reset", "Wipe all existing localnet data before starting", false).option(
|
|
10533
|
+
"--docker-repo <registry>",
|
|
10534
|
+
"Docker registry to use for Shelby images",
|
|
10535
|
+
"ghcr.io"
|
|
10536
|
+
).option(
|
|
10537
|
+
"--aptos-localnet-tag <tag>",
|
|
10538
|
+
"Tag to use for Aptos localnet image (e.g., latest, <commit-hash>)",
|
|
10539
|
+
"latest"
|
|
10540
|
+
).option("--rpc-tag <tag>", "Tag to use for RPC image", "latest").option("--sp-tag <tag>", "Tag to use for Storage Provider image", "latest").option(
|
|
10541
|
+
"--nci-processor-tag <tag>",
|
|
10542
|
+
"Tag to use for No-Code Indexer Processor image",
|
|
10543
|
+
"02b51d2cf5a0609eb04771adfc906457ffad95be"
|
|
10544
|
+
).option("--hasura-tag <tag>", "Tag to use for Hasura image", "v2.48.5-ce").option(
|
|
10545
|
+
"--postgres-port <port>",
|
|
10546
|
+
"Port to use for postgres",
|
|
10547
|
+
parsePort,
|
|
10548
|
+
5433
|
|
10549
|
+
).option(
|
|
10550
|
+
"--faucet-port <port>",
|
|
10551
|
+
"Port to use for Aptos faucet",
|
|
10552
|
+
parsePort,
|
|
10553
|
+
8081
|
|
10554
|
+
).option(
|
|
10555
|
+
"--txn-stream-port <port>",
|
|
10556
|
+
"Port to use for Aptos localnet transaction stream",
|
|
10557
|
+
parsePort,
|
|
10558
|
+
50051
|
|
10559
|
+
).option(
|
|
10560
|
+
"--core-indexer-api-port <port>",
|
|
10561
|
+
"Port to use for Aptos indexer API",
|
|
10562
|
+
parsePort,
|
|
10563
|
+
8090
|
|
10564
|
+
).option(
|
|
10565
|
+
"--localnet-readiness-port <port>",
|
|
10566
|
+
"Port to use for Aptos localnet readiness",
|
|
10567
|
+
parsePort,
|
|
10568
|
+
8070
|
|
10569
|
+
).option(
|
|
10570
|
+
"--nci-processor-metrics-port <port>",
|
|
10571
|
+
"Port to use for no-code indexer processor metrics",
|
|
10572
|
+
parsePort,
|
|
10573
|
+
7654
|
|
10574
|
+
).option(
|
|
10575
|
+
"--nci-indexer-api-port <port>",
|
|
10576
|
+
"Port to use for no-code indexer API",
|
|
10577
|
+
parsePort,
|
|
10578
|
+
8091
|
|
10579
|
+
).option(
|
|
10580
|
+
"--rpc-port <port>",
|
|
10581
|
+
"Port to use for the Shelby RPC",
|
|
10582
|
+
parsePort,
|
|
10583
|
+
8093
|
|
10584
|
+
).option(
|
|
10585
|
+
"--skip-nci",
|
|
10586
|
+
"Skip running the no-code indexer processor + API",
|
|
10587
|
+
false
|
|
10588
|
+
).option("--skip-rpc", "Skip running the Shelby RPC", false).action(async (options) => {
|
|
10589
|
+
const dataPath = path9.resolve(options.dataPath);
|
|
10590
|
+
const shelbyRepo = options.dockerRepo || "";
|
|
10591
|
+
const shelbyRepoWithSlash = shelbyRepo ? `${shelbyRepo}/` : "";
|
|
10592
|
+
setDebugEnabled(options.debug);
|
|
10593
|
+
const spinner = ora3();
|
|
10594
|
+
console.log("\u{1F680} Starting Shelby localnet...\n");
|
|
10595
|
+
console.log(`\u{1F5C2}\uFE0F Data path: ${dataPath}`);
|
|
10596
|
+
if (options.reset) {
|
|
10597
|
+
console.log("\u{1F5D1}\uFE0F Reset flag set - wiping data before starting");
|
|
10598
|
+
}
|
|
10599
|
+
if (shelbyRepo) {
|
|
10600
|
+
console.log(
|
|
10601
|
+
`\u{1F433} Using Docker registry for Shelby images: ${shelbyRepo}`
|
|
10602
|
+
);
|
|
10603
|
+
}
|
|
10604
|
+
console.log("");
|
|
10605
|
+
if (options.reset && fs10.existsSync(dataPath)) {
|
|
10606
|
+
const spinner2 = ora3("Removing existing data...").start();
|
|
10607
|
+
fs10.rmSync(dataPath, { recursive: true, force: true });
|
|
10608
|
+
spinner2.succeed("Data path wiped");
|
|
10609
|
+
}
|
|
10610
|
+
debug(`Creating localnet data in ${dataPath}...`);
|
|
10611
|
+
fs10.mkdirSync(dataPath, { recursive: true });
|
|
10612
|
+
fs10.mkdirSync(path9.join(dataPath, "postgres"), { recursive: true });
|
|
10613
|
+
fs10.mkdirSync(path9.join(dataPath, "nci"), { recursive: true });
|
|
10614
|
+
fs10.mkdirSync(path9.join(dataPath, "rpc", "blobs"), { recursive: true });
|
|
10615
|
+
debug("Directory structure created");
|
|
10616
|
+
const nciConfigPath = path9.join(dataPath, "nci", "shelby_internal.yaml");
|
|
10617
|
+
fs10.writeFileSync(nciConfigPath, nciConfigContent);
|
|
10618
|
+
fs10.writeFileSync(
|
|
10619
|
+
path9.join(dataPath, "nci", "hasura_metadata.json"),
|
|
10620
|
+
hasuraMetadataContent
|
|
10621
|
+
);
|
|
10622
|
+
const nciConfig = parse2(nciConfigContent);
|
|
10623
|
+
nciConfig.common_config.transaction_stream_config.indexer_grpc_data_service_address = `http://${shelbyAptosLocalnet}:${options.txnStreamPort}`;
|
|
10624
|
+
nciConfig.common_config.db_config.postgres_connection_string = `postgresql://postgres:postgres@${shelbyPostgres}:${options.postgresPort}/${nciPostgresDatabase}`;
|
|
10625
|
+
nciConfig.common_config.health_check_port = options.nciProcessorMetricsPort;
|
|
10626
|
+
fs10.writeFileSync(nciConfigPath, stringify(nciConfig, { indent: 2 }));
|
|
10627
|
+
debug("Generating docker-compose.yml...");
|
|
10628
|
+
const additionalAptosLocalnetArgs = options.additionalAptosLocalnetArgs ? options.additionalAptosLocalnetArgs.split(" ") : [];
|
|
10629
|
+
const composeConfig = createDockerCompose({
|
|
10630
|
+
shelbyRepoWithSlash,
|
|
10631
|
+
tags: {
|
|
10632
|
+
aptosLocalnet: options.aptosLocalnetTag,
|
|
10633
|
+
nciProcessor: options.nciProcessorTag,
|
|
10634
|
+
hasura: options.hasuraTag,
|
|
10635
|
+
rpc: options.rpcTag
|
|
10636
|
+
},
|
|
10637
|
+
skipNci: options.skipNci,
|
|
10638
|
+
skipRpc: options.skipRpc,
|
|
10639
|
+
ports: {
|
|
10640
|
+
postgres: options.postgresPort,
|
|
10641
|
+
faucet: options.faucetPort,
|
|
10642
|
+
txnStream: options.txnStreamPort,
|
|
10643
|
+
coreIndexerApi: options.coreIndexerApiPort,
|
|
10644
|
+
localnetReadiness: options.localnetReadinessPort,
|
|
10645
|
+
nciProcessorMetrics: options.nciProcessorMetricsPort,
|
|
10646
|
+
nciIndexerApi: options.nciIndexerApiPort,
|
|
10647
|
+
rpc: options.rpcPort
|
|
10648
|
+
},
|
|
10649
|
+
hostDataPath: dataPath,
|
|
10650
|
+
additionalAptosLocalnetArgs
|
|
10651
|
+
});
|
|
10652
|
+
const dockerComposePath = path9.join(dataPath, "docker-compose.yml");
|
|
10653
|
+
fs10.writeFileSync(
|
|
10654
|
+
dockerComposePath,
|
|
10655
|
+
stringify(composeConfig, { indent: 2 })
|
|
10656
|
+
);
|
|
10657
|
+
debug("docker-compose.yml generated");
|
|
10658
|
+
let dockerode;
|
|
10659
|
+
try {
|
|
10660
|
+
dockerode = new Dockerode();
|
|
10661
|
+
} catch (error) {
|
|
10662
|
+
console.error("Failed to connect to Docker, is it running?");
|
|
10663
|
+
throw error;
|
|
10664
|
+
}
|
|
10665
|
+
try {
|
|
10666
|
+
const deletedItems = await cleanupLocalnet(dockerode);
|
|
10667
|
+
if (deletedItems.length > 0) {
|
|
10668
|
+
debug(
|
|
10669
|
+
`Cleaned up leftover Docker resources from previous localnet: ${deletedItems.join(", ")}`
|
|
10670
|
+
);
|
|
10671
|
+
} else {
|
|
10672
|
+
debug("No leftover Docker resources found");
|
|
10673
|
+
}
|
|
10674
|
+
} catch (error) {
|
|
10675
|
+
console.error("Failed to clean up leftover Docker resources");
|
|
10676
|
+
throw error;
|
|
10677
|
+
}
|
|
10678
|
+
console.log("\nStarting services...");
|
|
10679
|
+
let logsProcess = null;
|
|
10680
|
+
let isShuttingDown = false;
|
|
10681
|
+
const shutdownHandler = async (signal) => {
|
|
10682
|
+
if (isShuttingDown) {
|
|
10683
|
+
console.log("\n\u26A0\uFE0F Second interrupt received, forcing exit...");
|
|
10684
|
+
process.exit(1);
|
|
10685
|
+
}
|
|
10686
|
+
isShuttingDown = true;
|
|
10687
|
+
console.log(`
|
|
10688
|
+
|
|
10689
|
+
\u{1F6D1} Received ${signal}, shutting down gracefully...`);
|
|
10690
|
+
console.log(" (Press Ctrl+C again to force exit)\n");
|
|
10691
|
+
try {
|
|
10692
|
+
if (logsProcess && !logsProcess.killed) {
|
|
10693
|
+
logsProcess.kill("SIGTERM");
|
|
10694
|
+
}
|
|
10695
|
+
await execa(
|
|
10696
|
+
"docker",
|
|
10697
|
+
["compose", "-f", dockerComposePath, "-p", LOCALNET_NAME, "down"],
|
|
10698
|
+
{
|
|
10699
|
+
stdio: "inherit"
|
|
10700
|
+
}
|
|
10701
|
+
);
|
|
10702
|
+
console.log("\n\u2705 Localnet shut down gracefully");
|
|
10703
|
+
process.exit(0);
|
|
10704
|
+
} catch (error) {
|
|
10705
|
+
console.error("\n\u274C Error during shutdown:", error);
|
|
10706
|
+
process.exit(1);
|
|
10707
|
+
}
|
|
10708
|
+
};
|
|
10709
|
+
process.on("SIGINT", () => {
|
|
10710
|
+
if (!isShuttingDown) {
|
|
10711
|
+
shutdownHandler("SIGINT");
|
|
10712
|
+
}
|
|
10713
|
+
});
|
|
10714
|
+
try {
|
|
10715
|
+
await execa(
|
|
10716
|
+
"docker",
|
|
10717
|
+
["compose", "-f", dockerComposePath, "-p", LOCALNET_NAME, "up", "-d"],
|
|
10718
|
+
{
|
|
10719
|
+
stdio: "inherit"
|
|
10720
|
+
}
|
|
10721
|
+
);
|
|
10722
|
+
console.log("\u2714 Services spawned");
|
|
10723
|
+
spinner.start("Waiting up to 2 minutes for services to be healthy...");
|
|
10724
|
+
await execa(
|
|
10725
|
+
"docker",
|
|
10726
|
+
[
|
|
10727
|
+
"compose",
|
|
10728
|
+
"-f",
|
|
10729
|
+
dockerComposePath,
|
|
10730
|
+
"-p",
|
|
10731
|
+
LOCALNET_NAME,
|
|
10732
|
+
"up",
|
|
10733
|
+
"--wait",
|
|
10734
|
+
"--wait-timeout",
|
|
10735
|
+
"120"
|
|
10736
|
+
],
|
|
10737
|
+
{
|
|
10738
|
+
stdio: "pipe"
|
|
10739
|
+
}
|
|
10740
|
+
);
|
|
10741
|
+
spinner.succeed("All services are healthy");
|
|
10742
|
+
} catch (error) {
|
|
10743
|
+
spinner.fail(
|
|
10744
|
+
`Failed to start services, try running: docker compose -p ${LOCALNET_NAME} logs -f`
|
|
10745
|
+
);
|
|
10746
|
+
throw error;
|
|
10747
|
+
}
|
|
10748
|
+
console.log();
|
|
10749
|
+
spinner.start("Running post-startup steps...");
|
|
10750
|
+
if (!options.skipNci) {
|
|
10751
|
+
try {
|
|
10752
|
+
await applyAndConfirmHasuraMetadata(
|
|
10753
|
+
`http://127.0.0.1:${options.nciIndexerApiPort}`,
|
|
10754
|
+
hasuraMetadataContent
|
|
10755
|
+
);
|
|
10756
|
+
} catch (error) {
|
|
10757
|
+
spinner.fail(`Failed to apply Hasura metadata: ${error}`);
|
|
10758
|
+
throw error;
|
|
10759
|
+
}
|
|
10760
|
+
}
|
|
10761
|
+
spinner.succeed("Post-startup steps complete");
|
|
10762
|
+
console.log("\n\u2705 Shelby localnet is running!\n");
|
|
10763
|
+
console.log("\u{1F4CD} Service Endpoints:");
|
|
10764
|
+
console.log(` Aptos REST API: http://127.0.0.1:${aptosNodePort}`);
|
|
10765
|
+
console.log(
|
|
10766
|
+
` Aptos Faucet: http://127.0.0.1:${options.faucetPort}`
|
|
10767
|
+
);
|
|
10768
|
+
if (!options.skipRpc) {
|
|
10769
|
+
console.log(
|
|
10770
|
+
` Shelby RPC Server: http://127.0.0.1:${options.rpcPort}`
|
|
10771
|
+
);
|
|
10772
|
+
}
|
|
10773
|
+
console.log(
|
|
10774
|
+
` Transaction Stream: http://127.0.0.1:${options.txnStreamPort}`
|
|
10775
|
+
);
|
|
10776
|
+
console.log(
|
|
10777
|
+
` Core Indexer API: http://127.0.0.1:${options.coreIndexerApiPort}`
|
|
10778
|
+
);
|
|
10779
|
+
if (!options.skipNci) {
|
|
10780
|
+
console.log(
|
|
10781
|
+
` No-Code Indexer API: http://127.0.0.1:${options.nciIndexerApiPort}`
|
|
10782
|
+
);
|
|
10783
|
+
}
|
|
10784
|
+
console.log(
|
|
10785
|
+
` Postgres: postgresql://postgres:postgres@127.0.0.1:${options.postgresPort}/${corePostgresDatabase}`
|
|
10786
|
+
);
|
|
10787
|
+
console.log("");
|
|
10788
|
+
if (options.f) {
|
|
10789
|
+
console.log("\u{1F4DA} Following logs (press Ctrl+C to stop)...");
|
|
10790
|
+
console.log("");
|
|
10791
|
+
try {
|
|
10792
|
+
logsProcess = execa(
|
|
10793
|
+
"docker",
|
|
10794
|
+
[
|
|
10795
|
+
"compose",
|
|
10796
|
+
"-f",
|
|
10797
|
+
dockerComposePath,
|
|
10798
|
+
"-p",
|
|
10799
|
+
LOCALNET_NAME,
|
|
10800
|
+
"logs",
|
|
10801
|
+
"-f"
|
|
10802
|
+
],
|
|
10803
|
+
{
|
|
10804
|
+
stdio: "inherit",
|
|
10805
|
+
reject: false
|
|
10806
|
+
}
|
|
10807
|
+
);
|
|
10808
|
+
await logsProcess;
|
|
10809
|
+
} catch (error) {
|
|
10810
|
+
console.error("Error while following logs:", error);
|
|
10811
|
+
throw error;
|
|
10812
|
+
}
|
|
10813
|
+
} else {
|
|
10814
|
+
console.log(
|
|
10815
|
+
[
|
|
10816
|
+
"\u{1F4DA} To view logs:",
|
|
10817
|
+
` docker compose -p ${LOCALNET_NAME} logs -f`,
|
|
10818
|
+
"",
|
|
10819
|
+
"\u{1F52C} To check the status:",
|
|
10820
|
+
` docker compose -p ${LOCALNET_NAME} ps --format 'table {{.Name}}\\t{{.State}}'`,
|
|
10821
|
+
"",
|
|
10822
|
+
"\u{1F6D1} To stop:",
|
|
10823
|
+
` docker compose -p ${LOCALNET_NAME} down`,
|
|
10824
|
+
""
|
|
10825
|
+
].join("\n")
|
|
10826
|
+
);
|
|
10827
|
+
}
|
|
10828
|
+
});
|
|
10829
|
+
}
|
|
10830
|
+
|
|
10831
|
+
// src/commands/localnet/index.tsx
|
|
10832
|
+
function localnetCommand(program) {
|
|
10833
|
+
const localnetCmd = program.command("localnet").description("Manage Shelby localnet");
|
|
10834
|
+
localnetStartCommand(localnetCmd);
|
|
10835
|
+
}
|
|
10836
|
+
|
|
10837
|
+
// src/cli.tsx
|
|
10838
|
+
var DEFAULT_CONTEXT = "default_context";
|
|
10839
|
+
var DEFAULT_ACCOUNT = "default_account";
|
|
10840
|
+
function getBaseCommand(defaultContext, defaultAccount) {
|
|
10841
|
+
return new Command().name("shelby").description(
|
|
8997
10842
|
"CLI tool for preparing, uploading, and reading video content on Shelby"
|
|
8998
10843
|
).version(version).option("-v, --verbose", "Enable verbose logging", false).option(
|
|
8999
10844
|
"-C, --config-file <path>",
|
|
9000
|
-
"Path to your Shelby CLI config"
|
|
9001
|
-
"~/.shelby/config.yaml"
|
|
10845
|
+
"Path to your Shelby CLI config (defaults to ~/.shelby/config.yaml unless config_location_behavior in global config is set to 'walk')"
|
|
9002
10846
|
).option(
|
|
9003
10847
|
"-c, --context <name>",
|
|
9004
|
-
"Load endpoints from contexts.<name>",
|
|
9005
|
-
|
|
10848
|
+
"Load endpoints from contexts.<name> (defaults to default_context in config)",
|
|
10849
|
+
defaultContext || "default_context"
|
|
9006
10850
|
).option(
|
|
9007
10851
|
"-a, --account <name>",
|
|
9008
|
-
"Load signing credentials from accounts.<name>",
|
|
9009
|
-
|
|
10852
|
+
"Load signing credentials from accounts.<name> (defaults to default_account in config)",
|
|
10853
|
+
defaultAccount || "default_account"
|
|
10854
|
+
);
|
|
10855
|
+
}
|
|
10856
|
+
function parseConfigFileArg() {
|
|
10857
|
+
const args = process.argv;
|
|
10858
|
+
for (let i = 0; i < args.length; i++) {
|
|
10859
|
+
if (args[i] === "--config-file" || args[i] === "-C") {
|
|
10860
|
+
if (i + 1 >= args.length || args[i + 1].startsWith("-")) {
|
|
10861
|
+
console.error(
|
|
10862
|
+
`\u274C Missing required value for ${args[i]} argument. Please provide a config file path after ${args[i]}.`
|
|
10863
|
+
);
|
|
10864
|
+
process.exit(1);
|
|
10865
|
+
}
|
|
10866
|
+
return args[i + 1];
|
|
10867
|
+
}
|
|
10868
|
+
}
|
|
10869
|
+
return void 0;
|
|
10870
|
+
}
|
|
10871
|
+
function createProgram() {
|
|
10872
|
+
const explicitConfigPath = parseConfigFileArg();
|
|
10873
|
+
let config;
|
|
10874
|
+
try {
|
|
10875
|
+
const configPath = explicitConfigPath || findExistingConfigPath();
|
|
10876
|
+
config = loadConfig(configPath);
|
|
10877
|
+
} catch (_err) {
|
|
10878
|
+
config = void 0;
|
|
10879
|
+
}
|
|
10880
|
+
const program = getBaseCommand(
|
|
10881
|
+
config?.default_context,
|
|
10882
|
+
config?.default_account
|
|
9010
10883
|
);
|
|
9011
10884
|
initCommand(program);
|
|
9012
10885
|
accountCommand(program);
|
|
10886
|
+
configCommand(program);
|
|
9013
10887
|
contextCommand(program);
|
|
9014
10888
|
downloadCommand(program);
|
|
9015
10889
|
faucetCommand(program);
|
|
10890
|
+
localnetCommand(program);
|
|
9016
10891
|
uploadCommand(program);
|
|
9017
10892
|
commitmentCommand(program);
|
|
9018
10893
|
return program;
|
|
@@ -9020,6 +10895,7 @@ function createProgram() {
|
|
|
9020
10895
|
|
|
9021
10896
|
// src/entry.ts
|
|
9022
10897
|
function main() {
|
|
10898
|
+
checkForUpdatesAsync();
|
|
9023
10899
|
const rawArgs = process.argv.slice(2);
|
|
9024
10900
|
const normalizedArgs = rawArgs[0] === "--" ? rawArgs.slice(1) : rawArgs;
|
|
9025
10901
|
createProgram().parse([process.argv[0], process.argv[1], ...normalizedArgs]);
|