From 91a22a80bec5cd4974de0cb49c95b4364e92d772 Mon Sep 17 00:00:00 2001 From: Aleksandr Kraiz Date: Mon, 27 Jun 2022 11:58:36 +0400 Subject: [PATCH] Display address in BalanceGuard --- package.json | 2 +- src/BalanceGuard.ts | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 3ed4e66..99347fa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.12.6", + "version": "0.12.7", "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 400886c..2f3abfa 100644 --- a/src/BalanceGuard.ts +++ b/src/BalanceGuard.ts @@ -216,6 +216,7 @@ export default class BalanceGuard { const exchangePlusWalletAggregatedRequirements = aggregatedRequirements .filter(({ sources }) => sources[0] === 'exchange' && sources[1] === 'wallet'); + const walletAddress = await this.signer.getAddress(); // This requirements can be fulfilled by exchange + wallet await Promise.all(exchangePlusWalletAggregatedRequirements .map(async ({ asset, spenderAddress, items }) => { @@ -235,7 +236,6 @@ export default class BalanceGuard { if (!spenderAddress) throw new Error(`Spender address is required for ${asset.name}`); const tokenContract = ERC20__factory.connect(asset.address, this.provider); const tokenDecimals = await tokenContract.decimals(); - const walletAddress = await this.signer.getAddress(); const tokenAllowance = await tokenContract.allowance(walletAddress, spenderAddress); denormalizedAllowance = denormalizeNumber(tokenAllowance, tokenDecimals); } @@ -330,7 +330,6 @@ export default class BalanceGuard { if (!spenderAddress) throw new Error(`Spender address is required for ${asset.name}`); const tokenContract = ERC20__factory.connect(asset.address, this.provider); const tokenDecimals = await tokenContract.decimals(); - const walletAddress = await this.signer.getAddress(); const tokenAllowance = await tokenContract.allowance(walletAddress, spenderAddress); denormalizedAllowance = denormalizeNumber(tokenAllowance, tokenDecimals); } @@ -428,7 +427,7 @@ export default class BalanceGuard { const unfixed = await this.fixAllAutofixableBalanceIssues(balanceIssues); if (unfixed.length > 0) throw new Error(`Balance issues: ${unfixed.map((issue, i) => `${i + 1}. ${issue.message}`).join('\n')}`); } else if (balanceIssues.length > 0) { - throw new Error(`Balance issues: ${balanceIssues.map((issue, i) => `${i + 1}. ${issue.message}`).join('\n')}`); + throw new Error(`Balance issues (address ${walletAddress}): ${balanceIssues.map((issue, i) => `${i + 1}. ${issue.message}`).join('\n')}`); } } }