@net-protocol/cli 0.1.32 → 0.1.34

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.
@@ -7,9 +7,9 @@ import chalk4 from 'chalk';
7
7
  import * as fs6 from 'fs';
8
8
  import { readFileSync, existsSync, mkdirSync, writeFileSync } from 'fs';
9
9
  import { OPTIMAL_CHUNK_SIZE, StorageClient, detectFileTypeFromBase64, base64ToDataUri, shouldSuggestXmlStorage, getStorageKeyBytes, encodeStorageKeyForUrl, chunkDataForStorage, CHUNKED_STORAGE_CONTRACT, STORAGE_CONTRACT as STORAGE_CONTRACT$1 } from '@net-protocol/storage';
10
- import { stringToHex, createWalletClient, http, hexToString, parseEther, encodeFunctionData, publicActions, defineChain, createPublicClient } from 'viem';
10
+ import { stringToHex, createWalletClient, http, hexToString, parseEther, encodeFunctionData, publicActions, concat, defineChain, createPublicClient } from 'viem';
11
11
  import { privateKeyToAccount } from 'viem/accounts';
12
- import { getNetContract, getChainName, getPublicClient, getChainRpcUrls, NetClient, getBaseDataSuffix, toBytes32, NULL_ADDRESS } from '@net-protocol/core';
12
+ import { getNetContract, getChainName, getPublicClient, getChainRpcUrls, getBaseDataSuffix, 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
14
  import { FeedRegistryClient, FeedClient, AgentRegistryClient } from '@net-protocol/feeds';
15
15
  import { isNetrSupportedChain, NetrClient } from '@net-protocol/netr';
@@ -746,8 +746,9 @@ async function uploadFileWithRelay(options) {
746
746
  const userWalletClient = createWalletClient({
747
747
  account: userAccount,
748
748
  chain: publicClient.chain,
749
- transport: http(rpcUrls[0])
749
+ transport: http(rpcUrls[0]),
750
750
  // Use first RPC URL
751
+ dataSuffix: getBaseDataSuffix(options.chainId)
751
752
  });
752
753
  const { fetchWithPayment, httpClient } = createRelayX402Client(
753
754
  userAccount,
@@ -1235,9 +1236,11 @@ function encodeTransaction(config, chainId) {
1235
1236
  functionName: config.functionName,
1236
1237
  args: config.args
1237
1238
  });
1239
+ const suffix = getBaseDataSuffix(chainId);
1240
+ const data = suffix ? concat([calldata, suffix]) : calldata;
1238
1241
  return {
1239
1242
  to: config.to,
1240
- data: calldata,
1243
+ data,
1241
1244
  chainId,
1242
1245
  value: config.value?.toString() ?? "0"
1243
1246
  };
@@ -1689,7 +1692,8 @@ async function executeSend(options) {
1689
1692
  });
1690
1693
  const walletClient = createWalletClient({
1691
1694
  account,
1692
- transport: http(rpcUrls[0])
1695
+ transport: http(rpcUrls[0]),
1696
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
1693
1697
  });
1694
1698
  console.log(chalk4.blue("Sending message..."));
1695
1699
  try {
@@ -2060,20 +2064,20 @@ async function executeEncodeOnly2(options) {
2060
2064
  },
2061
2065
  saltResult.salt
2062
2066
  );
2063
- const calldata = encodeFunctionData({
2064
- abi: txConfig.abi,
2065
- functionName: txConfig.functionName,
2066
- args: txConfig.args
2067
- });
2067
+ const encoded = encodeTransaction(
2068
+ {
2069
+ to: txConfig.address,
2070
+ abi: txConfig.abi,
2071
+ functionName: txConfig.functionName,
2072
+ args: txConfig.args,
2073
+ value: txConfig.value
2074
+ },
2075
+ readOnlyOptions.chainId
2076
+ );
2068
2077
  const result = {
2069
2078
  predictedAddress: saltResult.predictedAddress,
2070
2079
  salt: saltResult.salt,
2071
- transaction: {
2072
- to: txConfig.address,
2073
- data: calldata,
2074
- chainId: readOnlyOptions.chainId,
2075
- value: txConfig.value?.toString() ?? "0"
2076
- },
2080
+ transaction: encoded,
2077
2081
  config: {
2078
2082
  name: options.name,
2079
2083
  symbol: options.symbol,
@@ -2504,7 +2508,8 @@ async function executeProfileSetPicture(options) {
2504
2508
  account,
2505
2509
  chain: base,
2506
2510
  // TODO: Support other chains
2507
- transport: http(rpcUrls[0])
2511
+ transport: http(rpcUrls[0]),
2512
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
2508
2513
  }).extend(publicActions);
2509
2514
  console.log(chalk4.blue(`\u{1F4F7} Setting profile picture...`));
2510
2515
  console.log(chalk4.gray(` URL: ${options.url}`));
@@ -2618,7 +2623,8 @@ async function executeProfileSetUsername(options) {
2618
2623
  account,
2619
2624
  chain: base,
2620
2625
  // TODO: Support other chains
2621
- transport: http(rpcUrls[0])
2626
+ transport: http(rpcUrls[0]),
2627
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
2622
2628
  }).extend(publicActions);
2623
2629
  console.log(chalk4.blue(`Setting X username...`));
2624
2630
  console.log(chalk4.gray(` Username: ${displayUsername}`));
@@ -2719,7 +2725,8 @@ async function executeProfileSetBio(options) {
2719
2725
  account,
2720
2726
  chain: base,
2721
2727
  // TODO: Support other chains
2722
- transport: http(rpcUrls[0])
2728
+ transport: http(rpcUrls[0]),
2729
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
2723
2730
  }).extend(publicActions);
