Skip to content
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 - no operator overloading #295

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .changeset/violet-starfishes-visit.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
"@zoralabs/zora-1155-contracts": minor
---

Premint v2 - for add new signature, where createReferral can be specified. ZoraCreator1155PremintExecutor recognizes new version of the signature, and still works with the v1 (legacy) version of the signature. 1155 contract has been updated to now take abi encoded premint config, premint config version, and send it to an external library to decode the config, the signer, and setup actions.
Premint v2 - for add new signature, where createReferral can be specified. ZoraCreator1155PremintExecutor recognizes new version of the signature, and still works with the v1 (legacy) version of the signature. 1155 contract has been updated to now take abi encoded premint config, premint config version, and send it to an external library to decode the config, the signer, and setup actions.

changes to `ZoraCreator1155PremintExecutorImpl`:
* new function `premintV1` - takes a premint v1 signature and executed a premint, with added functionality of being able to specify mint referral and mint recipient
* new function `premintV2` - takes a premint v2 signature and executes a premint, with being able to specify mint referral and mint recipient
* deprecated function `premint` - call `premintV1` instead
19 changes: 12 additions & 7 deletions packages/1155-contracts/package/preminter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,19 @@ describe("ZoraCreator1155Preminter", () => {
});

// recover and verify address is correct
const [, , recoveredAddress] = await publicClient.readContract({
const [isValidSignature] = await publicClient.readContract({
abi: preminterAbi,
address: preminterAddress,
functionName: "isValidSignature",
args: [contractConfig, premintConfig, signedMessage],
functionName: "isValidSignatureV2",
args: [
contractConfig.contractAdmin,
contractAddress,
premintConfig,
signedMessage,
],
});

expect(recoveredAddress).to.equal(creatorAccount);
expect(isValidSignature).toBe(true);
},

20 * 1000
Expand Down Expand Up @@ -277,7 +282,7 @@ describe("ZoraCreator1155Preminter", () => {
// parameters are required to call this function
const mintHash = await walletClient.writeContract({
abi: preminterAbi,
functionName: "premint",
functionName: "premintV2",
account: collectorAccount,
address: preminterAddress,
args: [
Expand Down Expand Up @@ -352,7 +357,7 @@ describe("ZoraCreator1155Preminter", () => {
// it should create a new token against the existing contract
const mintHash2 = await walletClient.writeContract({
abi: preminterAbi,
functionName: "premint",
functionName: "premintV2",
account: collectorAccount,
address: preminterAddress,
args: [
Expand Down Expand Up @@ -450,7 +455,7 @@ describe("ZoraCreator1155Preminter", () => {
// parameters are required to call this function
const mintHash = await walletClient.writeContract({
abi: preminterAbi,
functionName: "premint",
functionName: "premintV2",
account: collectorAccount,
address: preminterAddress,
args: [
Expand Down
26 changes: 12 additions & 14 deletions packages/1155-contracts/package/preminter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,24 @@ import { ExtractAbiFunction, AbiParametersToPrimitiveTypes } from "abitype";
import { zoraCreator1155PremintExecutorImplABI as preminterAbi } from "./wagmiGenerated";
import { TypedDataDefinition } from "viem";

type PremintInputs = ExtractAbiFunction<
type PremintV1Inputs = ExtractAbiFunction<
typeof preminterAbi,
"premint"
"premintV1"
>["inputs"];

type PreminterHashDataTypes = AbiParametersToPrimitiveTypes<PremintInputs>;
type PremintV2Inputs = ExtractAbiFunction<
typeof preminterAbi,
"premintV2"
>["inputs"];

type PreminterV1HashDataTypes = AbiParametersToPrimitiveTypes<PremintV1Inputs>;
type PreminterV2HashDataTypes = AbiParametersToPrimitiveTypes<PremintV2Inputs>;

export type ContractCreationConfig = PreminterHashDataTypes[0];
export type PremintConfigs = PreminterHashDataTypes[1];
export type ContractCreationConfig = PreminterV2HashDataTypes[0];
export type PremintConfigV1 = PreminterV1HashDataTypes[1];
export type PremintConfigV2 = PreminterV2HashDataTypes[1];

export type TokenCreationConfigV1 = PremintConfigV2["tokenConfig"];
export type PremintConfigV2 = Extract<
PremintConfigs,
{
tokenConfig: {
createReferral: string;
};
}
>;
export type PremintConfigV1 = Exclude<PremintConfigs, PremintConfigV2>;
export type TokenCreationConfigV2 = PremintConfigV2["tokenConfig"];

const premintV2Types = {
Expand Down
Loading