@sentio/cli 3.7.0 → 3.7.1-rc.1
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/lib/index.js +39 -11
- package/package.json +1 -1
- package/src/commands/stop-processor.ts +18 -6
- package/src/commands/upload.ts +31 -7
package/lib/index.js
CHANGED
|
@@ -139798,6 +139798,18 @@ async function finishUpload(options, auth, sha2565, commitSha, gitUrl, continueF
|
|
|
139798
139798
|
}
|
|
139799
139799
|
|
|
139800
139800
|
// src/commands/upload.ts
|
|
139801
|
+
var PROCESSOR_ID_RE = /^[a-zA-Z0-9_-]+$/;
|
|
139802
|
+
function validateProcessorId(id2) {
|
|
139803
|
+
if (id2.length === 0) {
|
|
139804
|
+
throw new Error("Processor ID must not be empty.");
|
|
139805
|
+
}
|
|
139806
|
+
if (id2.length >= 32) {
|
|
139807
|
+
throw new Error(`Processor ID "${id2}" is too long (${id2.length} chars). Maximum length is 31 characters.`);
|
|
139808
|
+
}
|
|
139809
|
+
if (!PROCESSOR_ID_RE.test(id2)) {
|
|
139810
|
+
throw new Error(`Processor ID "${id2}" contains invalid characters. Only alphanumeric, "-", and "_" are allowed.`);
|
|
139811
|
+
}
|
|
139812
|
+
}
|
|
139801
139813
|
function myParseInt(value, dummyPrevious) {
|
|
139802
139814
|
const parsedValue = parseInt(value, 10);
|
|
139803
139815
|
if (isNaN(parsedValue)) {
|
|
@@ -139924,6 +139936,7 @@ The owner must call Permissions.addOperator(${walletAddress}) first.`
|
|
|
139924
139936
|
process.exit(1);
|
|
139925
139937
|
}
|
|
139926
139938
|
let processorId = processorConfig.project.replace("/", "_");
|
|
139939
|
+
validateProcessorId(processorId);
|
|
139927
139940
|
const sdkVersion = getSdkVersion() || "unknown";
|
|
139928
139941
|
console.log(source_default.blue("Checking if processor already exists on-chain..."));
|
|
139929
139942
|
const existingProcessor = await getProcessorOnChain(networkConfig, addresses, processorId);
|
|
@@ -139949,13 +139962,22 @@ The owner must call Permissions.addOperator(${walletAddress}) first.`
|
|
|
139949
139962
|
);
|
|
139950
139963
|
const randomSuffix = Math.random().toString(36).substring(2, 8);
|
|
139951
139964
|
const defaultNewId = `${processorId}-${randomSuffix}`;
|
|
139952
|
-
|
|
139953
|
-
|
|
139954
|
-
|
|
139955
|
-
|
|
139956
|
-
resolve
|
|
139957
|
-
|
|
139958
|
-
|
|
139965
|
+
let newId;
|
|
139966
|
+
for (; ; ) {
|
|
139967
|
+
const rl = readline3.createInterface({ input: process.stdin, output: process.stdout });
|
|
139968
|
+
newId = await new Promise(
|
|
139969
|
+
(resolve) => rl.question(`Enter a new processor ID [${defaultNewId}]: `, (answer) => {
|
|
139970
|
+
rl.close();
|
|
139971
|
+
resolve(answer.trim() || defaultNewId);
|
|
139972
|
+
})
|
|
139973
|
+
);
|
|
139974
|
+
try {
|
|
139975
|
+
validateProcessorId(newId);
|
|
139976
|
+
break;
|
|
139977
|
+
} catch (e10) {
|
|
139978
|
+
console.log(source_default.red(e10.message));
|
|
139979
|
+
}
|
|
139980
|
+
}
|
|
139959
139981
|
processorId = newId;
|
|
139960
139982
|
console.log(source_default.blue(`Using processor ID: ${processorId}`));
|
|
139961
139983
|
}
|
|
@@ -145453,7 +145475,7 @@ function formatTimestamp3(value) {
|
|
|
145453
145475
|
// src/commands/stop-processor.ts
|
|
145454
145476
|
init_cjs_shim();
|
|
145455
145477
|
function createStopProcessorCommand() {
|
|
145456
|
-
return new Command("stop").description("Stop a processor. Uses Sentio Network contract when --sentio-network is specified.").argument("<processorId>", "ID of the processor to stop").option("--sentio-network <network>", 'Stop via Sentio Network contract (only "testnet" supported)').option("--host <host>", "Override Sentio host").option("--api-key <key>", "Use an explicit API key instead of saved credentials").option("--token <token>", "Use an explicit bearer token instead of saved credentials").option("--project <owner/slug>", "Sentio project in <owner>/<slug> format").option("--owner <owner>", "Sentio project owner").option("--name <name>", "Sentio project name").option("-y, --yes", "Bypass confirmation").showHelpAfterError().action(async (processorId, options) => {
|
|
145478
|
+
return new Command("stop").description("Stop a processor. Uses Sentio Network contract when --sentio-network is specified.").argument("<processorId>", "ID of the processor to stop").option("--sentio-network <network>", 'Stop via Sentio Network contract (only "testnet" supported)').option("--host <host>", "Override Sentio host").option("--api-key <key>", "Use an explicit API key instead of saved credentials").option("--token <token>", "Use an explicit bearer token instead of saved credentials").option("--project <owner/slug>", "Sentio project in <owner>/<slug> format").option("--owner <owner>", "Sentio project owner").option("--name <name>", "Sentio project name").option("-y, --yes", "Bypass confirmation").option("--no-delete", "Skip deleting the processor after stopping").showHelpAfterError().action(async (processorId, options) => {
|
|
145457
145479
|
try {
|
|
145458
145480
|
if (options.sentioNetwork) {
|
|
145459
145481
|
await runStopProcessorOnChain(processorId, options);
|
|
@@ -145473,16 +145495,22 @@ async function runStopProcessorOnChain(processorId, options) {
|
|
|
145473
145495
|
console.log(source_default.blue(`Wallet address: ${wallet.address}`));
|
|
145474
145496
|
console.log(source_default.blue("Resolving contract addresses from AddressBook..."));
|
|
145475
145497
|
const addresses = await resolveNetworkAddresses(networkConfig);
|
|
145498
|
+
const willDelete = options.delete !== false;
|
|
145476
145499
|
if (!options.yes) {
|
|
145477
|
-
const
|
|
145500
|
+
const action = willDelete ? "Stop and delete" : "Stop";
|
|
145501
|
+
const confirmed = await confirm(`${action} processor "${processorId}" on Sentio Network ${network}?`);
|
|
145478
145502
|
if (!confirmed) {
|
|
145479
|
-
console.log("
|
|
145503
|
+
console.log("Cancelled.");
|
|
145480
145504
|
return;
|
|
145481
145505
|
}
|
|
145482
145506
|
}
|
|
145483
145507
|
await stopProcessorOnChain(networkConfig, addresses, wallet, processorId);
|
|
145484
|
-
console.log();
|
|
145485
145508
|
console.log(source_default.green(`Processor "${processorId}" stopped on Sentio Network ${network}.`));
|
|
145509
|
+
if (willDelete) {
|
|
145510
|
+
console.log();
|
|
145511
|
+
await deleteProcessorOnChain(networkConfig, addresses, wallet, processorId);
|
|
145512
|
+
console.log(source_default.green(`Processor "${processorId}" deleted on Sentio Network ${network}.`));
|
|
145513
|
+
}
|
|
145486
145514
|
}
|
|
145487
145515
|
|
|
145488
145516
|
// src/index.ts
|
package/package.json
CHANGED
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
resolveNetworkAddresses,
|
|
9
9
|
getWalletFromPrivateKey,
|
|
10
10
|
requirePrivateKey,
|
|
11
|
-
stopProcessorOnChain
|
|
11
|
+
stopProcessorOnChain,
|
|
12
|
+
deleteProcessorOnChain
|
|
12
13
|
} from '../network.js'
|
|
13
14
|
|
|
14
15
|
export function createStopProcessorCommand() {
|
|
@@ -23,6 +24,7 @@ export function createStopProcessorCommand() {
|
|
|
23
24
|
.option('--owner <owner>', 'Sentio project owner')
|
|
24
25
|
.option('--name <name>', 'Sentio project name')
|
|
25
26
|
.option('-y, --yes', 'Bypass confirmation')
|
|
27
|
+
.option('--no-delete', 'Skip deleting the processor after stopping')
|
|
26
28
|
.showHelpAfterError()
|
|
27
29
|
.action(async (processorId, options) => {
|
|
28
30
|
try {
|
|
@@ -37,7 +39,10 @@ export function createStopProcessorCommand() {
|
|
|
37
39
|
})
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
async function runStopProcessorOnChain(
|
|
42
|
+
async function runStopProcessorOnChain(
|
|
43
|
+
processorId: string,
|
|
44
|
+
options: { sentioNetwork?: string; yes?: boolean; delete?: boolean }
|
|
45
|
+
) {
|
|
41
46
|
const network = options.sentioNetwork!
|
|
42
47
|
const networkConfig = getSentioNetworkConfig(network)
|
|
43
48
|
|
|
@@ -48,16 +53,23 @@ async function runStopProcessorOnChain(processorId: string, options: { sentioNet
|
|
|
48
53
|
console.log(chalk.blue('Resolving contract addresses from AddressBook...'))
|
|
49
54
|
const addresses = await resolveNetworkAddresses(networkConfig)
|
|
50
55
|
|
|
56
|
+
const willDelete = options.delete !== false
|
|
57
|
+
|
|
51
58
|
if (!options.yes) {
|
|
52
|
-
const
|
|
59
|
+
const action = willDelete ? 'Stop and delete' : 'Stop'
|
|
60
|
+
const confirmed = await confirm(`${action} processor "${processorId}" on Sentio Network ${network}?`)
|
|
53
61
|
if (!confirmed) {
|
|
54
|
-
console.log('
|
|
62
|
+
console.log('Cancelled.')
|
|
55
63
|
return
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
await stopProcessorOnChain(networkConfig, addresses, wallet, processorId)
|
|
60
|
-
|
|
61
|
-
console.log()
|
|
62
68
|
console.log(chalk.green(`Processor "${processorId}" stopped on Sentio Network ${network}.`))
|
|
69
|
+
|
|
70
|
+
if (willDelete) {
|
|
71
|
+
console.log()
|
|
72
|
+
await deleteProcessorOnChain(networkConfig, addresses, wallet, processorId)
|
|
73
|
+
console.log(chalk.green(`Processor "${processorId}" deleted on Sentio Network ${network}.`))
|
|
74
|
+
}
|
|
63
75
|
}
|
package/src/commands/upload.ts
CHANGED
|
@@ -33,6 +33,20 @@ import { ethers } from 'ethers'
|
|
|
33
33
|
import { Auth, DefaultBatchUploader, FileType, IPFSBatchUploader, WalrusBatchUploader } from '../uploader.js'
|
|
34
34
|
export { type Auth } from '../uploader.js'
|
|
35
35
|
|
|
36
|
+
const PROCESSOR_ID_RE = /^[a-zA-Z0-9_-]+$/
|
|
37
|
+
|
|
38
|
+
function validateProcessorId(id: string): void {
|
|
39
|
+
if (id.length === 0) {
|
|
40
|
+
throw new Error('Processor ID must not be empty.')
|
|
41
|
+
}
|
|
42
|
+
if (id.length >= 32) {
|
|
43
|
+
throw new Error(`Processor ID "${id}" is too long (${id.length} chars). Maximum length is 31 characters.`)
|
|
44
|
+
}
|
|
45
|
+
if (!PROCESSOR_ID_RE.test(id)) {
|
|
46
|
+
throw new Error(`Processor ID "${id}" contains invalid characters. Only alphanumeric, "-", and "_" are allowed.`)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
36
50
|
function myParseInt(value: string, dummyPrevious: number): number {
|
|
37
51
|
// parseInt takes a string and a radix
|
|
38
52
|
const parsedValue = parseInt(value, 10)
|
|
@@ -208,6 +222,7 @@ async function runNoPlatformUpload(
|
|
|
208
222
|
|
|
209
223
|
// Step 7: Derive processor ID from project name
|
|
210
224
|
let processorId = processorConfig.project.replace('/', '_')
|
|
225
|
+
validateProcessorId(processorId)
|
|
211
226
|
const sdkVersion = getSdkVersion() || 'unknown'
|
|
212
227
|
|
|
213
228
|
// Step 7.5: Check if processor already exists on-chain
|
|
@@ -242,13 +257,22 @@ async function runNoPlatformUpload(
|
|
|
242
257
|
const randomSuffix = Math.random().toString(36).substring(2, 8)
|
|
243
258
|
const defaultNewId = `${processorId}-${randomSuffix}`
|
|
244
259
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
rl.
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
260
|
+
let newId: string
|
|
261
|
+
for (;;) {
|
|
262
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
|
|
263
|
+
newId = await new Promise((resolve) =>
|
|
264
|
+
rl.question(`Enter a new processor ID [${defaultNewId}]: `, (answer) => {
|
|
265
|
+
rl.close()
|
|
266
|
+
resolve(answer.trim() || defaultNewId)
|
|
267
|
+
})
|
|
268
|
+
)
|
|
269
|
+
try {
|
|
270
|
+
validateProcessorId(newId)
|
|
271
|
+
break
|
|
272
|
+
} catch (e: any) {
|
|
273
|
+
console.log(chalk.red(e.message))
|
|
274
|
+
}
|
|
275
|
+
}
|
|
252
276
|
processorId = newId
|
|
253
277
|
console.log(chalk.blue(`Using processor ID: ${processorId}`))
|
|
254
278
|
}
|