-
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PREVIEW] Complete launch NFT collection form
- Loading branch information
1 parent
5ea31ee
commit 1de4d41
Showing
14 changed files
with
215 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './NftRewardsPage' | ||
export * from './AddNftCollectionForm' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 0 additions & 71 deletions
71
...onents/v2v3/V2V3Project/V2V3ProjectSettings/pages/NewEditNftsPage/LaunchNftCollection.tsx
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
...ponents/v2v3/V2V3Project/V2V3ProjectSettings/pages/NewEditNftsPage/LaunchNftsAdvanced.tsx
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
src/components/v2v3/V2V3Project/V2V3ProjectSettings/pages/NewEditNftsPage/LaunchNftsPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { AddNftCollectionForm } from 'components/Create/components' | ||
import { UploadAndLaunchNftsButton } from './UploadAndLaunchNftsButton' | ||
|
||
export function LaunchNftsPage() { | ||
return ( | ||
<AddNftCollectionForm | ||
okButton={<UploadAndLaunchNftsButton className="mt-10" />} | ||
/> | ||
) | ||
} |
95 changes: 95 additions & 0 deletions
95
.../v2v3/V2V3Project/V2V3ProjectSettings/pages/NewEditNftsPage/UploadAndLaunchNftsButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { Trans } from '@lingui/macro' | ||
import { Button } from 'antd' | ||
import { useState } from 'react' | ||
import { useAppSelector } from 'redux/hooks/useAppSelector' | ||
import { pinNftCollectionMetadata, pinNftRewards } from 'utils/nftRewards' | ||
import { | ||
EditingFundingCycleConfig, | ||
useEditingFundingCycleConfig, | ||
} from '../ReconfigureFundingCycleSettingsPage/hooks/useEditingFundingCycleConfig' | ||
import { useReconfigureFundingCycle } from '../ReconfigureFundingCycleSettingsPage/hooks/useReconfigureFundingCycle' | ||
|
||
export function UploadAndLaunchNftsButton({ | ||
className, | ||
}: { | ||
className?: string | ||
}) { | ||
const [ipfsUploading, setIpfsUploading] = useState<boolean>(false) | ||
|
||
const { | ||
projectMetadata: { logoUri }, | ||
} = useAppSelector(state => state.editingV2Project) | ||
|
||
const editingFundingCycleConfig = useEditingFundingCycleConfig() | ||
const { reconfigureLoading, reconfigureFundingCycle } = | ||
useReconfigureFundingCycle({ | ||
editingFundingCycleConfig, | ||
memo: 'First NFT collection', | ||
launchedNewNfts: true, | ||
}) | ||
|
||
const { | ||
editingPayoutGroupedSplits, | ||
editingReservedTokensGroupedSplits, | ||
editingFundingCycleMetadata, | ||
editingFundingCycleData, | ||
editingFundAccessConstraints, | ||
editingNftRewards, | ||
editingMustStartAtOrAfter, | ||
} = editingFundingCycleConfig | ||
|
||
const uploadNftsToIpfs = async () => { | ||
setIpfsUploading(true) | ||
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, | ||
}), | ||
]) | ||
const latestEditingData: EditingFundingCycleConfig = { | ||
editingPayoutGroupedSplits, | ||
editingReservedTokensGroupedSplits, | ||
editingFundingCycleMetadata, | ||
editingFundingCycleData, | ||
editingFundAccessConstraints, | ||
editingNftRewards: editingNftRewards | ||
? { | ||
...editingNftRewards, | ||
collectionMetadata: { | ||
...editingNftRewards.collectionMetadata, | ||
uri: nftCollectionMetadataUri, | ||
}, | ||
CIDs: rewardTiersCIDs, | ||
} | ||
: undefined, | ||
editingMustStartAtOrAfter, | ||
} | ||
reconfigureFundingCycle(latestEditingData) | ||
setIpfsUploading(false) | ||
} | ||
|
||
return ( | ||
<Button | ||
type="primary" | ||
onClick={uploadNftsToIpfs} | ||
loading={ipfsUploading || reconfigureLoading} | ||
className={className} | ||
> | ||
<Trans>Deploy NFT collection</Trans> | ||
</Button> | ||
) | ||
} |
Oops, something went wrong.