Skip to content

Commit

Permalink
feat: change id separators
Browse files Browse the repository at this point in the history
Modify our id separators, swapping:

- `:` => `#`
- `#` => `.`

This allows us to write the identifiers as filenames on windows.

Resolves #441.
  • Loading branch information
kanej committed Sep 13, 2023
1 parent 4ac861a commit 8e459a0
Show file tree
Hide file tree
Showing 27 changed files with 344 additions and 344 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/internal/utils/future-id-builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
* The seperator in ids that indicated before as the module id and after
* as the parts making up the particular future.
*/
const MODULE_SEPERATOR = ":";
const MODULE_SEPERATOR = "#";

/**
* The seperator in ids that indicated different subparts of the future key.
*/
const SUBKEY_SEPERATOR = "#";
const SUBKEY_SEPERATOR = ".";

/**
* Construct the future id for a contract or library deployment, namespaced by the
Expand Down Expand Up @@ -76,7 +76,7 @@ export function toReadEventArgumentFutureId(
) {
const futureKey =
userProvidedId ??
`${contractName}#${eventName}${SUBKEY_SEPERATOR}${argumentName}${SUBKEY_SEPERATOR}${eventIndex}`;
`${contractName}${SUBKEY_SEPERATOR}${eventName}${SUBKEY_SEPERATOR}${argumentName}${SUBKEY_SEPERATOR}${eventIndex}`;

return `${moduleId}${MODULE_SEPERATOR}${futureKey}`;
}
Expand Down
32 changes: 16 additions & 16 deletions packages/core/test/batcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("batcher", () => {
return { contract1 };
});

assertBatching({ ignitionModule }, [["Module1:Contract1"]]);
assertBatching({ ignitionModule }, [["Module1#Contract1"]]);
});

it("should batch through dependencies", () => {
Expand All @@ -57,9 +57,9 @@ describe("batcher", () => {
});

assertBatching({ ignitionModule }, [
["Module1:Contract1", "Module1:Contract2"],
["Module1:Contract3"],
["Module1:Contract4", "Module1:Contract5"],
["Module1#Contract1", "Module1#Contract2"],
["Module1#Contract3"],
["Module1#Contract4", "Module1#Contract5"],
]);
});

Expand Down Expand Up @@ -98,15 +98,15 @@ describe("batcher", () => {
});

assertBatching({ ignitionModule }, [
["SubmoduleLeft:Contract1", "SubmoduleRight:Contract2"],
["SubmoduleLeft#Contract1", "SubmoduleRight#Contract2"],
[
"SubmoduleLeft:Contract1#configure",
"SubmoduleRight:Contract2#configure",
"SubmoduleLeft#Contract1.configure",
"SubmoduleRight#Contract2.configure",
],
["SubmoduleMiddle:Contract3"],
["SubmoduleMiddle:Contract3#configure"],
["Module:Contract4"],
["Module:Contract4#configure"],
["SubmoduleMiddle#Contract3"],
["SubmoduleMiddle#Contract3.configure"],
["Module#Contract4"],
["Module#Contract4.configure"],
]);
});

Expand Down Expand Up @@ -141,8 +141,8 @@ describe("batcher", () => {
});

assertBatching({ ignitionModule }, [
["Left:Contract1", "Middle:Contract3", "Right:Contract2"],
["Module:Contract4"],
["Left#Contract1", "Middle#Contract3", "Right#Contract2"],
["Module#Contract4"],
]);
});

Expand All @@ -162,15 +162,15 @@ describe("batcher", () => {
deploymentState: {
chainId: 123,
executionStates: {
"Module1:Contract2": {
"Module1#Contract2": {
...exampleDeploymentState,
id: "Module1:Contract2",
id: "Module1#Contract2",
status: ExecutionStatus.SUCCESS,
},
},
},
},
[["Module1:Contract1"], ["Module1:Contract3"]]
[["Module1#Contract1"], ["Module1#Contract3"]]
);
});
});
Expand Down
30 changes: 15 additions & 15 deletions packages/core/test/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("call", () => {
assert.equal(moduleWithASingleContract.id, "Module1");
assert.equal(
moduleWithASingleContract.results.contract1.id,
"Module1:Contract1"
"Module1#Contract1"
);

// 1 contract future & 1 call future
Expand Down Expand Up @@ -60,15 +60,15 @@ describe("call", () => {
assert.isDefined(moduleWithDependentContracts);

const exampleFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Example"
({ id }) => id === "Module1#Example"
);

const anotherFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Example"
({ id }) => id === "Module1#Example"
);

const callFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Example#test"
({ id }) => id === "Module1#Example.test"
);

if (!(callFuture instanceof NamedContractCallFutureImplementation)) {
Expand All @@ -93,15 +93,15 @@ describe("call", () => {
assert.isDefined(moduleWithDependentContracts);

const exampleFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Example"
({ id }) => id === "Module1#Example"
);

const anotherFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Another"
({ id }) => id === "Module1#Another"
);

const callFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Example#test"
({ id }) => id === "Module1#Example.test"
);

if (!(callFuture instanceof NamedContractCallFutureImplementation)) {
Expand All @@ -125,7 +125,7 @@ describe("call", () => {
assert.isDefined(moduleWithDependentContracts);

const callFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Example#test"
({ id }) => id === "Module1#Example.test"
);

if (!(callFuture instanceof NamedContractCallFutureImplementation)) {
Expand All @@ -147,7 +147,7 @@ describe("call", () => {
assert.isDefined(moduleWithDependentContracts);

const callFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Example#test"
({ id }) => id === "Module1#Example.test"
);

if (!(callFuture instanceof NamedContractCallFutureImplementation)) {
Expand All @@ -172,7 +172,7 @@ describe("call", () => {
assert.isDefined(moduleWithDependentContracts);

const callFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Example#test"
({ id }) => id === "Module1#Example.test"
);

if (!(callFuture instanceof NamedContractCallFutureImplementation)) {
Expand All @@ -194,7 +194,7 @@ describe("call", () => {
assert.isDefined(moduleWithDependentContracts);

const callFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Example#test"
({ id }) => id === "Module1#Example.test"
);

if (!(callFuture instanceof NamedContractCallFutureImplementation)) {
Expand Down Expand Up @@ -383,11 +383,11 @@ describe("call", () => {
assert.equal(moduleWithSameCallTwice.id, "Module1");

const callFuture = [...moduleWithSameCallTwice.futures].find(
({ id }) => id === "Module1:first"
({ id }) => id === "Module1#first"
);

const callFuture2 = [...moduleWithSameCallTwice.futures].find(
({ id }) => id === "Module1:second"
({ id }) => id === "Module1#second"
);

assert.isDefined(callFuture);
Expand All @@ -404,7 +404,7 @@ describe("call", () => {

return { sameContract1 };
}),
/Duplicated id Module1:SameContract#test found in module Module1/
/Duplicated id Module1#SameContract.test found in module Module1/
);
});

Expand All @@ -417,7 +417,7 @@ describe("call", () => {
m.call(sameContract1, "test", [], { id: "first" });
return { sameContract1 };
}),
/Duplicated id Module1:first found in module Module1/
/Duplicated id Module1#first found in module Module1/
);
});
});
Expand Down
30 changes: 15 additions & 15 deletions packages/core/test/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("contract", () => {
assert.equal(moduleWithASingleContract.id, "Module1");
assert.equal(
moduleWithASingleContract.results.contract1.id,
"Module1:Contract1"
"Module1#Contract1"
);

// 1 contract future
Expand All @@ -52,11 +52,11 @@ describe("contract", () => {
assert.isDefined(moduleWithDependentContracts);

const exampleFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Example"
({ id }) => id === "Module1#Example"
);

const anotherFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Another"
({ id }) => id === "Module1#Another"
);

if (
Expand All @@ -80,11 +80,11 @@ describe("contract", () => {
assert.isDefined(moduleWithDependentContracts);

const exampleFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Example"
({ id }) => id === "Module1#Example"
);

const anotherFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Another"
({ id }) => id === "Module1#Another"
);

if (
Expand All @@ -110,11 +110,11 @@ describe("contract", () => {
assert.isDefined(moduleWithDependentContracts);

const exampleFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Example"
({ id }) => id === "Module1#Example"
);

const anotherFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Another"
({ id }) => id === "Module1#Another"
);

if (
Expand All @@ -138,7 +138,7 @@ describe("contract", () => {
assert.isDefined(moduleWithDependentContracts);

const anotherFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Another"
({ id }) => id === "Module1#Another"
);

if (
Expand All @@ -162,7 +162,7 @@ describe("contract", () => {
assert.isDefined(moduleWithDependentContracts);

const anotherFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Another"
({ id }) => id === "Module1#Another"
);

if (
Expand All @@ -187,7 +187,7 @@ describe("contract", () => {
assert.isDefined(moduleWithDependentContracts);

const anotherFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Another"
({ id }) => id === "Module1#Another"
);

if (
Expand All @@ -209,7 +209,7 @@ describe("contract", () => {
assert.isDefined(moduleWithDependentContracts);

const anotherFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Another"
({ id }) => id === "Module1#Another"
);

if (
Expand Down Expand Up @@ -368,11 +368,11 @@ describe("contract", () => {
assert.equal(moduleWithSameContractTwice.id, "Module1");
assert.equal(
moduleWithSameContractTwice.results.sameContract1.id,
"Module1:first"
"Module1#first"
);
assert.equal(
moduleWithSameContractTwice.results.sameContract2.id,
"Module1:second"
"Module1#second"
);
});

Expand All @@ -385,7 +385,7 @@ describe("contract", () => {

return { sameContract1, sameContract2 };
}),
/Duplicated id Module1:SameContract found in module Module1/
/Duplicated id Module1#SameContract found in module Module1/
);
});

Expand All @@ -402,7 +402,7 @@ describe("contract", () => {

return { sameContract1, sameContract2 };
}),
/Duplicated id Module1:same found in module Module1/
/Duplicated id Module1#same found in module Module1/
);
});
});
Expand Down
12 changes: 6 additions & 6 deletions packages/core/test/contractAt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("contractAt", () => {
assert.equal(moduleWithContractFromArtifact.id, "Module1");
assert.equal(
moduleWithContractFromArtifact.results.contract1.id,
"Module1:Contract1"
"Module1#Contract1"
);

// Stores the address
Expand Down Expand Up @@ -79,7 +79,7 @@ describe("contractAt", () => {
const anotherFuture = moduleWithDependentContracts.results.another;

const callFuture = [...moduleWithDependentContracts.futures].find(
({ id }) => id === "Module1:Example#getAddress"
({ id }) => id === "Module1#Example.getAddress"
);

assert.equal(anotherFuture.dependencies.size, 1);
Expand Down Expand Up @@ -139,11 +139,11 @@ describe("contractAt", () => {
assert.equal(moduleWithSameContractTwice.id, "Module1");
assert.equal(
moduleWithSameContractTwice.results.sameContract1.id,
"Module1:first"
"Module1#first"
);
assert.equal(
moduleWithSameContractTwice.results.sameContract2.id,
"Module1:second"
"Module1#second"
);
});

Expand All @@ -156,7 +156,7 @@ describe("contractAt", () => {

return { sameContract1, sameContract2 };
}),
/Duplicated id Module1:SameContract found in module Module1/
/Duplicated id Module1#SameContract found in module Module1/
);
});

Expand All @@ -183,7 +183,7 @@ describe("contractAt", () => {

return { sameContract1, sameContract2 };
}),
/Duplicated id Module1:same found in module Module1/
/Duplicated id Module1#same found in module Module1/
);
});
});
Expand Down
Loading

0 comments on commit 8e459a0

Please sign in to comment.