Skip to content

Commit

Permalink
remove operator overloading
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Oct 30, 2023
1 parent 6296269 commit 5889ee0
Show file tree
Hide file tree
Showing 10 changed files with 295 additions and 187 deletions.
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

0 comments on commit 5889ee0

Please sign in to comment.