-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Swagger documentation for locking (#1304)
This adds the Swagger documentation for the locking-relevant endpoints.
- Loading branch information
Showing
6 changed files
with
136 additions
and
16 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
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 |
---|---|---|
@@ -1,4 +1,15 @@ | ||
import { LockingEventSchema } from '@/domain/locking/entities/schemas/locking-event.schema'; | ||
import { | ||
LockEventItemSchema, | ||
LockingEventSchema, | ||
UnlockEventItemSchema, | ||
WithdrawEventItemSchema, | ||
} from '@/domain/locking/entities/schemas/locking-event.schema'; | ||
import { z } from 'zod'; | ||
|
||
export type LockEventItem = z.infer<typeof LockEventItemSchema>; | ||
|
||
export type UnlockEventItem = z.infer<typeof UnlockEventItemSchema>; | ||
|
||
export type WithdrawEventItem = z.infer<typeof WithdrawEventItemSchema>; | ||
|
||
export type LockingEvent = z.infer<typeof LockingEventSchema>; |
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,74 @@ | ||
import { | ||
LockEventItem as DomainLockEventItem, | ||
UnlockEventItem as DomainUnlockEventItem, | ||
WithdrawEventItem as DomainWithdrawEventItem, | ||
} from '@/domain/locking/entities/locking-event.entity'; | ||
import { LockingEventType } from '@/domain/locking/entities/schemas/locking-event.schema'; | ||
import { Page } from '@/routes/common/entities/page.entity'; | ||
import { ApiExtraModels, ApiProperty, getSchemaPath } from '@nestjs/swagger'; | ||
|
||
class LockEventItem implements DomainLockEventItem { | ||
@ApiProperty({ enum: [LockingEventType.LOCKED] }) | ||
eventType!: LockingEventType.LOCKED; | ||
@ApiProperty({ type: String }) | ||
executionDate!: Date; | ||
@ApiProperty() | ||
transactionHash!: `0x${string}`; | ||
@ApiProperty() | ||
holder!: `0x${string}`; | ||
@ApiProperty() | ||
amount!: string; | ||
@ApiProperty() | ||
logIndex!: string; | ||
} | ||
|
||
class UnlockEventItem implements DomainUnlockEventItem { | ||
@ApiProperty({ enum: [LockingEventType.UNLOCKED] }) | ||
eventType!: LockingEventType.UNLOCKED; | ||
@ApiProperty({ type: String }) | ||
executionDate!: Date; | ||
@ApiProperty() | ||
transactionHash!: `0x${string}`; | ||
@ApiProperty() | ||
holder!: `0x${string}`; | ||
@ApiProperty() | ||
amount!: string; | ||
@ApiProperty() | ||
logIndex!: string; | ||
@ApiProperty() | ||
unlockIndex!: string; | ||
} | ||
|
||
class WithdrawEventItem implements DomainWithdrawEventItem { | ||
@ApiProperty({ enum: [LockingEventType.WITHDRAWN] }) | ||
eventType!: LockingEventType.WITHDRAWN; | ||
@ApiProperty({ type: String }) | ||
executionDate!: Date; | ||
@ApiProperty() | ||
transactionHash!: `0x${string}`; | ||
@ApiProperty() | ||
holder!: `0x${string}`; | ||
@ApiProperty() | ||
amount!: string; | ||
@ApiProperty() | ||
logIndex!: string; | ||
@ApiProperty() | ||
unlockIndex!: string; | ||
} | ||
|
||
@ApiExtraModels(LockEventItem, UnlockEventItem, WithdrawEventItem) | ||
export class LockingEventPage extends Page< | ||
DomainLockEventItem | DomainUnlockEventItem | DomainWithdrawEventItem | ||
> { | ||
@ApiProperty({ | ||
isArray: true, | ||
oneOf: [ | ||
{ $ref: getSchemaPath(LockEventItem) }, | ||
{ $ref: getSchemaPath(UnlockEventItem) }, | ||
{ $ref: getSchemaPath(WithdrawEventItem) }, | ||
], | ||
}) | ||
results!: Array< | ||
DomainLockEventItem | DomainUnlockEventItem | DomainWithdrawEventItem | ||
>; | ||
} |
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,15 @@ | ||
import { Rank as DomainRank } from '@/domain/locking/entities/rank.entity'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class Rank implements DomainRank { | ||
@ApiProperty() | ||
holder!: `0x${string}`; | ||
@ApiProperty() | ||
position!: string; | ||
@ApiProperty() | ||
lockedAmount!: string; | ||
@ApiProperty() | ||
unlockedAmount!: string; | ||
@ApiProperty() | ||
withdrawnAmount!: string; | ||
} |
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,8 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { Page } from '@/routes/common/entities/page.entity'; | ||
import { Rank } from '@/routes/locking/entities/rank.entity'; | ||
|
||
export class RankPage extends Page<Rank> { | ||
@ApiProperty({ type: Rank }) | ||
results!: Array<Rank>; | ||
} |
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