diff --git a/packages/grid_client/src/clients/tf-grid/client.ts b/packages/grid_client/src/clients/tf-grid/client.ts index b3a8d9b320..d1d4eac503 100644 --- a/packages/grid_client/src/clients/tf-grid/client.ts +++ b/packages/grid_client/src/clients/tf-grid/client.ts @@ -4,6 +4,7 @@ import { ValidationError } from "@threefold/types"; import { KeypairType } from "../../zos/deployment"; import { TFBalances } from "./balances"; import { TFContracts } from "./contracts"; +import { TFFarms } from "./farms"; import { TFKVStore } from "./kvstore"; import { TFTermsAndConditions } from "./terms_and_conditions"; import { TFTBridge } from "./tftBridge"; @@ -18,7 +19,7 @@ class TFClient extends Client { kvStore: TFKVStore = new TFKVStore(this); termsAndConditions: TFTermsAndConditions = new TFTermsAndConditions(this); tftBridge: TFTBridge = new TFTBridge(this); - + farms: TFFarms = new TFFarms(this); constructor( public url: string, public mnemonic: string, diff --git a/packages/grid_client/src/clients/tf-grid/farms.ts b/packages/grid_client/src/clients/tf-grid/farms.ts new file mode 100644 index 0000000000..8d2e266638 --- /dev/null +++ b/packages/grid_client/src/clients/tf-grid/farms.ts @@ -0,0 +1,25 @@ +import { ExtrinsicResult, Farm, Farms } from "@threefold/tfchain_client"; + +import { RemoveFarmIPModel } from "../../modules"; + +/** + * `TFFarms` is a subclass of `Farms` that provides additional functionality. + */ +class TFFarms extends Farms { + /** + * Removes farm IPs + * + * @param {RemoveFarmIPModel[]} options - An array of options used to remove farm IPs + * @returns {Promise} A promise that resolves when all extrinsics have been applied + * @see {applyAllExtrinsics} - The method used to apply all extrinsics + */ + async removeFarmIps(options: RemoveFarmIPModel[]) { + const extrinsics: ExtrinsicResult[] = []; + for (const option of options) { + extrinsics.push(await this.removeFarmIp(option)); + } + await this.client.applyAllExtrinsics(extrinsics); + } +} + +export { TFFarms }; diff --git a/packages/grid_client/src/clients/tf-grid/index.ts b/packages/grid_client/src/clients/tf-grid/index.ts index 3ef33641a9..16e0a1b157 100644 --- a/packages/grid_client/src/clients/tf-grid/index.ts +++ b/packages/grid_client/src/clients/tf-grid/index.ts @@ -6,3 +6,4 @@ export * from "./balances"; export * from "./tftPrice"; export * from "./terms_and_conditions"; export * from "./tftBridge"; +export * from "./farms"; diff --git a/packages/grid_client/src/modules/farms.ts b/packages/grid_client/src/modules/farms.ts index b2e57ff221..1060aa68bc 100644 --- a/packages/grid_client/src/modules/farms.ts +++ b/packages/grid_client/src/modules/farms.ts @@ -39,6 +39,19 @@ class Farms { return (await this.client.farms.removeFarmIp(options)).apply(); } + @expose + @validateInput + @checkBalance + async removeFarmIps(options: RemoveFarmIPModel[]) { + /** + * Removes farm IPs + * + * @param {RemoveFarmIPModel[]} options - An array of options used to remove farm IPs + * @returns {Promise} A promise that resolves when all farm IPs have been removed + */ + return await this.client.farms.removeFarmIps(options); + } + @expose @validateInput @checkBalance diff --git a/packages/playground/src/dashboard/components/public_ips_table.vue b/packages/playground/src/dashboard/components/public_ips_table.vue index 3245ccf154..9a3ba1d8c1 100644 --- a/packages/playground/src/dashboard/components/public_ips_table.vue +++ b/packages/playground/src/dashboard/components/public_ips_table.vue @@ -1,27 +1,21 @@