Skip to content

Commit

Permalink
1481: Fix checkFeeStatusAsync duplicate asset resolution issues with BTS
Browse files Browse the repository at this point in the history
  • Loading branch information
svk31 committed May 4, 2018
1 parent c69f297 commit c6cdd4a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
23 changes: 14 additions & 9 deletions app/components/Exchange/Exchange.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,16 +296,21 @@ class Exchange extends React.Component {
})
);
});
Promise.all(p).then(status => {
assets.forEach((a, idx) => {
feeStatus[a.get("id")] = status[idx];
});
if (!utils.are_equal_shallow(this.state.feeStatus, feeStatus)) {
this.setState({
feeStatus
Promise.all(p)
.then(status => {
assets.forEach((a, idx) => {
feeStatus[a.get("id")] = status[idx];
});
}
});
if (!utils.are_equal_shallow(this.state.feeStatus, feeStatus)) {
this.setState({
feeStatus
});
}
})
.catch(err => {
console.log("checkFeeStatusAsync error", err);
this.setState({feeStatus: {}});
});
}

_getWindowSize() {
Expand Down
23 changes: 17 additions & 6 deletions app/lib/common/trxHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,22 @@ function checkFeeStatusAsync({
let coreBalanceID = account.getIn(["balances", "1.3.0"]),
feeBalanceID = account.getIn(["balances", feeID]);

if (feeID === "1.3.0" && !coreBalanceID)
return res({
fee: new Asset({amount: coreFee}),
hasBalance,
hasPoolBalance
if (feeID === "1.3.0" && !coreBalanceID) {
asyncCache[key].queue.forEach(promise => {
promise.res({
fee: new Asset({amount: coreFee}),
hasBalance,
hasPoolBalance
});
});
asyncCache[key] = {
result: {fee, hasBalance, hasPoolBalance, hasValidCER}
};
setTimeout(() => {
delete asyncCache[key];
}, feeStatusTTL);
return;
}

Promise.all([
coreBalanceID
Expand Down Expand Up @@ -147,6 +157,7 @@ function checkFeeStatusAsync({
feeBalance.get("balance") >= fee.getAmount()
)
hasBalance = true;

asyncCache[key].queue.forEach(promise => {
promise.res({
fee,
Expand All @@ -164,7 +175,7 @@ function checkFeeStatusAsync({
});
})
.catch(() => {
asyncCache[key].forEach(promise => {
asyncCache[key].queue.forEach(promise => {
promise.rej();
});
});
Expand Down

0 comments on commit c6cdd4a

Please sign in to comment.