xflows 1.1.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 +42 -1
  2. package/dist/index.js +76 -5
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -15,6 +15,12 @@ A command-line interface for the [Wanchain XFlows](https://docs.wanchain.org/dev
15
15
  - [RPC Endpoints](#rpc-endpoints)
16
16
  - [Commands](#commands)
17
17
  - [Wallet Management](#wallet-management)
18
+ - [`wallet create`](#wallet-create----create-a-new-wallet)
19
+ - [`wallet list`](#wallet-list----list-all-saved-wallets)
20
+ - [`wallet show`](#wallet-show----show-wallet-details)
21
+ - [`wallet balance`](#wallet-balance----check-native-token-balance)
22
+ - [`wallet token-balance`](#wallet-token-balance----check-erc20-token-balance)
23
+ - [`wallet delete`](#wallet-delete----delete-a-wallet)
18
24
  - [Query Commands](#query-commands)
19
25
  - [Quote](#quote)
20
26
  - [Send Transaction](#send-transaction)
@@ -321,6 +327,9 @@ xflows wallet balance --name alice --chain-id 56
321
327
  # Check WAN balance on Wanchain
322
328
  xflows wallet balance --name alice --chain-id 888
323
329
 
330
+ # Check any address (no wallet needed)
331
+ xflows wallet balance --address 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --chain-id 1
332
+
324
333
  # Encrypted wallet
325
334
  xflows wallet balance --name alice --chain-id 1 --password mypassword
326
335
 
@@ -330,11 +339,43 @@ xflows wallet balance --name alice --chain-id 1 --rpc https://my-rpc.example.com
330
339
 
331
340
  | Flag | Required | Description |
332
341
  |------|----------|-------------|
333
- | `--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) |
334
344
  | `--chain-id <id>` | Yes | Chain ID to query balance on |
335
345
  | `--password <pw>` | No | Password for encrypted wallets |
336
346
  | `--rpc <url>` | No | Override default RPC endpoint |
337
347
 
348
+ #### `wallet token-balance` -- Check ERC20 token balance
349
+
350
+ ```bash
351
+ # Check USDC balance on Ethereum
352
+ xflows wallet token-balance --name alice --chain-id 1 \
353
+ --token 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
354
+
355
+ # Check USDT balance on BSC (auto-detect decimals)
356
+ xflows wallet token-balance --name alice --chain-id 56 \
357
+ --token 0x55d398326f99059fF775485246999027B3197955
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
+
363
+ # Check with explicit decimals and custom RPC
364
+ xflows wallet token-balance --name alice --chain-id 1 \
365
+ --token 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 \
366
+ --decimals 6 --rpc https://my-rpc.example.com
367
+ ```
368
+
369
+ | Flag | Required | Description |
370
+ |------|----------|-------------|
371
+ | `--name <name>` | One of `--name` or `--address` | Wallet name |
372
+ | `--address <addr>` | One of `--name` or `--address` | Query any address (no wallet needed) |
373
+ | `--chain-id <id>` | Yes | Chain ID to query balance on |
374
+ | `--token <addr>` | Yes | ERC20 token contract address |
375
+ | `--decimals <n>` | No | Token decimals (auto-detected if omitted) |
376
+ | `--password <pw>` | No | Password for encrypted wallets |
377
+ | `--rpc <url>` | No | Override default RPC endpoint |
378
+
338
379
  #### `wallet delete` -- Delete a wallet
339
380
 
340
381
  ```bash
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.1.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) {
@@ -18958,6 +18978,57 @@ walletCmd.command("balance").description(`Check native token balance on a specif
18958
18978
  process.exit(1);
18959
18979
  }
18960
18980
  });
18981
+ walletCmd.command("token-balance").description(`Check ERC20 token balance on a specific chain
18982
+
18983
+ ` + `Examples:
18984
+ ` + ` # Check USDC balance on Ethereum
18985
+ ` + " xflows wallet token-balance --name alice --chain-id 1 \\\n" + ` --token 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
18986
+
18987
+ ` + ` # Check USDT balance on BSC with explicit decimals
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) => {
18992
+ try {
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
+ }
19006
+ const provider = opts.rpc ? new JsonRpcProvider(opts.rpc) : getProvider2(opts.chainId);
19007
+ const tokenContract = new Contract(opts.token, ERC20_ABI, provider);
19008
+ let decimals;
19009
+ if (opts.decimals !== undefined) {
19010
+ decimals = Number(opts.decimals);
19011
+ } else {
19012
+ try {
19013
+ decimals = Number(await tokenContract.decimals());
19014
+ } catch {
19015
+ throw new Error("Could not auto-detect token decimals. Please provide --decimals manually.");
19016
+ }
19017
+ }
19018
+ let symbol = "TOKEN";
19019
+ try {
19020
+ symbol = await tokenContract.symbol();
19021
+ } catch {}
19022
+ const balance = await tokenContract.balanceOf(targetAddress);
19023
+ console.log(`Address: ${targetAddress}`);
19024
+ console.log(`Chain: ${opts.chainId}`);
19025
+ console.log(`Token: ${opts.token} (${symbol})`);
19026
+ console.log(`Balance: ${formatUnits(balance, decimals)}`);
19027
+ } catch (e) {
19028
+ console.error(`Error: ${e.message}`);
19029
+ process.exit(1);
19030
+ }
19031
+ });
18961
19032
  walletCmd.command("delete").description("Delete a saved wallet").requiredOption("--name <name>", "Wallet name to delete").option("--force", "Skip confirmation", false).action(async (opts) => {
18962
19033
  const walletDir = getWalletDir();
18963
19034
  const filePath = path.join(walletDir, `${opts.name}.json`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xflows",
3
- "version": "1.1.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": {