From 620e4a5ef74aaa67b05eb4d6a8d9aad72e07181f Mon Sep 17 00:00:00 2001 From: Aleksandr Kraiz Date: Mon, 4 Jul 2022 14:31:31 +0400 Subject: [PATCH] Clearer messages --- package.json | 2 +- src/BalanceGuard.ts | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index ab72ce6..312b14b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.12.11", + "version": "0.12.12", "description": "Orion Protocol SDK", "main": "./lib/esm/index.js", "module": "./lib/esm/index.js", diff --git a/src/BalanceGuard.ts b/src/BalanceGuard.ts index 2f3abfa..5b01fe2 100644 --- a/src/BalanceGuard.ts +++ b/src/BalanceGuard.ts @@ -262,9 +262,10 @@ export default class BalanceGuard { const issueMessage = `Not enough ${asset.name} on exchange + wallet balance. ` + `Needed: ${itemsAmountSum.toString()}, available: ${available?.toString()} ` - + `(exchange: ${exchangeBalance?.toString()}, wallet: ${approvedWalletBalance.toString()}). ${approveIsHelpful - ? `You need to be allowed to spend another ${lackAmount.toString()} ${asset.name} more` - : 'Approve is not helpful'}`; + + `(exchange: ${exchangeBalance?.toString()}, available (approved): ${approvedWalletBalance.toString()}).` + + ` ${approveIsHelpful + ? `You need approve at least ${lackAmount.toString()} ${asset.name}` + : 'Approve is not helpful'}`; if (approveIsHelpful) { if (!spenderAddress) throw new Error(`Spender address is required for ${asset.name}`); const resetRequired = await this.checkResetRequired( @@ -351,8 +352,8 @@ export default class BalanceGuard { const targetApprove = approvedWalletBalance.plus(lackAmount); const issueMessage = `Not enough ${asset.name} on wallet balance. ` - + `Needed: ${itemsAmountSum.toString()}, available: ${approvedWalletBalance.toString()}. ${approveIsHelpful - ? `You need to be allowed to spend another ${lackAmount.toString()} ${asset.name} more` + + `Needed: ${itemsAmountSum.toString()}, available (approved): ${approvedWalletBalance.toString()}. ${approveIsHelpful + ? `You need approve at least ${lackAmount.toString()} ${asset.name}` : 'Approve is not helpful'}`; if (approveIsHelpful) { if (!spenderAddress) throw new Error(`Spender address is required for ${asset.name}`);