xflows 1.0.0 → 1.0.1
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 +30 -6
- package/dist/index.js +15 -6
- 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
|
-
#
|
|
32
|
-
|
|
33
|
+
# Install globally via npm
|
|
34
|
+
npm install -g xflows
|
|
33
35
|
|
|
34
|
-
#
|
|
35
|
-
|
|
36
|
+
# Or via yarn
|
|
37
|
+
yarn global add xflows
|
|
38
|
+
|
|
39
|
+
# Or via pnpm
|
|
40
|
+
pnpm add -g xflows
|
|
36
41
|
|
|
37
|
-
#
|
|
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
|
@@ -18724,6 +18724,12 @@ async function apiPost(endpoint, body) {
|
|
|
18724
18724
|
throw new Error(`API error: ${resp.status} ${resp.statusText}`);
|
|
18725
18725
|
return resp.json();
|
|
18726
18726
|
}
|
|
18727
|
+
function unwrapResponse(resp) {
|
|
18728
|
+
if (resp && resp.success === true && resp.data !== undefined) {
|
|
18729
|
+
return resp.data;
|
|
18730
|
+
}
|
|
18731
|
+
return resp;
|
|
18732
|
+
}
|
|
18727
18733
|
function getWalletDir() {
|
|
18728
18734
|
const dir = path.join(process.env.HOME || "~", ".xflows", "wallets");
|
|
18729
18735
|
fs.mkdirSync(dir, { recursive: true });
|
|
@@ -18758,7 +18764,7 @@ function getProvider2(chainId) {
|
|
|
18758
18764
|
return new JsonRpcProvider(rpc);
|
|
18759
18765
|
}
|
|
18760
18766
|
function printJson(data) {
|
|
18761
|
-
console.log(JSON.stringify(data,
|
|
18767
|
+
console.log(JSON.stringify(data, (_key, value) => typeof value === "bigint" ? value.toString() : value, 2));
|
|
18762
18768
|
}
|
|
18763
18769
|
var ERC20_ABI = [
|
|
18764
18770
|
"function approve(address spender, uint256 amount) returns (bool)",
|
|
@@ -19020,7 +19026,8 @@ program2.command("send").description(`Build and send a cross-chain transaction
|
|
|
19020
19026
|
if (opts.slippage)
|
|
19021
19027
|
body.slippage = Number(opts.slippage);
|
|
19022
19028
|
console.log("Fetching quote...");
|
|
19023
|
-
const
|
|
19029
|
+
const quoteResp = await apiPost("/quote", body);
|
|
19030
|
+
const quote = unwrapResponse(quoteResp);
|
|
19024
19031
|
if (quote.error) {
|
|
19025
19032
|
console.error(`Quote error: ${quote.error}`);
|
|
19026
19033
|
process.exit(1);
|
|
@@ -19042,7 +19049,8 @@ program2.command("send").description(`Build and send a cross-chain transaction
|
|
|
19042
19049
|
}
|
|
19043
19050
|
console.log(`
|
|
19044
19051
|
Building transaction...`);
|
|
19045
|
-
const
|
|
19052
|
+
const buildResp = await apiPost("/buildTx", body);
|
|
19053
|
+
const buildResult = unwrapResponse(buildResp);
|
|
19046
19054
|
if (buildResult.error) {
|
|
19047
19055
|
console.error(`Build error: ${buildResult.error}`);
|
|
19048
19056
|
process.exit(1);
|
|
@@ -19051,7 +19059,7 @@ Building transaction...`);
|
|
|
19051
19059
|
if (!tx) {
|
|
19052
19060
|
console.error("No transaction data returned from API.");
|
|
19053
19061
|
console.log("Full response:");
|
|
19054
|
-
printJson(
|
|
19062
|
+
printJson(buildResp);
|
|
19055
19063
|
process.exit(1);
|
|
19056
19064
|
}
|
|
19057
19065
|
const NATIVE_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
@@ -19140,8 +19148,8 @@ program2.command("status").description(`Check cross-chain transaction status
|
|
|
19140
19148
|
if (opts.bridge)
|
|
19141
19149
|
body.bridge = opts.bridge;
|
|
19142
19150
|
const queryStatus = async () => {
|
|
19143
|
-
const
|
|
19144
|
-
return
|
|
19151
|
+
const resp = await apiPost("/status", body);
|
|
19152
|
+
return unwrapResponse(resp);
|
|
19145
19153
|
};
|
|
19146
19154
|
if (!opts.poll) {
|
|
19147
19155
|
const data = await queryStatus();
|
|
@@ -19176,6 +19184,7 @@ if (__require.main == __require.module) {
|
|
|
19176
19184
|
program2.parse();
|
|
19177
19185
|
}
|
|
19178
19186
|
export {
|
|
19187
|
+
unwrapResponse,
|
|
19179
19188
|
printJson,
|
|
19180
19189
|
loadWallet,
|
|
19181
19190
|
getWalletDir,
|