Skip to content

Commit

Permalink
Merge pull request #27 from OpenZeppelin/plat-5814-wizard-deploy-cons…
Browse files Browse the repository at this point in the history
…tructor-inputs-not-reacting-to-stablecoin

Fix: react to all types of assets and contract name changed
  • Loading branch information
MCarlomagno authored Dec 12, 2024
2 parents 4547cd6 + d150007 commit 6325203
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
10 changes: 10 additions & 0 deletions src/lib/models/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,13 @@ export interface DeploymentResult {
hash: string;
sender?: string;
}

export type ABITypeParameter = 'uint' | 'uint[]' | 'int' | 'int[]' | 'address' | 'address[]' | 'bool' | 'bool[]' | 'fixed' | 'fixed[]' | 'ufixed' | 'ufixed[]' | 'bytes' | 'bytes[]' | 'function' | 'function[]' | 'tuple' | 'tuple[]' | string;
export interface ABIParameter {
/** The name of the parameter */
name: string;
/** The canonical type of the parameter */
type: ABITypeParameter;
/** Used for tuple types */
components?: ABIParameter[];
}
35 changes: 17 additions & 18 deletions src/lib/wizard/components/Deploy.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { API } from "$lib/api";
import { deployContract, switchToNetwork } from "$lib/ethereum";
import type { ApprovalProcess, CreateApprovalProcessRequest } from "$lib/models/approval-process";
import type { Artifact, DeployContractRequest, DeploymentResult, UpdateDeploymentRequest } from "$lib/models/deploy";
import type { ABIParameter, Artifact, DeployContractRequest, DeploymentResult, UpdateDeploymentRequest } from "$lib/models/deploy";
import { getNetworkLiteral, isProductionNetwork } from "$lib/models/network";
import { buildCompilerInput, type ContractSources } from "$lib/models/solc";
import type { APIResponse } from "$lib/models/ui";
Expand Down Expand Up @@ -43,11 +43,6 @@
}
});
let inputs = $derived.by(() => {
if (!compilationResult) return [];
return getConstructorInputsWizard(globalState.contract?.target, compilationResult.output.contracts);
});
let displayUpgradeableWarning = $derived.by(() => {
return isUpgradeable(globalState.contract?.source?.sources as ContractSources);
});
Expand All @@ -66,6 +61,9 @@
: undefined
);
let inputs: ABIParameter[] = $state([]);
$effect(() => {
if (globalState.contract?.source?.sources) {
compile();
Expand All @@ -92,6 +90,10 @@
return;
}
compilationResult = res.data;
if (globalState.contract?.target && compilationResult) {
inputs = getConstructorInputsWizard(globalState.contract.target, compilationResult.output.contracts);
}
}
function displayMessage(message: string, type: "success" | "error") {
Expand Down Expand Up @@ -266,8 +268,8 @@
const deployRequest: DeployContractRequest = {
network: getNetworkLiteral(globalState.form.network),
approvalProcessId: approvalProcess.approvalProcessId,
contractName: globalState.contract!.target,
contractPath: globalState.contract!.target,
contractName: globalState.contract.target,
contractPath: globalState.contract.target,
verifySourceCode: true,
licenseType: 'MIT',
artifactPayload: JSON.stringify(deploymentArtifact),
Expand Down Expand Up @@ -310,19 +312,18 @@
</script>

<div class="flex flex-col gap-2">

{#if displayUpgradeableWarning}
<Message type="warn" message="Upgradable contracts are not yet fully supported. This action will only deploy the implementation contract without initializing. <br />We recommend using <u><a href='https://github.com/OpenZeppelin/openzeppelin-upgrades' target='_blank'>openzeppelin-upgrades</a></u> package instead." />
{/if}

{#if inputs.length > 0}
<h6 class="text-sm">Constructor Arguments</h6>
{#each inputs as input}
<Input name={input.name} placeholder={`${input.name} (${input.type})`} onchange={handleInputChange} value={''} type="text"/>
{/each}
{:else}
<Message type="info" message="No constructor arguments found" />
{/if}
<h6 class="text-sm">Constructor Arguments</h6>
{#each inputs as input}
<Input name={input.name} placeholder={`${input.name} (${input.type})`} onchange={handleInputChange} value={''} type="text"/>
{/each}
{:else}
<Message type="info" message="No constructor arguments found" />
{/if}

<div class="pt-2 flex">
<input
Expand Down Expand Up @@ -351,8 +352,6 @@
<Message message={compilationError} type="error" />
{/if}



<Button disabled={!globalState.authenticated || busy} loading={busy} label="Deploy" onClick={triggerDeploy} />

{#if successMessage || errorMessage}
Expand Down

0 comments on commit 6325203

Please sign in to comment.