nansen-cli 1.43.0 → 1.43.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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.43.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#526](https://github.com/nansen-ai/nansen-cli/pull/526) [`a7ab05c`](https://github.com/nansen-ai/nansen-cli/commit/a7ab05c592bddd1e0ca33c08586ef325bcc19277) Thanks [@dolmaciabdullah-byte](https://github.com/dolmaciabdullah-byte)! - Fix `formatValue` displaying `1000.00K` instead of `1.00M` when a value like 999999.995 rounds up at the K/M boundary.
8
+
9
+ - [#548](https://github.com/nansen-ai/nansen-cli/pull/548) [`000d01a`](https://github.com/nansen-ai/nansen-cli/commit/000d01a8530de7e5bb6af8a637ba1b4fe406b732) Thanks [@Sertug17](https://github.com/Sertug17)! - Fix `parseAmount` silently producing wrong values for negative decimal inputs. Negative amounts are now rejected with a clear error.
10
+
11
+ - [#551](https://github.com/nansen-ai/nansen-cli/pull/551) [`092535a`](https://github.com/nansen-ai/nansen-cli/commit/092535aa32bedb8c11a6ee624936bffca247d2d5) Thanks [@kome12](https://github.com/kome12)! - Harden `parseAmount` input validation: reject negative amounts wrapped in whitespace (previously silently miscalculated), and reject non-numeric or malformed inputs (e.g. `abc`, empty string, `1.`, `.5`) with a clear error instead of throwing a raw error or silently returning `0`.
12
+
13
+ - [#433](https://github.com/nansen-ai/nansen-cli/pull/433) [`977fbc5`](https://github.com/nansen-ai/nansen-cli/commit/977fbc51a75ef4a0764db161b4bbee26d1ebc3ae) Thanks [@aikido-autofix](https://github.com/apps/aikido-autofix)! - Validate the wallet name before the Privy pre-read in `wallet delete` and `wallet send`, routing both reads through `getWalletFile()` so the path stays confined to the wallets directory.
14
+
15
+ - [#545](https://github.com/nansen-ai/nansen-cli/pull/545) [`642eb20`](https://github.com/nansen-ai/nansen-cli/commit/642eb20a48fe1ff5a9ba17fcbeac4604c7172698) Thanks [@kome12](https://github.com/kome12)! - Update Noble crypto dependencies to the patched 2.4.x releases.
16
+
3
17
  ## 1.43.0
4
18
 
5
19
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nansen-cli",
3
- "version": "1.43.0",
3
+ "version": "1.43.1",
4
4
  "description": "AI-agent CLI for Nansen API analytics, DEX swaps, and cross-chain trading",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -73,8 +73,8 @@
73
73
  },
74
74
  "dependencies": {
75
75
  "@ethereumjs/rlp": "^10.1.1",
76
- "@noble/curves": "^2.0.1",
77
- "@noble/hashes": "^2.0.1",
76
+ "@noble/curves": "^2.4.0",
77
+ "@noble/hashes": "^2.4.0",
78
78
  "@scure/base": "^2.0.0"
79
79
  }
80
80
  }
package/src/cli.js CHANGED
@@ -232,7 +232,11 @@ export function formatValue(val) {
232
232
  if (val === null || val === undefined) return '';
233
233
  if (typeof val === 'number') {
234
234
  if (Math.abs(val) >= 1000000) return (val / 1000000).toFixed(2) + 'M';
235
- if (Math.abs(val) >= 1000) return (val / 1000).toFixed(2) + 'K';
235
+ if (Math.abs(val) >= 1000) {
236
+ const formatted = (val / 1000).toFixed(2);
237
+ if (Math.abs(parseFloat(formatted)) >= 1000) return (val / 1000000).toFixed(2) + 'M';
238
+ return formatted + 'K';
239
+ }
236
240
  if (Number.isInteger(val)) return val.toString();
237
241
  return val.toFixed(2);
238
242
  }
package/src/transfer.js CHANGED
@@ -49,7 +49,10 @@ function validateSolanaAddress(address) {
49
49
  // ============= Amount Parsing =============
50
50
 
51
51
  function parseAmount(amountStr, decimals) {
52
- const parts = amountStr.split('.');
52
+ const str = String(amountStr).trim();
53
+ if (str.startsWith('-')) throw new Error('Amount must be positive');
54
+ if (!/^\d+(\.\d+)?$/.test(str)) throw new Error('Amount must be a valid number');
55
+ const parts = str.split('.');
53
56
  const whole = parts[0] || '0';
54
57
  let frac = (parts[1] || '').padEnd(decimals, '0').slice(0, decimals);
55
58
  return BigInt(whole) * (10n ** BigInt(decimals)) + BigInt(frac);
package/src/wallet.js CHANGED
@@ -801,13 +801,15 @@ export function buildWalletCommands(deps = {}) {
801
801
  throw new CommandError('Usage: nansen wallet delete <name>', 'MISSING_ARGS');
802
802
  }
803
803
 
804
- // Check if this is a Privy wallet (no password needed)
804
+ // Check if this is a Privy wallet (no password needed).
805
+ // getWalletFile() runs validateWalletName(), which rejects any name
806
+ // outside [a-zA-Z0-9_-]{1,64} — so the path is confined to the wallets
807
+ // dir and cannot traverse. deleteWallet() re-validates below.
805
808
  let isPrivy = false;
806
809
  try {
807
- const walletFile = path.join(getWalletsDir(), `${name}.json`);
808
- const data = JSON.parse(fs.readFileSync(walletFile, 'utf8'));
810
+ const data = JSON.parse(fs.readFileSync(getWalletFile(name), 'utf8'));
809
811
  if (data.provider === 'privy') isPrivy = true;
810
- } catch { /* file might not exist, deleteWallet will throw */ }
812
+ } catch { /* invalid/missing name; deleteWallet will validate and throw */ }
811
813
 
812
814
  let password = null;
813
815
  if (!isPrivy) {
@@ -862,8 +864,10 @@ export function buildWalletCommands(deps = {}) {
862
864
  try {
863
865
  const walletName = options.wallet || getWalletConfig().defaultWallet;
864
866
  if (walletName) {
865
- const walletFile = path.join(getWalletsDir(), `${walletName}.json`);
866
- const data = JSON.parse(fs.readFileSync(walletFile, 'utf8'));
867
+ // getWalletFile() runs validateWalletName(), confining the path to
868
+ // the wallets dir; an invalid name throws and is ignored here, and
869
+ // the real wallet load downstream validates again.
870
+ const data = JSON.parse(fs.readFileSync(getWalletFile(walletName), 'utf8'));
867
871
  if (data.provider === 'privy') isPrivyWallet = true;
868
872
  }
869
873
  } catch { /* ignore */ }