From 5984fcf85aeb175c29ff9913b5ea8bab3f0dbb4c Mon Sep 17 00:00:00 2001 From: Mahmoud Emad Date: Tue, 25 Jun 2024 12:46:36 +0300 Subject: [PATCH] chore: WIP:: Thinking about creating a base types module for each module under the client. --- .../grid_client/scripts/add_node_to_network.ts | 6 +++--- packages/grid_client/src/modules/networks.ts | 14 +++++++++++++- packages/grid_client/src/types/high_level/index.ts | 0 packages/grid_client/src/types/modules/index.ts | 0 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 packages/grid_client/src/types/high_level/index.ts create mode 100644 packages/grid_client/src/types/modules/index.ts diff --git a/packages/grid_client/scripts/add_node_to_network.ts b/packages/grid_client/scripts/add_node_to_network.ts index 5469a158a5..fc9dbb390e 100644 --- a/packages/grid_client/scripts/add_node_to_network.ts +++ b/packages/grid_client/scripts/add_node_to_network.ts @@ -1,8 +1,8 @@ -import { NetworkAddNodeModel } from "../src"; +import { GridClient, NetworkAddNodeModel } from "../src"; import { getClient } from "./client_loader"; import { log } from "./utils"; -async function addNode(client, node) { +async function addNode(client: GridClient, node: NetworkAddNodeModel) { const res = await client.networks.addNode(node); log("================= Adding node ================="); log(res); @@ -10,7 +10,7 @@ async function addNode(client, node) { } async function main() { - const grid3 = await getClient(); + const grid3: GridClient = await getClient(); const node: NetworkAddNodeModel = { name: "wedtest", ipRange: "10.249.0.0/16", diff --git a/packages/grid_client/src/modules/networks.ts b/packages/grid_client/src/modules/networks.ts index e67dc35ad2..4b1de466f4 100644 --- a/packages/grid_client/src/modules/networks.ts +++ b/packages/grid_client/src/modules/networks.ts @@ -8,6 +8,18 @@ import { BaseModule } from "./base"; import { NetworkAddNodeModel, NetworkGetModel, NetworkHasNodeModel } from "./models"; import { checkBalance } from "./utils"; +interface INetworkModule { + addNode: { + contracts: {}; + }; +} + +class NetworkModuleResult implements INetworkModule { + addNode: { + contracts: {}; + }; +} + class NetworkModule extends BaseModule { moduleName = "networks"; network: NetworkHL; @@ -20,7 +32,7 @@ class NetworkModule extends BaseModule { @expose @validateInput @checkBalance - async addNode(options: NetworkAddNodeModel) { + async addNode(options: NetworkAddNodeModel): Promise<{}> { const twinDeployments = await this.network.addNode( options.name, options.ipRange, diff --git a/packages/grid_client/src/types/high_level/index.ts b/packages/grid_client/src/types/high_level/index.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/grid_client/src/types/modules/index.ts b/packages/grid_client/src/types/modules/index.ts new file mode 100644 index 0000000000..e69de29bb2