Skip to content

Commit

Permalink
wip on refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Nov 22, 2023
1 parent 135a163 commit 4686b87
Showing 1 changed file with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ struct PremintConfigV2 {
bool deleted;
}

struct PremintSettings {
uint32 uid;
uint32 version;
bool deleted;
}

struct TokenCreationConfigV2 {
// Metadata URI for the created token
string tokenURI;
Expand Down Expand Up @@ -156,23 +162,17 @@ library ZoraCreator1155Attribution {
"CreatorAttribution(TokenCreationConfig tokenConfig,uint32 uid,uint32 version,bool deleted)TokenCreationConfig(string tokenURI,uint256 maxSupply,uint64 maxTokensPerAddress,uint96 pricePerToken,uint64 mintStart,uint64 mintDuration,uint32 royaltyMintSchedule,uint32 royaltyBPS,address royaltyRecipient,address fixedPriceMinter)"
);

function hashPremint(PremintConfig memory premintConfig) internal pure returns (bytes32) {
return
keccak256(
abi.encode(ATTRIBUTION_DOMAIN_V1, _hashToken(premintConfig.tokenConfig), premintConfig.uid, premintConfig.version, premintConfig.deleted)
);
function hashPremint(TokenCreationConfig memory tokenConfig, PremintSettings memory settings) internal pure returns (bytes32) {
return keccak256(abi.encode(ATTRIBUTION_DOMAIN_V1, _hashToken(tokenConfig), settings.uid, settings.version, settings.deleted));
}

bytes32 constant ATTRIBUTION_DOMAIN_V2 =
keccak256(
"CreatorAttribution(TokenCreationConfig tokenConfig,uint32 uid,uint32 version,bool deleted)TokenCreationConfig(string tokenURI,uint256 maxSupply,uint64 maxTokensPerAddress,uint96 pricePerToken,uint64 mintStart,uint64 mintDuration,uint32 royaltyBPS,address payoutRecipient,address fixedPriceMinter,address createReferral)"
);

function hashPremint(PremintConfigV2 memory premintConfig) internal pure returns (bytes32) {
return
keccak256(
abi.encode(ATTRIBUTION_DOMAIN_V2, _hashToken(premintConfig.tokenConfig), premintConfig.uid, premintConfig.version, premintConfig.deleted)
);
function hashPremint(TokenCreationConfigV2 memory tokenConfig, PremintSettings memory settings) internal pure returns (bytes32) {
return keccak256(abi.encode(ATTRIBUTION_DOMAIN_V2, _hashToken(tokenConfig), settings.uid, settings.version, settings.deleted));
}

bytes32 constant TOKEN_DOMAIN_V1 =
Expand Down Expand Up @@ -392,7 +392,10 @@ library DelegatedTokenCreation {

creatorAttribution = recoverCreatorAttribution(
ZoraCreator1155Attribution.VERSION_1,
ZoraCreator1155Attribution.hashPremint(premintConfig),
ZoraCreator1155Attribution.hashPremint(
premintConfig.tokenConfig,
PremintSettings({uid: premintConfig.uid, version: premintConfig.version, deleted: premintConfig.deleted})
),
tokenContract,
signature
);
Expand All @@ -403,7 +406,10 @@ library DelegatedTokenCreation {

creatorAttribution = recoverCreatorAttribution(
ZoraCreator1155Attribution.VERSION_2,
ZoraCreator1155Attribution.hashPremint(premintConfig),
ZoraCreator1155Attribution.hashPremint(
premintConfig.tokenConfig,
PremintSettings({uid: premintConfig.uid, version: premintConfig.version, deleted: premintConfig.deleted})
),
tokenContract,
signature
);
Expand Down

0 comments on commit 4686b87

Please sign in to comment.