|
|
@ -12,6 +12,9 @@ contract Hubv3 is AccessControlEnumerable, Initializable {
|
|
|
|
using EnumerableSet for EnumerableSet.AddressSet;
|
|
|
|
using EnumerableSet for EnumerableSet.AddressSet;
|
|
|
|
using Repolib for Repolib.BranchInfo;
|
|
|
|
using Repolib for Repolib.BranchInfo;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
event RepoCreated(bytes repoName, address owner);
|
|
|
|
|
|
|
|
event SetRepoRef(bytes repoName, bytes branchPath, bytes20 refHash);
|
|
|
|
|
|
|
|
|
|
|
|
// Hub Info
|
|
|
|
// Hub Info
|
|
|
|
// bytes32 public constant CREATOR = bytes32(uint256(1));
|
|
|
|
// bytes32 public constant CREATOR = bytes32(uint256(1));
|
|
|
|
bytes32 public constant MANAGER = bytes32(uint256(1));
|
|
|
|
bytes32 public constant MANAGER = bytes32(uint256(1));
|
|
|
@ -88,10 +91,13 @@ contract Hubv3 is AccessControlEnumerable, Initializable {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getMembersByRole(bytes32 role) public view returns(address[] memory members){
|
|
|
|
function getMembersByRole(
|
|
|
|
|
|
|
|
bytes32 role
|
|
|
|
|
|
|
|
) public view returns(address[] memory members){
|
|
|
|
|
|
|
|
|
|
|
|
uint256 count = getRoleMemberCount(role);
|
|
|
|
uint256 count = getRoleMemberCount(role);
|
|
|
|
members = new address[](count);
|
|
|
|
members = new address[](count);
|
|
|
|
for (uint i = 0; i < count; i++){
|
|
|
|
for (uint i = 0; i < count; i++) {
|
|
|
|
members[i] = getRoleMember(role, i);
|
|
|
|
members[i] = getRoleMember(role, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -126,11 +132,8 @@ contract Hubv3 is AccessControlEnumerable, Initializable {
|
|
|
|
|
|
|
|
|
|
|
|
// ===== repository operator functions======
|
|
|
|
// ===== repository operator functions======
|
|
|
|
|
|
|
|
|
|
|
|
function repoList() public view returns(string[] memory rn){
|
|
|
|
function repoList() public view returns (bytes[] memory rn) {
|
|
|
|
rn = new string[](repoNames.length);
|
|
|
|
return repoNames;
|
|
|
|
for (uint i = 0; i <repoNames.length;i++){
|
|
|
|
|
|
|
|
rn[i] = string(repoNames[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//createRepository can be invoked by anyone within Hub
|
|
|
|
//createRepository can be invoked by anyone within Hub
|
|
|
@ -158,6 +161,7 @@ contract Hubv3 is AccessControlEnumerable, Initializable {
|
|
|
|
repo.owner = _msgSender();
|
|
|
|
repo.owner = _msgSender();
|
|
|
|
repo.exist = true;
|
|
|
|
repo.exist = true;
|
|
|
|
repoNames.push(repoName);
|
|
|
|
repoNames.push(repoName);
|
|
|
|
|
|
|
|
emit RepoCreated(repoName, repo.owner);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function deleteRepo(bytes memory repoName) public {
|
|
|
|
function deleteRepo(bytes memory repoName) public {
|
|
|
@ -241,6 +245,7 @@ contract Hubv3 is AccessControlEnumerable, Initializable {
|
|
|
|
branchPath,
|
|
|
|
branchPath,
|
|
|
|
refHash
|
|
|
|
refHash
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
emit SetRepoRef(repoName, branchPath, refHash);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getRepoRef(
|
|
|
|
function getRepoRef(
|
|
|
@ -285,7 +290,7 @@ contract Hubv3 is AccessControlEnumerable, Initializable {
|
|
|
|
bytes memory path,
|
|
|
|
bytes memory path,
|
|
|
|
bytes calldata data
|
|
|
|
bytes calldata data
|
|
|
|
) external payable {
|
|
|
|
) external payable {
|
|
|
|
return db.upload{value:msg.value}(repoName, path, data);
|
|
|
|
return db.upload{value: msg.value}(repoName, path, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function uploadChunk(
|
|
|
|
function uploadChunk(
|
|
|
@ -294,7 +299,7 @@ contract Hubv3 is AccessControlEnumerable, Initializable {
|
|
|
|
uint256 chunkId,
|
|
|
|
uint256 chunkId,
|
|
|
|
bytes calldata data
|
|
|
|
bytes calldata data
|
|
|
|
) external payable {
|
|
|
|
) external payable {
|
|
|
|
return db.uploadChunk{value:msg.value}(repoName, path,chunkId, data);
|
|
|
|
return db.uploadChunk{value: msg.value}(repoName, path, chunkId, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function batchUpload(
|
|
|
|
function batchUpload(
|
|
|
|