diff --git a/packages/grid_client/src/clients/tf-grid/contracts.ts b/packages/grid_client/src/clients/tf-grid/contracts.ts index be5084abd1..1f709823ea 100644 --- a/packages/grid_client/src/clients/tf-grid/contracts.ts +++ b/packages/grid_client/src/clients/tf-grid/contracts.ts @@ -12,6 +12,7 @@ import { ExtrinsicResult, GetDedicatedNodePriceOptions, NodeContractUsedResources, + OptOutV3BillingOptions, SetDedicatedNodeExtraFeesOptions, } from "@threefold/tfchain_client"; import { GridClientError } from "@threefold/types"; @@ -707,6 +708,12 @@ class TFContracts extends Contracts { extraFee: feeUSD, }); } + + async optOutV3Billing(options: OptOutV3BillingOptions) { + return await super.optOutV3Billing({ + nodeId: options.nodeId, + }); + } } export { TFContracts }; diff --git a/packages/grid_client/src/modules/contracts.ts b/packages/grid_client/src/modules/contracts.ts index 1a75795bd3..89f9fd441c 100644 --- a/packages/grid_client/src/modules/contracts.ts +++ b/packages/grid_client/src/modules/contracts.ts @@ -43,10 +43,12 @@ import { GetActiveContractsModel, GetDedicatedNodePriceModel, GetServiceContractModel, + IsNodeOptedOutOfV3BillingModel, NameContractCreateModel, NameContractGetModel, NodeContractCreateModel, NodeContractUpdateModel, + OptOutV3BillingModel, RentContractCreateModel, RentContractGetModel, ServiceContractApproveModel, @@ -215,6 +217,13 @@ class Contracts { return await this.client.contracts.getDedicatedNodeExtraFee(options); } + /** Returns whether the node has opted out of v3 billing. */ + @expose + @validateInput + async isNodeOptedOutOfV3Billing(options: IsNodeOptedOutOfV3BillingModel): Promise { + return await this.client.contracts.isNodeOptedOutOfV3Billing(options); + } + /** * Retrieves active `contract IDs` based on the provided node ID. * @@ -526,6 +535,27 @@ class Contracts { async setDedicatedNodeExtraFee(options: SetDedicatedNodeExtraFeesModel) { return (await this.client.contracts.setDedicatedNodeExtraFee(options)).apply(); } + + /** + * Opts out of billing for a v3 node. + * + * This method allows farmers to stop billing flows for a specific v3 node. + * After opting out, only Threefold admins will be able to create contracts on that node. + * + * @param {OptOutV3BillingModel} options - The options object containing the nodeId to opt out of billing. + * @returns {Promise} A promise that resolves to the node ID for opting out of billing. + * @decorators + * - `@expose`: Exposes the method for external use. + * - `@validateInput`: Validates the input options. + * - `@checkBalance`: Checks the balance before proceeding. + */ + @expose + @validateInput + @checkBalance + async optOutV3Billing(options: OptOutV3BillingModel) { + return (await this.client.contracts.optOutV3Billing(options)).apply(); + } + /** * Get contract discount package * @param {ContractDiscountPackage} options diff --git a/packages/grid_client/src/modules/models.ts b/packages/grid_client/src/modules/models.ts index 8ca86e5735..311157e3bc 100644 --- a/packages/grid_client/src/modules/models.ts +++ b/packages/grid_client/src/modules/models.ts @@ -861,10 +861,18 @@ class SetDedicatedNodeExtraFeesModel { @Expose() @IsNumber() @IsNotEmpty() @Min(0) extraFee: number; } +class OptOutV3BillingModel { + @Expose() @IsInt() @IsNotEmpty() @Min(1) nodeId: number; +} + class GetDedicatedNodePriceModel { @Expose() @IsInt() @IsNotEmpty() @Min(1) nodeId: number; } +class IsNodeOptedOutOfV3BillingModel { + @Expose() @IsInt() @IsNotEmpty() @Min(1) nodeId: number; +} + class SwapToStellarModel { @Expose() @IsNotEmpty() @IsString() target: string; @Expose() @IsNotEmpty() @Min(1) amount: number; @@ -1067,7 +1075,9 @@ export { NetworkGetModel, NodeGetModel, SetDedicatedNodeExtraFeesModel, + OptOutV3BillingModel, GetDedicatedNodePriceModel, + IsNodeOptedOutOfV3BillingModel, SwapToStellarModel, ListenToMintCompletedModel, AddFarmIPModel, diff --git a/packages/playground/src/dashboard/components/node_actions.vue b/packages/playground/src/dashboard/components/node_actions.vue new file mode 100644 index 0000000000..79b56aee17 --- /dev/null +++ b/packages/playground/src/dashboard/components/node_actions.vue @@ -0,0 +1,45 @@ + + + diff --git a/packages/playground/src/dashboard/components/opt_out_v3_billing.vue b/packages/playground/src/dashboard/components/opt_out_v3_billing.vue new file mode 100644 index 0000000000..baf1c372fb --- /dev/null +++ b/packages/playground/src/dashboard/components/opt_out_v3_billing.vue @@ -0,0 +1,76 @@ + + + diff --git a/packages/playground/src/dashboard/components/public_config.vue b/packages/playground/src/dashboard/components/public_config.vue index 1a0de2adfa..8110a40c51 100644 --- a/packages/playground/src/dashboard/components/public_config.vue +++ b/packages/playground/src/dashboard/components/public_config.vue @@ -1,14 +1,14 @@