跳到主要内容

Banny721TokenUriResolver

Git Source

Inherits: Ownable, ERC2771Context, ReentrancyGuard, IJB721TokenUriResolver, IBanny721TokenUriResolver, IERC721Receiver

Banny asset manager. Stores and shows Naked Bannys in worlds with outfits on.

State Variables

_ONE_BILLION

Just a kind reminder to our readers.

Used in 721 token ID generation.

uint256 private constant _ONE_BILLION = 1_000_000_000;

_LOCK_DURATION

The duration that naked Bannys can be locked for.

uint256 private constant _LOCK_DURATION = 7 days;

_NAKED_CATEGORY

uint8 private constant _NAKED_CATEGORY = 0;

_WORLD_CATEGORY

uint8 private constant _WORLD_CATEGORY = 1;

_BACKSIDE_CATEGORY

uint8 private constant _BACKSIDE_CATEGORY = 2;

_NECKLACE_CATEGORY

uint8 private constant _NECKLACE_CATEGORY = 3;

_HEAD_CATEGORY

uint8 private constant _HEAD_CATEGORY = 4;

_GLASSES_CATEGORY

uint8 private constant _GLASSES_CATEGORY = 5;

_MOUTH_CATEGORY

uint8 private constant _MOUTH_CATEGORY = 6;

_LEGS_CATEGORY

uint8 private constant _LEGS_CATEGORY = 7;

_SUIT_CATEGORY

uint8 private constant _SUIT_CATEGORY = 8;

_SUIT_BOTTOM_CATEGORY

uint8 private constant _SUIT_BOTTOM_CATEGORY = 9;

_SUIT_TOP_CATEGORY

uint8 private constant _SUIT_TOP_CATEGORY = 10;

_HEADTOP_CATEGORY

uint8 private constant _HEADTOP_CATEGORY = 11;

_HAND_CATEGORY

uint8 private constant _HAND_CATEGORY = 12;

_SPECIAL_SUIT_CATEGORY

uint8 private constant _SPECIAL_SUIT_CATEGORY = 13;

_SPECIAL_LEGS_CATEGORY

uint8 private constant _SPECIAL_LEGS_CATEGORY = 14;

_SPECIAL_HEAD_CATEGORY

uint8 private constant _SPECIAL_HEAD_CATEGORY = 15;

_SPECIAL_BODY_CATEGORY

uint8 private constant _SPECIAL_BODY_CATEGORY = 16;

ALIEN_UPC

uint8 private constant ALIEN_UPC = 1;

PINK_UPC

uint8 private constant PINK_UPC = 2;

ORANGE_UPC

uint8 private constant ORANGE_UPC = 3;

ORIGINAL_UPC

uint8 private constant ORIGINAL_UPC = 4;

outfitLockedUntil

The amount of time each naked banny is currently locked for.

mapping(address hook => mapping(uint256 upc => uint256)) public override outfitLockedUntil;

svgBaseUri

The base of the domain hosting the SVG files that can be lazily uploaded to the contract.

string public override svgBaseUri;

svgHashOf

The Naked Banny and outfit SVG hash files.

mapping(uint256 upc => bytes32) public override svgHashOf;

DEFAULT_ALIEN_EYES

string public override DEFAULT_ALIEN_EYES;

DEFAULT_MOUTH

string public override DEFAULT_MOUTH;

DEFAULT_NECKLACE

string public override DEFAULT_NECKLACE;

DEFAULT_STANDARD_EYES

string public override DEFAULT_STANDARD_EYES;

NAKED_BANNY

string public override NAKED_BANNY;

_attachedOutfitIdsOf

The outfits currently attached to each Naked Banny.

Nakes Banny's will only be shown with outfits currently owned by the owner of the Naked Banny.

mapping(address hook => mapping(uint256 nakedBannyId => uint256[])) internal _attachedOutfitIdsOf;

_attachedWorldIdOf

The world currently attached to each Naked Banny.

Nakes Banny's will only be shown with a world currently owned by the owner of the Naked Banny.

mapping(address hook => mapping(uint256 nakedBannyId => uint256)) internal _attachedWorldIdOf;

_customProductNameOf

The name of each product.

mapping(uint256 upc => string) internal _customProductNameOf;

_svgContentOf

The Naked Banny and outfit SVG files.

mapping(uint256 upc => string) internal _svgContentOf;

_userOf

The ID of the naked banny each world is being used by.

mapping(address hook => mapping(uint256 worldId => uint256)) internal _userOf;

_wearerOf

The ID of the naked banny each outfit is being worn by.

mapping(address hook => mapping(uint256 outfitId => uint256)) internal _wearerOf;

Functions

constructor

