Skip to content

Commit

Permalink
indexer fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ElessarST committed Feb 9, 2024
1 parent 17eb91c commit a06a4b5
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 14 deletions.
17 changes: 17 additions & 0 deletions indexer/db/migrations/1707469641353-Data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = class Data1707469641353 {
name = 'Data1707469641353'

async up(db) {
await db.query(`ALTER TABLE "collection" DROP COLUMN "transferable"`)
await db.query(`ALTER TABLE "collection" ADD "transferable" numeric`)
await db.query(`ALTER TABLE "collection" DROP COLUMN "sellable"`)
await db.query(`ALTER TABLE "collection" ADD "sellable" numeric`)
}

async down(db) {
await db.query(`ALTER TABLE "collection" ADD "transferable" boolean`)
await db.query(`ALTER TABLE "collection" DROP COLUMN "transferable"`)
await db.query(`ALTER TABLE "collection" ADD "sellable" boolean`)
await db.query(`ALTER TABLE "collection" DROP COLUMN "sellable"`)
}
}
4 changes: 2 additions & 2 deletions indexer/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ type Collection @entity {
royalty: Int!
collectionLogo: String!
collectionBanner: String!
transferable: Boolean
transferable: BigInt
approvable: Boolean
burnable: Boolean
sellable: Boolean
sellable: BigInt
attendable: Boolean
createdAt: DateTime!
nfts: [Nft!]! @derivedFrom(field: "collection")
Expand Down
14 changes: 10 additions & 4 deletions indexer/src/model/generated/collection.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,23 @@ export class Collection {
@Column_('text', { nullable: false })
collectionBanner!: string;

@Column_('bool', { nullable: true })
transferable!: boolean | undefined | null;
@Column_('numeric', {
transformer: marshal.bigintTransformer,
nullable: true,
})
transferable!: bigint | undefined | null;

@Column_('bool', { nullable: true })
approvable!: boolean | undefined | null;

@Column_('bool', { nullable: true })
burnable!: boolean | undefined | null;

@Column_('bool', { nullable: true })
sellable!: boolean | undefined | null;
@Column_('numeric', {
transformer: marshal.bigintTransformer,
nullable: true,
})
sellable!: bigint | undefined | null;

@Column_('bool', { nullable: true })
attendable!: boolean | undefined | null;
Expand Down
2 changes: 2 additions & 0 deletions indexer/src/processing/marketplace/auction-closed.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { INftMarketplaceEventHandler } from './nft-marketplace.handler';
import { AuctionStatus } from '../../model/types';
import { EventInfo } from '../event-info.type';
import { Transfer } from '../../model';
import { v4 as uuidv4 } from 'uuid';

export class AuctionClosedHandler implements INftMarketplaceEventHandler {
async handle(
Expand Down Expand Up @@ -35,6 +36,7 @@ export class AuctionClosedHandler implements INftMarketplaceEventHandler {
});
storage.addTransfer(
new Transfer({
id: uuidv4(),
nft,
from: auction.owner,
to: currentOwner,
Expand Down
2 changes: 2 additions & 0 deletions indexer/src/processing/marketplace/nft-sold.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { INftMarketplaceEventHandler } from './nft-marketplace.handler';
import { Nft, Sale, Transfer } from '../../model';
import { SaleStatus } from '../../model/types';
import { EventInfo } from '../event-info.type';
import { v4 as uuidv4 } from 'uuid';

export class NftSoldHandler implements INftMarketplaceEventHandler {
async handle(
Expand Down Expand Up @@ -46,6 +47,7 @@ export class NftSoldHandler implements INftMarketplaceEventHandler {
);
storage.addTransfer(
new Transfer({
id: uuidv4(),
nft,
from: sale.owner,
to: currentOwner,
Expand Down
2 changes: 2 additions & 0 deletions indexer/src/processing/marketplace/offer-accepted.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { INftMarketplaceEventHandler } from './nft-marketplace.handler';
import { OfferStatus } from '../../model/types';
import { Offer, Transfer } from '../../model';
import { EventInfo } from '../event-info.type';
import { v4 as uuidv4 } from 'uuid';

export class OfferAcceptedHandler implements INftMarketplaceEventHandler {
async handle(
Expand Down Expand Up @@ -38,6 +39,7 @@ export class OfferAcceptedHandler implements INftMarketplaceEventHandler {
);
storage.addTransfer(
new Transfer({
id: uuidv4(),
nft,
from: nft.owner,
to: offer.creator,
Expand Down
2 changes: 2 additions & 0 deletions indexer/src/processing/nft/transferred.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { EntitiesService } from '../entities.service';
import { INftEventHandler } from './nft.handler';
import { Transfer } from '../../model';
import { EventInfo } from '../event-info.type';
import { v4 as uuidv4 } from 'uuid';

export class TransferredHandler implements INftEventHandler {
async handle(
Expand All @@ -20,6 +21,7 @@ export class TransferredHandler implements INftEventHandler {
}
storage.addTransfer(
new Transfer({
id: uuidv4(),
nft,
from: owner,
to: recipient,
Expand Down
24 changes: 16 additions & 8 deletions indexer/src/types/nft.events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ export type NftConfig = {
additionalLinks: AdditionalLink | null;
royalty: number;
paymentForMint: bigint;
transferable: boolean;
transferable: bigint | null;
approvable: boolean;
burnable: boolean;
sellable: boolean;
sellable: bigint | null;
attendable: boolean;
totalNumberOfTokens: bigint | null;
};
Expand Down Expand Up @@ -143,10 +143,10 @@ export interface ConfigPlain {
additionalLinks: AdditionalLinkPlain;
royalty: u16;
paymentForMint: u128;
transferable: boolean;
transferable: Option<u64> | number;
approvable: boolean;
burnable: boolean;
sellable: boolean;
sellable: Option<u64> | number;
attendable: boolean;
}

Expand Down Expand Up @@ -251,10 +251,14 @@ export function getNftEvent(event: NftEventPlain): NftEvent | undefined {
paymentForMint: safeUnwrapToBigInt(
event.initialized.config.paymentForMint,
)!,
transferable: event.initialized.config.transferable,
transferable: safeUnwrapToBigInt(
safeUnwrapOptional(event.initialized.config.transferable),
),
approvable: event.initialized.config.approvable,
burnable: event.initialized.config.burnable,
sellable: event.initialized.config.sellable,
sellable: safeUnwrapToBigInt(
safeUnwrapOptional(event.initialized.config.sellable),
),
attendable: event.initialized.config.attendable,
totalNumberOfTokens: safeUnwrapToBigInt(
event.initialized.totalNumberOfTokens,
Expand Down Expand Up @@ -334,10 +338,14 @@ export function getNftEvent(event: NftEventPlain): NftEvent | undefined {
paymentForMint: safeUnwrapToBigInt(
event.configChanged.config.paymentForMint,
)!,
transferable: event.configChanged.config.transferable,
transferable: safeUnwrapToBigInt(
safeUnwrapOptional(event.configChanged.config.transferable),
),
approvable: event.configChanged.config.approvable,
burnable: event.configChanged.config.burnable,
sellable: event.configChanged.config.sellable,
sellable: safeUnwrapToBigInt(
safeUnwrapOptional(event.configChanged.config.sellable),
),
attendable: event.configChanged.config.attendable,
totalNumberOfTokens: safeUnwrapToBigInt(
event.configChanged.totalNumberOfTokens,
Expand Down

0 comments on commit a06a4b5

Please sign in to comment.