Skip to content

Commit

Permalink
tail sync fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vsubhuman committed Feb 2, 2024
1 parent 6d7f04a commit 309eadb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ export default class AdaDelegationStore extends Store<StoresMap, ActionsMap> {
publicDeriver: withStakingKey,
rewardBalance: new MultiToken(
[{
amount: new BigNumber(stateForStakingKey == null
? 0
: stateForStakingKey.remainingAmount),
amount: new BigNumber(stateForStakingKey?.remainingAmount ?? 0),
networkId: defaultToken.defaultNetworkId,
identifier: defaultToken.defaultIdentifier,
}],
Expand Down
20 changes: 13 additions & 7 deletions packages/yoroi-extension/app/stores/toplevel/TransactionsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,10 @@ export default class TransactionsStore extends Store<StoresMap, ActionsMap> {
/*
* TAIL REQUEST IS USED WHEN FIRST SYNC OR EMPTY WALLET
*/
result = await this._internalTailRequestForTxs(request.publicDeriver);
result = await this._internalTailRequestForTxs({
publicDeriver: request.publicDeriver,
isLocalRequest: request.isLocalRequest,
});
} else {
/*
* HEAD REQUEST IS USED WITH `AFTER` REFERENCE
Expand All @@ -371,6 +374,7 @@ export default class TransactionsStore extends Store<StoresMap, ActionsMap> {
headRequest.invalidate({ immediately: false });
headRequest.execute({
publicDeriver,
// HEAD request is never local by logic
isLocalRequest: false,
afterTx: txHistoryState.txs[0],
});
Expand Down Expand Up @@ -492,11 +496,13 @@ export default class TransactionsStore extends Store<StoresMap, ActionsMap> {
);
}

_internalTailRequestForTxs: (
PublicDeriver<> & IGetLastSyncInfo,
) => Promise<GetTransactionsResponse> = async (
_internalTailRequestForTxs: ({|
publicDeriver: PublicDeriver<> & IGetLastSyncInfo,
) => {
isLocalRequest?: boolean,
|}) => Promise<GetTransactionsResponse> = async ({
publicDeriver,
isLocalRequest = false,
}) => {
const withLevels = asHasLevels<ConceptualWallet, IGetLastSyncInfo>(publicDeriver);
if (withLevels == null) {
throw new Error(`${nameof(this._loadMore)} no levels`);
Expand All @@ -509,7 +515,7 @@ export default class TransactionsStore extends Store<StoresMap, ActionsMap> {
tailRequest.invalidate({ immediately: false });
tailRequest.execute({
publicDeriver: withLevels,
isLocalRequest: false,
isLocalRequest,
beforeTx,
});
if (!tailRequest.promise) throw new Error('unexpected nullish tailRequest.promise');
Expand All @@ -526,7 +532,7 @@ export default class TransactionsStore extends Store<StoresMap, ActionsMap> {
) => Promise<void> = async (
publicDeriver: PublicDeriver<> & IGetLastSyncInfo,
) => {
const result = await this._internalTailRequestForTxs(publicDeriver);
const result = await this._internalTailRequestForTxs({ publicDeriver });
await this._afterLoadingNewTxs(result, publicDeriver);
}

Expand Down

0 comments on commit 309eadb

Please sign in to comment.