@shelby-protocol/cli 0.0.9 → 0.0.11
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 +581 -782
- package/package.json +5 -5
package/bin/entry.js
CHANGED
|
@@ -4,10 +4,16 @@
|
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
|
|
6
6
|
// package.json
|
|
7
|
-
var version = "0.0.
|
|
7
|
+
var version = "0.0.11";
|
|
8
8
|
|
|
9
9
|
// src/commands/account.tsx
|
|
10
|
-
import
|
|
10
|
+
import readline from "readline";
|
|
11
|
+
import {
|
|
12
|
+
Account as Account3,
|
|
13
|
+
AptosApiError as AptosApiError2,
|
|
14
|
+
Ed25519PrivateKey as Ed25519PrivateKey4,
|
|
15
|
+
Hex as Hex4
|
|
16
|
+
} from "@aptos-labs/ts-sdk";
|
|
11
17
|
|
|
12
18
|
// ../../packages/sdk/dist/chunk-RBFWGDMY.mjs
|
|
13
19
|
import { AptosConfig, Network } from "@aptos-labs/ts-sdk";
|
|
@@ -69,7 +75,7 @@ import {
|
|
|
69
75
|
|
|
70
76
|
// ../../packages/sdk/dist/chunk-I6NG5GNL.mjs
|
|
71
77
|
function sleep(ms) {
|
|
72
|
-
return new Promise((
|
|
78
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
// ../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
|
|
@@ -229,10 +235,10 @@ var GraphQLError = class _GraphQLError extends Error {
|
|
|
229
235
|
*/
|
|
230
236
|
constructor(message, ...rawArgs) {
|
|
231
237
|
var _this$nodes, _nodeLocations$, _ref;
|
|
232
|
-
const { nodes, source, positions, path:
|
|
238
|
+
const { nodes, source, positions, path: path6, originalError, extensions } = toNormalizedOptions(rawArgs);
|
|
233
239
|
super(message);
|
|
234
240
|
this.name = "GraphQLError";
|
|
235
|
-
this.path =
|
|
241
|
+
this.path = path6 !== null && path6 !== void 0 ? path6 : void 0;
|
|
236
242
|
this.originalError = originalError !== null && originalError !== void 0 ? originalError : void 0;
|
|
237
243
|
this.nodes = undefinedIfEmpty(
|
|
238
244
|
Array.isArray(nodes) ? nodes : nodes ? [nodes] : void 0
|
|
@@ -2800,14 +2806,14 @@ function visit(root, visitor, visitorKeys = QueryDocumentKeys) {
|
|
|
2800
2806
|
let node = root;
|
|
2801
2807
|
let key = void 0;
|
|
2802
2808
|
let parent = void 0;
|
|
2803
|
-
const
|
|
2809
|
+
const path6 = [];
|
|
2804
2810
|
const ancestors = [];
|
|
2805
2811
|
do {
|
|
2806
2812
|
index++;
|
|
2807
2813
|
const isLeaving = index === keys.length;
|
|
2808
2814
|
const isEdited = isLeaving && edits.length !== 0;
|
|
2809
2815
|
if (isLeaving) {
|
|
2810
|
-
key = ancestors.length === 0 ? void 0 :
|
|
2816
|
+
key = ancestors.length === 0 ? void 0 : path6[path6.length - 1];
|
|
2811
2817
|
node = parent;
|
|
2812
2818
|
parent = ancestors.pop();
|
|
2813
2819
|
if (isEdited) {
|
|
@@ -2841,20 +2847,20 @@ function visit(root, visitor, visitorKeys = QueryDocumentKeys) {
|
|
|
2841
2847
|
if (node === null || node === void 0) {
|
|
2842
2848
|
continue;
|
|
2843
2849
|
}
|
|
2844
|
-
|
|
2850
|
+
path6.push(key);
|
|
2845
2851
|
}
|
|
2846
2852
|
let result;
|
|
2847
2853
|
if (!Array.isArray(node)) {
|
|
2848
2854
|
var _enterLeaveMap$get, _enterLeaveMap$get2;
|
|
2849
2855
|
isNode(node) || devAssert(false, `Invalid AST Node: ${inspect(node)}.`);
|
|
2850
2856
|
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;
|
|
2851
|
-
result = visitFn === null || visitFn === void 0 ? void 0 : visitFn.call(visitor, node, key, parent,
|
|
2857
|
+
result = visitFn === null || visitFn === void 0 ? void 0 : visitFn.call(visitor, node, key, parent, path6, ancestors);
|
|
2852
2858
|
if (result === BREAK) {
|
|
2853
2859
|
break;
|
|
2854
2860
|
}
|
|
2855
2861
|
if (result === false) {
|
|
2856
2862
|
if (!isLeaving) {
|
|
2857
|
-
|
|
2863
|
+
path6.pop();
|
|
2858
2864
|
continue;
|
|
2859
2865
|
}
|
|
2860
2866
|
} else if (result !== void 0) {
|
|
@@ -2863,7 +2869,7 @@ function visit(root, visitor, visitorKeys = QueryDocumentKeys) {
|
|
|
2863
2869
|
if (isNode(result)) {
|
|
2864
2870
|
node = result;
|
|
2865
2871
|
} else {
|
|
2866
|
-
|
|
2872
|
+
path6.pop();
|
|
2867
2873
|
continue;
|
|
2868
2874
|
}
|
|
2869
2875
|
}
|
|
@@ -2873,7 +2879,7 @@ function visit(root, visitor, visitorKeys = QueryDocumentKeys) {
|
|
|
2873
2879
|
edits.push([key, node]);
|
|
2874
2880
|
}
|
|
2875
2881
|
if (isLeaving) {
|
|
2876
|
-
|
|
2882
|
+
path6.pop();
|
|
2877
2883
|
} else {
|
|
2878
2884
|
var _node$kind;
|
|
2879
2885
|
stack = {
|
|
@@ -3319,7 +3325,7 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
3319
3325
|
};
|
|
3320
3326
|
}
|
|
3321
3327
|
|
|
3322
|
-
// ../../packages/sdk/dist/chunk-
|
|
3328
|
+
// ../../packages/sdk/dist/chunk-57KKLRIW.mjs
|
|
3323
3329
|
import { Network as Network3 } from "@aptos-labs/ts-sdk";
|
|
3324
3330
|
|
|
3325
3331
|
// ../../node_modules/.pnpm/graphql-request@7.2.0_graphql@16.11.0/node_modules/graphql-request/build/legacy/classes/ClientError.js
|
|
@@ -3834,14 +3840,14 @@ var parseRequestArgs = (documentOrOptions, variables, requestHeaders) => {
|
|
|
3834
3840
|
};
|
|
3835
3841
|
};
|
|
3836
3842
|
|
|
3837
|
-
// ../../packages/sdk/dist/chunk-
|
|
3843
|
+
// ../../packages/sdk/dist/chunk-57KKLRIW.mjs
|
|
3838
3844
|
function createShelbyIndexerClient(baseUrl, options) {
|
|
3839
3845
|
const graphqlClient = new GraphQLClient(baseUrl, options);
|
|
3840
3846
|
return getSdk(graphqlClient);
|
|
3841
3847
|
}
|
|
3842
3848
|
function getShelbyIndexerClient(config) {
|
|
3843
3849
|
const aptosConfig = config.aptos ?? getAptosConfig(config);
|
|
3844
|
-
let { apiKey, baseUrl } = config.indexer ?? {};
|
|
3850
|
+
let { apiKey: indexerApiKey, baseUrl } = config.indexer ?? {};
|
|
3845
3851
|
if (!baseUrl) {
|
|
3846
3852
|
switch (aptosConfig?.network) {
|
|
3847
3853
|
// TODO: Add endpoints for core networks
|
|
@@ -3858,6 +3864,7 @@ function getShelbyIndexerClient(config) {
|
|
|
3858
3864
|
"The ShelbyClientConfig does not support the Shelby indexer. Please configure the endpoint in the ShelbyClientConfig.indexer.endpoint or provide a supported Aptos network."
|
|
3859
3865
|
);
|
|
3860
3866
|
}
|
|
3867
|
+
const apiKey = indexerApiKey ?? config.apiKey;
|
|
3861
3868
|
return createShelbyIndexerClient(baseUrl, {
|
|
3862
3869
|
headers: {
|
|
3863
3870
|
...apiKey ? { Authorization: `Bearer ${apiKey}` } : {},
|
|
@@ -3945,10 +3952,10 @@ function isReadableStream(value) {
|
|
|
3945
3952
|
function toUint8Array(view) {
|
|
3946
3953
|
return view instanceof Uint8Array ? view : new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
|
|
3947
3954
|
}
|
|
3948
|
-
function buildRequestUrl(
|
|
3955
|
+
function buildRequestUrl(path6, baseUrl) {
|
|
3949
3956
|
const baseHasSlash = baseUrl.endsWith("/");
|
|
3950
3957
|
const safeBase = baseHasSlash ? baseUrl : `${baseUrl}/`;
|
|
3951
|
-
const safePath =
|
|
3958
|
+
const safePath = path6.replace(/^\/+/, "");
|
|
3952
3959
|
return new URL(safePath, safeBase);
|
|
3953
3960
|
}
|
|
3954
3961
|
|
|
@@ -3980,395 +3987,11 @@ var DEFAULT_ERASURE_D = ERASURE_CODE_PARAMS[
|
|
|
3980
3987
|
].erasure_d;
|
|
3981
3988
|
var DEFAULT_ERASURE_M = DEFAULT_ERASURE_N - DEFAULT_ERASURE_K;
|
|
3982
3989
|
|
|
3983
|
-
// ../../packages/clay-codes/dist/chunk-ST33RHQN.js
|
|
3984
|
-
var alignToMask = (value, mask) => value + mask & ~mask;
|
|
3985
|
-
function createBumpAllocator(memory, initialHeap, alignMask, pageSize, onGrow) {
|
|
3986
|
-
let heap = alignToMask(initialHeap, alignMask);
|
|
3987
|
-
const ensureCapacity = (end) => {
|
|
3988
|
-
while (end > memory.buffer.byteLength) {
|
|
3989
|
-
const deficit = end - memory.buffer.byteLength;
|
|
3990
|
-
const pages = Math.ceil(deficit / pageSize);
|
|
3991
|
-
memory.grow(Math.max(pages, 1));
|
|
3992
|
-
onGrow();
|
|
3993
|
-
}
|
|
3994
|
-
};
|
|
3995
|
-
const allocate = (size, customAlignMask = alignMask) => {
|
|
3996
|
-
const ptr = alignToMask(heap, customAlignMask);
|
|
3997
|
-
heap = alignToMask(ptr + size, alignMask);
|
|
3998
|
-
ensureCapacity(heap);
|
|
3999
|
-
return ptr;
|
|
4000
|
-
};
|
|
4001
|
-
return allocate;
|
|
4002
|
-
}
|
|
4003
|
-
function createWasmWorkspace(memory, initialHeap, { alignMask, pageSize }) {
|
|
4004
|
-
let buffer = memory.buffer;
|
|
4005
|
-
const refreshCallbacks = /* @__PURE__ */ new Set();
|
|
4006
|
-
const refreshAll = () => {
|
|
4007
|
-
buffer = memory.buffer;
|
|
4008
|
-
for (const callback of refreshCallbacks) callback();
|
|
4009
|
-
};
|
|
4010
|
-
const alloc = createBumpAllocator(
|
|
4011
|
-
memory,
|
|
4012
|
-
initialHeap,
|
|
4013
|
-
alignMask,
|
|
4014
|
-
pageSize,
|
|
4015
|
-
refreshAll
|
|
4016
|
-
);
|
|
4017
|
-
const createStagingBuffer = (size) => {
|
|
4018
|
-
const pointer = alloc(size);
|
|
4019
|
-
let view = new Uint8Array(buffer, pointer, size);
|
|
4020
|
-
const refresh = () => {
|
|
4021
|
-
view = new Uint8Array(memory.buffer, pointer, size);
|
|
4022
|
-
};
|
|
4023
|
-
refreshCallbacks.add(refresh);
|
|
4024
|
-
return {
|
|
4025
|
-
get pointer() {
|
|
4026
|
-
return pointer;
|
|
4027
|
-
},
|
|
4028
|
-
write(data) {
|
|
4029
|
-
if (data.byteLength !== size) {
|
|
4030
|
-
throw new Error(
|
|
4031
|
-
`Staging buffer expected ${size} bytes but received ${data.byteLength}`
|
|
4032
|
-
);
|
|
4033
|
-
}
|
|
4034
|
-
view.set(data);
|
|
4035
|
-
},
|
|
4036
|
-
read() {
|
|
4037
|
-
return view.slice();
|
|
4038
|
-
}
|
|
4039
|
-
};
|
|
4040
|
-
};
|
|
4041
|
-
return { alloc, createStagingBuffer };
|
|
4042
|
-
}
|
|
4043
|
-
|
|
4044
|
-
// ../../packages/clay-codes/dist/chunk-22OVODFS.js
|
|
4045
|
-
function normaliseChunkInput(input, expectedCount, chunkSize, label) {
|
|
4046
|
-
const total = expectedCount * chunkSize;
|
|
4047
|
-
const err = (msg) => new Error(`${label} ${msg}`);
|
|
4048
|
-
if (Array.isArray(input)) {
|
|
4049
|
-
if (input.length !== expectedCount) {
|
|
4050
|
-
throw err(
|
|
4051
|
-
`expected ${expectedCount} chunks but received ${input.length}`
|
|
4052
|
-
);
|
|
4053
|
-
}
|
|
4054
|
-
input.forEach((chunk, i) => {
|
|
4055
|
-
if (chunk.byteLength !== chunkSize) {
|
|
4056
|
-
throw err(
|
|
4057
|
-
`expected chunk ${i} to be ${chunkSize} bytes but received ${chunk.byteLength} bytes`
|
|
4058
|
-
);
|
|
4059
|
-
}
|
|
4060
|
-
});
|
|
4061
|
-
return input;
|
|
4062
|
-
}
|
|
4063
|
-
if (input.byteLength !== total) {
|
|
4064
|
-
throw err(
|
|
4065
|
-
`expected buffer to be ${total} bytes but received ${input.byteLength} bytes`
|
|
4066
|
-
);
|
|
4067
|
-
}
|
|
4068
|
-
const chunks = new Array(expectedCount);
|
|
4069
|
-
for (let i = 0; i < expectedCount; i++) {
|
|
4070
|
-
const start = i * chunkSize;
|
|
4071
|
-
const end = start + chunkSize;
|
|
4072
|
-
chunks[i] = input.subarray(start, end);
|
|
4073
|
-
}
|
|
4074
|
-
return chunks;
|
|
4075
|
-
}
|
|
4076
|
-
function buildChunkCollection(chunks, k) {
|
|
4077
|
-
return {
|
|
4078
|
-
chunks,
|
|
4079
|
-
systematic: chunks.slice(0, k),
|
|
4080
|
-
parity: chunks.slice(k)
|
|
4081
|
-
};
|
|
4082
|
-
}
|
|
4083
|
-
|
|
4084
|
-
// ../../packages/clay-codes/dist/chunk-N26WXNR7.js
|
|
4085
|
-
var DEFAULT_ALIGNMENT = 64;
|
|
4086
|
-
var DEFAULT_ALIGN_MASK = DEFAULT_ALIGNMENT - 1;
|
|
4087
|
-
var DEFAULT_PAGE_SIZE = 65536;
|
|
4088
|
-
var CLAY_PARAMS_BYTES = 64;
|
|
4089
|
-
|
|
4090
|
-
// ../../packages/clay-codes/dist/chunk-XAN62WH2.js
|
|
4091
|
-
var InvalidChunkIndexError = class extends Error {
|
|
4092
|
-
constructor(index, reason) {
|
|
4093
|
-
super(`Invalid chunk index ${index}: ${reason}`);
|
|
4094
|
-
this.index = index;
|
|
4095
|
-
this.name = "InvalidChunkIndexError";
|
|
4096
|
-
}
|
|
4097
|
-
};
|
|
4098
|
-
var DuplicateChunkIndexError = class extends Error {
|
|
4099
|
-
constructor(index) {
|
|
4100
|
-
super(`Duplicate chunk index ${index}`);
|
|
4101
|
-
this.index = index;
|
|
4102
|
-
this.name = "DuplicateChunkIndexError";
|
|
4103
|
-
}
|
|
4104
|
-
};
|
|
4105
|
-
|
|
4106
|
-
// ../../packages/clay-codes/dist/chunk-F5HTEQPI.js
|
|
4107
|
-
var MAX_WASM_MASK_BITS = 32;
|
|
4108
|
-
function toMaskFromIndexes(indexes, totalChunks) {
|
|
4109
|
-
let mask = 0;
|
|
4110
|
-
for (const idx of indexes) {
|
|
4111
|
-
if (!Number.isInteger(idx) || idx < 0) {
|
|
4112
|
-
throw new InvalidChunkIndexError(idx, "not a valid non-negative integer");
|
|
4113
|
-
}
|
|
4114
|
-
if (idx >= totalChunks) {
|
|
4115
|
-
throw new InvalidChunkIndexError(
|
|
4116
|
-
idx,
|
|
4117
|
-
`exceeds total chunks (${totalChunks})`
|
|
4118
|
-
);
|
|
4119
|
-
}
|
|
4120
|
-
if (idx >= MAX_WASM_MASK_BITS) {
|
|
4121
|
-
throw new InvalidChunkIndexError(
|
|
4122
|
-
idx,
|
|
4123
|
-
`exceeds mask width (${MAX_WASM_MASK_BITS} bits)`
|
|
4124
|
-
);
|
|
4125
|
-
}
|
|
4126
|
-
const bit = 1 << idx;
|
|
4127
|
-
if (mask & bit) {
|
|
4128
|
-
throw new DuplicateChunkIndexError(idx);
|
|
4129
|
-
}
|
|
4130
|
-
mask |= bit;
|
|
4131
|
-
}
|
|
4132
|
-
return mask >>> 0;
|
|
4133
|
-
}
|
|
4134
|
-
function erasedMaskFromAvailable(availableIndexes, totalChunks) {
|
|
4135
|
-
const available = /* @__PURE__ */ new Set();
|
|
4136
|
-
for (const idx of availableIndexes) {
|
|
4137
|
-
if (!Number.isInteger(idx) || idx < 0) {
|
|
4138
|
-
throw new InvalidChunkIndexError(idx, "not a valid non-negative integer");
|
|
4139
|
-
}
|
|
4140
|
-
if (idx >= totalChunks) {
|
|
4141
|
-
throw new InvalidChunkIndexError(
|
|
4142
|
-
idx,
|
|
4143
|
-
`exceeds total chunks (${totalChunks})`
|
|
4144
|
-
);
|
|
4145
|
-
}
|
|
4146
|
-
if (idx >= MAX_WASM_MASK_BITS) {
|
|
4147
|
-
throw new InvalidChunkIndexError(
|
|
4148
|
-
idx,
|
|
4149
|
-
`exceeds mask width (${MAX_WASM_MASK_BITS} bits)`
|
|
4150
|
-
);
|
|
4151
|
-
}
|
|
4152
|
-
if (available.has(idx)) {
|
|
4153
|
-
throw new DuplicateChunkIndexError(idx);
|
|
4154
|
-
}
|
|
4155
|
-
available.add(idx);
|
|
4156
|
-
}
|
|
4157
|
-
let mask = 0;
|
|
4158
|
-
for (let idx = 0; idx < totalChunks; idx++) {
|
|
4159
|
-
if (!available.has(idx)) {
|
|
4160
|
-
mask |= 1 << idx;
|
|
4161
|
-
}
|
|
4162
|
-
}
|
|
4163
|
-
return mask >>> 0;
|
|
4164
|
-
}
|
|
4165
|
-
function convertToErasedMask(options, totalChunks) {
|
|
4166
|
-
if ("erasedChunksMask" in options) {
|
|
4167
|
-
return options.erasedChunksMask >>> 0;
|
|
4168
|
-
}
|
|
4169
|
-
if ("erasedChunkIndexes" in options) {
|
|
4170
|
-
return toMaskFromIndexes(options.erasedChunkIndexes, totalChunks);
|
|
4171
|
-
}
|
|
4172
|
-
return erasedMaskFromAvailable(options.availableChunkIndexes, totalChunks);
|
|
4173
|
-
}
|
|
4174
|
-
function makeDecoderAPI(instance, opts) {
|
|
4175
|
-
const exp = instance.exports;
|
|
4176
|
-
const workspace = createWasmWorkspace(exp.memory, exp.__heap_base.value, {
|
|
4177
|
-
alignMask: DEFAULT_ALIGN_MASK,
|
|
4178
|
-
pageSize: DEFAULT_PAGE_SIZE
|
|
4179
|
-
});
|
|
4180
|
-
const paramsPtr = workspace.alloc(CLAY_PARAMS_BYTES, DEFAULT_ALIGN_MASK);
|
|
4181
|
-
exp.clay_params_init(paramsPtr, opts.n, opts.k, opts.d, opts.chunkSizeBytes);
|
|
4182
|
-
if (typeof exp.clay_decoder_footprint !== "function") {
|
|
4183
|
-
throw new Error(
|
|
4184
|
-
"Decoder footprint export not available in wasm module; bindings expect a dedicated decoder footprint entry point."
|
|
4185
|
-
);
|
|
4186
|
-
}
|
|
4187
|
-
const decoderSize = exp.clay_decoder_footprint(paramsPtr);
|
|
4188
|
-
const decoderPtr = workspace.alloc(decoderSize);
|
|
4189
|
-
const staging = workspace.createStagingBuffer(opts.chunkSizeBytes);
|
|
4190
|
-
const missingIndexes = /* @__PURE__ */ new Set();
|
|
4191
|
-
const availableIndexes = [];
|
|
4192
|
-
const staged = /* @__PURE__ */ new Set();
|
|
4193
|
-
const applyMask = (mask) => {
|
|
4194
|
-
missingIndexes.clear();
|
|
4195
|
-
availableIndexes.length = 0;
|
|
4196
|
-
for (let idx = 0; idx < opts.n; idx++) {
|
|
4197
|
-
if (mask >>> idx & 1) {
|
|
4198
|
-
missingIndexes.add(idx);
|
|
4199
|
-
} else {
|
|
4200
|
-
availableIndexes.push(idx);
|
|
4201
|
-
}
|
|
4202
|
-
}
|
|
4203
|
-
};
|
|
4204
|
-
const initialMask = convertToErasedMask(opts, opts.n);
|
|
4205
|
-
const returnedPtr = exp.clay_decoder_init_mds(
|
|
4206
|
-
decoderPtr,
|
|
4207
|
-
initialMask,
|
|
4208
|
-
paramsPtr
|
|
4209
|
-
);
|
|
4210
|
-
const activeDecoderPtr = returnedPtr || decoderPtr;
|
|
4211
|
-
applyMask(initialMask);
|
|
4212
|
-
let cachedMask = initialMask;
|
|
4213
|
-
const setChunk = (idx, data) => {
|
|
4214
|
-
if (missingIndexes.has(idx)) {
|
|
4215
|
-
throw new Error(`Chunk ${idx} is marked erased and cannot be staged`);
|
|
4216
|
-
}
|
|
4217
|
-
if (data.byteLength !== opts.chunkSizeBytes) {
|
|
4218
|
-
throw new Error(
|
|
4219
|
-
`Chunk ${idx} length ${data.byteLength} does not match chunkSizeBytes ${opts.chunkSizeBytes}`
|
|
4220
|
-
);
|
|
4221
|
-
}
|
|
4222
|
-
staging.write(data);
|
|
4223
|
-
exp.clay_decoder_set_slice(
|
|
4224
|
-
activeDecoderPtr,
|
|
4225
|
-
idx,
|
|
4226
|
-
staging.pointer,
|
|
4227
|
-
opts.chunkSizeBytes
|
|
4228
|
-
);
|
|
4229
|
-
staged.add(idx);
|
|
4230
|
-
};
|
|
4231
|
-
const run = () => {
|
|
4232
|
-
if (staged.size < opts.k) {
|
|
4233
|
-
throw new Error(
|
|
4234
|
-
`Decoder requires at least ${opts.k} staged chunks but only ${staged.size} provided`
|
|
4235
|
-
);
|
|
4236
|
-
}
|
|
4237
|
-
exp.clay_decoder_run(activeDecoderPtr);
|
|
4238
|
-
};
|
|
4239
|
-
const getChunk = (idx) => {
|
|
4240
|
-
exp.clay_decoder_get_chunk(activeDecoderPtr, idx, staging.pointer);
|
|
4241
|
-
return staging.read();
|
|
4242
|
-
};
|
|
4243
|
-
const reconfigure = (erasurePattern) => {
|
|
4244
|
-
const mask = convertToErasedMask(erasurePattern, opts.n);
|
|
4245
|
-
if (mask !== cachedMask) {
|
|
4246
|
-
const returned = exp.clay_decoder_init_mds(
|
|
4247
|
-
activeDecoderPtr,
|
|
4248
|
-
mask,
|
|
4249
|
-
paramsPtr
|
|
4250
|
-
);
|
|
4251
|
-
if (returned && returned !== activeDecoderPtr) {
|
|
4252
|
-
throw new Error(
|
|
4253
|
-
"Decoder reconfiguration returned unexpected pointer; multiple decoder instances are not supported in-place."
|
|
4254
|
-
);
|
|
4255
|
-
}
|
|
4256
|
-
applyMask(mask);
|
|
4257
|
-
cachedMask = mask;
|
|
4258
|
-
}
|
|
4259
|
-
staged.clear();
|
|
4260
|
-
};
|
|
4261
|
-
const decode = (available, erasurePattern) => {
|
|
4262
|
-
reconfigure(erasurePattern);
|
|
4263
|
-
const chunks = normaliseChunkInput(
|
|
4264
|
-
available,
|
|
4265
|
-
availableIndexes.length,
|
|
4266
|
-
opts.chunkSizeBytes,
|
|
4267
|
-
"decoder input"
|
|
4268
|
-
);
|
|
4269
|
-
for (let i = 0; i < availableIndexes.length; i++) {
|
|
4270
|
-
setChunk(availableIndexes[i], chunks[i]);
|
|
4271
|
-
}
|
|
4272
|
-
run();
|
|
4273
|
-
const outputs = new Array(opts.n);
|
|
4274
|
-
for (let idx = 0; idx < opts.n; idx++) {
|
|
4275
|
-
outputs[idx] = getChunk(idx);
|
|
4276
|
-
}
|
|
4277
|
-
return buildChunkCollection(outputs, opts.k);
|
|
4278
|
-
};
|
|
4279
|
-
return { setChunk, run, getChunk, decode };
|
|
4280
|
-
}
|
|
4281
|
-
|
|
4282
|
-
// ../../packages/clay-codes/dist/chunk-U2WMFYBV.js
|
|
4283
|
-
function makeEncoderAPI(instance, opts) {
|
|
4284
|
-
const exp = instance.exports;
|
|
4285
|
-
const workspace = createWasmWorkspace(exp.memory, exp.__heap_base.value, {
|
|
4286
|
-
alignMask: DEFAULT_ALIGN_MASK,
|
|
4287
|
-
pageSize: DEFAULT_PAGE_SIZE
|
|
4288
|
-
});
|
|
4289
|
-
const paramsPtr = workspace.alloc(CLAY_PARAMS_BYTES, DEFAULT_ALIGN_MASK);
|
|
4290
|
-
exp.clay_params_init(paramsPtr, opts.n, opts.k, opts.d, opts.chunkSizeBytes);
|
|
4291
|
-
const encPtr = workspace.alloc(exp.clay_encoder_footprint(paramsPtr));
|
|
4292
|
-
exp.clay_encoder_init(encPtr, paramsPtr);
|
|
4293
|
-
const staging = workspace.createStagingBuffer(opts.chunkSizeBytes);
|
|
4294
|
-
const setChunk = (idx, data) => {
|
|
4295
|
-
if (data.byteLength !== opts.chunkSizeBytes) {
|
|
4296
|
-
throw new Error(
|
|
4297
|
-
`Chunk ${idx} length ${data.byteLength} does not match chunkSizeBytes ${opts.chunkSizeBytes}`
|
|
4298
|
-
);
|
|
4299
|
-
}
|
|
4300
|
-
staging.write(data);
|
|
4301
|
-
exp.clay_encoder_set_data_chunk(encPtr, idx, staging.pointer);
|
|
4302
|
-
};
|
|
4303
|
-
const run = () => {
|
|
4304
|
-
exp.clay_encoder_run(encPtr);
|
|
4305
|
-
};
|
|
4306
|
-
const getChunk = (idx) => {
|
|
4307
|
-
exp.clay_encoder_get_chunk(encPtr, idx, staging.pointer);
|
|
4308
|
-
return staging.read();
|
|
4309
|
-
};
|
|
4310
|
-
const erasureCode = (input) => {
|
|
4311
|
-
const chunks = normaliseChunkInput(
|
|
4312
|
-
input,
|
|
4313
|
-
opts.k,
|
|
4314
|
-
opts.chunkSizeBytes,
|
|
4315
|
-
"encoder input"
|
|
4316
|
-
);
|
|
4317
|
-
for (let idx = 0; idx < chunks.length; idx++) {
|
|
4318
|
-
setChunk(idx, chunks[idx]);
|
|
4319
|
-
}
|
|
4320
|
-
run();
|
|
4321
|
-
const outputs = new Array(opts.n);
|
|
4322
|
-
for (let idx = 0; idx < opts.n; idx++) {
|
|
4323
|
-
outputs[idx] = getChunk(idx);
|
|
4324
|
-
}
|
|
4325
|
-
return buildChunkCollection(outputs, opts.k);
|
|
4326
|
-
};
|
|
4327
|
-
return { setChunk, run, getChunk, erasureCode };
|
|
4328
|
-
}
|
|
4329
|
-
|
|
4330
|
-
// ../../packages/clay-codes/dist/index-node.js
|
|
4331
|
-
import { readFile } from "fs/promises";
|
|
4332
|
-
import { dirname, resolve } from "path";
|
|
4333
|
-
import { fileURLToPath } from "url";
|
|
4334
|
-
async function loadWasm() {
|
|
4335
|
-
const here = dirname(fileURLToPath(import.meta.url));
|
|
4336
|
-
const paths = [
|
|
4337
|
-
resolve(here, "clay.wasm"),
|
|
4338
|
-
resolve(here, "../dist/clay.wasm")
|
|
4339
|
-
];
|
|
4340
|
-
let bytes;
|
|
4341
|
-
for (const path5 of paths) {
|
|
4342
|
-
try {
|
|
4343
|
-
bytes = await readFile(path5);
|
|
4344
|
-
break;
|
|
4345
|
-
} catch {
|
|
4346
|
-
}
|
|
4347
|
-
}
|
|
4348
|
-
if (!bytes) {
|
|
4349
|
-
throw new Error(`Unable to locate clay.wasm. Tried: ${paths.join(", ")}`);
|
|
4350
|
-
}
|
|
4351
|
-
const defaultImports = {
|
|
4352
|
-
env: {
|
|
4353
|
-
abort: () => {
|
|
4354
|
-
throw new Error("WASM abort called");
|
|
4355
|
-
},
|
|
4356
|
-
js_msg: (i) => console.log(`wasm msg: ${i}`)
|
|
4357
|
-
}
|
|
4358
|
-
};
|
|
4359
|
-
const module = await WebAssembly.compile(bytes);
|
|
4360
|
-
return WebAssembly.instantiate(module, defaultImports);
|
|
4361
|
-
}
|
|
4362
|
-
async function createEncoder(opts) {
|
|
4363
|
-
const instance = await loadWasm();
|
|
4364
|
-
return makeEncoderAPI(instance, opts);
|
|
4365
|
-
}
|
|
4366
|
-
async function createDecoder(opts) {
|
|
4367
|
-
const instance = await loadWasm();
|
|
4368
|
-
return makeDecoderAPI(instance, opts);
|
|
4369
|
-
}
|
|
4370
|
-
|
|
4371
3990
|
// ../../packages/sdk/dist/chunk-APML3CGJ.mjs
|
|
3991
|
+
import {
|
|
3992
|
+
createDecoder,
|
|
3993
|
+
createEncoder
|
|
3994
|
+
} from "@shelby-protocol/clay-codes";
|
|
4372
3995
|
var CHUNK_SIZE_PARAMS = {
|
|
4373
3996
|
[
|
|
4374
3997
|
"ChunkSet10MiB_Chunk1MiB"
|
|
@@ -4522,7 +4145,7 @@ var BlobNameSchema = z.string().min(1, "Blob name path parameter cannot be empty
|
|
|
4522
4145
|
message: "Blob name cannot end with a slash"
|
|
4523
4146
|
});
|
|
4524
4147
|
|
|
4525
|
-
// ../../packages/sdk/dist/chunk-
|
|
4148
|
+
// ../../packages/sdk/dist/chunk-PGBEBDNY.mjs
|
|
4526
4149
|
import { AccountAddress as AccountAddress3 } from "@aptos-labs/ts-sdk";
|
|
4527
4150
|
function encodeURIComponentKeepSlashes(str) {
|
|
4528
4151
|
return encodeURIComponent(str).replace(/%2F/g, "/");
|
|
@@ -4914,7 +4537,7 @@ function validatePrePaddedChunkset(chunkset, expectedSize, chunksetIdx) {
|
|
|
4914
4537
|
return chunkset;
|
|
4915
4538
|
}
|
|
4916
4539
|
|
|
4917
|
-
// ../../packages/sdk/dist/chunk-
|
|
4540
|
+
// ../../packages/sdk/dist/chunk-USBWGA27.mjs
|
|
4918
4541
|
import {
|
|
4919
4542
|
AccountAddress as AccountAddress5,
|
|
4920
4543
|
Aptos as Aptos2,
|
|
@@ -5078,16 +4701,16 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
5078
4701
|
owner: AccountAddress5.from(blob.owner),
|
|
5079
4702
|
name: blob.blob_name,
|
|
5080
4703
|
blobMerkleRoot: Hex3.fromHexInput(blob.blob_commitment).toUint8Array(),
|
|
5081
|
-
size: blob.size,
|
|
4704
|
+
size: Number(blob.size),
|
|
5082
4705
|
// TODO: Add encoding when supported in NCI
|
|
5083
4706
|
encoding: {
|
|
5084
4707
|
variant: "clay",
|
|
5085
4708
|
...ERASURE_CODE_PARAMS.ClayCode_16Total_10Data_13Helper,
|
|
5086
4709
|
...ERASURE_CODE_AND_CHUNK_MAPPING.ClayCode_16Total_10Data_13Helper
|
|
5087
4710
|
},
|
|
5088
|
-
expirationMicros: blob.expires_at,
|
|
4711
|
+
expirationMicros: Number(blob.expires_at),
|
|
5089
4712
|
sliceAddress: AccountAddress5.from(blob.slice_address),
|
|
5090
|
-
isWritten: blob.is_written
|
|
4713
|
+
isWritten: Boolean(Number(blob.is_written))
|
|
5091
4714
|
})
|
|
5092
4715
|
);
|
|
5093
4716
|
}
|
|
@@ -5272,7 +4895,7 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
5272
4895
|
}
|
|
5273
4896
|
};
|
|
5274
4897
|
|
|
5275
|
-
// ../../packages/sdk/dist/chunk-
|
|
4898
|
+
// ../../packages/sdk/dist/chunk-PUNXDYH2.mjs
|
|
5276
4899
|
import {
|
|
5277
4900
|
Aptos as Aptos3
|
|
5278
4901
|
} from "@aptos-labs/ts-sdk";
|
|
@@ -5427,7 +5050,7 @@ var ShelbyClient = class {
|
|
|
5427
5050
|
}
|
|
5428
5051
|
};
|
|
5429
5052
|
|
|
5430
|
-
// ../../packages/sdk/dist/chunk-
|
|
5053
|
+
// ../../packages/sdk/dist/chunk-I7SQAWUY.mjs
|
|
5431
5054
|
var ShelbyNodeClient = class extends ShelbyClient {
|
|
5432
5055
|
};
|
|
5433
5056
|
|
|
@@ -5464,7 +5087,7 @@ var shelbyNetworks = [Network4.LOCAL, Network4.SHELBYNET];
|
|
|
5464
5087
|
|
|
5465
5088
|
// src/commands/account.tsx
|
|
5466
5089
|
import { render } from "ink";
|
|
5467
|
-
import { z as
|
|
5090
|
+
import { z as z9 } from "zod";
|
|
5468
5091
|
|
|
5469
5092
|
// src/components/AccountWizard.tsx
|
|
5470
5093
|
import { Box, Text } from "ink";
|
|
@@ -5478,95 +5101,13 @@ import {
|
|
|
5478
5101
|
Aptos as Aptos4,
|
|
5479
5102
|
AptosConfig as AptosConfig3,
|
|
5480
5103
|
Ed25519Account,
|
|
5481
|
-
Ed25519PrivateKey
|
|
5482
|
-
Network as Network7,
|
|
5104
|
+
Ed25519PrivateKey,
|
|
5483
5105
|
NetworkToNetworkName
|
|
5484
5106
|
} from "@aptos-labs/ts-sdk";
|
|
5485
5107
|
import fs from "fs-extra";
|
|
5486
5108
|
import YAML from "yaml";
|
|
5487
5109
|
import { z as z6 } from "zod";
|
|
5488
5110
|
|
|
5489
|
-
// tests/utils/mockConfig.ts
|
|
5490
|
-
import { Network as Network5 } from "@aptos-labs/ts-sdk";
|
|
5491
|
-
|
|
5492
|
-
// src/utils/context-helpers.ts
|
|
5493
|
-
import {
|
|
5494
|
-
NetworkToFaucetAPI,
|
|
5495
|
-
NetworkToIndexerAPI,
|
|
5496
|
-
NetworkToNodeAPI,
|
|
5497
|
-
NetworkToPepperAPI,
|
|
5498
|
-
NetworkToProverAPI
|
|
5499
|
-
} from "@aptos-labs/ts-sdk";
|
|
5500
|
-
function createContextForNetwork(network) {
|
|
5501
|
-
return {
|
|
5502
|
-
aptos_network: {
|
|
5503
|
-
name: network,
|
|
5504
|
-
fullnode: NetworkToNodeAPI[network],
|
|
5505
|
-
faucet: NetworkToFaucetAPI[network],
|
|
5506
|
-
indexer: NetworkToIndexerAPI[network],
|
|
5507
|
-
pepper: NetworkToPepperAPI[network],
|
|
5508
|
-
prover: NetworkToProverAPI[network]
|
|
5509
|
-
},
|
|
5510
|
-
shelby_network: {
|
|
5511
|
-
rpc_endpoint: NetworkToShelbyRPCBaseUrl[network]
|
|
5512
|
-
}
|
|
5513
|
-
};
|
|
5514
|
-
}
|
|
5515
|
-
|
|
5516
|
-
// src/utils/keys.ts
|
|
5517
|
-
import {
|
|
5518
|
-
Account,
|
|
5519
|
-
AccountAddress as AccountAddress6,
|
|
5520
|
-
Ed25519PrivateKey,
|
|
5521
|
-
Secp256k1PrivateKey,
|
|
5522
|
-
SigningSchemeInput
|
|
5523
|
-
} from "@aptos-labs/ts-sdk";
|
|
5524
|
-
function generateEd25519Account() {
|
|
5525
|
-
const account = Account.generate({
|
|
5526
|
-
scheme: SigningSchemeInput.Ed25519,
|
|
5527
|
-
legacy: true
|
|
5528
|
-
});
|
|
5529
|
-
return account;
|
|
5530
|
-
}
|
|
5531
|
-
function isValidEd25519PrivateKey(value) {
|
|
5532
|
-
try {
|
|
5533
|
-
new Ed25519PrivateKey(value);
|
|
5534
|
-
return true;
|
|
5535
|
-
} catch {
|
|
5536
|
-
return false;
|
|
5537
|
-
}
|
|
5538
|
-
}
|
|
5539
|
-
function isValidAddress(address) {
|
|
5540
|
-
return AccountAddress6.isValid({ input: address }).valid;
|
|
5541
|
-
}
|
|
5542
|
-
var SECP256K1_NAME = "secp256k1";
|
|
5543
|
-
var ED25519_NAME = "ed25519";
|
|
5544
|
-
function isValidScheme(scheme) {
|
|
5545
|
-
return SECP256K1_NAME === scheme || ED25519_NAME === scheme;
|
|
5546
|
-
}
|
|
5547
|
-
|
|
5548
|
-
// tests/utils/mockConfig.ts
|
|
5549
|
-
var mockAccounts = {
|
|
5550
|
-
alice: generateEd25519Account(),
|
|
5551
|
-
bob: generateEd25519Account()
|
|
5552
|
-
};
|
|
5553
|
-
var mockConfig = {
|
|
5554
|
-
contexts: {
|
|
5555
|
-
[Network5.SHELBYNET]: createContextForNetwork(Network5.SHELBYNET)
|
|
5556
|
-
},
|
|
5557
|
-
accounts: Object.fromEntries(
|
|
5558
|
-
Object.entries(mockAccounts).map(([name, acc]) => [
|
|
5559
|
-
name,
|
|
5560
|
-
{
|
|
5561
|
-
address: acc.accountAddress.toString(),
|
|
5562
|
-
private_key: acc.privateKey.toAIP80String()
|
|
5563
|
-
}
|
|
5564
|
-
])
|
|
5565
|
-
),
|
|
5566
|
-
default_context: Network5.SHELBYNET,
|
|
5567
|
-
default_account: Object.keys(mockAccounts)[0]
|
|
5568
|
-
};
|
|
5569
|
-
|
|
5570
5111
|
// src/schemas/AptosNetworkSchema.ts
|
|
5571
5112
|
import { z as z4 } from "zod";
|
|
5572
5113
|
|
|
@@ -5597,19 +5138,45 @@ var ShelbyNetworkSchema = z5.object({
|
|
|
5597
5138
|
});
|
|
5598
5139
|
|
|
5599
5140
|
// src/utils/constants.ts
|
|
5600
|
-
import { APTOS_COIN, Network as
|
|
5141
|
+
import { APTOS_COIN, Network as Network5 } from "@aptos-labs/ts-sdk";
|
|
5142
|
+
|
|
5143
|
+
// src/utils/context-helpers.ts
|
|
5144
|
+
import {
|
|
5145
|
+
NetworkToFaucetAPI,
|
|
5146
|
+
NetworkToIndexerAPI,
|
|
5147
|
+
NetworkToNodeAPI,
|
|
5148
|
+
NetworkToPepperAPI,
|
|
5149
|
+
NetworkToProverAPI
|
|
5150
|
+
} from "@aptos-labs/ts-sdk";
|
|
5151
|
+
function createContextForNetwork(network) {
|
|
5152
|
+
return {
|
|
5153
|
+
aptos_network: {
|
|
5154
|
+
name: network,
|
|
5155
|
+
fullnode: NetworkToNodeAPI[network],
|
|
5156
|
+
faucet: NetworkToFaucetAPI[network],
|
|
5157
|
+
indexer: NetworkToIndexerAPI[network],
|
|
5158
|
+
pepper: NetworkToPepperAPI[network],
|
|
5159
|
+
prover: NetworkToProverAPI[network]
|
|
5160
|
+
},
|
|
5161
|
+
shelby_network: {
|
|
5162
|
+
rpc_endpoint: NetworkToShelbyRPCBaseUrl[network]
|
|
5163
|
+
}
|
|
5164
|
+
};
|
|
5165
|
+
}
|
|
5166
|
+
|
|
5167
|
+
// src/utils/constants.ts
|
|
5601
5168
|
var DEFAULT_CONFIG_PATH = "~/.shelby/config.yaml";
|
|
5602
5169
|
var DEFAULT_CONFIG = {
|
|
5603
5170
|
contexts: {
|
|
5604
|
-
[
|
|
5605
|
-
...createContextForNetwork(
|
|
5171
|
+
[Network5.LOCAL]: {
|
|
5172
|
+
...createContextForNetwork(Network5.LOCAL),
|
|
5606
5173
|
// Override shelby_network for local
|
|
5607
5174
|
shelby_network: { rpc_endpoint: "http://localhost:9090/" }
|
|
5608
5175
|
},
|
|
5609
|
-
[
|
|
5176
|
+
[Network5.SHELBYNET]: createContextForNetwork(Network5.SHELBYNET)
|
|
5610
5177
|
},
|
|
5611
5178
|
accounts: {},
|
|
5612
|
-
default_context:
|
|
5179
|
+
default_context: Network5.SHELBYNET,
|
|
5613
5180
|
default_account: ""
|
|
5614
5181
|
};
|
|
5615
5182
|
var STANDARD_CONTEXT_NAMES = Object.keys(DEFAULT_CONFIG.contexts).join(
|
|
@@ -5631,6 +5198,7 @@ var BALANCE_TARGETS = [
|
|
|
5631
5198
|
|
|
5632
5199
|
// src/utils/config.ts
|
|
5633
5200
|
var ContextSchema = z6.object({
|
|
5201
|
+
api_key: z6.string().optional(),
|
|
5634
5202
|
aptos_network: AptosNetworkSchema,
|
|
5635
5203
|
shelby_network: ShelbyNetworkSchema.optional()
|
|
5636
5204
|
});
|
|
@@ -5666,9 +5234,9 @@ function loadConfig(configPath = DEFAULT_CONFIG_PATH) {
|
|
|
5666
5234
|
const dir = path.dirname(resolvedPath);
|
|
5667
5235
|
if (!fs.existsSync(resolvedPath)) {
|
|
5668
5236
|
fs.mkdirpSync(dir);
|
|
5669
|
-
const yamlText = YAML.stringify(
|
|
5237
|
+
const yamlText = YAML.stringify(DEFAULT_CONFIG);
|
|
5670
5238
|
fs.writeFileSync(resolvedPath, yamlText, "utf8");
|
|
5671
|
-
return
|
|
5239
|
+
return DEFAULT_CONFIG;
|
|
5672
5240
|
}
|
|
5673
5241
|
const raw = fs.readFileSync(resolvedPath, "utf8");
|
|
5674
5242
|
let parsed;
|
|
@@ -5696,6 +5264,7 @@ function getCurrentContext(config, contextName) {
|
|
|
5696
5264
|
throw new Error(`Context '${name}' not found in config`);
|
|
5697
5265
|
}
|
|
5698
5266
|
return {
|
|
5267
|
+
api_key: context.api_key,
|
|
5699
5268
|
aptos_network: context.aptos_network,
|
|
5700
5269
|
shelby_network: context.shelby_network
|
|
5701
5270
|
};
|
|
@@ -5719,46 +5288,36 @@ function getCurrentAccount(config, accountName) {
|
|
|
5719
5288
|
address: account.address,
|
|
5720
5289
|
privateKey,
|
|
5721
5290
|
account: new Ed25519Account({
|
|
5722
|
-
privateKey: new
|
|
5291
|
+
privateKey: new Ed25519PrivateKey(privateKey)
|
|
5723
5292
|
})
|
|
5724
5293
|
};
|
|
5725
5294
|
}
|
|
5726
|
-
function
|
|
5727
|
-
const { name, api_key, ...options } =
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
default:
|
|
5739
|
-
config = new AptosConfig3({
|
|
5740
|
-
network: Network7.CUSTOM,
|
|
5741
|
-
clientConfig: { API_KEY: api_key },
|
|
5742
|
-
...options
|
|
5743
|
-
});
|
|
5744
|
-
break;
|
|
5745
|
-
}
|
|
5746
|
-
return new Aptos4(config);
|
|
5295
|
+
function getAptosSettingsFromContext(context) {
|
|
5296
|
+
const { name, api_key, ...options } = context.aptos_network;
|
|
5297
|
+
const activeApiKey = api_key || context.api_key;
|
|
5298
|
+
return {
|
|
5299
|
+
...options,
|
|
5300
|
+
network: NetworkToNetworkName[name],
|
|
5301
|
+
clientConfig: { API_KEY: activeApiKey }
|
|
5302
|
+
};
|
|
5303
|
+
}
|
|
5304
|
+
function getAptosFromContext(context) {
|
|
5305
|
+
const config = getAptosSettingsFromContext(context);
|
|
5306
|
+
return new Aptos4(new AptosConfig3(config));
|
|
5747
5307
|
}
|
|
5748
|
-
function
|
|
5308
|
+
function getShelbyConfigFromContext(context) {
|
|
5309
|
+
const aptosSettings = getAptosSettingsFromContext(context);
|
|
5749
5310
|
return {
|
|
5750
|
-
network:
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
network: NetworkToNetworkName[options.aptosNetwork.name]
|
|
5754
|
-
},
|
|
5311
|
+
network: context.aptos_network.name,
|
|
5312
|
+
apiKey: context.api_key,
|
|
5313
|
+
aptos: aptosSettings,
|
|
5755
5314
|
rpc: {
|
|
5756
|
-
baseUrl:
|
|
5757
|
-
apiKey:
|
|
5315
|
+
baseUrl: context.shelby_network?.rpc_endpoint,
|
|
5316
|
+
apiKey: context.shelby_network?.rpc_api_key
|
|
5758
5317
|
},
|
|
5759
5318
|
indexer: {
|
|
5760
|
-
baseUrl:
|
|
5761
|
-
apiKey:
|
|
5319
|
+
baseUrl: context.shelby_network?.indexer_endpoint,
|
|
5320
|
+
apiKey: context.shelby_network?.indexer_api_key
|
|
5762
5321
|
}
|
|
5763
5322
|
};
|
|
5764
5323
|
}
|
|
@@ -5770,18 +5329,58 @@ function getCurrentShelbyConfig(config, opts = { context: config.default_context
|
|
|
5770
5329
|
`Context '${context ?? config.default_context}' not found in config`
|
|
5771
5330
|
);
|
|
5772
5331
|
}
|
|
5773
|
-
const shelby =
|
|
5774
|
-
selectedContext.shelby_network ?? {},
|
|
5775
|
-
{ aptosNetwork: selectedContext.aptos_network }
|
|
5776
|
-
);
|
|
5332
|
+
const shelby = getShelbyConfigFromContext(selectedContext);
|
|
5777
5333
|
return shelby;
|
|
5778
5334
|
}
|
|
5779
5335
|
|
|
5336
|
+
// src/utils/account.ts
|
|
5337
|
+
function validateAccountName(name, config) {
|
|
5338
|
+
const parsed = AccountNameSchema.safeParse(name);
|
|
5339
|
+
if (!parsed.success || name.length === 0) {
|
|
5340
|
+
return parsed.error?.errors[0]?.message || "Account name must be a non-empty string containing only letters, numbers, underscores, or hyphens.";
|
|
5341
|
+
}
|
|
5342
|
+
if (config?.accounts[name]) {
|
|
5343
|
+
return `Account '${name}' already exists. Choose a different name.`;
|
|
5344
|
+
}
|
|
5345
|
+
return void 0;
|
|
5346
|
+
}
|
|
5347
|
+
|
|
5348
|
+
// src/utils/keys.ts
|
|
5349
|
+
import {
|
|
5350
|
+
Account,
|
|
5351
|
+
AccountAddress as AccountAddress6,
|
|
5352
|
+
Ed25519PrivateKey as Ed25519PrivateKey2,
|
|
5353
|
+
Secp256k1PrivateKey,
|
|
5354
|
+
SigningSchemeInput
|
|
5355
|
+
} from "@aptos-labs/ts-sdk";
|
|
5356
|
+
import { z as z7 } from "zod";
|
|
5357
|
+
function generateEd25519Account() {
|
|
5358
|
+
const account = Account.generate({
|
|
5359
|
+
scheme: SigningSchemeInput.Ed25519,
|
|
5360
|
+
legacy: true
|
|
5361
|
+
});
|
|
5362
|
+
return account;
|
|
5363
|
+
}
|
|
5364
|
+
function isValidEd25519PrivateKey(value) {
|
|
5365
|
+
try {
|
|
5366
|
+
new Ed25519PrivateKey2(value);
|
|
5367
|
+
return true;
|
|
5368
|
+
} catch {
|
|
5369
|
+
return false;
|
|
5370
|
+
}
|
|
5371
|
+
}
|
|
5372
|
+
function isValidAddress(address) {
|
|
5373
|
+
return AccountAddress6.isValid({ input: address }).valid;
|
|
5374
|
+
}
|
|
5375
|
+
var ED25519_NAME = "ed25519";
|
|
5376
|
+
var SignatureSchemeSchema = z7.enum([ED25519_NAME]);
|
|
5377
|
+
|
|
5780
5378
|
// src/components/AccountWizard.tsx
|
|
5781
5379
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5782
5380
|
var AccountWizard = ({
|
|
5783
5381
|
onComplete,
|
|
5784
|
-
initialName
|
|
5382
|
+
initialName,
|
|
5383
|
+
config
|
|
5785
5384
|
}) => {
|
|
5786
5385
|
const [step, setStep] = useState(
|
|
5787
5386
|
initialName ? "address" : "name"
|
|
@@ -5808,21 +5407,17 @@ var AccountWizard = ({
|
|
|
5808
5407
|
value: name,
|
|
5809
5408
|
onChange: (value) => {
|
|
5810
5409
|
setName(value);
|
|
5811
|
-
const
|
|
5812
|
-
|
|
5813
|
-
setNameError(result.error.errors[0]?.message || "Invalid name");
|
|
5814
|
-
} else {
|
|
5815
|
-
setNameError(null);
|
|
5816
|
-
}
|
|
5410
|
+
const error = validateAccountName(value, config);
|
|
5411
|
+
setNameError(error || null);
|
|
5817
5412
|
},
|
|
5818
5413
|
onSubmit: () => {
|
|
5819
|
-
const
|
|
5820
|
-
if (
|
|
5821
|
-
setNameError(
|
|
5822
|
-
|
|
5823
|
-
setNameError(null);
|
|
5824
|
-
setStep("address");
|
|
5414
|
+
const error = validateAccountName(name, config);
|
|
5415
|
+
if (error) {
|
|
5416
|
+
setNameError(error);
|
|
5417
|
+
return;
|
|
5825
5418
|
}
|
|
5419
|
+
setNameError(null);
|
|
5420
|
+
setStep("address");
|
|
5826
5421
|
}
|
|
5827
5422
|
}
|
|
5828
5423
|
),
|
|
@@ -6006,7 +5601,7 @@ var SHELBY_CONFIG_FIELDS = [
|
|
|
6006
5601
|
import { Box as Box3, Text as Text3 } from "ink";
|
|
6007
5602
|
import TextInput2 from "ink-text-input";
|
|
6008
5603
|
import { useState as useState2 } from "react";
|
|
6009
|
-
import
|
|
5604
|
+
import z8 from "zod";
|
|
6010
5605
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
6011
5606
|
function FormTextInput({
|
|
6012
5607
|
type,
|
|
@@ -6036,7 +5631,7 @@ function FormTextInput({
|
|
|
6036
5631
|
return;
|
|
6037
5632
|
}
|
|
6038
5633
|
if (value2) {
|
|
6039
|
-
if (type === "url" && !
|
|
5634
|
+
if (type === "url" && !z8.string().url().safeParse(value2).success) {
|
|
6040
5635
|
setError("The field must be a valid URL");
|
|
6041
5636
|
return;
|
|
6042
5637
|
}
|
|
@@ -6053,21 +5648,28 @@ function FormTextInput({
|
|
|
6053
5648
|
// src/components/ContextReviewWizard.tsx
|
|
6054
5649
|
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
6055
5650
|
var ContextReviewWizard = ({
|
|
5651
|
+
initialApiKey,
|
|
6056
5652
|
initialAptosNetwork,
|
|
6057
5653
|
initialShelbyNetwork,
|
|
6058
5654
|
onComplete
|
|
6059
5655
|
}) => {
|
|
6060
5656
|
const [step, setStep] = useState3("review");
|
|
6061
5657
|
const [fieldEditorInput, setFieldEditorInput] = useState3("");
|
|
5658
|
+
const [apiKey, setApiKey] = useState3(initialApiKey || "");
|
|
6062
5659
|
const [aptosNetwork, setAptosNetwork] = useState3(initialAptosNetwork);
|
|
6063
5660
|
const [shelbyNetwork, setShelbyNetwork] = useState3(initialShelbyNetwork);
|
|
6064
5661
|
useEffect2(() => {
|
|
6065
5662
|
if (step === "done") {
|
|
6066
|
-
onComplete({
|
|
5663
|
+
onComplete({
|
|
5664
|
+
apiKey: apiKey || void 0,
|
|
5665
|
+
aptosNetwork,
|
|
5666
|
+
shelbyNetwork
|
|
5667
|
+
});
|
|
6067
5668
|
}
|
|
6068
|
-
}, [step, aptosNetwork, shelbyNetwork, onComplete]);
|
|
5669
|
+
}, [step, apiKey, aptosNetwork, shelbyNetwork, onComplete]);
|
|
6069
5670
|
const formatFieldDisplay = (display) => !display ? "(not set)" : display.source === "current" ? `(current: ${display.value})` : `(default: ${display.value})`;
|
|
6070
|
-
const
|
|
5671
|
+
const formatApiKeyDisplay = (key) => key ? `(current: ${key})` : "(not set)";
|
|
5672
|
+
const getShelbyFieldDisplay = (key) => {
|
|
6071
5673
|
const value = shelbyNetwork[key];
|
|
6072
5674
|
if (value && value !== "") {
|
|
6073
5675
|
return { value, source: "current" };
|
|
@@ -6106,11 +5708,17 @@ var ContextReviewWizard = ({
|
|
|
6106
5708
|
SelectInput2,
|
|
6107
5709
|
{
|
|
6108
5710
|
items: [
|
|
5711
|
+
{ label: "API Key", value: "api-key" },
|
|
6109
5712
|
{ label: "Shelby Config", value: "shelby" },
|
|
6110
5713
|
{ label: "Aptos Config", value: "aptos" },
|
|
6111
5714
|
{ label: "Finish Setup \u2714", value: "finish" }
|
|
6112
5715
|
],
|
|
6113
5716
|
onSelect: (item) => {
|
|
5717
|
+
if (item.value === "api-key") {
|
|
5718
|
+
setFieldEditorInput(apiKey);
|
|
5719
|
+
setStep("api-key-edit");
|
|
5720
|
+
return;
|
|
5721
|
+
}
|
|
6114
5722
|
if (item.value === "shelby") {
|
|
6115
5723
|
setStep("shelby-config-options");
|
|
6116
5724
|
return;
|
|
@@ -6125,9 +5733,13 @@ var ContextReviewWizard = ({
|
|
|
6125
5733
|
),
|
|
6126
5734
|
/* @__PURE__ */ jsxs4(Box4, { marginTop: 1, flexDirection: "column", children: [
|
|
6127
5735
|
/* @__PURE__ */ jsx5(Text4, { color: "gray", children: "Current settings" }),
|
|
5736
|
+
/* @__PURE__ */ jsxs4(Text4, { children: [
|
|
5737
|
+
"API Key: ",
|
|
5738
|
+
formatApiKeyDisplay(apiKey)
|
|
5739
|
+
] }),
|
|
6128
5740
|
/* @__PURE__ */ jsx5(Text4, { children: "Shelby Config:" }),
|
|
6129
5741
|
SHELBY_CONFIG_FIELDS.map((field) => {
|
|
6130
|
-
const display =
|
|
5742
|
+
const display = getShelbyFieldDisplay(field.key);
|
|
6131
5743
|
if (!display) return null;
|
|
6132
5744
|
return /* @__PURE__ */ jsx5(
|
|
6133
5745
|
Text4,
|
|
@@ -6152,6 +5764,24 @@ var ContextReviewWizard = ({
|
|
|
6152
5764
|
] })
|
|
6153
5765
|
] });
|
|
6154
5766
|
}
|
|
5767
|
+
if (step === "api-key-edit") {
|
|
5768
|
+
return /* @__PURE__ */ jsx5(
|
|
5769
|
+
FormTextInput,
|
|
5770
|
+
{
|
|
5771
|
+
title: "Edit API Key",
|
|
5772
|
+
description: `Current value: ${formatApiKeyDisplay(apiKey)}`,
|
|
5773
|
+
required: false,
|
|
5774
|
+
value: fieldEditorInput,
|
|
5775
|
+
placeholder: "Enter API key (optional)",
|
|
5776
|
+
onChange: setFieldEditorInput,
|
|
5777
|
+
onSubmit: (value) => {
|
|
5778
|
+
setApiKey(value);
|
|
5779
|
+
setFieldEditorInput("");
|
|
5780
|
+
setStep("review");
|
|
5781
|
+
}
|
|
5782
|
+
}
|
|
5783
|
+
);
|
|
5784
|
+
}
|
|
6155
5785
|
if (step === "shelby-config-options") {
|
|
6156
5786
|
return /* @__PURE__ */ jsx5(
|
|
6157
5787
|
FormSelectInput,
|
|
@@ -6161,7 +5791,7 @@ var ContextReviewWizard = ({
|
|
|
6161
5791
|
items: [
|
|
6162
5792
|
...SHELBY_CONFIG_FIELDS.map((field) => ({
|
|
6163
5793
|
label: `${field.label} ${formatFieldDisplay(
|
|
6164
|
-
|
|
5794
|
+
getShelbyFieldDisplay(field.key)
|
|
6165
5795
|
)}`,
|
|
6166
5796
|
value: field.key
|
|
6167
5797
|
})),
|
|
@@ -6186,7 +5816,7 @@ var ContextReviewWizard = ({
|
|
|
6186
5816
|
const key = step.replace("shelby-config-edit-", "");
|
|
6187
5817
|
const field = SHELBY_CONFIG_FIELDS.find((f) => f.key === key);
|
|
6188
5818
|
if (!field) return null;
|
|
6189
|
-
const currentValue =
|
|
5819
|
+
const currentValue = getShelbyFieldDisplay(key);
|
|
6190
5820
|
if (field.type !== "text") return null;
|
|
6191
5821
|
return /* @__PURE__ */ jsx5(
|
|
6192
5822
|
FormTextInput,
|
|
@@ -6303,6 +5933,7 @@ var CreateContextWizard = ({
|
|
|
6303
5933
|
}) => {
|
|
6304
5934
|
const [step, setStep] = useState4("name");
|
|
6305
5935
|
const [name, setName] = useState4("");
|
|
5936
|
+
const [apiKey, setApiKey] = useState4("");
|
|
6306
5937
|
const [shelbyNetwork, setShelbyNetwork] = useState4(
|
|
6307
5938
|
{}
|
|
6308
5939
|
);
|
|
@@ -6313,10 +5944,11 @@ var CreateContextWizard = ({
|
|
|
6313
5944
|
const validatedShelbyNetwork = ShelbyNetworkSchema.parse(shelbyNetwork);
|
|
6314
5945
|
onComplete({
|
|
6315
5946
|
name,
|
|
5947
|
+
apiKey: apiKey || void 0,
|
|
6316
5948
|
shelbyNetwork: validatedShelbyNetwork,
|
|
6317
5949
|
aptosNetwork: validatedAptosNetwork
|
|
6318
5950
|
});
|
|
6319
|
-
}, [step, name, shelbyNetwork, aptosNetwork, onComplete]);
|
|
5951
|
+
}, [step, name, apiKey, shelbyNetwork, aptosNetwork, onComplete]);
|
|
6320
5952
|
if (step === "name") {
|
|
6321
5953
|
return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", children: [
|
|
6322
5954
|
/* @__PURE__ */ jsx6(Text5, { children: "Context name?" }),
|
|
@@ -6327,6 +5959,22 @@ var CreateContextWizard = ({
|
|
|
6327
5959
|
required: true,
|
|
6328
5960
|
value: name,
|
|
6329
5961
|
onChange: setName,
|
|
5962
|
+
onSubmit: () => setStep("api-key")
|
|
5963
|
+
}
|
|
5964
|
+
)
|
|
5965
|
+
] });
|
|
5966
|
+
}
|
|
5967
|
+
if (step === "api-key") {
|
|
5968
|
+
return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", children: [
|
|
5969
|
+
/* @__PURE__ */ jsx6(Text5, { children: "API Key (optional)?" }),
|
|
5970
|
+
/* @__PURE__ */ jsx6(Text5, { color: "gray", children: "Enter an API key to use as default for this context, or press Enter to skip." }),
|
|
5971
|
+
/* @__PURE__ */ jsx6(
|
|
5972
|
+
FormTextInput,
|
|
5973
|
+
{
|
|
5974
|
+
placeholder: "Enter API key (optional)",
|
|
5975
|
+
required: false,
|
|
5976
|
+
value: apiKey,
|
|
5977
|
+
onChange: setApiKey,
|
|
6330
5978
|
onSubmit: () => setStep("aptos-network-name")
|
|
6331
5979
|
}
|
|
6332
5980
|
)
|
|
@@ -6351,9 +5999,11 @@ var CreateContextWizard = ({
|
|
|
6351
5999
|
return /* @__PURE__ */ jsx6(
|
|
6352
6000
|
ContextReviewWizard,
|
|
6353
6001
|
{
|
|
6002
|
+
initialApiKey: apiKey,
|
|
6354
6003
|
initialAptosNetwork: aptosNetwork,
|
|
6355
6004
|
initialShelbyNetwork: shelbyNetwork,
|
|
6356
|
-
onComplete: ({ aptosNetwork: aptosNetwork2, shelbyNetwork: shelbyNetwork2 }) => {
|
|
6005
|
+
onComplete: ({ apiKey: newApiKey, aptosNetwork: aptosNetwork2, shelbyNetwork: shelbyNetwork2 }) => {
|
|
6006
|
+
setApiKey(newApiKey || "");
|
|
6357
6007
|
setAptosNetwork(aptosNetwork2);
|
|
6358
6008
|
setShelbyNetwork(shelbyNetwork2);
|
|
6359
6009
|
setStep("done");
|
|
@@ -6369,7 +6019,7 @@ import { useState as useState5 } from "react";
|
|
|
6369
6019
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
6370
6020
|
|
|
6371
6021
|
// src/components/InitWizard.tsx
|
|
6372
|
-
import { Network as
|
|
6022
|
+
import { Account as Account2, Ed25519PrivateKey as Ed25519PrivateKey3, Network as Network6 } from "@aptos-labs/ts-sdk";
|
|
6373
6023
|
import { Box as Box6, Text as Text6 } from "ink";
|
|
6374
6024
|
import SelectInput3 from "ink-select-input";
|
|
6375
6025
|
import Spinner from "ink-spinner";
|
|
@@ -6814,27 +6464,34 @@ function getAptosCliVersionInfo(minVersion = MIN_APTOS_CLI_VERSION) {
|
|
|
6814
6464
|
|
|
6815
6465
|
// src/components/InitWizard.tsx
|
|
6816
6466
|
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
6817
|
-
var InitWizard = ({
|
|
6467
|
+
var InitWizard = ({
|
|
6468
|
+
existingConfig,
|
|
6469
|
+
onComplete,
|
|
6470
|
+
onCancel
|
|
6471
|
+
}) => {
|
|
6818
6472
|
const [step, setStep] = useState6(
|
|
6819
6473
|
existingConfig ? "confirmOverwrite" : "checkAptos"
|
|
6820
6474
|
);
|
|
6475
|
+
const [overwriteExisting, setOverwriteExisting] = useState6(false);
|
|
6821
6476
|
const [aptosCliMeetsRequirement, setAptosCliMeetsRequirement] = useState6(false);
|
|
6822
6477
|
const [aptosCliVersion, setAptosCliVersion] = useState6(null);
|
|
6823
6478
|
const [setupStandardContexts, setSetupStandardContexts] = useState6(false);
|
|
6824
6479
|
const [setupCustomContext, setSetupCustomContext] = useState6(false);
|
|
6825
6480
|
const [customContextName, setCustomContextName] = useState6(
|
|
6826
|
-
|
|
6481
|
+
Network6.SHELBYNET
|
|
6827
6482
|
);
|
|
6828
6483
|
const [shelbyRpcEndpoint, setShelbyRpcEndpoint] = useState6(
|
|
6829
|
-
NetworkToShelbyRPCBaseUrl[
|
|
6484
|
+
NetworkToShelbyRPCBaseUrl[Network6.SHELBYNET]
|
|
6830
6485
|
);
|
|
6831
|
-
const [aptosNetwork, setAptosNetwork] = useState6(
|
|
6486
|
+
const [aptosNetwork, setAptosNetwork] = useState6(Network6.SHELBYNET);
|
|
6487
|
+
const [standardContextsApiKey, setStandardContextsApiKey] = useState6("");
|
|
6488
|
+
const [customContextApiKey, setCustomContextApiKey] = useState6("");
|
|
6832
6489
|
const [setupAccount, setSetupAccount] = useState6(false);
|
|
6833
6490
|
const [accountName, setAccountName] = useState6("alice");
|
|
6834
6491
|
const [accountNameError, setAccountNameError] = useState6("");
|
|
6835
6492
|
const [signatureScheme, setSignatureScheme] = useState6("ed25519");
|
|
6836
6493
|
const [privateKey, setPrivateKey] = useState6("");
|
|
6837
|
-
const [address,
|
|
6494
|
+
const [address, setAddress] = useState6("");
|
|
6838
6495
|
const [generatedKey, setGeneratedKey] = useState6("");
|
|
6839
6496
|
const [generatedAddress, setGeneratedAddress] = useState6("");
|
|
6840
6497
|
useEffect4(() => {
|
|
@@ -6847,12 +6504,13 @@ var InitWizard = ({ existingConfig, onComplete }) => {
|
|
|
6847
6504
|
}, [step]);
|
|
6848
6505
|
useEffect4(() => {
|
|
6849
6506
|
if (step === "complete") {
|
|
6850
|
-
const
|
|
6507
|
+
const shouldStartFresh = overwriteExisting || !existingConfig;
|
|
6508
|
+
const config = shouldStartFresh ? {
|
|
6851
6509
|
contexts: {},
|
|
6852
6510
|
accounts: {},
|
|
6853
6511
|
default_context: setupStandardContexts ? DEFAULT_CONFIG.default_context : customContextName,
|
|
6854
|
-
default_account: setupAccount ? accountName : "
|
|
6855
|
-
};
|
|
6512
|
+
default_account: setupAccount ? accountName : ""
|
|
6513
|
+
} : { ...existingConfig };
|
|
6856
6514
|
if (setupStandardContexts || setupCustomContext) {
|
|
6857
6515
|
config.default_context = setupStandardContexts ? DEFAULT_CONFIG.default_context : customContextName;
|
|
6858
6516
|
}
|
|
@@ -6860,10 +6518,20 @@ var InitWizard = ({ existingConfig, onComplete }) => {
|
|
|
6860
6518
|
config.default_account = accountName;
|
|
6861
6519
|
}
|
|
6862
6520
|
if (setupStandardContexts) {
|
|
6863
|
-
|
|
6521
|
+
const modifiedStandardContexts = { ...DEFAULT_CONFIG.contexts };
|
|
6522
|
+
if (standardContextsApiKey) {
|
|
6523
|
+
Object.keys(modifiedStandardContexts).forEach((contextName) => {
|
|
6524
|
+
modifiedStandardContexts[contextName] = {
|
|
6525
|
+
...modifiedStandardContexts[contextName],
|
|
6526
|
+
api_key: standardContextsApiKey
|
|
6527
|
+
};
|
|
6528
|
+
});
|
|
6529
|
+
}
|
|
6530
|
+
config.contexts = modifiedStandardContexts;
|
|
6864
6531
|
}
|
|
6865
6532
|
if (setupCustomContext) {
|
|
6866
6533
|
config.contexts[customContextName] = {
|
|
6534
|
+
api_key: customContextApiKey || void 0,
|
|
6867
6535
|
aptos_network: {
|
|
6868
6536
|
name: aptosNetwork
|
|
6869
6537
|
},
|
|
@@ -6894,9 +6562,14 @@ var InitWizard = ({ existingConfig, onComplete }) => {
|
|
|
6894
6562
|
],
|
|
6895
6563
|
onSelect: (item) => {
|
|
6896
6564
|
if (item.value) {
|
|
6565
|
+
setOverwriteExisting(true);
|
|
6897
6566
|
setStep("checkAptos");
|
|
6898
6567
|
} else {
|
|
6899
|
-
|
|
6568
|
+
if (onCancel) {
|
|
6569
|
+
onCancel();
|
|
6570
|
+
} else {
|
|
6571
|
+
process.exit(0);
|
|
6572
|
+
}
|
|
6900
6573
|
}
|
|
6901
6574
|
}
|
|
6902
6575
|
}
|
|
@@ -6942,12 +6615,41 @@ var InitWizard = ({ existingConfig, onComplete }) => {
|
|
|
6942
6615
|
],
|
|
6943
6616
|
onSelect: (item) => {
|
|
6944
6617
|
setSetupStandardContexts(item.value);
|
|
6945
|
-
|
|
6618
|
+
if (item.value) {
|
|
6619
|
+
setStep("standardContextsApiKey");
|
|
6620
|
+
} else {
|
|
6621
|
+
setStep("customContext");
|
|
6622
|
+
}
|
|
6946
6623
|
}
|
|
6947
6624
|
}
|
|
6948
6625
|
)
|
|
6949
6626
|
] });
|
|
6950
6627
|
}
|
|
6628
|
+
if (step === "standardContextsApiKey") {
|
|
6629
|
+
return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", children: [
|
|
6630
|
+
/* @__PURE__ */ jsxs6(Text6, { children: [
|
|
6631
|
+
"\u2714 Checking for Aptos CLI >=v",
|
|
6632
|
+
MIN_APTOS_CLI_VERSION,
|
|
6633
|
+
"...",
|
|
6634
|
+
" ",
|
|
6635
|
+
aptosCliMeetsRequirement ? "found" : "not found"
|
|
6636
|
+
] }),
|
|
6637
|
+
/* @__PURE__ */ jsxs6(Text6, { children: [
|
|
6638
|
+
"\u2714 Do you want to set up standard contexts (",
|
|
6639
|
+
STANDARD_CONTEXT_NAMES,
|
|
6640
|
+
")? Yes"
|
|
6641
|
+
] }),
|
|
6642
|
+
/* @__PURE__ */ jsx8(Text6, { children: "API Key? (optional: leave blank to skip)" }),
|
|
6643
|
+
/* @__PURE__ */ jsx8(
|
|
6644
|
+
TextInput3,
|
|
6645
|
+
{
|
|
6646
|
+
value: standardContextsApiKey,
|
|
6647
|
+
onChange: setStandardContextsApiKey,
|
|
6648
|
+
onSubmit: () => setStep("customContext")
|
|
6649
|
+
}
|
|
6650
|
+
)
|
|
6651
|
+
] });
|
|
6652
|
+
}
|
|
6951
6653
|
if (step === "customContext") {
|
|
6952
6654
|
return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", children: [
|
|
6953
6655
|
/* @__PURE__ */ jsxs6(Text6, { children: [
|
|
@@ -6964,6 +6666,11 @@ var InitWizard = ({ existingConfig, onComplete }) => {
|
|
|
6964
6666
|
" ",
|
|
6965
6667
|
setupStandardContexts ? "Yes" : "No"
|
|
6966
6668
|
] }),
|
|
6669
|
+
setupStandardContexts && /* @__PURE__ */ jsxs6(Text6, { children: [
|
|
6670
|
+
"\u2714 API Key for standard contexts?",
|
|
6671
|
+
" ",
|
|
6672
|
+
standardContextsApiKey ? "Set" : "Not set"
|
|
6673
|
+
] }),
|
|
6967
6674
|
/* @__PURE__ */ jsx8(Text6, { children: "Do you want to set up a custom context?" }),
|
|
6968
6675
|
/* @__PURE__ */ jsx8(
|
|
6969
6676
|
SelectInput3,
|
|
@@ -7003,7 +6710,7 @@ var InitWizard = ({ existingConfig, onComplete }) => {
|
|
|
7003
6710
|
] });
|
|
7004
6711
|
}
|
|
7005
6712
|
if (step === "shelbyRpcEndpoint") {
|
|
7006
|
-
const defaultRpcEndpoint = DEFAULT_CONFIG.contexts[
|
|
6713
|
+
const defaultRpcEndpoint = DEFAULT_CONFIG.contexts[Network6.SHELBYNET].shelby_network?.rpc_endpoint;
|
|
7007
6714
|
return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", children: [
|
|
7008
6715
|
/* @__PURE__ */ jsxs6(Text6, { children: [
|
|
7009
6716
|
"\u2714 Context name? ",
|
|
@@ -7037,12 +6744,33 @@ var InitWizard = ({ existingConfig, onComplete }) => {
|
|
|
7037
6744
|
items: shelbyNetworks.map((name) => ({ label: name, value: name })),
|
|
7038
6745
|
onSelect: (item) => {
|
|
7039
6746
|
setAptosNetwork(item.value);
|
|
7040
|
-
setStep("
|
|
6747
|
+
setStep("customContextApiKey");
|
|
7041
6748
|
}
|
|
7042
6749
|
}
|
|
7043
6750
|
)
|
|
7044
6751
|
] });
|
|
7045
6752
|
}
|
|
6753
|
+
if (step === "customContextApiKey") {
|
|
6754
|
+
return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", children: [
|
|
6755
|
+
/* @__PURE__ */ jsxs6(Text6, { children: [
|
|
6756
|
+
"\u2714 Shelby RPC endpoint? ",
|
|
6757
|
+
shelbyRpcEndpoint
|
|
6758
|
+
] }),
|
|
6759
|
+
/* @__PURE__ */ jsxs6(Text6, { children: [
|
|
6760
|
+
"\u2714 Aptos network? ",
|
|
6761
|
+
aptosNetwork
|
|
6762
|
+
] }),
|
|
6763
|
+
/* @__PURE__ */ jsx8(Text6, { children: "API Key? (optional: leave blank to skip)" }),
|
|
6764
|
+
/* @__PURE__ */ jsx8(
|
|
6765
|
+
TextInput3,
|
|
6766
|
+
{
|
|
6767
|
+
value: customContextApiKey,
|
|
6768
|
+
onChange: setCustomContextApiKey,
|
|
6769
|
+
onSubmit: () => setStep("setupAccount")
|
|
6770
|
+
}
|
|
6771
|
+
)
|
|
6772
|
+
] });
|
|
6773
|
+
}
|
|
7046
6774
|
if (step === "setupAccount") {
|
|
7047
6775
|
return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", children: [
|
|
7048
6776
|
/* @__PURE__ */ jsx8(Text6, { children: "Create or update an account now?" }),
|
|
@@ -7132,6 +6860,10 @@ var InitWizard = ({ existingConfig, onComplete }) => {
|
|
|
7132
6860
|
const newKey = generateEd25519Account();
|
|
7133
6861
|
setGeneratedKey(newKey.privateKey.toAIP80String());
|
|
7134
6862
|
setGeneratedAddress(newKey.accountAddress.toString());
|
|
6863
|
+
} else {
|
|
6864
|
+
const priv = new Ed25519PrivateKey3(privateKey);
|
|
6865
|
+
const key = Account2.fromPrivateKey({ privateKey: priv });
|
|
6866
|
+
setAddress(key.accountAddress.toString());
|
|
7135
6867
|
}
|
|
7136
6868
|
setStep("complete");
|
|
7137
6869
|
}
|
|
@@ -7146,25 +6878,33 @@ var InitWizard = ({ existingConfig, onComplete }) => {
|
|
|
7146
6878
|
import { useEffect as useEffect5, useState as useState7 } from "react";
|
|
7147
6879
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
7148
6880
|
var UpdateContextWizard = ({
|
|
6881
|
+
currentApiKey,
|
|
7149
6882
|
currentShelbyNetwork = {},
|
|
7150
6883
|
currentAptosNetwork,
|
|
7151
6884
|
onComplete
|
|
7152
6885
|
}) => {
|
|
7153
6886
|
const [step, setStep] = useState7("review");
|
|
6887
|
+
const [apiKey, setApiKey] = useState7(currentApiKey || "");
|
|
7154
6888
|
const [shelbyNetwork, setShelbyNetwork] = useState7(currentShelbyNetwork);
|
|
7155
6889
|
const [aptosNetwork, setAptosNetwork] = useState7(currentAptosNetwork);
|
|
7156
6890
|
useEffect5(() => {
|
|
7157
6891
|
if (step === "done") {
|
|
7158
|
-
onComplete({
|
|
6892
|
+
onComplete({
|
|
6893
|
+
apiKey: apiKey || void 0,
|
|
6894
|
+
shelbyNetwork,
|
|
6895
|
+
aptosNetwork
|
|
6896
|
+
});
|
|
7159
6897
|
}
|
|
7160
|
-
}, [step, shelbyNetwork, aptosNetwork, onComplete]);
|
|
6898
|
+
}, [step, apiKey, shelbyNetwork, aptosNetwork, onComplete]);
|
|
7161
6899
|
if (step === "review") {
|
|
7162
6900
|
return /* @__PURE__ */ jsx9(
|
|
7163
6901
|
ContextReviewWizard,
|
|
7164
6902
|
{
|
|
6903
|
+
initialApiKey: apiKey,
|
|
7165
6904
|
initialAptosNetwork: aptosNetwork,
|
|
7166
6905
|
initialShelbyNetwork: shelbyNetwork,
|
|
7167
|
-
onComplete: ({ aptosNetwork: aptosNetwork2, shelbyNetwork: shelbyNetwork2 }) => {
|
|
6906
|
+
onComplete: ({ apiKey: newApiKey, aptosNetwork: aptosNetwork2, shelbyNetwork: shelbyNetwork2 }) => {
|
|
6907
|
+
setApiKey(newApiKey || "");
|
|
7168
6908
|
setAptosNetwork(aptosNetwork2);
|
|
7169
6909
|
setShelbyNetwork(shelbyNetwork2);
|
|
7170
6910
|
setStep("done");
|
|
@@ -7245,32 +6985,54 @@ var handleError = (error) => {
|
|
|
7245
6985
|
|
|
7246
6986
|
// src/commands/account.tsx
|
|
7247
6987
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
7248
|
-
var CreateAccountOptionsSchema =
|
|
7249
|
-
name:
|
|
7250
|
-
privateKey:
|
|
7251
|
-
address:
|
|
7252
|
-
scheme:
|
|
6988
|
+
var CreateAccountOptionsSchema = z9.object({
|
|
6989
|
+
name: z9.string().optional(),
|
|
6990
|
+
privateKey: z9.string().optional(),
|
|
6991
|
+
address: z9.string().optional(),
|
|
6992
|
+
scheme: SignatureSchemeSchema.optional()
|
|
7253
6993
|
});
|
|
7254
|
-
var
|
|
7255
|
-
|
|
7256
|
-
|
|
6994
|
+
var allSchemes = SignatureSchemeSchema.options.join(", ");
|
|
6995
|
+
function askQuestion(question) {
|
|
6996
|
+
const rl = readline.createInterface({
|
|
6997
|
+
input: process.stdin,
|
|
6998
|
+
output: process.stdout
|
|
6999
|
+
});
|
|
7000
|
+
return new Promise((resolve2) => {
|
|
7001
|
+
rl.question(question, (answer) => {
|
|
7002
|
+
rl.close();
|
|
7003
|
+
resolve2(answer.trim());
|
|
7004
|
+
});
|
|
7005
|
+
});
|
|
7006
|
+
}
|
|
7007
|
+
async function promptForAccountName(config) {
|
|
7008
|
+
while (true) {
|
|
7009
|
+
const answer = await askQuestion("Enter a name for this account: ");
|
|
7010
|
+
const error = validateAccountName(answer, config);
|
|
7011
|
+
if (error) {
|
|
7012
|
+
console.error(`\u274C ${error}`);
|
|
7013
|
+
continue;
|
|
7014
|
+
}
|
|
7015
|
+
return answer;
|
|
7016
|
+
}
|
|
7017
|
+
}
|
|
7018
|
+
var ListAccountOptionsSchema = z9.object({});
|
|
7019
|
+
var UseAccountOptionsSchema = z9.object({
|
|
7020
|
+
accountName: z9.string()
|
|
7257
7021
|
});
|
|
7258
|
-
var DeleteAccountOptionsSchema =
|
|
7259
|
-
accountName:
|
|
7022
|
+
var DeleteAccountOptionsSchema = z9.object({
|
|
7023
|
+
accountName: z9.string()
|
|
7260
7024
|
});
|
|
7261
7025
|
function accountCommand(program) {
|
|
7262
7026
|
const account = program.command("account").description("Manage signing accounts (addresses & keys)");
|
|
7263
7027
|
account.command("create").description("Create a new account").option("--name <account-name>", "Name of the account").option(
|
|
7264
|
-
|
|
7265
|
-
'--scheme <signature-scheme: "ed25519">',
|
|
7028
|
+
`--scheme <signature-scheme: "${SignatureSchemeSchema.Enum.ed25519}">`,
|
|
7266
7029
|
"Signature scheme of the private key"
|
|
7267
7030
|
).option("--private-key <key>", "Raw private key").option(
|
|
7268
7031
|
"--address <account-address>",
|
|
7269
7032
|
"Aptos account address (hex-encoded)"
|
|
7270
|
-
).action((options) => {
|
|
7033
|
+
).action(async (options) => {
|
|
7271
7034
|
CreateAccountOptionsSchema.parse(options);
|
|
7272
7035
|
const { name, privateKey, address, scheme } = options;
|
|
7273
|
-
const allPresent = name && privateKey && address && scheme;
|
|
7274
7036
|
const configPath = program.opts().configFile;
|
|
7275
7037
|
let config;
|
|
7276
7038
|
try {
|
|
@@ -7280,48 +7042,78 @@ function accountCommand(program) {
|
|
|
7280
7042
|
`${err.message}. Please ensure you've first initialized the config by doing \`shelby init\``
|
|
7281
7043
|
);
|
|
7282
7044
|
}
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
7045
|
+
const targetName = options.name ?? null;
|
|
7046
|
+
if (privateKey && !scheme) {
|
|
7047
|
+
console.error(
|
|
7048
|
+
`\u274C --scheme is required when providing --private-key (currently only "${allSchemes}" is supported).`
|
|
7049
|
+
);
|
|
7050
|
+
process.exit(1);
|
|
7051
|
+
}
|
|
7052
|
+
if (scheme && !SignatureSchemeSchema.options.includes(scheme)) {
|
|
7053
|
+
console.error(
|
|
7054
|
+
`\u274C Unsupported signature scheme. Only "${allSchemes}" is supported.`
|
|
7055
|
+
);
|
|
7056
|
+
process.exit(1);
|
|
7057
|
+
}
|
|
7058
|
+
let finalName = targetName;
|
|
7059
|
+
if (privateKey && !finalName) {
|
|
7060
|
+
finalName = await promptForAccountName(config);
|
|
7061
|
+
}
|
|
7062
|
+
const canCreateFromFlags = Boolean(privateKey && finalName);
|
|
7063
|
+
if (canCreateFromFlags && privateKey && finalName) {
|
|
7064
|
+
if (!isValidEd25519PrivateKey(privateKey)) {
|
|
7065
|
+
throw new Error("Error invalid account address or private key");
|
|
7066
|
+
}
|
|
7067
|
+
let finalAddress = address ?? "";
|
|
7068
|
+
if (finalAddress) {
|
|
7069
|
+
if (!isValidAddress(finalAddress)) {
|
|
7070
|
+
throw new Error("Error invalid account address or private key");
|
|
7290
7071
|
}
|
|
7291
7072
|
} else {
|
|
7292
|
-
|
|
7073
|
+
const edKey = new Ed25519PrivateKey4(privateKey);
|
|
7074
|
+
const derived = Account3.fromPrivateKey({ privateKey: edKey });
|
|
7075
|
+
finalAddress = derived.accountAddress.toString();
|
|
7076
|
+
}
|
|
7077
|
+
config.accounts[finalName] = {
|
|
7078
|
+
private_key: privateKey,
|
|
7079
|
+
address: finalAddress
|
|
7080
|
+
};
|
|
7081
|
+
if (!config.default_account) {
|
|
7082
|
+
config.default_account = finalName;
|
|
7293
7083
|
}
|
|
7294
7084
|
saveConfig(config, configPath);
|
|
7295
|
-
console.log(`\u2705 Account '${
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7085
|
+
console.log(`\u2705 Account '${finalName}' created successfully`);
|
|
7086
|
+
console.log(` Address: ${finalAddress}`);
|
|
7087
|
+
return;
|
|
7088
|
+
}
|
|
7089
|
+
try {
|
|
7090
|
+
const { unmount } = render(
|
|
7091
|
+
/* @__PURE__ */ jsx10(
|
|
7092
|
+
AccountWizard,
|
|
7093
|
+
{
|
|
7094
|
+
initialName: name,
|
|
7095
|
+
config,
|
|
7096
|
+
onComplete: ({
|
|
7097
|
+
name: name2,
|
|
7098
|
+
address: address2,
|
|
7099
|
+
privateKey: privateKey2
|
|
7100
|
+
}) => {
|
|
7101
|
+
config.accounts[name2] = {
|
|
7102
|
+
private_key: privateKey2,
|
|
7103
|
+
address: address2
|
|
7104
|
+
};
|
|
7105
|
+
saveConfig(config, configPath);
|
|
7106
|
+
console.log(
|
|
7107
|
+
`\u2705 Account ${name2} saved to ${resolveConfigPath(configPath)}`
|
|
7108
|
+
);
|
|
7109
|
+
unmount();
|
|
7318
7110
|
}
|
|
7319
|
-
|
|
7320
|
-
)
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7111
|
+
}
|
|
7112
|
+
)
|
|
7113
|
+
);
|
|
7114
|
+
} catch (err) {
|
|
7115
|
+
console.error(`Error creating account: ${err.message}`);
|
|
7116
|
+
process.exit(1);
|
|
7325
7117
|
}
|
|
7326
7118
|
});
|
|
7327
7119
|
account.command("list").description("List all accounts in a table view").action(() => {
|
|
@@ -7472,7 +7264,7 @@ function accountCommand(program) {
|
|
|
7472
7264
|
const config = loadConfig(configPath);
|
|
7473
7265
|
const contextName = globalOpts.context || config.default_context;
|
|
7474
7266
|
const context = getCurrentContext(config, contextName);
|
|
7475
|
-
const aptos =
|
|
7267
|
+
const aptos = getAptosFromContext(context);
|
|
7476
7268
|
const accountName = globalOpts.account || config.default_account;
|
|
7477
7269
|
const accountInfo = getCurrentAccount(config, accountName);
|
|
7478
7270
|
const targetAddress = resolveAccountAddress({
|
|
@@ -7564,18 +7356,18 @@ function accountCommand(program) {
|
|
|
7564
7356
|
import * as fs2 from "fs";
|
|
7565
7357
|
import * as fsP from "fs/promises";
|
|
7566
7358
|
import { Readable } from "stream";
|
|
7567
|
-
import { z as
|
|
7568
|
-
var CommitmentOptionsSchema =
|
|
7569
|
-
input:
|
|
7570
|
-
async (
|
|
7571
|
-
const stat4 = await fsP.stat(
|
|
7359
|
+
import { z as z10 } from "zod";
|
|
7360
|
+
var CommitmentOptionsSchema = z10.object({
|
|
7361
|
+
input: z10.string().nonempty("`--input` is required").refine(
|
|
7362
|
+
async (path6) => {
|
|
7363
|
+
const stat4 = await fsP.stat(path6);
|
|
7572
7364
|
return stat4.isFile();
|
|
7573
7365
|
},
|
|
7574
7366
|
{
|
|
7575
7367
|
message: "`--input` must be a file"
|
|
7576
7368
|
}
|
|
7577
7369
|
),
|
|
7578
|
-
output:
|
|
7370
|
+
output: z10.string().nonempty("`--output` is required")
|
|
7579
7371
|
});
|
|
7580
7372
|
function commitmentCommand(program) {
|
|
7581
7373
|
program.command("commitment <input> <output>").description(
|
|
@@ -7597,29 +7389,29 @@ function commitmentCommand(program) {
|
|
|
7597
7389
|
|
|
7598
7390
|
// src/commands/context.tsx
|
|
7599
7391
|
import { render as render2 } from "ink";
|
|
7600
|
-
import { z as
|
|
7392
|
+
import { z as z12 } from "zod";
|
|
7601
7393
|
|
|
7602
7394
|
// src/utils/commands.ts
|
|
7603
|
-
import
|
|
7604
|
-
var AptosCommandOptionsSchema =
|
|
7605
|
-
aptosNetwork:
|
|
7395
|
+
import z11 from "zod";
|
|
7396
|
+
var AptosCommandOptionsSchema = z11.object({
|
|
7397
|
+
aptosNetwork: z11.string().optional(),
|
|
7606
7398
|
// predefined network name
|
|
7607
|
-
aptosFullnode:
|
|
7608
|
-
aptosFaucet:
|
|
7609
|
-
aptosIndexer:
|
|
7610
|
-
aptosPepper:
|
|
7611
|
-
aptosProver:
|
|
7612
|
-
aptosApiKey:
|
|
7399
|
+
aptosFullnode: z11.string().url().optional(),
|
|
7400
|
+
aptosFaucet: z11.string().url().optional(),
|
|
7401
|
+
aptosIndexer: z11.string().url().optional(),
|
|
7402
|
+
aptosPepper: z11.string().url().optional(),
|
|
7403
|
+
aptosProver: z11.string().url().optional(),
|
|
7404
|
+
aptosApiKey: z11.string().optional()
|
|
7613
7405
|
});
|
|
7614
7406
|
var addAptosCommandOptions = (context) => context.option(
|
|
7615
7407
|
"--aptos-network <network>",
|
|
7616
7408
|
`Aptos network (${shelbyNetworks.join(", ")})`
|
|
7617
7409
|
).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");
|
|
7618
|
-
var ShelbyCommandOptionsSchema =
|
|
7410
|
+
var ShelbyCommandOptionsSchema = z11.object({
|
|
7619
7411
|
shelbyRpcEndpoint: EndpointSchema.optional(),
|
|
7620
7412
|
shelbyIndexerEndpoint: EndpointSchema.optional(),
|
|
7621
|
-
shelbyRpcApiKey:
|
|
7622
|
-
shelbyIndexerApiKey:
|
|
7413
|
+
shelbyRpcApiKey: z11.string().optional(),
|
|
7414
|
+
shelbyIndexerApiKey: z11.string().optional()
|
|
7623
7415
|
});
|
|
7624
7416
|
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");
|
|
7625
7417
|
|
|
@@ -7656,8 +7448,8 @@ function getShelbyNetworkFromOptions(options) {
|
|
|
7656
7448
|
indexer_api_key: options.shelbyIndexerApiKey
|
|
7657
7449
|
};
|
|
7658
7450
|
}
|
|
7659
|
-
var CreateContextOptionsSchema =
|
|
7660
|
-
var UpdateContextOptionsSchema =
|
|
7451
|
+
var CreateContextOptionsSchema = z12.object({ name: z12.string().optional() }).merge(AptosCommandOptionsSchema).merge(ShelbyCommandOptionsSchema);
|
|
7452
|
+
var UpdateContextOptionsSchema = z12.object({}).merge(ShelbyCommandOptionsSchema).merge(AptosCommandOptionsSchema);
|
|
7661
7453
|
function contextCommand(program) {
|
|
7662
7454
|
const context = program.command("context").description("Manage network contexts (Shelby RPC & Aptos endpoints)");
|
|
7663
7455
|
addShelbyCommandOptions(addAptosCommandOptions(context.command("create"))).description("Create a new context").option("--name <context-name>", "Name of the context").action((options) => {
|
|
@@ -7707,10 +7499,12 @@ function contextCommand(program) {
|
|
|
7707
7499
|
{
|
|
7708
7500
|
onComplete: ({
|
|
7709
7501
|
name: name2,
|
|
7502
|
+
apiKey,
|
|
7710
7503
|
shelbyNetwork: shelbyNetwork2,
|
|
7711
7504
|
aptosNetwork: aptosNetwork2
|
|
7712
7505
|
}) => {
|
|
7713
7506
|
config.contexts[name2] = {
|
|
7507
|
+
api_key: apiKey,
|
|
7714
7508
|
shelby_network: shelbyNetwork2,
|
|
7715
7509
|
aptos_network: aptosNetwork2
|
|
7716
7510
|
};
|
|
@@ -7772,10 +7566,12 @@ function contextCommand(program) {
|
|
|
7772
7566
|
/* @__PURE__ */ jsx11(
|
|
7773
7567
|
UpdateContextWizard,
|
|
7774
7568
|
{
|
|
7569
|
+
currentApiKey: currentContext.api_key,
|
|
7775
7570
|
currentShelbyNetwork: currentContext.shelby_network,
|
|
7776
7571
|
currentAptosNetwork: currentContext.aptos_network,
|
|
7777
|
-
onComplete: ({ shelbyNetwork: shelbyNetwork2, aptosNetwork: aptosNetwork2 }) => {
|
|
7572
|
+
onComplete: ({ apiKey, shelbyNetwork: shelbyNetwork2, aptosNetwork: aptosNetwork2 }) => {
|
|
7778
7573
|
config.contexts[contextName] = {
|
|
7574
|
+
api_key: apiKey,
|
|
7779
7575
|
shelby_network: {
|
|
7780
7576
|
...currentContext.shelby_network,
|
|
7781
7577
|
...shelbyNetwork2,
|
|
@@ -7819,8 +7615,6 @@ function contextCommand(program) {
|
|
|
7819
7615
|
},
|
|
7820
7616
|
{ header: "Indexer", width: 40, shrinkPriority: "high" },
|
|
7821
7617
|
{ header: "Faucet", width: 40, shrinkPriority: "high" },
|
|
7822
|
-
{ header: "Pepper", width: 40, shrinkPriority: "low", minWidth: 8 },
|
|
7823
|
-
{ header: "Prover", width: 40, shrinkPriority: "low", minWidth: 8 },
|
|
7824
7618
|
{
|
|
7825
7619
|
header: "API Key",
|
|
7826
7620
|
width: 15,
|
|
@@ -7828,7 +7622,7 @@ function contextCommand(program) {
|
|
|
7828
7622
|
minWidth: 6
|
|
7829
7623
|
}
|
|
7830
7624
|
],
|
|
7831
|
-
padding:
|
|
7625
|
+
padding: 20
|
|
7832
7626
|
});
|
|
7833
7627
|
const { table: shelbyConfigTable, wrapCell: wrapShelbyCell } = createResponsiveTable({
|
|
7834
7628
|
columns: [
|
|
@@ -7850,11 +7644,13 @@ function contextCommand(program) {
|
|
|
7850
7644
|
],
|
|
7851
7645
|
padding: 18
|
|
7852
7646
|
});
|
|
7647
|
+
const defaultContext = config.default_context;
|
|
7648
|
+
const formatName = (ctxName) => ctxName === defaultContext ? `${ctxName} (default)` : ctxName;
|
|
7853
7649
|
for (const [ctxName, ctx] of Object.entries(config.contexts)) {
|
|
7854
7650
|
const shelbyRow = [
|
|
7855
|
-
ctxName,
|
|
7856
|
-
ctx.shelby_network?.rpc_endpoint || "
|
|
7857
|
-
ctx.shelby_network?.indexer_endpoint || "
|
|
7651
|
+
formatName(ctxName),
|
|
7652
|
+
ctx.shelby_network?.rpc_endpoint || "",
|
|
7653
|
+
ctx.shelby_network?.indexer_endpoint || "",
|
|
7858
7654
|
ctx.shelby_network?.rpc_api_key || "",
|
|
7859
7655
|
ctx.shelby_network?.indexer_api_key || ""
|
|
7860
7656
|
];
|
|
@@ -7862,13 +7658,11 @@ function contextCommand(program) {
|
|
|
7862
7658
|
shelbyRow.map((cell, i) => wrapShelbyCell(cell, i))
|
|
7863
7659
|
);
|
|
7864
7660
|
const aptosRow = [
|
|
7865
|
-
ctxName,
|
|
7661
|
+
formatName(ctxName),
|
|
7866
7662
|
ctx.aptos_network.name,
|
|
7867
|
-
ctx.aptos_network.fullnode || "
|
|
7868
|
-
ctx.aptos_network.indexer || "
|
|
7869
|
-
ctx.aptos_network.faucet || "
|
|
7870
|
-
ctx.aptos_network.pepper || "(default)",
|
|
7871
|
-
ctx.aptos_network.prover || "(default)",
|
|
7663
|
+
ctx.aptos_network.fullnode || "",
|
|
7664
|
+
ctx.aptos_network.indexer || "",
|
|
7665
|
+
ctx.aptos_network.faucet || "",
|
|
7872
7666
|
ctx.aptos_network.api_key || ""
|
|
7873
7667
|
];
|
|
7874
7668
|
aptosConfigTable.push(
|
|
@@ -7930,16 +7724,16 @@ import * as path3 from "path";
|
|
|
7930
7724
|
import { Readable as Readable2, Transform } from "stream";
|
|
7931
7725
|
import { pipeline } from "stream/promises";
|
|
7932
7726
|
import ora from "ora";
|
|
7933
|
-
import { z as
|
|
7727
|
+
import { z as z13 } from "zod";
|
|
7934
7728
|
var denormBlobName2 = (a, b, c) => denormBlobName(path3, a, b, c);
|
|
7935
7729
|
var endsWithDirectorySeparator = (filePath) => {
|
|
7936
7730
|
return filePath.endsWith("/") || filePath.endsWith("\\") || filePath.endsWith(path3.sep);
|
|
7937
7731
|
};
|
|
7938
|
-
var DownloadOptionsSchema =
|
|
7939
|
-
src:
|
|
7940
|
-
dst:
|
|
7941
|
-
recursive:
|
|
7942
|
-
force:
|
|
7732
|
+
var DownloadOptionsSchema = z13.object({
|
|
7733
|
+
src: z13.string().min(1, "`src`must be a valid blob name or directory prefix").describe("Blob name or directory prefix to download"),
|
|
7734
|
+
dst: z13.string().min(1, "`dst` must be a valid filepath").describe("Local path where to save the downloaded content"),
|
|
7735
|
+
recursive: z13.boolean().default(false).describe("Download assuming canonical directory layout and recurse"),
|
|
7736
|
+
force: z13.boolean().default(false).describe("Overwrite the dst if it already exists")
|
|
7943
7737
|
}).refine(
|
|
7944
7738
|
(data) => {
|
|
7945
7739
|
if (data.recursive) {
|
|
@@ -8179,12 +7973,12 @@ function downloadCommand(program) {
|
|
|
8179
7973
|
}
|
|
8180
7974
|
|
|
8181
7975
|
// src/commands/faucet.tsx
|
|
8182
|
-
import { Network as
|
|
7976
|
+
import { Network as Network7 } from "@aptos-labs/ts-sdk";
|
|
8183
7977
|
import { execaSync } from "execa";
|
|
8184
|
-
import { z as
|
|
8185
|
-
var FaucetOptionsSchema =
|
|
8186
|
-
network:
|
|
8187
|
-
"no-open":
|
|
7978
|
+
import { z as z14 } from "zod";
|
|
7979
|
+
var FaucetOptionsSchema = z14.object({
|
|
7980
|
+
network: z14.enum([Network7.SHELBYNET]).optional(),
|
|
7981
|
+
"no-open": z14.boolean().optional().default(false)
|
|
8188
7982
|
});
|
|
8189
7983
|
function faucetCommand(program) {
|
|
8190
7984
|
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) => {
|
|
@@ -8194,7 +7988,7 @@ function faucetCommand(program) {
|
|
|
8194
7988
|
const config = loadConfig(configPath);
|
|
8195
7989
|
const accountName = program.opts().account || config.default_account;
|
|
8196
7990
|
const { account } = getCurrentAccount(config, accountName);
|
|
8197
|
-
const network = validatedOptions.network ||
|
|
7991
|
+
const network = validatedOptions.network || Network7.SHELBYNET;
|
|
8198
7992
|
if (network === "mainnet") {
|
|
8199
7993
|
throw new Error(
|
|
8200
7994
|
"\u274C No faucet available for mainnet. Mainnet tokens must be obtained through other means."
|
|
@@ -8255,28 +8049,20 @@ function openBrowser(url) {
|
|
|
8255
8049
|
}
|
|
8256
8050
|
|
|
8257
8051
|
// src/commands/init.tsx
|
|
8052
|
+
import path4 from "path";
|
|
8053
|
+
import fs4 from "fs-extra";
|
|
8258
8054
|
import { render as render3 } from "ink";
|
|
8259
8055
|
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
8260
8056
|
function initCommand(program) {
|
|
8261
8057
|
program.command("init").description(
|
|
8262
8058
|
"Bootstrap your Shelby config via an interactive wizard or flags"
|
|
8263
8059
|
).option(
|
|
8264
|
-
"--setup-default
|
|
8265
|
-
|
|
8060
|
+
"--setup-default",
|
|
8061
|
+
"Generate standard contexts and a fresh account",
|
|
8266
8062
|
false
|
|
8267
|
-
).
|
|
8268
|
-
"--shelby-rpc-endpoint <url>",
|
|
8269
|
-
"Shelby RPC endpoint for this context"
|
|
8270
|
-
).option(
|
|
8271
|
-
"--aptos-api-endpoint <url>",
|
|
8272
|
-
"Aptos REST API endpoint for this context"
|
|
8273
|
-
).option(
|
|
8274
|
-
"--signature-scheme <scheme>",
|
|
8275
|
-
// "Signature scheme (ed25519 or secp256k1)",
|
|
8276
|
-
"Signature scheme (ed25519)",
|
|
8277
|
-
ED25519_NAME
|
|
8278
|
-
).option("--private-key <key>", "Raw private key").action((options) => {
|
|
8063
|
+
).action((options) => {
|
|
8279
8064
|
const configPath = program.opts().configFile || "~/.shelby/config.yaml";
|
|
8065
|
+
const resolvedPath = resolveConfigPath(configPath);
|
|
8280
8066
|
const accountName = program.opts().account;
|
|
8281
8067
|
const hasExistingConfig = configExists(configPath);
|
|
8282
8068
|
let existingConfigValid = false;
|
|
@@ -8285,104 +8071,112 @@ function initCommand(program) {
|
|
|
8285
8071
|
loadConfig(configPath);
|
|
8286
8072
|
existingConfigValid = true;
|
|
8287
8073
|
} catch (_error) {
|
|
8288
|
-
const
|
|
8074
|
+
const resolvedPath2 = resolveConfigPath(configPath);
|
|
8289
8075
|
console.log(
|
|
8290
|
-
`\u26A0\uFE0F Found existing config at ${
|
|
8076
|
+
`\u26A0\uFE0F Found existing config at ${resolvedPath2} but it has an incompatible schema.`
|
|
8291
8077
|
);
|
|
8292
8078
|
console.log(
|
|
8293
8079
|
"\u26A0\uFE0F The config will be overwritten with a new configuration.\n"
|
|
8294
8080
|
);
|
|
8295
8081
|
}
|
|
8296
8082
|
}
|
|
8297
|
-
if (options.
|
|
8298
|
-
if (
|
|
8299
|
-
|
|
8300
|
-
|
|
8301
|
-
|
|
8302
|
-
|
|
8303
|
-
);
|
|
8304
|
-
process.exit(1);
|
|
8305
|
-
}
|
|
8306
|
-
}
|
|
8307
|
-
let config;
|
|
8308
|
-
if (existingConfigValid) {
|
|
8309
|
-
config = loadConfig(configPath);
|
|
8310
|
-
} else {
|
|
8311
|
-
config = {
|
|
8312
|
-
contexts: {},
|
|
8313
|
-
accounts: {},
|
|
8314
|
-
default_context: options.setupDefaultContexts ? DEFAULT_CONFIG.default_context : options.context,
|
|
8315
|
-
default_account: accountName
|
|
8316
|
-
};
|
|
8317
|
-
}
|
|
8318
|
-
if (options.setupDefaultContexts) {
|
|
8319
|
-
config.contexts = DEFAULT_CONFIG.contexts;
|
|
8320
|
-
}
|
|
8321
|
-
if (options.context && options.shelbyRpcEndpoint && options.aptosNetwork) {
|
|
8322
|
-
config.contexts[options.context] = {
|
|
8323
|
-
aptos_network: options.aptosNetwork,
|
|
8324
|
-
shelby_network: { rpc_endpoint: options.shelbyRpcEndpoint }
|
|
8325
|
-
};
|
|
8326
|
-
}
|
|
8327
|
-
if (options.privateKey) {
|
|
8328
|
-
config.accounts[accountName] = {
|
|
8329
|
-
private_key: options.privateKey
|
|
8330
|
-
};
|
|
8083
|
+
if (options.setupDefault) {
|
|
8084
|
+
if (configExists(configPath)) {
|
|
8085
|
+
console.error(
|
|
8086
|
+
`\u274C Refusing to overwrite existing config at ${resolvedPath}. Remove it first or run 'shelby init' interactively.`
|
|
8087
|
+
);
|
|
8088
|
+
process.exit(1);
|
|
8331
8089
|
}
|
|
8090
|
+
const generated = generateEd25519Account();
|
|
8091
|
+
const finalAccountName = accountName ?? "default";
|
|
8092
|
+
const config = {
|
|
8093
|
+
contexts: cloneContexts(DEFAULT_CONFIG.contexts),
|
|
8094
|
+
accounts: {
|
|
8095
|
+
[finalAccountName]: {
|
|
8096
|
+
private_key: generated.privateKey.toAIP80String(),
|
|
8097
|
+
address: generated.accountAddress.toString()
|
|
8098
|
+
}
|
|
8099
|
+
},
|
|
8100
|
+
default_context: DEFAULT_CONFIG.default_context,
|
|
8101
|
+
default_account: finalAccountName
|
|
8102
|
+
};
|
|
8103
|
+
ensureConfigDir(resolvedPath);
|
|
8332
8104
|
saveConfig(config, configPath);
|
|
8333
8105
|
console.log(
|
|
8334
|
-
`\u2705
|
|
8106
|
+
`\u2705 Default Shelby configuration created at ${resolvedPath}`
|
|
8335
8107
|
);
|
|
8336
|
-
|
|
8337
|
-
|
|
8338
|
-
|
|
8339
|
-
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
8108
|
+
console.log(` Account name: ${finalAccountName}`);
|
|
8109
|
+
console.log(` Address: ${generated.accountAddress.toString()}`);
|
|
8110
|
+
console.log(` Private key: ${generated.privateKey.toAIP80String()}`);
|
|
8111
|
+
console.log("\n\u2139\uFE0F Fund the new account before performing uploads:");
|
|
8112
|
+
console.log(
|
|
8113
|
+
` aptos init --profile ${finalAccountName} --assume-yes --private-key ${generated.privateKey.toAIP80String()} --network ${DEFAULT_CONFIG.default_context}`
|
|
8114
|
+
);
|
|
8115
|
+
console.log(
|
|
8116
|
+
` aptos account fund-with-faucet --profile ${finalAccountName}`
|
|
8117
|
+
);
|
|
8118
|
+
return;
|
|
8119
|
+
}
|
|
8120
|
+
let existingConfigInstance;
|
|
8121
|
+
if (existingConfigValid) {
|
|
8122
|
+
existingConfigInstance = loadConfig(configPath);
|
|
8123
|
+
}
|
|
8124
|
+
const { unmount } = render3(
|
|
8125
|
+
/* @__PURE__ */ jsx12(
|
|
8126
|
+
InitWizard,
|
|
8127
|
+
{
|
|
8128
|
+
existingConfig: existingConfigInstance,
|
|
8129
|
+
onComplete: (config) => {
|
|
8130
|
+
ensureConfigDir(resolvedPath);
|
|
8131
|
+
saveConfig(config, configPath);
|
|
8132
|
+
console.log(`\u2705 Configuration saved to ${resolvedPath}`);
|
|
8133
|
+
if (config.default_account && config.accounts[config.default_account]?.private_key?.startsWith(
|
|
8134
|
+
"ed25519-priv-"
|
|
8135
|
+
)) {
|
|
8348
8136
|
console.log(
|
|
8349
|
-
|
|
8137
|
+
"\n\u2139\uFE0F To fund your new account on-chain (shelbynet only):"
|
|
8138
|
+
);
|
|
8139
|
+
console.log(" 1. Import the private key into Aptos CLI:");
|
|
8140
|
+
console.log(
|
|
8141
|
+
` aptos init --profile ${config.default_account} --private-key ${config.accounts[config.default_account].private_key} --network ${config.default_context}`
|
|
8142
|
+
);
|
|
8143
|
+
console.log(" 2. Run the faucet:");
|
|
8144
|
+
console.log(
|
|
8145
|
+
` aptos account fund-with-faucet --profile ${config.default_account}`
|
|
8350
8146
|
);
|
|
8351
|
-
if (config.default_account && config.accounts[config.default_account]?.private_key?.startsWith("ed25519-priv-")) {
|
|
8352
|
-
console.log(
|
|
8353
|
-
"\n\u2139\uFE0F To fund your new account on-chain (shelbynet only):"
|
|
8354
|
-
);
|
|
8355
|
-
console.log(" 1. Import the private key into Aptos CLI:");
|
|
8356
|
-
console.log(
|
|
8357
|
-
` aptos init --profile ${config.default_account} --private-key ${config.accounts[config.default_account].private_key} --network ${config.default_context}`
|
|
8358
|
-
);
|
|
8359
|
-
console.log(" 2. Run the faucet:");
|
|
8360
|
-
console.log(
|
|
8361
|
-
` aptos account fund-with-faucet --profile ${config.default_account}`
|
|
8362
|
-
);
|
|
8363
|
-
}
|
|
8364
|
-
unmount();
|
|
8365
|
-
process.exit(0);
|
|
8366
8147
|
}
|
|
8148
|
+
unmount();
|
|
8149
|
+
process.exit(0);
|
|
8150
|
+
},
|
|
8151
|
+
onCancel: () => {
|
|
8152
|
+
unmount();
|
|
8153
|
+
console.log("\u274C Init cancelled. Config file was not modified.");
|
|
8154
|
+
process.exit(0);
|
|
8367
8155
|
}
|
|
8368
|
-
|
|
8369
|
-
)
|
|
8370
|
-
|
|
8156
|
+
}
|
|
8157
|
+
)
|
|
8158
|
+
);
|
|
8371
8159
|
});
|
|
8372
8160
|
}
|
|
8161
|
+
function cloneContexts(contexts) {
|
|
8162
|
+
return JSON.parse(JSON.stringify(contexts));
|
|
8163
|
+
}
|
|
8164
|
+
function ensureConfigDir(resolvedPath) {
|
|
8165
|
+
fs4.mkdirpSync(path4.dirname(resolvedPath));
|
|
8166
|
+
}
|
|
8373
8167
|
|
|
8374
8168
|
// src/commands/upload.tsx
|
|
8375
|
-
import * as
|
|
8376
|
-
import * as
|
|
8169
|
+
import * as fs5 from "fs/promises";
|
|
8170
|
+
import * as path5 from "path";
|
|
8377
8171
|
import { Aptos as Aptos5, AptosConfig as AptosConfig4 } from "@aptos-labs/ts-sdk";
|
|
8378
8172
|
import { glob } from "glob";
|
|
8379
8173
|
import { Box as Box7, render as render4, Text as Text7 } from "ink";
|
|
8380
8174
|
import SelectInput4 from "ink-select-input";
|
|
8381
8175
|
import ora2 from "ora";
|
|
8382
|
-
import { z as
|
|
8176
|
+
import { z as z15 } from "zod";
|
|
8383
8177
|
import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
8384
|
-
var normBlobName2 = (i, f, b) => normBlobName(
|
|
8385
|
-
var flexibleDateSchema =
|
|
8178
|
+
var normBlobName2 = (i, f, b) => normBlobName(path5, i, f, b);
|
|
8179
|
+
var flexibleDateSchema = z15.string().transform((val) => {
|
|
8386
8180
|
if (/^\d+$/.test(val)) {
|
|
8387
8181
|
const timestamp = Number.parseInt(val, 10);
|
|
8388
8182
|
if (timestamp > 0 && timestamp < 4102444800) {
|
|
@@ -8395,18 +8189,18 @@ var flexibleDateSchema = z14.string().transform((val) => {
|
|
|
8395
8189
|
}
|
|
8396
8190
|
return ret;
|
|
8397
8191
|
});
|
|
8398
|
-
var UploadOptionsSchema =
|
|
8399
|
-
src:
|
|
8400
|
-
dst:
|
|
8192
|
+
var UploadOptionsSchema = z15.object({
|
|
8193
|
+
src: z15.string().nonempty("`src` positional arg is required"),
|
|
8194
|
+
dst: z15.string().nonempty("`dst` position arg is required"),
|
|
8401
8195
|
expiration: flexibleDateSchema,
|
|
8402
|
-
recursive:
|
|
8403
|
-
assumeYes:
|
|
8404
|
-
outputCommitments:
|
|
8196
|
+
recursive: z15.boolean().optional().default(false),
|
|
8197
|
+
assumeYes: z15.boolean().optional().default(false),
|
|
8198
|
+
outputCommitments: z15.string().optional()
|
|
8405
8199
|
}).superRefine(async (data, ctx) => {
|
|
8406
|
-
const stats = await
|
|
8200
|
+
const stats = await fs5.stat(data.src);
|
|
8407
8201
|
if (!stats.isFile() && !stats.isDirectory()) {
|
|
8408
8202
|
ctx.addIssue({
|
|
8409
|
-
code:
|
|
8203
|
+
code: z15.ZodIssueCode.custom,
|
|
8410
8204
|
message: "`src` must be a file or a directory",
|
|
8411
8205
|
path: ["src"]
|
|
8412
8206
|
});
|
|
@@ -8415,7 +8209,7 @@ var UploadOptionsSchema = z14.object({
|
|
|
8415
8209
|
if (stats.isDirectory()) {
|
|
8416
8210
|
if (!data.dst.endsWith("/")) {
|
|
8417
8211
|
ctx.addIssue({
|
|
8418
|
-
code:
|
|
8212
|
+
code: z15.ZodIssueCode.custom,
|
|
8419
8213
|
message: "When src is a directory, dst must end with '/'",
|
|
8420
8214
|
path: ["dst"]
|
|
8421
8215
|
});
|
|
@@ -8424,7 +8218,7 @@ var UploadOptionsSchema = z14.object({
|
|
|
8424
8218
|
const blobNameResult = BlobNameSchema.safeParse(data.dst);
|
|
8425
8219
|
if (!blobNameResult.success) {
|
|
8426
8220
|
ctx.addIssue({
|
|
8427
|
-
code:
|
|
8221
|
+
code: z15.ZodIssueCode.custom,
|
|
8428
8222
|
message: "When src is a file, dst must be a valid blob name (cannot end with '/')",
|
|
8429
8223
|
path: ["dst"]
|
|
8430
8224
|
});
|
|
@@ -8432,7 +8226,7 @@ var UploadOptionsSchema = z14.object({
|
|
|
8432
8226
|
}
|
|
8433
8227
|
});
|
|
8434
8228
|
async function createFilelist(options) {
|
|
8435
|
-
const stats = await
|
|
8229
|
+
const stats = await fs5.stat(options.src);
|
|
8436
8230
|
if (stats.isFile()) {
|
|
8437
8231
|
const blobname = normBlobName2(options.src, options.src, options.dst);
|
|
8438
8232
|
const blobNameValidation = BlobNameSchema.safeParse(blobname);
|
|
@@ -8449,11 +8243,11 @@ async function createFilelist(options) {
|
|
|
8449
8243
|
);
|
|
8450
8244
|
}
|
|
8451
8245
|
const fileList = [];
|
|
8452
|
-
const result = await glob(
|
|
8246
|
+
const result = await glob(path5.join(options.src, "**", "*"), {
|
|
8453
8247
|
nodir: true
|
|
8454
8248
|
});
|
|
8455
8249
|
for await (const file of result) {
|
|
8456
|
-
const stats2 = await
|
|
8250
|
+
const stats2 = await fs5.stat(file);
|
|
8457
8251
|
const blobname = normBlobName2(options.src, file, options.dst);
|
|
8458
8252
|
const blobNameValidation = BlobNameSchema.safeParse(blobname);
|
|
8459
8253
|
if (!blobNameValidation.success) {
|
|
@@ -8507,7 +8301,7 @@ function uploadCommand(program) {
|
|
|
8507
8301
|
}
|
|
8508
8302
|
const cost = computeCost(filelist);
|
|
8509
8303
|
if (!validatedOptions.assumeYes) {
|
|
8510
|
-
const shouldContinue = await new Promise((
|
|
8304
|
+
const shouldContinue = await new Promise((resolve2) => {
|
|
8511
8305
|
const { unmount } = render4(
|
|
8512
8306
|
/* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", children: [
|
|
8513
8307
|
/* @__PURE__ */ jsxs7(Text7, { children: [
|
|
@@ -8524,7 +8318,7 @@ function uploadCommand(program) {
|
|
|
8524
8318
|
],
|
|
8525
8319
|
onSelect: (item) => {
|
|
8526
8320
|
unmount();
|
|
8527
|
-
|
|
8321
|
+
resolve2(item.value);
|
|
8528
8322
|
}
|
|
8529
8323
|
}
|
|
8530
8324
|
)
|
|
@@ -8580,7 +8374,7 @@ function uploadCommand(program) {
|
|
|
8580
8374
|
for (const entry of filelist) {
|
|
8581
8375
|
spinner.text = `Reading ${entry.filename}.. (Overall: ${formatProgressPercent()}%, ${formatProgressRate()} MiB/s)`;
|
|
8582
8376
|
try {
|
|
8583
|
-
const blobData = await
|
|
8377
|
+
const blobData = await fs5.readFile(entry.filename);
|
|
8584
8378
|
if (blobData.length !== entry.sizeBytes) {
|
|
8585
8379
|
throw new Error(
|
|
8586
8380
|
`Size of file ${entry.filename} changed after initial scan. Original size was ${entry.sizeBytes} but it is now ${blobData.length}`
|
|
@@ -8640,7 +8434,7 @@ function uploadCommand(program) {
|
|
|
8640
8434
|
}
|
|
8641
8435
|
}
|
|
8642
8436
|
if (validatedOptions.outputCommitments) {
|
|
8643
|
-
await
|
|
8437
|
+
await fs5.writeFile(
|
|
8644
8438
|
validatedOptions.outputCommitments,
|
|
8645
8439
|
JSON.stringify(outputCommitments)
|
|
8646
8440
|
);
|
|
@@ -8690,4 +8484,9 @@ function createProgram() {
|
|
|
8690
8484
|
}
|
|
8691
8485
|
|
|
8692
8486
|
// src/entry.ts
|
|
8693
|
-
|
|
8487
|
+
function main() {
|
|
8488
|
+
const rawArgs = process.argv.slice(2);
|
|
8489
|
+
const normalizedArgs = rawArgs[0] === "--" ? rawArgs.slice(1) : rawArgs;
|
|
8490
|
+
createProgram().parse([process.argv[0], process.argv[1], ...normalizedArgs]);
|
|
8491
|
+
}
|
|
8492
|
+
main();
|