|
|
@ -4,11 +4,9 @@ pragma solidity ^0.8.0;
|
|
|
|
import "hardhat/console.sol";
|
|
|
|
import "hardhat/console.sol";
|
|
|
|
import "./IFileOperator.sol";
|
|
|
|
import "./IFileOperator.sol";
|
|
|
|
import "@openzeppelin/contracts/access/Ownable.sol";
|
|
|
|
import "@openzeppelin/contracts/access/Ownable.sol";
|
|
|
|
import "git3-evm-large-storage/contracts/LargeStorageManager.sol";
|
|
|
|
import "git3-evm-large-storage/contracts/v2/LargeStorageManagerV2.sol";
|
|
|
|
|
|
|
|
|
|
|
|
// import "evm-large-storage/contracts/W3RC3.sol";
|
|
|
|
contract Git3 is LargeStorageManagerV2 {
|
|
|
|
|
|
|
|
|
|
|
|
contract Git3 is LargeStorageManager {
|
|
|
|
|
|
|
|
struct refInfo {
|
|
|
|
struct refInfo {
|
|
|
|
bytes20 hash;
|
|
|
|
bytes20 hash;
|
|
|
|
uint96 index;
|
|
|
|
uint96 index;
|
|
|
@ -31,7 +29,7 @@ contract Git3 is LargeStorageManager {
|
|
|
|
res.name = repoNameToRefs[repoName][info.index];
|
|
|
|
res.name = repoNameToRefs[repoName][info.index];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
constructor() LargeStorageManager(0) {}
|
|
|
|
constructor() LargeStorageManagerV2(0) {}
|
|
|
|
|
|
|
|
|
|
|
|
modifier onlyOwner(bytes memory repoName) {
|
|
|
|
modifier onlyOwner(bytes memory repoName) {
|
|
|
|
require(repoNameToOwner[repoName] == msg.sender, "only owner");
|
|
|
|
require(repoNameToOwner[repoName] == msg.sender, "only owner");
|
|
|
@ -87,6 +85,15 @@ contract Git3 is LargeStorageManager {
|
|
|
|
return sTokens;
|
|
|
|
return sTokens;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getChunkAddr(
|
|
|
|
|
|
|
|
bytes memory repoName,
|
|
|
|
|
|
|
|
bytes memory path,
|
|
|
|
|
|
|
|
uint256 chunkId
|
|
|
|
|
|
|
|
) external view returns (address) {
|
|
|
|
|
|
|
|
bytes memory fullPath = bytes.concat(repoName, "/", path);
|
|
|
|
|
|
|
|
return _getChunkAddr(keccak256(fullPath), chunkId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function download(
|
|
|
|
function download(
|
|
|
|
bytes memory repoName,
|
|
|
|
bytes memory repoName,
|
|
|
|
bytes memory path
|
|
|
|
bytes memory path
|
|
|
@ -130,6 +137,14 @@ contract Git3 is LargeStorageManager {
|
|
|
|
_remove(keccak256(bytes.concat(repoName, "/", path)), 0);
|
|
|
|
_remove(keccak256(bytes.concat(repoName, "/", path)), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function removeChunk(
|
|
|
|
|
|
|
|
bytes memory repoName,
|
|
|
|
|
|
|
|
bytes memory path,
|
|
|
|
|
|
|
|
uint256 chunkId
|
|
|
|
|
|
|
|
) external onlyOwner(repoName) {
|
|
|
|
|
|
|
|
_removeChunk(keccak256(bytes.concat(repoName, "/", path)), chunkId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function size(
|
|
|
|
function size(
|
|
|
|
bytes memory repoName,
|
|
|
|
bytes memory repoName,
|
|
|
|
bytes memory name
|
|
|
|
bytes memory name
|
|
|
@ -146,7 +161,7 @@ contract Git3 is LargeStorageManager {
|
|
|
|
|
|
|
|
|
|
|
|
function listRefs(
|
|
|
|
function listRefs(
|
|
|
|
bytes memory repoName
|
|
|
|
bytes memory repoName
|
|
|
|
) public view returns (refData[] memory list) {
|
|
|
|
) external view returns (refData[] memory list) {
|
|
|
|
list = new refData[](repoNameToRefs[repoName].length);
|
|
|
|
list = new refData[](repoNameToRefs[repoName].length);
|
|
|
|
for (uint index = 0; index < repoNameToRefs[repoName].length; index++) {
|
|
|
|
for (uint index = 0; index < repoNameToRefs[repoName].length; index++) {
|
|
|
|
list[index] = _convertRefInfo(
|
|
|
|
list[index] = _convertRefInfo(
|
|
|
@ -160,7 +175,7 @@ contract Git3 is LargeStorageManager {
|
|
|
|
bytes memory repoName,
|
|
|
|
bytes memory repoName,
|
|
|
|
bytes memory name,
|
|
|
|
bytes memory name,
|
|
|
|
bytes20 refHash
|
|
|
|
bytes20 refHash
|
|
|
|
) public onlyOwner(repoName) {
|
|
|
|
) external onlyOwner(repoName) {
|
|
|
|
bytes memory fullName = bytes.concat(repoName, "/", name);
|
|
|
|
bytes memory fullName = bytes.concat(repoName, "/", name);
|
|
|
|
// only execute `sload` once to reduce gas consumption
|
|
|
|
// only execute `sload` once to reduce gas consumption
|
|
|
|
refInfo memory srs;
|
|
|
|
refInfo memory srs;
|
|
|
@ -187,7 +202,7 @@ contract Git3 is LargeStorageManager {
|
|
|
|
function delRef(
|
|
|
|
function delRef(
|
|
|
|
bytes memory repoName,
|
|
|
|
bytes memory repoName,
|
|
|
|
bytes memory name
|
|
|
|
bytes memory name
|
|
|
|
) public onlyOwner(repoName) {
|
|
|
|
) external onlyOwner(repoName) {
|
|
|
|
bytes memory fullName = bytes.concat(repoName, "/", name);
|
|
|
|
bytes memory fullName = bytes.concat(repoName, "/", name);
|
|
|
|
// only execute `sload` once to reduce gas consumption
|
|
|
|
// only execute `sload` once to reduce gas consumption
|
|
|
|
refInfo memory srs;
|
|
|
|
refInfo memory srs;
|
|
|
|