Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix validation for global params with no default value #836

Closed
wants to merge 1 commit into from
Closed
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
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 &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a bug, the additional brackets are not going to give the value expected.

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] ??
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
deploymentParameters.$global[future.value.name] ??
deploymentParameters.$global?.[future.value.name] ??

I think we need to guard against there being no global parameters passed.

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
Loading