|
|
|
@ -4,11 +4,9 @@ pragma solidity ^0.8.0;
|
|
|
|
|
import "hardhat/console.sol";
|
|
|
|
|
import "./IFileOperator.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 LargeStorageManager {
|
|
|
|
|
contract Git3 is LargeStorageManagerV2 {
|
|
|
|
|
struct refInfo {
|
|
|
|
|
bytes20 hash;
|
|
|
|
|
uint96 index;
|
|
|
|
@ -31,7 +29,7 @@ contract Git3 is LargeStorageManager {
|
|
|
|
|
res.name = repoNameToRefs[repoName][info.index];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constructor() LargeStorageManager(0) {}
|
|
|
|
|
constructor() LargeStorageManagerV2(0) {}
|
|
|
|
|
|
|
|
|
|
modifier onlyOwner(bytes memory repoName) {
|
|
|
|
|
require(repoNameToOwner[repoName] == msg.sender, "only owner");
|
|
|
|
@ -56,6 +54,15 @@ contract Git3 is LargeStorageManager {
|
|
|
|
|
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(
|
|
|
|
|
bytes memory repoName,
|
|
|
|
|
bytes memory path
|
|
|
|
@ -91,7 +98,7 @@ contract Git3 is LargeStorageManager {
|
|
|
|
|
bytes memory repoName,
|
|
|
|
|
bytes memory path,
|
|
|
|
|
bytes calldata data
|
|
|
|
|
) external payable onlyOwner(repoName) {
|
|
|
|
|
) public payable onlyOwner(repoName) {
|
|
|
|
|
_putChunkFromCalldata(
|
|
|
|
|
keccak256(bytes.concat(repoName, "/", path)),
|
|
|
|
|
0,
|
|
|
|
@ -105,7 +112,7 @@ contract Git3 is LargeStorageManager {
|
|
|
|
|
bytes memory path,
|
|
|
|
|
uint256 chunkId,
|
|
|
|
|
bytes calldata data
|
|
|
|
|
) external payable onlyOwner(repoName) {
|
|
|
|
|
) public payable onlyOwner(repoName) {
|
|
|
|
|
_putChunkFromCalldata(
|
|
|
|
|
keccak256(bytes.concat(repoName, "/", path)),
|
|
|
|
|
chunkId,
|
|
|
|
@ -117,11 +124,19 @@ contract Git3 is LargeStorageManager {
|
|
|
|
|
function remove(
|
|
|
|
|
bytes memory repoName,
|
|
|
|
|
bytes memory path
|
|
|
|
|
) external onlyOwner(repoName) {
|
|
|
|
|
) public onlyOwner(repoName) {
|
|
|
|
|
// The actually process of remove will remove all the chunks
|
|
|
|
|
_remove(keccak256(bytes.concat(repoName, "/", path)), 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function removeChunk(
|
|
|
|
|
bytes memory repoName,
|
|
|
|
|
bytes memory path,
|
|
|
|
|
uint256 chunkId
|
|
|
|
|
) public onlyOwner(repoName) {
|
|
|
|
|
_removeChunk(keccak256(bytes.concat(repoName, "/", path)), chunkId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function size(
|
|
|
|
|
bytes memory repoName,
|
|
|
|
|
bytes memory name
|
|
|
|
|