Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/managers/OngoingProcessManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export type OngoingProcessObjectData = {
walletName?: string;
count?: number;
iteration?: number;
chainIteration?: number;
};

export type OngoingProcessData = number | OngoingProcessObjectData | undefined;
Expand All @@ -99,6 +100,9 @@ const getWalletName = (data?: OngoingProcessData): string | undefined =>
const getIteration = (data?: OngoingProcessData): number =>
typeof data === 'object' && data !== null ? data.iteration ?? 1 : 1;

const getChainIteration = (data?: OngoingProcessData): number =>
typeof data === 'object' && data !== null ? data.chainIteration ?? 1 : 1;

const getCount = (data?: OngoingProcessData): number =>
typeof data === 'object' && data !== null
? data.count ?? 0
Expand Down Expand Up @@ -177,7 +181,9 @@ const translations: Record<
}),
findingCopayers: data =>
getIteration(data) > 1
? i18n.t('Checking for additional wallets...')
? i18n.t('Checking for additional wallets (account {{account}})...', {
account: getIteration(data) - 1,
})
: i18n.t('Searching for your wallets...'),
foundCopayers: data => {
const iteration = getIteration(data);
Expand Down Expand Up @@ -213,7 +219,13 @@ const translations: Record<
},
'walletInfo.gatheringTokens': data => {
const chain = getChain(data);
return i18n.t('Loading {{chain}} tokens...', {chain});
const chainIteration = getChainIteration(data);
return chainIteration > 1
? i18n.t('Loading {{chain}} tokens (account {{chainIteration}})...', {
chain,
chainIteration,
})
: i18n.t('Loading {{chain}} tokens...', {chain});
},
'walletInfo.gatheringTokens.error': () =>
i18n.t('Some tokens could not be loaded, continuing...'),
Expand Down
4 changes: 2 additions & 2 deletions src/store/transforms/transforms.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,13 +516,13 @@ describe('transformPortfolioSnapshotSeries', () => {
it('inbound: skips wallet entry when snaps array is empty', () => {
const state: any = {snapshotsByWalletId: {w1: []}};
const result = getInbound()(state);
expect(result.snapshotsByWalletId['w1']).toBeUndefined();
expect(result.snapshotsByWalletId.w1).toBeUndefined();
});

it('inbound: skips wallet entry when value is not array', () => {
const state: any = {snapshotsByWalletId: {w1: 'not-an-array'}};
const result = getInbound()(state);
expect(result.snapshotsByWalletId['w1']).toBeUndefined();
expect(result.snapshotsByWalletId.w1).toBeUndefined();
});

it('inbound: packs snapshots into series', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/store/wallet/wallet.reducer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ describe('SUCCESS_UPDATE_KEYS_TOTAL_BALANCE', () => {
type: WalletActionTypes.SUCCESS_UPDATE_KEYS_TOTAL_BALANCE,
payload: [{keyId: 'ghost', totalBalance: 100, totalBalanceLastDay: 100}],
});
expect(state.keys['ghost']).toBeUndefined();
expect(state.keys.ghost).toBeUndefined();
});
});

Expand Down
32 changes: 16 additions & 16 deletions src/utils/portfolio/assets.pure.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,8 @@ describe('buildWalletIdsByAssetGroupKey', () => {
makeWallet('w3', 'livenet', 'eth'),
];
const result = buildWalletIdsByAssetGroupKey(wallets);
expect(result['btc']).toEqual(['w1', 'w2']);
expect(result['eth']).toEqual(['w3']);
expect(result.btc).toEqual(['w1', 'w2']);
expect(result.eth).toEqual(['w3']);
});

it('skips wallets that are not on mainnet (livenet)', () => {
Expand All @@ -532,7 +532,7 @@ describe('buildWalletIdsByAssetGroupKey', () => {
makeWallet('w2', 'livenet', 'btc'),
];
const result = buildWalletIdsByAssetGroupKey(wallets);
expect(result['btc']).toEqual(['w2']);
expect(result.btc).toEqual(['w2']);
});

it('skips wallets with no id', () => {
Expand All @@ -541,7 +541,7 @@ describe('buildWalletIdsByAssetGroupKey', () => {
makeWallet('w2', 'livenet', 'btc'),
];
const result = buildWalletIdsByAssetGroupKey(wallets);
expect(result['btc']).toEqual(['w2']);
expect(result.btc).toEqual(['w2']);
});

it('skips wallets with no currencyAbbreviation', () => {
Expand All @@ -550,7 +550,7 @@ describe('buildWalletIdsByAssetGroupKey', () => {
makeWallet('w2', 'livenet', 'eth'),
];
const result = buildWalletIdsByAssetGroupKey(wallets);
expect(result['eth']).toEqual(['w2']);
expect(result.eth).toEqual(['w2']);
expect(result['']).toBeUndefined();
});
});
Expand Down Expand Up @@ -1128,7 +1128,7 @@ describe('getPopulateLoadingByAssetKey', () => {
} as any,
});
expect(result).not.toBeUndefined();
expect(result!['btc']).toBe(false);
expect(result!.btc).toBe(false);
});

it('returns map with true for assets with in_progress wallets', () => {
Expand All @@ -1142,7 +1142,7 @@ describe('getPopulateLoadingByAssetKey', () => {
currentWalletId: undefined,
} as any,
});
expect(result!['btc']).toBe(true);
expect(result!.btc).toBe(true);
});

