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

feat/constrain-ids #466

Merged
merged 11 commits into from
Sep 14, 2023
2 changes: 1 addition & 1 deletion examples/complete/ignition/CompleteModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = buildModule("CompleteModule", (m) => {
{ id: "ContractWithLibrary2" }
);

m.send("test-send", duplicate, 123n);
m.send("test_send", duplicate, 123n);

return {
basic,
Expand Down
6 changes: 3 additions & 3 deletions examples/ens/ignition/ENS.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const resolverModule = buildModule("RESOLVER", (m) => {
const resolver = m.contract("PublicResolver", [ens, ZERO_ADDRESS]);

m.call(ens, "setSubnodeOwner", [ZERO_HASH, resolverLabel, account], {
id: "set-subnode-owner-for-resolver",
id: "set_subnode_owner_for_resolver",
});

m.call(ens, "setResolver", [resolverNode, resolver]);
Expand All @@ -50,15 +50,15 @@ const reverseRegistrarModule = buildModule("REVERSEREGISTRAR", (m) => {
const reverseRegistrar = m.contract("ReverseRegistrar", [ens, resolver]);

m.call(ens, "setSubnodeOwner", [ZERO_HASH, reverseLabel, account], {
id: "set-subnode-owner-reverse",
id: "set_subnode_owner_reverse",
});

m.call(
ens,
"setSubnodeOwner",
[reverseTldHash, addrLabel, reverseRegistrar],
{
id: "set-subnode-addr-label",
id: "set_subnode_addr_label",
}
);

Expand Down
4 changes: 2 additions & 2 deletions examples/ens/ignition/test-registrar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const ZERO_HASH =

const ACCOUNT_0 = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266";

module.exports = buildModule("TEST registrar", (m) => {
module.exports = buildModule("TEST_registrar", (m) => {
const tld = "test";
const tldHash = namehash.hash(tld);
const tldLabel = labelhash(tld);
Expand All @@ -22,7 +22,7 @@ module.exports = buildModule("TEST registrar", (m) => {
const registrar = m.contract("FIFSRegistrar", [ens, tldHash]);

m.call(ens, "setSubnodeOwner", [ZERO_HASH, tldLabel, ACCOUNT_0], {
id: "set-subnode-owner-for-registrar",
id: "set_subnode_owner_for_registrar",
});

return { ens, resolver, registrar, reverseRegistrar };
Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/build-module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { IgnitionError } from "./errors";
import { ModuleConstructor } from "./internal/module-builder";
import { isValidIgnitionIdentifier } from "./internal/utils/identifier-validators";
import { IgnitionModule, IgnitionModuleResult } from "./types/module";
import { IgnitionModuleBuilder } from "./types/module-builder";

Expand All @@ -25,6 +26,12 @@ export function buildModule<
throw new IgnitionError(`\`moduleId\` must be a string`);
}

if (!isValidIgnitionIdentifier(moduleId)) {
throw new IgnitionError(
`The moduleId "${moduleId}" contains banned characters, ids can only contain alphanumerics or underscores`
);
}

if (typeof moduleDefintionFunction !== "function") {
throw new IgnitionError(`\`moduleDefintionFunction\` must be a function`);
}
Expand Down
Loading