-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from imashok02/ft-auction-contract-interaction
feat: auction contract interaction
- Loading branch information
Showing
33 changed files
with
1,121 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"development": { | ||
"username": "ashok", | ||
"password": "secret", | ||
"database": "eth", | ||
"host": "localhost", | ||
"dialect": "postgres", | ||
"port": 5432 | ||
}, | ||
"production": { | ||
"username": "ashok", | ||
"password": "secret", | ||
"database": "eth", | ||
"host": "postgres", | ||
"dialect": "postgres", | ||
"port": 5432 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
POSTGRES_DB=eth | ||
POSTGRES_USER=ashok | ||
POSTGRES_PASSWORD=secret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
NODE_ENV=production #DO NOT CHANGE | ||
|
||
PORT=4000 | ||
VERSION=v1 | ||
ORIGIN=* | ||
|
||
DB_USER=ashok | ||
DB_PASSWORD=secret | ||
DB_DATABASE=eth | ||
DB_PORT=5432 | ||
|
||
DB_HOST=postgres #DO NOT CHANGE | ||
|
||
JWT_SECRET=7LdPnw30KauR9jg63TJpw2BXixqrgo1j | ||
JWT_EXPIRY=1d | ||
|
||
LOCAL_NODE_PROVIDER_URL=http://127.0.0.1:8545 | ||
|
||
INFURA_API_KEY= | ||
INFURA_PROJECT_ID= | ||
INFURA_PROJECT_SECRET= | ||
|
||
NETWORK_NAME=sepolia | ||
CHAIN_ID=11155111 | ||
|
||
|
||
AUCTION_CONTRACT_ADDRESS=0x23436F18efEEcf9AB7210626940963F3d2549053 #Auction contract deployed on Sepolia testnet | ||
# Contract url => https://sepolia.etherscan.io/address/0x23436F18efEEcf9AB7210626940963F3d2549053 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import { Body, Controller, Get, Post, Query, UseGuards } from '@nestjs/common'; | ||
import { ApiOkResponse, ApiTags } from '@nestjs/swagger'; | ||
|
||
import { AuctionService } from './auction.service'; | ||
import { JwtAuthGuard } from 'src/common/guards/jwt-auth.guard'; | ||
import { | ||
AuctionBalanceDto, | ||
AuctionBeneficiary, | ||
AuctionEndTimeDto, | ||
AuctionHighestBid, | ||
AuctionHighestBidder, | ||
AuctionStatsDto, | ||
AuctionStatusDto, | ||
BidDto, | ||
} from './dto/auction-response-dto'; | ||
import { CurrentUser } from 'src/common/decorator/current-user.decorator'; | ||
import { User } from 'src/user/models/user.model'; | ||
import { PaginationDto } from 'src/common/dto/pagination.dto'; | ||
|
||
@ApiTags('Auction') | ||
@Controller('auction') | ||
export class AuctionController { | ||
constructor(private readonly auctionService: AuctionService) {} | ||
|
||
@Get('me') | ||
@UseGuards(JwtAuthGuard) | ||
async getMe() { | ||
return { | ||
id: 1, | ||
name: 'ss', | ||
email: 'asdsad', | ||
}; | ||
} | ||
|
||
@Get('beneficiary') | ||
async auction(): Promise<AuctionBeneficiary> { | ||
return this.auctionService.getBeneficiary(); | ||
} | ||
|
||
@Get('interface') | ||
async getAuctionInterface() { | ||
return this.auctionService.getAuctionInterface(); | ||
} | ||
|
||
@Get('highest-bid') | ||
async getHighestBid(): Promise<AuctionHighestBid> { | ||
return this.auctionService.getHighestBid(); | ||
} | ||
|
||
@Get('highest-bidder') | ||
async getHighestBidder(): Promise<AuctionHighestBidder> { | ||
return this.auctionService.getHighestBidder(); | ||
} | ||
|
||
@Get('end-time') | ||
async getAuctionEndTime(): Promise<AuctionEndTimeDto> { | ||
return this.auctionService.getAuctionEndTime(); | ||
} | ||
|
||
@Get('status') | ||
@UseGuards(JwtAuthGuard) | ||
@ApiOkResponse({ | ||
description: 'To know the status of the auction', | ||
type: AuctionStatusDto, | ||
}) | ||
async auctionStatus(): Promise<AuctionStatusDto> { | ||
return this.auctionService.auctionStatus(); | ||
} | ||
|
||
@Get('balance') | ||
@UseGuards(JwtAuthGuard) | ||
@ApiOkResponse({ | ||
description: 'To know the available balance of the contract', | ||
type: AuctionBalanceDto, | ||
}) | ||
async auctionBalance(): Promise<AuctionBalanceDto> { | ||
return this.auctionService.auctionBalance(); | ||
} | ||
|
||
@Get('stats') | ||
@ApiOkResponse({ | ||
description: 'To know the stats of the auction', | ||
type: AuctionStatsDto, | ||
}) | ||
async auctionStats(): Promise<AuctionStatsDto> { | ||
return this.auctionService.auctionStats(); | ||
} | ||
|
||
@Get('history') | ||
@UseGuards(JwtAuthGuard) | ||
async auctionHistory(@Query() paginationDto: PaginationDto) { | ||
return this.auctionService.auctionHistory(paginationDto); | ||
} | ||
|
||
@Post('bid') | ||
@UseGuards(JwtAuthGuard) | ||
async bid(@CurrentUser() user: User, @Body() bidDto: BidDto) { | ||
return this.auctionService.bid(user, bidDto); | ||
} | ||
|
||
@Get('balance') | ||
async getBalance() { | ||
return this.auctionService.getBalance(); | ||
} | ||
|
||
@Get('my-balance') | ||
@UseGuards(JwtAuthGuard) | ||
async getMyBalance( | ||
@CurrentUser() user: User, | ||
@Query('address') address: string, | ||
) { | ||
return this.auctionService.getMyBalance(user, address); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { ConfigModule } from '@nestjs/config'; | ||
|
||
import { AuctionController } from './auction.controller'; | ||
import { AuctionService } from './auction.service'; | ||
import { SequelizeModule } from '@nestjs/sequelize'; | ||
import { User } from 'src/user/models/user.model'; | ||
import { Bid } from './models/bid.model'; | ||
|
||
@Module({ | ||
imports: [SequelizeModule.forFeature([User, Bid]), ConfigModule], | ||
controllers: [AuctionController], | ||
providers: [AuctionService], | ||
exports: [AuctionService], | ||
}) | ||
export class AuctionModule {} |
Oops, something went wrong.