@net-protocol/cli 0.1.19 → 0.1.20
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/cli/index.mjs +7 -75
- package/dist/cli/index.mjs.map +1 -1
- package/dist/feed/index.d.ts +1 -6
- package/dist/feed/index.mjs +2 -76
- package/dist/feed/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/feed/index.d.ts
CHANGED
|
@@ -50,14 +50,9 @@ declare function registerFeedConfigCommand(parent: Command): void;
|
|
|
50
50
|
*/
|
|
51
51
|
declare function registerFeedHistoryCommand(parent: Command): void;
|
|
52
52
|
|
|
53
|
-
/**
|
|
54
|
-
* Register the register-agent subcommand
|
|
55
|
-
*/
|
|
56
|
-
declare function registerAgentRegisterCommand(parent: Command): void;
|
|
57
|
-
|
|
58
53
|
/**
|
|
59
54
|
* Register the feed command group with the commander program
|
|
60
55
|
*/
|
|
61
56
|
declare function registerFeedCommand(program: Command): void;
|
|
62
57
|
|
|
63
|
-
export {
|
|
58
|
+
export { registerFeedCommand, registerFeedCommentReadCommand, registerFeedCommentWriteCommand, registerFeedConfigCommand, registerFeedHistoryCommand, registerFeedListCommand, registerFeedPostCommand, registerFeedPostsCommand, registerFeedReadCommand, registerFeedRegisterCommand, registerFeedRepliesCommand };
|
package/dist/feed/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import chalk12 from 'chalk';
|
|
2
|
-
import { FeedRegistryClient, FeedClient
|
|
2
|
+
import { FeedRegistryClient, FeedClient } from '@net-protocol/feeds';
|
|
3
3
|
import { NULL_ADDRESS, getChainRpcUrls, NetClient } from '@net-protocol/core';
|
|
4
4
|
import '@net-protocol/storage';
|
|
5
5
|
import * as fs from 'fs';
|
|
@@ -80,12 +80,6 @@ function createNetClient(options) {
|
|
|
80
80
|
overrides: options.rpcUrl ? { rpcUrls: [options.rpcUrl] } : void 0
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
-
function createAgentRegistryClient(options) {
|
|
84
|
-
return new AgentRegistryClient({
|
|
85
|
-
chainId: options.chainId,
|
|
86
|
-
overrides: options.rpcUrl ? { rpcUrls: [options.rpcUrl] } : void 0
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
83
|
function exitWithError(message) {
|
|
90
84
|
console.error(chalk12.red(`Error: ${message}`));
|
|
91
85
|
process.exit(1);
|
|
@@ -1342,73 +1336,6 @@ function registerFeedHistoryCommand(parent) {
|
|
|
1342
1336
|
await executeFeedHistory(options);
|
|
1343
1337
|
});
|
|
1344
1338
|
}
|
|
1345
|
-
async function executeRegisterAgent(options) {
|
|
1346
|
-
if (options.encodeOnly) {
|
|
1347
|
-
const readOnlyOptions = parseReadOnlyOptionsWithDefault({
|
|
1348
|
-
chainId: options.chainId,
|
|
1349
|
-
rpcUrl: options.rpcUrl
|
|
1350
|
-
});
|
|
1351
|
-
const client2 = createAgentRegistryClient(readOnlyOptions);
|
|
1352
|
-
const txConfig2 = client2.prepareRegisterAgent();
|
|
1353
|
-
const encoded = encodeTransaction(txConfig2, readOnlyOptions.chainId);
|
|
1354
|
-
printJson(encoded);
|
|
1355
|
-
return;
|
|
1356
|
-
}
|
|
1357
|
-
const commonOptions = parseCommonOptionsWithDefault(
|
|
1358
|
-
{
|
|
1359
|
-
privateKey: options.privateKey,
|
|
1360
|
-
chainId: options.chainId,
|
|
1361
|
-
rpcUrl: options.rpcUrl
|
|
1362
|
-
},
|
|
1363
|
-
true
|
|
1364
|
-
// supports --encode-only
|
|
1365
|
-
);
|
|
1366
|
-
const client = createAgentRegistryClient(commonOptions);
|
|
1367
|
-
const walletClient = createWallet(
|
|
1368
|
-
commonOptions.privateKey,
|
|
1369
|
-
commonOptions.chainId,
|
|
1370
|
-
commonOptions.rpcUrl
|
|
1371
|
-
);
|
|
1372
|
-
const isRegistered = await client.isAgentRegistered(walletClient.account.address);
|
|
1373
|
-
if (isRegistered) {
|
|
1374
|
-
exitWithError(`Address ${walletClient.account.address} is already registered as an agent`);
|
|
1375
|
-
}
|
|
1376
|
-
console.log(chalk12.blue(`Registering agent ${walletClient.account.address}...`));
|
|
1377
|
-
const txConfig = client.prepareRegisterAgent();
|
|
1378
|
-
try {
|
|
1379
|
-
const hash = await executeTransaction(walletClient, txConfig);
|
|
1380
|
-
addHistoryEntry({
|
|
1381
|
-
type: "register",
|
|
1382
|
-
txHash: hash,
|
|
1383
|
-
chainId: commonOptions.chainId,
|
|
1384
|
-
feed: "agent-registry",
|
|
1385
|
-
sender: walletClient.account.address
|
|
1386
|
-
});
|
|
1387
|
-
console.log(
|
|
1388
|
-
chalk12.green(
|
|
1389
|
-
`Agent registered successfully!
|
|
1390
|
-
Transaction: ${hash}
|
|
1391
|
-
Address: ${walletClient.account.address}`
|
|
1392
|
-
)
|
|
1393
|
-
);
|
|
1394
|
-
} catch (error) {
|
|
1395
|
-
exitWithError(
|
|
1396
|
-
`Failed to register agent: ${error instanceof Error ? error.message : String(error)}`
|
|
1397
|
-
);
|
|
1398
|
-
}
|
|
1399
|
-
}
|
|
1400
|
-
function registerAgentRegisterCommand(parent) {
|
|
1401
|
-
parent.command("register-agent").description("Register your address on the agent leaderboard").option(
|
|
1402
|
-
"--chain-id <id>",
|
|
1403
|
-
"Chain ID (default: 8453 for Base)",
|
|
1404
|
-
(value) => parseInt(value, 10)
|
|
1405
|
-
).option("--rpc-url <url>", "Custom RPC URL").option("--private-key <key>", "Private key (0x-prefixed)").option(
|
|
1406
|
-
"--encode-only",
|
|
1407
|
-
"Output transaction data as JSON instead of executing"
|
|
1408
|
-
).action(async (options) => {
|
|
1409
|
-
await executeRegisterAgent(options);
|
|
1410
|
-
});
|
|
1411
|
-
}
|
|
1412
1339
|
|
|
1413
1340
|
// src/commands/feed/index.ts
|
|
1414
1341
|
function registerFeedCommand(program) {
|
|
@@ -1423,9 +1350,8 @@ function registerFeedCommand(program) {
|
|
|
1423
1350
|
registerFeedPostsCommand(feedCommand);
|
|
1424
1351
|
registerFeedConfigCommand(feedCommand);
|
|
1425
1352
|
registerFeedHistoryCommand(feedCommand);
|
|
1426
|
-
registerAgentRegisterCommand(feedCommand);
|
|
1427
1353
|
}
|
|
1428
1354
|
|
|
1429
|
-
export {
|
|
1355
|
+
export { registerFeedCommand, registerFeedCommentReadCommand, registerFeedCommentWriteCommand, registerFeedConfigCommand, registerFeedHistoryCommand, registerFeedListCommand, registerFeedPostCommand, registerFeedPostsCommand, registerFeedReadCommand, registerFeedRegisterCommand, registerFeedRepliesCommand };
|
|
1430
1356
|
//# sourceMappingURL=index.mjs.map
|
|
1431
1357
|
//# sourceMappingURL=index.mjs.map
|