diff --git a/src/lib/session.ts b/src/lib/session.ts deleted file mode 100644 index b1a56a40..00000000 --- a/src/lib/session.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { workspace, ConfigurationTarget } from 'vscode'; -import { logger } from '.'; - -export function updateUserSession(valueToAssign: any, keys: string[]): Promise { - return new Promise((resolve, reject) => { - try { - // @ts-ignore - const config = workspace.getConfiguration('ethcode', workspace.workspaceFolders[0].uri); - if (keys.length === 2) { - const userSession = `${keys[0]}.${keys[1]}`; - config.update(userSession, valueToAssign); - resolve(userSession); - // @ts-ignore - } else if (keys.length === 3) { - const userSession = `${keys[0]}.${keys[1]}.${keys[2]}`; - // @ts-ignore - config.update(userSession, valueToAssign); - resolve(userSession); - } - } catch (err) { - reject(err); - } - }); -} - -export async function updateUserSettings(accessScope: string, valueToAdd: string): Promise { - try { - await workspace.getConfiguration('ethcode').update(accessScope, valueToAdd, ConfigurationTarget.Global); - return true; - } catch (e) { - logger.log('Error updating: ', e); - return false; - } -} diff --git a/src/utils/contracts.ts b/src/utils/contracts.ts index f097b6cb..4efe2506 100644 --- a/src/utils/contracts.ts +++ b/src/utils/contracts.ts @@ -23,7 +23,7 @@ const parseBatchCompiledJSON = (context: ExtensionContext): void => { let name = path.parse(e).base; name = name.substring(0, name.length - 5); - logger.log(`Try to parse the ${name} contract output`); + logger.log(`Trying to parse ${name} contract output...`); const data = fs.readFileSync(e); const output: CompiledJSONOutput = getCompiledJsonObject(data); @@ -32,7 +32,7 @@ const parseBatchCompiledJSON = (context: ExtensionContext): void => { output.path = path.dirname(e); output.name = name; - logger.success(`Loaded ${name} contract and saved to workspace`); + logger.success(`Loaded ${name} contract into workspace.`); let contracts = context.workspaceState.get('contracts') as any; if (contracts === undefined || contracts === '') contracts = new Map(); @@ -67,13 +67,13 @@ const getCompiledJsonObject = (_jsonPayload: any): CompiledJSONOutput => { output.contractType = 1; output.hardhatOutput = data; - logger.log('Loaded Hardhat compiled json output'); + logger.log('Loaded Hardhat compiled json outputs.'); } else if (data.data !== undefined) { // Remix format output.contractType = 2; output.remixOutput = data; - logger.log('Loaded Remix compiled json output'); + logger.log('Loaded Remix compiled json output.'); } } catch (e) { // eslint-disable-next-line no-console @@ -112,7 +112,7 @@ const selectContract = (context: ExtensionContext) => { label: f || '', functionKey: f || '', })); - quickPick.placeholder = 'Select a contract'; + quickPick.placeholder = 'Select a contract.'; quickPick.onDidChangeSelection((selection: Array) => { if (selection[0] && workspace.workspaceFolders) { const { functionKey } = selection[0]; @@ -127,7 +127,7 @@ const selectContract = (context: ExtensionContext) => { createFunctionInput(contract); createDeployed(contract); - logger.success(`Contract ${name[0]} is selected`); + logger.success(`Contract ${name[0]} is selected.`); } }); quickPick.onDidHide(() => quickPick.dispose()); diff --git a/src/utils/functions.ts b/src/utils/functions.ts index 62bc491c..db348f33 100644 --- a/src/utils/functions.ts +++ b/src/utils/functions.ts @@ -12,7 +12,7 @@ import { createDeployedFile, writeConstructor, writeFunction } from '../lib/file const createDeployed = (contract: CompiledJSONOutput) => { const fullPath = getDeployedFullPath(contract); if (fs.existsSync(fullPath)) { - logger.success("Functions input file already exists, remove it to add a empty file"); + logger.success("Functions input file already exists, remove it to add a empty file."); return; } @@ -32,7 +32,7 @@ const createDeployed = (contract: CompiledJSONOutput) => { const createFunctionInput = (contract: CompiledJSONOutput) => { const fullPath = getFunctionInputFullPath(contract); if (fs.existsSync(fullPath)) { - logger.success("Functions input file already exists, remove it to add a empty file"); + logger.success("Functions input file already exists, remove it to add a empty file."); return; } diff --git a/src/utils/networks.ts b/src/utils/networks.ts index 87fc6f44..fb4539e6 100644 --- a/src/utils/networks.ts +++ b/src/utils/networks.ts @@ -107,20 +107,20 @@ const callContractMethod = async (context: vscode.ExtensionContext) => { const abi = getAbi(compiledOutput); if (abi == undefined) - throw new Error("Abi is not defined"); + throw new Error("Abi is not defined."); const abiItem = await getFunctionInputs(context); if (abiItem === undefined) - throw new Error("Please select a function to call"); + throw new Error("Function is not defined."); const params_ = abiItem.inputs?.map((e: any) => e.value); const params = params_ === undefined ? [] : params_; - logger.success(`Calling the function : ${abiItem.name} of selected contract...`); + logger.success(`Calling ${compiledOutput.name} : ${abiItem.name} -->`); const contractAddres = getDeployedInputs(context).address; if (contractAddres === undefined) - throw new Error("Please input deployed address of selected contract"); + throw new Error("Enter deployed address of selected contract."); if (abiItem.stateMutability === 'view') { const contract = new ethers.Contract( @@ -130,7 +130,7 @@ const callContractMethod = async (context: vscode.ExtensionContext) => { ); const result = await contract[abiItem.name as string](...params); - logger.success("Successfully called the function"); + logger.success(`Calling ${compiledOutput.name} : ${abiItem.name} --> Success!`); logger.log(JSON.stringify(result)); } else { const contract = await getSignedContract(context, contractAddres); @@ -138,7 +138,8 @@ const callContractMethod = async (context: vscode.ExtensionContext) => { logger.success("Waiting for confirmation..."); await result.wait(); - logger.success("Mutable function was succcessfully called."); + logger.success("Transaction confirmed!"); + logger.success(`Calling ${compiledOutput.name} : ${abiItem.name} --> Success!`); } } catch (err: any) { logger.error(err); @@ -171,11 +172,11 @@ const getSignedContract = async (context: vscode.ExtensionContext, contractAddre const abi = getAbi(compiledOutput); if (abi == undefined) - throw new Error("Abi is not defined"); + throw new Error("Abi is not defined."); const byteCode = getByteCode(compiledOutput); if (byteCode == undefined) - throw new Error("ByteCode is not defined"); + throw new Error("ByteCode is not defined."); let contract; if (isTestingNetwork(context)) { @@ -205,11 +206,11 @@ const getContractFactoryWithParams = async (context: vscode.ExtensionContext): P const abi = getAbi(compiledOutput); if (abi == undefined) - throw new Error("Abi is not defined"); + throw new Error("Abi is not defined."); const byteCode = getByteCode(compiledOutput); if (byteCode == undefined) - throw new Error("ByteCode is not defined"); + throw new Error("ByteCode is not defined."); let myContract; if (isTestingNetwork(context)) { diff --git a/src/utils/wallet.ts b/src/utils/wallet.ts index 78ada749..e9b07ea9 100644 --- a/src/utils/wallet.ts +++ b/src/utils/wallet.ts @@ -8,7 +8,7 @@ import { logger } from '../lib'; const keythereum = require('keythereum'); import { toChecksumAddress } from '../lib/hash/util'; -import { Account, GanacheAddressType, IAccountQP, LocalAddressType } from '../types'; +import { Account, LocalAddressType } from '../types'; import { getSelectedNetwork, getSelectedProvider, isTestingNetwork } from './networks'; // list all local addresses