From f60731119f13246685cac3a978d6dc33a229453d Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Fri, 3 Jun 2022 12:55:32 +0530 Subject: [PATCH] splitting gas price and microdenom --- package.json | 12 +++++++++--- src/models/Workspace.ts | 4 ++++ src/views/TxProvider.ts | 3 ++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 1fa902b..4a6aceb 100644 --- a/package.json +++ b/package.json @@ -129,25 +129,31 @@ "type": "string", "description": "default amount of gas to be used as the gas limit for a transaction." }, + "chainDenom": { + "type": "string", + "description": "the micro denom used to pay for gas and to track account balance" + }, "faucetEndpoint": { "type":"string", "description": "Faucet address and port to request funds" } }, - "required": ["configName","chainId", "addressPrefix", "rpcEndpoint", "defaultGasPrice"] + "required": ["configName","chainId", "addressPrefix", "rpcEndpoint", "defaultGasPrice", "chainDenom"] }, "default": [{ "configName": "Juno UNI-3 testnet", "chainId": "uni-3", "addressPrefix": "juno", "rpcEndpoint": "https://rpc.uni.juno.deuslabs.fi", - "defaultGasPrice": "0.025ujunox" + "defaultGasPrice": "0.025", + "chainDenom": "ujunox" }, { "configName": "Localnet - Juno", "chainId": "testing", "addressPrefix": "juno", "rpcEndpoint": "http://localhost:26657", - "defaultGasPrice": "0.025ujunox", + "defaultGasPrice": "0.025", + "chainDenom": "ujunox", "faucetEndpoint": "http://localhost:8000" }] } diff --git a/src/models/Workspace.ts b/src/models/Workspace.ts index 320da00..fae7d4d 100644 --- a/src/models/Workspace.ts +++ b/src/models/Workspace.ts @@ -55,6 +55,7 @@ class ChainConfig { addressPrefix!: string; rpcEndpoint!: string; defaultGasPrice!: string; + chainDenom!: string; public Validate() { if (!this) { @@ -78,6 +79,9 @@ class ChainConfig { if (!this.defaultGasPrice || this.defaultGasPrice === " ") { throw new Error("Default Gas Price is empty"); } + if (!this.chainDenom || this.chainDenom === " ") { + throw new Error("Chain denom is empty"); + } return; } } \ No newline at end of file diff --git a/src/views/TxProvider.ts b/src/views/TxProvider.ts index 583ae09..b191d5d 100644 --- a/src/views/TxProvider.ts +++ b/src/views/TxProvider.ts @@ -61,10 +61,11 @@ export class TxProvider implements vscode.WebviewViewProvider { DirectSecp256k1HdWallet.fromMnemonic(account.mnemonic, { prefix: Workspace.GetWorkspaceChainConfig().addressPrefix, }).then(signer => { + let gasPrice = Workspace.GetWorkspaceChainConfig().defaultGasPrice + Workspace.GetWorkspaceChainConfig().chainDenom; SigningCosmWasmClient.connectWithSigner( Workspace.GetWorkspaceChainConfig().rpcEndpoint, signer, { - gasPrice: GasPrice.fromString(Workspace.GetWorkspaceChainConfig().defaultGasPrice) + gasPrice: GasPrice.fromString(gasPrice) }).then(client => { client.execute(account.address, contract.contractAddress, req, "auto").then(res => { let output = "// Input: \n";