diff --git a/src/mappings/marketplace/events/auction_finalized.ts b/src/mappings/marketplace/events/auction_finalized.ts
index 243888a6..a7b1faf0 100644
--- a/src/mappings/marketplace/events/auction_finalized.ts
+++ b/src/mappings/marketplace/events/auction_finalized.ts
@@ -130,7 +130,6 @@ export async function auctionFinalized(
amount: listing.amount.toString(),
price: listing.price.toString(),
data: listing.data.toJSON(),
- tokenId: listing.makeAssetId.id,
},
winningBid: data.winningBid
? {
@@ -142,6 +141,7 @@ export async function auctionFinalized(
: null,
protocolFee: data.protocolFee,
royalty: data.royalty,
+ token: listing.makeAssetId.id,
extrinsic: item.extrinsic.id,
},
})
diff --git a/src/mappings/marketplace/events/bid_placed.ts b/src/mappings/marketplace/events/bid_placed.ts
index 30263e99..ec33eeae 100644
--- a/src/mappings/marketplace/events/bid_placed.ts
+++ b/src/mappings/marketplace/events/bid_placed.ts
@@ -128,7 +128,6 @@ export async function bidPlaced(
amount: listing.amount.toString(),
price: listing.price.toString(),
data: listing.data.toJSON(),
- tokenId: listing.makeAssetId.id,
},
lastBid: lastBid
? {
@@ -146,6 +145,7 @@ export async function bidPlaced(
id: bid.bidder.id,
},
},
+ token: listing.makeAssetId.id,
extrinsic: item.extrinsic.id,
},
})
diff --git a/src/mappings/marketplace/events/counter_offer_answered.ts b/src/mappings/marketplace/events/counter_offer_answered.ts
index f1632fdc..e824b07e 100644
--- a/src/mappings/marketplace/events/counter_offer_answered.ts
+++ b/src/mappings/marketplace/events/counter_offer_answered.ts
@@ -90,6 +90,7 @@ export async function counterOfferAnswered(
const listing = await ctx.store.findOneOrFail(Listing, {
where: { id: listingId },
relations: {
+ seller: true,
takeAssetId: {
collection: true,
bestListing: true,
@@ -113,11 +114,23 @@ export async function counterOfferAnswered(
id: item.id,
name: item.name,
body: {
+ listing: {
+ id: listing.id,
+ price: listing.price.toString(),
+ amount: listing.amount.toString(),
+ highestPrice: listing.highestPrice.toString(),
+ seller: {
+ id: listing.seller.id,
+ },
+ data: listing.data.toJSON(),
+ state: listing.state.toJSON(),
+ type: listing.type.toString(),
+ takeAssetId: listing.takeAssetId.id,
+ },
response: data.response.__kind,
- account: account.id,
- listing: listing.id,
+ account: { id: account.id },
extrinsic: item.extrinsic.id,
- tokenId: listing.takeAssetId.id,
+ token: listing.takeAssetId.id,
},
})
}
diff --git a/src/mappings/marketplace/events/counter_offer_placed.ts b/src/mappings/marketplace/events/counter_offer_placed.ts
index bfab57bd..30d38435 100644
--- a/src/mappings/marketplace/events/counter_offer_placed.ts
+++ b/src/mappings/marketplace/events/counter_offer_placed.ts
@@ -75,6 +75,7 @@ export async function counterOfferPlaced(
const listing = await ctx.store.findOneOrFail
(Listing, {
where: { id: listingId },
relations: {
+ seller: true,
takeAssetId: {
collection: true,
bestListing: true,
@@ -112,13 +113,25 @@ export async function counterOfferPlaced(
id: item.id,
name: item.name,
body: {
+ listing: {
+ id: listing.id,
+ price: listing.price.toString(),
+ amount: listing.amount.toString(),
+ highestPrice: listing.highestPrice.toString(),
+ seller: {
+ id: listing.seller.id,
+ },
+ data: listing.data.toJSON(),
+ state: listing.state.toJSON(),
+ type: listing.type.toString(),
+ takeAssetId: listing.takeAssetId.id,
+ },
buyerPrice: buyerPrice?.toString(),
amount: depositAmount.toString(),
sellerPrice: sellerPrice.toString(),
- account: account.id,
- listing: listing.id,
+ account: { id: account.id },
extrinsic: item.extrinsic.id,
- tokenId: listing.takeAssetId.id,
+ token: listing.takeAssetId.id,
},
})
}
diff --git a/src/mappings/marketplace/events/counter_offer_removed.ts b/src/mappings/marketplace/events/counter_offer_removed.ts
index aef9ba6f..9ee98d86 100644
--- a/src/mappings/marketplace/events/counter_offer_removed.ts
+++ b/src/mappings/marketplace/events/counter_offer_removed.ts
@@ -64,6 +64,7 @@ export async function counterOfferRemoved(
const listing = await ctx.store.findOneOrFail(Listing, {
where: { id: listingId },
relations: {
+ seller: true,
takeAssetId: {
collection: true,
bestListing: true,
@@ -87,10 +88,22 @@ export async function counterOfferRemoved(
id: item.id,
name: item.name,
body: {
- account: account.id,
- listing: listing.id,
+ listing: {
+ id: listing.id,
+ price: listing.price.toString(),
+ amount: listing.amount.toString(),
+ highestPrice: listing.highestPrice.toString(),
+ seller: {
+ id: listing.seller.id,
+ },
+ data: listing.data.toJSON(),
+ state: listing.state.toJSON(),
+ type: listing.type.toString(),
+ takeAssetId: listing.takeAssetId.id,
+ },
+ account: { id: account.id },
extrinsic: item.extrinsic.id,
- tokenId: listing.takeAssetId.id,
+ token: listing.takeAssetId.id,
},
})
}
diff --git a/src/mappings/marketplace/events/listing_cancelled.ts b/src/mappings/marketplace/events/listing_cancelled.ts
index 84b98357..ece4261d 100644
--- a/src/mappings/marketplace/events/listing_cancelled.ts
+++ b/src/mappings/marketplace/events/listing_cancelled.ts
@@ -7,6 +7,7 @@ import {
Listing,
ListingStatus,
ListingStatusType,
+ ListingType,
MarketplaceListingCancelled,
} from '../../../model'
import { CommonContext, BlockHeader, EventItem } from '../../types/contexts'
@@ -27,8 +28,8 @@ function getEvent(item: EventItem, listing: Listing): [EventModel, AccountTokenE
id: item.id,
name: MarketplaceListingCancelled.name,
extrinsic: item.extrinsic?.id ? new Extrinsic({ id: item.extrinsic.id }) : null,
- collectionId: listing.makeAssetId.collection.id,
- tokenId: listing.makeAssetId.id,
+ collectionId: listing.type === ListingType.Offer ? listing.takeAssetId.collection.id : listing.makeAssetId.collection.id,
+ tokenId: listing.type === ListingType.Offer ? listing.takeAssetId.id : listing.makeAssetId.id,
data: new MarketplaceListingCancelled({
listing: listing.id,
}),
@@ -38,7 +39,7 @@ function getEvent(item: EventItem, listing: Listing): [EventModel, AccountTokenE
event,
new AccountTokenEvent({
id: item.id,
- token: listing.makeAssetId,
+ token: listing.type === ListingType.Offer ? listing.takeAssetId : listing.makeAssetId,
from: listing.seller,
event,
}),
@@ -62,6 +63,9 @@ export async function listingCancelled(
collection: true,
bestListing: true,
},
+ takeAssetId: {
+ collection: true,
+ },
},
})
@@ -80,7 +84,7 @@ export async function listingCancelled(
await Promise.all([ctx.store.insert(listingStatus), ctx.store.save(listing)])
- if (listing.makeAssetId.bestListing?.id === listing.id) {
+ if (listing.makeAssetId.bestListing?.id === listing.id && listing.type !== ListingType.Offer) {
const bestListing = await getBestListing(ctx, listing.makeAssetId.id)
listing.makeAssetId.bestListing = null
if (bestListing) {
@@ -104,10 +108,11 @@ export async function listingCancelled(
seller: {
id: listing.seller.id,
},
+ type: listing.type.toString(),
data: listing.data.toJSON(),
state: listing.state.toJSON(),
- tokenId: listing.makeAssetId.id,
},
+ token: listing.type === ListingType.Offer ? listing.takeAssetId.id : listing.makeAssetId.id,
extrinsic: item.extrinsic.id,
},
})
diff --git a/src/mappings/marketplace/events/listing_created.ts b/src/mappings/marketplace/events/listing_created.ts
index abf1e68e..566fd967 100644
--- a/src/mappings/marketplace/events/listing_created.ts
+++ b/src/mappings/marketplace/events/listing_created.ts
@@ -196,6 +196,7 @@ export async function listingCreated(
makeAssetId: makeAssetId.id,
takeAssetId: takeAssetId.id,
},
+ token: listing.type === ListingType.Offer ? listing.takeAssetId.id : listing.makeAssetId.id,
extrinsic: item.extrinsic.id,
},
})
diff --git a/src/mappings/marketplace/events/listing_filled.ts b/src/mappings/marketplace/events/listing_filled.ts
index c38c5814..0421ac07 100644
--- a/src/mappings/marketplace/events/listing_filled.ts
+++ b/src/mappings/marketplace/events/listing_filled.ts
@@ -36,11 +36,11 @@ function getEvent(
listing: Listing
): [EventModel, AccountTokenEvent] | undefined {
let collectionId = listing.makeAssetId.collection.id
- let tokenId = listing.makeAssetId.id
+ let token = listing.makeAssetId
if (listing.data.listingType === ListingType.Offer) {
collectionId = listing.takeAssetId.collection.id
- tokenId = listing.takeAssetId.id
+ token = listing.takeAssetId
}
const event = new EventModel({
@@ -48,7 +48,7 @@ function getEvent(
name: MarketplaceListingFilled.name,
extrinsic: item.extrinsic?.id ? new Extrinsic({ id: item.extrinsic.id }) : null,
collectionId,
- tokenId,
+ tokenId: token.id,
data: new MarketplaceListingFilled({
listing: listing.id,
buyer: data.buyer,
@@ -63,7 +63,7 @@ function getEvent(
event,
new AccountTokenEvent({
id: item.id,
- token: listing.makeAssetId,
+ token,
from: listing.seller,
to: new Account({ id: data.buyer }),
event,
@@ -155,10 +155,11 @@ export async function listingFilled(
seller: {
id: listing.seller.id,
},
+ type: listing.type.toString(),
data: listing.data.toJSON(),
state: listing.state.toJSON(),
- tokenId: listing.makeAssetId.id,
},
+ token: listing.type === ListingType.Offer ? listing.takeAssetId.id : listing.makeAssetId.id,
buyer: { id: data.buyer },
amountFilled: data.amountFilled,
amountRemaining: data.amountRemaining,
diff --git a/src/mappings/multiTokens/events/approved.ts b/src/mappings/multiTokens/events/approved.ts
index fa18a42c..ebaea2fa 100644
--- a/src/mappings/multiTokens/events/approved.ts
+++ b/src/mappings/multiTokens/events/approved.ts
@@ -106,7 +106,8 @@ export async function approved(
address,
operator: data.operator,
collectionId: data.collectionId.toString(),
- tokenId: data.tokenId ? `${data.collectionId}-${data.tokenId}` : null,
+ tokenId: data.tokenId ?? null,
+ token: data.tokenId ? `${data.collectionId}-${data.tokenId}` : null,
extrinsic: item.extrinsic.id,
},
})
diff --git a/src/mappings/multiTokens/events/frozen.ts b/src/mappings/multiTokens/events/frozen.ts
index c126113b..e40f5449 100644
--- a/src/mappings/multiTokens/events/frozen.ts
+++ b/src/mappings/multiTokens/events/frozen.ts
@@ -166,7 +166,8 @@ export async function frozen(
kind: data.freezeType,
address: data.collectionAccount ?? data.tokenAccount,
collectionId: data.collectionId.toString(),
- tokenId: data.tokenId ? `${data.collectionId}-${data.tokenId}` : null,
+ tokenId: data.tokenId ?? null,
+ token: data.tokenId ? `${data.collectionId}-${data.tokenId}` : null,
extrinsic: item.extrinsic.id,
},
})
diff --git a/src/mappings/multiTokens/events/infused.ts b/src/mappings/multiTokens/events/infused.ts
index cc7f8e22..2d5c2714 100644
--- a/src/mappings/multiTokens/events/infused.ts
+++ b/src/mappings/multiTokens/events/infused.ts
@@ -60,6 +60,7 @@ export async function infused(ctx: CommonContext, block: BlockHeader, item: Even
body: {
collectionId: data.collectionId,
tokenId: data.tokenId,
+ token: `${data.collectionId}-${data.tokenId}`,
amount: data.amount,
accountId: data.accountId,
extrinsic: item.extrinsic.id,
diff --git a/src/mappings/multiTokens/events/thawed.ts b/src/mappings/multiTokens/events/thawed.ts
index 1f0061ac..73aee6e7 100644
--- a/src/mappings/multiTokens/events/thawed.ts
+++ b/src/mappings/multiTokens/events/thawed.ts
@@ -147,7 +147,8 @@ export async function thawed(
kind: data.freezeType,
address: data.collectionAccount ?? data.tokenAccount,
collectionId: data.collectionId.toString(),
- tokenId: data.tokenId ? `${data.collectionId}-${data.tokenId}` : null,
+ tokenId: data.tokenId ?? null,
+ token: data.tokenId ? `${data.collectionId}-${data.tokenId}` : null,
extrinsic: item.extrinsic.id,
},
})
diff --git a/src/mappings/multiTokens/events/token_destroyed.ts b/src/mappings/multiTokens/events/token_destroyed.ts
index 11fd681f..7050ee15 100644
--- a/src/mappings/multiTokens/events/token_destroyed.ts
+++ b/src/mappings/multiTokens/events/token_destroyed.ts
@@ -178,6 +178,7 @@ export async function tokenDestroyed(
body: {
collectionId: data.collectionId,
tokenId: data.tokenId,
+ token: `${data.collectionId}-${data.tokenId}`,
caller: data.caller,
extrinsic: item.extrinsic.id,
},
diff --git a/src/mappings/multiTokens/events/unapproved.ts b/src/mappings/multiTokens/events/unapproved.ts
index d7ce8228..aa328979 100644
--- a/src/mappings/multiTokens/events/unapproved.ts
+++ b/src/mappings/multiTokens/events/unapproved.ts
@@ -80,7 +80,8 @@ export async function unapproved(
address,
operator: data.operator,
collectionId: data.collectionId.toString(),
- tokenId: data.tokenId ? `${data.collectionId}-${data.tokenId}` : null,
+ tokenId: data.tokenId ?? null,
+ token: data.tokenId ? `${data.collectionId}-${data.tokenId}` : null,
extrinsic: item.extrinsic.id,
},
})