Skip to content

Commit

Permalink
premint client now implements is valid sig
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Nov 15, 2023
1 parent b63a053 commit 8206c7e
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions packages/protocol-sdk/src/premint/premint-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 8206c7e

Please sign in to comment.