clawmoney 0.17.1 → 0.17.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/setup.js +23 -15
- package/package.json +1 -1
package/dist/commands/setup.js
CHANGED
|
@@ -103,27 +103,35 @@ export async function setupCommand() {
|
|
|
103
103
|
email,
|
|
104
104
|
wallet_address: loginData.agent?.wallet_address ?? undefined,
|
|
105
105
|
});
|
|
106
|
-
//
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
106
|
+
// Always hit /me/wallet/balance to (a) let the backend reconcile
|
|
107
|
+
// legacy awal addresses to the canonical CDP address (the /login/verify
|
|
108
|
+
// response may still carry the stale awal value from DB), and (b) cache
|
|
109
|
+
// the authoritative address back to config. The returned `address` is
|
|
110
|
+
// the CDP account address after _ensure_agent_wallet has run.
|
|
111
|
+
let walletAddress = '';
|
|
112
|
+
const walletSpinner = ora('Reconciling CDP wallet...').start();
|
|
113
|
+
try {
|
|
114
|
+
const balResp = await apiGet('/api/v1/claw-agents/me/wallet/balance?asset=usdc', loginData.api_key);
|
|
115
|
+
if (balResp.ok && balResp.data?.address) {
|
|
116
|
+
walletAddress = balResp.data.address;
|
|
117
|
+
saveConfig({ wallet_address: walletAddress });
|
|
118
|
+
const prior = loginData.agent?.wallet_address ?? '';
|
|
119
|
+
if (prior && prior.toLowerCase() !== walletAddress.toLowerCase()) {
|
|
120
|
+
walletSpinner.succeed(`Wallet migrated: ${prior} → ${walletAddress}`);
|
|
121
|
+
console.log(chalk.yellow(` (Your old awal address ${prior} is no longer`));
|
|
122
|
+
console.log(chalk.yellow(` used by this CLI. Transfer any remaining funds manually.)`));
|
|
118
123
|
}
|
|
119
124
|
else {
|
|
120
|
-
walletSpinner.
|
|
125
|
+
walletSpinner.succeed(`Wallet ready: ${walletAddress}`);
|
|
121
126
|
}
|
|
122
127
|
}
|
|
123
|
-
|
|
124
|
-
walletSpinner.warn(
|
|
128
|
+
else {
|
|
129
|
+
walletSpinner.warn('Wallet reconcile failed — will be created on first use.');
|
|
125
130
|
}
|
|
126
131
|
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
walletSpinner.warn(`Wallet reconcile deferred: ${err.message}`);
|
|
134
|
+
}
|
|
127
135
|
// Summary.
|
|
128
136
|
console.log('');
|
|
129
137
|
console.log(chalk.green.bold(' Setup complete!'));
|