Skip to content
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
6 changes: 3 additions & 3 deletions contracts/Registry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ contract Registry is Initializable, AccessControlEnumerableUpgradeable {
string memory _name,
address _dev,
uint64 flags,
string memory _version,
string[] memory _contentURIs,
string[] memory _tags
string calldata _version,
string[] calldata _contentURIs,
string[] calldata _tags
) external onlyAddPackageRole returns (Repo) {
Repo repo = Repo(ClonesUpgradeable.clone(repoImplementation));

Expand Down
5 changes: 4 additions & 1 deletion contracts/Repo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ contract Repo is Initializable, AccessControlEnumerableUpgradeable {
mapping(bytes32 => uint256) internal versionIdByTag;

event NewVersion(uint256 versionId, string version, string[] contentURIs);
event NewTag(string tag, uint256 versionId);

constructor() initializer {}

Expand Down Expand Up @@ -88,7 +89,7 @@ contract Repo is Initializable, AccessControlEnumerableUpgradeable {
* @param _versionId version to point _tag to.
*/
function setTag(string memory _tag, uint256 _versionId) external onlyRole(CREATE_VERSION_ROLE) {
require(_versionId < nextIdx, "REPO_INEXISTENT_VERSION");
require(_versionId > 0 && _versionId < nextIdx, "REPO_INEXISTENT_VERSION");
_setTag(_tag, _versionId);
}

Expand Down Expand Up @@ -116,6 +117,8 @@ contract Repo is Initializable, AccessControlEnumerableUpgradeable {
function _setTag(string memory _tag, uint256 _versionId) internal {
bytes32 tagHash = stringHash(_tag);
versionIdByTag[tagHash] = _versionId;

emit NewTag(_tag, _versionId);
}

function stringHash(string memory version) internal pure returns (bytes32) {
Expand Down
6 changes: 6 additions & 0 deletions test/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ describe("Registry", function () {
"Wrong event NewVersion.contentURIs"
);

const newTagEvent = getEvent(newVersionReceipt.events, "NewTag");
expect(newTagEvent.args!.tag).to.equal("latest");

// Assert that there are two version in the Repo contract
await assertRepoVersions(repoWithDev, [newVersion1, newVersion2]);

Expand Down Expand Up @@ -189,6 +192,9 @@ describe("Registry", function () {
"Wrong event NewVersion.contentURIs"
);

const newTagEvent = getEvent(newVersionReceipt.events, "NewTag");
expect(newTagEvent.args!.tag).to.equal("latest");

// Assert that there are one version in the Repo contract
await assertRepoVersions(repoWithDev, [correctVersion]);

Expand Down