degate-cli 1.0.1 → 1.0.3

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.
Files changed (2) hide show
  1. package/cli.js +16 -1
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -427,7 +427,22 @@ function verifyApiSign(message, sig) {
427
427
 
428
428
  async function signAndSubmitIntent(client, tryResp, mnemonic, das) {
429
429
  const intentItem = tryResp.result;
430
- if (!intentItem) throw new Error('compact_try_create 未返回 result');
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 avail = tryResp.gas_pay_token_avail;
435
+ const needAmt = needed?.amount ? (parseInt(needed.amount) / 1e9).toFixed(6) : '?';
436
+ const availAmt = avail?.amount ? (parseInt(avail.amount) / 1e9).toFixed(6) : '0';
437
+ const tokenSymbol = needed?.token === 'So11111111111111111111111111111111111111112' ? 'SOL' : (needed?.token || 'gas token');
438
+ throw new Error(
439
+ `余额不足\n` +
440
+ ` ${tryResp.is_balance_enough === false ? '❌ USDC 余额不足' : ''}\n` +
441
+ ` ${tryResp.is_gas_pay_token_enough === false ? `❌ Gas 不足: 需要 ${needAmt} ${tokenSymbol},账户有 ${availAmt} ${tokenSymbol}` : ''}`
442
+ );
443
+ }
444
+ throw new Error('compact_try_create 未返回 result');
445
+ }
431
446
 
432
447
  if (!verifyApiSign(intentItem.data, intentItem.signature)) {
433
448
  throw new Error('API 签名验证失败');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "degate-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "DeGate Turbo Range CLI - deposit/withdraw LP positions across Solana & EVM chains",
5
5
  "main": "cli.js",
6
6
  "bin": {