degate-cli 1.0.2 → 1.0.4
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/cli.js +15 -4
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -404,9 +404,6 @@ async function intentTryCreate(client, order) {
|
|
|
404
404
|
const resp = await client.post('/order-book-api/intent/v2/compact_try_create', order, {
|
|
405
405
|
headers: { Version: '0.0.1' },
|
|
406
406
|
});
|
|
407
|
-
if (!resp.data?.result) {
|
|
408
|
-
console.log(chalk.yellow('[DEBUG] compact_try_create raw resp.data:'), JSON.stringify(resp.data, null, 2));
|
|
409
|
-
}
|
|
410
407
|
return resp.data;
|
|
411
408
|
}
|
|
412
409
|
|
|
@@ -430,7 +427,21 @@ function verifyApiSign(message, sig) {
|
|
|
430
427
|
|
|
431
428
|
async function signAndSubmitIntent(client, tryResp, mnemonic, das) {
|
|
432
429
|
const intentItem = tryResp.result;
|
|
433
|
-
if (!intentItem)
|
|
430
|
+
if (!intentItem) {
|
|
431
|
+
// 余额不足时后端返回 result: null,给出明确提示
|
|
432
|
+
if (tryResp.is_balance_enough === false || tryResp.is_gas_pay_token_enough === false) {
|
|
433
|
+
const needed = tryResp.gas_pay_token_needed;
|
|
434
|
+
const needAmt = needed?.amount ? (parseInt(needed.amount) / 1e9).toFixed(6) : '?';
|
|
435
|
+
const tokenSymbol = needed?.token === 'So11111111111111111111111111111111111111112' ? 'SOL' : (needed?.token || 'gas token');
|
|
436
|
+
const lines = ['余额不足:'];
|
|
437
|
+
if (tryResp.is_balance_enough === false) lines.push(' ❌ USDC 余额不足(请先充值 USDC 到 DeGate 账户)');
|
|
438
|
+
if (tryResp.is_gas_pay_token_enough === false) {
|
|
439
|
+
lines.push(` ❌ Gas 不足: 需要 ${needAmt} ${tokenSymbol}(请充值 ${tokenSymbol} 到 Solana DA 地址)`);
|
|
440
|
+
}
|
|
441
|
+
throw new Error(lines.join('\n'));
|
|
442
|
+
}
|
|
443
|
+
throw new Error('compact_try_create 未返回 result');
|
|
444
|
+
}
|
|
434
445
|
|
|
435
446
|
if (!verifyApiSign(intentItem.data, intentItem.signature)) {
|
|
436
447
|
throw new Error('API 签名验证失败');
|