xflows 1.0.0 → 1.0.2

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 +30 -6
  2. package/dist/index.js +74 -7
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -27,18 +27,42 @@ A command-line interface for the [Wanchain XFlows](https://docs.wanchain.org/dev
27
27
 
28
28
  ## Installation
29
29
 
30
+ ### From npm (recommended)
31
+
30
32
  ```bash
31
- # Clone and install dependencies
32
- bun install
33
+ # Install globally via npm
34
+ npm install -g xflows
33
35
 
34
- # Run directly
35
- bun src/index.ts --help
36
+ # Or via yarn
37
+ yarn global add xflows
38
+
39
+ # Or via pnpm
40
+ pnpm add -g xflows
36
41
 
37
- # Or link as a global command
38
- bun link
42
+ # Then use it anywhere
39
43
  xflows --help
40
44
  ```
41
45
 
46
+ **Requirements:** Node.js >= 18
47
+
48
+ ### One-time use with npx
49
+
50
+ ```bash
51
+ # Run without installing
52
+ npx xflows --help
53
+ npx xflows chains
54
+ npx xflows wallet create --name alice
55
+ ```
56
+
57
+ ### From source
58
+
59
+ ```bash
60
+ git clone https://github.com/wandevs/xflows-cli.git
61
+ cd xflows-cli
62
+ bun install
63
+ bun src/index.ts --help
64
+ ```
65
+
42
66
  **Requirements:** [Bun](https://bun.sh) v1.0+
43
67
 
44
68
  ## Quick Start
package/dist/index.js CHANGED
@@ -18654,8 +18654,66 @@ import * as crypto2 from "crypto";
18654
18654
  import * as fs from "fs";
18655
18655
  import * as path from "path";
18656
18656
  import * as readline from "readline";
18657
+ // package.json
18658
+ var package_default = {
18659
+ name: "xflows",
18660
+ version: "1.0.2",
18661
+ description: "CLI tool for Wanchain XFlows cross-chain bridge - wallet management, quote queries, and cross-chain transactions",
18662
+ type: "module",
18663
+ bin: {
18664
+ xflows: "dist/index.js"
18665
+ },
18666
+ files: [
18667
+ "dist",
18668
+ "README.md",
18669
+ "LICENSE"
18670
+ ],
18671
+ scripts: {
18672
+ build: "bun build src/index.ts --outfile dist/index.js --target node --format esm && chmod +x dist/index.js",
18673
+ prepublishOnly: "bun run build",
18674
+ start: "bun src/index.ts",
18675
+ test: "bun test"
18676
+ },
18677
+ keywords: [
18678
+ "wanchain",
18679
+ "xflows",
18680
+ "cross-chain",
18681
+ "bridge",
18682
+ "cli",
18683
+ "defi",
18684
+ "web3",
18685
+ "evm",
18686
+ "swap"
18687
+ ],
18688
+ author: "lolieatapple@gmail.com",
18689
+ license: "MIT",
18690
+ repository: {
18691
+ type: "git",
18692
+ url: "git+https://github.com/wandevs/xflows-cli.git"
18693
+ },
18694
+ bugs: {
18695
+ url: "https://github.com/wandevs/xflows-cli/issues"
18696
+ },
18697
+ homepage: "https://github.com/wandevs/xflows-cli#readme",
18698
+ engines: {
18699
+ node: ">=18"
18700
+ },
18701
+ devDependencies: {
18702
+ "@types/bun": "latest"
18703
+ },
18704
+ peerDependencies: {
18705
+ typescript: "^5"
18706
+ },
18707
+ dependencies: {
18708
+ chalk: "^5.6.2",
18709
+ commander: "^14.0.3",
18710
+ ethers: "^6.16.0"
18711
+ }
18712
+ };
18713
+
18714
+ // src/index.ts
18657
18715
  var API_BASE = "https://xflows.wanchain.org/api/v3";
18658
- var VERSION = "1.0.0";
18716
+ var VERSION = package_default.version;
18659
18717
  var RPC_MAP = {
18660
18718
  "1": "https://ethereum-rpc.publicnode.com",
18661
18719
  "56": "https://bsc-rpc.publicnode.com",
@@ -18724,6 +18782,12 @@ async function apiPost(endpoint, body) {
18724
18782
  throw new Error(`API error: ${resp.status} ${resp.statusText}`);
18725
18783
  return resp.json();
18726
18784
  }
18785
+ function unwrapResponse(resp) {
18786
+ if (resp && resp.success === true && resp.data !== undefined) {
18787
+ return resp.data;
18788
+ }
18789
+ return resp;
18790
+ }
18727
18791
  function getWalletDir() {
18728
18792
  const dir = path.join(process.env.HOME || "~", ".xflows", "wallets");
18729
18793
  fs.mkdirSync(dir, { recursive: true });
@@ -18758,7 +18822,7 @@ function getProvider2(chainId) {
18758
18822
  return new JsonRpcProvider(rpc);
18759
18823
  }
18760
18824
  function printJson(data) {
18761
- console.log(JSON.stringify(data, null, 2));
18825
+ console.log(JSON.stringify(data, (_key, value) => typeof value === "bigint" ? value.toString() : value, 2));
18762
18826
  }
18763
18827
  var ERC20_ABI = [
18764
18828
  "function approve(address spender, uint256 amount) returns (bool)",
@@ -19020,7 +19084,8 @@ program2.command("send").description(`Build and send a cross-chain transaction
19020
19084
  if (opts.slippage)
19021
19085
  body.slippage = Number(opts.slippage);
19022
19086
  console.log("Fetching quote...");
19023
- const quote = await apiPost("/quote", body);
19087
+ const quoteResp = await apiPost("/quote", body);
19088
+ const quote = unwrapResponse(quoteResp);
19024
19089
  if (quote.error) {
19025
19090
  console.error(`Quote error: ${quote.error}`);
19026
19091
  process.exit(1);
@@ -19042,7 +19107,8 @@ program2.command("send").description(`Build and send a cross-chain transaction
19042
19107
  }
19043
19108
  console.log(`
19044
19109
  Building transaction...`);
19045
- const buildResult = await apiPost("/buildTx", body);
19110
+ const buildResp = await apiPost("/buildTx", body);
19111
+ const buildResult = unwrapResponse(buildResp);
19046
19112
  if (buildResult.error) {
19047
19113
  console.error(`Build error: ${buildResult.error}`);
19048
19114
  process.exit(1);
@@ -19051,7 +19117,7 @@ Building transaction...`);
19051
19117
  if (!tx) {
19052
19118
  console.error("No transaction data returned from API.");
19053
19119
  console.log("Full response:");
19054
- printJson(buildResult);
19120
+ printJson(buildResp);
19055
19121
  process.exit(1);
19056
19122
  }
19057
19123
  const NATIVE_ADDRESS = "0x0000000000000000000000000000000000000000";
@@ -19140,8 +19206,8 @@ program2.command("status").description(`Check cross-chain transaction status
19140
19206
  if (opts.bridge)
19141
19207
  body.bridge = opts.bridge;
19142
19208
  const queryStatus = async () => {
19143
- const data = await apiPost("/status", body);
19144
- return data;
19209
+ const resp = await apiPost("/status", body);
19210
+ return unwrapResponse(resp);
19145
19211
  };
19146
19212
  if (!opts.poll) {
19147
19213
  const data = await queryStatus();
@@ -19176,6 +19242,7 @@ if (__require.main == __require.module) {
19176
19242
  program2.parse();
19177
19243
  }
19178
19244
  export {
19245
+ unwrapResponse,
19179
19246
  printJson,
19180
19247
  loadWallet,
19181
19248
  getWalletDir,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xflows",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
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": {