xflows 1.2.0 → 1.3.0

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.
Files changed (3) hide show
  1. package/README.md +11 -2
  2. package/dist/index.js +44 -9
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -327,6 +327,9 @@ xflows wallet balance --name alice --chain-id 56
327
327
  # Check WAN balance on Wanchain
328
328
  xflows wallet balance --name alice --chain-id 888
329
329
 
330
+ # Check any address (no wallet needed)
331
+ xflows wallet balance --address 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --chain-id 1
332
+
330
333
  # Encrypted wallet
331
334
  xflows wallet balance --name alice --chain-id 1 --password mypassword
332
335
 
@@ -336,7 +339,8 @@ xflows wallet balance --name alice --chain-id 1 --rpc https://my-rpc.example.com
336
339
 
337
340
  | Flag | Required | Description |
338
341
  |------|----------|-------------|
339
- | `--name <name>` | Yes | Wallet name |
342
+ | `--name <name>` | One of `--name` or `--address` | Wallet name |
343
+ | `--address <addr>` | One of `--name` or `--address` | Query any address (no wallet needed) |
340
344
  | `--chain-id <id>` | Yes | Chain ID to query balance on |
341
345
  | `--password <pw>` | No | Password for encrypted wallets |
342
346
  | `--rpc <url>` | No | Override default RPC endpoint |
@@ -352,6 +356,10 @@ xflows wallet token-balance --name alice --chain-id 1 \
352
356
  xflows wallet token-balance --name alice --chain-id 56 \
353
357
  --token 0x55d398326f99059fF775485246999027B3197955
354
358
 
359
+ # Check any address's USDC balance (no wallet needed)
360
+ xflows wallet token-balance --address 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 \
361
+ --chain-id 1 --token 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
362
+
355
363
  # Check with explicit decimals and custom RPC
356
364
  xflows wallet token-balance --name alice --chain-id 1 \
357
365
  --token 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 \
@@ -360,7 +368,8 @@ xflows wallet token-balance --name alice --chain-id 1 \
360
368
 
361
369
  | Flag | Required | Description |
362
370
  |------|----------|-------------|
363
- | `--name <name>` | Yes | Wallet name |
371
+ | `--name <name>` | One of `--name` or `--address` | Wallet name |
372
+ | `--address <addr>` | One of `--name` or `--address` | Query any address (no wallet needed) |
364
373
  | `--chain-id <id>` | Yes | Chain ID to query balance on |
365
374
  | `--token <addr>` | Yes | ERC20 token contract address |
366
375
  | `--decimals <n>` | No | Token decimals (auto-detected if omitted) |
