fibx 0.4.1 → 0.5.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/LICENSE +21 -0
- package/README.md +81 -31
- package/dist/commands/auth/import.d.ts.map +1 -1
- package/dist/commands/auth/import.js +15 -15
- package/dist/commands/auth/import.js.map +1 -1
- package/dist/commands/auth/login.d.ts.map +1 -1
- package/dist/commands/auth/login.js +9 -11
- package/dist/commands/auth/login.js.map +1 -1
- package/dist/commands/auth/logout.d.ts.map +1 -1
- package/dist/commands/auth/logout.js +3 -11
- package/dist/commands/auth/logout.js.map +1 -1
- package/dist/commands/auth/verify.d.ts.map +1 -1
- package/dist/commands/auth/verify.js +10 -9
- package/dist/commands/auth/verify.js.map +1 -1
- package/dist/commands/chain/transaction.d.ts.map +1 -1
- package/dist/commands/chain/transaction.js +13 -13
- package/dist/commands/chain/transaction.js.map +1 -1
- package/dist/commands/config/index.d.ts.map +1 -1
- package/dist/commands/config/index.js +40 -8
- package/dist/commands/config/index.js.map +1 -1
- package/dist/commands/defi/aave.d.ts +1 -0
- package/dist/commands/defi/aave.d.ts.map +1 -1
- package/dist/commands/defi/aave.js +105 -40
- package/dist/commands/defi/aave.js.map +1 -1
- package/dist/commands/portfolio/index.d.ts +3 -0
- package/dist/commands/portfolio/index.d.ts.map +1 -0
- package/dist/commands/portfolio/index.js +64 -0
- package/dist/commands/portfolio/index.js.map +1 -0
- package/dist/commands/trade/status.d.ts.map +1 -1
- package/dist/commands/trade/status.js +17 -19
- package/dist/commands/trade/status.js.map +1 -1
- package/dist/commands/trade/swap.d.ts +1 -0
- package/dist/commands/trade/swap.d.ts.map +1 -1
- package/dist/commands/trade/swap.js +156 -101
- package/dist/commands/trade/swap.js.map +1 -1
- package/dist/commands/wallet/address.d.ts.map +1 -1
- package/dist/commands/wallet/address.js +7 -9
- package/dist/commands/wallet/address.js.map +1 -1
- package/dist/commands/wallet/balance.d.ts.map +1 -1
- package/dist/commands/wallet/balance.js +42 -22
- package/dist/commands/wallet/balance.js.map +1 -1
- package/dist/commands/wallet/list.d.ts +1 -1
- package/dist/commands/wallet/list.d.ts.map +1 -1
- package/dist/commands/wallet/list.js +7 -16
- package/dist/commands/wallet/list.js.map +1 -1
- package/dist/commands/wallet/send.d.ts +5 -1
- package/dist/commands/wallet/send.d.ts.map +1 -1
- package/dist/commands/wallet/send.js +66 -24
- package/dist/commands/wallet/send.js.map +1 -1
- package/dist/index.js +185 -22
- package/dist/index.js.map +1 -1
- package/dist/lib/brand.d.ts +5 -0
- package/dist/lib/brand.d.ts.map +1 -0
- package/dist/lib/brand.js +15 -0
- package/dist/lib/brand.js.map +1 -0
- package/dist/lib/cli-helpers.d.ts +10 -0
- package/dist/lib/cli-helpers.d.ts.map +1 -0
- package/dist/lib/cli-helpers.js +20 -0
- package/dist/lib/cli-helpers.js.map +1 -0
- package/dist/lib/concurrency.d.ts +8 -0
- package/dist/lib/concurrency.d.ts.map +1 -0
- package/dist/lib/concurrency.js +26 -0
- package/dist/lib/concurrency.js.map +1 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +1 -2
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/errors.d.ts +1 -0
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +1 -0
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/format.d.ts +26 -3
- package/dist/lib/format.d.ts.map +1 -1
- package/dist/lib/format.js +131 -31
- package/dist/lib/format.js.map +1 -1
- package/dist/lib/parse-evm-error.d.ts +6 -0
- package/dist/lib/parse-evm-error.d.ts.map +1 -0
- package/dist/lib/parse-evm-error.js +48 -0
- package/dist/lib/parse-evm-error.js.map +1 -0
- package/dist/lib/parseAmount.d.ts.map +1 -1
- package/dist/lib/parseAmount.js +0 -1
- package/dist/lib/parseAmount.js.map +1 -1
- package/dist/lib/retry.d.ts +20 -0
- package/dist/lib/retry.d.ts.map +1 -0
- package/dist/lib/retry.js +36 -0
- package/dist/lib/retry.js.map +1 -0
- package/dist/mcp/handlers.d.ts +13 -0
- package/dist/mcp/handlers.d.ts.map +1 -1
- package/dist/mcp/handlers.js +114 -19
- package/dist/mcp/handlers.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +4 -3
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +29 -1
- package/dist/mcp/tools.js.map +1 -1
- package/dist/services/auth/session.d.ts.map +1 -1
- package/dist/services/auth/session.js +22 -1
- package/dist/services/auth/session.js.map +1 -1
- package/dist/services/chain/client.d.ts +9376 -241
- package/dist/services/chain/client.d.ts.map +1 -1
- package/dist/services/chain/client.js +0 -1
- package/dist/services/chain/client.js.map +1 -1
- package/dist/services/chain/constants.d.ts.map +1 -1
- package/dist/services/chain/constants.js +1 -2
- package/dist/services/chain/constants.js.map +1 -1
- package/dist/services/chain/erc20.d.ts +5 -183
- package/dist/services/chain/erc20.d.ts.map +1 -1
- package/dist/services/chain/erc20.js +15 -128
- package/dist/services/chain/erc20.js.map +1 -1
- package/dist/services/chain/nonceManager.d.ts.map +1 -1
- package/dist/services/chain/nonceManager.js +0 -3
- package/dist/services/chain/nonceManager.js.map +1 -1
- package/dist/services/config/config.d.ts +2 -0
- package/dist/services/config/config.d.ts.map +1 -1
- package/dist/services/config/config.js +9 -1
- package/dist/services/config/config.js.map +1 -1
- package/dist/services/defi/aave.d.ts +12 -10
- package/dist/services/defi/aave.d.ts.map +1 -1
- package/dist/services/defi/aave.js +83 -46
- package/dist/services/defi/aave.js.map +1 -1
- package/dist/services/defi/abi/aave.d.ts +99 -0
- package/dist/services/defi/abi/aave.d.ts.map +1 -1
- package/dist/services/defi/abi/aave.js +53 -0
- package/dist/services/defi/abi/aave.js.map +1 -1
- package/dist/services/defi/constants.d.ts +0 -4
- package/dist/services/defi/constants.d.ts.map +1 -1
- package/dist/services/defi/constants.js +1 -6
- package/dist/services/defi/constants.js.map +1 -1
- package/dist/services/fibrous/balances.d.ts.map +1 -1
- package/dist/services/fibrous/balances.js +12 -9
- package/dist/services/fibrous/balances.js.map +1 -1
- package/dist/services/fibrous/route.d.ts.map +1 -1
- package/dist/services/fibrous/route.js +17 -9
- package/dist/services/fibrous/route.js.map +1 -1
- package/dist/services/fibrous/tokens.d.ts +1 -0
- package/dist/services/fibrous/tokens.d.ts.map +1 -1
- package/dist/services/fibrous/tokens.js +7 -4
- package/dist/services/fibrous/tokens.js.map +1 -1
- package/dist/services/portfolio/portfolio.d.ts +28 -0
- package/dist/services/portfolio/portfolio.d.ts.map +1 -0
- package/dist/services/portfolio/portfolio.js +116 -0
- package/dist/services/portfolio/portfolio.js.map +1 -0
- package/dist/services/privy/account.d.ts +16 -14
- package/dist/services/privy/account.d.ts.map +1 -1
- package/dist/services/privy/account.js +6 -16
- package/dist/services/privy/account.js.map +1 -1
- package/package.json +9 -9
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ahmet Enes Dur
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# FibX
|
|
2
2
|
|
|
3
3
|
A command-line tool for DeFi operations on **Base, Citrea, HyperEVM, and Monad**, powered by [Fibrous](https://fibrous.finance) aggregation and [Privy](https://privy.io) Server Wallets.
|
|
4
4
|
|
|
@@ -7,19 +7,45 @@ A command-line tool for DeFi operations on **Base, Citrea, HyperEVM, and Monad**
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
9
|
- **Multi-Chain Support**: Base, Citrea, HyperEVM, and Monad
|
|
10
|
+
- **Portfolio**: Cross-chain portfolio overview with USD valuations and DeFi positions
|
|
10
11
|
- **Token Swaps**: Optimal routing via Fibrous aggregation with auto-slippage
|
|
11
12
|
- **Transfers**: Send ETH or any ERC-20 token
|
|
12
|
-
- **Aave V3**: Supply, borrow, repay, and
|
|
13
|
-
- **MCP Server**: Built-in AI agent integration for Cursor, Claude Desktop, and
|
|
14
|
-
- **
|
|
13
|
+
- **Aave V3**: Supply, borrow, repay, withdraw, and browse markets on Base
|
|
14
|
+
- **MCP Server**: Built-in AI agent integration for Cursor, Claude Desktop, and Antigravity
|
|
15
|
+
- **Agent Skills**: Prompt-based AI skills via [fibx-skills](https://github.com/Fibrous-Finance/fibx-skills)
|
|
16
|
+
- **Privy Server Wallets**: Secure server-side signing — private keys never leave Privy's TEE
|
|
15
17
|
- **Private Key Import**: Use an existing wallet for local execution
|
|
16
18
|
- **Simulation**: All transactions are simulated before execution
|
|
19
|
+
- **Dry‑Run Mode**: `--simulate` flag estimates gas without sending a transaction
|
|
17
20
|
- **JSON Output**: `--json` flag for scripting and pipelines
|
|
18
21
|
|
|
22
|
+
## Supported Chains
|
|
23
|
+
|
|
24
|
+
| Chain | Native Token | Aave V3 |
|
|
25
|
+
| -------- | ------------ | ------- |
|
|
26
|
+
| Base | ETH | ✅ |
|
|
27
|
+
| Citrea | cBTC | — |
|
|
28
|
+
| HyperEVM | HYPE | — |
|
|
29
|
+
| Monad | MON | — |
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
Run directly with `npx` (no install needed):
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx fibx status
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Or install globally:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install -g fibx
|
|
43
|
+
```
|
|
44
|
+
|
|
19
45
|
## Requirements
|
|
20
46
|
|
|
21
47
|
- Node.js >= 18
|
|
22
|
-
- A running [fibx-server](https://github.com/ahmetenesdur/fibx-server) instance (for Privy wallet operations)
|
|
48
|
+
- A running [fibx-server](https://github.com/ahmetenesdur/fibx-server) instance (required for Privy wallet operations; not needed for private key imports)
|
|
23
49
|
|
|
24
50
|
## Usage
|
|
25
51
|
|
|
@@ -33,47 +59,45 @@ npx fibx auth verify user@example.com 123456
|
|
|
33
59
|
# Or import a private key (local signing, no server needed)
|
|
34
60
|
npx fibx auth import
|
|
35
61
|
|
|
62
|
+
# Check session status
|
|
63
|
+
npx fibx status
|
|
64
|
+
|
|
36
65
|
# Logout
|
|
37
66
|
npx fibx auth logout
|
|
38
|
-
|
|
39
|
-
# Check status
|
|
40
|
-
npx fibx status
|
|
41
67
|
```
|
|
42
68
|
|
|
43
69
|
### Global Options
|
|
44
70
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
71
|
+
| Option | Description | Default |
|
|
72
|
+
| -------------------- | ---------------------------------------------------- | ------- |
|
|
73
|
+
| `-c, --chain <name>` | Target chain (`base`, `citrea`, `hyperevm`, `monad`) | `base` |
|
|
74
|
+
| `--json` | Output results as JSON | `false` |
|
|
48
75
|
|
|
49
|
-
###
|
|
50
|
-
|
|
51
|
-
You can configure custom RPC URLs to avoid rate limits on public endpoints.
|
|
76
|
+
### Balance
|
|
52
77
|
|
|
53
78
|
```bash
|
|
54
|
-
|
|
55
|
-
npx fibx
|
|
56
|
-
|
|
57
|
-
# View current RPC URL
|
|
58
|
-
npx fibx config get-rpc base
|
|
59
|
-
|
|
60
|
-
# List all custom configurations
|
|
61
|
-
npx fibx config list
|
|
79
|
+
npx fibx balance
|
|
80
|
+
npx fibx balance --chain citrea
|
|
62
81
|
```
|
|
63
82
|
|
|
64
|
-
###
|
|
83
|
+
### Portfolio
|
|
84
|
+
|
|
85
|
+
Consolidated cross-chain portfolio view with USD valuations:
|
|
65
86
|
|
|
66
87
|
```bash
|
|
67
|
-
npx fibx
|
|
68
|
-
npx fibx
|
|
88
|
+
npx fibx portfolio # Table output across all chains
|
|
89
|
+
npx fibx portfolio --json # Structured JSON for scripting
|
|
69
90
|
```
|
|
70
91
|
|
|
92
|
+
Shows all token holdings across Base, Citrea, HyperEVM, and Monad with USD values. Includes DeFi positions (Aave V3 collateral/debt) and total portfolio net worth. Token prices are sourced live from Fibrous.
|
|
93
|
+
|
|
71
94
|
### Send
|
|
72
95
|
|
|
73
96
|
```bash
|
|
74
97
|
npx fibx send 0.001 0xRecipient # Send native token on Base (ETH)
|
|
75
98
|
npx fibx send 10 0xRecipient USDC # Send ERC-20 on Base
|
|
76
|
-
npx fibx send 1 0xRecipient --chain monad # Send on Monad
|
|
99
|
+
npx fibx send 1 0xRecipient --chain monad # Send MON on Monad
|
|
100
|
+
npx fibx send 0.1 0xRecipient --simulate # Estimate gas without sending
|
|
77
101
|
```
|
|
78
102
|
|
|
79
103
|
### Swap
|
|
@@ -83,9 +107,10 @@ npx fibx trade <amount> <from> <to>
|
|
|
83
107
|
npx fibx trade 0.0001 ETH USDC
|
|
84
108
|
npx fibx trade 20 USDC DAI
|
|
85
109
|
npx fibx trade 1 MON USDC --chain monad
|
|
110
|
+
npx fibx trade 0.1 ETH USDC --simulate # Estimate gas without executing
|
|
86
111
|
```
|
|
87
112
|
|
|
88
|
-
Options: `--slippage <n>` (default: 0.5%), `--approve-max`, `--json`
|
|
113
|
+
Options: `--slippage <n>` (default: 0.5%), `--approve-max`, `--simulate`, `--json`
|
|
89
114
|
|
|
90
115
|
> **Note:** The `trade` command automatically detects **Wrap** (Native -> Wrapped) and **Unwrap** (Wrapped -> Native) operations and executes them directly via contract calls, bypassing aggregator routing to save gas.
|
|
91
116
|
|
|
@@ -99,29 +124,43 @@ npx fibx tx-status 0x123...abc --chain monad
|
|
|
99
124
|
### Wallet Info
|
|
100
125
|
|
|
101
126
|
```bash
|
|
102
|
-
npx fibx address
|
|
103
|
-
npx fibx wallets
|
|
127
|
+
npx fibx address # Print active wallet address
|
|
128
|
+
npx fibx wallets # Show active wallet details
|
|
104
129
|
```
|
|
105
130
|
|
|
106
131
|
### Aave V3 (Base)
|
|
107
132
|
|
|
108
133
|
```bash
|
|
109
134
|
npx fibx aave status # Account health
|
|
135
|
+
npx fibx aave markets # List all active reserves with APY & TVL
|
|
110
136
|
npx fibx aave supply 1 ETH # Auto-wraps ETH -> WETH and supplies
|
|
111
137
|
npx fibx aave supply 100 USDC # Supply ERC-20
|
|
112
138
|
npx fibx aave borrow 50 USDC # Borrow
|
|
113
139
|
npx fibx aave repay 50 USDC # Repay
|
|
114
140
|
npx fibx aave repay max ETH # Auto-wraps ETH and repays full WETH debt
|
|
115
141
|
npx fibx aave withdraw max ETH # Withdraws WETH and auto-unwraps to ETH
|
|
142
|
+
npx fibx aave supply 1 ETH --simulate # Estimate gas without executing
|
|
116
143
|
```
|
|
117
144
|
|
|
118
145
|
> **Note:** `supply`, `repay`, and `withdraw` support automatic **ETH <-> WETH** wrapping/unwrapping on Base.
|
|
119
146
|
|
|
147
|
+
### Configuration
|
|
148
|
+
|
|
149
|
+
Set custom RPC URLs to avoid rate limits on public endpoints:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
npx fibx config set-rpc base https://mainnet.base.org
|
|
153
|
+
npx fibx config get-rpc base
|
|
154
|
+
npx fibx config reset-rpc base # Reset single chain to default
|
|
155
|
+
npx fibx config reset-rpc # Reset all chains to default
|
|
156
|
+
npx fibx config list
|
|
157
|
+
```
|
|
158
|
+
|
|
120
159
|
## AI Agent Integration
|
|
121
160
|
|
|
122
161
|
### MCP Server
|
|
123
162
|
|
|
124
|
-
fibx includes a built-in MCP server for AI editors like Cursor, Claude Desktop, and
|
|
163
|
+
fibx includes a built-in [MCP](https://modelcontextprotocol.io) server for AI editors like Cursor, Claude Desktop, and Antigravity. See [MCP.md](MCP.md) for setup and available tools.
|
|
125
164
|
|
|
126
165
|
```bash
|
|
127
166
|
npx fibx mcp-start
|
|
@@ -129,4 +168,15 @@ npx fibx mcp-start
|
|
|
129
168
|
|
|
130
169
|
### Agent Skills
|
|
131
170
|
|
|
132
|
-
For prompt-based agent integration, see the [fibx-skills](https://github.com/Fibrous-Finance/fibx-skills)
|
|
171
|
+
For prompt-based agent integration (Claude Code, Cursor, etc.), see the [fibx-skills](https://github.com/Fibrous-Finance/fibx-skills) repository.
|
|
172
|
+
|
|
173
|
+
## Related Links
|
|
174
|
+
|
|
175
|
+
- [Fibrous Finance](https://fibrous.finance) — DEX aggregator powering swaps
|
|
176
|
+
- [fibx-server](https://github.com/ahmetenesdur/fibx-server) — Backend for Privy wallet operations
|
|
177
|
+
- [fibx-skills](https://github.com/Fibrous-Finance/fibx-skills) — AI agent skills
|
|
178
|
+
- [npm package](https://www.npmjs.com/package/fibx)
|
|
179
|
+
|
|
180
|
+
## License
|
|
181
|
+
|
|
182
|
+
[MIT](https://opensource.org/licenses/MIT)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/import.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/import.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,KAAK,aAAa,EAClB,MAAM,qBAAqB,CAAC;AAM7B,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA8C1E"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { outputResult,
|
|
1
|
+
import { createSpinner, outputResult, formatError, warn, } from "../../lib/format.js";
|
|
2
2
|
import { saveSession } from "../../services/auth/session.js";
|
|
3
3
|
import { privateKeyToAccount } from "viem/accounts";
|
|
4
|
-
import chalk from "chalk";
|
|
5
4
|
import inquirer from "inquirer";
|
|
6
5
|
export async function authImportCommand(opts) {
|
|
7
6
|
try {
|
|
@@ -18,27 +17,28 @@ export async function authImportCommand(opts) {
|
|
|
18
17
|
},
|
|
19
18
|
},
|
|
20
19
|
]);
|
|
20
|
+
const spinner = createSpinner("Importing key...").start();
|
|
21
21
|
const account = privateKeyToAccount(privateKey);
|
|
22
22
|
const address = account.address;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}, opts);
|
|
23
|
+
saveSession({
|
|
24
|
+
userId: "local-user",
|
|
25
|
+
walletAddress: address,
|
|
26
|
+
createdAt: new Date().toISOString(),
|
|
27
|
+
type: "private-key",
|
|
28
|
+
privateKey: privateKey,
|
|
29
|
+
});
|
|
30
|
+
spinner.succeed("Private key imported");
|
|
32
31
|
outputResult({
|
|
33
|
-
message: "Private key imported successfully!",
|
|
34
32
|
address: address,
|
|
35
33
|
type: "private-key",
|
|
34
|
+
message: "You're ready to go!",
|
|
36
35
|
}, opts);
|
|
37
|
-
console.log(
|
|
38
|
-
console.log(
|
|
36
|
+
console.log(warn("Your private key is stored locally in session.json."));
|
|
37
|
+
console.log(warn("Make sure your machine is secure."));
|
|
39
38
|
}
|
|
40
39
|
catch (error) {
|
|
41
|
-
|
|
40
|
+
console.error(formatError(error));
|
|
41
|
+
process.exitCode = 1;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
//# sourceMappingURL=import.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../../src/commands/auth/import.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../../src/commands/auth/import.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,YAAY,EACZ,WAAW,EACX,IAAI,GAEJ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAmB;IAC1D,IAAI,CAAC;QACJ,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;YAC5C;gBACC,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,YAAY;gBAClB,OAAO,EAAE,iCAAiC;gBAC1C,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE;oBAC3B,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;wBACxC,OAAO,sEAAsE,CAAC;oBAC/E,CAAC;oBACD,OAAO,IAAI,CAAC;gBACb,CAAC;aACD;SACD,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,aAAa,CAAC,kBAAkB,CAAC,CAAC,KAAK,EAAE,CAAC;QAE1D,MAAM,OAAO,GAAG,mBAAmB,CAAC,UAAiB,CAAC,CAAC;QACvD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAEhC,WAAW,CAAC;YACX,MAAM,EAAE,YAAY;YACpB,aAAa,EAAE,OAAO;YACtB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,IAAI,EAAE,aAAa;YACnB,UAAU,EAAE,UAAU;SACtB,CAAC,CAAC;QAEH,OAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;QAExC,YAAY,CACX;YACC,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,qBAAqB;SAC9B,EACD,IAAI,CACJ,CAAC;QAEF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,qDAAqD,CAAC,CAAC,CAAC;QACzE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC,CAAC;IACxD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;QAClC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACtB,CAAC;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGvE,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBxF"}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { apiLogin } from "../../services/api/client.js";
|
|
2
|
-
import { outputResult
|
|
2
|
+
import { outputResult } from "../../lib/format.js";
|
|
3
|
+
import { runCommand } from "../../lib/cli-helpers.js";
|
|
3
4
|
export async function authLoginCommand(email, opts) {
|
|
4
|
-
|
|
5
|
-
await
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
outputError(error, opts);
|
|
13
|
-
}
|
|
5
|
+
await runCommand("Sending OTP...", "OTP sent", "Failed to send OTP", async () => {
|
|
6
|
+
await apiLogin(email);
|
|
7
|
+
return { email };
|
|
8
|
+
}, (data) => outputResult({
|
|
9
|
+
email: data.email,
|
|
10
|
+
message: `OTP sent to ${email}. Run: fibx auth verify ${email} <code>`,
|
|
11
|
+
}, opts));
|
|
14
12
|
}
|
|
15
13
|
//# sourceMappingURL=login.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAsB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAAa,EAAE,IAAmB;IACxE,MAAM,UAAU,CACf,gBAAgB,EAChB,UAAU,EACV,oBAAoB,EACpB,KAAK,IAAI,EAAE;QACV,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;QACtB,OAAO,EAAE,KAAK,EAAE,CAAC;IAClB,CAAC,EACD,CAAC,IAAI,EAAE,EAAE,CACR,YAAY,CACX;QACC,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO,EAAE,eAAe,KAAK,2BAA2B,KAAK,SAAS;KACtE,EACD,IAAI,CACJ,CACF,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,eAAO,MAAM,aAAa,SAYvB,CAAC"}
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { clearSession } from "../../services/auth/session.js";
|
|
3
|
-
import
|
|
3
|
+
import { runCommand } from "../../lib/cli-helpers.js";
|
|
4
4
|
export const logoutCommand = new Command("logout")
|
|
5
5
|
.description("Log out and clear current session")
|
|
6
6
|
.action(async () => {
|
|
7
|
-
|
|
8
|
-
try {
|
|
7
|
+
await runCommand("Logging out...", "Logged out. Session cleared.", "Logout failed", async () => {
|
|
9
8
|
clearSession();
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
catch (error) {
|
|
13
|
-
spinner.fail("Logout failed.");
|
|
14
|
-
if (error instanceof Error) {
|
|
15
|
-
console.error(error.message);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
9
|
+
}, () => { });
|
|
18
10
|
});
|
|
19
11
|
//# sourceMappingURL=logout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAChD,WAAW,CAAC,mCAAmC,CAAC;KAChD,MAAM,CAAC,KAAK,IAAI,EAAE;IAClB,MAAM,UAAU,CACf,gBAAgB,EAChB,8BAA8B,EAC9B,eAAe,EACf,KAAK,IAAI,EAAE;QACV,YAAY,EAAE,CAAC;IAChB,CAAC,EACD,GAAG,EAAE,GAAE,CAAC,CACR,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/verify.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/verify.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4C,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEnG,wBAAsB,iBAAiB,CACtC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,aAAa,GACjB,OAAO,CAAC,IAAI,CAAC,CAgCf"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { apiVerify } from "../../services/api/client.js";
|
|
2
2
|
import { saveSession } from "../../services/auth/session.js";
|
|
3
|
-
import {
|
|
3
|
+
import { createSpinner, outputResult, formatError } from "../../lib/format.js";
|
|
4
4
|
export async function authVerifyCommand(email, code, opts) {
|
|
5
|
+
const spinner = createSpinner("Verifying OTP...").start();
|
|
5
6
|
try {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
await saveSession({
|
|
7
|
+
const result = await apiVerify(email, code);
|
|
8
|
+
spinner.text = "Saving session...";
|
|
9
|
+
saveSession({
|
|
10
10
|
userId: result.userId,
|
|
11
11
|
walletId: result.walletId,
|
|
12
12
|
walletAddress: result.walletAddress,
|
|
@@ -14,16 +14,17 @@ export async function authVerifyCommand(email, code, opts) {
|
|
|
14
14
|
createdAt: new Date().toISOString(),
|
|
15
15
|
type: "privy",
|
|
16
16
|
});
|
|
17
|
+
spinner.succeed(result.isExisting ? "Existing wallet connected" : "New wallet created");
|
|
17
18
|
outputResult({
|
|
18
19
|
walletAddress: result.walletAddress,
|
|
19
20
|
walletId: result.walletId,
|
|
20
|
-
message:
|
|
21
|
-
? "Existing wallet found and connected. You're ready to go!"
|
|
22
|
-
: "New wallet created and session saved. You're ready to go!",
|
|
21
|
+
message: "You're ready to go!",
|
|
23
22
|
}, opts);
|
|
24
23
|
}
|
|
25
24
|
catch (error) {
|
|
26
|
-
|
|
25
|
+
spinner.fail("Verification failed");
|
|
26
|
+
console.error(formatError(error));
|
|
27
|
+
process.exitCode = 1;
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
//# sourceMappingURL=verify.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../../src/commands/auth/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../../src/commands/auth/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAsB,MAAM,qBAAqB,CAAC;AAEnG,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACtC,KAAa,EACb,IAAY,EACZ,IAAmB;IAEnB,MAAM,OAAO,GAAG,aAAa,CAAC,kBAAkB,CAAC,CAAC,KAAK,EAAE,CAAC;IAE1D,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAE5C,OAAO,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAEnC,WAAW,CAAC;YACX,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,aAAa,EAAE,MAAM,CAAC,aAA8B;YACpD,OAAO,EAAE,MAAM,CAAC,KAAK;YACrB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,IAAI,EAAE,OAAO;SACb,CAAC,CAAC;QAEH,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC;QAExF,YAAY,CACX;YACC,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,OAAO,EAAE,qBAAqB;SAC9B,EACD,IAAI,CACJ,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QACpC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;QAClC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACtB,CAAC;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/commands/chain/transaction.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/commands/chain/transaction.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,KAAK,aAAa,EAAsB,MAAM,qBAAqB,CAAC;AAG3F,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAoCtF"}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { getPublicClient } from "../../services/chain/client.js";
|
|
2
2
|
import { getChainConfig } from "../../services/chain/constants.js";
|
|
3
|
-
import { outputResult
|
|
3
|
+
import { outputResult } from "../../lib/format.js";
|
|
4
|
+
import { runCommand } from "../../lib/cli-helpers.js";
|
|
4
5
|
export async function txStatusCommand(hash, opts) {
|
|
5
|
-
|
|
6
|
+
await runCommand(`Fetching transaction ${hash.slice(0, 10)}...`, "Transaction fetched", "Failed to fetch transaction", async (spinner) => {
|
|
6
7
|
const globalOpts = opts;
|
|
7
8
|
const chainName = globalOpts.chain || "base";
|
|
8
9
|
const chain = getChainConfig(chainName);
|
|
9
10
|
const publicClient = getPublicClient(chain);
|
|
10
11
|
const txHash = hash;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
spinner.text = "Waiting for receipt...";
|
|
13
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
|
|
14
|
+
spinner.text =
|
|
15
|
+
receipt.status === "success" ? "Transaction confirmed" : "Transaction reverted";
|
|
14
16
|
const explorerLink = chain.viemChain.blockExplorers?.default.url
|
|
15
17
|
? `${chain.viemChain.blockExplorers.default.url}/tx/${hash}`
|
|
16
|
-
:
|
|
17
|
-
|
|
18
|
+
: undefined;
|
|
19
|
+
return {
|
|
18
20
|
status: receipt.status,
|
|
19
21
|
blockNumber: receipt.blockNumber.toString(),
|
|
20
22
|
gasUsed: receipt.gasUsed.toString(),
|
|
21
23
|
from: receipt.from,
|
|
22
24
|
to: receipt.to,
|
|
23
|
-
|
|
25
|
+
txHash: hash,
|
|
26
|
+
...(explorerLink ? { explorer: explorerLink } : {}),
|
|
24
27
|
chain: chain.name,
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
outputError(error, opts);
|
|
29
|
-
}
|
|
28
|
+
};
|
|
29
|
+
}, (data) => outputResult(data, opts));
|
|
30
30
|
}
|
|
31
31
|
//# sourceMappingURL=transaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/commands/chain/transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/commands/chain/transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,YAAY,EAA0C,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAY,EAAE,IAAmB;IACtE,MAAM,UAAU,CACf,wBAAwB,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,EAC9C,qBAAqB,EACrB,6BAA6B,EAC7B,KAAK,EAAE,OAAO,EAAE,EAAE;QACjB,MAAM,UAAU,GAAG,IAAgC,CAAC;QACpD,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,IAAI,MAAM,CAAC;QAC7C,MAAM,KAAK,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;QAExC,MAAM,YAAY,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;QAC5C,MAAM,MAAM,GAAG,IAAY,CAAC;QAE5B,OAAO,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACxC,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,yBAAyB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QAE/E,OAAO,CAAC,IAAI;YACX,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,sBAAsB,CAAC;QAEjF,MAAM,YAAY,GAAG,KAAK,CAAC,SAAS,CAAC,cAAc,EAAE,OAAO,CAAC,GAAG;YAC/D,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,OAAO,IAAI,EAAE;YAC5D,CAAC,CAAC,SAAS,CAAC;QAEb,OAAO;YACN,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE;YAC3C,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE;YACnC,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,MAAM,EAAE,IAAI;YACZ,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACnD,KAAK,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC;IACH,CAAC,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAClC,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOzC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,QAwGtD"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import { configService } from "../../services/config/config.js";
|
|
3
3
|
import { SUPPORTED_CHAINS } from "../../services/chain/constants.js";
|
|
4
|
+
import { success, warn, formatError } from "../../lib/format.js";
|
|
5
|
+
import { BLUE } from "../../lib/brand.js";
|
|
4
6
|
export function registerConfigCommands(program) {
|
|
5
7
|
const configCmd = program
|
|
6
8
|
.command("config")
|
|
@@ -10,9 +12,10 @@ export function registerConfigCommands(program) {
|
|
|
10
12
|
.description("Set a custom RPC URL for a specific chain")
|
|
11
13
|
.argument("<chain>", "Chain name (base, citrea, hyperevm, monad)")
|
|
12
14
|
.argument("<url>", "RPC URL")
|
|
15
|
+
.addHelpText("after", "\nExamples:\n $ fibx config set-rpc base https://my-rpc.example.com\n $ fibx config set-rpc monad https://rpc.monad.xyz")
|
|
13
16
|
.action((chain, url) => {
|
|
14
17
|
if (!SUPPORTED_CHAINS[chain]) {
|
|
15
|
-
console.error(
|
|
18
|
+
console.error(formatError(new Error(`Unsupported chain: ${chain}`)));
|
|
16
19
|
console.log(chalk.gray(`Supported chains: ${Object.keys(SUPPORTED_CHAINS).join(", ")}`));
|
|
17
20
|
process.exit(1);
|
|
18
21
|
}
|
|
@@ -20,11 +23,11 @@ export function registerConfigCommands(program) {
|
|
|
20
23
|
new URL(url); // Validate URL format
|
|
21
24
|
}
|
|
22
25
|
catch {
|
|
23
|
-
console.error(
|
|
26
|
+
console.error(formatError(new Error("Invalid URL format.")));
|
|
24
27
|
process.exit(1);
|
|
25
28
|
}
|
|
26
29
|
configService.setRpcUrl(chain, url);
|
|
27
|
-
console.log(
|
|
30
|
+
console.log(success(`Updated RPC for ${chain} to: ${url}`));
|
|
28
31
|
});
|
|
29
32
|
configCmd
|
|
30
33
|
.command("get-rpc")
|
|
@@ -34,12 +37,12 @@ export function registerConfigCommands(program) {
|
|
|
34
37
|
const customUrl = configService.getRpcUrl(chain);
|
|
35
38
|
const defaultUrl = SUPPORTED_CHAINS[chain]?.rpcUrl;
|
|
36
39
|
if (!defaultUrl) {
|
|
37
|
-
console.error(
|
|
40
|
+
console.error(formatError(new Error(`Unsupported chain: ${chain}`)));
|
|
38
41
|
process.exit(1);
|
|
39
42
|
}
|
|
40
43
|
if (customUrl) {
|
|
41
|
-
console.log(chalk.bold("Current (Custom):"), chalk.
|
|
42
|
-
console.log(chalk.gray("Default:"), defaultUrl);
|
|
44
|
+
console.log(chalk.bold("Current (Custom):"), chalk.hex(BLUE)(customUrl));
|
|
45
|
+
console.log(chalk.gray("Default:"), chalk.dim(defaultUrl));
|
|
43
46
|
}
|
|
44
47
|
else {
|
|
45
48
|
console.log(chalk.bold("Current (Default):"), defaultUrl);
|
|
@@ -50,16 +53,45 @@ export function registerConfigCommands(program) {
|
|
|
50
53
|
.description("List all configuration")
|
|
51
54
|
.action(() => {
|
|
52
55
|
const config = configService.getConfig();
|
|
53
|
-
console.log(chalk.bold("\
|
|
56
|
+
console.log(chalk.bold.hex(BLUE)("\n Custom RPCs"));
|
|
54
57
|
if (Object.keys(config.rpcUrls).length === 0) {
|
|
55
58
|
console.log(chalk.gray(" (None set)"));
|
|
56
59
|
}
|
|
57
60
|
else {
|
|
58
61
|
for (const [chain, url] of Object.entries(config.rpcUrls)) {
|
|
59
|
-
console.log(`
|
|
62
|
+
console.log(` ${chalk.white(chain.padEnd(12))} ${chalk.hex(BLUE)(url)}`);
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
console.log("");
|
|
63
66
|
});
|
|
67
|
+
configCmd
|
|
68
|
+
.command("reset-rpc")
|
|
69
|
+
.description("Reset custom RPC URL(s) to default")
|
|
70
|
+
.argument("[chain]", "Chain name (omit to reset all)")
|
|
71
|
+
.action((chain) => {
|
|
72
|
+
if (chain) {
|
|
73
|
+
if (!SUPPORTED_CHAINS[chain]) {
|
|
74
|
+
console.error(formatError(new Error(`Unsupported chain: ${chain}`)));
|
|
75
|
+
console.log(chalk.gray(`Supported chains: ${Object.keys(SUPPORTED_CHAINS).join(", ")}`));
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
const currentUrl = configService.getRpcUrl(chain);
|
|
79
|
+
if (!currentUrl) {
|
|
80
|
+
console.log(warn(`No custom RPC set for ${chain}. Already using default.`));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
configService.resetRpcUrl(chain);
|
|
84
|
+
console.log(success(`Reset RPC for ${chain} to default.`));
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
const config = configService.getConfig();
|
|
88
|
+
if (Object.keys(config.rpcUrls).length === 0) {
|
|
89
|
+
console.log(warn("No custom RPCs set. Already using defaults."));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
configService.resetAll();
|
|
93
|
+
console.log(success("All custom RPC URLs have been reset to defaults."));
|
|
94
|
+
}
|
|
95
|
+
});
|
|
64
96
|
}
|
|
65
97
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/config/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/config/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACtD,MAAM,SAAS,GAAG,OAAO;SACvB,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,4CAA4C,CAAC,CAAC;IAE5D,SAAS;SAC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CAAC,GAAG,CAAC,OAAO,CAAC,iBAAiB,KAAK,cAAc,CAAC,CAAC,CAAC;QAC5D,CAAC;aAAM,CAAC;YACP,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,EAAE,CAAC;YACzC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC9C,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC,CAAC;gBACjE,OAAO;YACR,CAAC;YAED,aAAa,CAAC,QAAQ,EAAE,CAAC;YACzB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,kDAAkD,CAAC,CAAC,CAAC;QAC1E,CAAC;IACF,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aave.d.ts","sourceRoot":"","sources":["../../../src/commands/defi/aave.ts"],"names":[],"mappings":"AAYA,UAAU,aAAa;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"aave.d.ts","sourceRoot":"","sources":["../../../src/commands/defi/aave.ts"],"names":[],"mappings":"AAYA,UAAU,aAAa;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAID,eAAO,MAAM,WAAW,GACvB,QAAQ,MAAM,EACd,QAAQ,MAAM,EACd,aAAa,MAAM,EACnB,MAAM,aAAa,kBAmGnB,CAAC"}
|