Skip to content

Commit

Permalink
Fix an issue with missing base assets (#4284)
Browse files Browse the repository at this point in the history
* Fix an issue with missing base assets

* Add test case for bug
  • Loading branch information
FrederikBolding authored Feb 17, 2022
1 parent 144b8aa commit e708bf0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/services/Store/store/asset.slice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,28 @@ describe('fetchAssetsWorker()', () => {
.put(addAssetsFromAPI(expected))
.silentRun();
});

it('keeps base assets around', () => {
const a1 = fAssets[10];
const a2 = fAssets[11];
const a3 = fAssets[2];
const a4 = fAssets[0];
const state = [a1, a2, a3, a4];
const modifiedEntities = [{ ...a2, contractAddress: '0xchanged1' }];
const expected = [a1, a3, a4, modifiedEntities[0]];
const apiResult = arrayToObj('uuid')(modifiedEntities);
return expectSaga(fetchAssetsWorker)
.withState(
mockAppState({
assets: state,
accounts: fAccounts,
addressBook: fContacts,
networks: fNetworks
})
)
.provide([[call.fn(MyCryptoApiService.instance.getAssets), apiResult]])
.call(MyCryptoApiService.instance.getAssets)
.put(addAssetsFromAPI(expected))
.silentRun();
});
});
4 changes: 3 additions & 1 deletion src/services/Store/store/asset.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ export function* fetchAssetsWorker() {
const currentAssets = arrayToObj('uuid')(
lsAssets.filter(
(a) =>
(a.isCustom ?? a.type === 'base') ||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
a.isCustom ||
a.type === 'base' ||
accountAssets.some((accAsset) => accAsset.uuid === a.uuid && accAsset.balance.gt(0))
)
);
Expand Down

0 comments on commit e708bf0

Please sign in to comment.