编译器
0.8.19+commit.7dd6d404
文件 1 的 8:ConfigDigestUtilEVMSimple.sol
pragma solidity ^0.8.0;
library ConfigDigestUtilEVMSimple {
function configDigestFromConfigData(
uint256 chainId,
address contractAddress,
uint64 configCount,
address[] memory signers,
address[] memory transmitters,
uint8 f,
bytes memory onchainConfig,
uint64 offchainConfigVersion,
bytes memory offchainConfig
) internal pure returns (bytes32)
{
uint256 hash = uint256(
keccak256(
abi.encode(
chainId,
contractAddress,
configCount,
signers,
transmitters,
f,
onchainConfig,
offchainConfigVersion,
offchainConfig
)));
uint256 prefixMask = type(uint256).max << (256-16);
uint256 prefix = 0x0001 << (256-16);
return bytes32((prefix & prefixMask) | (hash & ~prefixMask));
}
}
文件 2 的 8:ConfirmedOwner.sol
pragma solidity ^0.8.0;
import "./ConfirmedOwnerWithProposal.sol";
contract ConfirmedOwner is ConfirmedOwnerWithProposal {
constructor(
address newOwner
)
ConfirmedOwnerWithProposal(
newOwner,
address(0)
)
{
}
}
文件 3 的 8:ConfirmedOwnerWithProposal.sol
pragma solidity ^0.8.0;
import "./interfaces/OwnableInterface.sol";
contract ConfirmedOwnerWithProposal is OwnableInterface {
address private s_owner;
address private s_pendingOwner;
event OwnershipTransferRequested(
address indexed from,
address indexed to
);
event OwnershipTransferred(
address indexed from,
address indexed to
);
constructor(
address newOwner,
address pendingOwner
) {
require(newOwner != address(0), "Cannot set owner to zero");
s_owner = newOwner;
if (pendingOwner != address(0)) {
_transferOwnership(pendingOwner);
}
}
function transferOwnership(
address to
)
public
override
onlyOwner()
{
_transferOwnership(to);
}
function acceptOwnership()
external
override
{
require(msg.sender == s_pendingOwner, "Must be proposed owner");
address oldOwner = s_owner;
s_owner = msg.sender;
s_pendingOwner = address(0);
emit OwnershipTransferred(oldOwner, msg.sender);
}
function owner()
public
view
override
returns (
address
)
{
return s_owner;
}
function _transferOwnership(
address to
)
private
{
require(to != msg.sender, "Cannot transfer to self");
s_pendingOwner = to;
emit OwnershipTransferRequested(s_owner, to);
}
function _validateOwnership()
internal
view
{
require(msg.sender == s_owner, "Only callable by owner");
}
modifier onlyOwner() {
_validateOwnership();
_;
}
}
文件 4 的 8:OCR2Abstract.sol
pragma solidity ^0.8.0;
import "./interfaces/TypeAndVersionInterface.sol";
abstract contract OCR2Abstract is TypeAndVersionInterface {
uint256 constant internal maxNumOracles = 31;
event ConfigSet(
uint32 previousConfigBlockNumber,
bytes32 configDigest,
uint64 configCount,
address[] signers,
address[] transmitters,
uint8 f,
bytes onchainConfig,
uint64 offchainConfigVersion,
bytes offchainConfig
);
function setConfig(
address[] memory signers,
address[] memory transmitters,
uint8 f,
bytes memory onchainConfig,
uint64 offchainConfigVersion,
bytes memory offchainConfig
)
external
virtual;
function latestConfigDetails()
external
view
virtual
returns (
uint32 configCount,
uint32 blockNumber,
bytes32 configDigest
);
function _configDigestFromConfigData(
uint256 chainId,
address contractAddress,
uint64 configCount,
address[] memory signers,
address[] memory transmitters,
uint8 f,
bytes memory onchainConfig,
uint64 offchainConfigVersion,
bytes memory offchainConfig
)
internal
pure
returns (bytes32)
{
uint256 h = uint256(keccak256(abi.encode(chainId, contractAddress, configCount,
signers, transmitters, f, onchainConfig, offchainConfigVersion, offchainConfig
)));
uint256 prefixMask = type(uint256).max << (256-16);
uint256 prefix = 0x0001 << (256-16);
return bytes32((prefix & prefixMask) | (h & ~prefixMask));
}
event Transmitted(
bytes32 configDigest,
uint32 epoch
);
function latestConfigDigestAndEpoch()
external
view
virtual
returns(
bool scanLogs,
bytes32 configDigest,
uint32 epoch
);
function transmit(
bytes32[3] calldata reportContext,
bytes calldata report,
bytes32[] calldata rs, bytes32[] calldata ss, bytes32 rawVs
)
external
virtual;
}
文件 5 的 8:OCRConfigurationStoreEVMSimple.sol
pragma solidity ^0.8.0;
import "./interfaces/TypeAndVersionInterface.sol";
import "./lib/ConfigDigestUtilEVMSimple.sol";
import "./OwnerIsCreator.sol";
import "./OCR2Abstract.sol";
contract OCRConfigurationStoreEVMSimple is TypeAndVersionInterface {
struct ConfigurationEVMSimple {
address[] signers;
address[] transmitters;
bytes onchainConfig;
bytes offchainConfig;
address contractAddress;
uint64 offchainConfigVersion;
uint32 configCount;
uint8 f;
}
mapping(bytes32 => ConfigurationEVMSimple) internal s_configurations;
event NewConfiguration(bytes32 indexed configDigest);
function addConfig(ConfigurationEVMSimple calldata configuration) external returns (bytes32) {
bytes32 configDigest = ConfigDigestUtilEVMSimple.configDigestFromConfigData(
block.chainid,
configuration.contractAddress,
configuration.configCount,
configuration.signers,
configuration.transmitters,
configuration.f,
configuration.onchainConfig,
configuration.offchainConfigVersion,
configuration.offchainConfig
);
s_configurations[configDigest] = configuration;
emit NewConfiguration(configDigest);
return configDigest;
}
function readConfig(bytes32 configDigest) external view returns (ConfigurationEVMSimple memory) {
return s_configurations[configDigest];
}
function typeAndVersion() external override pure virtual returns (string memory)
{
return "OCRConfigurationStoreEVMSimple 1.0.0";
}
}
文件 6 的 8:OwnableInterface.sol
pragma solidity ^0.8.0;
interface OwnableInterface {
function owner()
external
returns (
address
);
function transferOwnership(
address recipient
)
external;
function acceptOwnership()
external;
}
文件 7 的 8:OwnerIsCreator.sol
pragma solidity ^0.8.0;
import "./ConfirmedOwner.sol";
contract OwnerIsCreator is ConfirmedOwner {
constructor(
)
ConfirmedOwner(
msg.sender
)
{
}
}
文件 8 的 8:TypeAndVersionInterface.sol
pragma solidity ^0.8.0;
interface TypeAndVersionInterface{
function typeAndVersion()
external
pure
returns (string memory);
}
{
"compilationTarget": {
"src/dev/OCRConfigurationStoreEVMSimple.sol": "OCRConfigurationStoreEVMSimple"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":ds-test/=lib/forge-std/lib/ds-test/src/",
":forge-std/=lib/forge-std/src/"
]
}
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"configDigest","type":"bytes32"}],"name":"NewConfiguration","type":"event"},{"inputs":[{"components":[{"internalType":"address[]","name":"signers","type":"address[]"},{"internalType":"address[]","name":"transmitters","type":"address[]"},{"internalType":"bytes","name":"onchainConfig","type":"bytes"},{"internalType":"bytes","name":"offchainConfig","type":"bytes"},{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"uint64","name":"offchainConfigVersion","type":"uint64"},{"internalType":"uint32","name":"configCount","type":"uint32"},{"internalType":"uint8","name":"f","type":"uint8"}],"internalType":"struct OCRConfigurationStoreEVMSimple.ConfigurationEVMSimple","name":"configuration","type":"tuple"}],"name":"addConfig","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"configDigest","type":"bytes32"}],"name":"readConfig","outputs":[{"components":[{"internalType":"address[]","name":"signers","type":"address[]"},{"internalType":"address[]","name":"transmitters","type":"address[]"},{"internalType":"bytes","name":"onchainConfig","type":"bytes"},{"internalType":"bytes","name":"offchainConfig","type":"bytes"},{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"uint64","name":"offchainConfigVersion","type":"uint64"},{"internalType":"uint32","name":"configCount","type":"uint32"},{"internalType":"uint8","name":"f","type":"uint8"}],"internalType":"struct OCRConfigurationStoreEVMSimple.ConfigurationEVMSimple","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"typeAndVersion","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"}]