Skip to content

Commit a1d720c

Browse files
authored
Merge pull request #20 from OpenZeppelin/main
Release to wizard
2 parents de009e2 + 7906618 commit a1d720c

File tree

11 files changed

+480
-322
lines changed

11 files changed

+480
-322
lines changed

src/lib/models/deploy.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,11 @@ export interface UpdateDeploymentRequest {
7070
deploymentId: string;
7171
address: string;
7272
hash: string;
73-
}
73+
}
74+
75+
export interface DeploymentResult {
76+
deploymentId?: string;
77+
address: string;
78+
hash: string;
79+
sender?: string;
80+
}

src/lib/state/state.svelte.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ApprovalProcess } from "$lib/models/approval-process";
22
import type { GlobalState } from "$lib/models/ui";
3-
import type { ContractSources } from "$lib/models/solc";
3+
import { isDeploymentEnvironment, isSameNetwork } from "$lib/utils/helpers";
44

55
/**
66
* Global application state
@@ -84,3 +84,13 @@ export const addAPToDropdown = (approvalProcess: ApprovalProcess) => {
8484
export function setDeploymentCompleted(completed: boolean) {
8585
globalState.form.completed = completed;
8686
}
87+
88+
export function findDeploymentEnvironment(via?: string, network?: string) {
89+
if (!via || !network) return undefined;
90+
return globalState.approvalProcesses.find((ap) =>
91+
ap.network &&
92+
isDeploymentEnvironment(ap) &&
93+
isSameNetwork(ap.network, network) &&
94+
ap.via?.toLocaleLowerCase() === via.toLocaleLowerCase()
95+
);
96+
}

src/lib/utils/contracts.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ABIDescription, ABIParameter, CompilationResult } from "@remixproject/plugin-api";
22
import { AbiCoder } from "ethers";
33
import { attempt } from "./attempt";
4+
import type { Artifact } from "$lib/models/deploy";
45

56
export function getContractFeatures(
67
path: string,
@@ -28,6 +29,23 @@ export function getConstructorInputs(
2829
return constructor.inputs as ABIParameter[];
2930
}
3031

32+
export function getConstructorInputsWizard(
33+
path: string | undefined,
34+
contracts: Artifact['output']['contracts'],
35+
): ABIParameter[] {
36+
// if no compiled contracts found, then return empty inputs.
37+
if (!contracts || !path) return [];
38+
39+
const contractName =
40+
Object.keys(contracts[path]).length > 0
41+
? Object.keys(contracts[path])[0]
42+
: "";
43+
const abi: Array<ABIDescription> = contracts[path][contractName].abi;
44+
const constructor = abi.find((fragment) => fragment.type === "constructor");
45+
if (!constructor || !constructor.inputs) return [];
46+
return constructor.inputs as ABIParameter[];
47+
}
48+
3149
export async function encodeConstructorArgs(
3250
inputs: ABIParameter[],
3351
inputsWithValue: Record<string, string | number | boolean>

src/lib/utils/helpers.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { ApprovalProcess } from "$lib/models/approval-process";
22
import { getNetworkLiteral, type TenantNetworkResponse } from "$lib/models/network";
3+
import type { ContractSources } from "$lib/models/solc";
34

45
export const abbreviateAddress = (address: string, size = 6) => {
56
return `${address.slice(0, size)}...${address.slice(-size)}`;
@@ -14,3 +15,14 @@ export const isSameNetwork = (a: string | TenantNetworkResponse, b: string | Ten
1415
export const isDeploymentEnvironment = (approvalProcess: ApprovalProcess) => {
1516
return approvalProcess.component?.includes('deploy');
1617
}
18+
19+
export const isMultisig = (viaType?: ApprovalProcess['viaType']) => {
20+
if (!viaType) return false;
21+
const multisigTypes = ['Safe', 'Multisig', 'Gnosis Safe', 'Gnosis Multisig'];
22+
return multisigTypes.includes(viaType);
23+
}
24+
25+
export const isUpgradeable = (sources?: ContractSources) => {
26+
if (!sources) return false;
27+
return Object.keys(sources).some((path) => path.includes('@openzeppelin/contracts-upgradeable'));
28+
}

src/lib/wizard/components/ApprovalProcess.svelte

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import type { Relayer } from "$lib/models/relayer";
88
import { getNetworkLiteral } from "$lib/models/network";
99
import Input from "./shared/Input.svelte";
10+
import Message from "./shared/Message.svelte";
1011
1112
let address = $state<string>(globalState.form.approvalProcessToCreate?.via || "");
1213
@@ -167,11 +168,8 @@
167168
</div>
168169
{:else if approvalProcessType === "Relayer"}
169170
{#if disableRelayers}
170-
<div class="alert alert-warning d-flex align-items-center mt-2">
171-
<i class="fa fa-exclamation-triangle mr-2"></i>
172-
<p class="m-0 lh-1">
173-
<small class="lh-sm">API Key not allowed to manage Relayers</small>
174-
</p>
171+
<div class="mt-2">
172+
<Message message="API Key not allowed to manage Relayers" type="warn" />
175173
</div>
176174
{:else}
177175
<Dropdown

0 commit comments

Comments
 (0)