Skip to content

Commit

Permalink
Fix build - extract premint v2 types
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Oct 20, 2023
1 parent c1dc7c9 commit 6d4233a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
1 change: 0 additions & 1 deletion packages/1155-contracts/package/preminter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const [
creatorAccount,
collectorAccount,
createReferralAccount,
mintReferral,
] = (await walletClient.getAddresses()) as [
Address,
Address,
Expand Down
56 changes: 30 additions & 26 deletions packages/1155-contracts/package/preminter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,31 @@ export const preminterTypedDataDefinitionV2 = ({
return result;
};

const premintV1Types = {
CreatorAttribution: [
{ name: "tokenConfig", type: "TokenCreationConfig" },
// unique id scoped to the contract and token to create.
// ensure that a signature can be replaced, as long as the replacement
// has the same uid, and a newer version.
{ name: "uid", type: "uint32" },
{ name: "version", type: "uint32" },
// if this update should result in the signature being deleted.
{ name: "deleted", type: "bool" },
],
TokenCreationConfig: [
{ name: "tokenURI", type: "string" },
{ name: "maxSupply", type: "uint256" },
{ name: "maxTokensPerAddress", type: "uint64" },
{ name: "pricePerToken", type: "uint96" },
{ name: "mintStart", type: "uint64" },
{ name: "mintDuration", type: "uint64" },
{ name: "royaltyMintSchedule", type: "uint32" },
{ name: "royaltyBPS", type: "uint32" },
{ name: "royaltyRecipient", type: "address" },
{ name: "fixedPriceMinter", type: "address" },
],
};

// Convenience method to create the structured typed data
// needed to sign for a premint contract and token
export const preminterTypedDataDefinitionV1 = ({
Expand All @@ -98,39 +123,18 @@ export const preminterTypedDataDefinitionV1 = ({
chainId: number;
}) => {
const { tokenConfig, uid, version, deleted } = premintConfig;
const types = {
CreatorAttribution: [
{ name: "tokenConfig", type: "TokenCreationConfig" },
// unique id scoped to the contract and token to create.
// ensure that a signature can be replaced, as long as the replacement
// has the same uid, and a newer version.
{ name: "uid", type: "uint32" },
{ name: "version", type: "uint32" },
// if this update should result in the signature being deleted.
{ name: "deleted", type: "bool" },
],
TokenCreationConfig: [
{ name: "tokenURI", type: "string" },
{ name: "maxSupply", type: "uint256" },
{ name: "maxTokensPerAddress", type: "uint64" },
{ name: "pricePerToken", type: "uint96" },
{ name: "mintStart", type: "uint64" },
{ name: "mintDuration", type: "uint64" },
{ name: "royaltyMintSchedule", type: "uint32" },
{ name: "royaltyBPS", type: "uint32" },
{ name: "royaltyRecipient", type: "address" },
{ name: "fixedPriceMinter", type: "address" },
],
};

const result: TypedDataDefinition<typeof types, "CreatorAttribution"> = {
const result: TypedDataDefinition<
typeof premintV1Types,
"CreatorAttribution"
> = {
domain: {
chainId,
name: "Preminter",
version: "1",
verifyingContract: verifyingContract,
},
types,
types: premintV1Types,
message: {
tokenConfig,
uid,
Expand Down

0 comments on commit 6d4233a

Please sign in to comment.