2475a4c9: Updates to Premint that enables preminting against contracts that were not created via premint, as well as adding collaborators to premint contracts by being able specify an array of additionalAdmins in a premint's contract creation config.
No breaking changes
These updates are fully backwards compatible; the old functions on the contracts are still intact and will work. Additionally, these updates dont require a new premint config version to be signed; the only thing that could be affected is the deterministic address to be signed against, in the case there are additional contract admins.
Ability to add contract-wide additional admins with premint
There is a new struct called ContractWithAdditionalAdminsCreationConfig
that replaces ContractCreationConfig
. This contains, in addition to the existing fields, a new array address[] additionalAdmins
- these addresses are added as additional admins when a contract is created by converting each address into a setup action that adds the contract-wide role PERMISSION_BIT_ADMIN
to that account.
struct ContractWithAdditionalAdminsCreationConfig {
address contractAdmin;
string contractURI;
string contractName;
address[] additionalAdmins;
}
struct ContractCreationConfig {
address contractAdmin;
string contractURI;
string contractName;
}
Having a list of additionalAdmins
results in the 1155 contract having a different deterministic address, based on a salt
made from a hash of the array of setupActions
that are generated to add those additional accounts as admins. As a result, the creator and additional admins would be signing a message against an address expected to be deterministic with consideration for those additional admins.
To get the address in consideration of the new admins, there is a new function on the preminter contract:
function getContractWithAdditionalAdminsAddress(
ContractWithAdditionalAdminsCreationConfig calldata contractConfig
) public view override returns (address);
function getContractAddress(
ContractCreationConfig calldata contractConfig
) public view override returns (address);
This should be called to get the expected contract address when there are additional admins.
To determine if an address is authorized to create a premint when there are additional admins, there is a new function:
function isAuthorizedToCreatePremintWithAdditionalAdmins(
address signer,
address premintContractConfigContractAdmin,
address contractAddress,
address[] calldata additionalAdmins
) public view returns (bool isAuthorized);
function isAuthorizedToCreatePremint(
address signer,
address premintContractConfigContractAdmin,
address contractAddress
) public view returns (bool isAuthorized);
If any account in those additionalAdmins
, it is considered authorized and can also sign a premint against the contract address of the original premint, before the contract is created. The collaborator's premint can be brought onchain first, and the original admin will be set as the admin along with all the additionalAdmins
.
New ability to do premints against existing contracts
Executing premint against contracts not created via premint can be done with by passing a premintCollection
argument to the new premint
function:
function premint(
ContractWithAdditionalAdminsCreationConfig memory contractConfig,
address premintCollection,
PremintConfigEncoded calldata encodedPremintConfig,
bytes calldata signature,
uint256 quantityToMint,
MintArguments calldata mintArguments,
address firstMinter,
address signerContract
) external payable returns (uint256 tokenId);
This premint collection's address must be a zora creator 1155 contract that already supports premint, which is version 2.0.0 and up.
New single shared function for executing a premint, which works with all versions of premint configs
In order to avoid having to create one function each for premint v1, v2, and future versions of premint, the new function premint
takes a struct PremintConfigEncoded
that contains common properties for premint: uid
, version
, and deleted
, an abi encoded tokenConfig
and a premintConfigVersion
; the abi encoded token config can be a TokenCreationConfigV1
, TokenCreationConfigV2
, or TokenCreationConfigV3
.
Correspondingly the existing premintV1/premintV2/premintERC20
functions are deprecated in favor of this new function premint
that takes a PremintConfigEncoded
for the premintConfig, and the contractCreationConfig
as the first argument. If the premintCollection
parameter is set to a zeroAddress, the function will get or create a contract with an address determined by the contractCreationConfig. This single function works with all versions of premint configs:
struct PremintConfigEncoded {
uint32 uid;
uint32 version;
bool deleted;
bytes tokenConfig;
bytes32 premintConfigVersion;
}
function premint(
ContractWithAdditionalAdminsCreationConfig memory contractConfig,
address premintCollection,
PremintConfigEncoded calldata encodedPremintConfig,
bytes calldata signature,
uint256 quantityToMint,
MintArguments calldata mintArguments,
address firstMinter,
address signerContract
) external payable returns (uint256 tokenId);
premintV2WithSignerContract
has been removed from the preminter contract to save contract size.
1155 factory's createContractDeterministic resulting address is affected by setupActions
The FactoryProxy's createContractDeterministic
function now takes into consideration the bytes[] calldata setupActions
when creating the contract at the deterministic address. This won't affect contracts that don't have any setup actions, as their address will be the same as it was before.