Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bid model + Create Bid + Active landing page bid response #99

Merged
merged 17 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
840b689
feat-wip(bid): add bid model, get auction bids endpoint and service
vikinatora Oct 18, 2021
5efe018
feat(place-bid): add bid model, temp bidding functionality and upgrad…
vikinatora Oct 19, 2021
bbaeeb5
fix(bid-entity): combine the two migration files into a single on
vikinatora Oct 20, 2021
291e813
fix(auction-page): more active auctions returns only active, removed …
vikinatora Oct 20, 2021
1fedf7c
improve(bids): add get user bids endpoint, change auction page link, …
vikinatora Oct 22, 2021
8648706
fix(auction-page): reversed start and end date queries
vikinatora Oct 22, 2021
6869227
improve(my-bids): optimize queries and make code more readable and or…
vikinatora Oct 22, 2021
02710a6
Merge branch 'dev' into auctions
vikinatora Oct 22, 2021
5603fd7
refactor: remove unnecessary bidder grouping function
vikinatora Oct 22, 2021
502ac55
Merge branch 'auctions' of https://github.com/UniverseXYZ/UniverseApp…
vikinatora Oct 22, 2021
98fb06a
fix(my-bids): fix min and max bids query
vikinatora Oct 22, 2021
2ec0fdc
fix(my-bids): add auction creator info to auction response
vikinatora Oct 22, 2021
c92b930
optimize(my-bids): merge bid table queries together
vikinatora Oct 22, 2021
f238390
improve(my-bids): reduce .find() calls
vikinatora Oct 22, 2021
bee7ae5
improve(my-active-auctions): add bids response
vikinatora Oct 25, 2021
d4a843b
improve(past-auctions): add bids info to past auctions endpoint
vikinatora Oct 25, 2021
accdd0f
fix(active-auction-page): return all bids for the auction
vikinatora Oct 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions migrations/1634645086422-AuctionBid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {MigrationInterface, QueryRunner} from "typeorm";

export class AuctionBid1634645086422 implements MigrationInterface {
name = 'AuctionBid1634645086422'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE "universe-backend"."auction_bid" ("id" SERIAL NOT NULL, "userId" integer NOT NULL, "auctionId" integer NOT NULL, "amount" numeric NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_022e4f8fe9416b6f1e13c55cdfb" PRIMARY KEY ("id"))`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE "universe-backend"."auction_bid"`);
}

}
3 changes: 2 additions & 1 deletion src/modules/auction/auction.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { MulterConfigService } from '../multer/multer.service';
import { Nft } from '../nft/domain/nft.entity';
import { User } from '../users/user.entity';
import { Auction } from './domain/auction.entity';
import { AuctionBid } from './domain/auction.bid.entity';
import { RewardTierNft } from './domain/reward-tier-nft.entity';
import { RewardTier } from './domain/reward-tier.entity';
import { AuctionController } from './entrypoints/auction.controller';
Expand All @@ -22,7 +23,7 @@ import { NftCollection } from '../nft/domain/collection.entity';
MulterModule.registerAsync({
useClass: MulterConfigService,
}),
TypeOrmModule.forFeature([User, Auction, RewardTier, RewardTierNft, Nft, NftCollection]),
TypeOrmModule.forFeature([User, Auction, RewardTier, RewardTierNft, Nft, NftCollection, AuctionBid]),
FileSystemModule,
UsersModule,
],
Expand Down
24 changes: 24 additions & 0 deletions src/modules/auction/domain/auction.bid.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Exclude } from 'class-transformer';
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity({
schema: 'universe-backend',
})
export class AuctionBid {
@PrimaryGeneratedColumn()
id: number;

@Column()
@Exclude()
userId: number;

@Column()
@Exclude()
auctionId: number;

@Column({ type: 'decimal' })
amount: number;

@CreateDateColumn()
createdAt: Date;
}
6 changes: 0 additions & 6 deletions src/modules/auction/domain/auction.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,21 @@ export class Auction {
backgroundImageBlur: boolean;

@Column({ default: false })
@Exclude()
onChain: boolean;

@Column({ default: true })
@Exclude()
initialised: boolean;

@Column({ default: false })
@Exclude()
depositedNfts: boolean;

@Column({ default: false })
@Exclude()
canceled: boolean;

@Column({ default: false })
@Exclude()
finalised: boolean;

@Column({ nullable: true })
@Exclude()
onChainId: number;

@Column({ nullable: true })
Expand Down
13 changes: 13 additions & 0 deletions src/modules/auction/entrypoints/auction.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
GetAuctionPageParams,
GetMyAuctionsQuery,
GetMyAuctionsResponse,
PlaceBidBody,
UpdateAuctionExtraBody,
UpdateRewardTierBody,
UpdateRewardTierExtraBody,
Expand Down Expand Up @@ -284,6 +285,18 @@ export class AuctionController {
return await this.auctionService.listAuctionsByStatus(status, page, limit);
}

@Post('auction/placeBid')
@UseGuards(JwtAuthGuard)
async placeAuctionBid(@Req() req, @Body() placeBidBody: PlaceBidBody) {
return await this.auctionService.placeAuctionBid(req.user.sub, placeBidBody);
}

@Get('pages/my-bids')
@UseGuards(JwtAuthGuard)
async getUserBids(@Req() req) {
return await this.auctionService.getUserBids(req.user.sub);
}

//Todo: add tier info
@Get('auction/{:id}')
@UseGuards(JwtAuthGuard)
Expand Down
16 changes: 16 additions & 0 deletions src/modules/auction/entrypoints/dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,3 +660,19 @@ export class GetAuctionPageParams {
@IsString()
auctionName: string;
}

export class PlaceBidBody {
@ApiProperty({
example: 1,
description: 'The id of the auction to which the user is bidding',
})
@IsNumber()
auctionId: number;

@ApiProperty({
example: '0.1',
description: 'Amount of crypto the user is bidding',
})
@IsNumber()
amount: number;
}
Loading