Skip to content
Merged
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
92 changes: 42 additions & 50 deletions citizen.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,11 @@ describe("Test contract path resolution", () => {
epoch: "2.1",
transactions: [
{
"emulated-contract-publish": {
"contract-name": "project-contract",
"emulated-sender": "",
"clarity-version": 2,
path: "contracts/project-contract.clar",
},
"transaction-type": "emulated-contract-publish",
"contract-name": "project-contract",
"emulated-sender": "",
"clarity-version": 2,
path: "contracts/project-contract.clar",
},
],
id: 0,
Expand Down Expand Up @@ -322,12 +321,11 @@ describe("Test contract path resolution", () => {
epoch: "2.1",
transactions: [
{
"emulated-contract-publish": {
"contract-name": "requirement",
"emulated-sender": senderAddress,
"clarity-version": 2,
path: `./.cache/requirements/${senderAddress}.requirement.clar`,
},
"transaction-type": "emulated-contract-publish",
"contract-name": "requirement",
"emulated-sender": senderAddress,
"clarity-version": 2,
path: `./.cache/requirements/${senderAddress}.requirement.clar`,
},
],
id: 0,
Expand Down Expand Up @@ -391,13 +389,12 @@ describe("Test contract path resolution", () => {
epoch: "2.1",
transactions: [
{
"emulated-contract-publish": {
"contract-name": "nonexistent",
"emulated-sender":
"ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM",
"clarity-version": 2,
path: "contracts/nonexistent.clar",
},
"transaction-type": "emulated-contract-publish",
"contract-name": "nonexistent",
"emulated-sender":
"ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM",
"clarity-version": 2,
path: "contracts/nonexistent.clar",
},
],
id: 0,
Expand Down Expand Up @@ -430,12 +427,11 @@ describe("Deployment plan contract source retrieval", () => {
epoch: "2.1",
transactions: [
{
"emulated-contract-publish": {
"contract-name": "counter",
"emulated-sender": senderAddress,
"clarity-version": 2,
path: "contracts/counter.clar",
},
"transaction-type": "emulated-contract-publish",
"contract-name": "counter",
"emulated-sender": senderAddress,
"clarity-version": 2,
path: "contracts/counter.clar",
},
],
id: 0,
Expand Down Expand Up @@ -538,20 +534,18 @@ describe("Deployment plan contract selection edge cases", () => {
epoch: "2.1",
transactions: [
{
"emulated-contract-publish": {
"contract-name": contractName,
"emulated-sender": sender1Address,
"clarity-version": 2,
path: `.cache/requirements/${sender1Address}.shared-contract.clar`,
},
"transaction-type": "emulated-contract-publish",
"contract-name": contractName,
"emulated-sender": sender1Address,
"clarity-version": 2,
path: `.cache/requirements/${sender1Address}.shared-contract.clar`,
},
{
"emulated-contract-publish": {
"contract-name": contractName,
"emulated-sender": sender2Address,
"clarity-version": 2,
path: `.cache/requirements/${sender2Address}.shared-contract.clar`,
},
"transaction-type": "emulated-contract-publish",
"contract-name": contractName,
"emulated-sender": sender2Address,
"clarity-version": 2,
path: `.cache/requirements/${sender2Address}.shared-contract.clar`,
},
],
id: 0,
Expand Down Expand Up @@ -598,13 +592,12 @@ describe("Deployment plan contract selection edge cases", () => {
epoch: "2.1",
transactions: [
{
"emulated-contract-publish": {
"contract-name": "shared-name-contract",
// Requirement contract sender. Different from deployer.
"emulated-sender": "SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG",
"clarity-version": 2,
path: ".cache/requirements/SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.shared-name-contract.clar",
},
"transaction-type": "emulated-contract-publish",
"contract-name": "shared-name-contract",
// Requirement contract sender. Different from deployer.
"emulated-sender": "SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG",
"clarity-version": 2,
path: ".cache/requirements/SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.shared-name-contract.clar",
},
],
id: 0,
Expand All @@ -613,12 +606,11 @@ describe("Deployment plan contract selection edge cases", () => {
epoch: "3.0",
transactions: [
{
"emulated-contract-publish": {
"contract-name": "shared-name-contract",
"emulated-sender": deployerAddress,
"clarity-version": 3,
path: "contracts/shared-name-contract.clar",
},
"transaction-type": "emulated-contract-publish",
"contract-name": "shared-name-contract",
"emulated-sender": deployerAddress,
"clarity-version": 3,
path: "contracts/shared-name-contract.clar",
},
],
id: 0,
Expand Down
14 changes: 6 additions & 8 deletions citizen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,8 @@ const getSutContractDeploymentPlanEmulatedPublish = (
.flatMap((batch: Batch) => batch.transactions)
.filter(
(transaction: Transaction) =>
transaction["emulated-contract-publish"] &&
transaction["emulated-contract-publish"]["contract-name"] ===
sutContractName
transaction["transaction-type"] === "emulated-contract-publish" &&
transaction["contract-name"] === sutContractName
);

// If no matches are found, something went wrong.
Expand Down Expand Up @@ -317,9 +316,8 @@ const getSutContractDeploymentPlanEmulatedPublish = (
// having the same name, select the one deployed by the deployer.
const targetContractDeploymentData = contractPublishMatchesByName.find(
(transaction: Transaction) =>
transaction["emulated-contract-publish"]!["emulated-sender"]! ===
deployer
)?.["emulated-contract-publish"];
transaction["emulated-sender"] === deployer
);

// TODO: Consider handling requirements and project contracts separately.
// Eventually let the user specify if the contract is a requirement or a
Expand All @@ -338,9 +336,9 @@ const getSutContractDeploymentPlanEmulatedPublish = (
return targetContractDeploymentData;
}

// Only one match was found, return the path to the contract.
// Only one match was found, return the contract publish data.
const contractNameMatch =
contractPublishMatchesByName[0]["emulated-contract-publish"];
contractPublishMatchesByName[0]

if (!contractNameMatch) {
throw new Error(`Could not locate "${sutContractName}" contract.`);
Expand Down
7 changes: 4 additions & 3 deletions citizen.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ export type SimnetSession = {
};

export type EmulatedContractPublish = {
"transaction-type": "emulated-contract-publish";
"contract-name": string;
"emulated-sender": string;
path: string;
"clarity-version": 1 | 2 | 3 | 4;
};

export type Transaction = {
"emulated-contract-publish"?: EmulatedContractPublish;
};
// Enough to support EmulatedContractPublish for now, but can be extended to
// support more transaction types in the future.
export type Transaction = EmulatedContractPublish;

export type Batch = {
id: number;
Expand Down
71 changes: 37 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@
},
"dependencies": {
"@iarna/toml": "^2.2.5",
"@stacks/clarinet-sdk": "^3.12.0",
"@stacks/transactions": "^7.2.0",
"@stacks/clarinet-sdk": "^3.14.0",
"@stacks/transactions": "^7.3.1",
"ansicolor": "^2.0.3",
"fast-check": "^4.3.0",
"yaml": "^2.8.1"
"fast-check": "^4.5.3",
"yaml": "^2.8.2"
},
"devDependencies": {
"@stacks/clarinet-sdk-wasm": "^3.12.0",
"@stacks/clarinet-sdk-wasm": "^3.14.0",
"@types/jest": "^30.0.0",
"jest": "^30.2.0",
"ts-jest": "^29.4.5",
"ts-jest": "^29.4.6",
"typescript": "^5.9.3"
}
}