diff --git a/contracts/SLI/Git3Hub.sol b/contracts/SLI/Git3Hub.sol index f496811..53e7979 100644 --- a/contracts/SLI/Git3Hub.sol +++ b/contracts/SLI/Git3Hub.sol @@ -1,4 +1,4 @@ -//SPDX-License-Identifier: Unlicense +//SPDX-License-Identifier: GLP-3.0 pragma solidity ^0.8.0; // import "hardhat/console.sol"; diff --git a/contracts/SLI/Git3HubStorage.sol b/contracts/SLI/Git3HubStorage.sol index 0733843..cd977ac 100644 --- a/contracts/SLI/Git3HubStorage.sol +++ b/contracts/SLI/Git3HubStorage.sol @@ -1,4 +1,4 @@ -//SPDX-License-Identifier: Unlicense +//SPDX-License-Identifier: GLP-3.0 pragma solidity ^0.8.0; contract Git3HubStorage_SLI { diff --git a/contracts/SLI/testfvm.sol b/contracts/SLI/testfvm.sol index e128d8f..adc6bcb 100644 --- a/contracts/SLI/testfvm.sol +++ b/contracts/SLI/testfvm.sol @@ -1,4 +1,4 @@ -//SPDX-License-Identifier: Unlicense +//SPDX-License-Identifier: GLP-3.0 pragma solidity ^0.8.0; contract Hello{ diff --git a/contracts/nameservice/NameService.sol b/contracts/nameservice/NameService.sol index b2fc7f2..ac08c19 100644 --- a/contracts/nameservice/NameService.sol +++ b/contracts/nameservice/NameService.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.0; contract Git3NameService { mapping(string => address) public nameHub; + mapping(address => string) public hubName; mapping(string => address) public nameOwner; string[] public nameList; @@ -18,6 +19,7 @@ contract Git3NameService { function registerHub(string memory name, address hub) public { require(nameHub[name] == address(0), "Name already registered"); nameHub[name] = hub; + hubName[hub] = name; nameOwner[name] = msg.sender; nameList.push(name); } @@ -31,6 +33,7 @@ contract Git3NameService { address hub ) public onlyHubOwner(name) { nameHub[name] = hub; + hubName[hub] = name; } function transferNameOwner( diff --git a/contracts/v3/HubFactory.sol b/contracts/v3/HubFactory.sol index bdfc8dc..09fb6bf 100644 --- a/contracts/v3/HubFactory.sol +++ b/contracts/v3/HubFactory.sol @@ -1,3 +1,4 @@ +//SPDX-License-Identifier: GLP-3.0 pragma solidity ^0.8.0; // import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; @@ -8,12 +9,14 @@ import "./Hubv3.sol"; contract HubFactory is Ownable { event CreateHub(address indexed hub, address indexed creator); + + bool public dbSelector; address[] public hubs; Hubv3 public hubImp; - // function initialize() initializer public { - // __Ownable_init(); - // } + constructor(bool _dbSelector) { + dbSelector = _dbSelector; + } function newHubImp() public onlyOwner { hubImp = new Hubv3(); @@ -23,10 +26,10 @@ contract HubFactory is Ownable { hubImp = Hubv3(addr); } - function createHub(bool dbSelector) external { + function createHub(bool isPermissionless) external{ address instance = Clones.clone(address(hubImp)); hubs.push(instance); - Hubv3(instance).initialize(dbSelector, _msgSender()); + Hubv3(instance).initialize(dbSelector, _msgSender(), isPermissionless); emit CreateHub(instance, _msgSender()); } } diff --git a/contracts/v3/Hubv3.sol b/contracts/v3/Hubv3.sol index ddd3fb5..1de4ce9 100644 --- a/contracts/v3/Hubv3.sol +++ b/contracts/v3/Hubv3.sol @@ -1,3 +1,4 @@ +//SPDX-License-Identifier: GLP-3.0 pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/AccessControl.sol"; @@ -41,11 +42,16 @@ contract Hubv3 is AccessControl, Initializable { _setRoleAdmin(CONTRIBUTOR, MANAGER); } - function initialize(bool dbSelector, address user) public initializer { + function initialize( + bool dbSelector, + address user, + bool isPermissionless + ) public initializer { _setupRole(AccessControl.DEFAULT_ADMIN_ROLE, user); _setupRole(MANAGER, user); _setRoleAdmin(CONTRIBUTOR, MANAGER); _newDataBase(dbSelector); + permissionless = isPermissionless; } // ===== hub operator functions====== @@ -226,9 +232,9 @@ contract Hubv3 is AccessControl, Initializable { } // ===== database operator functions====== - function newDataBase(bool flag) public onlyRole(DEFAULT_ADMIN_ROLE) { - _newDataBase(flag); - } + // function newDataBase(bool flag) public onlyRole(DEFAULT_ADMIN_ROLE) { + // _newDataBase(flag); + // } function _newDataBase(bool flag) internal { if (flag) { @@ -253,4 +259,15 @@ contract Hubv3 is AccessControl, Initializable { ) external payable { return db.upload(repoName, path, data); } + + function batchUpload( + bytes memory repoName, + bytes[] memory path, + bytes[] calldata data + ) external payable { + require(path.length == data.length, "path and data length mismatch"); + for (uint i = 0; i < path.length; i++) { + db.upload(repoName, path[i], data[i]); + } + } } diff --git a/contracts/v3/Repolib.sol b/contracts/v3/Repolib.sol index 0ec13fb..a87a3b0 100644 --- a/contracts/v3/Repolib.sol +++ b/contracts/v3/Repolib.sol @@ -1,3 +1,4 @@ +//SPDX-License-Identifier: GLP-3.0 pragma solidity ^0.8.0; library Repolib { diff --git a/contracts/v3/database/database.sol b/contracts/v3/database/database.sol index b51ad6f..22116a3 100644 --- a/contracts/v3/database/database.sol +++ b/contracts/v3/database/database.sol @@ -1,3 +1,4 @@ +//SPDX-License-Identifier: GLP-3.0 pragma solidity ^0.8.0; interface database { diff --git a/contracts/v3/database/ethstorage.sol b/contracts/v3/database/ethstorage.sol index 706a323..1456ce6 100644 --- a/contracts/v3/database/ethstorage.sol +++ b/contracts/v3/database/ethstorage.sol @@ -1,3 +1,4 @@ +//SPDX-License-Identifier: GLP-3.0 pragma solidity ^0.8.0; import "./EthStorage/LargeStorageManagerV2.sol"; import "./database.sol"; diff --git a/contracts/v3/database/filecoin.sol b/contracts/v3/database/filecoin.sol index cf8ce72..7777d33 100644 --- a/contracts/v3/database/filecoin.sol +++ b/contracts/v3/database/filecoin.sol @@ -1,3 +1,4 @@ +//SPDX-License-Identifier: GLP-3.0 pragma solidity ^0.8.0; import "./database.sol"; diff --git a/scripts/deploy-ethstorage-v3.ts b/scripts/deploy-ethstorage-v3.ts index a19055f..321d74d 100644 --- a/scripts/deploy-ethstorage-v3.ts +++ b/scripts/deploy-ethstorage-v3.ts @@ -1,32 +1,34 @@ - import { ethers } from "hardhat"; async function main() { - let provider = ethers.provider - let [operator,] = await ethers.getSigners(); - let nonce = await operator.getTransactionCount() - + let provider = ethers.provider; + let [operator] = await ethers.getSigners(); + let nonce = await operator.getTransactionCount(); - let price = await provider.getFeeData() - console.log(price) + let price = await provider.getFeeData(); + console.log(price); - console.log(operator.address, nonce) + console.log(operator.address, nonce); const Git3Fac = await ethers.getContractFactory("HubFactory"); - const hubFac = await Git3Fac.deploy({ nonce: nonce }); + const hubFac = await Git3Fac.deploy(true, { nonce: nonce }); + + let logicReceipt = await hubFac.deployed(); + console.log(logicReceipt.deployTransaction.hash); + nonce++; + + let newHubReceipt = await hubFac.newHubImp({ nonce: nonce }); + nonce++; - let logicReceipt = await hubFac.deployed() - console.log(logicReceipt.deployTransaction.hash) - nonce++ + await newHubReceipt.wait(); - await hubFac.newHubImp({ nonce: nonce }); - nonce++ + let createHubReceipt = await hubFac.createHub({ nonce: nonce }); + nonce++; - await hubFac.createHub(true,{ nonce: nonce }) - nonce++ + await createHubReceipt.wait(); let hubAddr = await hubFac.hubs(0); - let git3 = await ethers.getContractAt("Hubv3",hubAddr) + let git3 = await ethers.getContractAt("Hubv3", hubAddr); // console.log({logicReceipt,proxyReceipt}); console.log("HubFactory Contract", hubFac.address); diff --git a/scripts/deploy-sli-v3.ts b/scripts/deploy-sli-v3.ts index c389647..75c5ee8 100644 --- a/scripts/deploy-sli-v3.ts +++ b/scripts/deploy-sli-v3.ts @@ -1,31 +1,30 @@ import { ethers } from "hardhat"; async function main() { - let provider = ethers.provider - let [operator,] = await ethers.getSigners(); - let nonce = await operator.getTransactionCount() + let provider = ethers.provider; + let [operator] = await ethers.getSigners(); + let nonce = await operator.getTransactionCount(); + let price = await provider.getFeeData(); + console.log(price); - let price = await provider.getFeeData() - console.log(price) - - console.log(operator.address, nonce) + console.log(operator.address, nonce); const Git3Fac = await ethers.getContractFactory("HubFactory"); - const hubFac = await Git3Fac.deploy({ nonce: nonce }); + const hubFac = await Git3Fac.deploy(false, { nonce: nonce }); - let logicReceipt = await hubFac.deployed() - console.log(logicReceipt.deployTransaction.hash) - nonce++ + let logicReceipt = await hubFac.deployed(); + console.log(logicReceipt.deployTransaction.hash); + nonce++; - await hubFac.newHubImp({ nonce: nonce }); - nonce++ + let newHubReceipt = await hubFac.newHubImp({ nonce: nonce }); + nonce++; - await hubFac.createHub(false,{ nonce: nonce }) - nonce++ + let createHubReceipt = await hubFac.createHub({ nonce: nonce }); + nonce++; let hubAddr = await hubFac.hubs(0); - let git3 = await ethers.getContractAt("Hubv3",hubAddr) + let git3 = await ethers.getContractAt("Hubv3", hubAddr); // console.log({logicReceipt,proxyReceipt}); console.log("HubFactory Contract", hubFac.address);