From b1d9bcb7b1bcb510fa0b508459440d758bf89e45 Mon Sep 17 00:00:00 2001 From: lljxx1 Date: Fri, 10 May 2024 14:29:09 +0800 Subject: [PATCH 1/3] feat: zora old contracts --- .../orderbook/mints/calldata/detector/zora.ts | 9 +++++--- packages/indexer/src/tests/mints/zora.test.ts | 22 +++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/packages/indexer/src/orderbook/mints/calldata/detector/zora.ts b/packages/indexer/src/orderbook/mints/calldata/detector/zora.ts index d7afc10e86..a2e2441f98 100644 --- a/packages/indexer/src/orderbook/mints/calldata/detector/zora.ts +++ b/packages/indexer/src/orderbook/mints/calldata/detector/zora.ts @@ -269,6 +269,7 @@ export const extractByCollectionERC1155 = async ( uint256 totalMinted ) )`, + `function contractVersion() view returns (string)`, ]), baseProvider ); @@ -350,14 +351,16 @@ export const extractByCollectionERC1155 = async ( c.getTokenInfo(tokenId), ]); - let mintFee = bn(0); + let mintFee: BigNumber | undefined; try { mintFee = await c.mintFee(); } catch { // Skip errors } - const price = saleConfig.pricePerToken.add(mintFee).toString(); + const price = mintFee + ? saleConfig.pricePerToken.add(mintFee).toString() + : saleConfig.pricePerToken.toString(); results.push({ collection, contract: collection, @@ -369,7 +372,7 @@ export const extractByCollectionERC1155 = async ( tx: { to: collection, data: - totalRewards == undefined + totalRewards == undefined && mintFee != undefined ? { // `mint` signature: "0x731133e9", diff --git a/packages/indexer/src/tests/mints/zora.test.ts b/packages/indexer/src/tests/mints/zora.test.ts index 387a5d3156..160f38d335 100644 --- a/packages/indexer/src/tests/mints/zora.test.ts +++ b/packages/indexer/src/tests/mints/zora.test.ts @@ -91,4 +91,26 @@ describe("Mints - Zora", () => { } expect(collectionMints[0]?.details.tx.data.signature).toBe("0xf54f216a"); }); + + it("mint-detect-issue", async () => { + // Optimism + const collection = `0x0a7695F65733cC8a3531babfD9e1E60cbE23f178`; + const transcation = await utils.fetchTransaction( + "0x166f4fa322577a52b5a984a2224873d56ec87349b80d699dddab6723b5b963e8" + ); + const collectionMints = await extractByTx(collection, transcation); + // expect(collectionMints.length).not.toBe(0); + // expect(infos[0]?.details.tx.data.signature).toBe("0x9dbb844d"); + for (const collectionMint of collectionMints) { + const data = await generateCollectionMintTxData( + collectionMint, + "0x0000000000000000000000000000000000000001", + 1 + ); + expect(data.txData.data.includes("0x1d7df191")).toBe(true); + // console.log("data", data); + // const result = await simulateCollectionMint(collectionMint); + // expect(result).toBe(true); + } + }); }); From e8ec01902ad48ba51ca49f3a44c7f011c31084a5 Mon Sep 17 00:00:00 2001 From: lljxx1 Date: Mon, 13 May 2024 15:18:12 +0800 Subject: [PATCH 2/3] fix: zora hardcode fee --- .../orderbook/mints/calldata/detector/zora.ts | 25 ++++++++++--------- packages/indexer/src/tests/mints/zora.test.ts | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/indexer/src/orderbook/mints/calldata/detector/zora.ts b/packages/indexer/src/orderbook/mints/calldata/detector/zora.ts index a2e2441f98..5ee90f3ae3 100644 --- a/packages/indexer/src/orderbook/mints/calldata/detector/zora.ts +++ b/packages/indexer/src/orderbook/mints/calldata/detector/zora.ts @@ -328,6 +328,16 @@ export const extractByCollectionERC1155 = async ( baseProvider ); + let mintFee: BigNumber = bn(0); + try { + mintFee = await c.mintFee(); + } catch { + // Skip errors + // TOTAL_REWARD_PER_MINT = 0.0007 ether; + mintFee = bn("700000000000000"); + totalRewards = bn("700000000000000"); + } + const contractName = await s.contractName(); if (contractName === "Fixed Price Sale Strategy") { const fixedSale = new Contract( @@ -351,16 +361,8 @@ export const extractByCollectionERC1155 = async ( c.getTokenInfo(tokenId), ]); - let mintFee: BigNumber | undefined; - try { - mintFee = await c.mintFee(); - } catch { - // Skip errors - } + const price = saleConfig.pricePerToken.add(mintFee).toString(); - const price = mintFee - ? saleConfig.pricePerToken.add(mintFee).toString() - : saleConfig.pricePerToken.toString(); results.push({ collection, contract: collection, @@ -372,7 +374,7 @@ export const extractByCollectionERC1155 = async ( tx: { to: collection, data: - totalRewards == undefined && mintFee != undefined + totalRewards == undefined ? { // `mint` signature: "0x731133e9", @@ -452,10 +454,9 @@ export const extractByCollectionERC1155 = async ( baseProvider ); - const [saleConfig, tokenInfo, mintFee] = await Promise.all([ + const [saleConfig, tokenInfo] = await Promise.all([ merkleSale.sale(collection, tokenId), c.getTokenInfo(tokenId), - c.mintFee(), ]); const merkleRoot = merkleSale.merkleRoot; diff --git a/packages/indexer/src/tests/mints/zora.test.ts b/packages/indexer/src/tests/mints/zora.test.ts index 160f38d335..a9dceba219 100644 --- a/packages/indexer/src/tests/mints/zora.test.ts +++ b/packages/indexer/src/tests/mints/zora.test.ts @@ -107,8 +107,8 @@ describe("Mints - Zora", () => { "0x0000000000000000000000000000000000000001", 1 ); - expect(data.txData.data.includes("0x1d7df191")).toBe(true); // console.log("data", data); + expect(data.txData.data.includes("0x9dbb844d")).toBe(true); // const result = await simulateCollectionMint(collectionMint); // expect(result).toBe(true); } From 36710c8f580d3a92a3ae2cd45131375cc050b503 Mon Sep 17 00:00:00 2001 From: George Roman <30772943+georgeroman@users.noreply.github.com> Date: Wed, 15 May 2024 07:27:58 +0200 Subject: [PATCH 3/3] fix: tweaks --- .../indexer/src/orderbook/mints/calldata/detector/zora.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/indexer/src/orderbook/mints/calldata/detector/zora.ts b/packages/indexer/src/orderbook/mints/calldata/detector/zora.ts index 5ee90f3ae3..fdcb0d20ca 100644 --- a/packages/indexer/src/orderbook/mints/calldata/detector/zora.ts +++ b/packages/indexer/src/orderbook/mints/calldata/detector/zora.ts @@ -269,7 +269,6 @@ export const extractByCollectionERC1155 = async ( uint256 totalMinted ) )`, - `function contractVersion() view returns (string)`, ]), baseProvider ); @@ -328,12 +327,11 @@ export const extractByCollectionERC1155 = async ( baseProvider ); - let mintFee: BigNumber = bn(0); + let mintFee = bn(0); try { mintFee = await c.mintFee(); } catch { // Skip errors - // TOTAL_REWARD_PER_MINT = 0.0007 ether; mintFee = bn("700000000000000"); totalRewards = bn("700000000000000"); }