2724
2731
  console.log(chalk4.blue(`Setting profile bio...`));
2725
2732
  console.log(chalk4.gray(` Bio: ${options.bio}`));
@@ -2820,7 +2827,8 @@ async function executeProfileSetDisplayName(options) {
2820
2827
  account,
2821
2828
  chain: base,
2822
2829
  // TODO: Support other chains
2823
- transport: http(rpcUrls[0])
2830
+ transport: http(rpcUrls[0]),
2831
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
2824
2832
  }).extend(publicActions);
2825
2833
  console.log(chalk4.blue(`Setting display name...`));
2826
2834
  console.log(chalk4.gray(` Name: ${options.name}`));
@@ -2922,7 +2930,8 @@ async function executeProfileSetTokenAddress(options) {
2922
2930
  account,
2923
2931
  chain: base,
2924
2932
  // TODO: Support other chains
2925
- transport: http(rpcUrls[0])
2933
+ transport: http(rpcUrls[0]),
2934
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
2926
2935
  }).extend(publicActions);
2927
2936
  console.log(chalk4.blue(`Setting profile token address...`));
2928
2937
  console.log(chalk4.gray(` Token Address: ${normalizedAddress}`));
@@ -3075,7 +3084,8 @@ async function executeProfileSetCanvas(options) {
3075
3084
  account,
3076
3085
  chain: base,
3077
3086
  // TODO: Support other chains
3078
- transport: http(rpcUrls[0])
3087
+ transport: http(rpcUrls[0]),
3088
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
3079
3089
  }).extend(publicActions);
3080
3090
  console.log(chalk4.blue(`Setting profile canvas...`));
