diff --git a/VERSION b/VERSION index a18dc4f69..4397dd171 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.157.4 +0.158.0 diff --git a/contracts/collectibles/CollectibleV1.sol b/contracts/collectibles/CollectibleV1.sol index 5c65fc7a9..7db823801 100644 --- a/contracts/collectibles/CollectibleV1.sol +++ b/contracts/collectibles/CollectibleV1.sol @@ -53,6 +53,11 @@ contract CollectibleV1 is // External functions + function setMaxSupply(uint256 newMaxSupply) external onlyOwner { + require(newMaxSupply >= totalSupply(), "MAX_SUPPLY_LOWER_THAN_TOTAL_SUPPLY"); + maxSupply = newMaxSupply; + } + /** * @dev Creates a new token for each address in `addresses`. Its token ID will be automatically * assigned (and available on the emitted {IERC721-Transfer} event), and the token @@ -62,7 +67,7 @@ contract CollectibleV1 is function mintTo(address[] memory addresses) external onlyOwner { // We cannot just use totalSupply() to create the new tokenId because tokens // can be burned so we use a separate counter. - require(_tokenIdTracker.current() + addresses.length < maxSupply, "MAX_SUPPLY_REACHED"); + require(_tokenIdTracker.current() + addresses.length <= maxSupply, "MAX_SUPPLY_REACHED"); for (uint256 i = 0; i < addresses.length; i++) { _safeMint(addresses[i], _tokenIdTracker.current(), ""); @@ -72,6 +77,10 @@ contract CollectibleV1 is // Public functions + function mintedCount() public view returns (uint256) { + return _tokenIdTracker.current(); + } + /** * @notice remoteBurn allows the owner to burn a token * @param tokenIds The list of token IDs to be burned @@ -117,6 +126,9 @@ contract CollectibleV1 is uint256 firstTokenId, uint256 batchSize ) internal virtual override(ERC721Enumerable) { + if (from != address(0) && to != address(0) && !transferable) { + revert("not transferable"); + } super._beforeTokenTransfer(from, to, firstTokenId, batchSize); } diff --git a/contracts/collectibles/collectibles.go b/contracts/collectibles/collectibles.go index c3b057e88..9f1eb2d0c 100644 --- a/contracts/collectibles/collectibles.go +++ b/contracts/collectibles/collectibles.go @@ -27,10 +27,10 @@ var ( ) // CollectiblesABI is the input ABI used to generate the binding from. -const CollectiblesABI = "[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_symbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_maxSupply\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"_remoteBurnable\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"_transferable\",\"type\":\"bool\"},{\"internalType\":\"string\",\"name\":\"_baseTokenURI\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"approved\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"baseTokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"getApproved\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"addresses\",\"type\":\"address[]\"}],\"name\":\"mintTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"tokenIds\",\"type\":\"uint256[]\"}],\"name\":\"remoteBurn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"remoteBurnable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"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\":\"approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"tokenByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"tokenOfOwnerByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"tokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"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\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"transferable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]" +const CollectiblesABI = "[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_symbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_maxSupply\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"_remoteBurnable\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"_transferable\",\"type\":\"bool\"},{\"internalType\":\"string\",\"name\":\"_baseTokenURI\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"approved\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"baseTokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"getApproved\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"maxSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"addresses\",\"type\":\"address[]\"}],\"name\":\"mintTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"mintedCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"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\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"tokenIds\",\"type\":\"uint256[]\"}],\"name\":\"remoteBurn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"remoteBurnable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"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\":\"approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newMaxSupply\",\"type\":\"uint256\"}],\"name\":\"setMaxSupply\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"tokenByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"tokenOfOwnerByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"tokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"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\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"transferable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]" // CollectiblesBin is the compiled bytecode used for deploying new contracts. -var CollectiblesBin = "0x60806040523480156200001157600080fd5b50604051620024d6380380620024d68339810160408190526200003491620001dd565b858560006200004483826200032b565b5060016200005382826200032b565b505050620000706200006a620000ac60201b60201c565b620000b0565b600c849055600d805461ffff191684151561ff0019161761010084151502179055600e6200009f82826200032b565b50505050505050620003f7565b3390565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200012a57600080fd5b81516001600160401b038082111562000147576200014762000102565b604051601f8301601f19908116603f0116810190828211818310171562000172576200017262000102565b816040528381526020925086838588010111156200018f57600080fd5b600091505b83821015620001b3578582018301518183018401529082019062000194565b600093810190920192909252949350505050565b80518015158114620001d857600080fd5b919050565b60008060008060008060c08789031215620001f757600080fd5b86516001600160401b03808211156200020f57600080fd5b6200021d8a838b0162000118565b975060208901519150808211156200023457600080fd5b620002428a838b0162000118565b9650604089015195506200025960608a01620001c7565b94506200026960808a01620001c7565b935060a08901519150808211156200028057600080fd5b506200028f89828a0162000118565b9150509295509295509295565b600181811c90821680620002b157607f821691505b602082108103620002d257634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200032657600081815260208120601f850160051c81016020861015620003015750805b601f850160051c820191505b8181101562000322578281556001016200030d565b5050505b505050565b81516001600160401b0381111562000347576200034762000102565b6200035f816200035884546200029c565b84620002d8565b602080601f8311600181146200039757600084156200037e5750858301515b600019600386901b1c1916600185901b17855562000322565b600085815260208120601f198616915b82811015620003c857888601518255948401946001909101908401620003a7565b5085821015620003e75787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6120cf80620004076000396000f3fe608060405234801561001057600080fd5b50600436106101a35760003560e01c806370a08231116100ee578063b88d4fde11610097578063d547cfb711610071578063d547cfb714610348578063d5abeb0114610350578063e985e9c514610359578063f2fde38b1461039557600080fd5b8063b88d4fde1461030f578063c87b56dd14610322578063ce7c8b491461033557600080fd5b806392ff0d31116100c857806392ff0d31146102e257806395d89b41146102f4578063a22cb465146102fc57600080fd5b806370a08231146102b6578063715018a6146102c95780638da5cb5b146102d157600080fd5b806323b872dd116101505780634f6ccce71161012a5780634f6ccce71461027d5780634fb95e02146102905780636352211e146102a357600080fd5b806323b872dd146102445780632f745c591461025757806342842e0e1461026a57600080fd5b8063095ea7b311610181578063095ea7b314610210578063101639f51461022557806318160ddd1461023257600080fd5b806301ffc9a7146101a857806306fdde03146101d0578063081812fc146101e5575b600080fd5b6101bb6101b6366004611b63565b6103a8565b60405190151581526020015b60405180910390f35b6101d86103b9565b6040516101c79190611bd0565b6101f86101f3366004611be3565b61044b565b6040516001600160a01b0390911681526020016101c7565b61022361021e366004611c18565b610472565b005b600d546101bb9060ff1681565b6008545b6040519081526020016101c7565b610223610252366004611c42565b6105a8565b610236610265366004611c18565b61061f565b610223610278366004611c42565b6106c7565b61023661028b366004611be3565b6106e2565b61022361029e366004611ce9565b610786565b6101f86102b1366004611be3565b610824565b6102366102c4366004611d7f565b610889565b610223610923565b600a546001600160a01b03166101f8565b600d546101bb90610100900460ff1681565b6101d8610937565b61022361030a366004611d9a565b610946565b61022361031d366004611dd6565b610951565b6101d8610330366004611be3565b6109cf565b610223610343366004611e96565b610a36565b6101d8610b04565b610236600c5481565b6101bb610367366004611f23565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6102236103a3366004611d7f565b610b92565b60006103b382610c22565b92915050565b6060600080546103c890611f56565b80601f01602080910402602001604051908101604052809291908181526020018280546103f490611f56565b80156104415780601f1061041657610100808354040283529160200191610441565b820191906000526020600020905b81548152906001019060200180831161042457829003601f168201915b5050505050905090565b600061045682610c60565b506000908152600460205260409020546001600160a01b031690565b600061047d82610824565b9050806001600160a01b0316836001600160a01b03160361050b5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b336001600160a01b038216148061052757506105278133610367565b6105995760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610502565b6105a38383610cc4565b505050565b6105b23382610d32565b6106145760405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201526c1c881bdc88185c1c1c9bdd9959609a1b6064820152608401610502565b6105a3838383610db1565b600061062a83610889565b821061069e5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e64730000000000000000000000000000000000000000006064820152608401610502565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6105a383838360405180602001604052806000815250610951565b60006106ed60085490565b82106107615760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e647300000000000000000000000000000000000000006064820152608401610502565b6008828154811061077457610774611f90565b90600052602060002001549050919050565b61078e610fb7565b600d5460ff166107e05760405162461bcd60e51b815260206004820152601360248201527f4e4f545f52454d4f54455f4255524e41424c45000000000000000000000000006044820152606401610502565b60005b81518110156108205761080e82828151811061080157610801611f90565b6020026020010151611011565b8061081881611fbc565b9150506107e3565b5050565b6000818152600260205260408120546001600160a01b0316806103b35760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610502565b60006001600160a01b0382166109075760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f74206120766160448201527f6c6964206f776e657200000000000000000000000000000000000000000000006064820152608401610502565b506001600160a01b031660009081526003602052604090205490565b61092b610fb7565b61093560006110b4565b565b6060600180546103c890611f56565b610820338383611106565b61095b3383610d32565b6109bd5760405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201526c1c881bdc88185c1c1c9bdd9959609a1b6064820152608401610502565b6109c9848484846111d4565b50505050565b60606109da82610c60565b60006109e4611252565b90506000815111610a045760405180602001604052806000815250610a2f565b80610a0e84611261565b604051602001610a1f929190611fd5565b6040516020818303038152906040525b9392505050565b610a3e610fb7565b600c548151600b54610a509190612004565b10610a9d5760405162461bcd60e51b815260206004820152601260248201527f4d41585f535550504c595f5245414348454400000000000000000000000000006044820152606401610502565b60005b815181101561082057610ae4828281518110610abe57610abe611f90565b6020026020010151610acf600b5490565b60405180602001604052806000815250611301565b610af2600b80546001019055565b80610afc81611fbc565b915050610aa0565b600e8054610b1190611f56565b80601f0160208091040260200160405190810160405280929190818152602001828054610b3d90611f56565b8015610b8a5780601f10610b5f57610100808354040283529160200191610b8a565b820191906000526020600020905b815481529060010190602001808311610b6d57829003601f168201915b505050505081565b610b9a610fb7565b6001600160a01b038116610c165760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610502565b610c1f816110b4565b50565b60006001600160e01b031982167f780e9d630000000000000000000000000000000000000000000000000000000014806103b357506103b38261137f565b6000818152600260205260409020546001600160a01b0316610c1f5760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610502565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610cf982610824565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080610d3e83610824565b9050806001600160a01b0316846001600160a01b03161480610d8557506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b80610da95750836001600160a01b0316610d9e8461044b565b6001600160a01b0316145b949350505050565b826001600160a01b0316610dc482610824565b6001600160a01b031614610e285760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610502565b6001600160a01b038216610ea35760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610502565b610eb0838383600161141a565b826001600160a01b0316610ec382610824565b6001600160a01b031614610f275760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610502565b600081815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0387811680865260038552838620805460001901905590871680865283862080546001019055868652600290945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a546001600160a01b031633146109355760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610502565b600061101c82610824565b905061102c81600084600161141a565b61103582610824565b600083815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0385168085526003845282852080546000190190558785526002909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b0316036111675760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610502565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6111df848484610db1565b6111eb84848484611426565b6109c95760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b6064820152608401610502565b6060600e80546103c890611f56565b6060600061126e83611572565b600101905060008167ffffffffffffffff81111561128e5761128e611c7e565b6040519080825280601f01601f1916602001820160405280156112b8576020820181803683370190505b5090508181016020015b600019017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a85049450846112c257509392505050565b61130b8383611654565b6113186000848484611426565b6105a35760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b6064820152608401610502565b60006001600160e01b031982167f80ac58cd0000000000000000000000000000000000000000000000000000000014806113e257506001600160e01b031982167f5b5e139f00000000000000000000000000000000000000000000000000000000145b806103b357507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316146103b3565b6109c9848484846117ed565b60006001600160a01b0384163b1561156757604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061146a903390899088908890600401612017565b6020604051808303816000875af19250505080156114a5575060408051601f3d908101601f191682019092526114a291810190612053565b60015b61154d573d8080156114d3576040519150601f19603f3d011682016040523d82523d6000602084013e6114d8565b606091505b5080516000036115455760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b6064820152608401610502565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610da9565b506001949350505050565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083106115bb577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef810000000083106115e7576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061160557662386f26fc10000830492506010015b6305f5e100831061161d576305f5e100830492506008015b612710831061163157612710830492506004015b60648310611643576064830492506002015b600a83106103b35760010192915050565b6001600160a01b0382166116aa5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610502565b6000818152600260205260409020546001600160a01b03161561170f5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610502565b61171d60008383600161141a565b6000818152600260205260409020546001600160a01b0316156117825760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610502565b6001600160a01b038216600081815260036020908152604080832080546001019055848352600290915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6117f984848484611935565b60018111156118705760405162461bcd60e51b815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e736563757469766520747260448201527f616e7366657273206e6f7420737570706f7274656400000000000000000000006064820152608401610502565b816001600160a01b0385166118cc576118c781600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6118ef565b836001600160a01b0316856001600160a01b0316146118ef576118ef85826119bd565b6001600160a01b03841661190b5761190681611a5a565b61192e565b846001600160a01b0316846001600160a01b03161461192e5761192e8482611b09565b5050505050565b60018111156109c9576001600160a01b0384161561197b576001600160a01b03841660009081526003602052604081208054839290611975908490612070565b90915550505b6001600160a01b038316156109c9576001600160a01b038316600090815260036020526040812080548392906119b2908490612004565b909155505050505050565b600060016119ca84610889565b6119d49190612070565b600083815260076020526040902054909150808214611a27576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090611a6c90600190612070565b60008381526009602052604081205460088054939450909284908110611a9457611a94611f90565b906000526020600020015490508060088381548110611ab557611ab5611f90565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480611aed57611aed612083565b6001900381819060005260206000200160009055905550505050565b6000611b1483610889565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160e01b031981168114610c1f57600080fd5b600060208284031215611b7557600080fd5b8135610a2f81611b4d565b60005b83811015611b9b578181015183820152602001611b83565b50506000910152565b60008151808452611bbc816020860160208601611b80565b601f01601f19169290920160200192915050565b602081526000610a2f6020830184611ba4565b600060208284031215611bf557600080fd5b5035919050565b80356001600160a01b0381168114611c1357600080fd5b919050565b60008060408385031215611c2b57600080fd5b611c3483611bfc565b946020939093013593505050565b600080600060608486031215611c5757600080fd5b611c6084611bfc565b9250611c6e60208501611bfc565b9150604084013590509250925092565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611cbd57611cbd611c7e565b604052919050565b600067ffffffffffffffff821115611cdf57611cdf611c7e565b5060051b60200190565b60006020808385031215611cfc57600080fd5b823567ffffffffffffffff811115611d1357600080fd5b8301601f81018513611d2457600080fd5b8035611d37611d3282611cc5565b611c94565b81815260059190911b82018301908381019087831115611d5657600080fd5b928401925b82841015611d7457833582529284019290840190611d5b565b979650505050505050565b600060208284031215611d9157600080fd5b610a2f82611bfc565b60008060408385031215611dad57600080fd5b611db683611bfc565b915060208301358015158114611dcb57600080fd5b809150509250929050565b60008060008060808587031215611dec57600080fd5b611df585611bfc565b93506020611e04818701611bfc565b935060408601359250606086013567ffffffffffffffff80821115611e2857600080fd5b818801915088601f830112611e3c57600080fd5b813581811115611e4e57611e4e611c7e565b611e60601f8201601f19168501611c94565b91508082528984828501011115611e7657600080fd5b808484018584013760008482840101525080935050505092959194509250565b60006020808385031215611ea957600080fd5b823567ffffffffffffffff811115611ec057600080fd5b8301601f81018513611ed157600080fd5b8035611edf611d3282611cc5565b81815260059190911b82018301908381019087831115611efe57600080fd5b928401925b82841015611d7457611f1484611bfc565b82529284019290840190611f03565b60008060408385031215611f3657600080fd5b611f3f83611bfc565b9150611f4d60208401611bfc565b90509250929050565b600181811c90821680611f6a57607f821691505b602082108103611f8a57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201611fce57611fce611fa6565b5060010190565b60008351611fe7818460208801611b80565b835190830190611ffb818360208801611b80565b01949350505050565b808201808211156103b3576103b3611fa6565b60006001600160a01b038087168352808616602084015250836040830152608060608301526120496080830184611ba4565b9695505050505050565b60006020828403121561206557600080fd5b8151610a2f81611b4d565b818103818111156103b3576103b3611fa6565b634e487b7160e01b600052603160045260246000fdfea26469706673582212203c8f2bacbbddfd6997d25825fd3defca5c24feaa4791eeee5120b62c639ab18c64736f6c63430008110033" +var CollectiblesBin = "0x60806040523480156200001157600080fd5b50604051620023bd380380620023bd8339810160408190526200003491620001dd565b858560006200004483826200032b565b5060016200005382826200032b565b505050620000706200006a620000ac60201b60201c565b620000b0565b600c849055600d805461ffff191684151561ff0019161761010084151502179055600e6200009f82826200032b565b50505050505050620003f7565b3390565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200012a57600080fd5b81516001600160401b038082111562000147576200014762000102565b604051601f8301601f19908116603f0116810190828211818310171562000172576200017262000102565b816040528381526020925086838588010111156200018f57600080fd5b600091505b83821015620001b3578582018301518183018401529082019062000194565b600093810190920192909252949350505050565b80518015158114620001d857600080fd5b919050565b60008060008060008060c08789031215620001f757600080fd5b86516001600160401b03808211156200020f57600080fd5b6200021d8a838b0162000118565b975060208901519150808211156200023457600080fd5b620002428a838b0162000118565b9650604089015195506200025960608a01620001c7565b94506200026960808a01620001c7565b935060a08901519150808211156200028057600080fd5b506200028f89828a0162000118565b9150509295509295509295565b600181811c90821680620002b157607f821691505b602082108103620002d257634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200032657600081815260208120601f850160051c81016020861015620003015750805b601f850160051c820191505b8181101562000322578281556001016200030d565b5050505b505050565b81516001600160401b0381111562000347576200034762000102565b6200035f816200035884546200029c565b84620002d8565b602080601f8311600181146200039757600084156200037e5750858301515b600019600386901b1c1916600185901b17855562000322565b600085815260208120601f198616915b82811015620003c857888601518255948401946001909101908401620003a7565b5085821015620003e75787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b611fb680620004076000396000f3fe608060405234801561001057600080fd5b50600436106101a95760003560e01c806370a08231116100f9578063c87b56dd11610097578063d547cfb711610071578063d547cfb714610369578063d5abeb0114610371578063e985e9c51461037a578063f2fde38b146103b657600080fd5b8063c87b56dd1461033b578063ce7c8b491461034e578063cf721b151461036157600080fd5b806392ff0d31116100d357806392ff0d31146102fb57806395d89b411461030d578063a22cb46514610315578063b88d4fde1461032857600080fd5b806370a08231146102cf578063715018a6146102e25780638da5cb5b146102ea57600080fd5b806323b872dd116101665780634f6ccce7116101405780634f6ccce7146102835780634fb95e02146102965780636352211e146102a95780636f8b44b0146102bc57600080fd5b806323b872dd1461024a5780632f745c591461025d57806342842e0e1461027057600080fd5b806301ffc9a7146101ae57806306fdde03146101d6578063081812fc146101eb578063095ea7b314610216578063101639f51461022b57806318160ddd14610238575b600080fd5b6101c16101bc366004611965565b6103c9565b60405190151581526020015b60405180910390f35b6101de6103da565b6040516101cd91906119d2565b6101fe6101f93660046119e5565b61046c565b6040516001600160a01b0390911681526020016101cd565b610229610224366004611a1a565b610493565b005b600d546101c19060ff1681565b6008545b6040519081526020016101cd565b610229610258366004611a44565b6105ad565b61023c61026b366004611a1a565b6105de565b61022961027e366004611a44565b610674565b61023c6102913660046119e5565b61068f565b6102296102a4366004611aeb565b610722565b6101fe6102b73660046119e5565b6107b6565b6102296102ca3660046119e5565b610816565b61023c6102dd366004611b81565b610880565b610229610906565b600a546001600160a01b03166101fe565b600d546101c190610100900460ff1681565b6101de61091a565b610229610323366004611b9c565b610929565b610229610336366004611bd8565b610934565b6101de6103493660046119e5565b61096c565b61022961035c366004611c98565b6109d3565b61023c610a97565b6101de610aa7565b61023c600c5481565b6101c1610388366004611d25565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6102296103c4366004611b81565b610b35565b60006103d482610bae565b92915050565b6060600080546103e990611d58565b80601f016020809104026020016040519081016040528092919081815260200182805461041590611d58565b80156104625780601f1061043757610100808354040283529160200191610462565b820191906000526020600020905b81548152906001019060200180831161044557829003601f168201915b5050505050905090565b600061047782610bd3565b506000908152600460205260409020546001600160a01b031690565b600061049e826107b6565b9050806001600160a01b0316836001600160a01b0316036105105760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b038216148061052c575061052c8133610388565b61059e5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610507565b6105a88383610c32565b505050565b6105b73382610ca0565b6105d35760405162461bcd60e51b815260040161050790611d92565b6105a8838383610d1f565b60006105e983610880565b821061064b5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610507565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6105a883838360405180602001604052806000815250610934565b600061069a60085490565b82106106fd5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610507565b6008828154811061071057610710611ddf565b90600052602060002001549050919050565b61072a610e90565b600d5460ff166107725760405162461bcd60e51b81526020600482015260136024820152724e4f545f52454d4f54455f4255524e41424c4560681b6044820152606401610507565b60005b81518110156107b2576107a082828151811061079357610793611ddf565b6020026020010151610eea565b806107aa81611e0b565b915050610775565b5050565b6000818152600260205260408120546001600160a01b0316806103d45760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610507565b61081e610e90565b60085481101561087b5760405162461bcd60e51b815260206004820152602260248201527f4d41585f535550504c595f4c4f5745525f5448414e5f544f54414c5f535550506044820152614c5960f01b6064820152608401610507565b600c55565b60006001600160a01b0382166108ea5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610507565b506001600160a01b031660009081526003602052604090205490565b61090e610e90565b6109186000610f8d565b565b6060600180546103e990611d58565b6107b2338383610fdf565b61093e3383610ca0565b61095a5760405162461bcd60e51b815260040161050790611d92565b610966848484846110ad565b50505050565b606061097782610bd3565b60006109816110e0565b905060008151116109a157604051806020016040528060008152506109cc565b806109ab846110ef565b6040516020016109bc929190611e24565b6040516020818303038152906040525b9392505050565b6109db610e90565b600c548151600b546109ed9190611e53565b1115610a305760405162461bcd60e51b815260206004820152601260248201527113505617d4d55414131657d4915050d2115160721b6044820152606401610507565b60005b81518110156107b257610a77828281518110610a5157610a51611ddf565b6020026020010151610a62600b5490565b60405180602001604052806000815250611182565b610a85600b80546001019055565b80610a8f81611e0b565b915050610a33565b6000610aa2600b5490565b905090565b600e8054610ab490611d58565b80601f0160208091040260200160405190810160405280929190818152602001828054610ae090611d58565b8015610b2d5780601f10610b0257610100808354040283529160200191610b2d565b820191906000526020600020905b815481529060010190602001808311610b1057829003601f168201915b505050505081565b610b3d610e90565b6001600160a01b038116610ba25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610507565b610bab81610f8d565b50565b60006001600160e01b0319821663780e9d6360e01b14806103d457506103d4826111b5565b6000818152600260205260409020546001600160a01b0316610bab5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610507565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610c67826107b6565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080610cac836107b6565b9050806001600160a01b0316846001600160a01b03161480610cf357506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b80610d175750836001600160a01b0316610d0c8461046c565b6001600160a01b0316145b949350505050565b826001600160a01b0316610d32826107b6565b6001600160a01b031614610d585760405162461bcd60e51b815260040161050790611e66565b6001600160a01b038216610dba5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610507565b610dc78383836001611205565b826001600160a01b0316610dda826107b6565b6001600160a01b031614610e005760405162461bcd60e51b815260040161050790611e66565b600081815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0387811680865260038552838620805460001901905590871680865283862080546001019055868652600290945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a546001600160a01b031633146109185760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610507565b6000610ef5826107b6565b9050610f05816000846001611205565b610f0e826107b6565b600083815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0385168085526003845282852080546000190190558785526002909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b0316036110405760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610507565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6110b8848484610d1f565b6110c484848484611285565b6109665760405162461bcd60e51b815260040161050790611eab565b6060600e80546103e990611d58565b606060006110fc83611386565b600101905060008167ffffffffffffffff81111561111c5761111c611a80565b6040519080825280601f01601f191660200182016040528015611146576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461115057509392505050565b61118c838361145e565b6111996000848484611285565b6105a85760405162461bcd60e51b815260040161050790611eab565b60006001600160e01b031982166380ac58cd60e01b14806111e657506001600160e01b03198216635b5e139f60e01b145b806103d457506301ffc9a760e01b6001600160e01b03198316146103d4565b6001600160a01b0384161580159061122557506001600160a01b03831615155b80156112395750600d54610100900460ff16155b156112795760405162461bcd60e51b815260206004820152601060248201526f6e6f74207472616e7366657261626c6560801b6044820152606401610507565b610966848484846115f7565b60006001600160a01b0384163b1561137b57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906112c9903390899088908890600401611efd565b6020604051808303816000875af1925050508015611304575060408051601f3d908101601f1916820190925261130191810190611f3a565b60015b611361573d808015611332576040519150601f19603f3d011682016040523d82523d6000602084013e611337565b606091505b5080516000036113595760405162461bcd60e51b815260040161050790611eab565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610d17565b506001949350505050565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106113c55772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106113f1576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061140f57662386f26fc10000830492506010015b6305f5e1008310611427576305f5e100830492506008015b612710831061143b57612710830492506004015b6064831061144d576064830492506002015b600a83106103d45760010192915050565b6001600160a01b0382166114b45760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610507565b6000818152600260205260409020546001600160a01b0316156115195760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610507565b611527600083836001611205565b6000818152600260205260409020546001600160a01b03161561158c5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610507565b6001600160a01b038216600081815260036020908152604080832080546001019055848352600290915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b61160384848484611737565b60018111156116725760405162461bcd60e51b815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e7365637574697665207472604482015274185b9cd9995c9cc81b9bdd081cdd5c1c1bdc9d1959605a1b6064820152608401610507565b816001600160a01b0385166116ce576116c981600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6116f1565b836001600160a01b0316856001600160a01b0316146116f1576116f185826117bf565b6001600160a01b03841661170d576117088161185c565b611730565b846001600160a01b0316846001600160a01b03161461173057611730848261190b565b5050505050565b6001811115610966576001600160a01b0384161561177d576001600160a01b03841660009081526003602052604081208054839290611777908490611f57565b90915550505b6001600160a01b03831615610966576001600160a01b038316600090815260036020526040812080548392906117b4908490611e53565b909155505050505050565b600060016117cc84610880565b6117d69190611f57565b600083815260076020526040902054909150808214611829576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061186e90600190611f57565b6000838152600960205260408120546008805493945090928490811061189657611896611ddf565b9060005260206000200154905080600883815481106118b7576118b7611ddf565b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806118ef576118ef611f6a565b6001900381819060005260206000200160009055905550505050565b600061191683610880565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160e01b031981168114610bab57600080fd5b60006020828403121561197757600080fd5b81356109cc8161194f565b60005b8381101561199d578181015183820152602001611985565b50506000910152565b600081518084526119be816020860160208601611982565b601f01601f19169290920160200192915050565b6020815260006109cc60208301846119a6565b6000602082840312156119f757600080fd5b5035919050565b80356001600160a01b0381168114611a1557600080fd5b919050565b60008060408385031215611a2d57600080fd5b611a36836119fe565b946020939093013593505050565b600080600060608486031215611a5957600080fd5b611a62846119fe565b9250611a70602085016119fe565b9150604084013590509250925092565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611abf57611abf611a80565b604052919050565b600067ffffffffffffffff821115611ae157611ae1611a80565b5060051b60200190565b60006020808385031215611afe57600080fd5b823567ffffffffffffffff811115611b1557600080fd5b8301601f81018513611b2657600080fd5b8035611b39611b3482611ac7565b611a96565b81815260059190911b82018301908381019087831115611b5857600080fd5b928401925b82841015611b7657833582529284019290840190611b5d565b979650505050505050565b600060208284031215611b9357600080fd5b6109cc826119fe565b60008060408385031215611baf57600080fd5b611bb8836119fe565b915060208301358015158114611bcd57600080fd5b809150509250929050565b60008060008060808587031215611bee57600080fd5b611bf7856119fe565b93506020611c068187016119fe565b935060408601359250606086013567ffffffffffffffff80821115611c2a57600080fd5b818801915088601f830112611c3e57600080fd5b813581811115611c5057611c50611a80565b611c62601f8201601f19168501611a96565b91508082528984828501011115611c7857600080fd5b808484018584013760008482840101525080935050505092959194509250565b60006020808385031215611cab57600080fd5b823567ffffffffffffffff811115611cc257600080fd5b8301601f81018513611cd357600080fd5b8035611ce1611b3482611ac7565b81815260059190911b82018301908381019087831115611d0057600080fd5b928401925b82841015611b7657611d16846119fe565b82529284019290840190611d05565b60008060408385031215611d3857600080fd5b611d41836119fe565b9150611d4f602084016119fe565b90509250929050565b600181811c90821680611d6c57607f821691505b602082108103611d8c57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201611e1d57611e1d611df5565b5060010190565b60008351611e36818460208801611982565b835190830190611e4a818360208801611982565b01949350505050565b808201808211156103d4576103d4611df5565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611f30908301846119a6565b9695505050505050565b600060208284031215611f4c57600080fd5b81516109cc8161194f565b818103818111156103d4576103d4611df5565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220c6ab3b6644629d79218fbba3a25de8f33b2e2556023ce5d005848d7052e933b164736f6c63430008110033" // DeployCollectibles deploys a new Ethereum contract, binding an instance of Collectibles to it. func DeployCollectibles(auth *bind.TransactOpts, backend bind.ContractBackend, _name string, _symbol string, _maxSupply *big.Int, _remoteBurnable bool, _transferable bool, _baseTokenURI string) (common.Address, *types.Transaction, *Collectibles, error) { @@ -343,6 +343,37 @@ func (_Collectibles *CollectiblesCallerSession) MaxSupply() (*big.Int, error) { return _Collectibles.Contract.MaxSupply(&_Collectibles.CallOpts) } +// MintedCount is a free data retrieval call binding the contract method 0xcf721b15. +// +// Solidity: function mintedCount() view returns(uint256) +func (_Collectibles *CollectiblesCaller) MintedCount(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Collectibles.contract.Call(opts, &out, "mintedCount") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// MintedCount is a free data retrieval call binding the contract method 0xcf721b15. +// +// Solidity: function mintedCount() view returns(uint256) +func (_Collectibles *CollectiblesSession) MintedCount() (*big.Int, error) { + return _Collectibles.Contract.MintedCount(&_Collectibles.CallOpts) +} + +// MintedCount is a free data retrieval call binding the contract method 0xcf721b15. +// +// Solidity: function mintedCount() view returns(uint256) +func (_Collectibles *CollectiblesCallerSession) MintedCount() (*big.Int, error) { + return _Collectibles.Contract.MintedCount(&_Collectibles.CallOpts) +} + // Name is a free data retrieval call binding the contract method 0x06fdde03. // // Solidity: function name() view returns(string) @@ -831,6 +862,27 @@ func (_Collectibles *CollectiblesTransactorSession) SetApprovalForAll(operator c return _Collectibles.Contract.SetApprovalForAll(&_Collectibles.TransactOpts, operator, approved) } +// SetMaxSupply is a paid mutator transaction binding the contract method 0x6f8b44b0. +// +// Solidity: function setMaxSupply(uint256 newMaxSupply) returns() +func (_Collectibles *CollectiblesTransactor) SetMaxSupply(opts *bind.TransactOpts, newMaxSupply *big.Int) (*types.Transaction, error) { + return _Collectibles.contract.Transact(opts, "setMaxSupply", newMaxSupply) +} + +// SetMaxSupply is a paid mutator transaction binding the contract method 0x6f8b44b0. +// +// Solidity: function setMaxSupply(uint256 newMaxSupply) returns() +func (_Collectibles *CollectiblesSession) SetMaxSupply(newMaxSupply *big.Int) (*types.Transaction, error) { + return _Collectibles.Contract.SetMaxSupply(&_Collectibles.TransactOpts, newMaxSupply) +} + +// SetMaxSupply is a paid mutator transaction binding the contract method 0x6f8b44b0. +// +// Solidity: function setMaxSupply(uint256 newMaxSupply) returns() +func (_Collectibles *CollectiblesTransactorSession) SetMaxSupply(newMaxSupply *big.Int) (*types.Transaction, error) { + return _Collectibles.Contract.SetMaxSupply(&_Collectibles.TransactOpts, newMaxSupply) +} + // TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. // // Solidity: function transferFrom(address from, address to, uint256 tokenId) returns() diff --git a/protocol/communities/manager.go b/protocol/communities/manager.go index 24da81d45..f132f5783 100644 --- a/protocol/communities/manager.go +++ b/protocol/communities/manager.go @@ -3845,8 +3845,12 @@ func (m *Manager) AddCommunityToken(token *CommunityToken) (*CommunityToken, err return token, m.persistence.AddCommunityToken(token) } -func (m *Manager) UpdateCommunityTokenState(contractAddress string, deployState DeployState) error { - return m.persistence.UpdateCommunityTokenState(contractAddress, deployState) +func (m *Manager) UpdateCommunityTokenState(chainID int, contractAddress string, deployState DeployState) error { + return m.persistence.UpdateCommunityTokenState(chainID, contractAddress, deployState) +} + +func (m *Manager) UpdateCommunityTokenSupply(chainID int, contractAddress string, supply int) error { + return m.persistence.UpdateCommunityTokenSupply(chainID, contractAddress, supply) } func (m *Manager) SetCommunityActiveMembersCount(communityID string, activeMembersCount uint64) error { diff --git a/protocol/communities/persistence.go b/protocol/communities/persistence.go index c9d32c298..e9bd56996 100644 --- a/protocol/communities/persistence.go +++ b/protocol/communities/persistence.go @@ -988,7 +988,12 @@ func (p *Persistence) AddCommunityToken(token *CommunityToken) error { return err } -func (p *Persistence) UpdateCommunityTokenState(contractAddress string, deployState DeployState) error { - _, err := p.db.Exec(`UPDATE community_tokens SET deploy_state = ? WHERE address = ?`, deployState, contractAddress) +func (p *Persistence) UpdateCommunityTokenState(chainID int, contractAddress string, deployState DeployState) error { + _, err := p.db.Exec(`UPDATE community_tokens SET deploy_state = ? WHERE address = ? AND chain_id = ?`, deployState, contractAddress, chainID) + return err +} + +func (p *Persistence) UpdateCommunityTokenSupply(chainID int, contractAddress string, supply int) error { + _, err := p.db.Exec(`UPDATE community_tokens SET supply = ? WHERE address = ? AND chain_id = ?`, supply, contractAddress, chainID) return err } diff --git a/protocol/communities/persistence_test.go b/protocol/communities/persistence_test.go index 1e3835d04..e7554a000 100644 --- a/protocol/communities/persistence_test.go +++ b/protocol/communities/persistence_test.go @@ -417,7 +417,7 @@ func (s *PersistenceSuite) TestGetCommunityTokens() { s.Require().Len(tokens, 1) s.Require().Equal(token, *tokens[0]) - err = s.db.UpdateCommunityTokenState("0x123", Deployed) + err = s.db.UpdateCommunityTokenState(1, "0x123", Deployed) s.Require().NoError(err) tokens, err = s.db.GetCommunityTokens("123") s.Require().NoError(err) diff --git a/protocol/messenger_communities.go b/protocol/messenger_communities.go index bf161e422..54bd3c544 100644 --- a/protocol/messenger_communities.go +++ b/protocol/messenger_communities.go @@ -3731,8 +3731,12 @@ func (m *Messenger) AddCommunityToken(token *communities.CommunityToken) (*commu return m.communitiesManager.AddCommunityToken(token) } -func (m *Messenger) UpdateCommunityTokenState(contractAddress string, deployState communities.DeployState) error { - return m.communitiesManager.UpdateCommunityTokenState(contractAddress, deployState) +func (m *Messenger) UpdateCommunityTokenState(chainID int, contractAddress string, deployState communities.DeployState) error { + return m.communitiesManager.UpdateCommunityTokenState(chainID, contractAddress, deployState) +} + +func (m *Messenger) UpdateCommunityTokenSupply(chainID int, contractAddress string, supply int) error { + return m.communitiesManager.UpdateCommunityTokenSupply(chainID, contractAddress, supply) } // UpdateCommunityEncryption takes a community and encrypts / decrypts the community diff --git a/services/collectibles/api.go b/services/collectibles/api.go index 0bfb88804..d57ca4c71 100644 --- a/services/collectibles/api.go +++ b/services/collectibles/api.go @@ -111,7 +111,8 @@ func (api *API) Deploy(ctx context.Context, chainID uint64, deploymentParameters // Returns gas units + 10% func (api *API) DeployCollectiblesEstimate(ctx context.Context) (uint64, error) { - return 3702411, nil + gasAmount := uint64(1960645) + return gasAmount + uint64(float32(gasAmount)*0.1), nil } func (api *API) newCollectiblesInstance(chainID uint64, contractAddress string) (*collectibles.Collectibles, error) { @@ -166,17 +167,6 @@ func (api *API) EstimateMintTo(ctx context.Context, chainID uint64, contractAddr return 0, err } - ethClient, err := api.RPCClient.EthClient(chainID) - if err != nil { - log.Error(err.Error()) - return 0, err - } - - collectiblesABI, err := abi.JSON(strings.NewReader(collectibles.CollectiblesABI)) - if err != nil { - return 0, err - } - totalAddresses := api.multiplyWalletAddresses(amount, walletAddresses) var usersAddresses = []common.Address{} @@ -184,35 +174,13 @@ func (api *API) EstimateMintTo(ctx context.Context, chainID uint64, contractAddr usersAddresses = append(usersAddresses, common.HexToAddress(k)) } - data, err := collectiblesABI.Pack("mintTo", usersAddresses) - if err != nil { - return 0, err - } - - ownerAddr, err := api.ContractOwner(ctx, chainID, contractAddress) - if err != nil { - return 0, err - } - toAddr := common.HexToAddress(contractAddress) - fromAddr := common.HexToAddress(ownerAddr) - - callMsg := ethereum.CallMsg{ - From: fromAddr, - To: &toAddr, - Value: big.NewInt(0), - Data: data, - } - - estimate, err := ethClient.EstimateGas(ctx, callMsg) - if err != nil { - return 0, err - } - return estimate + uint64(float32(estimate)*0.1), nil + return api.estimateMethod(ctx, chainID, contractAddress, "mintTo", usersAddresses) } func (api *API) RemoteBurn(ctx context.Context, chainID uint64, contractAddress string, txArgs transactions.SendTxArgs, password string, tokenIds []*bigint.BigInt) (string, error) { - if len(tokenIds) == 0 { - return "", errors.New("tokenIds list is empty") + err := api.validateTokens(tokenIds) + if err != nil { + return "", err } contractInst, err := api.newCollectiblesInstance(chainID, contractAddress) @@ -235,6 +203,20 @@ func (api *API) RemoteBurn(ctx context.Context, chainID uint64, contractAddress return tx.Hash().Hex(), nil } +func (api *API) EstimateRemoteBurn(ctx context.Context, chainID uint64, contractAddress string, tokenIds []*bigint.BigInt) (uint64, error) { + err := api.validateTokens(tokenIds) + if err != nil { + return 0, err + } + + var tempTokenIds []*big.Int + for _, v := range tokenIds { + tempTokenIds = append(tempTokenIds, v.Int) + } + + return api.estimateMethod(ctx, chainID, contractAddress, "remoteBurn", tempTokenIds) +} + func (api *API) ContractOwner(ctx context.Context, chainID uint64, contractAddress string) (string, error) { callOpts := &bind.CallOpts{Context: ctx, Pending: false} contractInst, err := api.newCollectiblesInstance(chainID, contractAddress) @@ -248,14 +230,90 @@ func (api *API) ContractOwner(ctx context.Context, chainID uint64, contractAddre return owner.String(), nil } -func (api *API) AddTokenOwners(ctx context.Context, chainID uint64, contractAddress string, walletAddresses []string, amount int) error { - err := api.validateWalletsAndAmounts(walletAddresses, amount) +func (api *API) MintedCount(ctx context.Context, chainID uint64, contractAddress string) (*big.Int, error) { + callOpts := &bind.CallOpts{Context: ctx, Pending: false} + contractInst, err := api.newCollectiblesInstance(chainID, contractAddress) if err != nil { - return err + return nil, err + } + mintedCount, err := contractInst.MintedCount(callOpts) + if err != nil { + return nil, err + } + return mintedCount, nil +} + +// RemainingSupply = MaxSupply - MintedCount +func (api *API) RemainingSupply(ctx context.Context, chainID uint64, contractAddress string) (*big.Int, error) { + callOpts := &bind.CallOpts{Context: ctx, Pending: false} + contractInst, err := api.newCollectiblesInstance(chainID, contractAddress) + if err != nil { + return nil, err + } + maxSupply, err := contractInst.MaxSupply(callOpts) + if err != nil { + return nil, err + } + mintedCount, err := contractInst.MintedCount(callOpts) + if err != nil { + return nil, err + } + var res = new(big.Int) + res.Sub(maxSupply, mintedCount) + return res, nil +} + +func (api *API) maxSupply(ctx context.Context, chainID uint64, contractAddress string) (*big.Int, error) { + callOpts := &bind.CallOpts{Context: ctx, Pending: false} + contractInst, err := api.newCollectiblesInstance(chainID, contractAddress) + if err != nil { + return nil, err + } + return contractInst.MaxSupply(callOpts) +} + +func (api *API) Burn(ctx context.Context, chainID uint64, contractAddress string, txArgs transactions.SendTxArgs, password string, burnAmount *bigint.BigInt) (string, error) { + err := api.validateBurnAmount(ctx, burnAmount, chainID, contractAddress) + if err != nil { + return "", err } - totalAddresses := api.multiplyWalletAddresses(amount, walletAddresses) - return api.db.AddTokenOwners(chainID, contractAddress, totalAddresses) + contractInst, err := api.newCollectiblesInstance(chainID, contractAddress) + if err != nil { + return "", err + } + + transactOpts := txArgs.ToTransactOpts(utils.GetSigner(chainID, api.accountsManager, api.config.KeyStoreDir, txArgs.From, password)) + + maxSupply, err := api.maxSupply(ctx, chainID, contractAddress) + if err != nil { + return "", err + } + var newMaxSupply = new(big.Int) + newMaxSupply.Sub(maxSupply, burnAmount.Int) + + tx, err := contractInst.SetMaxSupply(transactOpts, newMaxSupply) + if err != nil { + return "", err + } + + return tx.Hash().Hex(), nil +} + +func (api *API) EstimateBurn(ctx context.Context, chainID uint64, contractAddress string, burnAmount *bigint.BigInt) (uint64, error) { + err := api.validateBurnAmount(ctx, burnAmount, chainID, contractAddress) + if err != nil { + return 0, err + } + + maxSupply, err := api.maxSupply(ctx, chainID, contractAddress) + if err != nil { + return 0, err + } + var newMaxSupply = new(big.Int) + newMaxSupply.Sub(maxSupply, burnAmount.Int) + + return api.estimateMethod(ctx, chainID, contractAddress, "setMaxSupply", newMaxSupply) } func (api *API) validateWalletsAndAmounts(walletAddresses []string, amount int) error { @@ -268,11 +326,28 @@ func (api *API) validateWalletsAndAmounts(walletAddresses []string, amount int) return nil } -func (api *API) EstimateRemoteBurn(ctx context.Context, chainID uint64, contractAddress string, tokenIds []*bigint.BigInt) (uint64, error) { +func (api *API) validateTokens(tokenIds []*bigint.BigInt) error { if len(tokenIds) == 0 { - return 0, errors.New("token list is empty") + return errors.New("token list is empty") } + return nil +} +func (api *API) validateBurnAmount(ctx context.Context, burnAmount *bigint.BigInt, chainID uint64, contractAddress string) error { + if burnAmount.Cmp(big.NewInt(0)) <= 0 { + return errors.New("burnAmount is less than 0") + } + remainingSupply, err := api.RemainingSupply(ctx, chainID, contractAddress) + if err != nil { + return err + } + if burnAmount.Cmp(remainingSupply) > 1 { + return errors.New("burnAmount is bigger than remaining amount") + } + return nil +} + +func (api *API) estimateMethod(ctx context.Context, chainID uint64, contractAddress string, methodName string, args ...interface{}) (uint64, error) { ethClient, err := api.RPCClient.EthClient(chainID) if err != nil { log.Error(err.Error()) @@ -284,12 +359,7 @@ func (api *API) EstimateRemoteBurn(ctx context.Context, chainID uint64, contract return 0, err } - var tempTokenIds []*big.Int - for _, v := range tokenIds { - tempTokenIds = append(tempTokenIds, v.Int) - } - - data, err := collectiblesABI.Pack("remoteBurn", tempTokenIds) + data, err := collectiblesABI.Pack(methodName, args...) if err != nil { return 0, err } @@ -298,6 +368,7 @@ func (api *API) EstimateRemoteBurn(ctx context.Context, chainID uint64, contract if err != nil { return 0, err } + toAddr := common.HexToAddress(contractAddress) fromAddr := common.HexToAddress(ownerAddr) @@ -307,7 +378,6 @@ func (api *API) EstimateRemoteBurn(ctx context.Context, chainID uint64, contract Value: big.NewInt(0), Data: data, } - estimate, err := ethClient.EstimateGas(ctx, callMsg) if err != nil { return 0, err diff --git a/services/ext/api.go b/services/ext/api.go index b1aff8da6..701f7154d 100644 --- a/services/ext/api.go +++ b/services/ext/api.go @@ -1309,8 +1309,12 @@ func (api *PublicAPI) AddCommunityToken(token *communities.CommunityToken) (*com return api.service.messenger.AddCommunityToken(token) } -func (api *PublicAPI) UpdateCommunityTokenState(contractAddress string, deployState communities.DeployState) error { - return api.service.messenger.UpdateCommunityTokenState(contractAddress, deployState) +func (api *PublicAPI) UpdateCommunityTokenState(chainID int, contractAddress string, deployState communities.DeployState) error { + return api.service.messenger.UpdateCommunityTokenState(chainID, contractAddress, deployState) +} + +func (api *PublicAPI) UpdateCommunityTokenSupply(chainID int, contractAddress string, supply int) error { + return api.service.messenger.UpdateCommunityTokenSupply(chainID, contractAddress, supply) } func (api *PublicAPI) ToggleCollapsedCommunityCategory(request *requests.ToggleCollapsedCommunityCategory) error { diff --git a/services/wallet/transfer/transaction.go b/services/wallet/transfer/transaction.go index ccbe1b489..578e9baf8 100644 --- a/services/wallet/transfer/transaction.go +++ b/services/wallet/transfer/transaction.go @@ -89,6 +89,7 @@ const ( CollectibleDeployment PendingTrxType = "CollectibleDeployment" CollectibleAirdrop PendingTrxType = "CollectibleAirdrop" CollectibleRemoteSelfDestruct PendingTrxType = "CollectibleRemoteSelfDestruct" + CollectibleBurn PendingTrxType = "CollectibleBurn" ) type PendingTransaction struct {