mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-25 07:07:39 +03:00
Fix
This commit is contained in:
@@ -51,7 +51,7 @@ export default class BalanceGuard {
|
||||
// Used for case feeAsset === assetOut
|
||||
setExtraBalance(assetName: string, amount: BigNumber.Value, source: Source) {
|
||||
const assetBalance = this.balances[assetName];
|
||||
if (assetBalance == null) throw Error(`Can't set extra balance. Asset ${assetName} not found`);
|
||||
if (assetBalance === undefined) throw Error(`Can't set extra balance. Asset ${assetName} not found`);
|
||||
assetBalance[source] = assetBalance[source].plus(amount);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ export default class BalanceGuard {
|
||||
item.spenderAddress === curr.spenderAddress,
|
||||
);
|
||||
|
||||
if (aggregatedBalanceRequirement != null) {
|
||||
if (aggregatedBalanceRequirement !== undefined) {
|
||||
aggregatedBalanceRequirement.items = {
|
||||
...aggregatedBalanceRequirement.items,
|
||||
[curr.reason]: curr.amount,
|
||||
@@ -194,7 +194,7 @@ export default class BalanceGuard {
|
||||
|
||||
exchangeOnlyAggregatedRequirements.forEach(({ asset, items }) => {
|
||||
const remainingBalance = remainingBalances[asset.name];
|
||||
if (remainingBalance == null) throw new Error(`No ${asset.name} balance`);
|
||||
if (remainingBalance === undefined) throw new Error(`No ${asset.name} balance`);
|
||||
const itemsAmountSum = Object.values(items)
|
||||
.reduce<BigNumber>((p, c) => (c !== undefined ? p.plus(c) : p), new BigNumber(0));
|
||||
|
||||
@@ -221,7 +221,7 @@ export default class BalanceGuard {
|
||||
await Promise.all(exchangePlusWalletAggregatedRequirements
|
||||
.map(async ({ asset, spenderAddress, items }) => {
|
||||
const remainingBalance = remainingBalances[asset.name];
|
||||
if (remainingBalance == null) throw new Error(`No ${asset.name} balance`);
|
||||
if (remainingBalance === undefined) throw new Error(`No ${asset.name} balance`);
|
||||
const itemsAmountSum = Object.values(items)
|
||||
.reduce<BigNumber>((p, c) => (c !== undefined ? p.plus(c) : p), new BigNumber(0));
|
||||
|
||||
@@ -322,7 +322,7 @@ export default class BalanceGuard {
|
||||
await Promise.all(walletTokensAggregatedRequirements
|
||||
.map(async ({ asset, spenderAddress, items }) => {
|
||||
const remainingBalance = remainingBalances[asset.name];
|
||||
if (remainingBalance == null) throw new Error(`No ${asset.name} balance`);
|
||||
if (remainingBalance === undefined) throw new Error(`No ${asset.name} balance`);
|
||||
const itemsAmountSum = Object.values(items)
|
||||
.reduce<BigNumber>((p, c) => (c !== undefined ? p.plus(c) : p), new BigNumber(0));
|
||||
|
||||
@@ -411,7 +411,7 @@ export default class BalanceGuard {
|
||||
|
||||
walletNativeAggregatedRequirements.forEach(({ asset, items }) => {
|
||||
const remainingBalance = remainingBalances[asset.name];
|
||||
if (remainingBalance == null) throw new Error(`No ${asset.name} balance`);
|
||||
if (remainingBalance === undefined) throw new Error(`No ${asset.name} balance`);
|
||||
|
||||
const itemsAmountSum = Object.values({ ...items, ...requiredApproves.items })
|
||||
.reduce<BigNumber>((p, c) => (c !== undefined ? p.plus(c) : p), new BigNumber(0));
|
||||
|
||||
Reference in New Issue
Block a user