Skip to content

Commit

Permalink
No hardcoded deploy addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
aeolianeth committed Dec 15, 2024
1 parent c9a52a8 commit 6ebe0b6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 63 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@
"graphql": "^16.8.1",
"he": "^1.2.0",
"jsonwebtoken": "^9.0.0",
"juice-sdk-core": "^12.0.1-alpha",
"juice-sdk-react": "^12.0.1-alpha",
"juice-sdk-core": "^12.1.0-alpha",
"juice-sdk-react": "^12.1.0-alpha",
"juicebox-metadata-helper": "0.1.7",
"less": "4.1.2",
"lodash": "^4.17.21",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { TxHistoryContext } from 'contexts/Transaction/TxHistoryContext'
import { useWallet } from 'hooks/Wallet'
import {
DEFAULT_MEMO,
jbProjectDeploymentAddresses,
NATIVE_TOKEN,
NATIVE_TOKEN_DECIMALS,
} from 'juice-sdk-core'
Expand All @@ -23,22 +24,12 @@ import { useContext } from 'react'
import { DEFAULT_MUST_START_AT_OR_AFTER } from 'redux/slices/shared/v2ProjectDefaultState'
import { ipfsUri } from 'utils/ipfs'
import { Address, WaitForTransactionReceiptReturnType, zeroAddress } from 'viem'
import {
arbitrumSepolia,
baseSepolia,
optimismSepolia,
sepolia,
} from 'viem/chains'
import { useChainId } from 'wagmi'
import {
LaunchV2V3ProjectArgs,
transformV2V3CreateArgsToV4,
} from '../../../utils/launchProjectTransformers'
import {
LaunchTxOpts,
SUPPORTED_JB_CONTROLLER_ADDRESS,
SUPPORTED_JB_MULTITERMINAL_ADDRESS,
} from '../../useLaunchProjectTx'
import { LaunchTxOpts } from '../../useLaunchProjectTx'

/**
* Return the project ID created from a `launchProjectFor` transaction.
Expand All @@ -54,17 +45,6 @@ export const getProjectIdFromNftLaunchReceipt = (
return projectId
}

/**
* The contract addresses to use for deployment
* @todo not ideal to hardcode these addresses
*/
export const SUPPORTED_JB_721_TIER_STORE = {
[sepolia.id]: '0x4DeF0AA5B9CA095d11705284221b2878731ab4EF' as Address,
[optimismSepolia.id]: '0x4DeF0AA5B9CA095d11705284221b2878731ab4EF' as Address,
[arbitrumSepolia.id]: '0x4DeF0AA5B9CA095d11705284221b2878731ab4EF' as Address,
[baseSepolia.id]: '0x4DeF0AA5B9CA095d11705284221b2878731ab4EF' as Address,
}

