The transaction monitoring system tracks the status of transactions and updates the UI accordingly. Let's look at the key components:
// src/store/slices/walletSlice.ts
// Thunk for updating wallet UTxOs
// Handles both regular and virtual wallet UTxOs
export const updateWalletUtxosThunk = createAsyncThunk<
St.Utxo[],
unknown,
{
state: RootState;
extra: Services;
}
>("wallet/updateWalletUtxosThunk", async (_: unknown) => {
const utxos = await lucid.wallet.getUtxos();
// virtual wallet stuff
const mostRecentUtxos = pruneAndMostRecentUtxos(utxos);
// yes we currently have 2 virtual utxo systems...
// TODO: make it so we have 1
const mostRecentUtxos2 =
getLatestUtxosFromPersistedVirtualWalletUtxoMap(mostRecentUtxos);
return mostRecentUtxos2.map(lucidUtxoToUtxo);
});
// src/store/slices/walletSlice.ts
// Prunes and updates UTxO map with most recent UTxOs
// Handles both wallet and virtual UTxO management
export const pruneAndMostRecentUtxos = (utxos: Lucid.UTxO[]) => {
const walletUtxoMap = getWalletUtxoMap();
pruneWalletUtxoMap(walletUtxoMap, utxos);
setWalletUtxoMap(walletUtxoMap);
const [lucidUtxos, serverUtxos] = getMostRecentUtxosFromLucidUtxos(
walletUtxoMap,
utxos
);
return lucidUtxos.concat(serverUtxos.map(serverUtxoToLucid));
};