Skip to content

Commit

Permalink
fix: load contract to compile
Browse files Browse the repository at this point in the history
  • Loading branch information
MCarlomagno committed Dec 4, 2024
1 parent b9c0ca1 commit 492c670
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/lib/wizard/components/Configure.svelte
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>

0 comments on commit 492c670

Please sign in to comment.