Skip to content

Commit

Permalink
Merge pull request #488 from rabbitholegg/matthew/boost-4281-move-def…
Browse files Browse the repository at this point in the history
…ault-referral-address-to-utils

feat(utils): add default referral address to plugin utils
  • Loading branch information
mmackz authored Jul 17, 2024
2 parents aa4f44f + 4857084 commit 4cc5979
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 39 deletions.
8 changes: 8 additions & 0 deletions .changeset/chilly-flies-cheer.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions packages/pods/src/Pods.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
Chains,
DEFAULT_REFERRAL,
type MintActionParams,
type MintIntentParams,
} from '@rabbitholegg/questdk-plugin-utils'
Expand All @@ -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', () => {
Expand Down Expand Up @@ -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}`,
)
})

Expand Down
16 changes: 5 additions & 11 deletions packages/pods/src/Pods.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -13,6 +10,7 @@ import {
} from '@rabbitholegg/questdk'
import {
DEFAULT_ACCOUNT,
DEFAULT_REFERRAL,
type MintIntentParams,
chainIdToViemChain,
getExitAddresses,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions packages/pods/src/contract-addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
14 changes: 5 additions & 9 deletions packages/soundxyz/src/Soundxyz.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ import {
mint,
simulateMint,
} from './Soundxyz'
import {
SUPERMINTER,
SUPERMINTER_V2,
SUPERMINTER_V2_ABI,
ZORA_DEPLOYER_ADDRESS,
} from './constants'
import { SUPERMINTER, SUPERMINTER_V2, SUPERMINTER_V2_ABI } from './constants'
import {
OP_SUPERMINTER_V2,
failingTestCases,
Expand All @@ -20,6 +15,7 @@ import { Chains } from './utils'
import { apply } from '@rabbitholegg/questdk'
import {
ActionType,
DEFAULT_REFERRAL,
type DisctriminatedActionParams,
type MintActionParams,
type MintIntentParams,
Expand Down Expand Up @@ -181,7 +177,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'
Expand All @@ -198,7 +194,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'
Expand Down Expand Up @@ -236,7 +232,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}`,
)
})
})
6 changes: 3 additions & 3 deletions packages/soundxyz/src/Soundxyz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -21,6 +20,7 @@ import {
import {
ActionType,
DEFAULT_ACCOUNT,
DEFAULT_REFERRAL,
type DisctriminatedActionParams,
type MintIntentParams,
chainIdToViemChain,
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions packages/soundxyz/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,3 @@ export const CONTRACT_URI_ABI = [
type: 'function',
},
]

// for referrals
export const ZORA_DEPLOYER_ADDRESS =
'0xe3bBA2A4F8E0F5C32EF5097F988a4d88075C8B48'
1 change: 1 addition & 0 deletions packages/utils/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export {
BOOST_TREASURY_ADDRESS,
} from './contract-addresses'
export { Chains } from './chain-ids'
export { DEFAULT_REFERRAL } from './referral'
4 changes: 4 additions & 0 deletions packages/utils/src/constants/referral.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Boost-Owned EOA for collecting referral fees.
*/
export const DEFAULT_REFERRAL = '0xe3bBA2A4F8E0F5C32EF5097F988a4d88075C8B48'
1 change: 1 addition & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export {
Chains,
DEFAULT_ACCOUNT,
BOOST_TREASURY_ADDRESS,
DEFAULT_REFERRAL,
} from './constants/index'

export type { TestParams, TestCase } from './helpers/index'
Expand Down
2 changes: 1 addition & 1 deletion packages/zora/src/Zora.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import {
ActionType,
Chains,
DEFAULT_REFERRAL as ZORA_DEPLOYER_ADDRESS,
type DisctriminatedActionParams,
type MintActionParams,
type MintIntentParams,
Expand All @@ -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 = [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/zora/src/Zora.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions packages/zora/src/contract-addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit 4cc5979

Please sign in to comment.