-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into feat/add-delegation-search
- Loading branch information
Showing
12 changed files
with
259 additions
and
68 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
api/src/models/api/nova/commitment/ILatestSlotCommitmentsResponse.ts
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,18 @@ | ||
/* eslint-disable import/no-unresolved */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-argument */ | ||
import { SlotCommitment } from "@iota/sdk-nova"; | ||
import { IResponse } from "../../IResponse"; | ||
|
||
export enum SlotCommitmentStatus { | ||
Committed = "committed", | ||
Finalized = "finalized", | ||
} | ||
|
||
export interface ISlotCommitmentWrapper { | ||
status: SlotCommitmentStatus; | ||
slotCommitment: SlotCommitment; | ||
} | ||
|
||
export interface ILatestSlotCommitmentResponse extends IResponse { | ||
slotCommitments: ISlotCommitmentWrapper[]; | ||
} |
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,30 @@ | ||
import { ServiceFactory } from "../../../../factories/serviceFactory"; | ||
import { ILatestSlotCommitmentResponse } from "../../../../models/api/nova/commitment/ILatestSlotCommitmentsResponse"; | ||
import { IConfiguration } from "../../../../models/configuration/IConfiguration"; | ||
import { NOVA } from "../../../../models/db/protocolVersion"; | ||
import { NetworkService } from "../../../../services/networkService"; | ||
import { NovaFeed } from "../../../../services/nova/feed/novaFeed"; | ||
import { ValidationHelper } from "../../../../utils/validationHelper"; | ||
|
||
/** | ||
* Get the latest slot commitments. | ||
* @param _ The configuration. | ||
* @param request The request. | ||
* @param request.network The network in context. | ||
* @returns The response. | ||
*/ | ||
export async function get(_: IConfiguration, request: { network: string }): Promise<ILatestSlotCommitmentResponse> { | ||
const networkService = ServiceFactory.get<NetworkService>("network"); | ||
const networks = networkService.networkNames(); | ||
ValidationHelper.oneOf(request.network, networks, "network"); | ||
const networkConfig = networkService.get(request.network); | ||
|
||
if (networkConfig.protocolVersion !== NOVA) { | ||
return { error: "Endpoint available only on Nova networks.", slotCommitments: [] }; | ||
} | ||
|
||
const feedService = ServiceFactory.get<NovaFeed>(`feed-${request.network}`); | ||
const slotCommitments = feedService.getLatestSlotCommitments; | ||
|
||
return { slotCommitments }; | ||
} |
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
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
Oops, something went wrong.