Skip to content

Commit a4d3c48

Browse files
authored
Merge pull request #10 from OpenZeppelin/enforce-deterministic-when-multisig
Enforce deterministic deployment when using multisig
2 parents 3f2bf3a + 33e1dd6 commit a4d3c48

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/lib/components/ApprovalProcess.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import { approvalProcessTypes, type ApprovalProcess, type ApprovalProcessType } from "$lib/models/approval-process";
66
import type { DropdownItem, GlobalState } from "$lib/models/ui";
77
import type { Relayer } from "$lib/models/relayer";
8+
import { getNetworkLiteral } from "$lib/models/network";
89
910
function approvalProcessByNetworkAndComponent(ap: ApprovalProcess) {
1011
const networkName = typeof globalState.form.network === 'string'
@@ -58,6 +59,7 @@
5859
viaType: "Relayer",
5960
via: relayer.value.address,
6061
relayerId: relayer.value.relayerId,
62+
network: globalState.form.network && getNetworkLiteral(globalState.form.network),
6163
};
6264
}
6365
};
@@ -69,6 +71,7 @@
6971
globalState.form.approvalProcessToCreate = {
7072
viaType: approvalProcessType as "EOA" | "Safe" | "Relayer",
7173
via: element.value,
74+
network: globalState.form.network && getNetworkLiteral(globalState.form.network),
7275
};
7376
};
7477

src/lib/components/Deploy.svelte

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@
6565
return { path, name };
6666
});
6767
68+
let enforceDeterministic = $derived.by(() => {
69+
const selectedMultisig = globalState.form.approvalType === 'existing' && globalState.form.approvalProcessSelected?.viaType === "Safe";
70+
const toCreateMultisig = globalState.form.approvalType === 'new' && globalState.form.approvalProcessToCreate?.viaType === "Safe";
71+
return selectedMultisig || toCreateMultisig;
72+
});
73+
6874
$effect(() => {
6975
contractPath = contractInfo.path;
7076
contractName = contractInfo.name;
@@ -231,6 +237,12 @@
231237
setDeploymentCompleted(false);
232238
deploying = true;
233239
240+
if ((enforceDeterministic || isDeterministic) && !salt) {
241+
logError("[Defender Deploy] Salt is required for deterministic deployments.");
242+
deploying = false;
243+
return;
244+
}
245+
234246
const [constructorBytecode, constructorError] = await encodeConstructorArgs(inputs, inputsWithValue);
235247
if (constructorError) {
236248
logError(`[Defender Deploy] Error encoding constructor arguments: ${constructorError.msg}`);
@@ -350,17 +362,21 @@
350362
class="form-check-input"
351363
type="checkbox"
352364
id="isDeterministic"
353-
checked={isDeterministic}
365+
checked={isDeterministic || enforceDeterministic}
354366
onchange={() => (isDeterministic = !isDeterministic)}
367+
disabled={enforceDeterministic}
355368
>
356369
<label class="form-check-label" for="isDeterministic">
357370
Deterministic
358371
</label>
372+
{#if enforceDeterministic}
373+
<i class="fa fa-question-circle ml-2" title="When using a Safe as the approval process, the salt is required to be deterministic."></i>
374+
{/if}
359375
</div>
360376
</div>
361377

362378

363-
{#if isDeterministic}
379+
{#if isDeterministic || enforceDeterministic}
364380
<label for="salt">{`Salt`}</label>
365381
<input
366382
name="salt"

0 commit comments

Comments
 (0)