Skip to content

Commit

Permalink
fix validation for global params with no default value
Browse files Browse the repository at this point in the history
  • Loading branch information
zoeyTM committed Nov 20, 2024
1 parent 44ebf75 commit d9c9018
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/sample/ignition/modules/LockModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const TEN_YEARS_IN_FUTURE = currentTimestampInSeconds + TEN_YEAR_IN_SECS;
const ONE_GWEI = BigInt(hre.ethers.parseUnits("1", "gwei"));

module.exports = buildModule("LockModule", (m) => {
const unlockTime = m.getParameter("unlockTime", TEN_YEARS_IN_FUTURE);
const unlockTime = m.getParameter("unlockTime");
const lockedAmount = m.getParameter("lockedAmount", ONE_GWEI);

const lock = m.contract("Lock", [unlockTime], {
Expand Down
5 changes: 5 additions & 0 deletions examples/sample/parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$global": {
"unlockTime": 1987909200
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export async function validateArtifactContractAt(
if (isModuleParameterRuntimeValue(future.address)) {
const param =
deploymentParameters[future.address.moduleId]?.[future.address.name] ??
deploymentParameters.$global[future.address.name] ??
future.address.defaultValue;
if (param === undefined) {
errors.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export async function validateArtifactContractDeployment(
const missingParams = moduleParams.filter(
(param) =>
deploymentParameters[param.moduleId]?.[param.name] === undefined &&
deploymentParameters.$global[param.name] === undefined &&
param.defaultValue === undefined
);

Expand All @@ -69,6 +70,7 @@ export async function validateArtifactContractDeployment(
if (isModuleParameterRuntimeValue(future.value)) {
const param =
deploymentParameters[future.value.moduleId]?.[future.value.name] ??
deploymentParameters.$global[future.value.name] ??
future.value.defaultValue;
if (param === undefined) {
errors.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export async function validateNamedContractAt(
if (isModuleParameterRuntimeValue(future.address)) {
const param =
deploymentParameters[future.address.moduleId]?.[future.address.name] ??
deploymentParameters.$global[future.address.name] ??
future.address.defaultValue;
if (param === undefined) {
errors.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export async function validateNamedContractCall(

const missingParams = moduleParams.filter(
(param) =>
deploymentParameters[param.moduleId]?.[param.name] === undefined &&
(deploymentParameters[param.moduleId]?.[param.name] === undefined &&
deploymentParameters.$global[param.name]) === undefined &&
param.defaultValue === undefined
);

Expand All @@ -80,6 +81,7 @@ export async function validateNamedContractCall(
if (isModuleParameterRuntimeValue(future.value)) {
const param =
deploymentParameters[future.value.moduleId]?.[future.value.name] ??
deploymentParameters.$global[future.value.name] ??
future.value.defaultValue;
if (param === undefined) {
errors.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export async function validateNamedContractDeployment(

const missingParams = moduleParams.filter(
(param) =>
deploymentParameters[param.moduleId]?.[param.name] === undefined &&
(deploymentParameters[param.moduleId]?.[param.name] === undefined &&
deploymentParameters.$global[param.name]) === undefined &&
param.defaultValue === undefined
);

Expand All @@ -80,6 +81,7 @@ export async function validateNamedContractDeployment(
if (isModuleParameterRuntimeValue(future.value)) {
const param =
deploymentParameters[future.value.moduleId]?.[future.value.name] ??
deploymentParameters.$global[future.value.name] ??
future.value.defaultValue;
if (param === undefined) {
errors.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export async function validateNamedEncodeFunctionCall(

const missingParams = moduleParams.filter(
(param) =>
deploymentParameters[param.moduleId]?.[param.name] === undefined &&
(deploymentParameters[param.moduleId]?.[param.name] === undefined &&
deploymentParameters.$global[param.name]) === undefined &&
param.defaultValue === undefined
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export async function validateNamedStaticCall(

const missingParams = moduleParams.filter(
(param) =>
deploymentParameters[param.moduleId]?.[param.name] === undefined &&
(deploymentParameters[param.moduleId]?.[param.name] === undefined &&
deploymentParameters.$global[param.name]) === undefined &&
param.defaultValue === undefined
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export async function validateSendData(
if (isModuleParameterRuntimeValue(future.to)) {
const param =
deploymentParameters[future.to.moduleId]?.[future.to.name] ??
deploymentParameters.$global[future.to.name] ??
future.to.defaultValue;
if (param === undefined) {
errors.push(
Expand All @@ -54,6 +55,7 @@ export async function validateSendData(
if (isModuleParameterRuntimeValue(future.value)) {
const param =
deploymentParameters[future.value.moduleId]?.[future.value.name] ??
deploymentParameters.$global[future.value.name] ??
future.value.defaultValue;
if (param === undefined) {
errors.push(
Expand Down

0 comments on commit d9c9018

Please sign in to comment.