Skip to content

Commit

Permalink
[PREVIEW] handle ipfs uploads nft form
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyd-eth committed Sep 1, 2023
1 parent 8cc9ad9 commit 8120af0
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { Trans } from '@lingui/macro'
import { Button } from 'antd'
import { NftRewardsPage } from 'components/Create/components'
import { useDispatch } from 'react-redux'
import { useAppSelector } from 'redux/hooks/useAppSelector'
import { editingV2ProjectActions } from 'redux/slices/editingV2Project'
import { pinNftCollectionMetadata, pinNftRewards } from 'utils/nftRewards'
import { useEditingFundingCycleConfig } from '../ReconfigureFundingCycleSettingsPage/hooks/useEditingFundingCycleConfig'
import { useReconfigureFundingCycle } from '../ReconfigureFundingCycleSettingsPage/hooks/useReconfigureFundingCycle'

export function LaunchNftCollection() {
const {
projectMetadata: { logoUri },
} = useAppSelector(state => state.editingV2Project)
const dispatch = useDispatch()

const editingFundingCycleConfig = useEditingFundingCycleConfig()
const { reconfigureLoading, reconfigureFundingCycle } =
useReconfigureFundingCycle({
Expand All @@ -13,12 +22,44 @@ export function LaunchNftCollection() {
launchedNewNfts: true,
})

const onNftDeploy = async () => {
const newRewardTiers =
editingFundingCycleConfig.editingNftRewards?.rewardTiers
const collectionName =
editingFundingCycleConfig.editingNftRewards?.collectionMetadata.name ?? ''
const collectionDescription =
editingFundingCycleConfig.editingNftRewards?.collectionMetadata
.description ?? ''
const collectionLogoUri = logoUri ?? ''
const collectionInfoUri =
editingFundingCycleConfig.editingNftRewards?.collectionMetadata.uri ?? ''

const [rewardTiersCIDs, nftCollectionMetadataUri] = await Promise.all([
newRewardTiers ? pinNftRewards(newRewardTiers) : [],
pinNftCollectionMetadata({
collectionName,
collectionDescription,
collectionLogoUri,
collectionInfoUri,
}),
])
console.info('rewardTiersCIDs: ', rewardTiersCIDs)
console.info('nftCollectionMetadataUri: ', nftCollectionMetadataUri)
dispatch(editingV2ProjectActions.setNftRewardsCIDs(rewardTiersCIDs))
dispatch(
editingV2ProjectActions.setNftRewardsCollectionMetadataUri(
nftCollectionMetadataUri,
),
)
reconfigureFundingCycle()
}

return (
<NftRewardsPage
okButton={
<Button
type="primary"
onClick={reconfigureFundingCycle}
onClick={onNftDeploy}
loading={reconfigureLoading}
className="mt-10"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export const useReconfigureFundingCycle = ({
const {
nftRewards: { CIDs: nftRewardsCids },
} = useContext(NftRewardsContext)
console.info(
'TODO REMOVE: editingFundingCycleConfig: ',
editingFundingCycleConfig,
)

const [reconfigureTxLoading, setReconfigureTxLoading] =
useState<boolean>(false)
Expand Down
1 change: 0 additions & 1 deletion src/utils/nftRewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ export async function pinNftCollectionMetadata({
: 'https://juicebox.money',
fee_recipient: undefined,
}

const res = await pinJson(IPFSNftCollectionMetadata)
return res.Hash
}
Expand Down

0 comments on commit 8120af0

Please sign in to comment.