Skip to content

Commit

Permalink
makePrepareMintTOkenParams returns single object
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Nov 16, 2023
1 parent 597559d commit 1a04173
Show file tree
Hide file tree
Showing 3 changed files with 193 additions and 164 deletions.
11 changes: 11 additions & 0 deletions .changeset/chilled-seahorses-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@zoralabs/protocol-sdk": patch
---

`MintClient.makePrepareMintTokenParams` has the following changes:
* returns a `SimulateContractParams`, instead of an object containing it indexed by key
* PublicClient as an optional argument


Internally, MintClient is refactored to extract some functionality into static helpers that could eventually be publicly exposed

52 changes: 25 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 { simulateContractParameters: 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,27 +74,26 @@ describe("mint-helper", () => {
const targetTokenId = undefined;
const minter = createMintClient({ chain: zora });

const { simulateContractParameters: prepared } =
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,
functionName: "balanceOf",
args: [creatorAccount],
});

const simulated = await publicClient.simulateContract(prepared);
const simulated = await publicClient.simulateContract(params);

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

Expand Down
Loading

0 comments on commit 1a04173

Please sign in to comment.