Skip to content

Commit

Permalink
fix config
Browse files Browse the repository at this point in the history
  • Loading branch information
ElessarST committed Feb 26, 2024
1 parent 2da215b commit b52af49
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 42 deletions.
25 changes: 25 additions & 0 deletions indexer/db/migrations/1708939752324-Data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = class Data1708939752324 {
name = 'Data1708939752324'

async up(db) {
await db.query(`ALTER TABLE "marketplace_config" ALTER COLUMN "gas_for_creation" TYPE numeric`)
await db.query(`ALTER TABLE "marketplace_config" ALTER COLUMN "gas_for_transfer_token" TYPE numeric`)
await db.query(`ALTER TABLE "marketplace_config" ALTER COLUMN "gas_for_close_auction" TYPE numeric`)
await db.query(`ALTER TABLE "marketplace_config" ALTER COLUMN "gas_for_delete_collection" TYPE numeric`)
await db.query(`ALTER TABLE "marketplace_config" ALTER COLUMN "gas_for_get_token_info" TYPE numeric`)
await db.query(`ALTER TABLE "marketplace_config" ALTER COLUMN "time_between_create_collections" TYPE numeric`)
}

async down(db) {
await db.query(`ALTER TABLE "marketplace_config" DROP COLUMN "gas_for_creation"`)
await db.query(`ALTER TABLE "marketplace_config" ADD "gas_for_creation" integer NOT NULL DEFAULT '0'`)
await db.query(`ALTER TABLE "marketplace_config" DROP COLUMN "gas_for_transfer_token"`)
await db.query(`ALTER TABLE "marketplace_config" ADD "gas_for_transfer_token" integer NOT NULL DEFAULT '0'`)
await db.query(`ALTER TABLE "marketplace_config" DROP COLUMN "gas_for_close_auction"`)
await db.query(`ALTER TABLE "marketplace_config" ADD "gas_for_close_auction" integer NOT NULL DEFAULT '0'`)
await db.query(`ALTER TABLE "marketplace_config" DROP COLUMN "gas_for_delete_collection"`)
await db.query(`ALTER TABLE "marketplace_config" ADD "gas_for_delete_collection" integer NOT NULL DEFAULT '0'`)
await db.query(`ALTER TABLE "marketplace_config" DROP COLUMN "gas_for_get_token_info"`)
await db.query(`ALTER TABLE "marketplace_config" ADD "gas_for_get_token_info" integer NOT NULL DEFAULT '0'`)
}
}
12 changes: 6 additions & 6 deletions indexer/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ type Marketplace @entity {
}

