Display address in BalanceGuard

This commit is contained in:
Aleksandr Kraiz
2022-06-27 11:58:36 +04:00
parent ee6ac10ffc
commit 91a22a80be
2 changed files with 3 additions and 4 deletions

View File

@@ -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",

View File

@@ -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')}`);
}
}
}