constructor(
string memory nakedBanny,
string memory defaultNecklace,
string memory defaultMouth,
string memory defaultStandardEyes,
string memory defaultAlienEyes,
address owner,
address trustedForwarder
)
Ownable(owner)
ERC2771Context(trustedForwarder);

Parameters

NameTypeDescription
nakedBannystringThe SVG of the naked banny.
defaultNecklacestringThe SVG of the default necklace.
defaultMouthstringThe SVG of the default mouth.
defaultStandardEyesstringThe SVG of the default standard eyes.
defaultAlienEyesstringThe SVG of the default alien eyes.
owneraddressThe owner allowed to add SVG files that correspond to product IDs.
trustedForwarderaddressThe trusted forwarder for the ERC2771Context.

tokenUriOf

Returns the SVG showing a dressed Naked Banny in a world.

function tokenUriOf(address hook, uint256 tokenId) external view override returns (string memory);

Parameters

NameTypeDescription
hookaddress
tokenIduint256The ID of the token to show. If the ID belongs to a Naked Banny, it will be shown with its current outfits in its current world.

Returns

NameTypeDescription
<none>stringtokenUri The URI representing the SVG.

assetIdsOf

The assets currently attached to each Naked Banny.

function assetIdsOf(
address hook,
uint256 nakedBannyId
)
public
view
override
returns (uint256 worldId, uint256[] memory outfitIds);

Parameters

NameTypeDescription
hookaddressThe hook address of the collection.
nakedBannyIduint256The ID of the naked banny shows with the associated assets.

Returns

NameTypeDescription
worldIduint256The world attached to the Naked Banny.
outfitIdsuint256[]The outfits attached to the Naked Banny.

namesOf

Returns the name of the token.

function namesOf(
address hook,
uint256 tokenId
)
public
view
override
returns (string memory, string memory, string memory);

Parameters

NameTypeDescription
hookaddressThe hook storing the assets.
tokenIduint256The ID of the token to show.

Returns

NameTypeDescription
<none>stringfullName The full name of the token.
<none>stringcategoryName The name of the token's category.
<none>stringproductName The name of the token's product.

svgOf

Returns the SVG showing either a naked banny with/without outfits and a world, or the stand alone outfit or world.

function svgOf(
address hook,
uint256 tokenId,
bool shouldDressNakedBanny,
bool shouldIncludeWorldOnNakedBanny
)
public
view
override
returns (string memory);

Parameters

NameTypeDescription
hookaddressThe hook storing the assets.
tokenIduint256The ID of the token to show. If the ID belongs to a Naked Banny, it will be shown with its current outfits in its current world if specified.
shouldDressNakedBannyboolWhether the naked banny should be dressed.
shouldIncludeWorldOnNakedBannyboolWhether the world should be included on the naked banny.

Returns

NameTypeDescription
<none>stringsvg The SVG.

userOf

Checks to see which naked banny is currently using a particular world.

function userOf(address hook, uint256 worldId) public view override returns (uint256);

Parameters

NameTypeDescription
hookaddressThe hook address of the collection.
worldIduint256The ID of the world being used.

Returns

NameTypeDescription
<none>uint256The ID of the naked banny using the world.

wearerOf

Checks to see which naked banny is currently wearing a particular outfit.

function wearerOf(address hook, uint256 outfitId) public view override returns (uint256);

Parameters

NameTypeDescription
hookaddressThe hook address of the collection.
outfitIduint256The ID of the outfit being worn.

Returns

NameTypeDescription
<none>uint256The ID of the naked banny wearing the outfit.

_categoryNameOf

The name of each token's category.

function _categoryNameOf(uint256 category) internal pure returns (string memory);

Parameters

NameTypeDescription
categoryuint256The category of the token being named.

Returns

NameTypeDescription
<none>stringname The token's category name.

_contextSuffixLength

ERC-2771 specifies the context as being a single address (20 bytes).

function _contextSuffixLength() internal view virtual override(ERC2771Context, Context) returns (uint256);

_checkIfSenderIsOwner

Make sure the message sender own's the token.

function _checkIfSenderIsOwner(address hook, uint256 upc) internal view;

Parameters

NameTypeDescription
hookaddressThe 721 contract of the token having ownership checked.
upcuint256The product's UPC to check ownership of.

_fillsFor

The fills for a product.

function _fillsFor(uint256 upc)
internal
pure
returns (string memory, string memory, string memory, string memory, string memory, string memory, string memory);

Parameters

NameTypeDescription
upcuint256The ID of the token whose product's fills are being returned.

Returns

NameTypeDescription
<none>stringfills The fills for the product.
<none>string
<none>string
<none>string
<none>string
<none>string
<none>string

