diff --git a/indexer/db/migrations/1707926335271-Data.js b/indexer/db/migrations/1707926335271-Data.js new file mode 100644 index 0000000..656c25e --- /dev/null +++ b/indexer/db/migrations/1707926335271-Data.js @@ -0,0 +1,11 @@ +module.exports = class Data1707926335271 { + name = 'Data1707926335271' + + async up(db) { + await db.query(`ALTER TABLE "nft" ADD "minted_by" text NOT NULL`) + } + + async down(db) { + await db.query(`ALTER TABLE "nft" DROP COLUMN "minted_by"`) + } +} diff --git a/indexer/schema.graphql b/indexer/schema.graphql index 5ac9573..5ebd5ec 100644 --- a/indexer/schema.graphql +++ b/indexer/schema.graphql @@ -76,6 +76,7 @@ type Nft @entity { id: ID! owner: String! name: String! + mintedBy: String! description: String! idInCollection: Int! collection: Collection! diff --git a/indexer/src/main.ts b/indexer/src/main.ts index 5ee3869..f838bd4 100644 --- a/indexer/src/main.ts +++ b/indexer/src/main.ts @@ -10,7 +10,7 @@ import { getLocalStorage } from './processing/storage/local.storage'; import { BatchService } from './processing/batch.service'; // @ts-ignore -BigInt.prototype["toJSON"] = function () { +BigInt.prototype['toJSON'] = function () { return this.toString(); }; diff --git a/indexer/src/model/generated/nft.model.ts b/indexer/src/model/generated/nft.model.ts index 5bd5943..cec4f35 100644 --- a/indexer/src/model/generated/nft.model.ts +++ b/indexer/src/model/generated/nft.model.ts @@ -27,6 +27,9 @@ export class Nft { @Column_('text', { nullable: false }) name!: string; + @Column_('text', { nullable: false }) + mintedBy!: string; + @Column_('text', { nullable: false }) description!: string; diff --git a/indexer/src/processing/events.processing.ts b/indexer/src/processing/events.processing.ts index d6fc71d..02e731d 100644 --- a/indexer/src/processing/events.processing.ts +++ b/indexer/src/processing/events.processing.ts @@ -113,13 +113,21 @@ export class EventsProcessing { if (!parsed || !parsed.ok) { return null; } - console.log(`${blockNumber}-${messageId}: extracting marketplace event ${JSON.stringify(parsed.ok)}`); + console.log( + `${blockNumber}-${messageId}: extracting marketplace event ${JSON.stringify( + parsed.ok, + )}`, + ); const event = getMarketplaceEvent(parsed.ok); if (!event) { console.warn(`${blockNumber}-${messageId}: unknown event type`, parsed); return null; } - console.log(`${blockNumber}-${messageId}: detected event: ${event.type}\n${JSON.stringify(event)}`); + console.log( + `${blockNumber}-${messageId}: detected event: ${ + event.type + }\n${JSON.stringify(event)}`, + ); await this.entitiesService .addEvent({ blockNumber: eventInfo.blockNumber, @@ -173,7 +181,11 @@ export class EventsProcessing { ); return null; } - console.log(`${blockNumber}-${messageId}: extracting nft event ${JSON.stringify(parsed.ok)}`); + console.log( + `${blockNumber}-${messageId}: extracting nft event ${JSON.stringify( + parsed.ok, + )}`, + ); const event = getNftEvent(parsed.ok); if (!event) { console.warn( @@ -182,7 +194,11 @@ export class EventsProcessing { ); return null; } - console.log(`${blockNumber}-${messageId}: detected event: ${event.type}\n${JSON.stringify(event)}`); + console.log( + `${blockNumber}-${messageId}: detected event: ${ + event.type + }\n${JSON.stringify(event)}`, + ); const eventHandler = nftEventsToHandler[event.type]; if (!eventHandler) { console.warn( diff --git a/indexer/src/processing/marketplace/auction-closed.handler.ts b/indexer/src/processing/marketplace/auction-closed.handler.ts index 1f6e710..3805160 100644 --- a/indexer/src/processing/marketplace/auction-closed.handler.ts +++ b/indexer/src/processing/marketplace/auction-closed.handler.ts @@ -47,10 +47,12 @@ export class AuctionClosedHandler implements INftMarketplaceEventHandler { txHash: eventInfo.txHash, }), ); - await storage.setNft(new Nft({ - ...nft, - owner: currentOwner, - })); + await storage.setNft( + new Nft({ + ...nft, + owner: currentOwner, + }), + ); } } } diff --git a/indexer/src/processing/marketplace/bid-added.handler.ts b/indexer/src/processing/marketplace/bid-added.handler.ts index 0f9519f..1ba9db1 100644 --- a/indexer/src/processing/marketplace/bid-added.handler.ts +++ b/indexer/src/processing/marketplace/bid-added.handler.ts @@ -33,10 +33,12 @@ export class BidAddedHandler implements INftMarketplaceEventHandler { ); return; } - await storage.setAuction(new Auction({ - ...auction, - lastPrice: price, - })) + await storage.setAuction( + new Auction({ + ...auction, + lastPrice: price, + }), + ); storage.addBid( new Bid({ id: uuidv4(), diff --git a/indexer/src/processing/marketplace/offer-accepted.handler.ts b/indexer/src/processing/marketplace/offer-accepted.handler.ts index ecec8ec..8be7a77 100644 --- a/indexer/src/processing/marketplace/offer-accepted.handler.ts +++ b/indexer/src/processing/marketplace/offer-accepted.handler.ts @@ -48,9 +48,11 @@ export class OfferAcceptedHandler implements INftMarketplaceEventHandler { txHash: eventInfo.txHash, }), ); - await storage.setNft(new Nft({ - ...nft, - owner: offer.creator, - })); + await storage.setNft( + new Nft({ + ...nft, + owner: offer.creator, + }), + ); } } diff --git a/indexer/src/processing/nft/nft-minted.handler.ts b/indexer/src/processing/nft/nft-minted.handler.ts index 6d796a2..6570cfa 100644 --- a/indexer/src/processing/nft/nft-minted.handler.ts +++ b/indexer/src/processing/nft/nft-minted.handler.ts @@ -28,6 +28,7 @@ export class NftMintedHandler implements INftEventHandler { mediaUrl, name, owner, + mintedBy: owner, metadata: JSON.stringify(metadata), onSale: false, createdAt: timestamp, diff --git a/indexer/src/processing/nft/transferred.handler.ts b/indexer/src/processing/nft/transferred.handler.ts index 98087d2..f442a34 100644 --- a/indexer/src/processing/nft/transferred.handler.ts +++ b/indexer/src/processing/nft/transferred.handler.ts @@ -5,7 +5,8 @@ import { Nft, Transfer } from '../../model'; import { EventInfo } from '../event-info.type'; import { v4 as uuidv4 } from 'uuid'; -const NullAddress = '0x0000000000000000000000000000000000000000000000000000000000000000' +const NullAddress = + '0x0000000000000000000000000000000000000000000000000000000000000000'; export class TransferredHandler implements INftEventHandler { async handle( @@ -33,10 +34,12 @@ export class TransferredHandler implements INftEventHandler { txHash, }), ); - await storage.setNft(new Nft({ - ...nft, - owner: recipient, - })); + await storage.setNft( + new Nft({ + ...nft, + owner: recipient, + }), + ); } } } diff --git a/indexer/src/processing/storage/local.storage.ts b/indexer/src/processing/storage/local.storage.ts index 53bb0ee..e2b187d 100644 --- a/indexer/src/processing/storage/local.storage.ts +++ b/indexer/src/processing/storage/local.storage.ts @@ -213,8 +213,8 @@ export class LocalStorage implements IStorage { } if (!this.marketplace!.nftMetadata) { this.marketplace!.nftMetadata = nftMeta; - }} catch (e) { - } + } + } catch (e) {} } private async loadCollections() {