-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9c0ca1
commit 492c670
Showing
1 changed file
with
10 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
<script lang="ts"> | ||
import { API } from "$lib/api"; | ||
import { buildCompilerInput } from "$lib/models/solc"; | ||
import { buildCompilerInput, type ContractSources } from "$lib/models/solc"; | ||
import { wizardState } from "../state.svelte"; | ||
let result: any; | ||
let compilationResult: any; | ||
async function compile() { | ||
if (!wizardState.sources) return; | ||
const result = await API.compile(buildCompilerInput(wizardState.sources)); | ||
console.log(result); | ||
compilationResult = await API.compile(buildCompilerInput(wizardState.sources)); | ||
} | ||
function getMainContractName(sources?: ContractSources) { | ||
if (!sources) return ''; | ||
// The first name that is not a dependency | ||
return Object.keys(sources).find(name => !name.startsWith('@')); | ||
} | ||
</script> | ||
|
||
<p> | ||
Contract to compile: {wizardState.sources?.target} | ||
Contract to compile: {getMainContractName(wizardState.sources)} | ||
|
||
<button onclick={compile} > | ||
Compile | ||
</button> | ||
|
||
result: {JSON.stringify(result, null, 2)} | ||
</p> |