Skip to content

Commit

Permalink
add new fields to configs
Browse files Browse the repository at this point in the history
  • Loading branch information
ElessarST committed Feb 26, 2024
1 parent b52af49 commit f5cf3b7
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 37 deletions.
13 changes: 13 additions & 0 deletions indexer/db/migrations/1708949622123-Data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = class Data1708949622123 {
name = 'Data1708949622123'

async up(db) {
await db.query(`ALTER TABLE "marketplace_config" ADD "minimum_value_for_trade" numeric NOT NULL DEFAULT 0`)
await db.query(`ALTER TABLE "marketplace_config" ADD "minimum_value_for_mint" numeric NOT NULL DEFAULT 0`)
}

async down(db) {
await db.query(`ALTER TABLE "marketplace_config" DROP COLUMN "minimum_value_for_trade"`)
await db.query(`ALTER TABLE "marketplace_config" DROP COLUMN "minimum_value_for_mint"`)
}
}
2 changes: 2 additions & 0 deletions indexer/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type MarketplaceConfig @entity {
royaltyToMarketplaceForTrade: Int!
feePerUploadedFile: BigInt!
minimumTransferValue: BigInt!
minimumValueForTrade: BigInt!
minimumValueForMint: BigInt!
msInBlock: Int!
marketplace: Marketplace!
}
Expand Down
12 changes: 12 additions & 0 deletions indexer/src/model/generated/marketplaceConfig.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ export class MarketplaceConfig {
})
minimumTransferValue!: bigint;

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

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

@Column_('int4', { nullable: false })
msInBlock!: number;

Expand Down
61 changes: 24 additions & 37 deletions indexer/src/types/marketplace.events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,12 @@ export enum NftMarketplaceEventType {

export type Initialized = {
type: NftMarketplaceEventType.Initialized;
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;
minimumTransferValue: bigint | null;
msInBlock: number | null;
minimumValueForTrade: bigint | null;
minimumValueForMint: bigint | null;
};

export type NewCollectionAdded = {
Expand Down Expand Up @@ -159,6 +154,8 @@ export type ConfigUpdated = {
royaltyToMarketplaceForMint: number | null;
minimumTransferValue: bigint | null;
msInBlock: number | null;
minimumValueForTrade: bigint | null;
minimumValueForMint: bigint | null;
};

export type NftMarketplaceEvent =
Expand All @@ -184,15 +181,10 @@ export interface NftMarketplaceEventPlain extends Enum {
initialized: {
timeBetweenCreateCollections: u64;
feePerUploadedFile: u128;
minimumTransferValue: u128;
royaltyToMarketplaceForTrade: u16;
royaltyToMarketplaceForMint: u16;
gasForCreation: Option<u64>;
gasForTransferToken: Option<u64>;
gasForCloseAuction: Option<u64>;
gasForDeleteCollection: Option<u64>;
gasForGetTokenInfo: Option<u64>;
msInBlock: Option<u32>;
minimumValueForTrade: u128;
minimumValueForMint: u128;
};
newCollectionAdded: {
codeId: CodeId;
Expand Down Expand Up @@ -280,6 +272,8 @@ export interface NftMarketplaceEventPlain extends Enum {
feePerUploadedFile: Option<u128>;
royaltyToMarketplaceForTrade: Option<u16>;
royaltyToMarketplaceForMint: Option<u16>;
minimumValueForTrade: Option<u128>;
minimumValueForMint: Option<u128>;
};
}

Expand Down Expand Up @@ -454,40 +448,33 @@ export function getMarketplaceEvent(
event.configUpdated.royaltyToMarketplaceForMint,
),
),
minimumValueForTrade: safeUnwrapToBigInt(
safeUnwrapOptional<u128, number>(
event.configUpdated.minimumValueForTrade,
),
),
minimumValueForMint: safeUnwrapToBigInt(
safeUnwrapOptional<u128, number>(
event.configUpdated.minimumValueForMint,
),
),
};
}
if (event.initialized) {
return {
type: NftMarketplaceEventType.Initialized,
gasForCreation: safeUnwrapToBigInt(
safeUnwrapOptional<u64, number>(event.initialized.gasForCreation),
),
gasForTransferToken: safeUnwrapToBigInt(
safeUnwrapOptional<u64, number>(event.initialized.gasForTransferToken),
),
gasForCloseAuction: safeUnwrapToBigInt(
safeUnwrapOptional<u64, number>(event.initialized.gasForCloseAuction),
),
gasForDeleteCollection: safeUnwrapToBigInt(
safeUnwrapOptional<u64, number>(
event.initialized.gasForDeleteCollection,
),
),
gasForGetTokenInfo: safeUnwrapToBigInt(
safeUnwrapOptional<u64, number>(event.initialized.gasForGetTokenInfo),
),
timeBetweenCreateCollections: safeUnwrapToBigInt(
event.initialized.timeBetweenCreateCollections,
),
minimumTransferValue: safeUnwrapToBigInt(
event.initialized.minimumTransferValue,
),
msInBlock: safeUnwrapToNumber(
safeUnwrapOptional<u32, number>(event.initialized.msInBlock),
),
feePerUploadedFile: safeUnwrapToBigInt(
event.initialized.feePerUploadedFile,
),
minimumValueForTrade: safeUnwrapToBigInt(
event.initialized.minimumValueForTrade,
),
minimumValueForMint: safeUnwrapToBigInt(
event.initialized.minimumValueForMint,
),
royaltyToMarketplaceForTrade: safeUnwrapToNumber(
event.initialized.royaltyToMarketplaceForTrade,
),
Expand Down

0 comments on commit f5cf3b7

Please sign in to comment.