Merge branch 'main' into v3

main
cyhhao 2 years ago
commit a2b9329a79

@ -64,6 +64,19 @@ contract Git3Hub_SLI is Git3HubStorage_SLI {
pathToHash[keccak256(bytes.concat(repoName, "/", path))] = data;
}
function batchUpload(
bytes memory repoName,
bytes[] memory path,
bytes[] calldata data
) external payable onlyOwner(repoName) {
require(path.length == data.length, "path and data length mismatch");
for (uint i = 0; i < path.length; i++) {
pathToHash[keccak256(bytes.concat(repoName, "/", path[i]))] = data[
i
];
}
}
function remove(
bytes memory repoName,
bytes memory path

@ -0,0 +1,42 @@
//SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
contract Git3NameService {
mapping(string => address) public nameHub;
mapping(string => address) public nameOwner;
string[] public nameList;
mapping(address => mapping(string => string)) public HubRecords;
constructor() {}
modifier onlyHubOwner(string memory name) {
require(nameOwner[name] == msg.sender, "Only name owner can do this");
_;
}
function registerHub(string memory name, address hub) public {
require(nameHub[name] == address(0), "Name already registered");
nameHub[name] = hub;
nameOwner[name] = msg.sender;
nameList.push(name);
}
function nameListLength() public view returns (uint256) {
return nameList.length;
}
function rebindHubAddress(
string memory name,
address hub
) public onlyHubOwner(name) {
nameHub[name] = hub;
}
function transferNameOwner(
string memory name,
address newOwner
) public onlyHubOwner(name) {
nameOwner[name] = newOwner;
}
}

@ -0,0 +1,31 @@
import { ethers } from "hardhat";
async function main() {
let provider = ethers.provider;
let [operator] = await ethers.getSigners();
let nonce = await operator.getTransactionCount();
console.log(operator.address, nonce, await operator.getBalance());
let price = await provider.getFeeData();
let net = await provider.getNetwork();
console.log(price, net.chainId);
const Nameservice = await ethers.getContractFactory("Git3NameService");
const ns = await Nameservice.deploy({
nonce: nonce,
type: 2,
maxFeePerGas: price.maxFeePerGas!,
maxPriorityFeePerGas: price.maxPriorityFeePerGas!,
});
let receipt = await ns.deployed();
console.log(receipt.deployTransaction.hash);
console.log("NS Contract", ns.address);
}
// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});

@ -16,7 +16,6 @@ async function main() {
type: 2,
maxFeePerGas: price.maxFeePerGas!,
maxPriorityFeePerGas: price.maxPriorityFeePerGas!,
gasLimit: 3000000,
});
let logicReceipt = await git3.deployed();

Loading…
Cancel
Save