diff --git a/contracts/nameservice/NameService.sol b/contracts/nameservice/NameService.sol index ac08c19..43534da 100644 --- a/contracts/nameservice/NameService.sol +++ b/contracts/nameservice/NameService.sol @@ -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( diff --git a/contracts/v3/Hubv3.sol b/contracts/v3/Hubv3.sol index 3f4f919..2d09d0a 100644 --- a/contracts/v3/Hubv3.sol +++ b/contracts/v3/Hubv3.sol @@ -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,12 @@ contract Hubv3 is AccessControlEnumerable, Initializable { return false; } - function roleToMembers(bytes32 role) public view returns(address[] memory members){ + function roleToMembers( + 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); } } @@ -120,7 +125,7 @@ contract Hubv3 is AccessControlEnumerable, Initializable { // ===== repository operator functions====== - function repoList() public view returns(bytes[] memory rn){ + function repoList() public view returns (bytes[] memory rn) { return repoNames; } @@ -149,6 +154,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 { @@ -225,6 +231,7 @@ contract Hubv3 is AccessControlEnumerable, Initializable { branchPath, refHash ); + emit SetRepoRef(repoName, branchPath, refHash); } function getRepoRef( @@ -269,16 +276,16 @@ 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( bytes memory repoName, bytes memory path, - uint256 chunkId, + 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( diff --git a/contracts/v3/database/filecoin.sol b/contracts/v3/database/filecoin.sol index 991f707..1379b75 100644 --- a/contracts/v3/database/filecoin.sol +++ b/contracts/v3/database/filecoin.sol @@ -24,12 +24,16 @@ contract filecoin is database { pathToHash[fullName] = data; } - function uploadChunk( + function uploadChunk( bytes memory repoName, bytes memory path, uint256 chunkId, bytes calldata data ) external payable override { + repoName; + path; + chunkId; + data; revert("unsupport uploadChunk"); } } diff --git a/scripts/deploy-ethstorage-v3.ts b/scripts/deploy-ethstorage-v3.ts index 442cb9a..faaa6c9 100644 --- a/scripts/deploy-ethstorage-v3.ts +++ b/scripts/deploy-ethstorage-v3.ts @@ -22,17 +22,17 @@ async function main() { await newHubReceipt.wait(); - let createHubReceipt = await hubFac.createHub(false, { 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 diff --git a/scripts/deploy-sli-v3.ts b/scripts/deploy-sli-v3.ts index 46584a5..8fdb512 100644 --- a/scripts/deploy-sli-v3.ts +++ b/scripts/deploy-sli-v3.ts @@ -20,15 +20,15 @@ async function main() { let newHubReceipt = await hubFac.newHubImp({ nonce: nonce }); nonce++; - let createHubReceipt = await hubFac.createHub(false, { 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