forked from MergeFi/backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaintenance-pool.controller.ts
More file actions
65 lines (54 loc) · 1.56 KB
/
Copy pathmaintenance-pool.controller.ts
File metadata and controls
65 lines (54 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { IsOptional, IsString, IsUUID } from 'class-validator';
import { MaintenancePoolService } from './maintenance-pool.service';
import { CreatePoolDto } from './dto/create-pool.dto';
import { IsMoneyAmount } from '../common/validators/money.validator';
import { Idempotent } from '../common/idempotency/idempotent.decorator';
class DepositDto {
@IsMoneyAmount()
amount: string;
@IsString()
funderAddress: string;
}
class AssignRewardDto {
@IsMoneyAmount()
amount: string;
@IsString()
recipientAddress: string;
@IsOptional()
@IsUUID()
recipientId?: string;
}
@ApiTags('maintenance-pool')
@Controller('maintenance-pools')
export class MaintenancePoolController {
constructor(private readonly poolService: MaintenancePoolService) {}
@Post()
create(@Body() dto: CreatePoolDto) {
return this.poolService.create(dto);
}
@Get()
list() {
return this.poolService.list();
}
@Get(':id')
findOne(@Param('id') id: string) {
return this.poolService.findOne(id);
}
@Idempotent('pool.deposit')
@Post(':id/deposit')
deposit(@Param('id') id: string, @Body() dto: DepositDto) {
return this.poolService.deposit(id, dto.amount, dto.funderAddress);
}
@Idempotent('pool.assignReward')
@Post(':id/assign-reward')
assignReward(@Param('id') id: string, @Body() dto: AssignRewardDto) {
return this.poolService.assignReward(
id,
dto.amount,
dto.recipientAddress,
dto.recipientId,
);
}
}