Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 58 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Predict | 24221181 | 32 days ago | IN | 0 ETH | 0.00023776 | ||||
| Reveal | 24196087 | 36 days ago | IN | 0 ETH | 0.0000083 | ||||
| Predict | 24193229 | 36 days ago | IN | 0 ETH | 0.00016342 | ||||
| Predict | 24191661 | 36 days ago | IN | 0 ETH | 0.00017196 | ||||
| Predict | 24185194 | 37 days ago | IN | 0 ETH | 0.00000726 | ||||
| Predict | 24183767 | 37 days ago | IN | 0 ETH | 0.00002335 | ||||
| Predict | 24183715 | 37 days ago | IN | 0 ETH | 0.0001865 | ||||
| Predict | 24182993 | 37 days ago | IN | 0 ETH | 0.0000066 | ||||
| Predict | 24182339 | 38 days ago | IN | 0 ETH | 0.00019878 | ||||
| Set Status | 24169983 | 39 days ago | IN | 0 ETH | 0.00007465 | ||||
| Predict | 24169965 | 39 days ago | IN | 0 ETH | 0.0001869 | ||||
| Predict | 24169953 | 39 days ago | IN | 0 ETH | 0.00001878 | ||||
| Predict | 24169940 | 39 days ago | IN | 0 ETH | 0.00018994 | ||||
| Predict | 24167963 | 40 days ago | IN | 0 ETH | 0.00000618 | ||||
| Predict | 24166129 | 40 days ago | IN | 0 ETH | 0.0001775 | ||||
| Predict | 24166120 | 40 days ago | IN | 0 ETH | 0.00017792 | ||||
| Predict | 24164717 | 40 days ago | IN | 0 ETH | 0.00017523 | ||||
| Predict | 24163823 | 40 days ago | IN | 0 ETH | 0.00017596 | ||||
| Predict | 24163673 | 40 days ago | IN | 0 ETH | 0.00000288 | ||||
| Predict | 24163639 | 40 days ago | IN | 0 ETH | 0.00017552 | ||||
| Predict | 24163610 | 40 days ago | IN | 0 ETH | 0.00001324 | ||||
| Predict | 24163004 | 40 days ago | IN | 0 ETH | 0.00000404 | ||||
| Predict | 24162368 | 40 days ago | IN | 0 ETH | 0.00000647 | ||||
| Predict | 24162341 | 40 days ago | IN | 0 ETH | 0.00017803 | ||||
| Predict | 24162336 | 40 days ago | IN | 0 ETH | 0.00017775 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
TruthOracle
Compiler Version
v0.8.30+commit.73712a01
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.30;
import {ERC1155} from "solady/src/tokens/ERC1155.sol";
import {Ownable} from "solady/src/auth/Ownable.sol";
import {Base64} from "solady/src/utils/Base64.sol";
import {LibString} from "solady/src/utils/LibString.sol";
import {DynamicBufferLib} from "solady/src/utils/DynamicBufferLib.sol";
/**
* @title Truth Oracle
* @author 0xG
* @notice A conceptual blockchain artwork that criticizes prediction markets through recursive binary predictions.
* @dev Implements a prediction game-performance where participants hold soulbound tokens (0=No, 1=Yes) and predict binary outcomes.
* Each round, an oracle determines the winner, losing tokens are burned, and winners continue to the next round.
* The game ends when only one token remains or none survive, creating a transferable 1/1 NFT for the winner.
*/
contract TruthOracle is ERC1155, Ownable {
string public constant name = "Truth Oracle";
string public constant symbol = "TRUTH";
using DynamicBufferLib for DynamicBufferLib.DynamicBuffer;
/**
* @notice Game status states controlling contract behavior.
* @dev Acquire: Initial minting phase
* Play: Active prediction rounds
* Paused: Game temporarily halted
* Unclaimed: Game ended with a winner, awaiting claim
* Complete: Game ended (winner claimed or no winner)
*/
enum Status {
Acquire,
Play,
Paused,
Unclaimed,
Complete
}
/**
* @notice Current game status.
*/
Status public status;
/**
* @notice Total supply for each token ID (0=No, 1=Yes).
* @dev Tracks the number of participants holding each prediction token.
*/
mapping(uint256 tokenId => uint256 supply) public totalSupply;
/**
* @notice Base slot for Yes token balances, incremented to clear all balances in O(1).
* @dev Custom storage slot that enables mass balance clearing by incrementing the slot number.
*/
uint256 private _yesBalancesSlot = uint256(keccak256("_yesBalancesSlot")) >> 1;
/**
* @notice Base slot for No token balances, incremented to clear all balances in O(1).
* @dev Custom storage slot that enables mass balance clearing by incrementing the slot number.
*/
uint256 private _noBalancesSlot = uint256(keccak256("_noBalancesSlot")) >> 1;
/**
* @notice Timestamp when the current round can be revealed.
*/
uint256 public revealAt;
/**
* @notice Duration between reveals in seconds.
* @dev 302400 seconds (3.5 days, twice per week).
*/
uint256 public immutable revealInterval = 302400;
/**
* @notice Tracks the last prediction timestamp for each participant.
* @dev Used to prevent double-voting within the same round.
* Value of 1 indicates initial prediction during Acquire phase.
*/
mapping(address participant => uint256 predictedAt) public lastPredictedAt;
/**
* @notice Historical data for each completed prediction round.
* @dev yes: Number of Yes predictions
* no: Number of No predictions
* revealAt: Timestamp of the round reveal
* winner: Winning side (0=No, 1=Yes)
*/
struct PredictionData {
uint256 yes;
uint256 no;
uint256 revealAt;
uint256 winner;
}
/**
* @notice Array of all completed prediction rounds.
*/
PredictionData[] public predictions;
/**
* @notice Address of the truth oracle contract that determines round outcomes.
*/
address private truthOracle;
/**
* @notice Emitted when the game status changes.
* @param newStatus The new status of the game.
*/
event StatusChange(Status indexed newStatus);
/**
* @notice Emitted when the truth oracle is set or updated.
* @param oracle The address of the new truth oracle.
*/
event TruthOracleSet(address indexed oracle);
/**
* @notice Emitted when a participant makes a prediction.
* @param roundId The ID of the current round.
* @param participant The address making the prediction.
* @param yes Whether the prediction is Yes (true) or No (false).
*/
event Predict(uint256 indexed roundId, address indexed participant, bool indexed yes);
/**
* @notice Emitted when a round is revealed and outcome is determined.
* @param roundId The ID of the completed round.
* @param yes Whether Yes (true) or No (false) won.
* @param outcome The prediction data for this round.
*/
event Reveal(uint256 indexed roundId, bool indexed yes, PredictionData outcome);
/**
* @notice Initializes the Prediction contract.
* @dev Sets up the owner, initializes balance slots, and mints both token types to deployer.
* The deployer receives both No and Yes tokens to bootstrap the game.
*/
constructor() ERC1155() {
_initializeOwner(msg.sender);
_syntheticMint(msg.sender, 0);
_syntheticMint(msg.sender, 1);
lastPredictedAt[msg.sender] = 1;
}
/**
* @notice Returns the historical prediction data for all completed rounds.
* @return Array of PredictionData structs containing the history of all revealed rounds.
*/
function allPredictions() external view returns (PredictionData[] memory) {
return predictions;
}
/**
* @notice Returns base64-encoded JSON metadata with an SVG image representing prediction history.
* @param tokenId The token ID (0 for No, 1 for Yes).
* @return Base64-encoded JSON string containing name, description, and generative SVG image.
* @dev The SVG visualization shows concentric squares representing prediction percentages for each round.
* The winner token (when game is complete) displays "Truth." instead of "Yes." or "No.".
*/
function uri(uint256 tokenId) public view override returns (string memory) {
require(tokenId < 2, Unauthorized());
bool isYes = tokenId == 1;
string memory background = string.concat("hsl(", (isYes ? "81" : "355"), " 10% 5%)");
string memory stroke = isYes ? "hsl(81 10% 55%)" : "hsl(355 63% 30%)";
DynamicBufferLib.DynamicBuffer memory svg;
svg.p(
abi.encodePacked(
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000" style="background:',
background,
'"><rect width="1000" height="1000" fill="',
background,
'"/><g fill="none" stroke="',
stroke,
'" stroke-width="5">'
)
);
for (uint256 i = 0; i < predictions.length; i++) {
uint256 count = isYes ? predictions[i].yes : predictions[i].no;
uint256 total = predictions[i].yes + predictions[i].no;
uint256 pct = total > 0 ? (count * 100) / total : 0;
uint256 size = count == 0 ? 0 : pct > 0 ? (pct * 10) - 5 : 1;
uint256 pos = (1000 - size) / 2;
string memory sizeStr = LibString.toString(size);
string memory posStr = LibString.toString(pos);
bytes memory opacityAttr = i == 0
? bytes("")
: abi.encodePacked('" opacity="0.', LibString.toString(i + 1 + (i <= 5 ? (i % 2 == 0 ? 5 : 3) : 0)));
svg.p(
abi.encodePacked(
'<rect width="', sizeStr, '" height="', sizeStr, '" x="', posStr, '" y="', posStr,
opacityAttr, '"/>'
)
);
}
svg.p(bytes("</g></svg>"));
return string.concat(
"data:application/json;base64,",
Base64.encode(
abi.encodePacked(
'{"name":"', (status == Status.Unclaimed || status == Status.Complete) ? (totalSupply[tokenId] == 1 ? "Truth." : "Not Truth.") : (isYes ? "Yes." : "No."), '","created_by":"0xG","description":"Truth Oracle.\\n\\nPrediction markets position themselves as truth-discovery mechanisms. They claim that aggregating bets reveals accurate information about future events. In practice, they function as gambling platforms where outcomes are determined by external oracles, insider information advantages might persist, and market mechanisms have no special relationship to truth.\\n\\nThis artwork makes the dynamic explicit. An external oracle determines outcomes. Participants bet recursively on arbitrary binary outcomes. The mathematical certainty is that most will lose, and one possible outcome is that nobody wins-so the NFT itself might ultimately never exist.\\n\\nDuring the performance, all tokens are acquired for free and are soulbound. If a single winner emerges, they can claim the final token as a transferable ERC-1155 1/1. The artwork\'s visuals are generative, representing the prediction percentage for each round.","image":"data:image/svg+xml;base64,',
Base64.encode(svg.data),
'"}'
)
)
);
}
/**
* @notice Mints a synthetic soulbound token to an address.
* @param to The address to receive the token.
* @param tokenId The token ID to mint (0=No, 1=Yes).
* @dev Uses custom storage slots that can be cleared in O(1) by incrementing the slot counter.
* Tokens are soulbound during gameplay and cannot be transferred.
* Emits TransferSingle with 'this' as the holder to ensure marketplace compatibility.
*/
function _syntheticMint(address to, uint256 tokenId) internal {
_setBalance(to, tokenId, 1);
totalSupply[tokenId]++;
emit TransferSingle(to, address(0), address(this), tokenId, 1);
}
/**
* @notice Burns a synthetic soulbound token from an address.
* @param from The address to burn the token from.
* @param tokenId The token ID to burn (0=No, 1=Yes).
* @dev Decrements total supply and emits burn event for marketplace tracking.
*/
function _syntheticBurn(address from, uint256 tokenId) internal {
_setBalance(from, tokenId, 0);
totalSupply[tokenId]--;
emit TransferSingle(from, address(this), address(0), tokenId, 1);
}
/**
* @notice Gets the synthetic balance for an account and token ID.
* @param account The address to check balance for.
* @param tokenId The token ID (0=No, 1=Yes).
* @return The balance (0 or 1 during gameplay).
* @dev Reads from custom storage slots computed using the base slot and account address.
*/
function _getBalance(address account, uint256 tokenId) internal view returns (uint256) {
uint256 baseSlot = tokenId == 1 ? _yesBalancesSlot : _noBalancesSlot;
bytes32 slot = keccak256(abi.encode(tokenId == 1 ? "YES" : "NO", account, baseSlot));
uint256 bal;
assembly {
bal := sload(slot)
}
return bal;
}
/**
* @notice Sets the synthetic balance for an account and token ID.
* @param account The address to set balance for.
* @param tokenId The token ID (0=No, 1=Yes).
* @param amount The balance to set (0 or 1).
* @dev Writes to custom storage slots computed using the base slot and account address.
*/
function _setBalance(address account, uint256 tokenId, uint256 amount) internal {
uint256 baseSlot = tokenId == 1 ? _yesBalancesSlot : _noBalancesSlot;
bytes32 slot = keccak256(abi.encode(tokenId == 1 ? "YES" : "NO", account, baseSlot));
assembly {
sstore(slot, amount)
}
}
/**
* @notice Returns the balance of tokens for a given account and token ID.
* @param account The address to query balance for.
* @param id The token ID (0=No, 1=Yes).
* @return The token balance.
* @dev During gameplay, returns synthetic balances.
* After game completion but before claim: returns synthetic balance (1 for winner, 0 for losers).
* After winner claims: returns actual ERC1155 balance (1 for token holder, 0 otherwise).
* Returns totalSupply when querying this contract's balance (for marketplace compatibility).
*/
function balanceOf(address account, uint256 id) public view override returns (uint256) {
if (status == Status.Unclaimed) {
// Game ended with winner, but not yet claimed - return synthetic balances.
if (account == address(this)) {
return totalSupply[id];
}
return _getBalance(account, id);
}
if (status == Status.Complete) {
// Winner has claimed - return real ERC1155 balances.
return super.balanceOf(account, id);
}
// During gameplay (Acquire, Play, Paused) the contract owns the entire supply.
if (account == address(this)) {
return totalSupply[id];
}
return _getBalance(account, id);
}
/**
* @notice Allows participants to make or change their prediction.
* @param yes True to predict Yes, false to predict No.
* @dev During Acquire phase: Mints initial token to new participants.
* During Play phase: Changes prediction (burns old token, mints new one).
* Automatically reveals the round if reveal time has passed.
* Participants can only predict once per round.
*/
function predict(bool yes) external {
uint256 prediction = yes ? 1 : 0;
uint256 balanceYes = _getBalance(msg.sender, 1);
uint256 balanceNo = _getBalance(msg.sender, 0);
// First prediction.
if (status == Status.Acquire) {
require(balanceYes + balanceNo == 0, Unauthorized());
lastPredictedAt[msg.sender] = 1;
_syntheticMint(msg.sender, prediction);
emit Predict(0, msg.sender, yes);
return;
}
// Nth prediction.
require(status == Status.Play, Unauthorized());
// msg.sender must have a balance of 1 (either yes or no).
require(balanceYes + balanceNo == 1, Unauthorized());
// msg.sender must have not predicted in this round.
require(lastPredictedAt[msg.sender] > 0 && lastPredictedAt[msg.sender] < revealAt, Unauthorized());
uint256 currentTokenId = balanceYes == 1 ? 1 : 0;
// If the round is over do a reveal first and settle who won the previous.
if (revealAt <= block.timestamp) {
(, uint256 loser) = _reveal();
// If msg.sender lost or the entire game is over, exit here.
if (currentTokenId == loser || status == Status.Unclaimed || status == Status.Complete) {
return;
}
}
lastPredictedAt[msg.sender] = revealAt;
// If prediction is different than their current prediction change tokenId.
// This can happen when msg.sender was part of the winners in the previous round.
if (prediction != currentTokenId) {
_syntheticBurn(msg.sender, currentTokenId);
_syntheticMint(msg.sender, prediction);
}
emit Predict(predictions.length, msg.sender, yes);
}
/**
* @notice Manually triggers a round reveal when reveal time has passed.
* @return The winning token ID (0=No, 1=Yes).
* @dev Can only be called during Play status and after revealAt timestamp.
* Calls the truth oracle to determine the outcome.
* Burns all losing tokens and either ends the game or starts a new round.
*/
function reveal() external returns (uint256) {
require(status == Status.Play, Unauthorized());
require(revealAt <= block.timestamp, Unauthorized());
(uint256 winner,) = _reveal();
return winner;
}
/**
* @notice Internal function that performs the reveal logic.
* @return winner The winning token ID (0=No, 1=Yes).
* @return loser The losing token ID.
* @dev Queries the truth oracle for the outcome.
* Records prediction data for the round.
* Burns all losing tokens by incrementing the balance slot.
* Ends the game if only 0-1 winners remain, otherwise starts a new round.
*/
function _reveal() internal returns (uint256, uint256) {
uint256 winner = IOracle(truthOracle).reveal(revealAt, msg.sender) % 2;
uint256 loser = winner == 0 ? 1 : 0;
// Record prediction counts before resetting loser supply.
predictions.push(PredictionData({
yes: totalSupply[1],
no: totalSupply[0],
revealAt: revealAt,
winner: winner
}));
emit Reveal(predictions.length - 1, winner == 1, predictions[predictions.length - 1]);
// Increment base slot to clear all loser balances in O(1).
if (loser == 0) {
_noBalancesSlot++;
} else {
_yesBalancesSlot++;
}
uint256 supplyToBurn = totalSupply[loser];
if (supplyToBurn > 0) {
totalSupply[loser] = 0;
// Emit burn even for loser token id with amount=supplyToBurn.
emit TransferSingle(msg.sender, address(this), address(0), loser, supplyToBurn);
}
// Check if game is complete (calculated from incremental totalSupply).
if (totalSupply[winner] < 2) {
status = totalSupply[winner] == 1 ? Status.Unclaimed : Status.Complete;
} else {
// Start a new round.
revealAt = block.timestamp + revealInterval;
}
return (winner, loser);
}
/**
* @notice Allows the owner to change the game status between Play and Paused.
* @param _status The new status (Play or Paused).
* @dev Cannot change status once the game is Complete.
* When transitioning to Play, sets a new revealAt timestamp.
* Only Play and Paused statuses can be set via this function.
*/
function setStatus(Status _status) external onlyOwner {
require(
status != Status.Unclaimed && status != Status.Complete && // Once game ends we cannot change status.
(_status == Status.Play || _status == Status.Paused), // We can only Play and Pause.
Unauthorized()
);
if (_status == Status.Play) {
// First time transitioning to Play - immediately reveal the Acquire round
if (revealAt == 0) {
revealAt = block.timestamp; // Set to now so _reveal() can record it
_reveal(); // Eliminates losers, sets new revealAt for round 2
} else {
revealAt = block.timestamp + revealInterval;
}
}
status = _status;
emit StatusChange(_status);
}
/**
* @notice Sets the truth oracle contract address.
* @param _truthOracle The address of the IOracle contract.
* @dev Only callable by the owner. The oracle determines round outcomes.
*/
function setTruthOracle(address _truthOracle) external onlyOwner {
truthOracle = _truthOracle;
emit TruthOracleSet(_truthOracle);
}
/**
* @notice Allows the winner to claim their winning token after game completion.
* @dev Converts the synthetic soulbound token to a transferable ERC1155 token.
* Can only be called by the actual winner address.
*/
function claimWin() external {
_mintWinner(msg.sender);
}
/**
* @notice Allows the owner to airdrop the winning token to the verified winner.
* @param winner The address to receive the winning token (must have synthetic balance).
* @dev Enables owner to help the winner claim if they're unable to call claimWin themselves.
*/
function airdropWin(address winner) external onlyOwner {
_mintWinner(winner);
}
/**
* @notice Internal function to mint the final transferable winner token.
* @param winner The address to receive the winning token.
* @dev Verifies game is complete, only one token of one type remains, and winner holds it.
* Burns the synthetic token and mints a real transferable ERC1155 token.
* Restores totalSupply for uri() to continue working properly.
*/
function _mintWinner(address winner) internal {
require(status == Status.Unclaimed, Unauthorized());
uint256 side = totalSupply[0] == 1 ? 0 : 1;
require(totalSupply[side] == 1, Unauthorized());
require(_getBalance(winner, side) == 1, Unauthorized());
_syntheticBurn(winner, side);
// synthetic burn decreases the winner supply to 0, therefore we should should set it back to 1.
totalSupply[side] = 1;
status = Status.Complete;
_mint(winner, side, 1, "");
}
}
/**
* @title IOracle
* @notice Interface for the truth oracle that determines prediction round outcomes.
* @dev The oracle is called during each reveal to determine the winning side (0 or 1).
*/
interface IOracle {
/**
* @notice Determines the outcome of a prediction round.
* @param timestamp The revealAt timestamp for the round being revealed.
* @param revealer The address triggering the reveal.
* @return A number whose modulo 2 determines the winner (0=No, 1=Yes).
*/
function reveal(uint256 timestamp, address revealer) external returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/// @notice Library for buffers with automatic capacity resizing.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/DynamicBufferLib.sol)
/// @author Modified from cozyco (https://github.com/samkingco/cozyco/blob/main/contracts/utils/DynamicBuffer.sol)
library DynamicBufferLib {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* STRUCTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Type to represent a dynamic buffer in memory.
/// You can directly assign to `data`, and the `p` function will
/// take care of the memory allocation.
struct DynamicBuffer {
bytes data;
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
// Some of these functions return the same buffer for function chaining.
// e.g. `buffer.p("1").p("2")`.
/// @dev Shorthand for `buffer.data.length`.
function length(DynamicBuffer memory buffer) internal pure returns (uint256) {
return buffer.data.length;
}
/// @dev Reserves at least `minimum` amount of contiguous memory.
function reserve(DynamicBuffer memory buffer, uint256 minimum)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = buffer;
uint256 n = buffer.data.length;
if (minimum > n) {
uint256 i = 0x40;
do {} while ((i <<= 1) < minimum);
bytes memory data;
/// @solidity memory-safe-assembly
assembly {
data := 0x01
mstore(data, sub(i, n))
}
result = p(result, data);
}
}
/// @dev Clears the buffer without deallocating the memory.
function clear(DynamicBuffer memory buffer)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
/// @solidity memory-safe-assembly
assembly {
mstore(mload(buffer), 0)
}
result = buffer;
}
/// @dev Returns a string pointing to the underlying bytes data.
/// Note: The string WILL change if the buffer is updated.
function s(DynamicBuffer memory buffer) internal pure returns (string memory) {
return string(buffer.data);
}
/// @dev Appends `data` to `buffer`.
function p(DynamicBuffer memory buffer, bytes memory data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = buffer;
if (data.length == uint256(0)) return result;
/// @solidity memory-safe-assembly
assembly {
let w := not(0x1f)
let bufData := mload(buffer)
let bufDataLen := mload(bufData)
let newBufDataLen := add(mload(data), bufDataLen)
// Some random prime number to multiply `cap`, so that
// we know that the `cap` is for a dynamic buffer.
// Selected to be larger than any memory pointer realistically.
let prime := 1621250193422201
let cap := mload(add(bufData, w)) // `mload(sub(bufData, 0x20))`.
// Extract `cap`, initializing it to zero if it is not a multiple of `prime`.
cap := mul(div(cap, prime), iszero(mod(cap, prime)))
// Expand / Reallocate memory if required.
// Note that we need to allocate an extra word for the length, and
// and another extra word as a safety word (giving a total of 0x40 bytes).
// Without the safety word, the backwards copying can cause a buffer overflow.
for {} iszero(lt(newBufDataLen, cap)) {} {
// Approximately more than double the capacity to ensure more than enough space.
let newCap := and(add(cap, add(or(cap, newBufDataLen), 0x20)), w)
// If the memory is contiguous, we can simply expand it.
if iszero(or(xor(mload(0x40), add(bufData, add(0x40, cap))), iszero(cap))) {
// Store `cap * prime` in the word before the length.
mstore(add(bufData, w), mul(prime, newCap))
mstore(0x40, add(bufData, add(0x40, newCap))) // Expand the memory allocation.
break
}
// Set the `newBufData` to point to the word after `cap`.
let newBufData := add(mload(0x40), 0x20)
mstore(0x40, add(newBufData, add(0x40, newCap))) // Reallocate the memory.
mstore(buffer, newBufData) // Store the `newBufData`.
// Copy `bufData` one word at a time, backwards.
for { let o := and(add(bufDataLen, 0x20), w) } 1 {} {
mstore(add(newBufData, o), mload(add(bufData, o)))
o := add(o, w) // `sub(o, 0x20)`.
if iszero(o) { break }
}
// Store `cap * prime` in the word before the length.
mstore(add(newBufData, w), mul(prime, newCap))
bufData := newBufData // Assign `newBufData` to `bufData`.
break
}
// If it's a reserve operation, set the variables to skip the appending.
if eq(data, 0x01) {
mstore(data, 0x00)
newBufDataLen := bufDataLen
}
// Copy `data` one word at a time, backwards.
for { let o := and(add(mload(data), 0x20), w) } 1 {} {
mstore(add(add(bufData, bufDataLen), o), mload(add(data, o)))
o := add(o, w) // `sub(o, 0x20)`.
if iszero(o) { break }
}
mstore(add(add(bufData, 0x20), newBufDataLen), 0) // Zeroize the word after the buffer.
mstore(bufData, newBufDataLen) // Store the length.
}
}
/// @dev Appends `data0`, `data1` to `buffer`.
function p(DynamicBuffer memory buffer, bytes memory data0, bytes memory data1)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(p(buffer, data0), data1);
}
/// @dev Appends `data0` .. `data2` to `buffer`.
function p(
DynamicBuffer memory buffer,
bytes memory data0,
bytes memory data1,
bytes memory data2
) internal pure returns (DynamicBuffer memory result) {
_deallocate(result);
result = p(p(p(buffer, data0), data1), data2);
}
/// @dev Appends `data0` .. `data3` to `buffer`.
function p(
DynamicBuffer memory buffer,
bytes memory data0,
bytes memory data1,
bytes memory data2,
bytes memory data3
) internal pure returns (DynamicBuffer memory result) {
_deallocate(result);
result = p(p(p(p(buffer, data0), data1), data2), data3);
}
/// @dev Appends `data0` .. `data4` to `buffer`.
function p(
DynamicBuffer memory buffer,
bytes memory data0,
bytes memory data1,
bytes memory data2,
bytes memory data3,
bytes memory data4
) internal pure returns (DynamicBuffer memory result) {
_deallocate(result);
result = p(p(p(p(p(buffer, data0), data1), data2), data3), data4);
}
/// @dev Appends `data0` .. `data5` to `buffer`.
function p(
DynamicBuffer memory buffer,
bytes memory data0,
bytes memory data1,
bytes memory data2,
bytes memory data3,
bytes memory data4,
bytes memory data5
) internal pure returns (DynamicBuffer memory result) {
_deallocate(result);
result = p(p(p(p(p(p(buffer, data0), data1), data2), data3), data4), data5);
}
/// @dev Appends `data0` .. `data6` to `buffer`.
function p(
DynamicBuffer memory buffer,
bytes memory data0,
bytes memory data1,
bytes memory data2,
bytes memory data3,
bytes memory data4,
bytes memory data5,
bytes memory data6
) internal pure returns (DynamicBuffer memory result) {
_deallocate(result);
result = p(p(p(p(p(p(p(buffer, data0), data1), data2), data3), data4), data5), data6);
}
/// @dev Appends `abi.encodePacked(bool(data))` to buffer.
function pBool(DynamicBuffer memory buffer, bool data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
uint256 casted;
/// @solidity memory-safe-assembly
assembly {
casted := iszero(iszero(data))
}
result = p(buffer, _single(casted, 1));
}
/// @dev Appends `abi.encodePacked(address(data))` to buffer.
function pAddress(DynamicBuffer memory buffer, address data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(uint256(uint160(data)), 20));
}
/// @dev Appends `abi.encodePacked(uint8(data))` to buffer.
function pUint8(DynamicBuffer memory buffer, uint8 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 1));
}
/// @dev Appends `abi.encodePacked(uint16(data))` to buffer.
function pUint16(DynamicBuffer memory buffer, uint16 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 2));
}
/// @dev Appends `abi.encodePacked(uint24(data))` to buffer.
function pUint24(DynamicBuffer memory buffer, uint24 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 3));
}
/// @dev Appends `abi.encodePacked(uint32(data))` to buffer.
function pUint32(DynamicBuffer memory buffer, uint32 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 4));
}
/// @dev Appends `abi.encodePacked(uint40(data))` to buffer.
function pUint40(DynamicBuffer memory buffer, uint40 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 5));
}
/// @dev Appends `abi.encodePacked(uint48(data))` to buffer.
function pUint48(DynamicBuffer memory buffer, uint48 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 6));
}
/// @dev Appends `abi.encodePacked(uint56(data))` to buffer.
function pUint56(DynamicBuffer memory buffer, uint56 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 7));
}
/// @dev Appends `abi.encodePacked(uint64(data))` to buffer.
function pUint64(DynamicBuffer memory buffer, uint64 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 8));
}
/// @dev Appends `abi.encodePacked(uint72(data))` to buffer.
function pUint72(DynamicBuffer memory buffer, uint72 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 9));
}
/// @dev Appends `abi.encodePacked(uint80(data))` to buffer.
function pUint80(DynamicBuffer memory buffer, uint80 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 10));
}
/// @dev Appends `abi.encodePacked(uint88(data))` to buffer.
function pUint88(DynamicBuffer memory buffer, uint88 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 11));
}
/// @dev Appends `abi.encodePacked(uint96(data))` to buffer.
function pUint96(DynamicBuffer memory buffer, uint96 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 12));
}
/// @dev Appends `abi.encodePacked(uint104(data))` to buffer.
function pUint104(DynamicBuffer memory buffer, uint104 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 13));
}
/// @dev Appends `abi.encodePacked(uint112(data))` to buffer.
function pUint112(DynamicBuffer memory buffer, uint112 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 14));
}
/// @dev Appends `abi.encodePacked(uint120(data))` to buffer.
function pUint120(DynamicBuffer memory buffer, uint120 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 15));
}
/// @dev Appends `abi.encodePacked(uint128(data))` to buffer.
function pUint128(DynamicBuffer memory buffer, uint128 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 16));
}
/// @dev Appends `abi.encodePacked(uint136(data))` to buffer.
function pUint136(DynamicBuffer memory buffer, uint136 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 17));
}
/// @dev Appends `abi.encodePacked(uint144(data))` to buffer.
function pUint144(DynamicBuffer memory buffer, uint144 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 18));
}
/// @dev Appends `abi.encodePacked(uint152(data))` to buffer.
function pUint152(DynamicBuffer memory buffer, uint152 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 19));
}
/// @dev Appends `abi.encodePacked(uint160(data))` to buffer.
function pUint160(DynamicBuffer memory buffer, uint160 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 20));
}
/// @dev Appends `abi.encodePacked(uint168(data))` to buffer.
function pUint168(DynamicBuffer memory buffer, uint168 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 21));
}
/// @dev Appends `abi.encodePacked(uint176(data))` to buffer.
function pUint176(DynamicBuffer memory buffer, uint176 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 22));
}
/// @dev Appends `abi.encodePacked(uint184(data))` to buffer.
function pUint184(DynamicBuffer memory buffer, uint184 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 23));
}
/// @dev Appends `abi.encodePacked(uint192(data))` to buffer.
function pUint192(DynamicBuffer memory buffer, uint192 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 24));
}
/// @dev Appends `abi.encodePacked(uint200(data))` to buffer.
function pUint200(DynamicBuffer memory buffer, uint200 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 25));
}
/// @dev Appends `abi.encodePacked(uint208(data))` to buffer.
function pUint208(DynamicBuffer memory buffer, uint208 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 26));
}
/// @dev Appends `abi.encodePacked(uint216(data))` to buffer.
function pUint216(DynamicBuffer memory buffer, uint216 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 27));
}
/// @dev Appends `abi.encodePacked(uint224(data))` to buffer.
function pUint224(DynamicBuffer memory buffer, uint224 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 28));
}
/// @dev Appends `abi.encodePacked(uint232(data))` to buffer.
function pUint232(DynamicBuffer memory buffer, uint232 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 29));
}
/// @dev Appends `abi.encodePacked(uint240(data))` to buffer.
function pUint240(DynamicBuffer memory buffer, uint240 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 30));
}
/// @dev Appends `abi.encodePacked(uint248(data))` to buffer.
function pUint248(DynamicBuffer memory buffer, uint248 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 31));
}
/// @dev Appends `abi.encodePacked(uint256(data))` to buffer.
function pUint256(DynamicBuffer memory buffer, uint256 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(data, 32));
}
/// @dev Appends `abi.encodePacked(bytes1(data))` to buffer.
function pBytes1(DynamicBuffer memory buffer, bytes1 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 1));
}
/// @dev Appends `abi.encodePacked(bytes2(data))` to buffer.
function pBytes2(DynamicBuffer memory buffer, bytes2 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 2));
}
/// @dev Appends `abi.encodePacked(bytes3(data))` to buffer.
function pBytes3(DynamicBuffer memory buffer, bytes3 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 3));
}
/// @dev Appends `abi.encodePacked(bytes4(data))` to buffer.
function pBytes4(DynamicBuffer memory buffer, bytes4 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 4));
}
/// @dev Appends `abi.encodePacked(bytes5(data))` to buffer.
function pBytes5(DynamicBuffer memory buffer, bytes5 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 5));
}
/// @dev Appends `abi.encodePacked(bytes6(data))` to buffer.
function pBytes6(DynamicBuffer memory buffer, bytes6 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 6));
}
/// @dev Appends `abi.encodePacked(bytes7(data))` to buffer.
function pBytes7(DynamicBuffer memory buffer, bytes7 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 7));
}
/// @dev Appends `abi.encodePacked(bytes8(data))` to buffer.
function pBytes8(DynamicBuffer memory buffer, bytes8 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 8));
}
/// @dev Appends `abi.encodePacked(bytes9(data))` to buffer.
function pBytes9(DynamicBuffer memory buffer, bytes9 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 9));
}
/// @dev Appends `abi.encodePacked(bytes10(data))` to buffer.
function pBytes10(DynamicBuffer memory buffer, bytes10 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 10));
}
/// @dev Appends `abi.encodePacked(bytes11(data))` to buffer.
function pBytes11(DynamicBuffer memory buffer, bytes11 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 11));
}
/// @dev Appends `abi.encodePacked(bytes12(data))` to buffer.
function pBytes12(DynamicBuffer memory buffer, bytes12 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 12));
}
/// @dev Appends `abi.encodePacked(bytes13(data))` to buffer.
function pBytes13(DynamicBuffer memory buffer, bytes13 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 13));
}
/// @dev Appends `abi.encodePacked(bytes14(data))` to buffer.
function pBytes14(DynamicBuffer memory buffer, bytes14 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 14));
}
/// @dev Appends `abi.encodePacked(bytes15(data))` to buffer.
function pBytes15(DynamicBuffer memory buffer, bytes15 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 15));
}
/// @dev Appends `abi.encodePacked(bytes16(data))` to buffer.
function pBytes16(DynamicBuffer memory buffer, bytes16 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 16));
}
/// @dev Appends `abi.encodePacked(bytes17(data))` to buffer.
function pBytes17(DynamicBuffer memory buffer, bytes17 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 17));
}
/// @dev Appends `abi.encodePacked(bytes18(data))` to buffer.
function pBytes18(DynamicBuffer memory buffer, bytes18 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 18));
}
/// @dev Appends `abi.encodePacked(bytes19(data))` to buffer.
function pBytes19(DynamicBuffer memory buffer, bytes19 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 19));
}
/// @dev Appends `abi.encodePacked(bytes20(data))` to buffer.
function pBytes20(DynamicBuffer memory buffer, bytes20 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 20));
}
/// @dev Appends `abi.encodePacked(bytes21(data))` to buffer.
function pBytes21(DynamicBuffer memory buffer, bytes21 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 21));
}
/// @dev Appends `abi.encodePacked(bytes22(data))` to buffer.
function pBytes22(DynamicBuffer memory buffer, bytes22 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 22));
}
/// @dev Appends `abi.encodePacked(bytes23(data))` to buffer.
function pBytes23(DynamicBuffer memory buffer, bytes23 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 23));
}
/// @dev Appends `abi.encodePacked(bytes24(data))` to buffer.
function pBytes24(DynamicBuffer memory buffer, bytes24 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 24));
}
/// @dev Appends `abi.encodePacked(bytes25(data))` to buffer.
function pBytes25(DynamicBuffer memory buffer, bytes25 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 25));
}
/// @dev Appends `abi.encodePacked(bytes26(data))` to buffer.
function pBytes26(DynamicBuffer memory buffer, bytes26 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 26));
}
/// @dev Appends `abi.encodePacked(bytes27(data))` to buffer.
function pBytes27(DynamicBuffer memory buffer, bytes27 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 27));
}
/// @dev Appends `abi.encodePacked(bytes28(data))` to buffer.
function pBytes28(DynamicBuffer memory buffer, bytes28 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 28));
}
/// @dev Appends `abi.encodePacked(bytes29(data))` to buffer.
function pBytes29(DynamicBuffer memory buffer, bytes29 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 29));
}
/// @dev Appends `abi.encodePacked(bytes30(data))` to buffer.
function pBytes30(DynamicBuffer memory buffer, bytes30 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 30));
}
/// @dev Appends `abi.encodePacked(bytes31(data))` to buffer.
function pBytes31(DynamicBuffer memory buffer, bytes31 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 31));
}
/// @dev Appends `abi.encodePacked(bytes32(data))` to buffer.
function pBytes32(DynamicBuffer memory buffer, bytes32 data)
internal
pure
returns (DynamicBuffer memory result)
{
_deallocate(result);
result = p(buffer, _single(bytes32(data), 32));
}
/// @dev Shorthand for returning a new buffer.
function p() internal pure returns (DynamicBuffer memory result) {}
/// @dev Shorthand for `p(p(), data)`.
function p(bytes memory data) internal pure returns (DynamicBuffer memory result) {
p(result, data);
}
/// @dev Shorthand for `p(p(), data0, data1)`.
function p(bytes memory data0, bytes memory data1)
internal
pure
returns (DynamicBuffer memory result)
{
p(p(result, data0), data1);
}
/// @dev Shorthand for `p(p(), data0, .., data2)`.
function p(bytes memory data0, bytes memory data1, bytes memory data2)
internal
pure
returns (DynamicBuffer memory result)
{
p(p(p(result, data0), data1), data2);
}
/// @dev Shorthand for `p(p(), data0, .., data3)`.
function p(bytes memory data0, bytes memory data1, bytes memory data2, bytes memory data3)
internal
pure
returns (DynamicBuffer memory result)
{
p(p(p(p(result, data0), data1), data2), data3);
}
/// @dev Shorthand for `p(p(), data0, .., data4)`.
function p(
bytes memory data0,
bytes memory data1,
bytes memory data2,
bytes memory data3,
bytes memory data4
) internal pure returns (DynamicBuffer memory result) {
p(p(p(p(p(result, data0), data1), data2), data3), data4);
}
/// @dev Shorthand for `p(p(), data0, .., data5)`.
function p(
bytes memory data0,
bytes memory data1,
bytes memory data2,
bytes memory data3,
bytes memory data4,
bytes memory data5
) internal pure returns (DynamicBuffer memory result) {
p(p(p(p(p(p(result, data0), data1), data2), data3), data4), data5);
}
/// @dev Shorthand for `p(p(), data0, .., data6)`.
function p(
bytes memory data0,
bytes memory data1,
bytes memory data2,
bytes memory data3,
bytes memory data4,
bytes memory data5,
bytes memory data6
) internal pure returns (DynamicBuffer memory result) {
p(p(p(p(p(p(p(result, data0), data1), data2), data3), data4), data5), data6);
}
/// @dev Shorthand for `pBool(p(), data)`.
function pBool(bool data) internal pure returns (DynamicBuffer memory result) {
pBool(result, data);
}
/// @dev Shorthand for `pAddress(p(), data)`.
function pAddress(address data) internal pure returns (DynamicBuffer memory result) {
pAddress(result, data);
}
/// @dev Shorthand for `pUint8(p(), data)`.
function pUint8(uint8 data) internal pure returns (DynamicBuffer memory result) {
pUint8(result, data);
}
/// @dev Shorthand for `pUint16(p(), data)`.
function pUint16(uint16 data) internal pure returns (DynamicBuffer memory result) {
pUint16(result, data);
}
/// @dev Shorthand for `pUint24(p(), data)`.
function pUint24(uint24 data) internal pure returns (DynamicBuffer memory result) {
pUint24(result, data);
}
/// @dev Shorthand for `pUint32(p(), data)`.
function pUint32(uint32 data) internal pure returns (DynamicBuffer memory result) {
pUint32(result, data);
}
/// @dev Shorthand for `pUint40(p(), data)`.
function pUint40(uint40 data) internal pure returns (DynamicBuffer memory result) {
pUint40(result, data);
}
/// @dev Shorthand for `pUint48(p(), data)`.
function pUint48(uint48 data) internal pure returns (DynamicBuffer memory result) {
pUint48(result, data);
}
/// @dev Shorthand for `pUint56(p(), data)`.
function pUint56(uint56 data) internal pure returns (DynamicBuffer memory result) {
pUint56(result, data);
}
/// @dev Shorthand for `pUint64(p(), data)`.
function pUint64(uint64 data) internal pure returns (DynamicBuffer memory result) {
pUint64(result, data);
}
/// @dev Shorthand for `pUint72(p(), data)`.
function pUint72(uint72 data) internal pure returns (DynamicBuffer memory result) {
pUint72(result, data);
}
/// @dev Shorthand for `pUint80(p(), data)`.
function pUint80(uint80 data) internal pure returns (DynamicBuffer memory result) {
pUint80(result, data);
}
/// @dev Shorthand for `pUint88(p(), data)`.
function pUint88(uint88 data) internal pure returns (DynamicBuffer memory result) {
pUint88(result, data);
}
/// @dev Shorthand for `pUint96(p(), data)`.
function pUint96(uint96 data) internal pure returns (DynamicBuffer memory result) {
pUint96(result, data);
}
/// @dev Shorthand for `pUint104(p(), data)`.
function pUint104(uint104 data) internal pure returns (DynamicBuffer memory result) {
pUint104(result, data);
}
/// @dev Shorthand for `pUint112(p(), data)`.
function pUint112(uint112 data) internal pure returns (DynamicBuffer memory result) {
pUint112(result, data);
}
/// @dev Shorthand for `pUint120(p(), data)`.
function pUint120(uint120 data) internal pure returns (DynamicBuffer memory result) {
pUint120(result, data);
}
/// @dev Shorthand for `pUint128(p(), data)`.
function pUint128(uint128 data) internal pure returns (DynamicBuffer memory result) {
pUint128(result, data);
}
/// @dev Shorthand for `pUint136(p(), data)`.
function pUint136(uint136 data) internal pure returns (DynamicBuffer memory result) {
pUint136(result, data);
}
/// @dev Shorthand for `pUint144(p(), data)`.
function pUint144(uint144 data) internal pure returns (DynamicBuffer memory result) {
pUint144(result, data);
}
/// @dev Shorthand for `pUint152(p(), data)`.
function pUint152(uint152 data) internal pure returns (DynamicBuffer memory result) {
pUint152(result, data);
}
/// @dev Shorthand for `pUint160(p(), data)`.
function pUint160(uint160 data) internal pure returns (DynamicBuffer memory result) {
pUint160(result, data);
}
/// @dev Shorthand for `pUint168(p(), data)`.
function pUint168(uint168 data) internal pure returns (DynamicBuffer memory result) {
pUint168(result, data);
}
/// @dev Shorthand for `pUint176(p(), data)`.
function pUint176(uint176 data) internal pure returns (DynamicBuffer memory result) {
pUint176(result, data);
}
/// @dev Shorthand for `pUint184(p(), data)`.
function pUint184(uint184 data) internal pure returns (DynamicBuffer memory result) {
pUint184(result, data);
}
/// @dev Shorthand for `pUint192(p(), data)`.
function pUint192(uint192 data) internal pure returns (DynamicBuffer memory result) {
pUint192(result, data);
}
/// @dev Shorthand for `pUint200(p(), data)`.
function pUint200(uint200 data) internal pure returns (DynamicBuffer memory result) {
pUint200(result, data);
}
/// @dev Shorthand for `pUint208(p(), data)`.
function pUint208(uint208 data) internal pure returns (DynamicBuffer memory result) {
pUint208(result, data);
}
/// @dev Shorthand for `pUint216(p(), data)`.
function pUint216(uint216 data) internal pure returns (DynamicBuffer memory result) {
pUint216(result, data);
}
/// @dev Shorthand for `pUint224(p(), data)`.
function pUint224(uint224 data) internal pure returns (DynamicBuffer memory result) {
pUint224(result, data);
}
/// @dev Shorthand for `pUint232(p(), data)`.
function pUint232(uint232 data) internal pure returns (DynamicBuffer memory result) {
pUint232(result, data);
}
/// @dev Shorthand for `pUint240(p(), data)`.
function pUint240(uint240 data) internal pure returns (DynamicBuffer memory result) {
pUint240(result, data);
}
/// @dev Shorthand for `pUint248(p(), data)`.
function pUint248(uint248 data) internal pure returns (DynamicBuffer memory result) {
pUint248(result, data);
}
/// @dev Shorthand for `pUint256(p(), data)`.
function pUint256(uint256 data) internal pure returns (DynamicBuffer memory result) {
pUint256(result, data);
}
/// @dev Shorthand for `pBytes1(p(), data)`.
function pBytes1(bytes1 data) internal pure returns (DynamicBuffer memory result) {
pBytes1(result, data);
}
/// @dev Shorthand for `pBytes2(p(), data)`.
function pBytes2(bytes2 data) internal pure returns (DynamicBuffer memory result) {
pBytes2(result, data);
}
/// @dev Shorthand for `pBytes3(p(), data)`.
function pBytes3(bytes3 data) internal pure returns (DynamicBuffer memory result) {
pBytes3(result, data);
}
/// @dev Shorthand for `pBytes4(p(), data)`.
function pBytes4(bytes4 data) internal pure returns (DynamicBuffer memory result) {
pBytes4(result, data);
}
/// @dev Shorthand for `pBytes5(p(), data)`.
function pBytes5(bytes5 data) internal pure returns (DynamicBuffer memory result) {
pBytes5(result, data);
}
/// @dev Shorthand for `pBytes6(p(), data)`.
function pBytes6(bytes6 data) internal pure returns (DynamicBuffer memory result) {
pBytes6(result, data);
}
/// @dev Shorthand for `pBytes7(p(), data)`.
function pBytes7(bytes7 data) internal pure returns (DynamicBuffer memory result) {
pBytes7(result, data);
}
/// @dev Shorthand for `pBytes8(p(), data)`.
function pBytes8(bytes8 data) internal pure returns (DynamicBuffer memory result) {
pBytes8(result, data);
}
/// @dev Shorthand for `pBytes9(p(), data)`.
function pBytes9(bytes9 data) internal pure returns (DynamicBuffer memory result) {
pBytes9(result, data);
}
/// @dev Shorthand for `pBytes10(p(), data)`.
function pBytes10(bytes10 data) internal pure returns (DynamicBuffer memory result) {
pBytes10(result, data);
}
/// @dev Shorthand for `pBytes11(p(), data)`.
function pBytes11(bytes11 data) internal pure returns (DynamicBuffer memory result) {
pBytes11(result, data);
}
/// @dev Shorthand for `pBytes12(p(), data)`.
function pBytes12(bytes12 data) internal pure returns (DynamicBuffer memory result) {
pBytes12(result, data);
}
/// @dev Shorthand for `pBytes13(p(), data)`.
function pBytes13(bytes13 data) internal pure returns (DynamicBuffer memory result) {
pBytes13(result, data);
}
/// @dev Shorthand for `pBytes14(p(), data)`.
function pBytes14(bytes14 data) internal pure returns (DynamicBuffer memory result) {
pBytes14(result, data);
}
/// @dev Shorthand for `pBytes15(p(), data)`.
function pBytes15(bytes15 data) internal pure returns (DynamicBuffer memory result) {
pBytes15(result, data);
}
/// @dev Shorthand for `pBytes16(p(), data)`.
function pBytes16(bytes16 data) internal pure returns (DynamicBuffer memory result) {
pBytes16(result, data);
}
/// @dev Shorthand for `pBytes17(p(), data)`.
function pBytes17(bytes17 data) internal pure returns (DynamicBuffer memory result) {
pBytes17(result, data);
}
/// @dev Shorthand for `pBytes18(p(), data)`.
function pBytes18(bytes18 data) internal pure returns (DynamicBuffer memory result) {
pBytes18(result, data);
}
/// @dev Shorthand for `pBytes19(p(), data)`.
function pBytes19(bytes19 data) internal pure returns (DynamicBuffer memory result) {
pBytes19(result, data);
}
/// @dev Shorthand for `pBytes20(p(), data)`.
function pBytes20(bytes20 data) internal pure returns (DynamicBuffer memory result) {
pBytes20(result, data);
}
/// @dev Shorthand for `pBytes21(p(), data)`.
function pBytes21(bytes21 data) internal pure returns (DynamicBuffer memory result) {
pBytes21(result, data);
}
/// @dev Shorthand for `pBytes22(p(), data)`.
function pBytes22(bytes22 data) internal pure returns (DynamicBuffer memory result) {
pBytes22(result, data);
}
/// @dev Shorthand for `pBytes23(p(), data)`.
function pBytes23(bytes23 data) internal pure returns (DynamicBuffer memory result) {
pBytes23(result, data);
}
/// @dev Shorthand for `pBytes24(p(), data)`.
function pBytes24(bytes24 data) internal pure returns (DynamicBuffer memory result) {
pBytes24(result, data);
}
/// @dev Shorthand for `pBytes25(p(), data)`.
function pBytes25(bytes25 data) internal pure returns (DynamicBuffer memory result) {
pBytes25(result, data);
}
/// @dev Shorthand for `pBytes26(p(), data)`.
function pBytes26(bytes26 data) internal pure returns (DynamicBuffer memory result) {
pBytes26(result, data);
}
/// @dev Shorthand for `pBytes27(p(), data)`.
function pBytes27(bytes27 data) internal pure returns (DynamicBuffer memory result) {
pBytes27(result, data);
}
/// @dev Shorthand for `pBytes28(p(), data)`.
function pBytes28(bytes28 data) internal pure returns (DynamicBuffer memory result) {
pBytes28(result, data);
}
/// @dev Shorthand for `pBytes29(p(), data)`.
function pBytes29(bytes29 data) internal pure returns (DynamicBuffer memory result) {
pBytes29(result, data);
}
/// @dev Shorthand for `pBytes30(p(), data)`.
function pBytes30(bytes30 data) internal pure returns (DynamicBuffer memory result) {
pBytes30(result, data);
}
/// @dev Shorthand for `pBytes31(p(), data)`.
function pBytes31(bytes31 data) internal pure returns (DynamicBuffer memory result) {
pBytes31(result, data);
}
/// @dev Shorthand for `pBytes32(p(), data)`.
function pBytes32(bytes32 data) internal pure returns (DynamicBuffer memory result) {
pBytes32(result, data);
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* PRIVATE HELPERS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Helper for deallocating an automatically allocated `buffer` pointer.
function _deallocate(DynamicBuffer memory result) private pure {
/// @solidity memory-safe-assembly
assembly {
mstore(0x40, result) // Deallocate, as we have already allocated.
}
}
/// @dev Returns a temporary bytes string of length `n` for `data`.
function _single(uint256 data, uint256 n) private pure returns (bytes memory result) {
/// @solidity memory-safe-assembly
assembly {
result := 0x00
mstore(n, data)
mstore(result, n)
}
}
/// @dev Returns a temporary bytes string of length `n` for `data`.
function _single(bytes32 data, uint256 n) private pure returns (bytes memory result) {
/// @solidity memory-safe-assembly
assembly {
result := 0x00
mstore(0x20, data)
mstore(result, n)
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import {LibBytes} from "./LibBytes.sol";
/// @notice Library for converting numbers into strings and other string operations.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/LibString.sol)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/LibString.sol)
///
/// @dev Note:
/// For performance and bytecode compactness, most of the string operations are restricted to
/// byte strings (7-bit ASCII), except where otherwise specified.
/// Usage of byte string operations on charsets with runes spanning two or more bytes
/// can lead to undefined behavior.
library LibString {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* STRUCTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Goated string storage struct that totally MOGs, no cap, fr.
/// Uses less gas and bytecode than Solidity's native string storage. It's meta af.
/// Packs length with the first 31 bytes if <255 bytes, so it’s mad tight.
struct StringStorage {
bytes32 _spacer;
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CUSTOM ERRORS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The length of the output is too small to contain all the hex digits.
error HexLengthInsufficient();
/// @dev The length of the string is more than 32 bytes.
error TooBigForSmallString();
/// @dev The input string must be a 7-bit ASCII.
error StringNot7BitASCII();
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CONSTANTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The constant returned when the `search` is not found in the string.
uint256 internal constant NOT_FOUND = type(uint256).max;
/// @dev Lookup for '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.
uint128 internal constant ALPHANUMERIC_7_BIT_ASCII = 0x7fffffe07fffffe03ff000000000000;
/// @dev Lookup for 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.
uint128 internal constant LETTERS_7_BIT_ASCII = 0x7fffffe07fffffe0000000000000000;
/// @dev Lookup for 'abcdefghijklmnopqrstuvwxyz'.
uint128 internal constant LOWERCASE_7_BIT_ASCII = 0x7fffffe000000000000000000000000;
/// @dev Lookup for 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
uint128 internal constant UPPERCASE_7_BIT_ASCII = 0x7fffffe0000000000000000;
/// @dev Lookup for '0123456789'.
uint128 internal constant DIGITS_7_BIT_ASCII = 0x3ff000000000000;
/// @dev Lookup for '0123456789abcdefABCDEF'.
uint128 internal constant HEXDIGITS_7_BIT_ASCII = 0x7e0000007e03ff000000000000;
/// @dev Lookup for '01234567'.
uint128 internal constant OCTDIGITS_7_BIT_ASCII = 0xff000000000000;
/// @dev Lookup for '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'.
uint128 internal constant PRINTABLE_7_BIT_ASCII = 0x7fffffffffffffffffffffff00003e00;
/// @dev Lookup for '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'.
uint128 internal constant PUNCTUATION_7_BIT_ASCII = 0x78000001f8000001fc00fffe00000000;
/// @dev Lookup for ' \t\n\r\x0b\x0c'.
uint128 internal constant WHITESPACE_7_BIT_ASCII = 0x100003e00;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* STRING STORAGE OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Sets the value of the string storage `$` to `s`.
function set(StringStorage storage $, string memory s) internal {
LibBytes.set(bytesStorage($), bytes(s));
}
/// @dev Sets the value of the string storage `$` to `s`.
function setCalldata(StringStorage storage $, string calldata s) internal {
LibBytes.setCalldata(bytesStorage($), bytes(s));
}
/// @dev Sets the value of the string storage `$` to the empty string.
function clear(StringStorage storage $) internal {
delete $._spacer;
}
/// @dev Returns whether the value stored is `$` is the empty string "".
function isEmpty(StringStorage storage $) internal view returns (bool) {
return uint256($._spacer) & 0xff == uint256(0);
}
/// @dev Returns the length of the value stored in `$`.
function length(StringStorage storage $) internal view returns (uint256) {
return LibBytes.length(bytesStorage($));
}
/// @dev Returns the value stored in `$`.
function get(StringStorage storage $) internal view returns (string memory) {
return string(LibBytes.get(bytesStorage($)));
}
/// @dev Returns the uint8 at index `i`. If out-of-bounds, returns 0.
function uint8At(StringStorage storage $, uint256 i) internal view returns (uint8) {
return LibBytes.uint8At(bytesStorage($), i);
}
/// @dev Helper to cast `$` to a `BytesStorage`.
function bytesStorage(StringStorage storage $)
internal
pure
returns (LibBytes.BytesStorage storage casted)
{
/// @solidity memory-safe-assembly
assembly {
casted.slot := $.slot
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* DECIMAL OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns the base 10 decimal representation of `value`.
function toString(uint256 value) internal pure returns (string memory result) {
/// @solidity memory-safe-assembly
assembly {
// The maximum value of a uint256 contains 78 digits (1 byte per digit), but
// we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.
// We will need 1 word for the trailing zeros padding, 1 word for the length,
// and 3 words for a maximum of 78 digits.
result := add(mload(0x40), 0x80)
mstore(0x40, add(result, 0x20)) // Allocate memory.
mstore(result, 0) // Zeroize the slot after the string.
let end := result // Cache the end of the memory to calculate the length later.
let w := not(0) // Tsk.
// We write the string from rightmost digit to leftmost digit.
// The following is essentially a do-while loop that also handles the zero case.
for { let temp := value } 1 {} {
result := add(result, w) // `sub(result, 1)`.
// Store the character to the pointer.
// The ASCII index of the '0' character is 48.
mstore8(result, add(48, mod(temp, 10)))
temp := div(temp, 10) // Keep dividing `temp` until zero.
if iszero(temp) { break }
}
let n := sub(end, result)
result := sub(result, 0x20) // Move the pointer 32 bytes back to make room for the length.
mstore(result, n) // Store the length.
}
}
/// @dev Returns the base 10 decimal representation of `value`.
function toString(int256 value) internal pure returns (string memory result) {
if (value >= 0) return toString(uint256(value));
unchecked {
result = toString(~uint256(value) + 1);
}
/// @solidity memory-safe-assembly
assembly {
// We still have some spare memory space on the left,
// as we have allocated 3 words (96 bytes) for up to 78 digits.
let n := mload(result) // Load the string length.
mstore(result, 0x2d) // Store the '-' character.
result := sub(result, 1) // Move back the string pointer by a byte.
mstore(result, add(n, 1)) // Update the string length.
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* HEXADECIMAL OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns the hexadecimal representation of `value`,
/// left-padded to an input length of `byteCount` bytes.
/// The output is prefixed with "0x" encoded using 2 hexadecimal digits per byte,
/// giving a total length of `byteCount * 2 + 2` bytes.
/// Reverts if `byteCount` is too small for the output to contain all the digits.
function toHexString(uint256 value, uint256 byteCount)
internal
pure
returns (string memory result)
{
result = toHexStringNoPrefix(value, byteCount);
/// @solidity memory-safe-assembly
assembly {
let n := add(mload(result), 2) // Compute the length.
mstore(result, 0x3078) // Store the "0x" prefix.
result := sub(result, 2) // Move the pointer.
mstore(result, n) // Store the length.
}
}
/// @dev Returns the hexadecimal representation of `value`,
/// left-padded to an input length of `byteCount` bytes.
/// The output is not prefixed with "0x" and is encoded using 2 hexadecimal digits per byte,
/// giving a total length of `byteCount * 2` bytes.
/// Reverts if `byteCount` is too small for the output to contain all the digits.
function toHexStringNoPrefix(uint256 value, uint256 byteCount)
internal
pure
returns (string memory result)
{
/// @solidity memory-safe-assembly
assembly {
// We need 0x20 bytes for the trailing zeros padding, `byteCount * 2` bytes
// for the digits, 0x02 bytes for the prefix, and 0x20 bytes for the length.
// We add 0x20 to the total and round down to a multiple of 0x20.
// (0x20 + 0x20 + 0x02 + 0x20) = 0x62.
result := add(mload(0x40), and(add(shl(1, byteCount), 0x42), not(0x1f)))
mstore(0x40, add(result, 0x20)) // Allocate memory.
mstore(result, 0) // Zeroize the slot after the string.
let end := result // Cache the end to calculate the length later.
// Store "0123456789abcdef" in scratch space.
mstore(0x0f, 0x30313233343536373839616263646566)
let start := sub(result, add(byteCount, byteCount))
let w := not(1) // Tsk.
let temp := value
// We write the string from rightmost digit to leftmost digit.
// The following is essentially a do-while loop that also handles the zero case.
for {} 1 {} {
result := add(result, w) // `sub(result, 2)`.
mstore8(add(result, 1), mload(and(temp, 15)))
mstore8(result, mload(and(shr(4, temp), 15)))
temp := shr(8, temp)
if iszero(xor(result, start)) { break }
}
if temp {
mstore(0x00, 0x2194895a) // `HexLengthInsufficient()`.
revert(0x1c, 0x04)
}
let n := sub(end, result)
result := sub(result, 0x20)
mstore(result, n) // Store the length.
}
}
/// @dev Returns the hexadecimal representation of `value`.
/// The output is prefixed with "0x" and encoded using 2 hexadecimal digits per byte.
/// As address are 20 bytes long, the output will left-padded to have
/// a length of `20 * 2 + 2` bytes.
function toHexString(uint256 value) internal pure returns (string memory result) {
result = toHexStringNoPrefix(value);
/// @solidity memory-safe-assembly
assembly {
let n := add(mload(result), 2) // Compute the length.
mstore(result, 0x3078) // Store the "0x" prefix.
result := sub(result, 2) // Move the pointer.
mstore(result, n) // Store the length.
}
}
/// @dev Returns the hexadecimal representation of `value`.
/// The output is prefixed with "0x".
/// The output excludes leading "0" from the `toHexString` output.
/// `0x00: "0x0", 0x01: "0x1", 0x12: "0x12", 0x123: "0x123"`.
function toMinimalHexString(uint256 value) internal pure returns (string memory result) {
result = toHexStringNoPrefix(value);
/// @solidity memory-safe-assembly
assembly {
let o := eq(byte(0, mload(add(result, 0x20))), 0x30) // Whether leading zero is present.
let n := add(mload(result), 2) // Compute the length.
mstore(add(result, o), 0x3078) // Store the "0x" prefix, accounting for leading zero.
result := sub(add(result, o), 2) // Move the pointer, accounting for leading zero.
mstore(result, sub(n, o)) // Store the length, accounting for leading zero.
}
}
/// @dev Returns the hexadecimal representation of `value`.
/// The output excludes leading "0" from the `toHexStringNoPrefix` output.
/// `0x00: "0", 0x01: "1", 0x12: "12", 0x123: "123"`.
function toMinimalHexStringNoPrefix(uint256 value)
internal
pure
returns (string memory result)
{
result = toHexStringNoPrefix(value);
/// @solidity memory-safe-assembly
assembly {
let o := eq(byte(0, mload(add(result, 0x20))), 0x30) // Whether leading zero is present.
let n := mload(result) // Get the length.
result := add(result, o) // Move the pointer, accounting for leading zero.
mstore(result, sub(n, o)) // Store the length, accounting for leading zero.
}
}
/// @dev Returns the hexadecimal representation of `value`.
/// The output is encoded using 2 hexadecimal digits per byte.
/// As address are 20 bytes long, the output will left-padded to have
/// a length of `20 * 2` bytes.
function toHexStringNoPrefix(uint256 value) internal pure returns (string memory result) {
/// @solidity memory-safe-assembly
assembly {
// We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length,
// 0x02 bytes for the prefix, and 0x40 bytes for the digits.
// The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x40) is 0xa0.
result := add(mload(0x40), 0x80)
mstore(0x40, add(result, 0x20)) // Allocate memory.
mstore(result, 0) // Zeroize the slot after the string.
let end := result // Cache the end to calculate the length later.
mstore(0x0f, 0x30313233343536373839616263646566) // Store the "0123456789abcdef" lookup.
let w := not(1) // Tsk.
// We write the string from rightmost digit to leftmost digit.
// The following is essentially a do-while loop that also handles the zero case.
for { let temp := value } 1 {} {
result := add(result, w) // `sub(result, 2)`.
mstore8(add(result, 1), mload(and(temp, 15)))
mstore8(result, mload(and(shr(4, temp), 15)))
temp := shr(8, temp)
if iszero(temp) { break }
}
let n := sub(end, result)
result := sub(result, 0x20)
mstore(result, n) // Store the length.
}
}
/// @dev Returns the hexadecimal representation of `value`.
/// The output is prefixed with "0x", encoded using 2 hexadecimal digits per byte,
/// and the alphabets are capitalized conditionally according to
/// https://eips.ethereum.org/EIPS/eip-55
function toHexStringChecksummed(address value) internal pure returns (string memory result) {
result = toHexString(value);
/// @solidity memory-safe-assembly
assembly {
let mask := shl(6, div(not(0), 255)) // `0b010000000100000000 ...`
let o := add(result, 0x22)
let hashed := and(keccak256(o, 40), mul(34, mask)) // `0b10001000 ... `
let t := shl(240, 136) // `0b10001000 << 240`
for { let i := 0 } 1 {} {
mstore(add(i, i), mul(t, byte(i, hashed)))
i := add(i, 1)
if eq(i, 20) { break }
}
mstore(o, xor(mload(o), shr(1, and(mload(0x00), and(mload(o), mask)))))
o := add(o, 0x20)
mstore(o, xor(mload(o), shr(1, and(mload(0x20), and(mload(o), mask)))))
}
}
/// @dev Returns the hexadecimal representation of `value`.
/// The output is prefixed with "0x" and encoded using 2 hexadecimal digits per byte.
function toHexString(address value) internal pure returns (string memory result) {
result = toHexStringNoPrefix(value);
/// @solidity memory-safe-assembly
assembly {
let n := add(mload(result), 2) // Compute the length.
mstore(result, 0x3078) // Store the "0x" prefix.
result := sub(result, 2) // Move the pointer.
mstore(result, n) // Store the length.
}
}
/// @dev Returns the hexadecimal representation of `value`.
/// The output is encoded using 2 hexadecimal digits per byte.
function toHexStringNoPrefix(address value) internal pure returns (string memory result) {
/// @solidity memory-safe-assembly
assembly {
result := mload(0x40)
// Allocate memory.
// We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length,
// 0x02 bytes for the prefix, and 0x28 bytes for the digits.
// The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x28) is 0x80.
mstore(0x40, add(result, 0x80))
mstore(0x0f, 0x30313233343536373839616263646566) // Store the "0123456789abcdef" lookup.
result := add(result, 2)
mstore(result, 40) // Store the length.
let o := add(result, 0x20)
mstore(add(o, 40), 0) // Zeroize the slot after the string.
value := shl(96, value)
// We write the string from rightmost digit to leftmost digit.
// The following is essentially a do-while loop that also handles the zero case.
for { let i := 0 } 1 {} {
let p := add(o, add(i, i))
let temp := byte(i, value)
mstore8(add(p, 1), mload(and(temp, 15)))
mstore8(p, mload(shr(4, temp)))
i := add(i, 1)
if eq(i, 20) { break }
}
}
}
/// @dev Returns the hex encoded string from the raw bytes.
/// The output is encoded using 2 hexadecimal digits per byte.
function toHexString(bytes memory raw) internal pure returns (string memory result) {
result = toHexStringNoPrefix(raw);
/// @solidity memory-safe-assembly
assembly {
let n := add(mload(result), 2) // Compute the length.
mstore(result, 0x3078) // Store the "0x" prefix.
result := sub(result, 2) // Move the pointer.
mstore(result, n) // Store the length.
}
}
/// @dev Returns the hex encoded string from the raw bytes.
/// The output is encoded using 2 hexadecimal digits per byte.
function toHexStringNoPrefix(bytes memory raw) internal pure returns (string memory result) {
/// @solidity memory-safe-assembly
assembly {
let n := mload(raw)
result := add(mload(0x40), 2) // Skip 2 bytes for the optional prefix.
mstore(result, add(n, n)) // Store the length of the output.
mstore(0x0f, 0x30313233343536373839616263646566) // Store the "0123456789abcdef" lookup.
let o := add(result, 0x20)
let end := add(raw, n)
for {} iszero(eq(raw, end)) {} {
raw := add(raw, 1)
mstore8(add(o, 1), mload(and(mload(raw), 15)))
mstore8(o, mload(and(shr(4, mload(raw)), 15)))
o := add(o, 2)
}
mstore(o, 0) // Zeroize the slot after the string.
mstore(0x40, add(o, 0x20)) // Allocate memory.
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* RUNE STRING OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns the number of UTF characters in the string.
function runeCount(string memory s) internal pure returns (uint256 result) {
/// @solidity memory-safe-assembly
assembly {
if mload(s) {
mstore(0x00, div(not(0), 255))
mstore(0x20, 0x0202020202020202020202020202020202020202020202020303030304040506)
let o := add(s, 0x20)
let end := add(o, mload(s))
for { result := 1 } 1 { result := add(result, 1) } {
o := add(o, byte(0, mload(shr(250, mload(o)))))
if iszero(lt(o, end)) { break }
}
}
}
}
/// @dev Returns if this string is a 7-bit ASCII string.
/// (i.e. all characters codes are in [0..127])
function is7BitASCII(string memory s) internal pure returns (bool result) {
/// @solidity memory-safe-assembly
assembly {
result := 1
let mask := shl(7, div(not(0), 255))
let n := mload(s)
if n {
let o := add(s, 0x20)
let end := add(o, n)
let last := mload(end)
mstore(end, 0)
for {} 1 {} {
if and(mask, mload(o)) {
result := 0
break
}
o := add(o, 0x20)
if iszero(lt(o, end)) { break }
}
mstore(end, last)
}
}
}
/// @dev Returns if this string is a 7-bit ASCII string,
/// AND all characters are in the `allowed` lookup.
/// Note: If `s` is empty, returns true regardless of `allowed`.
function is7BitASCII(string memory s, uint128 allowed) internal pure returns (bool result) {
/// @solidity memory-safe-assembly
assembly {
result := 1
if mload(s) {
let allowed_ := shr(128, shl(128, allowed))
let o := add(s, 0x20)
for { let end := add(o, mload(s)) } 1 {} {
result := and(result, shr(byte(0, mload(o)), allowed_))
o := add(o, 1)
if iszero(and(result, lt(o, end))) { break }
}
}
}
}
/// @dev Converts the bytes in the 7-bit ASCII string `s` to
/// an allowed lookup for use in `is7BitASCII(s, allowed)`.
/// To save runtime gas, you can cache the result in an immutable variable.
function to7BitASCIIAllowedLookup(string memory s) internal pure returns (uint128 result) {
/// @solidity memory-safe-assembly
assembly {
if mload(s) {
let o := add(s, 0x20)
for { let end := add(o, mload(s)) } 1 {} {
result := or(result, shl(byte(0, mload(o)), 1))
o := add(o, 1)
if iszero(lt(o, end)) { break }
}
if shr(128, result) {
mstore(0x00, 0xc9807e0d) // `StringNot7BitASCII()`.
revert(0x1c, 0x04)
}
}
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* BYTE STRING OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
// For performance and bytecode compactness, byte string operations are restricted
// to 7-bit ASCII strings. All offsets are byte offsets, not UTF character offsets.
// Usage of byte string operations on charsets with runes spanning two or more bytes
// can lead to undefined behavior.
/// @dev Returns `subject` all occurrences of `needle` replaced with `replacement`.
function replace(string memory subject, string memory needle, string memory replacement)
internal
pure
returns (string memory)
{
return string(LibBytes.replace(bytes(subject), bytes(needle), bytes(replacement)));
}
/// @dev Returns the byte index of the first location of `needle` in `subject`,
/// needleing from left to right, starting from `from`.
/// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found.
function indexOf(string memory subject, string memory needle, uint256 from)
internal
pure
returns (uint256)
{
return LibBytes.indexOf(bytes(subject), bytes(needle), from);
}
/// @dev Returns the byte index of the first location of `needle` in `subject`,
/// needleing from left to right.
/// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found.
function indexOf(string memory subject, string memory needle) internal pure returns (uint256) {
return LibBytes.indexOf(bytes(subject), bytes(needle), 0);
}
/// @dev Returns the byte index of the first location of `needle` in `subject`,
/// needleing from right to left, starting from `from`.
/// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found.
function lastIndexOf(string memory subject, string memory needle, uint256 from)
internal
pure
returns (uint256)
{
return LibBytes.lastIndexOf(bytes(subject), bytes(needle), from);
}
/// @dev Returns the byte index of the first location of `needle` in `subject`,
/// needleing from right to left.
/// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found.
function lastIndexOf(string memory subject, string memory needle)
internal
pure
returns (uint256)
{
return LibBytes.lastIndexOf(bytes(subject), bytes(needle), type(uint256).max);
}
/// @dev Returns true if `needle` is found in `subject`, false otherwise.
function contains(string memory subject, string memory needle) internal pure returns (bool) {
return LibBytes.contains(bytes(subject), bytes(needle));
}
/// @dev Returns whether `subject` starts with `needle`.
function startsWith(string memory subject, string memory needle) internal pure returns (bool) {
return LibBytes.startsWith(bytes(subject), bytes(needle));
}
/// @dev Returns whether `subject` ends with `needle`.
function endsWith(string memory subject, string memory needle) internal pure returns (bool) {
return LibBytes.endsWith(bytes(subject), bytes(needle));
}
/// @dev Returns `subject` repeated `times`.
function repeat(string memory subject, uint256 times) internal pure returns (string memory) {
return string(LibBytes.repeat(bytes(subject), times));
}
/// @dev Returns a copy of `subject` sliced from `start` to `end` (exclusive).
/// `start` and `end` are byte offsets.
function slice(string memory subject, uint256 start, uint256 end)
internal
pure
returns (string memory)
{
return string(LibBytes.slice(bytes(subject), start, end));
}
/// @dev Returns a copy of `subject` sliced from `start` to the end of the string.
/// `start` is a byte offset.
function slice(string memory subject, uint256 start) internal pure returns (string memory) {
return string(LibBytes.slice(bytes(subject), start, type(uint256).max));
}
/// @dev Returns all the indices of `needle` in `subject`.
/// The indices are byte offsets.
function indicesOf(string memory subject, string memory needle)
internal
pure
returns (uint256[] memory)
{
return LibBytes.indicesOf(bytes(subject), bytes(needle));
}
/// @dev Returns an arrays of strings based on the `delimiter` inside of the `subject` string.
function split(string memory subject, string memory delimiter)
internal
pure
returns (string[] memory result)
{
bytes[] memory a = LibBytes.split(bytes(subject), bytes(delimiter));
/// @solidity memory-safe-assembly
assembly {
result := a
}
}
/// @dev Returns a concatenated string of `a` and `b`.
/// Cheaper than `string.concat()` and does not de-align the free memory pointer.
function concat(string memory a, string memory b) internal pure returns (string memory) {
return string(LibBytes.concat(bytes(a), bytes(b)));
}
/// @dev Returns a copy of the string in either lowercase or UPPERCASE.
/// WARNING! This function is only compatible with 7-bit ASCII strings.
function toCase(string memory subject, bool toUpper)
internal
pure
returns (string memory result)
{
/// @solidity memory-safe-assembly
assembly {
let n := mload(subject)
if n {
result := mload(0x40)
let o := add(result, 0x20)
let d := sub(subject, result)
let flags := shl(add(70, shl(5, toUpper)), 0x3ffffff)
for { let end := add(o, n) } 1 {} {
let b := byte(0, mload(add(d, o)))
mstore8(o, xor(and(shr(b, flags), 0x20), b))
o := add(o, 1)
if eq(o, end) { break }
}
mstore(result, n) // Store the length.
mstore(o, 0) // Zeroize the slot after the string.
mstore(0x40, add(o, 0x20)) // Allocate memory.
}
}
}
/// @dev Returns a string from a small bytes32 string.
/// `s` must be null-terminated, or behavior will be undefined.
function fromSmallString(bytes32 s) internal pure returns (string memory result) {
/// @solidity memory-safe-assembly
assembly {
result := mload(0x40)
let n := 0
for {} byte(n, s) { n := add(n, 1) } {} // Scan for '\0'.
mstore(result, n) // Store the length.
let o := add(result, 0x20)
mstore(o, s) // Store the bytes of the string.
mstore(add(o, n), 0) // Zeroize the slot after the string.
mstore(0x40, add(result, 0x40)) // Allocate memory.
}
}
/// @dev Returns the small string, with all bytes after the first null byte zeroized.
function normalizeSmallString(bytes32 s) internal pure returns (bytes32 result) {
/// @solidity memory-safe-assembly
assembly {
for {} byte(result, s) { result := add(result, 1) } {} // Scan for '\0'.
mstore(0x00, s)
mstore(result, 0x00)
result := mload(0x00)
}
}
/// @dev Returns the string as a normalized null-terminated small string.
function toSmallString(string memory s) internal pure returns (bytes32 result) {
/// @solidity memory-safe-assembly
assembly {
result := mload(s)
if iszero(lt(result, 33)) {
mstore(0x00, 0xec92f9a3) // `TooBigForSmallString()`.
revert(0x1c, 0x04)
}
result := shl(shl(3, sub(32, result)), mload(add(s, result)))
}
}
/// @dev Returns a lowercased copy of the string.
/// WARNING! This function is only compatible with 7-bit ASCII strings.
function lower(string memory subject) internal pure returns (string memory result) {
result = toCase(subject, false);
}
/// @dev Returns an UPPERCASED copy of the string.
/// WARNING! This function is only compatible with 7-bit ASCII strings.
function upper(string memory subject) internal pure returns (string memory result) {
result = toCase(subject, true);
}
/// @dev Escapes the string to be used within HTML tags.
function escapeHTML(string memory s) internal pure returns (string memory result) {
/// @solidity memory-safe-assembly
assembly {
result := mload(0x40)
let end := add(s, mload(s))
let o := add(result, 0x20)
// Store the bytes of the packed offsets and strides into the scratch space.
// `packed = (stride << 5) | offset`. Max offset is 20. Max stride is 6.
mstore(0x1f, 0x900094)
mstore(0x08, 0xc0000000a6ab)
// Store ""&'<>" into the scratch space.
mstore(0x00, shl(64, 0x2671756f743b26616d703b262333393b266c743b2667743b))
for {} iszero(eq(s, end)) {} {
s := add(s, 1)
let c := and(mload(s), 0xff)
// Not in `["\"","'","&","<",">"]`.
if iszero(and(shl(c, 1), 0x500000c400000000)) {
mstore8(o, c)
o := add(o, 1)
continue
}
let t := shr(248, mload(c))
mstore(o, mload(and(t, 0x1f)))
o := add(o, shr(5, t))
}
mstore(o, 0) // Zeroize the slot after the string.
mstore(result, sub(o, add(result, 0x20))) // Store the length.
mstore(0x40, add(o, 0x20)) // Allocate memory.
}
}
/// @dev Escapes the string to be used within double-quotes in a JSON.
/// If `addDoubleQuotes` is true, the result will be enclosed in double-quotes.
function escapeJSON(string memory s, bool addDoubleQuotes)
internal
pure
returns (string memory result)
{
/// @solidity memory-safe-assembly
assembly {
result := mload(0x40)
let o := add(result, 0x20)
if addDoubleQuotes {
mstore8(o, 34)
o := add(1, o)
}
// Store "\\u0000" in scratch space.
// Store "0123456789abcdef" in scratch space.
// Also, store `{0x08:"b", 0x09:"t", 0x0a:"n", 0x0c:"f", 0x0d:"r"}`.
// into the scratch space.
mstore(0x15, 0x5c75303030303031323334353637383961626364656662746e006672)
// Bitmask for detecting `["\"","\\"]`.
let e := or(shl(0x22, 1), shl(0x5c, 1))
for { let end := add(s, mload(s)) } iszero(eq(s, end)) {} {
s := add(s, 1)
let c := and(mload(s), 0xff)
if iszero(lt(c, 0x20)) {
if iszero(and(shl(c, 1), e)) {
// Not in `["\"","\\"]`.
mstore8(o, c)
o := add(o, 1)
continue
}
mstore8(o, 0x5c) // "\\".
mstore8(add(o, 1), c)
o := add(o, 2)
continue
}
if iszero(and(shl(c, 1), 0x3700)) {
// Not in `["\b","\t","\n","\f","\d"]`.
mstore8(0x1d, mload(shr(4, c))) // Hex value.
mstore8(0x1e, mload(and(c, 15))) // Hex value.
mstore(o, mload(0x19)) // "\\u00XX".
o := add(o, 6)
continue
}
mstore8(o, 0x5c) // "\\".
mstore8(add(o, 1), mload(add(c, 8)))
o := add(o, 2)
}
if addDoubleQuotes {
mstore8(o, 34)
o := add(1, o)
}
mstore(o, 0) // Zeroize the slot after the string.
mstore(result, sub(o, add(result, 0x20))) // Store the length.
mstore(0x40, add(o, 0x20)) // Allocate memory.
}
}
/// @dev Escapes the string to be used within double-quotes in a JSON.
function escapeJSON(string memory s) internal pure returns (string memory result) {
result = escapeJSON(s, false);
}
/// @dev Encodes `s` so that it can be safely used in a URI,
/// just like `encodeURIComponent` in JavaScript.
/// See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
/// See: https://datatracker.ietf.org/doc/html/rfc2396
/// See: https://datatracker.ietf.org/doc/html/rfc3986
function encodeURIComponent(string memory s) internal pure returns (string memory result) {
/// @solidity memory-safe-assembly
assembly {
result := mload(0x40)
// Store "0123456789ABCDEF" in scratch space.
// Uppercased to be consistent with JavaScript's implementation.
mstore(0x0f, 0x30313233343536373839414243444546)
let o := add(result, 0x20)
for { let end := add(s, mload(s)) } iszero(eq(s, end)) {} {
s := add(s, 1)
let c := and(mload(s), 0xff)
// If not in `[0-9A-Z-a-z-_.!~*'()]`.
if iszero(and(1, shr(c, 0x47fffffe87fffffe03ff678200000000))) {
mstore8(o, 0x25) // '%'.
mstore8(add(o, 1), mload(and(shr(4, c), 15)))
mstore8(add(o, 2), mload(and(c, 15)))
o := add(o, 3)
continue
}
mstore8(o, c)
o := add(o, 1)
}
mstore(result, sub(o, add(result, 0x20))) // Store the length.
mstore(o, 0) // Zeroize the slot after the string.
mstore(0x40, add(o, 0x20)) // Allocate memory.
}
}
/// @dev Returns whether `a` equals `b`.
function eq(string memory a, string memory b) internal pure returns (bool result) {
/// @solidity memory-safe-assembly
assembly {
result := eq(keccak256(add(a, 0x20), mload(a)), keccak256(add(b, 0x20), mload(b)))
}
}
/// @dev Returns whether `a` equals `b`, where `b` is a null-terminated small string.
function eqs(string memory a, bytes32 b) internal pure returns (bool result) {
/// @solidity memory-safe-assembly
assembly {
// These should be evaluated on compile time, as far as possible.
let m := not(shl(7, div(not(iszero(b)), 255))) // `0x7f7f ...`.
let x := not(or(m, or(b, add(m, and(b, m)))))
let r := shl(7, iszero(iszero(shr(128, x))))
r := or(r, shl(6, iszero(iszero(shr(64, shr(r, x))))))
r := or(r, shl(5, lt(0xffffffff, shr(r, x))))
r := or(r, shl(4, lt(0xffff, shr(r, x))))
r := or(r, shl(3, lt(0xff, shr(r, x))))
// forgefmt: disable-next-item
result := gt(eq(mload(a), add(iszero(x), xor(31, shr(3, r)))),
xor(shr(add(8, r), b), shr(add(8, r), mload(add(a, 0x20)))))
}
}
/// @dev Returns 0 if `a == b`, -1 if `a < b`, +1 if `a > b`.
/// If `a` == b[:a.length]`, and `a.length < b.length`, returns -1.
function cmp(string memory a, string memory b) internal pure returns (int256) {
return LibBytes.cmp(bytes(a), bytes(b));
}
/// @dev Packs a single string with its length into a single word.
/// Returns `bytes32(0)` if the length is zero or greater than 31.
function packOne(string memory a) internal pure returns (bytes32 result) {
/// @solidity memory-safe-assembly
assembly {
// We don't need to zero right pad the string,
// since this is our own custom non-standard packing scheme.
result :=
mul(
// Load the length and the bytes.
mload(add(a, 0x1f)),
// `length != 0 && length < 32`. Abuses underflow.
// Assumes that the length is valid and within the block gas limit.
lt(sub(mload(a), 1), 0x1f)
)
}
}
/// @dev Unpacks a string packed using {packOne}.
/// Returns the empty string if `packed` is `bytes32(0)`.
/// If `packed` is not an output of {packOne}, the output behavior is undefined.
function unpackOne(bytes32 packed) internal pure returns (string memory result) {
/// @solidity memory-safe-assembly
assembly {
result := mload(0x40) // Grab the free memory pointer.
mstore(0x40, add(result, 0x40)) // Allocate 2 words (1 for the length, 1 for the bytes).
mstore(result, 0) // Zeroize the length slot.
mstore(add(result, 0x1f), packed) // Store the length and bytes.
mstore(add(add(result, 0x20), mload(result)), 0) // Right pad with zeroes.
}
}
/// @dev Packs two strings with their lengths into a single word.
/// Returns `bytes32(0)` if combined length is zero or greater than 30.
function packTwo(string memory a, string memory b) internal pure returns (bytes32 result) {
/// @solidity memory-safe-assembly
assembly {
let aLen := mload(a)
// We don't need to zero right pad the strings,
// since this is our own custom non-standard packing scheme.
result :=
mul(
or( // Load the length and the bytes of `a` and `b`.
shl(shl(3, sub(0x1f, aLen)), mload(add(a, aLen))), mload(sub(add(b, 0x1e), aLen))),
// `totalLen != 0 && totalLen < 31`. Abuses underflow.
// Assumes that the lengths are valid and within the block gas limit.
lt(sub(add(aLen, mload(b)), 1), 0x1e)
)
}
}
/// @dev Unpacks strings packed using {packTwo}.
/// Returns the empty strings if `packed` is `bytes32(0)`.
/// If `packed` is not an output of {packTwo}, the output behavior is undefined.
function unpackTwo(bytes32 packed)
internal
pure
returns (string memory resultA, string memory resultB)
{
/// @solidity memory-safe-assembly
assembly {
resultA := mload(0x40) // Grab the free memory pointer.
resultB := add(resultA, 0x40)
// Allocate 2 words for each string (1 for the length, 1 for the byte). Total 4 words.
mstore(0x40, add(resultB, 0x40))
// Zeroize the length slots.
mstore(resultA, 0)
mstore(resultB, 0)
// Store the lengths and bytes.
mstore(add(resultA, 0x1f), packed)
mstore(add(resultB, 0x1f), mload(add(add(resultA, 0x20), mload(resultA))))
// Right pad with zeroes.
mstore(add(add(resultA, 0x20), mload(resultA)), 0)
mstore(add(add(resultB, 0x20), mload(resultB)), 0)
}
}
/// @dev Directly returns `a` without copying.
function directReturn(string memory a) internal pure {
/// @solidity memory-safe-assembly
assembly {
// Assumes that the string does not start from the scratch space.
let retStart := sub(a, 0x20)
let retUnpaddedSize := add(mload(a), 0x40)
// Right pad with zeroes. Just in case the string is produced
// by a method that doesn't zero right pad.
mstore(add(retStart, retUnpaddedSize), 0)
mstore(retStart, 0x20) // Store the return offset.
// End the transaction, returning the string.
return(retStart, and(not(0x1f), add(0x1f, retUnpaddedSize)))
}
}
}// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Library to encode strings in Base64. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/Base64.sol) /// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/Base64.sol) /// @author Modified from (https://github.com/Brechtpd/base64/blob/main/base64.sol) by Brecht Devos - <[email protected]>. library Base64 { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ENCODING / DECODING */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Encodes `data` using the base64 encoding described in RFC 4648. /// See: https://datatracker.ietf.org/doc/html/rfc4648 /// @param fileSafe Whether to replace '+' with '-' and '/' with '_'. /// @param noPadding Whether to strip away the padding. function encode(bytes memory data, bool fileSafe, bool noPadding) internal pure returns (string memory result) { /// @solidity memory-safe-assembly assembly { let dataLength := mload(data) if dataLength { // Multiply by 4/3 rounded up. // The `shl(2, ...)` is equivalent to multiplying by 4. let encodedLength := shl(2, div(add(dataLength, 2), 3)) // Set `result` to point to the start of the free memory. result := mload(0x40) // Store the table into the scratch space. // Offsetted by -1 byte so that the `mload` will load the character. // We will rewrite the free memory pointer at `0x40` later with // the allocated size. // The magic constant 0x0670 will turn "-_" into "+/". mstore(0x1f, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef") mstore(0x3f, xor("ghijklmnopqrstuvwxyz0123456789-_", mul(iszero(fileSafe), 0x0670))) // Skip the first slot, which stores the length. let ptr := add(result, 0x20) let end := add(ptr, encodedLength) let dataEnd := add(add(0x20, data), dataLength) let dataEndValue := mload(dataEnd) // Cache the value at the `dataEnd` slot. mstore(dataEnd, 0x00) // Zeroize the `dataEnd` slot to clear dirty bits. // Run over the input, 3 bytes at a time. for {} 1 {} { data := add(data, 3) // Advance 3 bytes. let input := mload(data) // Write 4 bytes. Optimized for fewer stack operations. mstore8(0, mload(and(shr(18, input), 0x3F))) mstore8(1, mload(and(shr(12, input), 0x3F))) mstore8(2, mload(and(shr(6, input), 0x3F))) mstore8(3, mload(and(input, 0x3F))) mstore(ptr, mload(0x00)) ptr := add(ptr, 4) // Advance 4 bytes. if iszero(lt(ptr, end)) { break } } mstore(dataEnd, dataEndValue) // Restore the cached value at `dataEnd`. mstore(0x40, add(end, 0x20)) // Allocate the memory. // Equivalent to `o = [0, 2, 1][dataLength % 3]`. let o := div(2, mod(dataLength, 3)) // Offset `ptr` and pad with '='. We can simply write over the end. mstore(sub(ptr, o), shl(240, 0x3d3d)) // Set `o` to zero if there is padding. o := mul(iszero(iszero(noPadding)), o) mstore(sub(ptr, o), 0) // Zeroize the slot after the string. mstore(result, sub(encodedLength, o)) // Store the length. } } } /// @dev Encodes `data` using the base64 encoding described in RFC 4648. /// Equivalent to `encode(data, false, false)`. function encode(bytes memory data) internal pure returns (string memory result) { result = encode(data, false, false); } /// @dev Encodes `data` using the base64 encoding described in RFC 4648. /// Equivalent to `encode(data, fileSafe, false)`. function encode(bytes memory data, bool fileSafe) internal pure returns (string memory result) { result = encode(data, fileSafe, false); } /// @dev Decodes base64 encoded `data`. /// /// Supports: /// - RFC 4648 (both standard and file-safe mode). /// - RFC 3501 (63: ','). /// /// Does not support: /// - Line breaks. /// /// Note: For performance reasons, /// this function will NOT revert on invalid `data` inputs. /// Outputs for invalid inputs will simply be undefined behaviour. /// It is the user's responsibility to ensure that the `data` /// is a valid base64 encoded string. function decode(string memory data) internal pure returns (bytes memory result) { /// @solidity memory-safe-assembly assembly { let dataLength := mload(data) if dataLength { let decodedLength := mul(shr(2, dataLength), 3) for {} 1 {} { // If padded. if iszero(and(dataLength, 3)) { let t := xor(mload(add(data, dataLength)), 0x3d3d) // forgefmt: disable-next-item decodedLength := sub( decodedLength, add(iszero(byte(30, t)), iszero(byte(31, t))) ) break } // If non-padded. decodedLength := add(decodedLength, sub(and(dataLength, 3), 1)) break } result := mload(0x40) // Write the length of the bytes. mstore(result, decodedLength) // Skip the first slot, which stores the length. let ptr := add(result, 0x20) let end := add(ptr, decodedLength) // Load the table into the scratch space. // Constants are optimized for smaller bytecode with zero gas overhead. // `m` also doubles as the mask of the upper 6 bits. let m := 0xfc000000fc00686c7074787c8084888c9094989ca0a4a8acb0b4b8bcc0c4c8cc mstore(0x5b, m) mstore(0x3b, 0x04080c1014181c2024282c3034383c4044484c5054585c6064) mstore(0x1a, 0xf8fcf800fcd0d4d8dce0e4e8ecf0f4) for {} 1 {} { // Read 4 bytes. data := add(data, 4) let input := mload(data) // Write 3 bytes. // forgefmt: disable-next-item mstore(ptr, or( and(m, mload(byte(28, input))), shr(6, or( and(m, mload(byte(29, input))), shr(6, or( and(m, mload(byte(30, input))), shr(6, mload(byte(31, input))) )) )) )) ptr := add(ptr, 3) if iszero(lt(ptr, end)) { break } } mstore(0x40, add(end, 0x20)) // Allocate the memory. mstore(end, 0) // Zeroize the slot after the bytes. mstore(0x60, 0) // Restore the zero slot. } } } }
// 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 Simple ERC1155 implementation.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/tokens/ERC1155.sol)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC1155.sol)
/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/token/ERC1155/ERC1155.sol)
///
/// @dev Note:
/// - The ERC1155 standard allows for self-approvals.
/// For performance, this implementation WILL NOT revert for such actions.
/// Please add any checks with overrides if desired.
/// - The transfer functions use the identity precompile (0x4)
/// to copy memory internally.
///
/// If you are overriding:
/// - Make sure all variables written to storage are properly cleaned
// (e.g. the bool value for `isApprovedForAll` MUST be either 1 or 0 under the hood).
/// - Check that the overridden function is actually used in the function you want to
/// change the behavior of. Much of the code has been manually inlined for performance.
abstract contract ERC1155 {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CUSTOM ERRORS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The lengths of the input arrays are not the same.
error ArrayLengthsMismatch();
/// @dev Cannot mint or transfer to the zero address.
error TransferToZeroAddress();
/// @dev The recipient's balance has overflowed.
error AccountBalanceOverflow();
/// @dev Insufficient balance.
error InsufficientBalance();
/// @dev Only the token owner or an approved account can manage the tokens.
error NotOwnerNorApproved();
/// @dev Cannot safely transfer to a contract that does not implement
/// the ERC1155Receiver interface.
error TransferToNonERC1155ReceiverImplementer();
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* EVENTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Emitted when `amount` of token `id` is transferred
/// from `from` to `to` by `operator`.
event TransferSingle(
address indexed operator,
address indexed from,
address indexed to,
uint256 id,
uint256 amount
);
/// @dev Emitted when `amounts` of token `ids` are transferred
/// from `from` to `to` by `operator`.
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] amounts
);
/// @dev Emitted when `owner` enables or disables `operator` to manage all of their tokens.
event ApprovalForAll(address indexed owner, address indexed operator, bool isApproved);
/// @dev Emitted when the Uniform Resource Identifier (URI) for token `id`
/// is updated to `value`. This event is not used in the base contract.
/// You may need to emit this event depending on your URI logic.
///
/// See: https://eips.ethereum.org/EIPS/eip-1155#metadata
event URI(string value, uint256 indexed id);
/// @dev `keccak256(bytes("TransferSingle(address,address,address,uint256,uint256)"))`.
uint256 private constant _TRANSFER_SINGLE_EVENT_SIGNATURE =
0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62;
/// @dev `keccak256(bytes("TransferBatch(address,address,address,uint256[],uint256[])"))`.
uint256 private constant _TRANSFER_BATCH_EVENT_SIGNATURE =
0x4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb;
/// @dev `keccak256(bytes("ApprovalForAll(address,address,bool)"))`.
uint256 private constant _APPROVAL_FOR_ALL_EVENT_SIGNATURE =
0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* STORAGE */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The `ownerSlotSeed` of a given owner is given by.
/// ```
/// let ownerSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, owner))
/// ```
///
/// The balance slot of `owner` is given by.
/// ```
/// mstore(0x20, ownerSlotSeed)
/// mstore(0x00, id)
/// let balanceSlot := keccak256(0x00, 0x40)
/// ```
///
/// The operator approval slot of `owner` is given by.
/// ```
/// mstore(0x20, ownerSlotSeed)
/// mstore(0x00, operator)
/// let operatorApprovalSlot := keccak256(0x0c, 0x34)
/// ```
uint256 private constant _ERC1155_MASTER_SLOT_SEED = 0x9a31110384e0b0c9;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* ERC1155 METADATA */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns the URI for token `id`.
///
/// You can either return the same templated URI for all token IDs,
/// (e.g. "https://example.com/api/{id}.json"),
/// or return a unique URI for each `id`.
///
/// See: https://eips.ethereum.org/EIPS/eip-1155#metadata
function uri(uint256 id) public view virtual returns (string memory);
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* ERC1155 */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns the amount of `id` owned by `owner`.
function balanceOf(address owner, uint256 id) public view virtual returns (uint256 result) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x20, _ERC1155_MASTER_SLOT_SEED)
mstore(0x14, owner)
mstore(0x00, id)
result := sload(keccak256(0x00, 0x40))
}
}
/// @dev Returns whether `operator` is approved to manage the tokens of `owner`.
function isApprovedForAll(address owner, address operator)
public
view
virtual
returns (bool result)
{
/// @solidity memory-safe-assembly
assembly {
mstore(0x20, _ERC1155_MASTER_SLOT_SEED)
mstore(0x14, owner)
mstore(0x00, operator)
result := sload(keccak256(0x0c, 0x34))
}
}
/// @dev Sets whether `operator` is approved to manage the tokens of the caller.
///
/// Emits a {ApprovalForAll} event.
function setApprovalForAll(address operator, bool isApproved) public virtual {
/// @solidity memory-safe-assembly
assembly {
// Convert to 0 or 1.
isApproved := iszero(iszero(isApproved))
// Update the `isApproved` for (`msg.sender`, `operator`).
mstore(0x20, _ERC1155_MASTER_SLOT_SEED)
mstore(0x14, caller())
mstore(0x00, operator)
sstore(keccak256(0x0c, 0x34), isApproved)
// Emit the {ApprovalForAll} event.
mstore(0x00, isApproved)
// forgefmt: disable-next-line
log3(0x00, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, caller(), shr(96, shl(96, operator)))
}
}
/// @dev Transfers `amount` of `id` from `from` to `to`.
///
/// Requirements:
/// - `to` cannot be the zero address.
/// - `from` must have at least `amount` of `id`.
/// - If the caller is not `from`,
/// it must be approved to manage the tokens of `from`.
/// - If `to` refers to a smart contract, it must implement
/// {ERC1155-onERC1155Received}, which is called upon a batch transfer.
///
/// Emits a {TransferSingle} event.
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) public virtual {
if (_useBeforeTokenTransfer()) {
_beforeTokenTransfer(from, to, _single(id), _single(amount), data);
}
/// @solidity memory-safe-assembly
assembly {
let fromSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, from))
let toSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, to))
mstore(0x20, fromSlotSeed)
// Clear the upper 96 bits.
from := shr(96, fromSlotSeed)
to := shr(96, toSlotSeed)
// Revert if `to` is the zero address.
if iszero(to) {
mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.
revert(0x1c, 0x04)
}
// If the caller is not `from`, do the authorization check.
if iszero(eq(caller(), from)) {
mstore(0x00, caller())
if iszero(sload(keccak256(0x0c, 0x34))) {
mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.
revert(0x1c, 0x04)
}
}
// Subtract and store the updated balance of `from`.
{
mstore(0x00, id)
let fromBalanceSlot := keccak256(0x00, 0x40)
let fromBalance := sload(fromBalanceSlot)
if gt(amount, fromBalance) {
mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.
revert(0x1c, 0x04)
}
sstore(fromBalanceSlot, sub(fromBalance, amount))
}
// Increase and store the updated balance of `to`.
{
mstore(0x20, toSlotSeed)
let toBalanceSlot := keccak256(0x00, 0x40)
let toBalanceBefore := sload(toBalanceSlot)
let toBalanceAfter := add(toBalanceBefore, amount)
if lt(toBalanceAfter, toBalanceBefore) {
mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.
revert(0x1c, 0x04)
}
sstore(toBalanceSlot, toBalanceAfter)
}
// Emit a {TransferSingle} event.
mstore(0x20, amount)
log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), from, to)
}
if (_useAfterTokenTransfer()) {
_afterTokenTransfer(from, to, _single(id), _single(amount), data);
}
/// @solidity memory-safe-assembly
assembly {
// Do the {onERC1155Received} check if `to` is a smart contract.
if extcodesize(to) {
// Prepare the calldata.
let m := mload(0x40)
// `onERC1155Received(address,address,uint256,uint256,bytes)`.
mstore(m, 0xf23a6e61)
mstore(add(m, 0x20), caller())
mstore(add(m, 0x40), from)
mstore(add(m, 0x60), id)
mstore(add(m, 0x80), amount)
mstore(add(m, 0xa0), 0xa0)
mstore(add(m, 0xc0), data.length)
calldatacopy(add(m, 0xe0), data.offset, data.length)
// Revert if the call reverts.
if iszero(call(gas(), to, 0, add(m, 0x1c), add(0xc4, data.length), m, 0x20)) {
if returndatasize() {
// Bubble up the revert if the call reverts.
returndatacopy(m, 0x00, returndatasize())
revert(m, returndatasize())
}
}
// Load the returndata and compare it with the function selector.
if iszero(eq(mload(m), shl(224, 0xf23a6e61))) {
mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`.
revert(0x1c, 0x04)
}
}
}
}
/// @dev Transfers `amounts` of `ids` from `from` to `to`.
///
/// Requirements:
/// - `to` cannot be the zero address.
/// - `from` must have at least `amount` of `id`.
/// - `ids` and `amounts` must have the same length.
/// - If the caller is not `from`,
/// it must be approved to manage the tokens of `from`.
/// - If `to` refers to a smart contract, it must implement
/// {ERC1155-onERC1155BatchReceived}, which is called upon a batch transfer.
///
/// Emits a {TransferBatch} event.
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) public virtual {
if (_useBeforeTokenTransfer()) {
_beforeTokenTransfer(from, to, ids, amounts, data);
}
/// @solidity memory-safe-assembly
assembly {
if iszero(eq(ids.length, amounts.length)) {
mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.
revert(0x1c, 0x04)
}
let fromSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, from))
let toSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, to))
mstore(0x20, fromSlotSeed)
// Clear the upper 96 bits.
from := shr(96, fromSlotSeed)
to := shr(96, toSlotSeed)
// Revert if `to` is the zero address.
if iszero(to) {
mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.
revert(0x1c, 0x04)
}
// If the caller is not `from`, do the authorization check.
if iszero(eq(caller(), from)) {
mstore(0x00, caller())
if iszero(sload(keccak256(0x0c, 0x34))) {
mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.
revert(0x1c, 0x04)
}
}
// Loop through all the `ids` and update the balances.
{
for { let i := shl(5, ids.length) } i {} {
i := sub(i, 0x20)
let amount := calldataload(add(amounts.offset, i))
// Subtract and store the updated balance of `from`.
{
mstore(0x20, fromSlotSeed)
mstore(0x00, calldataload(add(ids.offset, i)))
let fromBalanceSlot := keccak256(0x00, 0x40)
let fromBalance := sload(fromBalanceSlot)
if gt(amount, fromBalance) {
mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.
revert(0x1c, 0x04)
}
sstore(fromBalanceSlot, sub(fromBalance, amount))
}
// Increase and store the updated balance of `to`.
{
mstore(0x20, toSlotSeed)
let toBalanceSlot := keccak256(0x00, 0x40)
let toBalanceBefore := sload(toBalanceSlot)
let toBalanceAfter := add(toBalanceBefore, amount)
if lt(toBalanceAfter, toBalanceBefore) {
mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.
revert(0x1c, 0x04)
}
sstore(toBalanceSlot, toBalanceAfter)
}
}
}
// Emit a {TransferBatch} event.
{
let m := mload(0x40)
// Copy the `ids`.
mstore(m, 0x40)
let n := shl(5, ids.length)
mstore(add(m, 0x40), ids.length)
calldatacopy(add(m, 0x60), ids.offset, n)
// Copy the `amounts`.
mstore(add(m, 0x20), add(0x60, n))
let o := add(add(m, n), 0x60)
mstore(o, ids.length)
calldatacopy(add(o, 0x20), amounts.offset, n)
// Do the emit.
log4(m, add(add(n, n), 0x80), _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), from, to)
}
}
if (_useAfterTokenTransfer()) {
_afterTokenTransferCalldata(from, to, ids, amounts, data);
}
/// @solidity memory-safe-assembly
assembly {
// Do the {onERC1155BatchReceived} check if `to` is a smart contract.
if extcodesize(to) {
mstore(0x00, to) // Cache `to` to prevent stack too deep.
let m := mload(0x40)
// Prepare the calldata.
// `onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)`.
mstore(m, 0xbc197c81)
mstore(add(m, 0x20), caller())
mstore(add(m, 0x40), from)
// Copy the `ids`.
mstore(add(m, 0x60), 0xa0)
let n := shl(5, ids.length)
mstore(add(m, 0xc0), ids.length)
calldatacopy(add(m, 0xe0), ids.offset, n)
// Copy the `amounts`.
mstore(add(m, 0x80), add(0xc0, n))
let o := add(add(m, n), 0xe0)
mstore(o, ids.length)
calldatacopy(add(o, 0x20), amounts.offset, n)
// Copy the `data`.
mstore(add(m, 0xa0), add(add(0xe0, n), n))
o := add(add(o, n), 0x20)
mstore(o, data.length)
calldatacopy(add(o, 0x20), data.offset, data.length)
let nAll := add(0x104, add(data.length, add(n, n)))
// Revert if the call reverts.
if iszero(call(gas(), mload(0x00), 0, add(mload(0x40), 0x1c), nAll, m, 0x20)) {
if returndatasize() {
// Bubble up the revert if the call reverts.
returndatacopy(m, 0x00, returndatasize())
revert(m, returndatasize())
}
}
// Load the returndata and compare it with the function selector.
if iszero(eq(mload(m), shl(224, 0xbc197c81))) {
mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`.
revert(0x1c, 0x04)
}
}
}
}
/// @dev Returns the amounts of `ids` for `owners.
///
/// Requirements:
/// - `owners` and `ids` must have the same length.
function balanceOfBatch(address[] calldata owners, uint256[] calldata ids)
public
view
virtual
returns (uint256[] memory balances)
{
/// @solidity memory-safe-assembly
assembly {
if iszero(eq(ids.length, owners.length)) {
mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.
revert(0x1c, 0x04)
}
balances := mload(0x40)
mstore(balances, ids.length)
let o := add(balances, 0x20)
let i := shl(5, ids.length)
mstore(0x40, add(i, o))
// Loop through all the `ids` and load the balances.
for {} i {} {
i := sub(i, 0x20)
let owner := calldataload(add(owners.offset, i))
mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, shl(96, owner)))
mstore(0x00, calldataload(add(ids.offset, i)))
mstore(add(o, i), sload(keccak256(0x00, 0x40)))
}
}
}
/// @dev Returns true if this contract implements the interface defined by `interfaceId`.
/// See: https://eips.ethereum.org/EIPS/eip-165
/// This function call must use less than 30000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool result) {
/// @solidity memory-safe-assembly
assembly {
let s := shr(224, interfaceId)
// ERC165: 0x01ffc9a7, ERC1155: 0xd9b67a26, ERC1155MetadataURI: 0x0e89341c.
result := or(or(eq(s, 0x01ffc9a7), eq(s, 0xd9b67a26)), eq(s, 0x0e89341c))
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* INTERNAL MINT FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Mints `amount` of `id` to `to`.
///
/// Requirements:
/// - `to` cannot be the zero address.
/// - If `to` refers to a smart contract, it must implement
/// {ERC1155-onERC1155Received}, which is called upon a batch transfer.
///
/// Emits a {TransferSingle} event.
function _mint(address to, uint256 id, uint256 amount, bytes memory data) internal virtual {
if (_useBeforeTokenTransfer()) {
_beforeTokenTransfer(address(0), to, _single(id), _single(amount), data);
}
/// @solidity memory-safe-assembly
assembly {
let to_ := shl(96, to)
// Revert if `to` is the zero address.
if iszero(to_) {
mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.
revert(0x1c, 0x04)
}
// Increase and store the updated balance of `to`.
{
mstore(0x20, _ERC1155_MASTER_SLOT_SEED)
mstore(0x14, to)
mstore(0x00, id)
let toBalanceSlot := keccak256(0x00, 0x40)
let toBalanceBefore := sload(toBalanceSlot)
let toBalanceAfter := add(toBalanceBefore, amount)
if lt(toBalanceAfter, toBalanceBefore) {
mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.
revert(0x1c, 0x04)
}
sstore(toBalanceSlot, toBalanceAfter)
}
// Emit a {TransferSingle} event.
mstore(0x20, amount)
log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), 0, shr(96, to_))
}
if (_useAfterTokenTransfer()) {
_afterTokenTransfer(address(0), to, _single(id), _single(amount), data);
}
if (_hasCode(to)) _checkOnERC1155Received(address(0), to, id, amount, data);
}
/// @dev Mints `amounts` of `ids` to `to`.
///
/// Requirements:
/// - `to` cannot be the zero address.
/// - `ids` and `amounts` must have the same length.
/// - If `to` refers to a smart contract, it must implement
/// {ERC1155-onERC1155BatchReceived}, which is called upon a batch transfer.
///
/// Emits a {TransferBatch} event.
function _batchMint(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
if (_useBeforeTokenTransfer()) {
_beforeTokenTransfer(address(0), to, ids, amounts, data);
}
/// @solidity memory-safe-assembly
assembly {
if iszero(eq(mload(ids), mload(amounts))) {
mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.
revert(0x1c, 0x04)
}
let to_ := shl(96, to)
// Revert if `to` is the zero address.
if iszero(to_) {
mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.
revert(0x1c, 0x04)
}
// Loop through all the `ids` and update the balances.
{
mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, to_))
for { let i := shl(5, mload(ids)) } i { i := sub(i, 0x20) } {
let amount := mload(add(amounts, i))
// Increase and store the updated balance of `to`.
{
mstore(0x00, mload(add(ids, i)))
let toBalanceSlot := keccak256(0x00, 0x40)
let toBalanceBefore := sload(toBalanceSlot)
let toBalanceAfter := add(toBalanceBefore, amount)
if lt(toBalanceAfter, toBalanceBefore) {
mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.
revert(0x1c, 0x04)
}
sstore(toBalanceSlot, toBalanceAfter)
}
}
}
// Emit a {TransferBatch} event.
{
let m := mload(0x40)
// Copy the `ids`.
mstore(m, 0x40)
let n := add(0x20, shl(5, mload(ids)))
let o := add(m, 0x40)
pop(staticcall(gas(), 4, ids, n, o, n))
// Copy the `amounts`.
mstore(add(m, 0x20), add(0x40, returndatasize()))
o := add(o, returndatasize())
n := add(0x20, shl(5, mload(amounts)))
pop(staticcall(gas(), 4, amounts, n, o, n))
n := sub(add(o, returndatasize()), m)
// Do the emit.
log4(m, n, _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), 0, shr(96, to_))
}
}
if (_useAfterTokenTransfer()) {
_afterTokenTransfer(address(0), to, ids, amounts, data);
}
if (_hasCode(to)) _checkOnERC1155BatchReceived(address(0), to, ids, amounts, data);
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* INTERNAL BURN FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Equivalent to `_burn(address(0), from, id, amount)`.
function _burn(address from, uint256 id, uint256 amount) internal virtual {
_burn(address(0), from, id, amount);
}
/// @dev Destroys `amount` of `id` from `from`.
///
/// Requirements:
/// - `from` must have at least `amount` of `id`.
/// - If `by` is not the zero address, it must be either `from`,
/// or approved to manage the tokens of `from`.
///
/// Emits a {TransferSingle} event.
function _burn(address by, address from, uint256 id, uint256 amount) internal virtual {
if (_useBeforeTokenTransfer()) {
_beforeTokenTransfer(from, address(0), _single(id), _single(amount), "");
}
/// @solidity memory-safe-assembly
assembly {
let from_ := shl(96, from)
mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, from_))
// If `by` is not the zero address, and not equal to `from`,
// check if it is approved to manage all the tokens of `from`.
if iszero(or(iszero(shl(96, by)), eq(shl(96, by), from_))) {
mstore(0x00, by)
if iszero(sload(keccak256(0x0c, 0x34))) {
mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.
revert(0x1c, 0x04)
}
}
// Decrease and store the updated balance of `from`.
{
mstore(0x00, id)
let fromBalanceSlot := keccak256(0x00, 0x40)
let fromBalance := sload(fromBalanceSlot)
if gt(amount, fromBalance) {
mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.
revert(0x1c, 0x04)
}
sstore(fromBalanceSlot, sub(fromBalance, amount))
}
// Emit a {TransferSingle} event.
mstore(0x20, amount)
log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), shr(96, from_), 0)
}
if (_useAfterTokenTransfer()) {
_afterTokenTransfer(from, address(0), _single(id), _single(amount), "");
}
}
/// @dev Equivalent to `_batchBurn(address(0), from, ids, amounts)`.
function _batchBurn(address from, uint256[] memory ids, uint256[] memory amounts)
internal
virtual
{
_batchBurn(address(0), from, ids, amounts);
}
/// @dev Destroys `amounts` of `ids` from `from`.
///
/// Requirements:
/// - `ids` and `amounts` must have the same length.
/// - `from` must have at least `amounts` of `ids`.
/// - If `by` is not the zero address, it must be either `from`,
/// or approved to manage the tokens of `from`.
///
/// Emits a {TransferBatch} event.
function _batchBurn(address by, address from, uint256[] memory ids, uint256[] memory amounts)
internal
virtual
{
if (_useBeforeTokenTransfer()) {
_beforeTokenTransfer(from, address(0), ids, amounts, "");
}
/// @solidity memory-safe-assembly
assembly {
if iszero(eq(mload(ids), mload(amounts))) {
mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.
revert(0x1c, 0x04)
}
let from_ := shl(96, from)
mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, from_))
// If `by` is not the zero address, and not equal to `from`,
// check if it is approved to manage all the tokens of `from`.
let by_ := shl(96, by)
if iszero(or(iszero(by_), eq(by_, from_))) {
mstore(0x00, by)
if iszero(sload(keccak256(0x0c, 0x34))) {
mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.
revert(0x1c, 0x04)
}
}
// Loop through all the `ids` and update the balances.
{
for { let i := shl(5, mload(ids)) } i { i := sub(i, 0x20) } {
let amount := mload(add(amounts, i))
// Decrease and store the updated balance of `from`.
{
mstore(0x00, mload(add(ids, i)))
let fromBalanceSlot := keccak256(0x00, 0x40)
let fromBalance := sload(fromBalanceSlot)
if gt(amount, fromBalance) {
mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.
revert(0x1c, 0x04)
}
sstore(fromBalanceSlot, sub(fromBalance, amount))
}
}
}
// Emit a {TransferBatch} event.
{
let m := mload(0x40)
// Copy the `ids`.
mstore(m, 0x40)
let n := add(0x20, shl(5, mload(ids)))
let o := add(m, 0x40)
pop(staticcall(gas(), 4, ids, n, o, n))
// Copy the `amounts`.
mstore(add(m, 0x20), add(0x40, returndatasize()))
o := add(o, returndatasize())
n := add(0x20, shl(5, mload(amounts)))
pop(staticcall(gas(), 4, amounts, n, o, n))
n := sub(add(o, returndatasize()), m)
// Do the emit.
log4(m, n, _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), shr(96, from_), 0)
}
}
if (_useAfterTokenTransfer()) {
_afterTokenTransfer(from, address(0), ids, amounts, "");
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* INTERNAL APPROVAL FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Approve or remove the `operator` as an operator for `by`,
/// without authorization checks.
///
/// Emits a {ApprovalForAll} event.
function _setApprovalForAll(address by, address operator, bool isApproved) internal virtual {
/// @solidity memory-safe-assembly
assembly {
// Convert to 0 or 1.
isApproved := iszero(iszero(isApproved))
// Update the `isApproved` for (`by`, `operator`).
mstore(0x20, _ERC1155_MASTER_SLOT_SEED)
mstore(0x14, by)
mstore(0x00, operator)
sstore(keccak256(0x0c, 0x34), isApproved)
// Emit the {ApprovalForAll} event.
mstore(0x00, isApproved)
let m := shr(96, not(0))
log3(0x00, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, and(m, by), and(m, operator))
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* INTERNAL TRANSFER FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Equivalent to `_safeTransfer(address(0), from, to, id, amount, data)`.
function _safeTransfer(address from, address to, uint256 id, uint256 amount, bytes memory data)
internal
virtual
{
_safeTransfer(address(0), from, to, id, amount, data);
}
/// @dev Transfers `amount` of `id` from `from` to `to`.
///
/// Requirements:
/// - `to` cannot be the zero address.
/// - `from` must have at least `amount` of `id`.
/// - If `by` is not the zero address, it must be either `from`,
/// or approved to manage the tokens of `from`.
/// - If `to` refers to a smart contract, it must implement
/// {ERC1155-onERC1155Received}, which is called upon a batch transfer.
///
/// Emits a {TransferSingle} event.
function _safeTransfer(
address by,
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
if (_useBeforeTokenTransfer()) {
_beforeTokenTransfer(from, to, _single(id), _single(amount), data);
}
/// @solidity memory-safe-assembly
assembly {
let from_ := shl(96, from)
let to_ := shl(96, to)
// Revert if `to` is the zero address.
if iszero(to_) {
mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.
revert(0x1c, 0x04)
}
mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, from_))
// If `by` is not the zero address, and not equal to `from`,
// check if it is approved to manage all the tokens of `from`.
let by_ := shl(96, by)
if iszero(or(iszero(by_), eq(by_, from_))) {
mstore(0x00, by)
if iszero(sload(keccak256(0x0c, 0x34))) {
mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.
revert(0x1c, 0x04)
}
}
// Subtract and store the updated balance of `from`.
{
mstore(0x00, id)
let fromBalanceSlot := keccak256(0x00, 0x40)
let fromBalance := sload(fromBalanceSlot)
if gt(amount, fromBalance) {
mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.
revert(0x1c, 0x04)
}
sstore(fromBalanceSlot, sub(fromBalance, amount))
}
// Increase and store the updated balance of `to`.
{
mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, to_))
let toBalanceSlot := keccak256(0x00, 0x40)
let toBalanceBefore := sload(toBalanceSlot)
let toBalanceAfter := add(toBalanceBefore, amount)
if lt(toBalanceAfter, toBalanceBefore) {
mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.
revert(0x1c, 0x04)
}
sstore(toBalanceSlot, toBalanceAfter)
}
// Emit a {TransferSingle} event.
mstore(0x20, amount)
// forgefmt: disable-next-line
log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), shr(96, from_), shr(96, to_))
}
if (_useAfterTokenTransfer()) {
_afterTokenTransfer(from, to, _single(id), _single(amount), data);
}
if (_hasCode(to)) _checkOnERC1155Received(from, to, id, amount, data);
}
/// @dev Equivalent to `_safeBatchTransfer(address(0), from, to, ids, amounts, data)`.
function _safeBatchTransfer(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
_safeBatchTransfer(address(0), from, to, ids, amounts, data);
}
/// @dev Transfers `amounts` of `ids` from `from` to `to`.
///
/// Requirements:
/// - `to` cannot be the zero address.
/// - `ids` and `amounts` must have the same length.
/// - `from` must have at least `amounts` of `ids`.
/// - If `by` is not the zero address, it must be either `from`,
/// or approved to manage the tokens of `from`.
/// - If `to` refers to a smart contract, it must implement
/// {ERC1155-onERC1155BatchReceived}, which is called upon a batch transfer.
///
/// Emits a {TransferBatch} event.
function _safeBatchTransfer(
address by,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
if (_useBeforeTokenTransfer()) {
_beforeTokenTransfer(from, to, ids, amounts, data);
}
/// @solidity memory-safe-assembly
assembly {
if iszero(eq(mload(ids), mload(amounts))) {
mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.
revert(0x1c, 0x04)
}
let from_ := shl(96, from)
let to_ := shl(96, to)
// Revert if `to` is the zero address.
if iszero(to_) {
mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.
revert(0x1c, 0x04)
}
let fromSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, from_)
let toSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, to_)
mstore(0x20, fromSlotSeed)
// If `by` is not the zero address, and not equal to `from`,
// check if it is approved to manage all the tokens of `from`.
let by_ := shl(96, by)
if iszero(or(iszero(by_), eq(by_, from_))) {
mstore(0x00, by)
if iszero(sload(keccak256(0x0c, 0x34))) {
mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.
revert(0x1c, 0x04)
}
}
// Loop through all the `ids` and update the balances.
{
for { let i := shl(5, mload(ids)) } i { i := sub(i, 0x20) } {
let amount := mload(add(amounts, i))
// Subtract and store the updated balance of `from`.
{
mstore(0x20, fromSlotSeed)
mstore(0x00, mload(add(ids, i)))
let fromBalanceSlot := keccak256(0x00, 0x40)
let fromBalance := sload(fromBalanceSlot)
if gt(amount, fromBalance) {
mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.
revert(0x1c, 0x04)
}
sstore(fromBalanceSlot, sub(fromBalance, amount))
}
// Increase and store the updated balance of `to`.
{
mstore(0x20, toSlotSeed)
let toBalanceSlot := keccak256(0x00, 0x40)
let toBalanceBefore := sload(toBalanceSlot)
let toBalanceAfter := add(toBalanceBefore, amount)
if lt(toBalanceAfter, toBalanceBefore) {
mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.
revert(0x1c, 0x04)
}
sstore(toBalanceSlot, toBalanceAfter)
}
}
}
// Emit a {TransferBatch} event.
{
let m := mload(0x40)
// Copy the `ids`.
mstore(m, 0x40)
let n := add(0x20, shl(5, mload(ids)))
let o := add(m, 0x40)
pop(staticcall(gas(), 4, ids, n, o, n))
// Copy the `amounts`.
mstore(add(m, 0x20), add(0x40, returndatasize()))
o := add(o, returndatasize())
n := add(0x20, shl(5, mload(amounts)))
pop(staticcall(gas(), 4, amounts, n, o, n))
n := sub(add(o, returndatasize()), m)
// Do the emit.
log4(m, n, _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), shr(96, from_), shr(96, to_))
}
}
if (_useAfterTokenTransfer()) {
_afterTokenTransfer(from, to, ids, amounts, data);
}
if (_hasCode(to)) _checkOnERC1155BatchReceived(from, to, ids, amounts, data);
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* HOOKS FOR OVERRIDING */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Override this function to return true if `_beforeTokenTransfer` is used.
/// This is to help the compiler avoid producing dead bytecode.
function _useBeforeTokenTransfer() internal view virtual returns (bool) {
return false;
}
/// @dev Hook that is called before any token transfer.
/// This includes minting and burning, as well as batched variants.
///
/// The same hook is called on both single and batched variants.
/// For single transfers, the length of the `id` and `amount` arrays are 1.
function _beforeTokenTransfer(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
/// @dev Override this function to return true if `_afterTokenTransfer` is used.
/// This is to help the compiler avoid producing dead bytecode.
function _useAfterTokenTransfer() internal view virtual returns (bool) {
return false;
}
/// @dev Hook that is called after any token transfer.
/// This includes minting and burning, as well as batched variants.
///
/// The same hook is called on both single and batched variants.
/// For single transfers, the length of the `id` and `amount` arrays are 1.
function _afterTokenTransfer(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* PRIVATE HELPERS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Helper for calling the `_afterTokenTransfer` hook.
/// This is to help the compiler avoid producing dead bytecode.
function _afterTokenTransferCalldata(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) private {
if (_useAfterTokenTransfer()) {
_afterTokenTransfer(from, to, ids, amounts, data);
}
}
/// @dev Returns if `a` has bytecode of non-zero length.
function _hasCode(address a) private view returns (bool result) {
/// @solidity memory-safe-assembly
assembly {
result := extcodesize(a) // Can handle dirty upper bits.
}
}
/// @dev Perform a call to invoke {IERC1155Receiver-onERC1155Received} on `to`.
/// Reverts if the target does not support the function correctly.
function _checkOnERC1155Received(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) private {
/// @solidity memory-safe-assembly
assembly {
// Prepare the calldata.
let m := mload(0x40)
// `onERC1155Received(address,address,uint256,uint256,bytes)`.
mstore(m, 0xf23a6e61)
mstore(add(m, 0x20), caller())
mstore(add(m, 0x40), shr(96, shl(96, from)))
mstore(add(m, 0x60), id)
mstore(add(m, 0x80), amount)
mstore(add(m, 0xa0), 0xa0)
let n := mload(data)
mstore(add(m, 0xc0), n)
if n { pop(staticcall(gas(), 4, add(data, 0x20), n, add(m, 0xe0), n)) }
// Revert if the call reverts.
if iszero(call(gas(), to, 0, add(m, 0x1c), add(0xc4, n), m, 0x20)) {
if returndatasize() {
// Bubble up the revert if the call reverts.
returndatacopy(m, 0x00, returndatasize())
revert(m, returndatasize())
}
}
// Load the returndata and compare it with the function selector.
if iszero(eq(mload(m), shl(224, 0xf23a6e61))) {
mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`.
revert(0x1c, 0x04)
}
}
}
/// @dev Perform a call to invoke {IERC1155Receiver-onERC1155BatchReceived} on `to`.
/// Reverts if the target does not support the function correctly.
function _checkOnERC1155BatchReceived(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) private {
/// @solidity memory-safe-assembly
assembly {
// Prepare the calldata.
let m := mload(0x40)
// `onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)`.
mstore(m, 0xbc197c81)
mstore(add(m, 0x20), caller())
mstore(add(m, 0x40), shr(96, shl(96, from)))
// Copy the `ids`.
mstore(add(m, 0x60), 0xa0)
let n := add(0x20, shl(5, mload(ids)))
let o := add(m, 0xc0)
pop(staticcall(gas(), 4, ids, n, o, n))
// Copy the `amounts`.
let s := add(0xa0, returndatasize())
mstore(add(m, 0x80), s)
o := add(o, returndatasize())
n := add(0x20, shl(5, mload(amounts)))
pop(staticcall(gas(), 4, amounts, n, o, n))
// Copy the `data`.
mstore(add(m, 0xa0), add(s, returndatasize()))
o := add(o, returndatasize())
n := add(0x20, mload(data))
pop(staticcall(gas(), 4, data, n, o, n))
n := sub(add(o, returndatasize()), add(m, 0x1c))
// Revert if the call reverts.
if iszero(call(gas(), to, 0, add(m, 0x1c), n, m, 0x20)) {
if returndatasize() {
// Bubble up the revert if the call reverts.
returndatacopy(m, 0x00, returndatasize())
revert(m, returndatasize())
}
}
// Load the returndata and compare it with the function selector.
if iszero(eq(mload(m), shl(224, 0xbc197c81))) {
mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`.
revert(0x1c, 0x04)
}
}
}
/// @dev Returns `x` in an array with a single element.
function _single(uint256 x) private pure returns (uint256[] memory result) {
/// @solidity memory-safe-assembly
assembly {
result := mload(0x40)
mstore(0x40, add(result, 0x40))
mstore(result, 1)
mstore(add(result, 0x20), x)
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/// @notice Library for byte related operations.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/LibBytes.sol)
library LibBytes {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* STRUCTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Goated bytes storage struct that totally MOGs, no cap, fr.
/// Uses less gas and bytecode than Solidity's native bytes storage. It's meta af.
/// Packs length with the first 31 bytes if <255 bytes, so it’s mad tight.
struct BytesStorage {
bytes32 _spacer;
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CONSTANTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The constant returned when the `search` is not found in the bytes.
uint256 internal constant NOT_FOUND = type(uint256).max;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* BYTE STORAGE OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Sets the value of the bytes storage `$` to `s`.
function set(BytesStorage storage $, bytes memory s) internal {
/// @solidity memory-safe-assembly
assembly {
let n := mload(s)
let packed := or(0xff, shl(8, n))
for { let i := 0 } 1 {} {
if iszero(gt(n, 0xfe)) {
i := 0x1f
packed := or(n, shl(8, mload(add(s, i))))
if iszero(gt(n, i)) { break }
}
let o := add(s, 0x20)
mstore(0x00, $.slot)
for { let p := keccak256(0x00, 0x20) } 1 {} {
sstore(add(p, shr(5, i)), mload(add(o, i)))
i := add(i, 0x20)
if iszero(lt(i, n)) { break }
}
break
}
sstore($.slot, packed)
}
}
/// @dev Sets the value of the bytes storage `$` to `s`.
function setCalldata(BytesStorage storage $, bytes calldata s) internal {
/// @solidity memory-safe-assembly
assembly {
let packed := or(0xff, shl(8, s.length))
for { let i := 0 } 1 {} {
if iszero(gt(s.length, 0xfe)) {
i := 0x1f
packed := or(s.length, shl(8, shr(8, calldataload(s.offset))))
if iszero(gt(s.length, i)) { break }
}
mstore(0x00, $.slot)
for { let p := keccak256(0x00, 0x20) } 1 {} {
sstore(add(p, shr(5, i)), calldataload(add(s.offset, i)))
i := add(i, 0x20)
if iszero(lt(i, s.length)) { break }
}
break
}
sstore($.slot, packed)
}
}
/// @dev Sets the value of the bytes storage `$` to the empty bytes.
function clear(BytesStorage storage $) internal {
delete $._spacer;
}
/// @dev Returns whether the value stored is `$` is the empty bytes "".
function isEmpty(BytesStorage storage $) internal view returns (bool) {
return uint256($._spacer) & 0xff == uint256(0);
}
/// @dev Returns the length of the value stored in `$`.
function length(BytesStorage storage $) internal view returns (uint256 result) {
result = uint256($._spacer);
/// @solidity memory-safe-assembly
assembly {
let n := and(0xff, result)
result := or(mul(shr(8, result), eq(0xff, n)), mul(n, iszero(eq(0xff, n))))
}
}
/// @dev Returns the value stored in `$`.
function get(BytesStorage storage $) internal view returns (bytes memory result) {
/// @solidity memory-safe-assembly
assembly {
result := mload(0x40)
let o := add(result, 0x20)
let packed := sload($.slot)
let n := shr(8, packed)
for { let i := 0 } 1 {} {
if iszero(eq(or(packed, 0xff), packed)) {
mstore(o, packed)
n := and(0xff, packed)
i := 0x1f
if iszero(gt(n, i)) { break }
}
mstore(0x00, $.slot)
for { let p := keccak256(0x00, 0x20) } 1 {} {
mstore(add(o, i), sload(add(p, shr(5, i))))
i := add(i, 0x20)
if iszero(lt(i, n)) { break }
}
break
}
mstore(result, n) // Store the length of the memory.
mstore(add(o, n), 0) // Zeroize the slot after the bytes.
mstore(0x40, add(add(o, n), 0x20)) // Allocate memory.
}
}
/// @dev Returns the uint8 at index `i`. If out-of-bounds, returns 0.
function uint8At(BytesStorage storage $, uint256 i) internal view returns (uint8 result) {
/// @solidity memory-safe-assembly
assembly {
for { let packed := sload($.slot) } 1 {} {
if iszero(eq(or(packed, 0xff), packed)) {
if iszero(gt(i, 0x1e)) {
result := byte(i, packed)
break
}
if iszero(gt(i, and(0xff, packed))) {
mstore(0x00, $.slot)
let j := sub(i, 0x1f)
result := byte(and(j, 0x1f), sload(add(keccak256(0x00, 0x20), shr(5, j))))
}
break
}
if iszero(gt(i, shr(8, packed))) {
mstore(0x00, $.slot)
result := byte(and(i, 0x1f), sload(add(keccak256(0x00, 0x20), shr(5, i))))
}
break
}
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* BYTES OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns `subject` all occurrences of `needle` replaced with `replacement`.
function replace(bytes memory subject, bytes memory needle, bytes memory replacement)
internal
pure
returns (bytes memory result)
{
/// @solidity memory-safe-assembly
assembly {
result := mload(0x40)
let needleLen := mload(needle)
let replacementLen := mload(replacement)
let d := sub(result, subject) // Memory difference.
let i := add(subject, 0x20) // Subject bytes pointer.
mstore(0x00, add(i, mload(subject))) // End of subject.
if iszero(gt(needleLen, mload(subject))) {
let subjectSearchEnd := add(sub(mload(0x00), needleLen), 1)
let h := 0 // The hash of `needle`.
if iszero(lt(needleLen, 0x20)) { h := keccak256(add(needle, 0x20), needleLen) }
let s := mload(add(needle, 0x20))
for { let m := shl(3, sub(0x20, and(needleLen, 0x1f))) } 1 {} {
let t := mload(i)
// Whether the first `needleLen % 32` bytes of `subject` and `needle` matches.
if iszero(shr(m, xor(t, s))) {
if h {
if iszero(eq(keccak256(i, needleLen), h)) {
mstore(add(i, d), t)
i := add(i, 1)
if iszero(lt(i, subjectSearchEnd)) { break }
continue
}
}
// Copy the `replacement` one word at a time.
for { let j := 0 } 1 {} {
mstore(add(add(i, d), j), mload(add(add(replacement, 0x20), j)))
j := add(j, 0x20)
if iszero(lt(j, replacementLen)) { break }
}
d := sub(add(d, replacementLen), needleLen)
if needleLen {
i := add(i, needleLen)
if iszero(lt(i, subjectSearchEnd)) { break }
continue
}
}
mstore(add(i, d), t)
i := add(i, 1)
if iszero(lt(i, subjectSearchEnd)) { break }
}
}
let end := mload(0x00)
let n := add(sub(d, add(result, 0x20)), end)
// Copy the rest of the bytes one word at a time.
for {} lt(i, end) { i := add(i, 0x20) } { mstore(add(i, d), mload(i)) }
let o := add(i, d)
mstore(o, 0) // Zeroize the slot after the bytes.
mstore(0x40, add(o, 0x20)) // Allocate memory.
mstore(result, n) // Store the length.
}
}
/// @dev Returns the byte index of the first location of `needle` in `subject`,
/// needleing from left to right, starting from `from`.
/// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found.
function indexOf(bytes memory subject, bytes memory needle, uint256 from)
internal
pure
returns (uint256 result)
{
/// @solidity memory-safe-assembly
assembly {
result := not(0) // Initialize to `NOT_FOUND`.
for { let subjectLen := mload(subject) } 1 {} {
if iszero(mload(needle)) {
result := from
if iszero(gt(from, subjectLen)) { break }
result := subjectLen
break
}
let needleLen := mload(needle)
let subjectStart := add(subject, 0x20)
subject := add(subjectStart, from)
let end := add(sub(add(subjectStart, subjectLen), needleLen), 1)
let m := shl(3, sub(0x20, and(needleLen, 0x1f)))
let s := mload(add(needle, 0x20))
if iszero(and(lt(subject, end), lt(from, subjectLen))) { break }
if iszero(lt(needleLen, 0x20)) {
for { let h := keccak256(add(needle, 0x20), needleLen) } 1 {} {
if iszero(shr(m, xor(mload(subject), s))) {
if eq(keccak256(subject, needleLen), h) {
result := sub(subject, subjectStart)
break
}
}
subject := add(subject, 1)
if iszero(lt(subject, end)) { break }
}
break
}
for {} 1 {} {
if iszero(shr(m, xor(mload(subject), s))) {
result := sub(subject, subjectStart)
break
}
subject := add(subject, 1)
if iszero(lt(subject, end)) { break }
}
break
}
}
}
/// @dev Returns the byte index of the first location of `needle` in `subject`,
/// needleing from left to right, starting from `from`. Optimized for byte needles.
/// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found.
function indexOfByte(bytes memory subject, bytes1 needle, uint256 from)
internal
pure
returns (uint256 result)
{
/// @solidity memory-safe-assembly
assembly {
result := not(0) // Initialize to `NOT_FOUND`.
if gt(mload(subject), from) {
let start := add(subject, 0x20)
let end := add(start, mload(subject))
let m := div(not(0), 255) // `0x0101 ... `.
let h := mul(byte(0, needle), m) // Replicating needle mask.
m := not(shl(7, m)) // `0x7f7f ... `.
for { let i := add(start, from) } 1 {} {
let c := xor(mload(i), h) // Load 32-byte chunk and xor with mask.
c := not(or(or(add(and(c, m), m), c), m)) // Each needle byte will be `0x80`.
if c {
c := and(not(shr(shl(3, sub(end, i)), not(0))), c) // Truncate bytes past the end.
if c {
let r := shl(7, lt(0x8421084210842108cc6318c6db6d54be, c)) // Save bytecode.
r := or(shl(6, lt(0xffffffffffffffff, shr(r, c))), r)
// forgefmt: disable-next-item
result := add(sub(i, start), shr(3, xor(byte(and(0x1f, shr(byte(24,
mul(0x02040810204081, shr(r, c))), 0x8421084210842108cc6318c6db6d54be)),
0xc0c8c8d0c8e8d0d8c8e8e0e8d0d8e0f0c8d0e8d0e0e0d8f0d0d0e0d8f8f8f8f8), r)))
break
}
}
i := add(i, 0x20)
if iszero(lt(i, end)) { break }
}
}
}
}
/// @dev Returns the byte index of the first location of `needle` in `subject`,
/// needleing from left to right. Optimized for byte needles.
/// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found.
function indexOfByte(bytes memory subject, bytes1 needle)
internal
pure
returns (uint256 result)
{
return indexOfByte(subject, needle, 0);
}
/// @dev Returns the byte index of the first location of `needle` in `subject`,
/// needleing from left to right.
/// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found.
function indexOf(bytes memory subject, bytes memory needle) internal pure returns (uint256) {
return indexOf(subject, needle, 0);
}
/// @dev Returns the byte index of the first location of `needle` in `subject`,
/// needleing from right to left, starting from `from`.
/// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found.
function lastIndexOf(bytes memory subject, bytes memory needle, uint256 from)
internal
pure
returns (uint256 result)
{
/// @solidity memory-safe-assembly
assembly {
for {} 1 {} {
result := not(0) // Initialize to `NOT_FOUND`.
let needleLen := mload(needle)
if gt(needleLen, mload(subject)) { break }
let w := result
let fromMax := sub(mload(subject), needleLen)
if iszero(gt(fromMax, from)) { from := fromMax }
let end := add(add(subject, 0x20), w)
subject := add(add(subject, 0x20), from)
if iszero(gt(subject, end)) { break }
// As this function is not too often used,
// we shall simply use keccak256 for smaller bytecode size.
for { let h := keccak256(add(needle, 0x20), needleLen) } 1 {} {
if eq(keccak256(subject, needleLen), h) {
result := sub(subject, add(end, 1))
break
}
subject := add(subject, w) // `sub(subject, 1)`.
if iszero(gt(subject, end)) { break }
}
break
}
}
}
/// @dev Returns the byte index of the first location of `needle` in `subject`,
/// needleing from right to left.
/// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found.
function lastIndexOf(bytes memory subject, bytes memory needle)
internal
pure
returns (uint256)
{
return lastIndexOf(subject, needle, type(uint256).max);
}
/// @dev Returns true if `needle` is found in `subject`, false otherwise.
function contains(bytes memory subject, bytes memory needle) internal pure returns (bool) {
return indexOf(subject, needle) != NOT_FOUND;
}
/// @dev Returns whether `subject` starts with `needle`.
function startsWith(bytes memory subject, bytes memory needle)
internal
pure
returns (bool result)
{
/// @solidity memory-safe-assembly
assembly {
let n := mload(needle)
// Just using keccak256 directly is actually cheaper.
let t := eq(keccak256(add(subject, 0x20), n), keccak256(add(needle, 0x20), n))
result := lt(gt(n, mload(subject)), t)
}
}
/// @dev Returns whether `subject` ends with `needle`.
function endsWith(bytes memory subject, bytes memory needle)
internal
pure
returns (bool result)
{
/// @solidity memory-safe-assembly
assembly {
let n := mload(needle)
let notInRange := gt(n, mload(subject))
// `subject + 0x20 + max(subject.length - needle.length, 0)`.
let t := add(add(subject, 0x20), mul(iszero(notInRange), sub(mload(subject), n)))
// Just using keccak256 directly is actually cheaper.
result := gt(eq(keccak256(t, n), keccak256(add(needle, 0x20), n)), notInRange)
}
}
/// @dev Returns `subject` repeated `times`.
function repeat(bytes memory subject, uint256 times)
internal
pure
returns (bytes memory result)
{
/// @solidity memory-safe-assembly
assembly {
let l := mload(subject) // Subject length.
if iszero(or(iszero(times), iszero(l))) {
result := mload(0x40)
subject := add(subject, 0x20)
let o := add(result, 0x20)
for {} 1 {} {
// Copy the `subject` one word at a time.
for { let j := 0 } 1 {} {
mstore(add(o, j), mload(add(subject, j)))
j := add(j, 0x20)
if iszero(lt(j, l)) { break }
}
o := add(o, l)
times := sub(times, 1)
if iszero(times) { break }
}
mstore(o, 0) // Zeroize the slot after the bytes.
mstore(0x40, add(o, 0x20)) // Allocate memory.
mstore(result, sub(o, add(result, 0x20))) // Store the length.
}
}
}
/// @dev Returns a copy of `subject` sliced from `start` to `end` (exclusive).
/// `start` and `end` are byte offsets.
function slice(bytes memory subject, uint256 start, uint256 end)
internal
pure
returns (bytes memory result)
{
/// @solidity memory-safe-assembly
assembly {
let l := mload(subject) // Subject length.
if iszero(gt(l, end)) { end := l }
if iszero(gt(l, start)) { start := l }
if lt(start, end) {
result := mload(0x40)
let n := sub(end, start)
let i := add(subject, start)
let w := not(0x1f)
// Copy the `subject` one word at a time, backwards.
for { let j := and(add(n, 0x1f), w) } 1 {} {
mstore(add(result, j), mload(add(i, j)))
j := add(j, w) // `sub(j, 0x20)`.
if iszero(j) { break }
}
let o := add(add(result, 0x20), n)
mstore(o, 0) // Zeroize the slot after the bytes.
mstore(0x40, add(o, 0x20)) // Allocate memory.
mstore(result, n) // Store the length.
}
}
}
/// @dev Returns a copy of `subject` sliced from `start` to the end of the bytes.
/// `start` is a byte offset.
function slice(bytes memory subject, uint256 start)
internal
pure
returns (bytes memory result)
{
result = slice(subject, start, type(uint256).max);
}
/// @dev Returns a copy of `subject` sliced from `start` to `end` (exclusive).
/// `start` and `end` are byte offsets. Faster than Solidity's native slicing.
function sliceCalldata(bytes calldata subject, uint256 start, uint256 end)
internal
pure
returns (bytes calldata result)
{
/// @solidity memory-safe-assembly
assembly {
end := xor(end, mul(xor(end, subject.length), lt(subject.length, end)))
start := xor(start, mul(xor(start, subject.length), lt(subject.length, start)))
result.offset := add(subject.offset, start)
result.length := mul(lt(start, end), sub(end, start))
}
}
/// @dev Returns a copy of `subject` sliced from `start` to the end of the bytes.
/// `start` is a byte offset. Faster than Solidity's native slicing.
function sliceCalldata(bytes calldata subject, uint256 start)
internal
pure
returns (bytes calldata result)
{
/// @solidity memory-safe-assembly
assembly {
start := xor(start, mul(xor(start, subject.length), lt(subject.length, start)))
result.offset := add(subject.offset, start)
result.length := mul(lt(start, subject.length), sub(subject.length, start))
}
}
/// @dev Reduces the size of `subject` to `n`.
/// If `n` is greater than the size of `subject`, this will be a no-op.
function truncate(bytes memory subject, uint256 n)
internal
pure
returns (bytes memory result)
{
/// @solidity memory-safe-assembly
assembly {
result := subject
mstore(mul(lt(n, mload(result)), result), n)
}
}
/// @dev Returns a copy of `subject`, with the length reduced to `n`.
/// If `n` is greater than the size of `subject`, this will be a no-op.
function truncatedCalldata(bytes calldata subject, uint256 n)
internal
pure
returns (bytes calldata result)
{
/// @solidity memory-safe-assembly
assembly {
result.offset := subject.offset
result.length := xor(n, mul(xor(n, subject.length), lt(subject.length, n)))
}
}
/// @dev Returns all the indices of `needle` in `subject`.
/// The indices are byte offsets.
function indicesOf(bytes memory subject, bytes memory needle)
internal
pure
returns (uint256[] memory result)
{
/// @solidity memory-safe-assembly
assembly {
let searchLen := mload(needle)
if iszero(gt(searchLen, mload(subject))) {
result := mload(0x40)
let i := add(subject, 0x20)
let o := add(result, 0x20)
let subjectSearchEnd := add(sub(add(i, mload(subject)), searchLen), 1)
let h := 0 // The hash of `needle`.
if iszero(lt(searchLen, 0x20)) { h := keccak256(add(needle, 0x20), searchLen) }
let s := mload(add(needle, 0x20))
for { let m := shl(3, sub(0x20, and(searchLen, 0x1f))) } 1 {} {
let t := mload(i)
// Whether the first `searchLen % 32` bytes of `subject` and `needle` matches.
if iszero(shr(m, xor(t, s))) {
if h {
if iszero(eq(keccak256(i, searchLen), h)) {
i := add(i, 1)
if iszero(lt(i, subjectSearchEnd)) { break }
continue
}
}
mstore(o, sub(i, add(subject, 0x20))) // Append to `result`.
o := add(o, 0x20)
i := add(i, searchLen) // Advance `i` by `searchLen`.
if searchLen {
if iszero(lt(i, subjectSearchEnd)) { break }
continue
}
}
i := add(i, 1)
if iszero(lt(i, subjectSearchEnd)) { break }
}
mstore(result, shr(5, sub(o, add(result, 0x20)))) // Store the length of `result`.
// Allocate memory for result.
// We allocate one more word, so this array can be recycled for {split}.
mstore(0x40, add(o, 0x20))
}
}
}
/// @dev Returns an arrays of bytess based on the `delimiter` inside of the `subject` bytes.
function split(bytes memory subject, bytes memory delimiter)
internal
pure
returns (bytes[] memory result)
{
uint256[] memory indices = indicesOf(subject, delimiter);
/// @solidity memory-safe-assembly
assembly {
let w := not(0x1f)
let indexPtr := add(indices, 0x20)
let indicesEnd := add(indexPtr, shl(5, add(mload(indices), 1)))
mstore(add(indicesEnd, w), mload(subject))
mstore(indices, add(mload(indices), 1))
for { let prevIndex := 0 } 1 {} {
let index := mload(indexPtr)
mstore(indexPtr, 0x60)
if iszero(eq(index, prevIndex)) {
let element := mload(0x40)
let l := sub(index, prevIndex)
mstore(element, l) // Store the length of the element.
// Copy the `subject` one word at a time, backwards.
for { let o := and(add(l, 0x1f), w) } 1 {} {
mstore(add(element, o), mload(add(add(subject, prevIndex), o)))
o := add(o, w) // `sub(o, 0x20)`.
if iszero(o) { break }
}
mstore(add(add(element, 0x20), l), 0) // Zeroize the slot after the bytes.
// Allocate memory for the length and the bytes, rounded up to a multiple of 32.
mstore(0x40, add(element, and(add(l, 0x3f), w)))
mstore(indexPtr, element) // Store the `element` into the array.
}
prevIndex := add(index, mload(delimiter))
indexPtr := add(indexPtr, 0x20)
if iszero(lt(indexPtr, indicesEnd)) { break }
}
result := indices
if iszero(mload(delimiter)) {
result := add(indices, 0x20)
mstore(result, sub(mload(indices), 2))
}
}
}
/// @dev Returns a concatenated bytes of `a` and `b`.
/// Cheaper than `bytes.concat()` and does not de-align the free memory pointer.
function concat(bytes memory a, bytes memory b) internal pure returns (bytes memory result) {
/// @solidity memory-safe-assembly
assembly {
result := mload(0x40)
let w := not(0x1f)
let aLen := mload(a)
// Copy `a` one word at a time, backwards.
for { let o := and(add(aLen, 0x20), w) } 1 {} {
mstore(add(result, o), mload(add(a, o)))
o := add(o, w) // `sub(o, 0x20)`.
if iszero(o) { break }
}
let bLen := mload(b)
let output := add(result, aLen)
// Copy `b` one word at a time, backwards.
for { let o := and(add(bLen, 0x20), w) } 1 {} {
mstore(add(output, o), mload(add(b, o)))
o := add(o, w) // `sub(o, 0x20)`.
if iszero(o) { break }
}
let totalLen := add(aLen, bLen)
let last := add(add(result, 0x20), totalLen)
mstore(last, 0) // Zeroize the slot after the bytes.
mstore(result, totalLen) // Store the length.
mstore(0x40, add(last, 0x20)) // Allocate memory.
}
}
/// @dev Returns whether `a` equals `b`.
function eq(bytes memory a, bytes memory b) internal pure returns (bool result) {
/// @solidity memory-safe-assembly
assembly {
result := eq(keccak256(add(a, 0x20), mload(a)), keccak256(add(b, 0x20), mload(b)))
}
}
/// @dev Returns whether `a` equals `b`, where `b` is a null-terminated small bytes.
function eqs(bytes memory a, bytes32 b) internal pure returns (bool result) {
/// @solidity memory-safe-assembly
assembly {
// These should be evaluated on compile time, as far as possible.
let m := not(shl(7, div(not(iszero(b)), 255))) // `0x7f7f ...`.
let x := not(or(m, or(b, add(m, and(b, m)))))
let r := shl(7, iszero(iszero(shr(128, x))))
r := or(r, shl(6, iszero(iszero(shr(64, shr(r, x))))))
r := or(r, shl(5, lt(0xffffffff, shr(r, x))))
r := or(r, shl(4, lt(0xffff, shr(r, x))))
r := or(r, shl(3, lt(0xff, shr(r, x))))
// forgefmt: disable-next-item
result := gt(eq(mload(a), add(iszero(x), xor(31, shr(3, r)))),
xor(shr(add(8, r), b), shr(add(8, r), mload(add(a, 0x20)))))
}
}
/// @dev Returns 0 if `a == b`, -1 if `a < b`, +1 if `a > b`.
/// If `a` == b[:a.length]`, and `a.length < b.length`, returns -1.
function cmp(bytes memory a, bytes memory b) internal pure returns (int256 result) {
/// @solidity memory-safe-assembly
assembly {
let aLen := mload(a)
let bLen := mload(b)
let n := and(xor(aLen, mul(xor(aLen, bLen), lt(bLen, aLen))), not(0x1f))
if n {
for { let i := 0x20 } 1 {} {
let x := mload(add(a, i))
let y := mload(add(b, i))
if iszero(or(xor(x, y), eq(i, n))) {
i := add(i, 0x20)
continue
}
result := sub(gt(x, y), lt(x, y))
break
}
}
// forgefmt: disable-next-item
if iszero(result) {
let l := 0x201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a090807060504030201
let x := and(mload(add(add(a, 0x20), n)), shl(shl(3, byte(sub(aLen, n), l)), not(0)))
let y := and(mload(add(add(b, 0x20), n)), shl(shl(3, byte(sub(bLen, n), l)), not(0)))
result := sub(gt(x, y), lt(x, y))
if iszero(result) { result := sub(gt(aLen, bLen), lt(aLen, bLen)) }
}
}
}
/// @dev Directly returns `a` without copying.
function directReturn(bytes memory a) internal pure {
/// @solidity memory-safe-assembly
assembly {
// Assumes that the bytes does not start from the scratch space.
let retStart := sub(a, 0x20)
let retUnpaddedSize := add(mload(a), 0x40)
// Right pad with zeroes. Just in case the bytes is produced
// by a method that doesn't zero right pad.
mstore(add(retStart, retUnpaddedSize), 0)
mstore(retStart, 0x20) // Store the return offset.
// End the transaction, returning the bytes.
return(retStart, and(not(0x1f), add(0x1f, retUnpaddedSize)))
}
}
/// @dev Directly returns `a` with minimal copying.
function directReturn(bytes[] memory a) internal pure {
/// @solidity memory-safe-assembly
assembly {
let n := mload(a) // `a.length`.
let o := add(a, 0x20) // Start of elements in `a`.
let u := a // Highest memory slot.
let w := not(0x1f)
for { let i := 0 } iszero(eq(i, n)) { i := add(i, 1) } {
let c := add(o, shl(5, i)) // Location of pointer to `a[i]`.
let s := mload(c) // `a[i]`.
let l := mload(s) // `a[i].length`.
let r := and(l, 0x1f) // `a[i].length % 32`.
let z := add(0x20, and(l, w)) // Offset of last word in `a[i]` from `s`.
// If `s` comes before `o`, or `s` is not zero right padded.
if iszero(lt(lt(s, o), or(iszero(r), iszero(shl(shl(3, r), mload(add(s, z))))))) {
let m := mload(0x40)
mstore(m, l) // Copy `a[i].length`.
for {} 1 {} {
mstore(add(m, z), mload(add(s, z))) // Copy `a[i]`, backwards.
z := add(z, w) // `sub(z, 0x20)`.
if iszero(z) { break }
}
let e := add(add(m, 0x20), l)
mstore(e, 0) // Zeroize the slot after the copied bytes.
mstore(0x40, add(e, 0x20)) // Allocate memory.
s := m
}
mstore(c, sub(s, o)) // Convert to calldata offset.
let t := add(l, add(s, 0x20))
if iszero(lt(t, u)) { u := t }
}
let retStart := add(a, w) // Assumes `a` doesn't start from scratch space.
mstore(retStart, 0x20) // Store the return offset.
return(retStart, add(0x40, sub(u, retStart))) // End the transaction.
}
}
/// @dev Returns the word at `offset`, without any bounds checks.
function load(bytes memory a, uint256 offset) internal pure returns (bytes32 result) {
/// @solidity memory-safe-assembly
assembly {
result := mload(add(add(a, 0x20), offset))
}
}
/// @dev Returns the word at `offset`, without any bounds checks.
function loadCalldata(bytes calldata a, uint256 offset)
internal
pure
returns (bytes32 result)
{
/// @solidity memory-safe-assembly
assembly {
result := calldataload(add(a.offset, offset))
}
}
/// @dev Returns a slice representing a static struct in the calldata. Performs bounds checks.
function staticStructInCalldata(bytes calldata a, uint256 offset)
internal
pure
returns (bytes calldata result)
{
/// @solidity memory-safe-assembly
assembly {
let l := sub(a.length, 0x20)
result.offset := add(a.offset, offset)
result.length := sub(a.length, offset)
if or(shr(64, or(l, a.offset)), gt(offset, l)) { revert(l, 0x00) }
}
}
/// @dev Returns a slice representing a dynamic struct in the calldata. Performs bounds checks.
function dynamicStructInCalldata(bytes calldata a, uint256 offset)
internal
pure
returns (bytes calldata result)
{
/// @solidity memory-safe-assembly
assembly {
let l := sub(a.length, 0x20)
let s := calldataload(add(a.offset, offset)) // Relative offset of `result` from `a.offset`.
result.offset := add(a.offset, s)
result.length := sub(a.length, s)
if or(shr(64, or(s, or(l, a.offset))), gt(offset, l)) { revert(l, 0x00) }
}
}
/// @dev Returns bytes in calldata. Performs bounds checks.
function bytesInCalldata(bytes calldata a, uint256 offset)
internal
pure
returns (bytes calldata result)
{
/// @solidity memory-safe-assembly
assembly {
let l := sub(a.length, 0x20)
let s := calldataload(add(a.offset, offset)) // Relative offset of `result` from `a.offset`.
result.offset := add(add(a.offset, s), 0x20)
result.length := calldataload(add(a.offset, s))
// forgefmt: disable-next-item
if or(shr(64, or(result.length, or(s, or(l, a.offset)))),
or(gt(add(s, result.length), l), gt(offset, l))) { revert(l, 0x00) }
}
}
/// @dev Checks if `x` is in `a`. Assumes `a` has been checked.
function checkInCalldata(bytes calldata x, bytes calldata a) internal pure {
/// @solidity memory-safe-assembly
assembly {
if or(
or(lt(x.offset, a.offset), gt(add(x.offset, x.length), add(a.length, a.offset))),
shr(64, or(x.length, x.offset))
) { revert(0x00, 0x00) }
}
}
/// @dev Checks if `x` is in `a`. Assumes `a` has been checked.
function checkInCalldata(bytes[] calldata x, bytes calldata a) internal pure {
/// @solidity memory-safe-assembly
assembly {
let e := sub(add(a.length, a.offset), 0x20)
if or(lt(x.offset, a.offset), shr(64, x.offset)) { revert(0x00, 0x00) }
for { let i := 0 } iszero(eq(x.length, i)) { i := add(i, 1) } {
let o := calldataload(add(x.offset, shl(5, i)))
let t := add(o, x.offset)
let l := calldataload(t)
if or(shr(64, or(l, o)), gt(add(t, l), e)) { revert(0x00, 0x00) }
}
}
}
/// @dev Returns empty calldata bytes. For silencing the compiler.
function emptyCalldata() internal pure returns (bytes calldata result) {
/// @solidity memory-safe-assembly
assembly {
result.length := 0
}
}
/// @dev Returns the most significant 20 bytes as an address.
function msbToAddress(bytes32 x) internal pure returns (address) {
return address(bytes20(x));
}
/// @dev Returns the least significant 20 bytes as an address.
function lsbToAddress(bytes32 x) internal pure returns (address) {
return address(uint160(uint256(x)));
}
}{
"optimizer": {
"enabled": true,
"runs": 20000
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"abi"
]
}
},
"remappings": [],
"evmVersion": "shanghai"
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccountBalanceOverflow","type":"error"},{"inputs":[],"name":"AlreadyInitialized","type":"error"},{"inputs":[],"name":"ArrayLengthsMismatch","type":"error"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"NewOwnerIsZeroAddress","type":"error"},{"inputs":[],"name":"NoHandoverRequest","type":"error"},{"inputs":[],"name":"NotOwnerNorApproved","type":"error"},{"inputs":[],"name":"TransferToNonERC1155ReceiverImplementer","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"isApproved","type":"bool"}],"name":"ApprovalForAll","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"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":true,"internalType":"address","name":"participant","type":"address"},{"indexed":true,"internalType":"bool","name":"yes","type":"bool"}],"name":"Predict","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":true,"internalType":"bool","name":"yes","type":"bool"},{"components":[{"internalType":"uint256","name":"yes","type":"uint256"},{"internalType":"uint256","name":"no","type":"uint256"},{"internalType":"uint256","name":"revealAt","type":"uint256"},{"internalType":"uint256","name":"winner","type":"uint256"}],"indexed":false,"internalType":"struct TruthOracle.PredictionData","name":"outcome","type":"tuple"}],"name":"Reveal","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"enum TruthOracle.Status","name":"newStatus","type":"uint8"}],"name":"StatusChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oracle","type":"address"}],"name":"TruthOracleSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"inputs":[{"internalType":"address","name":"winner","type":"address"}],"name":"airdropWin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"allPredictions","outputs":[{"components":[{"internalType":"uint256","name":"yes","type":"uint256"},{"internalType":"uint256","name":"no","type":"uint256"},{"internalType":"uint256","name":"revealAt","type":"uint256"},{"internalType":"uint256","name":"winner","type":"uint256"}],"internalType":"struct TruthOracle.PredictionData[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"owners","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"balances","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"claimWin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"pendingOwner","type":"address"}],"name":"completeOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"result","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"participant","type":"address"}],"name":"lastPredictedAt","outputs":[{"internalType":"uint256","name":"predictedAt","type":"uint256"}],"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":[{"internalType":"bool","name":"yes","type":"bool"}],"name":"predict","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"predictions","outputs":[{"internalType":"uint256","name":"yes","type":"uint256"},{"internalType":"uint256","name":"no","type":"uint256"},{"internalType":"uint256","name":"revealAt","type":"uint256"},{"internalType":"uint256","name":"winner","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"requestOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"reveal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revealAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"revealInterval","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"isApproved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum TruthOracle.Status","name":"_status","type":"uint8"}],"name":"setStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_truthOracle","type":"address"}],"name":"setTruthOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"status","outputs":[{"internalType":"enum TruthOracle.Status","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"result","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"supply","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60a06040527f377557566a79046f27a58745001ee9dde3518274254e2956de88d2a8642790a86002557f5ab89a51e76131ef400eb20602e949c7c55b4abf224a53519d11e154ee254afe60035562049d4060805234801561005e575f5ffd5b5061006833610094565b610072335f6100cf565b61007d3360016100cf565b335f9081526005602052604090206001905561025f565b6001600160a01b0316638b78c6d819819055805f7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b6100db82826001610145565b5f8181526001602052604081208054916100f4836101d8565b9091555050604080518281526001602082015230915f916001600160a01b038616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a45050565b5f826001146101565760035461015a565b6002545b90505f8360011461018557604051806040016040528060028152602001614e4f60f01b8152506101a2565b6040518060400160405280600381526020016259455360e81b8152505b85836040516020016101b6939291906101fc565b6040516020818303038152906040528051906020012090508281555050505050565b5f600182016101f557634e487b7160e01b5f52601160045260245ffd5b5060010190565b606081525f84518060608401525f5b81811015610228576020818801810151608086840101520161020b565b505f60808285018101919091526001600160a01b03959095166020840152604083019390935250601f909101601f19160101919050565b60805161349c6102855f395f818161036e015281816111880152611d85015261349c5ff3fe6080604052600436106101c3575f3560e01c8063715018a6116100f2578063b5ffd81711610092578063f04e283e11610062578063f04e283e146105d6578063f242432a146105e9578063f2fde38b14610608578063fee81cf41461061b575f5ffd5b8063b5ffd8171461054b578063bd85b0391461055f578063cb30fd921461058a578063e985e9c51461059f575f5ffd5b806395d89b41116100cd57806395d89b41146104b1578063a22cb465146104f9578063a475b5dd14610518578063ac852eb51461052c575f5ffd5b8063715018a6146104355780638da5cb5b1461043d5780638fb75bd614610490575f5ffd5b8063200d2ed2116101685780632e49d78b116101385780632e49d78b146103c35780632eb2c2d6146103e25780634e1273f41461040157806354d1f13d1461042d575f5ffd5b8063200d2ed214610338578063247cd8ad1461035d57806325692962146103905780632d55e80d14610398575f5ffd5b806306fdde03116101a357806306fdde03146102845780630a990f54146102d95780630e89341c146102fa57806315fa56bc14610319575f5ffd5b80624fbbb0146101c7578062fdd58e1461020b57806301ffc9a714610238575b5f5ffd5b3480156101d2575f5ffd5b506101e66101e13660046124a6565b61064c565b6040805194855260208501939093529183015260608201526080015b60405180910390f35b348015610216575f5ffd5b5061022a6102253660046124e5565b610684565b604051908152602001610202565b348015610243575f5ffd5b5061027461025236600461250d565b6301ffc9a760e09190911c90811463d9b67a26821417630e89341c9091141790565b6040519015158152602001610202565b34801561028f575f5ffd5b506102cc6040518060400160405280600c81526020017f5472757468204f7261636c65000000000000000000000000000000000000000081525081565b60405161020291906125be565b3480156102e4575f5ffd5b506102f86102f33660046125df565b610764565b005b348015610305575f5ffd5b506102cc6103143660046124a6565b610a19565b348015610324575f5ffd5b506102f86103333660046125f8565b610fd9565b348015610343575f5ffd5b505f546103509060ff1681565b604051610202919061263e565b348015610368575f5ffd5b5061022a7f000000000000000000000000000000000000000000000000000000000000000081565b6102f861104f565b3480156103a3575f5ffd5b5061022a6103b23660046125f8565b60056020525f908152604090205481565b3480156103ce575f5ffd5b506102f86103dd36600461267d565b61109c565b3480156103ed575f5ffd5b506102f86103fc366004612721565b61122f565b34801561040c575f5ffd5b5061042061041b3660046127e0565b61146b565b604051610202919061284c565b6102f86114d8565b6102f8611511565b348015610448575f5ffd5b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275460405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610202565b34801561049b575f5ffd5b506104a4611524565b604051610202919061288e565b3480156104bc575f5ffd5b506102cc6040518060400160405280600581526020017f545255544800000000000000000000000000000000000000000000000000000081525081565b348015610504575f5ffd5b506102f86105133660046128eb565b6115a7565b348015610523575f5ffd5b5061022a6115fa565b348015610537575f5ffd5b506102f86105463660046125f8565b611696565b348015610556575f5ffd5b506102f86116aa565b34801561056a575f5ffd5b5061022a6105793660046124a6565b60016020525f908152604090205481565b348015610595575f5ffd5b5061022a60045481565b3480156105aa575f5ffd5b506102746105b936600461291c565b679a31110384e0b0c96020526014919091525f526034600c205490565b6102f86105e43660046125f8565b6116b3565b3480156105f4575f5ffd5b506102f8610603366004612944565b6116ed565b6102f86106163660046125f8565b611864565b348015610626575f5ffd5b5061022a6106353660046125f8565b63389a75e1600c9081525f91909152602090205490565b6006818154811061065b575f80fd5b5f9182526020909120600490910201805460018201546002830154600390930154919350919084565b5f60035f5460ff16600481111561069d5761069d612611565b036106e4573073ffffffffffffffffffffffffffffffffffffffff8416036106d357505f8181526001602052604090205461075e565b6106dd838361188a565b905061075e565b60045f5460ff1660048111156106fc576106fc612611565b0361072057679a31110384e0b0c960205260148390525f82815260409020546106dd565b3073ffffffffffffffffffffffffffffffffffffffff84160361075157505f8181526001602052604090205461075e565b61075b838361188a565b90505b92915050565b5f81610770575f610773565b60015b60ff1690505f61078433600161188a565b90505f610791335f61188a565b90505f5f5460ff1660048111156107aa576107aa612611565b03610842576107b981836129e4565b156107f0576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b335f8181526005602052604090206001905561080c9084611971565b6040518415159033905f907f5c3a0ec075db958d57c1deaa6b4dca935af6ffe57f69d470c404ada69d6915b7908290a450505050565b60015f5460ff16600481111561085a5761085a612611565b14610891576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61089b81836129e4565b6001146108d4576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b335f90815260056020526040902054158015906109005750600454335f90815260056020526040902054105b610936576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f82600114610945575f610948565b60015b60ff16905042600454116109b4575f61095f6119f5565b91505080821480610985575060035f5460ff16600481111561098357610983612611565b145b806109a5575060045f5460ff1660048111156109a3576109a3612611565b145b156109b257505050505050565b505b600454335f908152600560205260409020558381146109e1576109d73382611db8565b6109e13385611971565b6006546040518615159133917f5c3a0ec075db958d57c1deaa6b4dca935af6ffe57f69d470c404ada69d6915b7905f90a45050505050565b606060028210610a55576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600182145f81610a9a576040518060400160405280600381526020017f3335350000000000000000000000000000000000000000000000000000000000815250610ad1565b6040518060400160405280600281526020017f38310000000000000000000000000000000000000000000000000000000000008152505b604051602001610ae19190612a12565b60405160208183030381529060405290505f82610b33576040518060400160405280601081526020017f68736c2833353520363325203330252900000000000000000000000000000000815250610b6a565b6040518060400160405280600f81526020017f68736c28383120313025203535252900000000000000000000000000000000008152505b9050610b826040518060200160405280606081525090565b610bcf838484604051602001610b9a93929190612a7d565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190528290611e33565b505f5b600654811015610dfb575f85610c0a5760068281548110610bf557610bf5612be2565b905f5260205f20906004020160010154610c2d565b60068281548110610c1d57610c1d612be2565b905f5260205f2090600402015f01545b90505f60068381548110610c4357610c43612be2565b905f5260205f2090600402016001015460068481548110610c6657610c66612be2565b905f5260205f2090600402015f0154610c7f91906129e4565b90505f5f8211610c8f575f610ca5565b81610c9b846064612c0f565b610ca59190612c53565b90505f8315610cd8575f8211610cbc576001610cda565b6005610cc983600a612c0f565b610cd39190612c66565b610cda565b5f5b90505f6002610ceb836103e8612c66565b610cf59190612c53565b90505f610d0183611f0f565b90505f610d0d83611f0f565b90505f8815610d8357610d5f60058a1115610d28575f610d42565b610d3360028b612c79565b15610d3f576003610d42565b60055b60ff16610d508b60016129e4565b610d5a91906129e4565b611f0f565b604051602001610d6f9190612c8c565b604051602081830303815290604052610d93565b60405180602001604052805f8152505b9050610de68384848585604051602001610db1959493929190612cd0565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190528b90611e33565b505060019097019650610bd295505050505050565b5060408051808201909152600a81527f3c2f673e3c2f7376673e000000000000000000000000000000000000000000006020820152610e3b908290611e33565b50610faf60035f5460ff166004811115610e5757610e57612611565b1480610e78575060045f5460ff166004811115610e7657610e76612611565b145b610ef75784610ebc576040518060400160405280600381526020017f4e6f2e0000000000000000000000000000000000000000000000000000000000815250610f7f565b6040518060400160405280600481526020017f5965732e00000000000000000000000000000000000000000000000000000000815250610f7f565b5f8781526001602081905260409091205414610f48576040518060400160405280600a81526020017f4e6f742054727574682e00000000000000000000000000000000000000000000815250610f7f565b6040518060400160405280600681526020017f54727574682e00000000000000000000000000000000000000000000000000008152505b8251610f8a90611f6f565b604051602001610f9b929190612e10565b604051602081830303815290604052611f6f565b604051602001610fbf9190613366565b604051602081830303815290604052945050505050919050565b610fe1611f7c565b600780547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517f8d3aa9908fef1ee82f84b3cc052435228d26c3e20d3ad20a213b8042b495aa6b905f90a250565b5f6202a30067ffffffffffffffff164201905063389a75e1600c52335f52806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d5f5fa250565b6110a4611f7c565b60035f5460ff1660048111156110bc576110bc612611565b141580156110e0575060045f5460ff1660048111156110dd576110dd612611565b14155b8015611118575060018160048111156110fb576110fb612611565b14806111185750600281600481111561111657611116612611565b145b61114e576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600181600481111561116257611162612611565b036111b1576004545f03611183574260045561117c6119f5565b50506111b1565b6111ad7f0000000000000000000000000000000000000000000000000000000000000000426129e4565b6004555b5f80548291907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660018360048111156111ed576111ed612611565b021790555080600481111561120457611204612611565b6040517fcaf614a467539eadacc5961ee316ce2d5590a46321100b51c19e0bbec526dd27905f90a250565b82851461124357633b800a465f526004601cfd5b8760601b679a31110384e0b0c9178760601b679a31110384e0b0c917816020528160601c99508060601c9850886112815763ea553b345f526004601cfd5b8933146112a257335f526034600c20546112a257634b6e7f185f526004601cfd5b8660051b5b801561130f576020810390508087013583602052818a01355f5260405f208054808311156112dc5763f4d678b85f526004601cfd5b8290039055602083905260405f20805480830181811015611304576301336cea5f526004601cfd5b909155506112a79050565b505050604051604081528560051b866040830152808860608401378060600160208301526060818301018781528187602083013750888a337f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb60808586010186a450506113795f90565b1561138e5761138e8888888888888888611fb1565b863b1561146157865f5260405163bc197c81815233602082015288604082015260a060608201528560051b8660c0830152808860e08401378060c001608083015260e08183010187815281876020830137818260e0010160a084015260208282010190508381528385602083013750808101830161010401905060208282601c604051015f5f515af1611429573d15611429573d5f833e3d82fd5b5080517fbc197c81000000000000000000000000000000000000000000000000000000001461145f57639c05499b5f526004601cfd5b505b5050505050505050565b606083821461148157633b800a465f526004601cfd5b6040519050818152602081018260051b8181016040525b80156114ce57602081039050808701358060601b679a31110384e0b0c91760205250808501355f5260405f205481830152611498565b5050949350505050565b63389a75e1600c52335f525f6020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c925f5fa2565b611519611f7c565b6115225f611fb6565b565b60606006805480602002602001604051908101604052809291908181526020015f905b8282101561159e578382905f5260205f2090600402016040518060800160405290815f8201548152602001600182015481526020016002820154815260200160038201548152505081526020019060010190611547565b50505050905090565b8015159050679a31110384e0b0c960205233601452815f52806034600c2055805f528160601b60601c337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160205fa35050565b5f60015f5460ff16600481111561161357611613612611565b1461164a576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b426004541115611686576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f61168f6119f5565b5092915050565b61169e611f7c565b6116a78161201b565b50565b6115223361201b565b6116bb611f7c565b63389a75e1600c52805f526020600c2080544211156116e157636f5e88185f526004601cfd5b5f90556116a781611fb6565b8560601b679a31110384e0b0c9178560601b679a31110384e0b0c917816020528160601c97508060601c96508661172b5763ea553b345f526004601cfd5b87331461174c57335f526034600c205461174c57634b6e7f185f526004601cfd5b855f5260405f20915081548086111561176c5763f4d678b85f526004601cfd5b8581038355508060205260405f209150815485810181811015611796576301336cea5f526004601cfd5b909255505060208390528486337fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6260405fa4843b1561185c5760405163f23a6e61815233602082015286604082015284606082015283608082015260a0808201528160c0820152818360e08301376020818360c401601c84015f8a5af1611825573d15611825573d5f823e3d81fd5b80517ff23a6e61000000000000000000000000000000000000000000000000000000001461185a57639c05499b5f526004601cfd5b505b505050505050565b61186c611f7c565b8060601b61188157637448fbae5f526004601cfd5b6116a781611fb6565b5f5f8260011461189c576003546118a0565b6002545b90505f836001146118e6576040518060400160405280600281526020017f4e4f00000000000000000000000000000000000000000000000000000000000081525061191d565b6040518060400160405280600381526020017f59455300000000000000000000000000000000000000000000000000000000008152505b8583604051602001611931939291906133aa565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001815291905280516020909101205495945050505050565b61197d82826001612197565b5f818152600160205260408120805491611996836133e4565b9091555050604080518281526001602082015230915f9173ffffffffffffffffffffffffffffffffffffffff8616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6291015b60405180910390a45050565b600754600480546040517fbfb70e04000000000000000000000000000000000000000000000000000000008152918201523360248201525f918291829160029173ffffffffffffffffffffffffffffffffffffffff9091169063bfb70e04906044016020604051808303815f875af1158015611a73573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a97919061341b565b611aa19190612c79565b90505f8115611ab0575f611ab3565b60015b604080516080810182527fcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f548152600160208181527fa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb495490830190815260048054948401948552606084018881526006805480860182555f8290529551959092027ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f81019590955591517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d4085015593517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d41840155517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d4290920191909155905460ff92909216925083811491611be89190612c66565b600680547f0b245186681cb59283a89498512264caf02c1a62db21110a5bc1ab606d2bd1179190611c1b90600190612c66565b81548110611c2b57611c2b612be2565b905f5260205f209060040201604051611c689190815481526001820154602082015260028201546040820152600390910154606082015260800190565b60405180910390a3805f03611c905760038054905f611c86836133e4565b9190505550611ca5565b60028054905f611c9f836133e4565b91905055505b5f818152600160205260409020548015611d07575f8281526001602090815260408083208390558051858152918201849052309133917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a45b5f8381526001602052604090205460021115611d80575f8381526001602081905260409091205414611d3a576004611d3d565b60035b5f80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001836004811115611d7657611d76612611565b0217905550611dae565b611daa7f0000000000000000000000000000000000000000000000000000000000000000426129e4565b6004555b5090939092509050565b611dc382825f612197565b5f818152600160205260408120805491611ddc83613432565b909155505060408051828152600160208201525f91309173ffffffffffffffffffffffffffffffffffffffff8616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6291016119e9565b60408051606081529052805182901561075e57601f1983518051808551016605c284b9def7798484015181810615828204029050808310611ed2578560208483170182011681158260400187016040511817611e9f578083028787015280604001860160405250611ed2565b602060405101816040018101604052808b528760208701165b8781015182820152880180611eb857509083028188015294505b505060018603611ee257505f8552805b836020875101165b86810151848401820152840180611eea57505f83820160200152909152505092915050565b60606080604051019050602081016040525f8152805f19835b928101926030600a8206018453600a900480611f285750508190037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909101908152919050565b606061075e825f5f61225f565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927543314611522576382b429005f526004601cfd5b611461565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927805473ffffffffffffffffffffffffffffffffffffffff9092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a355565b60035f5460ff16600481111561203357612033612611565b1461206a576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f808052600160208190527fa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb4954146120a35760016120a5565b5f5b60ff165f81815260016020819052604090912054919250146120f3576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6120fd828261188a565b600114612136576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6121408282611db8565b5f81815260016020818152604080842083905583547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600417845580519182019052918252612193918491849161236c565b5050565b5f826001146121a8576003546121ac565b6002545b90505f836001146121f2576040518060400160405280600281526020017f4e4f000000000000000000000000000000000000000000000000000000000000815250612229565b6040518060400160405280600381526020017f59455300000000000000000000000000000000000000000000000000000000008152505b858360405160200161223d939291906133aa565b6040516020818303038152906040528051906020012090508281555050505050565b606083518015612364576003600282010460021b60405192507f4142434445464748494a4b4c4d4e4f505152535455565758595a616263646566601f526106708515027f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5f18603f526020830181810183886020010180515f82525b60038a0199508951603f8160121c16515f53603f81600c1c1651600153603f8160061c1651600253603f811651600353505f5184526004840193508284106122da5790526020016040527f3d3d00000000000000000000000000000000000000000000000000000000000060038406600204808303919091525f8615159091029182900352900382525b509392505050565b612377565b50505050565b8360601b8061238d5763ea553b345f526004601cfd5b679a31110384e0b0c960205284601452835f5260405f208054848101818110156123be576301336cea5f526004601cfd5b808355505050826020528060601c5f337fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6260405fa450833b15612371576123715f8585858560405163f23a6e6181523360208201528560601b60601c604082015283606082015282608082015260a08082015281518060c0830152801561244f578060e08301826020860160045afa505b6020828260c401601c85015f8a5af1612470573d15612470573d5f833e3d82fd5b5080517ff23a6e61000000000000000000000000000000000000000000000000000000001461185c57639c05499b5f526004601cfd5b5f602082840312156124b6575f5ffd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff811681146124e0575f5ffd5b919050565b5f5f604083850312156124f6575f5ffd5b6124ff836124bd565b946020939093013593505050565b5f6020828403121561251d575f5ffd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461254c575f5ffd5b9392505050565b5f5b8381101561256d578181015183820152602001612555565b50505f910152565b5f815180845261258c816020860160208601612553565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081525f61075b6020830184612575565b803580151581146124e0575f5ffd5b5f602082840312156125ef575f5ffd5b61075b826125d0565b5f60208284031215612608575f5ffd5b61075b826124bd565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b6020810160058310612677577f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b91905290565b5f6020828403121561268d575f5ffd5b81356005811061254c575f5ffd5b5f5f83601f8401126126ab575f5ffd5b50813567ffffffffffffffff8111156126c2575f5ffd5b6020830191508360208260051b85010111156126dc575f5ffd5b9250929050565b5f5f83601f8401126126f3575f5ffd5b50813567ffffffffffffffff81111561270a575f5ffd5b6020830191508360208285010111156126dc575f5ffd5b5f5f5f5f5f5f5f5f60a0898b031215612738575f5ffd5b612741896124bd565b975061274f60208a016124bd565b9650604089013567ffffffffffffffff81111561276a575f5ffd5b6127768b828c0161269b565b909750955050606089013567ffffffffffffffff811115612795575f5ffd5b6127a18b828c0161269b565b909550935050608089013567ffffffffffffffff8111156127c0575f5ffd5b6127cc8b828c016126e3565b999c989b5096995094979396929594505050565b5f5f5f5f604085870312156127f3575f5ffd5b843567ffffffffffffffff811115612809575f5ffd5b6128158782880161269b565b909550935050602085013567ffffffffffffffff811115612834575f5ffd5b6128408782880161269b565b95989497509550505050565b602080825282518282018190525f918401906040840190835b81811015612883578351835260209384019390920191600101612865565b509095945050505050565b602080825282518282018190525f918401906040840190835b8181101561288357835180518452602081015160208501526040810151604085015260608101516060850152506080830192506020840193506001810190506128a7565b5f5f604083850312156128fc575f5ffd5b612905836124bd565b9150612913602084016125d0565b90509250929050565b5f5f6040838503121561292d575f5ffd5b612936836124bd565b9150612913602084016124bd565b5f5f5f5f5f5f60a08789031215612959575f5ffd5b612962876124bd565b9550612970602088016124bd565b94506040870135935060608701359250608087013567ffffffffffffffff811115612999575f5ffd5b6129a589828a016126e3565b979a9699509497509295939492505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b8082018082111561075e5761075e6129b7565b5f8151612a08818560208601612553565b9290920192915050565b7f68736c280000000000000000000000000000000000000000000000000000000081525f8251612a49816004850160208701612553565b7f20313025203525290000000000000000000000000000000000000000000000006004939091019283015250600c01919050565b7f3c73766720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323081527f30302f737667222076696577426f783d2230203020313030302031303030222060208201527f7374796c653d226261636b67726f756e643a000000000000000000000000000060408201525f8451612b00816052850160208901612553565b7f223e3c726563742077696474683d223130303022206865696768743d223130306052918401918201527f30222066696c6c3d22000000000000000000000000000000000000000000000060728201528451612b6381607b840160208901612553565b6052818301019150507f222f3e3c672066696c6c3d226e6f6e6522207374726f6b653d2200000000000060298201528351612ba5816043840160208801612553565b612bd76043838301017f22207374726f6b652d77696474683d2235223e00000000000000000000000000815260130190565b979650505050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b808202811582820484141761075e5761075e6129b7565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f82612c6157612c61612c26565b500490565b8181038181111561075e5761075e6129b7565b5f82612c8757612c87612c26565b500690565b7f22206f7061636974793d22302e0000000000000000000000000000000000000081525f8251612cc381600d850160208701612553565b91909101600d0192915050565b7f3c726563742077696474683d220000000000000000000000000000000000000081525f8651612d0781600d850160208b01612553565b7f22206865696768743d2200000000000000000000000000000000000000000000600d918401918201528651612d44816017840160208b01612553565b600d818301019150507f2220783d22000000000000000000000000000000000000000000000000000000600a8201528551612d8681600f840160208a01612553565b600a818301019150507f2220793d2200000000000000000000000000000000000000000000000000000060058201528451612dc881600a840160208901612553565b612e03612dda600a84840101876129f7565b7f222f3e0000000000000000000000000000000000000000000000000000000000815260030190565b9998505050505050505050565b7f7b226e616d65223a22000000000000000000000000000000000000000000000081525f8351612e47816009850160208801612553565b7f222c22637265617465645f6279223a22307847222c226465736372697074696f6009918401918201527f6e223a225472757468204f7261636c652e5c6e5c6e50726564696374696f6e2060298201527f6d61726b65747320706f736974696f6e207468656d73656c766573206173207460498201527f727574682d646973636f76657279206d656368616e69736d732e20546865792060698201527f636c61696d2074686174206167677265676174696e672062657473207265766560898201527f616c7320616363757261746520696e666f726d6174696f6e2061626f7574206660a98201527f7574757265206576656e74732e20496e2070726163746963652c20746865792060c98201527f66756e6374696f6e2061732067616d626c696e6720706c6174666f726d73207760e98201527f68657265206f7574636f6d6573206172652064657465726d696e6564206279206101098201527f65787465726e616c206f7261636c65732c20696e736964657220696e666f726d6101298201527f6174696f6e20616476616e7461676573206d6967687420706572736973742c206101498201527f616e64206d61726b6574206d656368616e69736d732068617665206e6f2073706101698201527f656369616c2072656c6174696f6e7368697020746f2074727574682e5c6e5c6e6101898201527f5468697320617274776f726b206d616b6573207468652064796e616d696320656101a98201527f78706c696369742e20416e2065787465726e616c206f7261636c6520646574656101c98201527f726d696e6573206f7574636f6d65732e205061727469636970616e74732062656101e98201527f74207265637572736976656c79206f6e206172626974726172792062696e61726102098201527f79206f7574636f6d65732e20546865206d617468656d61746963616c206365726102298201527f7461696e74792069732074686174206d6f73742077696c6c206c6f73652c20616102498201527f6e64206f6e6520706f737369626c65206f7574636f6d652069732074686174206102698201527f6e6f626f64792077696e732d736f20746865204e465420697473656c66206d696102898201527f67687420756c74696d6174656c79206e657665722065786973742e5c6e5c6e446102a98201527f7572696e672074686520706572666f726d616e63652c20616c6c20746f6b656e6102c98201527f732061726520616371756972656420666f72206672656520616e6420617265206102e98201527f736f756c626f756e642e20496620612073696e676c652077696e6e657220656d6103098201527f65726765732c20746865792063616e20636c61696d207468652066696e616c206103298201527f746f6b656e2061732061207472616e7366657261626c65204552432d313135356103498201527f20312f312e2054686520617274776f726b27732076697375616c7320617265206103698201527f67656e657261746976652c20726570726573656e74696e6720746865207072656103898201527f64696374696f6e2070657263656e7461676520666f72206561636820726f756e6103a98201527f642e222c22696d616765223a22646174613a696d6167652f7376672b786d6c3b6103c98201527f6261736536342c000000000000000000000000000000000000000000000000006103e982015261335d6133346103f08301866129f7565b7f227d000000000000000000000000000000000000000000000000000000000000815260020190565b95945050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c00000081525f825161339d81601d850160208701612553565b91909101601d0192915050565b606081525f6133bc6060830186612575565b73ffffffffffffffffffffffffffffffffffffffff9490941660208301525060400152919050565b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613414576134146129b7565b5060010190565b5f6020828403121561342b575f5ffd5b5051919050565b5f81613440576134406129b7565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea264697066735822122097b18a00f73692aced0e23bee53d3743cafa4b58d4cc4a6b5a41247f0b2be97a64736f6c634300081e0033
Deployed Bytecode
0x6080604052600436106101c3575f3560e01c8063715018a6116100f2578063b5ffd81711610092578063f04e283e11610062578063f04e283e146105d6578063f242432a146105e9578063f2fde38b14610608578063fee81cf41461061b575f5ffd5b8063b5ffd8171461054b578063bd85b0391461055f578063cb30fd921461058a578063e985e9c51461059f575f5ffd5b806395d89b41116100cd57806395d89b41146104b1578063a22cb465146104f9578063a475b5dd14610518578063ac852eb51461052c575f5ffd5b8063715018a6146104355780638da5cb5b1461043d5780638fb75bd614610490575f5ffd5b8063200d2ed2116101685780632e49d78b116101385780632e49d78b146103c35780632eb2c2d6146103e25780634e1273f41461040157806354d1f13d1461042d575f5ffd5b8063200d2ed214610338578063247cd8ad1461035d57806325692962146103905780632d55e80d14610398575f5ffd5b806306fdde03116101a357806306fdde03146102845780630a990f54146102d95780630e89341c146102fa57806315fa56bc14610319575f5ffd5b80624fbbb0146101c7578062fdd58e1461020b57806301ffc9a714610238575b5f5ffd5b3480156101d2575f5ffd5b506101e66101e13660046124a6565b61064c565b6040805194855260208501939093529183015260608201526080015b60405180910390f35b348015610216575f5ffd5b5061022a6102253660046124e5565b610684565b604051908152602001610202565b348015610243575f5ffd5b5061027461025236600461250d565b6301ffc9a760e09190911c90811463d9b67a26821417630e89341c9091141790565b6040519015158152602001610202565b34801561028f575f5ffd5b506102cc6040518060400160405280600c81526020017f5472757468204f7261636c65000000000000000000000000000000000000000081525081565b60405161020291906125be565b3480156102e4575f5ffd5b506102f86102f33660046125df565b610764565b005b348015610305575f5ffd5b506102cc6103143660046124a6565b610a19565b348015610324575f5ffd5b506102f86103333660046125f8565b610fd9565b348015610343575f5ffd5b505f546103509060ff1681565b604051610202919061263e565b348015610368575f5ffd5b5061022a7f0000000000000000000000000000000000000000000000000000000000049d4081565b6102f861104f565b3480156103a3575f5ffd5b5061022a6103b23660046125f8565b60056020525f908152604090205481565b3480156103ce575f5ffd5b506102f86103dd36600461267d565b61109c565b3480156103ed575f5ffd5b506102f86103fc366004612721565b61122f565b34801561040c575f5ffd5b5061042061041b3660046127e0565b61146b565b604051610202919061284c565b6102f86114d8565b6102f8611511565b348015610448575f5ffd5b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275460405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610202565b34801561049b575f5ffd5b506104a4611524565b604051610202919061288e565b3480156104bc575f5ffd5b506102cc6040518060400160405280600581526020017f545255544800000000000000000000000000000000000000000000000000000081525081565b348015610504575f5ffd5b506102f86105133660046128eb565b6115a7565b348015610523575f5ffd5b5061022a6115fa565b348015610537575f5ffd5b506102f86105463660046125f8565b611696565b348015610556575f5ffd5b506102f86116aa565b34801561056a575f5ffd5b5061022a6105793660046124a6565b60016020525f908152604090205481565b348015610595575f5ffd5b5061022a60045481565b3480156105aa575f5ffd5b506102746105b936600461291c565b679a31110384e0b0c96020526014919091525f526034600c205490565b6102f86105e43660046125f8565b6116b3565b3480156105f4575f5ffd5b506102f8610603366004612944565b6116ed565b6102f86106163660046125f8565b611864565b348015610626575f5ffd5b5061022a6106353660046125f8565b63389a75e1600c9081525f91909152602090205490565b6006818154811061065b575f80fd5b5f9182526020909120600490910201805460018201546002830154600390930154919350919084565b5f60035f5460ff16600481111561069d5761069d612611565b036106e4573073ffffffffffffffffffffffffffffffffffffffff8416036106d357505f8181526001602052604090205461075e565b6106dd838361188a565b905061075e565b60045f5460ff1660048111156106fc576106fc612611565b0361072057679a31110384e0b0c960205260148390525f82815260409020546106dd565b3073ffffffffffffffffffffffffffffffffffffffff84160361075157505f8181526001602052604090205461075e565b61075b838361188a565b90505b92915050565b5f81610770575f610773565b60015b60ff1690505f61078433600161188a565b90505f610791335f61188a565b90505f5f5460ff1660048111156107aa576107aa612611565b03610842576107b981836129e4565b156107f0576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b335f8181526005602052604090206001905561080c9084611971565b6040518415159033905f907f5c3a0ec075db958d57c1deaa6b4dca935af6ffe57f69d470c404ada69d6915b7908290a450505050565b60015f5460ff16600481111561085a5761085a612611565b14610891576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61089b81836129e4565b6001146108d4576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b335f90815260056020526040902054158015906109005750600454335f90815260056020526040902054105b610936576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f82600114610945575f610948565b60015b60ff16905042600454116109b4575f61095f6119f5565b91505080821480610985575060035f5460ff16600481111561098357610983612611565b145b806109a5575060045f5460ff1660048111156109a3576109a3612611565b145b156109b257505050505050565b505b600454335f908152600560205260409020558381146109e1576109d73382611db8565b6109e13385611971565b6006546040518615159133917f5c3a0ec075db958d57c1deaa6b4dca935af6ffe57f69d470c404ada69d6915b7905f90a45050505050565b606060028210610a55576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600182145f81610a9a576040518060400160405280600381526020017f3335350000000000000000000000000000000000000000000000000000000000815250610ad1565b6040518060400160405280600281526020017f38310000000000000000000000000000000000000000000000000000000000008152505b604051602001610ae19190612a12565b60405160208183030381529060405290505f82610b33576040518060400160405280601081526020017f68736c2833353520363325203330252900000000000000000000000000000000815250610b6a565b6040518060400160405280600f81526020017f68736c28383120313025203535252900000000000000000000000000000000008152505b9050610b826040518060200160405280606081525090565b610bcf838484604051602001610b9a93929190612a7d565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190528290611e33565b505f5b600654811015610dfb575f85610c0a5760068281548110610bf557610bf5612be2565b905f5260205f20906004020160010154610c2d565b60068281548110610c1d57610c1d612be2565b905f5260205f2090600402015f01545b90505f60068381548110610c4357610c43612be2565b905f5260205f2090600402016001015460068481548110610c6657610c66612be2565b905f5260205f2090600402015f0154610c7f91906129e4565b90505f5f8211610c8f575f610ca5565b81610c9b846064612c0f565b610ca59190612c53565b90505f8315610cd8575f8211610cbc576001610cda565b6005610cc983600a612c0f565b610cd39190612c66565b610cda565b5f5b90505f6002610ceb836103e8612c66565b610cf59190612c53565b90505f610d0183611f0f565b90505f610d0d83611f0f565b90505f8815610d8357610d5f60058a1115610d28575f610d42565b610d3360028b612c79565b15610d3f576003610d42565b60055b60ff16610d508b60016129e4565b610d5a91906129e4565b611f0f565b604051602001610d6f9190612c8c565b604051602081830303815290604052610d93565b60405180602001604052805f8152505b9050610de68384848585604051602001610db1959493929190612cd0565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190528b90611e33565b505060019097019650610bd295505050505050565b5060408051808201909152600a81527f3c2f673e3c2f7376673e000000000000000000000000000000000000000000006020820152610e3b908290611e33565b50610faf60035f5460ff166004811115610e5757610e57612611565b1480610e78575060045f5460ff166004811115610e7657610e76612611565b145b610ef75784610ebc576040518060400160405280600381526020017f4e6f2e0000000000000000000000000000000000000000000000000000000000815250610f7f565b6040518060400160405280600481526020017f5965732e00000000000000000000000000000000000000000000000000000000815250610f7f565b5f8781526001602081905260409091205414610f48576040518060400160405280600a81526020017f4e6f742054727574682e00000000000000000000000000000000000000000000815250610f7f565b6040518060400160405280600681526020017f54727574682e00000000000000000000000000000000000000000000000000008152505b8251610f8a90611f6f565b604051602001610f9b929190612e10565b604051602081830303815290604052611f6f565b604051602001610fbf9190613366565b604051602081830303815290604052945050505050919050565b610fe1611f7c565b600780547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517f8d3aa9908fef1ee82f84b3cc052435228d26c3e20d3ad20a213b8042b495aa6b905f90a250565b5f6202a30067ffffffffffffffff164201905063389a75e1600c52335f52806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d5f5fa250565b6110a4611f7c565b60035f5460ff1660048111156110bc576110bc612611565b141580156110e0575060045f5460ff1660048111156110dd576110dd612611565b14155b8015611118575060018160048111156110fb576110fb612611565b14806111185750600281600481111561111657611116612611565b145b61114e576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600181600481111561116257611162612611565b036111b1576004545f03611183574260045561117c6119f5565b50506111b1565b6111ad7f0000000000000000000000000000000000000000000000000000000000049d40426129e4565b6004555b5f80548291907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660018360048111156111ed576111ed612611565b021790555080600481111561120457611204612611565b6040517fcaf614a467539eadacc5961ee316ce2d5590a46321100b51c19e0bbec526dd27905f90a250565b82851461124357633b800a465f526004601cfd5b8760601b679a31110384e0b0c9178760601b679a31110384e0b0c917816020528160601c99508060601c9850886112815763ea553b345f526004601cfd5b8933146112a257335f526034600c20546112a257634b6e7f185f526004601cfd5b8660051b5b801561130f576020810390508087013583602052818a01355f5260405f208054808311156112dc5763f4d678b85f526004601cfd5b8290039055602083905260405f20805480830181811015611304576301336cea5f526004601cfd5b909155506112a79050565b505050604051604081528560051b866040830152808860608401378060600160208301526060818301018781528187602083013750888a337f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb60808586010186a450506113795f90565b1561138e5761138e8888888888888888611fb1565b863b1561146157865f5260405163bc197c81815233602082015288604082015260a060608201528560051b8660c0830152808860e08401378060c001608083015260e08183010187815281876020830137818260e0010160a084015260208282010190508381528385602083013750808101830161010401905060208282601c604051015f5f515af1611429573d15611429573d5f833e3d82fd5b5080517fbc197c81000000000000000000000000000000000000000000000000000000001461145f57639c05499b5f526004601cfd5b505b5050505050505050565b606083821461148157633b800a465f526004601cfd5b6040519050818152602081018260051b8181016040525b80156114ce57602081039050808701358060601b679a31110384e0b0c91760205250808501355f5260405f205481830152611498565b5050949350505050565b63389a75e1600c52335f525f6020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c925f5fa2565b611519611f7c565b6115225f611fb6565b565b60606006805480602002602001604051908101604052809291908181526020015f905b8282101561159e578382905f5260205f2090600402016040518060800160405290815f8201548152602001600182015481526020016002820154815260200160038201548152505081526020019060010190611547565b50505050905090565b8015159050679a31110384e0b0c960205233601452815f52806034600c2055805f528160601b60601c337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160205fa35050565b5f60015f5460ff16600481111561161357611613612611565b1461164a576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b426004541115611686576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f61168f6119f5565b5092915050565b61169e611f7c565b6116a78161201b565b50565b6115223361201b565b6116bb611f7c565b63389a75e1600c52805f526020600c2080544211156116e157636f5e88185f526004601cfd5b5f90556116a781611fb6565b8560601b679a31110384e0b0c9178560601b679a31110384e0b0c917816020528160601c97508060601c96508661172b5763ea553b345f526004601cfd5b87331461174c57335f526034600c205461174c57634b6e7f185f526004601cfd5b855f5260405f20915081548086111561176c5763f4d678b85f526004601cfd5b8581038355508060205260405f209150815485810181811015611796576301336cea5f526004601cfd5b909255505060208390528486337fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6260405fa4843b1561185c5760405163f23a6e61815233602082015286604082015284606082015283608082015260a0808201528160c0820152818360e08301376020818360c401601c84015f8a5af1611825573d15611825573d5f823e3d81fd5b80517ff23a6e61000000000000000000000000000000000000000000000000000000001461185a57639c05499b5f526004601cfd5b505b505050505050565b61186c611f7c565b8060601b61188157637448fbae5f526004601cfd5b6116a781611fb6565b5f5f8260011461189c576003546118a0565b6002545b90505f836001146118e6576040518060400160405280600281526020017f4e4f00000000000000000000000000000000000000000000000000000000000081525061191d565b6040518060400160405280600381526020017f59455300000000000000000000000000000000000000000000000000000000008152505b8583604051602001611931939291906133aa565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001815291905280516020909101205495945050505050565b61197d82826001612197565b5f818152600160205260408120805491611996836133e4565b9091555050604080518281526001602082015230915f9173ffffffffffffffffffffffffffffffffffffffff8616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6291015b60405180910390a45050565b600754600480546040517fbfb70e04000000000000000000000000000000000000000000000000000000008152918201523360248201525f918291829160029173ffffffffffffffffffffffffffffffffffffffff9091169063bfb70e04906044016020604051808303815f875af1158015611a73573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a97919061341b565b611aa19190612c79565b90505f8115611ab0575f611ab3565b60015b604080516080810182527fcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f548152600160208181527fa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb495490830190815260048054948401948552606084018881526006805480860182555f8290529551959092027ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f81019590955591517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d4085015593517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d41840155517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d4290920191909155905460ff92909216925083811491611be89190612c66565b600680547f0b245186681cb59283a89498512264caf02c1a62db21110a5bc1ab606d2bd1179190611c1b90600190612c66565b81548110611c2b57611c2b612be2565b905f5260205f209060040201604051611c689190815481526001820154602082015260028201546040820152600390910154606082015260800190565b60405180910390a3805f03611c905760038054905f611c86836133e4565b9190505550611ca5565b60028054905f611c9f836133e4565b91905055505b5f818152600160205260409020548015611d07575f8281526001602090815260408083208390558051858152918201849052309133917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a45b5f8381526001602052604090205460021115611d80575f8381526001602081905260409091205414611d3a576004611d3d565b60035b5f80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001836004811115611d7657611d76612611565b0217905550611dae565b611daa7f0000000000000000000000000000000000000000000000000000000000049d40426129e4565b6004555b5090939092509050565b611dc382825f612197565b5f818152600160205260408120805491611ddc83613432565b909155505060408051828152600160208201525f91309173ffffffffffffffffffffffffffffffffffffffff8616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6291016119e9565b60408051606081529052805182901561075e57601f1983518051808551016605c284b9def7798484015181810615828204029050808310611ed2578560208483170182011681158260400187016040511817611e9f578083028787015280604001860160405250611ed2565b602060405101816040018101604052808b528760208701165b8781015182820152880180611eb857509083028188015294505b505060018603611ee257505f8552805b836020875101165b86810151848401820152840180611eea57505f83820160200152909152505092915050565b60606080604051019050602081016040525f8152805f19835b928101926030600a8206018453600a900480611f285750508190037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909101908152919050565b606061075e825f5f61225f565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927543314611522576382b429005f526004601cfd5b611461565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927805473ffffffffffffffffffffffffffffffffffffffff9092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a355565b60035f5460ff16600481111561203357612033612611565b1461206a576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f808052600160208190527fa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb4954146120a35760016120a5565b5f5b60ff165f81815260016020819052604090912054919250146120f3576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6120fd828261188a565b600114612136576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6121408282611db8565b5f81815260016020818152604080842083905583547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600417845580519182019052918252612193918491849161236c565b5050565b5f826001146121a8576003546121ac565b6002545b90505f836001146121f2576040518060400160405280600281526020017f4e4f000000000000000000000000000000000000000000000000000000000000815250612229565b6040518060400160405280600381526020017f59455300000000000000000000000000000000000000000000000000000000008152505b858360405160200161223d939291906133aa565b6040516020818303038152906040528051906020012090508281555050505050565b606083518015612364576003600282010460021b60405192507f4142434445464748494a4b4c4d4e4f505152535455565758595a616263646566601f526106708515027f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392d5f18603f526020830181810183886020010180515f82525b60038a0199508951603f8160121c16515f53603f81600c1c1651600153603f8160061c1651600253603f811651600353505f5184526004840193508284106122da5790526020016040527f3d3d00000000000000000000000000000000000000000000000000000000000060038406600204808303919091525f8615159091029182900352900382525b509392505050565b612377565b50505050565b8360601b8061238d5763ea553b345f526004601cfd5b679a31110384e0b0c960205284601452835f5260405f208054848101818110156123be576301336cea5f526004601cfd5b808355505050826020528060601c5f337fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6260405fa450833b15612371576123715f8585858560405163f23a6e6181523360208201528560601b60601c604082015283606082015282608082015260a08082015281518060c0830152801561244f578060e08301826020860160045afa505b6020828260c401601c85015f8a5af1612470573d15612470573d5f833e3d82fd5b5080517ff23a6e61000000000000000000000000000000000000000000000000000000001461185c57639c05499b5f526004601cfd5b5f602082840312156124b6575f5ffd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff811681146124e0575f5ffd5b919050565b5f5f604083850312156124f6575f5ffd5b6124ff836124bd565b946020939093013593505050565b5f6020828403121561251d575f5ffd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461254c575f5ffd5b9392505050565b5f5b8381101561256d578181015183820152602001612555565b50505f910152565b5f815180845261258c816020860160208601612553565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081525f61075b6020830184612575565b803580151581146124e0575f5ffd5b5f602082840312156125ef575f5ffd5b61075b826125d0565b5f60208284031215612608575f5ffd5b61075b826124bd565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b6020810160058310612677577f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b91905290565b5f6020828403121561268d575f5ffd5b81356005811061254c575f5ffd5b5f5f83601f8401126126ab575f5ffd5b50813567ffffffffffffffff8111156126c2575f5ffd5b6020830191508360208260051b85010111156126dc575f5ffd5b9250929050565b5f5f83601f8401126126f3575f5ffd5b50813567ffffffffffffffff81111561270a575f5ffd5b6020830191508360208285010111156126dc575f5ffd5b5f5f5f5f5f5f5f5f60a0898b031215612738575f5ffd5b612741896124bd565b975061274f60208a016124bd565b9650604089013567ffffffffffffffff81111561276a575f5ffd5b6127768b828c0161269b565b909750955050606089013567ffffffffffffffff811115612795575f5ffd5b6127a18b828c0161269b565b909550935050608089013567ffffffffffffffff8111156127c0575f5ffd5b6127cc8b828c016126e3565b999c989b5096995094979396929594505050565b5f5f5f5f604085870312156127f3575f5ffd5b843567ffffffffffffffff811115612809575f5ffd5b6128158782880161269b565b909550935050602085013567ffffffffffffffff811115612834575f5ffd5b6128408782880161269b565b95989497509550505050565b602080825282518282018190525f918401906040840190835b81811015612883578351835260209384019390920191600101612865565b509095945050505050565b602080825282518282018190525f918401906040840190835b8181101561288357835180518452602081015160208501526040810151604085015260608101516060850152506080830192506020840193506001810190506128a7565b5f5f604083850312156128fc575f5ffd5b612905836124bd565b9150612913602084016125d0565b90509250929050565b5f5f6040838503121561292d575f5ffd5b612936836124bd565b9150612913602084016124bd565b5f5f5f5f5f5f60a08789031215612959575f5ffd5b612962876124bd565b9550612970602088016124bd565b94506040870135935060608701359250608087013567ffffffffffffffff811115612999575f5ffd5b6129a589828a016126e3565b979a9699509497509295939492505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b8082018082111561075e5761075e6129b7565b5f8151612a08818560208601612553565b9290920192915050565b7f68736c280000000000000000000000000000000000000000000000000000000081525f8251612a49816004850160208701612553565b7f20313025203525290000000000000000000000000000000000000000000000006004939091019283015250600c01919050565b7f3c73766720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323081527f30302f737667222076696577426f783d2230203020313030302031303030222060208201527f7374796c653d226261636b67726f756e643a000000000000000000000000000060408201525f8451612b00816052850160208901612553565b7f223e3c726563742077696474683d223130303022206865696768743d223130306052918401918201527f30222066696c6c3d22000000000000000000000000000000000000000000000060728201528451612b6381607b840160208901612553565b6052818301019150507f222f3e3c672066696c6c3d226e6f6e6522207374726f6b653d2200000000000060298201528351612ba5816043840160208801612553565b612bd76043838301017f22207374726f6b652d77696474683d2235223e00000000000000000000000000815260130190565b979650505050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b808202811582820484141761075e5761075e6129b7565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f82612c6157612c61612c26565b500490565b8181038181111561075e5761075e6129b7565b5f82612c8757612c87612c26565b500690565b7f22206f7061636974793d22302e0000000000000000000000000000000000000081525f8251612cc381600d850160208701612553565b91909101600d0192915050565b7f3c726563742077696474683d220000000000000000000000000000000000000081525f8651612d0781600d850160208b01612553565b7f22206865696768743d2200000000000000000000000000000000000000000000600d918401918201528651612d44816017840160208b01612553565b600d818301019150507f2220783d22000000000000000000000000000000000000000000000000000000600a8201528551612d8681600f840160208a01612553565b600a818301019150507f2220793d2200000000000000000000000000000000000000000000000000000060058201528451612dc881600a840160208901612553565b612e03612dda600a84840101876129f7565b7f222f3e0000000000000000000000000000000000000000000000000000000000815260030190565b9998505050505050505050565b7f7b226e616d65223a22000000000000000000000000000000000000000000000081525f8351612e47816009850160208801612553565b7f222c22637265617465645f6279223a22307847222c226465736372697074696f6009918401918201527f6e223a225472757468204f7261636c652e5c6e5c6e50726564696374696f6e2060298201527f6d61726b65747320706f736974696f6e207468656d73656c766573206173207460498201527f727574682d646973636f76657279206d656368616e69736d732e20546865792060698201527f636c61696d2074686174206167677265676174696e672062657473207265766560898201527f616c7320616363757261746520696e666f726d6174696f6e2061626f7574206660a98201527f7574757265206576656e74732e20496e2070726163746963652c20746865792060c98201527f66756e6374696f6e2061732067616d626c696e6720706c6174666f726d73207760e98201527f68657265206f7574636f6d6573206172652064657465726d696e6564206279206101098201527f65787465726e616c206f7261636c65732c20696e736964657220696e666f726d6101298201527f6174696f6e20616476616e7461676573206d6967687420706572736973742c206101498201527f616e64206d61726b6574206d656368616e69736d732068617665206e6f2073706101698201527f656369616c2072656c6174696f6e7368697020746f2074727574682e5c6e5c6e6101898201527f5468697320617274776f726b206d616b6573207468652064796e616d696320656101a98201527f78706c696369742e20416e2065787465726e616c206f7261636c6520646574656101c98201527f726d696e6573206f7574636f6d65732e205061727469636970616e74732062656101e98201527f74207265637572736976656c79206f6e206172626974726172792062696e61726102098201527f79206f7574636f6d65732e20546865206d617468656d61746963616c206365726102298201527f7461696e74792069732074686174206d6f73742077696c6c206c6f73652c20616102498201527f6e64206f6e6520706f737369626c65206f7574636f6d652069732074686174206102698201527f6e6f626f64792077696e732d736f20746865204e465420697473656c66206d696102898201527f67687420756c74696d6174656c79206e657665722065786973742e5c6e5c6e446102a98201527f7572696e672074686520706572666f726d616e63652c20616c6c20746f6b656e6102c98201527f732061726520616371756972656420666f72206672656520616e6420617265206102e98201527f736f756c626f756e642e20496620612073696e676c652077696e6e657220656d6103098201527f65726765732c20746865792063616e20636c61696d207468652066696e616c206103298201527f746f6b656e2061732061207472616e7366657261626c65204552432d313135356103498201527f20312f312e2054686520617274776f726b27732076697375616c7320617265206103698201527f67656e657261746976652c20726570726573656e74696e6720746865207072656103898201527f64696374696f6e2070657263656e7461676520666f72206561636820726f756e6103a98201527f642e222c22696d616765223a22646174613a696d6167652f7376672b786d6c3b6103c98201527f6261736536342c000000000000000000000000000000000000000000000000006103e982015261335d6133346103f08301866129f7565b7f227d000000000000000000000000000000000000000000000000000000000000815260020190565b95945050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c00000081525f825161339d81601d850160208701612553565b91909101601d0192915050565b606081525f6133bc6060830186612575565b73ffffffffffffffffffffffffffffffffffffffff9490941660208301525060400152919050565b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613414576134146129b7565b5060010190565b5f6020828403121561342b575f5ffd5b5051919050565b5f81613440576134406129b7565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea264697066735822122097b18a00f73692aced0e23bee53d3743cafa4b58d4cc4a6b5a41247f0b2be97a64736f6c634300081e0033
Deployed Bytecode Sourcemap
895:18775:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3387:35;;;;;;;;;;-1:-1:-1;3387:35:0;;;;;:::i;:::-;;:::i;:::-;;;;476:25:7;;;532:2;517:18;;510:34;;;;560:18;;;553:34;618:2;603:18;;596:34;463:3;448:19;3387:35:0;;;;;;;;11670:677;;;;;;;;;;-1:-1:-1;11670:677:0;;;;;:::i;:::-;;:::i;:::-;;;1293:25:7;;;1281:2;1266:18;11670:677:0;1147:177:7;20052:385:2;;;;;;;;;;-1:-1:-1;20052:385:2;;;;;:::i;:::-;20370:10;20230:3;20226:21;;;;20364:17;;;20389:10;20383:17;;20361:40;20409:10;20403:17;;;20358:63;;20052:385;;;;1831:14:7;;1824:22;1806:41;;1794:2;1779:18;20052:385:2;1666:187:7;941:44:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;12782:1625::-;;;;;;;;;;-1:-1:-1;12782:1625:0;;;;;:::i;:::-;;:::i;:::-;;5746:2908;;;;;;;;;;-1:-1:-1;5746:2908:0;;;;;:::i;:::-;;:::i;17942:141::-;;;;;;;;;;-1:-1:-1;17942:141:0;;;;;:::i;:::-;;:::i;1562:20::-;;;;;;;;;;-1:-1:-1;1562:20:0;;;;;;;;;;;;;;;:::i;2592:48::-;;;;;;;;;;;;;;;9021:617:1;;;:::i;2870:74:0:-;;;;;;;;;;-1:-1:-1;2870:74:0;;;;;:::i;:::-;;;;;;;;;;;;;;17006:726;;;;;;;;;;-1:-1:-1;17006:726:0;;;;;:::i;:::-;;:::i;12785:5890:2:-;;;;;;;;;;-1:-1:-1;12785:5890:2;;;;;:::i;:::-;;:::i;18822:1021::-;;;;;;;;;;-1:-1:-1;18822:1021:2;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;9720:456:1:-;;;:::i;8762:100::-;;;:::i;11408:182::-;;;;;;;;;;-1:-1:-1;11562:11:1;11556:18;11408:182;;7609:42:7;7597:55;;;7579:74;;7567:2;7552:18;11408:182:1;7433:226:7;5162:103:0;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;989:39::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;7020:720:2;;;;;;;;;;-1:-1:-1;7020:720:2;;;;;:::i;:::-;;:::i;14775:215:0:-;;;;;;;;;;;;;:::i;18681:85::-;;;;;;;;;;-1:-1:-1;18681:85:0;;;;;:::i;:::-;;:::i;18329:63::-;;;;;;;;;;;;;:::i;1736:61::-;;;;;;;;;;-1:-1:-1;1736:61:0;;;;;:::i;:::-;;;;;;;;;;;;;;2446:23;;;;;;;;;;;;;;;;6495:386:2;;;;;;;;;;-1:-1:-1;6495:386:2;;;;;:::i;:::-;6721:25;6715:4;6708:39;6767:4;6760:19;;;;6615:11;6792:22;6859:4;-1:-1:-1;6843:21:2;6837:28;;6495:386;10363:708:1;;;;;;:::i;:::-;;:::i;8225:4012:2:-;;;;;;;;;;-1:-1:-1;8225:4012:2;;;;;:::i;:::-;;:::i;8348:349:1:-;;;;;;:::i;:::-;;:::i;11693:435::-;;;;;;;;;;-1:-1:-1;11693:435:1;;;;;:::i;:::-;11963:19;11957:4;11950:33;;;11812:14;11996:26;;;;12106:4;12090:21;;12084:28;;11693:435;3387:35:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;3387:35:0;;;:::o;11670:677::-;11748:7;11777:16;11767:6;;;;:26;;;;;;;;:::i;:::-;;11763:238;;11908:4;11889:24;;;;11885:71;;-1:-1:-1;11932:15:0;;;;:11;:15;;;;;;11925:22;;11885:71;11970:24;11982:7;11991:2;11970:11;:24::i;:::-;11963:31;;;;11763:238;12021:15;12011:6;;;;:25;;;;;;;;:::i;:::-;;12007:141;;6250:25:2;6244:4;6237:39;6296:4;6289:19;;;6145:14;6321:16;;;6382:4;6366:21;;6360:28;12113::0;6070:334:2;12007:141:0;12261:4;12242:24;;;;12238:67;;-1:-1:-1;12283:15:0;;;;:11;:15;;;;;;12276:22;;12238:67;12318:24;12330:7;12339:2;12318:11;:24::i;:::-;12311:31;;11670:677;;;;;:::o;12782:1625::-;12824:18;12845:3;:11;;12855:1;12845:11;;;12851:1;12845:11;12824:32;;;;12863:18;12884:26;12896:10;12908:1;12884:11;:26::i;:::-;12863:47;;12916:17;12936:26;12948:10;12960:1;12936:11;:26::i;:::-;12916:46;-1:-1:-1;13008:14:0;12998:6;;;;:24;;;;;;;;:::i;:::-;;12994:236;;13040:22;13053:9;13040:10;:22;:::i;:::-;:27;13032:52;;;;;;;;;;;;;;;;;13108:10;13092:27;;;;:15;:27;;;;;13122:1;13092:31;;13131:38;;13158:10;13131:14;:38::i;:::-;13182:27;;;;;;13193:10;;13190:1;;13182:27;;13190:1;;13182:27;13217:7;;;12782:1625;:::o;12994:236::-;13277:11;13267:6;;;;:21;;;;;;;;:::i;:::-;;13259:46;;;;;;;;;;;;;;;;;13382:22;13395:9;13382:10;:22;:::i;:::-;13408:1;13382:27;13374:52;;;;;;;;;;;;;;;;;13513:10;13527:1;13497:27;;;:15;:27;;;;;;:31;;;;:73;;-1:-1:-1;13562:8:0;;13548:10;13532:27;;;;:15;:27;;;;;;:38;13497:73;13489:98;;;;;;;;;;;;;;;;;13594:22;13619:10;13633:1;13619:15;:23;;13641:1;13619:23;;;13637:1;13619:23;13594:48;;;;13744:15;13732:8;;:27;13728:265;;13772:13;13789:9;:7;:9::i;:::-;13769:29;;;13896:5;13878:14;:23;:53;;;-1:-1:-1;13915:16:0;13905:6;;;;:26;;;;;;;;:::i;:::-;;13878:53;:82;;;-1:-1:-1;13945:15:0;13935:6;;;;:25;;;;;;;;:::i;:::-;;13878:82;13874:113;;;13972:7;;;;;12782:1625;:::o;13874:113::-;13761:232;13728:265;14029:8;;14015:10;13999:27;;;;:15;:27;;;;;:38;14214:28;;;14210:137;;14252:42;14267:10;14279:14;14252;:42::i;:::-;14302:38;14317:10;14329;14302:14;:38::i;:::-;14366:11;:18;14358:44;;;;;;14386:10;;14358:44;;;;;12818:1589;;;;12782:1625;:::o;5746:2908::-;5806:13;5845:1;5835:7;:11;5827:36;;;;;;;;;;;;;;;;;5894:1;5883:12;;5870:10;5883:12;5952:21;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5929:58;;;;;;;;:::i;:::-;;;;;;;;;;;;;5902:85;;5993:20;6016:5;:46;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5993:69;;6069:41;-1:-1:-1;;;;;;;;;;;;;;6069:41:0;6116:315;6249:10;6322;6380:6;6129:296;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;6116:3;;:5;:315::i;:::-;-1:-1:-1;6443:9:0;6438:816;6462:11;:18;6458:22;;6438:816;;;6495:13;6511:5;:46;;6540:11;6552:1;6540:14;;;;;;;;:::i;:::-;;;;;;;;;;;:17;;;6511:46;;;6519:11;6531:1;6519:14;;;;;;;;:::i;:::-;;;;;;;;;;;:18;;;6511:46;6495:62;;6565:13;6602:11;6614:1;6602:14;;;;;;;;:::i;:::-;;;;;;;;;;;:17;;;6581:11;6593:1;6581:14;;;;;;;;:::i;:::-;;;;;;;;;;;:18;;;:38;;;;:::i;:::-;6565:54;;6627:11;6649:1;6641:5;:9;:37;;6677:1;6641:37;;;6669:5;6654:11;:5;6662:3;6654:11;:::i;:::-;6653:21;;;;:::i;:::-;6627:51;-1:-1:-1;6686:12:0;6701:10;;:45;;6724:1;6718:3;:7;:28;;6745:1;6701:45;;6718:28;6741:1;6729:8;:3;6735:2;6729:8;:::i;:::-;6728:14;;;;:::i;:::-;6701:45;;;6714:1;6701:45;6686:60;-1:-1:-1;6754:11:0;6784:1;6769:11;6686:60;6769:4;:11;:::i;:::-;6768:17;;;;:::i;:::-;6754:31;;6793:21;6817:24;6836:4;6817:18;:24::i;:::-;6793:48;;6849:20;6872:23;6891:3;6872:18;:23::i;:::-;6849:46;-1:-1:-1;6904:24:0;6931:6;;:135;;7002:63;7035:1;7030;:6;;:33;;7062:1;7030:33;;;7040:5;7044:1;7040;:5;:::i;:::-;:10;:18;;7057:1;7040:18;;;7053:1;7040:18;7021:43;;:5;:1;7025;7021:5;:::i;:::-;:43;;;;:::i;:::-;7002:18;:63::i;:::-;6968:98;;;;;;;;:::i;:::-;;;;;;;;;;;;;6931:135;;;6948:9;;;;;;;;;;;;6931:135;6904:162;;7075:172;7135:7;7158;7176:6;7193;7211:11;7090:149;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;7075:3;;:5;:172::i;:::-;-1:-1:-1;;6482:3:0;;;;;-1:-1:-1;6438:816:0;;-1:-1:-1;;;;;;6438:816:0;;-1:-1:-1;7266:19:0;;;;;;;;;;;;;;;;;7260:26;;:3;;:5;:26::i;:::-;-1:-1:-1;7360:1283:0;7435:16;7425:6;;;;:26;;;;;;;;:::i;:::-;;:55;;;-1:-1:-1;7465:15:0;7455:6;;;;:25;;;;;;;;:::i;:::-;;7425:55;7424:140;;7541:5;:22;;;;;;;;;;;;;;;;;;;7424:140;;7541:22;;;;;;;;;;;;;;;;;;7424:140;;;7485:20;;;;:11;:20;;;;;;;;;:25;:51;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8600:8;;8586:23;;:13;:23::i;:::-;7383:1252;;;;;;;;;:::i;:::-;;;;;;;;;;;;;7360:13;:1283::i;:::-;7300:1349;;;;;;;;:::i;:::-;;;;;;;;;;;;;7293:1356;;;;;;5746:2908;;;:::o;17942:141::-;12517:13:1;:11;:13::i;:::-;18013:11:0::1;:26:::0;;;::::1;;::::0;::::1;::::0;;::::1;::::0;;;18050:28:::1;::::0;::::1;::::0;-1:-1:-1;;18050:28:0::1;17942:141:::0;:::o;9021:617:1:-;9114:15;7972:9;9132:46;;:15;:46;9114:64;;9346:19;9340:4;9333:33;9396:8;9390:4;9383:22;9452:7;9445:4;9439;9429:21;9422:38;9599:8;9552:45;9549:1;9546;9541:67;9248:374;9021:617::o;17006:726:0:-;12517:13:1;:11;:13::i;:::-;17091:16:0::1;17081:6;::::0;::::1;;:26;::::0;::::1;;;;;;:::i;:::-;;;:55;;;;-1:-1:-1::0;17121:15:0::1;17111:6;::::0;::::1;;:25;::::0;::::1;;;;;;:::i;:::-;;;17081:55;:160;;;;-1:-1:-1::0;17201:11:0::1;17190:7;:22;;;;;;;;:::i;:::-;;:50;;;-1:-1:-1::0;17227:13:0::1;17216:7;:24;;;;;;;;:::i;:::-;;17190:50;17066:234;;;;;;;;;;;;;;;;;17322:11;17311:7;:22;;;;;;;;:::i;:::-;::::0;17307:367:::1;;17428:8;;17440:1;17428:13:::0;17424:244:::1;;17464:15;17453:8;:26:::0;17530:9:::1;:7;:9::i;:::-;;;17424:244;;;17627:32;17645:14;17627:15;:32;:::i;:::-;17616:8;:43:::0;17424:244:::1;17679:6;:16:::0;;17688:7;;17679:6;:16;::::1;::::0;17688:7;17679:16:::1;::::0;::::1;;;;;;:::i;:::-;;;;;;17719:7;17706:21;;;;;;;;:::i;:::-;;::::0;::::1;::::0;;;::::1;17006:726:::0;:::o;12785:5890:2:-;13192:14;13180:10;13177:30;13167:162;;13240:10;13234:4;13227:24;13310:4;13304;13297:18;13167:162;13400:4;13396:2;13392:13;13365:25;13362:44;13475:2;13471;13467:11;13440:25;13437:42;13505:12;13499:4;13492:26;13587:12;13583:2;13579:21;13571:29;;13627:10;13623:2;13619:19;13613:25;;13712:2;13702:135;;13747:10;13741:4;13734:24;13818:4;13812;13805:18;13702:135;13945:4;13935:8;13932:18;13922:272;;13983:8;13977:4;13970:22;14041:4;14035;14025:21;14019:28;14009:171;;14084:10;14078:4;14071:24;14157:4;14151;14144:18;14009:171;14314:10;14311:1;14307:18;14292:1482;14328:1;14292:1482;;;14367:4;14364:1;14360:12;14355:17;;14440:1;14424:14;14420:22;14407:36;14576:12;14570:4;14563:26;14656:1;14644:10;14640:18;14627:32;14621:4;14614:46;14724:4;14718;14708:21;14779:15;14773:22;14834:11;14826:6;14823:23;14820:182;;;14890:10;14884:4;14877:24;14971:4;14965;14958:18;14820:182;15051:24;;;15027:49;;15223:4;15216:24;;;15302:4;15296;15286:21;15355:20;;15422:28;;;15478:35;;;15475:197;;;15557:10;15551:4;15544:24;15641:4;15635;15628:18;15475:197;15697:37;;;-1:-1:-1;14292:1482:2;;-1:-1:-1;14292:1482:2;;14296:31;14274:1514;;15879:4;15873:11;15946:4;15943:1;15936:15;15984:10;15981:1;15977:18;16033:10;16026:4;16023:1;16019:12;16012:32;16100:1;16088:10;16081:4;16078:1;16074:12;16061:41;16189:1;16183:4;16179:12;16172:4;16169:1;16165:12;16158:34;16233:4;16229:1;16226;16222:9;16218:20;16265:10;16262:1;16255:21;16336:1;16320:14;16313:4;16310:1;16306:12;16293:45;;16466:2;16460:4;16450:8;16417:31;16410:4;16406:1;16403;16399:9;16395:20;16392:1;16387:82;;;16506:24;41987:4;;41921:101;16506:24;16502:112;;;16546:57;16574:4;16580:2;16584:3;;16589:7;;16598:4;;16546:27;:57::i;:::-;16786:2;16774:15;16771:1888;;;16821:2;16815:4;16808:16;16897:4;16891:11;17058:10;17055:1;17048:21;17107:8;17100:4;17097:1;17093:12;17086:30;17154:4;17147;17144:1;17140:12;17133:26;17232:4;17225;17222:1;17218:12;17211:26;17270:10;17267:1;17263:18;17319:10;17312:4;17309:1;17305:12;17298:32;17386:1;17374:10;17367:4;17364:1;17360:12;17347:41;17475:1;17469:4;17465:12;17458:4;17455:1;17451:12;17444:34;17519:4;17515:1;17512;17508:9;17504:20;17551:10;17548:1;17541:21;17622:1;17606:14;17599:4;17596:1;17592:12;17579:45;17716:1;17712;17706:4;17702:12;17698:20;17691:4;17688:1;17684:12;17677:42;17756:4;17752:1;17749;17745:9;17741:20;17736:25;;17788:11;17785:1;17778:22;17857:11;17844;17837:4;17834:1;17830:12;17817:52;;17933:1;17930;17926:9;17913:11;17909:27;17902:5;17898:39;17886:51;;18072:4;18069:1;18063:4;18056;18049;18043:11;18039:22;18036:1;18029:4;18023:11;18016:5;18011:66;18001:348;;18104:16;18101:230;;;18240:16;18234:4;18231:1;18216:41;18292:16;18289:1;18282:27;18101:230;-1:-1:-1;18461:8:2;;18471:20;18458:34;18448:197;;18529:10;18523:4;18516:24;18622:4;18616;18609:18;18448:197;;16771:1888;12785:5890;;;;;;;;:::o;18822:1021::-;18958:25;19090:13;19078:10;19075:29;19065:161;;19137:10;19131:4;19124:24;19207:4;19201;19194:18;19065:161;19257:4;19251:11;19239:23;;19292:10;19282:8;19275:28;19339:4;19329:8;19325:19;19373:10;19370:1;19366:18;19417:1;19414;19410:9;19404:4;19397:23;19498:329;19505:1;19498:329;;;19540:4;19537:1;19533:12;19528:17;;19607:1;19592:13;19588:21;19575:35;19678:5;19674:2;19670:14;19643:25;19640:45;19634:4;19627:59;;19745:1;19733:10;19729:18;19716:32;19710:4;19703:46;19806:4;19800;19790:21;19784:28;19780:1;19777;19773:9;19766:47;19498:329;;;19502:2;;18822:1021;;;;;;:::o;9720:456:1:-;9922:19;9916:4;9909:33;9968:8;9962:4;9955:22;10020:1;10013:4;10007;9997:21;9990:32;10151:8;10105:44;10102:1;10099;10094:66;9720:456::o;8762:100::-;12517:13;:11;:13::i;:::-;8834:21:::1;8852:1;8834:9;:21::i;:::-;8762:100::o:0;5162:103:0:-;5211:23;5249:11;5242:18;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5162:103;:::o;7020:720:2:-;7235:10;7228:18;7221:26;7207:40;;7344:25;7338:4;7331:39;7396:8;7390:4;7383:22;7431:8;7425:4;7418:22;7483:10;7476:4;7470;7460:21;7453:41;7568:10;7562:4;7555:24;7713:8;7709:2;7705:17;7701:2;7697:26;7687:8;7652:33;7646:4;7640;7635:89;7020:720;;:::o;14775:215:0:-;14811:7;14844:11;14834:6;;;;:21;;;;;;;;:::i;:::-;;14826:46;;;;;;;;;;;;;;;;;14898:15;14886:8;;:27;;14878:52;;;;;;;;;;;;;;;;;14938:14;14957:9;:7;:9::i;:::-;-1:-1:-1;14937:29:0;14775:215;-1:-1:-1;;14775:215:0:o;18681:85::-;12517:13:1;:11;:13::i;:::-;18742:19:0::1;18754:6;18742:11;:19::i;:::-;18681:85:::0;:::o;18329:63::-;18364:23;18376:10;18364:11;:23::i;10363:708:1:-;12517:13;:11;:13::i;:::-;10597:19:::1;10591:4;10584:33;10643:12;10637:4;10630:26;10705:4;10699;10689:21;10811:12;10805:19;10792:11;10789:36;10786:157;;;10857:10;10851:4;10844:24;10924:4;10918;10911:18;10786:157;11020:1;10999:23:::0;;11041::::1;11051:12:::0;11041:9:::1;:23::i;8225:4012:2:-:0;8652:4;8648:2;8644:13;8617:25;8614:44;8727:2;8723;8719:11;8692:25;8689:42;8757:12;8751:4;8744:26;8839:12;8835:2;8831:21;8823:29;;8879:10;8875:2;8871:19;8865:25;;8964:2;8954:135;;8999:10;8993:4;8986:24;9070:4;9064;9057:18;8954:135;9197:4;9187:8;9184:18;9174:272;;9235:8;9229:4;9222:22;9293:4;9287;9277:21;9271:28;9261:171;;9336:10;9330:4;9323:24;9409:4;9403;9396:18;9261:171;9555:2;9549:4;9542:16;9614:4;9608;9598:21;9575:44;;9661:15;9655:22;9708:11;9700:6;9697:23;9694:158;;;9756:10;9750:4;9743:24;9829:4;9823;9816:18;9694:158;9910:6;9897:11;9893:24;9876:15;9869:49;;10039:10;10033:4;10026:24;10104:4;10098;10088:21;10067:42;;10155:13;10149:20;10229:6;10212:15;10208:28;10275:15;10259:14;10256:35;10253:173;;;10327:10;10321:4;10314:24;10403:4;10397;10390:18;10253:173;10443:37;;;-1:-1:-1;;10560:4:2;10553:20;;;10653:2;10647:4;10637:8;10603:32;10597:4;10591;10586:70;10962:2;10950:15;10947:1274;;;11040:4;11034:11;11151:10;11148:1;11141:21;11200:8;11193:4;11190:1;11186:12;11179:30;11247:4;11240;11237:1;11233:12;11226:26;11290:2;11283:4;11280:1;11276:12;11269:24;11331:6;11324:4;11321:1;11317:12;11310:28;11376:4;11369;11366:1;11362:12;11355:26;11419:11;11412:4;11409:1;11405:12;11398:33;11488:11;11475;11468:4;11465:1;11461:12;11448:52;11634:4;11631:1;11617:11;11611:4;11607:22;11600:4;11597:1;11593:12;11590:1;11586:2;11579:5;11574:65;11564:347;;11666:16;11663:230;;;11802:16;11796:4;11793:1;11778:41;11854:16;11851:1;11844:27;11663:230;12023:8;;12033:20;12020:34;12010:197;;12091:10;12085:4;12078:24;12184:4;12178;12171:18;12010:197;;10947:1274;8225:4012;;;;;;:::o;8348:349:1:-;12517:13;:11;:13::i;:::-;8520:8:::1;8516:2;8512:17;8502:150;;8562:10;8556:4;8549:24;8633:4;8627;8620:18;8502:150;8671:19;8681:8;8671:9;:19::i;10116:336:0:-:0;10194:7;10209:16;10228:7;10239:1;10228:12;:49;;10262:15;;10228:49;;;10243:16;;10228:49;10209:68;;10283:12;10319:7;10330:1;10319:12;:27;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;10348:7;10357:8;10308:58;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;10298:69;;10308:58;10298:69;;;;10415:11;;10116:336;-1:-1:-1;;;;;10116:336:0:o;9112:196::-;9180:27;9192:2;9196:7;9205:1;9180:11;:27::i;:::-;9213:20;;;;:11;:20;;;;;:22;;;;;;:::i;:::-;;;;-1:-1:-1;;9246:57:0;;;20869:25:7;;;9301:1:0;20925:2:7;20910:18;;20903:34;9285:4:0;;9273:1;;9246:57;;;;;;20842:18:7;9246:57:0;;;;;;;;9112:196;;:::o;15428:1222::-;15514:11;;15534:8;;;15506:49;;;;;;;;21122:25:7;15544:10:0;21163:18:7;;;21156:83;15465:7:0;;;;;;15558:1;;15514:11;;;;;15506:27;;21095:18:7;;15506:49:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;:53;;;;:::i;:::-;15489:70;-1:-1:-1;15565:13:0;15581:11;;:19;;15599:1;15581:19;;;15595:1;15581:19;15687:123;;;;;;;;15715:14;;15687:123;;15715:11;:14;15741;;;;;15687:123;;;;;;15773:8;;;15687:123;;;;;;;;;;;;15670:11;:141;;;;;;;-1:-1:-1;15670:141:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;15829:18;;15565:35;;;;;;-1:-1:-1;15853:11:0;;;;15829:22;;15715:11;15829:22;:::i;:::-;15866:11;15878:18;;15822:80;;15866:11;15878:22;;15899:1;;15878:22;:::i;:::-;15866:35;;;;;;;;:::i;:::-;;;;;;;;;;;15822:80;;;;;21661:13:7;;21643:32;;21731:4;21719:17;;21713:24;21706:4;21691:20;;21684:54;21794:4;21782:17;;21776:24;21769:4;21754:20;;21747:54;21857:4;21845:17;;;21839:24;21832:4;21817:20;;21810:54;21630:3;21615:19;;21439:431;15822:80:0;;;;;;;;15977:5;15986:1;15977:10;15973:87;;15997:15;:17;;;:15;:17;;;:::i;:::-;;;;;;15973:87;;;16035:16;:18;;;:16;:18;;;:::i;:::-;;;;;;15973:87;16066:20;16089:18;;;:11;:18;;;;;;16118:16;;16114:215;;16165:1;16144:18;;;:11;:18;;;;;;;;:22;;;16248:74;;20869:25:7;;;20910:18;;;20903:34;;;16283:4:0;;16263:10;;16248:74;;20842:18:7;16248:74:0;;;;;;;16114:215;16415:19;;;;:11;:19;;;;;;16437:1;-1:-1:-1;16411:206:0;;;16457:19;;;;:11;:19;;;;;;;;;:24;:61;;16503:15;16457:61;;;16484:16;16457:61;16448:6;:70;;;;;;;;;;;;;;:::i;:::-;;;;;;16411:206;;;16578:32;16596:14;16578:15;:32;:::i;:::-;16567:8;:43;16411:206;-1:-1:-1;16631:6:0;;16639:5;;-1:-1:-1;15428:1222:0;-1:-1:-1;15428:1222:0:o;9581:202::-;9651:29;9663:4;9669:7;9678:1;9651:11;:29::i;:::-;9686:20;;;;:11;:20;;;;;:22;;;;;;:::i;:::-;;;;-1:-1:-1;;9719:59:0;;;20869:25:7;;;9776:1:0;20925:2:7;20910:18;;20903:34;9763:1:0;;9748:4;;9719:59;;;;;;20842:18:7;9719:59:0;20687:256:7;2768:3517:4;-1:-1:-1;;;;;;42997:20:4;;2975:11;;2955:6;;2971:44;3002:13;2971:44;3104:4;3100:9;3143:6;3137:13;3187:7;3181:14;3246:10;3239:4;3233:11;3229:28;3489:16;3548:1;3539:7;3535:15;3529:22;3730:5;3725:3;3721:15;3714:23;3706:5;3701:3;3697:15;3693:45;3686:52;;4096:3;4081:13;4078:22;4064:1525;;4283:1;4275:4;4259:13;4254:3;4251:22;4247:33;4242:3;4238:43;4234:51;4443:3;4436:11;4428:3;4422:4;4418:14;4409:7;4405:28;4398:4;4392:11;4388:46;4385:63;4375:357;;4581:6;4574:5;4570:18;4566:1;4557:7;4553:15;4546:43;4646:6;4640:4;4636:17;4627:7;4623:31;4617:4;4610:45;4709:5;;;4375:357;4858:4;4851;4845:11;4841:22;4919:6;4913:4;4909:17;4897:10;4893:34;4887:4;4880:48;4986:10;4978:6;4971:26;5148:1;5141:4;5129:10;5125:21;5121:29;5106:239;5213:15;;;5207:22;5187:18;;;5180:50;5256:9;;5305:22;5106:239;5305:22;-1:-1:-1;5459:18:4;;;5439;;;5432:46;5443:10;-1:-1:-1;4064:1525:4;4068:2;;5699:4;5693;5690:14;5687:112;;-1:-1:-1;5736:4:4;5723:18;;5775:10;5687:112;5913:1;5906:4;5899;5893:11;5889:22;5885:30;5870:235;5988:12;;;5982:19;5952:24;;;5948:32;;5941:61;6024:9;;6069:22;5870:235;6069:22;-1:-1:-1;6165:1:4;6125:38;;;6142:4;6125:38;6118:49;6218:30;;;-1:-1:-1;;2768:3517:4;;;;:::o;6111:1560:6:-;6167:20;6618:4;6611;6605:11;6601:22;6591:32;;6661:4;6653:6;6649:17;6643:4;6636:31;6715:1;6707:6;6700:17;6780:6;6874:1;6870:6;7083:5;7065:398;7124:14;;;;7314:2;7328;7318:13;;7310:22;7124:14;7294:39;7368:2;7358:13;;7424:25;7065:398;7424:25;-1:-1:-1;;7485:16:6;;;7524:17;;;;7617;;;7524;6111:1560;-1:-1:-1;6111:1560:6:o;4032:132:3:-;4090:20;4131:26;4138:4;4144:5;4151;4131:6;:26::i;7292:355:1:-;7504:11;7498:18;7488:8;7485:32;7475:156;;7550:10;7544:4;7537:24;7612:4;7606;7599:18;43666:310:2;43866:104;;6145:1089:1;6857:11;7093:16;;6941:26;;;;;;;7053:38;7050:1;;7042:78;7177:27;6145:1089::o;19174:494:0:-;19244:16;19234:6;;;;:26;;;;;;;;:::i;:::-;;19226:51;;;;;;;;;;;;;;;;;19283:12;19298:14;;;:11;:14;;;;;;:19;:27;;19324:1;19298:27;;;19320:1;19298:27;19283:42;;19339:17;;;;:11;:17;;;;;;;;;19283:42;;-1:-1:-1;19339:22:0;19331:47;;;;;;;;;;;;;;;;;19392:25;19404:6;19412:4;19392:11;:25::i;:::-;19421:1;19392:30;19384:55;;;;;;;;;;;;;;;;;19445:28;19460:6;19468:4;19445:14;:28::i;:::-;19580:17;;;;19600:1;19580:17;;;;;;;;:21;;;19607:24;;;;19616:15;19607:24;;;19637:26;;;;;;;;;;;;19643:6;;19580:17;;19637:5;:26::i;:::-;19220:448;19174:494;:::o;10779:298::-;10865:16;10884:7;10895:1;10884:12;:49;;10918:15;;10884:49;;;10899:16;;10884:49;10865:68;;10939:12;10975:7;10986:1;10975:12;:27;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;11004:7;11013:8;10964:58;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;10954:69;;;;;;10939:84;;11060:6;11054:4;11047:20;11039:34;;10779:298;;;:::o;1005:2892:3:-;1118:20;1244:4;1238:11;1266:10;1263:2618;;;1466:1;1462;1450:10;1446:18;1442:26;1439:1;1435:34;1577:4;1571:11;1561:21;;1947:34;1941:4;1934:48;2074:6;2063:8;2056:16;2052:29;2016:34;2012:70;2006:4;1999:84;2189:4;2181:6;2177:17;2231:13;2226:3;2222:23;2299:10;2292:4;2286;2282:15;2278:32;2353:7;2347:14;2436:4;2427:7;2420:21;2568:623;2620:1;2614:4;2610:12;2602:20;;2682:4;2676:11;2822:4;2814:5;2810:2;2806:14;2802:25;2796:32;2793:1;2785:44;2887:4;2879:5;2875:2;2871:14;2867:25;2861:32;2858:1;2850:44;2951:4;2943:5;2940:1;2936:13;2932:24;2926:31;2923:1;2915:43;3007:4;3000:5;2996:16;2990:23;2987:1;2979:35;;3053:4;3047:11;3042:3;3035:24;3097:1;3092:3;3088:11;3081:18;;3158:3;3153;3150:12;2568:623;3140:33;3208:29;;3318:4;3309:14;3303:4;3296:28;3587:16;3463:1;3447:18;;3444:1;3440:26;3574:11;;;3567:37;;;;3752:1;3693:17;;3686:25;3682:33;;;3739:11;;;;3732:22;3824:21;;3809:37;;1263:2618;;1005:2892;;;;;:::o;21034:1574:2:-;21135:128;;21230:15;42317:188;;;;;21180:72;21357:2;21353;21349:11;21434:3;21424:136;;21470:10;21464:4;21457:24;21541:4;21535;21528:18;21424:136;21667:25;21661:4;21654:39;21723:2;21717:4;21710:16;21756:2;21750:4;21743:16;21813:4;21807;21797:21;21864:13;21858:20;21938:6;21921:15;21917:28;21984:15;21968:14;21965:35;21962:173;;;22036:10;22030:4;22023:24;22112:4;22106;22099:18;21962:173;22174:14;22159:13;22152:37;;;;22275:6;22269:4;22262:20;22367:3;22363:2;22359:12;22356:1;22346:8;22312:32;22306:4;22300;22295:77;-1:-1:-1;44193:14:2;;22526:75;;;22544:57;22576:1;22580:2;22584;22588:6;22596:4;44704;44698:11;44807:10;44804:1;44797:21;44852:8;44845:4;44842:1;44838:12;44831:30;44911:4;44907:2;44903:13;44899:2;44895:22;44888:4;44885:1;44881:12;44874:44;44952:2;44945:4;44942:1;44938:12;44931:24;44989:6;44982:4;44979:1;44975:12;44968:28;45030:4;45023;45020:1;45016:12;45009:26;45063:4;45057:11;45102:1;45095:4;45092:1;45088:12;45081:23;45120:1;45117:71;;;45183:1;45176:4;45173:1;45169:12;45166:1;45159:4;45153;45149:15;45146:1;45139:5;45128:57;45124:62;45117:71;45304:4;45301:1;45297;45291:4;45287:12;45280:4;45277:1;45273:12;45270:1;45266:2;45259:5;45254:55;45244:313;;45332:16;45329:214;;;45460:16;45454:4;45451:1;45436:41;45508:16;45505:1;45498:27;45329:214;-1:-1:-1;45661:8:2;;45671:20;45658:34;45648:185;;45725:10;45719:4;45712:24;45814:4;45808;45801:18;14:226:7;73:6;126:2;114:9;105:7;101:23;97:32;94:52;;;142:1;139;132:12;94:52;-1:-1:-1;187:23:7;;14:226;-1:-1:-1;14:226:7:o;641:196::-;709:20;;769:42;758:54;;748:65;;738:93;;827:1;824;817:12;738:93;641:196;;;:::o;842:300::-;910:6;918;971:2;959:9;950:7;946:23;942:32;939:52;;;987:1;984;977:12;939:52;1010:29;1029:9;1010:29;:::i;:::-;1000:39;1108:2;1093:18;;;;1080:32;;-1:-1:-1;;;842:300:7:o;1329:332::-;1387:6;1440:2;1428:9;1419:7;1415:23;1411:32;1408:52;;;1456:1;1453;1446:12;1408:52;1495:9;1482:23;1545:66;1538:5;1534:78;1527:5;1524:89;1514:117;;1627:1;1624;1617:12;1514:117;1650:5;1329:332;-1:-1:-1;;;1329:332:7:o;1858:250::-;1943:1;1953:113;1967:6;1964:1;1961:13;1953:113;;;2043:11;;;2037:18;2024:11;;;2017:39;1989:2;1982:10;1953:113;;;-1:-1:-1;;2100:1:7;2082:16;;2075:27;1858:250::o;2113:341::-;2166:3;2204:5;2198:12;2231:6;2226:3;2219:19;2247:76;2316:6;2309:4;2304:3;2300:14;2293:4;2286:5;2282:16;2247:76;:::i;:::-;2368:2;2356:15;2373:66;2352:88;2343:98;;;;2443:4;2339:109;;2113:341;-1:-1:-1;;2113:341:7:o;2459:231::-;2608:2;2597:9;2590:21;2571:4;2628:56;2680:2;2669:9;2665:18;2657:6;2628:56;:::i;2695:160::-;2760:20;;2816:13;;2809:21;2799:32;;2789:60;;2845:1;2842;2835:12;2860:180;2916:6;2969:2;2957:9;2948:7;2944:23;2940:32;2937:52;;;2985:1;2982;2975:12;2937:52;3008:26;3024:9;3008:26;:::i;3045:186::-;3104:6;3157:2;3145:9;3136:7;3132:23;3128:32;3125:52;;;3173:1;3170;3163:12;3125:52;3196:29;3215:9;3196:29;:::i;3236:184::-;3288:77;3285:1;3278:88;3385:4;3382:1;3375:15;3409:4;3406:1;3399:15;3425:394;3566:2;3551:18;;3599:1;3588:13;;3578:201;;3635:77;3632:1;3625:88;3736:4;3733:1;3726:15;3764:4;3761:1;3754:15;3578:201;3788:25;;;3425:394;:::o;3824:265::-;3892:6;3945:2;3933:9;3924:7;3920:23;3916:32;3913:52;;;3961:1;3958;3951:12;3913:52;4000:9;3987:23;4039:1;4032:5;4029:12;4019:40;;4055:1;4052;4045:12;4094:367;4157:8;4167:6;4221:3;4214:4;4206:6;4202:17;4198:27;4188:55;;4239:1;4236;4229:12;4188:55;-1:-1:-1;4262:20:7;;4305:18;4294:30;;4291:50;;;4337:1;4334;4327:12;4291:50;4374:4;4366:6;4362:17;4350:29;;4434:3;4427:4;4417:6;4414:1;4410:14;4402:6;4398:27;4394:38;4391:47;4388:67;;;4451:1;4448;4441:12;4388:67;4094:367;;;;;:::o;4466:347::-;4517:8;4527:6;4581:3;4574:4;4566:6;4562:17;4558:27;4548:55;;4599:1;4596;4589:12;4548:55;-1:-1:-1;4622:20:7;;4665:18;4654:30;;4651:50;;;4697:1;4694;4687:12;4651:50;4734:4;4726:6;4722:17;4710:29;;4786:3;4779:4;4770:6;4762;4758:19;4754:30;4751:39;4748:59;;;4803:1;4800;4793:12;4818:1221;4978:6;4986;4994;5002;5010;5018;5026;5034;5087:3;5075:9;5066:7;5062:23;5058:33;5055:53;;;5104:1;5101;5094:12;5055:53;5127:29;5146:9;5127:29;:::i;:::-;5117:39;;5175:38;5209:2;5198:9;5194:18;5175:38;:::i;:::-;5165:48;;5264:2;5253:9;5249:18;5236:32;5291:18;5283:6;5280:30;5277:50;;;5323:1;5320;5313:12;5277:50;5362:70;5424:7;5415:6;5404:9;5400:22;5362:70;:::i;:::-;5451:8;;-1:-1:-1;5336:96:7;-1:-1:-1;;5539:2:7;5524:18;;5511:32;5568:18;5555:32;;5552:52;;;5600:1;5597;5590:12;5552:52;5639:72;5703:7;5692:8;5681:9;5677:24;5639:72;:::i;:::-;5730:8;;-1:-1:-1;5613:98:7;-1:-1:-1;;5818:3:7;5803:19;;5790:33;5848:18;5835:32;;5832:52;;;5880:1;5877;5870:12;5832:52;5919:60;5971:7;5960:8;5949:9;5945:24;5919:60;:::i;:::-;4818:1221;;;;-1:-1:-1;4818:1221:7;;-1:-1:-1;4818:1221:7;;;;;;5998:8;-1:-1:-1;;;4818:1221:7:o;6044:768::-;6166:6;6174;6182;6190;6243:2;6231:9;6222:7;6218:23;6214:32;6211:52;;;6259:1;6256;6249:12;6211:52;6299:9;6286:23;6332:18;6324:6;6321:30;6318:50;;;6364:1;6361;6354:12;6318:50;6403:70;6465:7;6456:6;6445:9;6441:22;6403:70;:::i;:::-;6492:8;;-1:-1:-1;6377:96:7;-1:-1:-1;;6580:2:7;6565:18;;6552:32;6609:18;6596:32;;6593:52;;;6641:1;6638;6631:12;6593:52;6680:72;6744:7;6733:8;6722:9;6718:24;6680:72;:::i;:::-;6044:768;;;;-1:-1:-1;6771:8:7;-1:-1:-1;;;;6044:768:7:o;6817:611::-;7007:2;7019:21;;;7089:13;;6992:18;;;7111:22;;;6959:4;;7190:15;;;7164:2;7149:18;;;6959:4;7233:169;7247:6;7244:1;7241:13;7233:169;;;7308:13;;7296:26;;7351:2;7377:15;;;;7342:12;;;;7269:1;7262:9;7233:169;;;-1:-1:-1;7419:3:7;;6817:611;-1:-1:-1;;;;;6817:611:7:o;7664:868::-;7914:2;7926:21;;;7996:13;;7899:18;;;8018:22;;;7866:4;;8097:15;;;8071:2;8056:18;;;7866:4;8140:366;8154:6;8151:1;8148:13;8140:366;;;8219:6;8213:13;8257:2;8251:9;8246:3;8239:22;8309:2;8305;8301:11;8295:18;8290:2;8285:3;8281:12;8274:40;8362:2;8358;8354:11;8348:18;8343:2;8338:3;8334:12;8327:40;8417:4;8413:2;8409:13;8403:20;8396:4;8391:3;8387:14;8380:44;;8453:4;8448:3;8444:14;8437:21;;8493:2;8485:6;8481:15;8471:25;;8176:1;8173;8169:9;8164:14;;8140:366;;8537:254;8602:6;8610;8663:2;8651:9;8642:7;8638:23;8634:32;8631:52;;;8679:1;8676;8669:12;8631:52;8702:29;8721:9;8702:29;:::i;:::-;8692:39;;8750:35;8781:2;8770:9;8766:18;8750:35;:::i;:::-;8740:45;;8537:254;;;;;:::o;8796:260::-;8864:6;8872;8925:2;8913:9;8904:7;8900:23;8896:32;8893:52;;;8941:1;8938;8931:12;8893:52;8964:29;8983:9;8964:29;:::i;:::-;8954:39;;9012:38;9046:2;9035:9;9031:18;9012:38;:::i;9061:793::-;9167:6;9175;9183;9191;9199;9207;9260:3;9248:9;9239:7;9235:23;9231:33;9228:53;;;9277:1;9274;9267:12;9228:53;9300:29;9319:9;9300:29;:::i;:::-;9290:39;;9348:38;9382:2;9371:9;9367:18;9348:38;:::i;:::-;9338:48;-1:-1:-1;9455:2:7;9440:18;;9427:32;;-1:-1:-1;9556:2:7;9541:18;;9528:32;;-1:-1:-1;9637:3:7;9622:19;;9609:33;9665:18;9654:30;;9651:50;;;9697:1;9694;9687:12;9651:50;9736:58;9786:7;9777:6;9766:9;9762:22;9736:58;:::i;:::-;9061:793;;;;-1:-1:-1;9061:793:7;;-1:-1:-1;9061:793:7;;9813:8;;9061:793;-1:-1:-1;;;9061:793:7:o;9859:184::-;9911:77;9908:1;9901:88;10008:4;10005:1;9998:15;10032:4;10029:1;10022:15;10048:125;10113:9;;;10134:10;;;10131:36;;;10147:18;;:::i;10178:198::-;10220:3;10258:5;10252:12;10273:65;10331:6;10326:3;10319:4;10312:5;10308:16;10273:65;:::i;:::-;10354:16;;;;;10178:198;-1:-1:-1;;10178:198:7:o;10381:574::-;10722:6;10717:3;10710:19;10692:3;10758:6;10752:13;10774:74;10841:6;10837:1;10832:3;10828:11;10821:4;10813:6;10809:17;10774:74;:::i;:::-;10911:10;10907:1;10867:16;;;;10899:10;;;10892:30;-1:-1:-1;10946:2:7;10938:11;;10381:574;-1:-1:-1;10381:574:7:o;11143:1740::-;11804:66;11799:3;11792:79;11901:66;11896:2;11891:3;11887:12;11880:88;11998:66;11993:2;11988:3;11984:12;11977:88;11774:3;12094:6;12088:13;12110:73;12176:6;12171:2;12166:3;12162:12;12157:2;12149:6;12145:15;12110:73;:::i;:::-;12247:66;12242:2;12202:16;;;12234:11;;;12227:87;12344:66;12338:3;12330:12;;12323:88;12436:13;;12458:75;12436:13;12518:3;12510:12;;12505:2;12493:15;;12458:75;:::i;:::-;12575:2;12564:8;12560:2;12556:17;12552:26;12542:36;;;12607:66;12602:2;12598;12594:11;12587:87;12705:6;12699:13;12721:74;12786:8;12781:2;12777;12773:11;12768:2;12760:6;12756:15;12721:74;:::i;:::-;12811:66;12841:35;12849:17;;;12841:35;11037:66;11025:79;;11129:2;11120:12;;10960:178;12811:66;12804:73;11143:1740;-1:-1:-1;;;;;;;11143:1740:7:o;12888:184::-;12940:77;12937:1;12930:88;13037:4;13034:1;13027:15;13061:4;13058:1;13051:15;13077:168;13150:9;;;13181;;13198:15;;;13192:22;;13178:37;13168:71;;13219:18;;:::i;13250:184::-;13302:77;13299:1;13292:88;13399:4;13396:1;13389:15;13423:4;13420:1;13413:15;13439:120;13479:1;13505;13495:35;;13510:18;;:::i;:::-;-1:-1:-1;13544:9:7;;13439:120::o;13564:128::-;13631:9;;;13652:11;;;13649:37;;;13666:18;;:::i;13697:112::-;13729:1;13755;13745:35;;13760:18;;:::i;:::-;-1:-1:-1;13794:9:7;;13697:112::o;13814:496::-;14076:66;14071:3;14064:79;14046:3;14172:6;14166:13;14188:75;14256:6;14251:2;14246:3;14242:12;14235:4;14227:6;14223:17;14188:75;:::i;:::-;14283:16;;;;14301:2;14279:25;;13814:496;-1:-1:-1;;13814:496:7:o;14497:1937::-;15353:66;15348:3;15341:79;15323:3;15449:6;15443:13;15465:75;15533:6;15528:2;15523:3;15519:12;15512:4;15504:6;15500:17;15465:75;:::i;:::-;15604:66;15599:2;15559:16;;;15591:11;;;15584:87;15696:13;;15718:76;15696:13;15780:2;15772:11;;15765:4;15753:17;;15718:76;:::i;:::-;15836:2;15825:8;15821:2;15817:17;15813:26;15803:36;;;15868:66;15863:2;15859;15855:11;15848:87;15966:6;15960:13;15982:76;16049:8;16044:2;16040;16036:11;16029:4;16021:6;16017:17;15982:76;:::i;:::-;16100:2;16089:8;16085:2;16081:17;16077:26;16067:36;;;16131:66;16127:1;16123:2;16119:10;16112:86;16229:6;16223:13;16245:76;16312:8;16307:2;16303;16299:11;16292:4;16284:6;16280:17;16245:76;:::i;:::-;16337:91;16367:60;16393:33;16401:17;;;16393:33;16385:6;16367:60;:::i;:::-;14392:66;14380:79;;14484:1;14475:11;;14315:177;16337:91;16330:98;14497:1937;-1:-1:-1;;;;;;;;;14497:1937:7:o;16621:2978::-;17133:66;17128:3;17121:79;17103:3;17229:6;17223:13;17245:74;17312:6;17308:1;17303:3;17299:11;17292:4;17284:6;17280:17;17245:74;:::i;:::-;17382:66;17378:1;17338:16;;;17370:10;;;17363:86;17478:66;17473:2;17465:11;;17458:87;17574:34;17569:2;17561:11;;17554:55;17639:34;17633:3;17625:12;;17618:56;17704:34;17698:3;17690:12;;17683:56;17769:34;17763:3;17755:12;;17748:56;17834:34;17828:3;17820:12;;17813:56;17899:34;17893:3;17885:12;;17878:56;17964:34;17958:3;17950:12;;17943:56;18029:34;18023:3;18015:12;;18008:56;18094:34;18088:3;18080:12;;18073:56;18159:34;18153:3;18145:12;;18138:56;18224:36;18218:3;18210:12;;18203:58;18291:34;18285:3;18277:12;;18270:56;18356:34;18350:3;18342:12;;18335:56;18421:34;18415:3;18407:12;;18400:56;18486:34;18480:3;18472:12;;18465:56;18551:34;18545:3;18537:12;;18530:56;18616:34;18610:3;18602:12;;18595:56;18681:34;18675:3;18667:12;;18660:56;18746:34;18740:3;18732:12;;18725:56;18811:36;18805:3;18797:12;;18790:58;18878:34;18872:3;18864:12;;18857:56;18943:34;18937:3;18929:12;;18922:56;19008:34;19002:3;18994:12;;18987:56;19073:34;19067:3;19059:12;;19052:56;19138:34;19132:3;19124:12;;19117:56;19203:34;19197:3;19189:12;;19182:56;19268:34;19262:3;19254:12;;19247:56;19333:34;19327:3;19319:12;;19312:56;19398:66;19392:3;19384:12;;19377:88;19496:9;19489:4;19481:13;;19474:32;19522:71;19552:40;19586:4;19578:13;;19570:6;19552:40;:::i;:::-;16516:66;16504:79;;16608:1;16599:11;;16439:177;19522:71;19515:78;16621:2978;-1:-1:-1;;;;;16621:2978:7:o;19604:451::-;19856:31;19851:3;19844:44;19826:3;19917:6;19911:13;19933:75;20001:6;19996:2;19991:3;19987:12;19980:4;19972:6;19968:17;19933:75;:::i;:::-;20028:16;;;;20046:2;20024:25;;19604:451;-1:-1:-1;;19604:451:7:o;20060:422::-;20265:2;20254:9;20247:21;20228:4;20285:56;20337:2;20326:9;20322:18;20314:6;20285:56;:::i;:::-;20389:42;20377:55;;;;20372:2;20357:18;;20350:83;-1:-1:-1;20464:2:7;20449:18;20442:34;20277:64;20060:422;-1:-1:-1;20060:422:7:o;20487:195::-;20526:3;20557:66;20550:5;20547:77;20544:103;;20627:18;;:::i;:::-;-1:-1:-1;20674:1:7;20663:13;;20487:195::o;21250:184::-;21320:6;21373:2;21361:9;21352:7;21348:23;21344:32;21341:52;;;21389:1;21386;21379:12;21341:52;-1:-1:-1;21412:16:7;;21250:184;-1:-1:-1;21250:184:7:o;22128:196::-;22167:3;22195:5;22185:39;;22204:18;;:::i;:::-;-1:-1:-1;22251:66:7;22240:78;;22128:196::o
Swarm Source
ipfs://97b18a00f73692aced0e23bee53d3743cafa4b58d4cc4a6b5a41247f0b2be97a
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
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.