Skip to content

Commit

Permalink
chore: rename stardustTangleHelper to stardustApiService
Browse files Browse the repository at this point in the history
  • Loading branch information
VmMad committed Jan 19, 2024
1 parent 446ba17 commit 6cb41d3
Show file tree
Hide file tree
Showing 19 changed files with 61 additions and 61 deletions.
6 changes: 3 additions & 3 deletions api/src/initServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { ChronicleService } from "./services/stardust/chronicleService";
import { StardustFeed } from "./services/stardust/feed/stardustFeed";
import { InfluxDBService } from "./services/stardust/influx/influxDbService";
import { NodeInfoService } from "./services/stardust/nodeInfoService";
import { StardustApiService } from "./services/stardust/stardustApiService";
import { StardustStatsService } from "./services/stardust/stats/stardustStatsService";
import { StardustTangleHelper } from "./utils/stardust/stardustTangleHelper";

const CURRENCY_UPDATE_INTERVAL_MS = 5 * 60000;

Expand Down Expand Up @@ -158,8 +158,8 @@ function initStardustServices(networkConfig: INetwork): void {
const stardustClient = new StardustClient(stardustClientParams);
ServiceFactory.register(`client-${networkConfig.network}`, () => stardustClient);

const tangleHelper = new StardustTangleHelper(networkConfig);
ServiceFactory.register(`tangle-helper-${networkConfig.network}`, () => tangleHelper);
const stardustApiService = new StardustApiService(networkConfig);
ServiceFactory.register(`api-service-${networkConfig.network}`, () => stardustApiService);

// eslint-disable-next-line no-void
void NodeInfoService.build(networkConfig).then((nodeInfoService) => {
Expand Down
6 changes: 3 additions & 3 deletions api/src/routes/stardust/address/balance/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import IAddressDetailsWithBalance from "../../../../models/api/stardust/IAddress
import { IConfiguration } from "../../../../models/configuration/IConfiguration";
import { STARDUST } from "../../../../models/db/protocolVersion";
import { NetworkService } from "../../../../services/networkService";
import { StardustTangleHelper } from "../../../../utils/stardust/stardustTangleHelper";
import { StardustApiService } from "../../../../services/stardust/stardustApiService";
import { ValidationHelper } from "../../../../utils/validationHelper";

/**
Expand All @@ -24,6 +24,6 @@ export async function get(config: IConfiguration, request: IAddressBalanceReques
return undefined;
}

const tangleHelper = ServiceFactory.get<StardustTangleHelper>(`tangle-helper-${networkConfig.network}`);
return tangleHelper.addressDetails(request.address);
const stardustApiService = ServiceFactory.get<StardustApiService>(`api-service-${networkConfig.network}`);
return stardustApiService.addressDetails(request.address);
}
6 changes: 3 additions & 3 deletions api/src/routes/stardust/address/outputs/alias/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IAddressDetailsResponse } from "../../../../../models/api/stardust/IAdd
import { IConfiguration } from "../../../../../models/configuration/IConfiguration";
import { STARDUST } from "../../../../../models/db/protocolVersion";
import { NetworkService } from "../../../../../services/networkService";
import { StardustTangleHelper } from "../../../../../utils/stardust/stardustTangleHelper";
import { StardustApiService } from "../../../../../services/stardust/stardustApiService";
import { ValidationHelper } from "../../../../../utils/validationHelper";

/**
Expand All @@ -24,6 +24,6 @@ export async function get(config: IConfiguration, request: IAddressDetailsReques
return {};
}

const tangleHelper = ServiceFactory.get<StardustTangleHelper>(`tangle-helper-${networkConfig.network}`);
return tangleHelper.aliasOutputDetailsByAddress(request.address);
const stardustApiService = ServiceFactory.get<StardustApiService>(`api-service-${networkConfig.network}`);
return stardustApiService.aliasOutputDetailsByAddress(request.address);
}
6 changes: 3 additions & 3 deletions api/src/routes/stardust/address/outputs/basic/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IAddressDetailsResponse } from "../../../../../models/api/stardust/IAdd
import { IConfiguration } from "../../../../../models/configuration/IConfiguration";
import { STARDUST } from "../../../../../models/db/protocolVersion";
import { NetworkService } from "../../../../../services/networkService";
import { StardustTangleHelper } from "../../../../../utils/stardust/stardustTangleHelper";
import { StardustApiService } from "../../../../../services/stardust/stardustApiService";
import { ValidationHelper } from "../../../../../utils/validationHelper";

/**
Expand All @@ -24,6 +24,6 @@ export async function get(config: IConfiguration, request: IAddressDetailsReques
return {};
}

const tangleHelper = ServiceFactory.get<StardustTangleHelper>(`tangle-helper-${networkConfig.network}`);
return tangleHelper.basicOutputDetailsByAddress(request.address);
const stardustApiService = ServiceFactory.get<StardustApiService>(`api-service-${networkConfig.network}`);
return stardustApiService.basicOutputDetailsByAddress(request.address);
}
6 changes: 3 additions & 3 deletions api/src/routes/stardust/address/outputs/nft/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IAddressDetailsResponse } from "../../../../../models/api/stardust/IAdd
import { IConfiguration } from "../../../../../models/configuration/IConfiguration";
import { STARDUST } from "../../../../../models/db/protocolVersion";
import { NetworkService } from "../../../../../services/networkService";
import { StardustTangleHelper } from "../../../../../utils/stardust/stardustTangleHelper";
import { StardustApiService } from "../../../../../services/stardust/stardustApiService";
import { ValidationHelper } from "../../../../../utils/validationHelper";

/**
Expand All @@ -24,6 +24,6 @@ export async function get(config: IConfiguration, request: IAddressDetailsReques
return {};
}

const tangleHelper = ServiceFactory.get<StardustTangleHelper>(`tangle-helper-${networkConfig.network}`);
return tangleHelper.nftOutputDetailsByAddress(request.address);
const stardustApiService = ServiceFactory.get<StardustApiService>(`api-service-${networkConfig.network}`);
return stardustApiService.nftOutputDetailsByAddress(request.address);
}
6 changes: 3 additions & 3 deletions api/src/routes/stardust/alias/foundries/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IFoundriesResponse } from "../../../../models/api/stardust/foundry/IFou
import { IConfiguration } from "../../../../models/configuration/IConfiguration";
import { STARDUST } from "../../../../models/db/protocolVersion";
import { NetworkService } from "../../../../services/networkService";
import { StardustTangleHelper } from "../../../../utils/stardust/stardustTangleHelper";
import { StardustApiService } from "../../../../services/stardust/stardustApiService";
import { ValidationHelper } from "../../../../utils/validationHelper";

/**
Expand All @@ -25,6 +25,6 @@ export async function get(config: IConfiguration, request: IFoundriesRequest): P
return {};
}

const tangleHelper = ServiceFactory.get<StardustTangleHelper>(`tangle-helper-${networkConfig.network}`);
return tangleHelper.aliasFoundries(request.aliasAddress);
const stardustApiService = ServiceFactory.get<StardustApiService>(`api-service-${networkConfig.network}`);
return stardustApiService.aliasFoundries(request.aliasAddress);
}
6 changes: 3 additions & 3 deletions api/src/routes/stardust/alias/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IAliasResponse } from "../../../models/api/stardust/IAliasResponse";
import { IConfiguration } from "../../../models/configuration/IConfiguration";
import { STARDUST } from "../../../models/db/protocolVersion";
import { NetworkService } from "../../../services/networkService";
import { StardustTangleHelper } from "../../../utils/stardust/stardustTangleHelper";
import { StardustApiService } from "../../../services/stardust/stardustApiService";
import { ValidationHelper } from "../../../utils/validationHelper";

/**
Expand All @@ -25,6 +25,6 @@ export async function get(config: IConfiguration, request: IAliasRequest): Promi
return {};
}

const tangleHelper = ServiceFactory.get<StardustTangleHelper>(`tangle-helper-${networkConfig.network}`);
return tangleHelper.aliasDetails(request.aliasId);
const stardustApiService = ServiceFactory.get<StardustApiService>(`api-service-${networkConfig.network}`);
return stardustApiService.aliasDetails(request.aliasId);
}
6 changes: 3 additions & 3 deletions api/src/routes/stardust/block/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IBlockResponse } from "../../../models/api/stardust/IBlockResponse";
import { IConfiguration } from "../../../models/configuration/IConfiguration";
import { STARDUST } from "../../../models/db/protocolVersion";
import { NetworkService } from "../../../services/networkService";
import { StardustTangleHelper } from "../../../utils/stardust/stardustTangleHelper";
import { StardustApiService } from "../../../services/stardust/stardustApiService";
import { ValidationHelper } from "../../../utils/validationHelper";

/**
Expand All @@ -25,6 +25,6 @@ export async function get(_: IConfiguration, request: IBlockRequest): Promise<IB
return {};
}

const tangleHelper = ServiceFactory.get<StardustTangleHelper>(`tangle-helper-${networkConfig.network}`);
return tangleHelper.block(request.blockId);
const stardustApiService = ServiceFactory.get<StardustApiService>(`api-service-${networkConfig.network}`);
return stardustApiService.block(request.blockId);
}
6 changes: 3 additions & 3 deletions api/src/routes/stardust/block/metadata/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IBlockRequest } from "../../../../models/api/stardust/IBlockRequest";
import { IConfiguration } from "../../../../models/configuration/IConfiguration";
import { STARDUST } from "../../../../models/db/protocolVersion";
import { NetworkService } from "../../../../services/networkService";
import { StardustTangleHelper } from "../../../../utils/stardust/stardustTangleHelper";
import { StardustApiService } from "../../../../services/stardust/stardustApiService";
import { ValidationHelper } from "../../../../utils/validationHelper";

/**
Expand All @@ -25,6 +25,6 @@ export async function get(_: IConfiguration, request: IBlockRequest): Promise<IB
return {};
}

const tangleHelper = ServiceFactory.get<StardustTangleHelper>(`tangle-helper-${networkConfig.network}`);
return tangleHelper.blockDetails(request.blockId);
const stardustApiService = ServiceFactory.get<StardustApiService>(`api-service-${networkConfig.network}`);
return stardustApiService.blockDetails(request.blockId);
}
6 changes: 3 additions & 3 deletions api/src/routes/stardust/foundry/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IFoundryResponse } from "../../../models/api/stardust/foundry/IFoundryR
import { IConfiguration } from "../../../models/configuration/IConfiguration";
import { STARDUST } from "../../../models/db/protocolVersion";
import { NetworkService } from "../../../services/networkService";
import { StardustTangleHelper } from "../../../utils/stardust/stardustTangleHelper";
import { StardustApiService } from "../../../services/stardust/stardustApiService";
import { ValidationHelper } from "../../../utils/validationHelper";

/**
Expand All @@ -25,6 +25,6 @@ export async function get(config: IConfiguration, request: IFoundryRequest): Pro
return {};
}

const tangleHelper = ServiceFactory.get<StardustTangleHelper>(`tangle-helper-${networkConfig.network}`);
return tangleHelper.foundryDetails(request.foundryId);
const stardustApiService = ServiceFactory.get<StardustApiService>(`api-service-${networkConfig.network}`);
return stardustApiService.foundryDetails(request.foundryId);
}
6 changes: 3 additions & 3 deletions api/src/routes/stardust/milestone/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IMilestoneDetailsResponse } from "../../../models/api/stardust/mileston
import { IConfiguration } from "../../../models/configuration/IConfiguration";
import { STARDUST } from "../../../models/db/protocolVersion";
import { NetworkService } from "../../../services/networkService";
import { StardustTangleHelper } from "../../../utils/stardust/stardustTangleHelper";
import { StardustApiService } from "../../../services/stardust/stardustApiService";
import { ValidationHelper } from "../../../utils/validationHelper";

/**
Expand All @@ -25,8 +25,8 @@ export async function get(config: IConfiguration, request: IMilestoneDetailsRequ
return {};
}

const tangleHelper = ServiceFactory.get<StardustTangleHelper>(`tangle-helper-${networkConfig.network}`);
const milestoneDetails = await tangleHelper.milestoneDetailsByIndex(Number(request.milestoneIndex));
const stardustApiService = ServiceFactory.get<StardustApiService>(`api-service-${networkConfig.network}`);
const milestoneDetails = await stardustApiService.milestoneDetailsByIndex(Number(request.milestoneIndex));

return milestoneDetails;
}
6 changes: 3 additions & 3 deletions api/src/routes/stardust/nft/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { INftDetailsResponse } from "../../../models/api/stardust/nft/INftDetail
import { IConfiguration } from "../../../models/configuration/IConfiguration";
import { STARDUST } from "../../../models/db/protocolVersion";
import { NetworkService } from "../../../services/networkService";
import { StardustTangleHelper } from "../../../utils/stardust/stardustTangleHelper";
import { StardustApiService } from "../../../services/stardust/stardustApiService";
import { ValidationHelper } from "../../../utils/validationHelper";

/**
Expand All @@ -25,6 +25,6 @@ export async function get(config: IConfiguration, request: INftDetailsRequest):
return {};
}

const tangleHelper = ServiceFactory.get<StardustTangleHelper>(`tangle-helper-${networkConfig.network}`);
return tangleHelper.nftDetails(request.nftId);
const stardustApiService = ServiceFactory.get<StardustApiService>(`api-service-${networkConfig.network}`);
return stardustApiService.nftDetails(request.nftId);
}
6 changes: 3 additions & 3 deletions api/src/routes/stardust/output/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IOutputDetailsResponse } from "../../../models/api/stardust/IOutputDeta
import { IConfiguration } from "../../../models/configuration/IConfiguration";
import { STARDUST } from "../../../models/db/protocolVersion";
import { NetworkService } from "../../../services/networkService";
import { StardustTangleHelper } from "../../../utils/stardust/stardustTangleHelper";
import { StardustApiService } from "../../../services/stardust/stardustApiService";
import { ValidationHelper } from "../../../utils/validationHelper";

/**
Expand All @@ -25,6 +25,6 @@ export async function get(config: IConfiguration, request: IOutputDetailsRequest
return {};
}

const tangleHelper = ServiceFactory.get<StardustTangleHelper>(`tangle-helper-${networkConfig.network}`);
return tangleHelper.outputDetails(request.outputId);
const stardustApiService = ServiceFactory.get<StardustApiService>(`api-service-${networkConfig.network}`);
return stardustApiService.outputDetails(request.outputId);
}
8 changes: 4 additions & 4 deletions api/src/routes/stardust/output/tagged/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { INftOutputsResponse } from "../../../../models/api/stardust/nft/INftOut
import { IConfiguration } from "../../../../models/configuration/IConfiguration";
import { STARDUST } from "../../../../models/db/protocolVersion";
import { NetworkService } from "../../../../services/networkService";
import { StardustApiService } from "../../../../services/stardust/stardustApiService";
import { Converter } from "../../../../utils/convertUtils";
import { StardustTangleHelper } from "../../../../utils/stardust/stardustTangleHelper";
import { ValidationHelper } from "../../../../utils/validationHelper";

/**
Expand All @@ -29,12 +29,12 @@ export async function get(_: IConfiguration, request: ITaggedOutputsRequest): Pr
}

const tagHex = Converter.utf8ToHex(request.tag, true);
const tangleHelper = ServiceFactory.get<StardustTangleHelper>(`tangle-helper-${networkConfig.network}`);
const stardustApiService = ServiceFactory.get<StardustApiService>(`api-service-${networkConfig.network}`);

if (request.outputType === "basic") {
return tangleHelper.taggedBasicOutputs(tagHex, 10, request.cursor);
return stardustApiService.taggedBasicOutputs(tagHex, 10, request.cursor);
} else if (request.outputType === "nft") {
return tangleHelper.taggedNftOutputs(tagHex, 10, request.cursor);
return stardustApiService.taggedNftOutputs(tagHex, 10, request.cursor);
}

return { error: "Unsupported output type" };
Expand Down
6 changes: 3 additions & 3 deletions api/src/routes/stardust/participation/events/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IParticipationEventResponse } from "../../../../models/api/stardust/par
import { IConfiguration } from "../../../../models/configuration/IConfiguration";
import { STARDUST } from "../../../../models/db/protocolVersion";
import { NetworkService } from "../../../../services/networkService";
import { StardustTangleHelper } from "../../../../utils/stardust/stardustTangleHelper";
import { StardustApiService } from "../../../../services/stardust/stardustApiService";
import { ValidationHelper } from "../../../../utils/validationHelper";

/**
Expand All @@ -24,6 +24,6 @@ export async function get(config: IConfiguration, request: IParticipationEventRe
return {};
}

const tangleHelper = ServiceFactory.get<StardustTangleHelper>(`tangle-helper-${networkConfig.network}`);
return tangleHelper.participationEventDetails(request.eventId);
const stardustApiService = ServiceFactory.get<StardustApiService>(`api-service-${networkConfig.network}`);
return stardustApiService.participationEventDetails(request.eventId);
}
6 changes: 3 additions & 3 deletions api/src/routes/stardust/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ISearchResponse } from "../../models/api/stardust/ISearchResponse";
import { IConfiguration } from "../../models/configuration/IConfiguration";
import { STARDUST } from "../../models/db/protocolVersion";
import { NetworkService } from "../../services/networkService";
import { StardustTangleHelper } from "../../utils/stardust/stardustTangleHelper";
import { StardustApiService } from "../../services/stardust/stardustApiService";
import { ValidationHelper } from "../../utils/validationHelper";

/**
Expand All @@ -25,6 +25,6 @@ export async function search(_: IConfiguration, request: ISearchRequest): Promis
return {};
}

const tangleHelper = ServiceFactory.get<StardustTangleHelper>(`tangle-helper-${networkConfig.network}`);
return tangleHelper.search(request.query);
const stardustApiService = ServiceFactory.get<StardustApiService>(`api-service-${networkConfig.network}`);
return stardustApiService.search(request.query);
}
6 changes: 3 additions & 3 deletions api/src/routes/stardust/transaction/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ITransactionDetailsResponse } from "../../../models/api/stardust/ITrans
import { IConfiguration } from "../../../models/configuration/IConfiguration";
import { STARDUST } from "../../../models/db/protocolVersion";
import { NetworkService } from "../../../services/networkService";
import { StardustTangleHelper } from "../../../utils/stardust/stardustTangleHelper";
import { StardustApiService } from "../../../services/stardust/stardustApiService";
import { ValidationHelper } from "../../../utils/validationHelper";

/**
Expand All @@ -25,6 +25,6 @@ export async function get(config: IConfiguration, request: ITransactionDetailsRe
return {};
}

const tangleHelper = ServiceFactory.get<StardustTangleHelper>(`tangle-helper-${networkConfig.network}`);
return tangleHelper.transactionIncludedBlock(request.transactionId);
const stardustApiService = ServiceFactory.get<StardustApiService>(`api-service-${networkConfig.network}`);
return stardustApiService.transactionIncludedBlock(request.transactionId);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* eslint-disable no-warning-comments */
import { OutputResponse, Client, IOutputsResponse, HexEncodedString, Utils, NftQueryParameter } from "@iota/sdk";
import { SearchExecutor } from "./searchExecutor";
import { SearchQueryBuilder, SearchQuery } from "./searchQueryBuilder";
import { addressBalance, blockIdFromMilestonePayload } from "./utils";
import { NodeInfoService } from "./nodeInfoService";
import { ServiceFactory } from "../../factories/serviceFactory";
import logger from "../../logger";
import { IBasicOutputsResponse } from "../../models/api/stardust/basic/IBasicOutputsResponse";
Expand All @@ -24,13 +22,15 @@ import { IParticipationEventInfo } from "../../models/api/stardust/participation
import { IParticipationEventResponse } from "../../models/api/stardust/participation/IParticipationEventResponse";
import { IParticipationEventStatus } from "../../models/api/stardust/participation/IParticipationEventStatus";
import { INetwork } from "../../models/db/INetwork";
import { NodeInfoService } from "../../services/stardust/nodeInfoService";
import { HexHelper } from "../hexHelper";
import { HexHelper } from "../../utils/hexHelper";
import { SearchExecutor } from "../../utils/stardust/searchExecutor";
import { SearchQuery, SearchQueryBuilder } from "../../utils/stardust/searchQueryBuilder";
import { addressBalance, blockIdFromMilestonePayload } from "../../utils/stardust/utils";

/**
* Helper functions for use with tangle.
*/
export class StardustTangleHelper {
export class StardustApiService {
/**
* The network in context.
*/
Expand Down
Loading

0 comments on commit 6cb41d3

Please sign in to comment.