Overview
ETH Balance
More Info
ContractCreator
Multichain Info
Latest 25 from a total of 45 transactions
| Transaction Hash |
Method
|
Block
|
From
|
To
|
Amount
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Post Comment Wit... | 38216257 | 42 days ago | IN | 0 ETH | 0.00000153 | ||||
| Post Comment Wit... | 38173057 | 43 days ago | IN | 0 ETH | 0.00000152 | ||||
| Post Comment Wit... | 38129857 | 44 days ago | IN | 0 ETH | 0.00000166 | ||||
| Post Comment Wit... | 38086657 | 45 days ago | IN | 0 ETH | 0.00000152 | ||||
| Post Comment Wit... | 38043457 | 46 days ago | IN | 0 ETH | 0.00000166 | ||||
| Post Comment Wit... | 38000257 | 47 days ago | IN | 0 ETH | 0.00000166 | ||||
| Post Comment Wit... | 37957057 | 48 days ago | IN | 0 ETH | 0.00000165 | ||||
| Post Comment Wit... | 37913857 | 49 days ago | IN | 0 ETH | 0.00000166 | ||||
| Post Comment Wit... | 37870657 | 50 days ago | IN | 0 ETH | 0.00000088 | ||||
| Post Comment Wit... | 37827457 | 51 days ago | IN | 0 ETH | 0.00000079 | ||||
| Post Comment Wit... | 37784258 | 52 days ago | IN | 0 ETH | 0.00000082 | ||||
| Post Comment Wit... | 37784257 | 52 days ago | IN | 0 ETH | 0.00000082 | ||||
| Post Comment Wit... | 37741057 | 53 days ago | IN | 0 ETH | 0.00000082 | ||||
| Post Comment Wit... | 37697857 | 54 days ago | IN | 0 ETH | 0.00000083 | ||||
| Post Comment Wit... | 37654657 | 55 days ago | IN | 0 ETH | 0.00000084 | ||||
| Post Comment Wit... | 37611457 | 56 days ago | IN | 0 ETH | 0.00000095 | ||||
| Post Comment Wit... | 37568257 | 57 days ago | IN | 0 ETH | 0.00000092 | ||||
| Post Comment Wit... | 37525057 | 58 days ago | IN | 0 ETH | 0.00000084 | ||||
| Post Comment Wit... | 37481857 | 59 days ago | IN | 0 ETH | 0.00000035 | ||||
| Post Comment Wit... | 37438657 | 60 days ago | IN | 0 ETH | 0.00000032 | ||||
| Post Comment Wit... | 37395457 | 61 days ago | IN | 0 ETH | 0.00000032 | ||||
| Post Comment Wit... | 37352257 | 62 days ago | IN | 0 ETH | 0.00000035 | ||||
| Post Comment Wit... | 37309057 | 63 days ago | IN | 0 ETH | 0.00000031 | ||||
| Post Comment Wit... | 37265857 | 64 days ago | IN | 0 ETH | 0.00000032 | ||||
| Post Comment Wit... | 37222658 | 65 days ago | IN | 0 ETH | 0.00000035 |
Latest 1 internal transaction
| Parent Transaction Hash | Block | From | To | Amount | ||
|---|---|---|---|---|---|---|
| 27419063 | 292 days ago | Contract Creation | 0 ETH |
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "solady/src/auth/Ownable.sol";
import "solady/src/utils/ReentrancyGuard.sol";
import "./types/Comments.sol";
import "./types/Channels.sol";
import "./types/Metadata.sol";
import "./libraries/CommentSigning.sol";
import "./libraries/Batching.sol";
import "./libraries/Approvals.sol";
import "./libraries/CommentOps.sol";
import "./libraries/MetadataOps.sol";
import "./interfaces/ICommentManager.sol";
import "./interfaces/IChannelManager.sol";
import "./interfaces/IHook.sol";
import "./types/Hooks.sol";
import "./ProtocolFees.sol";
import "./ChannelManager.sol";
/// @title CommentManager - A decentralized comments system
/// @notice This contract allows users to post and manage comments with optional app-signer approval and channel-specific hooks
/// @dev Implements EIP-712 for typed structured data hashing and signing
contract CommentManager is ICommentManager, ReentrancyGuard, Ownable {
// go to ethcomments.xyz to learn more about ECP and building on ECP
string public constant name = "Ethereum Comments Protocol";
string public constant version = "1";
bytes32 public immutable DOMAIN_SEPARATOR;
// On-chain storage mappings
mapping(bytes32 => Comments.Comment) internal comments;
/// @notice Mapping of author to app to approval expiry timestamp (0 means no approval)
mapping(address => mapping(address => uint256)) internal approvals;
/// @notice Mapping of author to app to nonce
mapping(address => mapping(address => uint256)) internal nonces;
/// @notice Mapping of comment ID to deleted status, if missing in mapping, the comment is not deleted
mapping(bytes32 => bool) internal deleted;
// Metadata storage mappings
/// @notice Mapping of comment ID to metadata key to metadata value
mapping(bytes32 => mapping(bytes32 => bytes)) public commentMetadata;
/// @notice Mapping of comment ID to hook metadata key to hook metadata value
mapping(bytes32 => mapping(bytes32 => bytes)) public commentHookMetadata;
/// @notice Mapping of comment ID to array of metadata keys
mapping(bytes32 => bytes32[]) public commentMetadataKeys;
/// @notice Mapping of comment ID to array of hook metadata keys
mapping(bytes32 => bytes32[]) public commentHookMetadataKeys;
// Channel manager reference
IChannelManager public channelManager;
/// @notice Constructor initializes the contract with the deployer as owner and channel manager
/// @dev Sets up EIP-712 domain separator
/// @param initialOwner The address that will own the contract
constructor(address initialOwner) {
if (initialOwner == address(0)) revert ZeroAddress();
_initializeOwner(initialOwner);
DOMAIN_SEPARATOR = CommentSigning.generateDomainSeparator(
name,
version,
block.chainid,
address(this)
);
}
/// @inheritdoc ICommentManager
function postComment(
Comments.CreateComment calldata commentData,
bytes calldata appSignature
) external payable returns (bytes32) {
return _postComment(commentData, appSignature, msg.value);
}
/// @notice Internal function to handle comment posting with explicit value
function _postComment(
Comments.CreateComment memory commentData,
bytes memory appSignature,
uint256 value
)
internal
onlyAuthor(commentData.author)
notStale(commentData.deadline)
onlyParentIdOrTargetUri(commentData.parentId, commentData.targetUri)
channelExists(commentData.channelId)
onlyReplyInSameChannel(commentData.parentId, commentData.channelId)
reactionHasTargetOrParent(
commentData.commentType,
commentData.parentId,
commentData.targetUri
)
returns (bytes32)
{
bytes32 commentId = CommentSigning.getCommentId(
commentData,
DOMAIN_SEPARATOR
);
address app = commentData.app;
// Verify the App signature.
if (
CommentSigning.verifyAppSignature(
app,
commentId,
appSignature,
msg.sender
)
) {
_createComment(
commentId,
commentData,
Comments.AuthorAuthMethod.DIRECT_TX,
value
);
return commentId;
}
revert InvalidAppSignature();
}
/// @inheritdoc ICommentManager
function postCommentWithSig(
Comments.CreateComment calldata commentData,
bytes calldata authorSignature,
bytes calldata appSignature
) external payable returns (bytes32) {
return
_postCommentWithSig(
commentData,
authorSignature,
appSignature,
msg.value
);
}
/// @notice Internal function to handle comment posting with signature and explicit value
/// @dev This function is used to post a comment with a signature and explicit value
/// @param commentData The comment data struct containing content and metadata
/// @param authorSignature The author signature
/// @param appSignature The app signature
/// @param value The value to be paid for the comment
/// @return The comment ID
function _postCommentWithSig(
Comments.CreateComment memory commentData,
bytes memory authorSignature,
bytes memory appSignature,
uint256 value
)
internal
notStale(commentData.deadline)
onlyParentIdOrTargetUri(commentData.parentId, commentData.targetUri)
channelExists(commentData.channelId)
onlyReplyInSameChannel(commentData.parentId, commentData.channelId)
reactionHasTargetOrParent(
commentData.commentType,
commentData.parentId,
commentData.targetUri
)
returns (bytes32)
{
bytes32 commentId = CommentSigning.getCommentId(
commentData,
DOMAIN_SEPARATOR
);
address app = commentData.app;
if (
!CommentSigning.verifyAppSignature(
app,
commentId,
appSignature,
msg.sender
)
) {
revert InvalidAppSignature();
}
// Verify the author signature.
if (
CommentSigning.verifyAuthorSignature(
commentData.author,
commentId,
authorSignature
)
) {
_createComment(
commentId,
commentData,
Comments.AuthorAuthMethod.AUTHOR_SIGNATURE,
value
);
return commentId;
}
if (Approvals.isApproved(commentData.author, app, approvals)) {
_createComment(
commentId,
commentData,
Comments.AuthorAuthMethod.APP_APPROVAL,
value
);
return commentId;
}
revert NotAuthorized(msg.sender, commentData.author);
}
function _createComment(
bytes32 commentId,
Comments.CreateComment memory commentData,
Comments.AuthorAuthMethod authMethod,
uint256 value
) internal commentDoesNotExist(commentId) {
// Collect protocol comment fee, if any.
uint96 commentCreationFee = channelManager.getCommentCreationFee();
if (commentCreationFee > 0) {
if (msg.value < commentCreationFee) {
revert InsufficientValue(msg.value, commentCreationFee);
}
channelManager.collectCommentCreationFee{ value: commentCreationFee }();
}
CommentOps.createComment(
commentId,
commentData,
authMethod,
value,
commentCreationFee,
channelManager,
comments,
commentMetadata,
commentMetadataKeys,
commentHookMetadata,
commentHookMetadataKeys,
msg.sender
);
}
/// @inheritdoc ICommentManager
function editComment(
bytes32 commentId,
Comments.EditComment calldata editData,
bytes calldata appSignature
) external payable {
_editCommentDirect(commentId, editData, appSignature, msg.value);
}
/// @notice Internal function to handle comment editing with explicit value
/// @dev This function is used to edit a comment with an explicit value
/// @param commentId The unique identifier of the comment to edit
/// @param editData The comment data struct containing content and metadata
/// @param appSignature The app signature
/// @param value The value to be paid for the comment
function _editCommentDirect(
bytes32 commentId,
Comments.EditComment memory editData,
bytes memory appSignature,
uint256 value
)
internal
onlyAuthor(comments[commentId].author)
notStale(editData.deadline)
commentExists(commentId)
noEditingReactions(comments[commentId].commentType)
validateNonce(comments[commentId].author, editData.app, editData.nonce)
{
Comments.Comment storage comment = comments[commentId];
address author = comment.author;
address app = editData.app;
Approvals.incrementNonce(author, app, nonces);
bytes32 editHash = CommentSigning.getEditCommentHash(
commentId,
author,
editData,
DOMAIN_SEPARATOR
);
// Verify the app signature.
if (
CommentSigning.verifyAppSignature(app, editHash, appSignature, msg.sender)
) {
_editComment(
commentId,
editData,
Comments.AuthorAuthMethod.DIRECT_TX,
value
);
return;
}
revert InvalidAppSignature();
}
/// @inheritdoc ICommentManager
function editCommentWithSig(
bytes32 commentId,
Comments.EditComment calldata editData,
bytes calldata authorSignature,
bytes calldata appSignature
) external payable {
_editCommentWithSig(
commentId,
editData,
authorSignature,
appSignature,
msg.value
);
}
/// @notice Internal function to handle comment editing with signature and explicit value
/// @dev This function is used to edit a comment with a signature and explicit value
/// @param commentId The unique identifier of the comment to edit
/// @param editData The comment data struct containing content and metadata
/// @param authorSignature The author signature
/// @param appSignature The app signature
/// @param value The value to be paid for the comment
function _editCommentWithSig(
bytes32 commentId,
Comments.EditComment memory editData,
bytes memory authorSignature,
bytes memory appSignature,
uint256 value
)
internal
notStale(editData.deadline)
commentExists(commentId)
noEditingReactions(comments[commentId].commentType)
validateNonce(comments[commentId].author, editData.app, editData.nonce)
{
Comments.Comment storage comment = comments[commentId];
address author = comment.author;
address app = editData.app;
Approvals.incrementNonce(author, app, nonces);
require(author != address(0), "Comment does not exist");
bytes32 editHash = CommentSigning.getEditCommentHash(
commentId,
author,
editData,
DOMAIN_SEPARATOR
);
// Verify the app signature.
if (
!CommentSigning.verifyAppSignature(
app,
editHash,
appSignature,
msg.sender
)
) {
revert InvalidAppSignature();
}
// Verify the author signature.
if (
CommentSigning.verifyAuthorSignature(author, editHash, authorSignature)
) {
_editComment(
commentId,
editData,
Comments.AuthorAuthMethod.AUTHOR_SIGNATURE,
value
);
return;
}
if (Approvals.isApproved(author, app, approvals)) {
_editComment(
commentId,
editData,
Comments.AuthorAuthMethod.APP_APPROVAL,
value
);
return;
}
revert NotAuthorized(msg.sender, author);
}
/// @notice Internal function to handle comment editing logic
/// @param commentId The unique identifier of the comment to edit
/// @param editData The comment data struct containing content and metadata
/// @param authMethod The authentication method used for this edit
function _editComment(
bytes32 commentId,
Comments.EditComment memory editData,
Comments.AuthorAuthMethod authMethod,
uint256 value
) internal {
CommentOps.editComment(
commentId,
editData,
authMethod,
value,
channelManager,
comments,
commentMetadata,
commentMetadataKeys,
commentHookMetadata,
commentHookMetadataKeys,
msg.sender
);
}
/// @inheritdoc ICommentManager
function deleteComment(bytes32 commentId) public {
_deleteComment(commentId, msg.sender);
}
/// @notice Internal function to handle comment deletion logic
/// @param commentId The unique identifier of the comment to delete
/// @param author The address of the comment author
function _deleteComment(
bytes32 commentId,
address author
) internal commentExists(commentId) onlyAuthor(comments[commentId].author) {
CommentOps.deleteComment(
commentId,
author,
channelManager,
comments,
deleted,
commentMetadata,
commentMetadataKeys,
commentHookMetadata,
commentHookMetadataKeys,
msg.sender
);
}
/// @inheritdoc ICommentManager
function deleteCommentWithSig(
bytes32 commentId,
address app,
uint256 deadline,
bytes calldata authorSignature,
bytes calldata appSignature
) external {
_deleteCommentWithSig(
commentId,
app,
deadline,
authorSignature,
appSignature
);
}
/// @notice Internal function to handle comment deletion with signature logic
/// @param commentId The unique identifier of the comment to delete
/// @param app The address of the app
/// @param deadline The deadline for the signature
/// @param authorSignature The author signature
/// @param appSignature The app signature
function _deleteCommentWithSig(
bytes32 commentId,
address app,
uint256 deadline,
bytes calldata authorSignature,
bytes calldata appSignature
) internal notStale(deadline) commentExists(commentId) {
Comments.Comment storage comment = comments[commentId];
address author = comment.author;
bytes32 deleteHash = CommentSigning.getDeleteCommentHash(
commentId,
author,
app,
deadline,
DOMAIN_SEPARATOR
);
// for deleting comment, only single party (either author or app) is needed for authorization
bool isAuthorizedByAuthor = (msg.sender == author ||
CommentSigning.verifyAuthorSignature(
author,
deleteHash,
authorSignature
));
bool isAuthorizedByApprovedApp = Approvals.isApproved(
author,
app,
approvals
) &&
CommentSigning.verifyAppSignature(
app,
deleteHash,
appSignature,
msg.sender
);
if (isAuthorizedByAuthor || isAuthorizedByApprovedApp) {
CommentOps.deleteComment(
commentId,
author,
channelManager,
comments,
deleted,
commentMetadata,
commentMetadataKeys,
commentHookMetadata,
commentHookMetadataKeys,
msg.sender
);
return;
}
revert NotAuthorized(msg.sender, author);
}
/// @notice Internal function to get metadata for a comment
/// @param commentId The unique identifier of the comment
/// @return The metadata entries for the comment
/// @inheritdoc ICommentManager
function addApproval(address app, uint256 expiry) external {
Approvals.addApproval(msg.sender, app, expiry, approvals);
}
/// @inheritdoc ICommentManager
function addApprovalWithSig(
address author,
address app,
uint256 expiry,
uint256 nonce,
uint256 deadline,
bytes calldata authorSignature
) external notStale(deadline) validateNonce(author, app, nonce) {
Approvals.incrementNonce(author, app, nonces);
bytes32 addApprovalHash = CommentSigning.getAddApprovalHash(
author,
app,
expiry,
nonce,
deadline,
DOMAIN_SEPARATOR
);
if (
!CommentSigning.verifyAuthorSignature(
author,
addApprovalHash,
authorSignature
)
) {
revert InvalidAuthorSignature();
}
Approvals.addApproval(author, app, expiry, approvals);
}
/// @inheritdoc ICommentManager
function revokeApproval(address app) external {
Approvals.revokeApproval(msg.sender, app, approvals);
}
/// @inheritdoc ICommentManager
function removeApprovalWithSig(
address author,
address app,
uint256 nonce,
uint256 deadline,
bytes calldata authorSignature
) external notStale(deadline) validateNonce(author, app, nonce) {
Approvals.incrementNonce(author, app, nonces);
bytes32 removeApprovalHash = CommentSigning.getRemoveApprovalHash(
author,
app,
nonce,
deadline,
DOMAIN_SEPARATOR
);
if (
!CommentSigning.verifyAuthorSignature(
author,
removeApprovalHash,
authorSignature
)
) {
revert InvalidAuthorSignature();
}
Approvals.revokeApproval(author, app, approvals);
}
/// @inheritdoc ICommentManager
function updateCommentHookData(
bytes32 commentId
) external commentExists(commentId) {
CommentOps.updateCommentHookData(
commentId,
channelManager,
comments,
commentMetadata,
commentMetadataKeys,
commentHookMetadata,
commentHookMetadataKeys,
msg.sender
);
}
/// @inheritdoc ICommentManager
function getAddApprovalHash(
address author,
address app,
uint256 expiry,
uint256 nonce,
uint256 deadline
) public view returns (bytes32) {
return
CommentSigning.getAddApprovalHash(
author,
app,
expiry,
nonce,
deadline,
DOMAIN_SEPARATOR
);
}
/// @inheritdoc ICommentManager
function getRemoveApprovalHash(
address author,
address app,
uint256 nonce,
uint256 deadline
) public view returns (bytes32) {
return
CommentSigning.getRemoveApprovalHash(
author,
app,
nonce,
deadline,
DOMAIN_SEPARATOR
);
}
/// @inheritdoc ICommentManager
function getDeleteCommentHash(
bytes32 commentId,
address author,
address app,
uint256 deadline
) public view returns (bytes32) {
return
CommentSigning.getDeleteCommentHash(
commentId,
author,
app,
deadline,
DOMAIN_SEPARATOR
);
}
/// @inheritdoc ICommentManager
function getEditCommentHash(
bytes32 commentId,
address author,
Comments.EditComment calldata editData
) public view returns (bytes32) {
return
CommentSigning.getEditCommentHash(
commentId,
author,
editData,
DOMAIN_SEPARATOR
);
}
/// @inheritdoc ICommentManager
function getCommentId(
Comments.CreateComment memory commentData
) public view returns (bytes32) {
return CommentSigning.getCommentId(commentData, DOMAIN_SEPARATOR);
}
/// @inheritdoc ICommentManager
function updateChannelContract(address _channelContract) external onlyOwner {
if (_channelContract == address(0)) revert ZeroAddress();
channelManager = ChannelManager(payable(_channelContract));
}
/// @inheritdoc ICommentManager
function getComment(
bytes32 commentId
) external view returns (Comments.Comment memory) {
return comments[commentId];
}
/// @inheritdoc ICommentManager
function getCommentMetadata(
bytes32 commentId
) external view returns (Metadata.MetadataEntry[] memory) {
return
MetadataOps.getCommentMetadata(
commentId,
commentMetadata,
commentMetadataKeys
);
}
/// @inheritdoc ICommentManager
function getCommentHookMetadata(
bytes32 commentId
) external view returns (Metadata.MetadataEntry[] memory) {
return
MetadataOps.getCommentHookMetadata(
commentId,
commentHookMetadata,
commentHookMetadataKeys
);
}
/// @inheritdoc ICommentManager
function getCommentMetadataValue(
bytes32 commentId,
bytes32 key
) external view returns (bytes memory) {
return commentMetadata[commentId][key];
}
/// @inheritdoc ICommentManager
function getCommentHookMetadataValue(
bytes32 commentId,
bytes32 key
) external view returns (bytes memory) {
return commentHookMetadata[commentId][key];
}
/// @inheritdoc ICommentManager
function getCommentMetadataKeys(
bytes32 commentId
) external view returns (bytes32[] memory) {
return commentMetadataKeys[commentId];
}
/// @inheritdoc ICommentManager
function getCommentHookMetadataKeys(
bytes32 commentId
) external view returns (bytes32[] memory) {
return commentHookMetadataKeys[commentId];
}
/// @inheritdoc ICommentManager
function isApproved(
address author,
address app
) external view returns (bool) {
return Approvals.isApproved(author, app, approvals);
}
/// @inheritdoc ICommentManager
function getApprovalExpiry(
address author,
address app
) external view returns (uint256) {
return Approvals.getApprovalExpiry(author, app, approvals);
}
/// @inheritdoc ICommentManager
function getNonce(
address author,
address app
) external view returns (uint256) {
return Approvals.getNonce(author, app, nonces);
}
/// @inheritdoc ICommentManager
function isDeleted(bytes32 commentId) external view returns (bool) {
return deleted[commentId];
}
modifier channelExists(uint256 channelId) {
if (!channelManager.channelExists(channelId)) {
revert IChannelManager.ChannelDoesNotExist();
}
_;
}
modifier commentDoesNotExist(bytes32 commentId) {
if (comments[commentId].author != address(0)) {
revert CommentAlreadyExists();
}
if (deleted[commentId]) {
revert CommentAlreadyDeleted();
}
_;
}
modifier commentExists(bytes32 commentId) {
if (
comments[commentId].author == address(0) || deleted[commentId] == true
) {
revert CommentDoesNotExist();
}
_;
}
modifier notStale(uint256 deadline) {
if (block.timestamp > deadline) {
revert SignatureDeadlineReached(deadline, block.timestamp);
}
_;
}
modifier onlyReplyInSameChannel(bytes32 parentId, uint256 channelId) {
if (parentId != bytes32(0) && comments[parentId].channelId != channelId) {
revert ParentCommentNotInSameChannel();
}
_;
}
modifier onlyParentIdOrTargetUri(bytes32 parentId, string memory targetUri) {
if (parentId != bytes32(0)) {
if (comments[parentId].author == address(0) && !deleted[parentId]) {
revert ParentCommentHasNeverExisted();
}
if (bytes(targetUri).length > 0) {
revert InvalidCommentReference(
"Parent comment and targetUri cannot both be set"
);
}
}
_;
}
modifier noEditingReactions(uint8 commentType) {
if (commentType == Comments.COMMENT_TYPE_REACTION) {
revert ReactionCannotBeEdited();
}
_;
}
modifier validateNonce(address author, address app, uint256 nonce) {
Approvals.validateNonce(author, app, nonce, nonces);
_;
}
modifier onlyAuthor(address author) {
require(msg.sender == author, "Not comment author");
_;
}
modifier reactionHasTargetOrParent(
uint8 commentType,
bytes32 parentId,
string memory targetUri
) {
if (commentType == Comments.COMMENT_TYPE_REACTION) {
bool hasParent = parentId != bytes32(0);
bool hasTarget = bytes(targetUri).length > 0;
if (!hasParent && !hasTarget) {
revert InvalidReactionReference(
"Reactions must have either a parentId or targetUri"
);
}
}
_;
}
// ============ BATCH OPERATIONS ============
/// @inheritdoc ICommentManager
function batchOperations(
Comments.BatchOperation[] calldata operations
) external payable nonReentrant returns (bytes[] memory results) {
// Validate batch operations
Batching.validateBatchOperations(operations, msg.value);
results = new bytes[](operations.length);
// Execute operations in order
for (uint i = 0; i < operations.length; i++) {
Batching.validateBatchOperationSignatures(operations[i], i);
results[i] = _executeBatchOperation(operations[i], i);
}
emit BatchOperationExecuted(msg.sender, operations.length, msg.value);
return results;
}
/// @notice Internal function to execute a single batch operation
/// @param operation The batch operation to execute
/// @param operationIndex The index of the operation for error reporting
/// @return result The result of the operation
function _executeBatchOperation(
Comments.BatchOperation calldata operation,
uint256 operationIndex
) internal returns (bytes memory result) {
if (operation.operationType == Comments.BatchOperationType.POST_COMMENT) {
return _executePostCommentBatch(operation);
} else if (
operation.operationType ==
Comments.BatchOperationType.POST_COMMENT_WITH_SIG
) {
return _executePostCommentWithSigBatch(operation);
} else if (
operation.operationType == Comments.BatchOperationType.EDIT_COMMENT
) {
return _executeEditCommentBatch(operation);
} else if (
operation.operationType ==
Comments.BatchOperationType.EDIT_COMMENT_WITH_SIG
) {
return _executeEditCommentWithSigBatch(operation);
} else if (
operation.operationType == Comments.BatchOperationType.DELETE_COMMENT
) {
return _executeDeleteCommentBatch(operation);
} else if (
operation.operationType ==
Comments.BatchOperationType.DELETE_COMMENT_WITH_SIG
) {
return _executeDeleteCommentWithSigBatch(operation);
} else {
revert InvalidBatchOperation(operationIndex, "Invalid operation type");
}
}
function _executePostCommentBatch(
Comments.BatchOperation calldata operation
) internal returns (bytes memory) {
Comments.CreateComment memory commentData = Batching.decodePostCommentData(
operation
);
// Call internal postComment function with allocated value
bytes32 commentId = _postComment(
commentData,
operation.signatures[0], // app signature
operation.value
);
return Batching.encodeCommentIdResult(commentId);
}
function _executePostCommentWithSigBatch(
Comments.BatchOperation calldata operation
) internal returns (bytes memory) {
Comments.CreateComment memory commentData = Batching.decodePostCommentData(
operation
);
// Call postCommentWithSig function directly
bytes32 commentId = _postCommentWithSig(
commentData,
operation.signatures[0], // author signature
operation.signatures[1], // app signature
operation.value
);
return Batching.encodeCommentIdResult(commentId);
}
function _executeEditCommentBatch(
Comments.BatchOperation calldata operation
) internal returns (bytes memory) {
(bytes32 commentId, Comments.EditComment memory editData) = Batching
.decodeEditCommentData(operation);
// Call internal editComment function with allocated value
_editCommentDirect(
commentId,
editData,
operation.signatures[0], // app signature
operation.value
);
return "";
}
function _executeEditCommentWithSigBatch(
Comments.BatchOperation calldata operation
) internal returns (bytes memory) {
(bytes32 commentId, Comments.EditComment memory editData) = Batching
.decodeEditCommentData(operation);
// Call editCommentWithSig internal function with allocated value
_editCommentWithSig(
commentId,
editData,
operation.signatures[0], // author signature
operation.signatures[1], // app signature
operation.value
);
return "";
}
function _executeDeleteCommentBatch(
Comments.BatchOperation calldata operation
) internal returns (bytes memory) {
bytes32 commentId = Batching.decodeDeleteCommentData(operation);
// Call deleteComment function directly (preserves msg.sender)
_deleteComment(commentId, msg.sender);
return "";
}
function _executeDeleteCommentWithSigBatch(
Comments.BatchOperation calldata operation
) internal returns (bytes memory) {
Comments.BatchDeleteData memory deleteData = Batching
.decodeDeleteCommentWithSigData(operation);
// Call deleteCommentWithSig function directly
_deleteCommentWithSig(
deleteData.commentId,
deleteData.app,
deleteData.deadline,
operation.signatures[0], // author signature
operation.signatures[1] // app signature
);
return "";
}
}// 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();
_;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/// @notice Reentrancy guard mixin.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/ReentrancyGuard.sol)
abstract contract ReentrancyGuard {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CUSTOM ERRORS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Unauthorized reentrant call.
error Reentrancy();
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* STORAGE */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Equivalent to: `uint72(bytes9(keccak256("_REENTRANCY_GUARD_SLOT")))`.
/// 9 bytes is large enough to avoid collisions with lower slots,
/// but not too large to result in excessive bytecode bloat.
uint256 private constant _REENTRANCY_GUARD_SLOT = 0x929eee149b4bd21268;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* REENTRANCY GUARD */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Guards a function from reentrancy.
modifier nonReentrant() virtual {
/// @solidity memory-safe-assembly
assembly {
if eq(sload(_REENTRANCY_GUARD_SLOT), address()) {
mstore(0x00, 0xab143c06) // `Reentrancy()`.
revert(0x1c, 0x04)
}
sstore(_REENTRANCY_GUARD_SLOT, address())
}
_;
/// @solidity memory-safe-assembly
assembly {
sstore(_REENTRANCY_GUARD_SLOT, codesize())
}
}
/// @dev Guards a view function from read-only reentrancy.
modifier nonReadReentrant() virtual {
/// @solidity memory-safe-assembly
assembly {
if eq(sload(_REENTRANCY_GUARD_SLOT), address()) {
mstore(0x00, 0xab143c06) // `Reentrancy()`.
revert(0x1c, 0x04)
}
}
_;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./Metadata.sol";
/// @title Comments - Type definitions for comment-related structs and enums
library Comments {
/// @notice Comment type constants
/// @dev Type 0: Standard comment
/// @dev Type 1: Reaction (with reaction type in content field, e.g. "like", "dislike", "heart")
/// more types can be added in the future, please check the docs for more information.
uint8 public constant COMMENT_TYPE_COMMENT = 0;
uint8 public constant COMMENT_TYPE_REACTION = 1;
/// @notice Author Authentication method used to create the comment
/// @dev DIRECT_TX: User signed transaction directly (msg.sender == author).
/// @dev APP_APPROVAL: User has pre-approved the app that signed the comment (approvals[author][app] == true)
/// @dev AUTHOR_SIGNATURE: User signed the comment hash, the app submitted the comment on their behalf (gas-sponsored)
enum AuthorAuthMethod {
DIRECT_TX, // 0
APP_APPROVAL, // 1
AUTHOR_SIGNATURE // 2
}
/// @notice Struct containing all comment data
/// @param author The address of the comment author
/// @param createdAt The timestamp when the comment was created
/// @param app The address of the application signer that authorized this comment
/// @param updatedAt The timestamp when the comment was last updated
/// @param commentType The type of the comment (0=comment, 1=reaction)
/// @param authMethod The authentication method used to create this comment
/// @param channelId The channel ID associated with the comment
/// @param parentId The ID of the parent comment if this is a reply, otherwise bytes32(0)
/// @param content The text content of the comment - may contain urls, images and mentions
/// @param targetUri the URI about which the comment is being made
struct Comment {
// Pack these fields together (saves 1 storage slot)
address author; // 20 bytes --┬-- 32 bytes
uint88 createdAt; // 11 bytes --┘
AuthorAuthMethod authMethod; // 1 byte --┘
address app; // 20 bytes --┬-- 32 bytes
uint88 updatedAt; // 11 bytes --┘
uint8 commentType; // 1 byte --┘
// 32-byte types
uint256 channelId;
bytes32 parentId;
// Dynamic types last (conventional pattern)
string content;
string targetUri;
}
/// @notice Struct containing all comment data for creating a comment
/// @param author The address of the comment author
/// @param app The address of the application signer that authorized this comment
/// @param channelId The channel ID associated with the comment
/// @param deadline Timestamp after which the signatures for this comment become invalid
/// @param parentId The ID of the parent comment if this is a reply, otherwise bytes32(0)
/// @param content The actual text content of the comment. If the commentType is COMMENT_TYPE_REACTION, the content should be the reaction type, such as "like", "downvote", "repost" etc.
/// @param metadata Array of key-value pairs for additional data
/// @param targetUri the URI about which the comment is being made
/// @param commentType The type of the comment (0=comment, 1=reaction)
struct CreateComment {
address author;
address app;
uint256 channelId;
uint256 deadline;
bytes32 parentId;
uint8 commentType;
// Dynamic types last (conventional pattern)
string content;
Metadata.MetadataEntry[] metadata;
string targetUri;
}
/// @notice Struct containing all comment data for editing a comment
/// @param app The address of the application signer that authorized this comment
/// @param nonce The nonce for the comment
/// @param deadline Timestamp after which the signatures for this comment become invalid
/// @param content The actual text content of the comment
/// @param metadata Array of key-value pairs for additional data
struct EditComment {
address app;
uint256 nonce;
uint256 deadline;
string content;
Metadata.MetadataEntry[] metadata;
}
// Batch operation structures
/// @notice Enum for different operation types in batch calls
enum BatchOperationType {
POST_COMMENT, // 0
POST_COMMENT_WITH_SIG, // 1
EDIT_COMMENT, // 2
EDIT_COMMENT_WITH_SIG, // 3
DELETE_COMMENT, // 4
DELETE_COMMENT_WITH_SIG // 5
}
/// @notice Struct for batch delete operation data
/// @param commentId The unique identifier of the comment to delete
/// @param app The address of the app signer (only for deleteCommentWithSig)
/// @param deadline Timestamp after which the signature becomes invalid (only for deleteCommentWithSig)
struct BatchDeleteData {
bytes32 commentId;
address app;
uint256 deadline;
}
/// @notice Struct containing a single batch operation
/// @param operationType The type of operation to perform
/// @param value The amount of ETH to send with this operation
/// @param data Encoded operation-specific data
/// @param signatures Array of signatures required for this operation
struct BatchOperation {
BatchOperationType operationType;
uint256 value;
bytes data;
bytes[] signatures;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./Metadata.sol";
import "./Hooks.sol";
/// @title Channels - Type definitions for channel-related structs
library Channels {
/// @notice Struct containing channel configuration
/// @param name The name of the channel
/// @param description The description of the channel
/// @param hook The hook of the channel. Hook must implement IHook interface.
/// @param permissions The hook permissions of the channel
struct Channel {
string name;
string description;
address hook;
Hooks.Permissions permissions;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/// @title Metadata - Type definitions for metadata-related structs and enums
library Metadata {
/// @notice Struct containing metadata key-value pair
/// @param key UTF-8 encoded string of format "type key". Must fit in 32 bytes.
/// @param value The metadata value as bytes
struct MetadataEntry {
bytes32 key;
bytes value;
}
/// @notice Enum for metadata operations in hook updates
enum MetadataOperation {
SET, // Set or update the metadata value
DELETE // Delete the metadata key
}
/// @notice Struct for hook metadata operations with explicit operation type
/// @param operation The operation to perform (SET or DELETE)
/// @param key The metadata key
/// @param value The metadata value (ignored for DELETE operations)
struct MetadataEntryOp {
MetadataOperation operation;
bytes32 key;
bytes value;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "solady/src/utils/SignatureCheckerLib.sol";
import "../types/Comments.sol";
import "../types/Metadata.sol";
/// @title CommentSigning - Library for comment signing operations
/// @notice Handles EIP-712 signing, hash generation, and signature verification for comments
library CommentSigning {
// EIP-712 Type Hashes
bytes32 public constant ADD_COMMENT_TYPEHASH =
keccak256(
"AddComment(string content,MetadataEntry[] metadata,string targetUri,uint8 commentType,address author,address app,uint256 channelId,uint256 deadline,bytes32 parentId)MetadataEntry(bytes32 key,bytes value)"
);
bytes32 public constant DELETE_COMMENT_TYPEHASH =
keccak256(
"DeleteComment(bytes32 commentId,address author,address app,uint256 deadline)"
);
bytes32 public constant EDIT_COMMENT_TYPEHASH =
keccak256(
"EditComment(bytes32 commentId,string content,MetadataEntry[] metadata,address author,address app,uint256 nonce,uint256 deadline)MetadataEntry(bytes32 key,bytes value)"
);
bytes32 public constant ADD_APPROVAL_TYPEHASH =
keccak256(
"AddApproval(address author,address app,uint256 expiry,uint256 nonce,uint256 deadline)"
);
bytes32 public constant REMOVE_APPROVAL_TYPEHASH =
keccak256(
"RemoveApproval(address author,address app,uint256 nonce,uint256 deadline)"
);
/// @notice Generate EIP-712 domain separator
/// @param name The name of the signing domain
/// @param version The version of the signing domain
/// @param chainId The chain ID
/// @param verifyingContract The address of the contract that will verify signatures
/// @return The domain separator hash
function generateDomainSeparator(
string memory name,
string memory version,
uint256 chainId,
address verifyingContract
) internal pure returns (bytes32) {
return
keccak256(
abi.encode(
keccak256(
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
),
keccak256(bytes(name)),
keccak256(bytes(version)),
chainId,
verifyingContract
)
);
}
/// @notice Hash metadata array for EIP-712
/// @param metadata The metadata array to hash
/// @return The hash of the metadata array
function hashMetadataArray(
Metadata.MetadataEntry[] memory metadata
) internal pure returns (bytes32) {
bytes32[] memory hashedEntries = new bytes32[](metadata.length);
for (uint i = 0; i < metadata.length; i++) {
hashedEntries[i] = keccak256(
abi.encode(
keccak256("MetadataEntry(bytes32 key,bytes value)"),
metadata[i].key,
keccak256(metadata[i].value)
)
);
}
return keccak256(abi.encodePacked(hashedEntries));
}
/// @notice Generate comment ID hash
/// @param commentData The comment data to hash
/// @param domainSeparator The EIP-712 domain separator
/// @return The c∑omment ID hash
function getCommentId(
Comments.CreateComment memory commentData,
bytes32 domainSeparator
) internal pure returns (bytes32) {
bytes32 structHash = keccak256(
abi.encode(
ADD_COMMENT_TYPEHASH,
keccak256(bytes(commentData.content)),
hashMetadataArray(commentData.metadata),
keccak256(bytes(commentData.targetUri)),
commentData.commentType,
commentData.author,
commentData.app,
commentData.channelId,
commentData.deadline,
commentData.parentId
)
);
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
/// @notice Generate edit comment hash
/// @param commentId The unique identifier of the comment to edit
/// @param author The address of the comment author
/// @param editData The comment data struct containing content and metadata
/// @param domainSeparator The EIP-712 domain separator
/// @return The edit comment hash
function getEditCommentHash(
bytes32 commentId,
address author,
Comments.EditComment memory editData,
bytes32 domainSeparator
) internal pure returns (bytes32) {
bytes32 structHash = keccak256(
abi.encode(
EDIT_COMMENT_TYPEHASH,
commentId,
keccak256(bytes(editData.content)),
hashMetadataArray(editData.metadata),
author,
editData.app,
editData.nonce,
editData.deadline
)
);
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
/// @notice Generate delete comment hash
/// @param commentId The unique identifier of the comment to delete
/// @param author The address of the comment author
/// @param app The app address
/// @param deadline The signature deadline
/// @param domainSeparator The EIP-712 domain separator
/// @return The delete comment hash
function getDeleteCommentHash(
bytes32 commentId,
address author,
address app,
uint256 deadline,
bytes32 domainSeparator
) internal pure returns (bytes32) {
bytes32 structHash = keccak256(
abi.encode(DELETE_COMMENT_TYPEHASH, commentId, author, app, deadline)
);
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
/// @notice Generate add approval hash
/// @param author The address granting approval
/// @param app The address being approved
/// @param expiry The timestamp when the approval expires
/// @param nonce The nonce for replay protection
/// @param deadline The signature deadline
/// @param domainSeparator The EIP-712 domain separator
/// @return The add approval hash
function getAddApprovalHash(
address author,
address app,
uint256 expiry,
uint256 nonce,
uint256 deadline,
bytes32 domainSeparator
) internal pure returns (bytes32) {
bytes32 structHash = keccak256(
abi.encode(ADD_APPROVAL_TYPEHASH, author, app, expiry, nonce, deadline)
);
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
/// @notice Generate remove approval hash
/// @param author The address removing approval
/// @param app The address being unapproved
/// @param nonce The nonce for replay protection
/// @param deadline The signature deadline
/// @param domainSeparator The EIP-712 domain separator
/// @return The remove approval hash
function getRemoveApprovalHash(
address author,
address app,
uint256 nonce,
uint256 deadline,
bytes32 domainSeparator
) internal pure returns (bytes32) {
bytes32 structHash = keccak256(
abi.encode(REMOVE_APPROVAL_TYPEHASH, author, app, nonce, deadline)
);
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
/// @notice Verify app signature for comment operations
/// @param app The app address
/// @param hash The hash to verify
/// @param signature The signature to verify
/// @param msgSender The message sender
/// @return True if signature is valid or if msgSender is the app
function verifyAppSignature(
address app,
bytes32 hash,
bytes memory signature,
address msgSender
) internal view returns (bool) {
return
msgSender == app ||
SignatureCheckerLib.isValidSignatureNow(app, hash, signature);
}
/// @notice Verify author signature
/// @param author The author address
/// @param hash The hash to verify
/// @param signature The signature to verify
/// @return True if signature is valid
function verifyAuthorSignature(
address author,
bytes32 hash,
bytes memory signature
) internal view returns (bool) {
return SignatureCheckerLib.isValidSignatureNow(author, hash, signature);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "../types/Comments.sol";
import "../types/Metadata.sol";
import "../interfaces/ICommentManager.sol";
/// @title Batching - Library for handling batch comment operations
library Batching {
/// @notice Validate batch operations structure and value distribution
/// @param operations Array of batch operations to validate
/// @param msgValue The total value sent with the transaction
/// @return totalRequiredValue The total value required for all operations
function validateBatchOperations(
Comments.BatchOperation[] calldata operations,
uint256 msgValue
) external pure returns (uint256 totalRequiredValue) {
if (operations.length == 0) {
revert ICommentManager.InvalidBatchOperation(0, "Empty operations array");
}
// Validate total value distribution
totalRequiredValue = 0;
for (uint i = 0; i < operations.length; i++) {
totalRequiredValue += operations[i].value;
}
if (msgValue != totalRequiredValue) {
revert ICommentManager.InvalidValueDistribution(
msgValue,
totalRequiredValue
);
}
return totalRequiredValue;
}
/// @notice Validate a single batch operation's signature requirements
/// @param operation The batch operation to validate
/// @param operationIndex The index of the operation for error reporting
function validateBatchOperationSignatures(
Comments.BatchOperation calldata operation,
uint256 operationIndex
) external pure {
if (operation.operationType == Comments.BatchOperationType.POST_COMMENT) {
if (operation.signatures.length != 1) {
revert ICommentManager.InvalidBatchOperation(
operationIndex,
"POST_COMMENT requires exactly 1 signature"
);
}
} else if (
operation.operationType ==
Comments.BatchOperationType.POST_COMMENT_WITH_SIG
) {
if (operation.signatures.length != 2) {
revert ICommentManager.InvalidBatchOperation(
operationIndex,
"POST_COMMENT_WITH_SIG requires exactly 2 signatures"
);
}
} else if (
operation.operationType == Comments.BatchOperationType.EDIT_COMMENT
) {
if (operation.signatures.length != 1) {
revert ICommentManager.InvalidBatchOperation(
operationIndex,
"EDIT_COMMENT requires exactly 1 signature"
);
}
} else if (
operation.operationType ==
Comments.BatchOperationType.EDIT_COMMENT_WITH_SIG
) {
if (operation.signatures.length != 2) {
revert ICommentManager.InvalidBatchOperation(
operationIndex,
"EDIT_COMMENT_WITH_SIG requires exactly 2 signatures"
);
}
} else if (
operation.operationType == Comments.BatchOperationType.DELETE_COMMENT
) {
if (operation.signatures.length != 0) {
revert ICommentManager.InvalidBatchOperation(
operationIndex,
"DELETE_COMMENT requires no signatures"
);
}
} else if (
operation.operationType ==
Comments.BatchOperationType.DELETE_COMMENT_WITH_SIG
) {
if (operation.signatures.length != 2) {
revert ICommentManager.InvalidBatchOperation(
operationIndex,
"DELETE_COMMENT_WITH_SIG requires exactly 2 signatures"
);
}
} else {
revert ICommentManager.InvalidBatchOperation(
operationIndex,
"Invalid operation type"
);
}
}
/// @notice Decode batch operation data for POST_COMMENT and POST_COMMENT_WITH_SIG
/// @param operation The batch operation
/// @return commentData The decoded comment data
function decodePostCommentData(
Comments.BatchOperation calldata operation
) external pure returns (Comments.CreateComment memory commentData) {
commentData = abi.decode(operation.data, (Comments.CreateComment));
return commentData;
}
/// @notice Decode batch operation data for EDIT_COMMENT and EDIT_COMMENT_WITH_SIG
/// @param operation The batch operation
/// @return commentId The comment ID to edit
/// @return editData The decoded edit data
function decodeEditCommentData(
Comments.BatchOperation calldata operation
)
external
pure
returns (bytes32 commentId, Comments.EditComment memory editData)
{
(commentId, editData) = abi.decode(
operation.data,
(bytes32, Comments.EditComment)
);
return (commentId, editData);
}
/// @notice Decode batch operation data for DELETE_COMMENT
/// @param operation The batch operation
/// @return commentId The comment ID to delete
function decodeDeleteCommentData(
Comments.BatchOperation calldata operation
) external pure returns (bytes32 commentId) {
commentId = abi.decode(operation.data, (bytes32));
return commentId;
}
/// @notice Decode batch operation data for DELETE_COMMENT_WITH_SIG
/// @param operation The batch operation
/// @return deleteData The decoded delete data
function decodeDeleteCommentWithSigData(
Comments.BatchOperation calldata operation
) external pure returns (Comments.BatchDeleteData memory deleteData) {
deleteData = abi.decode(operation.data, (Comments.BatchDeleteData));
return deleteData;
}
/// @notice Encode a comment ID as result data
/// @param commentId The comment ID to encode
/// @return result The encoded result
function encodeCommentIdResult(
bytes32 commentId
) external pure returns (bytes memory result) {
return abi.encode(commentId);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "../interfaces/ICommentManager.sol";
/// @title Approvals - Library for handling approval management
library Approvals {
/// @notice Event emitted when an author approves an app signer
event ApprovalAdded(
address indexed author,
address indexed app,
uint256 expiry
);
/// @notice Event emitted when an author removes an app signer's approval
event ApprovalRemoved(address indexed author, address indexed app);
/// @notice Add an app signer approval
/// @param author The address granting approval
/// @param app The address being approved
/// @param expiry The timestamp when the approval expires
/// @param approvals Storage mapping for approvals
function addApproval(
address author,
address app,
uint256 expiry,
mapping(address => mapping(address => uint256)) storage approvals
) external {
if (expiry <= block.timestamp)
revert ICommentManager.InvalidApprovalExpiry();
approvals[author][app] = expiry;
emit ApprovalAdded(author, app, expiry);
}
/// @notice Remove an app signer approval
/// @param author The address removing approval
/// @param app The address being unapproved
/// @param approvals Storage mapping for approvals
function revokeApproval(
address author,
address app,
mapping(address => mapping(address => uint256)) storage approvals
) external {
approvals[author][app] = 0;
emit ApprovalRemoved(author, app);
}
/// @notice Check if an app is approved for an author
/// @param author The address of the author
/// @param app The address of the app
/// @param approvals Storage mapping for approvals
/// @return approved Whether the app is approved
function isApproved(
address author,
address app,
mapping(address => mapping(address => uint256)) storage approvals
) external view returns (bool approved) {
return approvals[author][app] > block.timestamp;
}
/// @notice Get approval expiry timestamp
/// @param author The address of the author
/// @param app The address of the app
/// @param approvals Storage mapping for approvals
/// @return expiry The approval expiry timestamp
function getApprovalExpiry(
address author,
address app,
mapping(address => mapping(address => uint256)) storage approvals
) external view returns (uint256 expiry) {
return approvals[author][app];
}
/// @notice Get nonce for author-app pair
/// @param author The address of the author
/// @param app The address of the app
/// @param nonces Storage mapping for nonces
/// @return nonce The current nonce
function getNonce(
address author,
address app,
mapping(address => mapping(address => uint256)) storage nonces
) external view returns (uint256 nonce) {
return nonces[author][app];
}
/// @notice Increment nonce for author-app pair
/// @param author The address of the author
/// @param app The address of the app
/// @param nonces Storage mapping for nonces
function incrementNonce(
address author,
address app,
mapping(address => mapping(address => uint256)) storage nonces
) external {
nonces[author][app]++;
}
/// @notice Validate nonce for author-app pair
/// @param author The address of the author
/// @param app The address of the app
/// @param expectedNonce The expected nonce value
/// @param nonces Storage mapping for nonces
function validateNonce(
address author,
address app,
uint256 expectedNonce,
mapping(address => mapping(address => uint256)) storage nonces
) external view {
if (nonces[author][app] != expectedNonce) {
revert ICommentManager.InvalidNonce(
author,
app,
nonces[author][app],
expectedNonce
);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "../types/Metadata.sol";
import "../types/Comments.sol";
import "../types/Channels.sol";
import "../interfaces/IHook.sol";
import "../interfaces/IChannelManager.sol";
import "../interfaces/ICommentManager.sol";
import "./MetadataOps.sol";
/// @title CommentOps - Library for comment-related operations
library CommentOps {
/// @notice Create a new comment
/// @param commentId The unique identifier for the comment
/// @param commentData The comment creation data
/// @param authMethod The authentication method used
/// @param value The ETH value sent with the transaction
/// @param commentCreationFee The protocol fee for comment creation
/// @param channelManager The channel manager contract
/// @param comments Storage mapping for comments
/// @param commentMetadata Storage mapping for comment metadata
/// @param commentMetadataKeys Storage mapping for comment metadata keys
/// @param commentHookMetadata Storage mapping for comment hook metadata
/// @param commentHookMetadataKeys Storage mapping for comment hook metadata keys
/// @param msgSender The sender of the transaction
function createComment(
bytes32 commentId,
Comments.CreateComment memory commentData,
Comments.AuthorAuthMethod authMethod,
uint256 value,
uint96 commentCreationFee,
IChannelManager channelManager,
mapping(bytes32 => Comments.Comment) storage comments,
mapping(bytes32 => mapping(bytes32 => bytes)) storage commentMetadata,
mapping(bytes32 => bytes32[]) storage commentMetadataKeys,
mapping(bytes32 => mapping(bytes32 => bytes)) storage commentHookMetadata,
mapping(bytes32 => bytes32[]) storage commentHookMetadataKeys,
address msgSender
) external {
uint256 remainingValue = value - commentCreationFee;
address author = commentData.author;
address app = commentData.app;
uint256 channelId = commentData.channelId;
bytes32 parentId = commentData.parentId;
string memory content = commentData.content;
Metadata.MetadataEntry[] memory metadata = commentData.metadata;
string memory targetUri = commentData.targetUri;
uint8 commentType = commentData.commentType;
uint88 timestampNow = uint88(block.timestamp);
Comments.Comment storage comment = comments[commentId];
comment.author = author;
comment.app = app;
comment.channelId = channelId;
comment.parentId = parentId;
comment.content = content;
comment.targetUri = targetUri;
comment.commentType = commentType;
comment.authMethod = authMethod;
comment.createdAt = timestampNow;
comment.updatedAt = timestampNow;
// emit event before calling the `onCommentAdd` hook to ensure the order of events is correct in the case of reentrancy
emit ICommentManager.CommentAdded(
commentId,
author,
app,
channelId,
parentId,
uint96(timestampNow),
content,
targetUri,
commentType,
uint8(comment.authMethod),
metadata
);
// Store metadata in mappings
if (metadata.length > 0) {
if (metadata.length > 1000) {
revert ICommentManager.MetadataTooLong();
}
MetadataOps.storeCommentMetadata(
commentId,
metadata,
commentMetadata,
commentMetadataKeys
);
}
Channels.Channel memory channel = channelManager.getChannel(channelId);
if (channel.hook != address(0) && channel.permissions.onCommentAdd) {
IHook hook = IHook(channel.hook);
// Calculate hook value after protocol fee
uint256 valueToPassToTheHook = channelManager
.deductProtocolHookTransactionFee(remainingValue);
if (remainingValue > valueToPassToTheHook) {
// send the hook transaction fee to the channel manager
payable(address(channelManager)).transfer(
remainingValue - valueToPassToTheHook
);
}
Metadata.MetadataEntry[] memory hookMetadata = hook.onCommentAdd{
value: valueToPassToTheHook
}(comment, metadata, msgSender, commentId);
// Store hook metadata
if (
hookMetadata.length > 0 &&
// don't store hook metadata if the hook re-entered to delete the comment
comments[commentId].author != address(0)
) {
if (hookMetadata.length > 1000) {
revert ICommentManager.HookMetadataTooLong();
}
MetadataOps.storeCommentHookMetadata(
commentId,
hookMetadata,
commentHookMetadata,
commentHookMetadataKeys
);
}
}
// refund excess payment if any
else if (remainingValue > 0) {
payable(msgSender).transfer(remainingValue);
}
}
/// @notice Edit an existing comment
/// @param commentId The unique identifier of the comment to edit
/// @param editData The comment edit data
/// @param authMethod The authentication method used
/// @param value The ETH value sent with the transaction
/// @param channelManager The channel manager contract
/// @param comments Storage mapping for comments
/// @param commentMetadata Storage mapping for comment metadata
/// @param commentMetadataKeys Storage mapping for comment metadata keys
/// @param commentHookMetadata Storage mapping for comment hook metadata
/// @param commentHookMetadataKeys Storage mapping for comment hook metadata keys
/// @param msgSender The sender of the transaction
function editComment(
bytes32 commentId,
Comments.EditComment memory editData,
Comments.AuthorAuthMethod authMethod,
uint256 value,
IChannelManager channelManager,
mapping(bytes32 => Comments.Comment) storage comments,
mapping(bytes32 => mapping(bytes32 => bytes)) storage commentMetadata,
mapping(bytes32 => bytes32[]) storage commentMetadataKeys,
mapping(bytes32 => mapping(bytes32 => bytes)) storage commentHookMetadata,
mapping(bytes32 => bytes32[]) storage commentHookMetadataKeys,
address msgSender
) external {
Comments.Comment storage comment = comments[commentId];
string memory content = editData.content;
Metadata.MetadataEntry[] memory metadata = editData.metadata;
uint88 timestampNow = uint88(block.timestamp);
comment.content = content;
comment.updatedAt = timestampNow;
comment.authMethod = authMethod;
// Clear existing metadata
MetadataOps.clearCommentMetadata(
commentId,
commentMetadata,
commentMetadataKeys
);
// Store metadata in mappings
if (metadata.length > 0) {
if (metadata.length > 1000) {
revert ICommentManager.MetadataTooLong();
}
MetadataOps.storeCommentMetadata(
commentId,
metadata,
commentMetadata,
commentMetadataKeys
);
}
Channels.Channel memory channel = channelManager.getChannel(
comment.channelId
);
// emit event before calling the `onCommentEdit` hook to ensure the order of events is correct in the case of reentrancy
emit ICommentManager.CommentEdited(
commentId,
comment.author,
editData.app,
comment.channelId,
comment.parentId,
uint96(comment.createdAt),
uint96(timestampNow),
content,
comment.targetUri,
comment.commentType,
uint8(comment.authMethod),
metadata
);
if (channel.hook != address(0) && channel.permissions.onCommentEdit) {
IHook hook = IHook(channel.hook);
// Calculate hook value after protocol fee
uint256 valueToPassToHook = channelManager
.deductProtocolHookTransactionFee(value);
if (value > valueToPassToHook) {
payable(address(channelManager)).transfer(value - valueToPassToHook);
}
Metadata.MetadataEntry[] memory hookMetadata = hook.onCommentEdit{
value: valueToPassToHook
}(comment, metadata, msgSender, commentId);
// Clear existing hook metadata
MetadataOps.clearCommentHookMetadata(
commentId,
commentHookMetadata,
commentHookMetadataKeys
);
// Store hook metadata
if (
hookMetadata.length > 0 &&
// don't store hook metadata if the hook re-entered to delete the comment
comments[commentId].author != address(0)
) {
if (hookMetadata.length > 1000) {
revert ICommentManager.HookMetadataTooLong();
}
MetadataOps.storeCommentHookMetadata(
commentId,
hookMetadata,
commentHookMetadata,
commentHookMetadataKeys
);
}
} else if (value > 0) {
// refund excess payment if any
payable(msgSender).transfer(value);
}
}
/// @notice Delete a comment
/// @param commentId The unique identifier of the comment to delete
/// @param author The address of the comment author
/// @param channelManager The channel manager contract
/// @param comments Storage mapping for comments
/// @param deleted Storage mapping for deleted comments
/// @param commentMetadata Storage mapping for comment metadata
/// @param commentMetadataKeys Storage mapping for comment metadata keys
/// @param commentHookMetadata Storage mapping for comment hook metadata
/// @param commentHookMetadataKeys Storage mapping for comment hook metadata keys
/// @param msgSender The sender of the transaction
function deleteComment(
bytes32 commentId,
address author,
IChannelManager channelManager,
mapping(bytes32 => Comments.Comment) storage comments,
mapping(bytes32 => bool) storage deleted,
mapping(bytes32 => mapping(bytes32 => bytes)) storage commentMetadata,
mapping(bytes32 => bytes32[]) storage commentMetadataKeys,
mapping(bytes32 => mapping(bytes32 => bytes)) storage commentHookMetadata,
mapping(bytes32 => bytes32[]) storage commentHookMetadataKeys,
address msgSender
) external {
Comments.Comment storage comment = comments[commentId];
// Store comment data for hook
Comments.Comment memory commentToDelete = comment;
// Get metadata for hook
Metadata.MetadataEntry[] memory metadata = MetadataOps.getCommentMetadata(
commentId,
commentMetadata,
commentMetadataKeys
);
Metadata.MetadataEntry[] memory hookMetadata = MetadataOps
.getCommentHookMetadata(
commentId,
commentHookMetadata,
commentHookMetadataKeys
);
// Delete the comment and metadata
delete comments[commentId];
deleted[commentId] = true;
MetadataOps.clearCommentMetadata(
commentId,
commentMetadata,
commentMetadataKeys
);
MetadataOps.clearCommentHookMetadata(
commentId,
commentHookMetadata,
commentHookMetadataKeys
);
Channels.Channel memory channel = channelManager.getChannel(
commentToDelete.channelId
);
// emit event before calling the `onCommentDelete` hook to ensure the order of events is correct in the case of reentrancy
emit ICommentManager.CommentDeleted(commentId, author);
if (channel.hook != address(0) && channel.permissions.onCommentDelete) {
IHook hook = IHook(channel.hook);
hook.onCommentDelete(
commentToDelete,
metadata,
hookMetadata,
msgSender,
commentId
);
}
}
/// @notice Update hook metadata for a comment
/// @param commentId The unique identifier of the comment
/// @param channelManager The channel manager contract
/// @param comments Storage mapping for comments
/// @param commentMetadata Storage mapping for comment metadata
/// @param commentMetadataKeys Storage mapping for comment metadata keys
/// @param commentHookMetadata Storage mapping for comment hook metadata
/// @param commentHookMetadataKeys Storage mapping for comment hook metadata keys
/// @param msgSender The sender of the transaction
function updateCommentHookData(
bytes32 commentId,
IChannelManager channelManager,
mapping(bytes32 => Comments.Comment) storage comments,
mapping(bytes32 => mapping(bytes32 => bytes)) storage commentMetadata,
mapping(bytes32 => bytes32[]) storage commentMetadataKeys,
mapping(bytes32 => mapping(bytes32 => bytes)) storage commentHookMetadata,
mapping(bytes32 => bytes32[]) storage commentHookMetadataKeys,
address msgSender
) external {
Comments.Comment storage comment = comments[commentId];
Channels.Channel memory channel = channelManager.getChannel(
comment.channelId
);
if (
channel.hook == address(0) || !channel.permissions.onCommentHookDataUpdate
) {
revert ICommentManager.HookNotEnabled();
}
// Get current metadata for hook
Metadata.MetadataEntry[] memory metadata = MetadataOps.getCommentMetadata(
commentId,
commentMetadata,
commentMetadataKeys
);
Metadata.MetadataEntry[] memory hookMetadata = MetadataOps
.getCommentHookMetadata(
commentId,
commentHookMetadata,
commentHookMetadataKeys
);
IHook hook = IHook(channel.hook);
Metadata.MetadataEntryOp[] memory operations = hook.onCommentHookDataUpdate(
comment,
metadata,
hookMetadata,
msgSender,
commentId
);
emit ICommentManager.CommentHookDataUpdate(commentId, operations);
if (operations.length > 1000) {
revert ICommentManager.HookMetadataTooLong();
}
// Apply hook metadata operations using merge mode (gas-efficient)
for (uint i = 0; i < operations.length; i++) {
Metadata.MetadataEntryOp memory op = operations[i];
if (op.operation == Metadata.MetadataOperation.DELETE) {
MetadataOps.deleteCommentHookMetadataKey(
commentId,
op.key,
commentHookMetadata,
commentHookMetadataKeys
);
emit ICommentManager.CommentHookMetadataSet(commentId, op.key, "");
} else if (op.operation == Metadata.MetadataOperation.SET) {
// Check if this is a new key for gas optimization
bool isNewKey = !MetadataOps.hookMetadataKeyExists(
commentId,
op.key,
commentHookMetadataKeys
);
commentHookMetadata[commentId][op.key] = op.value;
// Only add to keys array if it's a new key
if (isNewKey) {
commentHookMetadataKeys[commentId].push(op.key);
}
emit ICommentManager.CommentHookMetadataSet(
commentId,
op.key,
op.value
);
}
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "../interfaces/ICommentManager.sol";
import "../types/Metadata.sol";
/// @title MetadataOps - Library for metadata operations for comments and channels
library MetadataOps {
/// @notice Get metadata for a comment
/// @param commentId The unique identifier of the comment
/// @param commentMetadata Mapping of comment ID to metadata key to metadata value
/// @param commentMetadataKeys Mapping of comment ID to array of metadata keys
/// @return The metadata entries for the comment
function getCommentMetadata(
bytes32 commentId,
mapping(bytes32 => mapping(bytes32 => bytes)) storage commentMetadata,
mapping(bytes32 => bytes32[]) storage commentMetadataKeys
) external view returns (Metadata.MetadataEntry[] memory) {
bytes32[] memory keys = commentMetadataKeys[commentId];
Metadata.MetadataEntry[] memory metadata = new Metadata.MetadataEntry[](
keys.length
);
for (uint i = 0; i < keys.length; i++) {
metadata[i] = Metadata.MetadataEntry({
key: keys[i],
value: commentMetadata[commentId][keys[i]]
});
}
return metadata;
}
/// @notice Get hook metadata for a comment
/// @param commentId The unique identifier of the comment
/// @param commentHookMetadata Mapping of comment ID to hook metadata key to hook metadata value
/// @param commentHookMetadataKeys Mapping of comment ID to array of hook metadata keys
/// @return The hook metadata entries for the comment
function getCommentHookMetadata(
bytes32 commentId,
mapping(bytes32 => mapping(bytes32 => bytes)) storage commentHookMetadata,
mapping(bytes32 => bytes32[]) storage commentHookMetadataKeys
) external view returns (Metadata.MetadataEntry[] memory) {
bytes32[] memory keys = commentHookMetadataKeys[commentId];
Metadata.MetadataEntry[] memory hookMetadata = new Metadata.MetadataEntry[](
keys.length
);
for (uint i = 0; i < keys.length; i++) {
hookMetadata[i] = Metadata.MetadataEntry({
key: keys[i],
value: commentHookMetadata[commentId][keys[i]]
});
}
return hookMetadata;
}
/// @notice Clear all metadata for a comment
/// @param commentId The unique identifier of the comment
/// @param commentMetadata Mapping of comment ID to metadata key to metadata value
/// @param commentMetadataKeys Mapping of comment ID to array of metadata keys
function clearCommentMetadata(
bytes32 commentId,
mapping(bytes32 => mapping(bytes32 => bytes)) storage commentMetadata,
mapping(bytes32 => bytes32[]) storage commentMetadataKeys
) external {
bytes32[] storage keys = commentMetadataKeys[commentId];
for (uint i = 0; i < keys.length; i++) {
delete commentMetadata[commentId][keys[i]];
}
delete commentMetadataKeys[commentId];
}
/// @notice Clear all hook metadata for a comment
/// @param commentId The unique identifier of the comment
/// @param commentHookMetadata Mapping of comment ID to hook metadata key to hook metadata value
/// @param commentHookMetadataKeys Mapping of comment ID to array of hook metadata keys
function clearCommentHookMetadata(
bytes32 commentId,
mapping(bytes32 => mapping(bytes32 => bytes)) storage commentHookMetadata,
mapping(bytes32 => bytes32[]) storage commentHookMetadataKeys
) external {
bytes32[] storage keys = commentHookMetadataKeys[commentId];
for (uint i = 0; i < keys.length; i++) {
delete commentHookMetadata[commentId][keys[i]];
}
delete commentHookMetadataKeys[commentId];
}
/// @notice Apply hook metadata operations efficiently
/// @param commentId The unique identifier of the comment
/// @param operations The metadata operations to apply
/// @param commentHookMetadata Mapping of comment ID to hook metadata key to hook metadata value
/// @param commentHookMetadataKeys Mapping of comment ID to array of hook metadata keys
function applyHookMetadataOperations(
bytes32 commentId,
Metadata.MetadataEntryOp[] memory operations,
mapping(bytes32 => mapping(bytes32 => bytes)) storage commentHookMetadata,
mapping(bytes32 => bytes32[]) storage commentHookMetadataKeys
) external {
for (uint i = 0; i < operations.length; i++) {
Metadata.MetadataEntryOp memory op = operations[i];
if (op.operation == Metadata.MetadataOperation.DELETE) {
_deleteCommentHookMetadataKey(
commentId,
op.key,
commentHookMetadata,
commentHookMetadataKeys
);
} else if (op.operation == Metadata.MetadataOperation.SET) {
// Check if this is a new key for gas optimization
bool isNewKey = !_hookMetadataKeyExists(
commentId,
op.key,
commentHookMetadataKeys
);
commentHookMetadata[commentId][op.key] = op.value;
// Only add to keys array if it's a new key
if (isNewKey) {
commentHookMetadataKeys[commentId].push(op.key);
}
}
}
}
/// @notice Delete a specific hook metadata key
/// @param commentId The unique identifier of the comment
/// @param keyToDelete The key to delete
/// @param commentHookMetadata Mapping of comment ID to hook metadata key to hook metadata value
/// @param commentHookMetadataKeys Mapping of comment ID to array of hook metadata keys
function deleteCommentHookMetadataKey(
bytes32 commentId,
bytes32 keyToDelete,
mapping(bytes32 => mapping(bytes32 => bytes)) storage commentHookMetadata,
mapping(bytes32 => bytes32[]) storage commentHookMetadataKeys
) external {
_deleteCommentHookMetadataKey(
commentId,
keyToDelete,
commentHookMetadata,
commentHookMetadataKeys
);
}
/// @notice Internal function to delete a specific hook metadata key
/// @param commentId The unique identifier of the comment
/// @param keyToDelete The key to delete
/// @param commentHookMetadata Mapping of comment ID to hook metadata key to hook metadata value
/// @param commentHookMetadataKeys Mapping of comment ID to array of hook metadata keys
function _deleteCommentHookMetadataKey(
bytes32 commentId,
bytes32 keyToDelete,
mapping(bytes32 => mapping(bytes32 => bytes)) storage commentHookMetadata,
mapping(bytes32 => bytes32[]) storage commentHookMetadataKeys
) internal {
// Delete the value
delete commentHookMetadata[commentId][keyToDelete];
// Remove from keys array
bytes32[] storage keys = commentHookMetadataKeys[commentId];
for (uint i = 0; i < keys.length; i++) {
if (keys[i] == keyToDelete) {
// Move last element to current position and pop
keys[i] = keys[keys.length - 1];
keys.pop();
break;
}
}
}
/// @notice Check if a hook metadata key exists
/// @param commentId The unique identifier of the comment
/// @param targetKey The key to check for existence
/// @param commentHookMetadataKeys Mapping of comment ID to array of hook metadata keys
/// @return exists Whether the key exists in the metadata
function hookMetadataKeyExists(
bytes32 commentId,
bytes32 targetKey,
mapping(bytes32 => bytes32[]) storage commentHookMetadataKeys
) external view returns (bool exists) {
return
_hookMetadataKeyExists(commentId, targetKey, commentHookMetadataKeys);
}
/// @notice Internal function to check if a hook metadata key exists
/// @param commentId The unique identifier of the comment
/// @param targetKey The key to check for existence
/// @param commentHookMetadataKeys Mapping of comment ID to array of hook metadata keys
/// @return exists Whether the key exists in the metadata
function _hookMetadataKeyExists(
bytes32 commentId,
bytes32 targetKey,
mapping(bytes32 => bytes32[]) storage commentHookMetadataKeys
) internal view returns (bool exists) {
bytes32[] storage keys = commentHookMetadataKeys[commentId];
for (uint i = 0; i < keys.length; i++) {
if (keys[i] == targetKey) {
return true;
}
}
return false;
}
/// @notice Store metadata entries for a comment
/// @param commentId The unique identifier of the comment
/// @param metadata Array of metadata entries to store
/// @param commentMetadata Mapping of comment ID to metadata key to metadata value
/// @param commentMetadataKeys Mapping of comment ID to array of metadata keys
function storeCommentMetadata(
bytes32 commentId,
Metadata.MetadataEntry[] memory metadata,
mapping(bytes32 => mapping(bytes32 => bytes)) storage commentMetadata,
mapping(bytes32 => bytes32[]) storage commentMetadataKeys
) external {
mapping(bytes32 => bytes) storage commentMetadataForId = commentMetadata[
commentId
];
bytes32[] storage commentMetadataKeysForId = commentMetadataKeys[commentId];
for (uint i = 0; i < metadata.length; i++) {
bytes32 key = metadata[i].key;
bytes memory val = metadata[i].value;
// Ensure the key is not empty
if (key == bytes32(0)) revert ICommentManager.InvalidKey();
commentMetadataForId[key] = val;
commentMetadataKeysForId.push(key);
emit ICommentManager.CommentMetadataSet(commentId, key, val);
}
}
/// @notice Store hook metadata entries for a comment
/// @param commentId The unique identifier of the comment
/// @param hookMetadata Array of hook metadata entries to store
/// @param commentHookMetadata Mapping of comment ID to hook metadata key to hook metadata value
/// @param commentHookMetadataKeys Mapping of comment ID to array of hook metadata keys
function storeCommentHookMetadata(
bytes32 commentId,
Metadata.MetadataEntry[] memory hookMetadata,
mapping(bytes32 => mapping(bytes32 => bytes)) storage commentHookMetadata,
mapping(bytes32 => bytes32[]) storage commentHookMetadataKeys
) external {
mapping(bytes32 => bytes)
storage commentHookMetadataForId = commentHookMetadata[commentId];
bytes32[] storage commentHookMetadataKeysForId = commentHookMetadataKeys[
commentId
];
for (uint i = 0; i < hookMetadata.length; i++) {
bytes32 key = hookMetadata[i].key;
bytes memory val = hookMetadata[i].value;
// Ensure the key is not empty
if (key == bytes32(0)) revert ICommentManager.InvalidKey();
commentHookMetadataForId[key] = val;
commentHookMetadataKeysForId.push(key);
emit ICommentManager.CommentHookMetadataSet(commentId, key, val);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "../types/Comments.sol";
import "../types/Hooks.sol";
import "./IChannelManager.sol";
import "../types/Metadata.sol";
/// @title ICommentManager - Interface for the Comments contract
/// @notice This interface defines the functions and events for the Comments contract
interface ICommentManager {
/// @notice Emitted when a new comment is added
/// @param commentId Unique identifier of the comment
/// @param author Address of the comment author
/// @param app Address of the application signer
/// @param channelId The channel ID associated with the comment
/// @param parentId The ID of the parent comment if this is a reply, otherwise bytes32(0)
/// @param createdAt The timestamp when the comment was created
/// @param content The text content of the comment - may contain urls, images and mentions
/// @param targetUri the URI about which the comment is being made
/// @param commentType The type of the comment (0=comment, 1=reaction)
/// @param authMethod The author authentication method used to create this comment
/// @param metadata Array of key-value pairs for additional data
event CommentAdded(
bytes32 indexed commentId,
address indexed author,
address indexed app,
uint256 channelId,
bytes32 parentId,
uint96 createdAt,
string content,
string targetUri,
uint8 commentType,
uint8 authMethod,
Metadata.MetadataEntry[] metadata
);
/// @notice Emitted when metadata is set for a comment
/// @param commentId Unique identifier of the comment
/// @param key The metadata key
/// @param value The metadata value
event CommentMetadataSet(
bytes32 indexed commentId,
bytes32 indexed key,
bytes value
);
/// @notice Emitted when hook metadata is set for a comment
/// @param commentId Unique identifier of the comment
/// @param key The hook metadata key
/// @param value The hook metadata value
event CommentHookMetadataSet(
bytes32 indexed commentId,
bytes32 indexed key,
bytes value
);
/// @notice Emitted when a comment is deleted
/// @param commentId Unique identifier of the deleted comment
/// @param author Address of the comment author
event CommentDeleted(bytes32 indexed commentId, address indexed author);
/// @notice Emitted when a comment is edited
/// @param commentId Unique identifier of the edited comment
/// @param author Address of the comment author
/// @param editedByApp Address of the app signer that changed the comment
/// @param channelId The channel ID associated with the comment
/// @param parentId The ID of the parent comment if this is a reply, otherwise bytes32(0)
/// @param createdAt The timestamp when the comment was created
/// @param updatedAt The timestamp when the comment was last updated
/// @param content The text content of the comment - may contain urls, images and mentions
/// @param targetUri the URI about which the comment is being made
/// @param commentType The type of the comment (0=comment, 1=reaction)
/// @param authMethod The author authentication method used to create this comment (from original creation)
event CommentEdited(
bytes32 indexed commentId,
address indexed author,
address indexed editedByApp,
uint256 channelId,
bytes32 parentId,
uint96 createdAt,
uint96 updatedAt,
string content,
string targetUri,
uint8 commentType,
uint8 authMethod,
Metadata.MetadataEntry[] metadata
);
/// @notice Emitted when hook metadata is updated
/// @param commentId Unique identifier of the comment
/// @param operations Array of metadata operations
event CommentHookDataUpdate(
bytes32 indexed commentId,
Metadata.MetadataEntryOp[] operations
);
/// @notice Emitted when an author approves an app signer
/// @param author Address of the author giving approval
/// @param app Address being approved
/// @param expiry The timestamp when the approval expires
event ApprovalAdded(
address indexed author,
address indexed app,
uint256 expiry
);
/// @notice Emitted when an author removes an app signer's approval
/// @param author Address of the author removing approval
/// @param app Address being unapproved
event ApprovalRemoved(address indexed author, address indexed app);
/// @notice Emitted when a batch operation is executed
/// @param sender Address of the transaction sender
/// @param operationsCount Number of operations in the batch
/// @param totalValue Total ETH value sent with the batch
event BatchOperationExecuted(
address indexed sender,
uint256 operationsCount,
uint256 totalValue
);
/// @notice Error thrown when app signature verification fails
error InvalidAppSignature();
/// @notice Error thrown when author signature verification fails
error InvalidAuthorSignature();
/// @notice Error thrown when nonce is invalid
error InvalidNonce(
address author,
address app,
uint256 expected,
uint256 provided
);
/// @notice Error thrown when deadline has passed
error SignatureDeadlineReached(uint256 deadline, uint256 currentTime);
/// @notice Error thrown when caller is not authorized
error NotAuthorized(address caller, address requiredCaller);
/// @notice Error thrown when signature length is invalid
error InvalidSignatureLength();
/// @notice Error thrown when signature s value is invalid
error InvalidSignatureS();
/// @notice Error thrown when parent comment does not ever existed
/// @dev It reverts only if the comment has never been created, will not revert if the comment is deleted
error ParentCommentHasNeverExisted();
/// @notice Error thrown when both parentId and targetUri are set
error InvalidCommentReference(string message);
/// @notice Error thrown when address is zero
error ZeroAddress();
/// @notice Error thrown when comment does not exist
error CommentDoesNotExist();
/// @notice Error thrown when hook is not enabled for the operation
error HookNotEnabled();
/// @notice Error thrown when parent comment is not in the same channel
error ParentCommentNotInSameChannel();
/// @notice Error thrown when approval expiry is invalid (in the past)
error InvalidApprovalExpiry();
/// @notice Error thrown when batch operation is invalid
error InvalidBatchOperation(uint256 operationIndex, string reason);
/// @notice Error thrown when batch operation value distribution is invalid
error InvalidValueDistribution(uint256 providedValue, uint256 requiredValue);
/// @notice Error thrown when batch operation fails
error BatchOperationFailed(uint256 operationIndex, bytes reason);
/// @notice Error thrown when reaction has no parentId or targetUri
error InvalidReactionReference(string reason);
/// @notice Error thrown when comment already exists
error CommentAlreadyExists();
/// @notice Error thrown when comment is already deleted
error CommentAlreadyDeleted();
/// @notice Error thrown when metadata key is empty
error InvalidKey();
/// @notice Error thrown when hook metadata is too long, this can be used to gas-DOS comment edits/deletes
error HookMetadataTooLong();
/// @notice Error thrown when metadata is too long, this can be used to gas-DOS comment edits/deletes
error MetadataTooLong();
/// @notice Error thrown when value is insufficient for comment creation fee
error InsufficientValue(uint256 providedValue, uint256 requiredValue);
/// @notice Error thrown when reaction cannot be edited
error ReactionCannotBeEdited();
/// @notice Posts a comment directly from the author's address
/// @param commentData The comment data struct containing content and metadata
/// @param appSignature Signature from the app signer authorizing the comment
/// @return commentId The unique identifier of the created comment
function postComment(
Comments.CreateComment calldata commentData,
bytes calldata appSignature
) external payable returns (bytes32 commentId);
/// @notice Posts a comment with both author and app signer signatures
/// @param commentData The comment data struct containing content and metadata
/// @param authorSignature Signature from the author authorizing the comment
/// @param appSignature Signature from the app signer authorizing the comment
/// @return commentId The unique identifier of the created comment
function postCommentWithSig(
Comments.CreateComment calldata commentData,
bytes calldata authorSignature,
bytes calldata appSignature
) external payable returns (bytes32 commentId);
/// @notice Deletes a comment when called by the author directly
/// @param commentId The unique identifier of the comment to delete
function deleteComment(bytes32 commentId) external;
/// @notice Deletes a comment with author signature verification
/// @param commentId The unique identifier of the comment to delete
/// @param app The address of the app signer
/// @param deadline Timestamp after which the signature becomes invalid
/// @param authorSignature The signature from the author authorizing deletion (empty if app)
/// @param appSignature The signature from the app signer authorizing deletion (empty if author)
function deleteCommentWithSig(
bytes32 commentId,
address app,
uint256 deadline,
bytes calldata authorSignature,
bytes calldata appSignature
) external;
/// @notice Edits a comment when called by the author directly
/// @param commentId The unique identifier of the comment to edit
/// @param editData The comment data struct containing content and metadata
/// @param appSignature The signature from the app signer authorizing the edit
function editComment(
bytes32 commentId,
Comments.EditComment calldata editData,
bytes calldata appSignature
) external payable;
/// @notice Edits a comment with both author and app signer signatures
/// @param commentId The unique identifier of the comment to edit
/// @param editData The comment data struct containing content and metadata
/// @param authorSignature The signature from the author authorizing the edit (empty if app)
/// @param appSignature The signature from the app signer authorizing the edit (empty if author)
function editCommentWithSig(
bytes32 commentId,
Comments.EditComment calldata editData,
bytes calldata authorSignature,
bytes calldata appSignature
) external payable;
/// @notice Updates hook metadata for an existing comment using merge mode (gas-efficient). Anyone can call this function.
/// @dev Only updates provided metadata fields without clearing existing ones
/// @param commentId The unique identifier of the comment to update
function updateCommentHookData(bytes32 commentId) external;
/// @notice Approves an app signer when called directly by the author
/// @param app The address to approve
/// @param expiry The timestamp when the approval expires
function addApproval(address app, uint256 expiry) external;
/// @notice Removes an app signer approval when called directly by the author
/// @param app The address to remove approval from
function revokeApproval(address app) external;
/// @notice Approves an app signer with signature verification
/// @param author The address granting approval
/// @param app The address being approved
/// @param expiry The timestamp when the approval expires
/// @param nonce The current nonce for the author
/// @param deadline Timestamp after which the signature becomes invalid
/// @param signature The author's signature authorizing the approval
function addApprovalWithSig(
address author,
address app,
uint256 expiry,
uint256 nonce,
uint256 deadline,
bytes calldata signature
) external;
/// @notice Removes an app signer approval with signature verification
/// @param author The address removing approval
/// @param app The address being unapproved
/// @param nonce The current nonce for the author
/// @param deadline Timestamp after which the signature becomes invalid
/// @param signature The author's signature authorizing the removal
function removeApprovalWithSig(
address author,
address app,
uint256 nonce,
uint256 deadline,
bytes calldata signature
) external;
/// @notice Calculates the EIP-712 hash for a permit
/// @param author Address of the author
/// @param app Address of the app signer
/// @param expiry The timestamp when the approval expires
/// @param nonce Current nonce for the author
/// @param deadline Timestamp after which the signature is invalid
/// @return bytes32 The computed hash
function getAddApprovalHash(
address author,
address app,
uint256 expiry,
uint256 nonce,
uint256 deadline
) external view returns (bytes32);
/// @notice Calculates the EIP-712 hash for removing an approval
/// @param author The address removing approval
/// @param app The address being unapproved
/// @param nonce The current nonce for the author
/// @param deadline Timestamp after which the signature becomes invalid
/// @return The computed hash
function getRemoveApprovalHash(
address author,
address app,
uint256 nonce,
uint256 deadline
) external view returns (bytes32);
/// @notice Calculates the EIP-712 hash for deleting a comment
/// @param commentId The unique identifier of the comment to delete
/// @param author The address of the comment author
/// @param app The address of the app signer
/// @param deadline Timestamp after which the signature becomes invalid
/// @return The computed hash
function getDeleteCommentHash(
bytes32 commentId,
address author,
address app,
uint256 deadline
) external view returns (bytes32);
/// @notice Calculates the EIP-712 hash for editing a comment
/// @param commentId The unique identifier of the comment to edit
/// @param author The address of the comment author
/// @param editData The comment data struct containing content and metadata
/// @return The computed hash
function getEditCommentHash(
bytes32 commentId,
address author,
Comments.EditComment calldata editData
) external view returns (bytes32);
/// @notice Calculates the EIP-712 hash for a comment
/// @param commentData The comment data struct to hash
/// @return bytes32 The computed hash
function getCommentId(
Comments.CreateComment memory commentData
) external view returns (bytes32);
/// @notice Updates the channel manager contract address (only owner)
/// @param _channelContract The new channel manager contract address
function updateChannelContract(address _channelContract) external;
/// @notice Get a comment by its ID
/// @param commentId The ID of the comment to get
/// @return The comment data (returns empty struct with zero address author if comment doesn't exist)
function getComment(
bytes32 commentId
) external view returns (Comments.Comment memory);
/// @notice Get metadata for a comment
/// @param commentId The ID of the comment
/// @return The metadata entries for the comment
function getCommentMetadata(
bytes32 commentId
) external view returns (Metadata.MetadataEntry[] memory);
/// @notice Get hook metadata for a comment
/// @param commentId The ID of the comment
/// @return The hook metadata entries for the comment
function getCommentHookMetadata(
bytes32 commentId
) external view returns (Metadata.MetadataEntry[] memory);
/// @notice Get a specific metadata value for a comment
/// @param commentId The ID of the comment
/// @param key The metadata key
/// @return The metadata value
function getCommentMetadataValue(
bytes32 commentId,
bytes32 key
) external view returns (bytes memory);
/// @notice Get a specific hook metadata value for a comment
/// @param commentId The ID of the comment
/// @param key The hook metadata key
/// @return The hook metadata value
function getCommentHookMetadataValue(
bytes32 commentId,
bytes32 key
) external view returns (bytes memory);
/// @notice Get all metadata keys for a comment
/// @param commentId The ID of the comment
/// @return The metadata keys for the comment
function getCommentMetadataKeys(
bytes32 commentId
) external view returns (bytes32[] memory);
/// @notice Get all hook metadata keys for a comment
/// @param commentId The ID of the comment
/// @return The hook metadata keys for the comment
function getCommentHookMetadataKeys(
bytes32 commentId
) external view returns (bytes32[] memory);
/// @notice Get the approval status for an author and app
/// @param author The address of the author
/// @param app The address of the app
/// @return The approval status
function isApproved(address author, address app) external view returns (bool);
/// @notice Get the approval expiry timestamp for an author and app
/// @param author The address of the author
/// @param app The address of the app
/// @return The approval expiry timestamp (0 if not approved)
function getApprovalExpiry(
address author,
address app
) external view returns (uint256);
/// @notice Get the nonce for an author and app
/// @param author The address of the author
/// @param app The address of the app
/// @return The nonce
function getNonce(
address author,
address app
) external view returns (uint256);
/// @notice Get the deleted status for a comment
/// @param commentId The ID of the comment
/// @return The deleted status
function isDeleted(bytes32 commentId) external view returns (bool);
// Batch Operation Functions
/// @notice Executes multiple operations (post, edit, delete) in a single transaction preserving order
/// @param operations Array of batch operations to execute
/// @return results Array of results from each operation (comment IDs for post operations, empty for others)
function batchOperations(
Comments.BatchOperation[] calldata operations
) external payable returns (bytes[] memory results);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import "../types/Channels.sol";
import "../types/Metadata.sol";
import "./IHook.sol";
import "./IProtocolFees.sol";
/// @title IChannelManager - Interface for managing comment channels and their hooks
/// @notice This interface defines the core functionality for managing channels and their associated hooks
interface IChannelManager is IProtocolFees, IERC721Enumerable {
/// @notice Error thrown when channel does not exist
error ChannelDoesNotExist();
/// @notice Error thrown when hook does not implement required interface
error InvalidHookInterface();
/// @notice Error thrown when channel already exists
error ChannelAlreadyExists();
/// @notice Error thrown when base URI is invalid
error InvalidBaseURI();
/// @notice Error thrown when address is zero
error ZeroAddress();
/// @notice Error thrown when unauthorized caller tries to access function
error UnauthorizedCaller();
/// @notice Error thrown when metadata key is empty
error InvalidKey();
/// @notice Error thrown when channel name is empty
error EmptyChannelName();
/// @notice Error thrown when hook is already set
error HookAlreadySet();
/// @notice Emitted when the base URI for NFT metadata is updated
/// @param baseURI The new base URI
event BaseURIUpdated(string baseURI);
/// @notice Emitted when a new channel is created
/// @param channelId The unique identifier of the channel
/// @param name The name of the channel
/// @param metadata The channel metadata entries
event ChannelCreated(
uint256 indexed channelId,
string name,
string description,
Metadata.MetadataEntry[] metadata,
address hook,
address owner
);
/// @notice Emitted when a channel's configuration is updated
/// @param channelId The unique identifier of the channel
/// @param name The new name of the channel
/// @param description The new description of the channel
/// @param metadata The new metadata entries
event ChannelUpdated(
uint256 indexed channelId,
string name,
string description,
Metadata.MetadataEntry[] metadata
);
/// @notice Emitted when a hook is set for a channel
/// @param channelId The unique identifier of the channel
/// @param hook The address of the hook contract
event HookSet(uint256 indexed channelId, address indexed hook);
/// @notice Emitted when a hook's enabled status is updated
/// @param channelId The unique identifier of the channel
/// @param hook The address of the hook contract
/// @param enabled Whether the hook is enabled
event HookStatusUpdated(
uint256 indexed channelId,
address indexed hook,
bool enabled
);
/// @notice Emitted when channel metadata is set
/// @param channelId The unique identifier of the channel
/// @param key The metadata key
/// @param value The metadata value
event ChannelMetadataSet(
uint256 indexed channelId,
bytes32 indexed key,
bytes value
);
/// @notice Creates a new channel
/// @param name The name of the channel
/// @param description The description of the channel
/// @param metadata The channel metadata entries
/// @param hook Address of the hook to add to the channel
/// @return channelId The unique identifier of the created channel
function createChannel(
string calldata name,
string calldata description,
Metadata.MetadataEntry[] calldata metadata,
address hook
) external payable returns (uint256 channelId);
/// @notice Get a channel by its ID
/// @param channelId The ID of the channel to get
/// @return The channel configuration
function getChannel(
uint256 channelId
) external view returns (Channels.Channel memory);
/// @notice Updates an existing channel's configuration
/// @param channelId The unique identifier of the channel
/// @param name The new name of the channel
/// @param description The new description of the channel
/// @param metadataOperations The new metadata entries as operations
function updateChannel(
uint256 channelId,
string calldata name,
string calldata description,
Metadata.MetadataEntryOp[] calldata metadataOperations
) external;
/// @notice Sets the hook for a channel
/// @param channelId The unique identifier of the channel
/// @param hook The address of the hook contract
function setHook(uint256 channelId, address hook) external;
/// @notice Sets the base URI for NFT metadata
/// @param baseURI_ The new base URI
function setBaseURI(string calldata baseURI_) external;
/// @notice Checks if a channel exists
/// @param channelId Unique identifier of the channel
/// @return exists Whether the channel exists
function channelExists(uint256 channelId) external view returns (bool);
/// @notice Get all metadata for a channel
/// @param channelId The unique identifier of the channel
/// @return The metadata entries for the channel
function getChannelMetadata(
uint256 channelId
) external view returns (Metadata.MetadataEntry[] memory);
/// @notice Get metadata value for a specific key
/// @param channelId The unique identifier of the channel
/// @param key The metadata key
/// @return The metadata value
function getChannelMetadataValue(
uint256 channelId,
bytes32 key
) external view returns (bytes memory);
/// @notice Get all metadata keys for a channel
/// @param channelId The unique identifier of the channel
/// @return The metadata keys for the channel
function getChannelMetadataKeys(
uint256 channelId
) external view returns (bytes32[] memory);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import "../types/Hooks.sol";
import "../types/Comments.sol";
import "../types/Channels.sol";
import "../types/Metadata.sol";
interface IHook is IERC165 {
function getHookPermissions()
external
pure
returns (Hooks.Permissions memory);
/// @notice Execute after a hook is initialized on a channel
/// @param channelManager The address of the channel the hook was added to
/// @param channelData The channel data that was used to initialize the hook
/// @param channelId The unique identifier of the channel that was initialized
/// @param metadata The metadata entries for the channel that was initialized
/// @return success Whether the hook initialization was successful
function onInitialize(
address channelManager,
Channels.Channel memory channelData,
uint256 channelId,
Metadata.MetadataEntry[] calldata metadata
) external returns (bool success);
/// @notice Execute after a comment is processed
/// @param commentData The comment data that was processed
/// @param metadata The metadata entries for the comment
/// @param msgSender The original msg.sender that initiated the transaction
/// @param commentId The unique identifier of the processed comment
/// @return hookMetadata The hook metadata entries that were generated
function onCommentAdd(
Comments.Comment calldata commentData,
Metadata.MetadataEntry[] calldata metadata,
address msgSender,
bytes32 commentId
) external payable returns (Metadata.MetadataEntry[] memory hookMetadata);
/// @notice Execute after a comment is deleted
/// @param commentData The comment data that was deleted
/// @param metadata The metadata entries for the comment
/// @param hookMetadata The hook metadata entries for the comment
/// @param msgSender The original msg.sender that initiated the transaction
/// @param commentId The unique identifier of the deleted comment
/// @return success Whether the hook execution was successful
function onCommentDelete(
Comments.Comment calldata commentData,
Metadata.MetadataEntry[] calldata metadata,
Metadata.MetadataEntry[] calldata hookMetadata,
address msgSender,
bytes32 commentId
) external returns (bool success);
/// @notice Execute after a comment is edited
/// @param commentData The comment data that was edited
/// @param metadata The metadata entries for the comment
/// @param msgSender The original msg.sender that initiated the transaction
/// @param commentId The unique identifier of the edited comment
/// @return hookMetadata The hook metadata entries that were generated
function onCommentEdit(
Comments.Comment calldata commentData,
Metadata.MetadataEntry[] calldata metadata,
address msgSender,
bytes32 commentId
) external payable returns (Metadata.MetadataEntry[] memory hookMetadata);
/// @notice Execute after a channel is updated
/// @param channel The address of the channel that was updated
/// @param channelId The unique identifier of the channel that was updated
/// @param channelData The data of the channel that was updated
/// @return success Whether the channel update was successful
function onChannelUpdate(
address channel,
uint256 channelId,
Channels.Channel calldata channelData,
Metadata.MetadataEntry[] calldata metadata
) external returns (bool success);
/// @notice Execute to update hook data for an existing comment
/// @param commentData The comment data to update
/// @param metadata The current metadata entries for the comment
/// @param hookMetadata The current hook metadata entries for the comment
/// @param msgSender The original msg.sender that initiated the transaction
/// @param commentId The unique identifier of the comment to update
/// @return operations The explicit metadata operations to perform (SET or DELETE)
function onCommentHookDataUpdate(
Comments.Comment calldata commentData,
Metadata.MetadataEntry[] calldata metadata,
Metadata.MetadataEntry[] calldata hookMetadata,
address msgSender,
bytes32 commentId
) external returns (Metadata.MetadataEntryOp[] memory operations);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @title Hooks
* @notice Type definitions for hook-related structs
*/
library Hooks {
/**
* @notice Struct defining which hook functions are enabled
* @dev Each boolean indicates whether the corresponding hook function is enabled
*/
struct Permissions {
bool onInitialize;
bool onCommentAdd;
bool onCommentDelete;
bool onCommentEdit;
bool onChannelUpdate;
bool onCommentHookDataUpdate;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "solady/src/auth/Ownable.sol";
import "solady/src/utils/ReentrancyGuard.sol";
import "./interfaces/IProtocolFees.sol";
import "./interfaces/IChannelManager.sol";
/// @title ProtocolFees - Abstract contract for managing protocol fees
/// @notice This contract handles all fee-related functionality including channel creation, hook registration, and transaction fees
/// @dev Implements fee management with the following features:
/// 1. Fee Configuration:
/// - Channel creation fee
/// - Hook registration fee
/// - Hook transaction fee percentage
/// 2. Fee Collection:
/// - Accumulates fees from various operations
/// - Allows withdrawal of accumulated fees
/// 3. Fee Updates:
/// - Only owner can update fee amounts
/// - Fee percentage capped at 100%
abstract contract ProtocolFees is IProtocolFees, ReentrancyGuard, Ownable {
// Fee configuration
uint96 internal channelCreationFee;
uint96 internal commentCreationFee;
uint16 internal hookTransactionFeeBasisPoints; // (1 basis point = 0.01%)
/// @notice Constructor sets the initial owner
/// @param initialOwner The address that will own the contract
constructor(address initialOwner) {
if (initialOwner == address(0)) revert IChannelManager.ZeroAddress();
_initializeOwner(initialOwner);
// Initialize fees with safe defaults
// Initialize channel creation fees to reduce initial spammy channels
channelCreationFee = 0.02 ether;
// Make a future implementation of comment creation fees at subcent levels to be enabled, in the case of hooks monetizing via ERC20s that bypass hookTransactionFeeBasisPoints
commentCreationFee = 0;
// 2% fee on hook ETH revenue
hookTransactionFeeBasisPoints = 200;
}
/// @inheritdoc IProtocolFees
function setChannelCreationFee(uint96 fee) external onlyOwner {
channelCreationFee = fee;
emit IProtocolFees.ChannelCreationFeeUpdated(fee);
}
/// @inheritdoc IProtocolFees
function setCommentCreationFee(uint96 fee) external onlyOwner {
commentCreationFee = fee;
emit IProtocolFees.CommentCreationFeeUpdated(fee);
}
/// @inheritdoc IProtocolFees
function setHookTransactionFee(uint16 feeBasisPoints) external onlyOwner {
if (feeBasisPoints > 10000) revert InvalidFee(); // Max 100%
hookTransactionFeeBasisPoints = feeBasisPoints;
emit IProtocolFees.HookTransactionFeeUpdated(feeBasisPoints);
}
/// @inheritdoc IProtocolFees
function getChannelCreationFee() external view returns (uint96) {
return channelCreationFee;
}
/// @inheritdoc IProtocolFees
function getCommentCreationFee() external view returns (uint96) {
return commentCreationFee;
}
/// @inheritdoc IProtocolFees
function getHookTransactionFee() external view returns (uint16) {
return hookTransactionFeeBasisPoints;
}
/// @inheritdoc IProtocolFees
function withdrawFees(
address recipient
) external onlyOwner nonReentrant returns (uint256 amount) {
if (recipient == address(0)) revert IChannelManager.ZeroAddress();
amount = address(this).balance;
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Fee withdrawal failed");
emit IProtocolFees.FeesWithdrawn(recipient, amount);
return amount;
}
/// @notice Collects the protocol fee for channel creation
/// @return The amount of fees collected
function _collectChannelCreationFee() internal returns (uint96) {
return _collectFeeWithRefund(channelCreationFee);
}
/// @inheritdoc IProtocolFees
function collectCommentCreationFee() external payable returns (uint96) {
return _collectFeeWithRefund(commentCreationFee);
}
/// @notice Internal function to guard against insufficient fee with refund of excess
/// @param requiredFee The fee amount required for the operation
/// @return The amount of fees collected
function _collectFeeWithRefund(
uint96 requiredFee
) internal virtual returns (uint96) {
if (msg.value < requiredFee) revert InsufficientFee();
if (msg.value > requiredFee) {
// Refund excess payment using transfer for safety
payable(msg.sender).transfer(msg.value - requiredFee);
}
return requiredFee;
}
/// @inheritdoc IProtocolFees
function deductProtocolHookTransactionFee(
uint256 value
) external view returns (uint256 hookValue) {
// Cache storage variable
uint16 fee = hookTransactionFeeBasisPoints;
if (value <= 0 || fee <= 0) {
return value;
}
uint256 protocolFee = (value * fee) / 10000;
return value - protocolFee;
}
/// @inheritdoc IProtocolFees
function calculateMsgValueWithHookFee(
uint256 postFeeAmountForwardedToHook
) external view returns (uint256) {
if (hookTransactionFeeBasisPoints == 0) return postFeeAmountForwardedToHook;
// invalid fee basis points
if (hookTransactionFeeBasisPoints >= 10000) return 0;
// Formula: postFeeAmountForwardedToHook = input - (input * feeBasisPoints / 10000)
// Solving for input: input = postFeeAmountForwardedToHook / (1 - feeBasisPoints/10000)
return
(postFeeAmountForwardedToHook * 10000) /
(10000 - hookTransactionFeeBasisPoints);
}
/// @notice Allows the contract to receive ETH
receive() external payable {}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "solady/src/auth/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "./interfaces/IChannelManager.sol";
import "./interfaces/IProtocolFees.sol";
import "./ProtocolFees.sol";
import "./types/Comments.sol";
import "./types/Channels.sol";
import "./types/Metadata.sol";
import "./interfaces/IHook.sol";
/// @title ChannelManager - A contract for managing comment channels and their hooks as NFTs
/// @notice This contract allows creation and management of channels with configurable hooks, where each channel is an NFT
/// @dev Implements channel management with the following security features:
contract ChannelManager is IChannelManager, ProtocolFees, ERC721Enumerable {
/// @notice Base URI for NFT metadata
string internal baseURIValue;
// Mapping from channel ID to channel configuration
mapping(uint256 => Channels.Channel) internal channels;
// Channel metadata storage mappings
/// @notice Mapping of channel ID to metadata key to metadata value
mapping(uint256 => mapping(bytes32 => bytes)) public channelMetadata;
/// @notice Mapping of channel ID to array of metadata keys
mapping(uint256 => bytes32[]) public channelMetadataKeys;
/// @notice Constructor sets the contract owner and initializes ERC721
/// @param initialOwner The address that will own the contract
constructor(
address initialOwner
) ProtocolFees(initialOwner) ERC721("ECP Channel", "ECPC") {
if (initialOwner == address(0)) revert ZeroAddress();
// Create default channel with ID 0
_safeMint(initialOwner, 0);
Channels.Channel storage channelZero = channels[0];
channelZero.name = "Home";
channelZero.description = "Any kind of content";
emit ChannelCreated(
0,
channelZero.name,
channelZero.description,
new Metadata.MetadataEntry[](0),
channelZero.hook,
initialOwner
);
}
/// @inheritdoc IChannelManager
function getChannel(
uint256 channelId
) external view returns (Channels.Channel memory) {
if (!_channelExists(channelId)) revert ChannelDoesNotExist();
return channels[channelId];
}
/// @notice Calculates a unique hash for a channel
/// @param creator The address of the channel creator
/// @param name The name of the channel
/// @param description The description of the channel
/// @param metadata The channel metadata entries
/// @return bytes32 The computed hash
function _getChannelId(
address creator,
string memory name,
string memory description,
Metadata.MetadataEntry[] memory metadata
) internal view returns (uint256) {
return
uint256(
keccak256(
abi.encodePacked(
creator,
keccak256(bytes(name)),
keccak256(bytes(description)),
_hashMetadataArray(metadata),
block.timestamp,
block.chainid
)
)
);
}
/// @notice Internal function to check if a channel exists
/// @param channelId The channel ID to check
/// @return bool Whether the channel exists
function _channelExists(
uint256 channelId
) internal view virtual returns (bool) {
return _ownerOf(channelId) != address(0);
}
/// @notice Internal function to hash metadata array for deterministic channel ID generation
/// @param metadata The metadata array to hash
/// @return The hash of the metadata array
function _hashMetadataArray(
Metadata.MetadataEntry[] memory metadata
) internal pure returns (bytes32) {
bytes32[] memory hashedEntries = new bytes32[](metadata.length);
for (uint i = 0; i < metadata.length; i++) {
hashedEntries[i] = keccak256(
abi.encode(
keccak256("MetadataEntry(bytes32 key,bytes value)"),
metadata[i].key,
keccak256(metadata[i].value)
)
);
}
return keccak256(abi.encodePacked(hashedEntries));
}
/// @inheritdoc IChannelManager
function createChannel(
string calldata name,
string calldata description,
Metadata.MetadataEntry[] calldata metadata,
address hook
) external payable returns (uint256 channelId) {
if (bytes(name).length == 0) revert EmptyChannelName();
// Generate channel ID using the internal function
channelId = _getChannelId(msg.sender, name, description, metadata);
// Ensure channel ID doesn't already exist
if (_channelExists(channelId)) revert ChannelAlreadyExists();
_collectChannelCreationFee();
_safeMint(msg.sender, channelId);
Channels.Channel storage channel = channels[channelId];
channel.name = name;
channel.description = description;
_createChannelMetadata(channelId, metadata);
emit ChannelCreated(
channelId,
name,
description,
metadata,
hook,
msg.sender
);
// Add hook if provided
if (hook != address(0)) {
_setHook(channelId, hook);
}
return channelId;
}
/// @inheritdoc IChannelManager
function updateChannel(
uint256 channelId,
string calldata name,
string calldata description,
Metadata.MetadataEntryOp[] calldata metadataOperations
) external {
if (bytes(name).length == 0) revert EmptyChannelName();
if (!_channelExists(channelId)) revert ChannelDoesNotExist();
if (ownerOf(channelId) != msg.sender) revert UnauthorizedCaller();
Channels.Channel storage channel = channels[channelId];
channel.name = name;
channel.description = description;
_setChannelMetadata(channelId, metadataOperations);
Metadata.MetadataEntry[] memory metadata = getChannelMetadata(channelId);
emit ChannelUpdated(channelId, name, description, metadata);
if (channel.hook != address(0)) {
IHook hook = IHook(channel.hook);
Hooks.Permissions memory permissions = hook.getHookPermissions();
if (permissions.onChannelUpdate) {
hook.onChannelUpdate(address(this), channelId, channel, metadata);
}
}
}
/// @inheritdoc IChannelManager
function setHook(uint256 channelId, address hook) external {
if (!_channelExists(channelId)) revert ChannelDoesNotExist();
if (ownerOf(channelId) != msg.sender) revert UnauthorizedCaller();
if (hook == channels[channelId].hook) revert HookAlreadySet();
return _setHook(channelId, hook);
}
/// @notice Internal function to set the hook for a channel
/// @param channelId The unique identifier of the channel
/// @param hook The address of the hook contract
function _setHook(uint256 channelId, address hook) internal nonReentrant {
// Emit events before calling the`onInitialize` hook to ensure the order of events is correct in the case of reentrancy
emit HookSet(channelId, hook);
emit HookStatusUpdated(channelId, hook, hook != address(0));
if (hook != address(0)) {
// Validate that the hook implements IHook interface
try IERC165(hook).supportsInterface(type(IHook).interfaceId) returns (
bool result
) {
if (!result) revert InvalidHookInterface();
} catch {
revert InvalidHookInterface();
}
// Get hook permissions and store them on the channel
Hooks.Permissions memory permissions = IHook(hook).getHookPermissions();
channels[channelId].hook = hook;
channels[channelId].permissions = permissions;
// Call afterInitialize hook if permitted
if (permissions.onInitialize) {
IHook(hook).onInitialize(
address(this),
channels[channelId],
channelId,
getChannelMetadata(channelId)
);
}
} else {
delete channels[channelId].hook; // Properly reset to default value
delete channels[channelId].permissions;
}
}
/// @inheritdoc IChannelManager
function channelExists(uint256 channelId) external view returns (bool) {
return _channelExists(channelId);
}
/// @inheritdoc IChannelManager
function setBaseURI(string calldata baseURI_) external onlyOwner {
if (bytes(baseURI_).length == 0) revert IChannelManager.InvalidBaseURI();
baseURIValue = baseURI_;
emit IChannelManager.BaseURIUpdated(baseURI_);
}
/// @notice Returns the base URI for token metadata
/// @dev Internal function that overrides ERC721's _baseURI()
function _baseURI() internal view virtual override returns (string memory) {
return baseURIValue;
}
/// @notice Internal function to create channel metadata
/// @param channelId The unique identifier of the channel
/// @param metadata The metadata entries to create
function _createChannelMetadata(
uint256 channelId,
Metadata.MetadataEntry[] calldata metadata
) internal {
mapping(bytes32 => bytes) storage channelMetadataForId = channelMetadata[
channelId
];
bytes32[] storage channelMetadataKeysForId = channelMetadataKeys[channelId];
for (uint i = 0; i < metadata.length; i++) {
bytes32 key = metadata[i].key;
bytes memory val = metadata[i].value;
if (key == bytes32(0)) revert InvalidKey();
channelMetadataForId[key] = val;
channelMetadataKeysForId.push(key);
}
}
/// @notice Sets metadata for a channel
/// @param channelId The unique identifier of the channel
/// @param operations Array of metadata operations to perform
function _setChannelMetadata(
uint256 channelId,
Metadata.MetadataEntryOp[] calldata operations
) internal {
if (!_channelExists(channelId)) revert ChannelDoesNotExist();
if (ownerOf(channelId) != msg.sender) revert UnauthorizedCaller();
mapping(bytes32 => bytes) storage channelMetadataForId = channelMetadata[
channelId
];
bytes32[] storage channelMetadataKeysForId = channelMetadataKeys[channelId];
// Apply metadata operations
for (uint i = 0; i < operations.length; i++) {
Metadata.MetadataEntryOp memory op = operations[i];
// Ensure the key is not empty
if (op.key == bytes32(0)) revert InvalidKey();
if (op.operation == Metadata.MetadataOperation.DELETE) {
_deleteChannelMetadataKey(channelId, op.key);
emit ChannelMetadataSet(channelId, op.key, ""); // Emit empty value for deletion
} else if (op.operation == Metadata.MetadataOperation.SET) {
// Check if this is a new key for gas optimization
bool isNewKey = !_channelMetadataKeyExists(channelId, op.key);
channelMetadataForId[op.key] = op.value;
// Only add to keys array if it's a new key
if (isNewKey) {
channelMetadataKeysForId.push(op.key);
}
emit ChannelMetadataSet(channelId, op.key, op.value);
}
}
}
/// @notice Internal function to delete a specific channel metadata key
/// @param channelId The unique identifier of the channel
/// @param keyToDelete The key to delete
function _deleteChannelMetadataKey(
uint256 channelId,
bytes32 keyToDelete
) internal {
// Delete the value
delete channelMetadata[channelId][keyToDelete];
// Remove from keys array
bytes32[] storage keys = channelMetadataKeys[channelId];
for (uint i = 0; i < keys.length; i++) {
if (keys[i] == keyToDelete) {
// Move last element to current position and pop
keys[i] = keys[keys.length - 1];
keys.pop();
break;
}
}
}
/// @notice Internal function to check if a channel metadata key exists
/// @param channelId The unique identifier of the channel
/// @param targetKey The key to check for existence
/// @return exists Whether the key exists in the metadata
function _channelMetadataKeyExists(
uint256 channelId,
bytes32 targetKey
) internal view returns (bool) {
bytes32[] storage keys = channelMetadataKeys[channelId];
for (uint i = 0; i < keys.length; i++) {
if (keys[i] == targetKey) {
return true;
}
}
return false;
}
/// @inheritdoc IChannelManager
function getChannelMetadata(
uint256 channelId
) public view returns (Metadata.MetadataEntry[] memory) {
bytes32[] memory keys = channelMetadataKeys[channelId];
Metadata.MetadataEntry[] memory metadata = new Metadata.MetadataEntry[](
keys.length
);
for (uint i = 0; i < keys.length; i++) {
metadata[i] = Metadata.MetadataEntry({
key: keys[i],
value: channelMetadata[channelId][keys[i]]
});
}
return metadata;
}
/// @inheritdoc IChannelManager
function getChannelMetadataValue(
uint256 channelId,
bytes32 key
) external view returns (bytes memory) {
return channelMetadata[channelId][key];
}
/// @inheritdoc IChannelManager
function getChannelMetadataKeys(
uint256 channelId
) external view returns (bytes32[] memory) {
return channelMetadataKeys[channelId];
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/// @notice Signature verification helper that supports both ECDSA signatures from EOAs
/// and ERC1271 signatures from smart contract wallets like Argent and Gnosis safe.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/SignatureCheckerLib.sol)
/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/SignatureChecker.sol)
///
/// @dev Note:
/// - The signature checking functions use the ecrecover precompile (0x1).
/// - The `bytes memory signature` variants use the identity precompile (0x4)
/// to copy memory internally.
/// - Unlike ECDSA signatures, contract signatures are revocable.
/// - As of Solady version 0.0.134, all `bytes signature` variants accept both
/// regular 65-byte `(r, s, v)` and EIP-2098 `(r, vs)` short form signatures.
/// See: https://eips.ethereum.org/EIPS/eip-2098
/// This is for calldata efficiency on smart accounts prevalent on L2s.
///
/// WARNING! Do NOT use signatures as unique identifiers:
/// - Use a nonce in the digest to prevent replay attacks on the same contract.
/// - Use EIP-712 for the digest to prevent replay attacks across different chains and contracts.
/// EIP-712 also enables readable signing of typed data for better user safety.
/// This implementation does NOT check if a signature is non-malleable.
library SignatureCheckerLib {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* SIGNATURE CHECKING OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns whether `signature` is valid for `signer` and `hash`.
/// If `signer.code.length == 0`, then validate with `ecrecover`, else
/// it will validate with ERC1271 on `signer`.
function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature)
internal
view
returns (bool isValid)
{
if (signer == address(0)) return isValid;
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
for {} 1 {} {
if iszero(extcodesize(signer)) {
switch mload(signature)
case 64 {
let vs := mload(add(signature, 0x40))
mstore(0x20, add(shr(255, vs), 27)) // `v`.
mstore(0x60, shr(1, shl(1, vs))) // `s`.
}
case 65 {
mstore(0x20, byte(0, mload(add(signature, 0x60)))) // `v`.
mstore(0x60, mload(add(signature, 0x40))) // `s`.
}
default { break }
mstore(0x00, hash)
mstore(0x40, mload(add(signature, 0x20))) // `r`.
let recovered := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))
isValid := gt(returndatasize(), shl(96, xor(signer, recovered)))
mstore(0x60, 0) // Restore the zero slot.
mstore(0x40, m) // Restore the free memory pointer.
break
}
let f := shl(224, 0x1626ba7e)
mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m, 0x04), hash)
let d := add(m, 0x24)
mstore(d, 0x40) // The offset of the `signature` in the calldata.
// Copy the `signature` over.
let n := add(0x20, mload(signature))
let copied := staticcall(gas(), 4, signature, n, add(m, 0x44), n)
isValid := staticcall(gas(), signer, m, add(returndatasize(), 0x44), d, 0x20)
isValid := and(eq(mload(d), f), and(isValid, copied))
break
}
}
}
/// @dev Returns whether `signature` is valid for `signer` and `hash`.
/// If `signer.code.length == 0`, then validate with `ecrecover`, else
/// it will validate with ERC1271 on `signer`.
function isValidSignatureNowCalldata(address signer, bytes32 hash, bytes calldata signature)
internal
view
returns (bool isValid)
{
if (signer == address(0)) return isValid;
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
for {} 1 {} {
if iszero(extcodesize(signer)) {
switch signature.length
case 64 {
let vs := calldataload(add(signature.offset, 0x20))
mstore(0x20, add(shr(255, vs), 27)) // `v`.
mstore(0x40, calldataload(signature.offset)) // `r`.
mstore(0x60, shr(1, shl(1, vs))) // `s`.
}
case 65 {
mstore(0x20, byte(0, calldataload(add(signature.offset, 0x40)))) // `v`.
calldatacopy(0x40, signature.offset, 0x40) // `r`, `s`.
}
default { break }
mstore(0x00, hash)
let recovered := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))
isValid := gt(returndatasize(), shl(96, xor(signer, recovered)))
mstore(0x60, 0) // Restore the zero slot.
mstore(0x40, m) // Restore the free memory pointer.
break
}
let f := shl(224, 0x1626ba7e)
mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m, 0x04), hash)
let d := add(m, 0x24)
mstore(d, 0x40) // The offset of the `signature` in the calldata.
mstore(add(m, 0x44), signature.length)
// Copy the `signature` over.
calldatacopy(add(m, 0x64), signature.offset, signature.length)
isValid := staticcall(gas(), signer, m, add(signature.length, 0x64), d, 0x20)
isValid := and(eq(mload(d), f), isValid)
break
}
}
}
/// @dev Returns whether the signature (`r`, `vs`) is valid for `signer` and `hash`.
/// If `signer.code.length == 0`, then validate with `ecrecover`, else
/// it will validate with ERC1271 on `signer`.
function isValidSignatureNow(address signer, bytes32 hash, bytes32 r, bytes32 vs)
internal
view
returns (bool isValid)
{
if (signer == address(0)) return isValid;
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
for {} 1 {} {
if iszero(extcodesize(signer)) {
mstore(0x00, hash)
mstore(0x20, add(shr(255, vs), 27)) // `v`.
mstore(0x40, r) // `r`.
mstore(0x60, shr(1, shl(1, vs))) // `s`.
let recovered := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))
isValid := gt(returndatasize(), shl(96, xor(signer, recovered)))
mstore(0x60, 0) // Restore the zero slot.
mstore(0x40, m) // Restore the free memory pointer.
break
}
let f := shl(224, 0x1626ba7e)
mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m, 0x04), hash)
let d := add(m, 0x24)
mstore(d, 0x40) // The offset of the `signature` in the calldata.
mstore(add(m, 0x44), 65) // Length of the signature.
mstore(add(m, 0x64), r) // `r`.
mstore(add(m, 0x84), shr(1, shl(1, vs))) // `s`.
mstore8(add(m, 0xa4), add(shr(255, vs), 27)) // `v`.
isValid := staticcall(gas(), signer, m, 0xa5, d, 0x20)
isValid := and(eq(mload(d), f), isValid)
break
}
}
}
/// @dev Returns whether the signature (`v`, `r`, `s`) is valid for `signer` and `hash`.
/// If `signer.code.length == 0`, then validate with `ecrecover`, else
/// it will validate with ERC1271 on `signer`.
function isValidSignatureNow(address signer, bytes32 hash, uint8 v, bytes32 r, bytes32 s)
internal
view
returns (bool isValid)
{
if (signer == address(0)) return isValid;
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
for {} 1 {} {
if iszero(extcodesize(signer)) {
mstore(0x00, hash)
mstore(0x20, and(v, 0xff)) // `v`.
mstore(0x40, r) // `r`.
mstore(0x60, s) // `s`.
let recovered := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))
isValid := gt(returndatasize(), shl(96, xor(signer, recovered)))
mstore(0x60, 0) // Restore the zero slot.
mstore(0x40, m) // Restore the free memory pointer.
break
}
let f := shl(224, 0x1626ba7e)
mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m, 0x04), hash)
let d := add(m, 0x24)
mstore(d, 0x40) // The offset of the `signature` in the calldata.
mstore(add(m, 0x44), 65) // Length of the signature.
mstore(add(m, 0x64), r) // `r`.
mstore(add(m, 0x84), s) // `s`.
mstore8(add(m, 0xa4), v) // `v`.
isValid := staticcall(gas(), signer, m, 0xa5, d, 0x20)
isValid := and(eq(mload(d), f), isValid)
break
}
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* ERC1271 OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
// Note: These ERC1271 operations do NOT have an ECDSA fallback.
/// @dev Returns whether `signature` is valid for `hash` for an ERC1271 `signer` contract.
function isValidERC1271SignatureNow(address signer, bytes32 hash, bytes memory signature)
internal
view
returns (bool isValid)
{
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
let f := shl(224, 0x1626ba7e)
mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m, 0x04), hash)
let d := add(m, 0x24)
mstore(d, 0x40) // The offset of the `signature` in the calldata.
// Copy the `signature` over.
let n := add(0x20, mload(signature))
let copied := staticcall(gas(), 4, signature, n, add(m, 0x44), n)
isValid := staticcall(gas(), signer, m, add(returndatasize(), 0x44), d, 0x20)
isValid := and(eq(mload(d), f), and(isValid, copied))
}
}
/// @dev Returns whether `signature` is valid for `hash` for an ERC1271 `signer` contract.
function isValidERC1271SignatureNowCalldata(
address signer,
bytes32 hash,
bytes calldata signature
) internal view returns (bool isValid) {
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
let f := shl(224, 0x1626ba7e)
mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m, 0x04), hash)
let d := add(m, 0x24)
mstore(d, 0x40) // The offset of the `signature` in the calldata.
mstore(add(m, 0x44), signature.length)
// Copy the `signature` over.
calldatacopy(add(m, 0x64), signature.offset, signature.length)
isValid := staticcall(gas(), signer, m, add(signature.length, 0x64), d, 0x20)
isValid := and(eq(mload(d), f), isValid)
}
}
/// @dev Returns whether the signature (`r`, `vs`) is valid for `hash`
/// for an ERC1271 `signer` contract.
function isValidERC1271SignatureNow(address signer, bytes32 hash, bytes32 r, bytes32 vs)
internal
view
returns (bool isValid)
{
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
let f := shl(224, 0x1626ba7e)
mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m, 0x04), hash)
let d := add(m, 0x24)
mstore(d, 0x40) // The offset of the `signature` in the calldata.
mstore(add(m, 0x44), 65) // Length of the signature.
mstore(add(m, 0x64), r) // `r`.
mstore(add(m, 0x84), shr(1, shl(1, vs))) // `s`.
mstore8(add(m, 0xa4), add(shr(255, vs), 27)) // `v`.
isValid := staticcall(gas(), signer, m, 0xa5, d, 0x20)
isValid := and(eq(mload(d), f), isValid)
}
}
/// @dev Returns whether the signature (`v`, `r`, `s`) is valid for `hash`
/// for an ERC1271 `signer` contract.
function isValidERC1271SignatureNow(address signer, bytes32 hash, uint8 v, bytes32 r, bytes32 s)
internal
view
returns (bool isValid)
{
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
let f := shl(224, 0x1626ba7e)
mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m, 0x04), hash)
let d := add(m, 0x24)
mstore(d, 0x40) // The offset of the `signature` in the calldata.
mstore(add(m, 0x44), 65) // Length of the signature.
mstore(add(m, 0x64), r) // `r`.
mstore(add(m, 0x84), s) // `s`.
mstore8(add(m, 0xa4), v) // `v`.
isValid := staticcall(gas(), signer, m, 0xa5, d, 0x20)
isValid := and(eq(mload(d), f), isValid)
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* ERC6492 OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
// Note: These ERC6492 operations now include an ECDSA fallback at the very end.
// The calldata variants are excluded for brevity.
/// @dev Returns whether `signature` is valid for `hash`.
/// If the signature is postfixed with the ERC6492 magic number, it will attempt to
/// deploy / prepare the `signer` smart account before doing a regular ERC1271 check.
/// Note: This function is NOT reentrancy safe.
/// The verifier must be deployed.
/// Otherwise, the function will return false if `signer` is not yet deployed / prepared.
/// See: https://gist.github.com/Vectorized/011d6becff6e0a73e42fe100f8d7ef04
/// With a dedicated verifier, this function is safe to use in contracts
/// that have been granted special permissions.
function isValidERC6492SignatureNowAllowSideEffects(
address signer,
bytes32 hash,
bytes memory signature
) internal returns (bool isValid) {
/// @solidity memory-safe-assembly
assembly {
function callIsValidSignature(signer_, hash_, signature_) -> _isValid {
let m_ := mload(0x40)
let f_ := shl(224, 0x1626ba7e)
mstore(m_, f_) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m_, 0x04), hash_)
let d_ := add(m_, 0x24)
mstore(d_, 0x40) // The offset of the `signature` in the calldata.
let n_ := add(0x20, mload(signature_))
let copied_ := staticcall(gas(), 4, signature_, n_, add(m_, 0x44), n_)
_isValid := staticcall(gas(), signer_, m_, add(returndatasize(), 0x44), d_, 0x20)
_isValid := and(eq(mload(d_), f_), and(_isValid, copied_))
}
let noCode := iszero(extcodesize(signer))
let n := mload(signature)
for {} 1 {} {
if iszero(eq(mload(add(signature, n)), mul(0x6492, div(not(isValid), 0xffff)))) {
if iszero(noCode) { isValid := callIsValidSignature(signer, hash, signature) }
break
}
if iszero(noCode) {
let o := add(signature, 0x20) // Signature bytes.
isValid := callIsValidSignature(signer, hash, add(o, mload(add(o, 0x40))))
if isValid { break }
}
let m := mload(0x40)
mstore(m, signer)
mstore(add(m, 0x20), hash)
pop(
call(
gas(), // Remaining gas.
0x0000bc370E4DC924F427d84e2f4B9Ec81626ba7E, // Non-reverting verifier.
0, // Send zero ETH.
m, // Start of memory.
add(returndatasize(), 0x40), // Length of calldata in memory.
staticcall(gas(), 4, add(signature, 0x20), n, add(m, 0x40), n), // 1.
0x00 // Length of returndata to write.
)
)
isValid := returndatasize()
break
}
// Do `ecrecover` fallback if `noCode && !isValid`.
for {} gt(noCode, isValid) {} {
switch n
case 64 {
let vs := mload(add(signature, 0x40))
mstore(0x20, add(shr(255, vs), 27)) // `v`.
mstore(0x60, shr(1, shl(1, vs))) // `s`.
}
case 65 {
mstore(0x20, byte(0, mload(add(signature, 0x60)))) // `v`.
mstore(0x60, mload(add(signature, 0x40))) // `s`.
}
default { break }
let m := mload(0x40)
mstore(0x00, hash)
mstore(0x40, mload(add(signature, 0x20))) // `r`.
let recovered := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))
isValid := gt(returndatasize(), shl(96, xor(signer, recovered)))
mstore(0x60, 0) // Restore the zero slot.
mstore(0x40, m) // Restore the free memory pointer.
break
}
}
}
/// @dev Returns whether `signature` is valid for `hash`.
/// If the signature is postfixed with the ERC6492 magic number, it will attempt
/// to use a reverting verifier to deploy / prepare the `signer` smart account
/// and do a `isValidSignature` check via the reverting verifier.
/// Note: This function is reentrancy safe.
/// The reverting verifier must be deployed.
/// Otherwise, the function will return false if `signer` is not yet deployed / prepared.
/// See: https://gist.github.com/Vectorized/846a474c855eee9e441506676800a9ad
function isValidERC6492SignatureNow(address signer, bytes32 hash, bytes memory signature)
internal
returns (bool isValid)
{
/// @solidity memory-safe-assembly
assembly {
function callIsValidSignature(signer_, hash_, signature_) -> _isValid {
let m_ := mload(0x40)
let f_ := shl(224, 0x1626ba7e)
mstore(m_, f_) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m_, 0x04), hash_)
let d_ := add(m_, 0x24)
mstore(d_, 0x40) // The offset of the `signature` in the calldata.
let n_ := add(0x20, mload(signature_))
let copied_ := staticcall(gas(), 4, signature_, n_, add(m_, 0x44), n_)
_isValid := staticcall(gas(), signer_, m_, add(returndatasize(), 0x44), d_, 0x20)
_isValid := and(eq(mload(d_), f_), and(_isValid, copied_))
}
let noCode := iszero(extcodesize(signer))
let n := mload(signature)
for {} 1 {} {
if iszero(eq(mload(add(signature, n)), mul(0x6492, div(not(isValid), 0xffff)))) {
if iszero(noCode) { isValid := callIsValidSignature(signer, hash, signature) }
break
}
if iszero(noCode) {
let o := add(signature, 0x20) // Signature bytes.
isValid := callIsValidSignature(signer, hash, add(o, mload(add(o, 0x40))))
if isValid { break }
}
let m := mload(0x40)
mstore(m, signer)
mstore(add(m, 0x20), hash)
let willBeZeroIfRevertingVerifierExists :=
call(
gas(), // Remaining gas.
0x00007bd799e4A591FeA53f8A8a3E9f931626Ba7e, // Reverting verifier.
0, // Send zero ETH.
m, // Start of memory.
add(returndatasize(), 0x40), // Length of calldata in memory.
staticcall(gas(), 4, add(signature, 0x20), n, add(m, 0x40), n), // 1.
0x00 // Length of returndata to write.
)
isValid := gt(returndatasize(), willBeZeroIfRevertingVerifierExists)
break
}
// Do `ecrecover` fallback if `noCode && !isValid`.
for {} gt(noCode, isValid) {} {
switch n
case 64 {
let vs := mload(add(signature, 0x40))
mstore(0x20, add(shr(255, vs), 27)) // `v`.
mstore(0x60, shr(1, shl(1, vs))) // `s`.
}
case 65 {
mstore(0x20, byte(0, mload(add(signature, 0x60)))) // `v`.
mstore(0x60, mload(add(signature, 0x40))) // `s`.
}
default { break }
let m := mload(0x40)
mstore(0x00, hash)
mstore(0x40, mload(add(signature, 0x20))) // `r`.
let recovered := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))
isValid := gt(returndatasize(), shl(96, xor(signer, recovered)))
mstore(0x60, 0) // Restore the zero slot.
mstore(0x40, m) // Restore the free memory pointer.
break
}
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* HASHING OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns an Ethereum Signed Message, created from a `hash`.
/// This produces a hash corresponding to the one signed with the
/// [`eth_sign`](https://eth.wiki/json-rpc/API#eth_sign)
/// JSON-RPC method as part of EIP-191.
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 result) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x20, hash) // Store into scratch space for keccak256.
mstore(0x00, "\x00\x00\x00\x00\x19Ethereum Signed Message:\n32") // 28 bytes.
result := keccak256(0x04, 0x3c) // `32 * 2 - (32 - 28) = 60 = 0x3c`.
}
}
/// @dev Returns an Ethereum Signed Message, created from `s`.
/// This produces a hash corresponding to the one signed with the
/// [`eth_sign`](https://eth.wiki/json-rpc/API#eth_sign)
/// JSON-RPC method as part of EIP-191.
/// Note: Supports lengths of `s` up to 999999 bytes.
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32 result) {
/// @solidity memory-safe-assembly
assembly {
let sLength := mload(s)
let o := 0x20
mstore(o, "\x19Ethereum Signed Message:\n") // 26 bytes, zero-right-padded.
mstore(0x00, 0x00)
// Convert the `s.length` to ASCII decimal representation: `base10(s.length)`.
for { let temp := sLength } 1 {} {
o := sub(o, 1)
mstore8(o, add(48, mod(temp, 10)))
temp := div(temp, 10)
if iszero(temp) { break }
}
let n := sub(0x3a, o) // Header length: `26 + 32 - o`.
// Throw an out-of-offset error (consumes all gas) if the header exceeds 32 bytes.
returndatacopy(returndatasize(), returndatasize(), gt(n, 0x20))
mstore(s, or(mload(0x00), mload(n))) // Temporarily store the header.
result := keccak256(add(s, sub(0x20, n)), add(n, sLength))
mstore(s, sLength) // Restore the length.
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* EMPTY CALLDATA HELPERS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns an empty calldata bytes.
function emptySignature() internal pure returns (bytes calldata signature) {
/// @solidity memory-safe-assembly
assembly {
signature.length := 0
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Enumerable.sol)
pragma solidity ^0.8.20;
import {IERC721} from "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/// @title IProtocolFees - Interface for managing protocol fees
/// @notice This interface defines functions for managing various protocol fees
interface IProtocolFees {
/// @notice Error thrown when fee percentage is invalid (>100%)
error InvalidFee();
/// @notice Error thrown when insufficient fee is provided
error InsufficientFee();
/// @notice Emitted when channel creation fee is updated
/// @param newFee The new fee amount in wei
event ChannelCreationFeeUpdated(uint96 newFee);
/// @notice Emitted when comment creation fee is updated
/// @param newFee The new fee amount in wei
event CommentCreationFeeUpdated(uint96 newFee);
/// @notice Emitted when hook transaction fee percentage is updated
/// @param newBasisPoints The new fee basis points (1 basis points = 0.01%)
event HookTransactionFeeUpdated(uint16 newBasisPoints);
/// @notice Emitted when fees are withdrawn
/// @param recipient The address receiving the fees
/// @param amount The amount withdrawn
event FeesWithdrawn(address indexed recipient, uint256 amount);
/// @notice Sets the fee for creating a new channel
/// @param fee The fee amount in wei
function setChannelCreationFee(uint96 fee) external;
/// @notice Gets the current channel creation fee
/// @return fee The current fee in wei
function getChannelCreationFee() external view returns (uint96 fee);
/// @notice Sets the fee for creating a new comment
/// @param fee The fee amount in wei
function setCommentCreationFee(uint96 fee) external;
/// @notice Gets the current comment creation fee
/// @return fee The current fee in wei
function getCommentCreationFee() external view returns (uint96 fee);
/// @notice Sets the fee percentage taken from hook transactions
/// @param feeBasisPoints The fee percentage in basis points (1 basis point = 0.01%)
function setHookTransactionFee(uint16 feeBasisPoints) external;
/// @notice Gets the current hook transaction fee percentage
/// @return feeBasisPoints The current fee percentage in basis points (1 basis points = 0.01%)
function getHookTransactionFee()
external
view
returns (uint16 feeBasisPoints);
/// @notice Withdraws accumulated fees to a specified address
/// @param recipient The address to receive the fees
/// @return amount The amount withdrawn
function withdrawFees(address recipient) external returns (uint256 amount);
/// @notice Collects the protocol fee for comment creation
/// @return The amount of fees collected
function collectCommentCreationFee() external payable returns (uint96);
/// @notice Calculates the hook transaction fee by deducting the protocol fee
/// @param value The total value sent with the transaction
/// @return hookValue The amount that should be passed to the hook
function deductProtocolHookTransactionFee(
uint256 value
) external view returns (uint256 hookValue);
/// @notice Calculates the required input value to achieve a desired output after protocol fee deduction
/// @param postFeeAmountForwardedToHook The desired amount to receive after fee deduction
/// @return The required input value to send
function calculateMsgValueWithHookFee(
uint256 postFeeAmountForwardedToHook
) external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.20;
import {IERC721} from "./IERC721.sol";
import {IERC721Metadata} from "./extensions/IERC721Metadata.sol";
import {ERC721Utils} from "./utils/ERC721Utils.sol";
import {Context} from "../../utils/Context.sol";
import {Strings} from "../../utils/Strings.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
import {IERC721Errors} from "../../interfaces/draft-IERC6093.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC-721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Errors {
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
mapping(uint256 tokenId => address) private _owners;
mapping(address owner => uint256) private _balances;
mapping(uint256 tokenId => address) private _tokenApprovals;
mapping(address owner => mapping(address operator => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual returns (uint256) {
if (owner == address(0)) {
revert ERC721InvalidOwner(address(0));
}
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual returns (address) {
return _requireOwned(tokenId);
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual returns (string memory) {
_requireOwned(tokenId);
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string.concat(baseURI, tokenId.toString()) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual {
_approve(to, tokenId, _msgSender());
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual returns (address) {
_requireOwned(tokenId);
return _getApproved(tokenId);
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(address from, address to, uint256 tokenId) public virtual {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
// Setting an "auth" arguments enables the `_isAuthorized` check which verifies that the token exists
// (from != 0). Therefore, it is not needed to verify that the return value is not 0 here.
address previousOwner = _update(to, tokenId, _msgSender());
if (previousOwner != from) {
revert ERC721IncorrectOwner(from, tokenId, previousOwner);
}
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) public {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual {
transferFrom(from, to, tokenId);
ERC721Utils.checkOnERC721Received(_msgSender(), from, to, tokenId, data);
}
/**
* @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
*
* IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the
* core ERC-721 logic MUST be matched with the use of {_increaseBalance} to keep balances
* consistent with ownership. The invariant to preserve is that for any address `a` the value returned by
* `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`.
*/
function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
return _owners[tokenId];
}
/**
* @dev Returns the approved address for `tokenId`. Returns 0 if `tokenId` is not minted.
*/
function _getApproved(uint256 tokenId) internal view virtual returns (address) {
return _tokenApprovals[tokenId];
}
/**
* @dev Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in
* particular (ignoring whether it is owned by `owner`).
*
* WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
* assumption.
*/
function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) {
return
spender != address(0) &&
(owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender);
}
/**
* @dev Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner.
* Reverts if:
* - `spender` does not have approval from `owner` for `tokenId`.
* - `spender` does not have approval to manage all of `owner`'s assets.
*
* WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
* assumption.
*/
function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual {
if (!_isAuthorized(owner, spender, tokenId)) {
if (owner == address(0)) {
revert ERC721NonexistentToken(tokenId);
} else {
revert ERC721InsufficientApproval(spender, tokenId);
}
}
}
/**
* @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
*
* NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that
* a uint256 would ever overflow from increments when these increments are bounded to uint128 values.
*
* WARNING: Increasing an account's balance using this function tends to be paired with an override of the
* {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership
* remain consistent with one another.
*/
function _increaseBalance(address account, uint128 value) internal virtual {
unchecked {
_balances[account] += value;
}
}
/**
* @dev Transfers `tokenId` from its current owner to `to`, or alternatively mints (or burns) if the current owner
* (or `to`) is the zero address. Returns the owner of the `tokenId` before the update.
*
* The `auth` argument is optional. If the value passed is non 0, then this function will check that
* `auth` is either the owner of the token, or approved to operate on the token (by the owner).
*
* Emits a {Transfer} event.
*
* NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}.
*/
function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) {
address from = _ownerOf(tokenId);
// Perform (optional) operator check
if (auth != address(0)) {
_checkAuthorized(from, auth, tokenId);
}
// Execute the update
if (from != address(0)) {
// Clear approval. No need to re-authorize or emit the Approval event
_approve(address(0), tokenId, address(0), false);
unchecked {
_balances[from] -= 1;
}
}
if (to != address(0)) {
unchecked {
_balances[to] += 1;
}
}
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
return from;
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
address previousOwner = _update(to, tokenId, address(0));
if (previousOwner != address(0)) {
revert ERC721InvalidSender(address(0));
}
}
/**
* @dev Mints `tokenId`, transfers it to `to` and checks for `to` acceptance.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {
_mint(to, tokenId);
ERC721Utils.checkOnERC721Received(_msgSender(), address(0), to, tokenId, data);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
* This is an internal function that does not check if the sender is authorized to operate on the token.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal {
address previousOwner = _update(address(0), tokenId, address(0));
if (previousOwner == address(0)) {
revert ERC721NonexistentToken(tokenId);
}
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 tokenId) internal {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
address previousOwner = _update(to, tokenId, address(0));
if (previousOwner == address(0)) {
revert ERC721NonexistentToken(tokenId);
} else if (previousOwner != from) {
revert ERC721IncorrectOwner(from, tokenId, previousOwner);
}
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking that contract recipients
* are aware of the ERC-721 standard to prevent tokens from being forever locked.
*
* `data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is like {safeTransferFrom} in the sense that it invokes
* {IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `tokenId` token must exist and be owned by `from`.
* - `to` cannot be the zero address.
* - `from` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(address from, address to, uint256 tokenId) internal {
_safeTransfer(from, to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[`_safeTransfer`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {
_transfer(from, to, tokenId);
ERC721Utils.checkOnERC721Received(_msgSender(), from, to, tokenId, data);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* The `auth` argument is optional. If the value passed is non 0, then this function will check that `auth` is
* either the owner of the token, or approved to operate on all tokens held by this owner.
*
* Emits an {Approval} event.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address to, uint256 tokenId, address auth) internal {
_approve(to, tokenId, auth, true);
}
/**
* @dev Variant of `_approve` with an optional flag to enable or disable the {Approval} event. The event is not
* emitted in the context of transfers.
*/
function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual {
// Avoid reading the owner unless necessary
if (emitEvent || auth != address(0)) {
address owner = _requireOwned(tokenId);
// We do not use _isAuthorized because single-token approvals should not be able to call approve
if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) {
revert ERC721InvalidApprover(auth);
}
if (emitEvent) {
emit Approval(owner, to, tokenId);
}
}
_tokenApprovals[tokenId] = to;
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Requirements:
* - operator can't be the address zero.
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
if (operator == address(0)) {
revert ERC721InvalidOperator(operator);
}
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned).
* Returns the owner.
*
* Overrides to ownership logic should be done to {_ownerOf}.
*/
function _requireOwned(uint256 tokenId) internal view returns (address) {
address owner = _ownerOf(tokenId);
if (owner == address(0)) {
revert ERC721NonexistentToken(tokenId);
}
return owner;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/extensions/ERC721Enumerable.sol)
pragma solidity ^0.8.20;
import {ERC721} from "../ERC721.sol";
import {IERC721Enumerable} from "./IERC721Enumerable.sol";
import {IERC165} from "../../../utils/introspection/ERC165.sol";
/**
* @dev This implements an optional extension of {ERC721} defined in the ERC that adds enumerability
* of all the token ids in the contract as well as all token ids owned by each account.
*
* CAUTION: {ERC721} extensions that implement custom `balanceOf` logic, such as {ERC721Consecutive},
* interfere with enumerability and should not be used together with {ERC721Enumerable}.
*/
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
mapping(address owner => mapping(uint256 index => uint256)) private _ownedTokens;
mapping(uint256 tokenId => uint256) private _ownedTokensIndex;
uint256[] private _allTokens;
mapping(uint256 tokenId => uint256) private _allTokensIndex;
/**
* @dev An `owner`'s token query was out of bounds for `index`.
*
* NOTE: The owner being `address(0)` indicates a global out of bounds index.
*/
error ERC721OutOfBoundsIndex(address owner, uint256 index);
/**
* @dev Batch mint is not allowed.
*/
error ERC721EnumerableForbiddenBatchMint();
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256) {
if (index >= balanceOf(owner)) {
revert ERC721OutOfBoundsIndex(owner, index);
}
return _ownedTokens[owner][index];
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
return _allTokens.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual returns (uint256) {
if (index >= totalSupply()) {
revert ERC721OutOfBoundsIndex(address(0), index);
}
return _allTokens[index];
}
/**
* @dev See {ERC721-_update}.
*/
function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address) {
address previousOwner = super._update(to, tokenId, auth);
if (previousOwner == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (previousOwner != to) {
_removeTokenFromOwnerEnumeration(previousOwner, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (previousOwner != to) {
_addTokenToOwnerEnumeration(to, tokenId);
}
return previousOwner;
}
/**
* @dev Private function to add a token to this extension's ownership-tracking data structures.
* @param to address representing the new owner of the given token ID
* @param tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = balanceOf(to) - 1;
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
/**
* @dev Private function to add a token to this extension's token tracking data structures.
* @param tokenId uint256 ID of the token to be added to the tokens list
*/
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
/**
* @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
* while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
* gas optimizations e.g. when performing a transfer operation (avoiding double writes).
* This has O(1) time complexity, but alters the order of the _ownedTokens array.
* @param from address representing the previous owner of the given token ID
* @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = balanceOf(from);
uint256 tokenIndex = _ownedTokensIndex[tokenId];
mapping(uint256 index => uint256) storage _ownedTokensByOwner = _ownedTokens[from];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokensByOwner[lastTokenIndex];
_ownedTokensByOwner[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
delete _ownedTokensIndex[tokenId];
delete _ownedTokensByOwner[lastTokenIndex];
}
/**
* @dev Private function to remove a token from this extension's token tracking data structures.
* This has O(1) time complexity, but alters the order of the _allTokens array.
* @param tokenId uint256 ID of the token to be removed from the tokens list
*/
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
/**
* See {ERC721-_increaseBalance}. We need that to account tokens that were minted in batch
*/
function _increaseBalance(address account, uint128 amount) internal virtual override {
if (amount > 0) {
revert ERC721EnumerableForbiddenBatchMint();
}
super._increaseBalance(account, amount);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC-721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC-721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
* {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the address zero.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.20;
import {IERC721} from "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC721/utils/ERC721Utils.sol)
pragma solidity ^0.8.20;
import {IERC721Receiver} from "../IERC721Receiver.sol";
import {IERC721Errors} from "../../../interfaces/draft-IERC6093.sol";
/**
* @dev Library that provide common ERC-721 utility functions.
*
* See https://eips.ethereum.org/EIPS/eip-721[ERC-721].
*
* _Available since v5.1._
*/
library ERC721Utils {
/**
* @dev Performs an acceptance check for the provided `operator` by calling {IERC721Receiver-onERC721Received}
* on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).
*
* The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
* Otherwise, the recipient must implement {IERC721Receiver-onERC721Received} and return the acceptance magic value to accept
* the transfer.
*/
function checkOnERC721Received(
address operator,
address from,
address to,
uint256 tokenId,
bytes memory data
) internal {
if (to.code.length > 0) {
try IERC721Receiver(to).onERC721Received(operator, from, tokenId, data) returns (bytes4 retval) {
if (retval != IERC721Receiver.onERC721Received.selector) {
// Token rejected
revert IERC721Errors.ERC721InvalidReceiver(to);
}
} catch (bytes memory reason) {
if (reason.length == 0) {
// non-IERC721Receiver implementer
revert IERC721Errors.ERC721InvalidReceiver(to);
} else {
assembly ("memory-safe") {
revert(add(32, reason), mload(reason))
}
}
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/Strings.sol)
pragma solidity ^0.8.20;
import {Math} from "./math/Math.sol";
import {SafeCast} from "./math/SafeCast.sol";
import {SignedMath} from "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
using SafeCast for *;
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
uint8 private constant ADDRESS_LENGTH = 20;
uint256 private constant SPECIAL_CHARS_LOOKUP =
(1 << 0x08) | // backspace
(1 << 0x09) | // tab
(1 << 0x0a) | // newline
(1 << 0x0c) | // form feed
(1 << 0x0d) | // carriage return
(1 << 0x22) | // double quote
(1 << 0x5c); // backslash
/**
* @dev The `value` string doesn't fit in the specified `length`.
*/
error StringsInsufficientHexLength(uint256 value, uint256 length);
/**
* @dev The string being parsed contains characters that are not in scope of the given base.
*/
error StringsInvalidChar();
/**
* @dev The string being parsed is not a properly formatted address.
*/
error StringsInvalidAddressFormat();
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
assembly ("memory-safe") {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
assembly ("memory-safe") {
mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toStringSigned(int256 value) internal pure returns (string memory) {
return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
uint256 localValue = value;
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = HEX_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
revert StringsInsufficientHexLength(value, length);
}
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
* representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal
* representation, according to EIP-55.
*/
function toChecksumHexString(address addr) internal pure returns (string memory) {
bytes memory buffer = bytes(toHexString(addr));
// hash the hex part of buffer (skip length + 2 bytes, length 40)
uint256 hashValue;
assembly ("memory-safe") {
hashValue := shr(96, keccak256(add(buffer, 0x22), 40))
}
for (uint256 i = 41; i > 1; --i) {
// possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f)
if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) {
// case shift by xoring with 0x20
buffer[i] ^= 0x20;
}
hashValue >>= 4;
}
return string(buffer);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
/**
* @dev Parse a decimal string and returns the value as a `uint256`.
*
* Requirements:
* - The string must be formatted as `[0-9]*`
* - The result must fit into an `uint256` type
*/
function parseUint(string memory input) internal pure returns (uint256) {
return parseUint(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseUint-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `[0-9]*`
* - The result must fit into an `uint256` type
*/
function parseUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
(bool success, uint256 value) = tryParseUint(input, begin, end);
if (!success) revert StringsInvalidChar();
return value;
}
/**
* @dev Variant of {parseUint-string} that returns false if the parsing fails because of an invalid character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseUint(string memory input) internal pure returns (bool success, uint256 value) {
return _tryParseUintUncheckedBounds(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseUint-string-uint256-uint256} that returns false if the parsing fails because of an invalid
* character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseUint(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, uint256 value) {
if (end > bytes(input).length || begin > end) return (false, 0);
return _tryParseUintUncheckedBounds(input, begin, end);
}
/**
* @dev Implementation of {tryParseUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseUintUncheckedBounds(
string memory input,
uint256 begin,
uint256 end
) private pure returns (bool success, uint256 value) {
bytes memory buffer = bytes(input);
uint256 result = 0;
for (uint256 i = begin; i < end; ++i) {
uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
if (chr > 9) return (false, 0);
result *= 10;
result += chr;
}
return (true, result);
}
/**
* @dev Parse a decimal string and returns the value as a `int256`.
*
* Requirements:
* - The string must be formatted as `[-+]?[0-9]*`
* - The result must fit in an `int256` type.
*/
function parseInt(string memory input) internal pure returns (int256) {
return parseInt(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseInt-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `[-+]?[0-9]*`
* - The result must fit in an `int256` type.
*/
function parseInt(string memory input, uint256 begin, uint256 end) internal pure returns (int256) {
(bool success, int256 value) = tryParseInt(input, begin, end);
if (!success) revert StringsInvalidChar();
return value;
}
/**
* @dev Variant of {parseInt-string} that returns false if the parsing fails because of an invalid character or if
* the result does not fit in a `int256`.
*
* NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
*/
function tryParseInt(string memory input) internal pure returns (bool success, int256 value) {
return _tryParseIntUncheckedBounds(input, 0, bytes(input).length);
}
uint256 private constant ABS_MIN_INT256 = 2 ** 255;
/**
* @dev Variant of {parseInt-string-uint256-uint256} that returns false if the parsing fails because of an invalid
* character or if the result does not fit in a `int256`.
*
* NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
*/
function tryParseInt(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, int256 value) {
if (end > bytes(input).length || begin > end) return (false, 0);
return _tryParseIntUncheckedBounds(input, begin, end);
}
/**
* @dev Implementation of {tryParseInt-string-uint256-uint256} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseIntUncheckedBounds(
string memory input,
uint256 begin,
uint256 end
) private pure returns (bool success, int256 value) {
bytes memory buffer = bytes(input);
// Check presence of a negative sign.
bytes1 sign = begin == end ? bytes1(0) : bytes1(_unsafeReadBytesOffset(buffer, begin)); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
bool positiveSign = sign == bytes1("+");
bool negativeSign = sign == bytes1("-");
uint256 offset = (positiveSign || negativeSign).toUint();
(bool absSuccess, uint256 absValue) = tryParseUint(input, begin + offset, end);
if (absSuccess && absValue < ABS_MIN_INT256) {
return (true, negativeSign ? -int256(absValue) : int256(absValue));
} else if (absSuccess && negativeSign && absValue == ABS_MIN_INT256) {
return (true, type(int256).min);
} else return (false, 0);
}
/**
* @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as a `uint256`.
*
* Requirements:
* - The string must be formatted as `(0x)?[0-9a-fA-F]*`
* - The result must fit in an `uint256` type.
*/
function parseHexUint(string memory input) internal pure returns (uint256) {
return parseHexUint(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseHexUint-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `(0x)?[0-9a-fA-F]*`
* - The result must fit in an `uint256` type.
*/
function parseHexUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
(bool success, uint256 value) = tryParseHexUint(input, begin, end);
if (!success) revert StringsInvalidChar();
return value;
}
/**
* @dev Variant of {parseHexUint-string} that returns false if the parsing fails because of an invalid character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseHexUint(string memory input) internal pure returns (bool success, uint256 value) {
return _tryParseHexUintUncheckedBounds(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseHexUint-string-uint256-uint256} that returns false if the parsing fails because of an
* invalid character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseHexUint(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, uint256 value) {
if (end > bytes(input).length || begin > end) return (false, 0);
return _tryParseHexUintUncheckedBounds(input, begin, end);
}
/**
* @dev Implementation of {tryParseHexUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseHexUintUncheckedBounds(
string memory input,
uint256 begin,
uint256 end
) private pure returns (bool success, uint256 value) {
bytes memory buffer = bytes(input);
// skip 0x prefix if present
bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(buffer, begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
uint256 offset = hasPrefix.toUint() * 2;
uint256 result = 0;
for (uint256 i = begin + offset; i < end; ++i) {
uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
if (chr > 15) return (false, 0);
result *= 16;
unchecked {
// Multiplying by 16 is equivalent to a shift of 4 bits (with additional overflow check).
// This guarantees that adding a value < 16 will not cause an overflow, hence the unchecked.
result += chr;
}
}
return (true, result);
}
/**
* @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as an `address`.
*
* Requirements:
* - The string must be formatted as `(0x)?[0-9a-fA-F]{40}`
*/
function parseAddress(string memory input) internal pure returns (address) {
return parseAddress(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseAddress-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `(0x)?[0-9a-fA-F]{40}`
*/
function parseAddress(string memory input, uint256 begin, uint256 end) internal pure returns (address) {
(bool success, address value) = tryParseAddress(input, begin, end);
if (!success) revert StringsInvalidAddressFormat();
return value;
}
/**
* @dev Variant of {parseAddress-string} that returns false if the parsing fails because the input is not a properly
* formatted address. See {parseAddress-string} requirements.
*/
function tryParseAddress(string memory input) internal pure returns (bool success, address value) {
return tryParseAddress(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseAddress-string-uint256-uint256} that returns false if the parsing fails because input is not a properly
* formatted address. See {parseAddress-string-uint256-uint256} requirements.
*/
function tryParseAddress(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, address value) {
if (end > bytes(input).length || begin > end) return (false, address(0));
bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(bytes(input), begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
uint256 expectedLength = 40 + hasPrefix.toUint() * 2;
// check that input is the correct length
if (end - begin == expectedLength) {
// length guarantees that this does not overflow, and value is at most type(uint160).max
(bool s, uint256 v) = _tryParseHexUintUncheckedBounds(input, begin, end);
return (s, address(uint160(v)));
} else {
return (false, address(0));
}
}
function _tryParseChr(bytes1 chr) private pure returns (uint8) {
uint8 value = uint8(chr);
// Try to parse `chr`:
// - Case 1: [0-9]
// - Case 2: [a-f]
// - Case 3: [A-F]
// - otherwise not supported
unchecked {
if (value > 47 && value < 58) value -= 48;
else if (value > 96 && value < 103) value -= 87;
else if (value > 64 && value < 71) value -= 55;
else return type(uint8).max;
}
return value;
}
/**
* @dev Escape special characters in JSON strings. This can be useful to prevent JSON injection in NFT metadata.
*
* WARNING: This function should only be used in double quoted JSON strings. Single quotes are not escaped.
*
* NOTE: This function escapes all unicode characters, and not just the ones in ranges defined in section 2.5 of
* RFC-4627 (U+0000 to U+001F, U+0022 and U+005C). ECMAScript's `JSON.parse` does recover escaped unicode
* characters that are not in this range, but other tooling may provide different results.
*/
function escapeJSON(string memory input) internal pure returns (string memory) {
bytes memory buffer = bytes(input);
bytes memory output = new bytes(2 * buffer.length); // worst case scenario
uint256 outputLength = 0;
for (uint256 i; i < buffer.length; ++i) {
bytes1 char = bytes1(_unsafeReadBytesOffset(buffer, i));
if (((SPECIAL_CHARS_LOOKUP & (1 << uint8(char))) != 0)) {
output[outputLength++] = "\\";
if (char == 0x08) output[outputLength++] = "b";
else if (char == 0x09) output[outputLength++] = "t";
else if (char == 0x0a) output[outputLength++] = "n";
else if (char == 0x0c) output[outputLength++] = "f";
else if (char == 0x0d) output[outputLength++] = "r";
else if (char == 0x5c) output[outputLength++] = "\\";
else if (char == 0x22) {
// solhint-disable-next-line quotes
output[outputLength++] = '"';
}
} else {
output[outputLength++] = char;
}
}
// write the actual length and deallocate unused memory
assembly ("memory-safe") {
mstore(output, outputLength)
mstore(0x40, add(output, shl(5, shr(5, add(outputLength, 63)))))
}
return string(output);
}
/**
* @dev Reads a bytes32 from a bytes array without bounds checking.
*
* NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the
* assembly block as such would prevent some optimizations.
*/
function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) {
// This is not memory safe in the general case, but all calls to this private function are within bounds.
assembly ("memory-safe") {
value := mload(add(buffer, add(0x20, offset)))
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC-721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC-1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.20;
/**
* @title ERC-721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC-721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be
* reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Return the 512-bit addition of two uint256.
*
* The result is stored in two 256 variables such that sum = high * 2²⁵⁶ + low.
*/
function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
assembly ("memory-safe") {
low := add(a, b)
high := lt(low, a)
}
}
/**
* @dev Return the 512-bit multiplication of two uint256.
*
* The result is stored in two 256 variables such that product = high * 2²⁵⁶ + low.
*/
function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
// 512-bit multiply [high low] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
// the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = high * 2²⁵⁶ + low.
assembly ("memory-safe") {
let mm := mulmod(a, b, not(0))
low := mul(a, b)
high := sub(sub(mm, low), lt(mm, low))
}
}
/**
* @dev Returns the addition of two unsigned integers, with a success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
success = c >= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with a success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a - b;
success = c <= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with a success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a * b;
assembly ("memory-safe") {
// Only true when the multiplication doesn't overflow
// (c / a == b) || (a == 0)
success := or(eq(div(c, a), b), iszero(a))
}
// equivalent to: success ? c : 0
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
success = b > 0;
assembly ("memory-safe") {
// The `DIV` opcode returns zero when the denominator is 0.
result := div(a, b)
}
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
success = b > 0;
assembly ("memory-safe") {
// The `MOD` opcode returns zero when the denominator is 0.
result := mod(a, b)
}
}
}
/**
* @dev Unsigned saturating addition, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryAdd(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @dev Unsigned saturating subtraction, bounds to zero instead of overflowing.
*/
function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256) {
(, uint256 result) = trySub(a, b);
return result;
}
/**
* @dev Unsigned saturating multiplication, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryMul(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * SafeCast.toUint(condition));
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
Panic.panic(Panic.DIVISION_BY_ZERO);
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
}
}
/**
* @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
*
* Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
(uint256 high, uint256 low) = mul512(x, y);
// Handle non-overflow cases, 256 by 256 division.
if (high == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return low / denominator;
}
// Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
if (denominator <= high) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [high low].
uint256 remainder;
assembly ("memory-safe") {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
high := sub(high, gt(remainder, low))
low := sub(low, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly ("memory-safe") {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [high low] by twos.
low := div(low, twos)
// Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from high into low.
low |= high * twos;
// Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
// that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv ≡ 1 mod 2⁴.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2⁸
inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
inverse *= 2 - denominator * inverse; // inverse mod 2³²
inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is
// less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and high
// is no longer required.
result = low * inverse;
return result;
}
}
/**
* @dev Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
}
/**
* @dev Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.
*/
function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result) {
unchecked {
(uint256 high, uint256 low) = mul512(x, y);
if (high >= 1 << n) {
Panic.panic(Panic.UNDER_OVERFLOW);
}
return (high << (256 - n)) | (low >> n);
}
}
/**
* @dev Calculates x * y >> n with full precision, following the selected rounding direction.
*/
function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256) {
return mulShr(x, y, n) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, 1 << n) > 0);
}
/**
* @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
*
* If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
* If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
*
* If the input value is not inversible, 0 is returned.
*
* NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
* inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
*/
function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
unchecked {
if (n == 0) return 0;
// The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
// Used to compute integers x and y such that: ax + ny = gcd(a, n).
// When the gcd is 1, then the inverse of a modulo n exists and it's x.
// ax + ny = 1
// ax = 1 + (-y)n
// ax ≡ 1 (mod n) # x is the inverse of a modulo n
// If the remainder is 0 the gcd is n right away.
uint256 remainder = a % n;
uint256 gcd = n;
// Therefore the initial coefficients are:
// ax + ny = gcd(a, n) = n
// 0a + 1n = n
int256 x = 0;
int256 y = 1;
while (remainder != 0) {
uint256 quotient = gcd / remainder;
(gcd, remainder) = (
// The old remainder is the next gcd to try.
remainder,
// Compute the next remainder.
// Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
// where gcd is at most n (capped to type(uint256).max)
gcd - remainder * quotient
);
(x, y) = (
// Increment the coefficient of a.
y,
// Decrement the coefficient of n.
// Can overflow, but the result is casted to uint256 so that the
// next value of y is "wrapped around" to a value between 0 and n - 1.
x - y * int256(quotient)
);
}
if (gcd != 1) return 0; // No inverse exists.
return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
}
}
/**
* @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
*
* From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
* prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
* `a**(p-2)` is the modular multiplicative inverse of a in Fp.
*
* NOTE: this function does NOT check that `p` is a prime greater than `2`.
*/
function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
unchecked {
return Math.modExp(a, p - 2, p);
}
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
*
* Requirements:
* - modulus can't be zero
* - underlying staticcall to precompile must succeed
*
* IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
* sure the chain you're using it on supports the precompiled contract for modular exponentiation
* at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
* the underlying function will succeed given the lack of a revert, but the result may be incorrectly
* interpreted as 0.
*/
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
(bool success, uint256 result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
* It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
* to operate modulo 0 or if the underlying precompile reverted.
*
* IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
* you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
* https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
* of a revert, but the result may be incorrectly interpreted as 0.
*/
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
if (m == 0) return (false, 0);
assembly ("memory-safe") {
let ptr := mload(0x40)
// | Offset | Content | Content (Hex) |
// |-----------|------------|--------------------------------------------------------------------|
// | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x60:0x7f | value of b | 0x<.............................................................b> |
// | 0x80:0x9f | value of e | 0x<.............................................................e> |
// | 0xa0:0xbf | value of m | 0x<.............................................................m> |
mstore(ptr, 0x20)
mstore(add(ptr, 0x20), 0x20)
mstore(add(ptr, 0x40), 0x20)
mstore(add(ptr, 0x60), b)
mstore(add(ptr, 0x80), e)
mstore(add(ptr, 0xa0), m)
// Given the result < m, it's guaranteed to fit in 32 bytes,
// so we can use the memory scratch space located at offset 0.
success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
result := mload(0x00)
}
}
/**
* @dev Variant of {modExp} that supports inputs of arbitrary length.
*/
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
(bool success, bytes memory result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Variant of {tryModExp} that supports inputs of arbitrary length.
*/
function tryModExp(
bytes memory b,
bytes memory e,
bytes memory m
) internal view returns (bool success, bytes memory result) {
if (_zeroBytes(m)) return (false, new bytes(0));
uint256 mLen = m.length;
// Encode call args in result and move the free memory pointer
result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
assembly ("memory-safe") {
let dataPtr := add(result, 0x20)
// Write result on top of args to avoid allocating extra memory.
success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
// Overwrite the length.
// result.length > returndatasize() is guaranteed because returndatasize() == m.length
mstore(result, mLen)
// Set the memory pointer after the returned data.
mstore(0x40, add(dataPtr, mLen))
}
}
/**
* @dev Returns whether the provided byte array is zero.
*/
function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
for (uint256 i = 0; i < byteArray.length; ++i) {
if (byteArray[i] != 0) {
return false;
}
}
return true;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* This method is based on Newton's method for computing square roots; the algorithm is restricted to only
* using integer operations.
*/
function sqrt(uint256 a) internal pure returns (uint256) {
unchecked {
// Take care of easy edge cases when a == 0 or a == 1
if (a <= 1) {
return a;
}
// In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
// sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
// the current value as `ε_n = | x_n - sqrt(a) |`.
//
// For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
// of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
// bigger than any uint256.
//
// By noticing that
// `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
// we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
// to the msb function.
uint256 aa = a;
uint256 xn = 1;
if (aa >= (1 << 128)) {
aa >>= 128;
xn <<= 64;
}
if (aa >= (1 << 64)) {
aa >>= 64;
xn <<= 32;
}
if (aa >= (1 << 32)) {
aa >>= 32;
xn <<= 16;
}
if (aa >= (1 << 16)) {
aa >>= 16;
xn <<= 8;
}
if (aa >= (1 << 8)) {
aa >>= 8;
xn <<= 4;
}
if (aa >= (1 << 4)) {
aa >>= 4;
xn <<= 2;
}
if (aa >= (1 << 2)) {
xn <<= 1;
}
// We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
//
// We can refine our estimation by noticing that the middle of that interval minimizes the error.
// If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
// This is going to be our x_0 (and ε_0)
xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)
// From here, Newton's method give us:
// x_{n+1} = (x_n + a / x_n) / 2
//
// One should note that:
// x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
// = ((x_n² + a) / (2 * x_n))² - a
// = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
// = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
// = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
// = (x_n² - a)² / (2 * x_n)²
// = ((x_n² - a) / (2 * x_n))²
// ≥ 0
// Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
//
// This gives us the proof of quadratic convergence of the sequence:
// ε_{n+1} = | x_{n+1} - sqrt(a) |
// = | (x_n + a / x_n) / 2 - sqrt(a) |
// = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
// = | (x_n - sqrt(a))² / (2 * x_n) |
// = | ε_n² / (2 * x_n) |
// = ε_n² / | (2 * x_n) |
//
// For the first iteration, we have a special case where x_0 is known:
// ε_1 = ε_0² / | (2 * x_0) |
// ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
// ≤ 2**(2*e-4) / (3 * 2**(e-1))
// ≤ 2**(e-3) / 3
// ≤ 2**(e-3-log2(3))
// ≤ 2**(e-4.5)
//
// For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
// ε_{n+1} = ε_n² / | (2 * x_n) |
// ≤ (2**(e-k))² / (2 * 2**(e-1))
// ≤ 2**(2*e-2*k) / 2**e
// ≤ 2**(e-2*k)
xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above
xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5
xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9
xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18
xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36
xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72
// Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
// ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
// sqrt(a) or sqrt(a) + 1.
return xn - SafeCast.toUint(xn > a / xn);
}
}
/**
* @dev Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// If upper 8 bits of 16-bit half set, add 8 to result
r |= SafeCast.toUint((x >> r) > 0xff) << 3;
// If upper 4 bits of 8-bit half set, add 4 to result
r |= SafeCast.toUint((x >> r) > 0xf) << 2;
// Shifts value right by the current result and use it as an index into this lookup table:
//
// | x (4 bits) | index | table[index] = MSB position |
// |------------|---------|-----------------------------|
// | 0000 | 0 | table[0] = 0 |
// | 0001 | 1 | table[1] = 0 |
// | 0010 | 2 | table[2] = 1 |
// | 0011 | 3 | table[3] = 1 |
// | 0100 | 4 | table[4] = 2 |
// | 0101 | 5 | table[5] = 2 |
// | 0110 | 6 | table[6] = 2 |
// | 0111 | 7 | table[7] = 2 |
// | 1000 | 8 | table[8] = 3 |
// | 1001 | 9 | table[9] = 3 |
// | 1010 | 10 | table[10] = 3 |
// | 1011 | 11 | table[11] = 3 |
// | 1100 | 12 | table[12] = 3 |
// | 1101 | 13 | table[13] = 3 |
// | 1110 | 14 | table[14] = 3 |
// | 1111 | 15 | table[15] = 3 |
//
// The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the last 16 bytes.
assembly ("memory-safe") {
r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))
}
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8
return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.20;
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * int256(SafeCast.toUint(condition)));
}
}
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// Formula from the "Bit Twiddling Hacks" by Sean Eron Anderson.
// Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift,
// taking advantage of the most significant (or "sign" bit) in two's complement representation.
// This opcode adds new most significant bits set to the value of the previous most significant bit. As a result,
// the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative).
int256 mask = n >> 255;
// A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it.
return uint256((n + mask) ^ mask);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)
pragma solidity ^0.8.20;
/**
* @dev Helper library for emitting standardized panic codes.
*
* ```solidity
* contract Example {
* using Panic for uint256;
*
* // Use any of the declared internal constants
* function foo() { Panic.GENERIC.panic(); }
*
* // Alternatively
* function foo() { Panic.panic(Panic.GENERIC); }
* }
* ```
*
* Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
*
* _Available since v5.1._
*/
// slither-disable-next-line unused-state
library Panic {
/// @dev generic / unspecified error
uint256 internal constant GENERIC = 0x00;
/// @dev used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
/// @dev arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
/// @dev division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
/// @dev enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
/// @dev invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
/// @dev empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
/// @dev array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
/// @dev resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
/// @dev calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
/// @dev Reverts with a panic code. Recommended to use with
/// the internal constants with predefined codes.
function panic(uint256 code) internal pure {
assembly ("memory-safe") {
mstore(0x00, 0x4e487b71)
mstore(0x20, code)
revert(0x1c, 0x24)
}
}
}{
"remappings": [
"@account-abstraction/contracts/=node_modules/@account-abstraction/contracts/",
"@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/",
"forge-std/=node_modules/forge-std/src/",
"solady/=node_modules/solady/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": true,
"libraries": {
"src/CommentManager.sol": {
"Approvals": "0xb2286303d50c90f619d68feea5901947abc72726",
"Batching": "0xf30fccf0e8b483ae61be8731fd736ef794a63ac7",
"CommentOps": "0x150bde577c858a9f656c810f8781fe56f1b84bac",
"MetadataOps": "0xf3994bf7e3d258fd8fdca360b6f6c6dc8ce51690"
}
}
}Contract ABI
API[{"inputs":[{"internalType":"address","name":"initialOwner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyInitialized","type":"error"},{"inputs":[{"internalType":"uint256","name":"operationIndex","type":"uint256"},{"internalType":"bytes","name":"reason","type":"bytes"}],"name":"BatchOperationFailed","type":"error"},{"inputs":[],"name":"ChannelDoesNotExist","type":"error"},{"inputs":[],"name":"CommentAlreadyDeleted","type":"error"},{"inputs":[],"name":"CommentAlreadyExists","type":"error"},{"inputs":[],"name":"CommentDoesNotExist","type":"error"},{"inputs":[],"name":"HookMetadataTooLong","type":"error"},{"inputs":[],"name":"HookNotEnabled","type":"error"},{"inputs":[{"internalType":"uint256","name":"providedValue","type":"uint256"},{"internalType":"uint256","name":"requiredValue","type":"uint256"}],"name":"InsufficientValue","type":"error"},{"inputs":[],"name":"InvalidAppSignature","type":"error"},{"inputs":[],"name":"InvalidApprovalExpiry","type":"error"},{"inputs":[],"name":"InvalidAuthorSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"operationIndex","type":"uint256"},{"internalType":"string","name":"reason","type":"string"}],"name":"InvalidBatchOperation","type":"error"},{"inputs":[{"internalType":"string","name":"message","type":"string"}],"name":"InvalidCommentReference","type":"error"},{"inputs":[],"name":"InvalidKey","type":"error"},{"inputs":[{"internalType":"address","name":"author","type":"address"},{"internalType":"address","name":"app","type":"address"},{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"provided","type":"uint256"}],"name":"InvalidNonce","type":"error"},{"inputs":[{"internalType":"string","name":"reason","type":"string"}],"name":"InvalidReactionReference","type":"error"},{"inputs":[],"name":"InvalidSignatureLength","type":"error"},{"inputs":[],"name":"InvalidSignatureS","type":"error"},{"inputs":[{"internalType":"uint256","name":"providedValue","type":"uint256"},{"internalType":"uint256","name":"requiredValue","type":"uint256"}],"name":"InvalidValueDistribution","type":"error"},{"inputs":[],"name":"MetadataTooLong","type":"error"},{"inputs":[],"name":"NewOwnerIsZeroAddress","type":"error"},{"inputs":[],"name":"NoHandoverRequest","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"},{"internalType":"address","name":"requiredCaller","type":"address"}],"name":"NotAuthorized","type":"error"},{"inputs":[],"name":"ParentCommentHasNeverExisted","type":"error"},{"inputs":[],"name":"ParentCommentNotInSameChannel","type":"error"},{"inputs":[],"name":"ReactionCannotBeEdited","type":"error"},{"inputs":[],"name":"Reentrancy","type":"error"},{"inputs":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"currentTime","type":"uint256"}],"name":"SignatureDeadlineReached","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"author","type":"address"},{"indexed":true,"internalType":"address","name":"app","type":"address"},{"indexed":false,"internalType":"uint256","name":"expiry","type":"uint256"}],"name":"ApprovalAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"author","type":"address"},{"indexed":true,"internalType":"address","name":"app","type":"address"}],"name":"ApprovalRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"operationsCount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalValue","type":"uint256"}],"name":"BatchOperationExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"commentId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"author","type":"address"},{"indexed":true,"internalType":"address","name":"app","type":"address"},{"indexed":false,"internalType":"uint256","name":"channelId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"parentId","type":"bytes32"},{"indexed":false,"internalType":"uint96","name":"createdAt","type":"uint96"},{"indexed":false,"internalType":"string","name":"content","type":"string"},{"indexed":false,"internalType":"string","name":"targetUri","type":"string"},{"indexed":false,"internalType":"uint8","name":"commentType","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"authMethod","type":"uint8"},{"components":[{"internalType":"bytes32","name":"key","type":"bytes32"},{"internalType":"bytes","name":"value","type":"bytes"}],"indexed":false,"internalType":"struct Metadata.MetadataEntry[]","name":"metadata","type":"tuple[]"}],"name":"CommentAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"commentId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"author","type":"address"}],"name":"CommentDeleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"commentId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"author","type":"address"},{"indexed":true,"internalType":"address","name":"editedByApp","type":"address"},{"indexed":false,"internalType":"uint256","name":"channelId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"parentId","type":"bytes32"},{"indexed":false,"internalType":"uint96","name":"createdAt","type":"uint96"},{"indexed":false,"internalType":"uint96","name":"updatedAt","type":"uint96"},{"indexed":false,"internalType":"string","name":"content","type":"string"},{"indexed":false,"internalType":"string","name":"targetUri","type":"string"},{"indexed":false,"internalType":"uint8","name":"commentType","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"authMethod","type":"uint8"},{"components":[{"internalType":"bytes32","name":"key","type":"bytes32"},{"internalType":"bytes","name":"value","type":"bytes"}],"indexed":false,"internalType":"struct Metadata.MetadataEntry[]","name":"metadata","type":"tuple[]"}],"name":"CommentEdited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"commentId","type":"bytes32"},{"components":[{"internalType":"enum Metadata.MetadataOperation","name":"operation","type":"uint8"},{"internalType":"bytes32","name":"key","type":"bytes32"},{"internalType":"bytes","name":"value","type":"bytes"}],"indexed":false,"internalType":"struct Metadata.MetadataEntryOp[]","name":"operations","type":"tuple[]"}],"name":"CommentHookDataUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"commentId","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"key","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"value","type":"bytes"}],"name":"CommentHookMetadataSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"commentId","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"key","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"value","type":"bytes"}],"name":"CommentMetadataSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipHandoverCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipHandoverRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"app","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"}],"name":"addApproval","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"author","type":"address"},{"internalType":"address","name":"app","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"authorSignature","type":"bytes"}],"name":"addApprovalWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"enum Comments.BatchOperationType","name":"operationType","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"bytes[]","name":"signatures","type":"bytes[]"}],"internalType":"struct Comments.BatchOperation[]","name":"operations","type":"tuple[]"}],"name":"batchOperations","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"cancelOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"channelManager","outputs":[{"internalType":"contract IChannelManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"commentHookMetadata","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"commentHookMetadataKeys","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"commentMetadata","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"commentMetadataKeys","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pendingOwner","type":"address"}],"name":"completeOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commentId","type":"bytes32"}],"name":"deleteComment","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commentId","type":"bytes32"},{"internalType":"address","name":"app","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"authorSignature","type":"bytes"},{"internalType":"bytes","name":"appSignature","type":"bytes"}],"name":"deleteCommentWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commentId","type":"bytes32"},{"components":[{"internalType":"address","name":"app","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"string","name":"content","type":"string"},{"components":[{"internalType":"bytes32","name":"key","type":"bytes32"},{"internalType":"bytes","name":"value","type":"bytes"}],"internalType":"struct Metadata.MetadataEntry[]","name":"metadata","type":"tuple[]"}],"internalType":"struct Comments.EditComment","name":"editData","type":"tuple"},{"internalType":"bytes","name":"appSignature","type":"bytes"}],"name":"editComment","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commentId","type":"bytes32"},{"components":[{"internalType":"address","name":"app","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"string","name":"content","type":"string"},{"components":[{"internalType":"bytes32","name":"key","type":"bytes32"},{"internalType":"bytes","name":"value","type":"bytes"}],"internalType":"struct Metadata.MetadataEntry[]","name":"metadata","type":"tuple[]"}],"internalType":"struct Comments.EditComment","name":"editData","type":"tuple"},{"internalType":"bytes","name":"authorSignature","type":"bytes"},{"internalType":"bytes","name":"appSignature","type":"bytes"}],"name":"editCommentWithSig","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"author","type":"address"},{"internalType":"address","name":"app","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"getAddApprovalHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"author","type":"address"},{"internalType":"address","name":"app","type":"address"}],"name":"getApprovalExpiry","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commentId","type":"bytes32"}],"name":"getComment","outputs":[{"components":[{"internalType":"address","name":"author","type":"address"},{"internalType":"uint88","name":"createdAt","type":"uint88"},{"internalType":"enum Comments.AuthorAuthMethod","name":"authMethod","type":"uint8"},{"internalType":"address","name":"app","type":"address"},{"internalType":"uint88","name":"updatedAt","type":"uint88"},{"internalType":"uint8","name":"commentType","type":"uint8"},{"internalType":"uint256","name":"channelId","type":"uint256"},{"internalType":"bytes32","name":"parentId","type":"bytes32"},{"internalType":"string","name":"content","type":"string"},{"internalType":"string","name":"targetUri","type":"string"}],"internalType":"struct Comments.Comment","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commentId","type":"bytes32"}],"name":"getCommentHookMetadata","outputs":[{"components":[{"internalType":"bytes32","name":"key","type":"bytes32"},{"internalType":"bytes","name":"value","type":"bytes"}],"internalType":"struct Metadata.MetadataEntry[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commentId","type":"bytes32"}],"name":"getCommentHookMetadataKeys","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commentId","type":"bytes32"},{"internalType":"bytes32","name":"key","type":"bytes32"}],"name":"getCommentHookMetadataValue","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"author","type":"address"},{"internalType":"address","name":"app","type":"address"},{"internalType":"uint256","name":"channelId","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes32","name":"parentId","type":"bytes32"},{"internalType":"uint8","name":"commentType","type":"uint8"},{"internalType":"string","name":"content","type":"string"},{"components":[{"internalType":"bytes32","name":"key","type":"bytes32"},{"internalType":"bytes","name":"value","type":"bytes"}],"internalType":"struct Metadata.MetadataEntry[]","name":"metadata","type":"tuple[]"},{"internalType":"string","name":"targetUri","type":"string"}],"internalType":"struct Comments.CreateComment","name":"commentData","type":"tuple"}],"name":"getCommentId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commentId","type":"bytes32"}],"name":"getCommentMetadata","outputs":[{"components":[{"internalType":"bytes32","name":"key","type":"bytes32"},{"internalType":"bytes","name":"value","type":"bytes"}],"internalType":"struct Metadata.MetadataEntry[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commentId","type":"bytes32"}],"name":"getCommentMetadataKeys","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commentId","type":"bytes32"},{"internalType":"bytes32","name":"key","type":"bytes32"}],"name":"getCommentMetadataValue","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commentId","type":"bytes32"},{"internalType":"address","name":"author","type":"address"},{"internalType":"address","name":"app","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"getDeleteCommentHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commentId","type":"bytes32"},{"internalType":"address","name":"author","type":"address"},{"components":[{"internalType":"address","name":"app","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"string","name":"content","type":"string"},{"components":[{"internalType":"bytes32","name":"key","type":"bytes32"},{"internalType":"bytes","name":"value","type":"bytes"}],"internalType":"struct Metadata.MetadataEntry[]","name":"metadata","type":"tuple[]"}],"internalType":"struct Comments.EditComment","name":"editData","type":"tuple"}],"name":"getEditCommentHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"author","type":"address"},{"internalType":"address","name":"app","type":"address"}],"name":"getNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"author","type":"address"},{"internalType":"address","name":"app","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"getRemoveApprovalHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"author","type":"address"},{"internalType":"address","name":"app","type":"address"}],"name":"isApproved","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commentId","type":"bytes32"}],"name":"isDeleted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"result","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pendingOwner","type":"address"}],"name":"ownershipHandoverExpiresAt","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"author","type":"address"},{"internalType":"address","name":"app","type":"address"},{"internalType":"uint256","name":"channelId","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes32","name":"parentId","type":"bytes32"},{"internalType":"uint8","name":"commentType","type":"uint8"},{"internalType":"string","name":"content","type":"string"},{"components":[{"internalType":"bytes32","name":"key","type":"bytes32"},{"internalType":"bytes","name":"value","type":"bytes"}],"internalType":"struct Metadata.MetadataEntry[]","name":"metadata","type":"tuple[]"},{"internalType":"string","name":"targetUri","type":"string"}],"internalType":"struct Comments.CreateComment","name":"commentData","type":"tuple"},{"internalType":"bytes","name":"appSignature","type":"bytes"}],"name":"postComment","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"author","type":"address"},{"internalType":"address","name":"app","type":"address"},{"internalType":"uint256","name":"channelId","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes32","name":"parentId","type":"bytes32"},{"internalType":"uint8","name":"commentType","type":"uint8"},{"internalType":"string","name":"content","type":"string"},{"components":[{"internalType":"bytes32","name":"key","type":"bytes32"},{"internalType":"bytes","name":"value","type":"bytes"}],"internalType":"struct Metadata.MetadataEntry[]","name":"metadata","type":"tuple[]"},{"internalType":"string","name":"targetUri","type":"string"}],"internalType":"struct Comments.CreateComment","name":"commentData","type":"tuple"},{"internalType":"bytes","name":"authorSignature","type":"bytes"},{"internalType":"bytes","name":"appSignature","type":"bytes"}],"name":"postCommentWithSig","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"author","type":"address"},{"internalType":"address","name":"app","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"authorSignature","type":"bytes"}],"name":"removeApprovalWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"requestOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"app","type":"address"}],"name":"revokeApproval","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_channelContract","type":"address"}],"name":"updateChannelContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commentId","type":"bytes32"}],"name":"updateCommentHookData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60a080604052346101a157602081614ee7803803809161001f82856101a5565b8339810103126101a157516001600160a01b038116908190036101a15780156101925780638b78c6d819555f7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a360405161007d6040826101a5565b601a815260208101907f457468657265756d20436f6d6d656e74732050726f746f636f6c0000000000008252604051916100b86040846101a5565b600183526020830191603160f81b8352519020915190206040519060208201927f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8452604083015260608201524660808201523060a082015260a0815261012060c0826101a5565b519020608052604051614d0a90816101dd8239608051818181610ffa01528181611049015281816118370152818161196101528181611a7501528181611de001528181611f0c0152818161207b01528181612b3b01528181612ed40152818161351d015281816137730152613a040152f35b63d92e233d60e01b5f5260045ffd5b5f80fd5b601f909101601f19168101906001600160401b038211908210176101c857604052565b634e487b7160e01b5f52604160045260245ffdfe60806040526004361015610011575f80fd5b5f5f3560e01c8063035e3b751461205357806305c9a5d114611fcd57806306fdde0314611f6e578063144e661414611f3f5780631f3449fe14611ec75780632119073c14611ce657806323aa932c14611ca557806324d4207914611aec5780632569296214611aa15780632d229e7114611a4057806331c360241461185a5780633644e5151461181f578063385f4877146116485780633fab8ecd146115b4578063484685b0146115395780634b88f91e1461146057806354d1f13d1461141a57806354fd4d50146113d5578063558724a51461122857806356380be2146111c457806358595ba4146110ff5780635ce96cf7146110a9578063678233251461107a57806369b5cd041461101f5780636e0ce000146109145780636fab436414610fc2578063715018a614610f77578063762c08e214610ca757806386066c9d146105dd5780638c20d58714610aae5780638da5cb5b14610a815780638e3d471c146109ff578063a389783e1461094d578063a712eca414610914578063ac3cb72c1461088a578063b5c775d514610790578063d1d451ca14610767578063d605f6bb146106f7578063d828435d14610635578063e367e350146105dd578063f04e283e1461058f578063f2fde38b14610550578063fe1f2d70146102335763fee81cf4146101fe575f80fd5b34610230576020366003190112610230576102176120a8565b9063389a75e1600c5252602080600c2054604051908152f35b80fd5b506020366003190112610230576004356001600160401b0381116104a557366023820112156104a55780600401356001600160401b03811161054c5760248201918160051b3660248284010111610548573068929eee149b4bd21268541461053b573068929eee149b4bd212685573f30fccf0e8b483ae61be8731fd736ef794a63ac79160405191829163a2dcdd9f60e01b8352856044840160406004860152526064808401928401019187918960a21982360301915b8982106104fa57505050505090806020923460248301520381855af480156104ef576104bc575b5061031e82949394612333565b9361032c60405195866121fe565b828552601f1961033b84612333565b01845b8181106104a9575050835b8381106103f6575050506040519081523460208201527f3b8032d28c34fcac25523353721b303ab6f70304452d10939237194d1a1d56cc60403392a23868929eee149b4bd21268556040519182916020830160208452825180915260408401602060408360051b870101940192905b8282106103c757505050500390f35b919360019193955060206103e68192603f198a820301865288516120e8565b96019201920185949391926103b8565b846104058286859998996128c9565b843b156104a557816104339160405180938192636f819bbf60e11b83526040600484015260448301906127f2565b8660248301520381885af4801561049a57610481575b5050806104628161045d60019488876128c9565b613c50565b61046c82886128eb565b5261047781876128eb565b5001949394610349565b8161048b916121fe565b61049657855f610449565b8580fd5b6040513d84823e3d90fd5b5080fd5b606060208289018101919091520161033e565b6020813d6020116104e7575b816104d5602093836121fe565b810103126104e35751610311565b5f80fd5b3d91506104c8565b6040513d87823e3d90fd5b919395509193606319878203018552853584811215610537576020610527600193602486849501016127f2565b97019501920186959493916102ea565b8b80fd5b63ab143c0685526004601cfd5b8480fd5b8280fd5b506020366003190112610230576105656120a8565b61056d6138d5565b8060601b156105825761057f906139bf565b80f35b637448fbae82526004601cfd5b506020366003190112610230576105a46120a8565b6105ac6138d5565b63389a75e1600c528082526020600c20805442116105d057908261057f92556139bf565b636f5e881883526004601cfd5b50346102305761061661061d6040610631936105f83661223a565b908252600560205282822090825260205220604051928380926124f0565b03826121fe565b6040519182916020835260208301906120e8565b0390f35b50346102305760403660031901126102305761064f6120a8565b906106586120be565b604051637481a3f960e11b81526001600160a01b039384166004820152921660248301526002604483015260208260648173b2286303d50c90f619d68feea5901947abc727265af49081156106eb57906106b8575b602090604051908152f35b506020813d6020116106e3575b816106d2602093836121fe565b810103126104e357602090516106ad565b3d91506106c5565b604051903d90823e3d90fd5b5034610230576020366003190112610230576004358152600760205260408120604051918260208354918281520192825260208220915b8181106107515761063185610745818703826121fe565b604051918291826122a6565b825484526020909301926001928301920161072e565b50346102305780600319360112610230576008546040516001600160a01b039091168152602090f35b503461023057602036600319011261023057600435808252602082905260408220546001600160a01b031615801561086f575b61086057600854829173150bde577c858a9f656c810f8781fe56f1b84bac916001600160a01b0316823b1561085b576101048492604051948593849263e54ab90d60e01b8452600484015260248301528460448301526004606483015260066084830152600560a4830152600760c48301523360e48301525af4801561049a5761084a5750f35b81610854916121fe565b6102305780f35b505050fd5b6354ececb560e01b8252600482fd5b508082526003602052600160ff6040842054161515146107c3565b503461023057604036600319011261023057806108a56120a8565b73b2286303d50c90f619d68feea5901947abc72726803b156109105760405162feaaab60e61b81523360048201526001600160a01b0390921660248084019190915235604483015260016064830152829082908180608481015b03915af4801561049a5761084a5750f35b5050fd5b50346102305761061661061d60406106319361092f3661223a565b908252600460205282822090825260205220604051928380926124f0565b5034610230576040366003190112610230576109676120a8565b61096f6120be565b60405163842b3b7d60e01b81526001600160a01b039283166004820152911660248201526001604482015260208160648173b2286303d50c90f619d68feea5901947abc727265af490811561049a57602092916109d2575b506040519015158152f35b6109f29150823d84116109f8575b6109ea81836121fe565b810190612789565b5f6109c7565b503d6109e0565b503461023057604036600319011261023057610a196120a8565b90610a226120be565b60405163b04428bd60e01b81526001600160a01b039384166004820152921660248301526001604483015260208260648173b2286303d50c90f619d68feea5901947abc727265af49081156106eb57906106b857602090604051908152f35b5034610230578060031936011261023057638b78c6d819546040516001600160a01b039091168152602090f35b5034610230576020366003190112610230576060610120604051610ad18161217c565b83815283602082015283604082015283838201528360808201528360a08201528360c08201528360e08201528261010082015201526004358152806020526040812060405190610b208261217c565b80546001600160a01b038116835260a081901c6001600160581b03166020840190815293604084019160f81c906003821015610c935750815260018201546060840190600160a01b600190038116825260808501908060a01c6001600160581b0316825260a086019060f81c815260028501549160c0870192835260038601549360e0880194855260405195868060048a0190610bbc916124f0565b03610bc790886121fe565b6101008901968752604051806005819a0190610be2916124f0565b03610bed90896121fe565b6101208901978852604051998a9960208b52600160a01b6001900390511660208b0152516001600160581b031660408a01525160608901610c2d9161259b565b516001600160a01b03166080880152516001600160581b031660a08701525160ff1660c08601525160e08501525161010084015251610140610120840152610c7a906101608401906120e8565b9051828203601f190161014084015261063191906120e8565b634e487b7160e01b81526021600452602490fd5b506040366003190112610230576004356001600160401b0381116104a55761012060031982360301126104a5576024356001600160401b03811161054c57610d089291610cfb610d10923690600401612279565b9490913690600401612416565b9336916122df565b90610d2560018060a01b0384511633146136af565b6060830151804211610f605750608083019081519061010085019182519080610ead575b5050604085018051602060018060a01b036008541691602460405180948193633db29d8560e21b835260048301525afa908115610ea2578391610e83575b5015610e7457835190518115159182610e5a575b5050610e4b5750600160ff60a086015116925191519214610dcc575b6020610dc43485876139fc565b604051908152f35b1590511581610e43575b50610de2575f80610db7565b604051632962bb0960e11b815260206004820152603260248201527f5265616374696f6e73206d757374206861766520656974686572206120706172604482015271656e744964206f722074617267657455726960701b6064820152608490fd5b90505f610dd6565b6340d82e3560e01b8152600490fd5b909150825281602052600260408320015414155f80610d9b565b636ddd9da960e01b8252600482fd5b610e9c915060203d6020116109f8576109ea81836121fe565b5f610d87565b6040513d85823e3d90fd5b808352602083905260408320546001600160a01b0316159081610f49575b50610f3a5751610edc575f80610d49565b6040516329d0c04160e21b815260206004820152602f60248201527f506172656e7420636f6d6d656e7420616e64207461726765745572692063616e60448201526e1b9bdd08189bdd1a081899481cd95d608a1b6064820152608490fd5b630919176b60e31b8252600482fd5b8352506003602052604082205460ff16155f610ecb565b6394cf36f960e01b82526004524260245260449150fd5b508060031936011261023057610f8b6138d5565b80638b78c6d819547f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380638b78c6d8195580f35b503461023057602036600319011261023057600435906001600160401b038211610230576020610dc4610ff83660048601612416565b7f0000000000000000000000000000000000000000000000000000000000000000906138f1565b50346102305760a0366003190112610230576020610dc461103e6120a8565b6110466120be565b907f000000000000000000000000000000000000000000000000000000000000000091608435916064359160443591612a47565b50346102305760203660031901126102305760ff60406020926004358152600384522054166040519015158152f35b5034610230576020366003190112610230576110c36120a8565b6110cb6138d5565b6001600160a01b031680156110f0576001600160601b0360a01b600854161760085580f35b63d92e233d60e01b8252600482fd5b503461023057602036600319011261023057600435808252602082905260408220546001600160a01b03161580156111a9575b6108605780829182528160205261115660018060a01b0360408420541633146136af565b60085473150bde577c858a9f656c810f8781fe56f1b84bac916001600160a01b0390911690823b1561085b5760405163026447b560e01b81529284928492839182916108ff9133918290600486016134a5565b508082526003602052600160ff604084205416151514611132565b5034610230576020366003190112610230576004358152600660205260408120604051918260208354918281520192825260208220915b8181106112125761063185610745818703826121fe565b82548452602090930192600192830192016111fb565b506060366003190112610230576024356004356001600160401b03821161054c5760a0600319833603011261054c576044356001600160401b03811161138257610d089261127d61128a923690600401612279565b94909136906004016126e1565b818452836020526112a860018060a01b0360408620541633146136af565b60408301518042116113bf5750818452602084905260408420546001600160a01b03161580156113a4575b611395578184528360205260018060408620015460f81c14611386578184526020848152604085205484519185015186926001600160a01b0390811692169073b2286303d50c90f619d68feea5901947abc72726803b15610548576113519385936040519586948593849363820102e160e01b855260048501612760565b03915af4801561049a5761136d575b505061057f9234926136f0565b81611377916121fe565b61138257835f611360565b8380fd5b6395513bdb60e01b8452600484fd5b6354ececb560e01b8452600484fd5b508184526003602052600160ff6040862054161515146112d3565b6394cf36f960e01b855260045242602452604484fd5b5034610230578060031936011261023057506106316040516113f86040826121fe565b60018152603160f81b60208201526040519182916020835260208301906120e8565b50806003193601126102305763389a75e1600c52338152806020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c928280a280f35b50346102305760a0366003190112610230576004359061147e6120be565b604435906064356001600160401b038111611382576114a1903690600401612279565b906084356001600160401b038111610496576114c1903690600401612279565b94909381421161152157878752602087905260408720546001600160a01b0316158015611506575b6114f75761057f96976134fa565b6354ececb560e01b8752600487fd5b508787526003602052600160ff6040892054161515146114e9565b6394cf36f960e01b8752600482905242602452604487fd5b503461023057602036600319011261023057806115546120a8565b73b2286303d50c90f619d68feea5901947abc7272690813b15610910576040516359a9917160e11b81523360048201526001600160a01b03909116602482015260016044820152908290829060649082905af4801561049a5761084a5750f35b5034610230576020366003190112610230576040516314e7b8a360e11b815260048035908201526005602482015260076044820152818160648173f3994bf7e3d258fd8fdca360b6f6c6dc8ce516905af490811561049a57826106319392611625575b50506040519182918261210c565b61164192503d8091833e61163981836121fe565b8101906126bc565b5f80611617565b506060366003190112610230576004356001600160401b0381116104a55761012060031982360301126104a5576024356001600160401b03811161054c57611694903690600401612279565b9190604435916001600160401b038311610548576116d56116dd926116c06116cd953690600401612279565b9590933690600401612416565b9536916122df565b9236916122df565b926060830151804211610f6057506080830190815190610100850191825190806117d9575b5050604085018051602060018060a01b036008541691602460405180948193633db29d8560e21b835260048301525afa908115610ea25783916117ba575b5015610e74578351905181151591826117a0575b5050610e4b5750600160ff60a08601511692519151921461177e575b6020610dc434878688612ecb565b9291921590511581611798575b50610de257905f80611770565b90505f61178b565b909150825281602052600260408320015414155f80611754565b6117d3915060203d6020116109f8576109ea81836121fe565b5f611740565b808352602083905260408320546001600160a01b0316159081611808575b50610f3a5751610edc575f80611702565b8352506003602052604082205460ff16155f6117f7565b503461023057806003193601126102305760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b50346102305760a0366003190112610230576118746120a8565b9061187d6120be565b604435606435936084356001600160401b038111610548576118a3903690600401612279565b90864211611a285773b2286303d50c90f619d68feea5901947abc7272694853b15611a045760405163820102e160e01b81528781806118e789868a60048501612760565b03818a5af48015611a1d57908891611a08575b5050853b15611a0457604051638916a72d60e01b81526001600160a01b03858116600483018190529083166024830181905260026044840152999096909189816064818c5af480156119f957908a916119e0575b50506119879261198d969594926116d5927f000000000000000000000000000000000000000000000000000000000000000092886128ff565b916148b2565b156119d1578293823b1561085b576064849260405194859384926359a9917160e11b845260048401526024830152600160448301525af4801561049a5761084a5750f35b63b56d9ec560e01b8352600483fd5b816119ea916121fe565b6119f557885f61194e565b8880fd5b6040513d8c823e3d90fd5b8680fd5b81611a12916121fe565b611a0457865f6118fa565b6040513d8a823e3d90fd5b6394cf36f960e01b8652600487905242602452604486fd5b503461023057608036600319011261023057611a5a6120be565b604435916001600160a01b0383168303610230576020610dc47f00000000000000000000000000000000000000000000000000000000000000006064358686600435612e63565b50806003193601126102305763389a75e1600c523381526202a30042016020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d8280a280f35b506080366003190112610230576024356004356001600160401b03821161054c5760a0600319833603011261054c576044356001600160401b03811161138257611b3a903690600401612279565b9290606435916001600160401b038311610496576116d5611b7b92611b66611b73953690600401612279565b95909336906004016126e1565b9636916122df565b906040840151804211611c8f5750828552602085905260408520546001600160a01b0316158015611c74575b611c65578285528460205260018060408720015460f81c14611c56578285526020858152604086205485519186015187926001600160a01b0390811692169073b2286303d50c90f619d68feea5901947abc72726803b1561054857611c259385936040519586948593849363820102e160e01b855260048501612760565b03915af4801561049a57611c41575b505061057f933493612ab5565b81611c4b916121fe565b61054857845f611c34565b6395513bdb60e01b8552600485fd5b6354ececb560e01b8552600485fd5b508285526003602052600160ff604087205416151514611ba7565b6394cf36f960e01b865260045242602452604485fd5b503461023057611cb43661223a565b91908152600660205260408120908154831015610230576020611cd78484612250565b90549060031b1c604051908152f35b50346104e35760c03660031901126104e357611d006120a8565b90611d096120be565b6084359260443560643560a4356001600160401b0381116104e357611d32903690600401612279565b91874211611eb05773b2286303d50c90f619d68feea5901947abc7272697883b156104e35760405163820102e160e01b81525f8180611d76868c8c60048501612760565b03818d5af48015611ea557611e90575b50883b15611e8157604051638916a72d60e01b81526001600160a01b038781166004830152881660248201526002604482015288816064818d5af48015611e8557908991611e6c575b5050916116d5611e0892611e0f95947f000000000000000000000000000000000000000000000000000000000000000091888b8b612a47565b90846148b2565b15611e5d578484953b156105485760405162feaaab60e61b81526001600160a01b039384166004820152939092166024840152604483015260016064830152829082908180608481016108ff565b63b56d9ec560e01b8452600484fd5b81611e76916121fe565b611e8157875f611dcf565b8780fd5b6040513d8b823e3d90fd5b611e9d9198505f906121fe565b5f965f611d86565b6040513d5f823e3d90fd5b876394cf36f960e01b5f526004524260245260445ffd5b346104e35760603660031901126104e357611ee06120be565b604435906001600160401b0382116104e35760a060031983360301126104e357602091610dc491611f367f00000000000000000000000000000000000000000000000000000000000000009236906004016126e1565b906004356129a5565b346104e357611f4d3661223a565b905f52600760205260405f2080548210156104e357602091611cd791612250565b346104e3575f3660031901126104e357610631604051611f8f6040826121fe565b601a81527f457468657265756d20436f6d6d656e74732050726f746f636f6c00000000000060208201526040519182916020835260208301906120e8565b346104e35760203660031901126104e3576040516319196ddf60e11b815260048035818301526024820152600660448201525f8160648173f3994bf7e3d258fd8fdca360b6f6c6dc8ce516905af48015611ea557610631915f91612039575b506040519182918261210c565b61204d91503d805f833e61163981836121fe565b8261202c565b346104e35760803660031901126104e3576020610dc46120716120a8565b6120796120be565b7f00000000000000000000000000000000000000000000000000000000000000009160643591604435916128ff565b600435906001600160a01b03821682036104e357565b602435906001600160a01b03821682036104e357565b35906001600160a01b03821682036104e357565b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b602081016020825282518091526040820191602060408360051b8301019401925f915b83831061213e57505050505090565b909192939460208061216d600193603f198682030187526040838b5180518452015191818582015201906120e8565b9701930193019193929061212f565b61014081019081106001600160401b0382111761219857604052565b634e487b7160e01b5f52604160045260245ffd5b604081019081106001600160401b0382111761219857604052565b61012081019081106001600160401b0382111761219857604052565b60a081019081106001600160401b0382111761219857604052565b90601f801991011681019081106001600160401b0382111761219857604052565b6001600160401b03811161219857601f01601f191660200190565b60409060031901126104e3576004359060243590565b8054821015612265575f5260205f2001905f90565b634e487b7160e01b5f52603260045260245ffd5b9181601f840112156104e3578235916001600160401b0383116104e357602083818601950101116104e357565b60206040818301928281528451809452019201905f5b8181106122c95750505090565b82518452602093840193909201916001016122bc565b9291926122eb8261221f565b916122f960405193846121fe565b8294818452818301116104e3578281602093845f960137010152565b9080601f830112156104e357816020612330933591016122df565b90565b6001600160401b0381116121985760051b60200190565b81601f820112156104e35780359061236182612333565b9261236f60405194856121fe565b82845260208085019360051b830101918183116104e35760208101935b83851061239b57505050505090565b84356001600160401b0381116104e3578201906040828503601f1901126104e357604051916123c9836121ac565b6020810135835260408101356001600160401b0381116104e35760209101019084601f830112156104e35760209261240786848680963591016122df565b8382015281520194019361238c565b9190610120838203126104e35760405190612430826121c7565b819361243b816120d4565b8352612449602082016120d4565b602084015260408101356040840152606081013560608401526080810135608084015260a081013560ff811681036104e35760a084015260c08101356001600160401b0381116104e3578261249f918301612315565b60c084015260e08101356001600160401b0381116104e357826124c391830161234a565b60e0840152610100810135916001600160401b0383116104e357610100926124eb9201612315565b910152565b5f92918154918260011c92600181168015612591575b60208510811461257d57848452908115612560575060011461252757505050565b5f9081526020812093945091925b838310612546575060209250010190565b600181602092949394548385870101520191019190612535565b915050602093945060ff929192191683830152151560051b010190565b634e487b7160e01b5f52602260045260245ffd5b93607f1693612506565b9060038210156125a85752565b634e487b7160e01b5f52602160045260245ffd5b81601f820112156104e3576020815191016125d68261221f565b926125e460405194856121fe565b828452828201116104e357815f926020928386015e8301015290565b9080601f830112156104e35781519161261883612333565b9261262660405194856121fe565b80845260208085019160051b830101918383116104e35760208101915b83831061265257505050505090565b82516001600160401b0381116104e3578201906040828703601f1901126104e35760405190612680826121ac565b602083015182526040830151916001600160401b0383116104e3576126ad886020809695819601016125bc565b83820152815201920191612643565b906020828203126104e35781516001600160401b0381116104e3576123309201612600565b919060a0838203126104e357604051906126fa826121e3565b8193612705816120d4565b8352602081013560208401526040810135604084015260608101356001600160401b0381116104e3578261273a918301612315565b60608401526080810135916001600160401b0383116104e3576080926124eb920161234a565b6001600160a01b0391821681529116602082015260408101919091526002606082015260800190565b908160209103126104e3575180151581036104e35790565b9035601e19823603018112156104e35701602081359101916001600160401b0382116104e35781360383136104e357565b908060209392818452848401375f828201840152601f01601f1916010190565b90813560068110156104e35781526020820135602082015261282b61281a60408401846127a1565b6080604085015260808401916127d2565b916060810135601e19823603018112156104e3570190602082359201926001600160401b0383116104e3578260051b9182360385136104e35760608183969594960391015281815260208082019482010193835f925b8484106128915750505050505090565b9091929394956020806128b9600193601f198682030188526128b38b886127a1565b906127d2565b9801940194019294939190612881565b91908110156122655760051b81013590607e19813603018212156104e3570190565b80518210156122655760209160051b010190565b906129919361299f936040519260208401947fbb6675e570852dac6a2b90ed1a61b3c81bb4c23e8e9610f194b931455545dca3865260018060a01b0316604085015260018060a01b03166060840152608083015260a082015260a0815261296760c0826121fe565b519020604051928391602083019586909160429261190160f01b8352600283015260228201520190565b03601f1981018352826121fe565b51902090565b6129919261299f92606082015160208151910120916129c760808201516147ad565b9160018060a01b038251169060406020840151930151936040519560208701977fe1b8b434e23fc91cda7fb31b898a78ea3f8af9e4ccfe38c13e1c18d67c74c630895260408801526060870152608086015260018060a01b031660a085015260c084015260e08301526101008201526101008152612967610120826121fe565b919361299f93612991956040519360208501957fb38913717ea3c493b22dc1c94f654542ebfb71458c557257741c27408c042474875260018060a01b0316604086015260018060a01b03166060850152608084015260a083015260c082015260c0815261296760e0826121fe565b5f81815260208190526040812054835191966001600160a01b0391821696939590949373b2286303d50c90f619d68feea5901947abc727269390921691833b156104e357604051638916a72d60e01b8152886004820152836024820152600260448201525f81606481885af48015611ea557612e4e575b508715612e1057612b6c612b627f0000000000000000000000000000000000000000000000000000000000000000878b8b6129a5565b913390838661499f565b15612e015790612b7c91886148b2565b612d135760209060646040518094819363842b3b7d60e01b83528a60048401526024830152600160448301525af4908115612d08578691612ce9575b50612bd55763c55ddc9760e01b8552336004526024849052604485fd5b60085492935090916001600160a01b03169073150bde577c858a9f656c810f8781fe56f1b84bac90813b156104965760408051639bd750b360e01b81526004810196909652610160602487015281516001600160a01b031661016487015260208201516101848701528101516101a4860152606081015160a06101c4870152612c819190608090612c6b906102048901906120e8565b91015186820361016319016101e48801526149d0565b918480938192889660016044850152606484015260848301528560a4830152600460c4830152600660e4830152600561010483015260076101248301523361014483015203915af4801561049a57612cd7575050565b612ce28280926121fe565b6102305750565b612d02915060203d6020116109f8576109ea81836121fe565b5f612bb8565b6040513d88823e3d90fd5b505060085492935090916001600160a01b03169073150bde577c858a9f656c810f8781fe56f1b84bac90813b156104965760408051639bd750b360e01b81526004810196909652610160602487015281516001600160a01b031661016487015260208201516101848701528101516101a4860152606081015160a06101c4870152612dab9190608090612c6b906102048901906120e8565b918480938192889660026044850152606484015260848301528560a4830152600460c4830152600660e4830152600561010483015260076101248301523361014483015203915af4801561049a57612cd7575050565b63308117bb60e01b8952600489fd5b60405162461bcd60e51b815260206004820152601660248201527510dbdb5b595b9d08191bd95cc81b9bdd08195e1a5cdd60521b6044820152606490fd5b612e5b9199505f906121fe565b5f975f612b2c565b906129919361299f936040519260208401947ff811a238163deb0c3f205ad22be609d7c56480b7a43138a2b2899ca4ec1185308652604085015260018060a01b0316606084015260018060a01b0316608083015260a082015260a0815261296760c0826121fe565b91929092612ef97f0000000000000000000000000000000000000000000000000000000000000000846138f1565b916020840191825195612f195f9760018060a01b0316923390878561499f565b15613496578551612f35919086906001600160a01b03166148b2565b61325b57845160405163842b3b7d60e01b81526001600160a01b03909116600482015260248101919091526001604482015260208160648173b2286303d50c90f619d68feea5901947abc727265af4908115612d0857869161323c575b50612fb857835163c55ddc9760e01b8652336004526001600160a01b0316602452604485fd5b909193928484528360205260018060a01b0360408520541661322d57848452600360205260ff60408520541661321e576008546040516320279bed60e01b81526001600160a01b039091169390602081600481885afa908115612d0857906001600160601b039187916131ff575b5016938461318d575b5060085473150bde577c858a9f656c810f8781fe56f1b84bac93906001600160a01b0316843b15611a045791613124939187959360405197889687958695638c9e2d5b60e01b87528d6004880152610180602488015260018060a01b0382511661018488015260018060a01b039051166101a487015260408101516101c487015260608101516101e4870152608081015161020487015260ff60a08201511661022487015261010061310e6130f660c08401516101206102448b01526102a48a01906120e8565b60e084015189820361018319016102648b01526149d0565b91015186820361018319016102848801526120e8565b92600160448601526064850152608484015260a48301528560c4830152600460e48301526006610104830152600561012483015260076101448301523361016483015203915af4801561049a5761317a57505090565b6131858280926121fe565b610230575090565b8434106131e75760208591600460405180948193633f3071a960e11b83525af18015612d08571561302f576131d99060203d6020116131e0575b6131d181836121fe565b810190614a39565b505f61302f565b503d6131c7565b631c102d6360e21b8652346004526024859052604486fd5b613218915060203d6020116131e0576131d181836121fe565b5f613026565b6339c7811160e01b8452600484fd5b63e0048f3960e01b8452600484fd5b613255915060203d6020116109f8576109ea81836121fe565b5f612f92565b505f83815260208190526040902054929450916001600160a01b031661348757835f52600360205260ff60405f205416613478576008546040516320279bed60e01b81526001600160a01b039091169390602081600481885afa8015611ea5576001600160601b03915f91613459575b501693846133f8575b506008546001600160a01b03169173150bde577c858a9f656c810f8781fe56f1b84bac9190823b156104e3575f946133999460405197889687958695638c9e2d5b60e01b87528c6004880152610180602488015260018060a01b0382511661018488015260018060a01b039051166101a487015260408101516101c487015260608101516101e4870152608081015161020487015260ff60a08201511661022487015261010061310e6130f660c08401516101206102448b01526102a48a01906120e8565b92600260448601526064850152608484015260a48301528560c4830152600460e48301526006610104830152600561012483015260076101448301523361016483015203915af48015611ea5576133ee575090565b5f612330916121fe565b8434106134425760208591600460405180948193633f3071a960e11b83525af18015611ea557156132d45761343b9060203d6020116131e0576131d181836121fe565b505f6132d4565b84631c102d6360e21b5f523460045260245260445ffd5b613472915060203d6020116131e0576131d181836121fe565b5f6132cb565b6339c7811160e01b5f5260045ffd5b63e0048f3960e01b5f5260045ffd5b63308117bb60e01b5f5260045ffd5b9081526001600160a01b03918216602082015291811660408301525f606083015260036080830152600460a0830152600660c0830152600560e083015260076101008301529091166101208201526101400190565b939295909491945f96855f525f60205261354560018060a01b0360405f205416977f000000000000000000000000000000000000000000000000000000000000000090848a8a612e63565b9087331495861561368e575b505060405163842b3b7d60e01b8152600481018890526001600160a01b0383166024820152600160448201529360208560648173b2286303d50c90f619d68feea5901947abc727265af4948515611ea5575f9561366d575b508461364c575b505050508115613644575b506135d85763c55ddc9760e01b8352336004526024829052604483fd5b6008546001600160a01b0316925073150bde577c858a9f656c810f8781fe56f1b84bac803b156104e357613627935f936040519586948593849363026447b560e01b85523392600486016134a5565b03915af48015611ea5576136385750565b5f613642916121fe565b565b90505f6135bb565b613664945061365e90339436916122df565b9161499f565b5f8080806135b0565b61368791955060203d6020116109f8576109ea81836121fe565b935f6135a9565b6136a7929650906136a09136916122df565b85886148b2565b935f80613551565b156136b657565b60405162461bcd60e51b81526020600482015260126024820152712737ba1031b7b6b6b2b73a1030baba3437b960711b6044820152606490fd5b5f8181526020819052604081205483519195949293926001600160a01b039283169290911673b2286303d50c90f619d68feea5901947abc72726803b156104e3575f60649160405192838092638916a72d60e01b8252866004830152886024830152600260448301525af48015611ea5576138b5575b50906137996137a09392857f000000000000000000000000000000000000000000000000000000000000000091886129a5565b339261499f565b6137b35763308117bb60e01b8452600484fd5b6008546001600160a01b03169273150bde577c858a9f656c810f8781fe56f1b84bac9290833b1561049657918593916138609360405196879586948594639bd750b360e01b86526004860152610160602486015260018060a01b03815116610164860152602081015161018486015260408101516101a4860152608061384a606083015160a06101c48901526102048801906120e8565b91015185820361016319016101e48701526149d0565b9161386e604485018961259b565b606484015260848301528560a4830152600460c4830152600660e4830152600561010483015260076101248301523361014483015203915af4801561049a57612cd7575050565b6137a093929197505f6138c7916121fe565b6137995f9791929350613766565b638b78c6d8195433036138e457565b6382b429005f526004601cfd5b61299f6129919160c0810151602081519101209061391260e08201516147ad565b90610100810151602081519101209060ff60a08201511660018060a01b0382511660018060a01b036020840151169060408401519260806060860151950151956040519760208901997f04a5f1bbcb9ec1d0161775ef93887c9b059e8c7456620e0dce9fe29ba4d46e4b8b5260408a01526060890152608088015260a087015260c086015260e08501526101008401526101208301526101408201526101408152612967610160826121fe565b60018060a01b031680638b78c6d819547f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3638b78c6d81955565b919091613a297f0000000000000000000000000000000000000000000000000000000000000000826138f1565b9160208201613a4581515f9686339260018060a01b031661499f565b613a585763308117bb60e01b8552600485fd5b9091928094505f525f60205260018060a01b0360405f20541661348757835f52600360205260ff60405f205416613478576008546040516320279bed60e01b81526001600160a01b039091169390602081600481885afa8015611ea5576001600160601b03915f91613c31575b50169384613be7575b506008546001600160a01b03169173150bde577c858a9f656c810f8781fe56f1b84bac9190823b156104e3575f94613b939460405197889687958695638c9e2d5b60e01b87528c6004880152610180602488015260018060a01b0382511661018488015260018060a01b039051166101a487015260408101516101c487015260608101516101e4870152608081015161020487015260ff60a08201511661022487015261010061310e6130f660c08401516101206102448b01526102a48a01906120e8565b928860448601526064850152608484015260a48301528560c4830152600460e48301526006610104830152600561012483015260076101448301523361016483015203915af48015611ea5576133ee575090565b8434106134425760208591600460405180948193633f3071a960e11b83525af18015611ea55715613ace57613c2a9060203d6020116131e0576131d181836121fe565b505f613ace565b613c4a915060203d6020116131e0576131d181836121fe565b5f613ac5565b919060605f91843560068110156104e35780613ed957505050909173f30fccf0e8b483ae61be8731fd736ef794a63ac7906040516364d429a160e01b815260206004820152838180613ca560248201866127f2565b0381865af4908115613ece578491613eac575b50613cd9613cd2613ccc6060850185614a6c565b90614aa1565b36916122df565b91613cee60018060a01b0383511633146136af565b6060820151804211611c8f575060808201805161010084019081519080613e57575b5050604084018051602060018060a01b036008541691602460405180948193633db29d8560e21b835260048301525afa908115611e85578991613e38575b5015613e2957825190518115159182613e0f575b5050613e005790839291600160ff60a08a97015116925191519214613ddc575b5050926020613d9493940135916139fc565b6024604051809481936327bc54c960e11b835260048301525af49182156106eb578092613dc057505090565b61233092503d8091833e613dd481836121fe565b810190614caf565b909193501590511581613df8575b50610de25784915f80613d82565b90505f613dea565b6340d82e3560e01b8752600487fd5b909150885287602052600260408920015414155f80613d62565b636ddd9da960e01b8852600488fd5b613e51915060203d6020116109f8576109ea81836121fe565b5f613d4e565b808952602089905260408920546001600160a01b0316159081613e95575b50613e865751610edc575f80613d10565b630919176b60e31b8852600488fd5b8952506003602052604088205460ff16155f613e75565b613ec891503d8086833e613ec081836121fe565b810190614bbe565b5f613cb8565b6040513d86823e3d90fd5b6001810361411b57505050909173f30fccf0e8b483ae61be8731fd736ef794a63ac7906040516364d429a160e01b815260206004820152838180613f2060248201866127f2565b0381865af4908115613ece578491614101575b506060820191613f73613f5b613f6b613f61613f52613ccc8887614a6c565b93909786614a6c565b90614adb565b96909236916122df565b9436916122df565b9060608301518042116140eb575060808301805161010085019081519080614096575b5050604085018051602060018060a01b036008541691602460405180948193633db29d8560e21b835260048301525afa9081156119f9578a91614077575b50156140685782519051811515918261404e575b505061403f579084939291600160ff60a08b9801511692519151921461401b575b5050936020613d949495013592612ecb565b909194501590511581614037575b50610de25785925f80614009565b90505f614029565b6340d82e3560e01b8852600488fd5b909150895288602052600260408a20015414155f80613fe8565b636ddd9da960e01b8952600489fd5b614090915060203d6020116109f8576109ea81836121fe565b5f613fd4565b808a5260208a905260408a20546001600160a01b03161590816140d4575b506140c55751610edc575f80613f96565b630919176b60e31b8952600489fd5b8a52506003602052604089205460ff16155f6140b4565b6394cf36f960e01b875260045242602452604486fd5b61411591503d8086833e613ec081836121fe565b5f613f33565b600281036142d857505060405163c825815760e01b815260206004820152905081818061414b60248201886127f2565b038173f30fccf0e8b483ae61be8731fd736ef794a63ac75af4801561049a57829183916142b4575b50614187613cd2613ccc6060880188614a6c565b90828452836020526141a660018060a01b0360408620541633146136af565b60408101518042116113bf5750828452602084905260408420546001600160a01b0316158015614299575b611395578284528360205260018060408620015460f81c1461138657828452602084815260408520548251918301519173b2286303d50c90f619d68feea5901947abc72726916001600160a01b039182169116823b15611e815760405163820102e160e01b815293889385939092849283926142509260048501612760565b03915af480156104ef57614284575b5060206142709495960135926136f0565b6040519061427f6020836121fe565b815290565b61428f8580926121fe565b611382575f61425f565b508284526003602052600160ff6040862054161515146141d1565b90506142d291503d8084833e6142ca81836121fe565b810190614b1b565b5f614173565b6003810361447857505060405163c825815760e01b815260206004820152905081818061430860248201886127f2565b038173f30fccf0e8b483ae61be8731fd736ef794a63ac75af4801561049a578291839161445c575b5060608501614361613f5b6116d561435761434e613ccc868c614a6c565b9390958b614a6c565b94909236916122df565b916040810151804211611c8f5750838552602085905260408520546001600160a01b0316158015614441575b611c65578385528460205260018060408720015460f81c14611c5657838552602085815260408620548251918301519173b2286303d50c90f619d68feea5901947abc72726916001600160a01b039182169116823b156119f55760405163820102e160e01b8152938993859390928492839261440c9260048501612760565b03915af48015612d085761442c575b506020614270959697013593612ab5565b6144378680926121fe565b610548575f61441b565b508385526003602052600160ff60408720541615151461438d565b905061447291503d8084833e6142ca81836121fe565b5f614330565b93949293600481036145f85750505060206144ae91604051809381926328b5649b60e11b835284600484015260248301906127f2565b038173f30fccf0e8b483ae61be8731fd736ef794a63ac75af4908115611ea5575f916145c6575b505f818152602081905260409020546001600160a01b03161580156145ab575b61459c57805f525f60205261451760018060a01b0360405f20541633146136af565b60085473150bde577c858a9f656c810f8781fe56f1b84bac916001600160a01b0390911690823b156104e35760405163026447b560e01b8152925f9284928391829161456a9133918290600486016134a5565b03915af48015611ea557614589575b506040519061427f6020836121fe565b61459591505f906121fe565b5f5f614579565b6354ececb560e01b5f5260045ffd5b50805f526003602052600160ff60405f2054161515146144f5565b90506020813d6020116145f0575b816145e1602093836121fe565b810103126104e357515f6144d5565b3d91506145d4565b9293509091600503614768575060405163536d4c1f60e11b81526020600482015281818061462960248201876127f2565b038173f30fccf0e8b483ae61be8731fd736ef794a63ac75af4908115611ea5575f91614701575b50805192604060018060a01b0360208401511692015192810190614685613f5b61467d613ccc8585614a6c565b949093614a6c565b9490938142116146ea575f878152602081905260409020546001600160a01b03161580156146cf575b61459c576146bb966134fa565b6040516146c96020826121fe565b5f815290565b50865f526003602052600160ff60405f2054161515146146ae565b506394cf36f960e01b5f526004524260245260445ffd5b90508181813d8311614761575b61471881836121fe565b810103126104e35760405190828201908282106001600160401b038311176121985760409182528051835261474f60208201614a58565b6020840152015160408201525f614650565b503d61470e565b6084906040519063086ad52b60e01b82526004820152604060248201526016604482015275496e76616c6964206f7065726174696f6e207479706560501b6064820152fd5b9081516147d26147bc82612333565b916147ca60405193846121fe565b808352612333565b602082019290601f19013684375f5b845181101561486857806147f7600192876128eb565b5151602061480583896128eb565b510151602081519101206040519060208201927fac744b2be3b7f8d6f7d637db76586a27ab36aba301ab536c7226a6a344ab514f845260408301526060820152606081526148546080826121fe565b51902061486182866128eb565b52016147e1565b506040519151909350602082019290829084905f5b81811061489957505061299f925003601f1981018352826121fe565b845183526020948501948694509092019160010161487d565b90915f91906001600160a01b038216156149975760405192600484019460248501956044860192853b1561491b57509186939160209593630b135d3f60e11b8852526040845281518501809260045afa9360443d01915afa9151630b135d3f60e11b1491161690565b979650509050815180604014614972576041146149385750505050565b60209293955060608201515f1a835260408201516060525b5f5201516040526020600160805f825afa511860601b3d11915f606052604052565b506020929395506040820151601b8160ff1c01845260018060ff1b0316606052614950565b505050505f90565b6001600160a01b038181169416939093149283156149be575b50505090565b6149c893506148b2565b5f80806149b8565b9080602083519182815201916020808360051b8301019401925f915b8383106149fb57505050505090565b9091929394602080614a2a600193601f198682030187526040838b5180518452015191818582015201906120e8565b970193019301919392906149ec565b908160209103126104e357516001600160601b03811681036104e35790565b51906001600160a01b03821682036104e357565b903590601e19813603018212156104e357018035906001600160401b0382116104e357602001918160051b360383136104e357565b901561226557803590601e19813603018212156104e35701908135916001600160401b0383116104e35760200182360381136104e3579190565b906001101561226557602081013590601e19813603018212156104e35701908135916001600160401b0383116104e35760200182360381136104e3579190565b91906040838203126104e3578251926020810151906001600160401b0382116104e3570160a0818303126104e35760405191614b56836121e3565b614b5f82614a58565b8352602082015160208401526040820151604084015260608201516001600160401b0381116104e35781614b949184016125bc565b606084015260808201516001600160401b0381116104e357614bb69201612600565b608082015290565b6020818303126104e3578051906001600160401b0382116104e35701610120818303126104e35760405191614bf2836121c7565b614bfb82614a58565b8352614c0960208301614a58565b602084015260408201516040840152606082015160608401526080820151608084015260a082015160ff811681036104e35760a084015260c08201516001600160401b0381116104e35781614c5f9184016125bc565b60c084015260e08201516001600160401b0381116104e35781614c83918401612600565b60e08401526101008201516001600160401b0381116104e357614ca692016125bc565b61010082015290565b906020828203126104e35781516001600160401b0381116104e35761233092016125bc56fea2646970667358221220cb10a60526704b3a746fd9f56bb92cc8444d3078bd721ea22324ec4a6cffa55b64736f6c634300081c0033000000000000000000000000d1177f978a5535eba843bdd817e730df1c42c476
Deployed Bytecode
0x60806040526004361015610011575f80fd5b5f5f3560e01c8063035e3b751461205357806305c9a5d114611fcd57806306fdde0314611f6e578063144e661414611f3f5780631f3449fe14611ec75780632119073c14611ce657806323aa932c14611ca557806324d4207914611aec5780632569296214611aa15780632d229e7114611a4057806331c360241461185a5780633644e5151461181f578063385f4877146116485780633fab8ecd146115b4578063484685b0146115395780634b88f91e1461146057806354d1f13d1461141a57806354fd4d50146113d5578063558724a51461122857806356380be2146111c457806358595ba4146110ff5780635ce96cf7146110a9578063678233251461107a57806369b5cd041461101f5780636e0ce000146109145780636fab436414610fc2578063715018a614610f77578063762c08e214610ca757806386066c9d146105dd5780638c20d58714610aae5780638da5cb5b14610a815780638e3d471c146109ff578063a389783e1461094d578063a712eca414610914578063ac3cb72c1461088a578063b5c775d514610790578063d1d451ca14610767578063d605f6bb146106f7578063d828435d14610635578063e367e350146105dd578063f04e283e1461058f578063f2fde38b14610550578063fe1f2d70146102335763fee81cf4146101fe575f80fd5b34610230576020366003190112610230576102176120a8565b9063389a75e1600c5252602080600c2054604051908152f35b80fd5b506020366003190112610230576004356001600160401b0381116104a557366023820112156104a55780600401356001600160401b03811161054c5760248201918160051b3660248284010111610548573068929eee149b4bd21268541461053b573068929eee149b4bd212685573f30fccf0e8b483ae61be8731fd736ef794a63ac79160405191829163a2dcdd9f60e01b8352856044840160406004860152526064808401928401019187918960a21982360301915b8982106104fa57505050505090806020923460248301520381855af480156104ef576104bc575b5061031e82949394612333565b9361032c60405195866121fe565b828552601f1961033b84612333565b01845b8181106104a9575050835b8381106103f6575050506040519081523460208201527f3b8032d28c34fcac25523353721b303ab6f70304452d10939237194d1a1d56cc60403392a23868929eee149b4bd21268556040519182916020830160208452825180915260408401602060408360051b870101940192905b8282106103c757505050500390f35b919360019193955060206103e68192603f198a820301865288516120e8565b96019201920185949391926103b8565b846104058286859998996128c9565b843b156104a557816104339160405180938192636f819bbf60e11b83526040600484015260448301906127f2565b8660248301520381885af4801561049a57610481575b5050806104628161045d60019488876128c9565b613c50565b61046c82886128eb565b5261047781876128eb565b5001949394610349565b8161048b916121fe565b61049657855f610449565b8580fd5b6040513d84823e3d90fd5b5080fd5b606060208289018101919091520161033e565b6020813d6020116104e7575b816104d5602093836121fe565b810103126104e35751610311565b5f80fd5b3d91506104c8565b6040513d87823e3d90fd5b919395509193606319878203018552853584811215610537576020610527600193602486849501016127f2565b97019501920186959493916102ea565b8b80fd5b63ab143c0685526004601cfd5b8480fd5b8280fd5b506020366003190112610230576105656120a8565b61056d6138d5565b8060601b156105825761057f906139bf565b80f35b637448fbae82526004601cfd5b506020366003190112610230576105a46120a8565b6105ac6138d5565b63389a75e1600c528082526020600c20805442116105d057908261057f92556139bf565b636f5e881883526004601cfd5b50346102305761061661061d6040610631936105f83661223a565b908252600560205282822090825260205220604051928380926124f0565b03826121fe565b6040519182916020835260208301906120e8565b0390f35b50346102305760403660031901126102305761064f6120a8565b906106586120be565b604051637481a3f960e11b81526001600160a01b039384166004820152921660248301526002604483015260208260648173b2286303d50c90f619d68feea5901947abc727265af49081156106eb57906106b8575b602090604051908152f35b506020813d6020116106e3575b816106d2602093836121fe565b810103126104e357602090516106ad565b3d91506106c5565b604051903d90823e3d90fd5b5034610230576020366003190112610230576004358152600760205260408120604051918260208354918281520192825260208220915b8181106107515761063185610745818703826121fe565b604051918291826122a6565b825484526020909301926001928301920161072e565b50346102305780600319360112610230576008546040516001600160a01b039091168152602090f35b503461023057602036600319011261023057600435808252602082905260408220546001600160a01b031615801561086f575b61086057600854829173150bde577c858a9f656c810f8781fe56f1b84bac916001600160a01b0316823b1561085b576101048492604051948593849263e54ab90d60e01b8452600484015260248301528460448301526004606483015260066084830152600560a4830152600760c48301523360e48301525af4801561049a5761084a5750f35b81610854916121fe565b6102305780f35b505050fd5b6354ececb560e01b8252600482fd5b508082526003602052600160ff6040842054161515146107c3565b503461023057604036600319011261023057806108a56120a8565b73b2286303d50c90f619d68feea5901947abc72726803b156109105760405162feaaab60e61b81523360048201526001600160a01b0390921660248084019190915235604483015260016064830152829082908180608481015b03915af4801561049a5761084a5750f35b5050fd5b50346102305761061661061d60406106319361092f3661223a565b908252600460205282822090825260205220604051928380926124f0565b5034610230576040366003190112610230576109676120a8565b61096f6120be565b60405163842b3b7d60e01b81526001600160a01b039283166004820152911660248201526001604482015260208160648173b2286303d50c90f619d68feea5901947abc727265af490811561049a57602092916109d2575b506040519015158152f35b6109f29150823d84116109f8575b6109ea81836121fe565b810190612789565b5f6109c7565b503d6109e0565b503461023057604036600319011261023057610a196120a8565b90610a226120be565b60405163b04428bd60e01b81526001600160a01b039384166004820152921660248301526001604483015260208260648173b2286303d50c90f619d68feea5901947abc727265af49081156106eb57906106b857602090604051908152f35b5034610230578060031936011261023057638b78c6d819546040516001600160a01b039091168152602090f35b5034610230576020366003190112610230576060610120604051610ad18161217c565b83815283602082015283604082015283838201528360808201528360a08201528360c08201528360e08201528261010082015201526004358152806020526040812060405190610b208261217c565b80546001600160a01b038116835260a081901c6001600160581b03166020840190815293604084019160f81c906003821015610c935750815260018201546060840190600160a01b600190038116825260808501908060a01c6001600160581b0316825260a086019060f81c815260028501549160c0870192835260038601549360e0880194855260405195868060048a0190610bbc916124f0565b03610bc790886121fe565b6101008901968752604051806005819a0190610be2916124f0565b03610bed90896121fe565b6101208901978852604051998a9960208b52600160a01b6001900390511660208b0152516001600160581b031660408a01525160608901610c2d9161259b565b516001600160a01b03166080880152516001600160581b031660a08701525160ff1660c08601525160e08501525161010084015251610140610120840152610c7a906101608401906120e8565b9051828203601f190161014084015261063191906120e8565b634e487b7160e01b81526021600452602490fd5b506040366003190112610230576004356001600160401b0381116104a55761012060031982360301126104a5576024356001600160401b03811161054c57610d089291610cfb610d10923690600401612279565b9490913690600401612416565b9336916122df565b90610d2560018060a01b0384511633146136af565b6060830151804211610f605750608083019081519061010085019182519080610ead575b5050604085018051602060018060a01b036008541691602460405180948193633db29d8560e21b835260048301525afa908115610ea2578391610e83575b5015610e7457835190518115159182610e5a575b5050610e4b5750600160ff60a086015116925191519214610dcc575b6020610dc43485876139fc565b604051908152f35b1590511581610e43575b50610de2575f80610db7565b604051632962bb0960e11b815260206004820152603260248201527f5265616374696f6e73206d757374206861766520656974686572206120706172604482015271656e744964206f722074617267657455726960701b6064820152608490fd5b90505f610dd6565b6340d82e3560e01b8152600490fd5b909150825281602052600260408320015414155f80610d9b565b636ddd9da960e01b8252600482fd5b610e9c915060203d6020116109f8576109ea81836121fe565b5f610d87565b6040513d85823e3d90fd5b808352602083905260408320546001600160a01b0316159081610f49575b50610f3a5751610edc575f80610d49565b6040516329d0c04160e21b815260206004820152602f60248201527f506172656e7420636f6d6d656e7420616e64207461726765745572692063616e60448201526e1b9bdd08189bdd1a081899481cd95d608a1b6064820152608490fd5b630919176b60e31b8252600482fd5b8352506003602052604082205460ff16155f610ecb565b6394cf36f960e01b82526004524260245260449150fd5b508060031936011261023057610f8b6138d5565b80638b78c6d819547f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380638b78c6d8195580f35b503461023057602036600319011261023057600435906001600160401b038211610230576020610dc4610ff83660048601612416565b7fb22f94c9effcc577ed8d9c14cad648cd018b60030c47e7dc0890bb0ddb363c0a906138f1565b50346102305760a0366003190112610230576020610dc461103e6120a8565b6110466120be565b907fb22f94c9effcc577ed8d9c14cad648cd018b60030c47e7dc0890bb0ddb363c0a91608435916064359160443591612a47565b50346102305760203660031901126102305760ff60406020926004358152600384522054166040519015158152f35b5034610230576020366003190112610230576110c36120a8565b6110cb6138d5565b6001600160a01b031680156110f0576001600160601b0360a01b600854161760085580f35b63d92e233d60e01b8252600482fd5b503461023057602036600319011261023057600435808252602082905260408220546001600160a01b03161580156111a9575b6108605780829182528160205261115660018060a01b0360408420541633146136af565b60085473150bde577c858a9f656c810f8781fe56f1b84bac916001600160a01b0390911690823b1561085b5760405163026447b560e01b81529284928492839182916108ff9133918290600486016134a5565b508082526003602052600160ff604084205416151514611132565b5034610230576020366003190112610230576004358152600660205260408120604051918260208354918281520192825260208220915b8181106112125761063185610745818703826121fe565b82548452602090930192600192830192016111fb565b506060366003190112610230576024356004356001600160401b03821161054c5760a0600319833603011261054c576044356001600160401b03811161138257610d089261127d61128a923690600401612279565b94909136906004016126e1565b818452836020526112a860018060a01b0360408620541633146136af565b60408301518042116113bf5750818452602084905260408420546001600160a01b03161580156113a4575b611395578184528360205260018060408620015460f81c14611386578184526020848152604085205484519185015186926001600160a01b0390811692169073b2286303d50c90f619d68feea5901947abc72726803b15610548576113519385936040519586948593849363820102e160e01b855260048501612760565b03915af4801561049a5761136d575b505061057f9234926136f0565b81611377916121fe565b61138257835f611360565b8380fd5b6395513bdb60e01b8452600484fd5b6354ececb560e01b8452600484fd5b508184526003602052600160ff6040862054161515146112d3565b6394cf36f960e01b855260045242602452604484fd5b5034610230578060031936011261023057506106316040516113f86040826121fe565b60018152603160f81b60208201526040519182916020835260208301906120e8565b50806003193601126102305763389a75e1600c52338152806020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c928280a280f35b50346102305760a0366003190112610230576004359061147e6120be565b604435906064356001600160401b038111611382576114a1903690600401612279565b906084356001600160401b038111610496576114c1903690600401612279565b94909381421161152157878752602087905260408720546001600160a01b0316158015611506575b6114f75761057f96976134fa565b6354ececb560e01b8752600487fd5b508787526003602052600160ff6040892054161515146114e9565b6394cf36f960e01b8752600482905242602452604487fd5b503461023057602036600319011261023057806115546120a8565b73b2286303d50c90f619d68feea5901947abc7272690813b15610910576040516359a9917160e11b81523360048201526001600160a01b03909116602482015260016044820152908290829060649082905af4801561049a5761084a5750f35b5034610230576020366003190112610230576040516314e7b8a360e11b815260048035908201526005602482015260076044820152818160648173f3994bf7e3d258fd8fdca360b6f6c6dc8ce516905af490811561049a57826106319392611625575b50506040519182918261210c565b61164192503d8091833e61163981836121fe565b8101906126bc565b5f80611617565b506060366003190112610230576004356001600160401b0381116104a55761012060031982360301126104a5576024356001600160401b03811161054c57611694903690600401612279565b9190604435916001600160401b038311610548576116d56116dd926116c06116cd953690600401612279565b9590933690600401612416565b9536916122df565b9236916122df565b926060830151804211610f6057506080830190815190610100850191825190806117d9575b5050604085018051602060018060a01b036008541691602460405180948193633db29d8560e21b835260048301525afa908115610ea25783916117ba575b5015610e74578351905181151591826117a0575b5050610e4b5750600160ff60a08601511692519151921461177e575b6020610dc434878688612ecb565b9291921590511581611798575b50610de257905f80611770565b90505f61178b565b909150825281602052600260408320015414155f80611754565b6117d3915060203d6020116109f8576109ea81836121fe565b5f611740565b808352602083905260408320546001600160a01b0316159081611808575b50610f3a5751610edc575f80611702565b8352506003602052604082205460ff16155f6117f7565b503461023057806003193601126102305760206040517fb22f94c9effcc577ed8d9c14cad648cd018b60030c47e7dc0890bb0ddb363c0a8152f35b50346102305760a0366003190112610230576118746120a8565b9061187d6120be565b604435606435936084356001600160401b038111610548576118a3903690600401612279565b90864211611a285773b2286303d50c90f619d68feea5901947abc7272694853b15611a045760405163820102e160e01b81528781806118e789868a60048501612760565b03818a5af48015611a1d57908891611a08575b5050853b15611a0457604051638916a72d60e01b81526001600160a01b03858116600483018190529083166024830181905260026044840152999096909189816064818c5af480156119f957908a916119e0575b50506119879261198d969594926116d5927fb22f94c9effcc577ed8d9c14cad648cd018b60030c47e7dc0890bb0ddb363c0a92886128ff565b916148b2565b156119d1578293823b1561085b576064849260405194859384926359a9917160e11b845260048401526024830152600160448301525af4801561049a5761084a5750f35b63b56d9ec560e01b8352600483fd5b816119ea916121fe565b6119f557885f61194e565b8880fd5b6040513d8c823e3d90fd5b8680fd5b81611a12916121fe565b611a0457865f6118fa565b6040513d8a823e3d90fd5b6394cf36f960e01b8652600487905242602452604486fd5b503461023057608036600319011261023057611a5a6120be565b604435916001600160a01b0383168303610230576020610dc47fb22f94c9effcc577ed8d9c14cad648cd018b60030c47e7dc0890bb0ddb363c0a6064358686600435612e63565b50806003193601126102305763389a75e1600c523381526202a30042016020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d8280a280f35b506080366003190112610230576024356004356001600160401b03821161054c5760a0600319833603011261054c576044356001600160401b03811161138257611b3a903690600401612279565b9290606435916001600160401b038311610496576116d5611b7b92611b66611b73953690600401612279565b95909336906004016126e1565b9636916122df565b906040840151804211611c8f5750828552602085905260408520546001600160a01b0316158015611c74575b611c65578285528460205260018060408720015460f81c14611c56578285526020858152604086205485519186015187926001600160a01b0390811692169073b2286303d50c90f619d68feea5901947abc72726803b1561054857611c259385936040519586948593849363820102e160e01b855260048501612760565b03915af4801561049a57611c41575b505061057f933493612ab5565b81611c4b916121fe565b61054857845f611c34565b6395513bdb60e01b8552600485fd5b6354ececb560e01b8552600485fd5b508285526003602052600160ff604087205416151514611ba7565b6394cf36f960e01b865260045242602452604485fd5b503461023057611cb43661223a565b91908152600660205260408120908154831015610230576020611cd78484612250565b90549060031b1c604051908152f35b50346104e35760c03660031901126104e357611d006120a8565b90611d096120be565b6084359260443560643560a4356001600160401b0381116104e357611d32903690600401612279565b91874211611eb05773b2286303d50c90f619d68feea5901947abc7272697883b156104e35760405163820102e160e01b81525f8180611d76868c8c60048501612760565b03818d5af48015611ea557611e90575b50883b15611e8157604051638916a72d60e01b81526001600160a01b038781166004830152881660248201526002604482015288816064818d5af48015611e8557908991611e6c575b5050916116d5611e0892611e0f95947fb22f94c9effcc577ed8d9c14cad648cd018b60030c47e7dc0890bb0ddb363c0a91888b8b612a47565b90846148b2565b15611e5d578484953b156105485760405162feaaab60e61b81526001600160a01b039384166004820152939092166024840152604483015260016064830152829082908180608481016108ff565b63b56d9ec560e01b8452600484fd5b81611e76916121fe565b611e8157875f611dcf565b8780fd5b6040513d8b823e3d90fd5b611e9d9198505f906121fe565b5f965f611d86565b6040513d5f823e3d90fd5b876394cf36f960e01b5f526004524260245260445ffd5b346104e35760603660031901126104e357611ee06120be565b604435906001600160401b0382116104e35760a060031983360301126104e357602091610dc491611f367fb22f94c9effcc577ed8d9c14cad648cd018b60030c47e7dc0890bb0ddb363c0a9236906004016126e1565b906004356129a5565b346104e357611f4d3661223a565b905f52600760205260405f2080548210156104e357602091611cd791612250565b346104e3575f3660031901126104e357610631604051611f8f6040826121fe565b601a81527f457468657265756d20436f6d6d656e74732050726f746f636f6c00000000000060208201526040519182916020835260208301906120e8565b346104e35760203660031901126104e3576040516319196ddf60e11b815260048035818301526024820152600660448201525f8160648173f3994bf7e3d258fd8fdca360b6f6c6dc8ce516905af48015611ea557610631915f91612039575b506040519182918261210c565b61204d91503d805f833e61163981836121fe565b8261202c565b346104e35760803660031901126104e3576020610dc46120716120a8565b6120796120be565b7fb22f94c9effcc577ed8d9c14cad648cd018b60030c47e7dc0890bb0ddb363c0a9160643591604435916128ff565b600435906001600160a01b03821682036104e357565b602435906001600160a01b03821682036104e357565b35906001600160a01b03821682036104e357565b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b602081016020825282518091526040820191602060408360051b8301019401925f915b83831061213e57505050505090565b909192939460208061216d600193603f198682030187526040838b5180518452015191818582015201906120e8565b9701930193019193929061212f565b61014081019081106001600160401b0382111761219857604052565b634e487b7160e01b5f52604160045260245ffd5b604081019081106001600160401b0382111761219857604052565b61012081019081106001600160401b0382111761219857604052565b60a081019081106001600160401b0382111761219857604052565b90601f801991011681019081106001600160401b0382111761219857604052565b6001600160401b03811161219857601f01601f191660200190565b60409060031901126104e3576004359060243590565b8054821015612265575f5260205f2001905f90565b634e487b7160e01b5f52603260045260245ffd5b9181601f840112156104e3578235916001600160401b0383116104e357602083818601950101116104e357565b60206040818301928281528451809452019201905f5b8181106122c95750505090565b82518452602093840193909201916001016122bc565b9291926122eb8261221f565b916122f960405193846121fe565b8294818452818301116104e3578281602093845f960137010152565b9080601f830112156104e357816020612330933591016122df565b90565b6001600160401b0381116121985760051b60200190565b81601f820112156104e35780359061236182612333565b9261236f60405194856121fe565b82845260208085019360051b830101918183116104e35760208101935b83851061239b57505050505090565b84356001600160401b0381116104e3578201906040828503601f1901126104e357604051916123c9836121ac565b6020810135835260408101356001600160401b0381116104e35760209101019084601f830112156104e35760209261240786848680963591016122df565b8382015281520194019361238c565b9190610120838203126104e35760405190612430826121c7565b819361243b816120d4565b8352612449602082016120d4565b602084015260408101356040840152606081013560608401526080810135608084015260a081013560ff811681036104e35760a084015260c08101356001600160401b0381116104e3578261249f918301612315565b60c084015260e08101356001600160401b0381116104e357826124c391830161234a565b60e0840152610100810135916001600160401b0383116104e357610100926124eb9201612315565b910152565b5f92918154918260011c92600181168015612591575b60208510811461257d57848452908115612560575060011461252757505050565b5f9081526020812093945091925b838310612546575060209250010190565b600181602092949394548385870101520191019190612535565b915050602093945060ff929192191683830152151560051b010190565b634e487b7160e01b5f52602260045260245ffd5b93607f1693612506565b9060038210156125a85752565b634e487b7160e01b5f52602160045260245ffd5b81601f820112156104e3576020815191016125d68261221f565b926125e460405194856121fe565b828452828201116104e357815f926020928386015e8301015290565b9080601f830112156104e35781519161261883612333565b9261262660405194856121fe565b80845260208085019160051b830101918383116104e35760208101915b83831061265257505050505090565b82516001600160401b0381116104e3578201906040828703601f1901126104e35760405190612680826121ac565b602083015182526040830151916001600160401b0383116104e3576126ad886020809695819601016125bc565b83820152815201920191612643565b906020828203126104e35781516001600160401b0381116104e3576123309201612600565b919060a0838203126104e357604051906126fa826121e3565b8193612705816120d4565b8352602081013560208401526040810135604084015260608101356001600160401b0381116104e3578261273a918301612315565b60608401526080810135916001600160401b0383116104e3576080926124eb920161234a565b6001600160a01b0391821681529116602082015260408101919091526002606082015260800190565b908160209103126104e3575180151581036104e35790565b9035601e19823603018112156104e35701602081359101916001600160401b0382116104e35781360383136104e357565b908060209392818452848401375f828201840152601f01601f1916010190565b90813560068110156104e35781526020820135602082015261282b61281a60408401846127a1565b6080604085015260808401916127d2565b916060810135601e19823603018112156104e3570190602082359201926001600160401b0383116104e3578260051b9182360385136104e35760608183969594960391015281815260208082019482010193835f925b8484106128915750505050505090565b9091929394956020806128b9600193601f198682030188526128b38b886127a1565b906127d2565b9801940194019294939190612881565b91908110156122655760051b81013590607e19813603018212156104e3570190565b80518210156122655760209160051b010190565b906129919361299f936040519260208401947fbb6675e570852dac6a2b90ed1a61b3c81bb4c23e8e9610f194b931455545dca3865260018060a01b0316604085015260018060a01b03166060840152608083015260a082015260a0815261296760c0826121fe565b519020604051928391602083019586909160429261190160f01b8352600283015260228201520190565b03601f1981018352826121fe565b51902090565b6129919261299f92606082015160208151910120916129c760808201516147ad565b9160018060a01b038251169060406020840151930151936040519560208701977fe1b8b434e23fc91cda7fb31b898a78ea3f8af9e4ccfe38c13e1c18d67c74c630895260408801526060870152608086015260018060a01b031660a085015260c084015260e08301526101008201526101008152612967610120826121fe565b919361299f93612991956040519360208501957fb38913717ea3c493b22dc1c94f654542ebfb71458c557257741c27408c042474875260018060a01b0316604086015260018060a01b03166060850152608084015260a083015260c082015260c0815261296760e0826121fe565b5f81815260208190526040812054835191966001600160a01b0391821696939590949373b2286303d50c90f619d68feea5901947abc727269390921691833b156104e357604051638916a72d60e01b8152886004820152836024820152600260448201525f81606481885af48015611ea557612e4e575b508715612e1057612b6c612b627fb22f94c9effcc577ed8d9c14cad648cd018b60030c47e7dc0890bb0ddb363c0a878b8b6129a5565b913390838661499f565b15612e015790612b7c91886148b2565b612d135760209060646040518094819363842b3b7d60e01b83528a60048401526024830152600160448301525af4908115612d08578691612ce9575b50612bd55763c55ddc9760e01b8552336004526024849052604485fd5b60085492935090916001600160a01b03169073150bde577c858a9f656c810f8781fe56f1b84bac90813b156104965760408051639bd750b360e01b81526004810196909652610160602487015281516001600160a01b031661016487015260208201516101848701528101516101a4860152606081015160a06101c4870152612c819190608090612c6b906102048901906120e8565b91015186820361016319016101e48801526149d0565b918480938192889660016044850152606484015260848301528560a4830152600460c4830152600660e4830152600561010483015260076101248301523361014483015203915af4801561049a57612cd7575050565b612ce28280926121fe565b6102305750565b612d02915060203d6020116109f8576109ea81836121fe565b5f612bb8565b6040513d88823e3d90fd5b505060085492935090916001600160a01b03169073150bde577c858a9f656c810f8781fe56f1b84bac90813b156104965760408051639bd750b360e01b81526004810196909652610160602487015281516001600160a01b031661016487015260208201516101848701528101516101a4860152606081015160a06101c4870152612dab9190608090612c6b906102048901906120e8565b918480938192889660026044850152606484015260848301528560a4830152600460c4830152600660e4830152600561010483015260076101248301523361014483015203915af4801561049a57612cd7575050565b63308117bb60e01b8952600489fd5b60405162461bcd60e51b815260206004820152601660248201527510dbdb5b595b9d08191bd95cc81b9bdd08195e1a5cdd60521b6044820152606490fd5b612e5b9199505f906121fe565b5f975f612b2c565b906129919361299f936040519260208401947ff811a238163deb0c3f205ad22be609d7c56480b7a43138a2b2899ca4ec1185308652604085015260018060a01b0316606084015260018060a01b0316608083015260a082015260a0815261296760c0826121fe565b91929092612ef97fb22f94c9effcc577ed8d9c14cad648cd018b60030c47e7dc0890bb0ddb363c0a846138f1565b916020840191825195612f195f9760018060a01b0316923390878561499f565b15613496578551612f35919086906001600160a01b03166148b2565b61325b57845160405163842b3b7d60e01b81526001600160a01b03909116600482015260248101919091526001604482015260208160648173b2286303d50c90f619d68feea5901947abc727265af4908115612d0857869161323c575b50612fb857835163c55ddc9760e01b8652336004526001600160a01b0316602452604485fd5b909193928484528360205260018060a01b0360408520541661322d57848452600360205260ff60408520541661321e576008546040516320279bed60e01b81526001600160a01b039091169390602081600481885afa908115612d0857906001600160601b039187916131ff575b5016938461318d575b5060085473150bde577c858a9f656c810f8781fe56f1b84bac93906001600160a01b0316843b15611a045791613124939187959360405197889687958695638c9e2d5b60e01b87528d6004880152610180602488015260018060a01b0382511661018488015260018060a01b039051166101a487015260408101516101c487015260608101516101e4870152608081015161020487015260ff60a08201511661022487015261010061310e6130f660c08401516101206102448b01526102a48a01906120e8565b60e084015189820361018319016102648b01526149d0565b91015186820361018319016102848801526120e8565b92600160448601526064850152608484015260a48301528560c4830152600460e48301526006610104830152600561012483015260076101448301523361016483015203915af4801561049a5761317a57505090565b6131858280926121fe565b610230575090565b8434106131e75760208591600460405180948193633f3071a960e11b83525af18015612d08571561302f576131d99060203d6020116131e0575b6131d181836121fe565b810190614a39565b505f61302f565b503d6131c7565b631c102d6360e21b8652346004526024859052604486fd5b613218915060203d6020116131e0576131d181836121fe565b5f613026565b6339c7811160e01b8452600484fd5b63e0048f3960e01b8452600484fd5b613255915060203d6020116109f8576109ea81836121fe565b5f612f92565b505f83815260208190526040902054929450916001600160a01b031661348757835f52600360205260ff60405f205416613478576008546040516320279bed60e01b81526001600160a01b039091169390602081600481885afa8015611ea5576001600160601b03915f91613459575b501693846133f8575b506008546001600160a01b03169173150bde577c858a9f656c810f8781fe56f1b84bac9190823b156104e3575f946133999460405197889687958695638c9e2d5b60e01b87528c6004880152610180602488015260018060a01b0382511661018488015260018060a01b039051166101a487015260408101516101c487015260608101516101e4870152608081015161020487015260ff60a08201511661022487015261010061310e6130f660c08401516101206102448b01526102a48a01906120e8565b92600260448601526064850152608484015260a48301528560c4830152600460e48301526006610104830152600561012483015260076101448301523361016483015203915af48015611ea5576133ee575090565b5f612330916121fe565b8434106134425760208591600460405180948193633f3071a960e11b83525af18015611ea557156132d45761343b9060203d6020116131e0576131d181836121fe565b505f6132d4565b84631c102d6360e21b5f523460045260245260445ffd5b613472915060203d6020116131e0576131d181836121fe565b5f6132cb565b6339c7811160e01b5f5260045ffd5b63e0048f3960e01b5f5260045ffd5b63308117bb60e01b5f5260045ffd5b9081526001600160a01b03918216602082015291811660408301525f606083015260036080830152600460a0830152600660c0830152600560e083015260076101008301529091166101208201526101400190565b939295909491945f96855f525f60205261354560018060a01b0360405f205416977fb22f94c9effcc577ed8d9c14cad648cd018b60030c47e7dc0890bb0ddb363c0a90848a8a612e63565b9087331495861561368e575b505060405163842b3b7d60e01b8152600481018890526001600160a01b0383166024820152600160448201529360208560648173b2286303d50c90f619d68feea5901947abc727265af4948515611ea5575f9561366d575b508461364c575b505050508115613644575b506135d85763c55ddc9760e01b8352336004526024829052604483fd5b6008546001600160a01b0316925073150bde577c858a9f656c810f8781fe56f1b84bac803b156104e357613627935f936040519586948593849363026447b560e01b85523392600486016134a5565b03915af48015611ea5576136385750565b5f613642916121fe565b565b90505f6135bb565b613664945061365e90339436916122df565b9161499f565b5f8080806135b0565b61368791955060203d6020116109f8576109ea81836121fe565b935f6135a9565b6136a7929650906136a09136916122df565b85886148b2565b935f80613551565b156136b657565b60405162461bcd60e51b81526020600482015260126024820152712737ba1031b7b6b6b2b73a1030baba3437b960711b6044820152606490fd5b5f8181526020819052604081205483519195949293926001600160a01b039283169290911673b2286303d50c90f619d68feea5901947abc72726803b156104e3575f60649160405192838092638916a72d60e01b8252866004830152886024830152600260448301525af48015611ea5576138b5575b50906137996137a09392857fb22f94c9effcc577ed8d9c14cad648cd018b60030c47e7dc0890bb0ddb363c0a91886129a5565b339261499f565b6137b35763308117bb60e01b8452600484fd5b6008546001600160a01b03169273150bde577c858a9f656c810f8781fe56f1b84bac9290833b1561049657918593916138609360405196879586948594639bd750b360e01b86526004860152610160602486015260018060a01b03815116610164860152602081015161018486015260408101516101a4860152608061384a606083015160a06101c48901526102048801906120e8565b91015185820361016319016101e48701526149d0565b9161386e604485018961259b565b606484015260848301528560a4830152600460c4830152600660e4830152600561010483015260076101248301523361014483015203915af4801561049a57612cd7575050565b6137a093929197505f6138c7916121fe565b6137995f9791929350613766565b638b78c6d8195433036138e457565b6382b429005f526004601cfd5b61299f6129919160c0810151602081519101209061391260e08201516147ad565b90610100810151602081519101209060ff60a08201511660018060a01b0382511660018060a01b036020840151169060408401519260806060860151950151956040519760208901997f04a5f1bbcb9ec1d0161775ef93887c9b059e8c7456620e0dce9fe29ba4d46e4b8b5260408a01526060890152608088015260a087015260c086015260e08501526101008401526101208301526101408201526101408152612967610160826121fe565b60018060a01b031680638b78c6d819547f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3638b78c6d81955565b919091613a297fb22f94c9effcc577ed8d9c14cad648cd018b60030c47e7dc0890bb0ddb363c0a826138f1565b9160208201613a4581515f9686339260018060a01b031661499f565b613a585763308117bb60e01b8552600485fd5b9091928094505f525f60205260018060a01b0360405f20541661348757835f52600360205260ff60405f205416613478576008546040516320279bed60e01b81526001600160a01b039091169390602081600481885afa8015611ea5576001600160601b03915f91613c31575b50169384613be7575b506008546001600160a01b03169173150bde577c858a9f656c810f8781fe56f1b84bac9190823b156104e3575f94613b939460405197889687958695638c9e2d5b60e01b87528c6004880152610180602488015260018060a01b0382511661018488015260018060a01b039051166101a487015260408101516101c487015260608101516101e4870152608081015161020487015260ff60a08201511661022487015261010061310e6130f660c08401516101206102448b01526102a48a01906120e8565b928860448601526064850152608484015260a48301528560c4830152600460e48301526006610104830152600561012483015260076101448301523361016483015203915af48015611ea5576133ee575090565b8434106134425760208591600460405180948193633f3071a960e11b83525af18015611ea55715613ace57613c2a9060203d6020116131e0576131d181836121fe565b505f613ace565b613c4a915060203d6020116131e0576131d181836121fe565b5f613ac5565b919060605f91843560068110156104e35780613ed957505050909173f30fccf0e8b483ae61be8731fd736ef794a63ac7906040516364d429a160e01b815260206004820152838180613ca560248201866127f2565b0381865af4908115613ece578491613eac575b50613cd9613cd2613ccc6060850185614a6c565b90614aa1565b36916122df565b91613cee60018060a01b0383511633146136af565b6060820151804211611c8f575060808201805161010084019081519080613e57575b5050604084018051602060018060a01b036008541691602460405180948193633db29d8560e21b835260048301525afa908115611e85578991613e38575b5015613e2957825190518115159182613e0f575b5050613e005790839291600160ff60a08a97015116925191519214613ddc575b5050926020613d9493940135916139fc565b6024604051809481936327bc54c960e11b835260048301525af49182156106eb578092613dc057505090565b61233092503d8091833e613dd481836121fe565b810190614caf565b909193501590511581613df8575b50610de25784915f80613d82565b90505f613dea565b6340d82e3560e01b8752600487fd5b909150885287602052600260408920015414155f80613d62565b636ddd9da960e01b8852600488fd5b613e51915060203d6020116109f8576109ea81836121fe565b5f613d4e565b808952602089905260408920546001600160a01b0316159081613e95575b50613e865751610edc575f80613d10565b630919176b60e31b8852600488fd5b8952506003602052604088205460ff16155f613e75565b613ec891503d8086833e613ec081836121fe565b810190614bbe565b5f613cb8565b6040513d86823e3d90fd5b6001810361411b57505050909173f30fccf0e8b483ae61be8731fd736ef794a63ac7906040516364d429a160e01b815260206004820152838180613f2060248201866127f2565b0381865af4908115613ece578491614101575b506060820191613f73613f5b613f6b613f61613f52613ccc8887614a6c565b93909786614a6c565b90614adb565b96909236916122df565b9436916122df565b9060608301518042116140eb575060808301805161010085019081519080614096575b5050604085018051602060018060a01b036008541691602460405180948193633db29d8560e21b835260048301525afa9081156119f9578a91614077575b50156140685782519051811515918261404e575b505061403f579084939291600160ff60a08b9801511692519151921461401b575b5050936020613d949495013592612ecb565b909194501590511581614037575b50610de25785925f80614009565b90505f614029565b6340d82e3560e01b8852600488fd5b909150895288602052600260408a20015414155f80613fe8565b636ddd9da960e01b8952600489fd5b614090915060203d6020116109f8576109ea81836121fe565b5f613fd4565b808a5260208a905260408a20546001600160a01b03161590816140d4575b506140c55751610edc575f80613f96565b630919176b60e31b8952600489fd5b8a52506003602052604089205460ff16155f6140b4565b6394cf36f960e01b875260045242602452604486fd5b61411591503d8086833e613ec081836121fe565b5f613f33565b600281036142d857505060405163c825815760e01b815260206004820152905081818061414b60248201886127f2565b038173f30fccf0e8b483ae61be8731fd736ef794a63ac75af4801561049a57829183916142b4575b50614187613cd2613ccc6060880188614a6c565b90828452836020526141a660018060a01b0360408620541633146136af565b60408101518042116113bf5750828452602084905260408420546001600160a01b0316158015614299575b611395578284528360205260018060408620015460f81c1461138657828452602084815260408520548251918301519173b2286303d50c90f619d68feea5901947abc72726916001600160a01b039182169116823b15611e815760405163820102e160e01b815293889385939092849283926142509260048501612760565b03915af480156104ef57614284575b5060206142709495960135926136f0565b6040519061427f6020836121fe565b815290565b61428f8580926121fe565b611382575f61425f565b508284526003602052600160ff6040862054161515146141d1565b90506142d291503d8084833e6142ca81836121fe565b810190614b1b565b5f614173565b6003810361447857505060405163c825815760e01b815260206004820152905081818061430860248201886127f2565b038173f30fccf0e8b483ae61be8731fd736ef794a63ac75af4801561049a578291839161445c575b5060608501614361613f5b6116d561435761434e613ccc868c614a6c565b9390958b614a6c565b94909236916122df565b916040810151804211611c8f5750838552602085905260408520546001600160a01b0316158015614441575b611c65578385528460205260018060408720015460f81c14611c5657838552602085815260408620548251918301519173b2286303d50c90f619d68feea5901947abc72726916001600160a01b039182169116823b156119f55760405163820102e160e01b8152938993859390928492839261440c9260048501612760565b03915af48015612d085761442c575b506020614270959697013593612ab5565b6144378680926121fe565b610548575f61441b565b508385526003602052600160ff60408720541615151461438d565b905061447291503d8084833e6142ca81836121fe565b5f614330565b93949293600481036145f85750505060206144ae91604051809381926328b5649b60e11b835284600484015260248301906127f2565b038173f30fccf0e8b483ae61be8731fd736ef794a63ac75af4908115611ea5575f916145c6575b505f818152602081905260409020546001600160a01b03161580156145ab575b61459c57805f525f60205261451760018060a01b0360405f20541633146136af565b60085473150bde577c858a9f656c810f8781fe56f1b84bac916001600160a01b0390911690823b156104e35760405163026447b560e01b8152925f9284928391829161456a9133918290600486016134a5565b03915af48015611ea557614589575b506040519061427f6020836121fe565b61459591505f906121fe565b5f5f614579565b6354ececb560e01b5f5260045ffd5b50805f526003602052600160ff60405f2054161515146144f5565b90506020813d6020116145f0575b816145e1602093836121fe565b810103126104e357515f6144d5565b3d91506145d4565b9293509091600503614768575060405163536d4c1f60e11b81526020600482015281818061462960248201876127f2565b038173f30fccf0e8b483ae61be8731fd736ef794a63ac75af4908115611ea5575f91614701575b50805192604060018060a01b0360208401511692015192810190614685613f5b61467d613ccc8585614a6c565b949093614a6c565b9490938142116146ea575f878152602081905260409020546001600160a01b03161580156146cf575b61459c576146bb966134fa565b6040516146c96020826121fe565b5f815290565b50865f526003602052600160ff60405f2054161515146146ae565b506394cf36f960e01b5f526004524260245260445ffd5b90508181813d8311614761575b61471881836121fe565b810103126104e35760405190828201908282106001600160401b038311176121985760409182528051835261474f60208201614a58565b6020840152015160408201525f614650565b503d61470e565b6084906040519063086ad52b60e01b82526004820152604060248201526016604482015275496e76616c6964206f7065726174696f6e207479706560501b6064820152fd5b9081516147d26147bc82612333565b916147ca60405193846121fe565b808352612333565b602082019290601f19013684375f5b845181101561486857806147f7600192876128eb565b5151602061480583896128eb565b510151602081519101206040519060208201927fac744b2be3b7f8d6f7d637db76586a27ab36aba301ab536c7226a6a344ab514f845260408301526060820152606081526148546080826121fe565b51902061486182866128eb565b52016147e1565b506040519151909350602082019290829084905f5b81811061489957505061299f925003601f1981018352826121fe565b845183526020948501948694509092019160010161487d565b90915f91906001600160a01b038216156149975760405192600484019460248501956044860192853b1561491b57509186939160209593630b135d3f60e11b8852526040845281518501809260045afa9360443d01915afa9151630b135d3f60e11b1491161690565b979650509050815180604014614972576041146149385750505050565b60209293955060608201515f1a835260408201516060525b5f5201516040526020600160805f825afa511860601b3d11915f606052604052565b506020929395506040820151601b8160ff1c01845260018060ff1b0316606052614950565b505050505f90565b6001600160a01b038181169416939093149283156149be575b50505090565b6149c893506148b2565b5f80806149b8565b9080602083519182815201916020808360051b8301019401925f915b8383106149fb57505050505090565b9091929394602080614a2a600193601f198682030187526040838b5180518452015191818582015201906120e8565b970193019301919392906149ec565b908160209103126104e357516001600160601b03811681036104e35790565b51906001600160a01b03821682036104e357565b903590601e19813603018212156104e357018035906001600160401b0382116104e357602001918160051b360383136104e357565b901561226557803590601e19813603018212156104e35701908135916001600160401b0383116104e35760200182360381136104e3579190565b906001101561226557602081013590601e19813603018212156104e35701908135916001600160401b0383116104e35760200182360381136104e3579190565b91906040838203126104e3578251926020810151906001600160401b0382116104e3570160a0818303126104e35760405191614b56836121e3565b614b5f82614a58565b8352602082015160208401526040820151604084015260608201516001600160401b0381116104e35781614b949184016125bc565b606084015260808201516001600160401b0381116104e357614bb69201612600565b608082015290565b6020818303126104e3578051906001600160401b0382116104e35701610120818303126104e35760405191614bf2836121c7565b614bfb82614a58565b8352614c0960208301614a58565b602084015260408201516040840152606082015160608401526080820151608084015260a082015160ff811681036104e35760a084015260c08201516001600160401b0381116104e35781614c5f9184016125bc565b60c084015260e08201516001600160401b0381116104e35781614c83918401612600565b60e08401526101008201516001600160401b0381116104e357614ca692016125bc565b61010082015290565b906020828203126104e35781516001600160401b0381116104e35761233092016125bc56fea2646970667358221220cb10a60526704b3a746fd9f56bb92cc8444d3078bd721ea22324ec4a6cffa55b64736f6c634300081c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000d1177f978a5535eba843bdd817e730df1c42c476
-----Decoded View---------------
Arg [0] : initialOwner (address): 0xD1177f978A5535eBa843bDd817E730DF1c42c476
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000d1177f978a5535eba843bdd817e730df1c42c476
Deployed Bytecode Sourcemap
893:27644:20:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;893:27644:20;;;;;;:::i;:::-;11885:237:16;;;;;893:27644:20;11885:237:16;;;;893:27644:20;;;;;;;;;;-1:-1:-1;893:27644:20;;-1:-1:-1;;893:27644:20;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;;;;;1575:245:17;;;;;;;;;23825:8:20;893:27644;;;;;;;;;23825:55;;893:27644;;;;;;23825:55;;893:27644;;;;;;;;;;;;;;;;;;;;;;;;;;;23870:9;;;;;;;893:27644;23870:9;;893:27644;;;;23825:55;;;;;;;;;;;893:27644;;;;;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;-1:-1:-1;;893:27644:20;;;:::i;:::-;;;;;;;;;23974:10;;;23986:21;;;;;;893:27644;;;;;;;;23870:9;893:27644;;;;24160:64;893:27644;24183:10;24160:64;;1883:75:17;1575:245;1883:75;893:27644:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;24009:3;24064:13;;;;;;;;;:::i;:::-;24022:59;;;;;893:27644;;;;;;;;;;;;24022:59;;893:27644;;24022:59;;893:27644;;;;;;:::i;:::-;;;;;;24022:59;;;;;;;;;;;24009:3;24125:13;;;24102:40;24125:13;;893:27644;24125:13;;;;:::i;:::-;24102:40;:::i;:::-;24089:53;;;;:::i;:::-;;;;;;:::i;:::-;;893:27644;23974:10;;;;;24022:59;;;;;:::i;:::-;893:27644;;24022:59;;;;893:27644;;;;24022:59;893:27644;;;;;;;;;24022:59;893:27644;;;;;;;;;;;;;;;;;;23825:55;893:27644;23825:55;;893:27644;23825:55;;;;;;893:27644;23825:55;;;:::i;:::-;;;893:27644;;;;;23825:55;;893:27644;-1:-1:-1;893:27644:20;;23825:55;;;-1:-1:-1;23825:55:20;;;893:27644;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;1575:245:17;;;;893:27644:20;1575:245:17;;893:27644:20;;;;;;;;;-1:-1:-1;893:27644:20;;-1:-1:-1;;893:27644:20;;;;;;:::i;:::-;12478:70:16;;:::i;:::-;8479:183;;;;;;8681:8;;;:::i;:::-;893:27644:20;;8479:183:16;;;;893:27644:20;8479:183:16;;893:27644:20;-1:-1:-1;893:27644:20;;-1:-1:-1;;893:27644:20;;;;;;:::i;:::-;12478:70:16;;:::i;:::-;10506:526;;;;;;893:27644:20;10506:526:16;;;;;;;;;;11051:12;10506:526;;11051:12;:::i;10506:526::-;;;;893:27644:20;10506:526:16;;893:27644:20;;;;;;;;;;;;;:::i;:::-;;;;20148:19;893:27644;;;;;;;;;;;;;;;;;;:::i;:::-;;;;:::i;:::-;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;-1:-1:-1;;893:27644:20;;;;;;:::i;:::-;;;;:::i;:::-;;;-1:-1:-1;;;21107:39:20;;-1:-1:-1;;;;;893:27644:20;;;;21107:39;;893:27644;;;;;;;21139:6;893:27644;;;;;;21107:39;893:27644;21107:9;:39;;;;;;;;;;893:27644;;;;;;;;;21107:39;;893:27644;21107:39;;893:27644;21107:39;;;;;;893:27644;21107:39;;;:::i;:::-;;;893:27644;;;;;;;21107:39;;;;;-1:-1:-1;21107:39:20;;;893:27644;;;;;;;;;;;;;;;;;-1:-1:-1;;893:27644:20;;;;;;;;20529:23;893:27644;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2314:37;893:27644;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;-1:-1:-1;;893:27644:20;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;21756:40;:70;;;;893:27644;21745:131;;17017:14;893:27644;16960:10;;;;-1:-1:-1;;;;;893:27644:20;16960:219;;;;;;893:27644;;;;;;;;;;;;16960:219;;893:27644;16960:219;;893:27644;;;;;;;;;;;;;;;17078:19;893:27644;;;;17105:19;893:27644;;;;17132:23;893:27644;;;;17163:10;893:27644;;;;16960:219;;;;;;;;893:27644;;16960:219;;;;;:::i;:::-;893:27644;;16960:219;893:27644;16960:219;893:27644;;;;21745:131;-1:-1:-1;;;21848:21:20;;893:27644;21848:21;;21756:70;893:27644;;;;21800:7;893:27644;;;;;;;;;;;21800:26;21756:70;;893:27644;;;;;;;-1:-1:-1;;893:27644:20;;;;;;;:::i;:::-;15188:9;:57;;;;;893:27644;;-1:-1:-1;;;15188:57:20;;15210:10;893:27644;15188:57;;893:27644;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;15962:9;893:27644;;;;;;;;;;;;;15188:57;;;;;;;;;;;893:27644;;15188:57;893:27644;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;-1:-1:-1;;893:27644:20;;;;;;:::i;:::-;;;:::i;:::-;;;-1:-1:-1;;;20709:44:20;;-1:-1:-1;;;;;893:27644:20;;;;20709:44;;893:27644;;;;;;;;;;;;;;20709:44;893:27644;20709:9;:44;;;;;;;893:27644;20709:44;;;;893:27644;;;;;;;;;;20709:44;;;;;;;;;;;;;;;:::i;:::-;;;;;:::i;:::-;;;;;;;;;893:27644;;;;;;;-1:-1:-1;;893:27644:20;;;;;;:::i;:::-;;;;:::i;:::-;;;-1:-1:-1;;;20909:51:20;;-1:-1:-1;;;;;893:27644:20;;;;20909:51;;893:27644;;;;;;;;;;;;;;20909:51;893:27644;20909:9;:51;;;;;;;;;;893:27644;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;11523:61:16;893:27644:20;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;-1:-1:-1;;893:27644:20;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;:::i;:::-;;-1:-1:-1;;;;;893:27644:20;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;-1:-1:-1;;893:27644:20;;;;;;;;;:::i;:::-;-1:-1:-1;;;893:27644:20;;;;;;;;;-1:-1:-1;893:27644:20;;-1:-1:-1;;893:27644:20;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;:::i;:::-;;;;;:::i;:::-;;23040:51;893:27644;;;;;881:191:29;;893:27644:20;23048:10;:20;23040:51;:::i;:::-;3350:20;;;881:191:29;21937:15:20;;:26;21933:105;;3400:20;;;;893:27644;;;3422:21;;;;;;;22355:22;;22351:326;;893:27644;3463:21;;893:27644;3463:21;;881:191:29;;893:27644:20;;;;;;21349:14;893:27644;;;;;;;;;;;;;21349:39;;893:27644;21349:39;;893:27644;21349:39;;;;;;;;;;;893:27644;21348:40;;21344:105;;893:27644;;881:191:29;;22132:22:20;;;:67;;;;893:27644;22128:126;;;;3595:23;539:1:32;893:27644:20;3595:23;;;893:27644;;;;3654:21;;23231:45;;23227:318;;893:27644;;3166:1050;3069:9;;;3166:1050;:::i;:::-;893:27644;;;;;;23227:318;23303:22;893:27644;;23350:27;23389:24;;;23227:318;23385:154;;;23227:318;;;;23385:154;893:27644;;-1:-1:-1;;;23432:98:20;;893:27644;;23432:98;;893:27644;;;;;;;;;;;-1:-1:-1;;;893:27644:20;;;;;;23432:98;23389:24;;;;;;22128:126;-1:-1:-1;;;22216:31:20;;893:27644;;22216:31;22132:67;893:27644;;;;;;;;22158:28;893:27644;;;22158:28;893:27644;22158:41;;22132:67;;;;21344:105;-1:-1:-1;;;21405:37:20;;893:27644;21405:37;;21349:39;;;;893:27644;21349:39;893:27644;21349:39;;;;;;;:::i;:::-;;;;;893:27644;;;;;;;;;22351:326;893:27644;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;22391:39;;;:61;;22351:326;22387:123;;;893:27644;22518:153;;22351:326;;;;22518:153;893:27644;;-1:-1:-1;;;22568:94:20;;893:27644;;22568:94;;893:27644;;;;;;;;;;;-1:-1:-1;;;893:27644:20;;;;;;23432:98;22387:123;-1:-1:-1;;;22471:30:20;;893:27644;22471:30;;22391:61;893:27644;;-1:-1:-1;22435:7:20;893:27644;;;;;;;;22434:18;-1:-1:-1;22391:61:20;;21933:105;-1:-1:-1;;;21980:51:20;;893:27644;;21937:15;893:27644;;;;-1:-1:-1;21980:51:20;893:27644;;;;;;;;;;12478:70:16;;:::i;:::-;6813:405;;;;;;;;;;;;893:27644:20;;;;;;;;;-1:-1:-1;;893:27644:20;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;18716:58;893:27644;;;;;;:::i;:::-;18757:16;18716:58;;:::i;893:27644::-;;;;;;;-1:-1:-1;;893:27644:20;;;;;17401:145;893:27644;;:::i;:::-;;;:::i;:::-;17522:16;;893:27644;;;;;;;;;17401:145;;:::i;893:27644::-;;;;;;;-1:-1:-1;;893:27644:20;;;;;;;;;;;;21269:7;893:27644;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;893:27644:20;;;;;;:::i;:::-;12478:70:16;;:::i;:::-;-1:-1:-1;;;;;893:27644:20;18903:30;;18899:56;;-1:-1:-1;;;;;893:27644:20;;18961:58;893:27644;;;18961:58;893:27644;;;18899:56;-1:-1:-1;;;18942:13:20;;893:27644;18942:13;;893:27644;;;;;;;-1:-1:-1;;893:27644:20;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;21756:40;:70;;;;893:27644;21745:131;;893:27644;;;;;;;;23040:51;893:27644;;;;;;;;;;12254:10;23048:20;23040:51;:::i;:::-;12676:14;893:27644;12613:10;;-1:-1:-1;;;;;893:27644:20;;;;12613:240;;;;;893:27644;;-1:-1:-1;;;12613:240:20;;893:27644;;;;;;;;;12613:240;;12254:10;;;;893:27644;12613:240;;;:::i;21756:70::-;893:27644;;;;21800:7;893:27644;;;;;;;;;;;21800:26;21756:70;;893:27644;;;;;;;-1:-1:-1;;893:27644:20;;;;;;;;20339:19;893:27644;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;-1:-1:-1;893:27644:20;;-1:-1:-1;;893:27644:20;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;:::i;:::-;;;;;;;23040:51;893:27644;;;;;;;;;;23048:10;:20;23040:51;:::i;:::-;893:27644;8253:17;;881:191:29;21937:15:20;;:26;21933:105;;-1:-1:-1;893:27644:20;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;21756:40;:70;;;;893:27644;21745:131;;893:27644;;;;;;;;;;;8324:31;893:27644;;;22750:45;22746:97;;893:27644;;;;;;;;;;;881:191:29;;8417:14:20;;;881:191:29;893:27644:20;;-1:-1:-1;;;;;893:27644:20;;;;;;22931:9;:51;;;;;;893:27644;;;;;;;;;;;;;;;22931:51;;893:27644;22931:51;;;:::i;:::-;;;;;;;;;;;893:27644;7620:9;;22988:1;7620:9;;22988:1;;:::i;22931:51::-;;;;;:::i;:::-;893:27644;;22931:51;;;;893:27644;;;;22746:97;-1:-1:-1;;;22812:24:20;;893:27644;22812:24;;21745:131;-1:-1:-1;;;21848:21:20;;893:27644;21848:21;;21756:70;893:27644;;;;21800:7;893:27644;;;;;;;;;;;21800:26;21756:70;;21933:105;-1:-1:-1;;;21980:51:20;;893:27644;;21937:15;893:27644;;;21980:51;;893:27644;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;-1:-1:-1;;;893:27644:20;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;9831:339:16;;;;;;;;;;;;;;;;893:27644:20;;;;;;;;;-1:-1:-1;;893:27644:20;;;;;;;;;:::i;:::-;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;:::i;:::-;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;:::i;:::-;21937:15;;;;;:26;21933:105;;893:27644;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;21756:40;:70;;;;893:27644;21745:131;;21881:1;;;;:::i;21745:131::-;-1:-1:-1;;;21848:21:20;;893:27644;21848:21;;21756:70;893:27644;;;;21800:7;893:27644;;;;;;;;;;;21800:26;21756:70;;21933:105;-1:-1:-1;;;21980:51:20;;893:27644;;;;21937:15;893:27644;;;21980:51;;893:27644;;;;;;;-1:-1:-1;;893:27644:20;;;;;;;:::i;:::-;16067:9;:52;;;;;;893:27644;;-1:-1:-1;;;16067:52:20;;16092:10;893:27644;16067:52;;893:27644;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;;16067:52;;893:27644;;16067:52;;;;;;;;893:27644;;;;;;;;;-1:-1:-1;;893:27644:20;;;;;;-1:-1:-1;;;19650:123:20;;893:27644;;;19650:123;;;893:27644;19713:19;893:27644;;;;19742:23;893:27644;;;;19650:11;893:27644;19650:123;893:27644;19650:11;:123;;;;;;;;893:27644;19650:123;;;;893:27644;;;;;;;;;;:::i;19650:123::-;;;;;;;;;;;;;:::i;:::-;;;;;:::i;:::-;;;;;893:27644;-1:-1:-1;893:27644:20;;-1:-1:-1;;893:27644:20;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;:::i;:::-;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;:::i;:::-;;;;;:::i;:::-;;;;;:::i;:::-;5210:20;893:27644;5210:20;;881:191:29;21937:15:20;;:26;21933:105;;5260:20;;;;893:27644;;;5282:21;;;;;;;22355:22;;22351:326;;893:27644;5323:21;;893:27644;5323:21;;881:191:29;;893:27644:20;;;;;;21349:14;893:27644;;;;;;;;;;;;;21349:39;;893:27644;21349:39;;893:27644;21349:39;;;;;;;;;;;893:27644;21348:40;;21344:105;;893:27644;;881:191:29;;22132:22:20;;;:67;;;;893:27644;22128:126;;;;5455:23;539:1:32;893:27644:20;5455:23;;;893:27644;;;;5514:21;;23231:45;;23227:318;;893:27644;;5020:1505;4555:9;;;;5020:1505;:::i;23227:318::-;23303:22;;;;893:27644;;23350:27;23389:24;;;23227:318;23385:154;;;23227:318;;;;;23389:24;;;;;;22132:67;893:27644;;;;;;;;22158:28;893:27644;;;22158:28;893:27644;22158:41;;22132:67;;;;21349:39;;;;893:27644;21349:39;893:27644;21349:39;;;;;;;:::i;:::-;;;;22351:326;893:27644;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;22391:39;;;:61;;22351:326;22387:123;;;893:27644;22518:153;;22351:326;;;;22391:61;893:27644;;-1:-1:-1;22435:7:20;893:27644;;;;;;;;22434:18;-1:-1:-1;22391:61:20;;893:27644;;;;;;;;;;;;;;;;1139:41;893:27644;;;;;;;;;;-1:-1:-1;;893:27644:20;;;;;;:::i;:::-;;;;:::i;:::-;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;:::i;:::-;21937:15;;;:26;21933:105;;22931:9;:51;;;;;;893:27644;;-1:-1:-1;;;22931:51:20;;;893:27644;;22931:51;;;;893:27644;22931:51;;;:::i;:::-;;;;;;;;;;;;;;;893:27644;16379:45;;;;;;;893:27644;;-1:-1:-1;;;16379:45:20;;-1:-1:-1;;;;;893:27644:20;;;;16379:45;;893:27644;;;;;;;;;;;;22975:6;893:27644;;;;;;;;;16379:45;893:27644;;;16379:45;;;;;;;;;;;;893:27644;16558:16;;893:27644;16558:16;7705:64:29;16558:16:20;;;;16460:120;16558:16;;16460:120;;;:::i;893:27644::-;7705:64:29;;:::i;:::-;16598:114:20;16587:178;;16771:48;;;;;;;893:27644;;;;;;;;;;;;;16771:48;;893:27644;16771:48;;893:27644;;;;;;;;;;16771:48;;;;;;;;893:27644;;16587:178;-1:-1:-1;;;16734:24:20;;893:27644;15882:24;16734;16379:45;;;;;:::i;:::-;893:27644;;16379:45;;;;893:27644;;;;16379:45;893:27644;;;;;;;;;16379:45;893:27644;;;22931:51;;;;;:::i;:::-;893:27644;;22931:51;;;;;893:27644;;;;;;;;;21933:105;-1:-1:-1;;;21980:51:20;;893:27644;;;;21937:15;893:27644;;;21980:51;;893:27644;;;;;;;-1:-1:-1;;893:27644:20;;;;;;:::i;:::-;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;18091:135;18202:16;893:27644;;18202:16;;893:27644;;18091:135;:::i;893:27644::-;;;;;;;;;;9239:383:16;;;;;;7972:9;9132:15;893:27644:20;9239:383:16;;;;;;;;;893:27644:20;;;-1:-1:-1;893:27644:20;;-1:-1:-1;;893:27644:20;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;:::i;:::-;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;:::i;:::-;;;;;:::i;:::-;10108:17;893:27644;10108:17;;881:191:29;21937:15:20;;:26;21933:105;;-1:-1:-1;893:27644:20;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;21756:40;:70;;;;893:27644;21745:131;;893:27644;;;;;;;;;;;10179:31;893:27644;;;22750:45;22746:97;;893:27644;;;;;;;;;;;881:191:29;;10272:14:20;;;881:191:29;893:27644:20;;-1:-1:-1;;;;;893:27644:20;;;;;;22931:9;:51;;;;;;893:27644;;;;;;;;;;;;;;;22931:51;;893:27644;22931:51;;;:::i;:::-;;;;;;;;;;;893:27644;9401:9;;22988:1;9401:9;;22988:1;;:::i;22931:51::-;;;;;:::i;:::-;893:27644;;22931:51;;;;22746:97;-1:-1:-1;;;22812:24:20;;893:27644;22812:24;;21745:131;-1:-1:-1;;;21848:21:20;;893:27644;21848:21;;21756:70;893:27644;;;;21800:7;893:27644;;;;;;;;;;;21800:26;21756:70;;21933:105;-1:-1:-1;;;21980:51:20;;893:27644;;21937:15;893:27644;;;21980:51;;893:27644;;;;;;;;:::i;:::-;;;;;2091:56;893:27644;;;;;;;;2091:56;;;;;893:27644;2091:56;;;;:::i;:::-;893:27644;;;;;;;;;;;;;;;;;;;-1:-1:-1;;893:27644:20;;;;;;:::i;:::-;;;;:::i;:::-;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;:::i;:::-;21937:15;;;:26;21933:105;;22931:9;:51;;;;;;893:27644;;-1:-1:-1;;;22931:51:20;;893:27644;;;22931:51;;;;893:27644;22931:51;;;:::i;:::-;;;;;;;;;;;;893:27644;15522:45;;;;;;893:27644;;-1:-1:-1;;;15522:45:20;;-1:-1:-1;;;;;893:27644:20;;;;15522:45;;893:27644;;;;;;;22975:6;893:27644;;;;15522:45;893:27644;;;15522:45;;;;;;;;;;;;893:27644;15709:16;;;15600:131;893:27644;15709:16;7705:64:29;15709:16:20;;;15600:131;;;;;:::i;893:27644::-;7705:64:29;;;:::i;:::-;15749:111:20;15738:175;;15919:53;;;;;;;893:27644;;-1:-1:-1;;;15919:53:20;;-1:-1:-1;;;;;893:27644:20;;;;15919:53;;893:27644;;;;;;;;;;;;;15962:9;893:27644;;;;;;;;;;;;;15919:53;893:27644;15738:175;-1:-1:-1;;;15882:24:20;;893:27644;15882:24;;15522:45;;;;;:::i;:::-;893:27644;;15522:45;;;;893:27644;;;;15522:45;893:27644;;;;;;;;;22931:51;;;;;893:27644;22931:51;;:::i;:::-;893:27644;22931:51;;;;;893:27644;;;;;;;;;21933:105;21980:51;;;;893:27644;21980:51;893:27644;;21937:15;893:27644;;;;21980:51;893:27644;;;;;;-1:-1:-1;;893:27644:20;;;;;;:::i;:::-;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;18533:16;18437:120;18533:16;893:27644;18533:16;893:27644;;;;;;:::i;:::-;;;;18437:120;:::i;893:27644::-;;;;;;;:::i;:::-;;;;2218:60;893:27644;;;;;;;2218:60;;;;;893:27644;2218:60;;;;:::i;893:27644::-;;;;;;-1:-1:-1;;893:27644:20;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;-1:-1:-1;;893:27644:20;;;;;;-1:-1:-1;;;19362:111:20;;893:27644;;;19362:111;;;893:27644;;;;;19446:19;893:27644;;;;-1:-1:-1;893:27644:20;19362:111;893:27644;19362:11;:111;;;;;;893:27644;19362:111;893:27644;19362:111;;;893:27644;;;;;;;;;:::i;19362:111::-;;;;;;893:27644;19362:111;;;;;;:::i;:::-;;;;893:27644;;;;;;-1:-1:-1;;893:27644:20;;;;;17751:132;893:27644;;:::i;:::-;;;:::i;:::-;17859:16;893:27644;;;;;;17751:132;;:::i;893:27644::-;;;;-1:-1:-1;;;;;893:27644:20;;;;;;:::o;:::-;;;;-1:-1:-1;;;;;893:27644:20;;;;;;:::o;:::-;;;-1:-1:-1;;;;;893:27644:20;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;-1:-1:-1;893:27644:20;;;;;;;;-1:-1:-1;;893:27644:20;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;:::o;:::-;;;;-1:-1:-1;893:27644:20;;;;;-1:-1:-1;893:27644:20;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;:::o;:::-;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;:::o;:::-;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;:::o;:::-;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;:::o;:::-;-1:-1:-1;;;;;893:27644:20;;;;;;-1:-1:-1;;893:27644:20;;;;:::o;:::-;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;-1:-1:-1;893:27644:20;;-1:-1:-1;893:27644:20;;;-1:-1:-1;893:27644:20;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;-1:-1:-1;893:27644:20;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;:::i;:::-;;:::o;:::-;-1:-1:-1;;;;;893:27644:20;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;-1:-1:-1;;893:27644:20;;;;;;;;;;:::i;:::-;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;:::i;:::-;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;:::i;:::-;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;:::i;:::-;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;-1:-1:-1;893:27644:20;;;;;;;;-1:-1:-1;893:27644:20;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;-1:-1:-1;893:27644:20;;;;;-1:-1:-1;893:27644:20;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;-1:-1:-1;893:27644:20;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;-1:-1:-1;;893:27644:20;;;;;;;;;;:::i;:::-;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;:::i;:::-;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;:::i;:::-;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;;;22975:6;893:27644;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;-1:-1:-1;893:27644:20;;;;;;;;-1:-1:-1;;893:27644:20;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;893:27644:20;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;:::o;6432:377:29:-;;6746:57;6432:377;6746:57;6432:377;893:27644:20;;6650:66:29;;;;893:27644:20;1297:98:29;893:27644:20;;;;;;;;;1297:98:29;;893:27644:20;;;;;;;1297:98:29;;;893:27644:20;1297:98:29;;;893:27644:20;1297:98:29;;;893:27644:20;1297:98:29;6650:66;;;;;;:::i;:::-;893:27644:20;6633:89:29;;893:27644:20;;6746:57:29;;;6650:66;6746:57;;;;1297:98;;;;;;;;;;;;893:27644:20;1297:98:29;;;893:27644:20;1297:98:29;;;6746:57;;893:27644:20;;6746:57:29;;;;;;:::i;:::-;893:27644:20;6736:68:29;;6432:377;:::o;4017:562::-;4516:57;4017:562;4516:57;4017:562;4325:16;;;;893:27644:20;;;;;4309:34:29;4371:17;4353:36;4371:17;;;;4353:36;:::i;:::-;893:27644:20;;;;;;881:191:29;;893:27644:20;4437:14:29;4461:17;893:27644:20;4437:14:29;;881:191;4461:17;;881:191;893:27644:20;4461:17:29;893:27644:20;4239:247:29;893:27644:20;4239:247:29;;893:27644:20;881:191:29;893:27644:20;;4461:17:29;881:191;;893:27644:20;4325:16:29;881:191;;893:27644:20;4371:17:29;881:191;;893:27644:20;;;;;;;881:191:29;;;893:27644:20;881:191:29;;;893:27644:20;881:191:29;;;893:27644:20;881:191:29;;;893:27644:20;881:191:29;4239:247;;;;;;:::i;5696:399::-;;;6032:57;5696:399;6032:57;5696:399;893:27644:20;;5931:71:29;;;;893:27644:20;1128:110:29;893:27644:20;;;;;;;;;1128:110:29;;893:27644:20;;;;;;;1128:110:29;;;893:27644:20;1128:110:29;;;893:27644:20;1128:110:29;;;893:27644:20;1128:110:29;;;893:27644:20;1128:110:29;5931:71;;;;;;:::i;9900:1524:20:-;10331:8;893:27644;;;;;;;;;;;881:191:29;;10331:8:20;;-1:-1:-1;;;;;893:27644:20;;;;9900:1524;;;;;10426:9;;893:27644;;;;10426:45;;;;;893:27644;;;;;10426:45;;;;;;893:27644;;;;;;10464:6;893:27644;;;;10331:8;10426:45;;;;;;;;;;;;9900:1524;10486:20;;;893:27644;;10721:114;10559:110;10647:16;10559:110;;;;:::i;:::-;10817:10;;10721:114;;;;:::i;:::-;10720:115;10709:176;;7705:64:29;;;;;:::i;:::-;10927:242:20;;893:27644;;10426:45;893:27644;;;;;;;;;11178:44;;;10426:45;11178:44;;893:27644;;;;;11212:9;893:27644;;;;11178:44;;;;;;;;;;;9900:1524;11174:199;;;-1:-1:-1;;;11386:33:20;;10817:10;10426:45;893:27644;;;;;;11386:33;;11174:199;11968:14;893:27644;11874:10;;-1:-1:-1;11874:10:20;;-1:-1:-1;;;;;893:27644:20;;11874:10;;:256;;;;;893:27644;;;-1:-1:-1;;;11874:256:20;;10426:45;11874:256;;893:27644;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;-1:-1:-1;;893:27644:20;;;;;;:::i;:::-;;;;;;;;;11212:9;893:27644;;;;10426:45;893:27644;;;;;;;;;;;;10426:45;893:27644;;;;12029:19;893:27644;;;;12056:19;893:27644;;;;12083:23;893:27644;;;;10817:10;893:27644;;;;11874:256;;;;;;;;;;11360:7;;:::o;11874:256::-;;;;;;:::i;:::-;893:27644;;11360:7;:::o;11178:44::-;;;;893:27644;11178:44;893:27644;11178:44;;;;;;;:::i;:::-;;;;;893:27644;;;;;;;;;10927:242;-1:-1:-1;;11968:14:20;893:27644;11874:10;;-1:-1:-1;11874:10:20;;-1:-1:-1;;;;;893:27644:20;;11874:10;;:256;;;;;893:27644;;;-1:-1:-1;;;11874:256:20;;10426:45;11874:256;;893:27644;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;10464:6;893:27644;;;;10426:45;893:27644;;;;;;;;;;;;10426:45;893:27644;;;;12029:19;893:27644;;;;12056:19;893:27644;;;;12083:23;893:27644;;;;10817:10;893:27644;;;;11874:256;;;;;;;;;;11156:7;;:::o;10709:176::-;-1:-1:-1;;;10857:21:20;;10426:45;10857:21;;893:27644;;;-1:-1:-1;;;893:27644:20;;;10426:45;893:27644;;;;;;;;-1:-1:-1;;;893:27644:20;;;;10426:45;;893:27644;10426:45;;;;;10331:8;10426:45;;:::i;:::-;10331:8;10426:45;;;;4924:383:29;;5244:57;4924:383;5244:57;4924:383;893:27644:20;;5145:69:29;;;;893:27644:20;724:101:29;893:27644:20;;;724:101:29;;893:27644:20;;;;;;;724:101:29;;;893:27644:20;;;;;;;724:101:29;;;893:27644:20;724:101:29;;;893:27644:20;724:101:29;5145:69;;;;;;:::i;5020:1505:20:-;;;;;5592:76;5646:16;5592:76;;:::i;:::-;5688:15;;;;881:191:29;;;;5722:115:20;-1:-1:-1;893:27644:20;;;;;;;5819:10;;5722:115;;;;:::i;:::-;5721:116;5710:177;;881:191:29;;7705:64;;893:27644:20;;;-1:-1:-1;;;;;893:27644:20;7705:64:29;:::i;:::-;5929:302:20;;881:191:29;;893:27644:20;;-1:-1:-1;;;6240:56:20;;-1:-1:-1;;;;;893:27644:20;;;6240:56;;;893:27644;;;;;;;;;;;;;5688:15;893:27644;6240:56;893:27644;6240:9;:56;;;;;;;;;;;5020:1505;6236:226;;;881:191:29;;-1:-1:-1;;;6475:45:20;;5819:10;6240:56;893:27644;-1:-1:-1;;;;;893:27644:20;;;;;6475:45;6236:226;893:27644;;;;;;;;5688:15;893:27644;;;;;;;;;;;21518:90;;893:27644;;;21617:7;5688:15;893:27644;;;;;;;21613:69;;6807:14;893:27644;;;-1:-1:-1;;;6807:38:20;;-1:-1:-1;;;;;893:27644:20;;;;;5688:15;893:27644;6240:56;893:27644;;6807:38;;;;;;;;-1:-1:-1;;;;;6807:38:20;;;;;6236:226;893:27644;;6855:22;;6851:231;;6236:226;-1:-1:-1;6807:14:20;893:27644;7088:10;;893:27644;-1:-1:-1;;;;;893:27644:20;7088:287;;;;;893:27644;;;;;;;;;;;;;;;;;;;7088:287;;;6240:56;7088:287;;893:27644;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;-1:-1:-1;;893:27644:20;;;;;;:::i;:::-;;;;;;;-1:-1:-1;;893:27644:20;;;;;;:::i;:::-;;6286:9;893:27644;;;;6240:56;893:27644;;;;;;;;;;;;;;;;6240:56;893:27644;;;;7274:19;893:27644;;;;7301:19;893:27644;;;;7328:23;893:27644;;;;5819:10;893:27644;;;;7088:287;;;;;;;;;;6439:16;;;:::o;7088:287::-;;;;;;:::i;:::-;893:27644;;6439:16;;:::o;6851:231::-;6891:9;;:30;6887:110;;5688:15;893:27644;;6240:56;893:27644;;;;;;;;;7004:71;;;;;;;;;6851:231;7004:71;;;5688:15;7004:71;5688:15;7004:71;;;;;;;;:::i;:::-;;;;;:::i;:::-;;;6851:231;;7004:71;;;;;6887:110;-1:-1:-1;;;6940:48:20;;6891:9;6240:56;893:27644;;;;;;6940:48;;6807:38;;;;5688:15;6807:38;5688:15;6807:38;;;;;;;:::i;:::-;;;;21613:69;-1:-1:-1;;;21652:23:20;;6240:56;21652:23;;21518:90;-1:-1:-1;;;21579:22:20;;6240:56;21579:22;;6240:56;;;;5688:15;6240:56;5688:15;6240:56;;;;;;;:::i;:::-;;;;5929:302;-1:-1:-1;;893:27644:20;;;5688:15;893:27644;;;;;;;;;-1:-1:-1;893:27644:20;-1:-1:-1;;;;;893:27644:20;21518:90;;893:27644;-1:-1:-1;893:27644:20;21617:7;5688:15;893:27644;;;-1:-1:-1;893:27644:20;;;21613:69;;6807:14;893:27644;;;-1:-1:-1;;;6807:38:20;;-1:-1:-1;;;;;893:27644:20;;;;;5688:15;893:27644;6807:38;893:27644;;6807:38;;;;;;-1:-1:-1;;;;;6807:38:20;-1:-1:-1;6807:38:20;;;5929:302;893:27644;;6855:22;;6851:231;;5929:302;-1:-1:-1;6807:14:20;893:27644;-1:-1:-1;;;;;893:27644:20;;7088:10;;893:27644;7088:287;;;;;-1:-1:-1;893:27644:20;;;;;;;;;;;;;;;7088:287;;;6807:38;7088:287;;893:27644;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;6135:42;893:27644;;;;;;;;;;;;;;;;;;;;;6807:38;893:27644;;;;7274:19;893:27644;;;;7301:19;893:27644;;;;7328:23;893:27644;;;;5819:10;893:27644;;;;7088:287;;;;;;;;;;6208:16;;:::o;7088:287::-;-1:-1:-1;7088:287:20;;;:::i;6851:231::-;6891:9;;:30;6887:110;;5688:15;893:27644;;6807:38;893:27644;;;;;;;;;7004:71;;;;;;;;;6851:231;7004:71;;;5688:15;7004:71;5688:15;7004:71;;;;;;;:::i;:::-;;;6851:231;;6887:110;6940:48;;;;-1:-1:-1;6940:48:20;6891:9;6807:38;893:27644;;;;-1:-1:-1;6940:48:20;6807:38;;;;5688:15;6807:38;5688:15;6807:38;;;;;;;:::i;:::-;;;;21613:69;21652:23;;;-1:-1:-1;21652:23:20;;-1:-1:-1;21652:23:20;21518:90;21579:22;;;-1:-1:-1;21579:22:20;;-1:-1:-1;21579:22:20;5710:177;10857:21;;;-1:-1:-1;5859:21:20;;-1:-1:-1;5859:21:20;893:27644;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;-1:-1:-1;893:27644:20;;;;12714:7;893:27644;;;;;;;;;12752:19;893:27644;;;;12779:19;893:27644;;;;12806:23;893:27644;;;;;;;;;;;;;;:::o;13536:1375::-;;;;;;;;13796:8;893:27644;;13796:8;893:27644;13796:8;893:27644;;13880:123;893:27644;;;;;;13796:8;893:27644;;;13981:16;;13880:123;;;;;:::i;:::-;14137:10;;;:20;:135;;;;;13536:1375;-1:-1:-1;;893:27644:20;;-1:-1:-1;;;14313:68:20;;;;;893:27644;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;14313:68;893:27644;14313:9;:68;;;;;;;13796:8;14313:68;;;13536:1375;14313:194;;;;13536:1375;14518:49;;;;;;;;13536:1375;14514:346;;;-1:-1:-1;;;14873:33:20;;14137:10;14313:68;893:27644;;;;;;11386:33;14873;14514:346;14646:14;893:27644;-1:-1:-1;;;;;893:27644:20;;-1:-1:-1;14577:10:20;:262;;;;;;893:27644;13796:8;893:27644;;;;;;;;;;;;;14577:262;;14137:10;14577:262;14313:68;14577:262;;;:::i;:::-;;;;;;;;;;;14847:7;:::o;14577:262::-;13796:8;14577:262;;;:::i;:::-;14847:7::o;14518:49::-;;;;;;14313:194;14391:116;14137:10;;893:27644;14137:10;;893:27644;;;;:::i;:::-;14391:116;;:::i;:::-;14313:194;;;;;;:68;;;;;893:27644;14313:68;893:27644;14313:68;;;;;;;:::i;:::-;;;;;14137:135;7705:64:29;893:27644:20;;;;;;;;;:::i;:::-;7705:64:29;;;:::i;:::-;14137:135:20;;;;;893:27644;;;;:::o;:::-;;;-1:-1:-1;;;893:27644:20;;;;;;;;;;;;-1:-1:-1;;;893:27644:20;;;;;;;8037:1032;8476:8;893:27644;;;;;;;;;;;881:191:29;;8476:8:20;;8037:1032;;;;-1:-1:-1;;;;;893:27644:20;;;;8037:1032;;893:27644;8571:9;:45;;;;;8476:8;8571:45;893:27644;;;;;;;;;;8571:45;;;;;;893:27644;;;;;;8609:6;893:27644;;;;8571:45;;;;;;;;8037:1032;8730:16;;8642:110;8803:74;8730:16;;;;8642:110;;;:::i;:::-;8866:10;8803:74;;:::i;:::-;8792:238;;-1:-1:-1;;;9043:21:20;;8571:45;10857:21;9043;8792:238;11968:14;893:27644;-1:-1:-1;;;;;893:27644:20;;11874:10;;893:27644;11874:256;;;;;893:27644;;;;;;;;;;;;;;;;;;11874:256;;8571:45;11874:256;;893:27644;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;-1:-1:-1;;893:27644:20;;;;;;:::i;:::-;;;;;;;;:::i;:::-;8571:45;893:27644;;;;;;;;;;;;8571:45;893:27644;;;;12029:19;893:27644;;;;12056:19;893:27644;;;;12083:23;893:27644;;;;8866:10;893:27644;;;;11874:256;;;;;;;;;;9017:7;;:::o;8571:45::-;8803:74;8571:45;;;;;8476:8;8571:45;;;:::i;:::-;8642:110;8476:8;8571:45;;;;;;;7292:355:16;-1:-1:-1;;7390:251:16;;;;;7292:355::o;7390:251::-;;;;;;;3037:641:29;3615:57;;3037:641;3281:19;;;;893:27644:20;;;;;3265:37:29;3330:20;3312:39;3330:20;;;;3312:39;:::i;:::-;3377:21;;;;;893:27644:20;;;;;3361:39:29;3410:23;893:27644:20;3410:23:29;;;893:27644:20;;;;;;;881:191:29;;893:27644:20;;;;;;;3471:15:29;;881:191;893:27644:20;3496:21:29;;;;881:191;3527:20;3557;3527;;;881:191;3557:20;;893:27644:20;;3496:21:29;893:27644:20;3215:370:29;893:27644:20;3215:370:29;;893:27644:20;438:228:29;893:27644:20;;3496:21:29;438:228;;893:27644:20;3527:20:29;438:228;;893:27644:20;3557:20:29;438:228;;893:27644:20;3410:23:29;438:228;;893:27644:20;3281:19:29;438:228;;893:27644:20;3330:20:29;438:228;;893:27644:20;3377:21:29;438:228;;893:27644:20;438:228:29;;;893:27644:20;438:228:29;;;893:27644:20;438:228:29;3215:370;;;;;;:::i;6145:1089:16:-;893:27644:20;;;;;6813:405:16;;;;;;-1:-1:-1;6813:405:16;;-1:-1:-1;;6813:405:16;6145:1089::o;3166:1050:20:-;;;;3732:76;3786:16;3732:76;;:::i;:::-;3828:15;;;;3894:115;881:191:29;;-1:-1:-1;3991:10:20;;;893:27644;;;;;;;3894:115;:::i;:::-;3883:294;;-1:-1:-1;;;4190:21:20;;;10857;4190;3883:294;893:27644;;;;;;-1:-1:-1;893:27644:20;-1:-1:-1;3828:15:20;893:27644;;;;;;;-1:-1:-1;893:27644:20;;;21518:90;;893:27644;-1:-1:-1;893:27644:20;21617:7;3828:15;893:27644;;;-1:-1:-1;893:27644:20;;;21613:69;;6807:14;893:27644;;;-1:-1:-1;;;6807:38:20;;-1:-1:-1;;;;;893:27644:20;;;;;3828:15;893:27644;6807:38;893:27644;;6807:38;;;;;;-1:-1:-1;;;;;6807:38:20;-1:-1:-1;6807:38:20;;;3883:294;893:27644;;6855:22;;6851:231;;3883:294;-1:-1:-1;6807:14:20;893:27644;-1:-1:-1;;;;;893:27644:20;;7088:10;;893:27644;7088:287;;;;;-1:-1:-1;893:27644:20;;;;;;;;;;;;;;;7088:287;;;6807:38;7088:287;;893:27644;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;6807:38;893:27644;;;;7274:19;893:27644;;;;7301:19;893:27644;;;;7328:23;893:27644;;;;3991:10;893:27644;;;;7088:287;;;;;;;;;;4154:16;;:::o;6851:231::-;6891:9;;:30;6887:110;;3828:15;893:27644;;6807:38;893:27644;;;;;;;;;7004:71;;;;;;;;;6851:231;7004:71;;;3828:15;7004:71;3828:15;7004:71;;;;;;;:::i;:::-;;;6851:231;;6807:38;;;;3828:15;6807:38;3828:15;6807:38;;;;;;;:::i;:::-;;;;24500:1196;;;893:27644;-1:-1:-1;893:27644:20;;;;;;;;;24661:67;;;25868:8;;;;;;893:27644;;;;;;25868:53;;893:27644;25868:53;;;893:27644;;;;;;;;;;:::i;:::-;25868:53;;;;;;;;;;;;;;24657:1035;26050:20;893:27644;26050:23;:20;893:27644;26050:20;;;;:::i;:::-;:23;;:::i;:::-;893:27644;;;:::i;:::-;;23040:51;893:27644;;;;;881:191:29;;893:27644:20;23048:10;:20;23040:51;:::i;:::-;893:27644;3350:20;;881:191:29;21937:15:20;;:26;21933:105;;3400:20;;;;893:27644;;3422:21;;;;;;22355:22;;22351:326;;24657:1035;3463:21;;893:27644;3463:21;;881:191:29;;893:27644:20;;;;;;21349:14;893:27644;;;;;;;;;;;;;21349:39;;25868:53;21349:39;;893:27644;21349:39;;;;;;;;;;;24657:1035;21348:40;;21344:105;;893:27644;;881:191:29;;22132:22:20;;;:67;;;;24657:1035;22128:126;;;;3595:23;;;;893:27644;;3595:23;;;;893:27644;;;;3654:21;;23231:45;;23227:318;;24657:1035;26098:15;;;893:27644;3166:1050;26098:15;;;893:27644;3166:1050;;:::i;:::-;893:27644;;;;;;;;;;26133:41;;25868:53;26133:41;;893:27644;26133:41;;;;;;;;;;;24738:42;;;:::o;26133:41::-;;;;;;;;;;;;;:::i;:::-;;;;;:::i;23227:318::-;23303:22;;;;;893:27644;;23350:27;23389:24;;;23227:318;23385:154;;;23227:318;;;;;;23389:24;;;;;;22128:126;-1:-1:-1;;;22216:31:20;;25868:53;22216:31;;22132:67;893:27644;;;;;;;;22158:28;893:27644;;;22158:28;893:27644;22158:41;;22132:67;;;;21344:105;-1:-1:-1;;;21405:37:20;;25868:53;21405:37;;21349:39;;;;893:27644;21349:39;893:27644;21349:39;;;;;;;:::i;:::-;;;;22351:326;893:27644;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;22391:39;;;:61;;22351:326;22387:123;;;893:27644;22518:153;;22351:326;;;;22387:123;-1:-1:-1;;;22471:30:20;;25868:53;22471:30;;22391:61;893:27644;;-1:-1:-1;22435:7:20;893:27644;;;;;;;;22434:18;-1:-1:-1;22391:61:20;;25868:53;;;;;;;;;;;;;:::i;:::-;;;;;:::i;:::-;;;;;893:27644;;;;;;;;;24657:1035;893:27644;24804:82;;893:27644;;26358:8;;;;;;893:27644;;;;;;26358:53;;893:27644;26358:53;;;893:27644;;;;;;;;;;:::i;:::-;26358:53;;;;;;;;;;;;;;24793:899;26533:20;893:27644;26533:20;;;893:27644;26584:20;893:27644;26584:23;26533;:20;;;;:::i;:23::-;26584:20;;;;;:::i;:::-;:23;;:::i;:::-;893:27644;;;;;;:::i;:::-;;;;;:::i;:::-;5210:20;893:27644;5210:20;;881:191:29;21937:15:20;;:26;21933:105;;5260:20;;;;893:27644;;5282:21;;;;;;22355:22;;22351:326;;24793:899;5323:21;;893:27644;5323:21;;881:191:29;;893:27644:20;;;;;;21349:14;893:27644;;;;;;;;;;;;;21349:39;;26358:53;21349:39;;893:27644;21349:39;;;;;;;;;;;24793:899;21348:40;;21344:105;;893:27644;;881:191:29;;22132:22:20;;;:67;;;;24793:899;22128:126;;;;5455:23;;;;;893:27644;;5455:23;;;;893:27644;;;;5514:21;;23231:45;;23227:318;;24793:899;26632:15;;;893:27644;5020:1505;26632:15;;;893:27644;5020:1505;;:::i;23227:318::-;23303:22;;;;;893:27644;;23350:27;23389:24;;;23227:318;23385:154;;;23227:318;;;;;;23389:24;;;;;;22128:126;-1:-1:-1;;;22216:31:20;;26358:53;22216:31;;22132:67;893:27644;;;;;;;;22158:28;893:27644;;;22158:28;893:27644;22158:41;;22132:67;;;;21344:105;-1:-1:-1;;;21405:37:20;;26358:53;21405:37;;21349:39;;;;893:27644;21349:39;893:27644;21349:39;;;;;;;:::i;:::-;;;;22351:326;893:27644;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;22391:39;;;:61;;22351:326;22387:123;;;893:27644;22518:153;;22351:326;;;;22387:123;-1:-1:-1;;;22471:30:20;;26358:53;22471:30;;22391:61;893:27644;;-1:-1:-1;22435:7:20;893:27644;;;;;;;;22434:18;-1:-1:-1;22391:61:20;;21933:105;-1:-1:-1;;;21980:51:20;;26358:53;893:27644;21937:15;893:27644;;;21980:51;;26358:53;;;;;;;;;;;;;:::i;:::-;;;;24793:899;25001:40;24974:67;;25001:40;;-1:-1:-1;;893:27644:20;;-1:-1:-1;;;26901:48:20;;893:27644;26901:48;;;893:27644;;-1:-1:-1;893:27644:20;;;;;;;;;:::i;:::-;26901:48;:8;;:48;;;;;;;-1:-1:-1;;26901:48:20;;;24963:729;27078:20;893:27644;27078:23;:20;893:27644;27078:20;;;;:::i;893:27644::-;;;;;;;;23040:51;893:27644;;;;;;;;;;23048:10;:20;23040:51;:::i;:::-;893:27644;8253:17;;881:191:29;21937:15:20;;:26;21933:105;;-1:-1:-1;893:27644:20;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;21756:40;:70;;;;24963:729;21745:131;;893:27644;;;;;;;;;;;8324:31;893:27644;;;22750:45;22746:97;;893:27644;;;;;;;;;;;881:191:29;;8417:14:20;;;881:191:29;;22931:9:20;;-1:-1:-1;;;;;893:27644:20;;;;;22931:51;;;;;893:27644;;-1:-1:-1;;;22931:51:20;;893:27644;;;;;;;;;;;22931:51;;26901:48;22931:51;;;:::i;:::-;;;;;;;;;;;24963:729;27126:15;893:27644;22988:1;27126:15;;;;893:27644;22988:1;;:::i;:::-;893:27644;;;;;;;:::i;:::-;;;25056:42;:::o;22931:51::-;;;;;;:::i;:::-;893:27644;;22931:51;;;21756:70;893:27644;;;;21800:7;893:27644;;;;;;;;;;;21800:26;21756:70;;26901:48;;;;;;;;;;;;;;;:::i;:::-;;;;;:::i;:::-;;;;24963:729;25155:49;25122:82;;25155:49;;-1:-1:-1;;893:27644:20;;-1:-1:-1;;;27363:48:20;;893:27644;27363:48;;;893:27644;;-1:-1:-1;893:27644:20;;;;;;;;;:::i;:::-;27363:48;:8;;:48;;;;;;;-1:-1:-1;;27363:48:20;;;25111:581;27548:20;893:27644;27548:20;;893:27644;27599:20;893:27644;27599:23;27548;:20;;;;:::i;:23::-;27599:20;;;;;:::i;:23::-;893:27644;;;;;;:::i;:::-;10108:17;893:27644;10108:17;;881:191:29;21937:15:20;;:26;21933:105;;-1:-1:-1;893:27644:20;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;21756:40;:70;;;;25111:581;21745:131;;893:27644;;;;;;;;;;;10179:31;893:27644;;;22750:45;22746:97;;893:27644;;;;;;;;;;;881:191:29;;10272:14:20;;;881:191:29;;22931:9:20;;-1:-1:-1;;;;;893:27644:20;;;;;22931:51;;;;;893:27644;;-1:-1:-1;;;22931:51:20;;893:27644;;;;;;;;;;;22931:51;;27363:48;22931:51;;;:::i;:::-;;;;;;;;;;;25111:581;27647:15;893:27644;22988:1;27647:15;;;;893:27644;22988:1;;:::i;22931:51::-;;;;;;:::i;:::-;893:27644;;22931:51;;;21756:70;893:27644;;;;25155:49;893:27644;;;;;;;;;;;21800:26;21756:70;;27363:48;;;;;;;;;;;;;;;:::i;:::-;;;;25111:581;893:27644;;;;25319:42;25292:69;;25319:42;;893:27644;;;;;;;;;;;;;;;27839:43;;;25319:42;27839:43;;893:27644;;;;;;:::i;:::-;27839:43;:8;;:43;;;;;;;-1:-1:-1;27839:43:20;;;25281:411;-1:-1:-1;;893:27644:20;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;21756:40;:70;;;;25281:411;21745:131;;893:27644;-1:-1:-1;893:27644:20;-1:-1:-1;893:27644:20;;23040:51;893:27644;;;;;;-1:-1:-1;893:27644:20;;;27982:10;23048:20;23040:51;:::i;:::-;12676:14;893:27644;12613:10;;-1:-1:-1;;;;;893:27644:20;;;;12613:240;;;;;893:27644;;-1:-1:-1;;;12613:240:20;;893:27644;-1:-1:-1;;893:27644:20;;;;;;12613:240;;27982:10;;;;25319:42;12613:240;;;:::i;:::-;;;;;;;;;;;25281:411;893:27644;;;;;;;;:::i;12613:240::-;;;;-1:-1:-1;12613:240:20;;:::i;:::-;-1:-1:-1;12613:240:20;;;21745:131;21848:21;;;-1:-1:-1;21848:21:20;25319:42;-1:-1:-1;21848:21:20;21756:70;893:27644;;-1:-1:-1;893:27644:20;25155:49;893:27644;;;;;-1:-1:-1;893:27644:20;;;;;21800:26;21756:70;;27839:43;;;893:27644;27839:43;;893:27644;27839:43;;;;;;893:27644;27839:43;;;:::i;:::-;;;893:27644;;;;;27839:43;;;;;;-1:-1:-1;27839:43:20;;25281:411;893:27644;;-1:-1:-1;893:27644:20;;25477:51;25444:84;25477:51;;-1:-1:-1;893:27644:20;;-1:-1:-1;;;28196:57:20;;893:27644;25319:42;28196:57;;893:27644;;;;;;;;;;:::i;:::-;28196:57;:8;;:57;;;;;;;-1:-1:-1;28196:57:20;;;25433:259;893:27644;;;;;;;;;;;28368:14;;881:191:29;893:27644:20;28390:19;;881:191:29;28417:20:20;;;;28468:23;:20;28417:23;:20;;;;:::i;:23::-;28468:20;;;;:::i;:23::-;21937:15;;;;;:26;21933:105;;-1:-1:-1;893:27644:20;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;21756:40;:70;;;;25433:259;21745:131;;21881:1;;;:::i;:::-;893:27644;;;;;;:::i;:::-;-1:-1:-1;893:27644:20;;25543:51;:::o;21756:70::-;893:27644;;-1:-1:-1;893:27644:20;25155:49;893:27644;;;;;-1:-1:-1;893:27644:20;;;;;21800:26;21756:70;;21933:105;21980:51;;;;-1:-1:-1;21980:51:20;25319:42;893:27644;21937:15;893:27644;;;-1:-1:-1;21980:51:20;28196:57;;;;;;;;;;;;;;;;:::i;:::-;;;893:27644;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;28196:57;;;;;;;;25433:259;25622:63;893:27644;;;25622:63;;;;;;25319:42;25622:63;;893:27644;;;;;;;;;;;-1:-1:-1;;;893:27644:20;;;;25622:63;2350:499:29;;893:27644:20;;;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;:::i;:::-;;;;;;-1:-1:-1;;893:27644:20;;;;-1:-1:-1;2573:3:29;893:27644:20;;2552:19:29;;;;;2709:11;;893:27644:20;2709:11:29;;;:::i;:::-;;893:27644:20;;2746:11:29;;;;:::i;:::-;;:17;;893:27644:20;;;;;2736:28:29;893:27644:20;;2624:150:29;893:27644:20;2624:150:29;;893:27644:20;2646:51:29;893:27644:20;;;;;;;;;;;2624:150:29;;;;;;:::i;:::-;893:27644:20;2605:177:29;;2586:196;;;;:::i;:::-;893:27644:20;;2540:10:29;;2552:19;-1:-1:-1;893:27644:20;;;;2552:19:29;;-1:-1:-1;893:27644:20;2812:31:29;;;2552:19;893:27644:20;;2812:31:29;;-1:-1:-1;893:27644:20;;;;;;2812:31:29;;;;;;893:27644:20;;2812:31:29;;;;;;:::i;893:27644:20:-;;;;;;;;;;;;-1:-1:-1;893:27644:20;;;;;;;;1956:2062:18;;;893:27644:20;;1956:2062:18;-1:-1:-1;;;;;893:27644:20;;2118:20:18;2114:40;;2207:1805;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;2207:1805:18;;;;;1956:2062::o;2207:1805::-;;;;;;;;;;;;;;;893:27644:20;;;2207:1805:18;;;;1956:2062::o;2207:1805::-;;;;;;;;;;893:27644:20;2207:1805:18;;;;;;;;;;893:27644:20;2207:1805:18;;;;;;;;893:27644:20;2207:1805:18;;;;;;;;;;893:27644:20;2207:1805:18;;;;1956:2062::o;2207:1805::-;;;;;;;;;;;;;;;;;;893:27644:20;2207:1805:18;;;;;;;;;2114:40;2140:14;;;;893:27644:20;2140:14:18;:::o;7098:258:29:-;-1:-1:-1;;;;;893:27644:20;;;;;7264:16:29;;;;;:87;;;;7098:258;7251:100;;;7098:258;:::o;7264:87::-;7290:61;;;;:::i;:::-;7264:87;;;;;893:27644:20;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;893:27644:20;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;:::o;:::-;;;-1:-1:-1;;;;;893:27644:20;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;:::o;:::-;;24837:49;893:27644;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;;;:::i;:::-;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;:::i;:::-;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;:::i;:::-;;;;;;:::o;:::-;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;;;;;;;;;:::i;:::-;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;:::i;:::-;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;;;:::i;:::-;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;:::i;:::-;;;;;;:::o;:::-;;;;;;;;;;;-1:-1:-1;;;;;893:27644:20;;;;;;;;:::i
Swarm Source
ipfs://cb10a60526704b3a746fd9f56bb92cc8444d3078bd721ea22324ec4a6cffa55b
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.