diff --git a/citizen.tests.ts b/citizen.tests.ts index 6d6e7ca1..62ed755c 100644 --- a/citizen.tests.ts +++ b/citizen.tests.ts @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/citizen.ts b/citizen.ts index 0581acf4..4abda7a7 100644 --- a/citizen.ts +++ b/citizen.ts @@ -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. @@ -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 @@ -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.`); diff --git a/citizen.types.ts b/citizen.types.ts index 84e1c727..b0d4f630 100644 --- a/citizen.types.ts +++ b/citizen.types.ts @@ -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; diff --git a/package-lock.json b/package-lock.json index d90e554a..69c338d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,20 +10,20 @@ "license": "GPL-3.0-only", "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" }, "bin": { "rv": "dist/app.js" }, "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" } }, @@ -1086,12 +1086,12 @@ } }, "node_modules/@stacks/clarinet-sdk": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/@stacks/clarinet-sdk/-/clarinet-sdk-3.12.0.tgz", - "integrity": "sha512-vVAV7i566wDapq7Gvy5coeOsofJ6qJN27NOPeECLMA4p13E6iFvFhmDw9UXTMPQMak4JSAr2BPGFMyqcSQpg1g==", + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@stacks/clarinet-sdk/-/clarinet-sdk-3.14.0.tgz", + "integrity": "sha512-lbDzK/CT/Sspb2IDsxCf9AUQQ2b7VrGFAGd1HYWlgs8Dl4Wu0gb1kXC8cSrkhzLy+lVJz6wHIbwCj2MfJE1/dA==", "license": "GPL-3.0", "dependencies": { - "@stacks/clarinet-sdk-wasm": "3.12.0", + "@stacks/clarinet-sdk-wasm": "3.14.0", "@stacks/transactions": "^7.0.6", "kolorist": "^1.8.0", "prompts": "^2.4.2", @@ -1102,9 +1102,9 @@ } }, "node_modules/@stacks/clarinet-sdk-wasm": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/@stacks/clarinet-sdk-wasm/-/clarinet-sdk-wasm-3.12.0.tgz", - "integrity": "sha512-QN+p4hHdiRrIbhjxWTTN88wTH9aXQF175kqcya0ToFFwILF2OOP7YhXH3+1n0IDgxCOQRcFUzsUA31QztjF8VQ==", + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@stacks/clarinet-sdk-wasm/-/clarinet-sdk-wasm-3.14.0.tgz", + "integrity": "sha512-/HE09fg76TxgYIZfSq+72QJAyYL9o9jHnwc/upbBOaj+wjYGqvuyruRR2OHEbGiWcA9BfTJHioB9yHIfZa0YfQ==", "license": "GPL-3.0" }, "node_modules/@stacks/clarinet-sdk/node_modules/ansi-styles": { @@ -1200,31 +1200,31 @@ } }, "node_modules/@stacks/common": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@stacks/common/-/common-7.0.2.tgz", - "integrity": "sha512-+RSecHdkxOtswmE4tDDoZlYEuULpnTQVeDIG5eZ32opK8cFxf4EugAcK9CsIsHx/Se1yTEaQ21WGATmJGK84lQ==", + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/@stacks/common/-/common-7.3.1.tgz", + "integrity": "sha512-29ANTFcSSlXnGQlgDVWg7OQ74lgQhu3x8JkeN19Q+UE/1lbQrzcctgPHG74XHjWNp8NPBqskUYA8/HLgIKuKNQ==", "license": "MIT" }, "node_modules/@stacks/network": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@stacks/network/-/network-7.2.0.tgz", - "integrity": "sha512-AkLougCF2RLbK97TtISZxAhF3cE757XMXWOGKvEFWNauiQ5/bYyI9W5jZypG3yI/AyYIo04NKoFWWTnpJcn1iA==", + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/@stacks/network/-/network-7.3.1.tgz", + "integrity": "sha512-dQjhcwkz8lihSYSCUMf7OYeEh/Eh0++NebDtXbIB3pHWTvNCYEH7sxhYTB1iyunurv31/QEi0RuWdlfXK/BjeA==", "license": "MIT", "dependencies": { - "@stacks/common": "^7.0.2", + "@stacks/common": "^7.3.1", "cross-fetch": "^3.1.5" } }, "node_modules/@stacks/transactions": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@stacks/transactions/-/transactions-7.2.0.tgz", - "integrity": "sha512-U7wjlxM9Q+408ihRsv5mlKRslXGt2WCShKi1lduiqf5+dBSRGdVi8ttCIEckSsg3ulCVF3EHTQF3LZgw4kwKlQ==", + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/@stacks/transactions/-/transactions-7.3.1.tgz", + "integrity": "sha512-ufnC1BPrOKz5b5gxxdseP3vBrFq1+qx1L6t+J/QnjXULyWdkhtS+LBEqRw2bL5qNteMvU2GhqPgFtYQPzolGbw==", "license": "MIT", "dependencies": { "@noble/hashes": "1.1.5", "@noble/secp256k1": "1.7.1", - "@stacks/common": "^7.0.2", - "@stacks/network": "^7.2.0", + "@stacks/common": "^7.3.1", + "@stacks/network": "^7.3.1", "c32check": "^2.0.0", "lodash.clonedeep": "^4.5.0" } @@ -2340,9 +2340,9 @@ } }, "node_modules/fast-check": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/fast-check/-/fast-check-4.3.0.tgz", - "integrity": "sha512-JVw/DJSxVKl8uhCb7GrwanT9VWsCIdBkK3WpP37B/Au4pyaspriSjtrY2ApbSFwTg3ViPfniT13n75PhzE7VEQ==", + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/fast-check/-/fast-check-4.5.3.tgz", + "integrity": "sha512-IE9csY7lnhxBnA8g/WI5eg/hygA6MGWJMSNfFRrBlXUciADEhS1EDB0SIsMSvzubzIlOBbVITSsypCsW717poA==", "funding": [ { "type": "individual", @@ -4380,9 +4380,9 @@ "license": "MIT" }, "node_modules/ts-jest": { - "version": "29.4.5", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.4.5.tgz", - "integrity": "sha512-HO3GyiWn2qvTQA4kTgjDcXiMwYQt68a1Y8+JuLRVpdIzm+UOLSHgl/XqR4c6nzJkq5rOkjc02O2I7P7l/Yof0Q==", + "version": "29.4.6", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.4.6.tgz", + "integrity": "sha512-fSpWtOO/1AjSNQguk43hb/JCo16oJDnMJf3CdEGNkqsEX3t0KX96xvyX1D7PfLCpVoKu4MfVrqUkFyblYoY4lA==", "dev": true, "license": "MIT", "dependencies": { @@ -4797,15 +4797,18 @@ "license": "ISC" }, "node_modules/yaml": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.1.tgz", - "integrity": "sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==", + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.2.tgz", + "integrity": "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A==", "license": "ISC", "bin": { "yaml": "bin.mjs" }, "engines": { "node": ">= 14.6" + }, + "funding": { + "url": "https://github.com/sponsors/eemeli" } }, "node_modules/yargs": { diff --git a/package.json b/package.json index 812e498c..075bbd6f 100644 --- a/package.json +++ b/package.json @@ -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" } }