Address Contract Verified
Address
0x05F9067205af1aFFA7DF1C076FC7209407EfcA60
Balance
0 ETH
Nonce
2
Code Size
8440 bytes
Creator
0xF2dFcF5d...F39b at tx 0x62262591...caa0bf
Indexed Transactions
0
Contract Bytecode
8440 bytes
0x608060405234801561001057600080fd5b50600436106101585760003560e01c80637119ca76116100c3578063a1abf77f1161007c578063a1abf77f146103c8578063a4d67809146103d1578063a7ce5a9b146103e4578063d1f6b202146103f7578063e24dc13e146103ff578063f2fde38b1461040757600080fd5b80637119ca7614610343578063715018a61461035a5780638da5cb5b1461036257806392b612941461037357806394d266e31461037a57806395c34e03146103a157600080fd5b80634e9f8e8f116101155780634e9f8e8f1461023a5780635380c1641461025a5780635c975abb14610281578063609b3ab314610293578063688a3741146103225780636d4229c91461033557600080fd5b806301ffc9a71461015d57806327603f3414610185578063375b74c31461019a5780633ef6da87146101d9578063465ac962146102005780634de7508614610213575b600080fd5b61017061016b366004611d04565b61041a565b60405190151581526020015b60405180910390f35b610198610193366004611d80565b610451565b005b6101c17f00000000000000000000000018910aeb9fe4f92734a38604541993a763dbd21a81565b6040516001600160a01b03909116815260200161017c565b6101c17f0000000000000000000000005c2c9094bb47c6fee89abd4a6126fb3fb39de92381565b61019861020e366004611e19565b610527565b6101c17f00000000000000000000000097abea635efdaf4cdc844b8677623cac8d77681481565b61024d610248366004611e32565b610591565b60405161017c9190611e73565b6101c17f000000000000000000000000bbd3f1d05b3a0d9b281c7739c48c3ab3924824ac81565b600054600160a01b900460ff16610170565b6102e76102a1366004611e19565b6003602052600090815260409020546001600160401b0381169061ffff600160401b8204811691600160501b8104909116906001600160a01b03600160601b9091041684565b604080516001600160401b0395909516855261ffff938416602086015291909216908301526001600160a01b0316606082015260800161017c565b610198610330366004611f05565b6106bc565b610198610330366004611f3a565b61034c60015481565b60405190815260200161017c565b6101986106d5565b6000546001600160a01b03166101c1565b6000610170565b6101c17f000000000000000000000000812f5cf0d10539ef9534929940f3aeede3d3d96781565b6101c17f0000000000000000000000001ca97f9a77114a0a6759bd10c18097db8628cb7c81565b61034c60025481565b6101986103df366004611e32565b6106e9565b6101986103f2366004611e32565b610bed565b610198610c43565b610198610c53565b610198610415366004611f75565b610c63565b60006001600160e01b031982166325df830760e21b148061044b57506301ffc9a760e01b6001600160e01b03198316145b92915050565b610459610ce1565b84610476576040516266e68160e51b815260040160405180910390fd5b84831415806104855750828114155b156104a3576040516343714afd60e01b815260040160405180910390fd5b6001805486810182550160005b8681101561051d576105156104c58284611f92565b8989848181106104d7576104d7611fb8565b905060200201358888858181106104f0576104f0611fb8565b9050602002013587878681811061050957610509611fb8565b90506020020135610d2e565b6001016104b0565b5050505050505050565b61052f6112ff565b600254808210610552576040516397d46e7b60e01b815260040160405180910390fd5b60408051828152602081018490527fda0b3cfc04b85577884799375303a6fb55003f942faaec32a81be934a17ab69f910160405180910390a150600255565b6060816001600160401b038111156105ab576105ab611fce565b6040519080825280602002602001820160405280156105fd57816020015b6040805160808101825260008082526020808301829052928201819052606082015282526000199092019101816105c95790505b50905060005b828110156106b5576003600085858481811061062157610621611fb8565b60209081029290920135835250818101929092526040908101600020815160808101835290546001600160401b0381168252600160401b810461ffff90811694830194909452600160501b810490931691810191909152600160601b9091046001600160a01b0316606082015282518390839081106106a2576106a2611fb8565b6020908102919091010152600101610603565b5092915050565b6040516319367fa960e01b815260040160405180910390fd5b6106dd6112ff565b6106e76000611359565b565b80610706576040516266e68160e51b815260040160405180910390fd5b6000816001600160401b0381111561072057610720611fce565b604051908082528060200260200182016040528015610749578160200160208202803683370190505b5090506000826001600160401b0381111561076657610766611fce565b60405190808252806020026020018201604052801561078f578160200160208202803683370190505b5090506000836001600160401b038111156107ac576107ac611fce565b6040519080825280602002602001820160405280156107d5578160200160208202803683370190505b50905060008060005b8681101561089557600080600061080c8b8b8681811061080057610800611fb8565b905060200201356113a9565b9250925092508015610842578288858151811061082b5761082b611fb8565b602002602001018181525050846001019450610868565b8289858151811061085557610855611fb8565b6020026020010181815250508560010195505b8187858151811061087b5761087b611fb8565b6020026020010181815250508360010193505050506107de565b506000826001600160401b038111156108b0576108b0611fce565b6040519080825280602002602001820160405280156108d9578160200160208202803683370190505b5090506000836001600160401b038111156108f6576108f6611fce565b60405190808252806020026020018201604052801561091f578160200160208202803683370190505b5090506000836001600160401b0381111561093c5761093c611fce565b604051908082528060200260200182016040528015610965578160200160208202803683370190505b5090506000846001600160401b0381111561098257610982611fce565b6040519080825280602002602001820160405280156109ab578160200160208202803683370190505b50905060008060005b8c811015610acb5760008c82815181106109d0576109d0611fb8565b6020026020010151905060008c83815181106109ee576109ee611fb8565b602002602001015190506000821115610a63578b8381518110610a1357610a13611fb8565b6020026020010151888681518110610a2d57610a2d611fb8565b60200260200101818152505081898681518110610a4c57610a4c611fb8565b602002602001018181525050846001019450610ac1565b8b8381518110610a7557610a75611fb8565b6020026020010151868581518110610a8f57610a8f611fb8565b60200260200101818152505080878581518110610aae57610aae611fb8565b6020026020010181815250508360010193505b50506001016109b4565b508715610b5557604051632225750f60e21b81527f00000000000000000000000097abea635efdaf4cdc844b8677623cac8d7768146001600160a01b031690638895d43c90610b229033908a908a9060040161201f565b600060405180830381600087803b158015610b3c57600080fd5b505af1158015610b50573d6000803e3d6000fd5b505050505b8615610bde57604051632225750f60e21b81527f0000000000000000000000005c2c9094bb47c6fee89abd4a6126fb3fb39de9236001600160a01b031690638895d43c90610bab9033908890889060040161201f565b600060405180830381600087803b158015610bc557600080fd5b505af1158015610bd9573d6000803e3d6000fd5b505050505b50505050505050505050505050565b80610c0a576040516266e68160e51b815260040160405180910390fd5b60005b81811015610c3e57610c36838383818110610c2a57610c2a611fb8565b905060200201356115bc565b600101610c0d565b505050565b610c4b6112ff565b6106e7611b2e565b610c5b6112ff565b6106e7611b8e565b610c6b6112ff565b6001600160a01b038116610cd55760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b610cde81611359565b50565b600054600160a01b900460ff16156106e75760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610ccc565b8115801590610d3c57508015155b15610d5a57604051635f607c7b60e01b815260040160405180910390fd5b82610d7857604051630fc6d19360e01b815260040160405180910390fd5b617fff811180610d895750617fff82115b15610da75760405163af70c01d60e01b815260040160405180910390fd5b3360008315610db65783610db8565b825b9050808315610dc657618000175b6000878152600360209081526040918290208054426001600160401b031669ffffffffffffffffffff1990911617600160401b61ffff8b811682029290921769ffffffffffffffffffff16600160501b878416026bffffffffffffffffffffffff1617600160601b6001600160a01b038a169081029190911793849055855188841681529190930490911692810192909252861515928201929092528891907f6935deae4e3ea51c19570a2359d90508f7beab6bfb1ec3fd44a10ce05a0736f89060600160405180910390a3826001600160a01b03167f000000000000000000000000812f5cf0d10539ef9534929940f3aeede3d3d9676001600160a01b0316636352211e886040518263ffffffff1660e01b8152600401610eea91815260200190565b60206040518083038186803b158015610f0257600080fd5b505afa158015610f16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3a919061205f565b6001600160a01b031614610f61576040516314d737cb60e01b815260040160405180910390fd5b6040516371b855a360e11b81526001600160a01b037f000000000000000000000000812f5cf0d10539ef9534929940f3aeede3d3d967169063e370ab4690610fd19086907f00000000000000000000000018910aeb9fe4f92734a38604541993a763dbd21a908b9060040161207c565b600060405180830381600087803b158015610feb57600080fd5b505af1158015610fff573d6000803e3d6000fd5b50505050600085111561117e57826001600160a01b03167f000000000000000000000000bbd3f1d05b3a0d9b281c7739c48c3ab3924824ac6001600160a01b0316636352211e876040518263ffffffff1660e01b815260040161106491815260200190565b60206040518083038186803b15801561107c57600080fd5b505afa158015611090573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b4919061205f565b6001600160a01b0316146110db576040516355f77cdb60e11b815260040160405180910390fd5b6040516371b855a360e11b81526001600160a01b037f000000000000000000000000bbd3f1d05b3a0d9b281c7739c48c3ab3924824ac169063e370ab469061114b9086907f00000000000000000000000018910aeb9fe4f92734a38604541993a763dbd21a908a9060040161207c565b600060405180830381600087803b15801561116557600080fd5b505af1158015611179573d6000803e3d6000fd5b505050505b83156112f657826001600160a01b03167f0000000000000000000000001ca97f9a77114a0a6759bd10c18097db8628cb7c6001600160a01b0316636352211e866040518263ffffffff1660e01b81526004016111dc91815260200190565b60206040518083038186803b1580156111f457600080fd5b505afa158015611208573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122c919061205f565b6001600160a01b03161461125357604051638cd32acb60e01b815260040160405180910390fd5b6040516371b855a360e11b81526001600160a01b037f0000000000000000000000001ca97f9a77114a0a6759bd10c18097db8628cb7c169063e370ab46906112c39086907f00000000000000000000000018910aeb9fe4f92734a38604541993a763dbd21a90899060040161207c565b600060405180830381600087803b1580156112dd57600080fd5b505af11580156112f1573d6000803e3d6000fd5b505050505b50505050505050565b6000546001600160a01b031633146106e75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610ccc565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000806000806000806000806113be89611bca565b94509450945094509450806113e657604051633f04771560e21b815260040160405180910390fd5b88856001600160a01b03167fcbb6d73f9f07129d8c57927b8d97eb7e58900b8c6943027ae78b78c2f46e067c84604051611424911515815260200190565b60405180910390a381156114b1576040516326f05fa960e21b8152600481018490527f0000000000000000000000001ca97f9a77114a0a6759bd10c18097db8628cb7c6001600160a01b031690639bc17ea490602401600060405180830381600087803b15801561149457600080fd5b505af11580156114a8573d6000803e3d6000fd5b50505050611532565b8215611532576040516326f05fa960e21b8152600481018490527f000000000000000000000000bbd3f1d05b3a0d9b281c7739c48c3ab3924824ac6001600160a01b031690639bc17ea490602401600060405180830381600087803b15801561151957600080fd5b505af115801561152d573d6000803e3d6000fd5b505050505b6040516326f05fa960e21b8152600481018590527f000000000000000000000000812f5cf0d10539ef9534929940f3aeede3d3d9676001600160a01b031690639bc17ea490602401600060405180830381600087803b15801561159457600080fd5b505af11580156115a8573d6000803e3d6000fd5b50959b949a50929850929650505050505050565b60008060008060006115cd86611bca565b60405162c06f9d60e61b8152306004820152949950929750909550935091506000906001600160a01b037f000000000000000000000000812f5cf0d10539ef9534929940f3aeede3d3d967169063301be7409060240160206040518083038186803b15801561163b57600080fd5b505afa15801561164f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061167391906120a0565b1580611712575060405162c06f9d60e61b81523060048201527f000000000000000000000000bbd3f1d05b3a0d9b281c7739c48c3ab3924824ac6001600160a01b03169063301be7409060240160206040518083038186803b1580156116d857600080fd5b505afa1580156116ec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061171091906120a0565b155b806117b0575060405162c06f9d60e61b81523060048201527f0000000000000000000000001ca97f9a77114a0a6759bd10c18097db8628cb7c6001600160a01b03169063301be7409060240160206040518083038186803b15801561177657600080fd5b505afa15801561178a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ae91906120a0565b155b8061184f575060405163ed1e008560e01b81523060048201527f00000000000000000000000097abea635efdaf4cdc844b8677623cac8d7768146001600160a01b03169063ed1e00859060240160206040518083038186803b15801561181557600080fd5b505afa158015611829573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061184d91906120a0565b155b806118ee575060405163ed1e008560e01b81523060048201527f0000000000000000000000005c2c9094bb47c6fee89abd4a6126fb3fb39de9236001600160a01b03169063ed1e00859060240160206040518083038186803b1580156118b457600080fd5b505afa1580156118c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118ec91906120a0565b155b156118f7575060015b818015611902575080155b1561192057604051632874237d60e01b815260040160405180910390fd5b86866001600160a01b03167f3e583d96dc451462c8861b49a608d6c8aab11e997707155b619cfc0ee7ea13ac8560405161195e911515815260200190565b60405180910390a36040516323b872dd60e01b81526001600160a01b037f000000000000000000000000812f5cf0d10539ef9534929940f3aeede3d3d96716906323b872dd906119d6907f00000000000000000000000018910aeb9fe4f92734a38604541993a763dbd21a908a908a9060040161207c565b600060405180830381600087803b1580156119f057600080fd5b505af1158015611a04573d6000803e3d6000fd5b5050505060008411156112f6578215611abe576040516323b872dd60e01b81526001600160a01b037f0000000000000000000000001ca97f9a77114a0a6759bd10c18097db8628cb7c16906323b872dd90611a87907f00000000000000000000000018910aeb9fe4f92734a38604541993a763dbd21a908a90899060040161207c565b600060405180830381600087803b158015611aa157600080fd5b505af1158015611ab5573d6000803e3d6000fd5b505050506112f6565b6040516323b872dd60e01b81526001600160a01b037f000000000000000000000000bbd3f1d05b3a0d9b281c7739c48c3ab3924824ac16906323b872dd906112c3907f00000000000000000000000018910aeb9fe4f92734a38604541993a763dbd21a908a90899060040161207c565b611b36610ce1565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611b713390565b6040516001600160a01b03909116815260200160405180910390a1565b611b96611cb4565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33611b71565b6000818152600360209081526040808320815160808101835290546001600160401b038116808352600160401b820461ffff908116958401869052600160501b8304908116948401859052600160601b9092046001600160a01b03166060840181905295617fff8316946001600f9490941c841690931493909290919081611c655760405163a15f264160e01b815260040160405180910390fd5b6001600160a01b0388163314611c8e5760405163294ed80560e21b815260040160405180910390fd5b506002546000898152600360205260408120554291909103101591505091939590929450565b600054600160a01b900460ff166106e75760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610ccc565b600060208284031215611d1657600080fd5b81356001600160e01b031981168114611d2e57600080fd5b9392505050565b60008083601f840112611d4757600080fd5b5081356001600160401b03811115611d5e57600080fd5b6020830191508360208260051b8501011115611d7957600080fd5b9250929050565b60008060008060008060608789031215611d9957600080fd5b86356001600160401b0380821115611db057600080fd5b611dbc8a838b01611d35565b90985096506020890135915080821115611dd557600080fd5b611de18a838b01611d35565b90965094506040890135915080821115611dfa57600080fd5b50611e0789828a01611d35565b979a9699509497509295939492505050565b600060208284031215611e2b57600080fd5b5035919050565b60008060208385031215611e4557600080fd5b82356001600160401b03811115611e5b57600080fd5b611e6785828601611d35565b90969095509350505050565b602080825282518282018190526000919060409081850190868401855b82811015611ee357815180516001600160401b031685528681015161ffff908116888701528682015116868601526060908101516001600160a01b03169085015260809093019290850190600101611e90565b5091979650505050505050565b6001600160a01b0381168114610cde57600080fd5b600080600060608486031215611f1a57600080fd5b8335611f2581611ef0565b95602085013595506040909401359392505050565b60008060008060808587031215611f5057600080fd5b8435611f5b81611ef0565b966020860135965060408601359560600135945092505050565b600060208284031215611f8757600080fd5b8135611d2e81611ef0565b60008219821115611fb357634e487b7160e01b600052601160045260246000fd5b500190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b600081518084526020808501945080840160005b8381101561201457815187529582019590820190600101611ff8565b509495945050505050565b6001600160a01b038416815260606020820181905260009061204390830185611fe4565b82810360408401526120558185611fe4565b9695505050505050565b60006020828403121561207157600080fd5b8151611d2e81611ef0565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6000602082840312156120b257600080fd5b81518015158114611d2e57600080fdfea2646970667358221220c18671518d32c1d35b894961a141ba8e10a1c2877cd5bdadef34a479aeed07c364736f6c63430008090033
Verified Source Code Full Match
Compiler: v0.8.9+commit.e5eed63a
EVM: london
Optimization: Yes (200 runs)
IAdventure.sol 35 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @title IAdventure
* @author Limit Break, Inc.
* @notice The base interface that all `Adventure` contracts must conform to.
* @dev All contracts that implement the adventure/quest system and interact with an {IAdventurous} token are required to implement this interface.
*/
interface IAdventure is IERC165 {
/**
* @dev Returns whether or not quests on this adventure lock tokens.
* Developers of adventure contract should ensure that this is immutable
* after deployment of the adventure contract. Failure to do so
* can lead to error that deadlock token transfers.
*/
function questsLockTokens() external view returns (bool);
/**
* @dev A callback function that AdventureERC721 must invoke when a quest has been successfully entered.
* Throws if the caller is not an expected AdventureERC721 contract designed to work with the Adventure.
* Not permitted to throw in any other case, as this could lead to tokens being locked in quests.
*/
function onQuestEntered(address adventurer, uint256 tokenId, uint256 questId) external;
/**
* @dev A callback function that AdventureERC721 must invoke when a quest has been successfully exited.
* Throws if the caller is not an expected AdventureERC721 contract designed to work with the Adventure.
* Not permitted to throw in any other case, as this could lead to tokens being locked in quests.
*/
function onQuestExited(address adventurer, uint256 tokenId, uint256 questId, uint256 questStartTimestamp) external;
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
VillainUnmaskingAdventure.sol 518 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;
import "./IMintableVillain.sol";
import "./IMinterWhitelist.sol";
import "./VillainCustodian.sol";
import "@limit-break/adventures/IAdventure.sol";
import "@limit-break/adventures/IAdventurousERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
error CallbackNotImplemented();
error CallerDidNotCreateClaimId();
error CallerNotOwnerOfSuperVillainPotion();
error CallerNotOwnerOfMaskedVillain();
error CallerNotOwnerOfVillainPotion();
error CannotIncludeMoreThanOnePotion();
error CannotSpecifyZeroAddressForSuperVillainContract();
error CannotSpecifyZeroAddressForVillainContract();
error CannotSpecifyZeroAddressForSuperVillainPotionContract();
error CannotSpecifyZeroAddressForMaskedVillainContract();
error CannotSpecifyZeroAddressForVillainPotionContract();
error CompleteQuestToUnmaskVillain();
error InputArrayLengthMismatch();
error MustIncludeMaskedVillain();
error NewUnmaskingDurationMustBeLessThanCurrentDuration();
error NoUnmaskingQuestFoundForSpecifiedClaimId();
error PotionGreaterThanAllocatedSpace();
error QuantityMustBeGreaterThanZero();
error QuestCompleteVillainMustBeUnmasked();
/**
* @title VillainUnmaskingAdventure
* @author Limit Break, Inc.
* @notice An adventure that unmasks villains based on the provided potion
*/
contract VillainUnmaskingAdventure is Ownable, Pausable, ERC165, IAdventure {
struct UnmaskingQuest {
uint64 startTimestamp;
uint16 villainTokenId;
uint16 potionBitmap;
address adventurer;
}
/// @dev An unchangeable reference to the villain potion contract optionally used in an unmasking quest
IAdventurousERC721 immutable public villainPotionContract;
/// @dev An unchangeable reference to the super villain potion contract optionally used in an unmasking quest
IAdventurousERC721 immutable public superVillainPotionContract;
/// @dev An unchangeable reference to the masked villain contract to be unmasked
IAdventurousERC721 immutable public maskedVillainContract;
/// @dev An unchangeable reference to the villain contract unmasked at the end of a quest
IMintableVillain immutable public villainContract;
/// @dev An unchangeable reference to the super villain contract unmasked at the end of a quest
IMintableVillain immutable public superVillainContract;
/// @dev An unchangeable reference to a custodial holding contract for masked villains and potions
VillainCustodian immutable public custodian;
/// @dev A counter for claim ids
uint256 public lastClaimId;
/// @dev The amount of time the user must remain in a quest to complete it and receive their unmasked villain
uint256 public unmaskingDuration = 7 days;
/// @dev Map claim id to unmasking quest details
mapping (uint256 => UnmaskingQuest) public unmaskingQuestLookup;
/// @dev Designation of uint(1) to be used for bitmap functions
uint constant private ONE = uint(1);
/// @dev Maximum value stored in 15 bits. Used to prevent falsely setting the 16th bit on the potionBitmap.
uint256 constant private MAX_15_BIT_VALUE = 32767;
/// @dev Emitted when an adventurer cancels a villain unmasking
event VillainMasked(address indexed adventurer, uint256 indexed claimId, bool isSuperVillain);
/// @dev Emitted when the unmaskingDuration is updated.
event UnmaskingDurationUpdated(uint256 oldUnmaskingDuration, uint256 newUnmaskingDuration);
/// @dev Emitted when an adventurer starts unmasking a villain
event UnmaskingVillain(address indexed adventurer, uint256 indexed claimId, uint256 potionTokenId, uint256 villainTokenId, bool isSuperVillain);
/// @dev Emitted when an adventurer unmasks their villain
event UnmaskedVillain(address indexed adventurer, uint256 indexed claimId, bool isSuperVillain);
constructor(address villainPotionAddress, address superVillainPotionAddress, address maskedVillainAddress, address villainAddress, address superVillainAddress) {
if(villainPotionAddress == address(0)) {
revert CannotSpecifyZeroAddressForVillainPotionContract();
}
if(superVillainPotionAddress == address(0)) {
revert CannotSpecifyZeroAddressForSuperVillainPotionContract();
}
if(maskedVillainAddress == address(0)) {
revert CannotSpecifyZeroAddressForMaskedVillainContract();
}
if(villainAddress == address(0)) {
revert CannotSpecifyZeroAddressForVillainContract();
}
if(superVillainAddress == address(0)) {
revert CannotSpecifyZeroAddressForSuperVillainContract();
}
villainPotionContract = IAdventurousERC721(villainPotionAddress);
superVillainPotionContract = IAdventurousERC721(superVillainPotionAddress);
maskedVillainContract = IAdventurousERC721(maskedVillainAddress);
villainContract = IMintableVillain(villainAddress);
superVillainContract = IMintableVillain(superVillainAddress);
custodian = new VillainCustodian(address(this), maskedVillainAddress, superVillainPotionAddress, villainPotionAddress);
}
/// @dev A callback function that AdventureERC721 must invoke when a quest has been successfully entered.
/// Throws in all cases quest entry for this adventure is fulfilled via adventureTransferFrom instead of enterQuest, and this callback should not be triggered.
function onQuestEntered(address /*adventurer*/, uint256 /*tokenId*/, uint256 /*questId*/) external override pure {
revert CallbackNotImplemented();
}
/// @dev A callback function that AdventureERC721 must invoke when a quest has been successfully entered.
/// Throws in all cases quest exit for this adventure is fulfilled via transferFrom or adventureBurn instead of exitQuest, and this callback should not be triggered.
function onQuestExited(address /*adventurer*/, uint256 /*tokenId*/, uint256 /*questId*/, uint256 /*questStartTimestamp*/) external override pure {
revert CallbackNotImplemented();
}
/// @dev Returns false - this quest uses hard staking
function questsLockTokens() external override pure returns (bool) {
return false;
}
/// @dev Pauses and blocks adventurers from starting new villain unmasking quests
/// Throws if the adventure is already paused
function pauseNewQuestEntries() external onlyOwner {
_pause();
}
/// @dev Unpauses and allows adventurers to start new villain unmasking quests
/// Throws if the adventure is already unpaused
function unpauseNewQuestEntries() external onlyOwner {
_unpause();
}
/// @dev Sets the unmasking duration for the quest
/// Throws if the unmasking duration is greater than current unmasking duration
///
/// Postconditions:
/// ---------------
/// The unmasking duration is updated to the provided new unmasking duration.
function setUnmaskingDuration(uint256 unmaskingDuration_) external onlyOwner {
uint256 currentUnmaskingDuration = unmaskingDuration;
if(unmaskingDuration_ >= currentUnmaskingDuration) {
revert NewUnmaskingDurationMustBeLessThanCurrentDuration();
}
emit UnmaskingDurationUpdated(currentUnmaskingDuration, unmaskingDuration_);
unmaskingDuration = unmaskingDuration_;
}
/// @notice Returns the mask to multiple villains referenced by the specifed claim ids before the required unmasking duration has been met.
///
/// Throws when `quantity` is zero, where `quantity` is the length of the claim id arrays.
/// Throws when no unmasking quest is found for one or more of the specified claim ids (start timestamp is zero).
/// Throws when the caller did not create one or more of the specified claim id (adventurer not the same as caller).
/// Throws when the one or more of the villains are ready to redeem (required unmasking duration has been met or exceeded).
/// - This is invalid if any of the potions or masked villain contracts are removed from the adventure whitelist or the adventure is removed
/// as a whitelisted minter for the villain or super villain contracts.
/// In these cases, the user can remask the villain to recover their potion and masked villain since redemption is not possible.
///
/// Postconditions:
/// ---------------
/// The masked villains that were in use to unmask have been returned to the adventurer that started the quest.
/// The potions that were in use to unmask the villains have been returned to the adventurer that started the quest.
/// The unmasking quest lookup entries for the specified claim ids have been removed.
/// `quantity` VillainMasked events have been emitted, where `quantity` is the length of the claim id array.
function maskVillainsBatch(uint256[] calldata claimIds) external {
if(claimIds.length == 0) {
revert QuantityMustBeGreaterThanZero();
}
for(uint256 i = 0; i < claimIds.length;) {
_maskVillain(claimIds[i]);
unchecked {
++i;
}
}
}
/// @notice Enters the villain unmasking quests with a batch of specified masked villains and optional potions.
/// Villain Potion token ids may be 0, in which case it means no villain potion will be used to enhance the unmasking.
/// Super Villain token ids may be 0, in which case it means no super villain potion will be used to enhance the unmasking.
///
/// Throws when `quantity` is zero, where `quantity` is the length of the token id arrays.
/// Throws when token id array lengths don't match.
/// Throws when the caller does not own a specified masked villain token.
/// Throws when the caller does not own a specified villain potion token.
/// Throws when the caller does not own a specified super villain potion token.
/// Throws when both a villain potion and super villain potion token are specified (non 0 values for both ids at the same array index).
/// Throws when adventureTransferFrom throws, typically for one of the following reasons:
/// - This adventure contract is not in the adventure whitelist for included contracts.
/// - The caller has not set adventure approval for this contract.
/// Throws when the contract is paused
///
/// Postconditions:
/// ---------------
/// The specified masked villains are now owned by the custodian.
/// The specified potions are now owned by the custodian.
/// The value of the lastClaimId counter has increased by `quantity`, where `quantity` is the length of the token id arrays.
/// The unmasking quest lookup for the newly created claim ids contains the following information:
/// - The block timestamp of this transaction (the time at which unmasking the villain began).
/// - The specified masked villain token id.
/// - A bitmap containing the potion token ID and an indicator in the 16th bit, `1` if it is a super villain, `0` otherwise.
/// - The address of the adventurer that is permitted to retrieve their masked villain and potion or unmask their villain.
/// `quantity` UnmaskingVillain events have been emitted, where `quantity` is the length of the token id arrays.
function startUnmaskingVillainsBatch(uint256[] calldata maskedVillainTokenIds, uint256[] calldata villainPotionTokenIds, uint256[] calldata superVillainPotionTokenIds) external whenNotPaused {
if(maskedVillainTokenIds.length == 0) {
revert QuantityMustBeGreaterThanZero();
}
if(maskedVillainTokenIds.length != villainPotionTokenIds.length || villainPotionTokenIds.length != superVillainPotionTokenIds.length) {
revert InputArrayLengthMismatch();
}
uint256 claimId;
unchecked {
claimId = lastClaimId;
lastClaimId = claimId + maskedVillainTokenIds.length;
++claimId;
}
for(uint256 i = 0; i < maskedVillainTokenIds.length;) {
_startUnmaskingVillain(claimId + i, maskedVillainTokenIds[i], villainPotionTokenIds[i], superVillainPotionTokenIds[i]);
unchecked {
++i;
}
}
}
/// @notice Unmasks multiple villains referenced by the specifed claim ids after the required unmasking duration has been met.
///
/// Throws when `quantity` is zero, where `quantity` is the length of the claim id arrays.
/// Throws when no unmasking quest is found for one or more of the specified claim ids (start timestamp is zero).
/// Throws when the caller did not create one or more of the specified claim ids (adventurer not the same as caller).
/// Throws when one or more of the villains is not ready to unmask (required unmasking duration has not been met).
///
/// Postconditions:
/// ---------------
/// The villain or super villain potion that was in use to unmask the villain has been burnt.
/// The masked villain that was in use to unmask has been burnt.
/// The unmasking quest lookup entry for the specified claim id has been removed.
/// An unmasked villain or super villain has been minted to the adventurer who completed the quest.
/// `quantity` UnmaskedVillain events have been emitted, where `quantity` is the length of the claim id arrays.
function unmaskVillainsBatch(uint256[] calldata claimIds) external {
if(claimIds.length == 0) {
revert QuantityMustBeGreaterThanZero();
}
uint256[] memory tempVillainTokenIds = new uint256[](claimIds.length);
uint256[] memory tempSuperVillainTokenIds = new uint256[](claimIds.length);
uint256[] memory potionTokenIds = new uint256[](claimIds.length);
uint256 villainCounter = 0;
uint256 superVillainCounter = 0;
for(uint256 i = 0; i < claimIds.length;) {
(uint256 villainTokenId, uint256 potionTokenId, bool isSuperVillain) = _unmaskVillain(claimIds[i]);
unchecked {
if (isSuperVillain) {
tempSuperVillainTokenIds[i] = villainTokenId;
++superVillainCounter;
} else {
tempVillainTokenIds[i] = villainTokenId;
++villainCounter;
}
potionTokenIds[i] = potionTokenId;
++i;
}
}
uint256[] memory villainTokenIds = new uint256[](villainCounter);
uint256[] memory villainPotionTokenIds = new uint256[](villainCounter);
uint256[] memory superVillainTokenIds = new uint256[](superVillainCounter);
uint256[] memory superVillainPotionTokenIds = new uint256[](superVillainCounter);
uint256 villainPotionCounter = 0;
uint256 superVillainPotionCounter = 0;
unchecked {
for(uint256 i = 0; i < claimIds.length; ++i) {
uint256 villainTokenId = tempVillainTokenIds[i];
uint256 superVillainTokenId = tempSuperVillainTokenIds[i];
if(villainTokenId > 0) {
villainPotionTokenIds[villainPotionCounter] = potionTokenIds[i];
villainTokenIds[villainPotionCounter] = villainTokenId;
++villainPotionCounter;
} else {
superVillainPotionTokenIds[superVillainPotionCounter] = potionTokenIds[i];
superVillainTokenIds[superVillainPotionCounter] = superVillainTokenId;
++superVillainPotionCounter;
}
}
}
if(villainCounter > 0) {
villainContract.unmaskVillainsBatch(_msgSender(), villainTokenIds, villainPotionTokenIds);
}
if(superVillainCounter > 0) {
superVillainContract.unmaskVillainsBatch(_msgSender(), superVillainTokenIds, superVillainPotionTokenIds);
}
}
/// @dev Enumerates all specified claim ids and returns the unmasking quest details for each.
/// Never use this function in a transaction context - it is fine for a read-only query for
/// external applications, but will consume a lot of gas when used in a transaction.
function getUnmaskingQuestDetailsBatch(uint256[] calldata claimIds) external view returns (UnmaskingQuest[] memory unmaskingQuests) {
unmaskingQuests = new UnmaskingQuest[](claimIds.length);
unchecked {
for(uint256 i = 0; i < claimIds.length; ++i) {
unmaskingQuests[i] = unmaskingQuestLookup[claimIds[i]];
}
}
}
/// @dev ERC-165 interface support
function supportsInterface(bytes4 interfaceId) public view virtual override (ERC165, IERC165) returns (bool) {
return interfaceId == type(IAdventure).interfaceId || super.supportsInterface(interfaceId);
}
/// @dev Records the details of an unmasking quest with the specified claim id and transfers
/// specified masked villain token and potion to the custodian
///
/// Throws when the caller does not own a specified masked villain token.
/// Throws when the caller does not own a specified villain potion token.
/// Throws when the caller does not own a specified super villain potion token.
/// Throws when both a villain potion and super villain potion token are specified (non 0 values for both ids at the same array index).
/// Throws when adventureTransferFrom throws, typically for one of the following reasons:
/// - This adventure contract is not in the adventure whitelist for included contracts.
/// - The caller has not set adventure approval for this contract.
/// Throws when the contract is paused
///
/// Postconditions:
/// ---------------
/// The specified masked villain is now owned by the custodian.
/// The specified potion is now owned by the custodian.
/// The unmasking quest lookup for the newly created claim ids contains the following information:
/// - The block timestamp of this transaction (the time at which unmasking the villain began).
/// - The specified masked villain token id.
/// - A bitmap containing the potion token ID and an indicator in the 16th bit `1` if it is a super villain, `0` otherwise.
/// - The address of the adventurer that is permitted to retrieve their masked villain and potion or unmask their villain.
/// A UnmaskingVillain event has been emitted.
function _startUnmaskingVillain(uint256 claimId, uint256 maskedVillainTokenId, uint256 villainPotionTokenId, uint256 superVillainPotionTokenId) private {
if(villainPotionTokenId != 0 && superVillainPotionTokenId != 0) {
revert CannotIncludeMoreThanOnePotion();
}
if(maskedVillainTokenId == 0) {
revert MustIncludeMaskedVillain();
}
if(superVillainPotionTokenId > MAX_15_BIT_VALUE || villainPotionTokenId > MAX_15_BIT_VALUE) {
revert PotionGreaterThanAllocatedSpace();
}
address caller = _msgSender();
uint16 potionTokenId = villainPotionTokenId == 0 ? uint16(superVillainPotionTokenId) : uint16(villainPotionTokenId);
uint16 potionBitmap = potionTokenId;
if(superVillainPotionTokenId > 0) {
potionBitmap = potionBitmap | uint16(ONE << 15);
}
unmaskingQuestLookup[claimId].startTimestamp = uint64(block.timestamp);
unmaskingQuestLookup[claimId].villainTokenId = uint16(maskedVillainTokenId);
unmaskingQuestLookup[claimId].potionBitmap = potionBitmap;
unmaskingQuestLookup[claimId].adventurer = caller;
emit UnmaskingVillain(caller, claimId, potionTokenId, unmaskingQuestLookup[claimId].villainTokenId, superVillainPotionTokenId > 0);
if (maskedVillainContract.ownerOf(maskedVillainTokenId) != caller) {
revert CallerNotOwnerOfMaskedVillain();
}
maskedVillainContract.adventureTransferFrom(caller, address(custodian), maskedVillainTokenId);
if (villainPotionTokenId > 0) {
if (villainPotionContract.ownerOf(villainPotionTokenId) != caller) {
revert CallerNotOwnerOfVillainPotion();
}
villainPotionContract.adventureTransferFrom(caller, address(custodian), villainPotionTokenId);
}
if (superVillainPotionTokenId > 0) {
if (superVillainPotionContract.ownerOf(superVillainPotionTokenId) != caller) {
revert CallerNotOwnerOfSuperVillainPotion();
}
superVillainPotionContract.adventureTransferFrom(caller, address(custodian), superVillainPotionTokenId);
}
}
/// @dev Returns the mask to the villain referenced by the claim id before the required unmasking duration has been met.
///
/// Throws when no unmasking quest is found for the specified claim id (start timestamp is zero).
/// Throws when the caller did not create the specified claim id (adventurer not the same as caller).
/// Throws when the villain is ready to unmask (required unmasking duration has been met or exceeded).
/// - This is invalid if any of the potions or masked villain contracts are removed from the adventure whitelist or the adventure is removed
/// as a whitelisted minter for the villain or super villain contracts.
/// In these cases, the user can remask the villain to recover their potion and masked villain since redemption is not possible.
///
/// Postconditions:
/// ---------------
/// The masked villain that was in use to unmask has been returned to the adventurer that started the quest.
/// The potion that was in use to unmask the villain has been returned to the adventurer that started the quest.
/// The unmasking quest lookup entry for the specified claim id has been removed.
/// A VillainMasked event has been emitted.
function _maskVillain(uint256 claimId) private {
(address adventurer, uint256 villainTokenId, uint256 potionTokenId, bool isSuperVillain, bool questCompleted) = _getAndClearUnmaskingQuestStatus(claimId);
bool allowUserToReturnMaskAfterQuestCompleted = false;
if(!IAdventureApproval(address(maskedVillainContract)).isAdventureWhitelisted(address(this)) ||
!IAdventureApproval(address(villainPotionContract)).isAdventureWhitelisted(address(this)) ||
!IAdventureApproval(address(superVillainPotionContract)).isAdventureWhitelisted(address(this)) ||
!IMinterWhitelist(address(villainContract)).whitelistedMinters(address(this)) ||
!IMinterWhitelist(address(superVillainContract)).whitelistedMinters(address(this))) {
allowUserToReturnMaskAfterQuestCompleted = true;
}
if(questCompleted && !allowUserToReturnMaskAfterQuestCompleted) {
revert QuestCompleteVillainMustBeUnmasked();
}
emit VillainMasked(adventurer, claimId, isSuperVillain);
maskedVillainContract.transferFrom(address(custodian), adventurer, villainTokenId);
if(potionTokenId > 0) {
if(isSuperVillain) {
superVillainPotionContract.transferFrom(address(custodian), adventurer, potionTokenId);
} else {
villainPotionContract.transferFrom(address(custodian), adventurer, potionTokenId);
}
}
}
/// @dev Unmasks a villain referenced by the claim id after the required unmasking duration has been met.
///
/// Throws when no unmasking quest is found for the specified claim id (start timestamp is zero).
/// Throws when the caller did not create the specified claim id (adventurer not the same as caller).
/// Throws when the villain is not ready to unmask (required unmasking duration has not been met).
///
/// Postconditions:
/// ---------------
/// The villain or super villain potion used to unmask has been burned.
/// The masked villain has been burned.
/// The unmasking quest lookup entry for the specified claim id has been removed.
/// A villain or super villain has been minted to the adventurer who removed the mask.
/// A UnmaskedVillain event has been emitted.
function _unmaskVillain(uint256 claimId) private returns (uint256, uint256, bool) {
(address adventurer, uint256 villainTokenId, uint256 potionTokenId, bool isSuperVillain, bool questCompleted) = _getAndClearUnmaskingQuestStatus(claimId);
if(!questCompleted) {
revert CompleteQuestToUnmaskVillain();
}
emit UnmaskedVillain(adventurer, claimId, isSuperVillain);
if(isSuperVillain) {
superVillainPotionContract.adventureBurn(potionTokenId);
} else if(potionTokenId > 0) {
villainPotionContract.adventureBurn(potionTokenId);
}
maskedVillainContract.adventureBurn(villainTokenId);
return (villainTokenId, potionTokenId, isSuperVillain);
}
/// @dev Returns unmasking quest details and removes the lookup entry
///
/// Throws when no unmasking quest is found
/// Throws when the caller did not create the claim id (caller != adventurer)
function _getAndClearUnmaskingQuestStatus(uint256 claimId) private returns (address adventurer, uint256 villainTokenId, uint256 potionTokenId, bool isSuperVillain, bool questCompleted) {
UnmaskingQuest memory unmaskingQuest = unmaskingQuestLookup[claimId];
uint256 startTimestamp = unmaskingQuest.startTimestamp;
adventurer = unmaskingQuest.adventurer;
villainTokenId = unmaskingQuest.villainTokenId;
uint16 potionBitmap = unmaskingQuest.potionBitmap;
isSuperVillain = potionBitmap >> 15 & 1 == 1;
potionTokenId = potionBitmap & ~(ONE << 15);
if (startTimestamp == 0) {
revert NoUnmaskingQuestFoundForSpecifiedClaimId();
}
if (adventurer != _msgSender()) {
revert CallerDidNotCreateClaimId();
}
unchecked {
questCompleted = block.timestamp - startTimestamp >= unmaskingDuration;
}
delete unmaskingQuestLookup[claimId];
return (adventurer, villainTokenId, potionTokenId, isSuperVillain, questCompleted);
}
}
IAdventurous.sol 69 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "./Quest.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @title IAdventurous
* @author Limit Break, Inc.
* @notice The base interface that all `Adventurous` token contracts must conform to in order to support adventures and quests.
* @dev All contracts that support adventures and quests are required to implement this interface.
*/
interface IAdventurous is IERC165 {
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets, for special in-game adventures.
*/
event AdventureApprovalForAll(address indexed tokenOwner, address indexed operator, bool approved);
/**
* @dev Emitted when a token enters or exits a quest
*/
event QuestUpdated(uint256 indexed tokenId, address indexed tokenOwner, address indexed adventure, uint256 questId, bool active, bool booted);
/**
* @notice Transfers a player's token if they have opted into an authorized, whitelisted adventure.
*/
function adventureTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @notice Safe transfers a player's token if they have opted into an authorized, whitelisted adventure.
*/
function adventureSafeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @notice Burns a player's token if they have opted into an authorized, whitelisted adventure.
*/
function adventureBurn(uint256 tokenId) external;
/**
* @notice Enters a player's token into a quest if they have opted into an authorized, whitelisted adventure.
*/
function enterQuest(uint256 tokenId, uint256 questId) external;
/**
* @notice Exits a player's token from a quest if they have opted into an authorized, whitelisted adventure.
*/
function exitQuest(uint256 tokenId, uint256 questId) external;
/**
* @notice Returns the number of quests a token is actively participating in for a specified adventure
*/
function getQuestCount(uint256 tokenId, address adventure) external view returns (uint256);
/**
* @notice Returns the amount of time a token has been participating in the specified quest
*/
function getTimeOnQuest(uint256 tokenId, address adventure, uint256 questId) external view returns (uint256);
/**
* @notice Returns whether or not a token is currently participating in the specified quest as well as the time it was started and the quest index
*/
function isParticipatingInQuest(uint256 tokenId, address adventure, uint256 questId) external view returns (bool participatingInQuest, uint256 startTimestamp, uint256 index);
/**
* @notice Returns a list of all active quests for the specified token id and adventure
*/
function getActiveQuests(uint256 tokenId, address adventure) external view returns (Quest[] memory activeQuests);
}
Pausable.sol 105 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IMintableVillain.sol 13 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
/**
* @dev Required interface of mintable villain contracts.
*/
interface IMintableVillain {
/**
* @notice Mints multiple villains unmasked with the specified masked villain token ids
*/
function unmaskVillainsBatch(address to, uint256[] calldata villainTokenIds, uint256[] calldata potionTokenIds) external;
}
IMinterWhitelist.sol 12 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
/**
* @dev Required interface to determine if a minter is whitelisted
*/
interface IMinterWhitelist {
/**
* @notice Determines if an address is a whitelisted minter
*/
function whitelistedMinters(address account) external view returns (bool);
}
VillainCustodian.sol 23 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "./IAdventureApproval.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
/**
* @title VillainCustodian
* @author Limit Break, Inc.
* @notice Holds masked villain and potion tokens that are currently on a villain unmasking adventure.
*/
contract VillainCustodian {
/// @dev Specify the villain unmasking adventure, masked villain, super villain potion and villain potion contract addresses during creation
constructor(address villainUnmaskingAdventure, address maskedVillainAddress, address superVillainPotionAddress, address villainPotionAddress) {
IERC721(maskedVillainAddress).setApprovalForAll(villainUnmaskingAdventure, true);
IERC721(superVillainPotionAddress).setApprovalForAll(villainUnmaskingAdventure, true);
IERC721(villainPotionAddress).setApprovalForAll(villainUnmaskingAdventure, true);
IAdventureApproval(maskedVillainAddress).setAdventuresApprovedForAll(villainUnmaskingAdventure, true);
IAdventureApproval(superVillainPotionAddress).setAdventuresApprovedForAll(villainUnmaskingAdventure, true);
IAdventureApproval(villainPotionAddress).setAdventuresApprovedForAll(villainUnmaskingAdventure, true);
}
}
IAdventurousERC721.sol 15 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "./IAdventurous.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
/**
* @title IAdventurousERC721
* @author Limit Break, Inc.
* @notice Combines all {IAdventurous} and all {IERC721} functionality into a single, unified interface.
* @dev This interface may be used as a convenience to interact with tokens that support both interface standards.
*/
interface IAdventurousERC721 is IERC721, IAdventurous {
}
Quest.sol 14 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/**
* @title Quest
* @author Limit Break, Inc.
* @notice Quest data structure for {IAdventurous} contracts.
*/
struct Quest {
bool isActive;
uint32 questId;
uint64 startTimestamp;
uint32 arrayIndex;
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
IAdventureApproval.sol 8 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
interface IAdventureApproval {
function setAdventuresApprovedForAll(address operator, bool approved) external;
function areAdventuresApprovedForAll(address owner, address operator) external view returns (bool);
function isAdventureWhitelisted(address account) external view returns (bool);
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Read Contract
custodian 0x375b74c3 → address
getUnmaskingQuestDetailsBatch 0x4e9f8e8f → tuple[]
lastClaimId 0x7119ca76 → uint256
maskedVillainContract 0x94d266e3 → address
onQuestEntered 0x688a3741
onQuestExited 0x6d4229c9
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
questsLockTokens 0x92b61294 → bool
superVillainContract 0x3ef6da87 → address
superVillainPotionContract 0x95c34e03 → address
supportsInterface 0x01ffc9a7 → bool
unmaskingDuration 0xa1abf77f → uint256
unmaskingQuestLookup 0x609b3ab3 → uint64, uint16, uint16, address
villainContract 0x4de75086 → address
villainPotionContract 0x5380c164 → address
Write Contract 8 functions
These functions modify contract state and require a wallet transaction to execute.
maskVillainsBatch 0xa7ce5a9b
uint256[] claimIds
pauseNewQuestEntries 0xd1f6b202
No parameters
renounceOwnership 0x715018a6
No parameters
setUnmaskingDuration 0x465ac962
uint256 unmaskingDuration_
startUnmaskingVillainsBatch 0x27603f34
uint256[] maskedVillainTokenIds
uint256[] villainPotionTokenIds
uint256[] superVillainPotionTokenIds
transferOwnership 0xf2fde38b
address newOwner
unmaskVillainsBatch 0xa4d67809
uint256[] claimIds
unpauseNewQuestEntries 0xe24dc13e
No parameters
Recent Transactions
No transactions found for this address