Skip to content

Commit

Permalink
Merge pull request #5 from OpenZeppelin/fix-deployment-link
Browse files Browse the repository at this point in the history
fix prod deployment link
  • Loading branch information
MCarlomagno authored Nov 27, 2024
2 parents 0616f9e + 406e9ab commit 7961bff
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/lib/components/ApprovalProcess.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
import type { DropdownItem, GlobalState } from "$lib/models/ui";
import type { Relayer } from "$lib/models/relayer";
const approvalProcessByNetworkAndComponent = (ap: ApprovalProcess) =>
ap.network === globalState.form.network && ap.component?.includes("deploy");
function approvalProcessByNetworkAndComponent(ap: ApprovalProcess) {
const networkName = typeof globalState.form.network === 'string'
? globalState.form.network
: globalState.form.network?.name;
return ap.network === networkName && ap.component?.includes("deploy");
}
// Approval processes load logic
const toDisplayName = (ap: ApprovalProcess) => `${ap.name} (${ap.viaType})`;
Expand Down
17 changes: 13 additions & 4 deletions src/lib/components/Depoy.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { deployContract, switchToNetwork } from "$lib/ethereum";
import { API } from "$lib/api";
import type { APIResponse } from "$lib/models/ui";
import { getNetworkLiteral } from "$lib/models/network";
import { getNetworkLiteral, isProductionNetwork } from "$lib/models/network";
let contractName: string | undefined;
let contractBytecode: string | undefined;
Expand All @@ -30,6 +30,13 @@
let contractPath: string | undefined;
let deploymentId = $state<string | undefined>(undefined);
const deploymentUrl = $derived(
deploymentId && globalState.form.network
? `https://defender.openzeppelin.com/#/deploy/environment/${
isProductionNetwork(globalState.form.network) ? 'production' : 'test'
}?deploymentId=${deploymentId}`
: undefined
);
let deploying = $state(false);
let isDeterministic = $state(false);
Expand Down Expand Up @@ -321,9 +328,11 @@
<p class="m-0">
<small class="lh-sm">
Contract deployment submitted to Defender!<br>
<a class="text-success" href={`https://defender.openzeppelin.com/#/deploy/environment/test?deploymentId=${deploymentId}`} target="_blank">
View Deployment
</a>
{#if deploymentUrl}
<a class="text-success" href={deploymentUrl} target="_blank">
View Deployment
</a>
{/if}
</small>
</p>
</div>
Expand Down
34 changes: 34 additions & 0 deletions src/lib/models/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,40 @@ export interface TenantNetworkResponse {
name: string;
chainId: number;
networkType: 'private' | 'fork';
isProduction?: boolean;
}

export const productionNetworks = new Set([
'arbitrum',
'arbitrum-nova',
'aurora',
'avalanche',
'base',
'bsc',
'celo',
'fantom',
'fuse',
'hedera',
'japan',
'linea',
'mainnet',
'mantle',
'matic',
'matic-zkevm',
'meld',
'moonbeam',
'moonriver',
'optimism',
'scroll',
'xdai',
'zksync'
]);

export function isProductionNetwork(network: string | TenantNetworkResponse): boolean {
if (typeof network === 'string') {
return productionNetworks.has(network);
}
return network.isProduction ?? false;
}

export function getNetworkLiteral(network: string | TenantNetworkResponse): string {
Expand Down

0 comments on commit 7961bff

Please sign in to comment.