Merge branch 'latest'

main
cyl19970726 2 years ago
commit d844d782e2

@ -2,6 +2,8 @@
pragma solidity ^0.8.0;
contract Git3NameService {
event RegisterHub(string name, address hub);
mapping(string => address) public nameHub;
mapping(address => string) public hubName;
mapping(string => address) public nameOwner;
@ -22,6 +24,7 @@ contract Git3NameService {
hubName[hub] = name;
nameOwner[name] = msg.sender;
nameList.push(name);
emit RegisterHub(name, hub);
}
function nameListLength() public view returns (uint256) {
@ -34,6 +37,7 @@ contract Git3NameService {
) public onlyHubOwner(name) {
nameHub[name] = hub;
hubName[hub] = name;
emit RegisterHub(name, hub);
}
function transferNameOwner(

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

@ -30,6 +30,10 @@ contract filecoin is database {
uint256 chunkId,
bytes calldata data
) external payable override {
repoName;
path;
chunkId;
data;
revert("unsupport uploadChunk");
}
}

@ -22,17 +22,17 @@ async function main() {
await newHubReceipt.wait();
let createHubReceipt = await hubFac.createHub({ nonce: nonce });
nonce++;
// let createHubReceipt = await hubFac.createHub(false, { nonce: nonce });
// nonce++;
await createHubReceipt.wait();
// await createHubReceipt.wait();
let hubAddr = await hubFac.hubs(0);
let git3 = await ethers.getContractAt("Hubv3", hubAddr);
// let hubAddr = await hubFac.hubs(0);
// let git3 = await ethers.getContractAt("Hubv3", hubAddr);
// console.log({logicReceipt,proxyReceipt});
console.log("HubFactory Contract", hubFac.address);
console.log("Hub Contract", git3.address);
// console.log("Hub Contract", git3.address);
}
// We recommend this pattern to be able to use async/await everywhere

@ -20,15 +20,15 @@ async function main() {
let newHubReceipt = await hubFac.newHubImp({ nonce: nonce });
nonce++;
let createHubReceipt = await hubFac.createHub({ nonce: nonce });
nonce++;
// let createHubReceipt = await hubFac.createHub(false, { nonce: nonce });
// nonce++;
let hubAddr = await hubFac.hubs(0);
let git3 = await ethers.getContractAt("Hubv3", hubAddr);
// let hubAddr = await hubFac.hubs(0);
// let git3 = await ethers.getContractAt("Hubv3", hubAddr);
// console.log({logicReceipt,proxyReceipt});
console.log("HubFactory Contract", hubFac.address);
console.log("Hub Contract", git3.address);
// console.log("Hub Contract", git3.address);
}
// We recommend this pattern to be able to use async/await everywhere

Loading…
Cancel
Save