Skip to content

Commit

Permalink
fix import account
Browse files Browse the repository at this point in the history
  • Loading branch information
0mkara committed Apr 10, 2023
1 parent cccacb3 commit 958b56f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/utils/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {

const keythereum = require('keythereum')

// list all local addresses
// List all local addresses
const listAddresses: any = async (
context: vscode.ExtensionContext,
keyStorePath: string
Expand Down Expand Up @@ -50,7 +50,7 @@ const listAddresses: any = async (
}
}

// create keypair
// Create keypair
const createKeyPair: any = (context: vscode.ExtensionContext, path: string, pswd: string) => {
const params = { keyBytes: 32, ivBytes: 16 }
const bareKey = keythereum.create(params)
Expand Down Expand Up @@ -83,7 +83,7 @@ const createKeyPair: any = (context: vscode.ExtensionContext, path: string, pswd
return keyObject.address
}

// delete privateKey against address
// Delete privateKey against address
const deleteKeyPair: any = async (context: vscode.ExtensionContext) => {
try {
const pubkeyInp: InputBoxOptions = {
Expand All @@ -92,7 +92,7 @@ const deleteKeyPair: any = async (context: vscode.ExtensionContext) => {
}
const publicKey = await window.showInputBox(pubkeyInp)
if (publicKey === undefined) {
logger.log('Please input public address')
logger.log('Please input public address!')
return
}
fs.readdir(`${context.extensionPath}/keystore`, (err, files) => {
Expand All @@ -115,7 +115,6 @@ const deleteKeyPair: any = async (context: vscode.ExtensionContext) => {
}

// Import Key pair

const importKeyPair: any = async (context: vscode.ExtensionContext) => {
try {
const options: vscode.OpenDialogOptions = {
Expand All @@ -130,6 +129,7 @@ const importKeyPair: any = async (context: vscode.ExtensionContext) => {

await vscode.window.showOpenDialog(options).then((fileUri) => {
if ((fileUri?.[0]) != null) {
const filename = fileUri[0].fsPath.replace(/^.*[\\/]/, '')
const arrFilePath = fileUri[0].fsPath.split('\\')
const file = arrFilePath[arrFilePath.length - 1]
const arr = file.split('--')
Expand All @@ -144,7 +144,7 @@ const importKeyPair: any = async (context: vscode.ExtensionContext) => {
} else {
fs.copyFile(
fileUri[0].fsPath,
`${context.extensionPath}/keystore/${file}`,
`${context.extensionPath}/keystore/${filename}`,
(err) => {
if (err != null) throw err
}
Expand All @@ -163,7 +163,7 @@ const importKeyPair: any = async (context: vscode.ExtensionContext) => {
}
}

// extract privateKey against address
// Extract privateKey against address
const extractPvtKey: any = async (keyStorePath: string, address: string) => {
try {
const pwdInpOpt: vscode.InputBoxOptions = {
Expand Down

0 comments on commit 958b56f

Please sign in to comment.