nansen-cli 1.10.1 → 1.11.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 +20 -0
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/api.js +18 -5
- package/src/cli.js +52 -22
- package/src/index.js +4 -4
- package/src/schema.json +197 -1
- package/src/trading.js +111 -111
- package/src/wallet.js +37 -39
- package/src/walletconnect-x402.js +3 -1
package/src/wallet.js
CHANGED
|
@@ -519,7 +519,7 @@ export function buildWalletCommands(deps = {}) {
|
|
|
519
519
|
log(` Base (recommended, lower fees): send USDC to ${result.evm}`);
|
|
520
520
|
log(` Solana: send USDC to ${result.solana}`);
|
|
521
521
|
log('');
|
|
522
|
-
return
|
|
522
|
+
return;
|
|
523
523
|
} catch (err) {
|
|
524
524
|
log(`❌ ${err.message}`);
|
|
525
525
|
exit(1);
|
|
@@ -530,7 +530,7 @@ export function buildWalletCommands(deps = {}) {
|
|
|
530
530
|
const result = listWallets();
|
|
531
531
|
if (result.wallets.length === 0) {
|
|
532
532
|
log('No wallets found. Create one with: nansen wallet create');
|
|
533
|
-
return
|
|
533
|
+
return;
|
|
534
534
|
}
|
|
535
535
|
log('');
|
|
536
536
|
for (const w of result.wallets) {
|
|
@@ -540,7 +540,6 @@ export function buildWalletCommands(deps = {}) {
|
|
|
540
540
|
log(` Solana: ${w.solana}`);
|
|
541
541
|
log('');
|
|
542
542
|
}
|
|
543
|
-
return result;
|
|
544
543
|
},
|
|
545
544
|
|
|
546
545
|
'show': async () => {
|
|
@@ -557,7 +556,7 @@ export function buildWalletCommands(deps = {}) {
|
|
|
557
556
|
log(` EVM: ${result.evm}`);
|
|
558
557
|
log(` Solana: ${result.solana}`);
|
|
559
558
|
log(` Created: ${result.createdAt}\n`);
|
|
560
|
-
return
|
|
559
|
+
return;
|
|
561
560
|
} catch (err) {
|
|
562
561
|
log(`❌ ${err.message}`);
|
|
563
562
|
exit(1);
|
|
@@ -582,7 +581,7 @@ export function buildWalletCommands(deps = {}) {
|
|
|
582
581
|
log(` Address: ${result.solana.address}`);
|
|
583
582
|
log(` Private Key: ${result.solana.privateKey}`);
|
|
584
583
|
log('');
|
|
585
|
-
return
|
|
584
|
+
return;
|
|
586
585
|
} catch (err) {
|
|
587
586
|
log(`❌ ${err.message}`);
|
|
588
587
|
exit(1);
|
|
@@ -599,7 +598,7 @@ export function buildWalletCommands(deps = {}) {
|
|
|
599
598
|
try {
|
|
600
599
|
const result = setDefaultWallet(name);
|
|
601
600
|
log(`✓ Default wallet set to "${result.defaultWallet}"`);
|
|
602
|
-
return
|
|
601
|
+
return;
|
|
603
602
|
} catch (err) {
|
|
604
603
|
log(`❌ ${err.message}`);
|
|
605
604
|
exit(1);
|
|
@@ -620,7 +619,7 @@ export function buildWalletCommands(deps = {}) {
|
|
|
620
619
|
if (result.newDefault) {
|
|
621
620
|
log(` New default: ${result.newDefault}`);
|
|
622
621
|
}
|
|
623
|
-
return
|
|
622
|
+
return;
|
|
624
623
|
} catch (err) {
|
|
625
624
|
log(`❌ ${err.message}`);
|
|
626
625
|
exit(1);
|
|
@@ -675,37 +674,32 @@ export function buildWalletCommands(deps = {}) {
|
|
|
675
674
|
if (dryRun) {
|
|
676
675
|
// Build the transaction but don't broadcast
|
|
677
676
|
const result = await sendTokens(sendOpts);
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
log(JSON.stringify(output, null, 2));
|
|
688
|
-
return output;
|
|
677
|
+
log(`\nDry run — transaction not broadcast\n`);
|
|
678
|
+
log(` From: ${result.from}`);
|
|
679
|
+
log(` To: ${options.to}`);
|
|
680
|
+
log(` Amount: ${result.amount || (isMax ? 'max' : String(options.amount))}`);
|
|
681
|
+
log(` Token: ${options.token || '(native)'}`);
|
|
682
|
+
log(` Chain: ${options.chain}`);
|
|
683
|
+
if (result.estimatedFee) log(` Fee: ${result.estimatedFee}`);
|
|
684
|
+
log('');
|
|
685
|
+
return;
|
|
689
686
|
}
|
|
690
687
|
|
|
691
688
|
const result = await sendTokens(sendOpts);
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
};
|
|
705
|
-
log(JSON.stringify(output, null, 2));
|
|
706
|
-
return output;
|
|
689
|
+
log(`\n✓ Transaction sent\n`);
|
|
690
|
+
log(` Tx Hash: ${result.transactionHash}`);
|
|
691
|
+
log(` Chain: ${result.chain}`);
|
|
692
|
+
log(` From: ${result.from}`);
|
|
693
|
+
log(` To: ${result.to}`);
|
|
694
|
+
log(` Amount: ${result.amount}`);
|
|
695
|
+
log(` Token: ${result.token}`);
|
|
696
|
+
if (result.blockNumber) log(` Block: ${result.blockNumber}`);
|
|
697
|
+
log(` Status: ${result.confirmed ? 'confirmed' : 'pending'}`);
|
|
698
|
+
log(` Explorer: ${result.explorer}`);
|
|
699
|
+
log('');
|
|
700
|
+
return;
|
|
707
701
|
} catch (err) {
|
|
708
|
-
log(
|
|
702
|
+
log(`Error: ${err.message}`);
|
|
709
703
|
exit(1);
|
|
710
704
|
}
|
|
711
705
|
},
|
|
@@ -749,15 +743,19 @@ EXAMPLES:
|
|
|
749
743
|
nansen wallet send --to 0x742d35Cc... --amount 1.5 --chain evm
|
|
750
744
|
nansen wallet send --to 9WzDXw... --amount 0.1 --chain solana --token So11...
|
|
751
745
|
`);
|
|
752
|
-
return
|
|
753
|
-
commands: ['create', 'list', 'show', 'export', 'default', 'delete', 'send'],
|
|
754
|
-
description: 'Local wallet management for EVM and Solana',
|
|
755
|
-
};
|
|
746
|
+
return;
|
|
756
747
|
},
|
|
757
748
|
};
|
|
758
749
|
|
|
759
750
|
if (!handlers[subcommand]) {
|
|
760
|
-
|
|
751
|
+
log(`Unknown subcommand: ${subcommand}. Available: ${Object.keys(handlers).join(', ')}`);
|
|
752
|
+
exit(1);
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
// --help on any wallet subcommand shows wallet help instead of executing
|
|
757
|
+
if (flags.help || flags.h) {
|
|
758
|
+
return handlers['help']();
|
|
761
759
|
}
|
|
762
760
|
|
|
763
761
|
return handlers[subcommand]();
|
|
@@ -142,7 +142,9 @@ export async function handleX402Payment(paymentRequirements) {
|
|
|
142
142
|
const wallet = await checkWalletConnection();
|
|
143
143
|
if (!wallet) {
|
|
144
144
|
throw new NansenError(
|
|
145
|
-
'x402 payment required but no wallet connected.
|
|
145
|
+
'x402 payment required but no wallet connected. ' +
|
|
146
|
+
'To pay automatically: create a local wallet with `nansen wallet create` (then set NANSEN_WALLET_PASSWORD), ' +
|
|
147
|
+
'or connect an external wallet via the `walletconnect` CLI (`walletconnect connect`).',
|
|
146
148
|
ErrorCode.PAYMENT_REQUIRED,
|
|
147
149
|
402
|
|
148
150
|
);
|