3081
3091
  console.log(
@@ -3299,7 +3309,8 @@ ${available}`
3299
3309
  const client = createWalletClient({
3300
3310
  account,
3301
3311
  chain: base,
3302
- transport: http(rpcUrls[0])
3312
+ transport: http(rpcUrls[0]),
3313
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
3303
3314
  }).extend(publicActions);
3304
3315
  console.log(chalk4.blue(`Setting profile CSS...`));
3305
3316
  console.log(
@@ -3844,7 +3855,8 @@ async function executeCreateListing(options) {
3844
3855
  });
3845
3856
  const walletClient = createWalletClient({
3846
3857
  account,
3847
- transport: http(rpcUrls[0])
3858
+ transport: http(rpcUrls[0]),
3859
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
3848
3860
  });
3849
3861
  for (const approval of prepared.approvals) {
3850
3862
  console.log(chalk4.blue("Sending approval transaction..."));
@@ -3982,7 +3994,8 @@ async function executeCreateOffer(options) {
3982
3994
  });
3983
3995
  const walletClient = createWalletClient({
3984
3996
  account,
3985
- transport: http(rpcUrls[0])
3997
+ transport: http(rpcUrls[0]),
3998
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
3986
3999
  });
3987
4000
  for (const approval of prepared.approvals) {
3988
4001
  console.log(chalk4.blue("Sending approval transaction..."));
@@ -4127,7 +4140,8 @@ async function executeSubmitListing(options) {
4127
4140
  });
4128
4141
  const walletClient = createWalletClient({
4129
4142
  account,
4130
- transport: http(rpcUrls[0])
4143
+ transport: http(rpcUrls[0]),
4144
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
4131
4145
  });
4132
4146
  console.log(chalk4.blue("Submitting listing..."));
4133
4147
  const calldata = encodeFunctionData({
@@ -4208,7 +4222,8 @@ async function executeSubmitOffer(options) {
4208
4222
  });
4209
4223
  const walletClient = createWalletClient({
4210
4224
  account,
4211
- transport: http(rpcUrls[0])
4225
+ transport: http(rpcUrls[0]),
4226
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
4212
4227
  });
4213
4228
  console.log(chalk4.blue("Submitting offer..."));
4214
4229
  const calldata = encodeFunctionData({
@@ -4287,7 +4302,8 @@ async function executeBuyListing(options) {
4287
4302
  });
4288
4303
  const walletClient = createWalletClient({
4289
4304
  account,
4290
- transport: http(rpcUrls[0])
4305
+ transport: http(rpcUrls[0]),
4306
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
4291
4307
  });
4292
4308
  for (const approval of prepared.approvals) {
4293
4309
  console.log(chalk4.blue("Sending approval transaction..."));
@@ -4420,7 +4436,8 @@ async function executeAcceptOffer(options) {
4420
4436
  });
4421
4437
  const walletClient = createWalletClient({
4422
4438
  account,
4423
- transport: http(rpcUrls[0])
4439
+ transport: http(rpcUrls[0]),
4440
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
4424
4441
  });
4425
4442
  for (const approval of prepared.approvals) {
4426
4443
  console.log(chalk4.blue("Sending approval transaction..."));
@@ -4701,7 +4718,8 @@ async function executeCreateErc20Listing(options) {
4701
4718
  });
4702
4719
  const walletClient = createWalletClient({
4703
4720
  account,
4704
- transport: http(rpcUrls[0])
4721
+ transport: http(rpcUrls[0]),
4722
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
4705
4723
  });
4706
4724
  for (const approval of prepared.approvals) {
4707
4725
  console.log(chalk4.blue("Sending approval transaction..."));
@@ -4842,7 +4860,8 @@ async function executeCreateErc20Offer(options) {
4842
4860
  });
4843
4861
  const walletClient = createWalletClient({
4844
4862
  account,
4845
- transport: http(rpcUrls[0])
4863
+ transport: http(rpcUrls[0]),
4864
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
4846
4865
  });
4847
4866
  for (const approval of prepared.approvals) {
4848
4867
  console.log(chalk4.blue("Sending approval transaction..."));
@@ -4990,7 +5009,8 @@ async function executeSubmitErc20Listing(options) {
4990
5009
  });
4991
5010
  const walletClient = createWalletClient({
4992
5011
  account,
4993
- transport: http(rpcUrls[0])
5012
+ transport: http(rpcUrls[0]),
5013
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
4994
5014
  });
4995
5015
  console.log(chalk4.blue("Submitting ERC-20 listing..."));
4996
5016
  const calldata = encodeFunctionData({
@@ -5071,7 +5091,8 @@ async function executeSubmitErc20Offer(options) {
5071
5091
  });
5072
5092
  const walletClient = createWalletClient({
5073
5093
  account,
5074
- transport: http(rpcUrls[0])
5094
+ transport: http(rpcUrls[0]),
5095
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
5075
5096
  });
5076
5097
  console.log(chalk4.blue("Submitting ERC-20 offer..."));
5077
5098
  const calldata = encodeFunctionData({
@@ -5150,7 +5171,8 @@ async function executeBuyErc20Listing(options) {
5150
5171
  });
5151
5172
  const walletClient = createWalletClient({
5152
5173
  account,
5153
- transport: http(rpcUrls[0])
5174
+ transport: http(rpcUrls[0]),
5175
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
5154
5176
  });
5155
5177
  for (const approval of prepared.approvals) {
5156
5178
  console.log(chalk4.blue("Sending approval transaction..."));
@@ -5283,7 +5305,8 @@ async function executeAcceptErc20Offer(options) {
5283
5305
  });
5284
5306
  const walletClient = createWalletClient({
5285
5307
  account,
5286
- transport: http(rpcUrls[0])
5308
+ transport: http(rpcUrls[0]),
5309
+ dataSuffix: getBaseDataSuffix(commonOptions.chainId)
5287
5310
  });
5288
5311
  for (const approval of prepared.approvals) {
5289
5312
  console.log(chalk4.blue("Sending approval transaction..."));