_fullNameOf

The full name of each product, including category and inventory.

function _fullNameOf(uint256 tokenId, JB721Tier memory product) internal view returns (string memory name);

Parameters

NameTypeDescription
tokenIduint256The ID of the token being named.
productJB721TierThe product of the token being named.

Returns

NameTypeDescription
namestringThe full name.

_layeredSvg

Returns the standard dimension SVG containing dynamic contents and SVG metadata.

function _layeredSvg(string memory contents) internal pure returns (string memory);

Parameters

NameTypeDescription
contentsstringThe contents of the SVG

Returns

NameTypeDescription
<none>stringsvg The SVG contents.

_mannequinBannySvg

The SVG contents for a mannequin banny.

function _mannequinBannySvg() internal view returns (string memory);

Returns

NameTypeDescription
<none>stringcontents The SVG contents of the mannequin banny.

_msgData

Returns the calldata, prefered to use over msg.data

function _msgData() internal view override(ERC2771Context, Context) returns (bytes calldata);

Returns

NameTypeDescription
<none>bytescalldata the msg.data of this call

_msgSender

Returns the sender, prefered to use over msg.sender

function _msgSender() internal view override(ERC2771Context, Context) returns (address sender);

Returns

NameTypeDescription
senderaddressthe sender address of this call.

_nakedBannySvgOf

The SVG contents for a naked banny.

function _nakedBannySvgOf(uint256 upc) internal view returns (string memory);

Parameters

NameTypeDescription
upcuint256The ID of the token whose product's SVG is being returned.

Returns

NameTypeDescription
<none>stringcontents The SVG contents of the naked banny.

_outfitContentsFor

The SVG contents for a list of outfit IDs.

function _outfitContentsFor(address hook, uint256[] memory outfitIds) internal view returns (string memory contents);

Parameters

NameTypeDescription
hookaddressThe 721 contract that the product belongs to.
outfitIdsuint256[]The IDs of the outfits that'll be associated with the specified banny.

Returns

NameTypeDescription
contentsstringThe SVG contents of the outfits.

_productNameOf

The name of each token's product type.

function _productNameOf(uint256 upc) internal view returns (string memory);

Parameters

NameTypeDescription
upcuint256The ID of the token whose product type is being named.

Returns

NameTypeDescription
<none>stringname The item's product name.

_productOfTokenId

Get the product of the 721 with the provided token ID in the provided 721 contract.

function _productOfTokenId(address hook, uint256 tokenId) internal view returns (JB721Tier memory);

Parameters

NameTypeDescription
hookaddressThe 721 contract that the product belongs to.
tokenIduint256The token ID of the 721 to get the product of.

Returns

NameTypeDescription
<none>JB721Tierproduct The product.

_storeOf

The store of the hook.

function _storeOf(address hook) internal view returns (IJB721TiersHookStore);

Parameters

NameTypeDescription
hookaddressThe hook to get the store of.

Returns

NameTypeDescription
<none>IJB721TiersHookStorestore The store of the hook.

_svgOf

The Naked Banny and outfit SVG files.

function _svgOf(address hook, uint256 upc) internal view returns (string memory);

Parameters

NameTypeDescription
hookaddressThe 721 contract that the product belongs to.
upcuint256The universal product code of the product that the SVG contents represent.

decorateBannyWith

Dress your Naked Banny with outfits.

The caller must own the naked banny being dressed and all outfits being worn.

function decorateBannyWith(
address hook,
uint256 nakedBannyId,
uint256 worldId,
uint256[] calldata outfitIds
)
external
override
nonReentrant;

Parameters

NameTypeDescription
hookaddressThe hook storing the assets.
nakedBannyIduint256The ID of the Naked Banny being dressed.
worldIduint256The ID of the world that'll be associated with the specified banny.
outfitIdsuint256[]The IDs of the outfits that'll be associated with the specified banny. Only one outfit per outfit category allowed at a time and they must be passed in order.

lockOutfitChangesFor

Locks a naked banny ID so that it can't change its outfit for a period of time.

function lockOutfitChangesFor(address hook, uint256 nakedBannyId) public override;

Parameters

NameTypeDescription
hookaddressThe hook address of the collection.
nakedBannyIduint256The ID of the Naked Banny to lock.

onERC721Received

Make sure tokens can be receieved if the transaction was initiated by this contract.

function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
)
external
view
override
returns (bytes4);

Parameters

NameTypeDescription
operatoraddressThe address that initiated the transaction.
fromaddressThe address that initiated the transfer.
tokenIduint256The ID of the token being transferred.
databytesThe data of the transfer.

setProductNames

Allows the owner to set the product's name.

