diff --git a/packages/grid_client/src/high_level/farmerbot.ts b/packages/grid_client/src/high_level/farmerbot.ts index 97ff256527..a1f2029949 100644 --- a/packages/grid_client/src/high_level/farmerbot.ts +++ b/packages/grid_client/src/high_level/farmerbot.ts @@ -51,7 +51,7 @@ class FarmerBot { client: TFClient; constructor(public config: GridClientConfig) { - this.client = new TFClient(config.substrateURL, config.mnemonic, config.storeSecret, config.keypairType); + this.client = config.tfclient; this.rmb = new RMB(config.rmbClient); } diff --git a/packages/grid_client/src/high_level/twinDeploymentHandler.ts b/packages/grid_client/src/high_level/twinDeploymentHandler.ts index 7e4df80780..27c72a39d7 100644 --- a/packages/grid_client/src/high_level/twinDeploymentHandler.ts +++ b/packages/grid_client/src/high_level/twinDeploymentHandler.ts @@ -16,7 +16,7 @@ class TwinDeploymentHandler { nodes: Nodes; constructor(public config: GridClientConfig) { - this.tfclient = new TFClient(config.substrateURL, config.mnemonic, config.storeSecret, config.keypairType); + this.tfclient = config.tfclient; this.deploymentFactory = new DeploymentFactory(this.config); this.rmb = new RMB(config.rmbClient); this.nodes = new Nodes(this.config.graphqlURL, this.config.proxyURL, this.config.rmbClient); diff --git a/packages/grid_client/src/modules/algorand.ts b/packages/grid_client/src/modules/algorand.ts index 068ba20670..fba1d54e87 100644 --- a/packages/grid_client/src/modules/algorand.ts +++ b/packages/grid_client/src/modules/algorand.ts @@ -42,12 +42,7 @@ class Algorand implements blockchainInterface { config.backendStorage, config.seed, ); - this.tfClient = new TFClient( - this.config.substrateURL, - this.config.mnemonic, - this.config.storeSecret, - this.config.keypairType, - ); + this.tfClient = config.tfclient; } private async saveIfKVStoreBackend(extrinsics) { diff --git a/packages/grid_client/src/modules/balance.ts b/packages/grid_client/src/modules/balance.ts index f586474c3a..1dd8befe85 100644 --- a/packages/grid_client/src/modules/balance.ts +++ b/packages/grid_client/src/modules/balance.ts @@ -8,7 +8,7 @@ import { checkBalance } from "./utils"; class Balance { client: TFClient; constructor(config: GridClientConfig) { - this.client = new TFClient(config.substrateURL, config.mnemonic, config.storeSecret, config.keypairType); + this.client = config.tfclient; } @expose @validateInput diff --git a/packages/grid_client/src/modules/base.ts b/packages/grid_client/src/modules/base.ts index c89f57faf3..c8192ec2cf 100644 --- a/packages/grid_client/src/modules/base.ts +++ b/packages/grid_client/src/modules/base.ts @@ -44,12 +44,7 @@ class BaseModule { config.backendStorage, config.seed, ); - this.tfClient = new TFClient( - this.config.substrateURL, - this.config.mnemonic, - this.config.storeSecret, - this.config.keypairType, - ); + this.tfClient = config.tfclient; } getDeploymentPath(name: string): string { diff --git a/packages/grid_client/src/modules/calculator.ts b/packages/grid_client/src/modules/calculator.ts index 9c4668a5bd..b6a975ad92 100644 --- a/packages/grid_client/src/modules/calculator.ts +++ b/packages/grid_client/src/modules/calculator.ts @@ -8,7 +8,7 @@ class Calculator { client: TFClient; constructor(config: GridClientConfig) { - this.client = new TFClient(config.substrateURL, config.mnemonic, config.storeSecret, config.keypairType); + this.client = config.tfclient; } @expose @validateInput diff --git a/packages/grid_client/src/modules/contracts.ts b/packages/grid_client/src/modules/contracts.ts index db4914af40..3d1118d68f 100644 --- a/packages/grid_client/src/modules/contracts.ts +++ b/packages/grid_client/src/modules/contracts.ts @@ -38,7 +38,7 @@ class Contracts { client: TFClient; nodes: Nodes; constructor(public config: GridClientConfig) { - this.client = new TFClient(config.substrateURL, config.mnemonic, config.storeSecret, config.keypairType); + this.client = config.tfclient; this.nodes = new Nodes(config.graphqlURL, config.proxyURL, config.rmbClient); } diff --git a/packages/grid_client/src/modules/farmerbot.ts b/packages/grid_client/src/modules/farmerbot.ts index 96cf27c98e..9ab126e4db 100644 --- a/packages/grid_client/src/modules/farmerbot.ts +++ b/packages/grid_client/src/modules/farmerbot.ts @@ -14,7 +14,7 @@ class Farmerbot { rmb: RMB; constructor(public config: GridClientConfig) { - this.client = new TFClient(config.substrateURL, config.mnemonic, config.storeSecret, config.keypairType); + this.client = config.tfclient; this.farmerBot = new FarmerBot(this.config); this.rmb = new RMB(config.rmbClient); } diff --git a/packages/grid_client/src/modules/farms.ts b/packages/grid_client/src/modules/farms.ts index b358cdd388..5aeb3cf743 100644 --- a/packages/grid_client/src/modules/farms.ts +++ b/packages/grid_client/src/modules/farms.ts @@ -8,7 +8,7 @@ class Farms { client: TFClient; constructor(public config: GridClientConfig) { - this.client = new TFClient(config.substrateURL, config.mnemonic, config.storeSecret, config.keypairType); + this.client = config.tfclient; } @expose diff --git a/packages/grid_client/src/modules/kvstore.ts b/packages/grid_client/src/modules/kvstore.ts index 082090c016..54a20a873f 100644 --- a/packages/grid_client/src/modules/kvstore.ts +++ b/packages/grid_client/src/modules/kvstore.ts @@ -8,7 +8,7 @@ import { checkBalance } from "./utils"; class KVStore { client: TFClient; constructor(config: GridClientConfig) { - this.client = new TFClient(config.substrateURL, config.mnemonic, config.storeSecret, config.keypairType); + this.client = config.tfclient; } @expose @validateInput diff --git a/packages/grid_client/src/modules/nodes.ts b/packages/grid_client/src/modules/nodes.ts index c4edfa1c31..fd5a9a2887 100644 --- a/packages/grid_client/src/modules/nodes.ts +++ b/packages/grid_client/src/modules/nodes.ts @@ -16,7 +16,7 @@ import { checkBalance } from "./utils"; class Nodes { client: TFClient; constructor(public config: GridClientConfig) { - this.client = new TFClient(config.substrateURL, config.mnemonic, config.storeSecret, config.keypairType); + this.client = config.tfclient; } @expose diff --git a/packages/grid_client/src/modules/stellar.ts b/packages/grid_client/src/modules/stellar.ts index 0f071a51c2..69b77559fd 100644 --- a/packages/grid_client/src/modules/stellar.ts +++ b/packages/grid_client/src/modules/stellar.ts @@ -44,12 +44,7 @@ class Stellar implements blockchainInterface { config.backendStorage, config.seed, ); - this.tfClient = new TFClient( - this.config.substrateURL, - this.config.mnemonic, - this.config.storeSecret, - this.config.keypairType, - ); + this.tfClient = config.tfclient; } private async saveIfKVStoreBackend(extrinsics) { diff --git a/packages/grid_client/src/modules/tfchain.ts b/packages/grid_client/src/modules/tfchain.ts index 1535b01035..5d7a2b1400 100644 --- a/packages/grid_client/src/modules/tfchain.ts +++ b/packages/grid_client/src/modules/tfchain.ts @@ -54,12 +54,7 @@ class TFChain implements blockchainInterface { this.storeSecret = config.storeSecret as string; this.keypairType = config.keypairType; this.network = config.network; - this.tfClient = new TFClient( - this.config.substrateURL, - this.config.mnemonic, - this.config.storeSecret, - this.config.keypairType, - ); + this.tfClient = config.tfclient; } getPath() { diff --git a/packages/grid_client/src/modules/twins.ts b/packages/grid_client/src/modules/twins.ts index ce4efbd0e8..b0ef1805ef 100644 --- a/packages/grid_client/src/modules/twins.ts +++ b/packages/grid_client/src/modules/twins.ts @@ -8,7 +8,7 @@ import { checkBalance } from "./utils"; class Twins { client: TFClient; constructor(config: GridClientConfig) { - this.client = new TFClient(config.substrateURL, config.mnemonic, config.storeSecret, config.keypairType); + this.client = config.tfclient; } @expose diff --git a/packages/grid_client/src/modules/utility.ts b/packages/grid_client/src/modules/utility.ts index 5b5fd0bb92..33979b6294 100644 --- a/packages/grid_client/src/modules/utility.ts +++ b/packages/grid_client/src/modules/utility.ts @@ -12,7 +12,7 @@ class Utility { client: TFClient; constructor(public config: GridClientConfig) { - this.client = new TFClient(config.substrateURL, config.mnemonic, config.storeSecret, config.keypairType); + this.client = config.tfclient; } @expose diff --git a/packages/grid_client/src/modules/utils.ts b/packages/grid_client/src/modules/utils.ts index cce2115a05..08c0a5965d 100644 --- a/packages/grid_client/src/modules/utils.ts +++ b/packages/grid_client/src/modules/utils.ts @@ -5,9 +5,7 @@ import { TFClient } from "../clients/tf-grid/client"; function checkBalance(target, propertyKey: string, descriptor: PropertyDescriptor) { const method = descriptor.value; descriptor.value = async function (...args) { - const { substrateURL, mnemonic, storeSecret, keypairType } = this.config; - const tfclient = new TFClient(substrateURL, mnemonic, storeSecret, keypairType); - const balances = await tfclient.balances.getMyBalance(); + const balances = await this.config.tfclient.balances.getMyBalance(); if (balances["free"] < 0.001) { throw Error("Balance is not enough to apply an extrinsic"); } diff --git a/packages/grid_client/src/primitives/network.ts b/packages/grid_client/src/primitives/network.ts index bd30e85746..f30b61edbe 100644 --- a/packages/grid_client/src/primitives/network.ts +++ b/packages/grid_client/src/primitives/network.ts @@ -65,12 +65,7 @@ class Network { ); this.rmb = new RMB(config.rmbClient); this.capacity = new Nodes(this.config.graphqlURL, this.config.proxyURL, this.config.rmbClient); - this.tfClient = new TFClient( - this.config.substrateURL, - this.config.mnemonic, - this.config.storeSecret, - this.config.keypairType, - ); + this.tfClient = config.tfclient; } private async saveIfKVStoreBackend(extrinsics) {