@net-protocol/cli 0.1.18 → 0.1.19
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/README.md +14 -3
- package/dist/cli/index.mjs +75 -1
- package/dist/cli/index.mjs.map +1 -1
- package/dist/feed/index.d.ts +6 -1
- package/dist/feed/index.mjs +76 -2
- package/dist/feed/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -43,7 +43,8 @@ netp storage upload \
|
|
|
43
43
|
--text <description> \
|
|
44
44
|
[--private-key <0x...>] \
|
|
45
45
|
--chain-id <8453|1|...> \
|
|
46
|
-
[--rpc-url <custom-rpc>]
|
|
46
|
+
[--rpc-url <custom-rpc>] \
|
|
47
|
+
[--chunk-size <bytes>]
|
|
47
48
|
```
|
|
48
49
|
|
|
49
50
|
**Storage Upload Arguments:**
|
|
@@ -54,6 +55,7 @@ netp storage upload \
|
|
|
54
55
|
- `--private-key` (optional): Private key (0x-prefixed hex, 66 characters). Can also be set via `NET_PRIVATE_KEY` or `PRIVATE_KEY` environment variable
|
|
55
56
|
- `--chain-id` (optional): Chain ID (8453 for Base, 1 for Ethereum, etc.). Can also be set via `NET_CHAIN_ID` environment variable
|
|
56
57
|
- `--rpc-url` (optional): Custom RPC URL. Can also be set via `NET_RPC_URL` environment variable
|
|
58
|
+
- `--chunk-size` (optional): Size of each XML chunk in bytes (default: 80000). Controls how large files are split for XML storage
|
|
57
59
|
|
|
58
60
|
**Examples:**
|
|
59
61
|
|
|
@@ -80,6 +82,14 @@ netp storage upload \
|
|
|
80
82
|
# NET_CHAIN_ID=8453
|
|
81
83
|
# NET_RPC_URL=https://base-mainnet.public.blastapi.io # optional
|
|
82
84
|
netp storage upload --file ./example.txt --key "my-file" --text "Example file"
|
|
85
|
+
|
|
86
|
+
# Custom chunk size (40KB instead of default 80KB)
|
|
87
|
+
netp storage upload \
|
|
88
|
+
--file ./large-file.bin \
|
|
89
|
+
--key "my-file" \
|
|
90
|
+
--text "Large file" \
|
|
91
|
+
--chunk-size 40000 \
|
|
92
|
+
--chain-id 8453
|
|
83
93
|
```
|
|
84
94
|
|
|
85
95
|
##### Storage Preview
|
|
@@ -93,7 +103,8 @@ netp storage preview \
|
|
|
93
103
|
--text <description> \
|
|
94
104
|
[--private-key <0x...>] \
|
|
95
105
|
--chain-id <8453|1|...> \
|
|
96
|
-
[--rpc-url <custom-rpc>]
|
|
106
|
+
[--rpc-url <custom-rpc>] \
|
|
107
|
+
[--chunk-size <bytes>]
|
|
97
108
|
```
|
|
98
109
|
|
|
99
110
|
**Storage Preview Arguments:**
|
|
@@ -675,7 +686,7 @@ For files up to 20KB, the tool uses normal storage:
|
|
|
675
686
|
|
|
676
687
|
For files larger than 20KB or containing XML references, the tool uses XML storage:
|
|
677
688
|
|
|
678
|
-
- Breaks file into 80KB XML chunks
|
|
689
|
+
- Breaks file into 80KB XML chunks (configurable via `--chunk-size`)
|
|
679
690
|
- Each XML chunk is stored in ChunkedStorage (compressed and chunked into 20KB pieces)
|
|
680
691
|
- XML metadata references all chunks
|
|
681
692
|
- Multiple sequential transactions (metadata first, then chunks)
|
package/dist/cli/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { stringToHex, createWalletClient, http, hexToString, parseEther, encodeF
|
|
|
11
11
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
12
12
|
import { getNetContract, getChainName, getPublicClient, getChainRpcUrls, NetClient, toBytes32, NULL_ADDRESS } from '@net-protocol/core';
|
|
13
13
|
import { createRelayX402Client, createRelaySession, checkBackendWalletBalance, fundBackendWallet, batchTransactions, submitTransactionsViaRelay, waitForConfirmations, retryFailedTransactions as retryFailedTransactions$1 } from '@net-protocol/relay';
|
|
14
|
-
import { FeedRegistryClient, FeedClient } from '@net-protocol/feeds';
|
|
14
|
+
import { FeedRegistryClient, FeedClient, AgentRegistryClient } from '@net-protocol/feeds';
|
|
15
15
|
import { isNetrSupportedChain, NetrClient } from '@net-protocol/netr';
|
|
16
16
|
import { PROFILE_PICTURE_STORAGE_KEY, PROFILE_METADATA_STORAGE_KEY, parseProfileMetadata, PROFILE_CANVAS_STORAGE_KEY, isValidUrl, getProfilePictureStorageArgs, STORAGE_CONTRACT, isValidXUsername, getProfileMetadataStorageArgs, isValidBio, isValidTokenAddress } from '@net-protocol/profiles';
|
|
17
17
|
import { base } from 'viem/chains';
|
|
@@ -1641,6 +1641,12 @@ function createNetClient(options) {
|
|
|
1641
1641
|
overrides: options.rpcUrl ? { rpcUrls: [options.rpcUrl] } : void 0
|
|
1642
1642
|
});
|
|
1643
1643
|
}
|
|
1644
|
+
function createAgentRegistryClient(options) {
|
|
1645
|
+
return new AgentRegistryClient({
|
|
1646
|
+
chainId: options.chainId,
|
|
1647
|
+
overrides: options.rpcUrl ? { rpcUrls: [options.rpcUrl] } : void 0
|
|
1648
|
+
});
|
|
1649
|
+
}
|
|
1644
1650
|
|
|
1645
1651
|
// src/commands/message/send.ts
|
|
1646
1652
|
function prepareMessageConfig(client, options) {
|
|
@@ -6384,6 +6390,73 @@ function registerFeedHistoryCommand(parent) {
|
|
|
6384
6390
|
await executeFeedHistory(options);
|
|
6385
6391
|
});
|
|
6386
6392
|
}
|
|
6393
|
+
async function executeRegisterAgent(options) {
|
|
6394
|
+
if (options.encodeOnly) {
|
|
6395
|
+
const readOnlyOptions = parseReadOnlyOptionsWithDefault({
|
|
6396
|
+
chainId: options.chainId,
|
|
6397
|
+
rpcUrl: options.rpcUrl
|
|
6398
|
+
});
|
|
6399
|
+
const client2 = createAgentRegistryClient(readOnlyOptions);
|
|
6400
|
+
const txConfig2 = client2.prepareRegisterAgent();
|
|
6401
|
+
const encoded = encodeTransaction(txConfig2, readOnlyOptions.chainId);
|
|
6402
|
+
printJson(encoded);
|
|
6403
|
+
return;
|
|
6404
|
+
}
|
|
6405
|
+
const commonOptions = parseCommonOptionsWithDefault(
|
|
6406
|
+
{
|
|
6407
|
+
privateKey: options.privateKey,
|
|
6408
|
+
chainId: options.chainId,
|
|
6409
|
+
rpcUrl: options.rpcUrl
|
|
6410
|
+
},
|
|
6411
|
+
true
|
|
6412
|
+
// supports --encode-only
|
|
6413
|
+
);
|
|
6414
|
+
const client = createAgentRegistryClient(commonOptions);
|
|
6415
|
+
const walletClient = createWallet(
|
|
6416
|
+
commonOptions.privateKey,
|
|
6417
|
+
commonOptions.chainId,
|
|
6418
|
+
commonOptions.rpcUrl
|
|
6419
|
+
);
|
|
6420
|
+
const isRegistered = await client.isAgentRegistered(walletClient.account.address);
|
|
6421
|
+
if (isRegistered) {
|
|
6422
|
+
exitWithError(`Address ${walletClient.account.address} is already registered as an agent`);
|
|
6423
|
+
}
|
|
6424
|
+
console.log(chalk4.blue(`Registering agent ${walletClient.account.address}...`));
|
|
6425
|
+
const txConfig = client.prepareRegisterAgent();
|
|
6426
|
+
try {
|
|
6427
|
+
const hash = await executeTransaction(walletClient, txConfig);
|
|
6428
|
+
addHistoryEntry({
|
|
6429
|
+
type: "register",
|
|
6430
|
+
txHash: hash,
|
|
6431
|
+
chainId: commonOptions.chainId,
|
|
6432
|
+
feed: "agent-registry",
|
|
6433
|
+
sender: walletClient.account.address
|
|
6434
|
+
});
|
|
6435
|
+
console.log(
|
|
6436
|
+
chalk4.green(
|
|
6437
|
+
`Agent registered successfully!
|
|
6438
|
+
Transaction: ${hash}
|
|
6439
|
+
Address: ${walletClient.account.address}`
|
|
6440
|
+
)
|
|
6441
|
+
);
|
|
6442
|
+
} catch (error) {
|
|
6443
|
+
exitWithError(
|
|
6444
|
+
`Failed to register agent: ${error instanceof Error ? error.message : String(error)}`
|
|
6445
|
+
);
|
|
6446
|
+
}
|
|
6447
|
+
}
|
|
6448
|
+
function registerAgentRegisterCommand(parent) {
|
|
6449
|
+
parent.command("register-agent").description("Register your address on the agent leaderboard").option(
|
|
6450
|
+
"--chain-id <id>",
|
|
6451
|
+
"Chain ID (default: 8453 for Base)",
|
|
6452
|
+
(value) => parseInt(value, 10)
|
|
6453
|
+
).option("--rpc-url <url>", "Custom RPC URL").option("--private-key <key>", "Private key (0x-prefixed)").option(
|
|
6454
|
+
"--encode-only",
|
|
6455
|
+
"Output transaction data as JSON instead of executing"
|
|
6456
|
+
).action(async (options) => {
|
|
6457
|
+
await executeRegisterAgent(options);
|
|
6458
|
+
});
|
|
6459
|
+
}
|
|
6387
6460
|
|
|
6388
6461
|
// src/commands/feed/index.ts
|
|
6389
6462
|
function registerFeedCommand(program2) {
|
|
@@ -6398,6 +6471,7 @@ function registerFeedCommand(program2) {
|
|
|
6398
6471
|
registerFeedPostsCommand(feedCommand);
|
|
6399
6472
|
registerFeedConfigCommand(feedCommand);
|
|
6400
6473
|
registerFeedHistoryCommand(feedCommand);
|
|
6474
|
+
registerAgentRegisterCommand(feedCommand);
|
|
6401
6475
|
}
|
|
6402
6476
|
|
|
6403
6477
|
// src/cli/index.ts
|