From 75c7cbbf829b88ec74d27bbb2c1f181c9e8d1d72 Mon Sep 17 00:00:00 2001 From: mmackz Date: Fri, 12 Jul 2024 09:58:20 -0700 Subject: [PATCH 01/82] feat(sound): add referral to validation function --- packages/soundxyz/src/Soundxyz.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/soundxyz/src/Soundxyz.ts b/packages/soundxyz/src/Soundxyz.ts index 971267a6c..c710f7c1d 100644 --- a/packages/soundxyz/src/Soundxyz.ts +++ b/packages/soundxyz/src/Soundxyz.ts @@ -41,7 +41,7 @@ import { export const mint = async ( mint: MintActionParams, ): Promise => { - const { chainId, contractAddress, amount, recipient, tokenId } = mint + const { chainId, contractAddress, amount, recipient, tokenId, referral } = mint return compressJson({ chainId, @@ -53,6 +53,7 @@ export const mint = async ( quantity: formatAmount(amount), tier: tokenId, to: recipient, // Can be given as gift, so recipient will not always match sender + affiliate: referral, }, }, }) From 1170530a9f8191f0fcf7456609a7af546121cccf Mon Sep 17 00:00:00 2001 From: mmackz Date: Fri, 12 Jul 2024 10:32:01 -0700 Subject: [PATCH 02/82] feat(sound): update simulateMint function to include referral parameter --- packages/soundxyz/src/Soundxyz.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/soundxyz/src/Soundxyz.ts b/packages/soundxyz/src/Soundxyz.ts index c710f7c1d..aedccab02 100644 --- a/packages/soundxyz/src/Soundxyz.ts +++ b/packages/soundxyz/src/Soundxyz.ts @@ -103,9 +103,8 @@ export const simulateMint = async ( value: bigint, account?: Address, client?: PublicClient, - creatorAddress?: Address, ): Promise => { - const { contractAddress, recipient, tokenId, amount } = mint + const { contractAddress, recipient, tokenId, amount, referral } = mint const _client = (client ?? createPublicClient({ chain: chainIdToViemChain(mint.chainId), @@ -133,7 +132,7 @@ export const simulateMint = async ( signedClaimTicket: 0, signedDeadline: 0, signature: zeroHash, - affiliate: creatorAddress ?? ZORA_DEPLOYER_ADDRESS, + affiliate: referral ?? ZORA_DEPLOYER_ADDRESS, affiliateProof: [zeroHash], attributionId: 0, } From 6d2486cd0b9c585d86ab1ef15d130f50be6f1157 Mon Sep 17 00:00:00 2001 From: mmackz Date: Fri, 12 Jul 2024 10:32:23 -0700 Subject: [PATCH 03/82] chore: format --- packages/soundxyz/src/Soundxyz.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/soundxyz/src/Soundxyz.ts b/packages/soundxyz/src/Soundxyz.ts index aedccab02..7c00a4cbe 100644 --- a/packages/soundxyz/src/Soundxyz.ts +++ b/packages/soundxyz/src/Soundxyz.ts @@ -41,7 +41,8 @@ import { export const mint = async ( mint: MintActionParams, ): Promise => { - const { chainId, contractAddress, amount, recipient, tokenId, referral } = mint + const { chainId, contractAddress, amount, recipient, tokenId, referral } = + mint return compressJson({ chainId, From e8e13cbd23b1eb076d93d27e41562361b1a925cd Mon Sep 17 00:00:00 2001 From: mmackz Date: Fri, 12 Jul 2024 10:33:51 -0700 Subject: [PATCH 04/82] chore: generate changeset --- .changeset/two-comics-explain.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/two-comics-explain.md diff --git a/.changeset/two-comics-explain.md b/.changeset/two-comics-explain.md new file mode 100644 index 000000000..3cd675c92 --- /dev/null +++ b/.changeset/two-comics-explain.md @@ -0,0 +1,5 @@ +--- +"@rabbitholegg/questdk-plugin-soundxyz": minor +--- + +use referral param in validation and mint simulation From 1269d8026f0339a3f8ab8fd5c1330c88d9cb36a2 Mon Sep 17 00:00:00 2001 From: mmackz Date: Sun, 14 Jul 2024 20:25:10 -0700 Subject: [PATCH 05/82] test(pods): add tests for referral validation --- packages/pods/src/test-setup.ts | 12 ++++++++++-- packages/pods/src/test-transactions.ts | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/packages/pods/src/test-setup.ts b/packages/pods/src/test-setup.ts index 8b07a7c17..7761652ab 100644 --- a/packages/pods/src/test-setup.ts +++ b/packages/pods/src/test-setup.ts @@ -1,12 +1,17 @@ -import { POD_MINT, ZERO_QUANTITY } from './test-transactions' +import { + POD_MINT, + MINT_WITH_REWARDS_REFERRAL, + ZERO_QUANTITY, +} from './test-transactions' import { createTestCase } from '@rabbitholegg/questdk-plugin-utils' -import { getAddress } from 'viem' +import { getAddress, zeroAddress } from 'viem' export const passingTestCases = [ createTestCase(POD_MINT, 'when minting a podcast'), createTestCase(POD_MINT, 'when contractAddress is checksummed', { contractAddress: getAddress(POD_MINT.params.contractAddress), }), + createTestCase(MINT_WITH_REWARDS_REFERRAL, 'when referral is correct'), createTestCase(POD_MINT, 'using "any tokenId"', { tokenId: undefined, amount: undefined, @@ -30,4 +35,7 @@ export const failingTestCases = [ amount: '72', }), createTestCase(ZERO_QUANTITY, 'when quantity minted is 0'), + createTestCase(MINT_WITH_REWARDS_REFERRAL, 'when referral is incorrect', { + referral: zeroAddress, + }), ] diff --git a/packages/pods/src/test-transactions.ts b/packages/pods/src/test-transactions.ts index a5e14991b..e3fad7e59 100644 --- a/packages/pods/src/test-transactions.ts +++ b/packages/pods/src/test-transactions.ts @@ -36,6 +36,25 @@ export const ZERO_QUANTITY: TestParams = { }, } +export const MINT_WITH_REWARDS_REFERRAL: TestParams = { + transaction: { + chainId: 8453, + from: '0x4da04ca44ef0a105f159ec8d9595423c1834febe', + to: '0x7e0b40af1d6f26f2141b90170c513e57b5edd74e', + hash: '0x66f1157e9f442d83f0292c1fb4965ae46e5b4fe0132d672b170eb7be6955eb1e', + input: + '0x9dbb844d00000000000000000000000004e2516a2c207e84a1839755675dfd8ef6302f0a0000000000000000000000000000000000000000000000000000000000000015000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000099fdd2a67ba5ec9fb98f451f0e88d0fbec1ee12100000000000000000000000000000000000000000000000000000000000000600000000000000000000000004da04ca44ef0a105f159ec8d9595423c1834febe00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000', + value: '7000000000000000', + }, + params: { + chainId: Chains.BASE, + contractAddress: '0x7e0b40af1d6f26f2141b90170c513e57b5edd74e', + tokenId: 21, + recipient: '0x4da04ca44ef0a105f159ec8d9595423c1834febe', + referral: '0x99fdd2a67ba5ec9fb98f451f0e88d0fbec1ee121', + }, +} + export const EXPECTED_ENCODED_DATA_721 = '0xefef39a1000000000000000000000000000000000000000000000000000000000000000a' export const EXPECTED_ENCODED_DATA_1155 = From cce685d968b68f89c8f9b6b05b182dadc60bd0b9 Mon Sep 17 00:00:00 2001 From: mmackz Date: Sun, 14 Jul 2024 20:25:51 -0700 Subject: [PATCH 06/82] feat(pods): implement validation for referral address --- packages/pods/src/Pods.ts | 16 +++++++++++++++- packages/pods/src/utils.ts | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/pods/src/Pods.ts b/packages/pods/src/Pods.ts index aba53407d..8675d75fd 100644 --- a/packages/pods/src/Pods.ts +++ b/packages/pods/src/Pods.ts @@ -33,13 +33,27 @@ import { export const mint = async ( mint: MintActionParams, ): Promise => { - const { chainId, contractAddress, tokenId, amount, recipient } = mint + const { chainId, contractAddress, tokenId, amount, recipient, referral } = + mint const andArray1155: AndArrayItem[] = [ { quantity: formatAmount(amount), }, ] + if (referral) { + const referralLower = referral.toLowerCase() as Address + andArray1155.push({ + $or: [ + { mintReferral: referralLower }, + { + rewardsRecipients: { + $and: [{ $first: referralLower }, { $last: referralLower }], + }, + }, + ], + }) + } if (recipient) { andArray1155.push({ minterArguments: { diff --git a/packages/pods/src/utils.ts b/packages/pods/src/utils.ts index 9c1631c8c..662a645f5 100644 --- a/packages/pods/src/utils.ts +++ b/packages/pods/src/utils.ts @@ -9,6 +9,9 @@ export type AndArrayItem = | { quantity: string | number | bigint | FilterOperator } | { minterArguments: { $regex: string } } | { tokenId: number | string } + | { mintReferral: Address } + | { rewardsRecipients: { $and: [{ $first: Address }, { $last: Address }] } } + | { $or: AndArrayItem[] } export async function getLatestTokenId( contractAddress: Address, From 5c6c88d8ef1b8d0335b76ac5e88fc1e9bc543f98 Mon Sep 17 00:00:00 2001 From: mmackz Date: Sun, 14 Jul 2024 20:25:57 -0700 Subject: [PATCH 07/82] chore: format --- packages/zora/src/Zora.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index 4d752deaf..aa9205760 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -93,7 +93,8 @@ export const create = async ( export const mint = async ( mint: MintActionParams, ): Promise => { - const { chainId, contractAddress, tokenId, amount, recipient } = mint + const { chainId, contractAddress, tokenId, amount, recipient, referral } = + mint const universalMinter = zoraUniversalMinterAddress[ @@ -228,7 +229,8 @@ export const simulateMint = async ( account?: Address, client?: PublicClient, ): Promise => { - const { chainId, contractAddress, tokenId, amount, recipient } = mint + const { chainId, contractAddress, tokenId, amount, recipient, referral } = + mint const _client = client ?? createPublicClient({ @@ -286,7 +288,7 @@ export const simulateMint = async ( fixedPriceSaleStratAddress, _tokenId, amount, - [ZORA_DEPLOYER_ADDRESS], + [referral ?? ZORA_DEPLOYER_ADDRESS], pad(recipient), ] const result = await _client.simulateContract({ From c641a6200e6cac93541e5b5da9d740f4b9387546 Mon Sep 17 00:00:00 2001 From: mmackz Date: Sun, 14 Jul 2024 20:56:10 -0700 Subject: [PATCH 08/82] test(pods): add test for referral array --- packages/pods/src/Pods.test.ts | 3 +++ packages/pods/src/test-setup.ts | 5 +++++ packages/pods/src/test-transactions.ts | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/packages/pods/src/Pods.test.ts b/packages/pods/src/Pods.test.ts index 78832edac..357e0bc84 100644 --- a/packages/pods/src/Pods.test.ts +++ b/packages/pods/src/Pods.test.ts @@ -79,6 +79,7 @@ describe('Given the getMintIntent function', () => { contractAddress: CONTRACT_ADDRESS, amount: BigInt('10'), recipient: RECIPIENT_ADDRESS, + referral: '0xe3bba2a4f8e0f5c32ef5097f988a4d88075c8b48', } const result = await getMintIntent(mint) @@ -124,6 +125,7 @@ describe('simulateMint function', () => { tokenId: 1, amount: BigInt(1), recipient: '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF', + referral: '0xe3bba2a4f8e0f5c32ef5097f988a4d88075c8b48', } const value = parseEther('0.0007') const address = mint.recipient as Address @@ -165,6 +167,7 @@ describe('simulateMint function', () => { contractAddress: '0x7e0b40af1d6f26f2141b90170c513e57b5edd74e', amount: BigInt(1), recipient: '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF', + referral: '0xe3bba2a4f8e0f5c32ef5097f988a4d88075c8b48', } const value = parseEther('0.0007') const address = mint.recipient as Address diff --git a/packages/pods/src/test-setup.ts b/packages/pods/src/test-setup.ts index 7761652ab..7b05e4d7f 100644 --- a/packages/pods/src/test-setup.ts +++ b/packages/pods/src/test-setup.ts @@ -1,5 +1,6 @@ import { POD_MINT, + MINT_REFERRAL, MINT_WITH_REWARDS_REFERRAL, ZERO_QUANTITY, } from './test-transactions' @@ -12,6 +13,7 @@ export const passingTestCases = [ contractAddress: getAddress(POD_MINT.params.contractAddress), }), createTestCase(MINT_WITH_REWARDS_REFERRAL, 'when referral is correct'), + createTestCase(MINT_REFERRAL, 'when referral is correct'), createTestCase(POD_MINT, 'using "any tokenId"', { tokenId: undefined, amount: undefined, @@ -38,4 +40,7 @@ export const failingTestCases = [ createTestCase(MINT_WITH_REWARDS_REFERRAL, 'when referral is incorrect', { referral: zeroAddress, }), + createTestCase(MINT_REFERRAL, 'when referral is incorrect', { + referral: zeroAddress, + }), ] diff --git a/packages/pods/src/test-transactions.ts b/packages/pods/src/test-transactions.ts index e3fad7e59..0ec945995 100644 --- a/packages/pods/src/test-transactions.ts +++ b/packages/pods/src/test-transactions.ts @@ -55,6 +55,25 @@ export const MINT_WITH_REWARDS_REFERRAL: TestParams = { }, } +export const MINT_REFERRAL: TestParams = { + transaction: { + chainId: 8453, + from: '0x3468f46837aa359c3fe4ccca1436eb13af8790a5', + to: '0x7e0b40af1d6f26f2141b90170c513e57b5edd74e', + hash: '0x30765404084521c901d6339a55e7f9260055eceae0733cfe15d60546a0ebc8b6', + input: + '0x359f130200000000000000000000000004e2516a2c207e84a1839755675dfd8ef6302f0a0000000000000000000000000000000000000000000000000000000000000015000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000e3bba2a4f8e0f5c32ef5097f988a4d88075c8b4800000000000000000000000000000000000000000000000000000000000000200000000000000000000000003468f46837aa359c3fe4ccca1436eb13af8790a5', + value: '7000000000000000', + }, + params: { + chainId: Chains.BASE, + contractAddress: '0x7e0b40af1d6f26f2141b90170c513e57b5edd74e', + tokenId: 21, + recipient: '0x3468f46837aa359c3fe4ccca1436eb13af8790a5', + referral: '0xe3bba2a4f8e0f5c32ef5097f988a4d88075c8b48', + }, +} + export const EXPECTED_ENCODED_DATA_721 = '0xefef39a1000000000000000000000000000000000000000000000000000000000000000a' export const EXPECTED_ENCODED_DATA_1155 = From 4c3513237707243a6c476ce188d90040e754ea56 Mon Sep 17 00:00:00 2001 From: mmackz Date: Sun, 14 Jul 2024 20:56:44 -0700 Subject: [PATCH 09/82] feat(pods): use checksum address in rewardsRecipient array --- packages/pods/src/Pods.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/pods/src/Pods.ts b/packages/pods/src/Pods.ts index 8675d75fd..9b9cee94f 100644 --- a/packages/pods/src/Pods.ts +++ b/packages/pods/src/Pods.ts @@ -26,6 +26,7 @@ import { type TransactionRequest, createPublicClient, encodeFunctionData, + getAddress, pad, parseEther, } from 'viem' @@ -42,14 +43,12 @@ export const mint = async ( }, ] if (referral) { - const referralLower = referral.toLowerCase() as Address + const checksumAddress = getAddress(referral) andArray1155.push({ $or: [ - { mintReferral: referralLower }, + { mintReferral: checksumAddress }, { - rewardsRecipients: { - $and: [{ $first: referralLower }, { $last: referralLower }], - }, + rewardsRecipients: { $and: [{ $first: checksumAddress }, { $last: checksumAddress }] }, }, ], }) From 17180f8369cdb868dfe53e9e7e005be112ccd64a Mon Sep 17 00:00:00 2001 From: mmackz Date: Sun, 14 Jul 2024 20:57:06 -0700 Subject: [PATCH 10/82] chore: format --- packages/pods/src/Pods.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/pods/src/Pods.ts b/packages/pods/src/Pods.ts index 9b9cee94f..6d318e5d5 100644 --- a/packages/pods/src/Pods.ts +++ b/packages/pods/src/Pods.ts @@ -48,7 +48,9 @@ export const mint = async ( $or: [ { mintReferral: checksumAddress }, { - rewardsRecipients: { $and: [{ $first: checksumAddress }, { $last: checksumAddress }] }, + rewardsRecipients: { + $and: [{ $first: checksumAddress }, { $last: checksumAddress }], + }, }, ], }) From c394b198778cbe959ce706d173def78c2d26df38 Mon Sep 17 00:00:00 2001 From: mmackz Date: Sun, 14 Jul 2024 20:58:10 -0700 Subject: [PATCH 11/82] chore: generate changeset --- .changeset/warm-insects-lick.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/warm-insects-lick.md diff --git a/.changeset/warm-insects-lick.md b/.changeset/warm-insects-lick.md new file mode 100644 index 000000000..ec9eb335a --- /dev/null +++ b/.changeset/warm-insects-lick.md @@ -0,0 +1,5 @@ +--- +"@rabbitholegg/questdk-plugin-pods": minor +--- + +use referral param in validation From 99602404e8795af816bd577ae71a17c7a6a55d9d Mon Sep 17 00:00:00 2001 From: mmackz Date: Sun, 14 Jul 2024 21:01:27 -0700 Subject: [PATCH 12/82] chore: revert "chore: format" --- packages/zora/src/Zora.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index aa9205760..4d752deaf 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -93,8 +93,7 @@ export const create = async ( export const mint = async ( mint: MintActionParams, ): Promise => { - const { chainId, contractAddress, tokenId, amount, recipient, referral } = - mint + const { chainId, contractAddress, tokenId, amount, recipient } = mint const universalMinter = zoraUniversalMinterAddress[ @@ -229,8 +228,7 @@ export const simulateMint = async ( account?: Address, client?: PublicClient, ): Promise => { - const { chainId, contractAddress, tokenId, amount, recipient, referral } = - mint + const { chainId, contractAddress, tokenId, amount, recipient } = mint const _client = client ?? createPublicClient({ @@ -288,7 +286,7 @@ export const simulateMint = async ( fixedPriceSaleStratAddress, _tokenId, amount, - [referral ?? ZORA_DEPLOYER_ADDRESS], + [ZORA_DEPLOYER_ADDRESS], pad(recipient), ] const result = await _client.simulateContract({ From 81b71b96adcb4968ffd1b26f439b5369d1b178f9 Mon Sep 17 00:00:00 2001 From: mmackz Date: Sun, 14 Jul 2024 21:05:22 -0700 Subject: [PATCH 13/82] feat(pods): add referral to mint simulation --- packages/pods/src/Pods.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/pods/src/Pods.ts b/packages/pods/src/Pods.ts index 6d318e5d5..aefb543b4 100644 --- a/packages/pods/src/Pods.ts +++ b/packages/pods/src/Pods.ts @@ -116,7 +116,7 @@ export const simulateMint = async ( account?: Address, client?: PublicClient, ): Promise => { - const { chainId, contractAddress, tokenId, amount, recipient } = mint + const { chainId, contractAddress, tokenId, amount, recipient, referral } = mint const _client = client ?? (createPublicClient({ @@ -135,7 +135,7 @@ export const simulateMint = async ( fixedPriceSaleStratAddress, _tokenId, amount, - [ZORA_DEPLOYER_ADDRESS], + [getAddress(referral) ?? ZORA_DEPLOYER_ADDRESS], pad(recipient), ] const result = await _client.simulateContract({ From 983acd64c65de74afda03162ee661a1dff89f32e Mon Sep 17 00:00:00 2001 From: mmackz Date: Sun, 14 Jul 2024 21:05:44 -0700 Subject: [PATCH 14/82] chore: format --- packages/pods/src/Pods.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/pods/src/Pods.ts b/packages/pods/src/Pods.ts index aefb543b4..5e1e2776d 100644 --- a/packages/pods/src/Pods.ts +++ b/packages/pods/src/Pods.ts @@ -116,7 +116,8 @@ export const simulateMint = async ( account?: Address, client?: PublicClient, ): Promise => { - const { chainId, contractAddress, tokenId, amount, recipient, referral } = mint + const { chainId, contractAddress, tokenId, amount, recipient, referral } = + mint const _client = client ?? (createPublicClient({ From ab076efd7c22c4ec5df64de8fe705fc5325ddc17 Mon Sep 17 00:00:00 2001 From: mmackz Date: Sun, 14 Jul 2024 21:06:31 -0700 Subject: [PATCH 15/82] feat(pods): add referral to mintIntents function --- packages/pods/src/Pods.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/pods/src/Pods.ts b/packages/pods/src/Pods.ts index 5e1e2776d..24e9be8b8 100644 --- a/packages/pods/src/Pods.ts +++ b/packages/pods/src/Pods.ts @@ -83,7 +83,8 @@ export const mint = async ( export const getMintIntent = async ( mint: MintIntentParams, ): Promise => { - const { chainId, contractAddress, tokenId, amount, recipient } = mint + const { chainId, contractAddress, tokenId, amount, recipient, referral } = + mint const fixedPriceSaleStratAddress = FIXED_PRICE_SALE_STRATS[chainId] @@ -93,7 +94,7 @@ export const getMintIntent = async ( fixedPriceSaleStratAddress, _tokenId, amount, - [ZORA_DEPLOYER_ADDRESS], + [getAddress(referral) ?? ZORA_DEPLOYER_ADDRESS], pad(recipient), ] From 3dfc53b6f6d9fe56c6cae2d86c5c0eca558d2c2d Mon Sep 17 00:00:00 2001 From: mmackz Date: Sun, 14 Jul 2024 21:12:52 -0700 Subject: [PATCH 16/82] feat(sound): add contracturi abi --- packages/soundxyz/src/constants.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/soundxyz/src/constants.ts b/packages/soundxyz/src/constants.ts index 2a0f416f3..80730eb19 100644 --- a/packages/soundxyz/src/constants.ts +++ b/packages/soundxyz/src/constants.ts @@ -317,6 +317,16 @@ export const MINT_INFO_LIST_ABI = [ }, ] +export const CONTRACT_URI_ABI = [ + { + inputs: [], + name: 'contractURI', + outputs: [{ internalType: 'string', name: '', type: 'string' }], + stateMutability: 'view', + type: 'function', + }, +] + // for referrals export const ZORA_DEPLOYER_ADDRESS = '0xe3bBA2A4F8E0F5C32EF5097F988a4d88075C8B48' From 6df697fcdeff4c94239f6ec0312ff5865100eb6d Mon Sep 17 00:00:00 2001 From: mmackz Date: Sun, 14 Jul 2024 21:18:34 -0700 Subject: [PATCH 17/82] test(sound): add test for external url --- packages/soundxyz/src/Soundxyz.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/soundxyz/src/Soundxyz.test.ts b/packages/soundxyz/src/Soundxyz.test.ts index 117fec98c..165f39d6b 100644 --- a/packages/soundxyz/src/Soundxyz.test.ts +++ b/packages/soundxyz/src/Soundxyz.test.ts @@ -1,5 +1,6 @@ import { getDynamicNameParams, + getExternalUrl, getProjectFees, mint, simulateMint, @@ -175,6 +176,7 @@ describe('simulateMint function', () => { contractAddress: '0xdf71F2F15bCcDC7c7A89F01dd45cDE5A43F7e79f', amount: BigInt(1), recipient: '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF', + referralAddress: '0xe3bba2a4f8e0f5c32ef5097f988a4d88075c8b48', } const value = parseEther('0.000777') const account = '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF' @@ -191,6 +193,7 @@ describe('simulateMint function', () => { contractAddress: '0x0c418874315698096ecA7ce0e1Dccf0A517DC9DE', amount: BigInt(1), recipient: '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF', + referral: '0xe3bba2a4f8e0f5c32ef5097f988a4d88075c8b48', } const value = parseEther('0.000777') const account = '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF' @@ -201,3 +204,14 @@ describe('simulateMint function', () => { expect(request.value).toBe(value) }) }) + +describe('getExternalLink', () => { + test('should return the correct link', async () => { + const contractAddress: Address = + '0xE39Df1AD806e84de47D0F6ddf56a0007C678597c' + const mintParams = { contractAddress, chainId: Chains.BASE } + + const link = await getExternalUrl(mintParams) + expect(link).equals('https://www.sound.xyz/33below/midnight-diner-ii') + }) +}) From b82ff4237b12db05b52f73716d805b7c15b279c3 Mon Sep 17 00:00:00 2001 From: mmackz Date: Sun, 14 Jul 2024 21:19:22 -0700 Subject: [PATCH 18/82] feat(sound): implement getExternalUrl function --- packages/soundxyz/src/Soundxyz.ts | 37 +++++++++++++++++++++++++++++++ packages/soundxyz/src/index.ts | 5 ++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/packages/soundxyz/src/Soundxyz.ts b/packages/soundxyz/src/Soundxyz.ts index f0d55a5d3..718201e2f 100644 --- a/packages/soundxyz/src/Soundxyz.ts +++ b/packages/soundxyz/src/Soundxyz.ts @@ -1,4 +1,6 @@ +import axios from 'axios' import { + CONTRACT_URI_ABI, MINT_INFO_LIST_ABI, NEXT_SCHEDULE_NUM_ABI, SUPERMINTER, @@ -284,3 +286,38 @@ export const getDynamicNameParams = async ( } return values } + +export const getExternalUrl = async ( + params: MintActionParams, +): Promise => { + const { chainId, contractAddress } = params + + try { + const client = createPublicClient({ + chain: chainIdToViemChain(chainId), + transport: http(), + }) as PublicClient + + const contractUri = await client.readContract({ + address: contractAddress, + abi: CONTRACT_URI_ABI, + functionName: 'contractURI', + }) as string + + const cid = contractUri.split('/').slice(2).join('/') + + const { data } = await axios.get(`https://arweave.net/${cid}`) + const { external_link } = data + + return external_link + } catch (error) { + console.error('an error occurred fetching the contract uri') + if (error instanceof Error) { + console.error(error.message) + } else { + console.error(error) + } + // fallback to default sound.xyz url + return 'https://sound.xyz' + } +} diff --git a/packages/soundxyz/src/index.ts b/packages/soundxyz/src/index.ts index ca0957ae2..5ca9f3a8b 100644 --- a/packages/soundxyz/src/index.ts +++ b/packages/soundxyz/src/index.ts @@ -7,6 +7,7 @@ import { import { getDynamicNameParams, + getExternalUrl, getFees, getMintIntent, getProjectFees, @@ -14,7 +15,7 @@ import { getSupportedTokenAddresses, mint, simulateMint, -} from './Soundxyz.js' +} from './Soundxyz' export const Soundxyz: IActionPlugin = { pluginId: 'soundxyz', @@ -24,6 +25,8 @@ export const Soundxyz: IActionPlugin = { bridge: async () => new PluginActionNotImplementedError(), swap: async () => new PluginActionNotImplementedError(), getDynamicNameParams, + getExternalUrl: async (params: ActionParams) => + getExternalUrl(params as unknown as MintActionParams), getMintIntent, getProjectFees: async (params: ActionParams) => getProjectFees(params as unknown as MintActionParams), From fb5202a8f92fbc40ad97a8a18d3a849544278a67 Mon Sep 17 00:00:00 2001 From: mmackz Date: Sun, 14 Jul 2024 21:26:40 -0700 Subject: [PATCH 19/82] chore: generate changeset --- .changeset/eleven-maps-fetch.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/eleven-maps-fetch.md diff --git a/.changeset/eleven-maps-fetch.md b/.changeset/eleven-maps-fetch.md new file mode 100644 index 000000000..6da782ebb --- /dev/null +++ b/.changeset/eleven-maps-fetch.md @@ -0,0 +1,5 @@ +--- +"@rabbitholegg/questdk-plugin-soundxyz": minor +--- + +add getExternalUrl function to sound plugin From 0e2e8a98e70587fef1f3871ea7bda6b05ca1d500 Mon Sep 17 00:00:00 2001 From: mmackz Date: Sun, 14 Jul 2024 21:27:30 -0700 Subject: [PATCH 20/82] chore: format --- packages/soundxyz/src/Soundxyz.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/soundxyz/src/Soundxyz.ts b/packages/soundxyz/src/Soundxyz.ts index 718201e2f..f751bf6fa 100644 --- a/packages/soundxyz/src/Soundxyz.ts +++ b/packages/soundxyz/src/Soundxyz.ts @@ -297,18 +297,18 @@ export const getExternalUrl = async ( chain: chainIdToViemChain(chainId), transport: http(), }) as PublicClient - - const contractUri = await client.readContract({ + + const contractUri = (await client.readContract({ address: contractAddress, abi: CONTRACT_URI_ABI, functionName: 'contractURI', - }) as string - + })) as string + const cid = contractUri.split('/').slice(2).join('/') - + const { data } = await axios.get(`https://arweave.net/${cid}`) const { external_link } = data - + return external_link } catch (error) { console.error('an error occurred fetching the contract uri') From 84b5a6d0129137da762ecb42ae5360869a42aefe Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 12:25:45 -0700 Subject: [PATCH 21/82] test(zora): add referral param to existing tests --- packages/zora/src/Zora.test.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/zora/src/Zora.test.ts b/packages/zora/src/Zora.test.ts index 91b20cd66..bedfb2723 100644 --- a/packages/zora/src/Zora.test.ts +++ b/packages/zora/src/Zora.test.ts @@ -29,6 +29,7 @@ import { describe, expect, test, vi, beforeEach, MockedFunction } from 'vitest' import { PremintResponse } from './types' import axios from 'axios' import { validatePremint } from './validate' +import { ZORA_DEPLOYER_ADDRESS } from './contract-addresses' const MockedPremintResponse: PremintResponse = [ { @@ -262,6 +263,7 @@ describe('Given the getMintIntent function', () => { contractAddress: CONTRACT_ADDRESS, amount: BigInt('10'), recipient: RECIPIENT_ADDRESS, + referral: ZORA_DEPLOYER_ADDRESS, } const result = await getMintIntent(mint) @@ -276,10 +278,10 @@ describe('Given the getMintIntent function', () => { test('returns a TransactionRequest with correct properties when tokenId is null', async () => { const mint: MintIntentParams = { chainId: 1, - contractAddress: CONTRACT_ADDRESS, amount: BigInt('10'), recipient: RECIPIENT_ADDRESS, + referral: ZORA_DEPLOYER_ADDRESS, } const result = await getMintIntent(mint) @@ -404,11 +406,12 @@ describe('simulateMint function', () => { tokenId: 10, amount: BigInt(1), recipient: '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF', + referral: ZORA_DEPLOYER_ADDRESS, } const value = parseEther('0.000777') const account = '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF' - const result = await mockFn.simulateMint(mint, value, account) + const result = await simulateMint(mint, value, account) const request = result.request expect(request.address).toBe(mint.contractAddress) expect(request.value).toBe(value) @@ -431,15 +434,16 @@ describe('simulateMint function', () => { const mint: MintIntentParams = { chainId: Chains.BLAST, - contractAddress: '0x8704c8b68e577d54be3c16341fbd31bac47c7471', + contractAddress: '0x553f0a63858a9000212cdbd0c40cf7861b692dc0', tokenId: 1, amount: BigInt(1), recipient: '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF', + referral: ZORA_DEPLOYER_ADDRESS, } const value = parseEther('0.000777') const account = '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF' - const result = await mockFn.simulateMint(mint, value, account) + const result = await simulateMint(mint, value, account) const request = result.request expect(request.address).toBe(mint.contractAddress) expect(request.value).toBe(value) @@ -452,6 +456,7 @@ describe('simulateMint function', () => { tokenId: 1, amount: BigInt(1), recipient: '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF', + referral: ZORA_DEPLOYER_ADDRESS, } const value = parseEther('0.000777') const account = '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF' From cd77c8b64d112a91348e412f0394b6c851472325 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 12:26:10 -0700 Subject: [PATCH 22/82] feat(zora): add referral param to mint simulation --- packages/zora/src/Zora.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index 4d752deaf..c26dcc960 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -228,7 +228,7 @@ export const simulateMint = async ( account?: Address, client?: PublicClient, ): Promise => { - const { chainId, contractAddress, tokenId, amount, recipient } = mint + const { chainId, contractAddress, tokenId, amount, recipient, referral } = mint const _client = client ?? createPublicClient({ @@ -286,7 +286,7 @@ export const simulateMint = async ( fixedPriceSaleStratAddress, _tokenId, amount, - [ZORA_DEPLOYER_ADDRESS], + [referral ?? ZORA_DEPLOYER_ADDRESS], pad(recipient), ] const result = await _client.simulateContract({ From d961e2d106f2538f16feeb163112f5f8ffe567c3 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 12:26:51 -0700 Subject: [PATCH 23/82] feat(zora): add referral param to mint intents function --- packages/zora/src/Zora.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index c26dcc960..96078caae 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -177,7 +177,7 @@ export const mint = async ( export const getMintIntent = async ( mint: MintIntentParams, ): Promise => { - const { chainId, contractAddress, tokenId, amount, recipient } = mint + const { chainId, contractAddress, tokenId, amount, recipient, referral } = mint let data let fixedPriceSaleStratAddress = FIXED_PRICE_SALE_STRATS[chainId] @@ -197,7 +197,7 @@ export const getMintIntent = async ( fixedPriceSaleStratAddress, tokenId, amount, - [ZORA_DEPLOYER_ADDRESS], + [referral ?? ZORA_DEPLOYER_ADDRESS], pad(recipient), ] // Assume it's an 1155 mint From 7339077a2af1b575da9651f7de563fc4084a36af Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 12:32:08 -0700 Subject: [PATCH 24/82] chore: allow additional types in $and array --- packages/zora/src/types.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/zora/src/types.ts b/packages/zora/src/types.ts index 29155187e..d7729f20b 100644 --- a/packages/zora/src/types.ts +++ b/packages/zora/src/types.ts @@ -1,8 +1,9 @@ -import { z } from 'zod' import { type FilterOperator, EthAddressSchema, } from '@rabbitholegg/questdk-plugin-utils' +import { type Address } from 'viem' +import { z } from 'zod' export const PremintResponseSchema = z.array( z.object({ @@ -49,3 +50,6 @@ export type AndArrayItem = | { quantity: string | number | bigint | FilterOperator } | RecipientCondition | { tokenId: string | number } + | { mintReferral: Address } + | { rewardsRecipients: { $and: [{ $first: Address }, { $last: Address }] } } + | { $or: AndArrayItem[] } \ No newline at end of file From 82c9c1dca665157bb6f669ef5ace99b1ef916d62 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 12:32:26 -0700 Subject: [PATCH 25/82] feat(zora): add referral prop to validation function --- packages/zora/src/Zora.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index 96078caae..1ef1aa79f 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -93,7 +93,7 @@ export const create = async ( export const mint = async ( mint: MintActionParams, ): Promise => { - const { chainId, contractAddress, tokenId, amount, recipient } = mint + const { chainId, contractAddress, tokenId, amount, recipient, referral } = mint const universalMinter = zoraUniversalMinterAddress[ @@ -126,6 +126,19 @@ export const mint = async ( tokenId, }) } + if (referral) { + const checksumAddress = getAddress(referral) + andArray1155.push({ + $or: [ + { mintReferral: checksumAddress }, + { + rewardsRecipients: { + $and: [{ $first: checksumAddress }, { $last: checksumAddress }], + }, + }, + ], + }) + } const ERC721_FILTER_ABSTRACT = { $abiAbstract: ZORA_MINTER_ABI_721, From ee615508b6ebe88ad212d6ed47c08919210aec6c Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 12:33:42 -0700 Subject: [PATCH 26/82] refactor(zora): update bytecode retrieval method in simulateMint function --- packages/zora/src/Zora.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index 1ef1aa79f..5e04845b8 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -273,7 +273,7 @@ export const simulateMint = async ( )}` // Check if the implementation contracts bytecode contains valid function selectors - const bytecode = await _client.getBytecode({ address: implementationAddress }) + const bytecode = await _client.getCode({ address: implementationAddress }) const containsSelector = FUNCTION_SELECTORS.some((selector) => bytecode?.includes(selector), ) From 58be3c8d2bc8503efecc922b326bcd127672be32 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 12:34:01 -0700 Subject: [PATCH 27/82] chore: format --- packages/zora/src/Zora.ts | 9 ++++++--- packages/zora/src/types.ts | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index 5e04845b8..716d3528c 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -93,7 +93,8 @@ export const create = async ( export const mint = async ( mint: MintActionParams, ): Promise => { - const { chainId, contractAddress, tokenId, amount, recipient, referral } = mint + const { chainId, contractAddress, tokenId, amount, recipient, referral } = + mint const universalMinter = zoraUniversalMinterAddress[ @@ -190,7 +191,8 @@ export const mint = async ( export const getMintIntent = async ( mint: MintIntentParams, ): Promise => { - const { chainId, contractAddress, tokenId, amount, recipient, referral } = mint + const { chainId, contractAddress, tokenId, amount, recipient, referral } = + mint let data let fixedPriceSaleStratAddress = FIXED_PRICE_SALE_STRATS[chainId] @@ -241,7 +243,8 @@ export const simulateMint = async ( account?: Address, client?: PublicClient, ): Promise => { - const { chainId, contractAddress, tokenId, amount, recipient, referral } = mint + const { chainId, contractAddress, tokenId, amount, recipient, referral } = + mint const _client = client ?? createPublicClient({ diff --git a/packages/zora/src/types.ts b/packages/zora/src/types.ts index d7729f20b..c704a1d47 100644 --- a/packages/zora/src/types.ts +++ b/packages/zora/src/types.ts @@ -52,4 +52,4 @@ export type AndArrayItem = | { tokenId: string | number } | { mintReferral: Address } | { rewardsRecipients: { $and: [{ $first: Address }, { $last: Address }] } } - | { $or: AndArrayItem[] } \ No newline at end of file + | { $or: AndArrayItem[] } From 1f6b17a55ff7f61add0a9e4f602f16cbcb75348a Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 13:22:57 -0700 Subject: [PATCH 28/82] test(zora): setup test for mint function with referral --- packages/zora/src/test-setup.ts | 10 +++++++++- packages/zora/src/test-transactions.ts | 23 ++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/packages/zora/src/test-setup.ts b/packages/zora/src/test-setup.ts index 05ea4c96c..a6dade1ab 100644 --- a/packages/zora/src/test-setup.ts +++ b/packages/zora/src/test-setup.ts @@ -3,6 +3,7 @@ import { CREATE_COLLECTION_BASE, CREATE_COLLECTION_ZORA, LAYER_ZERO_MINT, + MINT, MINT_BATCH_WITHOUT_FEES, MINT_WITH_REWARDS, MINT_WITH_REWARDS_1155, @@ -15,7 +16,8 @@ export const passingTestCasesMint = [ createTestCase(MINT_WITH_REWARDS, 'Minting with rewards'), createTestCase(MINT_WITH_REWARDS_1155, 'Minting with rewards 1155'), createTestCase(MINT_BATCH_WITHOUT_FEES, 'When using the batch mint function'), - createTestCase(BATCH_MINT_ARB, 'when using batch mint function on arbitrum'), + createTestCase(BATCH_MINT_ARB, 'when using batch mint function on optimism'), + createTestCase(MINT, 'when using mint function'), createTestCase(MINT_WITH_REWARDS, 'when contractAddress is checksummed', { contractAddress: getAddress(MINT_WITH_REWARDS.params.contractAddress), }), @@ -61,6 +63,12 @@ export const failingTestCasesMint = [ }, ), createTestCase(ZERO_QUANTITY, 'when quantity minted is 0'), + createTestCase(MINT_WITH_REWARDS, 'when referral is incorrect', { + referral: '0xDEAD0940159fB3368F5b06b34212C0cDF4e2C032', + }), + createTestCase(MINT, 'when referral is incorrect', { + referral: '0xDEAD0940159fB3368F5b06b34212C0cDF4e2C032', + }), ] export const passingTestCasesCreate = [ diff --git a/packages/zora/src/test-transactions.ts b/packages/zora/src/test-transactions.ts index 56f7e9043..99e88e810 100644 --- a/packages/zora/src/test-transactions.ts +++ b/packages/zora/src/test-transactions.ts @@ -3,6 +3,7 @@ import type { CreateActionParams, } from '@rabbitholegg/questdk' import { Chains, type TestParams } from '@rabbitholegg/questdk-plugin-utils' +import { zeroAddress } from 'viem' export const BASIC_PURCHASE: TestParams = { transaction: { @@ -21,6 +22,24 @@ export const BASIC_PURCHASE: TestParams = { }, } +export const MINT: TestParams = { + transaction: { + chainId: 7777777, // Zora + from: '0xeE520B72e4772E9bcb29a7B5940ACeC3d82AC9B1', + to: '0x8057c6bf3bc3adfc20b0deaf1898d5294d9701e8', + hash: '0x6e4e91536b59f1027913a77e2bb93ee362de64f95a41467c642ab8b1c0182804', + input: '0x359f130200000000000000000000000004e2516a2c207e84a1839755675dfd8ef6302f0a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000ee520b72e4772e9bcb29a7b5940acec3d82ac9b1', + value: '777000000000000', // 0.000777 ETH + }, + params: { + chainId: Chains.ZORA, + contractAddress: '0x8057C6Bf3bc3aDfc20B0dEaf1898d5294d9701e8', + amount: '1', + tokenId: 1, + referral: zeroAddress, + }, +} + export const MINT_WITH_REWARDS: TestParams = { transaction: { chainId: 1, // Ethereum @@ -53,6 +72,7 @@ export const MINT_WITH_REWARDS_1155: TestParams = { contractAddress: '0x4c0c2dd31d2661e8bcec60a42e803dcc6f81baad', amount: '1', tokenId: 25, + referral: zeroAddress, }, } @@ -71,6 +91,7 @@ export const MINT_BATCH_WITHOUT_FEES: TestParams = { contractAddress: '0xe538598941e4a25f471aef9b1b5dffd6ee0fda54', amount: '1', tokenId: 2, + referral: zeroAddress, }, } @@ -98,7 +119,7 @@ export const EXPECTED_ENCODED_DATA_1155 = export const BATCH_MINT_ARB: TestParams = { transaction: { - chainId: 42161, // Optimism + chainId: 42161, // Arbitrum from: '0x1671b592610fb7427ed788b66fa3e9217ff41047', hash: '0x4c0d898b6f3864332e3e47a3924cad33491b8df0a05590d13175823ee62ef07c', input: From 188b927938c1683c851365ea423aff5178fe8429 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 13:23:30 -0700 Subject: [PATCH 29/82] refactor(zora): use mock tests for intent and simulation --- packages/zora/src/Zora.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/zora/src/Zora.test.ts b/packages/zora/src/Zora.test.ts index bedfb2723..ecbdb73eb 100644 --- a/packages/zora/src/Zora.test.ts +++ b/packages/zora/src/Zora.test.ts @@ -411,7 +411,7 @@ describe('simulateMint function', () => { const value = parseEther('0.000777') const account = '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF' - const result = await simulateMint(mint, value, account) + const result = await mockFn.simulateMint(mint, value, account) const request = result.request expect(request.address).toBe(mint.contractAddress) expect(request.value).toBe(value) @@ -434,7 +434,7 @@ describe('simulateMint function', () => { const mint: MintIntentParams = { chainId: Chains.BLAST, - contractAddress: '0x553f0a63858a9000212cdbd0c40cf7861b692dc0', + contractAddress: '0x8704c8b68e577d54be3c16341fbd31bac47c7471', tokenId: 1, amount: BigInt(1), recipient: '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF', @@ -443,7 +443,7 @@ describe('simulateMint function', () => { const value = parseEther('0.000777') const account = '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF' - const result = await simulateMint(mint, value, account) + const result = await mockFn.simulateMint(mint, value, account) const request = result.request expect(request.address).toBe(mint.contractAddress) expect(request.value).toBe(value) From 4a129b221c94bbd1aa2c67a469c42ba192ba466f Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 13:26:00 -0700 Subject: [PATCH 30/82] chore: format --- packages/zora/src/test-transactions.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/zora/src/test-transactions.ts b/packages/zora/src/test-transactions.ts index 99e88e810..70d16626c 100644 --- a/packages/zora/src/test-transactions.ts +++ b/packages/zora/src/test-transactions.ts @@ -28,7 +28,8 @@ export const MINT: TestParams = { from: '0xeE520B72e4772E9bcb29a7B5940ACeC3d82AC9B1', to: '0x8057c6bf3bc3adfc20b0deaf1898d5294d9701e8', hash: '0x6e4e91536b59f1027913a77e2bb93ee362de64f95a41467c642ab8b1c0182804', - input: '0x359f130200000000000000000000000004e2516a2c207e84a1839755675dfd8ef6302f0a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000ee520b72e4772e9bcb29a7b5940acec3d82ac9b1', + input: + '0x359f130200000000000000000000000004e2516a2c207e84a1839755675dfd8ef6302f0a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000ee520b72e4772e9bcb29a7b5940acec3d82ac9b1', value: '777000000000000', // 0.000777 ETH }, params: { From a58a6f626e5446eaf207a39fbab0bfc54d1cb542 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 13:26:32 -0700 Subject: [PATCH 31/82] chore: generate changeset --- .changeset/nine-coats-remember.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/nine-coats-remember.md diff --git a/.changeset/nine-coats-remember.md b/.changeset/nine-coats-remember.md new file mode 100644 index 000000000..9a0dced7f --- /dev/null +++ b/.changeset/nine-coats-remember.md @@ -0,0 +1,5 @@ +--- +"@rabbitholegg/questdk-plugin-zora": minor +--- + +use referral param in validation and simulations From 6de5ea98de2bd49567297e339451f3b0138f073c Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 13:27:39 -0700 Subject: [PATCH 32/82] chore: fix typo --- packages/zora/src/test-setup.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/zora/src/test-setup.ts b/packages/zora/src/test-setup.ts index a6dade1ab..13e58a31f 100644 --- a/packages/zora/src/test-setup.ts +++ b/packages/zora/src/test-setup.ts @@ -16,7 +16,7 @@ export const passingTestCasesMint = [ createTestCase(MINT_WITH_REWARDS, 'Minting with rewards'), createTestCase(MINT_WITH_REWARDS_1155, 'Minting with rewards 1155'), createTestCase(MINT_BATCH_WITHOUT_FEES, 'When using the batch mint function'), - createTestCase(BATCH_MINT_ARB, 'when using batch mint function on optimism'), + createTestCase(BATCH_MINT_ARB, 'when using batch mint function on arbitrum'), createTestCase(MINT, 'when using mint function'), createTestCase(MINT_WITH_REWARDS, 'when contractAddress is checksummed', { contractAddress: getAddress(MINT_WITH_REWARDS.params.contractAddress), From f511250a8ac5079f0921e1d4e523441f92886b97 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 13:34:20 -0700 Subject: [PATCH 33/82] test(zora): update blast test to use mintable contract --- packages/zora/src/Zora.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/zora/src/Zora.test.ts b/packages/zora/src/Zora.test.ts index ecbdb73eb..7ed15c118 100644 --- a/packages/zora/src/Zora.test.ts +++ b/packages/zora/src/Zora.test.ts @@ -425,7 +425,7 @@ describe('simulateMint function', () => { _account: Address, ) => ({ request: { - address: '0x8704c8b68e577d54be3c16341fbd31bac47c7471', + address: '0x553f0a63858a9000212cdbd0c40cf7861b692dc0', value: parseEther('0.000777'), }, }), @@ -434,7 +434,7 @@ describe('simulateMint function', () => { const mint: MintIntentParams = { chainId: Chains.BLAST, - contractAddress: '0x8704c8b68e577d54be3c16341fbd31bac47c7471', + contractAddress: '0x553f0a63858a9000212cdbd0c40cf7861b692dc0', tokenId: 1, amount: BigInt(1), recipient: '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF', From 12099b3b98c49e949898a16013c46f4c9e4b8a8b Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 13:36:35 -0700 Subject: [PATCH 34/82] test(sound): use referral in tests to satisfy MintIntentParams type --- packages/soundxyz/src/Soundxyz.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/soundxyz/src/Soundxyz.test.ts b/packages/soundxyz/src/Soundxyz.test.ts index 117fec98c..eedfe186a 100644 --- a/packages/soundxyz/src/Soundxyz.test.ts +++ b/packages/soundxyz/src/Soundxyz.test.ts @@ -4,7 +4,12 @@ import { mint, simulateMint, } from './Soundxyz' -import { SUPERMINTER, SUPERMINTER_V2, SUPERMINTER_V2_ABI } from './constants' +import { + SUPERMINTER, + SUPERMINTER_V2, + SUPERMINTER_V2_ABI, + ZORA_DEPLOYER_ADDRESS, +} from './constants' import { OP_SUPERMINTER_V2, failingTestCases, @@ -175,6 +180,7 @@ describe('simulateMint function', () => { contractAddress: '0xdf71F2F15bCcDC7c7A89F01dd45cDE5A43F7e79f', amount: BigInt(1), recipient: '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF', + referral: ZORA_DEPLOYER_ADDRESS, } const value = parseEther('0.000777') const account = '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF' @@ -191,6 +197,7 @@ describe('simulateMint function', () => { contractAddress: '0x0c418874315698096ecA7ce0e1Dccf0A517DC9DE', amount: BigInt(1), recipient: '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF', + referral: ZORA_DEPLOYER_ADDRESS, } const value = parseEther('0.000777') const account = '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF' From 930c40b0262b167806e1dbb90789eec27f948695 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 14:24:24 -0700 Subject: [PATCH 35/82] feat(zora): map chain id to zora slug --- packages/zora/src/chain-ids.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/zora/src/chain-ids.ts b/packages/zora/src/chain-ids.ts index df114f702..cd4869d6d 100644 --- a/packages/zora/src/chain-ids.ts +++ b/packages/zora/src/chain-ids.ts @@ -8,3 +8,12 @@ export const CHAIN_ID_ARRAY = [ Chains.OPTIMISM, Chains.ZORA, ] + +export const CHAIN_ID_TO_ZORA_SLUG: Record = { + [Chains.ARBITRUM_ONE]: 'arb', + [Chains.BASE]: 'base', + [Chains.BLAST]: 'blast', + [Chains.ETHEREUM]: 'eth', + [Chains.OPTIMISM]: 'oeth', + [Chains.ZORA]: 'zora', +} From 97e9dbec920342e1dd260a43ec800012b7da97c5 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 14:24:43 -0700 Subject: [PATCH 36/82] feat(zora): implement getExternalUrl function --- packages/zora/src/Zora.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index 4d752deaf..5ec59d058 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -6,7 +6,7 @@ import { ZORA_MINTER_ABI_1155, ZORA_MINTER_ABI_1155_LEGACY, } from './abi' -import { CHAIN_ID_ARRAY } from './chain-ids' +import { CHAIN_ID_ARRAY, CHAIN_ID_TO_ZORA_SLUG } from './chain-ids' import { FIXED_PRICE_SALE_STRATS, ZORA_1155_FACTORY, @@ -426,3 +426,14 @@ export const getDynamicNameParams = async ( } return values } + +export const getExternalUrl = async ( + params: MintActionParams, +): Promise => { + const { chainId, contractAddress, tokenId, referral } = params + const chainSlug = CHAIN_ID_TO_ZORA_SLUG[chainId] + const referralParams = referral ? `?referrer=${referral}` : '' + const baseUrl = `https://zora.co/collect/${chainSlug}:${contractAddress}` + + return tokenId != null ? `${baseUrl}/${tokenId}${referralParams}` : `${baseUrl}${referralParams}` +} From 3830cac4eb74ba4b3c6f2043eff4e1d1d039aa1d Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 14:29:24 -0700 Subject: [PATCH 37/82] test(zora): add test for getExternalUrl --- packages/zora/src/Zora.test.ts | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/packages/zora/src/Zora.test.ts b/packages/zora/src/Zora.test.ts index 91b20cd66..b18be8d11 100644 --- a/packages/zora/src/Zora.test.ts +++ b/packages/zora/src/Zora.test.ts @@ -1,6 +1,7 @@ import { create, getDynamicNameParams, + getExternalUrl, getMintIntent, mint, simulateMint, @@ -24,7 +25,7 @@ import { type PremintActionParams, } from '@rabbitholegg/questdk-plugin-utils' import { apply } from '@rabbitholegg/questdk' -import { type Address, parseEther } from 'viem' +import { type Address, getAddress, parseEther } from 'viem' import { describe, expect, test, vi, beforeEach, MockedFunction } from 'vitest' import { PremintResponse } from './types' import axios from 'axios' @@ -513,3 +514,30 @@ describe('getDynamicNameParams function', () => { ).rejects.toThrow(`Invalid action type "${params.type}"`) }) }) + +describe('getExternalUrl function', () => { + test('should return correct url for 1155 mint with token id', async () => { + const params = { + chainId: Chains.ZORA, + contractAddress: getAddress('0x393c46fe7887697124a73f6028f39751aa1961a3'), + tokenId: 1, + referral: getAddress('0x1234567890123456789012345678901234567890'), + } + const result = await getExternalUrl(params) + expect(result).toBe( + 'https://zora.co/collect/zora:0x393c46fe7887697124A73f6028f39751aA1961a3/1?referrer=0x1234567890123456789012345678901234567890', + ) + }) + + test('should return correct url for 1155 mint without token id', async () => { + const params = { + chainId: Chains.ZORA, + contractAddress: getAddress('0x393c46fe7887697124a73f6028f39751aa1961a3'), + referral: getAddress('0x1234567890123456789012345678901234567890'), + } + const result = await getExternalUrl(params) + expect(result).toBe( + 'https://zora.co/collect/zora:0x393c46fe7887697124A73f6028f39751aA1961a3?referrer=0x1234567890123456789012345678901234567890', + ) + }) +}) From c7095cc3604de03685df12df54f55dfb6f916898 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 14:29:41 -0700 Subject: [PATCH 38/82] chore: format --- packages/zora/src/Zora.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index 5ec59d058..e5dbb277a 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -435,5 +435,7 @@ export const getExternalUrl = async ( const referralParams = referral ? `?referrer=${referral}` : '' const baseUrl = `https://zora.co/collect/${chainSlug}:${contractAddress}` - return tokenId != null ? `${baseUrl}/${tokenId}${referralParams}` : `${baseUrl}${referralParams}` + return tokenId != null + ? `${baseUrl}/${tokenId}${referralParams}` + : `${baseUrl}${referralParams}` } From 379f7fc05703a705b23ec89e8b25cdd5ba2eb35c Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 14:30:15 -0700 Subject: [PATCH 39/82] chore: generate changeset --- .changeset/hot-boats-help.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/hot-boats-help.md diff --git a/.changeset/hot-boats-help.md b/.changeset/hot-boats-help.md new file mode 100644 index 000000000..a3e4d26c0 --- /dev/null +++ b/.changeset/hot-boats-help.md @@ -0,0 +1,5 @@ +--- +"@rabbitholegg/questdk-plugin-zora": minor +--- + +implement getExternalUrl function From 78532a4d1966a289086ecc43c11b032f508168f2 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 14:41:45 -0700 Subject: [PATCH 40/82] feat(zora): export getExternalUrl function --- packages/zora/src/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/zora/src/index.ts b/packages/zora/src/index.ts index b945b6a03..e03944aa7 100644 --- a/packages/zora/src/index.ts +++ b/packages/zora/src/index.ts @@ -8,6 +8,7 @@ import { import { create, getDynamicNameParams, + getExternalUrl, getFees, getMintIntent, getProjectFees, @@ -28,6 +29,8 @@ export const Zora: IActionPlugin = { swap: async () => new PluginActionNotImplementedError(), mint, getDynamicNameParams, + getExternalUrl: async (params: ActionParams) => + getExternalUrl(params as unknown as MintActionParams), getProjectFees: async (params: ActionParams) => getProjectFees(params as unknown as MintActionParams), getFees: async (params: ActionParams) => From 931fed327bdd4c14348ac56dc8d337704ac9e631 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 15:17:21 -0700 Subject: [PATCH 41/82] feat(pods): implement getUri function in utils --- packages/pods/src/utils.ts | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/packages/pods/src/utils.ts b/packages/pods/src/utils.ts index 9c1631c8c..d12e6b079 100644 --- a/packages/pods/src/utils.ts +++ b/packages/pods/src/utils.ts @@ -35,3 +35,40 @@ export async function getLatestTokenId( return 1 } } + +export async function getUri( + client: PublicClient, + contractAddress: Address, + tokenId?: number, +): Promise { + if (tokenId == null) { + return (await client.readContract({ + address: contractAddress, + abi: [ + { + inputs: [], + name: 'contractURI', + outputs: [{ internalType: 'string', name: '', type: 'string' }], + stateMutability: 'view', + type: 'function', + }, + ], + functionName: 'contractURI', + })) as string + } + + return (await client.readContract({ + address: contractAddress, + abi: [ + { + inputs: [{ internalType: 'uint256', name: 'tokenId', type: 'uint256' }], + name: 'uri', + outputs: [{ internalType: 'string', name: '', type: 'string' }], + stateMutability: 'view', + type: 'function', + }, + ], + functionName: 'uri', + args: [BigInt(tokenId)], + })) as string +} From 69de56d98ffcb541889517292c743667d07317ee Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 15:17:44 -0700 Subject: [PATCH 42/82] test(pods): add tests for getExternalUrl function --- packages/pods/src/Pods.test.ts | 37 ++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/packages/pods/src/Pods.test.ts b/packages/pods/src/Pods.test.ts index 78832edac..b74b830fc 100644 --- a/packages/pods/src/Pods.test.ts +++ b/packages/pods/src/Pods.test.ts @@ -4,9 +4,9 @@ import { type MintIntentParams, } from '@rabbitholegg/questdk-plugin-utils' import { apply } from '@rabbitholegg/questdk' -import { type Address, parseEther } from 'viem' +import { type Address, parseEther, getAddress, zeroAddress } from 'viem' import { describe, expect, test, vi } from 'vitest' -import { getMintIntent, mint } from './Pods' +import { getExternalUrl, getMintIntent, mint } from './Pods' import { failingTestCases, passingTestCases } from './test-setup' import { EXPECTED_ENCODED_DATA_1155 } from './test-transactions' @@ -201,3 +201,36 @@ describe('simulateMint function', () => { expect(request.value).toBe(value) }) }) + +describe('getExternalUrl function', () => { + test('should return correct url for mint w/tokenId', async () => { + const params = { + chainId: Chains.BASE, + contractAddress: getAddress('0x7e0b40af1d6f26f2141b90170c513e57b5edd74e'), + tokenId: 21, + referral: getAddress('0x1234567890123456789012345678901234567890'), + } + const result = await getExternalUrl(params) + expect(result).toBe('https://pods.media/mint-podcast/why-social-needs-a-layer-2-ft-ryan-li-of-cyber?referrer=0x1234567890123456789012345678901234567890') + }) + + test('should return correct url for mint w/out tokenId', async () => { + const params = { + chainId: Chains.BASE, + contractAddress: getAddress('0x7e0b40af1d6f26f2141b90170c513e57b5edd74e'), + referral: getAddress('0x1234567890123456789012345678901234567890'), + } + const result = await getExternalUrl(params) + expect(result).toBe('https://pods.media/mint-podcast?referrer=0x1234567890123456789012345678901234567890') + }) + + test('should return fallback url if error occurs', async () => { + const params = { + chainId: Chains.BASE, + contractAddress: zeroAddress, + referral: getAddress('0x1234567890123456789012345678901234567890'), + } + const result = await getExternalUrl(params) + expect(result).toBe('https://pods.media') + }) +}) From 965f598e0c40742cef2eeeacfcce1f8a2627ac03 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 15:18:08 -0700 Subject: [PATCH 43/82] feat(pods): implement getExternalUrl function --- packages/pods/src/Pods.ts | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/packages/pods/src/Pods.ts b/packages/pods/src/Pods.ts index aba53407d..1af4eab66 100644 --- a/packages/pods/src/Pods.ts +++ b/packages/pods/src/Pods.ts @@ -1,10 +1,11 @@ +import axios from 'axios' import { FEES_ABI, ZORA_MINTER_ABI_1155 } from './abi' import { CHAIN_ID_ARRAY } from './chain-ids' import { FIXED_PRICE_SALE_STRATS, ZORA_DEPLOYER_ADDRESS, } from './contract-addresses' -import { type AndArrayItem, getLatestTokenId } from './utils' +import { type AndArrayItem, getLatestTokenId, getUri } from './utils' import { type MintActionParams, type TransactionFilter, @@ -180,6 +181,39 @@ export const getFees = async ( } } +export const getExternalUrl = async ( + params: MintActionParams, +): Promise => { + const { chainId, contractAddress, tokenId, referral } = params + + try { + const client = createPublicClient({ + chain: chainIdToViemChain(chainId), + transport: http(), + }) as PublicClient + + const uri = await getUri(client, contractAddress, tokenId) + console.log('uri', uri) + const cid = uri.split('/').slice(2).join('/') + + const { data } = await axios.get(`https://arweave.net/${cid}`) + + // different properties depending uri function. At least one of these will be defined + const baseUrl = data.external_link ?? data.external_url + + return referral ? `${baseUrl}?referrer=${referral}` : baseUrl + } catch (error) { + console.error('an error occurred fetching data from the contract') + if (error instanceof Error) { + console.error(error.message) + } else { + console.error(error) + } + // fallback to default pods url + return 'https://pods.media' + } +} + export const getSupportedTokenAddresses = async ( _chainId: number, ): Promise => { From 542a2ab909019fc1052eb7b33e12ba2893716d62 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 15:19:04 -0700 Subject: [PATCH 44/82] feat(pods): export getExternalUrl from plugin --- packages/pods/src/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/pods/src/index.ts b/packages/pods/src/index.ts index 167165fab..f1ba85a0f 100644 --- a/packages/pods/src/index.ts +++ b/packages/pods/src/index.ts @@ -6,6 +6,7 @@ import { } from '@rabbitholegg/questdk-plugin-utils' import { + getExternalUrl, getFees, getMintIntent, getProjectFees, @@ -13,7 +14,7 @@ import { getSupportedTokenAddresses, mint, simulateMint, -} from './Pods.js' +} from './Pods' export const Pods: IActionPlugin = { pluginId: 'pods', @@ -24,6 +25,8 @@ export const Pods: IActionPlugin = { mint, getProjectFees: async (params: ActionParams) => getProjectFees(params as unknown as MintActionParams), + getExternalUrl: async (params: ActionParams) => + getExternalUrl(params as unknown as MintActionParams), getFees: async (params: ActionParams) => getFees(params as unknown as MintActionParams), getMintIntent, From 6a692b75ad1fb0d4eab3fdb80a3bb54abd08f09e Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 15:19:40 -0700 Subject: [PATCH 45/82] chore: generate changeset --- .changeset/light-rabbits-develop.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/light-rabbits-develop.md diff --git a/.changeset/light-rabbits-develop.md b/.changeset/light-rabbits-develop.md new file mode 100644 index 000000000..e7eeec645 --- /dev/null +++ b/.changeset/light-rabbits-develop.md @@ -0,0 +1,5 @@ +--- +"@rabbitholegg/questdk-plugin-pods": minor +--- + +implement getExternalUrl for pods From 5ce15a958566e69131f15330943ffc98eb8dd4a0 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 15:21:14 -0700 Subject: [PATCH 46/82] chore: format --- packages/pods/src/Pods.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/pods/src/Pods.test.ts b/packages/pods/src/Pods.test.ts index b74b830fc..2b43c7f78 100644 --- a/packages/pods/src/Pods.test.ts +++ b/packages/pods/src/Pods.test.ts @@ -211,7 +211,9 @@ describe('getExternalUrl function', () => { referral: getAddress('0x1234567890123456789012345678901234567890'), } const result = await getExternalUrl(params) - expect(result).toBe('https://pods.media/mint-podcast/why-social-needs-a-layer-2-ft-ryan-li-of-cyber?referrer=0x1234567890123456789012345678901234567890') + expect(result).toBe( + 'https://pods.media/mint-podcast/why-social-needs-a-layer-2-ft-ryan-li-of-cyber?referrer=0x1234567890123456789012345678901234567890', + ) }) test('should return correct url for mint w/out tokenId', async () => { @@ -221,7 +223,9 @@ describe('getExternalUrl function', () => { referral: getAddress('0x1234567890123456789012345678901234567890'), } const result = await getExternalUrl(params) - expect(result).toBe('https://pods.media/mint-podcast?referrer=0x1234567890123456789012345678901234567890') + expect(result).toBe( + 'https://pods.media/mint-podcast?referrer=0x1234567890123456789012345678901234567890', + ) }) test('should return fallback url if error occurs', async () => { From 90f7620e07180f131ef89194f3e2f91a17f0f6f2 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 15:23:07 -0700 Subject: [PATCH 47/82] chore: fix typo --- packages/pods/src/Pods.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pods/src/Pods.ts b/packages/pods/src/Pods.ts index 1af4eab66..94e750663 100644 --- a/packages/pods/src/Pods.ts +++ b/packages/pods/src/Pods.ts @@ -198,7 +198,7 @@ export const getExternalUrl = async ( const { data } = await axios.get(`https://arweave.net/${cid}`) - // different properties depending uri function. At least one of these will be defined + // different properties depending on uri function. At least one of these will be defined const baseUrl = data.external_link ?? data.external_url return referral ? `${baseUrl}?referrer=${referral}` : baseUrl From c97e1f08a67c4e51556928d74a1fd76f74d91a2c Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 15:23:37 -0700 Subject: [PATCH 48/82] chore: fix typo --- packages/pods/src/Pods.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pods/src/Pods.ts b/packages/pods/src/Pods.ts index 94e750663..811c0c968 100644 --- a/packages/pods/src/Pods.ts +++ b/packages/pods/src/Pods.ts @@ -198,7 +198,7 @@ export const getExternalUrl = async ( const { data } = await axios.get(`https://arweave.net/${cid}`) - // different properties depending on uri function. At least one of these will be defined + // different properties depending on uri function. One of these will be defined const baseUrl = data.external_link ?? data.external_url return referral ? `${baseUrl}?referrer=${referral}` : baseUrl From f318e67837b805874c500ef5d3658fc9b657ee32 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 15:24:12 -0700 Subject: [PATCH 49/82] chore: remove console.log --- packages/pods/src/Pods.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/pods/src/Pods.ts b/packages/pods/src/Pods.ts index 811c0c968..345254eea 100644 --- a/packages/pods/src/Pods.ts +++ b/packages/pods/src/Pods.ts @@ -193,7 +193,6 @@ export const getExternalUrl = async ( }) as PublicClient const uri = await getUri(client, contractAddress, tokenId) - console.log('uri', uri) const cid = uri.split('/').slice(2).join('/') const { data } = await axios.get(`https://arweave.net/${cid}`) From 1109886c7858890e4f723ce0115c750f00c578d5 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 17:18:02 -0700 Subject: [PATCH 50/82] feat(foundation): add chain to slug mapping --- packages/foundation/src/utils.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/foundation/src/utils.ts b/packages/foundation/src/utils.ts index 26ac596af..d62b62cb5 100644 --- a/packages/foundation/src/utils.ts +++ b/packages/foundation/src/utils.ts @@ -8,11 +8,17 @@ import { } from './constants' import { type SaleTerms } from './types' import { + Chains, type MintActionParams, chainIdToViemChain, } from '@rabbitholegg/questdk-plugin-utils' import { type Address, type PublicClient, createPublicClient, http } from 'viem' +export const CHAIN_TO_NETWORK_SLUG: Record = { + [Chains.ETHEREUM]: 'eth', + [Chains.BASE]: 'base', +} + export async function getFixedPriceData( client: PublicClient, address: Address, From 4cefcda0a6cbb686adb771989bdde04d92ab33bd Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 18:00:09 -0700 Subject: [PATCH 51/82] test(foundation): add tests for external url function --- packages/foundation/src/Foundation.test.ts | 35 ++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/packages/foundation/src/Foundation.test.ts b/packages/foundation/src/Foundation.test.ts index a0d86c7b3..a57f342ee 100644 --- a/packages/foundation/src/Foundation.test.ts +++ b/packages/foundation/src/Foundation.test.ts @@ -1,4 +1,4 @@ -import { mint } from './Foundation' +import { getExternalUrl, mint } from './Foundation' // import { getFees, getMintIntent, simulateMint } from './Foundation' import { dutchAuctionResponse, @@ -403,4 +403,35 @@ describe('Given the foundation plugin', () => { expect(request.value).toBe(value) }) }) -}) + + describe('getExternalUrl function', () => { + test('should return the correct url for a 721 mint', async () => { + const mint: MintActionParams = { + chainId: Chains.BASE, + contractAddress: '0xead6dca70b0465725a57eb81f7d3ab8b5e0b81b4', + } + const result = await getExternalUrl(mint) + expect(result).toBe('https://foundation.app/mint/base/0xead6dca70b0465725a57eb81f7d3ab8b5e0b81b4') + }) + + test('should return the base url for 1155 mint', async () => { + const mint: MintActionParams = { + chainId: Chains.BASE, + contractAddress: '0x1d2550d198197df1a10af515cf2ea0d790889b93', + tokenId: 213, + } + const result = await getExternalUrl(mint) + expect(result).toBe('https://foundation.app/') + }) + + test('should return the base url for unsupported chain', async () => { + const mint: MintActionParams = { + chainId: Chains.OPTIMISM, + contractAddress: '0x1d2550d198197df1a10af515cf2ea0d790889b93', + tokenId: 213, + } + const result = await getExternalUrl(mint) + expect(result).toBe('https://foundation.app/') + }) + }) +}) \ No newline at end of file From 7e11dc4c37b34598628bad40806d0d0cd47654e8 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 18:01:54 -0700 Subject: [PATCH 52/82] add undefined to network slug record --- packages/foundation/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/foundation/src/utils.ts b/packages/foundation/src/utils.ts index d62b62cb5..89d969a64 100644 --- a/packages/foundation/src/utils.ts +++ b/packages/foundation/src/utils.ts @@ -14,7 +14,7 @@ import { } from '@rabbitholegg/questdk-plugin-utils' import { type Address, type PublicClient, createPublicClient, http } from 'viem' -export const CHAIN_TO_NETWORK_SLUG: Record = { +export const CHAIN_TO_NETWORK_SLUG: Record = { [Chains.ETHEREUM]: 'eth', [Chains.BASE]: 'base', } From a0a46a2da7daca725e2f7dcdcb8ad88fc7643564 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 18:02:32 -0700 Subject: [PATCH 53/82] feat(foundation): implement getExternalUrl function --- packages/foundation/src/Foundation.ts | 13 +++++++++++++ packages/foundation/src/index.ts | 3 +++ 2 files changed, 16 insertions(+) diff --git a/packages/foundation/src/Foundation.ts b/packages/foundation/src/Foundation.ts index 7966acf30..cbc25a0ef 100644 --- a/packages/foundation/src/Foundation.ts +++ b/packages/foundation/src/Foundation.ts @@ -8,6 +8,7 @@ import { REFERRAL_ADDRESS, } from './constants' import { + CHAIN_TO_NETWORK_SLUG, calculateFees, getContractType, getDutchAuctionData, @@ -341,6 +342,18 @@ export const simulateMint = async ( throw new Error('Invalid contract type') } +export const getExternalUrl = async ( + params: MintActionParams, +): Promise => { + const { chainId, contractAddress, tokenId } = params + const baseUrl = 'https://foundation.app/' + const networkSlug = CHAIN_TO_NETWORK_SLUG[chainId] + if (tokenId != null || !networkSlug) { + return baseUrl + } + return `${baseUrl}mint/${networkSlug}/${contractAddress}` +} + export const getSupportedTokenAddresses = async ( _chainId: number, ): Promise => { diff --git a/packages/foundation/src/index.ts b/packages/foundation/src/index.ts index ae70ff0c7..98610b259 100644 --- a/packages/foundation/src/index.ts +++ b/packages/foundation/src/index.ts @@ -5,6 +5,7 @@ import { } from '@rabbitholegg/questdk' import { + getExternalUrl, getFees, getMintIntent, getProjectFees, @@ -16,6 +17,8 @@ import { export const Foundation: IActionPlugin = { pluginId: 'foundation', + getExternalUrl: async (params: ActionParams) => + getExternalUrl(params as unknown as MintActionParams), getFees: async (params: ActionParams) => getFees(params as unknown as MintActionParams), getMintIntent, From dc17ad3e67062b727736dd0fc3b3ad96df539401 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 18:05:06 -0700 Subject: [PATCH 54/82] chore: format --- packages/foundation/src/Foundation.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/foundation/src/Foundation.test.ts b/packages/foundation/src/Foundation.test.ts index a57f342ee..a387adf5f 100644 --- a/packages/foundation/src/Foundation.test.ts +++ b/packages/foundation/src/Foundation.test.ts @@ -411,7 +411,9 @@ describe('Given the foundation plugin', () => { contractAddress: '0xead6dca70b0465725a57eb81f7d3ab8b5e0b81b4', } const result = await getExternalUrl(mint) - expect(result).toBe('https://foundation.app/mint/base/0xead6dca70b0465725a57eb81f7d3ab8b5e0b81b4') + expect(result).toBe( + 'https://foundation.app/mint/base/0xead6dca70b0465725a57eb81f7d3ab8b5e0b81b4', + ) }) test('should return the base url for 1155 mint', async () => { @@ -434,4 +436,4 @@ describe('Given the foundation plugin', () => { expect(result).toBe('https://foundation.app/') }) }) -}) \ No newline at end of file +}) From 6e85c79c93ce1e2916fd88bedbbd521466b03c96 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 18:05:45 -0700 Subject: [PATCH 55/82] chore: generate changeset --- .changeset/fresh-buckets-float.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fresh-buckets-float.md diff --git a/.changeset/fresh-buckets-float.md b/.changeset/fresh-buckets-float.md new file mode 100644 index 000000000..114bab1e5 --- /dev/null +++ b/.changeset/fresh-buckets-float.md @@ -0,0 +1,5 @@ +--- +"@rabbitholegg/questdk-plugin-foundation": minor +--- + +implement getExternalUrl function From b7740721aea7ee7e0fde62ca9666cdc8bf691b75 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 18:46:54 -0700 Subject: [PATCH 56/82] test(manifold): add test for getExternalUrl --- packages/manifold/src/Manifold.test.ts | 34 ++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/packages/manifold/src/Manifold.test.ts b/packages/manifold/src/Manifold.test.ts index eb58729b8..1073e026d 100644 --- a/packages/manifold/src/Manifold.test.ts +++ b/packages/manifold/src/Manifold.test.ts @@ -1,4 +1,4 @@ -import { getFees, getMintIntent, mint, simulateMint } from './Manifold' +import { getExternalUrl, getFees, getMintIntent, mint, simulateMint } from './Manifold' import { ERC721_CONTRACT, ERC1155_CONTRACT } from './constants' import { failingTestCases, passingTestCases } from './test-transactions' import { apply } from '@rabbitholegg/questdk' @@ -8,7 +8,7 @@ import { type MintIntentParams, } from '@rabbitholegg/questdk-plugin-utils' import axios from 'axios' -import { type Address, parseEther } from 'viem' +import { type Address, parseEther, getAddress } from 'viem' import { MockedFunction, beforeEach, describe, expect, test, vi } from 'vitest' vi.mock('axios', () => { @@ -218,3 +218,33 @@ describe('simulateMint function', () => { expect(request.value).toBe(value) }) }) + +describe('getExternalUrl function', () => { + beforeEach(() => { + vi.resetAllMocks() + }) + test('should return the correct url for a 721 mint', async () => { + const mint = { + chainId: Chains.OPTIMISM, + contractAddress: getAddress('0x6935cd348193bab133f3081f53eb99ee6f0d685b'), + } + ;(axios.get as MockedFunction).mockResolvedValue({ + status: 200, + data: { + slug: 'girls-man', + }, + }) + + const result = await getExternalUrl(mint) + expect(result).toBe('https://app.manifold.xyz/c/girls-man') + }) + + test('should return the fallback url for an unknown contract', async () => { + const mint = { + chainId: Chains.OPTIMISM, + contractAddress: getAddress('0x7935cd348193bab133f3081f53eb99ee6f0d685b'), + } + const result = await getExternalUrl(mint) + expect(result).toBe('https://app.manifold.xyz/') + }) +}) \ No newline at end of file From 2b83fa5a7acf7298164007cd5f63e28cc03c37d1 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 18:48:31 -0700 Subject: [PATCH 57/82] feat(manifold): implement getExternalUrl function --- packages/manifold/src/Manifold.ts | 31 +++++++++++++++++++++++++++++++ packages/manifold/src/index.ts | 3 +++ 2 files changed, 34 insertions(+) diff --git a/packages/manifold/src/Manifold.ts b/packages/manifold/src/Manifold.ts index a2a2f2ad0..7ecdb6403 100644 --- a/packages/manifold/src/Manifold.ts +++ b/packages/manifold/src/Manifold.ts @@ -214,6 +214,37 @@ export const getFees = async ( } } +export const getExternalUrl = async (mint: MintActionParams): Promise => { + const { chainId, contractAddress, tokenId } = mint + + const baseUrl = 'https://app.manifold.xyz/' + + try { + const instanceId = await getInstanceId( + chainId, + contractAddress, + tokenId ?? 1, + ) + + const { data } = await axios.get<{ slug?: string }>(`https://apps.api.manifoldxyz.dev/public/instance/data?id=${instanceId}`) + const slug = data.slug + + if (!slug) { + throw new Error('Slug not found in response') + } + + return `${baseUrl}c/${slug}` + } catch (err) { + if (err instanceof Error) { + console.error(err.message) + } else { + console.error(err) + } + // fallback to default manifold url + return baseUrl + } +} + export const getSupportedTokenAddresses = async ( _chainId: number, ): Promise => { diff --git a/packages/manifold/src/index.ts b/packages/manifold/src/index.ts index a52019b62..65b95935f 100644 --- a/packages/manifold/src/index.ts +++ b/packages/manifold/src/index.ts @@ -5,6 +5,7 @@ import type { } from '@rabbitholegg/questdk' import { + getExternalUrl, getFees, getMintIntent, getProjectFees, @@ -23,6 +24,8 @@ export const Manifold: IActionPlugin = { getProjectFees(params as unknown as MintActionParams), getFees: async (params: ActionParams) => getFees(params as unknown as MintActionParams), + getExternalUrl: async (params: ActionParams) => + getExternalUrl(params as unknown as MintActionParams), getMintIntent, simulateMint, } From af0777ecbc6f04681aebaef89bdae1f6f50ee538 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 18:49:07 -0700 Subject: [PATCH 58/82] chore: generate changeset --- .changeset/lovely-pans-approve.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/lovely-pans-approve.md diff --git a/.changeset/lovely-pans-approve.md b/.changeset/lovely-pans-approve.md new file mode 100644 index 000000000..e74d039f7 --- /dev/null +++ b/.changeset/lovely-pans-approve.md @@ -0,0 +1,5 @@ +--- +"@rabbitholegg/questdk-plugin-manifold": minor +--- + +implement getExternalUrl function From bd70f6471858a92b8ee3f44c71f5cfc707c0aa5c Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 18:49:50 -0700 Subject: [PATCH 59/82] chore: format --- packages/manifold/src/Manifold.test.ts | 10 ++++++++-- packages/manifold/src/Manifold.ts | 12 ++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/manifold/src/Manifold.test.ts b/packages/manifold/src/Manifold.test.ts index 1073e026d..22628feaf 100644 --- a/packages/manifold/src/Manifold.test.ts +++ b/packages/manifold/src/Manifold.test.ts @@ -1,4 +1,10 @@ -import { getExternalUrl, getFees, getMintIntent, mint, simulateMint } from './Manifold' +import { + getExternalUrl, + getFees, + getMintIntent, + mint, + simulateMint, +} from './Manifold' import { ERC721_CONTRACT, ERC1155_CONTRACT } from './constants' import { failingTestCases, passingTestCases } from './test-transactions' import { apply } from '@rabbitholegg/questdk' @@ -247,4 +253,4 @@ describe('getExternalUrl function', () => { const result = await getExternalUrl(mint) expect(result).toBe('https://app.manifold.xyz/') }) -}) \ No newline at end of file +}) diff --git a/packages/manifold/src/Manifold.ts b/packages/manifold/src/Manifold.ts index 7ecdb6403..305e64c85 100644 --- a/packages/manifold/src/Manifold.ts +++ b/packages/manifold/src/Manifold.ts @@ -214,7 +214,9 @@ export const getFees = async ( } } -export const getExternalUrl = async (mint: MintActionParams): Promise => { +export const getExternalUrl = async ( + mint: MintActionParams, +): Promise => { const { chainId, contractAddress, tokenId } = mint const baseUrl = 'https://app.manifold.xyz/' @@ -225,10 +227,12 @@ export const getExternalUrl = async (mint: MintActionParams): Promise => contractAddress, tokenId ?? 1, ) - - const { data } = await axios.get<{ slug?: string }>(`https://apps.api.manifoldxyz.dev/public/instance/data?id=${instanceId}`) + + const { data } = await axios.get<{ slug?: string }>( + `https://apps.api.manifoldxyz.dev/public/instance/data?id=${instanceId}`, + ) const slug = data.slug - + if (!slug) { throw new Error('Slug not found in response') } From 17763d5d4fa96dae948b5a83b410eab1f77bfb0d Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 18:50:55 -0700 Subject: [PATCH 60/82] feat(utils): allow referral to be optional in mintIntentParams --- packages/utils/src/types/intents.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/utils/src/types/intents.ts b/packages/utils/src/types/intents.ts index 81c06371f..816b37159 100644 --- a/packages/utils/src/types/intents.ts +++ b/packages/utils/src/types/intents.ts @@ -1,8 +1,9 @@ import type { MintActionParams } from './actions' export type MintIntentParams = Required< - Omit + Omit > & { amount: bigint tokenId?: number + referral?: string } export type IntentParams = MintIntentParams From 4f9c41b13dacd3e3d96343877481cec237b9ba6e Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 19:01:35 -0700 Subject: [PATCH 61/82] chore: generate changeset --- .changeset/silent-fireants-grab.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/silent-fireants-grab.md diff --git a/.changeset/silent-fireants-grab.md b/.changeset/silent-fireants-grab.md new file mode 100644 index 000000000..4db7a8c12 --- /dev/null +++ b/.changeset/silent-fireants-grab.md @@ -0,0 +1,5 @@ +--- +"@rabbitholegg/questdk-plugin-utils": minor +--- + +allow referral to be optional in MintIntentParams From 34a43162f2088ddfb628c0b3f99d1482d070f590 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 19:06:48 -0700 Subject: [PATCH 62/82] refactor(utils): use Address type for referral --- packages/utils/src/types/intents.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/utils/src/types/intents.ts b/packages/utils/src/types/intents.ts index 816b37159..4d29adf67 100644 --- a/packages/utils/src/types/intents.ts +++ b/packages/utils/src/types/intents.ts @@ -1,9 +1,10 @@ import type { MintActionParams } from './actions' +import type { Address } from 'viem' export type MintIntentParams = Required< Omit > & { amount: bigint tokenId?: number - referral?: string + referral?: Address } export type IntentParams = MintIntentParams From 62d1038916f7c68a852cefa66f781bed503defa9 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 22:03:15 -0700 Subject: [PATCH 63/82] refactor(pods): check referral is defined before using getAddress --- packages/pods/src/Pods.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/pods/src/Pods.ts b/packages/pods/src/Pods.ts index 24e9be8b8..74b9dab4b 100644 --- a/packages/pods/src/Pods.ts +++ b/packages/pods/src/Pods.ts @@ -89,12 +89,13 @@ export const getMintIntent = async ( const fixedPriceSaleStratAddress = FIXED_PRICE_SALE_STRATS[chainId] const _tokenId = tokenId ?? (await getLatestTokenId(contractAddress, chainId)) + const referralAddress = referral ? getAddress(referral) : ZORA_DEPLOYER_ADDRESS const mintArgs = [ fixedPriceSaleStratAddress, _tokenId, amount, - [getAddress(referral) ?? ZORA_DEPLOYER_ADDRESS], + [referralAddress], pad(recipient), ] @@ -132,12 +133,13 @@ export const simulateMint = async ( } const fixedPriceSaleStratAddress = FIXED_PRICE_SALE_STRATS[chainId] + const referralAddress = referral ? getAddress(referral) : ZORA_DEPLOYER_ADDRESS const mintArgs = [ fixedPriceSaleStratAddress, _tokenId, amount, - [getAddress(referral) ?? ZORA_DEPLOYER_ADDRESS], + [referralAddress], pad(recipient), ] const result = await _client.simulateContract({ From ebeae0f4f4a3c9502d0f5002d0acb91c3c64ee13 Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 16 Jul 2024 05:04:11 +0000 Subject: [PATCH 64/82] chore: format --- packages/pods/src/Pods.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/pods/src/Pods.ts b/packages/pods/src/Pods.ts index 74b9dab4b..6bbfc41f7 100644 --- a/packages/pods/src/Pods.ts +++ b/packages/pods/src/Pods.ts @@ -89,7 +89,9 @@ export const getMintIntent = async ( const fixedPriceSaleStratAddress = FIXED_PRICE_SALE_STRATS[chainId] const _tokenId = tokenId ?? (await getLatestTokenId(contractAddress, chainId)) - const referralAddress = referral ? getAddress(referral) : ZORA_DEPLOYER_ADDRESS + const referralAddress = referral + ? getAddress(referral) + : ZORA_DEPLOYER_ADDRESS const mintArgs = [ fixedPriceSaleStratAddress, @@ -133,7 +135,9 @@ export const simulateMint = async ( } const fixedPriceSaleStratAddress = FIXED_PRICE_SALE_STRATS[chainId] - const referralAddress = referral ? getAddress(referral) : ZORA_DEPLOYER_ADDRESS + const referralAddress = referral + ? getAddress(referral) + : ZORA_DEPLOYER_ADDRESS const mintArgs = [ fixedPriceSaleStratAddress, From c10163182b0a44d3a465feffedce4ab060f24bf3 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 22:10:27 -0700 Subject: [PATCH 65/82] refactor(pods): rename variable --- packages/pods/src/Pods.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/pods/src/Pods.ts b/packages/pods/src/Pods.ts index 6bbfc41f7..d2c024b5a 100644 --- a/packages/pods/src/Pods.ts +++ b/packages/pods/src/Pods.ts @@ -43,13 +43,13 @@ export const mint = async ( }, ] if (referral) { - const checksumAddress = getAddress(referral) + const referralAddress = getAddress(referral) andArray1155.push({ $or: [ - { mintReferral: checksumAddress }, + { mintReferral: referralAddress }, { rewardsRecipients: { - $and: [{ $first: checksumAddress }, { $last: checksumAddress }], + $and: [{ $first: referralAddress }, { $last: referralAddress }], }, }, ], From 633420985878dcfa563ba95b307f2f5eab9f7942 Mon Sep 17 00:00:00 2001 From: mmackz Date: Mon, 15 Jul 2024 22:11:28 -0700 Subject: [PATCH 66/82] refactor(zora): rename variable --- packages/zora/src/Zora.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index 716d3528c..15ff5d3bf 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -128,13 +128,13 @@ export const mint = async ( }) } if (referral) { - const checksumAddress = getAddress(referral) + const referralAddress = getAddress(referral) andArray1155.push({ $or: [ - { mintReferral: checksumAddress }, + { mintReferral: referralAddress }, { rewardsRecipients: { - $and: [{ $first: checksumAddress }, { $last: checksumAddress }], + $and: [{ $first: referralAddress }, { $last: referralAddress }], }, }, ], From 5806b121dfcef4a6d717ee30b89f9b8cf5c434ce Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 16 Jul 2024 11:30:33 -0700 Subject: [PATCH 67/82] feat(sound): use referral in external url --- packages/soundxyz/src/Soundxyz.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/soundxyz/src/Soundxyz.ts b/packages/soundxyz/src/Soundxyz.ts index e60608204..a220861d5 100644 --- a/packages/soundxyz/src/Soundxyz.ts +++ b/packages/soundxyz/src/Soundxyz.ts @@ -292,7 +292,7 @@ export const getDynamicNameParams = async ( export const getExternalUrl = async ( params: MintActionParams, ): Promise => { - const { chainId, contractAddress } = params + const { chainId, contractAddress, referral } = params try { const client = createPublicClient({ @@ -311,7 +311,7 @@ export const getExternalUrl = async ( const { data } = await axios.get(`https://arweave.net/${cid}`) const { external_link } = data - return external_link + return `${external_link}?referral=${referral ?? ZORA_DEPLOYER_ADDRESS}` } catch (error) { console.error('an error occurred fetching the contract uri') if (error instanceof Error) { From 612498ad9d4289cc8f0704f8a2b3bda688e9a461 Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 16 Jul 2024 11:30:55 -0700 Subject: [PATCH 68/82] test(sound): add additional test for no referral --- packages/soundxyz/src/Soundxyz.test.ts | 34 ++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/packages/soundxyz/src/Soundxyz.test.ts b/packages/soundxyz/src/Soundxyz.test.ts index 165f39d6b..041c4678d 100644 --- a/packages/soundxyz/src/Soundxyz.test.ts +++ b/packages/soundxyz/src/Soundxyz.test.ts @@ -5,7 +5,7 @@ import { mint, simulateMint, } from './Soundxyz' -import { SUPERMINTER, SUPERMINTER_V2, SUPERMINTER_V2_ABI } from './constants' +import { SUPERMINTER, SUPERMINTER_V2, SUPERMINTER_V2_ABI, ZORA_DEPLOYER_ADDRESS } from './constants' import { OP_SUPERMINTER_V2, failingTestCases, @@ -20,7 +20,7 @@ import { type MintIntentParams, getExitAddresses, } from '@rabbitholegg/questdk-plugin-utils' -import { type Address, parseEther } from 'viem' +import { type Address, parseEther, getAddress } from 'viem' import { describe, expect, test, vi } from 'vitest' describe('Given the soundxyz plugin', () => { @@ -176,7 +176,7 @@ describe('simulateMint function', () => { contractAddress: '0xdf71F2F15bCcDC7c7A89F01dd45cDE5A43F7e79f', amount: BigInt(1), recipient: '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF', - referralAddress: '0xe3bba2a4f8e0f5c32ef5097f988a4d88075c8b48', + referral: '0xe3bba2a4f8e0f5c32ef5097f988a4d88075c8b48', } const value = parseEther('0.000777') const account = '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF' @@ -205,13 +205,33 @@ describe('simulateMint function', () => { }) }) -describe('getExternalLink', () => { - test('should return the correct link', async () => { +describe('getExternalUrl', () => { + test('should return the correct link with referral', async () => { const contractAddress: Address = '0xE39Df1AD806e84de47D0F6ddf56a0007C678597c' - const mintParams = { contractAddress, chainId: Chains.BASE } + const mintParams = { + contractAddress, + chainId: Chains.BASE, + referral: getAddress('0x1234567890123456789012345678901234567890'), + } + + const link = await getExternalUrl(mintParams) + expect(link).equals( + 'https://www.sound.xyz/33below/midnight-diner-ii?referral=0x1234567890123456789012345678901234567890', + ) + }) + + test('should return the correct link with our own referral if no referral is provided', async () => { + const contractAddress: Address = + '0xE39Df1AD806e84de47D0F6ddf56a0007C678597c' + const mintParams = { + contractAddress, + chainId: Chains.BASE, + } const link = await getExternalUrl(mintParams) - expect(link).equals('https://www.sound.xyz/33below/midnight-diner-ii') + expect(link).equals( + `https://www.sound.xyz/33below/midnight-diner-ii?referral=${ZORA_DEPLOYER_ADDRESS}`, + ) }) }) From 506f1bf00e7299de261842847da81e9fb9c36321 Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 16 Jul 2024 18:33:17 +0000 Subject: [PATCH 69/82] chore: format --- packages/soundxyz/src/Soundxyz.test.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/soundxyz/src/Soundxyz.test.ts b/packages/soundxyz/src/Soundxyz.test.ts index 041c4678d..9572c70bc 100644 --- a/packages/soundxyz/src/Soundxyz.test.ts +++ b/packages/soundxyz/src/Soundxyz.test.ts @@ -5,7 +5,12 @@ import { mint, simulateMint, } from './Soundxyz' -import { SUPERMINTER, SUPERMINTER_V2, SUPERMINTER_V2_ABI, ZORA_DEPLOYER_ADDRESS } from './constants' +import { + SUPERMINTER, + SUPERMINTER_V2, + SUPERMINTER_V2_ABI, + ZORA_DEPLOYER_ADDRESS, +} from './constants' import { OP_SUPERMINTER_V2, failingTestCases, From 575cc9dc9b59b3eac620c1b4d9147549e126aead Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 16 Jul 2024 11:36:16 -0700 Subject: [PATCH 70/82] test(pods): add additional test w/o referral attached --- packages/pods/src/Pods.test.ts | 15 ++++++++++++++- packages/pods/src/Pods.ts | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/pods/src/Pods.test.ts b/packages/pods/src/Pods.test.ts index 2b43c7f78..03509a891 100644 --- a/packages/pods/src/Pods.test.ts +++ b/packages/pods/src/Pods.test.ts @@ -9,6 +9,7 @@ import { describe, expect, test, vi } from 'vitest' import { getExternalUrl, getMintIntent, mint } from './Pods' import { failingTestCases, passingTestCases } from './test-setup' import { EXPECTED_ENCODED_DATA_1155 } from './test-transactions' +import { ZORA_DEPLOYER_ADDRESS } from './contract-addresses' describe('Given the pods plugin', () => { describe('When handling the mint', () => { @@ -203,7 +204,7 @@ describe('simulateMint function', () => { }) describe('getExternalUrl function', () => { - test('should return correct url for mint w/tokenId', async () => { + test('should return correct url for mint w/tokenId and referral', async () => { const params = { chainId: Chains.BASE, contractAddress: getAddress('0x7e0b40af1d6f26f2141b90170c513e57b5edd74e'), @@ -216,6 +217,18 @@ describe('getExternalUrl function', () => { ) }) + test('should return correct url for mint w/tokenId and w/o referral', async () => { + const params = { + chainId: Chains.BASE, + contractAddress: getAddress('0x7e0b40af1d6f26f2141b90170c513e57b5edd74e'), + tokenId: 21, + } + const result = await getExternalUrl(params) + expect(result).toBe( + `https://pods.media/mint-podcast/why-social-needs-a-layer-2-ft-ryan-li-of-cyber?referrer=${ZORA_DEPLOYER_ADDRESS}`, + ) + }) + test('should return correct url for mint w/out tokenId', async () => { const params = { chainId: Chains.BASE, diff --git a/packages/pods/src/Pods.ts b/packages/pods/src/Pods.ts index 345254eea..19240a662 100644 --- a/packages/pods/src/Pods.ts +++ b/packages/pods/src/Pods.ts @@ -200,7 +200,7 @@ export const getExternalUrl = async ( // different properties depending on uri function. One of these will be defined const baseUrl = data.external_link ?? data.external_url - return referral ? `${baseUrl}?referrer=${referral}` : baseUrl + return `${baseUrl}?referrer=${referral ?? ZORA_DEPLOYER_ADDRESS}` } catch (error) { console.error('an error occurred fetching data from the contract') if (error instanceof Error) { From aaba101dfe1d32b6d48cc9e474c429fc5fc33991 Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 16 Jul 2024 12:05:47 -0700 Subject: [PATCH 71/82] feat(pods): update rewardsRecipients to use array for referralAddress --- packages/pods/src/Pods.ts | 4 +--- packages/pods/src/utils.ts | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/pods/src/Pods.ts b/packages/pods/src/Pods.ts index d2c024b5a..d050a9b88 100644 --- a/packages/pods/src/Pods.ts +++ b/packages/pods/src/Pods.ts @@ -48,9 +48,7 @@ export const mint = async ( $or: [ { mintReferral: referralAddress }, { - rewardsRecipients: { - $and: [{ $first: referralAddress }, { $last: referralAddress }], - }, + rewardsRecipients: [referralAddress], }, ], }) diff --git a/packages/pods/src/utils.ts b/packages/pods/src/utils.ts index 662a645f5..148613eb3 100644 --- a/packages/pods/src/utils.ts +++ b/packages/pods/src/utils.ts @@ -10,7 +10,7 @@ export type AndArrayItem = | { minterArguments: { $regex: string } } | { tokenId: number | string } | { mintReferral: Address } - | { rewardsRecipients: { $and: [{ $first: Address }, { $last: Address }] } } + | { rewardsRecipients: Address[] } | { $or: AndArrayItem[] } export async function getLatestTokenId( From 2d568ea0ed6a8ef6b24be75b5f910fddbdd4554c Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 16 Jul 2024 12:07:27 -0700 Subject: [PATCH 72/82] refactor(zora): update rewardsRecipients to use array instead of $and operator --- packages/zora/src/Zora.ts | 4 +--- packages/zora/src/types.ts | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index 15ff5d3bf..23f2839d7 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -133,9 +133,7 @@ export const mint = async ( $or: [ { mintReferral: referralAddress }, { - rewardsRecipients: { - $and: [{ $first: referralAddress }, { $last: referralAddress }], - }, + rewardsRecipients: [referralAddress], }, ], }) diff --git a/packages/zora/src/types.ts b/packages/zora/src/types.ts index c704a1d47..1b10f5acf 100644 --- a/packages/zora/src/types.ts +++ b/packages/zora/src/types.ts @@ -51,5 +51,5 @@ export type AndArrayItem = | RecipientCondition | { tokenId: string | number } | { mintReferral: Address } - | { rewardsRecipients: { $and: [{ $first: Address }, { $last: Address }] } } + | { rewardsRecipients: Address[] } | { $or: AndArrayItem[] } From f792e9aaa12bf0a2967a3a1152d078ade13b4c0e Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 16 Jul 2024 12:13:03 -0700 Subject: [PATCH 73/82] feat(zora): fallback to zora deplyer if no referral passed in --- packages/zora/src/Zora.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index e5dbb277a..c30ea5d6f 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -432,7 +432,7 @@ export const getExternalUrl = async ( ): Promise => { const { chainId, contractAddress, tokenId, referral } = params const chainSlug = CHAIN_ID_TO_ZORA_SLUG[chainId] - const referralParams = referral ? `?referrer=${referral}` : '' + const referralParams = `?referrer=${referral ?? ZORA_DEPLOYER_ADDRESS}` const baseUrl = `https://zora.co/collect/${chainSlug}:${contractAddress}` return tokenId != null From ca73899a6c71921f2524ed28c7af59d4a0370a87 Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 16 Jul 2024 12:14:41 -0700 Subject: [PATCH 74/82] test: add additional test for no referral --- packages/zora/src/Zora.test.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/zora/src/Zora.test.ts b/packages/zora/src/Zora.test.ts index b18be8d11..f625c295e 100644 --- a/packages/zora/src/Zora.test.ts +++ b/packages/zora/src/Zora.test.ts @@ -30,6 +30,7 @@ import { describe, expect, test, vi, beforeEach, MockedFunction } from 'vitest' import { PremintResponse } from './types' import axios from 'axios' import { validatePremint } from './validate' +import { ZORA_DEPLOYER_ADDRESS } from './contract-addresses' const MockedPremintResponse: PremintResponse = [ { @@ -516,7 +517,7 @@ describe('getDynamicNameParams function', () => { }) describe('getExternalUrl function', () => { - test('should return correct url for 1155 mint with token id', async () => { + test('should return correct url for 1155 mint with token id w/referral', async () => { const params = { chainId: Chains.ZORA, contractAddress: getAddress('0x393c46fe7887697124a73f6028f39751aa1961a3'), @@ -529,6 +530,18 @@ describe('getExternalUrl function', () => { ) }) + test('should return correct url for 1155 mint with token id w/o referral', async () => { + const params = { + chainId: Chains.ZORA, + contractAddress: getAddress('0x393c46fe7887697124a73f6028f39751aa1961a3'), + tokenId: 1, + } + const result = await getExternalUrl(params) + expect(result).toBe( + `https://zora.co/collect/zora:0x393c46fe7887697124A73f6028f39751aA1961a3/1?referrer=${ZORA_DEPLOYER_ADDRESS}`, + ) + }) + test('should return correct url for 1155 mint without token id', async () => { const params = { chainId: Chains.ZORA, From bee49ccf39a923ae3030136697e2f87eca75a959 Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 16 Jul 2024 15:02:53 -0700 Subject: [PATCH 75/82] refactor(zora): remove checksum on referral --- packages/zora/src/Zora.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index 23f2839d7..ced203ea2 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -128,12 +128,11 @@ export const mint = async ( }) } if (referral) { - const referralAddress = getAddress(referral) andArray1155.push({ $or: [ - { mintReferral: referralAddress }, + { mintReferral: referral }, { - rewardsRecipients: [referralAddress], + rewardsRecipients: [referral], }, ], }) From 299e90bbaa3c865e2fbe839aad66a1cffaeb45fd Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 16 Jul 2024 17:42:35 -0700 Subject: [PATCH 76/82] feat(utils): export default referral address from utils --- packages/utils/src/constants/index.ts | 1 + packages/utils/src/constants/referral.ts | 4 ++++ packages/utils/src/index.ts | 1 + 3 files changed, 6 insertions(+) create mode 100644 packages/utils/src/constants/referral.ts diff --git a/packages/utils/src/constants/index.ts b/packages/utils/src/constants/index.ts index 2069cc915..e94bc13b5 100644 --- a/packages/utils/src/constants/index.ts +++ b/packages/utils/src/constants/index.ts @@ -4,3 +4,4 @@ export { BOOST_TREASURY_ADDRESS, } from './contract-addresses' export { Chains } from './chain-ids' +export { REFERRAL_ADDRESS } from './referral' diff --git a/packages/utils/src/constants/referral.ts b/packages/utils/src/constants/referral.ts new file mode 100644 index 000000000..256751934 --- /dev/null +++ b/packages/utils/src/constants/referral.ts @@ -0,0 +1,4 @@ +/** + * Boost-Owned EOA for collecting referral fees. + */ +export const REFERRAL_ADDRESS = '0xe3bBA2A4F8E0F5C32EF5097F988a4d88075C8B48' \ No newline at end of file diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index b2929af68..36aa4313c 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -3,6 +3,7 @@ export { Chains, DEFAULT_ACCOUNT, BOOST_TREASURY_ADDRESS, + REFERRAL_ADDRESS, } from './constants/index' export type { TestParams, TestCase } from './helpers/index' From f76913cd1083d0b980a2c8ad155f5adaae5bd0a9 Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 16 Jul 2024 17:46:13 -0700 Subject: [PATCH 77/82] refactor(utils): update referral constant name to DEFAULT_REFERRAL --- packages/utils/src/constants/index.ts | 2 +- packages/utils/src/constants/referral.ts | 2 +- packages/utils/src/index.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/utils/src/constants/index.ts b/packages/utils/src/constants/index.ts index e94bc13b5..cf6ae2539 100644 --- a/packages/utils/src/constants/index.ts +++ b/packages/utils/src/constants/index.ts @@ -4,4 +4,4 @@ export { BOOST_TREASURY_ADDRESS, } from './contract-addresses' export { Chains } from './chain-ids' -export { REFERRAL_ADDRESS } from './referral' +export { DEFAULT_REFERRAL } from './referral' diff --git a/packages/utils/src/constants/referral.ts b/packages/utils/src/constants/referral.ts index 256751934..87bd71a82 100644 --- a/packages/utils/src/constants/referral.ts +++ b/packages/utils/src/constants/referral.ts @@ -1,4 +1,4 @@ /** * Boost-Owned EOA for collecting referral fees. */ -export const REFERRAL_ADDRESS = '0xe3bBA2A4F8E0F5C32EF5097F988a4d88075C8B48' \ No newline at end of file +export const DEFAULT_REFERRAL = '0xe3bBA2A4F8E0F5C32EF5097F988a4d88075C8B48' diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 36aa4313c..9d85f4f5d 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -3,7 +3,7 @@ export { Chains, DEFAULT_ACCOUNT, BOOST_TREASURY_ADDRESS, - REFERRAL_ADDRESS, + DEFAULT_REFERRAL, } from './constants/index' export type { TestParams, TestCase } from './helpers/index' From bb5f48cf5f17e730d627d9cd4ee23c220664babd Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 16 Jul 2024 17:49:14 -0700 Subject: [PATCH 78/82] feat(pods): use ref address from utils --- packages/pods/src/Pods.test.ts | 4 ++-- packages/pods/src/Pods.ts | 16 +++++----------- packages/pods/src/contract-addresses.ts | 4 ---- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/packages/pods/src/Pods.test.ts b/packages/pods/src/Pods.test.ts index 989c4da2f..94389e3ba 100644 --- a/packages/pods/src/Pods.test.ts +++ b/packages/pods/src/Pods.test.ts @@ -1,5 +1,6 @@ import { Chains, + DEFAULT_REFERRAL, type MintActionParams, type MintIntentParams, } from '@rabbitholegg/questdk-plugin-utils' @@ -9,7 +10,6 @@ import { describe, expect, test, vi } from 'vitest' import { getExternalUrl, getMintIntent, mint } from './Pods' import { failingTestCases, passingTestCases } from './test-setup' import { EXPECTED_ENCODED_DATA_1155 } from './test-transactions' -import { ZORA_DEPLOYER_ADDRESS } from './contract-addresses' describe('Given the pods plugin', () => { describe('When handling the mint', () => { @@ -228,7 +228,7 @@ describe('getExternalUrl function', () => { } const result = await getExternalUrl(params) expect(result).toBe( - `https://pods.media/mint-podcast/why-social-needs-a-layer-2-ft-ryan-li-of-cyber?referrer=${ZORA_DEPLOYER_ADDRESS}`, + `https://pods.media/mint-podcast/why-social-needs-a-layer-2-ft-ryan-li-of-cyber?referrer=${DEFAULT_REFERRAL}`, ) }) diff --git a/packages/pods/src/Pods.ts b/packages/pods/src/Pods.ts index 097830485..5073cf963 100644 --- a/packages/pods/src/Pods.ts +++ b/packages/pods/src/Pods.ts @@ -1,10 +1,7 @@ import axios from 'axios' import { FEES_ABI, ZORA_MINTER_ABI_1155 } from './abi' import { CHAIN_ID_ARRAY } from './chain-ids' -import { - FIXED_PRICE_SALE_STRATS, - ZORA_DEPLOYER_ADDRESS, -} from './contract-addresses' +import { FIXED_PRICE_SALE_STRATS } from './contract-addresses' import { type AndArrayItem, getLatestTokenId, getUri } from './utils' import { type MintActionParams, @@ -13,6 +10,7 @@ import { } from '@rabbitholegg/questdk' import { DEFAULT_ACCOUNT, + DEFAULT_REFERRAL, type MintIntentParams, chainIdToViemChain, getExitAddresses, @@ -88,9 +86,7 @@ export const getMintIntent = async ( const fixedPriceSaleStratAddress = FIXED_PRICE_SALE_STRATS[chainId] const _tokenId = tokenId ?? (await getLatestTokenId(contractAddress, chainId)) - const referralAddress = referral - ? getAddress(referral) - : ZORA_DEPLOYER_ADDRESS + const referralAddress = referral ? getAddress(referral) : DEFAULT_REFERRAL const mintArgs = [ fixedPriceSaleStratAddress, @@ -134,9 +130,7 @@ export const simulateMint = async ( } const fixedPriceSaleStratAddress = FIXED_PRICE_SALE_STRATS[chainId] - const referralAddress = referral - ? getAddress(referral) - : ZORA_DEPLOYER_ADDRESS + const referralAddress = referral ? getAddress(referral) : DEFAULT_REFERRAL const mintArgs = [ fixedPriceSaleStratAddress, @@ -221,7 +215,7 @@ export const getExternalUrl = async ( // different properties depending on uri function. One of these will be defined const baseUrl = data.external_link ?? data.external_url - return `${baseUrl}?referrer=${referral ?? ZORA_DEPLOYER_ADDRESS}` + return `${baseUrl}?referrer=${referral ?? DEFAULT_REFERRAL}` } catch (error) { console.error('an error occurred fetching data from the contract') if (error instanceof Error) { diff --git a/packages/pods/src/contract-addresses.ts b/packages/pods/src/contract-addresses.ts index 6f048c1a5..d9cb27ddd 100644 --- a/packages/pods/src/contract-addresses.ts +++ b/packages/pods/src/contract-addresses.ts @@ -9,7 +9,3 @@ export const FIXED_PRICE_SALE_STRATS: { [chainId: number]: Address } = { [Chains.BASE]: '0x04E2516A2c207E84a1839755675dfd8eF6302F0a', [Chains.ARBITRUM_ONE]: '0x1Cd1C1f3b8B779B50Db23155F2Cb244FCcA06B21', } - -// for referrals -export const ZORA_DEPLOYER_ADDRESS = - '0xe3bBA2A4F8E0F5C32EF5097F988a4d88075C8B48' From faa10e15a61acf7af658b7c56d1451ba5087b7d2 Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 16 Jul 2024 17:50:54 -0700 Subject: [PATCH 79/82] refactor(sound): use ref address from utils --- packages/soundxyz/src/Soundxyz.test.ts | 8 ++++---- packages/soundxyz/src/Soundxyz.ts | 6 +++--- packages/soundxyz/src/constants.ts | 4 ---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/soundxyz/src/Soundxyz.test.ts b/packages/soundxyz/src/Soundxyz.test.ts index c2d136495..913f3a0ec 100644 --- a/packages/soundxyz/src/Soundxyz.test.ts +++ b/packages/soundxyz/src/Soundxyz.test.ts @@ -9,7 +9,6 @@ import { SUPERMINTER, SUPERMINTER_V2, SUPERMINTER_V2_ABI, - ZORA_DEPLOYER_ADDRESS, } from './constants' import { OP_SUPERMINTER_V2, @@ -20,6 +19,7 @@ import { Chains } from './utils' import { apply } from '@rabbitholegg/questdk' import { ActionType, + DEFAULT_REFERRAL, type DisctriminatedActionParams, type MintActionParams, type MintIntentParams, @@ -181,7 +181,7 @@ describe('simulateMint function', () => { contractAddress: '0xdf71F2F15bCcDC7c7A89F01dd45cDE5A43F7e79f', amount: BigInt(1), recipient: '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF', - referral: ZORA_DEPLOYER_ADDRESS, + referral: DEFAULT_REFERRAL, } const value = parseEther('0.000777') const account = '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF' @@ -198,7 +198,7 @@ describe('simulateMint function', () => { contractAddress: '0x0c418874315698096ecA7ce0e1Dccf0A517DC9DE', amount: BigInt(1), recipient: '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF', - referral: ZORA_DEPLOYER_ADDRESS, + referral: DEFAULT_REFERRAL, } const value = parseEther('0.000777') const account = '0xf70da97812CB96acDF810712Aa562db8dfA3dbEF' @@ -236,7 +236,7 @@ describe('getExternalUrl', () => { const link = await getExternalUrl(mintParams) expect(link).equals( - `https://www.sound.xyz/33below/midnight-diner-ii?referral=${ZORA_DEPLOYER_ADDRESS}`, + `https://www.sound.xyz/33below/midnight-diner-ii?referral=${DEFAULT_REFERRAL}`, ) }) }) diff --git a/packages/soundxyz/src/Soundxyz.ts b/packages/soundxyz/src/Soundxyz.ts index c20afbf38..303027412 100644 --- a/packages/soundxyz/src/Soundxyz.ts +++ b/packages/soundxyz/src/Soundxyz.ts @@ -9,7 +9,6 @@ import { SUPERMINTER_V2_ABI, TOTAL_PRICE_AND_FEES_V1_ABI, TOTAL_PRICE_AND_FEES_V2_ABI, - ZORA_DEPLOYER_ADDRESS, } from './constants' import type { TotalPriceAndFees } from './types' import { Chains } from './utils' @@ -21,6 +20,7 @@ import { import { ActionType, DEFAULT_ACCOUNT, + DEFAULT_REFERRAL, type DisctriminatedActionParams, type MintIntentParams, chainIdToViemChain, @@ -135,7 +135,7 @@ export const simulateMint = async ( signedClaimTicket: 0, signedDeadline: 0, signature: zeroHash, - affiliate: referral ?? ZORA_DEPLOYER_ADDRESS, + affiliate: referral ?? DEFAULT_REFERRAL, affiliateProof: [zeroHash], attributionId: 0, } @@ -312,7 +312,7 @@ export const getExternalUrl = async ( const { data } = await axios.get(`https://arweave.net/${cid}`) const { external_link } = data - return `${external_link}?referral=${referral ?? ZORA_DEPLOYER_ADDRESS}` + return `${external_link}?referral=${referral ?? DEFAULT_REFERRAL}` } catch (error) { console.error('an error occurred fetching the contract uri') if (error instanceof Error) { diff --git a/packages/soundxyz/src/constants.ts b/packages/soundxyz/src/constants.ts index 80730eb19..32c88ec34 100644 --- a/packages/soundxyz/src/constants.ts +++ b/packages/soundxyz/src/constants.ts @@ -326,7 +326,3 @@ export const CONTRACT_URI_ABI = [ type: 'function', }, ] - -// for referrals -export const ZORA_DEPLOYER_ADDRESS = - '0xe3bBA2A4F8E0F5C32EF5097F988a4d88075C8B48' From fd15ad928b6b1bf9133872037c658d718e488d1b Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 16 Jul 2024 17:52:48 -0700 Subject: [PATCH 80/82] refactor(zora): use ref address from utils --- packages/zora/src/Zora.test.ts | 2 +- packages/zora/src/Zora.ts | 2 +- packages/zora/src/contract-addresses.ts | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/zora/src/Zora.test.ts b/packages/zora/src/Zora.test.ts index da228ff7b..3048b58ab 100644 --- a/packages/zora/src/Zora.test.ts +++ b/packages/zora/src/Zora.test.ts @@ -19,6 +19,7 @@ import { import { ActionType, Chains, + DEFAULT_REFERRAL as ZORA_DEPLOYER_ADDRESS, type DisctriminatedActionParams, type MintActionParams, type MintIntentParams, @@ -30,7 +31,6 @@ import { describe, expect, test, vi, beforeEach, MockedFunction } from 'vitest' import { PremintResponse } from './types' import axios from 'axios' import { validatePremint } from './validate' -import { ZORA_DEPLOYER_ADDRESS } from './contract-addresses' const MockedPremintResponse: PremintResponse = [ { diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index 0e6703273..51cd22bf0 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -10,7 +10,6 @@ import { CHAIN_ID_ARRAY, CHAIN_ID_TO_ZORA_SLUG } from './chain-ids' import { FIXED_PRICE_SALE_STRATS, ZORA_1155_FACTORY, - ZORA_DEPLOYER_ADDRESS, } from './contract-addresses' import { AndArrayItem } from './types' import { validatePremint } from './validate' @@ -24,6 +23,7 @@ import { formatAmount } from '@rabbitholegg/questdk-plugin-utils' import { ActionType, DEFAULT_ACCOUNT, + DEFAULT_REFERRAL as ZORA_DEPLOYER_ADDRESS, type DisctriminatedActionParams, type MintIntentParams, chainIdToViemChain, diff --git a/packages/zora/src/contract-addresses.ts b/packages/zora/src/contract-addresses.ts index 1c0cc264a..aaeeeeba3 100644 --- a/packages/zora/src/contract-addresses.ts +++ b/packages/zora/src/contract-addresses.ts @@ -12,7 +12,3 @@ export const FIXED_PRICE_SALE_STRATS: { [chainId: number]: Address } = { } export const ZORA_1155_FACTORY = '0x777777c338d93e2c7adf08d102d45ca7cc4ed021' - -// for referrals -export const ZORA_DEPLOYER_ADDRESS = - '0xe3bBA2A4F8E0F5C32EF5097F988a4d88075C8B48' From c6216c1209692f0f2d8e351a36f8c21d5210c838 Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 16 Jul 2024 17:55:07 -0700 Subject: [PATCH 81/82] chore: format --- packages/soundxyz/src/Soundxyz.test.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/soundxyz/src/Soundxyz.test.ts b/packages/soundxyz/src/Soundxyz.test.ts index 913f3a0ec..9484b78da 100644 --- a/packages/soundxyz/src/Soundxyz.test.ts +++ b/packages/soundxyz/src/Soundxyz.test.ts @@ -5,11 +5,7 @@ import { mint, simulateMint, } from './Soundxyz' -import { - SUPERMINTER, - SUPERMINTER_V2, - SUPERMINTER_V2_ABI, -} from './constants' +import { SUPERMINTER, SUPERMINTER_V2, SUPERMINTER_V2_ABI } from './constants' import { OP_SUPERMINTER_V2, failingTestCases, From 485708435bcf129d381e54b1faf0024cbae42819 Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 16 Jul 2024 17:55:46 -0700 Subject: [PATCH 82/82] chore: generate changeset --- .changeset/chilly-flies-cheer.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .changeset/chilly-flies-cheer.md diff --git a/.changeset/chilly-flies-cheer.md b/.changeset/chilly-flies-cheer.md new file mode 100644 index 000000000..d95031765 --- /dev/null +++ b/.changeset/chilly-flies-cheer.md @@ -0,0 +1,8 @@ +--- +"@rabbitholegg/questdk-plugin-soundxyz": patch +"@rabbitholegg/questdk-plugin-utils": patch +"@rabbitholegg/questdk-plugin-pods": patch +"@rabbitholegg/questdk-plugin-zora": patch +--- + +add default ref address to utils package