Skip to content

Commit

Permalink
add sns for transfers
Browse files Browse the repository at this point in the history
  • Loading branch information
justraman committed Oct 12, 2023
1 parent aeb4cf6 commit 582c7bb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/mappings/balances/events/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BalancesTransferEvent } from '../../../types/generated/events'
import { BalancesTransfer, Event as EventModel, Extrinsic } from '../../../model'
import { Event } from '../../../types/generated/support'
import { CommonContext } from '../../types/contexts'
import { Sns } from '../../../common/sns'

interface EventData {
from: Uint8Array
Expand All @@ -32,6 +33,19 @@ export async function transfer(
const eventData = getEventData(ctx, item.event)
if (!eventData) return undefined

if (item.event.extrinsic) {
await Sns.getInstance().send({
id: item.event.id,
name: item.event.name,
body: {
from: u8aToHex(eventData.from),
to: u8aToHex(eventData.to),
amount: eventData.amount,
extrinsic: item.event.extrinsic.id,
},
})
}

return new EventModel({
id: item.event.id,
extrinsic: item.event.extrinsic?.id ? new Extrinsic({ id: item.event.extrinsic.id }) : null,
Expand Down

0 comments on commit 582c7bb

Please sign in to comment.