Skip to content

Commit

Permalink
rename to isValidSignature
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Nov 29, 2023
1 parent 702ad19 commit dadc411
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
33 changes: 14 additions & 19 deletions packages/protocol-sdk/src/premint/premint-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import {
getPremintCollectionAddress,
premintTypedDataDefinition,
ContractCreationConfig,
recoverAndValidateSignature,
isValidSignature,
isAuthorizedToCreatePremint,
getPremintExecutorAddress,
} from "./preminter";
import type {
PremintSignatureGetResponse,
Expand Down Expand Up @@ -198,16 +199,6 @@ class PremintClient {
publicClient || createPublicClient({ chain, transport: http() });
}

/**
* The premint executor address is deployed to the same address across all chains.
* Can be overridden as needed by making a parent class.
*
* @returns Executor address for premints
*/
getExecutorAddress() {
return zoraCreator1155PremintExecutorImplAddress[999];
}

/**
* The fixed price minter address is the same across all chains for our current
* deployer strategy.
Expand Down Expand Up @@ -389,7 +380,7 @@ class PremintClient {
signature,
publicClient: this.publicClient,
signer: typeof account === "string" ? account : account.address,
collectionAddress: await this.getCollectionAddres(convertedCollection),
collectionAddress: await this.getCollectionAddress(convertedCollection),
...premintConfigAndVersion,
});
if (!isAuthorized) {
Expand Down Expand Up @@ -517,7 +508,12 @@ class PremintClient {
});
}

async getCollectionAddres(collection: ContractCreationConfig) {
/**
* Gets the deterministic contract address for a premint collection
* @param collection Collection to get the address for
* @returns deterministic contract address
*/
async getCollectionAddress(collection: ContractCreationConfig) {
return await getPremintCollectionAddress({
collection,
publicClient: this.publicClient,
Expand All @@ -534,7 +530,7 @@ class PremintClient {
isValid: boolean;
recoveredSigner: Address | undefined;
}> {
const {isAuthorized, recoveredAddress }= await recoverAndValidateSignature({
const {isAuthorized, recoveredAddress }= await isValidSignature({
chainId: this.chain.id,
signature: data.signature as Hex,
premintConfig: convertPremintV1(data.premint),
Expand Down Expand Up @@ -603,12 +599,11 @@ class PremintClient {
quantityToMint: number;
mintComment?: string;
};
}): Promise<SimulateContractParameters> {
}): Promise<SimulateContractParameters<typeof zoraCreator1155PremintExecutorImplABI, "premint">> {
if (mintArguments && mintArguments?.quantityToMint < 1) {
throw new Error("Quantity to mint cannot be below 1");
}

const targetAddress = this.getExecutorAddress();
const numberToMint = BigInt(mintArguments?.quantityToMint || 1);
const args = [
convertCollection(data.collection),
Expand All @@ -624,14 +619,14 @@ class PremintClient {

const value = numberToMint * REWARD_PER_TOKEN;

const request: SimulateContractParameters = {
const request = {
account,
abi: zoraCreator1155PremintExecutorImplABI,
functionName: "premint",
value,
address: targetAddress,
address: getPremintExecutorAddress(),
args,
};
} satisfies SimulateContractParameters<typeof zoraCreator1155PremintExecutorImplABI, "premint">;

return request;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol-sdk/src/premint/preminter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export async function tryRecoverPremintSigner(
* @param params.tokenContract the address of the 1155 contract
* @returns
*/
export async function recoverAndValidateSignature({
export async function isValidSignature({
signature,
publicClient,
collection,
Expand Down

0 comments on commit dadc411

Please sign in to comment.