package/dist/index.js CHANGED
@@ -7241,6 +7241,13 @@ function getCreateAddress(tx) {
7241
7241
  function isAddressable(value) {
7242
7242
  return value && typeof value.getAddress === "function";
7243
7243
  }
7244
+ function isAddress(value) {
7245
+ try {
7246
+ getAddress(value);
7247
+ return true;
7248
+ } catch (error) {}
7249
+ return false;
7250
+ }
7244
7251
  async function checkAddress(target, promise) {
7245
7252
  const result = await promise;
7246
7253
  if (result == null || result === "0x0000000000000000000000000000000000000000") {
@@ -18660,7 +18667,7 @@ import * as readline from "readline";
18660
18667
  // package.json
18661
18668
  var package_default = {
18662
18669
  name: "xflows",
18663
- version: "1.2.0",
18670
+ version: "1.3.0",
18664
18671
  description: "CLI tool for Wanchain XFlows cross-chain bridge - wallet management, quote queries, and cross-chain transactions",
18665
18672
  type: "module",
18666
18673
  bin: {
@@ -18945,12 +18952,25 @@ walletCmd.command("balance").description(`Check native token balance on a specif
18945
18952
 
18946
18953
  ` + `Examples:
18947
18954
  ` + ` xflows wallet balance --name myWallet --chain-id 1
18948
- ` + " xflows wallet balance --name myWallet --chain-id 56 --password mysecret").requiredOption("--name <name>", "Wallet name").requiredOption("--chain-id <chainId>", "Chain ID to check balance on").option("--password <password>", "Password to decrypt encrypted wallet").option("--rpc <url>", "Custom RPC URL (overrides default)").action(async (opts) => {
18955
+ ` + ` xflows wallet balance --name myWallet --chain-id 56 --password mysecret
18956
+ ` + " xflows wallet balance --address 0x1234...abcd --chain-id 1").option("--name <name>", "Wallet name").option("--address <address>", "Query balance for any address (no wallet needed)").requiredOption("--chain-id <chainId>", "Chain ID to check balance on").option("--password <password>", "Password to decrypt encrypted wallet").option("--rpc <url>", "Custom RPC URL (overrides default)").action(async (opts) => {
18949
18957
  try {
18950
- const wallet = loadWallet(opts.name, opts.password);
18958
+ if (!opts.name && !opts.address) {
18959
+ throw new Error("Please provide either --name or --address");
18960
+ }
18961
+ let targetAddress;
18962
+ if (opts.address) {
18963
+ if (!isAddress(opts.address)) {
18964
+ throw new Error(`Invalid address: ${opts.address}`);
18965
+ }
18966
+ targetAddress = opts.address;
18967
+ } else {
18968
+ const wallet = loadWallet(opts.name, opts.password);
18969
+ targetAddress = wallet.address;
18970
+ }
18951
18971
  const provider = opts.rpc ? new JsonRpcProvider(opts.rpc) : getProvider2(opts.chainId);
18952
- const balance = await provider.getBalance(wallet.address);
18953
- console.log(`Address: ${wallet.address}`);
18972
+ const balance = await provider.getBalance(targetAddress);
18973
+ console.log(`Address: ${targetAddress}`);
18954
18974
  console.log(`Chain: ${opts.chainId}`);
18955
18975
  console.log(`Balance: ${formatUnits(balance, 18)} (native token)`);
18956
18976
  } catch (e) {
@@ -18965,9 +18985,24 @@ walletCmd.command("token-balance").description(`Check ERC20 token balance on a s
18965
18985
  ` + " xflows wallet token-balance --name alice --chain-id 1 \\\n" + ` --token 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
18966
18986
 
18967
18987
  ` + ` # Check USDT balance on BSC with explicit decimals
18968
- ` + " xflows wallet token-balance --name alice --chain-id 56 \\\n" + " --token 0x55d398326f99059fF775485246999027B3197955 --decimals 18").requiredOption("--name <name>", "Wallet name").requiredOption("--chain-id <chainId>", "Chain ID to check balance on").requiredOption("--token <address>", "ERC20 token contract address").option("--decimals <decimals>", "Token decimals (auto-detected if omitted)").option("--password <password>", "Password to decrypt encrypted wallet").option("--rpc <url>", "Custom RPC URL (overrides default)").action(async (opts) => {
18988
+ ` + " xflows wallet token-balance --name alice --chain-id 56 \\\n" + ` --token 0x55d398326f99059fF775485246999027B3197955 --decimals 18
18989
+
18990
+ ` + ` # Check any address's USDC balance (no wallet needed)
18991
+ ` + " xflows wallet token-balance --address 0x1234...abcd --chain-id 1 \\\n" + " --token 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48").option("--name <name>", "Wallet name").option("--address <address>", "Query balance for any address (no wallet needed)").requiredOption("--chain-id <chainId>", "Chain ID to check balance on").requiredOption("--token <address>", "ERC20 token contract address").option("--decimals <decimals>", "Token decimals (auto-detected if omitted)").option("--password <password>", "Password to decrypt encrypted wallet").option("--rpc <url>", "Custom RPC URL (overrides default)").action(async (opts) => {
18969
18992
  try {
18970
- const wallet = loadWallet(opts.name, opts.password);
18993
+ if (!opts.name && !opts.address) {
18994
+ throw new Error("Please provide either --name or --address");
18995
+ }
18996
+ let targetAddress;
18997
+ if (opts.address) {
18998
+ if (!isAddress(opts.address)) {
18999
+ throw new Error(`Invalid address: ${opts.address}`);
19000
+ }
19001
+ targetAddress = opts.address;
19002
+ } else {
19003
+ const wallet = loadWallet(opts.name, opts.password);
19004
+ targetAddress = wallet.address;
19005
+ }
18971
19006
  const provider = opts.rpc ? new JsonRpcProvider(opts.rpc) : getProvider2(opts.chainId);
18972
19007
  const tokenContract = new Contract(opts.token, ERC20_ABI, provider);
18973
19008
  let decimals;
@@ -18984,8 +19019,8 @@ walletCmd.command("token-balance").description(`Check ERC20 token balance on a s
18984
19019
  try {
18985
19020
  symbol = await tokenContract.symbol();
18986
19021
  } catch {}
18987
- const balance = await tokenContract.balanceOf(wallet.address);
18988
- console.log(`Address: ${wallet.address}`);
19022
+ const balance = await tokenContract.balanceOf(targetAddress);
19023
+ console.log(`Address: ${targetAddress}`);
18989
19024
  console.log(`Chain: ${opts.chainId}`);
18990
19025
  console.log(`Token: ${opts.token} (${symbol})`);
18991
19026
  console.log(`Balance: ${formatUnits(balance, decimals)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xflows",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "CLI tool for Wanchain XFlows cross-chain bridge - wallet management, quote queries, and cross-chain transactions",
5
5
  "type": "module",
6
6
  "bin": {