From 7c598542d548bd9de014f72f1eb038c71f43d776 Mon Sep 17 00:00:00 2001 From: mmackz Date: Fri, 19 Jul 2024 12:18:44 -0700 Subject: [PATCH 1/7] feat(utils): add base sepolia to chians util --- packages/utils/src/constants/chain-ids.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/utils/src/constants/chain-ids.ts b/packages/utils/src/constants/chain-ids.ts index 544947ef9..dc17afed8 100644 --- a/packages/utils/src/constants/chain-ids.ts +++ b/packages/utils/src/constants/chain-ids.ts @@ -16,4 +16,5 @@ export enum Chains { SCROLL = 534352, ZORA = 7777777, SEPOLIA = 11155111, + BASE_SEPOLIA = 84532, } From da0625591efff621435b380786d812317ba9ccce Mon Sep 17 00:00:00 2001 From: mmackz Date: Fri, 19 Jul 2024 12:19:17 -0700 Subject: [PATCH 2/7] feat(zora): add support for sep and bsep url slugs --- packages/zora/src/chain-ids.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/zora/src/chain-ids.ts b/packages/zora/src/chain-ids.ts index cd4869d6d..fe9c49957 100644 --- a/packages/zora/src/chain-ids.ts +++ b/packages/zora/src/chain-ids.ts @@ -12,8 +12,10 @@ export const CHAIN_ID_ARRAY = [ export const CHAIN_ID_TO_ZORA_SLUG: Record = { [Chains.ARBITRUM_ONE]: 'arb', [Chains.BASE]: 'base', + [Chains.BASE_SEPOLIA]: 'bsep', [Chains.BLAST]: 'blast', [Chains.ETHEREUM]: 'eth', [Chains.OPTIMISM]: 'oeth', [Chains.ZORA]: 'zora', + [Chains.SEPOLIA]: 'sep', } From f6480b30d4eba283bf02bf1fd49db1a6560cb468 Mon Sep 17 00:00:00 2001 From: mmackz Date: Fri, 19 Jul 2024 12:19:41 -0700 Subject: [PATCH 3/7] test(zora): add test for bsep url generation --- packages/zora/src/Zora.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/zora/src/Zora.test.ts b/packages/zora/src/Zora.test.ts index 3048b58ab..ff50b52d1 100644 --- a/packages/zora/src/Zora.test.ts +++ b/packages/zora/src/Zora.test.ts @@ -557,4 +557,17 @@ describe('getExternalUrl function', () => { 'https://zora.co/collect/zora:0x393c46fe7887697124A73f6028f39751aA1961a3?referrer=0x1234567890123456789012345678901234567890', ) }) + + test('should return correct url for testnet mint', async () => { + const params = { + chainId: Chains.BASE_SEPOLIA, + contractAddress: getAddress('0x627a509d76498ddd7d80a28ef4cd887b5b6df2cd'), + tokenId: 39, + referral: getAddress('0xe3bBA2A4F8E0F5C32EF5097F988a4d88075C8B48'), + } + const result = await getExternalUrl(params) + expect(result).toBe( + 'https://testnet.zora.co/collect/bsep:0x627a509D76498DDD7D80a28eF4cD887B5b6df2Cd/39?referrer=0xe3bBA2A4F8E0F5C32EF5097F988a4d88075C8B48', + ) + }) }) From da73a852cfa7774db58ccb2f9ef57f70e35e99a9 Mon Sep 17 00:00:00 2001 From: mmackz Date: Fri, 19 Jul 2024 12:20:10 -0700 Subject: [PATCH 4/7] feat(zora): resolve testnet mint urls --- packages/zora/src/Zora.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index dfb90561b..77fd42401 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -22,6 +22,7 @@ import { import { formatAmount } from '@rabbitholegg/questdk-plugin-utils' import { ActionType, + Chains, DEFAULT_ACCOUNT, DEFAULT_REFERRAL as ZORA_DEPLOYER_ADDRESS, type DisctriminatedActionParams, @@ -445,10 +446,17 @@ export const getExternalUrl = async ( ): Promise => { const { chainId, contractAddress, tokenId, referral } = params const chainSlug = CHAIN_ID_TO_ZORA_SLUG[chainId] - const referralParams = `?referrer=${referral ?? ZORA_DEPLOYER_ADDRESS}` - const baseUrl = `https://zora.co/collect/${chainSlug}:${contractAddress}` + const isTestnet = chainId === Chains.BASE_SEPOLIA || chainId === Chains.SEPOLIA + + if (chainSlug) { + const referralParams = `?referrer=${referral ?? ZORA_DEPLOYER_ADDRESS}` + const baseUrl = `https://${isTestnet ? 'testnet.' : ''}zora.co/collect/${chainSlug}:${contractAddress}` + + return tokenId != null + ? `${baseUrl}/${tokenId}${referralParams}` + : `${baseUrl}${referralParams}` + } - return tokenId != null - ? `${baseUrl}/${tokenId}${referralParams}` - : `${baseUrl}${referralParams}` + // fallback to default zora url + return 'https://zora.co' } From 52f77ac748ce52dcc8e8db3ee6436c4a3574463c Mon Sep 17 00:00:00 2001 From: mmackz Date: Fri, 19 Jul 2024 12:20:36 -0700 Subject: [PATCH 5/7] chore: format --- packages/zora/src/Zora.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index 77fd42401..ea0b2d3d9 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -446,12 +446,15 @@ export const getExternalUrl = async ( ): Promise => { const { chainId, contractAddress, tokenId, referral } = params const chainSlug = CHAIN_ID_TO_ZORA_SLUG[chainId] - const isTestnet = chainId === Chains.BASE_SEPOLIA || chainId === Chains.SEPOLIA + const isTestnet = + chainId === Chains.BASE_SEPOLIA || chainId === Chains.SEPOLIA if (chainSlug) { const referralParams = `?referrer=${referral ?? ZORA_DEPLOYER_ADDRESS}` - const baseUrl = `https://${isTestnet ? 'testnet.' : ''}zora.co/collect/${chainSlug}:${contractAddress}` - + const baseUrl = `https://${ + isTestnet ? 'testnet.' : '' + }zora.co/collect/${chainSlug}:${contractAddress}` + return tokenId != null ? `${baseUrl}/${tokenId}${referralParams}` : `${baseUrl}${referralParams}` From 1240bf6b414202f7cfececff5e3cd9bb98cbaed7 Mon Sep 17 00:00:00 2001 From: mmackz Date: Fri, 19 Jul 2024 12:21:31 -0700 Subject: [PATCH 6/7] chore: generate changeset --- .changeset/quick-ladybugs-repair.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/quick-ladybugs-repair.md diff --git a/.changeset/quick-ladybugs-repair.md b/.changeset/quick-ladybugs-repair.md new file mode 100644 index 000000000..6c8b6e6d9 --- /dev/null +++ b/.changeset/quick-ladybugs-repair.md @@ -0,0 +1,6 @@ +--- +"@rabbitholegg/questdk-plugin-utils": minor +"@rabbitholegg/questdk-plugin-zora": minor +--- + +add support for testnet url generation From f6b75d5a3f73532d8c0a8ca529eaed3ac13edc68 Mon Sep 17 00:00:00 2001 From: mmackz Date: Fri, 19 Jul 2024 12:27:45 -0700 Subject: [PATCH 7/7] refactor(zora): refactor getExternalUrl --- 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 ea0b2d3d9..5ba576c4c 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -451,9 +451,8 @@ export const getExternalUrl = async ( if (chainSlug) { const referralParams = `?referrer=${referral ?? ZORA_DEPLOYER_ADDRESS}` - const baseUrl = `https://${ - isTestnet ? 'testnet.' : '' - }zora.co/collect/${chainSlug}:${contractAddress}` + const domain = isTestnet ? 'testnet.zora.co' : 'zora.co' + const baseUrl = `https://${domain}/collect/${chainSlug}:${contractAddress}` return tokenId != null ? `${baseUrl}/${tokenId}${referralParams}`