type MarketplaceConfig @entity {
gasForCreation: Int!
gasForTransferToken: Int!
gasForCloseAuction: Int!
gasForDeleteCollection: Int!
gasForGetTokenInfo: Int!
timeBetweenCreateCollections: Int!
gasForCreation: BigInt!
gasForTransferToken: BigInt!
gasForCloseAuction: BigInt!
gasForDeleteCollection: BigInt!
gasForGetTokenInfo: BigInt!
timeBetweenCreateCollections: BigInt!
royaltyToMarketplaceForMint: Int!
royaltyToMarketplaceForTrade: Int!
feePerUploadedFile: BigInt!
Expand Down
42 changes: 30 additions & 12 deletions indexer/src/model/generated/marketplaceConfig.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,41 @@ export class MarketplaceConfig {
@PrimaryColumn_()
id!: string;

@Column_('int4', { nullable: false })
gasForCreation!: number;
@Column_('numeric', {
transformer: marshal.bigintTransformer,
nullable: false,
})
gasForCreation!: bigint;

@Column_('int4', { nullable: false })
gasForTransferToken!: number;
@Column_('numeric', {
transformer: marshal.bigintTransformer,
nullable: false,
})
gasForTransferToken!: bigint;

@Column_('int4', { nullable: false })
gasForCloseAuction!: number;
@Column_('numeric', {
transformer: marshal.bigintTransformer,
nullable: false,
})
gasForCloseAuction!: bigint;

@Column_('int4', { nullable: false })
gasForDeleteCollection!: number;
@Column_('numeric', {
transformer: marshal.bigintTransformer,
nullable: false,
})
gasForDeleteCollection!: bigint;

@Column_('int4', { nullable: false })
gasForGetTokenInfo!: number;
@Column_('numeric', {
transformer: marshal.bigintTransformer,
nullable: false,
})
gasForGetTokenInfo!: bigint;

@Column_('int4', { nullable: false })
timeBetweenCreateCollections!: number;
@Column_('numeric', {
transformer: marshal.bigintTransformer,
nullable: false,
})
timeBetweenCreateCollections!: bigint;

@Column_('int4', { nullable: false })
royaltyToMarketplaceForMint!: number;
Expand Down
48 changes: 24 additions & 24 deletions indexer/src/types/marketplace.events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ export enum NftMarketplaceEventType {

export type Initialized = {
type: NftMarketplaceEventType.Initialized;
gasForCreation: number | null;
gasForTransferToken: number | null;
gasForCloseAuction: number | null;
gasForDeleteCollection: number | null;
gasForGetTokenInfo: number | null;
timeBetweenCreateCollections: number | null;
gasForCreation: bigint | null;
gasForTransferToken: bigint | null;
gasForCloseAuction: bigint | null;
gasForDeleteCollection: bigint | null;
gasForGetTokenInfo: bigint | null;
timeBetweenCreateCollections: bigint | null;
feePerUploadedFile: bigint | null;
royaltyToMarketplaceForTrade: number | null;
royaltyToMarketplaceForMint: number | null;
Expand Down Expand Up @@ -148,12 +148,12 @@ export type AdminDeleted = {

export type ConfigUpdated = {
type: NftMarketplaceEventType.ConfigUpdated;
gasForCreation: number | null;
gasForTransferToken: number | null;
gasForCloseAuction: number | null;
gasForDeleteCollection: number | null;
gasForGetTokenInfo: number | null;
timeBetweenCreateCollections: number | null;
gasForCreation: bigint | null;
gasForTransferToken: bigint | null;
gasForCloseAuction: bigint | null;
gasForDeleteCollection: bigint | null;
gasForGetTokenInfo: bigint | null;
timeBetweenCreateCollections: bigint | null;
feePerUploadedFile: bigint | null;
royaltyToMarketplaceForTrade: number | null;
royaltyToMarketplaceForMint: number | null;
Expand Down Expand Up @@ -407,26 +407,26 @@ export function getMarketplaceEvent(
if (event.configUpdated) {
return {
type: NftMarketplaceEventType.ConfigUpdated,
gasForCreation: safeUnwrapToNumber(
gasForCreation: safeUnwrapToBigInt(
safeUnwrapOptional<u64, number>(event.configUpdated.gasForCreation),
),
gasForTransferToken: safeUnwrapToNumber(
gasForTransferToken: safeUnwrapToBigInt(
safeUnwrapOptional<u64, number>(
event.configUpdated.gasForTransferToken,
),
),
gasForCloseAuction: safeUnwrapToNumber(
gasForCloseAuction: safeUnwrapToBigInt(
safeUnwrapOptional<u64, number>(event.configUpdated.gasForCloseAuction),
),
gasForDeleteCollection: safeUnwrapToNumber(
gasForDeleteCollection: safeUnwrapToBigInt(
safeUnwrapOptional<u64, number>(
event.configUpdated.gasForDeleteCollection,
),
),
gasForGetTokenInfo: safeUnwrapToNumber(
gasForGetTokenInfo: safeUnwrapToBigInt(
safeUnwrapOptional<u64, number>(event.configUpdated.gasForGetTokenInfo),
),
timeBetweenCreateCollections: safeUnwrapToNumber(
timeBetweenCreateCollections: safeUnwrapToBigInt(
safeUnwrapOptional<u64, number>(
event.configUpdated.timeBetweenCreateCollections,
),
Expand Down Expand Up @@ -459,24 +459,24 @@ export function getMarketplaceEvent(
if (event.initialized) {
return {
type: NftMarketplaceEventType.Initialized,
gasForCreation: safeUnwrapToNumber(
gasForCreation: safeUnwrapToBigInt(
safeUnwrapOptional<u64, number>(event.initialized.gasForCreation),
),
gasForTransferToken: safeUnwrapToNumber(
gasForTransferToken: safeUnwrapToBigInt(
safeUnwrapOptional<u64, number>(event.initialized.gasForTransferToken),
),
gasForCloseAuction: safeUnwrapToNumber(
gasForCloseAuction: safeUnwrapToBigInt(
safeUnwrapOptional<u64, number>(event.initialized.gasForCloseAuction),
),
gasForDeleteCollection: safeUnwrapToNumber(
gasForDeleteCollection: safeUnwrapToBigInt(
safeUnwrapOptional<u64, number>(
event.initialized.gasForDeleteCollection,
),
),
gasForGetTokenInfo: safeUnwrapToNumber(
gasForGetTokenInfo: safeUnwrapToBigInt(
safeUnwrapOptional<u64, number>(event.initialized.gasForGetTokenInfo),
),
timeBetweenCreateCollections: safeUnwrapToNumber(
timeBetweenCreateCollections: safeUnwrapToBigInt(
event.initialized.timeBetweenCreateCollections,
),
minimumTransferValue: safeUnwrapToBigInt(
Expand Down

0 comments on commit b52af49

Please sign in to comment.