-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Premint - get supported premint signature version #303
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@zoralabs/zora-1155-contracts": patch | ||
--- | ||
|
||
Premint - added method getSupportedPremintSignatureVersions(contractAddress) that returns an array of the premint signature versions an 1155 contract supports. If the contract hasn't been created yet, assumes that when it will be created it will support the latest versions of the signatures, so the function returns all versions. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@zoralabs/zora-1155-contracts": patch | ||
--- | ||
|
||
Added method `IZoraCreator1155PremintExecutor.supportedPremintSignatureVersions(contractAddress)` that tells what version of the premint signature the contract supports, and added corresponding method `ZoraCreator1155Impl.supportedPremintSignatureVersions()` to fetch supported version. If premint not supported, returns an empty array. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,9 @@ import {ZoraCreatorFixedPriceSaleStrategy} from "../minters/fixed-price/ZoraCrea | |
import {IMinter1155} from "../interfaces/IMinter1155.sol"; | ||
import {ERC1155DelegationStorageV1} from "../delegation/ERC1155DelegationStorageV1.sol"; | ||
import {ZoraCreator1155PremintExecutorImplLib} from "./ZoraCreator1155PremintExecutorImplLib.sol"; | ||
import {PremintEncoding, ZoraCreator1155Attribution, ContractCreationConfig, PremintConfig, PremintConfigV2, TokenCreationConfig, TokenCreationConfigV2} from "./ZoraCreator1155Attribution.sol"; | ||
import {PremintEncoding, ZoraCreator1155Attribution, DelegatedTokenCreation, ContractCreationConfig, PremintConfig, PremintConfigV2, TokenCreationConfig, TokenCreationConfigV2} from "./ZoraCreator1155Attribution.sol"; | ||
import {IZoraCreator1155PremintExecutor} from "../interfaces/IZoraCreator1155PremintExecutor.sol"; | ||
import {IZoraCreator1155DelegatedCreation} from "../interfaces/IZoraCreator1155DelegatedCreation.sol"; | ||
|
||
struct MintArguments { | ||
// which account should receive the tokens minted. | ||
|
@@ -213,6 +214,31 @@ contract ZoraCreator1155PremintExecutorImpl is | |
); | ||
} | ||
|
||
/// @notice Returns the versions of the premint signature that the contract supports | ||
/// @param contractAddress The address of the contract to check | ||
/// @return versions The versions of the premint signature that the contract supports. If contract hasn't been created yet, | ||
/// assumes that when it will be created it will support the latest versions of the signatures, so the function returns all versions. | ||
function supportedPremintSignatureVersions(address contractAddress) external view returns (string[] memory versions) { | ||
// if contract hasn't been created yet, assume it will be created with the latest version | ||
// and thus supports all versions of the signature | ||
if (contractAddress.code.length == 0) { | ||
return DelegatedTokenCreation._supportedPremintSignatureVersions(); | ||
} | ||
|
||
IZoraCreator1155 creatorContract = IZoraCreator1155(contractAddress); | ||
if (creatorContract.supportsInterface(type(IZoraCreator1155DelegatedCreation).interfaceId)) { | ||
return IZoraCreator1155DelegatedCreation(contractAddress).supportedPremintSignatureVersions(); | ||
} | ||
|
||
// try get token id for uid 0 - if call fails, we know this didn't support premint | ||
try ERC1155DelegationStorageV1(contractAddress).delegatedTokenId(uint32(0)) returns (uint256) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are we somehow ensuring that the first premint executed on a contract is uid 0? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it doesn't really matter here - this is really just checking if that function exists on the contract. even if the uid is not 0, this will return 0. It will revert if the function doesn't exist on the contract |
||
versions = new string[](1); | ||
versions[0] = ZoraCreator1155Attribution.VERSION_1; | ||
} catch { | ||
versions = new string[](0); | ||
} | ||
} | ||
|
||
// upgrade related functionality | ||
|
||
/// @notice The name of the contract for upgrade purposes | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should version be a string or an integer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hrrrm great q. when you sign the message, the version according to eip-712 is a string. so maybe it makes sense for this to actually return an array saying
supportedSignatureVersions
with an array of the versions supported?or we store internally as integers and convert to string in the eip-712 domain, and this returns a an integer which acts as a max version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String is fine for alignment for EIP-712. Another option would be to stringify an integer to come up.