From 8206c7ed4ae3406a43fc6073ec431c3eb09301d9 Mon Sep 17 00:00:00 2001 From: Dan Oved Date: Wed, 15 Nov 2023 09:21:08 -0800 Subject: [PATCH] premint client now implements is valid sig --- .../src/premint/premint-client.ts | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/protocol-sdk/src/premint/premint-client.ts b/packages/protocol-sdk/src/premint/premint-client.ts index 790e58a9e..6009a5cbb 100644 --- a/packages/protocol-sdk/src/premint/premint-client.ts +++ b/packages/protocol-sdk/src/premint/premint-client.ts @@ -14,7 +14,11 @@ import { zoraCreator1155PremintExecutorImplAddress, zoraCreatorFixedPriceSaleStrategyAddress, } from "@zoralabs/protocol-deployments"; -import { PremintConfig, preminterTypedDataDefinition } from "./preminter"; +import { + PremintConfig, + isValidSignatureV1, + preminterTypedDataDefinition, +} from "./preminter"; import type { PremintSignatureGetResponse, PremintSignatureResponse, @@ -495,24 +499,20 @@ class PremintClient extends ClientBase { publicClient?: PublicClient; }): Promise<{ isValid: boolean; - contractAddress: Address; - recoveredSigner: Address; + recoveredSigner: Address | undefined; }> { publicClient = this.getPublicClient(publicClient); - const [isValid, contractAddress, recoveredSigner] = - await publicClient.readContract({ - abi: zoraCreator1155PremintExecutorImplABI, - address: this.getExecutorAddress(), - functionName: "isValidSignature", - args: [ - convertCollection(data.collection), - convertPremint(data.premint), - data.signature as Hex, - ], - }); + const { isAuthorized, recoveredAddress } = await isValidSignatureV1({ + contractAddress: data.collection_address as Address, + chainId: this.chain.id, + originalContractAdmin: data.collection.contractAdmin as Address, + premintConfig: convertPremint(data.premint), + publicClient: this.getPublicClient(), + signature: data.signature as Hex, + }); - return { isValid, contractAddress, recoveredSigner }; + return { isValid: isAuthorized, recoveredSigner: recoveredAddress }; } protected makeUrls({