export function useLaunchProjectWithNftsTx() {
const { contracts } = useJBContractContext()
const { addTransaction } = useContext(TxHistoryContext)
Expand All @@ -73,13 +53,13 @@ export function useLaunchProjectWithNftsTx() {
const chainId = useChainId()

const defaultJBController = chainId
? SUPPORTED_JB_CONTROLLER_ADDRESS[chainId as JBChainId]
? jbProjectDeploymentAddresses.JBController[chainId as JBChainId]
: undefined
const defaultJBETHPaymentTerminal = chainId
? SUPPORTED_JB_MULTITERMINAL_ADDRESS[chainId as JBChainId]
? jbProjectDeploymentAddresses.JBMultiTerminal[chainId as JBChainId]
: undefined
const JBTiered721DelegateStoreAddress = chainId
? SUPPORTED_JB_721_TIER_STORE[chainId as JBChainId]
? jbProjectDeploymentAddresses.JB721TiersHookStore[chainId as JBChainId]
: undefined

const { writeContractAsync: writeLaunchProject } =
Expand Down
32 changes: 4 additions & 28 deletions src/packages/v4/hooks/useLaunchProjectTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,15 @@ import { JUICEBOX_MONEY_PROJECT_METADATA_DOMAIN } from 'constants/metadataDomain
import { DEFAULT_MEMO } from 'constants/transactionDefaults'
import { TxHistoryContext } from 'contexts/Transaction/TxHistoryContext'
import { useWallet } from 'hooks/Wallet'
import { NATIVE_TOKEN } from 'juice-sdk-core'
import { jbProjectDeploymentAddresses, NATIVE_TOKEN } from 'juice-sdk-core'
import {
JBChainId,
useWriteJbControllerLaunchProjectFor,
} from 'juice-sdk-react'
import { LaunchV2V3ProjectData } from 'packages/v2v3/hooks/transactor/useLaunchProjectTx'
import { useCallback, useContext } from 'react'
import { DEFAULT_MUST_START_AT_OR_AFTER } from 'redux/slices/shared/v2ProjectDefaultState'
import { Address, WaitForTransactionReceiptReturnType } from 'viem'
import {
arbitrumSepolia,
baseSepolia,
optimismSepolia,
sepolia,
} from 'viem/chains'
import { WaitForTransactionReceiptReturnType } from 'viem'
import { useChainId } from 'wagmi'
import {
LaunchV2V3ProjectArgs,
Expand Down Expand Up @@ -50,24 +44,6 @@ export const getProjectIdFromLaunchReceipt = (
return projectId
}

/**
* The contract addresses to use for deployment
* @todo not ideal to hardcode these addresses
*/
export const SUPPORTED_JB_MULTITERMINAL_ADDRESS = {
[sepolia.id]: '0x4DeF0AA5B9CA095d11705284221b2878731ab4EF' as Address,
[optimismSepolia.id]: '0x4DeF0AA5B9CA095d11705284221b2878731ab4EF' as Address,
[arbitrumSepolia.id]: '0x4DeF0AA5B9CA095d11705284221b2878731ab4EF' as Address,
[baseSepolia.id]: '0x4DeF0AA5B9CA095d11705284221b2878731ab4EF' as Address,
}

export const SUPPORTED_JB_CONTROLLER_ADDRESS = {
[sepolia.id]: '0x219A5cE6d1c512D5b050ad2E3d380b8746BE0Cb8' as Address,
[optimismSepolia.id]: '0x219A5cE6d1c512D5b050ad2E3d380b8746BE0Cb8' as Address,
[arbitrumSepolia.id]: '0x219A5cE6d1c512D5b050ad2E3d380b8746BE0Cb8' as Address,
[baseSepolia.id]: '0x219A5cE6d1c512D5b050ad2E3d380b8746BE0Cb8' as Address,
}

/**
* Takes data in V2V3 format, converts it to v4 format and passes it to `writeLaunchProject`
* @returns A function that deploys a project.
Expand All @@ -79,11 +55,11 @@ export function useLaunchProjectTx() {
const chainId = useChainId()

const terminalAddress = chainId
? SUPPORTED_JB_MULTITERMINAL_ADDRESS[chainId as JBChainId]
? jbProjectDeploymentAddresses.JBMultiTerminal[chainId as JBChainId]
: undefined

const controllerAddress = chainId
? SUPPORTED_JB_CONTROLLER_ADDRESS[chainId as JBChainId]
? jbProjectDeploymentAddresses.JBController[chainId as JBChainId]
: undefined

const { addTransaction } = useContext(TxHistoryContext)
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12178,18 +12178,18 @@ jsx-ast-utils@^3.3.5:
object.assign "^4.1.4"
object.values "^1.1.6"

juice-sdk-core@^12.0.1-alpha:
version "12.0.1-alpha"
resolved "https://registry.yarnpkg.com/juice-sdk-core/-/juice-sdk-core-12.0.1-alpha.tgz#72622f2d63e6e7eae4b37cdd4d32142387997111"
integrity sha512-6tydUNfUicI/6awFkX8k7NKQPKkHCPRzv0uRlVGPG7fpSv77OFHpanX66znSFqQdiz3hsRxG8/maoIK4FPu/pA==
juice-sdk-core@^12.1.0-alpha:
version "12.1.0-alpha"
resolved "https://registry.yarnpkg.com/juice-sdk-core/-/juice-sdk-core-12.1.0-alpha.tgz#016aefb05ac9c7aa395d91240746c250f366283c"
integrity sha512-uVe+sdZgA8/pudUGh4duGfduwguVqBW6ez01WcstSgq9mEtWOnoP4T9KVAxyp92xlhFO9MLoj3a0GJzRg0K+zg==
dependencies:
bs58 "^5.0.0"
fpnum "^1.0.0"

juice-sdk-react@^12.0.1-alpha:
version "12.0.1-alpha"
resolved "https://registry.yarnpkg.com/juice-sdk-react/-/juice-sdk-react-12.0.1-alpha.tgz#91b7031649f64617f2f43129f10a44249baabcca"
integrity sha512-GKXlDUlzuvpX1P8pLJc6wlmEK1CRG1XKCovUdyQygFdrX/3xw2p7jTy2KtghyS+wHJo4nA/OuLUlKABaUiNiqA==
juice-sdk-react@^12.1.0-alpha:
version "12.1.0-alpha"
resolved "https://registry.yarnpkg.com/juice-sdk-react/-/juice-sdk-react-12.1.0-alpha.tgz#97630084c2deff402598e808a8ffe1acf45fd744"
integrity sha512-961BNlHuwJfeqbh08nUIxkhxDcNYOGaZmaiOwWm1vpFUW4MNTlv81qtuH1H+QUPUDPg8OQw/bfqXRADGFz/WJA==

juice@^10.0.0:
version "10.0.0"
Expand Down

0 comments on commit 6ebe0b6

Please sign in to comment.