it('uses prev value when no wallets are in scope for an asset key', () => {
Expand All @@ -1158,7 +1158,7 @@ describe('getPopulateLoadingByAssetKey', () => {
prev: {eth: true},
});
// w2 is not in scope (not in statusById, not currentWalletId) → use prev
expect(result!['eth']).toBe(true);
expect(result!.eth).toBe(true);
});

it('preserves prev keys that are not in items', () => {
Expand All @@ -1174,8 +1174,8 @@ describe('getPopulateLoadingByAssetKey', () => {
prev: {eth: true, btc: false},
});
// eth was in prev but not in items → it should be copied over
expect(result!['eth']).toBe(true);
expect(result!['btc']).toBe(false);
expect(result!.eth).toBe(true);
expect(result!.btc).toBe(false);
});

it('returns false for asset with error status (counts as finished)', () => {
Expand All @@ -1189,7 +1189,7 @@ describe('getPopulateLoadingByAssetKey', () => {
currentWalletId: undefined,
} as any,
});
expect(result!['btc']).toBe(false);
expect(result!.btc).toBe(false);
});

it('returns true for asset in fullPopulate mode (wallets total matches)', () => {
Expand All @@ -1205,7 +1205,7 @@ describe('getPopulateLoadingByAssetKey', () => {
currentWalletId: undefined,
} as any,
});
expect(result!['btc']).toBe(true);
expect(result!.btc).toBe(true);
});

it('returns prev reference when next is identical to prev (same keys and values)', () => {
Expand Down Expand Up @@ -1240,7 +1240,7 @@ describe('getPopulateLoadingByAssetKey', () => {
});
// w1 is currentWalletId but not in statusById → statusById[w1] = undefined
// undefined !== 'done' && undefined !== 'error' → allFinished=false → loading=true
expect(result!['btc']).toBe(true);
expect(result!.btc).toBe(true);
});
});

Expand Down Expand Up @@ -1434,8 +1434,8 @@ describe('getWalletIdsToPopulateFromSnapshots', () => {
},
});
expect(result.walletIdsToPopulate).toContain('w1');
expect(result.snapshotBalanceMismatchUpdates['w1']).toBeDefined();
expect(result.snapshotBalanceMismatchUpdates['w1']?.walletId).toBe('w1');
expect(result.snapshotBalanceMismatchUpdates.w1).toBeDefined();
expect(result.snapshotBalanceMismatchUpdates.w1?.walletId).toBe('w1');
});

it('does not add to populate list when mismatch unchanged from previous', () => {
Expand Down Expand Up @@ -1478,7 +1478,7 @@ describe('getWalletIdsToPopulateFromSnapshots', () => {
});
expect(result.walletIdsToPopulate).not.toContain('w1');
expect('w1' in result.snapshotBalanceMismatchUpdates).toBe(true);
expect(result.snapshotBalanceMismatchUpdates['w1']).toBeUndefined();
expect(result.snapshotBalanceMismatchUpdates.w1).toBeUndefined();
});

it('skips wallet with no id', () => {
Expand Down
12 changes: 6 additions & 6 deletions src/utils/portfolio/core/pnl/analysis.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,8 @@ describe('buildPnlAnalysisSeries — two BTC wallets', () => {

it('byWalletId has entries for both wallets', () => {
const pt = result.points[0];
expect(pt.byWalletId['w1']).toBeDefined();
expect(pt.byWalletId['w2']).toBeDefined();
expect(pt.byWalletId.w1).toBeDefined();
expect(pt.byWalletId.w2).toBeDefined();
});

it('totalCryptoBalanceAtomic sums both wallets (singleAsset=true)', () => {
Expand Down Expand Up @@ -1003,25 +1003,25 @@ describe('buildPnlAnalysisSeries — per-wallet pnlPercent', () => {

it('per-wallet pnlPercent at last point is ~50% (rate went from 10k to 15k)', () => {
const last = result.points[result.points.length - 1];
const walletPoint = last.byWalletId['w1'];
const walletPoint = last.byWalletId.w1;
expect(walletPoint.pnlPercent).toBeCloseTo(50, 0);
});

it('per-wallet ratePercentChange at last point is ~50%', () => {
const last = result.points[result.points.length - 1];
const walletPoint = last.byWalletId['w1'];
const walletPoint = last.byWalletId.w1;
expect(walletPoint.ratePercentChange).toBeCloseTo(50, 0);
});

it('per-wallet balanceAtomic equals the snapshot balance', () => {
const last = result.points[result.points.length - 1];
const walletPoint = last.byWalletId['w1'];
const walletPoint = last.byWalletId.w1;
expect(walletPoint.balanceAtomic).toBe('100000000');
});

it('per-wallet markRate is the current rate at that point', () => {
const last = result.points[result.points.length - 1];
const walletPoint = last.byWalletId['w1'];
const walletPoint = last.byWalletId.w1;
expect(walletPoint.markRate).toBeCloseTo(endRate, 0);
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jest.mock('react-native/Libraries/Utilities/Platform', () => {
isPad: false,
isTV: false,
isTesting: true,
select: spec => spec['android'] ?? null,
select: spec => spec.android ?? null,
};
return {...Platform, default: Platform};
});
Expand Down
Loading