Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/lib/models/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,11 @@ export interface UpdateDeploymentRequest {
deploymentId: string;
address: string;
hash: string;
}
}

export interface DeploymentResult {
deploymentId?: string;
address: string;
hash: string;
sender?: string;
}
12 changes: 11 additions & 1 deletion src/lib/state/state.svelte.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ApprovalProcess } from "$lib/models/approval-process";
import type { GlobalState } from "$lib/models/ui";
import type { ContractSources } from "$lib/models/solc";
import { isDeploymentEnvironment, isSameNetwork } from "$lib/utils/helpers";

/**
* Global application state
Expand Down Expand Up @@ -84,3 +84,13 @@ export const addAPToDropdown = (approvalProcess: ApprovalProcess) => {
export function setDeploymentCompleted(completed: boolean) {
globalState.form.completed = completed;
}

export function findDeploymentEnvironment(via?: string, network?: string) {
if (!via || !network) return undefined;
return globalState.approvalProcesses.find((ap) =>
ap.network &&
isDeploymentEnvironment(ap) &&
isSameNetwork(ap.network, network) &&
ap.via?.toLocaleLowerCase() === via.toLocaleLowerCase()
);
}
18 changes: 18 additions & 0 deletions src/lib/utils/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ABIDescription, ABIParameter, CompilationResult } from "@remixproject/plugin-api";
import { AbiCoder } from "ethers";
import { attempt } from "./attempt";
import type { Artifact } from "$lib/models/deploy";

export function getContractFeatures(
path: string,
Expand Down Expand Up @@ -28,6 +29,23 @@ export function getConstructorInputs(
return constructor.inputs as ABIParameter[];
}

export function getConstructorInputsWizard(
path: string | undefined,
contracts: Artifact['output']['contracts'],
): ABIParameter[] {
// if no compiled contracts found, then return empty inputs.
if (!contracts || !path) return [];

const contractName =
Object.keys(contracts[path]).length > 0
? Object.keys(contracts[path])[0]
: "";
const abi: Array<ABIDescription> = contracts[path][contractName].abi;
const constructor = abi.find((fragment) => fragment.type === "constructor");
if (!constructor || !constructor.inputs) return [];
return constructor.inputs as ABIParameter[];
}

export async function encodeConstructorArgs(
inputs: ABIParameter[],
inputsWithValue: Record<string, string | number | boolean>
Expand Down
12 changes: 12 additions & 0 deletions src/lib/utils/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ApprovalProcess } from "$lib/models/approval-process";
import { getNetworkLiteral, type TenantNetworkResponse } from "$lib/models/network";
import type { ContractSources } from "$lib/models/solc";

export const abbreviateAddress = (address: string, size = 6) => {
return `${address.slice(0, size)}...${address.slice(-size)}`;
Expand All @@ -14,3 +15,14 @@ export const isSameNetwork = (a: string | TenantNetworkResponse, b: string | Ten
export const isDeploymentEnvironment = (approvalProcess: ApprovalProcess) => {
return approvalProcess.component?.includes('deploy');
}

export const isMultisig = (viaType?: ApprovalProcess['viaType']) => {
if (!viaType) return false;
const multisigTypes = ['Safe', 'Multisig', 'Gnosis Safe', 'Gnosis Multisig'];
return multisigTypes.includes(viaType);
}

export const isUpgradeable = (sources?: ContractSources) => {
if (!sources) return false;
return Object.keys(sources).some((path) => path.includes('@openzeppelin/contracts-upgradeable'));
}
8 changes: 3 additions & 5 deletions src/lib/wizard/components/ApprovalProcess.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import type { Relayer } from "$lib/models/relayer";
import { getNetworkLiteral } from "$lib/models/network";
import Input from "./shared/Input.svelte";
import Message from "./shared/Message.svelte";

let address = $state<string>(globalState.form.approvalProcessToCreate?.via || "");

Expand Down Expand Up @@ -167,11 +168,8 @@
</div>
{:else if approvalProcessType === "Relayer"}
{#if disableRelayers}
<div class="alert alert-warning d-flex align-items-center mt-2">
<i class="fa fa-exclamation-triangle mr-2"></i>
<p class="m-0 lh-1">
<small class="lh-sm">API Key not allowed to manage Relayers</small>
</p>
<div class="mt-2">
<Message message="API Key not allowed to manage Relayers" type="warn" />
</div>
{:else}
<Dropdown
Expand Down
Loading
Loading