diff --git a/packages/grid_client/scripts/client_loader.ts b/packages/grid_client/scripts/client_loader.ts index 38ff374bd9..839fdb7813 100644 --- a/packages/grid_client/scripts/client_loader.ts +++ b/packages/grid_client/scripts/client_loader.ts @@ -38,7 +38,7 @@ function setConfig() { * @example * * const deploymentName = 'testVM' - * const projectName = 'vm' + deploymentName + * const projectName = 'vm/' + deploymentName * const gc = await getClient(projectName) * await gc.machines.deploy({...}); * // When you deploy using this project name, you'll only be able to list your deployments using this same project name. diff --git a/packages/grid_client/scripts/config.json b/packages/grid_client/scripts/config.json index dddeb2c18b..8430566cb7 100644 --- a/packages/grid_client/scripts/config.json +++ b/packages/grid_client/scripts/config.json @@ -1,6 +1,6 @@ { "network": "dev", - "mnemonic": "", + "mnemonic": "actual reveal dish guilt inner film scheme between lonely myself material replace", "storeSecret": "", "ssh_key": "" } diff --git a/packages/grid_client/scripts/test.ts b/packages/grid_client/scripts/test.ts new file mode 100644 index 0000000000..d20dcc7920 --- /dev/null +++ b/packages/grid_client/scripts/test.ts @@ -0,0 +1,29 @@ +import { FilterOptions, GridClient, log, NodeInfo } from "../src"; +import { getClient } from "./client_loader"; + +async function pingNodes(client: GridClient, nodes: NodeInfo[]) { + for (const node of nodes) { + try { + const x = await client.zos.getNodePerfTests({ nodeId: node.nodeId }); + console.log({ x }); + } catch (error) { + log("node " + node.nodeId + " is not responding, trying different node."); + } + } +} + +async function main() { + const name = "newVMS"; + const grid3 = await getClient(`vm/${name}`); + const nodes = await grid3.capacity.filterNodes({ + gateway: true, + farmId: 1, + availableFor: await grid3.twins.get_my_twin_id(), + } as FilterOptions); + + await pingNodes(grid3, nodes); + + await grid3.disconnect(); +} + +main(); diff --git a/packages/grid_client/src/client.ts b/packages/grid_client/src/client.ts index 1601d40bbe..0075494ed5 100644 --- a/packages/grid_client/src/client.ts +++ b/packages/grid_client/src/client.ts @@ -211,7 +211,8 @@ class GridClient { } /** - * Gets the default URLs for the specified network environment. + * Gets the configured URLs (or the default URLs if not provided) for the specified network environment. + * * @param {NetworkEnv} network - The network environment. * diff --git a/packages/grid_client/src/clients/tf-grid/balances.ts b/packages/grid_client/src/clients/tf-grid/balances.ts index ddd6264337..221b58c1a6 100644 --- a/packages/grid_client/src/clients/tf-grid/balances.ts +++ b/packages/grid_client/src/clients/tf-grid/balances.ts @@ -13,7 +13,7 @@ class TFBalances extends Balances { /** * Get the balance for a specific address. * - * This method retrieves the balance for a specific address by dividing the retrieved balances by 10^7. + * This method retrieves the balance for a specific address in TFT. * * @param {QueryBalancesGetOptions} options - The options for getting the balance, including the address. * @returns {Promise} A promise that resolves with the balance object containing free, reserved, and frozen amounts. @@ -28,10 +28,10 @@ class TFBalances extends Balances { } /** - * Transfer a specified amount of TFT (`ThreeFold Tokens`) to a given address. + * Prepare a Transfer extrinsic for a specified amount of TFT (`ThreeFold Tokens`) to a given address. * * @param {BalanceTransferOptions} options - The transfer options, including the destination address and the amount to transfer. - * @returns {Promise>} A promise that resolves once the transfer is successfully completed. + * @returns {Promise>} A promise that resolves once the transfer extrinsic is created. */ async transfer(options: BalanceTransferOptions): Promise> { const decimalAmount = new Decimal(options.amount); diff --git a/packages/grid_client/src/clients/tf-grid/kvstore.ts b/packages/grid_client/src/clients/tf-grid/kvstore.ts index 3561390cf2..cddfb1b225 100644 --- a/packages/grid_client/src/clients/tf-grid/kvstore.ts +++ b/packages/grid_client/src/clients/tf-grid/kvstore.ts @@ -22,11 +22,11 @@ class TFKVStore extends KVStore { } /** - * Sets a `key-value` pair in the `key-value` store. + * Prepares a set extrinsic for a `key-value` pair in the `key-value` store. * If encryption is enabled, the value will be encrypted before storing. * * @param {KVStoreSetOptions & { encrypt?: boolean }} options - The options for setting the `key-value` pair. - * @returns {Promise>} - A promise that resolves once the `key-value` pair is set. + * @returns {Promise>} - A promise that resolves once the `key-value` set extrinsic is created. */ async set(options: KVStoreSetOptions & { encrypt?: boolean }): Promise> { if (options.encrypt === false) { diff --git a/packages/grid_client/src/clients/tf-grid/twins.ts b/packages/grid_client/src/clients/tf-grid/twins.ts index b5bb1d696e..287b87a67f 100644 --- a/packages/grid_client/src/clients/tf-grid/twins.ts +++ b/packages/grid_client/src/clients/tf-grid/twins.ts @@ -13,10 +13,10 @@ interface TwinOptions { */ class TFTwins extends Twins { /** - * Creates a new `twin` with the specified options. + * Prepare an extrinsic for creating a new `twin` with the specified options. * * @param options - The options for creating the `twin`, including the `relay` to connect to. - * @returns {Promise>} A promise that resolves with the created `twin`. + * @returns {Promise>} A promise that resolves with an extrinsic for `twin` creation. */ async create(options: TwinOptions): Promise> { const pk = generatePublicKey(this.client.mnemonicOrSecret!); @@ -24,10 +24,10 @@ class TFTwins extends Twins { } /** - * Updates an existing `twin` with the specified options. + * Prepare an extrinsic for updating an existing `twin` with the specified options. * * @param options - The options for updating the `twin`, including the `relay` to connect to. - * @returns {Promise>} A promise that resolves with the updated `twin`. + * @returns {Promise>} A promise that resolves with an extrinsic for the `twin` update. */ async update(options: TwinOptions): Promise> { const pk = generatePublicKey(this.client.mnemonicOrSecret!); diff --git a/packages/grid_client/src/modules/algorand.ts b/packages/grid_client/src/modules/algorand.ts index 44a66c4a45..419e09f9c9 100644 --- a/packages/grid_client/src/modules/algorand.ts +++ b/packages/grid_client/src/modules/algorand.ts @@ -210,7 +210,7 @@ class Algorand implements blockchainInterface { /** * Initializes a new account on the Algorand blockchain. * - * This method generates a new account using the provided secret key, saves the account under the specified name, + * This method loads an account using the provided secret key, saves the account under the specified name, * and returns the address of the created account. * * @param {AlgorandAccountInitModel} options - The options for initializing the account, including the name and secret key. diff --git a/packages/grid_client/src/modules/base.ts b/packages/grid_client/src/modules/base.ts index 50ad2f6537..d5fd52eb03 100644 --- a/packages/grid_client/src/modules/base.ts +++ b/packages/grid_client/src/modules/base.ts @@ -138,7 +138,6 @@ class BaseModule { * * This method processes the created and deleted contracts, updates the existing contracts, * and handles the backend storage operations for storing the contracts data. - * It also applies extrinsics to the TFChain client for updating the contracts on the blockchain. * * @param {string} name - The name of the deployment to save contracts for. * @param {DeploymentResultContracts} contracts - The contracts data containing created and deleted contracts. @@ -324,7 +323,7 @@ class BaseModule { } /** - * Lists all of the contracts based on the user secret. + * Lists the deployment names for the current user. * * @returns {Promise} - A promise that resolves to the list of contract names. */ @@ -920,7 +919,7 @@ class BaseModule { } /** - * Add a new machine to the deployment. + * Add a new [ZDB or K8S worker] to the deployment. * * @param deployment_name The name of the deployment. * @param node_id The ID of the node where the machine will be added. @@ -1014,10 +1013,10 @@ class BaseModule { * Finally, it saves the updated contracts and returns the result containing created, deleted, and updated contracts. * * @param {string} name - The name of the deployment to delete contracts for. - * @returns {Promise<{ created: Contract[]; deleted: Contract[]; updated: Contract[] }>} - A promise that resolves to an object containing the created, deleted, and updated contracts. + * @returns {Promise} - A promise that resolves to an object containing the created, deleted, and updated contracts. */ - async _delete(name: string): Promise<{ created: Contract[]; deleted: Contract[]; updated: Contract[] }> { - const contracts: { created: Contract[]; deleted: Contract[]; updated: Contract[] } = { + async _delete(name: string): Promise { + const contracts: DeploymentResultContracts = { created: [], deleted: [], updated: [], diff --git a/packages/grid_client/src/modules/blockchain.ts b/packages/grid_client/src/modules/blockchain.ts index e37769ba9b..cff7ff9af0 100644 --- a/packages/grid_client/src/modules/blockchain.ts +++ b/packages/grid_client/src/modules/blockchain.ts @@ -3,13 +3,30 @@ import { GridClientError, ValidationError } from "@threefold/types"; import { GridClientConfig } from "../config"; import { expose } from "../helpers/expose"; import { validateInput } from "../helpers/validator"; -import * as blockchain from "."; +import { algorand } from "./algorand"; import blockchainInterface, { blockchainType } from "./blockchainInterface"; +import { + BlockchainAssetsModel, + BlockchainCreateModel, + BlockchainCreateResultModel, + BlockchainDeleteModel, + BlockchainGetModel, + BlockchainGetResultModel, + BlockchainInitModel, + BlockchainListModel, + BlockchainListResultModel, + BlockchainPayModel, + BlockchainPayNoNameModel, + BlockchainSignModel, + BlockchainSignNoNameModel, +} from "./models"; +import { stellar } from "./stellar"; +import { tfchain } from "./tfchain"; class Blockchain implements blockchainInterface { - stellar: blockchain.stellar; - algorand: blockchain.algorand; - tfchain: blockchain.tfchain; + stellar: stellar; + algorand: algorand; + tfchain: tfchain; current_account: string; blockchain_type: blockchainType; @@ -20,9 +37,9 @@ class Blockchain implements blockchainInterface { * */ constructor(public config: GridClientConfig) { - this.stellar = new blockchain.stellar(config); - this.algorand = new blockchain.algorand(config); - this.tfchain = new blockchain.tfchain(config); + this.stellar = new stellar(config); + this.algorand = new algorand(config); + this.tfchain = new tfchain(config); } /** @@ -31,7 +48,7 @@ class Blockchain implements blockchainInterface { * @param {BlockchainGetModel} options - The options containing the account name to check. * @returns {Promise} The type of blockchain where the account exists or undefined. */ - async exist_in(options: blockchain.BlockchainGetModel): Promise { + async exist_in(options: BlockchainGetModel): Promise { if (await this.stellar.exist(options)) return blockchainType.stellar; else if (await this.algorand.exist(options)) return blockchainType.algorand; else if (await this.tfchain.exist(options)) return blockchainType.tfchain; @@ -48,7 +65,7 @@ class Blockchain implements blockchainInterface { */ @expose @validateInput - async exist(options: blockchain.BlockchainGetModel): Promise { + async exist(options: BlockchainGetModel): Promise { return ( (await this.stellar.exist({ name: options.name })) || (await this.algorand.exist({ name: options.name })) || @@ -70,7 +87,7 @@ class Blockchain implements blockchainInterface { */ @expose @validateInput - async select(options: blockchain.BlockchainGetModel): Promise { + async select(options: BlockchainGetModel): Promise { const account_exists = await this.exist(options); if (!account_exists) throw new ValidationError(`Account ${options.name} doesn't exist.`); @@ -96,7 +113,7 @@ class Blockchain implements blockchainInterface { */ @expose @validateInput - async create(options: blockchain.BlockchainCreateModel): Promise { + async create(options: BlockchainCreateModel): Promise { const account_exists = await this.exist(options); if (account_exists) throw new ValidationError(`Name ${options.name} already exists.`); @@ -118,16 +135,16 @@ class Blockchain implements blockchainInterface { */ @expose @validateInput - async sign(options: blockchain.BlockchainSignNoNameModel): Promise { + async sign(options: BlockchainSignNoNameModel): Promise { if (!this.current_account) throw new ValidationError(`No account is selected. Please select an account first.`); - const modified_options: blockchain.BlockchainSignModel = { name: this.current_account, content: options.content }; + const modified_options: BlockchainSignModel = { name: this.current_account, content: options.content }; return this[this.blockchain_type].sign(modified_options); } /** - * Initialize a new account on the specified blockchain type. + * Loads the account based on the specified blockchain type. * * This method delegates the initialization to the specific blockchain type based on the provided options. * @@ -139,7 +156,7 @@ class Blockchain implements blockchainInterface { */ @expose @validateInput - async init(options: blockchain.BlockchainInitModel): Promise { + async init(options: BlockchainInitModel): Promise { return this[options.blockchain_type].init(options); } @@ -156,7 +173,7 @@ class Blockchain implements blockchainInterface { */ @expose @validateInput - async get(): Promise { + async get(): Promise { if (!this.current_account) throw new ValidationError(`No account is selected. Please select an account first.`); const options = { name: this.current_account }; @@ -177,7 +194,7 @@ class Blockchain implements blockchainInterface { */ @expose @validateInput - async list(options?: blockchain.BlockchainListModel): Promise { + async list(options?: BlockchainListModel): Promise { if (!options || !options.blockchain_type) { const stellar_accounts = await this.stellar.list(); const algorand_accounts = await this.algorand.list(); @@ -201,7 +218,7 @@ class Blockchain implements blockchainInterface { */ @expose @validateInput - async assets(): Promise { + async assets(): Promise { if (!this.current_account) throw new ValidationError(`No account is selected. Please select an account first.`); const options = { name: this.current_account }; @@ -225,13 +242,13 @@ class Blockchain implements blockchainInterface { @expose @validateInput // TODO : bridge, still - async pay(options: blockchain.BlockchainPayNoNameModel): Promise { + async pay(options: BlockchainPayNoNameModel): Promise { if (!this.current_account) throw new ValidationError(`No account is selected. Please select an account first.`); if (this.blockchain_type != options.blockchain_type_dest) throw new GridClientError(`Transfer between blockchains isn't implemented yet.`); - const modified_options: blockchain.BlockchainPayModel = { + const modified_options: BlockchainPayModel = { name: this.current_account, blockchain_type_dest: options.blockchain_type_dest, description: options.description, @@ -259,7 +276,7 @@ class Blockchain implements blockchainInterface { async delete(): Promise { if (!this.current_account) throw new ValidationError(`No account is selected. Please select an account first.`); - const options: blockchain.BlockchainDeleteModel = { name: this.current_account }; + const options: BlockchainDeleteModel = { name: this.current_account }; return this[this.blockchain_type].delete(options); } diff --git a/packages/grid_client/src/modules/bridge.ts b/packages/grid_client/src/modules/bridge.ts index e24ef490fa..aa208d0ddf 100644 --- a/packages/grid_client/src/modules/bridge.ts +++ b/packages/grid_client/src/modules/bridge.ts @@ -7,7 +7,7 @@ class Bridge { client: TFClient; /** - * Class representing a Bridge for interacting with TFClient's TFTBridge functionality. + * Class representing a Bridge for interacting with TFChain's TFTBridge functionality. * * This class provides methods for listening to mint completion, getting withdrawal and deposit fees, * and swapping assets to Stellar network. diff --git a/packages/grid_client/src/modules/calculator.ts b/packages/grid_client/src/modules/calculator.ts index 41ede55e79..3ee9f0ba56 100644 --- a/packages/grid_client/src/modules/calculator.ts +++ b/packages/grid_client/src/modules/calculator.ts @@ -123,7 +123,7 @@ class Calculator { } /** - * Asynchronously retrieves the TFT price from the client. + * Asynchronously retrieves the TFT price from the TFChain. * * @returns {Promise} A promise that resolves to the TFT price. * @decorators @@ -138,7 +138,7 @@ class Calculator { } /** - * Asynchronously calculates the monthly cost in musd (millions of USD) based on the provided options. + * Asynchronously calculates the monthly cost in musd (milli USD) based on the provided options. * * @param {CalculatorModel} options - The calculator model options containing, sru, mru, and some other fields. * @returns {Promise<{ musd_month: number, dedicatedDiscount: number }>} A promise that resolves to an object containing the calculated monthly cost in musd and the discount for dedication nodes. diff --git a/packages/grid_client/src/modules/contracts.ts b/packages/grid_client/src/modules/contracts.ts index 2b0e845e32..571d8d456c 100644 --- a/packages/grid_client/src/modules/contracts.ts +++ b/packages/grid_client/src/modules/contracts.ts @@ -1,8 +1,9 @@ -import { Contract } from "@threefold/tfchain_client"; +import { Contract, ContractLock, ServiceContract } from "@threefold/tfchain_client"; import { DeploymentKeyDeletionError, InsufficientBalanceError } from "@threefold/types"; import * as PATH from "path"; import { + GqlContracts, GqlNameContract, GqlNodeContract, GqlRentContract, @@ -17,7 +18,32 @@ import { expose } from "../helpers/expose"; import { validateInput } from "../helpers/validator"; import { Nodes } from "../primitives/nodes"; import { BaseModule } from "./base"; -import * as modules from "./models"; +import { + BatchCancelContractsModel, + ContractCancelModel, + ContractConsumption, + ContractGetByNodeIdAndHashModel, + ContractGetModel, + ContractLockModel, + ContractState, + ContractStates, + CreateServiceContractModel, + GetActiveContractsModel, + GetDedicatedNodePriceModel, + GetServiceContractModel, + NameContractCreateModel, + NameContractGetModel, + NodeContractCreateModel, + NodeContractUpdateModel, + RentContractCreateModel, + RentContractGetModel, + ServiceContractApproveModel, + ServiceContractBillModel, + ServiceContractCancelModel, + SetDedicatedNodeExtraFeesModel, + SetServiceContractFeesModel, + SetServiceContractMetadataModel, +} from "./models"; import { checkBalance } from "./utils"; class Contracts { @@ -61,7 +87,7 @@ class Contracts { /** * Creates a new node contract. * - * @param {modules.NodeContractCreateModel} options - The options for creating the node contract. + * @param {NodeContractCreateModel} options - The options for creating the node contract. * @returns {Promise } A promise that resolves to the result of creating the node contract. * @decorators * - `@expose`: Exposes the method for external use. @@ -71,7 +97,7 @@ class Contracts { @expose @validateInput @checkBalance - async create_node(options: modules.NodeContractCreateModel): Promise { + async create_node(options: NodeContractCreateModel): Promise { return ( await this.client.contracts.createNode({ nodeId: options.node_id, @@ -86,7 +112,7 @@ class Contracts { /** * Creates a new name contract. * - * @param {modules.NameContractCreateModel} options - The options for creating the name contract. + * @param {NameContractCreateModel} options - The options for creating the name contract. * @returns {Promise} A promise that resolves to the result of creating the name contract. * @decorators * - `@expose`: Exposes the method for external use. @@ -96,14 +122,14 @@ class Contracts { @expose @validateInput @checkBalance - async create_name(options: modules.NameContractCreateModel): Promise { + async create_name(options: NameContractCreateModel): Promise { return (await this.client.contracts.createName(options)).apply(); } /** * Creates a new rent contract. * - * @param {modules.RentContractCreateModel} options - The options for creating the rent contract. + * @param {RentContractCreateModel} options - The options for creating the rent contract. * @returns {Promise} A promise that resolves to the result of creating the rent contract. * @decorators * - `@expose`: Exposes the method for external use. @@ -113,14 +139,14 @@ class Contracts { @expose @validateInput @checkBalance - async createRent(options: modules.RentContractCreateModel): Promise { + async createRent(options: RentContractCreateModel): Promise { return (await this.client.contracts.createRent(options)).apply(); } /** * Retrieves a contract based on the provided options. * - * @param {modules.ContractGetModel} options - The options to retrieve the contract. + * @param {ContractGetModel} options - The options to retrieve the contract. * @returns {Promise} A promise that resolves to the retrieved contract. * @decorators * - `@expose`: Exposes the method for external use. @@ -128,14 +154,14 @@ class Contracts { */ @expose @validateInput - async get(options: modules.ContractGetModel): Promise { + async get(options: ContractGetModel): Promise { return this.client.contracts.get(options); } /** * Retrieves the contract ID based on the provided node ID and hash. * - * @param {modules.ContractGetByNodeIdAndHashModel} options - The options containing the node ID and hash. + * @param {ContractGetByNodeIdAndHashModel} options - The options containing the node ID and hash. * @returns {Promise} A promise that resolves to the contract ID. * @decorators * - `@expose`: Exposes the method for external use. @@ -143,14 +169,14 @@ class Contracts { */ @expose @validateInput - async get_contract_id_by_node_id_and_hash(options: modules.ContractGetByNodeIdAndHashModel): Promise { + async get_contract_id_by_node_id_and_hash(options: ContractGetByNodeIdAndHashModel): Promise { return this.client.contracts.getContractIdByNodeIdAndHash({ nodeId: options.node_id, hash: options.hash }); } /** * Retrieves a `name contract ID` based on the provided options. * - * @param {modules.NameContractGetModel} options - The options to retrieve the name contract. + * @param {NameContractGetModel} options - The options to retrieve the name contract. * @returns {Promise} A promise that resolves to the retrieved `name contract ID`. * @decorators * - `@expose`: Exposes the method for external use. @@ -158,14 +184,14 @@ class Contracts { */ @expose @validateInput - async get_name_contract(options: modules.NameContractGetModel): Promise { + async get_name_contract(options: NameContractGetModel): Promise { return this.client.contracts.getContractIdByName(options); } /** * Retrieves the extra fee for a dedicated node based on the provided options. * - * @param {modules.GetDedicatedNodePriceModel} options - The options to retrieve the extra fee for a dedicated node. + * @param {GetDedicatedNodePriceModel} options - The options to retrieve the extra fee for a dedicated node. * @returns {Promise} A promise that resolves to the extra fee for the dedicated node. * @decorators * - `@expose`: Exposes the method for external use. @@ -173,14 +199,14 @@ class Contracts { */ @expose @validateInput - async getDedicatedNodeExtraFee(options: modules.GetDedicatedNodePriceModel): Promise { + async getDedicatedNodeExtraFee(options: GetDedicatedNodePriceModel): Promise { return await this.client.contracts.getDedicatedNodeExtraFee(options); } /** * Retrieves active `contract IDs` based on the provided node ID. * - * @param {modules.GetActiveContractsModel} options - The options containing the node ID. + * @param {GetActiveContractsModel} options - The options containing the node ID. * @returns {Promise} A promise that resolves to the active `contract IDs`. * @decorators * - `@expose`: Exposes the method for external use. @@ -188,14 +214,14 @@ class Contracts { */ @expose @validateInput - async getActiveContracts(options: modules.GetActiveContractsModel): Promise { + async getActiveContracts(options: GetActiveContractsModel): Promise { return await this.client.contracts.getActiveContracts(options); } /** * Retrieves the active rent `contract ID` for a specific node based on the provided options. * - * @param {modules.RentContractGetModel} options - The options to retrieve the active rent contract for a node. + * @param {RentContractGetModel} options - The options to retrieve the active rent contract for a node. * @returns {Promise} A promise that resolves to the active rent `contract ID`. * @decorators * - `@expose`: Exposes the method for external use. @@ -203,14 +229,14 @@ class Contracts { */ @expose @validateInput - async activeRentContractForNode(options: modules.RentContractGetModel): Promise { + async activeRentContractForNode(options: RentContractGetModel): Promise { return this.client.contracts.getContractIdByActiveRentForNode(options); } /** - * Locks a contract based on the provided options. + * Returns the lock details of the contract. * - * @param {modules.ContractLockModel} options - The options for locking the contract. + * @param {ContractLockModel} options - The options for locking the contract. * @returns {Promise} A promise that resolves when the contract is successfully locked. * @decorators * - `@expose`: Exposes the method for external use. @@ -218,14 +244,14 @@ class Contracts { */ @expose @validateInput - async contractLock(options: modules.ContractLockModel): Promise { + async contractLock(options: ContractLockModel): Promise { return this.client.contracts.contractLock(options); } /** * Updates a node contract. * - * @param {modules.NodeContractUpdateModel} options - The options for updating the node contract. + * @param {NodeContractUpdateModel} options - The options for updating the node contract. * @returns {Promise} A promise that resolves to the result of updating the node contract. * @decorators * - `@expose`: Exposes the method for external use. @@ -235,14 +261,14 @@ class Contracts { @expose @validateInput @checkBalance - async update_node(options: modules.NodeContractUpdateModel): Promise { + async update_node(options: NodeContractUpdateModel): Promise { return (await this.client.contracts.updateNode(options)).apply(); } /** * Cancels a contract based on the provided options. * - * @param {modules.ContractCancelModel} options - The options for canceling the contract. + * @param {ContractCancelModel} options - The options for canceling the contract. * @returns {Promise} A promise that resolves to the deleted `contract ID`. * @decorators * - `@expose`: Exposes the method for external use. @@ -252,32 +278,32 @@ class Contracts { @expose @validateInput @checkBalance - async cancel(options: modules.ContractCancelModel): Promise { + async cancel(options: ContractCancelModel): Promise { const deletedContract = await (await this.client.contracts.cancel(options)).apply(); await this.invalidateDeployment(options.id); return deletedContract; } /** - * Retrieves a list of `graphql contracts` associated with the current user. + * Retrieves a list of `contracts` associated with the current user. * - * @param {modules.ContractState} [options] - The state of the contracts to filter by. - * @returns {Promise<(GqlContracts)[]>} A promise that resolves to an array of `graphql contracts`. + * @param {ContractState} [options] - The state of the contracts to filter by. + * @returns {Promise<(GqlContracts)[]>} A promise that resolves to an array of `contracts`. * @decorators * - `@expose`: Exposes the method for external use. * - `@validateInput`: Validates the input options. */ @expose @validateInput - async listMyContracts(options?: modules.ContractState): Promise { + async listMyContracts(options?: ContractState): Promise { return this.client.contracts.listMyContracts({ graphqlURL: this.config.graphqlURL, stateList: options?.state }); } /** - * Retrieves a list of `graphql contracts` associated with a specific twin ID. + * Retrieves a list of `contracts` associated with a specific twin ID. * - * @param {modules.ContractsByTwinId} options - The options containing the twin ID. - * @returns {Promise } A promise that resolves to the list of `graphql contracts` associated with the specified twin ID. + * @param {ContractsByTwinId} options - The options containing the twin ID. + * @returns {Promise } A promise that resolves to the list of `contracts` associated with the specified twin ID. * @decorators * - `@expose`: Exposes the method for external use. * - `@validateInput`: Validates the input options. @@ -293,10 +319,10 @@ class Contracts { } /** - * Retrieves a list of `graphql contracts` associated with a specific address. + * Retrieves a list of `contracts` associated with a specific address. * - * @param {modules.ContractsByAddress} options - The options containing the address to retrieve `graphql contracts` for. - * @returns {Promise } A promise that resolves to the list of `graphql contracts` associated with the specified address. + * @param {ContractsByAddress} options - The options containing the address to retrieve `contracts` for. + * @returns {Promise } A promise that resolves to the list of `contracts` associated with the specified address. * @decorators * - `@expose`: Exposes the method for external use. * - `@validateInput`: Validates the input options. @@ -314,7 +340,7 @@ class Contracts { /** * Creates a new `service contract`. * - * @param {modules.CreateServiceContractModel} options - The options for creating the `service contract`. + * @param {CreateServiceContractModel} options - The options for creating the `service contract`. * @returns {Promise} A promise that resolves to the result of creating the `service contract`. * @decorators * - `@expose`: Exposes the method for external use. @@ -324,14 +350,14 @@ class Contracts { @expose @validateInput @checkBalance - async createServiceContract(options: modules.CreateServiceContractModel): Promise { + async createServiceContract(options: CreateServiceContractModel): Promise { return (await this.client.contracts.createService(options)).apply(); } /** * Approves a `service contract`. * - * @param {modules.ServiceContractApproveModel} options - The options for approving the `service contract`. + * @param {ServiceContractApproveModel} options - The options for approving the `service contract`. * @returns {Promise} A promise that resolves to the approved `service contract`. * @decorators * - `@expose`: Exposes the method for external use. @@ -341,14 +367,14 @@ class Contracts { @expose @validateInput @checkBalance - async approveServiceContract(options: modules.ServiceContractApproveModel): Promise { + async approveServiceContract(options: ServiceContractApproveModel): Promise { return (await this.client.contracts.approveService(options)).apply(); } /** * Bills a `service contract` based on the provided options. * - * @param {modules.ServiceContractBillModel} options - The options for billing the `service contract`. + * @param {ServiceContractBillModel} options - The options for billing the `service contract`. * @returns {Promise} A promise that resolves to the result of billing the `service contract`. * @decorators * - `@expose`: Exposes the method for external use. @@ -358,14 +384,14 @@ class Contracts { @expose @validateInput @checkBalance - async billServiceContract(options: modules.ServiceContractBillModel): Promise { + async billServiceContract(options: ServiceContractBillModel): Promise { return (await this.client.contracts.billService(options)).apply(); } /** * Cancels a `service contract` based on the provided options. * - * @param {modules.ServiceContractCancelModel} options - The options for canceling the `service contract`. + * @param {ServiceContractCancelModel} options - The options for canceling the `service contract`. * @returns {Promise} A promise that resolves to the canceled `service contract ID`. * @decorators * - `@expose`: Exposes the method for external use. @@ -375,14 +401,14 @@ class Contracts { @expose @validateInput @checkBalance - async cancelServiceContract(options: modules.ServiceContractCancelModel): Promise { + async cancelServiceContract(options: ServiceContractCancelModel): Promise { return (await this.client.contracts.cancelService(options)).apply(); } /** * Sets the fees for a `service contract`. * - * @param {modules.SetServiceContractFeesModel} options - The options for setting the fees for the `service contract`. + * @param {SetServiceContractFeesModel} options - The options for setting the fees for the `service contract`. * @returns {Promise} A promise that resolves to the result of setting the fees for the `service contract`. * @decorators * - `@expose`: Exposes the method for external use. @@ -392,14 +418,14 @@ class Contracts { @expose @validateInput @checkBalance - async setFeesServiceContract(options: modules.SetServiceContractFeesModel): Promise { + async setFeesServiceContract(options: SetServiceContractFeesModel): Promise { return (await this.client.contracts.setServiceFees(options)).apply(); } /** * Sets the metadata for a `service contract`. * - * @param {modules.SetServiceContractMetadataModel} options - The options for setting the metadata for the `service contract`. + * @param {SetServiceContractMetadataModel} options - The options for setting the metadata for the `service contract`. * @returns {Promise} A promise that resolves to the result of setting the metadata for the `service contract`. * @decorators * - `@expose`: Exposes the method for external use. @@ -409,14 +435,14 @@ class Contracts { @expose @validateInput @checkBalance - async setMetadataServiceContract(options: modules.SetServiceContractMetadataModel): Promise { + async setMetadataServiceContract(options: SetServiceContractMetadataModel): Promise { return (await this.client.contracts.setServiceMetadata(options)).apply(); } /** * Retrieves a `service contract` based on the provided options. * - * @param {modules.GetServiceContractModel} options - The options to retrieve the `service contract`. + * @param {GetServiceContractModel} options - The options to retrieve the `service contract`. * @returns {Promise} A Promise that resolves to the retrieved `service contract`. * @decorators * - `@expose`: Exposes the method for external use. @@ -424,7 +450,7 @@ class Contracts { */ @expose @validateInput - async getServiceContract(options: modules.GetServiceContractModel): Promise { + async getServiceContract(options: GetServiceContractModel): Promise { return this.client.contracts.getService(options); } @@ -454,7 +480,7 @@ class Contracts { /** * Cancels multiple contracts in batch. * - * @param {modules.BatchCancelContractsModel} options - The options for batch canceling contracts. + * @param {BatchCancelContractsModel} options - The options for batch canceling contracts. * @returns {Promise} A promise that resolves to an array of canceled `contract IDs`. * @decorators * - `@expose`: Exposes the method for external use. @@ -464,7 +490,7 @@ class Contracts { @expose @validateInput @checkBalance - async batchCancelContracts(options: modules.BatchCancelContractsModel): Promise { + async batchCancelContracts(options: BatchCancelContractsModel): Promise { const contracts = await this.client.contracts.batchCancelContracts(options.ids); for (const id of options.ids) { await this.invalidateDeployment(id); @@ -475,7 +501,7 @@ class Contracts { /** * Sets the extra fee for a `dedicated node`. * - * @param {modules.SetDedicatedNodeExtraFeesModel} options - The options for setting the extra fee for the `dedicated node`. + * @param {SetDedicatedNodeExtraFeesModel} options - The options for setting the extra fee for the `dedicated node`. * @returns A promise that resolves to the result of setting the extra fee for the `dedicated node`. * @decorators * - `@expose`: Exposes the method for external use. @@ -485,7 +511,7 @@ class Contracts { @expose @validateInput @checkBalance - async setDedicatedNodeExtraFee(options: modules.SetDedicatedNodeExtraFeesModel) { + async setDedicatedNodeExtraFee(options: SetDedicatedNodeExtraFeesModel) { return (await this.client.contracts.setDedicatedNodeExtraFee(options)).apply(); } @@ -500,14 +526,14 @@ class Contracts { */ @expose @validateInput - async getConsumption(options: modules.ContractConsumption): Promise { + async getConsumption(options: ContractConsumption): Promise { return this.client.contracts.getConsumption({ id: options.id, graphqlURL: this.config.graphqlURL }); } /** * Retrieves the deletion time of a contract based on the provided options. * - * @param {modules.ContractGetModel} options - The options to retrieve the deletion time of the contract. + * @param {ContractGetModel} options - The options to retrieve the deletion time of the contract. * @returns {Promise} A promise that resolves to the deletion time of the contract. * @decorators * - `@expose`: Exposes the method for external use. @@ -515,7 +541,7 @@ class Contracts { */ @expose @validateInput - async getDeletionTime(options: modules.ContractGetModel): Promise { + async getDeletionTime(options: ContractGetModel): Promise { return this.client.contracts.getDeletionTime(options); } @@ -535,7 +561,7 @@ class Contracts { rentContracts: {}, totalAmountLocked: 0, }; - const contracts = await this.listMyContracts({ state: [modules.ContractStates.GracePeriod] }); + const contracts = await this.listMyContracts({ state: [ContractStates.GracePeriod] }); if (contracts == undefined) return LockedContracts; diff --git a/packages/grid_client/src/modules/currency.ts b/packages/grid_client/src/modules/currency.ts index 8ef32c902e..72a30c9af9 100644 --- a/packages/grid_client/src/modules/currency.ts +++ b/packages/grid_client/src/modules/currency.ts @@ -33,7 +33,7 @@ class TFTUSDConversionService { /** * Convert the given amount from `USD` to `TFT` using the current conversion rate. * - * @param options - The currency model containing the amount in `USD` to convert. + * @param options - The currency model containing the amount in `USD`. * @returns A string representation of the converted amount in `TFT`. * @decorators * - `@expose`: Exposes the method for external use. @@ -49,7 +49,7 @@ class TFTUSDConversionService { /** * Convert the given amount from `TFT` to `USD` using the current conversion rate. * - * @param options - The currency model containing the amount in `TFT` to convert. + * @param options - The currency model containing the amount in `TFT`. * @returns A string representation of the converted amount in `USD`. * @decorators * - `@expose`: Exposes the method for external use. @@ -63,9 +63,9 @@ class TFTUSDConversionService { } /** - * Convert the given amount from `TFT` to `TFT` by multiplying with 24 hours. + * Changes the rate from hourly to daily. * - * @param options - The currency model containing the amount in `TFT` to convert. + * @param options - The currency model containing the amount in `TFT`. * @returns A string representation of the converted amount in `TFT`. * @decorators * - `@expose`: Exposes the method for external use. @@ -79,9 +79,9 @@ class TFTUSDConversionService { } /** - * Convert the given amount from `TFT` to `TFT` by multiplying with 30 days. + * Changes the rate from hourly to monthly. * - * @param options - The currency model containing the amount in `TFT` to convert. + * @param options - The currency model containing the amount in `TFT`. * @returns A string representation of the converted amount in `TFT`. * @decorators * - `@expose`: Exposes the method for external use. @@ -95,9 +95,9 @@ class TFTUSDConversionService { } /** - * Convert the given amount from TFT to TFT by multiplying with 12 months. + * Changes the rate from hourly to yearly. * - * @param options - The currency model containing the amount in TFT to convert. + * @param options - The currency model containing the amount in TFT. * @returns A string representation of the converted amount in TFT. * @decorators * - `@expose`: Exposes the method for external use. @@ -111,9 +111,9 @@ class TFTUSDConversionService { } /** - * Convert the given amount from USD to USD by multiplying with 24 hours. + * Changes the rate from hourly to daily. * - * @param options - The currency model containing the amount in USD to convert. + * @param options - The currency model containing the amount in USD. * @returns A string representation of the converted amount in USD. * @decorators * - `@expose`: Exposes the method for external use. @@ -127,9 +127,9 @@ class TFTUSDConversionService { } /** - * Convert the given amount from `USD` to `USD` by multiplying with 30 days. + * Changes the rate from hourly to monthly. * - * @param options - The currency model containing the amount in `USD` to convert. + * @param options - The currency model containing the amount in `USD`. * @returns A string representation of the converted amount in `USD`. * @decorators * - `@expose`: Exposes the method for external use. @@ -143,9 +143,9 @@ class TFTUSDConversionService { } /** - * Convert the given amount from `USD` to `USD` by multiplying with `12 months`. + * Changes the rate from hourly to yearly. * - * @param options - The currency model containing the amount in `USD` to convert. + * @param options - The currency model containing the amount in `USD`. * @returns A string representation of the converted amount in `USD`. * @decorators * - `@expose`: Exposes the method for external use. diff --git a/packages/grid_client/src/modules/gateway.ts b/packages/grid_client/src/modules/gateway.ts index ddcbde3d8f..73c3b11971 100644 --- a/packages/grid_client/src/modules/gateway.ts +++ b/packages/grid_client/src/modules/gateway.ts @@ -43,9 +43,9 @@ class GWModule extends BaseModule { } /** - * Deploys a gateway with FQDN. + * Deploys a gateway workload with FQDN. * - * This method deploys a gateway with the provided FQDN configuration. + * This method deploys a gateway workload with the provided FQDN configuration. * * It checks if another gateway deployment with the same name already exists, * emits a log event, creates the gateway deployment, handles the twin deployments, @@ -90,9 +90,9 @@ class GWModule extends BaseModule { } /** - * Deploys a gateway with a given name. + * Deploys a gateway workload with a given name, this name will be used as a subdomain to the gateway's domain. * - * This method deploys a gateway with the provided name configuration. + * This method deploys a gateway workload with the provided name configuration. * It checks if another gateway deployment with the same name already exists, * emits a log event, creates the gateway deployment, handles the twin deployments, * saves the contracts, and returns the deployed contracts. @@ -184,12 +184,8 @@ class GWModule extends BaseModule { @expose @validateInput @checkBalance - async delete_fqdn(options: GatewayFQDNDeleteModel): Promise<{ - created: Contract[]; - deleted: Contract[]; - updated: Contract[]; - }> { - events.emit("logs", `Start deleting the ZDB deployment with name ${options.name}`); + async delete_fqdn(options: GatewayFQDNDeleteModel): Promise { + events.emit("logs", `Start deleting the gateway deployment with name ${options.name}`); return await this._delete(options.name); } @@ -226,12 +222,8 @@ class GWModule extends BaseModule { @expose @validateInput @checkBalance - async delete_name(options: GatewayNameDeleteModel): Promise<{ - created: Contract[]; - deleted: Contract[]; - updated: Contract[]; - }> { - events.emit("logs", `Start deleting the ZDB deployment with name ${options.name}`); + async delete_name(options: GatewayNameDeleteModel): Promise { + events.emit("logs", `Start deleting the gateway deployment with name ${options.name}`); return await this._delete(options.name); } diff --git a/packages/grid_client/src/modules/k8s.ts b/packages/grid_client/src/modules/k8s.ts index 56afd40a57..eef2bc0600 100644 --- a/packages/grid_client/src/modules/k8s.ts +++ b/packages/grid_client/src/modules/k8s.ts @@ -337,11 +337,7 @@ class K8sModule extends BaseModule { @expose @validateInput @checkBalance - async delete(options: K8SDeleteModel): Promise<{ - created: Contract[]; - deleted: Contract[]; - updated: Contract[]; - }> { + async delete(options: K8SDeleteModel): Promise { events.emit("logs", `Start deleting the cluster with name ${options.name}`); return await this._delete(options.name); } diff --git a/packages/grid_client/src/modules/machines.ts b/packages/grid_client/src/modules/machines.ts index 604905662d..30f837ce1e 100644 --- a/packages/grid_client/src/modules/machines.ts +++ b/packages/grid_client/src/modules/machines.ts @@ -123,7 +123,8 @@ class MachinesModule extends BaseModule { * machines: [...], * }; * - * const result = await MachinesModule.deploy(options); + * const machineModel = new MachinesModule() + * const result = await machineModel.deploy(options); * console.log(result.contracts); * * @decorators @@ -152,7 +153,8 @@ class MachinesModule extends BaseModule { * * @example * - * const result = await MachinesModule.list(); + * const machineModel = new MachinesModule() + * const result = await machineModel.list(); * console.log(result); * * @decorators @@ -171,8 +173,9 @@ class MachinesModule extends BaseModule { * * @example * - * const result = await MachinesModule.getObj("testName"); - * console.log(result.contracts); + * const machineModel = new MachinesModule() + * const result = await machineModel.getObj("testName"); + * console.log(result); * */ async getObj(deploymentName: string): Promise { @@ -192,11 +195,12 @@ class MachinesModule extends BaseModule { * * @example * - * const options: NetworkAddNodeModel = { + * const options: MachinesGetModel = { * name: "test", * }; * - * const result = await MachinesModule.get(options); + * const machineModel = new MachinesModule() + * const result = await machineModel.get(options); * console.log(result); * * @decorators @@ -218,11 +222,12 @@ class MachinesModule extends BaseModule { * * @example * - * const options: NetworkAddNodeModel = { + * const options: MachinesDeleteModel = { * name: "test", * }; * - * const result = await MachinesModule.delete(options); + * const machineModel = new MachinesModule() + * const result = await machineModel.delete(options); * console.log(result); * * @decorators @@ -255,7 +260,8 @@ class MachinesModule extends BaseModule { * machines: [...], * }; * - * const result = await MachinesModule.update(options); + * const machineModel = new MachinesModule() + * const result = await machineModel.update(options); * console.log(result); * * @decorators @@ -298,7 +304,8 @@ class MachinesModule extends BaseModule { * // Add other required options here * }; * - * const result = await MachinesModule.add_machine(options); + * const machineModel = new MachinesModule() + * const result = await machineModel.add_machine(options); * console.log(result); * * @decorators @@ -380,7 +387,8 @@ class MachinesModule extends BaseModule { * deployment_name: "deploymentName", * }; * - * const result = await MachinesModule.delete_machine(options); + * const machineModel = new MachinesModule() + * const result = await machineModel.delete_machine(options); * console.log(result); * * @decorators diff --git a/packages/grid_client/src/modules/models.ts b/packages/grid_client/src/modules/models.ts index 662eb13fee..179d82797a 100644 --- a/packages/grid_client/src/modules/models.ts +++ b/packages/grid_client/src/modules/models.ts @@ -4,6 +4,7 @@ import { Expose, Transform, Type } from "class-transformer"; import { ArrayNotEmpty, IsAlphanumeric, + IsArray, IsBoolean, IsDefined, IsEnum, @@ -689,6 +690,11 @@ class NodeCPUTest { @Expose() result: CPUBenchmark | {}; } +class NodeHealthCheck { + @Expose() @IsArray() cache: []; + @Expose() @IsArray() network: []; +} + class NodeIPValidation { @Expose() @IsNotEmpty() @IsString() name: string; @Expose() @IsNotEmpty() @IsString() description: string; @@ -846,6 +852,58 @@ interface GPUCardInfo { vendor: string; } +class ZOSVersionResultModel { + @Expose() @IsString() @IsNotEmpty() zos: string; + @Expose() @IsString() @IsNotEmpty() zinit: string; +} + +class ZOSResources { + @Expose() @IsNumber() @IsNotEmpty() cru: number; + @Expose() @IsNumber() @IsNotEmpty() sru: number; + @Expose() @IsNumber() @IsNotEmpty() hru: number; + @Expose() @IsNumber() @IsNotEmpty() mru: number; + @Expose() @IsNumber() @IsNotEmpty() ipv4u: number; +} + +class ZOSNodeStatistics { + system: ZOSResources; + total: ZOSResources; + used: ZOSResources; + users: { + deployments: number; + workloads: number; + last_deployment_timestamp: number; + }; +} + +class ZOSNetworkInterfaces { + @Expose() @IsArray() ygg: string[]; + @Expose() @IsArray() zos: string[]; +} + +class ZOSNetworkPublicConfig { + @Expose() @IsString() type: string; + @Expose() @IsString() ipv4: string; + @Expose() @IsString() ipv6: string; + @Expose() @IsString() gw4: string; + @Expose() @IsString() gw6: string; + @Expose() @IsString() domain: string; +} + +class ZOSStoragePools { + @Expose() @IsString() @IsNotEmpty() name: string; + @Expose() @IsString() @IsNotEmpty() type: string; + @Expose() @IsNumber() size: number; + @Expose() @IsNumber() used: number; +} + +class ZOSNodePerfTestsResult { + @Expose() iperf?: NodeIPerf; + @Expose() publicIPValidation?: NodeIPValidation; + @Expose() healthCheck?: NodeHealthCheck; + @Expose() cpuBenchmark?: NodeCPUTest; +} + export { AlgorandAccountCreateModel, AlgorandAccountInitModel, @@ -984,5 +1042,12 @@ export { NodeCPUTest, NodeIPValidation, NodeIPerf, + NodeHealthCheck, CurrencyModel, + ZOSVersionResultModel, + ZOSNodeStatistics, + ZOSNetworkInterfaces, + ZOSNetworkPublicConfig, + ZOSStoragePools, + ZOSNodePerfTestsResult, }; diff --git a/packages/grid_client/src/modules/networks.ts b/packages/grid_client/src/modules/networks.ts index ac43e3593d..5c2ad34c4e 100644 --- a/packages/grid_client/src/modules/networks.ts +++ b/packages/grid_client/src/modules/networks.ts @@ -51,6 +51,8 @@ class NetworkModule extends BaseModule { * description: "Example node", * myceliumSeed: "seed123", * }; + * + * const networkModule = new NetworkModule(); * const result = await networkModule.addNode(nodeOptions); * console.log(result.contracts); * @@ -85,6 +87,8 @@ class NetworkModule extends BaseModule { * @returns {Promise} A promise that resolves to an array of network names. * * @example + * + * const networkModule = new NetworkModule(); * const networkNames = await networkModule.list(); * console.log(networkNames); * @@ -115,6 +119,8 @@ class NetworkModule extends BaseModule { * ipRange: "10.0.0.0/16", * nodeId: 123 * }; + * + * const networkModule = new NetworkModule(); * const doesNodeExist = await networkModule.hasNode(options); * console.log(doesNodeExist); // true or false * @@ -145,6 +151,8 @@ class NetworkModule extends BaseModule { * name: "exampleNetwork", * ipRange: "10.0.0.0/16" * }; + * + * const networkModule = new NetworkModule(); * const wireGuardConfigs = await networkModule.getWireGuardConfigs(options); * console.log(wireGuardConfigs); // ["config1", "config2", ...] * diff --git a/packages/grid_client/src/modules/qsfs_zdbs.ts b/packages/grid_client/src/modules/qsfs_zdbs.ts index 98eb6bdc5b..27487a22ae 100644 --- a/packages/grid_client/src/modules/qsfs_zdbs.ts +++ b/packages/grid_client/src/modules/qsfs_zdbs.ts @@ -1,4 +1,3 @@ -import { Contract } from "@threefold/tfchain_client"; import { ValidationError } from "@threefold/types"; import { GridClientConfig } from "../config"; @@ -33,7 +32,7 @@ class QSFSZdbsModule extends BaseModule { } /** - * Creates multiple QSFS ZDB deployments based on the provided options. + * Creates QSFS ZDB deployment, this deployment contains multiple zdb instances. * * @param {QSFSZDBSModel} options - The options for creating the QSFS ZDB deployments. * @returns {Promise} An array of TwinDeployment objects representing the created deployments. @@ -76,7 +75,7 @@ class QSFSZdbsModule extends BaseModule { } /** - * Deploys multiple QSFS ZDB deployments based on the provided options. + * Deploys QSFS ZDB deployment based on the provided options. * * @param {QSFSZDBSModel} options - The options for deploying the QSFS ZDBs. * @returns {Promise<{ contracts: DeploymentResultContracts }>} An object containing the contracts of the deployed ZDBs. @@ -141,11 +140,7 @@ class QSFSZdbsModule extends BaseModule { @expose @validateInput @checkBalance - async delete(options: QSFSZDBDeleteModel): Promise<{ - created: Contract[]; - deleted: Contract[]; - updated: Contract[]; - }> { + async delete(options: QSFSZDBDeleteModel): Promise { events.emit("logs", `Start deleting the QSFS ZDBs deployment with name ${options.name}`); return await this._delete(options.name); } diff --git a/packages/grid_client/src/modules/stellar.ts b/packages/grid_client/src/modules/stellar.ts index 78807a4f87..d204942cee 100644 --- a/packages/grid_client/src/modules/stellar.ts +++ b/packages/grid_client/src/modules/stellar.ts @@ -1,3 +1,4 @@ +import { ExtrinsicResult } from "@threefold/tfchain_client"; import { GridClientError, RequestError, ValidationError } from "@threefold/types"; import axios, { AxiosError } from "axios"; import { Buffer } from "buffer"; @@ -63,7 +64,7 @@ class Stellar implements blockchainInterface { * @param {any[]} extrinsics - The extrinsics to be saved to the `key-value` store backend. * @returns {Promise} - A promise that resolves once the extrinsics are saved to the backend. */ - private async saveIfKVStoreBackend(extrinsics: any[]): Promise { + private async saveIfKVStoreBackend(extrinsics: any[]) { if (this.config.backendStorageType === BackendStorageType.tfkvstore && extrinsics && extrinsics.length > 0) { extrinsics = extrinsics.filter(e => e !== undefined); if (extrinsics.length > 0) { @@ -173,7 +174,7 @@ class Stellar implements blockchainInterface { } /** - * Verifies the provided content using the public key and signed content. + * Verifies the provided signed content using the public key and content. * * @param {StellarWalletVerifyModel} options - The options containing the public key, content, and signed content. * @returns {boolean} - A boolean indicating whether the content is successfully verified. @@ -190,9 +191,9 @@ class Stellar implements blockchainInterface { } /** - * Initializes a new `Stellar wallet` with the provided `name` and `secret key`. + * Loads `Stellar wallet` based on the provided `name` and `secret key`. * - * This method generates a new `Stellar wallet` using the provided `secret key`, loads the account associated with the wallet's `public key`, and saves the wallet to the backend storage. + * This method loads the account associated with the wallet's `public key`, and saves the wallet to the backend storage. * * @param {StellarWalletInitModel} options - The options for initializing the `Stellar` wallet, including the name and `secret key`. * @returns {Promise} A Promise that resolves the `public key` of the initialized `Stellar` wallet. @@ -347,7 +348,7 @@ class Stellar implements blockchainInterface { } /** - * Retrieves the assets associated with a `Stellar wallet` by its `address` from the backend storage. + * Retrieves the assets associated with a `Stellar wallet` by its `address`. * * This method fetches the `balances` of the account associated with the provided `address` and returns the assets including the `asset code` and `balance`. * @@ -445,7 +446,7 @@ class Stellar implements blockchainInterface { * Deletes a wallet with the provided `name` from the backend storage. * * This method checks if a wallet with the given `name` exists, deletes it from the backend storage, - * and saves the changes to the backend if the storage type is `tfkvstore`. + * and saves the changes to the backend storage. * * @param {BlockchainDeleteModel} options - The options containing the name of the wallet to delete. * @returns {Promise} - A promise that resolves with a message indicating the deletion was successful. diff --git a/packages/grid_client/src/modules/tfchain.ts b/packages/grid_client/src/modules/tfchain.ts index 8be2fec631..7847a4533c 100644 --- a/packages/grid_client/src/modules/tfchain.ts +++ b/packages/grid_client/src/modules/tfchain.ts @@ -119,9 +119,9 @@ class TFChain implements blockchainInterface { } /** - * Initializes a new TFChain wallet with the provided options. + * Loads the TFChain wallet with the provided options. * - * @param {TfchainWalletInitModel} options - The options for initializing the wallet, including name and secret. + * @param {TfchainWalletInitModel} options - The options for loading the wallet, including name and secret. * @returns {Promise} A promise that resolves to the address of the initialized wallet. * @decorators * - `@expose`: Exposes the method for external use. @@ -446,10 +446,10 @@ class TFChain implements blockchainInterface { } /** - * Creates a new account by generating a mnemonic, activating the account, and creating a twin. + * Activates an account for the given mnemonic and creates a twin. * - * @param relay The relay to use for the account creation. - * @param disconnect Flag indicating whether to disconnect after creating the account. + * @param relay The relay to use for the twin creation. + * @param disconnect Flag indicating whether to disconnect after activating the account. * @returns A promise that resolves to an object containing the public key, mnemonic, and twin ID of the created account. */ async activateAccountAndCreateTwin(mnemonic: string, relay: string, disconnect = false) { diff --git a/packages/grid_client/src/modules/utility.ts b/packages/grid_client/src/modules/utility.ts index d1599aa437..254beee936 100644 --- a/packages/grid_client/src/modules/utility.ts +++ b/packages/grid_client/src/modules/utility.ts @@ -39,6 +39,9 @@ class Utility { * Executes a batch operation for all provided extrinsics. * This method first checks the balance to ensure it is sufficient before applying the extrinsics. * + * if one of the extrinsics fails in the case of using batchAll, all the extrinsics will be rolled back. However, + * the extrinsics won't roll back in the case of using batch. + * * @param {BatchModel} options - The options for the batch operation, including the extrinsics to be executed. * @returns {Promise} A promise that resolves with the result of the batch operation. */ diff --git a/packages/grid_client/src/modules/zdb.ts b/packages/grid_client/src/modules/zdb.ts index 053d1c6007..8ef1c480ed 100644 --- a/packages/grid_client/src/modules/zdb.ts +++ b/packages/grid_client/src/modules/zdb.ts @@ -116,7 +116,7 @@ class ZdbsModule extends BaseModule { * * This method fetches and returns a list of ZDB deployments. * - * @returns {Promise} - A promise that resolves to an array of string representing the ZDB contract names. + * @returns {Promise} - A promise that resolves to an array of string representing the ZDB deployment names. * @decorators * - `@expose`: Exposes the method for external use. */ @@ -191,11 +191,7 @@ class ZdbsModule extends BaseModule { @expose @validateInput @checkBalance - async delete(options: ZDBDeleteModel): Promise<{ - created: Contract[]; - deleted: Contract[]; - updated: Contract[]; - }> { + async delete(options: ZDBDeleteModel): Promise { events.emit("logs", `Start deleting the ZDB deployment with name ${options.name}`); return await this._delete(options.name); } diff --git a/packages/grid_client/src/modules/zos.ts b/packages/grid_client/src/modules/zos.ts index c3b62162cb..de222d8599 100644 --- a/packages/grid_client/src/modules/zos.ts +++ b/packages/grid_client/src/modules/zos.ts @@ -6,16 +6,24 @@ import { DeploymentResultContracts, Operations, TwinDeployment } from "../high_l import { TwinDeploymentHandler } from "../high_level/twinDeploymentHandler"; import { DeploymentFactory } from "../primitives/deployment"; import { Nodes } from "../primitives/nodes"; +import { Deployment } from "../zos"; import { WorkloadTypes } from "../zos/workload"; import { GPUCardInfo, NodeCPUTest, + NodeHealthCheck, NodeIPerf, NodeIPValidation, PingNodeOptionsModel, ZOSGetDeploymentModel, ZOSModel, + ZOSNetworkInterfaces, + ZOSNetworkPublicConfig, ZOSNodeModel, + ZOSNodePerfTestsResult, + ZOSNodeStatistics, + ZOSStoragePools, + ZOSVersionResultModel, } from "./models"; import { checkBalance } from "./utils"; @@ -33,8 +41,13 @@ class Zos { this.capacity = new Nodes(this.config.graphqlURL, this.config.proxyURL, this.config.rmbClient); } + // Helper function to filter the test by name + private filterTest(response: T[], testName: string): T | undefined { + return response.find((obj: T) => (obj as any).name === testName); + } + /** - * Deploy a workload on a node. + * Deploy a deployment on a node. * * @param {ZOSModel} options - The options for the deployment. * @returns {Promise} - The result of the deployment. @@ -77,7 +90,7 @@ class Zos { */ @expose @validateInput - async pingNode(options: PingNodeOptionsModel): Promise { + async pingNode(options: PingNodeOptionsModel): Promise { const nodeTwinId = await this.capacity.getNodeTwinId(options.nodeId); return await this.rmb.request([nodeTwinId], "zos.system.version", "", 10, 1); } @@ -86,14 +99,14 @@ class Zos { * Get deployment information based on the contract ID. * * @param {ZOSGetDeploymentModel} options - The options for getting deployment information. - * @returns {Promise} - A promise that resolves with the deployment information. + * @returns {Promise} - A promise that resolves with the deployment information. * @decorators * - `@expose`: Exposes the method for external use. * - `@validateInput`: Validates the input options. */ @expose @validateInput - async getDeployment(options: ZOSGetDeploymentModel): Promise { + async getDeployment(options: ZOSGetDeploymentModel): Promise { const nodeId = await this.capacity.getNodeIdFromContractId(options.contractId, this.config.substrateURL); const nodeTwinId = await this.capacity.getNodeTwinId(nodeId); const payload = JSON.stringify({ contract_id: options.contractId }); @@ -104,14 +117,14 @@ class Zos { * Get statistics for a specific node. * * @param {ZOSNodeModel} options - The options for getting node statistics. - * @returns {Promise} - A promise that resolves with the node statistics. + * @returns {Promise} - A promise that resolves with the node statistics. * @decorators * - `@expose`: Exposes the method for external use. * - `@validateInput`: Validates the input options. */ @expose @validateInput - async getNodeStatistics(options: ZOSNodeModel): Promise { + async getNodeStatistics(options: ZOSNodeModel): Promise { const nodeTwinId = await this.capacity.getNodeTwinId(options.nodeId); return await this.rmb.request([nodeTwinId], "zos.statistics.get", ""); } @@ -136,14 +149,14 @@ class Zos { * List network interfaces for a specific node. * * @param {ZOSNodeModel} options - The options containing the node ID. - * @returns {Promise} - A promise that resolves with the network interfaces information. + * @returns {Promise} - A promise that resolves with the network interfaces information. * @decorators * - `@expose`: Exposes the method for external use. * - `@validateInput`: Validates the input options. */ @expose @validateInput - async listNetworkInterfaces(options: ZOSNodeModel): Promise { + async listNetworkInterfaces(options: ZOSNodeModel): Promise { const nodeTwinId = await this.capacity.getNodeTwinId(options.nodeId); return await this.rmb.request([nodeTwinId], "zos.network.interfaces", ""); } @@ -152,14 +165,14 @@ class Zos { * List the public IP addresses associated with a specific node. * * @param {ZOSNodeModel} options - The options containing the node ID. - * @returns {Promise} - A promise that resolves with the list of public IP addresses. + * @returns {Promise} - A promise that resolves with the list of public IP addresses. * @decorators * - `@expose`: Exposes the method for external use. * - `@validateInput`: Validates the input options. */ @expose @validateInput - async listNetworkPublicIPs(options: ZOSNodeModel): Promise { + async listNetworkPublicIPs(options: ZOSNodeModel): Promise { const nodeTwinId = await this.capacity.getNodeTwinId(options.nodeId); return await this.rmb.request([nodeTwinId], "zos.network.list_public_ips", ""); } @@ -168,14 +181,14 @@ class Zos { * Get the public network configuration for a specific node. * * @param {ZOSNodeModel} options - The options containing the node ID. - * @returns {Promise} - A promise that resolves with the public network configuration. + * @returns {Promise} - A promise that resolves with the public network configuration. * @decorators * - `@expose`: Exposes the method for external use. * - `@validateInput`: Validates the input options. */ @expose @validateInput - async getNetworkPublicConfig(options: ZOSNodeModel): Promise { + async getNetworkPublicConfig(options: ZOSNodeModel): Promise { const nodeTwinId = await this.capacity.getNodeTwinId(options.nodeId); return await this.rmb.request([nodeTwinId], "zos.network.public_config_get", ""); } @@ -184,14 +197,14 @@ class Zos { * Get the storage pools information for a specific node. * * @param {ZOSNodeModel} options - The options containing the node ID. - * @returns {Promise} - A promise that resolves with the storage pools information. + * @returns {Promise} - A promise that resolves with the storage pools information. * @decorators * - `@expose`: Exposes the method for external use. * - `@validateInput`: Validates the input options. */ @expose @validateInput - async getStoragePools(options: ZOSNodeModel): Promise { + async getStoragePools(options: ZOSNodeModel): Promise { const nodeTwinId = await this.capacity.getNodeTwinId(options.nodeId); return await this.rmb.request([nodeTwinId], "zos.storage.pools", ""); } @@ -216,16 +229,22 @@ class Zos { * Get performance tests for a specific node. * * @param {ZOSNodeModel} options - The options containing the node ID. - * @returns {Promise} - A promise that resolves with the performance test results. + * @returns {Promise} - A promise that resolves with the performance test results. * @decorators * - `@expose`: Exposes the method for external use. * - `@validateInput`: Validates the input options. */ @expose @validateInput - async getNodePerfTests(options: ZOSNodeModel): Promise { + async getNodePerfTests(options: ZOSNodeModel): Promise { const nodeTwinId = await this.capacity.getNodeTwinId(options.nodeId); - return await this.rmb.request([nodeTwinId], "zos.perf.get_all", ""); + const result = new ZOSNodePerfTestsResult(); + const response = await this.rmb.request([nodeTwinId], "zos.perf.get_all", ""); + result.iperf = this.filterTest(response, "iperf"); + result.publicIPValidation = this.filterTest(response, "public-ip-validation"); + result.healthCheck = this.filterTest(response, "healthcheck"); + result.cpuBenchmark = this.filterTest(response, "cpu-benchmark"); + return result; } /** diff --git a/packages/grid_client/src/storage/backend.ts b/packages/grid_client/src/storage/backend.ts index 31a7ca73c9..330b721259 100644 --- a/packages/grid_client/src/storage/backend.ts +++ b/packages/grid_client/src/storage/backend.ts @@ -93,10 +93,10 @@ class BackendStorage { } /** - * Retrieves a list of values stored under the specified key from the storage. + * Retrieves a list of keys starting with a specified key from the storage. * - * @param key The key of the values to be retrieved. - * @returns A promise that resolves with an array of strings representing the values stored under the key. + * @param key The starting part of the keys to be retrieved. + * @returns A promise that resolves with an array of strings representing the keys starting with the provided key. */ list(key: string): Promise { return this.storage.list(key); diff --git a/packages/tfchain_client/src/contracts.ts b/packages/tfchain_client/src/contracts.ts index b823ae900b..061803e3aa 100644 --- a/packages/tfchain_client/src/contracts.ts +++ b/packages/tfchain_client/src/contracts.ts @@ -305,10 +305,11 @@ class Contracts extends QueryContracts { /** * Creates a node contract. - * - * This method creates a node contract with the specified `nodeId`, `hash`, `data`, `numberOfPublicIps`, and `solutionProviderId`. + * This method creates a node contract extrinsic with the specified `nodeId`, `hash`, `data`, `numberOfPublicIps`, and `solutionProviderId`. * * @param {CreateNodeOptions} options - The options object containing the `nodeId`, `hash`, `data`, `numberOfPublicIps`, and `solutionProviderId` for creating the node contract. + * @returns {Promise>} A promise that resolves to the created Contract extrinsic. + * @returns {Promise>} A promise that resolves to the created Contract object. */ @checkConnection @@ -329,7 +330,7 @@ class Contracts extends QueryContracts { * This method updates a node contract identified by the provided `id` with the new `hash` and `data`. * * @param {UpdateNodeOptions} options - The options object containing the `id`, `hash`, and `data` for updating the node contract. - * @returns {Promise>} A promise that resolves to the updated Contract object. + * @returns {Promise>} A promise that resolves to the updated Contract extrinsic. */ @checkConnection async updateNode(options: UpdateNodeOptions): Promise> { @@ -342,12 +343,12 @@ class Contracts extends QueryContracts { } /** - * Creates a name contract. + * Creates a name contract extrinsic. * * This method creates a name contract with the specified `name`. * * @param {CreateNameOptions} options - The options object containing the `name` for creating the name contract. - * @returns {Promise>} A promise that resolves to the created Contract object. + * @returns {Promise>} A promise that resolves to the created Contract extrinsic. */ @checkConnection async createName(options: CreateNameOptions): Promise> { @@ -356,12 +357,12 @@ class Contracts extends QueryContracts { } /** - * Creates a rent contract. + * Creates a rent contract extrinsic. * * This method creates a rent contract for the specified `nodeId` and `solutionProviderId`. * * @param {CreateRentOptions} options - The options object containing the `nodeId` and optional `solutionProviderId`. - * @returns {Promise>} A promise that resolves to the created Contract object. + * @returns {Promise>} A promise that resolves to the created Contract extrinsic. */ @checkConnection async createRent(options: CreateRentOptions): Promise> { @@ -382,8 +383,8 @@ class Contracts extends QueryContracts { * result with the `contract ID` and specific result events related to contract cancellation. * * @param {CancelOptions} options - The options object containing the `ID` of the contract to be canceled. - * @returns {Promise | undefined>} A promise that resolves to the updated `contract ID` after canceling the contract, - * or `undefined` if the contract does not exist. + * @returns {Promise | undefined>} A promise that resolves with the contract cancelling extrinsic, + * * or `undefined` if the contract does not exist. */ @checkConnection async cancel(options: CancelOptions): Promise | undefined> { @@ -399,12 +400,12 @@ class Contracts extends QueryContracts { } /** - * Creates a new service contract. + * Creates a new service contract extrinsic. * - * This method creates a new service contract with the provided `serviceAccount` and `consumerAccount`. + * This method creates a new service contract extrinsic with the provided `serviceAccount` and `consumerAccount`. * * @param {CreateServiceOptions} options - The options object containing the `serviceAccount` and `consumerAccount` for creating the service contract. - * @returns {Promise>} A promise that resolves to the created ServiceContract object. + * @returns {Promise>} A promise that resolves to the created ServiceContract extrinsic. */ @checkConnection async createService(options: CreateServiceOptions): Promise> { @@ -421,7 +422,7 @@ class Contracts extends QueryContracts { * This method either approves or rejects a service contract based on the provided `approve` flag in the `options` object. * * @param {ApproveServiceOptions} options - The options object containing the `serviceId` of the service contract and a boolean `approve` flag indicating whether to approve or reject the contract. - * @returns {Promise>} A promise that resolves to the updated ServiceContract object after approving or rejecting the service contract. + * @returns {Promise>} A promise that resolves to the updated ServiceContract extrinsic. */ @checkConnection async approveService(options: ApproveServiceOptions): Promise> { @@ -435,12 +436,12 @@ class Contracts extends QueryContracts { } /** - * Bills a service contract. + * Creates an extrinsic for Billing a service contract. * * This method bills a service contract identified by the provided `serviceId` with the specified `variableAmount` and `metadata`. * * @param {BillServiceOptions} options - The options object containing the `serviceId`, `variableAmount`, and `metadata` for billing the service contract. - * @returns {Promise>} A promise that resolves to the updated ServiceContract object after billing the service contract. + * @returns {Promise>} A promise that resolves to the extrinsic for billing the service contract. */ @checkConnection async billService(options: BillServiceOptions): Promise> { @@ -453,12 +454,12 @@ class Contracts extends QueryContracts { } /** - * Cancels a service contract. + * Creates an extrinsic for canceling a service contract. * * This method cancels a service contract identified by the provided `serviceId`. * * @param {CancelServiceOptions} options - The options object containing the `serviceId` of the service contract to be canceled. - * @returns {Promise>} A promise that resolves to the updated ServiceContract object after canceling the service contract. + * @returns {Promise>} A promise that resolves to the extrinsic for canceling the service contract. */ @checkConnection async cancelService(options: CancelServiceOptions): Promise> { @@ -472,7 +473,7 @@ class Contracts extends QueryContracts { * This method sets the base fee and variable fee for a service contract identified by the provided `serviceId`. * * @param {SetServiceFeesOptions} options - The options object containing the `serviceId`, `baseFee`, and `variableFee` to be set. - * @returns {Promise>} A promise that resolves to the updated ServiceContract object after setting the fees. + * @returns {Promise>} A promise that resolves to the extrinsic for setting the fees. */ @checkConnection async setServiceFees(options: SetServiceFeesOptions): Promise> { @@ -490,7 +491,7 @@ class Contracts extends QueryContracts { * This method sets the extra fee for a dedicated node identified by the provided nodeId. * * @param {SetDedicatedNodeExtraFeesOptions} options - The options object containing the nodeId and extraFee to be set. - * @returns {Promise} A promise that resolves to the result of setting the extra fee for the dedicated node. + * @returns {Promise} A promise that resolves to the extrinsic for setting the extra fee for the dedicated node. */ @checkConnection async setDedicatedNodeExtraFee(options: SetDedicatedNodeExtraFeesOptions): Promise { @@ -504,7 +505,7 @@ class Contracts extends QueryContracts { * This method sets the metadata for a service contract identified by the provided serviceId. * * @param {SetServiceMetadataOptions} options - The options object containing the serviceId and metadata to be set. - * @returns {Promise>} A promise that resolves to the updated ServiceContract object after setting the metadata. + * @returns {Promise>} A promise that resolves to the extrinsic for setting the metadata. */ @checkConnection async setServiceMetadata(options: SetServiceMetadataOptions): Promise> { diff --git a/packages/tfchain_client/src/farms.ts b/packages/tfchain_client/src/farms.ts index 1ece019a2e..b8fb77dd8d 100644 --- a/packages/tfchain_client/src/farms.ts +++ b/packages/tfchain_client/src/farms.ts @@ -1,5 +1,4 @@ import { Client, QueryClient } from "./client"; -import type { ExtrinsicResult } from "./types"; import { checkConnection } from "./utils"; enum Certification { @@ -88,12 +87,11 @@ class Farms extends QueryFarms { } /** - * Create a new farm. - * + * Create a new farm extrinsic. * @param options - The options for creating a new farm. * @param options.name - The name of the new farm. * @param options.publicIps - Optional array of public IPs for the new farm. - * @returns A promise that resolves to the created farm object. + * @returns A promise that resolves to the created farm extrinsic. */ @checkConnection async create(options: CreateFarmOptions) { @@ -108,7 +106,7 @@ class Farms extends QueryFarms { * @param options.farmId - The ID of the farm to add the public IP to. * @param options.ip - The IP address to add to the farm. * @param options.gw - The gateway for the IP address. - * @returns A promise that resolves to the updated farm object after adding the public IP. + * @returns A promise that resolves to the updated farm extrinsic after adding the public IP. */ @checkConnection async addFarmIp(options: AddFarmIPOptions) { @@ -122,7 +120,7 @@ class Farms extends QueryFarms { * @param options - The options for removing a public IP from a farm. * @param options.farmId - The ID of the farm from which to remove the public IP. * @param options.ip - The IP address to remove from the farm. - * @returns A promise that resolves to the updated farm object after removing the public IP. + * @returns A promise that resolves to the updated farm extrinsic after removing the public IP. */ @checkConnection async removeFarmIp(options: RemoveFarmIPOptions) { @@ -136,7 +134,7 @@ class Farms extends QueryFarms { * @param options - The options for adding a Stellar address. * @param options.farmId - The ID of the farm to add the Stellar address to. * @param options.stellarAddress - The Stellar address to add for payout. - * @returns A promise that resolves to the updated farm object after adding the Stellar address. + * @returns A promise that resolves to the updated farm extrinsic after adding the Stellar address. */ @checkConnection async addStellarAddress(options: AddStellarOptions) { diff --git a/packages/tfchain_client/src/kvstore.ts b/packages/tfchain_client/src/kvstore.ts index 10e6cbf2c1..a50037221f 100644 --- a/packages/tfchain_client/src/kvstore.ts +++ b/packages/tfchain_client/src/kvstore.ts @@ -38,7 +38,7 @@ class KVStore { * It then patches the extrinsic and returns the result of the deletion operation. * * @param options - An object containing the key to be deleted from the `key-value` store. - * @returns {Promise>} A promise that resolves once the key is successfully deleted. + * @returns {Promise>} A promise that resolves once the delete extrinsic is successfully created. */ @checkConnection async delete(options: KVStoreGetOptions): Promise> { diff --git a/packages/tfchain_client/src/twins.ts b/packages/tfchain_client/src/twins.ts index 06c1546018..3831214601 100644 --- a/packages/tfchain_client/src/twins.ts +++ b/packages/tfchain_client/src/twins.ts @@ -76,10 +76,10 @@ class Twins extends QueryTwins { } /** - * Creates a new twin with the provided options. + * Creates a new twin extrinsic with the provided options. * * @param {TwinOptions} options - The options for creating the twin, including the relay and public key. - * @returns {Promise>} A Promise that resolves to the created twin object. + * @returns {Promise>} A Promise that resolves to the created twin extrinsic. */ @checkConnection async create(options: TwinOptions): Promise> { @@ -91,7 +91,7 @@ class Twins extends QueryTwins { * Updates an existing twin with the provided options. * * @param {TwinOptions} options - The options for updating the twin, including the relay and public key. - * @returns {Promise>} A Promise that resolves to the updated twin object. + * @returns {Promise>} A Promise that resolves to the updated twin extrinsic. */ @checkConnection async update(options: TwinOptions): Promise> {