Skip to content

Commit

Permalink
feat: IDXR-54 Add SNS event to approved and unapproved (#1254)
Browse files Browse the repository at this point in the history
add SNS event to approved and unapproved
  • Loading branch information
justraman authored Aug 23, 2024
1 parent 0c37339 commit 7b4ae3b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/mappings/multiTokens/events/approved.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Extrinsic,
} from '../../../model'
import { encodeId } from '../../../common/tools'
import { Sns } from '../../../common/sns'
import { events } from '../../../types/generated'
import { CommonContext, BlockHeader, EventItem } from '../../types/contexts'

Expand Down Expand Up @@ -96,5 +97,17 @@ export async function approved(
await ctx.store.save(collectionAccount)
}

if (item.extrinsic) {
await Sns.getInstance().send({
id: item.id,
name: item.name,
body: {
collectionId: data.collectionId.toString(),
tokenId: data.tokenId ? `${data.collectionId}-${data.tokenId}` : null,
extrinsic: item.extrinsic.id,
},
})
}

return getEvent(item, data)
}
13 changes: 13 additions & 0 deletions src/mappings/multiTokens/events/unapproved.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { UnknownVersionError, throwError } from '../../../common/errors'
import { events } from '../../../types/generated'
import { CollectionAccount, Event as EventModel, Extrinsic, MultiTokensUnapproved, TokenAccount } from '../../../model'
import { encodeId } from '../../../common/tools'
import { Sns } from '../../../common/sns'
import { CommonContext, BlockHeader, EventItem } from '../../types/contexts'

function getEventData(event: EventItem) {
Expand Down Expand Up @@ -70,5 +71,17 @@ export async function unapproved(
}
}

if (item.extrinsic) {
await Sns.getInstance().send({
id: item.id,
name: item.name,
body: {
collectionId: data.collectionId.toString(),
tokenId: data.tokenId ? `${data.collectionId}-${data.tokenId}` : null,
extrinsic: item.extrinsic.id,
},
})
}

return getEvent(item, data)
}

0 comments on commit 7b4ae3b

Please sign in to comment.