Verified contractPartialMIT
SourceMirror
Address0x8059d91b96b8bb52ba9ba73d321bfc007105df84
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.26
- Same code
Only this contract
Details
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- Via IR
- yes
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,307,643
- Creation transaction
- 0xc7465a7f4e…2692962046
3 files
- src/os/SourceMirror.solmain3.89 KB
- src/interfaces/Interfaces.sol3.24 KB
- src/os/IOS.sol3.04 KB
src/os/SourceMirror.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {IOSView, ISourcePiece, ISourceToken} from "./IOS.sol";
/// @notice The OS factory's record of the minted outputs, by number.
interface IOutputs {
function outputOf(uint256 number) external view returns (address);
}
/// @notice The roll an output's design shows: this week's, or its frozen epoch's.
interface IOutputRoll {
function roll() external view returns (bytes32);
}
/// @notice THE SOURCE's mirror. Its holder points THE SOURCE at one minted output, and THE SOURCE takes on that
/// output's form in its own colour field: the same composition, as many windows, and each week the same roll, so it
/// turns when the output turns. THE SOURCE itself never changes: its contract, its key and its token stay as they are,
/// and it is never installed or locked anywhere. Only public facts cross over (the output's number, composition, window
/// count and roll); no output's editions or keys are read, so mirroring a sealed output shows nothing of it.
///
/// A mirror is its holder's choice: it shows while the holder who set it holds THE SOURCE, and is clear for the next
/// holder until they set their own. Any output may be mirrored. No owner, no fee: gas only.
contract SourceMirror {
ISourcePiece public immutable source; // ArtifactsSource
IOutputs public immutable osFactory;
uint256 private _number; // the mirrored output's number, 1 to 64 (zero: none)
address private _setBy; // the holder who chose it
uint64 private _since;
event Mirrored(address indexed holder, uint256 indexed number, address output);
error ZeroAddress();
error NotHolder();
error NotAnOutput();
constructor(address source_, address osFactory_) {
if (source_ == address(0) || osFactory_ == address(0)) revert ZeroAddress();
source = ISourcePiece(source_);
osFactory = IOutputs(osFactory_);
}
/// @notice THE SOURCE's holder mirrors output `number` (1 to 64, once minted), or clears the mirror with 0.
function setMirror(uint256 number) external {
if (msg.sender != holder()) revert NotHolder();
address output;
if (number != 0) {
output = osFactory.outputOf(number);
if (output == address(0)) revert NotAnOutput();
}
_number = number;
_setBy = msg.sender;
_since = uint64(block.timestamp);
emit Mirrored(msg.sender, number, output);
}
/// @notice THE SOURCE's current holder (zero before its auction settles).
function holder() public view returns (address) {
address piece = source.pieceContract();
return piece == address(0) ? address(0) : ISourceToken(piece).ownerOf(1);
}
/// @notice The output THE SOURCE mirrors now, and since when: zeros when there is none, or when THE SOURCE has
/// changed hands since its mirror was set.
function mirrorOf() public view returns (uint256 number, address output, uint64 since) {
if (_number == 0 || _setBy != holder()) return (0, address(0), 0);
return (_number, osFactory.outputOf(_number), _since);
}
/// @notice What a renderer needs to draw THE SOURCE mirroring this week, all public: the output, its composition
/// (1 Tiled, 2 Overprint, 3 Merged field), its window count, and the epoch and roll its design shows (this week's,
/// or the one its holder froze it at). Zeros when none.
function form()
external
view
returns (uint256 number, address output, uint8 composition, uint256 windows, uint256 epoch, bytes32 roll)
{
(number, output,) = mirrorOf();
if (output == address(0)) return (0, address(0), 0, 0, 0, bytes32(0));
IOSView o = IOSView(output);
return (number, output, o.composition(), o.windows().length, o.shownEpoch(), IOutputRoll(output).roll());
}
}
src/interfaces/Interfaces.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
interface IERC20 {
function transferFrom(address from, address to, uint256 amount) external returns (bool);
function transfer(address to, uint256 amount) external returns (bool);
function balanceOf(address account) external view returns (uint256);
}
interface IERC2981 {
function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address, uint256);
}
interface IArtHouse {
function recordSale(address collection, address buyer, address broker) external payable;
function canRecordSale(address module) external view returns (bool);
function recordResale(address broker, uint256 royalty, uint256 brokerShare) external payable;
function isEligibleBroker(address broker) external view returns (bool);
function royaltyFor(address collection, uint256 salePrice) external view returns (address, uint256);
function pieceMetadata(address collection, uint256 pieceId)
external
view
returns (string memory title, string memory description, bytes memory svg);
function owner() external view returns (address);
}
interface IArtCollection {
function initialize(address house, string calldata name_, string calldata symbol_) external;
function mint(address to, uint256 tokenId) external;
}
/// @notice Chainlink VRF v2.5 coordinator surface used by ArtifactsFactory.
interface IVRFCoordinatorV2Plus {
struct RandomWordsRequest {
bytes32 keyHash;
uint256 subId;
uint16 requestConfirmations;
uint32 callbackGasLimit;
uint32 numWords;
bytes extraArgs;
}
function requestRandomWords(RandomWordsRequest calldata req) external returns (uint256 requestId);
}
struct Traits {
string title;
string palette;
uint8 colourCount;
string direction;
}
interface IArtifactsPiece {
function initialize(
address controller,
address house,
uint256 pieceId,
address to,
Traits calldata traits,
address ciphertext,
bytes32 commitment,
bytes calldata wrappedKey,
bool isSource,
bytes32 ownerViewingKey
) external;
function rewrapFor(bytes calldata wrapped) external;
function ownerOf(uint256 tokenId) external view returns (address);
}
/// @notice A sale module that deploys piece contracts answers whether a contract is one of its pieces.
interface IPieceRegistry {
function isPiece(address piece) external view returns (bool);
}
interface IPieceController {
function controller() external view returns (address);
}
interface IBalanceOf {
function balanceOf(address account) external view returns (uint256);
}
interface IOwnerOf {
function ownerOf(uint256 tokenId) external view returns (address);
}
/// @notice What an ArtifactsPiece needs from THE SOURCE's controller to serve the revealed tokenURI.
/// @notice What THE SOURCE's piece reads from ArtifactsSource: its renderer page and its encrypted seed.
interface ISourceStore {
function rendererChunks() external view returns (address[] memory);
function locked() external view returns (bool);
function sealedSeed() external view returns (bytes32);
}
src/os/IOS.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {Traits} from "../interfaces/Interfaces.sol";
/// @notice What an Operating System uses of a deployed ARTIFACTS edition (ArtifactsPiece), unchanged.
interface IEdition {
function ownerOf(uint256 tokenId) external view returns (address);
function transferFrom(address from, address to, uint256 tokenId) external;
function safeTransferFrom(address from, address to, uint256 tokenId) external;
function registerViewingKey(bytes32 key) external;
function rewrapFor(bytes calldata wrapped) external;
function previousOwner() external view returns (address);
function wrappedKey() external view returns (bytes memory);
function commitment() external view returns (bytes32);
function pieceId() external view returns (uint256);
function traits() external view returns (Traits memory);
}
/// @notice ArtifactsFactory's answer to "is this contract a genuine edition?" (THE SOURCE is not one of its pieces).
interface IEditionRegistry {
function isPiece(address piece) external view returns (bool);
}
/// @notice What an OS asks of the OS factory: its output number, the week, each week's random number, the metadata.
interface IOSFactory {
function claimNumber() external returns (uint256);
function currentWeek() external view returns (uint256);
function weekRandom(uint256 week) external view returns (uint256);
function metadata() external view returns (address);
}
/// @notice Draws an output's token metadata from the OS's public state.
interface IOSMetadata {
function tokenURI(address os) external view returns (string memory);
}
/// @notice The public state of an OS that OSMetadata reads.
interface IOSView {
function osName() external view returns (string memory);
function number() external view returns (uint256);
function composition() external view returns (uint8);
function revealed() external view returns (bool);
function epoch() external view returns (uint256);
function shownEpoch() external view returns (uint256);
function frozen() external view returns (bool);
function windows() external view returns (address[] memory);
}
/// @notice Where THE SOURCE's piece lives: ArtifactsSource's answer, zero until its auction settles.
interface ISourcePiece {
function pieceContract() external view returns (address);
function keyCommitment() external view returns (bytes32);
}
/// @notice What THE SOURCE's mirror and outputs read of THE SOURCE's piece (the ArtifactsPiece runtime), unchanged.
interface ISourceToken {
function ownerOf(uint256 tokenId) external view returns (address);
function escrow()
external
view
returns (
uint256 price,
address seller,
address buyer,
uint64 paidAt,
bool keyPosted,
bytes memory key,
address broker,
uint64 keyPostedAt,
bytes32 viewingKey,
uint256 deposit
);
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": false,
"bytecodeHash": "none",
"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.