naracli 1.0.83 → 1.0.85

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.
@@ -107,15 +107,15 @@ async function handleQuestGet(options: GlobalOptions & { verbose?: boolean }) {
107
107
  return;
108
108
  }
109
109
 
110
- // Stake only applies when reward slots have reached maxRewardCount
111
- let stakeRequired = quest.effectiveStakeRequirement > 0;
110
+ // Stake is required once reward slots have reached maxRewardCount
111
+ let stakeRequired = true;
112
112
  try {
113
113
  const config = await getQuestConfig(connection);
114
114
  if (quest.rewardCount < config.maxRewardCount) {
115
115
  stakeRequired = false;
116
116
  }
117
117
  } catch {
118
- // If config fetch fails, fall back to showing stake as-is
118
+ // If config fetch fails, default to requiring stake
119
119
  }
120
120
 
121
121
  // Fetch free credits (stake-free answer quota)
package/src/cli/index.ts CHANGED
@@ -13,6 +13,8 @@ import { registerSkillsCommands } from "./commands/skills";
13
13
  import { registerZkIdCommands } from "./commands/zkid";
14
14
  import { registerAgentCommands } from "./commands/agent";
15
15
  import { registerConfigCommands } from "./commands/config";
16
+ import { registerBridgeCommands } from "./commands/bridge";
17
+ import { registerDexCommands } from "./commands/dex";
16
18
  import {
17
19
  handleWalletAddress,
18
20
  handleWalletBalance,
@@ -79,6 +81,12 @@ export function registerCommands(program: Command): void {
79
81
  // agent
80
82
  registerAgentCommands(program);
81
83
 
84
+ // bridge
85
+ registerBridgeCommands(program);
86
+
87
+ // dex
88
+ registerDexCommands(program);
89
+
82
90
  // config
83
91
  registerConfigCommands(program);
84
92
 
@@ -171,13 +179,68 @@ export function registerCommands(program: Command): void {
171
179
 
172
180
  // Top-level: token-balance
173
181
  program
174
- .command("token-balance <token-address>")
175
- .description("Check token balance (supports SPL Token and Token-2022)")
182
+ .command("token-balance [token-address]")
183
+ .description("Check token balance. Without token-address, shows USDC, USDT, SOL balances.")
176
184
  .option("--owner <address>", "Owner address (optional, defaults to current wallet)")
177
- .action(async (tokenAddress: string, options: { owner?: string }) => {
185
+ .action(async (tokenAddress: string | undefined, options: { owner?: string }) => {
178
186
  const opts = program.opts() as TokenBalanceOptions;
179
187
  try {
180
- await handleTokenBalance(tokenAddress, { ...opts, ...options });
188
+ if (tokenAddress) {
189
+ await handleTokenBalance(tokenAddress, { ...opts, ...options });
190
+ } else {
191
+ // Show common token balances
192
+ const { Connection, PublicKey } = await import("@solana/web3.js");
193
+ const { getAssociatedTokenAddress, TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID } = await import("@solana/spl-token");
194
+ const rpcUrl = getRpcUrl(opts.rpcUrl);
195
+ const connection = new Connection(rpcUrl, "confirmed");
196
+
197
+ let owner: PublicKey;
198
+ if (options.owner) {
199
+ owner = new PublicKey(options.owner);
200
+ } else {
201
+ const wallet = await loadWallet(opts.wallet);
202
+ owner = wallet.publicKey;
203
+ }
204
+
205
+ const tokens = [
206
+ { symbol: "USDC", mint: "8P7UGWjq86N3WUmwEgKeGHJZLcoMJqr5jnRUmeBN7YwR", program: TOKEN_2022_PROGRAM_ID, decimals: 6 },
207
+ { symbol: "USDT", mint: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", program: TOKEN_PROGRAM_ID, decimals: 6 },
208
+ { symbol: "SOL", mint: "7fKh7DqPZmsYPHdGvt9Qw2rZkSEGp9F5dBa3XuuuhavU", program: TOKEN_2022_PROGRAM_ID, decimals: 9 },
209
+ ];
210
+
211
+ // Build all ATA addresses
212
+ const atas = await Promise.all(
213
+ tokens.map(t => getAssociatedTokenAddress(new PublicKey(t.mint), owner, true, t.program))
214
+ );
215
+
216
+ // Batch fetch with getMultipleAccountsInfo
217
+ const accounts = await connection.getMultipleAccountsInfo(atas);
218
+
219
+ const results = tokens.map((t, i) => {
220
+ const acc = accounts[i];
221
+ let balance = "0";
222
+ let amount = "0";
223
+ if (acc) {
224
+ try {
225
+ // Parse token account data: amount is at offset 64, 8 bytes LE
226
+ const raw = BigInt("0x" + Buffer.from(acc.data.slice(64, 72)).reverse().toString("hex"));
227
+ amount = raw.toString();
228
+ balance = (Number(raw) / 10 ** t.decimals).toString();
229
+ } catch {}
230
+ }
231
+ return { symbol: t.symbol, mint: t.mint, balance, amount };
232
+ });
233
+
234
+ if (opts.json) {
235
+ console.log(JSON.stringify({ owner: owner.toBase58(), tokens: results }, null, 2));
236
+ } else {
237
+ console.log(`\n Owner: ${owner.toBase58()}\n`);
238
+ for (const r of results) {
239
+ console.log(` ${r.mint} ${r.symbol.padEnd(6)} ${r.balance}`);
240
+ }
241
+ console.log("");
242
+ }
243
+ }
181
244
  } catch (error: any) {
182
245
  printError(error.message);
183
246
  process.exit(1);