Bug/1606 wrong update of new added deposit (#1608)

* chore: fix for accounts update

* chore: fix for accounts update

Co-authored-by: maciek <maciek@vegaprotocol.io>
This commit is contained in:
macqbat 2022-10-04 17:57:36 +02:00 committed by GitHub
parent 2031a57b48
commit 15e6c4ffef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 2 deletions

View File

@ -1,6 +1,6 @@
import { AccountType } from '@vegaprotocol/types'; import { AccountType } from '@vegaprotocol/types';
import type { AccountFields, Account } from './accounts-data-provider'; import type { AccountFields, Account } from './accounts-data-provider';
import { getAccountData } from './accounts-data-provider'; import { getAccountData, getId } from './accounts-data-provider';
describe('getAccountData', () => { describe('getAccountData', () => {
it('should return the correct aggregated data', () => { it('should return the correct aggregated data', () => {
@ -9,6 +9,41 @@ describe('getAccountData', () => {
}); });
}); });
describe('getId', () => {
it('should return the correct string', () => {
expect(
getId({
type: AccountType.ACCOUNT_TYPE_GENERAL,
balance: '1',
asset: { id: 'assetId' },
market: null,
})
).toEqual(
getId({
type: AccountType.ACCOUNT_TYPE_GENERAL,
balance: '1',
assetId: 'assetId',
marketId: '',
})
);
expect(
getId({
type: AccountType.ACCOUNT_TYPE_GENERAL,
balance: '1',
asset: { id: 'assetId' },
market: { id: 'testId' },
})
).toEqual(
getId({
type: AccountType.ACCOUNT_TYPE_GENERAL,
balance: '1',
assetId: 'assetId',
marketId: 'testId',
})
);
});
});
const accounts = [ const accounts = [
{ {
__typename: 'Account', __typename: 'Account',

View File

@ -37,7 +37,7 @@ export const getId = (
) => ) =>
isAccount(account) isAccount(account)
? `${account.type}-${account.asset.id}-${account.market?.id ?? 'null'}` ? `${account.type}-${account.asset.id}-${account.market?.id ?? 'null'}`
: `${account.type}-${account.assetId}-${account.marketId}`; : `${account.type}-${account.assetId}-${account.marketId || 'null'}`;
export type Account = Omit<AccountFieldsFragment, 'market' | 'asset'> & { export type Account = Omit<AccountFieldsFragment, 'market' | 'asset'> & {
market?: Market | null; market?: Market | null;