Skip to content

Commit

Permalink
wip on premint v2 sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Nov 15, 2023
1 parent c299eb0 commit 9b58811
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 64 deletions.
11 changes: 7 additions & 4 deletions packages/protocol-sdk/src/premint/premint-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import {
zoraCreator1155PremintExecutorImplAddress,
zoraCreatorFixedPriceSaleStrategyAddress,
} from "@zoralabs/protocol-deployments";
import { PremintConfig, preminterTypedDataDefinition } from "./preminter";
import {
PremintConfigV1,
premintConfigV1TypedDataDefinition,
} from "./preminter";
import type {
PremintSignatureGetResponse,
PremintSignatureResponse,
Expand Down Expand Up @@ -127,7 +130,7 @@ export const convertCollection = (
export const encodePremintForAPI = ({
tokenConfig,
...premint
}: PremintConfig) => ({
}: PremintConfigV1) => ({
...premint,
tokenConfig: {
...tokenConfig,
Expand Down Expand Up @@ -327,7 +330,7 @@ class PremintClient extends ClientBase {
verifyingContract: Address;
checkSignature: boolean;
account?: Address | Account;
premintConfig: PremintConfig;
premintConfig: PremintConfigV1;
collection: PremintSignatureGetResponse["collection"];
}) {
if (!account) {
Expand All @@ -339,7 +342,7 @@ class PremintClient extends ClientBase {

const signature = await walletClient.signTypedData({
account,
...preminterTypedDataDefinition({
...premintConfigV1TypedDataDefinition({
verifyingContract,
premintConfig,
chainId: this.chain.id,
Expand Down
20 changes: 10 additions & 10 deletions packages/protocol-sdk/src/premint/preminter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import {

import {
ContractCreationConfig,
PremintConfig,
TokenCreationConfig,
preminterTypedDataDefinition,
PremintConfigV1,
TokenCreationConfigV1,
premintConfigV1TypedDataDefinition,
isValidSignatureV1,
} from "./preminter";
import {
Expand All @@ -45,7 +45,7 @@ const defaultContractConfig = ({
const defaultTokenConfig = (
fixedPriceMinterAddress: Address,
creatorAccount: Address,
): TokenCreationConfig => ({
): TokenCreationConfigV1 => ({
tokenURI: "ipfs://tokenIpfsId0",
maxSupply: 100n,
maxTokensPerAddress: 10n,
Expand All @@ -61,7 +61,7 @@ const defaultTokenConfig = (
const defaultPremintConfig = (
fixedPriceMinter: Address,
creatorAccount: Address,
): PremintConfig => ({
): PremintConfigV1 => ({
tokenConfig: defaultTokenConfig(fixedPriceMinter, creatorAccount),
deleted: false,
uid: 105,
Expand Down Expand Up @@ -128,7 +128,7 @@ describe("ZoraCreator1155Preminter", () => {
});

const signedMessage = await viemClients.walletClient.signTypedData({
...preminterTypedDataDefinition({
...premintConfigV1TypedDataDefinition({
verifyingContract: contractAddress,
chainId: 999,
premintConfig,
Expand Down Expand Up @@ -174,7 +174,7 @@ describe("ZoraCreator1155Preminter", () => {

// sign message containing contract and token creation config and uid
const signedMessage = await viemClients.walletClient.signTypedData({
...preminterTypedDataDefinition({
...premintConfigV1TypedDataDefinition({
verifyingContract: contractAddress,
// we need to sign here for the anvil chain, cause thats where it is run on
chainId: foundry.id,
Expand Down Expand Up @@ -230,7 +230,7 @@ describe("ZoraCreator1155Preminter", () => {
// have creator sign the message to create the contract
// and the token
const signedMessage = await viemClients.walletClient.signTypedData({
...preminterTypedDataDefinition({
...premintConfigV1TypedDataDefinition({
verifyingContract: contractAddress,
// we need to sign here for the anvil chain, cause thats where it is run on
chainId: foundry.id,
Expand Down Expand Up @@ -326,7 +326,7 @@ describe("ZoraCreator1155Preminter", () => {

// sign the message to create the second token
const signedMessage2 = await viemClients.walletClient.signTypedData({
...preminterTypedDataDefinition({
...premintConfigV1TypedDataDefinition({
verifyingContract: contractAddress,
chainId: foundry.id,
premintConfig: premintConfig2,
Expand Down Expand Up @@ -418,7 +418,7 @@ describe("ZoraCreator1155Preminter", () => {
// have creator sign the message to create the contract
// and the token
const signedMessage = await viemClients.walletClient.signTypedData({
...preminterTypedDataDefinition({
...premintConfigV1TypedDataDefinition({
verifyingContract: contractAddress,
// we need to sign here for the anvil chain, cause thats where it is run on
chainId: foundry.id,
Expand Down
Loading

0 comments on commit 9b58811

Please sign in to comment.