From 8df39bf2a2b771ba16cc3142f77cb1a48bee4404 Mon Sep 17 00:00:00 2001 From: mmackz Date: Thu, 15 Aug 2024 12:38:31 -0700 Subject: [PATCH 1/7] test(Zora): add test for getFees function with V1 1155 mint --- packages/zora/src/Zora.test.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/zora/src/Zora.test.ts b/packages/zora/src/Zora.test.ts index 404d4311a..fede9a4a6 100644 --- a/packages/zora/src/Zora.test.ts +++ b/packages/zora/src/Zora.test.ts @@ -2,6 +2,7 @@ import { create, getDynamicNameParams, getExternalUrl, + getFees, mint, simulateMint, } from './Zora' @@ -385,6 +386,32 @@ describe('Given the getFee function', () => { expect(fee.projectFee).equals(BigInt('777000000000000')) expect(fee.actionFee).equals(BigInt('0')) }) + + test('should return the correct project + action fee for V1 1155 mint w/o tokenId', async () => { + const contractAddress: Address = + '0x34ce43d58d0d4ecf2581f4eb6238178c77fb32d9' + const tokenId = undefined + const mintParams = { + contractAddress, + tokenId, + chainId: Chains.OPTIMISM, + amount: 1, + } + + const mockFns = { + getFees: async (_mint: MintActionParams) => ({ + projectFee: parseEther('0.000777'), + actionFee: parseEther('0.29'), + }), + } + + const getFeesSpy = vi.spyOn(mockFns, 'getFees') + const fee = await mockFns.getFees(mintParams) + console.log('fee', fee) + expect(getFeesSpy.mock.calls.length).toBe(1) + expect(fee.projectFee).equals(parseEther('0.000777')) + expect(fee.actionFee).equals(parseEther('0.29')) + }) }) describe('simulateMint function', () => { From 12e8e63136f822cafff6154ba5035c7c370439a6 Mon Sep 17 00:00:00 2001 From: mmackz Date: Thu, 15 Aug 2024 12:38:48 -0700 Subject: [PATCH 2/7] feat(Zora): handle missing tokenId for contract type 1155 --- packages/zora/src/Zora.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index 0a711e46f..9047eee30 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -456,7 +456,8 @@ export const getFees = async ( mint: MintActionParams, ): Promise<{ actionFee: bigint; projectFee: bigint }> => { try { - const { chainId, contractAddress, tokenId, amount } = mint + const { chainId, contractAddress, amount } = mint + let tokenId = mint.tokenId const client = getPublicClient(chainId) @@ -471,6 +472,12 @@ export const getFees = async ( publicClient: client, }) + // if contract type is 1155, we need to get the latest tokenId + if (contractType === '1155' && tokenId == null) { + const nextTokenId = await getNextTokenId(client, contractAddress) + tokenId = Number(nextTokenId) + } + const quantityToMint = formatAmountToInteger(amount) const { prepareMint } = await collectorClient.getToken({ tokenContract: contractAddress, From 0868cf07efc073389768fd2c78111b711e2d9b75 Mon Sep 17 00:00:00 2001 From: mmackz Date: Thu, 15 Aug 2024 12:40:58 -0700 Subject: [PATCH 3/7] test: remove console log from getFees test --- packages/zora/src/Zora.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/zora/src/Zora.test.ts b/packages/zora/src/Zora.test.ts index fede9a4a6..0c263771f 100644 --- a/packages/zora/src/Zora.test.ts +++ b/packages/zora/src/Zora.test.ts @@ -407,7 +407,6 @@ describe('Given the getFee function', () => { const getFeesSpy = vi.spyOn(mockFns, 'getFees') const fee = await mockFns.getFees(mintParams) - console.log('fee', fee) expect(getFeesSpy.mock.calls.length).toBe(1) expect(fee.projectFee).equals(parseEther('0.000777')) expect(fee.actionFee).equals(parseEther('0.29')) From 36f7d215a81a9f77d916b4f1f9a21dc71ca15760 Mon Sep 17 00:00:00 2001 From: mmackz Date: Thu, 15 Aug 2024 12:46:02 -0700 Subject: [PATCH 4/7] chore: generate changeset --- .changeset/slow-peas-sit.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/slow-peas-sit.md diff --git a/.changeset/slow-peas-sit.md b/.changeset/slow-peas-sit.md new file mode 100644 index 000000000..0fe187417 --- /dev/null +++ b/.changeset/slow-peas-sit.md @@ -0,0 +1,5 @@ +--- +"@rabbitholegg/questdk-plugin-zora": patch +--- + +add tokenId to zora SDK call for 1155s From ae2b3530ac9a802f46223c779342b695ab59f0b1 Mon Sep 17 00:00:00 2001 From: mmackz Date: Thu, 15 Aug 2024 13:04:49 -0700 Subject: [PATCH 5/7] chore: remove unused import --- packages/zora/src/Zora.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/zora/src/Zora.test.ts b/packages/zora/src/Zora.test.ts index 0c263771f..d27f2af7c 100644 --- a/packages/zora/src/Zora.test.ts +++ b/packages/zora/src/Zora.test.ts @@ -2,7 +2,6 @@ import { create, getDynamicNameParams, getExternalUrl, - getFees, mint, simulateMint, } from './Zora' From 911f4e0db47383d92645c05f24047d1e7f9e34d4 Mon Sep 17 00:00:00 2001 From: mmackz Date: Thu, 15 Aug 2024 14:17:37 -0700 Subject: [PATCH 6/7] refactor(Zora): remove unnecessary comment about tokenId --- packages/zora/src/Zora.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index 9047eee30..f759fd763 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -472,7 +472,6 @@ export const getFees = async ( publicClient: client, }) - // if contract type is 1155, we need to get the latest tokenId if (contractType === '1155' && tokenId == null) { const nextTokenId = await getNextTokenId(client, contractAddress) tokenId = Number(nextTokenId) From 33ab22d70589b9b3584f4c9a5f3e26350f67a9f5 Mon Sep 17 00:00:00 2001 From: mmackz Date: Thu, 15 Aug 2024 14:18:19 -0700 Subject: [PATCH 7/7] docs: add comment about latest tokenId --- packages/zora/src/Zora.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index f759fd763..d74f475eb 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -472,6 +472,7 @@ export const getFees = async ( publicClient: client, }) + // if no tokenId is provided for 1155, we need to get the latest tokenId if (contractType === '1155' && tokenId == null) { const nextTokenId = await getNextTokenId(client, contractAddress) tokenId = Number(nextTokenId)