@yamo/cli 1.3.2 → 1.3.4
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/dist/index.js +17 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -97,7 +97,7 @@ program
|
|
|
97
97
|
.description("Submit a YAMO block to the blockchain")
|
|
98
98
|
.argument("<file>", "Path to the YAMO file")
|
|
99
99
|
.requiredOption("--id <blockId>", "Unique Block ID")
|
|
100
|
-
.option("--prev <previousBlock>", "Previous Block Hash
|
|
100
|
+
.option("--prev <previousBlock>", "Previous Block Hash (omits to auto-fetch from chain)")
|
|
101
101
|
.option("--consensus <type>", "Consensus Type", "cli_manual")
|
|
102
102
|
.option("--ledger <name>", "Ledger Name", "yamo_cli")
|
|
103
103
|
.option("--ipfs", "Upload content to IPFS before submitting")
|
|
@@ -161,7 +161,22 @@ program
|
|
|
161
161
|
ipfsCID = await ipfsManager.upload({ content, files, encryptionKey });
|
|
162
162
|
console.log(chalk_1.default.cyan(`IPFS Bundle CID: ${ipfsCID}`));
|
|
163
163
|
}
|
|
164
|
-
|
|
164
|
+
// Auto-fetch previousBlock if not provided (chain continuation)
|
|
165
|
+
let resolvedPreviousBlock = options.prev;
|
|
166
|
+
if (!resolvedPreviousBlock) {
|
|
167
|
+
console.log(chalk_1.default.blue(`[INFO] No previousBlock provided, fetching latest block from chain...`));
|
|
168
|
+
const latestBlock = await chainClient.getLatestBlock();
|
|
169
|
+
if (latestBlock) {
|
|
170
|
+
resolvedPreviousBlock = latestBlock.contentHash;
|
|
171
|
+
console.log(chalk_1.default.green(`[INFO] Using latest block's contentHash: ${resolvedPreviousBlock}`));
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
// No blocks exist yet, use genesis
|
|
175
|
+
resolvedPreviousBlock = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
176
|
+
console.log(chalk_1.default.yellow(`[INFO] No existing blocks found, using genesis`));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
await chainClient.submitBlock(options.id, resolvedPreviousBlock, contentHash, options.consensus, options.ledger, ipfsCID);
|
|
165
180
|
}
|
|
166
181
|
catch (error) {
|
|
167
182
|
console.error(chalk_1.default.red(`Error: ${error.message}`));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yamo/cli",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "YAMO Protocol v0.4 - Command-line tools for blockchain integration",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"typescript": "^5.9.3"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@yamo/core": "^1.
|
|
46
|
+
"@yamo/core": "^1.2.7",
|
|
47
47
|
"axios": "^1.13.2",
|
|
48
48
|
"chalk": "^4.1.2",
|
|
49
49
|
"commander": "^12.0.0",
|