|
|
@ -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");
|
|
|
@ -56,6 +54,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
|
|
|
@ -91,7 +98,7 @@ contract Git3 is LargeStorageManager {
|
|
|
|
bytes memory repoName,
|
|
|
|
bytes memory repoName,
|
|
|
|
bytes memory path,
|
|
|
|
bytes memory path,
|
|
|
|
bytes calldata data
|
|
|
|
bytes calldata data
|
|
|
|
) external payable onlyOwner(repoName) {
|
|
|
|
) public payable onlyOwner(repoName) {
|
|
|
|
_putChunkFromCalldata(
|
|
|
|
_putChunkFromCalldata(
|
|
|
|
keccak256(bytes.concat(repoName, "/", path)),
|
|
|
|
keccak256(bytes.concat(repoName, "/", path)),
|
|
|
|
0,
|
|
|
|
0,
|
|
|
@ -105,7 +112,7 @@ contract Git3 is LargeStorageManager {
|
|
|
|
bytes memory path,
|
|
|
|
bytes memory path,
|
|
|
|
uint256 chunkId,
|
|
|
|
uint256 chunkId,
|
|
|
|
bytes calldata data
|
|
|
|
bytes calldata data
|
|
|
|
) external payable onlyOwner(repoName) {
|
|
|
|
) public payable onlyOwner(repoName) {
|
|
|
|
_putChunkFromCalldata(
|
|
|
|
_putChunkFromCalldata(
|
|
|
|
keccak256(bytes.concat(repoName, "/", path)),
|
|
|
|
keccak256(bytes.concat(repoName, "/", path)),
|
|
|
|
chunkId,
|
|
|
|
chunkId,
|
|
|
@ -117,11 +124,19 @@ contract Git3 is LargeStorageManager {
|
|
|
|
function remove(
|
|
|
|
function remove(
|
|
|
|
bytes memory repoName,
|
|
|
|
bytes memory repoName,
|
|
|
|
bytes memory path
|
|
|
|
bytes memory path
|
|
|
|
) external onlyOwner(repoName) {
|
|
|
|
) public onlyOwner(repoName) {
|
|
|
|
// The actually process of remove will remove all the chunks
|
|
|
|
// The actually process of remove will remove all the chunks
|
|
|
|
_remove(keccak256(bytes.concat(repoName, "/", path)), 0);
|
|
|
|
_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(
|
|
|
|
function size(
|
|
|
|
bytes memory repoName,
|
|
|
|
bytes memory repoName,
|
|
|
|
bytes memory name
|
|
|
|
bytes memory name
|
|
|
|