跳到主要内容

CTPublisher

Git Source

Inherits: JBPermissioned, ERC2771Context, ICTPublisher

A contract that facilitates the permissioned publishing of NFT posts to a Juicebox project.

State Variables

FEE_DIVISOR

The divisor that describes the fee that should be taken.

This is equal to 100 divided by the fee percent.

uint256 public constant override FEE_DIVISOR = 20;

CONTROLLER

The controller that directs the projects being posted to.

IJBController public immutable override CONTROLLER;

FEE_PROJECT_ID

The ID of the project to which fees will be routed.

uint256 public immutable override FEE_PROJECT_ID;

tierIdForEncodedIPFSUriOf

The ID of the tier that an IPFS metadata has been saved to.

mapping(address hook => mapping(bytes32 encodedIPFSUri => uint256)) public override tierIdForEncodedIPFSUriOf;

_allowedAddresses

Stores addresses that are allowed to post onto a hook category.

mapping(address hook => mapping(uint256 category => address[])) internal _allowedAddresses;

_packedAllowanceFor

Packed values that determine the allowance of posts.

mapping(address hook => mapping(uint256 category => uint256)) internal _packedAllowanceFor;

Functions

constructor

constructor(
IJBController controller,
IJBPermissions permissions,
uint256 feeProjectId,
address trustedForwarder
)
JBPermissioned(permissions)
ERC2771Context(trustedForwarder);

Parameters

NameTypeDescription
controllerIJBControllerThe controller that directs the projects being posted to.
permissionsIJBPermissionsA contract storing permissions.
feeProjectIduint256The ID of the project to which fees will be routed.
trustedForwarderaddressThe trusted forwarder for the ERC2771Context.

tiersFor

Get the tiers for the provided encoded IPFS URIs.

function tiersFor(
address hook,
bytes32[] memory encodedIPFSUris
)
external
view
override
returns (JB721Tier[] memory tiers);

Parameters

NameTypeDescription
hookaddressThe hook from which to get tiers.
encodedIPFSUrisbytes32[]The URIs to get tiers of.

Returns

NameTypeDescription
tiersJB721Tier[]The tiers that correspond to the provided encoded IPFS URIs. If there's no tier yet, an empty tier is returned.

allowanceFor

Post allowances for a particular category on a particular hook.

function allowanceFor(
address hook,
uint256 category
)
public
view
override
returns (
uint256 minimumPrice,
uint256 minimumTotalSupply,
uint256 maximumTotalSupply,
address[] memory allowedAddresses
);

Parameters

NameTypeDescription
hookaddressThe hook contract for which this allowance applies.
categoryuint256The category for which this allowance applies.

Returns

NameTypeDescription
minimumPriceuint256The minimum price that a poster must pay to record a new NFT.
minimumTotalSupplyuint256The minimum total number of available tokens that a minter must set to record a new NFT.
maximumTotalSupplyuint256The max total supply of NFTs that can be made available when minting. Leave as 0 for max.
allowedAddressesaddress[]The addresses allowed to post. Returns empty if all addresses are allowed.

_contextSuffixLength

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

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

_isAllowed

Check if an address is included in an allow list.

function _isAllowed(address addrs, address[] memory addresses) internal pure returns (bool);

Parameters

NameTypeDescription
addrsaddressThe candidate address.
addressesaddress[]An array of allowed addresses.

_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.

configurePostingCriteriaFor

Collection owners can set the allowed criteria for publishing a new NFT to their project.

function configurePostingCriteriaFor(CTAllowedPost[] memory allowedPosts) external override;

Parameters

NameTypeDescription
allowedPostsCTAllowedPost[]An array of criteria for allowed posts.

mintFrom

Publish an NFT to become mintable, and mint a first copy.

A fee is taken into the appropriate treasury.

function mintFrom(
IJB721TiersHook hook,
CTPost[] calldata posts,
address nftBeneficiary,
address feeBeneficiary,
bytes calldata additionalPayMetadata,
bytes calldata feeMetadata
)
external
payable
override;

Parameters

NameTypeDescription
hookIJB721TiersHookThe hook to mint from.
postsCTPost[]An array of posts that should be published as NFTs to the specified project.
nftBeneficiaryaddressThe beneficiary of the NFT mints.
feeBeneficiaryaddressThe beneficiary of the fee project's token.
additionalPayMetadatabytesMetadata bytes that should be included in the pay function's metadata. This prepends the payload needed for NFT creation.
feeMetadatabytesThe metadata to send alongside the fee payment.

_setupPosts

Setup the posts.

function _setupPosts(
IJB721TiersHook hook,
CTPost[] memory posts
)
internal
returns (JB721TierConfig[] memory tiersToAdd, uint256[] memory tierIdsToMint, uint256 totalPrice);

Parameters

NameTypeDescription
hookIJB721TiersHookThe NFT hook on which the posts will apply.
postsCTPost[]An array of posts that should be published as NFTs to the specified project.

Returns

NameTypeDescription
tiersToAddJB721TierConfig[]The tiers that will be created to represent the posts.
tierIdsToMintuint256[]The tier IDs of the posts that should be minted once published.
totalPriceuint256The total price being paid.

Errors

CTPublisher_EmptyEncodedIPFSUri

error CTPublisher_EmptyEncodedIPFSUri();

CTPublisher_InsufficientEthSent

error CTPublisher_InsufficientEthSent(uint256 expected, uint256 sent);

CTPublisher_MaxTotalSupplyLessThanMin

error CTPublisher_MaxTotalSupplyLessThanMin(uint256 min, uint256 max);

CTPublisher_NotInAllowList

error CTPublisher_NotInAllowList(address addr, address[] allowedAddresses);

CTPublisher_PriceTooSmall

error CTPublisher_PriceTooSmall(uint256 price, uint256 minimumPrice);

CTPublisher_TotalSupplyTooBig

error CTPublisher_TotalSupplyTooBig(uint256 totalSupply, uint256 maximumTotalSupply);

CTPublisher_TotalSupplyTooSmall

error CTPublisher_TotalSupplyTooSmall(uint256 totalSupply, uint256 minimumTotalSupply);

CTPublisher_UnauthorizedToPostInCategory

error CTPublisher_UnauthorizedToPostInCategory();

CTPublisher_ZeroTotalSupply

error CTPublisher_ZeroTotalSupply();