function setProductNames(uint256[] memory upcs, string[] memory names) external override onlyOwner;

Parameters

NameTypeDescription
upcsuint256[]The universal product codes of the products having their name stored.
namesstring[]The names of the products.

setSvgBaseUri

Allows the owner of this contract to specify the base of the domain hosting the SVG files.

function setSvgBaseUri(string calldata baseUri) external override onlyOwner;

Parameters

NameTypeDescription
baseUristringThe base URI of the SVG files.

setSvgContentsOf

The owner of this contract can store SVG files for product IDs.

function setSvgContentsOf(uint256[] memory upcs, string[] calldata svgContents) external override;

Parameters

NameTypeDescription
upcsuint256[]The universal product codes of the products having SVGs stored.
svgContentsstring[]The svg contents being stored, not including the parent element.

setSvgHashsOf

Allows the owner of this contract to upload the hash of an svg file for a universal product code.

This allows anyone to lazily upload the correct svg file.

function setSvgHashsOf(uint256[] memory upcs, bytes32[] memory svgHashs) external override onlyOwner;

Parameters

NameTypeDescription
upcsuint256[]The universal product codes of the products having SVG hashes stored.
svgHashsbytes32[]The svg hashes being stored, not including the parent element.

_decorateBannyWithOutfits

Add outfits to a naked banny.

The caller must own the naked banny being dressed and all outfits being worn.

function _decorateBannyWithOutfits(address hook, uint256 nakedBannyId, uint256[] memory outfitIds) internal;

Parameters

NameTypeDescription
hookaddressThe hook storing the assets.
nakedBannyIduint256The ID of the Naked Banny being dressed.
outfitIdsuint256[]The IDs of the outfits that'll be associated with the specified banny. Only one outfit per outfit category allowed at a time and they must be passed in order.

_decorateBannyWithWorld

Add a world to a Naked Banny.

function _decorateBannyWithWorld(address hook, uint256 nakedBannyId, uint256 worldId) internal;

Parameters

NameTypeDescription
hookaddressThe hook storing the assets.
nakedBannyIduint256The ID of the Naked Banny being dressed.
worldIduint256The ID of the world that'll be associated with the specified banny.

_transferFrom

Transfer a token from one address to another.

function _transferFrom(address hook, address from, address to, uint256 assetId) internal;

Parameters

NameTypeDescription
hookaddressThe 721 contract of the token being transfered.
fromaddressThe address to transfer the token from.
toaddressThe address to transfer the token to.
assetIduint256The ID of the token to transfer.

Errors

Banny721TokenUriResolver_CantAccelerateTheLock

error Banny721TokenUriResolver_CantAccelerateTheLock();

Banny721TokenUriResolver_ContentsAlreadyStored

error Banny721TokenUriResolver_ContentsAlreadyStored();

Banny721TokenUriResolver_ContentsMismatch

error Banny721TokenUriResolver_ContentsMismatch();

Banny721TokenUriResolver_HashAlreadyStored

error Banny721TokenUriResolver_HashAlreadyStored();

Banny721TokenUriResolver_HashNotFound

error Banny721TokenUriResolver_HashNotFound();

Banny721TokenUriResolver_HeadAlreadyAdded

error Banny721TokenUriResolver_HeadAlreadyAdded();

Banny721TokenUriResolver_LockedNakedBanny

error Banny721TokenUriResolver_LockedNakedBanny();

Banny721TokenUriResolver_OutfitChangesLocked

error Banny721TokenUriResolver_OutfitChangesLocked();

Banny721TokenUriResolver_SuitAlreadyAdded

error Banny721TokenUriResolver_SuitAlreadyAdded();

Banny721TokenUriResolver_UnauthorizedNakedBanny

error Banny721TokenUriResolver_UnauthorizedNakedBanny();

Banny721TokenUriResolver_UnauthorizedOutfit

error Banny721TokenUriResolver_UnauthorizedOutfit();

Banny721TokenUriResolver_UnauthorizedWorld

error Banny721TokenUriResolver_UnauthorizedWorld();

Banny721TokenUriResolver_UnorderedCategories

error Banny721TokenUriResolver_UnorderedCategories();

Banny721TokenUriResolver_UnrecognizedCategory

error Banny721TokenUriResolver_UnrecognizedCategory();

Banny721TokenUriResolver_UnrecognizedWorld

error Banny721TokenUriResolver_UnrecognizedWorld();

Banny721TokenUriResolver_UnrecognizedProduct

error Banny721TokenUriResolver_UnrecognizedProduct();

Banny721TokenUriResolver_UnauthorizedTransfer

error Banny721TokenUriResolver_UnauthorizedTransfer();