forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettlement.controller.ts
More file actions
51 lines (45 loc) · 1.39 KB
/
Copy pathsettlement.controller.ts
File metadata and controls
51 lines (45 loc) · 1.39 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
import { Controller, Get, Post, Put, Body, Param, Req } from "@nestjs/common";
import { SuggestionEngineService } from "./suggestion-engine.service";
import { SettlementService } from "./settlement.service";
@Controller("settlement")
export class SettlementController {
constructor(
private readonly suggestionEngine: SuggestionEngineService,
private readonly settlementService: SettlementService,
) {}
@Get("suggestions")
async getSuggestions(@Req() req: any) {
return this.suggestionEngine.generateSuggestions(
req.user.id,
req.user.walletAddress,
);
}
@Post("suggestions/refresh")
async refresh(@Req() req: any) {
return this.suggestionEngine.generateSuggestions(
req.user.id,
req.user.walletAddress,
);
}
@Get("net-position")
async getNetPosition(@Req() req: any) {
return this.settlementService.calculateNetPosition(req.user.walletAddress);
}
@Post("suggestions/snooze")
async snooze(@Req() req: any) {
return this.settlementService.snoozeSuggestions(req.user.id);
}
@Put("steps/:stepId/complete")
async completeStep(
@Param("stepId") stepId: string,
@Body("txHash") txHash: string,
@Req() req: any,
) {
// This triggers the Stellar verification and updates split/participant status
return this.settlementService.verifyAndCompleteStep(
stepId,
txHash,
req.user.walletAddress,
);
}
}