xflows 1.1.0 → 1.2.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.
- package/README.md +32 -0
- package/dist/index.js +37 -1
- 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)
|
|
@@ -335,6 +341,32 @@ xflows wallet balance --name alice --chain-id 1 --rpc https://my-rpc.example.com
|
|
|
335
341
|
| `--password <pw>` | No | Password for encrypted wallets |
|
|
336
342
|
| `--rpc <url>` | No | Override default RPC endpoint |
|
|
337
343
|
|
|
344
|
+
#### `wallet token-balance` -- Check ERC20 token balance
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
# Check USDC balance on Ethereum
|
|
348
|
+
xflows wallet token-balance --name alice --chain-id 1 \
|
|
349
|
+
--token 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
|
|
350
|
+
|
|
351
|
+
# Check USDT balance on BSC (auto-detect decimals)
|
|
352
|
+
xflows wallet token-balance --name alice --chain-id 56 \
|
|
353
|
+
--token 0x55d398326f99059fF775485246999027B3197955
|
|
354
|
+
|
|
355
|
+
# Check with explicit decimals and custom RPC
|
|
356
|
+
xflows wallet token-balance --name alice --chain-id 1 \
|
|
357
|
+
--token 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 \
|
|
358
|
+
--decimals 6 --rpc https://my-rpc.example.com
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
| Flag | Required | Description |
|
|
362
|
+
|------|----------|-------------|
|
|
363
|
+
| `--name <name>` | Yes | Wallet name |
|
|
364
|
+
| `--chain-id <id>` | Yes | Chain ID to query balance on |
|
|
365
|
+
| `--token <addr>` | Yes | ERC20 token contract address |
|
|
366
|
+
| `--decimals <n>` | No | Token decimals (auto-detected if omitted) |
|
|
367
|
+
| `--password <pw>` | No | Password for encrypted wallets |
|
|
368
|
+
| `--rpc <url>` | No | Override default RPC endpoint |
|
|
369
|
+
|
|
338
370
|
#### `wallet delete` -- Delete a wallet
|
|
339
371
|
|
|
340
372
|
```bash
|
package/dist/index.js
CHANGED
|
@@ -18660,7 +18660,7 @@ import * as readline from "readline";
|
|
|
18660
18660
|
// package.json
|
|
18661
18661
|
var package_default = {
|
|
18662
18662
|
name: "xflows",
|
|
18663
|
-
version: "1.
|
|
18663
|
+
version: "1.2.0",
|
|
18664
18664
|
description: "CLI tool for Wanchain XFlows cross-chain bridge - wallet management, quote queries, and cross-chain transactions",
|
|
18665
18665
|
type: "module",
|
|
18666
18666
|
bin: {
|
|
@@ -18958,6 +18958,42 @@ walletCmd.command("balance").description(`Check native token balance on a specif
|
|
|
18958
18958
|
process.exit(1);
|
|
18959
18959
|
}
|
|
18960
18960
|
});
|
|
18961
|
+
walletCmd.command("token-balance").description(`Check ERC20 token balance on a specific chain
|
|
18962
|
+
|
|
18963
|
+
` + `Examples:
|
|
18964
|
+
` + ` # Check USDC balance on Ethereum
|
|
18965
|
+
` + " xflows wallet token-balance --name alice --chain-id 1 \\\n" + ` --token 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
|
|
18966
|
+
|
|
18967
|
+
` + ` # 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) => {
|
|
18969
|
+
try {
|
|
18970
|
+
const wallet = loadWallet(opts.name, opts.password);
|
|
18971
|
+
const provider = opts.rpc ? new JsonRpcProvider(opts.rpc) : getProvider2(opts.chainId);
|
|
18972
|
+
const tokenContract = new Contract(opts.token, ERC20_ABI, provider);
|
|
18973
|
+
let decimals;
|
|
18974
|
+
if (opts.decimals !== undefined) {
|
|
18975
|
+
decimals = Number(opts.decimals);
|
|
18976
|
+
} else {
|
|
18977
|
+
try {
|
|
18978
|
+
decimals = Number(await tokenContract.decimals());
|
|
18979
|
+
} catch {
|
|
18980
|
+
throw new Error("Could not auto-detect token decimals. Please provide --decimals manually.");
|
|
18981
|
+
}
|
|
18982
|
+
}
|
|
18983
|
+
let symbol = "TOKEN";
|
|
18984
|
+
try {
|
|
18985
|
+
symbol = await tokenContract.symbol();
|
|
18986
|
+
} catch {}
|
|
18987
|
+
const balance = await tokenContract.balanceOf(wallet.address);
|
|
18988
|
+
console.log(`Address: ${wallet.address}`);
|
|
18989
|
+
console.log(`Chain: ${opts.chainId}`);
|
|
18990
|
+
console.log(`Token: ${opts.token} (${symbol})`);
|
|
18991
|
+
console.log(`Balance: ${formatUnits(balance, decimals)}`);
|
|
18992
|
+
} catch (e) {
|
|
18993
|
+
console.error(`Error: ${e.message}`);
|
|
18994
|
+
process.exit(1);
|
|
18995
|
+
}
|
|
18996
|
+
});
|
|
18961
18997
|
walletCmd.command("delete").description("Delete a saved wallet").requiredOption("--name <name>", "Wallet name to delete").option("--force", "Skip confirmation", false).action(async (opts) => {
|
|
18962
18998
|
const walletDir = getWalletDir();
|
|
18963
18999
|
const filePath = path.join(walletDir, `${opts.name}.json`);
|