编译器
0.5.17+commit.d19bba13
文件 1 的 6:NamedContract.sol
pragma solidity ^0.5.0;
contract NamedContract {
string public name;
function setContractName(string memory newName) internal {
name = newName;
}
}
文件 2 的 6:Ownable.sol
pragma solidity ^0.5.0;
contract Ownable {
bytes32 private constant _ownerPosition = keccak256("owner");
bytes32 private constant _authorizedNewOwnerPosition = keccak256("authorizedNewOwner");
constructor() public {
bytes32 ownerPosition = _ownerPosition;
address owner = msg.sender;
assembly {
sstore(ownerPosition, owner)
}
}
function requireOwner() internal view {
require(
msg.sender == getOwner(),
"Sender must be owner"
);
}
function getOwner() public view returns (address owner) {
bytes32 ownerPosition = _ownerPosition;
assembly {
owner := sload(ownerPosition)
}
}
function getAuthorizedNewOwner() public view returns (address newOwner) {
bytes32 authorizedNewOwnerPosition = _authorizedNewOwnerPosition;
assembly {
newOwner := sload(authorizedNewOwnerPosition)
}
}
function authorizeOwnershipTransfer(address authorizedAddress) external {
requireOwner();
bytes32 authorizedNewOwnerPosition = _authorizedNewOwnerPosition;
assembly {
sstore(authorizedNewOwnerPosition, authorizedAddress)
}
}
function assumeOwnership() external {
bytes32 authorizedNewOwnerPosition = _authorizedNewOwnerPosition;
address newOwner;
assembly {
newOwner := sload(authorizedNewOwnerPosition)
}
require(
msg.sender == newOwner,
"Only the authorized new owner can accept ownership"
);
bytes32 ownerPosition = _ownerPosition;
address zero = address(0);
assembly {
sstore(ownerPosition, newOwner)
sstore(authorizedNewOwnerPosition, zero)
}
}
}
文件 3 的 6:StakingEvent.sol
pragma solidity ^0.5.0;
contract StakingEvent {
event Initialize(
address indexed owner,
address indexed sxp,
address indexed rewardProvider,
uint256 minimumStakeAmount,
uint256 rewardCycle,
uint256 rewardAmount,
uint256 rewardCycleTimestamp
);
event Stake(
address indexed staker,
uint256 indexed amount
);
event Claim(
address indexed toAddress,
uint256 indexed amount,
uint256 indexed nonce
);
event Withdraw(
address indexed toAddress,
uint256 indexed amount
);
event GuardianshipTransferAuthorization(
address indexed authorizedAddress
);
event GuardianUpdate(
address indexed oldValue,
address indexed newValue
);
event MinimumStakeAmountUpdate(
uint256 indexed oldValue,
uint256 indexed newValue
);
event RewardProviderUpdate(
address indexed oldValue,
address indexed newValue
);
event RewardPolicyUpdate(
uint256 oldCycle,
uint256 oldAmount,
uint256 indexed newCycle,
uint256 indexed newAmount,
uint256 indexed newTimeStamp
);
event DepositRewardPool(
address indexed depositor,
uint256 indexed amount
);
event WithdrawRewardPool(
address indexed toAddress,
uint256 indexed amount
);
event ApproveClaim(
address indexed toAddress,
uint256 indexed amount,
uint256 indexed nonce
);
}
文件 4 的 6:StakingProxy.sol
pragma solidity ^0.5.0;
import "./SwipeRegistry.sol";
import "./StakingEvent.sol";
contract StakingProxy is SwipeRegistry, StakingEvent {
constructor() public SwipeRegistry("Swipe Staking Proxy") {}
}
文件 5 的 6:SwipeRegistry.sol
pragma solidity ^0.5.0;
import "./NamedContract.sol";
import "./Upgradeable.sol";
contract SwipeRegistry is NamedContract, Upgradeable {
constructor(string memory contractName) public Upgradeable() {
setContractName(contractName);
}
function() external payable {
require(msg.data.length > 0, "Calldata must not be empty");
address _impl = getImplementation();
assembly {
let ptr := mload(0x40)
calldatacopy(ptr, 0x0, calldatasize)
let result := delegatecall(gas, _impl, ptr, calldatasize, 0x0, 0)
let size := returndatasize
returndatacopy(ptr, 0x0, size)
switch result
case 0 {
revert(ptr, size)
}
default {
return(ptr, size)
}
}
}
}
文件 6 的 6:Upgradeable.sol
pragma solidity ^0.5.0;
import "./Ownable.sol";
contract Upgradeable is Ownable {
bytes32 private constant implementationPosition = keccak256(
"implementation"
);
constructor() public Ownable() {}
function getImplementation() public view returns (address implementation) {
bytes32 position = implementationPosition;
assembly {
implementation := sload(position)
}
}
function setImplementation(address _newImplementation) public {
requireOwner();
require(_newImplementation != address(0), "New implementation must have non-zero address");
address currentImplementation = getImplementation();
require(currentImplementation != _newImplementation, "New implementation must have new address");
bytes32 position = implementationPosition;
assembly {
sstore(position, _newImplementation)
}
}
function setImplementationAndCall(
address _newImplementation,
bytes calldata _newImplementaionCallData
) external payable {
setImplementation(_newImplementation);
if (_newImplementaionCallData.length > 0) {
(bool success, ) = address(this).call.value(msg.value)(
_newImplementaionCallData
);
require(success, "Delegatecall has failed");
}
}
}
{
"compilationTarget": {
"StakingProxy.sol": "StakingProxy"
},
"evmVersion": "istanbul",
"libraries": {},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"toAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"ApproveClaim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"toAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"depositor","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DepositRewardPool","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldValue","type":"address"},{"indexed":true,"internalType":"address","name":"newValue","type":"address"}],"name":"GuardianUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"authorizedAddress","type":"address"}],"name":"GuardianshipTransferAuthorization","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"sxp","type":"address"},{"indexed":true,"internalType":"address","name":"rewardProvider","type":"address"},{"indexed":false,"internalType":"uint256","name":"minimumStakeAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardCycle","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardCycleTimestamp","type":"uint256"}],"name":"Initialize","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"oldValue","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"MinimumStakeAmountUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldCycle","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"oldAmount","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"newCycle","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"newAmount","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"newTimeStamp","type":"uint256"}],"name":"RewardPolicyUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldValue","type":"address"},{"indexed":true,"internalType":"address","name":"newValue","type":"address"}],"name":"RewardProviderUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Stake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"toAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"toAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawRewardPool","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":false,"inputs":[],"name":"assumeOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"authorizedAddress","type":"address"}],"name":"authorizeOwnershipTransfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getAuthorizedNewOwner","outputs":[{"internalType":"address","name":"newOwner","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getImplementation","outputs":[{"internalType":"address","name":"implementation","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getOwner","outputs":[{"internalType":"address","name":"owner","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_newImplementation","type":"address"}],"name":"setImplementation","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_newImplementation","type":"address"},{"internalType":"bytes","name":"_newImplementaionCallData","type":"bytes"}],"name":"setImplementationAndCall","outputs":[],"payable":true,"stateMutability":"payable","type":"function"}]