diff --git a/packages/grid_client/src/high_level/network.ts b/packages/grid_client/src/high_level/network.ts index ba5da767d3..56dc1b689b 100644 --- a/packages/grid_client/src/high_level/network.ts +++ b/packages/grid_client/src/high_level/network.ts @@ -46,6 +46,12 @@ class NetworkHL extends HighLevelBase { } return twinDeployments; } + + async hasNode(networkName: string, ipRange: string, nodeId: number): Promise { + const network = new Network(networkName, ipRange, this.config); + await network.load(); + return network.nodeExists(nodeId); + } } export { NetworkHL }; diff --git a/packages/grid_client/src/modules/models.ts b/packages/grid_client/src/modules/models.ts index f2b74f009b..ea8ed1e3b0 100644 --- a/packages/grid_client/src/modules/models.ts +++ b/packages/grid_client/src/modules/models.ts @@ -648,6 +648,12 @@ class NetworkAddNodeModel { @Expose() @IsString() @IsOptional() description?: string; } +class NetworkHasNodeModel { + @Expose() @IsString() @IsNotEmpty() @IsAlphanumeric() @MaxLength(NameLength) name: string; + @Expose() @IsString() @IsNotEmpty() ipRange: string; + @Expose() @IsInt() @IsNotEmpty() @Min(1) nodeId: number; +} + class NetworkGetModel { @Expose() @IsString() @IsNotEmpty() @IsAlphanumeric() @MaxLength(NameLength) name: string; } @@ -778,6 +784,7 @@ export { SetServiceContractMetadataModel, GetServiceContractModel, NetworkAddNodeModel, + NetworkHasNodeModel, NetworkGetModel, NodeGetModel, SetDedicatedNodeExtraFeesModel, diff --git a/packages/grid_client/src/modules/networks.ts b/packages/grid_client/src/modules/networks.ts index a7aa908628..ae7d0c2c73 100644 --- a/packages/grid_client/src/modules/networks.ts +++ b/packages/grid_client/src/modules/networks.ts @@ -5,7 +5,7 @@ import { expose } from "../helpers/expose"; import { validateInput } from "../helpers/validator"; import { NetworkHL } from "../high_level/network"; import { BaseModule } from "./base"; -import { NetworkAddNodeModel, NetworkGetModel } from "./models"; +import { NetworkAddNodeModel, NetworkGetModel, NetworkHasNodeModel } from "./models"; import { checkBalance } from "./utils"; class NetworkModule extends BaseModule { @@ -36,6 +36,12 @@ class NetworkModule extends BaseModule { return await this._list(); } + @expose + @validateInput + async hasNode(options: NetworkHasNodeModel): Promise { + return await this.network.hasNode(options.name, options.ipRange, options.nodeId); + } + @expose @validateInput async getWireGuardConfigs(options: NetworkGetModel) {