From a9c9a81b5ab895a7e0867eae37c2ca44cab68d33 Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Thu, 19 Feb 2026 15:26:16 +0200 Subject: [PATCH 1/2] Support opt out from billing, stop propagation on icon click in node actions --- .../src/clients/tf-grid/contracts.ts | 7 + packages/grid_client/src/modules/contracts.ts | 22 + packages/grid_client/src/modules/models.ts | 5 + .../components/opt_out_v3_billing.vue | 71 + .../dashboard/components/public_config.vue | 6 +- .../dashboard/components/set_extra_fee.vue | 6 +- .../src/dashboard/components/user_nodes.vue | 15 +- packages/tfchain_client/src/contracts.ts | 1287 +++++++++-------- 8 files changed, 771 insertions(+), 648 deletions(-) create mode 100644 packages/playground/src/dashboard/components/opt_out_v3_billing.vue 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..2a122c9413 100644 --- a/packages/grid_client/src/modules/contracts.ts +++ b/packages/grid_client/src/modules/contracts.ts @@ -47,6 +47,7 @@ import { NameContractGetModel, NodeContractCreateModel, NodeContractUpdateModel, + OptOutV3BillingModel, RentContractCreateModel, RentContractGetModel, ServiceContractApproveModel, @@ -526,6 +527,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..3a19a2fc89 100644 --- a/packages/grid_client/src/modules/models.ts +++ b/packages/grid_client/src/modules/models.ts @@ -861,6 +861,10 @@ 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; } @@ -1067,6 +1071,7 @@ export { NetworkGetModel, NodeGetModel, SetDedicatedNodeExtraFeesModel, + OptOutV3BillingModel, GetDedicatedNodePriceModel, SwapToStellarModel, ListenToMintCompletedModel, 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..a31b56a5ca --- /dev/null +++ b/packages/playground/src/dashboard/components/opt_out_v3_billing.vue @@ -0,0 +1,71 @@ + + + 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 @@