@shelby-protocol/cli 0.0.17 → 0.0.18
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 +41 -22
- package/package.json +2 -2
package/bin/entry.js
CHANGED
|
@@ -508,7 +508,7 @@ import { Command } from "@commander-js/extra-typings";
|
|
|
508
508
|
|
|
509
509
|
// package.json
|
|
510
510
|
var name = "@shelby-protocol/cli";
|
|
511
|
-
var version = "0.0.
|
|
511
|
+
var version = "0.0.18";
|
|
512
512
|
|
|
513
513
|
// src/commands/account.tsx
|
|
514
514
|
import readline from "readline";
|
|
@@ -564,7 +564,7 @@ var SHELBY_DEPLOYER = "0xc63d6a5efb0080a6029403131715bd4971e1149f7cc099aac69bb00
|
|
|
564
564
|
var SHELBYUSD_TOKEN_NAME = "ShelbyUSD";
|
|
565
565
|
var SHELBYUSD_FA_METADATA_ADDRESS = "0x1b18363a9f1fe5e6ebf247daba5cc1c18052bb232efdc4c50f556053922d98e1";
|
|
566
566
|
|
|
567
|
-
// ../../packages/sdk/dist/chunk-
|
|
567
|
+
// ../../packages/sdk/dist/chunk-LHVCCJIB.mjs
|
|
568
568
|
import {
|
|
569
569
|
AccountAddress,
|
|
570
570
|
Aptos,
|
|
@@ -4514,7 +4514,7 @@ var ERASURE_CODE_AND_CHUNK_MAPPING = {
|
|
|
4514
4514
|
}
|
|
4515
4515
|
};
|
|
4516
4516
|
|
|
4517
|
-
// ../../packages/sdk/dist/chunk-
|
|
4517
|
+
// ../../packages/sdk/dist/chunk-LZSIZJYR.mjs
|
|
4518
4518
|
var ERASURE_CODE_PARAMS = {
|
|
4519
4519
|
[
|
|
4520
4520
|
"ClayCode_16Total_10Data_13Helper"
|
|
@@ -4542,14 +4542,14 @@ var DEFAULT_ERASURE_D = ERASURE_CODE_PARAMS[
|
|
|
4542
4542
|
].erasure_d;
|
|
4543
4543
|
var DEFAULT_ERASURE_M = DEFAULT_ERASURE_N - DEFAULT_ERASURE_K;
|
|
4544
4544
|
|
|
4545
|
-
// ../../packages/sdk/dist/chunk-
|
|
4545
|
+
// ../../packages/sdk/dist/chunk-W5NRGZEP.mjs
|
|
4546
4546
|
import { AccountAddress as AccountAddress2 } from "@aptos-labs/ts-sdk";
|
|
4547
4547
|
import { z } from "zod";
|
|
4548
4548
|
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("/"), {
|
|
4549
4549
|
message: "Blob name cannot end with a slash"
|
|
4550
4550
|
});
|
|
4551
4551
|
|
|
4552
|
-
// ../../packages/sdk/dist/chunk-
|
|
4552
|
+
// ../../packages/sdk/dist/chunk-4EPQP4DM.mjs
|
|
4553
4553
|
import { AccountAddress as AccountAddress3 } from "@aptos-labs/ts-sdk";
|
|
4554
4554
|
function encodeURIComponentKeepSlashes(str) {
|
|
4555
4555
|
return encodeURIComponent(str).replace(/%2F/g, "/");
|
|
@@ -4605,7 +4605,7 @@ var ShelbyRPCClient = class {
|
|
|
4605
4605
|
}
|
|
4606
4606
|
throw new Error(`Failed to upload part ${partIdx}.`);
|
|
4607
4607
|
}
|
|
4608
|
-
async #putBlobMultipart(account, blobName, blobData, partSize = 5 * 1024 * 1024) {
|
|
4608
|
+
async #putBlobMultipart(account, blobName, blobData, partSize = 5 * 1024 * 1024, onProgress) {
|
|
4609
4609
|
const startResponse = await fetch(
|
|
4610
4610
|
buildRequestUrl("/v1/multipart-uploads", this.baseUrl),
|
|
4611
4611
|
{
|
|
@@ -4638,6 +4638,13 @@ var ShelbyRPCClient = class {
|
|
|
4638
4638
|
const end = Math.min(start + partSize, blobData.length);
|
|
4639
4639
|
const partData = blobData.slice(start, end);
|
|
4640
4640
|
await this.#uploadPart(uploadId, partIdx, partData);
|
|
4641
|
+
onProgress?.({
|
|
4642
|
+
partIdx,
|
|
4643
|
+
totalParts,
|
|
4644
|
+
partBytes: partData.length,
|
|
4645
|
+
uploadedBytes: end,
|
|
4646
|
+
totalBytes: blobData.length
|
|
4647
|
+
});
|
|
4641
4648
|
}
|
|
4642
4649
|
const completeResponse = await fetch(
|
|
4643
4650
|
buildRequestUrl(
|
|
@@ -4688,7 +4695,9 @@ var ShelbyRPCClient = class {
|
|
|
4688
4695
|
await this.#putBlobMultipart(
|
|
4689
4696
|
params.account,
|
|
4690
4697
|
params.blobName,
|
|
4691
|
-
params.blobData
|
|
4698
|
+
params.blobData,
|
|
4699
|
+
void 0,
|
|
4700
|
+
params.onProgress
|
|
4692
4701
|
);
|
|
4693
4702
|
}
|
|
4694
4703
|
// FIXME make this possible to stream in put ^^^
|
|
@@ -4819,7 +4828,7 @@ var createBlobKey = (params) => {
|
|
|
4819
4828
|
return `@${AccountAddress4.from(params.account).toStringLongWithoutPrefix()}/${params.blobName}`;
|
|
4820
4829
|
};
|
|
4821
4830
|
|
|
4822
|
-
// ../../packages/sdk/dist/chunk-
|
|
4831
|
+
// ../../packages/sdk/dist/chunk-ONW6NSKZ.mjs
|
|
4823
4832
|
import { Hex as Hex3 } from "@aptos-labs/ts-sdk";
|
|
4824
4833
|
import { z as z2 } from "zod";
|
|
4825
4834
|
var ChunksetCommitmentSchema = z2.object({
|
|
@@ -4966,7 +4975,7 @@ function validatePrePaddedChunkset(chunkset, expectedSize, chunksetIdx) {
|
|
|
4966
4975
|
return chunkset;
|
|
4967
4976
|
}
|
|
4968
4977
|
|
|
4969
|
-
// ../../packages/sdk/dist/chunk-
|
|
4978
|
+
// ../../packages/sdk/dist/chunk-X345MKRA.mjs
|
|
4970
4979
|
import {
|
|
4971
4980
|
AccountAddress as AccountAddress5,
|
|
4972
4981
|
Aptos as Aptos2,
|
|
@@ -5485,7 +5494,7 @@ var ShelbyBlobClient = class _ShelbyBlobClient {
|
|
|
5485
5494
|
}
|
|
5486
5495
|
};
|
|
5487
5496
|
|
|
5488
|
-
// ../../packages/sdk/dist/chunk-
|
|
5497
|
+
// ../../packages/sdk/dist/chunk-UCDAABAS.mjs
|
|
5489
5498
|
import {
|
|
5490
5499
|
createDecoder,
|
|
5491
5500
|
createEncoder
|
|
@@ -5622,7 +5631,7 @@ function buildClayConfig(input) {
|
|
|
5622
5631
|
};
|
|
5623
5632
|
}
|
|
5624
5633
|
|
|
5625
|
-
// ../../packages/sdk/dist/chunk-
|
|
5634
|
+
// ../../packages/sdk/dist/chunk-GVROD2TF.mjs
|
|
5626
5635
|
import {
|
|
5627
5636
|
AccountAddress as AccountAddress6,
|
|
5628
5637
|
Aptos as Aptos3,
|
|
@@ -5767,7 +5776,7 @@ function validateConcurrency(concurrency) {
|
|
|
5767
5776
|
}
|
|
5768
5777
|
}
|
|
5769
5778
|
|
|
5770
|
-
// ../../packages/sdk/dist/chunk-
|
|
5779
|
+
// ../../packages/sdk/dist/chunk-GVROD2TF.mjs
|
|
5771
5780
|
var ShelbyClient = class {
|
|
5772
5781
|
/**
|
|
5773
5782
|
* The coordination client is used to interact with the Aptos blockchain which handles the commitments
|
|
@@ -5885,7 +5894,8 @@ var ShelbyClient = class {
|
|
|
5885
5894
|
blobName: params.blobName,
|
|
5886
5895
|
blobMerkleRoot: blobCommitments.blob_merkle_root,
|
|
5887
5896
|
size: params.blobData.length,
|
|
5888
|
-
expirationMicros: params.expirationMicros
|
|
5897
|
+
expirationMicros: params.expirationMicros,
|
|
5898
|
+
options: params.options
|
|
5889
5899
|
});
|
|
5890
5900
|
await this.coordination.aptos.waitForTransaction({
|
|
5891
5901
|
transactionHash: pendingRegisterBlobTransaction.hash
|
|
@@ -6075,7 +6085,7 @@ var ShelbyClient = class {
|
|
|
6075
6085
|
}
|
|
6076
6086
|
};
|
|
6077
6087
|
|
|
6078
|
-
// ../../packages/sdk/dist/chunk-
|
|
6088
|
+
// ../../packages/sdk/dist/chunk-NRDGHGOH.mjs
|
|
6079
6089
|
var ShelbyNodeClient = class extends ShelbyClient {
|
|
6080
6090
|
};
|
|
6081
6091
|
|
|
@@ -10183,12 +10193,16 @@ function uploadCommand(program) {
|
|
|
10183
10193
|
totalSize += entry.sizeBytes;
|
|
10184
10194
|
}
|
|
10185
10195
|
const isSingleFile = filelist.length === 1;
|
|
10186
|
-
const
|
|
10196
|
+
const formatOverallProgressPercent = (currentFileUploadedBytes = 0) => totalSize > 0 ? (100 * ((amountUploaded + currentFileUploadedBytes) / totalSize)).toFixed(2) : "0.00";
|
|
10187
10197
|
let filesProcessed = 0;
|
|
10188
10198
|
for (const entry of filelist) {
|
|
10189
10199
|
const fileName = path7.basename(entry.filename);
|
|
10190
|
-
|
|
10191
|
-
|
|
10200
|
+
let currentFileUploadedBytes = 0;
|
|
10201
|
+
const formatOverallProgress = () => isSingleFile ? `(${formatOverallProgressPercent(currentFileUploadedBytes)}%)` : `(${filesProcessed}/${filelist.length} files, ${formatOverallProgressPercent(
|
|
10202
|
+
currentFileUploadedBytes
|
|
10203
|
+
)}%)`;
|
|
10204
|
+
const overallProgress = formatOverallProgress();
|
|
10205
|
+
spinner.text = `\u{1F4D6} Reading ${fileName}... ${overallProgress}`;
|
|
10192
10206
|
try {
|
|
10193
10207
|
const blobData = await fs8.readFile(entry.filename);
|
|
10194
10208
|
if (blobData.length !== entry.sizeBytes) {
|
|
@@ -10196,7 +10210,7 @@ function uploadCommand(program) {
|
|
|
10196
10210
|
`Size of file ${entry.filename} changed after initial scan. Original size was ${entry.sizeBytes} but it is now ${blobData.length}`
|
|
10197
10211
|
);
|
|
10198
10212
|
}
|
|
10199
|
-
spinner.text = `\u{1F517} Checking if blob exists... ${
|
|
10213
|
+
spinner.text = `\u{1F517} Checking if blob exists... ${overallProgress}`;
|
|
10200
10214
|
const existingBlobMetadata = await shelbyClient.coordination.getBlobMetadata({
|
|
10201
10215
|
account: activeAccount.accountAddress,
|
|
10202
10216
|
name: entry.blobname
|
|
@@ -10207,13 +10221,13 @@ function uploadCommand(program) {
|
|
|
10207
10221
|
);
|
|
10208
10222
|
process.exit(1);
|
|
10209
10223
|
}
|
|
10210
|
-
spinner.text = `\u{1F517} Generating commitments for ${fileName}... ${
|
|
10224
|
+
spinner.text = `\u{1F517} Generating commitments for ${fileName}... ${overallProgress}`;
|
|
10211
10225
|
const provider = await getErasureCodingProvider();
|
|
10212
10226
|
const blobCommitments = await generateCommitments(provider, blobData);
|
|
10213
10227
|
if (options.outputCommitments) {
|
|
10214
10228
|
outputCommitments[entry.filename] = blobCommitments;
|
|
10215
10229
|
}
|
|
10216
|
-
spinner.text = `\u{1F517} Registering ${fileName} on L1... ${
|
|
10230
|
+
spinner.text = `\u{1F517} Registering ${fileName} on L1... ${overallProgress}`;
|
|
10217
10231
|
const { transaction: pendingRegisterBlobTransaction } = await shelbyClient.coordination.registerBlob({
|
|
10218
10232
|
account: activeAccount,
|
|
10219
10233
|
blobName: entry.blobname,
|
|
@@ -10228,11 +10242,16 @@ function uploadCommand(program) {
|
|
|
10228
10242
|
await aptos.waitForTransaction({
|
|
10229
10243
|
transactionHash: pendingRegisterBlobTransaction.hash
|
|
10230
10244
|
});
|
|
10231
|
-
spinner.text = `\u{1F4E4} Uploading ${fileName} to Shelby RPC... ${
|
|
10245
|
+
spinner.text = `\u{1F4E4} Uploading ${fileName} to Shelby RPC... ${overallProgress}`;
|
|
10232
10246
|
await shelbyClient.rpc.putBlob({
|
|
10233
10247
|
account: activeAccount.accountAddress,
|
|
10234
10248
|
blobName: entry.blobname,
|
|
10235
|
-
blobData
|
|
10249
|
+
blobData,
|
|
10250
|
+
onProgress: ({ uploadedBytes, totalBytes }) => {
|
|
10251
|
+
currentFileUploadedBytes = uploadedBytes;
|
|
10252
|
+
const pct = totalBytes > 0 ? (100 * uploadedBytes / totalBytes).toFixed(2) : "0.00";
|
|
10253
|
+
spinner.text = isSingleFile ? `\u{1F4E4} Uploading ${fileName} to Shelby RPC... ${pct}%` : `\u{1F4E4} Uploading ${fileName} to Shelby RPC... ${pct}% ${formatOverallProgress()}`;
|
|
10254
|
+
}
|
|
10236
10255
|
});
|
|
10237
10256
|
amountUploaded += blobData.length;
|
|
10238
10257
|
filesProcessed++;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shelby-protocol/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.18",
|
|
5
5
|
"private": false,
|
|
6
6
|
"bin": {
|
|
7
7
|
"shelby": "bin/entry.js"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"yaml": "2.8.1",
|
|
45
45
|
"zod": "^3.22.4",
|
|
46
46
|
"@shelby-protocol/clay-codes": "0.0.2",
|
|
47
|
-
"@shelby-protocol/sdk": "0.0.
|
|
47
|
+
"@shelby-protocol/sdk": "0.0.9"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/dockerode": "^3.3.45",
|