Skip to content

Commit

Permalink
fix logic
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-aurele-besner committed Feb 13, 2025
1 parent b5a8c82 commit bb49615
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions indexers/staking/src/mappings/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
OperatorStakingHistory,
OperatorTaxCollection,
RuntimeCreation,
StakedUnlockedEvent,
UnlockedEvent,
WithdrawEvent,
WithdrawalHistory,
} from "../types";
Expand All @@ -32,7 +32,7 @@ export type Cache = {
runtimeCreation: RuntimeCreation[];
withdrawEvent: WithdrawEvent[];
withdrawalHistory: WithdrawalHistory[];
stakedUnlockedEvent: StakedUnlockedEvent[];
unlockedEvent: UnlockedEvent[];
};

export const initializeCache = (): Cache => ({
Expand All @@ -50,7 +50,7 @@ export const initializeCache = (): Cache => ({
runtimeCreation: [],
withdrawEvent: [],
withdrawalHistory: [],
stakedUnlockedEvent: [],
unlockedEvent: [],
});

export const saveCache = async (cache: Cache) => {
Expand All @@ -69,7 +69,7 @@ export const saveCache = async (cache: Cache) => {
store.bulkCreate(`RuntimeCreation`, cache.runtimeCreation),
store.bulkCreate(`WithdrawEvent`, cache.withdrawEvent),
store.bulkCreate(`WithdrawalHistory`, cache.withdrawalHistory),
store.bulkCreate(`StakedUnlockedEvent`, cache.stakedUnlockedEvent),
store.bulkCreate(`UnlockedEvent`, cache.unlockedEvent),
]);
};

Expand Down Expand Up @@ -245,7 +245,7 @@ export function createOperatorTaxCollection(
});
}

export function createStakedUnlockedEvent(
export function createUnlockedEvent(
domainId: string,
operatorId: string,
accountId: string,
Expand All @@ -254,12 +254,13 @@ export function createStakedUnlockedEvent(
blockHeight: bigint,
extrinsicId: string,
eventId: string
): StakedUnlockedEvent {
return StakedUnlockedEvent.create({
): UnlockedEvent {
return UnlockedEvent.create({
id: extrinsicId,
domainId,
operatorId,
accountId,
nominatorId: accountId + "-" + operatorId,
amount,
storageFee,
blockHeight,
Expand Down
4 changes: 2 additions & 2 deletions indexers/staking/src/mappings/eventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ export const EVENT_HANDLERS: Record<string, EventHandler> = {
StorageFeeUnlockedEvent?.event.data[2].toString() ?? 0
);

cache.stakedUnlockedEvent.push(
db.createStakedUnlockedEvent(
cache.unlockedEvent.push(
db.createUnlockedEvent(
domainId,
operatorId,
accountId,
Expand Down

0 comments on commit bb49615

Please sign in to comment.