naracli 1.0.79 → 1.0.80

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.
@@ -173034,7 +173034,13 @@ async function relaySignAndSend(connection, wallet, relayUrl, endpoint, body) {
173034
173034
  headers: { "Content-Type": "application/json" },
173035
173035
  body: JSON.stringify(body)
173036
173036
  });
173037
- const data = await res.json();
173037
+ const text = await res.text();
173038
+ let data;
173039
+ try {
173040
+ data = JSON.parse(text);
173041
+ } catch {
173042
+ throw new Error(`Relay returned invalid response: ${text.slice(0, 200)}`);
173043
+ }
173038
173044
  if (data.error) throw new Error(data.error);
173039
173045
  const txBuf = Buffer.from(data.transaction, "base64");
173040
173046
  const tx = import_web3103.VersionedTransaction.deserialize(new Uint8Array(txBuf));
@@ -173083,6 +173089,22 @@ async function handleAgentRegister(agentId, options) {
173083
173089
  const result = options.referral ? await registerAgentWithReferral(connection, wallet, agentId, options.referral) : await registerAgent(connection, wallet, agentId);
173084
173090
  signature = result.signature;
173085
173091
  }
173092
+ if (!options.json) printInfo("Confirming transaction...");
173093
+ try {
173094
+ const confirmation = await connection.confirmTransaction(signature, "confirmed");
173095
+ if (confirmation.value.err) {
173096
+ printError(`Transaction failed: ${JSON.stringify(confirmation.value.err)}`);
173097
+ process.exit(1);
173098
+ }
173099
+ } catch {
173100
+ printWarning("Could not confirm transaction. Verifying on-chain...");
173101
+ try {
173102
+ await getAgentInfo(connection, agentId);
173103
+ } catch {
173104
+ printError("Agent registration not found on-chain. Transaction may have failed.");
173105
+ process.exit(1);
173106
+ }
173107
+ }
173086
173108
  if (!options.json) printSuccess(`Agent "${agentId}" registered!`);
173087
173109
  setAgentId(agentId, rpcUrl, pubkey);
173088
173110
  if (options.json) {
@@ -174012,7 +174034,7 @@ function registerCommands(program3) {
174012
174034
  }
174013
174035
 
174014
174036
  // bin/nara-cli.ts
174015
- var version2 = true ? "1.0.79" : "dev";
174037
+ var version2 = true ? "1.0.80" : "dev";
174016
174038
  var program2 = new Command();
174017
174039
  program2.name("naracli").description("CLI for the Nara chain. Native coin is NARA (not SOL). Mine NARA for free via PoMI quests, manage wallets, register agents, and more. Run 'naracli <command> --help' for details on any command.").version(version2);
174018
174040
  program2.option("-r, --rpc-url <url>", "RPC endpoint (default: https://mainnet-api.nara.build/)").option("-w, --wallet <path>", "Path to wallet keypair JSON file (default: ~/.config/nara/id.json)").option("-j, --json", "Output in JSON format");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "naracli",
3
- "version": "1.0.79",
3
+ "version": "1.0.80",
4
4
  "description": "CLI for the Nara chain (Solana-compatible)",
5
5
  "homepage": "https://nara.build",
6
6
  "repository": {
@@ -61,7 +61,13 @@ async function relaySignAndSend(
61
61
  headers: { "Content-Type": "application/json" },
62
62
  body: JSON.stringify(body),
63
63
  });
64
- const data = await res.json() as any;
64
+ const text = await res.text();
65
+ let data: any;
66
+ try {
67
+ data = JSON.parse(text);
68
+ } catch {
69
+ throw new Error(`Relay returned invalid response: ${text.slice(0, 200)}`);
70
+ }
65
71
  if (data.error) throw new Error(data.error);
66
72
 
67
73
  const txBuf = Buffer.from(data.transaction, "base64");
@@ -126,6 +132,24 @@ async function handleAgentRegister(agentId: string, options: GlobalOptions & { r
126
132
  signature = result.signature;
127
133
  }
128
134
 
135
+ // Confirm transaction before saving config
136
+ if (!options.json) printInfo("Confirming transaction...");
137
+ try {
138
+ const confirmation = await connection.confirmTransaction(signature, "confirmed");
139
+ if (confirmation.value.err) {
140
+ printError(`Transaction failed: ${JSON.stringify(confirmation.value.err)}`);
141
+ process.exit(1);
142
+ }
143
+ } catch {
144
+ printWarning("Could not confirm transaction. Verifying on-chain...");
145
+ try {
146
+ await getAgentInfo(connection, agentId);
147
+ } catch {
148
+ printError("Agent registration not found on-chain. Transaction may have failed.");
149
+ process.exit(1);
150
+ }
151
+ }
152
+
129
153
  if (!options.json) printSuccess(`Agent "${agentId}" registered!`);
130
154
  setAgentId(agentId, rpcUrl, pubkey);
131
155