Verified contractExactMIT
OnRailsPoRAddressList
Address0xab794c0d3f41d69cf80e996f2ad555f326bf3898
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.24
- Same code
1 more contract
Details
- Compiler
- solc 0.8.24+commit.e11b9ed9
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,372,324
- Creation transaction
- 0x7fc15d4e17…a5af5322b2
2 files
- src/OnRailsPoRAddressList.solmain2.57 KB
- src/interfaces/IPoRAddressList.sol737 B
src/OnRailsPoRAddressList.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
import {IPoRAddressList} from "./interfaces/IPoRAddressList.sol";
/// @title Immutable Chainlink PoR address list for one asset.
/// @notice Deploy one instance per PoR feed. The list is fixed at construction: no owner, no setters, no proxy.
/// To change the list, deploy a new instance and repoint the feed.
/// @dev Entries are opaque strings in the format the balance reader expects (EVM hex, Solana base58, ...).
contract OnRailsPoRAddressList is IPoRAddressList {
error EmptyList();
error EmptyEntry(uint256 index);
error DuplicateEntry(uint256 index);
/// @notice Human-readable label, e.g. "cETH reserves". Not read by Chainlink.
string public description;
string[] private _addresses;
constructor(string memory description_, string[] memory addresses_) {
uint256 len = addresses_.length;
if (len == 0) revert EmptyList();
// forge-lint: disable-start(require-revert-in-loop) one-shot constructor validation, revert is the intent
for (uint256 i; i < len; ++i) {
if (bytes(addresses_[i]).length == 0) revert EmptyEntry(i);
bytes32 h = keccak256(bytes(addresses_[i]));
// Duplicates would double-count reserves. Lists are short, so O(n^2) is fine.
for (uint256 j; j < i; ++j) {
if (keccak256(bytes(addresses_[j])) == h) revert DuplicateEntry(i);
}
_addresses.push(addresses_[i]);
}
// forge-lint: disable-end(require-revert-in-loop)
description = description_;
}
/// @inheritdoc IPoRAddressList
function getPoRAddressListLength() external view returns (uint256) {
return _addresses.length;
}
/// @inheritdoc IPoRAddressList
/// @dev Same semantics as Chainlink's ExampleStringPoRAddressList: inclusive `endIndex`, clamped to the last
/// entry, empty array when `startIndex > endIndex`. Unlike the example, a `startIndex` past the end returns an
/// empty array instead of reverting on underflow.
function getPoRAddressList(uint256 startIndex, uint256 endIndex) external view returns (string[] memory list) {
uint256 len = _addresses.length;
if (endIndex >= len) endIndex = len - 1; // len > 0 is guaranteed by the constructor
if (startIndex > endIndex) return new string[](0);
list = new string[](endIndex - startIndex + 1);
for (uint256 i = startIndex; i <= endIndex; ++i) {
list[i - startIndex] = _addresses[i];
}
}
}
src/interfaces/IPoRAddressList.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
/// @title Chainlink Proof-of-Reserve address list interface.
/// @notice Verbatim ABI of smartcontractkit/por-demo-contracts IPoRAddressList
/// (same as chainlink contracts-v1.3.0 `PoRAddressList`).
interface IPoRAddressList {
/// @notice Total number of addresses in the list.
function getPoRAddressListLength() external view returns (uint256);
/// @notice Batch of human-readable addresses. `endIndex` is inclusive; if it is past the end it defaults to
/// `getPoRAddressListLength() - 1`; if `endIndex < startIndex` the result is an empty array.
function getPoRAddressList(uint256 startIndex, uint256 endIndex) external view returns (string[] memory);
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"forge-std/=lib/forge-std/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.