@shelby-protocol/cli 0.0.14 → 0.0.15
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 +699 -266
- package/package.json +2 -2
package/bin/entry.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
|
|
6
6
|
// package.json
|
|
7
|
-
var
|
|
7
|
+
var name = "@shelby-protocol/cli";
|
|
8
|
+
var version = "0.0.15";
|
|
8
9
|
|
|
9
10
|
// src/commands/account.tsx
|
|
10
11
|
import readline from "readline";
|
|
@@ -228,10 +229,10 @@ var GraphQLError = class _GraphQLError extends Error {
|
|
|
228
229
|
*/
|
|
229
230
|
constructor(message, ...rawArgs) {
|
|
230
231
|
var _this$nodes, _nodeLocations$, _ref;
|
|
231
|
-
const { nodes, source, positions, path:
|
|
232
|
+
const { nodes, source, positions, path: path7, originalError, extensions } = toNormalizedOptions(rawArgs);
|
|
232
233
|
super(message);
|
|
233
234
|
this.name = "GraphQLError";
|
|
234
|
-
this.path =
|
|
235
|
+
this.path = path7 !== null && path7 !== void 0 ? path7 : void 0;
|
|
235
236
|
this.originalError = originalError !== null && originalError !== void 0 ? originalError : void 0;
|
|
236
237
|
this.nodes = undefinedIfEmpty(
|
|
237
238
|
Array.isArray(nodes) ? nodes : nodes ? [nodes] : void 0
|
|
@@ -1277,9 +1278,9 @@ function formatArray(array, seenValues) {
|
|
|
1277
1278
|
function getObjectTag(object) {
|
|
1278
1279
|
const tag = Object.prototype.toString.call(object).replace(/^\[object /, "").replace(/]$/, "");
|
|
1279
1280
|
if (tag === "Object" && typeof object.constructor === "function") {
|
|
1280
|
-
const
|
|
1281
|
-
if (typeof
|
|
1282
|
-
return
|
|
1281
|
+
const name2 = object.constructor.name;
|
|
1282
|
+
if (typeof name2 === "string" && name2 !== "") {
|
|
1283
|
+
return name2;
|
|
1283
1284
|
}
|
|
1284
1285
|
}
|
|
1285
1286
|
return tag;
|
|
@@ -1326,13 +1327,13 @@ spurious results.`);
|
|
|
1326
1327
|
|
|
1327
1328
|
// ../../node_modules/.pnpm/graphql@16.11.0/node_modules/graphql/language/source.mjs
|
|
1328
1329
|
var Source = class {
|
|
1329
|
-
constructor(body,
|
|
1330
|
+
constructor(body, name2 = "GraphQL request", locationOffset = {
|
|
1330
1331
|
line: 1,
|
|
1331
1332
|
column: 1
|
|
1332
1333
|
}) {
|
|
1333
1334
|
typeof body === "string" || devAssert(false, `Body must be a string. Received: ${inspect(body)}.`);
|
|
1334
1335
|
this.body = body;
|
|
1335
|
-
this.name =
|
|
1336
|
+
this.name = name2;
|
|
1336
1337
|
this.locationOffset = locationOffset;
|
|
1337
1338
|
this.locationOffset.line > 0 || devAssert(
|
|
1338
1339
|
false,
|
|
@@ -1482,14 +1483,14 @@ var Parser = class {
|
|
|
1482
1483
|
});
|
|
1483
1484
|
}
|
|
1484
1485
|
const operation = this.parseOperationType();
|
|
1485
|
-
let
|
|
1486
|
+
let name2;
|
|
1486
1487
|
if (this.peek(TokenKind.NAME)) {
|
|
1487
|
-
|
|
1488
|
+
name2 = this.parseName();
|
|
1488
1489
|
}
|
|
1489
1490
|
return this.node(start, {
|
|
1490
1491
|
kind: Kind.OPERATION_DEFINITION,
|
|
1491
1492
|
operation,
|
|
1492
|
-
name,
|
|
1493
|
+
name: name2,
|
|
1493
1494
|
variableDefinitions: this.parseVariableDefinitions(),
|
|
1494
1495
|
directives: this.parseDirectives(false),
|
|
1495
1496
|
selectionSet: this.parseSelectionSet()
|
|
@@ -1576,17 +1577,17 @@ var Parser = class {
|
|
|
1576
1577
|
const start = this._lexer.token;
|
|
1577
1578
|
const nameOrAlias = this.parseName();
|
|
1578
1579
|
let alias;
|
|
1579
|
-
let
|
|
1580
|
+
let name2;
|
|
1580
1581
|
if (this.expectOptionalToken(TokenKind.COLON)) {
|
|
1581
1582
|
alias = nameOrAlias;
|
|
1582
|
-
|
|
1583
|
+
name2 = this.parseName();
|
|
1583
1584
|
} else {
|
|
1584
|
-
|
|
1585
|
+
name2 = nameOrAlias;
|
|
1585
1586
|
}
|
|
1586
1587
|
return this.node(start, {
|
|
1587
1588
|
kind: Kind.FIELD,
|
|
1588
1589
|
alias,
|
|
1589
|
-
name,
|
|
1590
|
+
name: name2,
|
|
1590
1591
|
arguments: this.parseArguments(false),
|
|
1591
1592
|
directives: this.parseDirectives(false),
|
|
1592
1593
|
selectionSet: this.peek(TokenKind.BRACE_L) ? this.parseSelectionSet() : void 0
|
|
@@ -1604,11 +1605,11 @@ var Parser = class {
|
|
|
1604
1605
|
*/
|
|
1605
1606
|
parseArgument(isConst = false) {
|
|
1606
1607
|
const start = this._lexer.token;
|
|
1607
|
-
const
|
|
1608
|
+
const name2 = this.parseName();
|
|
1608
1609
|
this.expectToken(TokenKind.COLON);
|
|
1609
1610
|
return this.node(start, {
|
|
1610
1611
|
kind: Kind.ARGUMENT,
|
|
1611
|
-
name,
|
|
1612
|
+
name: name2,
|
|
1612
1613
|
value: this.parseValueLiteral(isConst)
|
|
1613
1614
|
});
|
|
1614
1615
|
}
|
|
@@ -1803,11 +1804,11 @@ var Parser = class {
|
|
|
1803
1804
|
*/
|
|
1804
1805
|
parseObjectField(isConst) {
|
|
1805
1806
|
const start = this._lexer.token;
|
|
1806
|
-
const
|
|
1807
|
+
const name2 = this.parseName();
|
|
1807
1808
|
this.expectToken(TokenKind.COLON);
|
|
1808
1809
|
return this.node(start, {
|
|
1809
1810
|
kind: Kind.OBJECT_FIELD,
|
|
1810
|
-
name,
|
|
1811
|
+
name: name2,
|
|
1811
1812
|
value: this.parseValueLiteral(isConst)
|
|
1812
1813
|
});
|
|
1813
1814
|
}
|
|
@@ -1931,12 +1932,12 @@ var Parser = class {
|
|
|
1931
1932
|
const start = this._lexer.token;
|
|
1932
1933
|
const description = this.parseDescription();
|
|
1933
1934
|
this.expectKeyword("scalar");
|
|
1934
|
-
const
|
|
1935
|
+
const name2 = this.parseName();
|
|
1935
1936
|
const directives = this.parseConstDirectives();
|
|
1936
1937
|
return this.node(start, {
|
|
1937
1938
|
kind: Kind.SCALAR_TYPE_DEFINITION,
|
|
1938
1939
|
description,
|
|
1939
|
-
name,
|
|
1940
|
+
name: name2,
|
|
1940
1941
|
directives
|
|
1941
1942
|
});
|
|
1942
1943
|
}
|
|
@@ -1949,14 +1950,14 @@ var Parser = class {
|
|
|
1949
1950
|
const start = this._lexer.token;
|
|
1950
1951
|
const description = this.parseDescription();
|
|
1951
1952
|
this.expectKeyword("type");
|
|
1952
|
-
const
|
|
1953
|
+
const name2 = this.parseName();
|
|
1953
1954
|
const interfaces = this.parseImplementsInterfaces();
|
|
1954
1955
|
const directives = this.parseConstDirectives();
|
|
1955
1956
|
const fields = this.parseFieldsDefinition();
|
|
1956
1957
|
return this.node(start, {
|
|
1957
1958
|
kind: Kind.OBJECT_TYPE_DEFINITION,
|
|
1958
1959
|
description,
|
|
1959
|
-
name,
|
|
1960
|
+
name: name2,
|
|
1960
1961
|
interfaces,
|
|
1961
1962
|
directives,
|
|
1962
1963
|
fields
|
|
@@ -1989,7 +1990,7 @@ var Parser = class {
|
|
|
1989
1990
|
parseFieldDefinition() {
|
|
1990
1991
|
const start = this._lexer.token;
|
|
1991
1992
|
const description = this.parseDescription();
|
|
1992
|
-
const
|
|
1993
|
+
const name2 = this.parseName();
|
|
1993
1994
|
const args = this.parseArgumentDefs();
|
|
1994
1995
|
this.expectToken(TokenKind.COLON);
|
|
1995
1996
|
const type = this.parseTypeReference();
|
|
@@ -1997,7 +1998,7 @@ var Parser = class {
|
|
|
1997
1998
|
return this.node(start, {
|
|
1998
1999
|
kind: Kind.FIELD_DEFINITION,
|
|
1999
2000
|
description,
|
|
2000
|
-
name,
|
|
2001
|
+
name: name2,
|
|
2001
2002
|
arguments: args,
|
|
2002
2003
|
type,
|
|
2003
2004
|
directives
|
|
@@ -2020,7 +2021,7 @@ var Parser = class {
|
|
|
2020
2021
|
parseInputValueDef() {
|
|
2021
2022
|
const start = this._lexer.token;
|
|
2022
2023
|
const description = this.parseDescription();
|
|
2023
|
-
const
|
|
2024
|
+
const name2 = this.parseName();
|
|
2024
2025
|
this.expectToken(TokenKind.COLON);
|
|
2025
2026
|
const type = this.parseTypeReference();
|
|
2026
2027
|
let defaultValue;
|
|
@@ -2031,7 +2032,7 @@ var Parser = class {
|
|
|
2031
2032
|
return this.node(start, {
|
|
2032
2033
|
kind: Kind.INPUT_VALUE_DEFINITION,
|
|
2033
2034
|
description,
|
|
2034
|
-
name,
|
|
2035
|
+
name: name2,
|
|
2035
2036
|
type,
|
|
2036
2037
|
defaultValue,
|
|
2037
2038
|
directives
|
|
@@ -2045,14 +2046,14 @@ var Parser = class {
|
|
|
2045
2046
|
const start = this._lexer.token;
|
|
2046
2047
|
const description = this.parseDescription();
|
|
2047
2048
|
this.expectKeyword("interface");
|
|
2048
|
-
const
|
|
2049
|
+
const name2 = this.parseName();
|
|
2049
2050
|
const interfaces = this.parseImplementsInterfaces();
|
|
2050
2051
|
const directives = this.parseConstDirectives();
|
|
2051
2052
|
const fields = this.parseFieldsDefinition();
|
|
2052
2053
|
return this.node(start, {
|
|
2053
2054
|
kind: Kind.INTERFACE_TYPE_DEFINITION,
|
|
2054
2055
|
description,
|
|
2055
|
-
name,
|
|
2056
|
+
name: name2,
|
|
2056
2057
|
interfaces,
|
|
2057
2058
|
directives,
|
|
2058
2059
|
fields
|
|
@@ -2066,13 +2067,13 @@ var Parser = class {
|
|
|
2066
2067
|
const start = this._lexer.token;
|
|
2067
2068
|
const description = this.parseDescription();
|
|
2068
2069
|
this.expectKeyword("union");
|
|
2069
|
-
const
|
|
2070
|
+
const name2 = this.parseName();
|
|
2070
2071
|
const directives = this.parseConstDirectives();
|
|
2071
2072
|
const types = this.parseUnionMemberTypes();
|
|
2072
2073
|
return this.node(start, {
|
|
2073
2074
|
kind: Kind.UNION_TYPE_DEFINITION,
|
|
2074
2075
|
description,
|
|
2075
|
-
name,
|
|
2076
|
+
name: name2,
|
|
2076
2077
|
directives,
|
|
2077
2078
|
types
|
|
2078
2079
|
});
|
|
@@ -2093,13 +2094,13 @@ var Parser = class {
|
|
|
2093
2094
|
const start = this._lexer.token;
|
|
2094
2095
|
const description = this.parseDescription();
|
|
2095
2096
|
this.expectKeyword("enum");
|
|
2096
|
-
const
|
|
2097
|
+
const name2 = this.parseName();
|
|
2097
2098
|
const directives = this.parseConstDirectives();
|
|
2098
2099
|
const values = this.parseEnumValuesDefinition();
|
|
2099
2100
|
return this.node(start, {
|
|
2100
2101
|
kind: Kind.ENUM_TYPE_DEFINITION,
|
|
2101
2102
|
description,
|
|
2102
|
-
name,
|
|
2103
|
+
name: name2,
|
|
2103
2104
|
directives,
|
|
2104
2105
|
values
|
|
2105
2106
|
});
|
|
@@ -2122,12 +2123,12 @@ var Parser = class {
|
|
|
2122
2123
|
parseEnumValueDefinition() {
|
|
2123
2124
|
const start = this._lexer.token;
|
|
2124
2125
|
const description = this.parseDescription();
|
|
2125
|
-
const
|
|
2126
|
+
const name2 = this.parseEnumValueName();
|
|
2126
2127
|
const directives = this.parseConstDirectives();
|
|
2127
2128
|
return this.node(start, {
|
|
2128
2129
|
kind: Kind.ENUM_VALUE_DEFINITION,
|
|
2129
2130
|
description,
|
|
2130
|
-
name,
|
|
2131
|
+
name: name2,
|
|
2131
2132
|
directives
|
|
2132
2133
|
});
|
|
2133
2134
|
}
|
|
@@ -2154,13 +2155,13 @@ var Parser = class {
|
|
|
2154
2155
|
const start = this._lexer.token;
|
|
2155
2156
|
const description = this.parseDescription();
|
|
2156
2157
|
this.expectKeyword("input");
|
|
2157
|
-
const
|
|
2158
|
+
const name2 = this.parseName();
|
|
2158
2159
|
const directives = this.parseConstDirectives();
|
|
2159
2160
|
const fields = this.parseInputFieldsDefinition();
|
|
2160
2161
|
return this.node(start, {
|
|
2161
2162
|
kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
|
2162
2163
|
description,
|
|
2163
|
-
name,
|
|
2164
|
+
name: name2,
|
|
2164
2165
|
directives,
|
|
2165
2166
|
fields
|
|
2166
2167
|
});
|
|
@@ -2246,14 +2247,14 @@ var Parser = class {
|
|
|
2246
2247
|
const start = this._lexer.token;
|
|
2247
2248
|
this.expectKeyword("extend");
|
|
2248
2249
|
this.expectKeyword("scalar");
|
|
2249
|
-
const
|
|
2250
|
+
const name2 = this.parseName();
|
|
2250
2251
|
const directives = this.parseConstDirectives();
|
|
2251
2252
|
if (directives.length === 0) {
|
|
2252
2253
|
throw this.unexpected();
|
|
2253
2254
|
}
|
|
2254
2255
|
return this.node(start, {
|
|
2255
2256
|
kind: Kind.SCALAR_TYPE_EXTENSION,
|
|
2256
|
-
name,
|
|
2257
|
+
name: name2,
|
|
2257
2258
|
directives
|
|
2258
2259
|
});
|
|
2259
2260
|
}
|
|
@@ -2267,7 +2268,7 @@ var Parser = class {
|
|
|
2267
2268
|
const start = this._lexer.token;
|
|
2268
2269
|
this.expectKeyword("extend");
|
|
2269
2270
|
this.expectKeyword("type");
|
|
2270
|
-
const
|
|
2271
|
+
const name2 = this.parseName();
|
|
2271
2272
|
const interfaces = this.parseImplementsInterfaces();
|
|
2272
2273
|
const directives = this.parseConstDirectives();
|
|
2273
2274
|
const fields = this.parseFieldsDefinition();
|
|
@@ -2276,7 +2277,7 @@ var Parser = class {
|
|
|
2276
2277
|
}
|
|
2277
2278
|
return this.node(start, {
|
|
2278
2279
|
kind: Kind.OBJECT_TYPE_EXTENSION,
|
|
2279
|
-
name,
|
|
2280
|
+
name: name2,
|
|
2280
2281
|
interfaces,
|
|
2281
2282
|
directives,
|
|
2282
2283
|
fields
|
|
@@ -2292,7 +2293,7 @@ var Parser = class {
|
|
|
2292
2293
|
const start = this._lexer.token;
|
|
2293
2294
|
this.expectKeyword("extend");
|
|
2294
2295
|
this.expectKeyword("interface");
|
|
2295
|
-
const
|
|
2296
|
+
const name2 = this.parseName();
|
|
2296
2297
|
const interfaces = this.parseImplementsInterfaces();
|
|
2297
2298
|
const directives = this.parseConstDirectives();
|
|
2298
2299
|
const fields = this.parseFieldsDefinition();
|
|
@@ -2301,7 +2302,7 @@ var Parser = class {
|
|
|
2301
2302
|
}
|
|
2302
2303
|
return this.node(start, {
|
|
2303
2304
|
kind: Kind.INTERFACE_TYPE_EXTENSION,
|
|
2304
|
-
name,
|
|
2305
|
+
name: name2,
|
|
2305
2306
|
interfaces,
|
|
2306
2307
|
directives,
|
|
2307
2308
|
fields
|
|
@@ -2316,7 +2317,7 @@ var Parser = class {
|
|
|
2316
2317
|
const start = this._lexer.token;
|
|
2317
2318
|
this.expectKeyword("extend");
|
|
2318
2319
|
this.expectKeyword("union");
|
|
2319
|
-
const
|
|
2320
|
+
const name2 = this.parseName();
|
|
2320
2321
|
const directives = this.parseConstDirectives();
|
|
2321
2322
|
const types = this.parseUnionMemberTypes();
|
|
2322
2323
|
if (directives.length === 0 && types.length === 0) {
|
|
@@ -2324,7 +2325,7 @@ var Parser = class {
|
|
|
2324
2325
|
}
|
|
2325
2326
|
return this.node(start, {
|
|
2326
2327
|
kind: Kind.UNION_TYPE_EXTENSION,
|
|
2327
|
-
name,
|
|
2328
|
+
name: name2,
|
|
2328
2329
|
directives,
|
|
2329
2330
|
types
|
|
2330
2331
|
});
|
|
@@ -2338,7 +2339,7 @@ var Parser = class {
|
|
|
2338
2339
|
const start = this._lexer.token;
|
|
2339
2340
|
this.expectKeyword("extend");
|
|
2340
2341
|
this.expectKeyword("enum");
|
|
2341
|
-
const
|
|
2342
|
+
const name2 = this.parseName();
|
|
2342
2343
|
const directives = this.parseConstDirectives();
|
|
2343
2344
|
const values = this.parseEnumValuesDefinition();
|
|
2344
2345
|
if (directives.length === 0 && values.length === 0) {
|
|
@@ -2346,7 +2347,7 @@ var Parser = class {
|
|
|
2346
2347
|
}
|
|
2347
2348
|
return this.node(start, {
|
|
2348
2349
|
kind: Kind.ENUM_TYPE_EXTENSION,
|
|
2349
|
-
name,
|
|
2350
|
+
name: name2,
|
|
2350
2351
|
directives,
|
|
2351
2352
|
values
|
|
2352
2353
|
});
|
|
@@ -2360,7 +2361,7 @@ var Parser = class {
|
|
|
2360
2361
|
const start = this._lexer.token;
|
|
2361
2362
|
this.expectKeyword("extend");
|
|
2362
2363
|
this.expectKeyword("input");
|
|
2363
|
-
const
|
|
2364
|
+
const name2 = this.parseName();
|
|
2364
2365
|
const directives = this.parseConstDirectives();
|
|
2365
2366
|
const fields = this.parseInputFieldsDefinition();
|
|
2366
2367
|
if (directives.length === 0 && fields.length === 0) {
|
|
@@ -2368,7 +2369,7 @@ var Parser = class {
|
|
|
2368
2369
|
}
|
|
2369
2370
|
return this.node(start, {
|
|
2370
2371
|
kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,
|
|
2371
|
-
name,
|
|
2372
|
+
name: name2,
|
|
2372
2373
|
directives,
|
|
2373
2374
|
fields
|
|
2374
2375
|
});
|
|
@@ -2384,7 +2385,7 @@ var Parser = class {
|
|
|
2384
2385
|
const description = this.parseDescription();
|
|
2385
2386
|
this.expectKeyword("directive");
|
|
2386
2387
|
this.expectToken(TokenKind.AT);
|
|
2387
|
-
const
|
|
2388
|
+
const name2 = this.parseName();
|
|
2388
2389
|
const args = this.parseArgumentDefs();
|
|
2389
2390
|
const repeatable = this.expectOptionalKeyword("repeatable");
|
|
2390
2391
|
this.expectKeyword("on");
|
|
@@ -2392,7 +2393,7 @@ var Parser = class {
|
|
|
2392
2393
|
return this.node(start, {
|
|
2393
2394
|
kind: Kind.DIRECTIVE_DEFINITION,
|
|
2394
2395
|
description,
|
|
2395
|
-
name,
|
|
2396
|
+
name: name2,
|
|
2396
2397
|
arguments: args,
|
|
2397
2398
|
repeatable,
|
|
2398
2399
|
locations
|
|
@@ -2435,9 +2436,9 @@ var Parser = class {
|
|
|
2435
2436
|
*/
|
|
2436
2437
|
parseDirectiveLocation() {
|
|
2437
2438
|
const start = this._lexer.token;
|
|
2438
|
-
const
|
|
2439
|
-
if (Object.prototype.hasOwnProperty.call(DirectiveLocation,
|
|
2440
|
-
return
|
|
2439
|
+
const name2 = this.parseName();
|
|
2440
|
+
if (Object.prototype.hasOwnProperty.call(DirectiveLocation, name2.value)) {
|
|
2441
|
+
return name2;
|
|
2441
2442
|
}
|
|
2442
2443
|
throw this.unexpected(start);
|
|
2443
2444
|
}
|
|
@@ -2799,14 +2800,14 @@ function visit(root, visitor, visitorKeys = QueryDocumentKeys) {
|
|
|
2799
2800
|
let node = root;
|
|
2800
2801
|
let key = void 0;
|
|
2801
2802
|
let parent = void 0;
|
|
2802
|
-
const
|
|
2803
|
+
const path7 = [];
|
|
2803
2804
|
const ancestors = [];
|
|
2804
2805
|
do {
|
|
2805
2806
|
index++;
|
|
2806
2807
|
const isLeaving = index === keys.length;
|
|
2807
2808
|
const isEdited = isLeaving && edits.length !== 0;
|
|
2808
2809
|
if (isLeaving) {
|
|
2809
|
-
key = ancestors.length === 0 ? void 0 :
|
|
2810
|
+
key = ancestors.length === 0 ? void 0 : path7[path7.length - 1];
|
|
2810
2811
|
node = parent;
|
|
2811
2812
|
parent = ancestors.pop();
|
|
2812
2813
|
if (isEdited) {
|
|
@@ -2840,20 +2841,20 @@ function visit(root, visitor, visitorKeys = QueryDocumentKeys) {
|
|
|
2840
2841
|
if (node === null || node === void 0) {
|
|
2841
2842
|
continue;
|
|
2842
2843
|
}
|
|
2843
|
-
|
|
2844
|
+
path7.push(key);
|
|
2844
2845
|
}
|
|
2845
2846
|
let result;
|
|
2846
2847
|
if (!Array.isArray(node)) {
|
|
2847
2848
|
var _enterLeaveMap$get, _enterLeaveMap$get2;
|
|
2848
2849
|
isNode(node) || devAssert(false, `Invalid AST Node: ${inspect(node)}.`);
|
|
2849
2850
|
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,
|
|
2851
|
+
result = visitFn === null || visitFn === void 0 ? void 0 : visitFn.call(visitor, node, key, parent, path7, ancestors);
|
|
2851
2852
|
if (result === BREAK) {
|
|
2852
2853
|
break;
|
|
2853
2854
|
}
|
|
2854
2855
|
if (result === false) {
|
|
2855
2856
|
if (!isLeaving) {
|
|
2856
|
-
|
|
2857
|
+
path7.pop();
|
|
2857
2858
|
continue;
|
|
2858
2859
|
}
|
|
2859
2860
|
} else if (result !== void 0) {
|
|
@@ -2862,7 +2863,7 @@ function visit(root, visitor, visitorKeys = QueryDocumentKeys) {
|
|
|
2862
2863
|
if (isNode(result)) {
|
|
2863
2864
|
node = result;
|
|
2864
2865
|
} else {
|
|
2865
|
-
|
|
2866
|
+
path7.pop();
|
|
2866
2867
|
continue;
|
|
2867
2868
|
}
|
|
2868
2869
|
}
|
|
@@ -2872,7 +2873,7 @@ function visit(root, visitor, visitorKeys = QueryDocumentKeys) {
|
|
|
2872
2873
|
edits.push([key, node]);
|
|
2873
2874
|
}
|
|
2874
2875
|
if (isLeaving) {
|
|
2875
|
-
|
|
2876
|
+
path7.pop();
|
|
2876
2877
|
} else {
|
|
2877
2878
|
var _node$kind;
|
|
2878
2879
|
stack = {
|
|
@@ -2950,8 +2951,8 @@ var printDocASTReducer = {
|
|
|
2950
2951
|
leave: ({ selections }) => block(selections)
|
|
2951
2952
|
},
|
|
2952
2953
|
Field: {
|
|
2953
|
-
leave({ alias, name, arguments: args, directives, selectionSet }) {
|
|
2954
|
-
const prefix = wrap("", alias, ": ") +
|
|
2954
|
+
leave({ alias, name: name2, arguments: args, directives, selectionSet }) {
|
|
2955
|
+
const prefix = wrap("", alias, ": ") + name2;
|
|
2955
2956
|
let argsLine = prefix + wrap("(", join(args, ", "), ")");
|
|
2956
2957
|
if (argsLine.length > MAX_LINE_LENGTH) {
|
|
2957
2958
|
argsLine = prefix + wrap("(\n", indent(join(args, "\n")), "\n)");
|
|
@@ -2960,11 +2961,11 @@ var printDocASTReducer = {
|
|
|
2960
2961
|
}
|
|
2961
2962
|
},
|
|
2962
2963
|
Argument: {
|
|
2963
|
-
leave: ({ name, value }) =>
|
|
2964
|
+
leave: ({ name: name2, value }) => name2 + ": " + value
|
|
2964
2965
|
},
|
|
2965
2966
|
// Fragments
|
|
2966
2967
|
FragmentSpread: {
|
|
2967
|
-
leave: ({ name, directives }) => "..." +
|
|
2968
|
+
leave: ({ name: name2, directives }) => "..." + name2 + wrap(" ", join(directives, " "))
|
|
2968
2969
|
},
|
|
2969
2970
|
InlineFragment: {
|
|
2970
2971
|
leave: ({ typeCondition, directives, selectionSet }) => join(
|
|
@@ -2978,9 +2979,9 @@ var printDocASTReducer = {
|
|
|
2978
2979
|
)
|
|
2979
2980
|
},
|
|
2980
2981
|
FragmentDefinition: {
|
|
2981
|
-
leave: ({ name, typeCondition, variableDefinitions, directives, selectionSet }) => (
|
|
2982
|
+
leave: ({ name: name2, typeCondition, variableDefinitions, directives, selectionSet }) => (
|
|
2982
2983
|
// or removed in the future.
|
|
2983
|
-
`fragment ${
|
|
2984
|
+
`fragment ${name2}${wrap("(", join(variableDefinitions, ", "), ")")} on ${typeCondition} ${wrap("", join(directives, " "), " ")}` + selectionSet
|
|
2984
2985
|
)
|
|
2985
2986
|
},
|
|
2986
2987
|
// Value
|
|
@@ -3009,15 +3010,15 @@ var printDocASTReducer = {
|
|
|
3009
3010
|
leave: ({ fields }) => "{" + join(fields, ", ") + "}"
|
|
3010
3011
|
},
|
|
3011
3012
|
ObjectField: {
|
|
3012
|
-
leave: ({ name, value }) =>
|
|
3013
|
+
leave: ({ name: name2, value }) => name2 + ": " + value
|
|
3013
3014
|
},
|
|
3014
3015
|
// Directive
|
|
3015
3016
|
Directive: {
|
|
3016
|
-
leave: ({ name, arguments: args }) => "@" +
|
|
3017
|
+
leave: ({ name: name2, arguments: args }) => "@" + name2 + wrap("(", join(args, ", "), ")")
|
|
3017
3018
|
},
|
|
3018
3019
|
// Type
|
|
3019
3020
|
NamedType: {
|
|
3020
|
-
leave: ({ name }) =>
|
|
3021
|
+
leave: ({ name: name2 }) => name2
|
|
3021
3022
|
},
|
|
3022
3023
|
ListType: {
|
|
3023
3024
|
leave: ({ type }) => "[" + type + "]"
|
|
@@ -3033,13 +3034,13 @@ var printDocASTReducer = {
|
|
|
3033
3034
|
leave: ({ operation, type }) => operation + ": " + type
|
|
3034
3035
|
},
|
|
3035
3036
|
ScalarTypeDefinition: {
|
|
3036
|
-
leave: ({ description, name, directives }) => wrap("", description, "\n") + join(["scalar",
|
|
3037
|
+
leave: ({ description, name: name2, directives }) => wrap("", description, "\n") + join(["scalar", name2, join(directives, " ")], " ")
|
|
3037
3038
|
},
|
|
3038
3039
|
ObjectTypeDefinition: {
|
|
3039
|
-
leave: ({ description, name, interfaces, directives, fields }) => wrap("", description, "\n") + join(
|
|
3040
|
+
leave: ({ description, name: name2, interfaces, directives, fields }) => wrap("", description, "\n") + join(
|
|
3040
3041
|
[
|
|
3041
3042
|
"type",
|
|
3042
|
-
|
|
3043
|
+
name2,
|
|
3043
3044
|
wrap("implements ", join(interfaces, " & ")),
|
|
3044
3045
|
join(directives, " "),
|
|
3045
3046
|
block(fields)
|
|
@@ -3048,19 +3049,19 @@ var printDocASTReducer = {
|
|
|
3048
3049
|
)
|
|
3049
3050
|
},
|
|
3050
3051
|
FieldDefinition: {
|
|
3051
|
-
leave: ({ description, name, arguments: args, type, directives }) => wrap("", description, "\n") +
|
|
3052
|
+
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
3053
|
},
|
|
3053
3054
|
InputValueDefinition: {
|
|
3054
|
-
leave: ({ description, name, type, defaultValue, directives }) => wrap("", description, "\n") + join(
|
|
3055
|
-
[
|
|
3055
|
+
leave: ({ description, name: name2, type, defaultValue, directives }) => wrap("", description, "\n") + join(
|
|
3056
|
+
[name2 + ": " + type, wrap("= ", defaultValue), join(directives, " ")],
|
|
3056
3057
|
" "
|
|
3057
3058
|
)
|
|
3058
3059
|
},
|
|
3059
3060
|
InterfaceTypeDefinition: {
|
|
3060
|
-
leave: ({ description, name, interfaces, directives, fields }) => wrap("", description, "\n") + join(
|
|
3061
|
+
leave: ({ description, name: name2, interfaces, directives, fields }) => wrap("", description, "\n") + join(
|
|
3061
3062
|
[
|
|
3062
3063
|
"interface",
|
|
3063
|
-
|
|
3064
|
+
name2,
|
|
3064
3065
|
wrap("implements ", join(interfaces, " & ")),
|
|
3065
3066
|
join(directives, " "),
|
|
3066
3067
|
block(fields)
|
|
@@ -3069,22 +3070,22 @@ var printDocASTReducer = {
|
|
|
3069
3070
|
)
|
|
3070
3071
|
},
|
|
3071
3072
|
UnionTypeDefinition: {
|
|
3072
|
-
leave: ({ description, name, directives, types }) => wrap("", description, "\n") + join(
|
|
3073
|
-
["union",
|
|
3073
|
+
leave: ({ description, name: name2, directives, types }) => wrap("", description, "\n") + join(
|
|
3074
|
+
["union", name2, join(directives, " "), wrap("= ", join(types, " | "))],
|
|
3074
3075
|
" "
|
|
3075
3076
|
)
|
|
3076
3077
|
},
|
|
3077
3078
|
EnumTypeDefinition: {
|
|
3078
|
-
leave: ({ description, name, directives, values }) => wrap("", description, "\n") + join(["enum",
|
|
3079
|
+
leave: ({ description, name: name2, directives, values }) => wrap("", description, "\n") + join(["enum", name2, join(directives, " "), block(values)], " ")
|
|
3079
3080
|
},
|
|
3080
3081
|
EnumValueDefinition: {
|
|
3081
|
-
leave: ({ description, name, directives }) => wrap("", description, "\n") + join([
|
|
3082
|
+
leave: ({ description, name: name2, directives }) => wrap("", description, "\n") + join([name2, join(directives, " ")], " ")
|
|
3082
3083
|
},
|
|
3083
3084
|
InputObjectTypeDefinition: {
|
|
3084
|
-
leave: ({ description, name, directives, fields }) => wrap("", description, "\n") + join(["input",
|
|
3085
|
+
leave: ({ description, name: name2, directives, fields }) => wrap("", description, "\n") + join(["input", name2, join(directives, " "), block(fields)], " ")
|
|
3085
3086
|
},
|
|
3086
3087
|
DirectiveDefinition: {
|
|
3087
|
-
leave: ({ description, name, arguments: args, repeatable, locations }) => wrap("", description, "\n") + "directive @" +
|
|
3088
|
+
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
3089
|
},
|
|
3089
3090
|
SchemaExtension: {
|
|
3090
3091
|
leave: ({ directives, operationTypes }) => join(
|
|
@@ -3093,13 +3094,13 @@ var printDocASTReducer = {
|
|
|
3093
3094
|
)
|
|
3094
3095
|
},
|
|
3095
3096
|
ScalarTypeExtension: {
|
|
3096
|
-
leave: ({ name, directives }) => join(["extend scalar",
|
|
3097
|
+
leave: ({ name: name2, directives }) => join(["extend scalar", name2, join(directives, " ")], " ")
|
|
3097
3098
|
},
|
|
3098
3099
|
ObjectTypeExtension: {
|
|
3099
|
-
leave: ({ name, interfaces, directives, fields }) => join(
|
|
3100
|
+
leave: ({ name: name2, interfaces, directives, fields }) => join(
|
|
3100
3101
|
[
|
|
3101
3102
|
"extend type",
|
|
3102
|
-
|
|
3103
|
+
name2,
|
|
3103
3104
|
wrap("implements ", join(interfaces, " & ")),
|
|
3104
3105
|
join(directives, " "),
|
|
3105
3106
|
block(fields)
|
|
@@ -3108,10 +3109,10 @@ var printDocASTReducer = {
|
|
|
3108
3109
|
)
|
|
3109
3110
|
},
|
|
3110
3111
|
InterfaceTypeExtension: {
|
|
3111
|
-
leave: ({ name, interfaces, directives, fields }) => join(
|
|
3112
|
+
leave: ({ name: name2, interfaces, directives, fields }) => join(
|
|
3112
3113
|
[
|
|
3113
3114
|
"extend interface",
|
|
3114
|
-
|
|
3115
|
+
name2,
|
|
3115
3116
|
wrap("implements ", join(interfaces, " & ")),
|
|
3116
3117
|
join(directives, " "),
|
|
3117
3118
|
block(fields)
|
|
@@ -3120,10 +3121,10 @@ var printDocASTReducer = {
|
|
|
3120
3121
|
)
|
|
3121
3122
|
},
|
|
3122
3123
|
UnionTypeExtension: {
|
|
3123
|
-
leave: ({ name, directives, types }) => join(
|
|
3124
|
+
leave: ({ name: name2, directives, types }) => join(
|
|
3124
3125
|
[
|
|
3125
3126
|
"extend union",
|
|
3126
|
-
|
|
3127
|
+
name2,
|
|
3127
3128
|
join(directives, " "),
|
|
3128
3129
|
wrap("= ", join(types, " | "))
|
|
3129
3130
|
],
|
|
@@ -3131,10 +3132,10 @@ var printDocASTReducer = {
|
|
|
3131
3132
|
)
|
|
3132
3133
|
},
|
|
3133
3134
|
EnumTypeExtension: {
|
|
3134
|
-
leave: ({ name, directives, values }) => join(["extend enum",
|
|
3135
|
+
leave: ({ name: name2, directives, values }) => join(["extend enum", name2, join(directives, " "), block(values)], " ")
|
|
3135
3136
|
},
|
|
3136
3137
|
InputObjectTypeExtension: {
|
|
3137
|
-
leave: ({ name, directives, fields }) => join(["extend input",
|
|
3138
|
+
leave: ({ name: name2, directives, fields }) => join(["extend input", name2, join(directives, " "), block(fields)], " ")
|
|
3138
3139
|
}
|
|
3139
3140
|
};
|
|
3140
3141
|
function join(maybeArray, separator = "") {
|
|
@@ -3342,7 +3343,7 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
3342
3343
|
};
|
|
3343
3344
|
}
|
|
3344
3345
|
|
|
3345
|
-
// ../../packages/sdk/dist/chunk-
|
|
3346
|
+
// ../../packages/sdk/dist/chunk-HFGEQP5N.mjs
|
|
3346
3347
|
import { Network as Network3 } from "@aptos-labs/ts-sdk";
|
|
3347
3348
|
|
|
3348
3349
|
// ../../node_modules/.pnpm/graphql-request@7.2.0_graphql@16.11.0/node_modules/graphql-request/build/legacy/classes/ClientError.js
|
|
@@ -3378,9 +3379,9 @@ var HeadersInitToPlainObject = (headers) => {
|
|
|
3378
3379
|
if (headers instanceof Headers) {
|
|
3379
3380
|
oHeaders = HeadersInstanceToPlainObject(headers);
|
|
3380
3381
|
} else if (Array.isArray(headers)) {
|
|
3381
|
-
headers.forEach(([
|
|
3382
|
-
if (
|
|
3383
|
-
oHeaders[
|
|
3382
|
+
headers.forEach(([name2, value]) => {
|
|
3383
|
+
if (name2 && value !== void 0) {
|
|
3384
|
+
oHeaders[name2] = value;
|
|
3384
3385
|
}
|
|
3385
3386
|
});
|
|
3386
3387
|
} else if (headers) {
|
|
@@ -3644,8 +3645,8 @@ var createFetcher = (method) => async (params) => {
|
|
|
3644
3645
|
initResolved = initNew;
|
|
3645
3646
|
}
|
|
3646
3647
|
if (searchParams) {
|
|
3647
|
-
searchParams.forEach((value,
|
|
3648
|
-
url.searchParams.append(
|
|
3648
|
+
searchParams.forEach((value, name2) => {
|
|
3649
|
+
url.searchParams.append(name2, value);
|
|
3649
3650
|
});
|
|
3650
3651
|
}
|
|
3651
3652
|
const $fetch = params.fetch ?? fetch;
|
|
@@ -3857,7 +3858,7 @@ var parseRequestArgs = (documentOrOptions, variables, requestHeaders) => {
|
|
|
3857
3858
|
};
|
|
3858
3859
|
};
|
|
3859
3860
|
|
|
3860
|
-
// ../../packages/sdk/dist/chunk-
|
|
3861
|
+
// ../../packages/sdk/dist/chunk-HFGEQP5N.mjs
|
|
3861
3862
|
function createShelbyIndexerClient(baseUrl, options) {
|
|
3862
3863
|
const graphqlClient = new GraphQLClient(baseUrl, options);
|
|
3863
3864
|
return getSdk(graphqlClient);
|
|
@@ -3969,10 +3970,10 @@ function isReadableStream(value) {
|
|
|
3969
3970
|
function toUint8Array(view) {
|
|
3970
3971
|
return view instanceof Uint8Array ? view : new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
|
|
3971
3972
|
}
|
|
3972
|
-
function buildRequestUrl(
|
|
3973
|
+
function buildRequestUrl(path7, baseUrl) {
|
|
3973
3974
|
const baseHasSlash = baseUrl.endsWith("/");
|
|
3974
3975
|
const safeBase = baseHasSlash ? baseUrl : `${baseUrl}/`;
|
|
3975
|
-
const safePath =
|
|
3976
|
+
const safePath = path7.replace(/^\/+/, "");
|
|
3976
3977
|
return new URL(safePath, safeBase);
|
|
3977
3978
|
}
|
|
3978
3979
|
function getBlobNameSuffix(blobName) {
|
|
@@ -4162,11 +4163,11 @@ function buildClayConfig(input) {
|
|
|
4162
4163
|
// ../../packages/sdk/dist/chunk-FIFKKWXV.mjs
|
|
4163
4164
|
import { AccountAddress as AccountAddress2 } from "@aptos-labs/ts-sdk";
|
|
4164
4165
|
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((
|
|
4166
|
+
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
4167
|
message: "Blob name cannot end with a slash"
|
|
4167
4168
|
});
|
|
4168
4169
|
|
|
4169
|
-
// ../../packages/sdk/dist/chunk-
|
|
4170
|
+
// ../../packages/sdk/dist/chunk-7P3P3D3X.mjs
|
|
4170
4171
|
import { AccountAddress as AccountAddress3 } from "@aptos-labs/ts-sdk";
|
|
4171
4172
|
function encodeURIComponentKeepSlashes(str) {
|
|
4172
4173
|
return encodeURIComponent(str).replace(/%2F/g, "/");
|
|
@@ -4558,7 +4559,7 @@ function validatePrePaddedChunkset(chunkset, expectedSize, chunksetIdx) {
|
|
|
4558
4559
|
return chunkset;
|
|
4559
4560
|
}
|
|
4560
4561
|
|
|
4561
|
-
// ../../packages/sdk/dist/chunk-
|
|
4562
|
+
// ../../packages/sdk/dist/chunk-HDYY6NS4.mjs
|
|
4562
4563
|
import {
|
|
4563
4564
|
AccountAddress as AccountAddress5,
|
|
4564
4565
|
Aptos as Aptos2,
|
|
@@ -4623,7 +4624,7 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
4623
4624
|
try {
|
|
4624
4625
|
const rawMetadata = await this.aptos.view({
|
|
4625
4626
|
payload: {
|
|
4626
|
-
function: `${this.deployer.toString()}::
|
|
4627
|
+
function: `${this.deployer.toString()}::blob_metadata::get_blob_metadata`,
|
|
4627
4628
|
functionArguments: [
|
|
4628
4629
|
createBlobKey({
|
|
4629
4630
|
account: params.account,
|
|
@@ -4757,10 +4758,10 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
4757
4758
|
orderBy
|
|
4758
4759
|
});
|
|
4759
4760
|
const activityTypeMapping = {
|
|
4760
|
-
[`${this.deployer.toStringLong()}::
|
|
4761
|
-
[`${this.deployer.toStringLong()}::
|
|
4762
|
-
[`${this.deployer.toStringLong()}::
|
|
4763
|
-
[`${this.deployer.toStringLong()}::
|
|
4761
|
+
[`${this.deployer.toStringLong()}::blob_metadata::BlobRegisteredEvent`]: "register_blob",
|
|
4762
|
+
[`${this.deployer.toStringLong()}::blob_metadata::BlobDeletedEvent`]: "delete_blob",
|
|
4763
|
+
[`${this.deployer.toStringLong()}::blob_metadata::BlobExpirationExtendedEvent`]: "extend_blob_expiration",
|
|
4764
|
+
[`${this.deployer.toStringLong()}::blob_metadata::BlobWrittenEvent`]: "write_blob"
|
|
4764
4765
|
};
|
|
4765
4766
|
return blob_activities.map(
|
|
4766
4767
|
(activity) => ({
|
|
@@ -4859,6 +4860,63 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
4859
4860
|
})
|
|
4860
4861
|
};
|
|
4861
4862
|
}
|
|
4863
|
+
/**
|
|
4864
|
+
* Registers multiple blobs on the blockchain by writing their merkle roots and metadata.
|
|
4865
|
+
*
|
|
4866
|
+
* @param params.account - The account that is signing and paying for the transaction.
|
|
4867
|
+
* @param params.expirationMicros - The expiration time of the blobs in microseconds.
|
|
4868
|
+
* @param params.blobs - The blobs to register.
|
|
4869
|
+
* @param params.blobs.blobName - The name/path of the blob (e.g. "foo/bar.txt").
|
|
4870
|
+
* @param params.blobs.blobSize - The size of the blob in bytes.
|
|
4871
|
+
* @param params.blobs.blobMerkleRoot - The merkle root of the blob commitments as a hex string.
|
|
4872
|
+
* @param params.options - Optional transaction building options.
|
|
4873
|
+
* @param params.options.chunksetSizeBytes - Custom chunkset size (defaults to DEFAULT_CHUNKSET_SIZE_BYTES).
|
|
4874
|
+
* @param params.options.build - Additional Aptos transaction building options.
|
|
4875
|
+
*
|
|
4876
|
+
* @returns An object containing the pending transaction.
|
|
4877
|
+
*
|
|
4878
|
+
* @example
|
|
4879
|
+
* ```typescript
|
|
4880
|
+
* const provider = await ClayErasureCodingProvider.create();
|
|
4881
|
+
* const blobCommitments = await generateCommitments(provider, data);
|
|
4882
|
+
*
|
|
4883
|
+
* const { transaction } = await client.batchRegisterBlobs({
|
|
4884
|
+
* account: signer,
|
|
4885
|
+
* expirationMicros: Date.now() * 1000 + 3600_000_000, // 1 hour from now in microseconds
|
|
4886
|
+
* blobs: [
|
|
4887
|
+
* {
|
|
4888
|
+
* blobName: "foo/bar.txt",
|
|
4889
|
+
* blobSize: data.length,
|
|
4890
|
+
* blobMerkleRoot: blobCommitments.blob_merkle_root,
|
|
4891
|
+
* },
|
|
4892
|
+
* ],
|
|
4893
|
+
* });
|
|
4894
|
+
* ```
|
|
4895
|
+
*/
|
|
4896
|
+
async batchRegisterBlobs(params) {
|
|
4897
|
+
const chunksetSize = params.options?.chunksetSizeBytes ?? DEFAULT_CHUNKSET_SIZE_BYTES;
|
|
4898
|
+
const transaction = await this.aptos.transaction.build.simple({
|
|
4899
|
+
...params.options?.build,
|
|
4900
|
+
sender: params.account.accountAddress,
|
|
4901
|
+
data: _ShelbyBlobClient.createBatchRegisterBlobsPayload({
|
|
4902
|
+
deployer: this.deployer,
|
|
4903
|
+
account: params.account.accountAddress,
|
|
4904
|
+
expirationMicros: params.expirationMicros,
|
|
4905
|
+
blobs: params.blobs.map((blob) => ({
|
|
4906
|
+
blobName: blob.blobName,
|
|
4907
|
+
blobSize: blob.blobSize,
|
|
4908
|
+
blobMerkleRoot: blob.blobMerkleRoot,
|
|
4909
|
+
numChunksets: expectedTotalChunksets(blob.blobSize, chunksetSize)
|
|
4910
|
+
}))
|
|
4911
|
+
})
|
|
4912
|
+
});
|
|
4913
|
+
return {
|
|
4914
|
+
transaction: await this.aptos.signAndSubmitTransaction({
|
|
4915
|
+
signer: params.account,
|
|
4916
|
+
transaction
|
|
4917
|
+
})
|
|
4918
|
+
};
|
|
4919
|
+
}
|
|
4862
4920
|
/**
|
|
4863
4921
|
* Creates a transaction payload to register a blob on the blockchain.
|
|
4864
4922
|
* This is a static helper method for constructing the Move function call payload.
|
|
@@ -4877,7 +4935,7 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
4877
4935
|
*/
|
|
4878
4936
|
static createRegisterBlobPayload(params) {
|
|
4879
4937
|
return {
|
|
4880
|
-
function: `${(params.deployer ?? SHELBY_DEPLOYER).toString()}::
|
|
4938
|
+
function: `${(params.deployer ?? SHELBY_DEPLOYER).toString()}::blob_metadata::register_blob`,
|
|
4881
4939
|
functionArguments: [
|
|
4882
4940
|
params.blobName,
|
|
4883
4941
|
params.expirationMicros,
|
|
@@ -4921,7 +4979,7 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
4921
4979
|
blobSizes.push(blob.blobSize);
|
|
4922
4980
|
});
|
|
4923
4981
|
return {
|
|
4924
|
-
function: `${(params.deployer ?? SHELBY_DEPLOYER).toString()}::
|
|
4982
|
+
function: `${(params.deployer ?? SHELBY_DEPLOYER).toString()}::blob_metadata::register_multiple_blobs`,
|
|
4925
4983
|
functionArguments: [
|
|
4926
4984
|
blobNames,
|
|
4927
4985
|
params.expirationMicros,
|
|
@@ -4947,16 +5005,155 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
4947
5005
|
*/
|
|
4948
5006
|
static createDeleteBlobPayload(params) {
|
|
4949
5007
|
return {
|
|
4950
|
-
function: `${(params.deployer ?? SHELBY_DEPLOYER).toString()}::
|
|
5008
|
+
function: `${(params.deployer ?? SHELBY_DEPLOYER).toString()}::blob_metadata::delete_blob`,
|
|
4951
5009
|
functionArguments: [params.blobNameSuffix]
|
|
4952
5010
|
};
|
|
4953
5011
|
}
|
|
4954
5012
|
};
|
|
4955
5013
|
|
|
4956
|
-
// ../../packages/sdk/dist/chunk-
|
|
5014
|
+
// ../../packages/sdk/dist/chunk-CQZZRXA6.mjs
|
|
4957
5015
|
import {
|
|
4958
5016
|
Aptos as Aptos3
|
|
4959
5017
|
} from "@aptos-labs/ts-sdk";
|
|
5018
|
+
|
|
5019
|
+
// ../../node_modules/.pnpm/yocto-queue@1.2.1/node_modules/yocto-queue/index.js
|
|
5020
|
+
var Node = class {
|
|
5021
|
+
value;
|
|
5022
|
+
next;
|
|
5023
|
+
constructor(value) {
|
|
5024
|
+
this.value = value;
|
|
5025
|
+
}
|
|
5026
|
+
};
|
|
5027
|
+
var Queue = class {
|
|
5028
|
+
#head;
|
|
5029
|
+
#tail;
|
|
5030
|
+
#size;
|
|
5031
|
+
constructor() {
|
|
5032
|
+
this.clear();
|
|
5033
|
+
}
|
|
5034
|
+
enqueue(value) {
|
|
5035
|
+
const node = new Node(value);
|
|
5036
|
+
if (this.#head) {
|
|
5037
|
+
this.#tail.next = node;
|
|
5038
|
+
this.#tail = node;
|
|
5039
|
+
} else {
|
|
5040
|
+
this.#head = node;
|
|
5041
|
+
this.#tail = node;
|
|
5042
|
+
}
|
|
5043
|
+
this.#size++;
|
|
5044
|
+
}
|
|
5045
|
+
dequeue() {
|
|
5046
|
+
const current = this.#head;
|
|
5047
|
+
if (!current) {
|
|
5048
|
+
return;
|
|
5049
|
+
}
|
|
5050
|
+
this.#head = this.#head.next;
|
|
5051
|
+
this.#size--;
|
|
5052
|
+
return current.value;
|
|
5053
|
+
}
|
|
5054
|
+
peek() {
|
|
5055
|
+
if (!this.#head) {
|
|
5056
|
+
return;
|
|
5057
|
+
}
|
|
5058
|
+
return this.#head.value;
|
|
5059
|
+
}
|
|
5060
|
+
clear() {
|
|
5061
|
+
this.#head = void 0;
|
|
5062
|
+
this.#tail = void 0;
|
|
5063
|
+
this.#size = 0;
|
|
5064
|
+
}
|
|
5065
|
+
get size() {
|
|
5066
|
+
return this.#size;
|
|
5067
|
+
}
|
|
5068
|
+
*[Symbol.iterator]() {
|
|
5069
|
+
let current = this.#head;
|
|
5070
|
+
while (current) {
|
|
5071
|
+
yield current.value;
|
|
5072
|
+
current = current.next;
|
|
5073
|
+
}
|
|
5074
|
+
}
|
|
5075
|
+
*drain() {
|
|
5076
|
+
while (this.#head) {
|
|
5077
|
+
yield this.dequeue();
|
|
5078
|
+
}
|
|
5079
|
+
}
|
|
5080
|
+
};
|
|
5081
|
+
|
|
5082
|
+
// ../../node_modules/.pnpm/p-limit@7.1.1/node_modules/p-limit/index.js
|
|
5083
|
+
function pLimit(concurrency) {
|
|
5084
|
+
validateConcurrency(concurrency);
|
|
5085
|
+
const queue = new Queue();
|
|
5086
|
+
let activeCount = 0;
|
|
5087
|
+
const resumeNext = () => {
|
|
5088
|
+
if (activeCount < concurrency && queue.size > 0) {
|
|
5089
|
+
activeCount++;
|
|
5090
|
+
queue.dequeue()();
|
|
5091
|
+
}
|
|
5092
|
+
};
|
|
5093
|
+
const next = () => {
|
|
5094
|
+
activeCount--;
|
|
5095
|
+
resumeNext();
|
|
5096
|
+
};
|
|
5097
|
+
const run = async (function_, resolve3, arguments_) => {
|
|
5098
|
+
const result = (async () => function_(...arguments_))();
|
|
5099
|
+
resolve3(result);
|
|
5100
|
+
try {
|
|
5101
|
+
await result;
|
|
5102
|
+
} catch {
|
|
5103
|
+
}
|
|
5104
|
+
next();
|
|
5105
|
+
};
|
|
5106
|
+
const enqueue = (function_, resolve3, arguments_) => {
|
|
5107
|
+
new Promise((internalResolve) => {
|
|
5108
|
+
queue.enqueue(internalResolve);
|
|
5109
|
+
}).then(run.bind(void 0, function_, resolve3, arguments_));
|
|
5110
|
+
if (activeCount < concurrency) {
|
|
5111
|
+
resumeNext();
|
|
5112
|
+
}
|
|
5113
|
+
};
|
|
5114
|
+
const generator = (function_, ...arguments_) => new Promise((resolve3) => {
|
|
5115
|
+
enqueue(function_, resolve3, arguments_);
|
|
5116
|
+
});
|
|
5117
|
+
Object.defineProperties(generator, {
|
|
5118
|
+
activeCount: {
|
|
5119
|
+
get: () => activeCount
|
|
5120
|
+
},
|
|
5121
|
+
pendingCount: {
|
|
5122
|
+
get: () => queue.size
|
|
5123
|
+
},
|
|
5124
|
+
clearQueue: {
|
|
5125
|
+
value() {
|
|
5126
|
+
queue.clear();
|
|
5127
|
+
}
|
|
5128
|
+
},
|
|
5129
|
+
concurrency: {
|
|
5130
|
+
get: () => concurrency,
|
|
5131
|
+
set(newConcurrency) {
|
|
5132
|
+
validateConcurrency(newConcurrency);
|
|
5133
|
+
concurrency = newConcurrency;
|
|
5134
|
+
queueMicrotask(() => {
|
|
5135
|
+
while (activeCount < concurrency && queue.size > 0) {
|
|
5136
|
+
resumeNext();
|
|
5137
|
+
}
|
|
5138
|
+
});
|
|
5139
|
+
}
|
|
5140
|
+
},
|
|
5141
|
+
map: {
|
|
5142
|
+
async value(array, function_) {
|
|
5143
|
+
const promises = array.map((value, index) => this(function_, value, index));
|
|
5144
|
+
return Promise.all(promises);
|
|
5145
|
+
}
|
|
5146
|
+
}
|
|
5147
|
+
});
|
|
5148
|
+
return generator;
|
|
5149
|
+
}
|
|
5150
|
+
function validateConcurrency(concurrency) {
|
|
5151
|
+
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
|
5152
|
+
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
|
5153
|
+
}
|
|
5154
|
+
}
|
|
5155
|
+
|
|
5156
|
+
// ../../packages/sdk/dist/chunk-CQZZRXA6.mjs
|
|
4960
5157
|
var ShelbyClient = class {
|
|
4961
5158
|
/**
|
|
4962
5159
|
* The coordination client is used to interact with the Aptos blockchain which handles the commitments
|
|
@@ -5086,6 +5283,89 @@ var ShelbyClient = class {
|
|
|
5086
5283
|
blobData: params.blobData
|
|
5087
5284
|
});
|
|
5088
5285
|
}
|
|
5286
|
+
/**
|
|
5287
|
+
* Uploads a batch of blobs to the Shelby network.
|
|
5288
|
+
* This method handles the complete upload flow including commitment generation,
|
|
5289
|
+
* blockchain registration, and storage upload.
|
|
5290
|
+
*
|
|
5291
|
+
* @param params.blobs - The blobs to upload.
|
|
5292
|
+
* @param params.blobs.blobData - The raw data to upload as a Uint8Array.
|
|
5293
|
+
* @param params.blobs.blobName - The name/path of the blob (e.g. "folder/file.txt").
|
|
5294
|
+
* @param params.expirationMicros - The expiration time in microseconds since Unix epoch.
|
|
5295
|
+
* @param params.signer - The account that signs and pays for the transaction.
|
|
5296
|
+
* @param params.options - Optional upload configuration.
|
|
5297
|
+
* @param params.options.chunksetSizeBytes - Custom chunkset size.
|
|
5298
|
+
* @param params.options.build - Additional Aptos transaction options.
|
|
5299
|
+
*
|
|
5300
|
+
* @returns The transaction and generated blob commitments (when implemented).
|
|
5301
|
+
*
|
|
5302
|
+
* @example
|
|
5303
|
+
* ```typescript
|
|
5304
|
+
* await client.batchUpload({
|
|
5305
|
+
* blobs: [
|
|
5306
|
+
* { blobData: Buffer.from("Hello, World!"), blobName: "hello.txt" },
|
|
5307
|
+
* { blobData: Buffer.from("Hello, World 2!"), blobName: "hello2.txt" },
|
|
5308
|
+
* ],
|
|
5309
|
+
* expirationMicros: Date.now() * 1000 + 86400_000_000 // 24 hours from now
|
|
5310
|
+
* });
|
|
5311
|
+
* ```
|
|
5312
|
+
*/
|
|
5313
|
+
async batchUpload(params) {
|
|
5314
|
+
const existingBlobs = await this.coordination.getBlobs({
|
|
5315
|
+
where: {
|
|
5316
|
+
blob_name: {
|
|
5317
|
+
_in: params.blobs.map(
|
|
5318
|
+
(blob) => createBlobKey({
|
|
5319
|
+
account: params.signer.accountAddress,
|
|
5320
|
+
blobName: blob.blobName
|
|
5321
|
+
})
|
|
5322
|
+
)
|
|
5323
|
+
}
|
|
5324
|
+
}
|
|
5325
|
+
});
|
|
5326
|
+
const blobsToRegister = params.blobs.filter(
|
|
5327
|
+
(blob) => !existingBlobs.some(
|
|
5328
|
+
(existingBlob) => existingBlob.name === createBlobKey({
|
|
5329
|
+
account: params.signer.accountAddress,
|
|
5330
|
+
blobName: blob.blobName
|
|
5331
|
+
})
|
|
5332
|
+
)
|
|
5333
|
+
);
|
|
5334
|
+
if (blobsToRegister.length > 0) {
|
|
5335
|
+
const provider = await this.getProvider();
|
|
5336
|
+
const blobCommitments = await Promise.all(
|
|
5337
|
+
blobsToRegister.map(
|
|
5338
|
+
async (blob) => generateCommitments(provider, blob.blobData)
|
|
5339
|
+
)
|
|
5340
|
+
);
|
|
5341
|
+
const { transaction: pendingRegisterBlobTransaction } = await this.coordination.batchRegisterBlobs({
|
|
5342
|
+
account: params.signer,
|
|
5343
|
+
expirationMicros: params.expirationMicros,
|
|
5344
|
+
blobs: blobsToRegister.map((blob, index) => ({
|
|
5345
|
+
blobName: blob.blobName,
|
|
5346
|
+
blobSize: blob.blobData.length,
|
|
5347
|
+
blobMerkleRoot: blobCommitments[index].blob_merkle_root
|
|
5348
|
+
})),
|
|
5349
|
+
options: params.options
|
|
5350
|
+
});
|
|
5351
|
+
await this.coordination.aptos.waitForTransaction({
|
|
5352
|
+
transactionHash: pendingRegisterBlobTransaction.hash,
|
|
5353
|
+
options: { waitForIndexer: true }
|
|
5354
|
+
});
|
|
5355
|
+
}
|
|
5356
|
+
const limit = pLimit(3);
|
|
5357
|
+
await Promise.all(
|
|
5358
|
+
params.blobs.map(
|
|
5359
|
+
(blob) => limit(
|
|
5360
|
+
() => this.rpc.putBlob({
|
|
5361
|
+
account: params.signer.accountAddress,
|
|
5362
|
+
blobName: blob.blobName,
|
|
5363
|
+
blobData: blob.blobData
|
|
5364
|
+
})
|
|
5365
|
+
)
|
|
5366
|
+
)
|
|
5367
|
+
);
|
|
5368
|
+
}
|
|
5089
5369
|
/**
|
|
5090
5370
|
* Downloads a blob from the Shelby RPC node.
|
|
5091
5371
|
*
|
|
@@ -5108,15 +5388,15 @@ var ShelbyClient = class {
|
|
|
5108
5388
|
}
|
|
5109
5389
|
};
|
|
5110
5390
|
|
|
5111
|
-
// ../../packages/sdk/dist/chunk-
|
|
5391
|
+
// ../../packages/sdk/dist/chunk-2JMRK5PM.mjs
|
|
5112
5392
|
var ShelbyNodeClient = class extends ShelbyClient {
|
|
5113
5393
|
};
|
|
5114
5394
|
|
|
5115
5395
|
// ../../packages/sdk/dist/chunk-7P6ASYW6.mjs
|
|
5116
5396
|
var __defProp = Object.defineProperty;
|
|
5117
5397
|
var __export = (target, all) => {
|
|
5118
|
-
for (var
|
|
5119
|
-
__defProp(target,
|
|
5398
|
+
for (var name2 in all)
|
|
5399
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
5120
5400
|
};
|
|
5121
5401
|
|
|
5122
5402
|
// ../../packages/sdk/dist/chunk-A4IG6GSE.mjs
|
|
@@ -5215,10 +5495,10 @@ var reed_solomon_erasure_bg_default = __toBinaryNode("AGFzbQEAAAAB/oCAgAASYAJ/fw
|
|
|
5215
5495
|
var DEFAULT_CHUNK_SIZE_BYTES2 = 2 * 1024 * 1024;
|
|
5216
5496
|
|
|
5217
5497
|
// src/commands/account.tsx
|
|
5218
|
-
import
|
|
5498
|
+
import chalk2 from "chalk";
|
|
5219
5499
|
import { filesize } from "filesize";
|
|
5220
5500
|
import { render } from "ink";
|
|
5221
|
-
import { z as
|
|
5501
|
+
import { z as z10 } from "zod";
|
|
5222
5502
|
|
|
5223
5503
|
// src/components/AccountWizard.tsx
|
|
5224
5504
|
import { Box, Text } from "ink";
|
|
@@ -5389,10 +5669,10 @@ function saveConfig(config, configPath = "~/.shelby/config.yaml") {
|
|
|
5389
5669
|
fs.writeFileSync(resolvedPath, YAML.stringify(config), "utf8");
|
|
5390
5670
|
}
|
|
5391
5671
|
function getCurrentContext(config, contextName) {
|
|
5392
|
-
const
|
|
5393
|
-
const context = config.contexts[
|
|
5672
|
+
const name2 = contextName || config.default_context;
|
|
5673
|
+
const context = config.contexts[name2];
|
|
5394
5674
|
if (!context) {
|
|
5395
|
-
throw new Error(`Context '${
|
|
5675
|
+
throw new Error(`Context '${name2}' not found in config`);
|
|
5396
5676
|
}
|
|
5397
5677
|
return {
|
|
5398
5678
|
api_key: context.api_key,
|
|
@@ -5401,19 +5681,19 @@ function getCurrentContext(config, contextName) {
|
|
|
5401
5681
|
};
|
|
5402
5682
|
}
|
|
5403
5683
|
function getCurrentAccount(config, accountName) {
|
|
5404
|
-
const
|
|
5405
|
-
if (!
|
|
5406
|
-
throw new Error(`Account with name '${
|
|
5684
|
+
const name2 = accountName || config.default_account;
|
|
5685
|
+
if (!name2) {
|
|
5686
|
+
throw new Error(`Account with name '${name2}' not found in config`);
|
|
5407
5687
|
}
|
|
5408
|
-
const account = config.accounts[
|
|
5688
|
+
const account = config.accounts[name2];
|
|
5409
5689
|
if (!account) {
|
|
5410
|
-
throw new Error(`Account '${
|
|
5690
|
+
throw new Error(`Account '${name2}' not found in config`);
|
|
5411
5691
|
}
|
|
5412
5692
|
let privateKey;
|
|
5413
5693
|
if (account.private_key) {
|
|
5414
5694
|
privateKey = account.private_key;
|
|
5415
5695
|
} else {
|
|
5416
|
-
throw new Error(`No private key found for account '${
|
|
5696
|
+
throw new Error(`No private key found for account '${name2}'`);
|
|
5417
5697
|
}
|
|
5418
5698
|
return {
|
|
5419
5699
|
address: account.address,
|
|
@@ -5424,11 +5704,11 @@ function getCurrentAccount(config, accountName) {
|
|
|
5424
5704
|
};
|
|
5425
5705
|
}
|
|
5426
5706
|
function getAptosSettingsFromContext(context) {
|
|
5427
|
-
const { name, api_key, ...options } = context.aptos_network;
|
|
5707
|
+
const { name: name2, api_key, ...options } = context.aptos_network;
|
|
5428
5708
|
const activeApiKey = api_key || context.api_key;
|
|
5429
5709
|
return {
|
|
5430
5710
|
...options,
|
|
5431
|
-
network: NetworkToNetworkName[
|
|
5711
|
+
network: NetworkToNetworkName[name2],
|
|
5432
5712
|
clientConfig: { API_KEY: activeApiKey }
|
|
5433
5713
|
};
|
|
5434
5714
|
}
|
|
@@ -5465,13 +5745,13 @@ function getCurrentShelbyConfig(config, opts = { context: config.default_context
|
|
|
5465
5745
|
}
|
|
5466
5746
|
|
|
5467
5747
|
// src/utils/account.ts
|
|
5468
|
-
function validateAccountName(
|
|
5469
|
-
const parsed = AccountNameSchema.safeParse(
|
|
5470
|
-
if (!parsed.success ||
|
|
5748
|
+
function validateAccountName(name2, config) {
|
|
5749
|
+
const parsed = AccountNameSchema.safeParse(name2);
|
|
5750
|
+
if (!parsed.success || name2.length === 0) {
|
|
5471
5751
|
return parsed.error?.errors[0]?.message || "Account name must be a non-empty string containing only letters, numbers, underscores, or hyphens.";
|
|
5472
5752
|
}
|
|
5473
|
-
if (config?.accounts[
|
|
5474
|
-
return `Account '${
|
|
5753
|
+
if (config?.accounts[name2]) {
|
|
5754
|
+
return `Account '${name2}' already exists. Choose a different name.`;
|
|
5475
5755
|
}
|
|
5476
5756
|
return void 0;
|
|
5477
5757
|
}
|
|
@@ -5516,33 +5796,33 @@ var AccountWizard = ({
|
|
|
5516
5796
|
const [step, setStep] = useState(
|
|
5517
5797
|
initialName ? "address" : "name"
|
|
5518
5798
|
);
|
|
5519
|
-
const [
|
|
5799
|
+
const [name2, setName] = useState(initialName || "");
|
|
5520
5800
|
const [nameError, setNameError] = useState(null);
|
|
5521
5801
|
const [address, setAddress] = useState("");
|
|
5522
5802
|
const [privateKey, setPrivateKey] = useState("");
|
|
5523
5803
|
useEffect(() => {
|
|
5524
5804
|
if (step === "done") {
|
|
5525
5805
|
onComplete({
|
|
5526
|
-
name,
|
|
5806
|
+
name: name2,
|
|
5527
5807
|
address: address || void 0,
|
|
5528
5808
|
privateKey
|
|
5529
5809
|
});
|
|
5530
5810
|
}
|
|
5531
|
-
}, [onComplete, step,
|
|
5811
|
+
}, [onComplete, step, name2, address, privateKey]);
|
|
5532
5812
|
if (step === "name") {
|
|
5533
5813
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
5534
5814
|
/* @__PURE__ */ jsx(Text, { children: "Account name?" }),
|
|
5535
5815
|
/* @__PURE__ */ jsx(
|
|
5536
5816
|
TextInput,
|
|
5537
5817
|
{
|
|
5538
|
-
value:
|
|
5818
|
+
value: name2,
|
|
5539
5819
|
onChange: (value) => {
|
|
5540
5820
|
setName(value);
|
|
5541
5821
|
const error = validateAccountName(value, config);
|
|
5542
5822
|
setNameError(error || null);
|
|
5543
5823
|
},
|
|
5544
5824
|
onSubmit: () => {
|
|
5545
|
-
const error = validateAccountName(
|
|
5825
|
+
const error = validateAccountName(name2, config);
|
|
5546
5826
|
if (error) {
|
|
5547
5827
|
setNameError(error);
|
|
5548
5828
|
return;
|
|
@@ -5626,7 +5906,7 @@ function AptosNetworkNameSelector({
|
|
|
5626
5906
|
onSelect
|
|
5627
5907
|
}) {
|
|
5628
5908
|
const items = [
|
|
5629
|
-
...shelbyNetworks.map((
|
|
5909
|
+
...shelbyNetworks.map((name2) => ({ label: name2, value: name2 })),
|
|
5630
5910
|
...additionalItems
|
|
5631
5911
|
];
|
|
5632
5912
|
return /* @__PURE__ */ jsx3(
|
|
@@ -5662,9 +5942,9 @@ var APTOS_CONFIG_FIELDS = [
|
|
|
5662
5942
|
type: "select",
|
|
5663
5943
|
key: "name",
|
|
5664
5944
|
label: "Network Name",
|
|
5665
|
-
items: shelbyNetworks.map((
|
|
5666
|
-
label:
|
|
5667
|
-
value:
|
|
5945
|
+
items: shelbyNetworks.map((name2) => ({
|
|
5946
|
+
label: name2,
|
|
5947
|
+
value: name2
|
|
5668
5948
|
}))
|
|
5669
5949
|
},
|
|
5670
5950
|
{
|
|
@@ -6063,7 +6343,7 @@ var CreateContextWizard = ({
|
|
|
6063
6343
|
onComplete
|
|
6064
6344
|
}) => {
|
|
6065
6345
|
const [step, setStep] = useState4("name");
|
|
6066
|
-
const [
|
|
6346
|
+
const [name2, setName] = useState4("");
|
|
6067
6347
|
const [apiKey, setApiKey] = useState4("");
|
|
6068
6348
|
const [shelbyNetwork, setShelbyNetwork] = useState4(
|
|
6069
6349
|
{}
|
|
@@ -6074,12 +6354,12 @@ var CreateContextWizard = ({
|
|
|
6074
6354
|
const validatedAptosNetwork = AptosNetworkSchema.parse(aptosNetwork);
|
|
6075
6355
|
const validatedShelbyNetwork = ShelbyNetworkSchema.parse(shelbyNetwork);
|
|
6076
6356
|
onComplete({
|
|
6077
|
-
name,
|
|
6357
|
+
name: name2,
|
|
6078
6358
|
apiKey: apiKey || void 0,
|
|
6079
6359
|
shelbyNetwork: validatedShelbyNetwork,
|
|
6080
6360
|
aptosNetwork: validatedAptosNetwork
|
|
6081
6361
|
});
|
|
6082
|
-
}, [step,
|
|
6362
|
+
}, [step, name2, apiKey, shelbyNetwork, aptosNetwork, onComplete]);
|
|
6083
6363
|
if (step === "name") {
|
|
6084
6364
|
return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", children: [
|
|
6085
6365
|
/* @__PURE__ */ jsx6(Text5, { children: "Context name?" }),
|
|
@@ -6088,7 +6368,7 @@ var CreateContextWizard = ({
|
|
|
6088
6368
|
{
|
|
6089
6369
|
placeholder: "Enter context name",
|
|
6090
6370
|
required: true,
|
|
6091
|
-
value:
|
|
6371
|
+
value: name2,
|
|
6092
6372
|
onChange: setName,
|
|
6093
6373
|
onSubmit: () => setStep("api-key")
|
|
6094
6374
|
}
|
|
@@ -6318,6 +6598,158 @@ function assetTypeToString(asset) {
|
|
|
6318
6598
|
return AccountAddress7.from(asset).toString();
|
|
6319
6599
|
}
|
|
6320
6600
|
|
|
6601
|
+
// src/utils/cache.ts
|
|
6602
|
+
import path2 from "path";
|
|
6603
|
+
import fs2 from "fs-extra";
|
|
6604
|
+
var Cache = class {
|
|
6605
|
+
cachePath;
|
|
6606
|
+
schema;
|
|
6607
|
+
constructor(cacheFileName, schema) {
|
|
6608
|
+
this.cachePath = resolveConfigPath(`~/.shelby/${cacheFileName}`);
|
|
6609
|
+
this.schema = schema;
|
|
6610
|
+
}
|
|
6611
|
+
/**
|
|
6612
|
+
* Read data from cache
|
|
6613
|
+
* Returns null if cache doesn't exist or fails validation
|
|
6614
|
+
*/
|
|
6615
|
+
read() {
|
|
6616
|
+
try {
|
|
6617
|
+
if (!fs2.existsSync(this.cachePath)) {
|
|
6618
|
+
return null;
|
|
6619
|
+
}
|
|
6620
|
+
const data = fs2.readFileSync(this.cachePath, "utf-8");
|
|
6621
|
+
const parsed = JSON.parse(data);
|
|
6622
|
+
const result = this.schema.safeParse(parsed);
|
|
6623
|
+
if (!result.success) {
|
|
6624
|
+
return null;
|
|
6625
|
+
}
|
|
6626
|
+
return result.data;
|
|
6627
|
+
} catch {
|
|
6628
|
+
return null;
|
|
6629
|
+
}
|
|
6630
|
+
}
|
|
6631
|
+
/**
|
|
6632
|
+
* Write data to cache
|
|
6633
|
+
* Data is validated before writing
|
|
6634
|
+
*/
|
|
6635
|
+
write(data) {
|
|
6636
|
+
try {
|
|
6637
|
+
const validated = this.schema.parse(data);
|
|
6638
|
+
const cacheDir = path2.dirname(this.cachePath);
|
|
6639
|
+
fs2.mkdirpSync(cacheDir);
|
|
6640
|
+
fs2.writeFileSync(
|
|
6641
|
+
this.cachePath,
|
|
6642
|
+
JSON.stringify(validated, null, 2),
|
|
6643
|
+
"utf-8"
|
|
6644
|
+
);
|
|
6645
|
+
return true;
|
|
6646
|
+
} catch {
|
|
6647
|
+
return false;
|
|
6648
|
+
}
|
|
6649
|
+
}
|
|
6650
|
+
/**
|
|
6651
|
+
* Delete the cache file
|
|
6652
|
+
*/
|
|
6653
|
+
clear() {
|
|
6654
|
+
try {
|
|
6655
|
+
if (fs2.existsSync(this.cachePath)) {
|
|
6656
|
+
fs2.unlinkSync(this.cachePath);
|
|
6657
|
+
}
|
|
6658
|
+
return true;
|
|
6659
|
+
} catch {
|
|
6660
|
+
return false;
|
|
6661
|
+
}
|
|
6662
|
+
}
|
|
6663
|
+
/**
|
|
6664
|
+
* Check if cache exists
|
|
6665
|
+
*/
|
|
6666
|
+
exists() {
|
|
6667
|
+
return fs2.existsSync(this.cachePath);
|
|
6668
|
+
}
|
|
6669
|
+
/**
|
|
6670
|
+
* Get the resolved cache file path
|
|
6671
|
+
*/
|
|
6672
|
+
getPath() {
|
|
6673
|
+
return this.cachePath;
|
|
6674
|
+
}
|
|
6675
|
+
};
|
|
6676
|
+
|
|
6677
|
+
// src/utils/check-version.ts
|
|
6678
|
+
import boxen from "boxen";
|
|
6679
|
+
import chalk from "chalk";
|
|
6680
|
+
import { getLatestVersion } from "fast-npm-meta";
|
|
6681
|
+
import * as semver from "semver";
|
|
6682
|
+
import { z as z9 } from "zod";
|
|
6683
|
+
var CHECK_INTERVAL = 1e3 * 60 * 60 * 24;
|
|
6684
|
+
var NOTIFY_INTERVAL = CHECK_INTERVAL;
|
|
6685
|
+
var VersionCacheSchema = z9.object({
|
|
6686
|
+
lastChecked: z9.number(),
|
|
6687
|
+
latestVersion: z9.string(),
|
|
6688
|
+
lastNotified: z9.number().optional()
|
|
6689
|
+
});
|
|
6690
|
+
var versionCache = new Cache("version-check.json", VersionCacheSchema);
|
|
6691
|
+
async function fetchLatestVersion() {
|
|
6692
|
+
try {
|
|
6693
|
+
const result = await getLatestVersion(name, { throw: false });
|
|
6694
|
+
if ("error" in result) {
|
|
6695
|
+
return null;
|
|
6696
|
+
}
|
|
6697
|
+
return result.version;
|
|
6698
|
+
} catch {
|
|
6699
|
+
return null;
|
|
6700
|
+
}
|
|
6701
|
+
}
|
|
6702
|
+
function displayUpdateNotification(latestVersion) {
|
|
6703
|
+
const message = [
|
|
6704
|
+
`Update available ${chalk.dim(version)} \u2192 ${chalk.green(
|
|
6705
|
+
latestVersion
|
|
6706
|
+
)}`,
|
|
6707
|
+
"",
|
|
6708
|
+
`Run ${chalk.cyan(`npm install -g ${name}`)} to update`
|
|
6709
|
+
].join("\n");
|
|
6710
|
+
console.log(
|
|
6711
|
+
"\n" + boxen(message, {
|
|
6712
|
+
padding: 1,
|
|
6713
|
+
margin: 1,
|
|
6714
|
+
borderStyle: "round",
|
|
6715
|
+
borderColor: "yellow"
|
|
6716
|
+
}) + "\n"
|
|
6717
|
+
);
|
|
6718
|
+
}
|
|
6719
|
+
async function checkForUpdates(force = false) {
|
|
6720
|
+
try {
|
|
6721
|
+
const now = Date.now();
|
|
6722
|
+
const cache = versionCache.read();
|
|
6723
|
+
const shouldUseCache = cache && !force && now - cache.lastChecked < CHECK_INTERVAL;
|
|
6724
|
+
if (shouldUseCache) {
|
|
6725
|
+
if (semver.gt(cache.latestVersion, version)) {
|
|
6726
|
+
const shouldNotify = !cache.lastNotified || now - cache.lastNotified >= NOTIFY_INTERVAL;
|
|
6727
|
+
if (shouldNotify) {
|
|
6728
|
+
displayUpdateNotification(cache.latestVersion);
|
|
6729
|
+
versionCache.write({ ...cache, lastNotified: now });
|
|
6730
|
+
}
|
|
6731
|
+
}
|
|
6732
|
+
return;
|
|
6733
|
+
}
|
|
6734
|
+
const latestVersion = await fetchLatestVersion();
|
|
6735
|
+
if (!latestVersion) return;
|
|
6736
|
+
const isUpdateAvailable = semver.gt(latestVersion, version);
|
|
6737
|
+
versionCache.write({
|
|
6738
|
+
lastChecked: now,
|
|
6739
|
+
latestVersion,
|
|
6740
|
+
lastNotified: isUpdateAvailable ? now : cache?.lastNotified
|
|
6741
|
+
});
|
|
6742
|
+
if (isUpdateAvailable) {
|
|
6743
|
+
displayUpdateNotification(latestVersion);
|
|
6744
|
+
}
|
|
6745
|
+
} catch (err) {
|
|
6746
|
+
console.error("Unable to check for updates", err);
|
|
6747
|
+
}
|
|
6748
|
+
}
|
|
6749
|
+
async function checkForUpdatesAsync() {
|
|
6750
|
+
await checkForUpdates();
|
|
6751
|
+
}
|
|
6752
|
+
|
|
6321
6753
|
// src/utils/erasure.ts
|
|
6322
6754
|
var providerPromise;
|
|
6323
6755
|
function getErasureCodingProvider() {
|
|
@@ -6328,9 +6760,9 @@ function getErasureCodingProvider() {
|
|
|
6328
6760
|
}
|
|
6329
6761
|
|
|
6330
6762
|
// src/utils/paths.ts
|
|
6331
|
-
import
|
|
6763
|
+
import path3 from "path";
|
|
6332
6764
|
function endsWithDirectorySeparator(filePath) {
|
|
6333
|
-
return filePath.endsWith("/") || filePath.endsWith("\\") || filePath.endsWith(
|
|
6765
|
+
return filePath.endsWith("/") || filePath.endsWith("\\") || filePath.endsWith(path3.sep);
|
|
6334
6766
|
}
|
|
6335
6767
|
function normBlobName(pathModule, inputDirectoryName, filename, blobPrefix) {
|
|
6336
6768
|
const blobNameWithoutInputDir = pathModule.relative(
|
|
@@ -6343,7 +6775,7 @@ function normBlobName(pathModule, inputDirectoryName, filename, blobPrefix) {
|
|
|
6343
6775
|
);
|
|
6344
6776
|
const blobNameNormalized = pathModule.normalize(blobNameWithPrefix);
|
|
6345
6777
|
const parts = blobNameNormalized.split(pathModule.sep);
|
|
6346
|
-
return
|
|
6778
|
+
return path3.posix.join(...parts);
|
|
6347
6779
|
}
|
|
6348
6780
|
function denormBlobName(pathModule, blobPrefix, blobName, outputPrefix) {
|
|
6349
6781
|
if (!pathModule.isAbsolute(outputPrefix)) {
|
|
@@ -6577,7 +7009,7 @@ function createResponsiveTable(options) {
|
|
|
6577
7009
|
|
|
6578
7010
|
// src/utils/version.ts
|
|
6579
7011
|
import { execSync } from "child_process";
|
|
6580
|
-
import
|
|
7012
|
+
import semver2 from "semver";
|
|
6581
7013
|
var MIN_APTOS_CLI_VERSION = "7.8.0";
|
|
6582
7014
|
var MIN_NODE_VERSION = "22.0.0";
|
|
6583
7015
|
function getNodeVersion() {
|
|
@@ -6585,7 +7017,7 @@ function getNodeVersion() {
|
|
|
6585
7017
|
}
|
|
6586
7018
|
function getNodeVersionInfo(minVersion = MIN_NODE_VERSION) {
|
|
6587
7019
|
const version2 = getNodeVersion();
|
|
6588
|
-
const meetsRequirement =
|
|
7020
|
+
const meetsRequirement = semver2.gte(version2, minVersion);
|
|
6589
7021
|
return { version: version2, meetsRequirement };
|
|
6590
7022
|
}
|
|
6591
7023
|
function getAptosCliVersion() {
|
|
@@ -6601,7 +7033,7 @@ function getAptosCliVersion() {
|
|
|
6601
7033
|
}
|
|
6602
7034
|
function getAptosCliVersionInfo(minVersion = MIN_APTOS_CLI_VERSION) {
|
|
6603
7035
|
const version2 = getAptosCliVersion();
|
|
6604
|
-
const meetsRequirement = version2 ?
|
|
7036
|
+
const meetsRequirement = version2 ? semver2.gte(version2, minVersion) : false;
|
|
6605
7037
|
return { version: version2, meetsRequirement };
|
|
6606
7038
|
}
|
|
6607
7039
|
|
|
@@ -7083,10 +7515,10 @@ var handleError = (error) => {
|
|
|
7083
7515
|
|
|
7084
7516
|
// src/commands/account.tsx
|
|
7085
7517
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
7086
|
-
var CreateAccountOptionsSchema =
|
|
7087
|
-
name:
|
|
7088
|
-
privateKey:
|
|
7089
|
-
address:
|
|
7518
|
+
var CreateAccountOptionsSchema = z10.object({
|
|
7519
|
+
name: z10.string().optional(),
|
|
7520
|
+
privateKey: z10.string().optional(),
|
|
7521
|
+
address: z10.string().optional(),
|
|
7090
7522
|
scheme: SignatureSchemeSchema.optional()
|
|
7091
7523
|
});
|
|
7092
7524
|
var allSchemes = SignatureSchemeSchema.options.join(", ");
|
|
@@ -7113,12 +7545,12 @@ async function promptForAccountName(config) {
|
|
|
7113
7545
|
return answer;
|
|
7114
7546
|
}
|
|
7115
7547
|
}
|
|
7116
|
-
var ListAccountOptionsSchema =
|
|
7117
|
-
var UseAccountOptionsSchema =
|
|
7118
|
-
accountName:
|
|
7548
|
+
var ListAccountOptionsSchema = z10.object({});
|
|
7549
|
+
var UseAccountOptionsSchema = z10.object({
|
|
7550
|
+
accountName: z10.string()
|
|
7119
7551
|
});
|
|
7120
|
-
var DeleteAccountOptionsSchema =
|
|
7121
|
-
accountName:
|
|
7552
|
+
var DeleteAccountOptionsSchema = z10.object({
|
|
7553
|
+
accountName: z10.string()
|
|
7122
7554
|
});
|
|
7123
7555
|
function accountCommand(program) {
|
|
7124
7556
|
const account = program.command("account").description("Manage signing accounts (addresses & keys)");
|
|
@@ -7130,7 +7562,7 @@ function accountCommand(program) {
|
|
|
7130
7562
|
"Aptos account address (hex-encoded)"
|
|
7131
7563
|
).action(async (options) => {
|
|
7132
7564
|
CreateAccountOptionsSchema.parse(options);
|
|
7133
|
-
const { name, privateKey, address, scheme } = options;
|
|
7565
|
+
const { name: name2, privateKey, address, scheme } = options;
|
|
7134
7566
|
const configPath = program.opts().configFile;
|
|
7135
7567
|
let config;
|
|
7136
7568
|
try {
|
|
@@ -7189,20 +7621,20 @@ function accountCommand(program) {
|
|
|
7189
7621
|
/* @__PURE__ */ jsx10(
|
|
7190
7622
|
AccountWizard,
|
|
7191
7623
|
{
|
|
7192
|
-
initialName:
|
|
7624
|
+
initialName: name2,
|
|
7193
7625
|
config,
|
|
7194
7626
|
onComplete: ({
|
|
7195
|
-
name:
|
|
7627
|
+
name: name3,
|
|
7196
7628
|
address: address2,
|
|
7197
7629
|
privateKey: privateKey2
|
|
7198
7630
|
}) => {
|
|
7199
|
-
config.accounts[
|
|
7631
|
+
config.accounts[name3] = {
|
|
7200
7632
|
private_key: privateKey2,
|
|
7201
7633
|
address: address2
|
|
7202
7634
|
};
|
|
7203
7635
|
saveConfig(config, configPath);
|
|
7204
7636
|
console.log(
|
|
7205
|
-
`\u2705 Account ${
|
|
7637
|
+
`\u2705 Account ${name3} saved to ${resolveConfigPath(configPath)}`
|
|
7206
7638
|
);
|
|
7207
7639
|
unmount();
|
|
7208
7640
|
}
|
|
@@ -7238,9 +7670,9 @@ function accountCommand(program) {
|
|
|
7238
7670
|
padding: 12
|
|
7239
7671
|
// Account for borders (4) + cell padding (6) + margin
|
|
7240
7672
|
});
|
|
7241
|
-
for (const [
|
|
7242
|
-
const isDefault =
|
|
7243
|
-
const displayName =
|
|
7673
|
+
for (const [name2, { address, private_key }] of accounts) {
|
|
7674
|
+
const isDefault = name2 === config.default_account ? " (default)" : "";
|
|
7675
|
+
const displayName = name2 + isDefault;
|
|
7244
7676
|
const maskedKey = private_key ? `${private_key.slice(0, 20)}...` : "";
|
|
7245
7677
|
const row = [displayName, address || "", maskedKey];
|
|
7246
7678
|
table.push(row.map((cell, i) => wrapCell(cell, i)));
|
|
@@ -7424,16 +7856,16 @@ function accountCommand(program) {
|
|
|
7424
7856
|
console.log("\n\u{1F464} Account Information");
|
|
7425
7857
|
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
7858
|
if (!addressArg && accountName) {
|
|
7427
|
-
console.log(`\u{1F3F7}\uFE0F Alias: ${
|
|
7859
|
+
console.log(`\u{1F3F7}\uFE0F Alias: ${chalk2.cyan(accountName)}`);
|
|
7428
7860
|
}
|
|
7429
|
-
console.log(`\u{1F310} Context: ${
|
|
7861
|
+
console.log(`\u{1F310} Context: ${chalk2.magenta(contextName)}`);
|
|
7430
7862
|
console.log("");
|
|
7431
|
-
console.log(`\u{1F511} Address: ${
|
|
7863
|
+
console.log(`\u{1F511} Address: ${chalk2.dim(targetAddress)}`);
|
|
7432
7864
|
console.log(
|
|
7433
|
-
`\u{1F517} Aptos Explorer: ${
|
|
7865
|
+
`\u{1F517} Aptos Explorer: ${chalk2.blueBright.underline(aptosExplorerUrl)}`
|
|
7434
7866
|
);
|
|
7435
7867
|
console.log(
|
|
7436
|
-
`\u{1F5C2}\uFE0F Shelby Explorer: ${
|
|
7868
|
+
`\u{1F5C2}\uFE0F Shelby Explorer: ${chalk2.blueBright.underline(shelbyExplorerUrl)}`
|
|
7437
7869
|
);
|
|
7438
7870
|
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
7871
|
console.log("\n\u{1F4B0} Balance:\n");
|
|
@@ -7483,21 +7915,21 @@ function accountCommand(program) {
|
|
|
7483
7915
|
}
|
|
7484
7916
|
|
|
7485
7917
|
// src/commands/commitment.ts
|
|
7486
|
-
import * as
|
|
7918
|
+
import * as fs3 from "fs";
|
|
7487
7919
|
import * as fsP from "fs/promises";
|
|
7488
7920
|
import { Readable } from "stream";
|
|
7489
|
-
import { z as
|
|
7490
|
-
var CommitmentOptionsSchema =
|
|
7491
|
-
input:
|
|
7492
|
-
async (
|
|
7493
|
-
const stat4 = await fsP.stat(
|
|
7921
|
+
import { z as z11 } from "zod";
|
|
7922
|
+
var CommitmentOptionsSchema = z11.object({
|
|
7923
|
+
input: z11.string().nonempty("`--input` is required").refine(
|
|
7924
|
+
async (path7) => {
|
|
7925
|
+
const stat4 = await fsP.stat(path7);
|
|
7494
7926
|
return stat4.isFile();
|
|
7495
7927
|
},
|
|
7496
7928
|
{
|
|
7497
7929
|
message: "`--input` must be a file"
|
|
7498
7930
|
}
|
|
7499
7931
|
),
|
|
7500
|
-
output:
|
|
7932
|
+
output: z11.string().nonempty("`--output` is required")
|
|
7501
7933
|
});
|
|
7502
7934
|
function commitmentCommand(program) {
|
|
7503
7935
|
program.command("commitment <input> <output>").description(
|
|
@@ -7507,7 +7939,7 @@ function commitmentCommand(program) {
|
|
|
7507
7939
|
input,
|
|
7508
7940
|
output
|
|
7509
7941
|
});
|
|
7510
|
-
const inputFile =
|
|
7942
|
+
const inputFile = fs3.createReadStream(validatedOptions.input);
|
|
7511
7943
|
const provider = await getErasureCodingProvider();
|
|
7512
7944
|
const commitment = await generateCommitments(
|
|
7513
7945
|
provider,
|
|
@@ -7519,29 +7951,29 @@ function commitmentCommand(program) {
|
|
|
7519
7951
|
|
|
7520
7952
|
// src/commands/context.tsx
|
|
7521
7953
|
import { render as render2 } from "ink";
|
|
7522
|
-
import { z as
|
|
7954
|
+
import { z as z13 } from "zod";
|
|
7523
7955
|
|
|
7524
7956
|
// src/utils/commands.ts
|
|
7525
|
-
import
|
|
7526
|
-
var AptosCommandOptionsSchema =
|
|
7527
|
-
aptosNetwork:
|
|
7957
|
+
import z12 from "zod";
|
|
7958
|
+
var AptosCommandOptionsSchema = z12.object({
|
|
7959
|
+
aptosNetwork: z12.string().optional(),
|
|
7528
7960
|
// predefined network name
|
|
7529
|
-
aptosFullnode:
|
|
7530
|
-
aptosFaucet:
|
|
7531
|
-
aptosIndexer:
|
|
7532
|
-
aptosPepper:
|
|
7533
|
-
aptosProver:
|
|
7534
|
-
aptosApiKey:
|
|
7961
|
+
aptosFullnode: z12.string().url().optional(),
|
|
7962
|
+
aptosFaucet: z12.string().url().optional(),
|
|
7963
|
+
aptosIndexer: z12.string().url().optional(),
|
|
7964
|
+
aptosPepper: z12.string().url().optional(),
|
|
7965
|
+
aptosProver: z12.string().url().optional(),
|
|
7966
|
+
aptosApiKey: z12.string().optional()
|
|
7535
7967
|
});
|
|
7536
7968
|
var addAptosCommandOptions = (context) => context.option(
|
|
7537
7969
|
"--aptos-network <network>",
|
|
7538
7970
|
`Aptos network (${shelbyNetworks.join(", ")})`
|
|
7539
7971
|
).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 =
|
|
7972
|
+
var ShelbyCommandOptionsSchema = z12.object({
|
|
7541
7973
|
shelbyRpcEndpoint: EndpointSchema.optional(),
|
|
7542
7974
|
shelbyIndexerEndpoint: EndpointSchema.optional(),
|
|
7543
|
-
shelbyRpcApiKey:
|
|
7544
|
-
shelbyIndexerApiKey:
|
|
7975
|
+
shelbyRpcApiKey: z12.string().optional(),
|
|
7976
|
+
shelbyIndexerApiKey: z12.string().optional()
|
|
7545
7977
|
});
|
|
7546
7978
|
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
7979
|
|
|
@@ -7578,13 +8010,13 @@ function getShelbyNetworkFromOptions(options) {
|
|
|
7578
8010
|
indexer_api_key: options.shelbyIndexerApiKey
|
|
7579
8011
|
};
|
|
7580
8012
|
}
|
|
7581
|
-
var CreateContextOptionsSchema =
|
|
7582
|
-
var UpdateContextOptionsSchema =
|
|
8013
|
+
var CreateContextOptionsSchema = z13.object({ name: z13.string().optional() }).merge(AptosCommandOptionsSchema).merge(ShelbyCommandOptionsSchema);
|
|
8014
|
+
var UpdateContextOptionsSchema = z13.object({}).merge(ShelbyCommandOptionsSchema).merge(AptosCommandOptionsSchema);
|
|
7583
8015
|
function contextCommand(program) {
|
|
7584
8016
|
const context = program.command("context").description("Manage network contexts (Shelby RPC & Aptos endpoints)");
|
|
7585
8017
|
addShelbyCommandOptions(addAptosCommandOptions(context.command("create"))).description("Create a new context").option("--name <context-name>", "Name of the context").action((options) => {
|
|
7586
8018
|
CreateContextOptionsSchema.parse(options);
|
|
7587
|
-
const { name } = options;
|
|
8019
|
+
const { name: name2 } = options;
|
|
7588
8020
|
const aptosNetwork = getAptosNetworkFromOptions(options);
|
|
7589
8021
|
const shelbyNetwork = getShelbyNetworkFromOptions(options);
|
|
7590
8022
|
const configPath = program.opts().configFile;
|
|
@@ -7595,7 +8027,7 @@ function contextCommand(program) {
|
|
|
7595
8027
|
config = {
|
|
7596
8028
|
contexts: {},
|
|
7597
8029
|
accounts: {},
|
|
7598
|
-
default_context:
|
|
8030
|
+
default_context: name2 || "",
|
|
7599
8031
|
default_account: "default_account"
|
|
7600
8032
|
};
|
|
7601
8033
|
}
|
|
@@ -7605,10 +8037,10 @@ function contextCommand(program) {
|
|
|
7605
8037
|
const hasAptosNetworkChanges = Object.values(aptosNetwork).some(
|
|
7606
8038
|
(value) => value !== void 0
|
|
7607
8039
|
);
|
|
7608
|
-
if (
|
|
8040
|
+
if (name2 && (hasAptosNetworkChanges || hasShelbyNetworkChanges)) {
|
|
7609
8041
|
const validatedAptosNetwork = AptosNetworkSchema.parse(aptosNetwork);
|
|
7610
8042
|
const validatedShelbyNetwork = ShelbyNetworkSchema.parse(shelbyNetwork);
|
|
7611
|
-
config.contexts[
|
|
8043
|
+
config.contexts[name2] = {
|
|
7612
8044
|
shelby_network: {
|
|
7613
8045
|
...validatedShelbyNetwork,
|
|
7614
8046
|
// This is to ensure there are no trailing slashes
|
|
@@ -7620,7 +8052,7 @@ function contextCommand(program) {
|
|
|
7620
8052
|
aptos_network: validatedAptosNetwork
|
|
7621
8053
|
};
|
|
7622
8054
|
saveConfig(config, configPath);
|
|
7623
|
-
console.log(`\u2705 Context '${
|
|
8055
|
+
console.log(`\u2705 Context '${name2}' created successfully`);
|
|
7624
8056
|
return;
|
|
7625
8057
|
}
|
|
7626
8058
|
const { unmount } = render2(
|
|
@@ -7628,18 +8060,18 @@ function contextCommand(program) {
|
|
|
7628
8060
|
CreateContextWizard,
|
|
7629
8061
|
{
|
|
7630
8062
|
onComplete: ({
|
|
7631
|
-
name:
|
|
8063
|
+
name: name3,
|
|
7632
8064
|
apiKey,
|
|
7633
8065
|
shelbyNetwork: shelbyNetwork2,
|
|
7634
8066
|
aptosNetwork: aptosNetwork2
|
|
7635
8067
|
}) => {
|
|
7636
|
-
config.contexts[
|
|
8068
|
+
config.contexts[name3] = {
|
|
7637
8069
|
api_key: apiKey,
|
|
7638
8070
|
shelby_network: shelbyNetwork2,
|
|
7639
8071
|
aptos_network: aptosNetwork2
|
|
7640
8072
|
};
|
|
7641
8073
|
saveConfig(config, configPath);
|
|
7642
|
-
console.log(`\u2705 Context '${
|
|
8074
|
+
console.log(`\u2705 Context '${name3}' created successfully`);
|
|
7643
8075
|
unmount();
|
|
7644
8076
|
process.exit(0);
|
|
7645
8077
|
}
|
|
@@ -7849,22 +8281,22 @@ function contextCommand(program) {
|
|
|
7849
8281
|
|
|
7850
8282
|
// src/commands/download.tsx
|
|
7851
8283
|
import * as fsS from "fs";
|
|
7852
|
-
import * as
|
|
7853
|
-
import * as
|
|
8284
|
+
import * as fs4 from "fs/promises";
|
|
8285
|
+
import * as path4 from "path";
|
|
7854
8286
|
import { Readable as Readable2, Transform } from "stream";
|
|
7855
8287
|
import { pipeline } from "stream/promises";
|
|
7856
8288
|
import ora from "ora";
|
|
7857
|
-
import { z as
|
|
7858
|
-
var denormBlobName2 = (a, b, c) => denormBlobName(
|
|
7859
|
-
var DownloadOptionsSchema =
|
|
7860
|
-
source:
|
|
8289
|
+
import { z as z14 } from "zod";
|
|
8290
|
+
var denormBlobName2 = (a, b, c) => denormBlobName(path4, a, b, c);
|
|
8291
|
+
var DownloadOptionsSchema = z14.object({
|
|
8292
|
+
source: z14.string({
|
|
7861
8293
|
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
8294
|
}).min(1, "Source blob name or directory prefix is required").describe("Blob name or directory prefix to download"),
|
|
7863
|
-
destination:
|
|
8295
|
+
destination: z14.string({
|
|
7864
8296
|
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
8297
|
}).min(1, "`destination` must be a valid filepath").describe("Local path where to save the downloaded content"),
|
|
7866
|
-
recursive:
|
|
7867
|
-
force:
|
|
8298
|
+
recursive: z14.boolean().default(false).describe("Download assuming canonical directory layout and recurse"),
|
|
8299
|
+
force: z14.boolean().default(false).describe("Overwrite the destination if it already exists")
|
|
7868
8300
|
}).refine(
|
|
7869
8301
|
(data) => {
|
|
7870
8302
|
if (data.recursive) {
|
|
@@ -7937,9 +8369,9 @@ var DownloadOptionsSchema = z13.object({
|
|
|
7937
8369
|
}
|
|
7938
8370
|
);
|
|
7939
8371
|
async function validateOutput(options) {
|
|
7940
|
-
const parentDir =
|
|
8372
|
+
const parentDir = path4.dirname(options.destination);
|
|
7941
8373
|
try {
|
|
7942
|
-
const parentStats = await
|
|
8374
|
+
const parentStats = await fs4.stat(parentDir);
|
|
7943
8375
|
if (!parentStats.isDirectory()) {
|
|
7944
8376
|
throw new Error(
|
|
7945
8377
|
`Parent path '${parentDir}' exists but is not a directory. Cannot create destination ${options.recursive ? "directory" : "file"} '${options.destination}'.`
|
|
@@ -7956,7 +8388,7 @@ async function validateOutput(options) {
|
|
|
7956
8388
|
if (options.force) return;
|
|
7957
8389
|
let outputStats;
|
|
7958
8390
|
try {
|
|
7959
|
-
outputStats = await
|
|
8391
|
+
outputStats = await fs4.stat(options.destination);
|
|
7960
8392
|
} catch (error) {
|
|
7961
8393
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
7962
8394
|
return;
|
|
@@ -7975,7 +8407,7 @@ async function validateOutput(options) {
|
|
|
7975
8407
|
);
|
|
7976
8408
|
}
|
|
7977
8409
|
if (options.recursive) {
|
|
7978
|
-
const entries = await
|
|
8410
|
+
const entries = await fs4.readdir(options.destination);
|
|
7979
8411
|
if (entries.length > 0) {
|
|
7980
8412
|
throw new Error(
|
|
7981
8413
|
`Directory '${options.destination}' exists and is not empty. Use --force to overwrite or choose an empty directory.`
|
|
@@ -8042,12 +8474,12 @@ async function createFileList(options, nodeClient, account) {
|
|
|
8042
8474
|
async function createOutputDirectories(fileList) {
|
|
8043
8475
|
const uniqueDirectories = /* @__PURE__ */ new Set();
|
|
8044
8476
|
for (const fileEntry of fileList) {
|
|
8045
|
-
const parentDir =
|
|
8477
|
+
const parentDir = path4.dirname(fileEntry.filename);
|
|
8046
8478
|
uniqueDirectories.add(parentDir);
|
|
8047
8479
|
}
|
|
8048
8480
|
for (const dir of uniqueDirectories) {
|
|
8049
8481
|
try {
|
|
8050
|
-
await
|
|
8482
|
+
await fs4.mkdir(dir, { recursive: true });
|
|
8051
8483
|
} catch (error) {
|
|
8052
8484
|
throw new Error(
|
|
8053
8485
|
`Failed to create directory '${dir}': ${error instanceof Error ? error.message : error}`
|
|
@@ -8084,7 +8516,7 @@ function downloadCommand(program) {
|
|
|
8084
8516
|
destination
|
|
8085
8517
|
});
|
|
8086
8518
|
} catch (error) {
|
|
8087
|
-
if (error instanceof
|
|
8519
|
+
if (error instanceof z14.ZodError) {
|
|
8088
8520
|
const firstIssue = error.issues[0];
|
|
8089
8521
|
if (firstIssue) {
|
|
8090
8522
|
console.log(firstIssue.message);
|
|
@@ -8098,7 +8530,7 @@ function downloadCommand(program) {
|
|
|
8098
8530
|
}
|
|
8099
8531
|
process.exit(1);
|
|
8100
8532
|
}
|
|
8101
|
-
options.destination =
|
|
8533
|
+
options.destination = path4.resolve(options.destination);
|
|
8102
8534
|
let config;
|
|
8103
8535
|
let spinner;
|
|
8104
8536
|
const handleSigint = () => {
|
|
@@ -8127,13 +8559,13 @@ function downloadCommand(program) {
|
|
|
8127
8559
|
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
8560
|
for (let i = 0; i < fileList.length; i++) {
|
|
8129
8561
|
const fileEntry = fileList[i];
|
|
8130
|
-
const blobBaseName =
|
|
8562
|
+
const blobBaseName = path4.basename(fileEntry.blobname);
|
|
8131
8563
|
console.log(`${i + 1}. ${blobBaseName} \u2192 ${fileEntry.filename}`);
|
|
8132
8564
|
}
|
|
8133
8565
|
console.log();
|
|
8134
8566
|
if (options.force) {
|
|
8135
8567
|
console.log(`--force was set, so deleting ${options.destination}`);
|
|
8136
|
-
await
|
|
8568
|
+
await fs4.rm(options.destination, { recursive: true, force: true });
|
|
8137
8569
|
}
|
|
8138
8570
|
process.removeAllListeners("SIGINT");
|
|
8139
8571
|
process.on("SIGINT", handleSigint);
|
|
@@ -8151,7 +8583,7 @@ function downloadCommand(program) {
|
|
|
8151
8583
|
const formatProgressPercent = () => totalSize > 0 ? (100 * (amountDownloaded / totalSize)).toFixed(2) : "0.00";
|
|
8152
8584
|
for (const fileEntry of fileList) {
|
|
8153
8585
|
const out = fsS.createWriteStream(fileEntry.filename);
|
|
8154
|
-
const fileName =
|
|
8586
|
+
const fileName = path4.basename(fileEntry.blobname);
|
|
8155
8587
|
const { readable } = await nodeClient.rpc.getBlob({
|
|
8156
8588
|
account: activeAccount.accountAddress,
|
|
8157
8589
|
blobName: fileEntry.blobname
|
|
@@ -8242,10 +8674,10 @@ function downloadCommand(program) {
|
|
|
8242
8674
|
// src/commands/faucet.tsx
|
|
8243
8675
|
import { Network as Network9 } from "@aptos-labs/ts-sdk";
|
|
8244
8676
|
import { execaSync } from "execa";
|
|
8245
|
-
import { z as
|
|
8246
|
-
var FaucetOptionsSchema =
|
|
8247
|
-
network:
|
|
8248
|
-
open:
|
|
8677
|
+
import { z as z15 } from "zod";
|
|
8678
|
+
var FaucetOptionsSchema = z15.object({
|
|
8679
|
+
network: z15.enum([Network9.SHELBYNET]).optional(),
|
|
8680
|
+
open: z15.boolean().optional().default(true)
|
|
8249
8681
|
});
|
|
8250
8682
|
function faucetCommand(program) {
|
|
8251
8683
|
program.command("faucet").description("Open the Shelby faucet web page to request tokens").option("--network <network>", "Network to request tokens for (shelbynet)").option("--no-open", "Don't automatically open browser, just print the URL").action((options) => {
|
|
@@ -8316,9 +8748,9 @@ function openBrowser(url) {
|
|
|
8316
8748
|
}
|
|
8317
8749
|
|
|
8318
8750
|
// src/commands/init.tsx
|
|
8319
|
-
import
|
|
8751
|
+
import path5 from "path";
|
|
8320
8752
|
import { Network as Network10 } from "@aptos-labs/ts-sdk";
|
|
8321
|
-
import
|
|
8753
|
+
import fs5 from "fs-extra";
|
|
8322
8754
|
import { render as render3 } from "ink";
|
|
8323
8755
|
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
8324
8756
|
function initCommand(program) {
|
|
@@ -8447,12 +8879,12 @@ function cloneContexts(contexts) {
|
|
|
8447
8879
|
return JSON.parse(JSON.stringify(contexts));
|
|
8448
8880
|
}
|
|
8449
8881
|
function ensureConfigDir(resolvedPath) {
|
|
8450
|
-
|
|
8882
|
+
fs5.mkdirpSync(path5.dirname(resolvedPath));
|
|
8451
8883
|
}
|
|
8452
8884
|
|
|
8453
8885
|
// src/commands/upload.tsx
|
|
8454
|
-
import * as
|
|
8455
|
-
import * as
|
|
8886
|
+
import * as fs6 from "fs/promises";
|
|
8887
|
+
import * as path6 from "path";
|
|
8456
8888
|
import { Aptos as Aptos5, AptosConfig as AptosConfig4 } from "@aptos-labs/ts-sdk";
|
|
8457
8889
|
import * as chrono from "chrono-node";
|
|
8458
8890
|
import { glob } from "glob";
|
|
@@ -8460,7 +8892,7 @@ import ignore from "ignore";
|
|
|
8460
8892
|
import { Box as Box7, render as render4, Text as Text7 } from "ink";
|
|
8461
8893
|
import SelectInput4 from "ink-select-input";
|
|
8462
8894
|
import ora2 from "ora";
|
|
8463
|
-
import { z as
|
|
8895
|
+
import { z as z16 } from "zod";
|
|
8464
8896
|
|
|
8465
8897
|
// src/utils/commander-helpers.ts
|
|
8466
8898
|
function createExitOverrideHandler(commandName, requiredArgs, requiredOptions, exampleUsage, warningMessage) {
|
|
@@ -8511,8 +8943,8 @@ function createExitOverrideHandler(commandName, requiredArgs, requiredOptions, e
|
|
|
8511
8943
|
|
|
8512
8944
|
// src/commands/upload.tsx
|
|
8513
8945
|
import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
8514
|
-
var normBlobName2 = (i, f, b) => normBlobName(
|
|
8515
|
-
var flexibleDateSchema =
|
|
8946
|
+
var normBlobName2 = (i, f, b) => normBlobName(path6, i, f, b);
|
|
8947
|
+
var flexibleDateSchema = z16.string().transform((val, ctx) => {
|
|
8516
8948
|
const now = /* @__PURE__ */ new Date();
|
|
8517
8949
|
let parsedDate = null;
|
|
8518
8950
|
if (/^\d+$/.test(val)) {
|
|
@@ -8535,7 +8967,7 @@ var flexibleDateSchema = z15.string().transform((val, ctx) => {
|
|
|
8535
8967
|
}
|
|
8536
8968
|
if (!parsedDate || Number.isNaN(parsedDate.getTime())) {
|
|
8537
8969
|
ctx.addIssue({
|
|
8538
|
-
code:
|
|
8970
|
+
code: z16.ZodIssueCode.custom,
|
|
8539
8971
|
message: `
|
|
8540
8972
|
\u274C Upload Failed
|
|
8541
8973
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\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 +8981,11 @@ var flexibleDateSchema = z15.string().transform((val, ctx) => {
|
|
|
8549
8981
|
|
|
8550
8982
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\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
8983
|
});
|
|
8552
|
-
return
|
|
8984
|
+
return z16.NEVER;
|
|
8553
8985
|
}
|
|
8554
8986
|
if (parsedDate.getTime() <= now.getTime()) {
|
|
8555
8987
|
ctx.addIssue({
|
|
8556
|
-
code:
|
|
8988
|
+
code: z16.ZodIssueCode.custom,
|
|
8557
8989
|
message: `
|
|
8558
8990
|
\u274C Upload Failed
|
|
8559
8991
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\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 +8997,26 @@ var flexibleDateSchema = z15.string().transform((val, ctx) => {
|
|
|
8565
8997
|
|
|
8566
8998
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\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
8999
|
});
|
|
8568
|
-
return
|
|
9000
|
+
return z16.NEVER;
|
|
8569
9001
|
}
|
|
8570
9002
|
return parsedDate;
|
|
8571
9003
|
});
|
|
8572
|
-
var UploadOptionsSchema =
|
|
8573
|
-
source:
|
|
9004
|
+
var UploadOptionsSchema = z16.object({
|
|
9005
|
+
source: z16.string({
|
|
8574
9006
|
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
9007
|
}).min(1, "Source file or directory path is required"),
|
|
8576
|
-
destination:
|
|
9008
|
+
destination: z16.string({
|
|
8577
9009
|
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
9010
|
}).min(1, "Destination blob name is required"),
|
|
8579
9011
|
expiration: flexibleDateSchema,
|
|
8580
|
-
recursive:
|
|
8581
|
-
assumeYes:
|
|
8582
|
-
outputCommitments:
|
|
9012
|
+
recursive: z16.boolean().optional().default(false),
|
|
9013
|
+
assumeYes: z16.boolean().optional().default(false),
|
|
9014
|
+
outputCommitments: z16.string().optional()
|
|
8583
9015
|
}).superRefine(async (data, ctx) => {
|
|
8584
|
-
const stats = await
|
|
9016
|
+
const stats = await fs6.stat(data.source);
|
|
8585
9017
|
if (!stats.isFile() && !stats.isDirectory()) {
|
|
8586
9018
|
ctx.addIssue({
|
|
8587
|
-
code:
|
|
9019
|
+
code: z16.ZodIssueCode.custom,
|
|
8588
9020
|
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
9021
|
path: ["source"]
|
|
8590
9022
|
});
|
|
@@ -8593,7 +9025,7 @@ var UploadOptionsSchema = z15.object({
|
|
|
8593
9025
|
if (stats.isDirectory()) {
|
|
8594
9026
|
if (!data.destination.endsWith("/")) {
|
|
8595
9027
|
ctx.addIssue({
|
|
8596
|
-
code:
|
|
9028
|
+
code: z16.ZodIssueCode.custom,
|
|
8597
9029
|
message: `
|
|
8598
9030
|
\u274C Upload Failed
|
|
8599
9031
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\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 +9043,7 @@ var UploadOptionsSchema = z15.object({
|
|
|
8611
9043
|
const blobNameResult = BlobNameSchema.safeParse(data.destination);
|
|
8612
9044
|
if (!blobNameResult.success) {
|
|
8613
9045
|
ctx.addIssue({
|
|
8614
|
-
code:
|
|
9046
|
+
code: z16.ZodIssueCode.custom,
|
|
8615
9047
|
message: `
|
|
8616
9048
|
\u274C Upload Failed
|
|
8617
9049
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\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 +9060,7 @@ var UploadOptionsSchema = z15.object({
|
|
|
8628
9060
|
}
|
|
8629
9061
|
});
|
|
8630
9062
|
async function buildGitignoreMap(root) {
|
|
8631
|
-
const resolvedRoot =
|
|
9063
|
+
const resolvedRoot = path6.resolve(root);
|
|
8632
9064
|
const gitignoreMap = /* @__PURE__ */ new Map();
|
|
8633
9065
|
const ensureMatcher = (dir) => {
|
|
8634
9066
|
const existing = gitignoreMap.get(dir);
|
|
@@ -8648,8 +9080,8 @@ async function buildGitignoreMap(root) {
|
|
|
8648
9080
|
});
|
|
8649
9081
|
for (const gitignorePath of gitignoreFiles) {
|
|
8650
9082
|
try {
|
|
8651
|
-
const contents = await
|
|
8652
|
-
const directory =
|
|
9083
|
+
const contents = await fs6.readFile(gitignorePath, "utf8");
|
|
9084
|
+
const directory = path6.dirname(gitignorePath);
|
|
8653
9085
|
ensureMatcher(directory).add(contents);
|
|
8654
9086
|
} catch (error) {
|
|
8655
9087
|
if (error instanceof Error && Object.hasOwn(error, "code") && // biome-ignore lint/suspicious/noExplicitAny: node fs error type
|
|
@@ -8663,13 +9095,13 @@ async function buildGitignoreMap(root) {
|
|
|
8663
9095
|
}
|
|
8664
9096
|
function collectDirectoriesFromRoot(root, filePath) {
|
|
8665
9097
|
const directories = [];
|
|
8666
|
-
let current =
|
|
9098
|
+
let current = path6.dirname(filePath);
|
|
8667
9099
|
while (true) {
|
|
8668
9100
|
directories.push(current);
|
|
8669
9101
|
if (current === root) {
|
|
8670
9102
|
break;
|
|
8671
9103
|
}
|
|
8672
|
-
const parent =
|
|
9104
|
+
const parent = path6.dirname(current);
|
|
8673
9105
|
if (parent === current) {
|
|
8674
9106
|
break;
|
|
8675
9107
|
}
|
|
@@ -8685,7 +9117,7 @@ function shouldIgnorePath(gitignoreMap, root, filePath) {
|
|
|
8685
9117
|
if (!matcher) {
|
|
8686
9118
|
continue;
|
|
8687
9119
|
}
|
|
8688
|
-
const relative2 =
|
|
9120
|
+
const relative2 = path6.relative(directory, filePath).split(path6.sep).join("/");
|
|
8689
9121
|
const result = matcher.test(relative2);
|
|
8690
9122
|
if (result.ignored) {
|
|
8691
9123
|
ignored = true;
|
|
@@ -8697,7 +9129,7 @@ function shouldIgnorePath(gitignoreMap, root, filePath) {
|
|
|
8697
9129
|
return ignored;
|
|
8698
9130
|
}
|
|
8699
9131
|
async function createFilelist(options) {
|
|
8700
|
-
const stats = await
|
|
9132
|
+
const stats = await fs6.stat(options.source);
|
|
8701
9133
|
if (stats.isFile()) {
|
|
8702
9134
|
const blobname = normBlobName2(
|
|
8703
9135
|
options.source,
|
|
@@ -8717,7 +9149,7 @@ async function createFilelist(options) {
|
|
|
8717
9149
|
`${options.source} is a directory. Use --recursive to upload directories.`
|
|
8718
9150
|
);
|
|
8719
9151
|
}
|
|
8720
|
-
const sourceRoot =
|
|
9152
|
+
const sourceRoot = path6.resolve(options.source);
|
|
8721
9153
|
const gitignoreMap = await buildGitignoreMap(sourceRoot);
|
|
8722
9154
|
const fileList = [];
|
|
8723
9155
|
const result = await glob("**/*", {
|
|
@@ -8730,7 +9162,7 @@ async function createFilelist(options) {
|
|
|
8730
9162
|
if (shouldIgnorePath(gitignoreMap, sourceRoot, file)) {
|
|
8731
9163
|
continue;
|
|
8732
9164
|
}
|
|
8733
|
-
const stats2 = await
|
|
9165
|
+
const stats2 = await fs6.stat(file);
|
|
8734
9166
|
if (!stats2.isFile()) {
|
|
8735
9167
|
continue;
|
|
8736
9168
|
}
|
|
@@ -8782,7 +9214,7 @@ function uploadCommand(program) {
|
|
|
8782
9214
|
destination
|
|
8783
9215
|
});
|
|
8784
9216
|
} catch (error) {
|
|
8785
|
-
if (error instanceof
|
|
9217
|
+
if (error instanceof z16.ZodError) {
|
|
8786
9218
|
const firstIssue = error.issues[0];
|
|
8787
9219
|
if (firstIssue) {
|
|
8788
9220
|
console.log(firstIssue.message);
|
|
@@ -8894,11 +9326,11 @@ function uploadCommand(program) {
|
|
|
8894
9326
|
const formatProgressPercent = () => totalSize > 0 ? (100 * (amountUploaded / totalSize)).toFixed(2) : "0.00";
|
|
8895
9327
|
let filesProcessed = 0;
|
|
8896
9328
|
for (const entry of filelist) {
|
|
8897
|
-
const fileName =
|
|
9329
|
+
const fileName = path6.basename(entry.filename);
|
|
8898
9330
|
const fileProgress = isSingleFile ? `(${formatProgressPercent()}%)` : `(${filesProcessed}/${filelist.length} files, ${formatProgressPercent()}%)`;
|
|
8899
9331
|
spinner.text = `\u{1F4D6} Reading ${fileName}... ${fileProgress}`;
|
|
8900
9332
|
try {
|
|
8901
|
-
const blobData = await
|
|
9333
|
+
const blobData = await fs6.readFile(entry.filename);
|
|
8902
9334
|
if (blobData.length !== entry.sizeBytes) {
|
|
8903
9335
|
throw new Error(
|
|
8904
9336
|
`Size of file ${entry.filename} changed after initial scan. Original size was ${entry.sizeBytes} but it is now ${blobData.length}`
|
|
@@ -8951,7 +9383,7 @@ function uploadCommand(program) {
|
|
|
8951
9383
|
}
|
|
8952
9384
|
}
|
|
8953
9385
|
if (validatedOptions.outputCommitments) {
|
|
8954
|
-
await
|
|
9386
|
+
await fs6.writeFile(
|
|
8955
9387
|
validatedOptions.outputCommitments,
|
|
8956
9388
|
JSON.stringify(outputCommitments)
|
|
8957
9389
|
);
|
|
@@ -9020,6 +9452,7 @@ function createProgram() {
|
|
|
9020
9452
|
|
|
9021
9453
|
// src/entry.ts
|
|
9022
9454
|
function main() {
|
|
9455
|
+
checkForUpdatesAsync();
|
|
9023
9456
|
const rawArgs = process.argv.slice(2);
|
|
9024
9457
|
const normalizedArgs = rawArgs[0] === "--" ? rawArgs.slice(1) : rawArgs;
|
|
9025
9458
|
createProgram().parse([process.argv[0], process.argv[1], ...normalizedArgs]);
|