Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Ownable2Step instead of Ownable #119

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contracts/DecentralizedKV.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import "./libraries/MerkleLib.sol";
import "./libraries/BinaryRelated.sol";

/// @custom:upgradeable
/// @title DecentralizedKV
/// @notice The DecentralizedKV is a top base contract for the EthStorage contract. It provides the
/// basic key-value store functionalities.
contract DecentralizedKV is OwnableUpgradeable {
contract DecentralizedKV is Ownable2StepUpgradeable {
/// @notice Represents the metadata of the key-value .
/// @custom:field kvIdx Internal address seeking.
/// @custom:field kvSize BLOB size.
Expand Down
32 changes: 32 additions & 0 deletions contracts/test/DecentralizedKVTest.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.28;

import "./TestDecentralizedKV.sol";
import "forge-std/Test.sol";

contract DecentralizedKVTest is Test {
uint256 constant MAX_KV_SIZE = 17;
uint256 constant STORAGE_COST = 10000000;
uint256 constant SHARD_SIZE_BITS = 19;
uint256 constant PREPAID_AMOUNT = 2 * STORAGE_COST;
TestDecentralizedKV decentralizedKV;

function setUp() public {
decentralizedKV = new TestDecentralizedKV(MAX_KV_SIZE, 0, STORAGE_COST, 340282366367469178095360967382638002176);
decentralizedKV.initialize(vm.addr(1));
}

function testTransferOwnership() public {
vm.expectRevert();
vm.prank(address(vm.addr(2)));
decentralizedKV.transferOwnership(vm.addr(2));

vm.prank(address(vm.addr(1)));
decentralizedKV.transferOwnership(vm.addr(2));
assertEq(decentralizedKV.owner(), vm.addr(1));

vm.prank(address(vm.addr(2)));
decentralizedKV.acceptOwnership();
assertEq(decentralizedKV.owner(), vm.addr(2));
}
}
Loading