Проверенный контрактЧастичноеMIT
PanoramaSeason4Storage
Адрес0xa97c8ac43b2c4102e2ecd12f744377db06ae00d7
- Баланс
0 ETH
- Транзакций
29
- Компилятор
solc 0.8.34
- Тот же код
Только этот контракт
Подробности
- Компилятор
- solc 0.8.34+commit.80d5c536
- Язык
- solidity
- Оптимизация
- Да, 10 000 прогонов
- Версия EVM
- prague
- Лицензия
- MIT
- Совпадение
- Частичноекод создания: да, код в сети: да
- Проверен на Sourcify
- Создан в блоке
- 26 442 442
- Транзакция создания
- 0x4162e42333…f30810cda9
8 файлов
- src/PanoramaSeason4Storage.solглавный22,57 КБ
- node_modules/solady/src/auth/Ownable.sol12,55 КБ
- node_modules/solady/src/utils/Lifebuoy.sol14,5 КБ
- node_modules/solady/src/utils/SSTORE2.sol12,63 КБ
- src/interfaces/IMURIProtocolCreator.sol207 Б
- src/interfaces/IPanorama.sol2,12 КБ
- src/interfaces/IPanoramaSeason4Storage.sol6,18 КБ
- src/interfaces/IPanoramaStorage.sol7,71 КБ
src/PanoramaSeason4Storage.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.34;
import { Ownable } from "solady/auth/Ownable.sol";
import { Lifebuoy } from "solady/utils/Lifebuoy.sol";
import { SSTORE2 } from "solady/utils/SSTORE2.sol";
import { IPanoramaSeason4Storage } from "./interfaces/IPanoramaSeason4Storage.sol";
import { IPanorama } from "./interfaces/IPanorama.sol";
import { IMURIProtocolCreator } from "./interfaces/IMURIProtocolCreator.sol";
import { IPanoramaStorage } from "./interfaces/IPanoramaStorage.sol";
/// @title PanoramaSeason4Storage
/// @author Yigit Duman (@yigitduman)
/// @notice What Season 4 (#211-#270) keeps on-chain beside PanoramaStorage: the dynamic scene
/// (its HTML template and its code), each day's data, each holder's choice of what the
/// token's animation shows, and the RPC addresses a page reads on-chain bytes through
/// when they are too large for one answer (the artist's for every page, a holder's for
/// their token). The renderer builds the dynamic scene from these.
/// Must be an authorized operator on Panorama to signal metadata updates.
contract PanoramaSeason4Storage is IPanoramaSeason4Storage, Ownable, Lifebuoy {
uint256 public constant FIRST_TOKEN_ID = 211;
uint256 public constant LAST_TOKEN_ID = 270;
/// @notice Size of every fragment but the last, for the scene renderer and day data.
uint256 public constant FRAGMENT_SIZE = 24_000;
/// @notice `leadOf` for #270, the day all six lead.
uint8 public constant ALL_LEADS = 6;
/// @notice The most traits a token holds, the longest name and the longest value (bytes).
uint256 public constant MAX_TRAITS = 16;
uint256 public constant MAX_TRAIT_NAME_LENGTH = 64;
uint256 public constant MAX_TRAIT_VALUE_LENGTH = 128;
address public panorama;
mapping(address operator => bool authorized) public authorizedOperators;
// SSTORE2 pointer for HTML before the data injection point in the dynamic scene
address public sceneRendererHtmlPrefixPointer;
// SSTORE2 pointer for HTML after the data injection point in the dynamic scene
address public sceneRendererHtmlSuffixPointer;
// The scene renderer: the 3D code that draws and plays any day from its data, stored once for
// every Season 4 token (gzipped JavaScript: three.js, strokes, depth, Dav's music renderer)
FragmentData internal _sceneRenderer;
// Per-token day data: everything the dynamic scene draws and plays for that day
mapping(uint256 tokenId => FragmentData data) internal _dayData;
// Per-token holder's choice of what `animation_url` shows; StaticVideo by default
mapping(uint256 tokenId => View view_) public viewOf;
// Dav's music controller: makes each token's music from its lead and mood, read by the page
// and asked by the renderer for the music's traits (IPanoramaSeason4Music)
address public musicController;
// Most RPC addresses in one list, and the longest address; set by the owner
uint256 public maxRpcUrls = 8;
uint256 public maxRpcUrlLength = 200;
// RPC addresses every page reads on-chain bytes through, kept by the artist
string[] internal _rpcUrls;
// RPC addresses a holder adds for their token's page, tried before the artist's
mapping(uint256 tokenId => string[] urls) internal _tokenRpcUrls;
// Per-token traits the artists add at a day's reveal (who visits, what the story holds),
// names and values paired by index
mapping(uint256 tokenId => string[] names) internal _traitNames;
mapping(uint256 tokenId => string[] values) internal _traitValues;
constructor(address _panorama) {
_initializeOwner(msg.sender);
panorama = _panorama;
}
modifier onlyOwnerOrOperator() {
if (msg.sender != owner() && !authorizedOperators[msg.sender]) revert NotOwnerOrOperator();
_;
}
modifier onlySeason4(uint256 tokenId) {
if (tokenId < FIRST_TOKEN_ID || tokenId > LAST_TOKEN_ID) revert InvalidIndex();
_;
}
function setPanorama(address _panorama) external onlyOwner {
panorama = _panorama;
}
function setAuthorizedOperator(address operator, bool authorized) external onlyOwner {
authorizedOperators[operator] = authorized;
emit AuthorizedOperatorUpdated(operator, authorized);
}
/*//////////////////////////////////////////////////////////////
SCENE RENDERER HTML TEMPLATE
//////////////////////////////////////////////////////////////*/
function setSceneRendererHtmlPrefix(bytes calldata _data) external onlyOwner {
sceneRendererHtmlPrefixPointer = SSTORE2.write(_data);
_signalSeason4();
}
function setSceneRendererHtmlSuffix(bytes calldata _data) external onlyOwner {
sceneRendererHtmlSuffixPointer = SSTORE2.write(_data);
_signalSeason4();
}
function getSceneRendererHtmlPrefixData() external view returns (bytes memory) {
if (sceneRendererHtmlPrefixPointer == address(0)) revert HtmlTemplateNotSet();
return SSTORE2.read(sceneRendererHtmlPrefixPointer);
}
function getSceneRendererHtmlSuffixData() external view returns (bytes memory) {
if (sceneRendererHtmlSuffixPointer == address(0)) revert HtmlTemplateNotSet();
return SSTORE2.read(sceneRendererHtmlSuffixPointer);
}
/*//////////////////////////////////////////////////////////////
SCENE RENDERER
Stored once for every Season 4 token, as fragments, as a tableau's
image is in PanoramaStorage: the owner commits the hashes, then
anyone can upload the bytes. A token's dynamic scene is the scene
renderer in its template with the token's day data. Committing new
hashes replaces the scene renderer; until
all of it is uploaded, tokens show their static video.
//////////////////////////////////////////////////////////////*/
/// @notice Commit fragment hashes for the scene renderer.
/// Resets any previously uploaded fragments.
function setSceneRendererFragmentHashes(bytes32[] calldata hashes) external onlyOwner {
_setFragmentHashes(_sceneRenderer, hashes);
emit SceneRendererFragmentHashesSet(hashes.length);
_signalSeason4();
}
/// @notice Upload a single fragment of the scene renderer.
function uploadSceneRendererFragment(uint256 fragmentIndex, bytes calldata data) external {
address pointer = _uploadFragment(_sceneRenderer, fragmentIndex, data);
emit SceneRendererFragmentUploaded(fragmentIndex, pointer);
if (_isFullyUploaded(_sceneRenderer)) {
emit SceneRendererFinalized(_sceneRenderer.fragmentHashes.length);
_signalSeason4();
}
}
function getSceneRendererFragmentHashes() external view returns (bytes32[] memory) {
return _sceneRenderer.fragmentHashes;
}
function getSceneRendererFragmentPointers() external view returns (address[] memory) {
return _sceneRenderer.fragmentPointers;
}
function isSceneRendererFullyUploaded() external view returns (bool) {
return _isFullyUploaded(_sceneRenderer);
}
/// @notice True when a dynamic scene can be built: template set and code fully uploaded.
function hasSceneRenderer() external view returns (bool) {
return sceneRendererHtmlPrefixPointer != address(0) && sceneRendererHtmlSuffixPointer != address(0)
&& _isFullyUploaded(_sceneRenderer);
}
/*//////////////////////////////////////////////////////////////
DAY DATA
A day's data is committed when the day is final (the next day
has joined it), as a still's fragment hashes are. Until it is
uploaded, the dynamic scene reads it from the CDN and checks it
against these hashes.
//////////////////////////////////////////////////////////////*/
/// @notice Commit fragment hashes for a Season 4 day's data.
/// Resets any previously uploaded fragments for this token.
function setDayDataFragmentHashes(
uint256 tokenId,
bytes32[] calldata hashes
) external onlyOwnerOrOperator onlySeason4(tokenId) {
_setFragmentHashes(_dayData[tokenId], hashes);
emit DayDataFragmentHashesSet(tokenId, hashes.length);
IPanorama(panorama).signalMetadataUpdate(tokenId);
}
/// @notice Upload a single fragment of a day's data. Permissionless: the data must match
/// the committed hash.
function uploadDayDataFragment(uint256 tokenId, uint256 fragmentIndex, bytes calldata data) external {
FragmentData storage d = _dayData[tokenId];
address pointer = _uploadFragment(d, fragmentIndex, data);
emit DayDataFragmentUploaded(tokenId, fragmentIndex, pointer);
if (_isFullyUploaded(d)) {
emit DayDataFinalized(tokenId, d.fragmentHashes.length);
IPanorama(panorama).signalMetadataUpdate(tokenId);
}
}
function getDayDataFragmentHashes(uint256 tokenId) external view returns (bytes32[] memory) {
return _dayData[tokenId].fragmentHashes;
}
function getDayDataFragmentPointers(uint256 tokenId) external view returns (address[] memory) {
return _dayData[tokenId].fragmentPointers;
}
function getUploadedDayDataFragmentCount(uint256 tokenId) external view returns (uint256) {
return _dayData[tokenId].uploadedFragmentCount;
}
function isDayDataFullyUploaded(uint256 tokenId) external view returns (bool) {
return _isFullyUploaded(_dayData[tokenId]);
}
/*//////////////////////////////////////////////////////////////
FRAGMENT MANAGEMENT
Owner-only escape hatches for correcting a day's data, as in
PanoramaStorage.
//////////////////////////////////////////////////////////////*/
/// @notice Directly set an SSTORE2 pointer for a day data fragment slot.
function setDayDataFragmentPointer(uint256 tokenId, uint256 fragmentIndex, address pointer) external onlyOwner {
FragmentData storage d = _dayData[tokenId];
if (fragmentIndex >= d.fragmentHashes.length) revert FragmentIndexOutOfBounds();
address old = d.fragmentPointers[fragmentIndex];
if (old == address(0) && pointer != address(0)) ++d.uploadedFragmentCount;
if (old != address(0) && pointer == address(0)) --d.uploadedFragmentCount;
d.fragmentPointers[fragmentIndex] = pointer;
IPanorama(panorama).signalMetadataUpdate(tokenId);
}
/// @notice Clear a day data fragment pointer, allowing re-upload.
function removeDayDataFragmentPointer(uint256 tokenId, uint256 fragmentIndex) external onlyOwner {
FragmentData storage d = _dayData[tokenId];
if (fragmentIndex >= d.fragmentHashes.length) revert FragmentIndexOutOfBounds();
if (d.fragmentPointers[fragmentIndex] != address(0)) --d.uploadedFragmentCount;
d.fragmentPointers[fragmentIndex] = address(0);
IPanorama(panorama).signalMetadataUpdate(tokenId);
}
/// @notice Wipe all fragment hashes, pointers, and progress for a day's data.
function clearDayData(uint256 tokenId) external onlyOwner {
FragmentData storage d = _dayData[tokenId];
delete d.fragmentHashes;
delete d.fragmentPointers;
d.uploadedFragmentCount = 0;
IPanorama(panorama).signalMetadataUpdate(tokenId);
}
/*//////////////////////////////////////////////////////////////
HOLDER VIEW
//////////////////////////////////////////////////////////////*/
/// @notice The holder chooses what the token's `animation_url` shows: the static video or
/// the dynamic scene. A delegate counts as the holder, by the MURI operator's rule.
function setView(uint256 tokenId, View view_) external onlySeason4(tokenId) {
_requireHolder(tokenId);
viewOf[tokenId] = view_;
emit ViewSet(tokenId, msg.sender, view_);
IPanorama(panorama).signalMetadataUpdate(tokenId);
}
/*//////////////////////////////////////////////////////////////
RPC ADDRESSES
A page whose on-chain bytes are too large to sit inside one answer
(a day's data past what fits in its page, a still in the whole
artwork) reads them through these: one fragment a call, each checked
against its committed hash. The artist keeps the list every page
tries; a holder or their delegate can add their own for their token,
tried first. Each address is http(s) and carries no quote, backslash,
angle bracket or space, since the page is written around it.
//////////////////////////////////////////////////////////////*/
/// @notice The most addresses a list holds and the longest address, for lists set from now on
/// (lists already set stay as they are).
function setRpcUrlLimits(uint256 _maxRpcUrls, uint256 _maxRpcUrlLength) external onlyOwner {
maxRpcUrls = _maxRpcUrls;
maxRpcUrlLength = _maxRpcUrlLength;
emit RpcUrlLimitsSet(_maxRpcUrls, _maxRpcUrlLength);
}
/// @notice Replace the RPC addresses every page tries.
function setRpcUrls(string[] calldata urls) external onlyOwner {
_checkRpcUrls(urls);
delete _rpcUrls;
for (uint256 i; i < urls.length; ++i) {
_rpcUrls.push(urls[i]);
}
emit RpcUrlsSet(urls.length);
_signalSeason4();
}
/// @notice Replace the RPC addresses a token's page tries before the artist's. The holder
/// or a delegate, by the MURI operator's rule.
function setTokenRpcUrls(uint256 tokenId, string[] calldata urls) external onlySeason4(tokenId) {
_requireHolder(tokenId);
_checkRpcUrls(urls);
delete _tokenRpcUrls[tokenId];
for (uint256 i; i < urls.length; ++i) {
_tokenRpcUrls[tokenId].push(urls[i]);
}
emit TokenRpcUrlsSet(tokenId, msg.sender, urls.length);
IPanorama(panorama).signalMetadataUpdate(tokenId);
}
function getRpcUrls() external view returns (string[] memory) {
return _rpcUrls;
}
function getTokenRpcUrls(uint256 tokenId) external view returns (string[] memory) {
return _tokenRpcUrls[tokenId];
}
/// @notice Every address a token's page tries, in order: the holder's, then the artist's.
function getRpcUrlsFor(uint256 tokenId) external view onlySeason4(tokenId) returns (string[] memory urls) {
string[] storage mine = _tokenRpcUrls[tokenId];
uint256 n = mine.length;
urls = new string[](n + _rpcUrls.length);
for (uint256 i; i < n; ++i) {
urls[i] = mine[i];
}
for (uint256 i; i < _rpcUrls.length; ++i) {
urls[n + i] = _rpcUrls[i];
}
}
/*//////////////////////////////////////////////////////////////
TRAITS
Traits the artists add to a day, written at its reveal: who visits,
what the story holds. The renderer shows them on a revealed token
after Panorama's own and before the music's. A name may repeat (two
visitors); it is checked off-chain against Panorama's own names.
//////////////////////////////////////////////////////////////*/
/// @notice Replace a token's traits (empty arrays clear them). Names and values pair by
/// index; at most MAX_TRAITS, each name 1 to MAX_TRAIT_NAME_LENGTH bytes and each value 1 to
/// MAX_TRAIT_VALUE_LENGTH.
function setTokenTraits(
uint256 tokenId,
string[] calldata names,
string[] calldata values
) external onlyOwnerOrOperator onlySeason4(tokenId) {
uint256 n = names.length;
if (n != values.length || n > MAX_TRAITS) revert InvalidTrait();
delete _traitNames[tokenId];
delete _traitValues[tokenId];
for (uint256 i; i < n; ++i) {
uint256 k = bytes(names[i]).length;
uint256 v = bytes(values[i]).length;
if (k == 0 || k > MAX_TRAIT_NAME_LENGTH || v == 0 || v > MAX_TRAIT_VALUE_LENGTH) revert InvalidTrait();
_traitNames[tokenId].push(names[i]);
_traitValues[tokenId].push(values[i]);
}
emit TokenTraitsSet(tokenId, n);
IPanorama(panorama).signalMetadataUpdate(tokenId);
}
function getTokenTraits(uint256 tokenId) external view returns (string[] memory names, string[] memory values) {
return (_traitNames[tokenId], _traitValues[tokenId]);
}
/*//////////////////////////////////////////////////////////////
MUSIC
Dav's music controller makes each token's music from what Panorama
already holds: the day's lead and the mood its price set. It reads
both here, and the RPC addresses above; the renderer asks it for
the music's traits.
//////////////////////////////////////////////////////////////*/
/// @notice Set the music controller (the zero address for none).
function setMusicController(address _musicController) external onlyOwner {
musicController = _musicController;
emit MusicControllerSet(_musicController);
_signalSeason4();
}
/// @notice The day's lead, ten days each: 0 Newcomer, 1 Night Worker, 2 Caretaker,
/// 3 Performer, 4 Runaway, 5 Young One (nine days); ALL_LEADS (6) for #270.
function leadOf(uint256 tokenId) external pure onlySeason4(tokenId) returns (uint8) {
if (tokenId == LAST_TOKEN_ID) return ALL_LEADS;
return uint8((tokenId - FIRST_TOKEN_ID) / 10);
}
/// @notice The mood the day's price set, PanoramaStorage's moodIndex: 0 Extreme Bliss,
/// 1 High Bliss, 2 Mild Joy, 3 Equilibrium, 4 Mild Suffering, 5 Deep Suffering,
/// 6 Extreme Anguish. Reverts until the day is revealed.
function moodOf(uint256 tokenId) external view onlySeason4(tokenId) returns (uint8) {
IPanoramaStorage store = IPanoramaStorage(IPanorama(panorama).storageContract());
if (tokenId > store.entryCount()) revert NotRevealed();
return store.getTableauData(tokenId).moodIndex;
}
/// @notice One uploaded fragment of a day's data, for a page reading it over RPC.
function getDayDataFragment(uint256 tokenId, uint256 fragmentIndex) external view returns (bytes memory) {
FragmentData storage d = _dayData[tokenId];
if (fragmentIndex >= d.fragmentPointers.length) revert FragmentIndexOutOfBounds();
address pointer = d.fragmentPointers[fragmentIndex];
if (pointer == address(0)) revert FragmentNotUploaded();
return SSTORE2.read(pointer);
}
/// @notice One uploaded fragment of any tableau's still in PanoramaStorage, for a page
/// reading it over RPC.
function getImageFragment(uint256 tokenId, uint256 fragmentIndex) external view returns (bytes memory) {
address pointer =
IPanoramaStorage(IPanorama(panorama).storageContract()).getFragmentPointer(tokenId, fragmentIndex);
if (pointer == address(0)) revert FragmentNotUploaded();
return SSTORE2.read(pointer);
}
/*//////////////////////////////////////////////////////////////
INTERNAL
//////////////////////////////////////////////////////////////*/
/// @dev The holder or a delegate, as the MURI operator registered for Panorama judges it.
function _requireHolder(uint256 tokenId) internal view {
address muriOperator = IPanorama(panorama).muriOperator();
if (
muriOperator == address(0)
|| !IMURIProtocolCreator(muriOperator).isTokenOwner(panorama, msg.sender, tokenId)
) revert NotTokenHolder();
}
/// @dev At most maxRpcUrls, each http:// or https:// and at most maxRpcUrlLength bytes of
/// printable ASCII with no quote, backslash, angle bracket or backtick.
function _checkRpcUrls(string[] calldata urls) internal view {
if (urls.length > maxRpcUrls) revert InvalidRpcUrl();
uint256 maxLength = maxRpcUrlLength;
for (uint256 i; i < urls.length; ++i) {
bytes calldata u = bytes(urls[i]);
if (u.length > maxLength) revert InvalidRpcUrl();
bool https = u.length > 8 && bytes8(u[:8]) == "https://";
if (!https && !(u.length > 7 && bytes7(u[:7]) == "http://")) revert InvalidRpcUrl();
for (uint256 j; j < u.length; ++j) {
bytes1 c = u[j];
if (c < 0x21 || c > 0x7e || c == '"' || c == "\\" || c == "<" || c == ">" || c == "`") {
revert InvalidRpcUrl();
}
}
}
}
function _setFragmentHashes(FragmentData storage d, bytes32[] calldata hashes) internal {
delete d.fragmentHashes;
delete d.fragmentPointers;
for (uint256 i; i < hashes.length; ++i) {
d.fragmentHashes.push(hashes[i]);
d.fragmentPointers.push(address(0));
}
d.uploadedFragmentCount = 0;
}
function _uploadFragment(
FragmentData storage d,
uint256 fragmentIndex,
bytes calldata data
) internal returns (address pointer) {
uint256 totalFragments = d.fragmentHashes.length;
if (totalFragments == 0) revert NoFragmentsConfigured();
if (fragmentIndex >= totalFragments) revert FragmentIndexOutOfBounds();
if (d.fragmentPointers[fragmentIndex] != address(0)) revert FragmentAlreadyUploaded();
bool isLast = fragmentIndex + 1 == totalFragments;
if (isLast ? data.length == 0 || data.length > FRAGMENT_SIZE : data.length != FRAGMENT_SIZE) {
revert FragmentSizeInvalid();
}
if (keccak256(data) != d.fragmentHashes[fragmentIndex]) revert FragmentHashMismatch();
pointer = SSTORE2.write(data);
d.fragmentPointers[fragmentIndex] = pointer;
++d.uploadedFragmentCount;
}
function _isFullyUploaded(FragmentData storage d) internal view returns (bool) {
uint256 totalFragments = d.fragmentHashes.length;
return totalFragments > 0 && d.uploadedFragmentCount == totalFragments;
}
/// @dev Every Season 4 token and the whole artwork.
function _signalSeason4() internal {
IPanorama(panorama).signalBatchMetadataUpdate(FIRST_TOKEN_ID, LAST_TOKEN_ID);
IPanorama(panorama).signalMetadataUpdate(0);
}
}
node_modules/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();
_;
}
}
node_modules/solady/src/utils/Lifebuoy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/// @notice Class that allows for rescue of ETH, ERC20, ERC721 tokens.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/Lifebuoy.sol)
///
/// @dev This contract is created to mitigate the following disasters:
/// - Careless user sends tokens to the wrong chain or wrong contract.
/// - Careless dev deploys a contract without a withdraw function in attempt to rescue
/// careless user's tokens, due to deployment nonce mismatch caused by
/// script misfire / misconfiguration.
/// - Careless dev forgets to add a withdraw function to a NFT sale contract.
///
/// Note: if you are deploying via a untrusted `tx.origin`,
/// you MUST override `_lifebuoyDefaultDeployer` to return a trusted address.
///
/// For best safety:
/// - For non-escrow contracts, inherit Lifebuoy as much as possible,
/// and leave it unlocked.
/// - For escrow contracts, lock access as tight as possible,
/// as soon as possible. Or simply don't inherit Lifebuoy.
/// Escrow: Your contract is designed to hold ETH, ERC20s, ERC721s
/// (e.g. liquidity pools).
///
/// All rescue and rescue authorization functions require either:
/// - Caller is the deployer
/// AND the contract is not a proxy
/// AND `rescueLocked() & _LIFEBUOY_DEPLOYER_ACCESS_LOCK == 0`.
/// - Caller is `owner()`
/// AND `rescueLocked() & _LIFEBUOY_OWNER_ACCESS_LOCK == 0`.
///
/// The choice of using bit flags to represent locked statuses is for
/// efficiency, flexibility, convenience.
///
/// This contract is optimized with a priority on minimal bytecode size,
/// as the methods are not intended to be called often.
contract Lifebuoy {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CUSTOM ERRORS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The caller is not authorized to rescue or lock the rescue function.
error RescueUnauthorizedOrLocked();
/// @dev The rescue operation has failed due to a failed transfer.
error RescueTransferFailed();
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* LOCK FLAGS CONSTANTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
// These flags are kept internal to avoid bloating up the function dispatch.
// You can just copy paste this into your own code.
/// @dev Flag to denote that the deployer's access is locked. (1)
uint256 internal constant _LIFEBUOY_DEPLOYER_ACCESS_LOCK = 1 << 0;
/// @dev Flag to denote that the `owner()`'s access is locked. (2)
uint256 internal constant _LIFEBUOY_OWNER_ACCESS_LOCK = 1 << 1;
/// @dev Flag to denote that the `lockRescue` function is locked. (4)
uint256 internal constant _LIFEBUOY_LOCK_RESCUE_LOCK = 1 << 2;
/// @dev Flag to denote that the `rescueETH` function is locked. (8)
uint256 internal constant _LIFEBUOY_RESCUE_ETH_LOCK = 1 << 3;
/// @dev Flag to denote that the `rescueERC20` function is locked. (16)
uint256 internal constant _LIFEBUOY_RESCUE_ERC20_LOCK = 1 << 4;
/// @dev Flag to denote that the `rescueERC721` function is locked. (32)
uint256 internal constant _LIFEBUOY_RESCUE_ERC721_LOCK = 1 << 5;
/// @dev Flag to denote that the `rescueERC1155` function is locked. (64)
uint256 internal constant _LIFEBUOY_RESCUE_ERC1155_LOCK = 1 << 6;
/// @dev Flag to denote that the `rescueERC6909` function is locked. (128)
uint256 internal constant _LIFEBUOY_RESCUE_ERC6909_LOCK = 1 << 7;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* IMMUTABLES */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev For checking that the caller is the deployer and
/// that the context is not a delegatecall
/// (so that the implementation deployer cannot drain proxies).
bytes32 internal immutable _lifebuoyDeployerHash;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* STORAGE */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The rescue locked flags slot is given by:
/// `bytes32(~uint256(uint32(bytes4(keccak256("_RESCUE_LOCKED_FLAGS_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 _RESCUE_LOCKED_FLAGS_SLOT =
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffb8e2915b;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CONSTRUCTOR */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
constructor() payable {
bytes32 hash;
uint256 deployer = uint160(_lifebuoyDefaultDeployer());
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, address())
mstore(0x20, deployer)
hash := keccak256(0x00, 0x40)
}
_lifebuoyDeployerHash = hash;
}
/// @dev Returns `tx.origin` by default. Override to return another address if needed.
///
/// Note: If you are deploying via a untrusted `tx.origin` (e.g. ERC4337 bundler)
/// you MUST override this function to return a trusted address.
function _lifebuoyDefaultDeployer() internal view virtual returns (address) {
// I know about EIP7645, and I will stop it if it gets traction.
// Worse case, I will add an `ecrecover` method. But not today.
return tx.origin;
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* RESCUE OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Sends `amount` (in wei) ETH from the current contract to `to`.
/// Reverts upon failure.
function rescueETH(address to, uint256 amount)
public
payable
virtual
onlyRescuer(_LIFEBUOY_RESCUE_ETH_LOCK)
{
/// @solidity memory-safe-assembly
assembly {
if iszero(call(gas(), to, amount, codesize(), 0x00, codesize(), 0x00)) {
mstore(0x00, 0x7ec62e76) // `RescueTransferFailed()`.
revert(0x1c, 0x04)
}
}
}
/// @dev Sends `amount` of ERC20 `token` from the current contract to `to`.
/// Does not check for existence of token or return data. Reverts upon failure.
function rescueERC20(address token, address to, uint256 amount)
public
payable
virtual
onlyRescuer(_LIFEBUOY_RESCUE_ERC20_LOCK)
{
/// @solidity memory-safe-assembly
assembly {
mstore(0x14, to) // Store the `to` argument.
mstore(0x34, amount) // Store the `amount` argument.
// `RescueTransferFailed()` and `transfer(address,uint256)`.
mstore(0x00, shl(96, 0x7ec62e76a9059cbb))
if iszero(call(gas(), token, callvalue(), 0x10, 0x44, codesize(), 0x00)) {
revert(0x0c, 0x04)
}
mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.
}
}
/// @dev Sends `id` of ERC721 `token` from the current contract to `to`.
/// Does not check for existence of token or return data. Reverts upon failure.
function rescueERC721(address token, address to, uint256 id)
public
payable
virtual
onlyRescuer(_LIFEBUOY_RESCUE_ERC721_LOCK)
{
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40) // Cache the free memory pointer.
mstore(0x60, id) // Store the `id` argument.
mstore(0x40, shr(96, shl(96, to))) // Store the `to` argument.
mstore(0x20, address()) // Store the `from` argument.
// `RescueTransferFailed()` and `transferFrom(address,address,uint256)`.
mstore(0x00, 0x7ec62e7623b872dd)
if iszero(call(gas(), token, callvalue(), 0x1c, 0x64, codesize(), 0x00)) {
revert(0x18, 0x04)
}
mstore(0x60, 0) // Restore the zero slot to zero.
mstore(0x40, m) // Restore the free memory pointer.
}
}
/// @dev Sends `amount` of `id` of ERC1155 `token` from the current contract to `to`.
/// Does not check for existence of token or return data. Reverts upon failure.
function rescueERC1155(
address token,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) public payable virtual onlyRescuer(_LIFEBUOY_RESCUE_ERC1155_LOCK) {
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40) // Cache the free memory pointer.
// `RescueTransferFailed()` and `safeTransferFrom(address,address,uint256,uint256,bytes)`.
mstore(m, 0x7ec62e76f242432a)
mstore(add(0x20, m), address()) // Store the `from` argument.
mstore(add(0x40, m), shr(96, shl(96, to))) // Store the `to` argument.
mstore(add(0x60, m), id) // Store the `id` argument.
mstore(add(0x80, m), amount) // Store the `amount` argument.
mstore(add(0xa0, m), 0xa0) // Store the offset to `data`.
mstore(add(0xc0, m), data.length)
calldatacopy(add(m, 0xe0), data.offset, data.length)
// forgefmt: disable-next-item
if iszero(
call(gas(), token, callvalue(), add(m, 0x1c), add(0xc4, data.length), codesize(), 0x00)
) { revert(add(m, 0x18), 0x04) }
}
}
/// @dev Sends `amount` of `id` of ERC6909 `token` from the current contract to `to`.
/// Does not check for existence of token or return data. Reverts upon failure.
function rescueERC6909(address token, address to, uint256 id, uint256 amount)
public
payable
virtual
onlyRescuer(_LIFEBUOY_RESCUE_ERC6909_LOCK)
{
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40) // Cache the free memory pointer.
mstore(0x14, to) // Store the `to` argument.
mstore(0x34, id) // Store the `id` argument.
mstore(0x54, amount) // Store the `amount` argument.
// `RescueTransferFailed()` and `transfer(address,uint256,uint256)`.
mstore(0x00, shl(96, 0x7ec62e76095bcdb6))
if iszero(call(gas(), token, callvalue(), 0x10, 0x64, codesize(), 0x00)) {
revert(0x0c, 0x04)
}
mstore(0x60, 0) // Restore the zero slot to zero.
mstore(0x40, m) // Restore the free memory pointer.
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* RESCUE AUTHORIZATION OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns the flags denoting whether access to rescue functions
/// (including `lockRescue`) is locked.
function rescueLocked() public view virtual returns (uint256 locks) {
/// @solidity memory-safe-assembly
assembly {
locks := sload(_RESCUE_LOCKED_FLAGS_SLOT)
}
}
/// @dev Locks (i.e. permanently removes) access to rescue functions (including `lockRescue`).
function lockRescue(uint256 locksToSet)
public
payable
virtual
onlyRescuer(_LIFEBUOY_LOCK_RESCUE_LOCK)
{
_lockRescue(locksToSet);
}
/// @dev Internal function to set the lock flags without going through access control.
function _lockRescue(uint256 locksToSet) internal virtual {
/// @solidity memory-safe-assembly
assembly {
let s := _RESCUE_LOCKED_FLAGS_SLOT
sstore(s, or(sload(s), locksToSet))
}
}
/// @dev Requires that the rescue function being guarded is:
/// 1. Not locked, AND
/// 2. Called by either:
/// (a) The `owner()`, OR
/// (b) The deployer (if not via a delegate call and deployer is an EOA).
function _checkRescuer(uint256 modeLock) internal view virtual {
uint256 locks = rescueLocked();
bytes32 h = _lifebuoyDeployerHash;
/// @solidity memory-safe-assembly
assembly {
for {} 1 {} {
// If the `modeLock` flag is true, set all bits in `locks` to true.
locks := or(sub(0, iszero(iszero(and(modeLock, locks)))), locks)
// Caller is the deployer
// AND the contract is not a proxy
// AND `locks & _LIFEBUOY_DEPLOYER_ACCESS_LOCK` is false.
mstore(0x20, caller())
mstore(and(locks, _LIFEBUOY_DEPLOYER_ACCESS_LOCK), address())
if eq(keccak256(0x00, 0x40), h) { break }
// If the caller is `owner()`
// AND `locks & _LIFEBUOY_OWNER_ACCESS_LOCK` is false.
mstore(0x08, 0x8da5cb5b0a0362e0) // `owner()` and `RescueUnauthorizedOrLocked()`.
if and( // The arguments of `and` are evaluated from right to left.
lt(
and(locks, _LIFEBUOY_OWNER_ACCESS_LOCK),
and(gt(returndatasize(), 0x1f), eq(mload(0x00), caller()))
),
staticcall(gas(), address(), 0x20, 0x04, 0x00, 0x20)
) { break }
revert(0x24, 0x04)
}
}
}
/// @dev Modifier that calls `_checkRescuer()` at the start of the function.
modifier onlyRescuer(uint256 modeLock) virtual {
_checkRescuer(modeLock);
_;
}
}
node_modules/solady/src/utils/SSTORE2.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/// @notice Read and write to persistent storage at a fraction of the cost.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/SSTORE2.sol)
/// @author Saw-mon-and-Natalie (https://github.com/Saw-mon-and-Natalie)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SSTORE2.sol)
/// @author Modified from 0xSequence (https://github.com/0xSequence/sstore2/blob/master/contracts/SSTORE2.sol)
/// @author Modified from SSTORE3 (https://github.com/Philogy/sstore3)
library SSTORE2 {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CONSTANTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The proxy initialization code.
uint256 private constant _CREATE3_PROXY_INITCODE = 0x67363d3d37363d34f03d5260086018f3;
/// @dev Hash of the `_CREATE3_PROXY_INITCODE`.
/// Equivalent to `keccak256(abi.encodePacked(hex"67363d3d37363d34f03d5260086018f3"))`.
bytes32 internal constant CREATE3_PROXY_INITCODE_HASH =
0x21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CUSTOM ERRORS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Unable to deploy the storage contract.
error DeploymentFailed();
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* WRITE LOGIC */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Writes `data` into the bytecode of a storage contract and returns its address.
function write(bytes memory data) internal returns (address pointer) {
/// @solidity memory-safe-assembly
assembly {
let n := mload(data) // Let `l` be `n + 1`. +1 as we prefix a STOP opcode.
/**
* ---------------------------------------------------+
* Opcode | Mnemonic | Stack | Memory |
* ---------------------------------------------------|
* 61 l | PUSH2 l | l | |
* 80 | DUP1 | l l | |
* 60 0xa | PUSH1 0xa | 0xa l l | |
* 3D | RETURNDATASIZE | 0 0xa l l | |
* 39 | CODECOPY | l | [0..l): code |
* 3D | RETURNDATASIZE | 0 l | [0..l): code |
* F3 | RETURN | | [0..l): code |
* 00 | STOP | | |
* ---------------------------------------------------+
* @dev Prefix the bytecode with a STOP opcode to ensure it cannot be called.
* Also PUSH2 is used since max contract size cap is 24,576 bytes which is less than 2 ** 16.
*/
// Do a out-of-gas revert if `n + 1` is more than 2 bytes.
mstore(add(data, gt(n, 0xfffe)), add(0xfe61000180600a3d393df300, shl(0x40, n)))
// Deploy a new contract with the generated creation code.
pointer := create(0, add(data, 0x15), add(n, 0xb))
if iszero(pointer) {
mstore(0x00, 0x30116425) // `DeploymentFailed()`.
revert(0x1c, 0x04)
}
mstore(data, n) // Restore the length of `data`.
}
}
/// @dev Writes `data` into the bytecode of a storage contract with `salt`
/// and returns its normal CREATE2 deterministic address.
function writeCounterfactual(bytes memory data, bytes32 salt)
internal
returns (address pointer)
{
/// @solidity memory-safe-assembly
assembly {
let n := mload(data)
// Do a out-of-gas revert if `n + 1` is more than 2 bytes.
mstore(add(data, gt(n, 0xfffe)), add(0xfe61000180600a3d393df300, shl(0x40, n)))
// Deploy a new contract with the generated creation code.
pointer := create2(0, add(data, 0x15), add(n, 0xb), salt)
if iszero(pointer) {
mstore(0x00, 0x30116425) // `DeploymentFailed()`.
revert(0x1c, 0x04)
}
mstore(data, n) // Restore the length of `data`.
}
}
/// @dev Writes `data` into the bytecode of a storage contract and returns its address.
/// This uses the so-called "CREATE3" workflow,
/// which means that `pointer` is agnostic to `data, and only depends on `salt`.
function writeDeterministic(bytes memory data, bytes32 salt)
internal
returns (address pointer)
{
/// @solidity memory-safe-assembly
assembly {
let n := mload(data)
mstore(0x00, _CREATE3_PROXY_INITCODE) // Store the `_PROXY_INITCODE`.
let proxy := create2(0, 0x10, 0x10, salt)
if iszero(proxy) {
mstore(0x00, 0x30116425) // `DeploymentFailed()`.
revert(0x1c, 0x04)
}
mstore(0x14, proxy) // Store the proxy's address.
// 0xd6 = 0xc0 (short RLP prefix) + 0x16 (length of: 0x94 ++ proxy ++ 0x01).
// 0x94 = 0x80 + 0x14 (0x14 = the length of an address, 20 bytes, in hex).
mstore(0x00, 0xd694)
mstore8(0x34, 0x01) // Nonce of the proxy contract (1).
pointer := keccak256(0x1e, 0x17)
// Do a out-of-gas revert if `n + 1` is more than 2 bytes.
mstore(add(data, gt(n, 0xfffe)), add(0xfe61000180600a3d393df300, shl(0x40, n)))
if iszero(
mul( // The arguments of `mul` are evaluated last to first.
extcodesize(pointer),
call(gas(), proxy, 0, add(data, 0x15), add(n, 0xb), codesize(), 0x00)
)
) {
mstore(0x00, 0x30116425) // `DeploymentFailed()`.
revert(0x1c, 0x04)
}
mstore(data, n) // Restore the length of `data`.
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* ADDRESS CALCULATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns the initialization code hash of the storage contract for `data`.
/// Used for mining vanity addresses with create2crunch.
function initCodeHash(bytes memory data) internal pure returns (bytes32 hash) {
/// @solidity memory-safe-assembly
assembly {
let n := mload(data)
// Do a out-of-gas revert if `n + 1` is more than 2 bytes.
returndatacopy(returndatasize(), returndatasize(), gt(n, 0xfffe))
mstore(data, add(0x61000180600a3d393df300, shl(0x40, n)))
hash := keccak256(add(data, 0x15), add(n, 0xb))
mstore(data, n) // Restore the length of `data`.
}
}
/// @dev Equivalent to `predictCounterfactualAddress(data, salt, address(this))`
function predictCounterfactualAddress(bytes memory data, bytes32 salt)
internal
view
returns (address pointer)
{
pointer = predictCounterfactualAddress(data, salt, address(this));
}
/// @dev Returns the CREATE2 address of the storage contract for `data`
/// deployed with `salt` by `deployer`.
/// Note: The returned result has dirty upper 96 bits. Please clean if used in assembly.
function predictCounterfactualAddress(bytes memory data, bytes32 salt, address deployer)
internal
pure
returns (address predicted)
{
bytes32 hash = initCodeHash(data);
/// @solidity memory-safe-assembly
assembly {
// Compute and store the bytecode hash.
mstore8(0x00, 0xff) // Write the prefix.
mstore(0x35, hash)
mstore(0x01, shl(96, deployer))
mstore(0x15, salt)
predicted := keccak256(0x00, 0x55)
// Restore the part of the free memory pointer that has been overwritten.
mstore(0x35, 0)
}
}
/// @dev Equivalent to `predictDeterministicAddress(salt, address(this))`.
function predictDeterministicAddress(bytes32 salt) internal view returns (address pointer) {
pointer = predictDeterministicAddress(salt, address(this));
}
/// @dev Returns the "CREATE3" deterministic address for `salt` with `deployer`.
function predictDeterministicAddress(bytes32 salt, address deployer)
internal
pure
returns (address pointer)
{
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40) // Cache the free memory pointer.
mstore(0x00, deployer) // Store `deployer`.
mstore8(0x0b, 0xff) // Store the prefix.
mstore(0x20, salt) // Store the salt.
mstore(0x40, CREATE3_PROXY_INITCODE_HASH) // Store the bytecode hash.
mstore(0x14, keccak256(0x0b, 0x55)) // Store the proxy's address.
mstore(0x40, m) // Restore the free memory pointer.
// 0xd6 = 0xc0 (short RLP prefix) + 0x16 (length of: 0x94 ++ proxy ++ 0x01).
// 0x94 = 0x80 + 0x14 (0x14 = the length of an address, 20 bytes, in hex).
mstore(0x00, 0xd694)
mstore8(0x34, 0x01) // Nonce of the proxy contract (1).
pointer := keccak256(0x1e, 0x17)
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* READ LOGIC */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Equivalent to `read(pointer, 0, 2 ** 256 - 1)`.
function read(address pointer) internal view returns (bytes memory data) {
/// @solidity memory-safe-assembly
assembly {
data := mload(0x40)
let n := and(0xffffffffff, sub(extcodesize(pointer), 0x01))
extcodecopy(pointer, add(data, 0x1f), 0x00, add(n, 0x21))
mstore(data, n) // Store the length.
mstore(0x40, add(n, add(data, 0x40))) // Allocate memory.
}
}
/// @dev Equivalent to `read(pointer, start, 2 ** 256 - 1)`.
function read(address pointer, uint256 start) internal view returns (bytes memory data) {
/// @solidity memory-safe-assembly
assembly {
data := mload(0x40)
let n := and(0xffffffffff, sub(extcodesize(pointer), 0x01))
let l := sub(n, and(0xffffff, mul(lt(start, n), start)))
extcodecopy(pointer, add(data, 0x1f), start, add(l, 0x21))
mstore(data, mul(sub(n, start), lt(start, n))) // Store the length.
mstore(0x40, add(data, add(0x40, mload(data)))) // Allocate memory.
}
}
/// @dev Returns a slice of the data on `pointer` from `start` to `end`.
/// `start` and `end` will be clamped to the range `[0, args.length]`.
/// The `pointer` MUST be deployed via the SSTORE2 write functions.
/// Otherwise, the behavior is undefined.
/// Out-of-gas reverts if `pointer` does not have any code.
function read(address pointer, uint256 start, uint256 end)
internal
view
returns (bytes memory data)
{
/// @solidity memory-safe-assembly
assembly {
data := mload(0x40)
if iszero(lt(end, 0xffff)) { end := 0xffff }
let d := mul(sub(end, start), lt(start, end))
extcodecopy(pointer, add(data, 0x1f), start, add(d, 0x01))
if iszero(and(0xff, mload(add(data, d)))) {
let n := sub(extcodesize(pointer), 0x01)
returndatacopy(returndatasize(), returndatasize(), shr(40, n))
d := mul(gt(n, start), sub(d, mul(gt(end, n), sub(end, n))))
}
mstore(data, d) // Store the length.
mstore(add(add(data, 0x20), d), 0) // Zeroize the slot after the bytes.
mstore(0x40, add(add(data, 0x40), d)) // Allocate memory.
}
}
}
src/interfaces/IMURIProtocolCreator.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.34;
interface IMURIProtocolCreator {
function isTokenOwner(address creatorContract, address account, uint256 tokenId) external view returns (bool);
}
src/interfaces/IPanorama.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.34;
interface IPanorama {
error MaxSupplyReached();
error RendererNotSet();
error NotOwnerOrOperator();
event MetadataUpdate(uint256 _tokenId);
event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);
event AuthorizedOperatorUpdated(address indexed operator, bool indexed authorized);
// ERC20
function tokenURI() external view returns (string memory);
// State
function MAX_SUPPLY() external view returns (uint256);
function totalMinted() external view returns (uint256);
function totalBurned() external view returns (uint256);
function totalSupply() external view returns (uint256);
function renderer() external view returns (address);
function storageContract() external view returns (address);
function muriOperator() external view returns (address);
function panoramaERC20() external view returns (address);
function muriProtocol() external view returns (address);
function authorizedOperators(address operator) external view returns (bool);
// Mutations
function mintTo(address to) external returns (uint256);
function mintTo(address to, uint256 quantity) external returns (uint256[] memory);
function burn(uint256 tokenId) external;
function signalMetadataUpdate() external;
function signalMetadataUpdate(uint256 tokenId) external;
function signalBatchMetadataUpdate(uint256 fromTokenId, uint256 toTokenId) external;
function setAuthorizedOperator(address operator, bool authorized) external;
function setRenderer(address _renderer) external;
function setStorageContract(address _storage) external;
function setMuriOperator(address _muriOperator) external;
function setPanoramaERC20(address _token) external;
function setMuriProtocol(address _muriProtocol) external;
function mintController() external view returns (address);
function maxSupply() external view returns (uint256);
function mintCap() external view returns (uint256);
function setMintController(address _mintController) external;
}
src/interfaces/IPanoramaSeason4Storage.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.34;
interface IPanoramaSeason4Storage {
error InvalidIndex();
error HtmlTemplateNotSet();
error NotOwnerOrOperator();
error NotTokenHolder();
error FragmentIndexOutOfBounds();
error FragmentAlreadyUploaded();
error FragmentHashMismatch();
error FragmentSizeInvalid();
error NoFragmentsConfigured();
error FragmentNotUploaded();
error InvalidRpcUrl();
error NotRevealed();
error InvalidTrait();
/// @notice What a Season 4 token's `animation_url` shows. The holder chooses.
enum View {
StaticVideo,
DynamicScene
}
/// @dev Bytes stored on-chain as ordered fragments, as PanoramaStorage stores a tableau's
/// image. The owner (or an operator, for day data) commits the keccak256 hash of each
/// fragment, then anyone can upload the bytes: each upload must match its hash. Every
/// fragment but the last is FRAGMENT_SIZE bytes, so the dynamic scene can check data it
/// fetched from a link against the same hashes.
struct FragmentData {
bytes32[] fragmentHashes;
address[] fragmentPointers;
uint256 uploadedFragmentCount;
}
event AuthorizedOperatorUpdated(address indexed operator, bool indexed authorized);
event SceneRendererFragmentHashesSet(uint256 indexed fragmentCount);
event SceneRendererFragmentUploaded(uint256 indexed fragmentIndex, address indexed pointer);
event SceneRendererFinalized(uint256 indexed fragmentCount);
event DayDataFragmentHashesSet(uint256 indexed tokenId, uint256 indexed fragmentCount);
event DayDataFragmentUploaded(uint256 indexed tokenId, uint256 indexed fragmentIndex, address indexed pointer);
event DayDataFinalized(uint256 indexed tokenId, uint256 indexed fragmentCount);
event ViewSet(uint256 indexed tokenId, address indexed holder, View view_);
event RpcUrlLimitsSet(uint256 maxRpcUrls, uint256 maxRpcUrlLength);
event RpcUrlsSet(uint256 count);
event TokenRpcUrlsSet(uint256 indexed tokenId, address indexed holder, uint256 count);
event MusicControllerSet(address indexed musicController);
event TokenTraitsSet(uint256 indexed tokenId, uint256 count);
// State
function FIRST_TOKEN_ID() external view returns (uint256);
function LAST_TOKEN_ID() external view returns (uint256);
function FRAGMENT_SIZE() external view returns (uint256);
function ALL_LEADS() external view returns (uint8);
function maxRpcUrls() external view returns (uint256);
function maxRpcUrlLength() external view returns (uint256);
function panorama() external view returns (address);
function authorizedOperators(address operator) external view returns (bool);
function sceneRendererHtmlPrefixPointer() external view returns (address);
function sceneRendererHtmlSuffixPointer() external view returns (address);
function viewOf(uint256 tokenId) external view returns (View);
function musicController() external view returns (address);
function MAX_TRAITS() external view returns (uint256);
function getTokenTraits(uint256 tokenId) external view returns (string[] memory names, string[] memory values);
// View: dynamic scene
function getSceneRendererHtmlPrefixData() external view returns (bytes memory);
function getSceneRendererHtmlSuffixData() external view returns (bytes memory);
function getSceneRendererFragmentHashes() external view returns (bytes32[] memory);
function getSceneRendererFragmentPointers() external view returns (address[] memory);
function isSceneRendererFullyUploaded() external view returns (bool);
function hasSceneRenderer() external view returns (bool);
// View: day data
function getDayDataFragmentHashes(uint256 tokenId) external view returns (bytes32[] memory);
function getDayDataFragmentPointers(uint256 tokenId) external view returns (address[] memory);
function getUploadedDayDataFragmentCount(uint256 tokenId) external view returns (uint256);
function isDayDataFullyUploaded(uint256 tokenId) external view returns (bool);
function getDayDataFragment(uint256 tokenId, uint256 fragmentIndex) external view returns (bytes memory);
function getImageFragment(uint256 tokenId, uint256 fragmentIndex) external view returns (bytes memory);
// View: RPC addresses
function getRpcUrls() external view returns (string[] memory);
function getTokenRpcUrls(uint256 tokenId) external view returns (string[] memory);
function getRpcUrlsFor(uint256 tokenId) external view returns (string[] memory);
// View: music (what the music controller reads)
function leadOf(uint256 tokenId) external view returns (uint8);
function moodOf(uint256 tokenId) external view returns (uint8);
// Mutations
function setPanorama(address _panorama) external;
function setAuthorizedOperator(address operator, bool authorized) external;
function setSceneRendererHtmlPrefix(bytes calldata _data) external;
function setSceneRendererHtmlSuffix(bytes calldata _data) external;
function setSceneRendererFragmentHashes(bytes32[] calldata hashes) external;
function uploadSceneRendererFragment(uint256 fragmentIndex, bytes calldata data) external;
function setDayDataFragmentHashes(uint256 tokenId, bytes32[] calldata hashes) external;
function uploadDayDataFragment(uint256 tokenId, uint256 fragmentIndex, bytes calldata data) external;
function setDayDataFragmentPointer(uint256 tokenId, uint256 fragmentIndex, address pointer) external;
function removeDayDataFragmentPointer(uint256 tokenId, uint256 fragmentIndex) external;
function clearDayData(uint256 tokenId) external;
function setView(uint256 tokenId, View view_) external;
function setMusicController(address _musicController) external;
function setRpcUrlLimits(uint256 _maxRpcUrls, uint256 _maxRpcUrlLength) external;
function setRpcUrls(string[] calldata urls) external;
function setTokenRpcUrls(uint256 tokenId, string[] calldata urls) external;
function setTokenTraits(uint256 tokenId, string[] calldata names, string[] calldata values) external;
}
src/interfaces/IPanoramaStorage.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.34;
interface IPanoramaStorage {
error InvalidIndex();
error LengthMismatch();
error HtmlTemplateNotSet();
error InvalidWorkflowId();
error NotOwnerOrOperator();
error FragmentIndexOutOfBounds();
error FragmentAlreadyUploaded();
error FragmentHashMismatch();
error NotFullyUploaded();
error NoFragmentsConfigured();
event EntryAdded(uint256 indexed tokenId, uint256 indexed price, int256 indexed changeBps);
event WorkflowAdded(uint256 indexed id, string name);
event WorkflowUpdated(uint256 indexed id);
event ImageFragmentHashesSet(uint256 indexed tokenId, uint256 indexed fragmentCount);
event ImageFragmentUploaded(uint256 indexed tokenId, uint256 indexed fragmentIndex, address indexed pointer);
event TableauFinalized(uint256 indexed tokenId, uint256 indexed fragmentCount);
event AuthorizedOperatorUpdated(address indexed operator, bool indexed authorized);
/// @dev Each tableau is a single 1920x1080 AI-generated painting in the panorama.
/// Its image can be stored fully on-chain by splitting the raw image bytes (WebP)
/// into ordered fragments. The owner commits keccak256 hashes for each fragment,
/// then anyone can upload the corresponding data (hash-verified, permissionless).
/// Once all fragments are uploaded, `uploadImageFragment` automatically
/// finalizes the tableau. The image is served directly via `getOnchainImageDataUri`,
/// fully retrievable from contract storage without any external dependency.
struct TableauData {
uint256 price;
int256 changeBps;
uint40 timestamp;
uint8 moodIndex;
uint8 workflowId;
uint8 season;
uint256 seed;
string prompt;
string name;
string description;
/// @dev Ordered keccak256 hashes of each image fragment. Set by the owner/operator
/// before upload begins. The image bytes are split into N sequential chunks off-chain,
/// each chunk hashed, and the hash array committed here. This serves as a commitment
/// scheme: uploaders must provide data matching each hash exactly.
bytes32[] imageFragmentHashes;
/// @dev SSTORE2 pointers to uploaded fragment data, parallel to imageFragmentHashes.
/// Each slot starts as address(0) and is filled when the corresponding fragment is
/// uploaded via `uploadImageFragment`. Reading the stored bytes: `SSTORE2.read(pointer)`.
address[] imageFragmentPointers;
/// @dev Number of fragments uploaded so far. When this equals imageFragmentHashes.length,
/// the image is fully on-chain and `finalizeOnchainTableau` can be called.
uint256 uploadedFragmentCount;
}
struct Workflow {
string name;
address jsonPointer;
string gpuUsed;
string cudaVersion;
bytes32[] modelSha256;
string[] customNodeNames;
string[] customNodeVersions;
bytes32[] customNodeSha256;
string[] modelDownloadLinks;
}
// State
function panorama() external view returns (address);
function authorizedOperators(address operator) external view returns (bool);
function erc20TokenDescription() external view returns (string memory);
function externalUrl() external view returns (string memory);
function startTimestamp() external view returns (uint40);
function cdnBase() external view returns (string memory);
function panoramaHtmlPrefixPointer() external view returns (address);
function panoramaHtmlSuffixPointer() external view returns (address);
function entryCount() external view returns (uint256);
// View — Tableau
function getTableauData(uint256 tokenId) external view returns (TableauData memory);
function getPanoramaHtmlPrefixData() external view returns (bytes memory);
function getPanoramaHtmlSuffixData() external view returns (bytes memory);
// View — Image Fragments
function getImageFragmentHashes(uint256 tokenId) external view returns (bytes32[] memory);
function getTotalFragments(uint256 tokenId) external view returns (uint256);
function getFragmentPointer(uint256 tokenId, uint256 index) external view returns (address);
function getFragmentPointers(uint256 tokenId) external view returns (address[] memory);
function getUploadedFragmentCount(uint256 tokenId) external view returns (uint256);
function isFullyUploaded(uint256 tokenId) external view returns (bool);
function getOnchainImageDataUri(uint256 tokenId) external view returns (string memory);
// View — Workflows
function getWorkflow(uint256 id) external view returns (Workflow memory);
function getWorkflowCount() external view returns (uint256);
function getWorkflowJson(uint256 id) external view returns (bytes memory);
// Mutations — Config
function setPanorama(address _panorama) external;
function setAuthorizedOperator(address operator, bool authorized) external;
function setCdnBase(string calldata _cdnBase) external;
function setExternalUrl(string calldata _url) external;
function setStartTimestamp(uint40 _startTimestamp) external;
function updateErc20Description(string calldata _description) external;
function setPanoramaHtmlPrefix(bytes calldata _data) external;
function setPanoramaHtmlSuffix(bytes calldata _data) external;
// Mutations — Tableau
function addTableauEntry(TableauData calldata data) external;
function batchAddTableauEntries(TableauData[] calldata entries) external;
function setTableauPrice(uint256 tokenId, uint256 price) external;
function setTableauChangeBps(uint256 tokenId, int256 changeBps) external;
function setTableauTimestamp(uint256 tokenId, uint40 timestamp) external;
function setTableauMoodIndex(uint256 tokenId, uint8 moodIndex) external;
function setTableauWorkflowId(uint256 tokenId, uint8 workflowId) external;
function setTableauSeason(uint256 tokenId, uint8 season) external;
function setTableauSeed(uint256 tokenId, uint256 seed) external;
function setTableauPrompt(uint256 tokenId, string calldata prompt) external;
function setCustomTableauName(uint256 tokenId, string calldata _name) external;
function setCustomTableauDescription(uint256 tokenId, string calldata description) external;
// Mutations — Image Fragments
function setTableauImageFragmentHashes(uint256 tokenId, bytes32[] calldata hashes) external;
function batchSetTableauImageFragmentHashes(uint256[] calldata tokenIds, bytes32[][] calldata hashes) external;
function uploadImageFragment(uint256 tokenId, uint256 fragmentIndex, bytes calldata data) external;
function setFragmentPointer(uint256 tokenId, uint256 fragmentIndex, address pointer) external;
function removeFragmentPointer(uint256 tokenId, uint256 fragmentIndex) external;
function clearFragmentData(uint256 tokenId) external;
// Mutations — Workflows
function addWorkflow(Workflow calldata wf, bytes calldata json) external returns (uint256 id);
function updateWorkflowName(uint256 id, string calldata _name) external;
function updateWorkflowJson(uint256 id, bytes calldata json) external;
function updateWorkflowGpu(uint256 id, string calldata gpu, string calldata cuda) external;
function updateWorkflowModels(uint256 id, bytes32[] calldata modelHashes, string[] calldata downloadLinks) external;
function updateWorkflowCustomNodes(
uint256 id,
string[] calldata names,
string[] calldata versions,
bytes32[] calldata nodeHashes
) external;
}
Настройки компилятораПоказать
{
"viaIR": false,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "none",
"useLiteralContent": false
},
"optimizer": {
"runs": 10000,
"enabled": true
},
"evmVersion": "prague",
"remappings": [
"forge-std/=node_modules/forge-std/",
"solady/=node_modules/solady/src/",
"@uniswap/v4-core/=node_modules/@uniswap/v4-core/",
"@uniswap/v4-periphery/=node_modules/@uniswap/v4-periphery/",
"@ensdomains/=node_modules/@ensdomains/",
"@manifoldxyz/=node_modules/@manifoldxyz/",
"@openzeppelin/=node_modules/@openzeppelin/",
"ds-test/=node_modules/@uniswap/v4-core/lib/solmate/lib/ds-test/",
"erc4626-tests/=node_modules/@uniswap/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-gas-snapshot/=node_modules/@uniswap/v4-periphery/lib/permit2/lib/forge-gas-snapshot/",
"openzeppelin-contracts/=node_modules/@uniswap/v4-core/lib/openzeppelin-contracts/",
"permit2/=node_modules/@uniswap/v4-periphery/lib/permit2/",
"solmate/=node_modules/@uniswap/v4-core/lib/solmate/",
"v4-core/=node_modules/@uniswap/v4-periphery/lib/v4-core/"
]
}Исходный код и метаданные: Sourcify.
Исходный код принадлежит авторам контракта.