-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07e1eb3
commit e2188e1
Showing
10 changed files
with
237 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
PRIVATE_KEY= | ||
ETHERSCAN_API_KEY= | ||
sepolia=https://ethereum-sepolia-rpc.publicnode.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
## RoyaltyAutoClaim | ||
|
||
- [去中心化領稿費機制實驗 HackMD](https://hackmd.io/@nic619/SkZDIp2GJl?utm_source=substack&utm_medium=email) | ||
- [去中心化領稿費機制實驗 HackMD](https://hackmd.io/@nic619/SkZDIp2GJl?utm_source=substack&utm_medium=email) | ||
|
||
### Rules | ||
|
||
Owner | ||
- 可以升級合約 | ||
- 可以指定 Admin | ||
- 可以更改稿費幣種 | ||
- 可以轉移所有權 | ||
|
||
Admin | ||
- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@openzeppelin/contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/ | ||
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.13; | ||
|
||
import {Script, console} from "forge-std/Script.sol"; | ||
import {UUPSProxy, RoyaltyAutoClaim} from "../src/RoyaltyAutoClaim.sol"; | ||
|
||
// forge script script/deploy_v1.s.sol --account dev --rpc-url $sepolia --broadcast --verify | ||
|
||
contract DeployV1Script is Script { | ||
function run() public { | ||
address owner = msg.sender; | ||
address admin = msg.sender; | ||
address token = 0x0000000000000000000000000000000000000000; | ||
address[] memory reviewers = new address[](0); | ||
|
||
vm.startBroadcast(); | ||
|
||
RoyaltyAutoClaim royaltyAutoClaim = new RoyaltyAutoClaim(); | ||
UUPSProxy proxy = new UUPSProxy( | ||
address(royaltyAutoClaim), abi.encodeCall(RoyaltyAutoClaim.initialize, (owner, admin, token, reviewers)) | ||
); | ||
|
||
console.log("RoyaltyAutoClaim proxy at:", address(proxy)); | ||
console.log("RoyaltyAutoClaim implementation at:", address(royaltyAutoClaim)); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,51 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.27; | ||
|
||
contract RoyaltyAutoClaim {} | ||
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | ||
|
||
contract UUPSProxy is ERC1967Proxy { | ||
constructor(address _implementation, bytes memory _data) payable ERC1967Proxy(_implementation, _data) { | ||
(bool success,) = _implementation.delegatecall(_data); | ||
require(success, "Initialization failed"); | ||
} | ||
} | ||
|
||
contract RoyaltyAutoClaim is UUPSUpgradeable, OwnableUpgradeable { | ||
string internal constant RENUNCIATION_DISABLED = "Renouncing ownership is disabled"; | ||
|
||
address public admin; | ||
address public token; // 稿費幣種 | ||
address[] public reviewers; | ||
|
||
constructor() { | ||
_disableInitializers(); | ||
} | ||
|
||
function initialize(address _owner, address _admin, address _token, address[] memory _reviewers) | ||
public | ||
initializer | ||
{ | ||
__Ownable_init(_owner); | ||
admin = _admin; | ||
token = _token; | ||
reviewers = _reviewers; | ||
} | ||
|
||
// ================================ Ownership ================================ | ||
|
||
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} | ||
|
||
function changeAdmin(address _admin) public onlyOwner { | ||
admin = _admin; | ||
} | ||
|
||
function changeRoyaltyToken(address _token) public onlyOwner { | ||
token = _token; | ||
} | ||
|
||
function renounceOwnership() public pure override { | ||
revert(RENUNCIATION_DISABLED); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.27; | ||
|
||
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | ||
|
||
contract RoyaltyAutoClaimV2 is UUPSUpgradeable, OwnableUpgradeable { | ||
string internal constant RENUNCIATION_DISABLED = "Renouncing ownership is disabled"; | ||
|
||
address public admin; | ||
address public token; // 稿費幣種 | ||
address[] public reviewers; | ||
|
||
constructor() { | ||
_disableInitializers(); | ||
} | ||
|
||
function initialize(address _owner, address _admin, address _token, address[] memory _reviewers) | ||
public | ||
reinitializer(2) | ||
{ | ||
__Ownable_init(_owner); | ||
admin = _admin; | ||
token = _token; | ||
reviewers = _reviewers; | ||
} | ||
|
||
// ================================ Ownership ================================ | ||
|
||
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} | ||
|
||
function changeAdmin(address _admin) public onlyOwner { | ||
admin = _admin; | ||
} | ||
|
||
function changeRoyaltyToken(address _token) public onlyOwner { | ||
token = _token; | ||
} | ||
|
||
function renounceOwnership() public pure override { | ||
revert(RENUNCIATION_DISABLED); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.27; | ||
|
||
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | ||
|
||
contract MockV2 is UUPSUpgradeable, OwnableUpgradeable { | ||
string internal constant RENUNCIATION_DISABLED = "Renouncing ownership is disabled"; | ||
|
||
address public admin; | ||
address public token; // 稿費幣種 | ||
address[] public reviewers; | ||
|
||
constructor() { | ||
_disableInitializers(); | ||
} | ||
|
||
function initialize(address _owner, address _admin, address _token, address[] memory _reviewers) | ||
public | ||
reinitializer(2) | ||
{ | ||
__Ownable_init(_owner); | ||
admin = _admin; | ||
token = _token; | ||
reviewers = _reviewers; | ||
} | ||
|
||
// ================================ Ownership ================================ | ||
|
||
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} | ||
|
||
function changeAdmin(address _admin) public onlyOwner { | ||
admin = _admin; | ||
} | ||
|
||
function changeRoyaltyToken(address _token) public onlyOwner { | ||
token = _token; | ||
} | ||
|
||
function renounceOwnership() public pure override { | ||
revert(RENUNCIATION_DISABLED); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters