Skip to content

Commit

Permalink
resolve files URI
Browse files Browse the repository at this point in the history
  • Loading branch information
0mkara committed Apr 5, 2023
1 parent 28e222d commit 344f3fe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ethcode",
"displayName": "ETHcode",
"description": "Ethereum IDE for VS Code",
"version": "0.4.5",
"version": "0.4.6",
"publisher": "7finney",
"categories": [
"Debuggers",
Expand Down
21 changes: 13 additions & 8 deletions src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,23 @@ const getDeployedContractAddress = async (
for (let i = 0; i < Object.keys(contracts).length; i++) {
const contract: CompiledJSONOutput = contracts[Object.keys(contracts)[i]]
if (contract.name === name) {
console.log('get contract path')
console.log(contract.path)
const link = getDeployedFullPath(contract)
const linkchnage = link.replace(/\\/g, '/')
const parsedUrl = new URL(linkchnage)
const fileUrl: vscode.Uri = vscode.Uri.parse(`file://${parsedUrl.pathname}`)
const contents: Uint8Array = await vscode.workspace.fs.readFile(fileUrl)
// const parsedUrl = new URL(linkchnage)
// console.log(parsedUrl)
// const fileUrl: vscode.Uri = vscode.Uri.parse(`file://${parsedUrl.pathname}`)
const fileUri = vscode.Uri.file(linkchnage)
const contents: Uint8Array = await vscode.workspace.fs.readFile(fileUri)
const decoder = new TextDecoder()
const jsonString = decoder.decode(contents)
const json = JSON.parse(jsonString)
return json.address
}
}
} catch (error) {
console.log(error)
console.error(error)
}
}

Expand All @@ -146,16 +150,17 @@ const getFunctionInputFile: any = async (
if (contract != null) {
const link = getFunctionInputFullPath(contract)
const linkchnage = link.replace(/\\/g, '/')
const parsedUrl = new URL(linkchnage)
const fileUrl: vscode.Uri = vscode.Uri.parse(`file://${parsedUrl.pathname}`)
const contents: Uint8Array = await vscode.workspace.fs.readFile(fileUrl)
// const parsedUrl = new URL(linkchnage)
// const fileUrl: vscode.Uri = vscode.Uri.parse(`file://${parsedUrl.pathname}`)
const fileUri = vscode.Uri.file(linkchnage)
const contents: Uint8Array = await vscode.workspace.fs.readFile(fileUri)
const decoder = new TextDecoder()
const jsonString = decoder.decode(contents)
const json = JSON.parse(jsonString)
return json
}
} catch (error) {
console.log(error)
console.error(error)
}
}

Expand Down

0 comments on commit 344f3fe

Please sign in to comment.