Skip to content

Commit

Permalink
split out individual functions to private methods
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Nov 16, 2023
1 parent 1208f23 commit 1069e3b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
51 changes: 24 additions & 27 deletions packages/protocol-sdk/src/mint/mint-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,18 @@ describe("mint-helper", () => {
const targetTokenId = 1n;
const minter = createMintClient({ chain: zora });

const params =
await minter.makePrepareMintTokenParams({
publicClient,
minterAccount: creatorAccount,
mintable: await minter.getMintable({
tokenId: targetTokenId,
tokenContract: targetContract,
}),
mintArguments: {
mintToAddress: creatorAccount,
quantityToMint: 1,
},
});
const params = await minter.makePrepareMintTokenParams({
publicClient,
minterAccount: creatorAccount,
mintable: await minter.getMintable({
tokenId: targetTokenId,
tokenContract: targetContract,
}),
mintArguments: {
mintToAddress: creatorAccount,
quantityToMint: 1,
},
});

const oldBalance = await publicClient.readContract({
abi: zoraCreator1155ImplABI,
Expand Down Expand Up @@ -75,19 +74,18 @@ describe("mint-helper", () => {
const targetTokenId = undefined;
const minter = createMintClient({ chain: zora });

const params =
await minter.makePrepareMintTokenParams({
mintable: await minter.getMintable({
tokenContract: targetContract,
tokenId: targetTokenId,
}),
publicClient,
minterAccount: creatorAccount,
mintArguments: {
mintToAddress: creatorAccount,
quantityToMint: 1,
},
});
const params = await minter.makePrepareMintTokenParams({
mintable: await minter.getMintable({
tokenContract: targetContract,
tokenId: targetTokenId,
}),
publicClient,
minterAccount: creatorAccount,
mintArguments: {
mintToAddress: creatorAccount,
quantityToMint: 1,
},
});
const oldBalance = await publicClient.readContract({
abi: erc721ABI,
address: targetContract,
Expand All @@ -97,7 +95,6 @@ describe("mint-helper", () => {

const simulated = await publicClient.simulateContract(params);


const hash = await walletClient.writeContract(simulated.request);

const receipt = await publicClient.getTransactionReceipt({ hash });
Expand Down
10 changes: 8 additions & 2 deletions packages/protocol-sdk/src/mint/mint-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ class MintClient extends ClientBase {

if (mintContextType === "zora_create_1155") {
return makePrepareMint1155TokenParams({
subgraphUrl: this.network.subgraphUrl,
apiClient: this.apiClient,
publicClient: thisPublicClient,
mintable,
mintContextType,
Expand Down Expand Up @@ -196,16 +198,20 @@ async function makePrepareMint721TokenParams({

async function makePrepareMint1155TokenParams({
publicClient,
apiClient,
minterAccount,
mintable,
mintContextType,
mintArguments,
subgraphUrl,
}: {
publicClient: PublicClient;
apiClient: typeof MintAPIClient;
mintable: MintableGetTokenResponse;
mintContextType: ReturnType<typeof validateMintable>;
minterAccount: Address;
mintArguments: MintArguments;
subgraphUrl: string;
}) {
if (mintContextType !== "zora_create_1155") {
throw new Error("Minted token type must be for 1155");
Expand All @@ -221,10 +227,10 @@ async function makePrepareMint1155TokenParams({
address,
});

const tokenFixedPriceMinter = await this.apiClient.getSalesConfigFixedPrice({
const tokenFixedPriceMinter = await apiClient.getSalesConfigFixedPrice({
contractAddress: mintable.contract_address,
tokenId: mintable.token_id!,
subgraphUrl: this.network.subgraphUrl,
subgraphUrl,
});

const result = {
Expand Down

0 comments on commit 1069e3b

Please sign in to comment.