Verified contractPartialMIT
SectionsPosterOperator
Address0x533723f1111aff7cde644895355a44fd96ffe2b6
- Balance
0 ETH
- Transactions
77
- Compiler
solc 0.8.35
- Same code
Only this contract
Details
- Compiler
- solc 0.8.35+commit.47b9dedd
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,444,356
- Creation transaction
- 0xf758afb139…71c283c00a
2 files
- src/SectionsPosterOperator.solmain5.19 KB
- lib/solady/src/auth/Ownable.sol12.55 KB
src/SectionsPosterOperator.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
import { Ownable } from "solady/auth/Ownable.sol";
interface IOperationsMetadataPosters {
function setTokenImage(uint256 tokenId, string calldata uri) external;
function setTokenImages(uint256[] calldata ids, string[] calldata uris) external;
function transferOwnership(address newOwner) external payable;
}
/**
* @title SectionsPosterOperator
* @notice Owns OperationsMetadata (0x365Be6356BdC0e61f7f0Fc73A238e9c7cEa78E37) on behalf of the Ledger, so a hot key can
* update one token's poster when its holder saves a view, without the Ledger signing each time (Fred, 18 Nov
* 2026: "ledger needing to save is not possible all the time, how can we improve").
*
* An operator can do one thing: set a token's poster (`setTokenImage`, `setTokenImages`), and only to an
* `ipfs://` address of plain characters or to "" (back to the collection's poster). Nothing else in the
* metadata is reachable from an operator: not the traits, the engine, the views, the JSON, the ownership.
* The owner (the Ledger) can do everything: the same poster calls, any call to the metadata through `execute`,
* the operator list, and `reclaim`, which hands the metadata straight back to the owner.
*
* Reversibility: an operator is removed with `setOperator(who, false)`; a poster is undone with "" (or the
* previous address); the whole arrangement is undone with `reclaim`. Ownership cannot be renounced.
*/
contract SectionsPosterOperator is Ownable {
IOperationsMetadataPosters public immutable metadata;
mapping(address => bool) public isOperator;
event OperatorSet(address indexed who, bool on);
event Reclaimed(address indexed to);
event Executed(address indexed target, uint256 value, bytes data);
error NotOperator();
error ZeroAddress();
error NotAContract();
error BadPoster();
error LengthMismatch();
error ExecuteFailed();
error OwnershipCannotBeRenounced();
constructor(address metadata_, address owner_, address operator_) {
if (metadata_ == address(0) || owner_ == address(0)) revert ZeroAddress();
if (metadata_.code.length == 0) revert NotAContract();
metadata = IOperationsMetadataPosters(metadata_);
_initializeOwner(owner_);
if (operator_ != address(0)) {
isOperator[operator_] = true;
emit OperatorSet(operator_, true);
}
}
modifier onlyOperatorOrOwner() {
if (!isOperator[msg.sender] && msg.sender != owner()) revert NotOperator();
_;
}
// ============ Posters (operator or owner) ============
function setTokenImage(uint256 tokenId, string calldata uri) external onlyOperatorOrOwner {
_checkPoster(uri);
metadata.setTokenImage(tokenId, uri);
}
function setTokenImages(uint256[] calldata ids, string[] calldata uris) external onlyOperatorOrOwner {
if (ids.length != uris.length) revert LengthMismatch();
for (uint256 i; i < uris.length; ++i) _checkPoster(uris[i]);
metadata.setTokenImages(ids, uris);
}
/// @dev "" or "ipfs://" + [a-z0-9] (a CID) + optionally "/" and [A-Za-z0-9._-/] (a path), at most 200 bytes.
/// The metadata writes the poster into its JSON unescaped, so a quote or a backslash would break the token.
function _checkPoster(string calldata uri) internal pure {
bytes calldata b = bytes(uri);
if (b.length == 0) return;
if (b.length < 15 || b.length > 200) revert BadPoster();
bytes7 head = bytes7(b[0:7]);
if (head != "ipfs://") revert BadPoster();
bool path;
for (uint256 i = 7; i < b.length; ++i) {
bytes1 c = b[i];
bool alnum = (c >= "a" && c <= "z") || (c >= "0" && c <= "9");
if (c == "/") { if (i == 7) revert BadPoster(); path = true; continue; } // a CID first
if (!path) { if (!alnum) revert BadPoster(); continue; }
if (!(alnum || (c >= "A" && c <= "Z") || c == "." || c == "_" || c == "-")) revert BadPoster();
}
}
// ============ The owner's ============
function setOperator(address who, bool on) external onlyOwner {
if (who == address(0)) revert ZeroAddress();
isOperator[who] = on;
emit OperatorSet(who, on);
}
/// @notice Hand the metadata back to the owner: the undo of the whole arrangement.
function reclaim() external onlyOwner {
metadata.transferOwnership(owner());
emit Reclaimed(owner());
}
/// @notice Any call as the metadata's owner (setViewsContract, setRawJson, setTraits, …), for the owner only.
function execute(address target, uint256 value, bytes calldata data)
external
payable
onlyOwner
returns (bytes memory result)
{
bool ok;
(ok, result) = target.call{ value: value }(data);
if (!ok) revert ExecuteFailed();
emit Executed(target, value, data);
}
function renounceOwnership() public payable override {
revert OwnershipCannotBeRenounced();
}
}
lib/solady/src/auth/Ownable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/// @notice Simple single owner authorization mixin.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/Ownable.sol)
///
/// @dev Note:
/// This implementation does NOT auto-initialize the owner to `msg.sender`.
/// You MUST call the `_initializeOwner` in the constructor / initializer.
///
/// While the ownable portion follows
/// [EIP-173](https://eips.ethereum.org/EIPS/eip-173) for compatibility,
/// the nomenclature for the 2-step ownership handover may be unique to this codebase.
abstract contract Ownable {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CUSTOM ERRORS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The caller is not authorized to call the function.
error Unauthorized();
/// @dev The `newOwner` cannot be the zero address.
error NewOwnerIsZeroAddress();
/// @dev The `pendingOwner` does not have a valid handover request.
error NoHandoverRequest();
/// @dev Cannot double-initialize.
error AlreadyInitialized();
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* EVENTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The ownership is transferred from `oldOwner` to `newOwner`.
/// This event is intentionally kept the same as OpenZeppelin's Ownable to be
/// compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173),
/// despite it not being as lightweight as a single argument event.
event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);
/// @dev An ownership handover to `pendingOwner` has been requested.
event OwnershipHandoverRequested(address indexed pendingOwner);
/// @dev The ownership handover to `pendingOwner` has been canceled.
event OwnershipHandoverCanceled(address indexed pendingOwner);
/// @dev `keccak256(bytes("OwnershipTransferred(address,address)"))`.
uint256 private constant _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE =
0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0;
/// @dev `keccak256(bytes("OwnershipHandoverRequested(address)"))`.
uint256 private constant _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE =
0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d;
/// @dev `keccak256(bytes("OwnershipHandoverCanceled(address)"))`.
uint256 private constant _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE =
0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* STORAGE */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The owner slot is given by:
/// `bytes32(~uint256(uint32(bytes4(keccak256("_OWNER_SLOT_NOT")))))`.
/// It is intentionally chosen to be a high value
/// to avoid collision with lower slots.
/// The choice of manual storage layout is to enable compatibility
/// with both regular and upgradeable contracts.
bytes32 internal constant _OWNER_SLOT =
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927;
/// The ownership handover slot of `newOwner` is given by:
/// ```
/// mstore(0x00, or(shl(96, user), _HANDOVER_SLOT_SEED))
/// let handoverSlot := keccak256(0x00, 0x20)
/// ```
/// It stores the expiry timestamp of the two-step ownership handover.
uint256 private constant _HANDOVER_SLOT_SEED = 0x389a75e1;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* INTERNAL FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Override to return true to make `_initializeOwner` prevent double-initialization.
function _guardInitializeOwner() internal pure virtual returns (bool guard) {}
/// @dev Initializes the owner directly without authorization guard.
/// This function must be called upon initialization,
/// regardless of whether the contract is upgradeable or not.
/// This is to enable generalization to both regular and upgradeable contracts,
/// and to save gas in case the initial owner is not the caller.
/// For performance reasons, this function will not check if there
/// is an existing owner.
function _initializeOwner(address newOwner) internal virtual {
if (_guardInitializeOwner()) {
/// @solidity memory-safe-assembly
assembly {
let ownerSlot := _OWNER_SLOT
if sload(ownerSlot) {
mstore(0x00, 0x0dc149f0) // `AlreadyInitialized()`.
revert(0x1c, 0x04)
}
// Clean the upper 96 bits.
newOwner := shr(96, shl(96, newOwner))
// Store the new value.
sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner))))
// Emit the {OwnershipTransferred} event.
log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)
}
} else {
/// @solidity memory-safe-assembly
assembly {
// Clean the upper 96 bits.
newOwner := shr(96, shl(96, newOwner))
// Store the new value.
sstore(_OWNER_SLOT, newOwner)
// Emit the {OwnershipTransferred} event.
log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)
}
}
}
/// @dev Sets the owner directly without authorization guard.
function _setOwner(address newOwner) internal virtual {
if (_guardInitializeOwner()) {
/// @solidity memory-safe-assembly
assembly {
let ownerSlot := _OWNER_SLOT
// Clean the upper 96 bits.
newOwner := shr(96, shl(96, newOwner))
// Emit the {OwnershipTransferred} event.
log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)
// Store the new value.
sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner))))
}
} else {
/// @solidity memory-safe-assembly
assembly {
let ownerSlot := _OWNER_SLOT
// Clean the upper 96 bits.
newOwner := shr(96, shl(96, newOwner))
// Emit the {OwnershipTransferred} event.
log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)
// Store the new value.
sstore(ownerSlot, newOwner)
}
}
}
/// @dev Throws if the sender is not the owner.
function _checkOwner() internal view virtual {
/// @solidity memory-safe-assembly
assembly {
// If the caller is not the stored owner, revert.
if iszero(eq(caller(), sload(_OWNER_SLOT))) {
mstore(0x00, 0x82b42900) // `Unauthorized()`.
revert(0x1c, 0x04)
}
}
}
/// @dev Returns how long a two-step ownership handover is valid for in seconds.
/// Override to return a different value if needed.
/// Made internal to conserve bytecode. Wrap it in a public function if needed.
function _ownershipHandoverValidFor() internal view virtual returns (uint64) {
return 48 * 3600;
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* PUBLIC UPDATE FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Allows the owner to transfer the ownership to `newOwner`.
function transferOwnership(address newOwner) public payable virtual onlyOwner {
/// @solidity memory-safe-assembly
assembly {
if iszero(shl(96, newOwner)) {
mstore(0x00, 0x7448fbae) // `NewOwnerIsZeroAddress()`.
revert(0x1c, 0x04)
}
}
_setOwner(newOwner);
}
/// @dev Allows the owner to renounce their ownership.
function renounceOwnership() public payable virtual onlyOwner {
_setOwner(address(0));
}
/// @dev Request a two-step ownership handover to the caller.
/// The request will automatically expire in 48 hours (172800 seconds) by default.
function requestOwnershipHandover() public payable virtual {
unchecked {
uint256 expires = block.timestamp + _ownershipHandoverValidFor();
/// @solidity memory-safe-assembly
assembly {
// Compute and set the handover slot to `expires`.
mstore(0x0c, _HANDOVER_SLOT_SEED)
mstore(0x00, caller())
sstore(keccak256(0x0c, 0x20), expires)
// Emit the {OwnershipHandoverRequested} event.
log2(0, 0, _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE, caller())
}
}
}
/// @dev Cancels the two-step ownership handover to the caller, if any.
function cancelOwnershipHandover() public payable virtual {
/// @solidity memory-safe-assembly
assembly {
// Compute and set the handover slot to 0.
mstore(0x0c, _HANDOVER_SLOT_SEED)
mstore(0x00, caller())
sstore(keccak256(0x0c, 0x20), 0)
// Emit the {OwnershipHandoverCanceled} event.
log2(0, 0, _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE, caller())
}
}
/// @dev Allows the owner to complete the two-step ownership handover to `pendingOwner`.
/// Reverts if there is no existing ownership handover requested by `pendingOwner`.
function completeOwnershipHandover(address pendingOwner) public payable virtual onlyOwner {
/// @solidity memory-safe-assembly
assembly {
// Compute and set the handover slot to 0.
mstore(0x0c, _HANDOVER_SLOT_SEED)
mstore(0x00, pendingOwner)
let handoverSlot := keccak256(0x0c, 0x20)
// If the handover does not exist, or has expired.
if gt(timestamp(), sload(handoverSlot)) {
mstore(0x00, 0x6f5e8818) // `NoHandoverRequest()`.
revert(0x1c, 0x04)
}
// Set the handover slot to 0.
sstore(handoverSlot, 0)
}
_setOwner(pendingOwner);
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* PUBLIC READ FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns the owner of the contract.
function owner() public view virtual returns (address result) {
/// @solidity memory-safe-assembly
assembly {
result := sload(_OWNER_SLOT)
}
}
/// @dev Returns the expiry timestamp for the two-step ownership handover to `pendingOwner`.
function ownershipHandoverExpiresAt(address pendingOwner)
public
view
virtual
returns (uint256 result)
{
/// @solidity memory-safe-assembly
assembly {
// Compute the handover slot.
mstore(0x0c, _HANDOVER_SLOT_SEED)
mstore(0x00, pendingOwner)
// Load the handover slot.
result := sload(keccak256(0x0c, 0x20))
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* MODIFIERS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Marks a function as only callable by the owner.
modifier onlyOwner() virtual {
_checkOwner();
_;
}
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "none",
"useLiteralContent": false
},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"seadrop/=lib/seadrop/src/",
"ERC721A/=lib/seadrop/lib/ERC721A/contracts/",
"openzeppelin-contracts/=lib/seadrop/lib/openzeppelin-contracts/contracts/",
"operator-filter-registry/=lib/seadrop/lib/operator-filter-registry/src/",
"solmate/=lib/seadrop/lib/solmate/src/",
"utility-contracts/=lib/seadrop/lib/utility-contracts/src/",
"solady/=lib/solady/src/",
"forge-std/=lib/forge-std/src/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"ERC721A-Upgradeable/=lib/seadrop/lib/ERC721A-Upgradeable/contracts/",
"create2-helpers/=lib/seadrop/lib/create2-helpers/",
"create2-scripts/=lib/seadrop/lib/create2-helpers/script/",
"murky/=lib/seadrop/lib/murky/src/",
"openzeppelin-contracts-upgradeable/=lib/seadrop/lib/openzeppelin-contracts-upgradeable/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.