minara 0.2.1 → 0.2.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.
- package/dist/commands/deposit.js +5 -9
- package/dist/commands/swap.js +5 -23
- package/dist/commands/transfer.js +4 -20
- package/dist/commands/withdraw.js +4 -24
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +3 -0
- package/package.json +1 -1
package/dist/commands/deposit.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { select,
|
|
2
|
+
import { select, number as numberPrompt } from '@inquirer/prompts';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import { getAccount } from '../api/crosschain.js';
|
|
5
5
|
import { getCurrentUser } from '../api/auth.js';
|
|
@@ -113,16 +113,12 @@ async function transferSpotToPerps(token, opts) {
|
|
|
113
113
|
console.error(chalk.red('✖'), 'Minimum deposit is 5 USDC');
|
|
114
114
|
process.exit(1);
|
|
115
115
|
}
|
|
116
|
-
console.log(`\n Transfer : ${chalk.bold(amount)} USDC ${chalk.dim('Spot wallet')} → ${chalk.cyan('Perps wallet')}\n`);
|
|
117
116
|
if (!opts?.yes) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
await requireTransactionConfirmation(`Transfer ${amount} USDC from Spot → Perps`, undefined, {
|
|
118
|
+
amount: `${amount} USDC`,
|
|
119
|
+
side: 'Spot → Perps',
|
|
120
|
+
});
|
|
121
121
|
}
|
|
122
|
-
await requireTransactionConfirmation(`Transfer ${amount} USDC from Spot → Perps`, undefined, {
|
|
123
|
-
amount: `${amount} USDC`,
|
|
124
|
-
side: 'Spot → Perps',
|
|
125
|
-
});
|
|
126
122
|
await requireTouchId();
|
|
127
123
|
const spin = spinner('Transferring…');
|
|
128
124
|
const res = await perpsApi.deposit(token, { usdcAmount: amount });
|
package/dist/commands/swap.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { input, select
|
|
2
|
+
import { input, select } from '@inquirer/prompts';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import { swaps, swapsSimulate } from '../api/crosschain.js';
|
|
5
5
|
import { get } from '../api/client.js';
|
|
6
6
|
import { requireAuth } from '../config.js';
|
|
7
|
-
import { success, info, warn, spinner,
|
|
7
|
+
import { success, info, warn, spinner, assertApiOk, wrapAction, requireTransactionConfirmation, lookupToken, normalizeChain } from '../utils.js';
|
|
8
8
|
import { requireTouchId } from '../touchid.js';
|
|
9
9
|
import { printTxResult, printKV } from '../formatters.js';
|
|
10
10
|
export const swapCommand = new Command('swap')
|
|
@@ -80,16 +80,7 @@ export const swapCommand = new Command('swap')
|
|
|
80
80
|
amount = String(maxBalance);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
// ── 5.
|
|
84
|
-
console.log('');
|
|
85
|
-
console.log(chalk.bold('Swap Summary:'));
|
|
86
|
-
console.log(` Chain : ${chalk.cyan(chain)}`);
|
|
87
|
-
console.log(` Action : ${formatOrderSide(side)}`);
|
|
88
|
-
console.log(` Token : ${formatTokenLabel(tokenInfo)}`);
|
|
89
|
-
console.log(` Address : ${chalk.yellow(tokenInfo.address)}`);
|
|
90
|
-
console.log(` Amount : ${chalk.bold(amount)} ${side === 'buy' ? 'USD' : '(token)'}`);
|
|
91
|
-
console.log('');
|
|
92
|
-
// ── 6. Dry run ───────────────────────────────────────────────────────
|
|
83
|
+
// ── 5. Dry run ───────────────────────────────────────────────────────
|
|
93
84
|
if (opts.dryRun) {
|
|
94
85
|
info('Simulating swap (dry-run)…');
|
|
95
86
|
const spin = spinner('Simulating…');
|
|
@@ -111,19 +102,10 @@ export const swapCommand = new Command('swap')
|
|
|
111
102
|
}
|
|
112
103
|
return;
|
|
113
104
|
}
|
|
114
|
-
// ── 7. Confirm
|
|
105
|
+
// ── 7. Confirm & Touch ID ──────────────────────────────────────────
|
|
115
106
|
if (!opts.yes) {
|
|
116
|
-
|
|
117
|
-
message: `Confirm ${side.toUpperCase()} swap?`,
|
|
118
|
-
default: false,
|
|
119
|
-
});
|
|
120
|
-
if (!confirmed) {
|
|
121
|
-
console.log(chalk.dim('Swap cancelled.'));
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
107
|
+
await requireTransactionConfirmation(`${side.toUpperCase()} swap · ${amount} ${side === 'buy' ? 'USD' : 'tokens'} · ${chain}`, tokenInfo, { chain, side, amount: `${amount} ${side === 'buy' ? 'USD' : '(token)'}` });
|
|
124
108
|
}
|
|
125
|
-
// ── 8. Transaction confirmation & Touch ID ────────────────────────────
|
|
126
|
-
await requireTransactionConfirmation(`${side.toUpperCase()} swap · ${amount} ${side === 'buy' ? 'USD' : 'tokens'} · ${chain}`, tokenInfo, { chain, side, amount: `${amount} ${side === 'buy' ? 'USD' : '(token)'}` });
|
|
127
109
|
await requireTouchId();
|
|
128
110
|
// ── 9. Execute ───────────────────────────────────────────────────────
|
|
129
111
|
const spin = spinner('Executing swap…');
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { input
|
|
3
|
-
import chalk from 'chalk';
|
|
2
|
+
import { input } from '@inquirer/prompts';
|
|
4
3
|
import { transfer } from '../api/crosschain.js';
|
|
5
4
|
import { requireAuth } from '../config.js';
|
|
6
|
-
import { success,
|
|
5
|
+
import { success, spinner, assertApiOk, selectChain, wrapAction, requireTransactionConfirmation, lookupToken } from '../utils.js';
|
|
7
6
|
import { requireTouchId } from '../touchid.js';
|
|
8
7
|
import { printTxResult } from '../formatters.js';
|
|
9
8
|
export const transferCommand = new Command('transfer')
|
|
@@ -36,25 +35,10 @@ export const transferCommand = new Command('transfer')
|
|
|
36
35
|
message: 'Recipient address:',
|
|
37
36
|
validate: (v) => (v.length > 5 ? true : 'Enter a valid address'),
|
|
38
37
|
});
|
|
39
|
-
// ── 5.
|
|
40
|
-
console.log('');
|
|
41
|
-
console.log(chalk.bold.red('⚠ Transfer Summary:'));
|
|
42
|
-
console.log(` Chain : ${chalk.cyan(chain)}`);
|
|
43
|
-
console.log(` Token : ${formatTokenLabel(tokenInfo)}`);
|
|
44
|
-
console.log(` Address : ${chalk.yellow(tokenInfo.address)}`);
|
|
45
|
-
console.log(` Amount : ${chalk.bold(amount)}`);
|
|
46
|
-
console.log(` To : ${chalk.yellow(recipient)}`);
|
|
47
|
-
console.log('');
|
|
48
|
-
warn('Transfers cannot be reversed. Double-check the recipient address!');
|
|
38
|
+
// ── 5. Confirm & Touch ID ──────────────────────────────────────────
|
|
49
39
|
if (!opts.yes) {
|
|
50
|
-
|
|
51
|
-
if (!confirmed) {
|
|
52
|
-
console.log(chalk.dim('Transfer cancelled.'));
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
40
|
+
await requireTransactionConfirmation(`Transfer ${amount} → ${recipient} · ${chain}`, tokenInfo, { chain, amount, destination: recipient });
|
|
55
41
|
}
|
|
56
|
-
// ── 6. Transaction confirmation & Touch ID ────────────────────────────
|
|
57
|
-
await requireTransactionConfirmation(`Transfer ${amount} tokens → ${recipient} · ${chain}`, tokenInfo, { chain, amount });
|
|
58
42
|
await requireTouchId();
|
|
59
43
|
// ── 7. Execute ───────────────────────────────────────────────────────
|
|
60
44
|
const spin = spinner('Processing transfer…');
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { input
|
|
2
|
+
import { input } from '@inquirer/prompts';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import { transfer, getAssets } from '../api/crosschain.js';
|
|
5
5
|
import { requireAuth } from '../config.js';
|
|
6
|
-
import { success,
|
|
6
|
+
import { success, spinner, assertApiOk, selectChain, wrapAction, requireTransactionConfirmation, lookupToken } from '../utils.js';
|
|
7
7
|
import { requireTouchId } from '../touchid.js';
|
|
8
8
|
import { printTxResult } from '../formatters.js';
|
|
9
9
|
export const withdrawCommand = new Command('withdraw')
|
|
@@ -59,30 +59,10 @@ export const withdrawCommand = new Command('withdraw')
|
|
|
59
59
|
message: 'Destination address (your external wallet):',
|
|
60
60
|
validate: (v) => (v.length > 5 ? true : 'Enter a valid address'),
|
|
61
61
|
});
|
|
62
|
-
// ── 6.
|
|
63
|
-
console.log('');
|
|
64
|
-
console.log(chalk.bold.red('⚠ Withdrawal Summary'));
|
|
65
|
-
console.log(` Chain : ${chalk.cyan(chain)}`);
|
|
66
|
-
console.log(` Token : ${formatTokenLabel(tokenInfo)}`);
|
|
67
|
-
console.log(` Address : ${chalk.yellow(tokenInfo.address)}`);
|
|
68
|
-
console.log(` Amount : ${chalk.bold(amount)}`);
|
|
69
|
-
console.log(` Destination : ${chalk.yellow(recipient)}`);
|
|
70
|
-
console.log('');
|
|
71
|
-
warn('Withdrawals are irreversible. Please double-check the network and address!');
|
|
72
|
-
warn('Sending to the wrong chain or address will result in permanent loss of funds.');
|
|
73
|
-
console.log('');
|
|
62
|
+
// ── 6. Confirm & Touch ID ──────────────────────────────────────────
|
|
74
63
|
if (!opts.yes) {
|
|
75
|
-
|
|
76
|
-
message: 'I have verified the address and network. Proceed with withdrawal?',
|
|
77
|
-
default: false,
|
|
78
|
-
});
|
|
79
|
-
if (!confirmed) {
|
|
80
|
-
console.log(chalk.dim('Withdrawal cancelled.'));
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
64
|
+
await requireTransactionConfirmation(`Withdraw ${amount} → ${recipient} · ${chain}`, tokenInfo, { chain, amount, destination: recipient });
|
|
83
65
|
}
|
|
84
|
-
// ── 7. Transaction confirmation & Touch ID ────────────────────────────
|
|
85
|
-
await requireTransactionConfirmation(`Withdraw ${amount} tokens → ${recipient} · ${chain}`, tokenInfo, { chain, amount });
|
|
86
66
|
await requireTouchId();
|
|
87
67
|
// ── 8. Execute ───────────────────────────────────────────────────────
|
|
88
68
|
const spin = spinner('Processing withdrawal…');
|
package/dist/utils.d.ts
CHANGED
|
@@ -73,6 +73,7 @@ export declare function requireTransactionConfirmation(description: string, toke
|
|
|
73
73
|
chain?: string;
|
|
74
74
|
side?: string;
|
|
75
75
|
amount?: string;
|
|
76
|
+
destination?: string;
|
|
76
77
|
}): Promise<void>;
|
|
77
78
|
/** Open a URL in the user's default browser (cross-platform). */
|
|
78
79
|
export declare function openBrowser(url: string): void;
|
package/dist/utils.js
CHANGED
|
@@ -326,6 +326,9 @@ export async function requireTransactionConfirmation(description, token, details
|
|
|
326
326
|
if (details?.amount) {
|
|
327
327
|
console.log(chalk.dim(' Amount : ') + chalk.bold(details.amount));
|
|
328
328
|
}
|
|
329
|
+
if (details?.destination) {
|
|
330
|
+
console.log(chalk.dim(' To : ') + chalk.yellow(details.destination));
|
|
331
|
+
}
|
|
329
332
|
console.log(chalk.dim(` Action : ${description}`));
|
|
330
333
|
console.log('');
|
|
331
334
|
const ok = await confirm({
|