-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds latest block fetched logic and store for noves
- Loading branch information
1 parent
d5b595e
commit 8eb7be8
Showing
3 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './latest-block-persisted-for-noves-transactions.store' | ||
export * from './transactions.store' |
47 changes: 47 additions & 0 deletions
47
...d/src/lib/core/transactions/stores/latest-block-persisted-for-noves-transactions.store.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { NetworkId } from '@core/network' | ||
import { get, writable } from 'svelte/store' | ||
|
||
type LatestBlockPersistedForAccountNetwork = { | ||
[profileId: string]: { | ||
[accountId: number]: { | ||
[networkId in NetworkId]?: { | ||
latestBlock?: number | ||
} | ||
} | ||
} | ||
} | ||
|
||
export const latestBlockPersistedForNovesTransactions = writable<LatestBlockPersistedForAccountNetwork>({}) | ||
|
||
export function getLatestBlockForPersistedNovesTransactionsForAccountNetwork( | ||
profileId: string, | ||
accountId: number, | ||
networkId: NetworkId | ||
): number | undefined { | ||
return get(latestBlockPersistedForNovesTransactions)[profileId]?.[accountId]?.[networkId]?.latestBlock | ||
} | ||
|
||
export function updateLatestBlockForPersistedNovesTransactionsForAccountNetwork( | ||
profileId: string, | ||
accountId: number, | ||
networkId: NetworkId, | ||
latestBlock: number | ||
): void { | ||
latestBlockPersistedForNovesTransactions.update((state) => { | ||
if (!state[profileId]) { | ||
state[profileId] = {} | ||
} | ||
|
||
if (!state[profileId][accountId]) { | ||
state[profileId][accountId] = {} | ||
} | ||
|
||
if (!state[profileId][accountId][networkId]) { | ||
state[profileId][accountId][networkId] = {} | ||
} | ||
|
||
state[profileId][accountId][networkId].latestBlock = latestBlock | ||
|
||
return state | ||
}) | ||
} |