Skip to content
Merged
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
21 changes: 20 additions & 1 deletion src/mappings/indexer.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,26 @@ This function is used to call handlers in order to avoid updating the same entit
for messages it is the path of the decodedMsg to get the entity id
for events it is a function that receives the attributes and returns the entity id
*/
async function indexStakeEntity(data: Array<CosmosEvent | CosmosMessage>, getEntityIdArg: RecordGetId) {
async function indexStakeEntity(allData: Array<CosmosEvent | CosmosMessage>, getEntityIdArg: RecordGetId) {
const allEvents: Array<CosmosEvent> = [], allMsgs: Array<CosmosMessage> = [];

for (const datum of allData) {
if ('event' in datum) {
allEvents.push(datum)
} else {
allMsgs.push(datum)
}
}

const {success: successfulEvents} = filterEventsByTxStatus(allEvents)

const {success: successfulMsgs} = filterMsgByTxStatus(allMsgs)

const data = [
...successfulEvents,
...successfulMsgs,
]

// this is to handle events where more than one stake entity is updated
// like in _handleTransferApplicationEndEvent handler
const entitiesUpdatedAtSameDatum: Array<Array<string>> = [];
Expand Down
9 changes: 5 additions & 4 deletions src/mappings/pocket/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,16 @@ function _handleMsgClaimMorseAccount(

export async function updateMorseClaimableAccounts(
items: Array<{
publicKey: Uint8Array
publicKey?: Uint8Array
morseAddress?: string
destinationAddress: string
}>,
): Promise<void> {
const MorseClaimableAccountModel = getStoreModel("MorseClaimableAccount");
const blockHeight = store.context.getHistoricalUnit();

await Promise.all(
items.map(({ destinationAddress, publicKey }) => MorseClaimableAccountModel.model.update(
items.map(({ destinationAddress, morseAddress, publicKey }) => MorseClaimableAccountModel.model.update(
// mark as claimed
{
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand All @@ -85,9 +86,9 @@ export async function updateMorseClaimableAccounts(
{
hooks: false,
where: {
id: pubKeyToAddress(
id: morseAddress ? morseAddress : pubKeyToAddress(
Ed25519,
publicKey,
publicKey!,
undefined,
true
)
Expand Down
2 changes: 1 addition & 1 deletion src/mappings/pocket/suppliers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ export async function handleMsgClaimMorseSupplier(
...messages.map(_handleMsgClaimMorseSupplier),
updateMorseClaimableAccounts(
messages.map((msg) => ({
publicKey: msg.msg.decodedMsg.morsePublicKey,
morseAddress: msg.msg.decodedMsg.morseNodeAddress,
destinationAddress: msg.msg.decodedMsg.shannonOperatorAddress,
}))
)
Expand Down
Loading