Skip to content

Commit

Permalink
Final touches for token submit
Browse files Browse the repository at this point in the history
  • Loading branch information
WRadoslaw committed Sep 21, 2023
1 parent 184b65d commit 5ea3ea3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export const TokenIssuanceStep = ({
const data =
assuranceType === 'custom'
? generateChartData(Number(customCliff ?? 0), Number(customVesting ?? 0), firstPayout ? firstPayout : 0)
: generateChartData(...getDataBasedOnType(assuranceType))
: generateChartData(...(getDataBasedOnType(assuranceType) as [number, number, number]))
setPreview(
<PreviewContainer>
<Text variant="h100" as="h1" color="colorTextMuted">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Datum } from '@nivo/line'
import { z } from 'zod'

import { IssuanceStepForm } from '@/components/_crt/CreateTokenDrawer/CreateTokenDrawer.types'

export const assuranceOptions = [
{
label: 'Secure',
Expand Down Expand Up @@ -172,13 +174,15 @@ export const generateChartData = (cliffTime: number, vestingTime: number, firstP
return data
}

export const getDataBasedOnType = (type: 'secure' | 'safe' | 'risky'): [number, number, number] => {
export const getDataBasedOnType = (type: IssuanceStepForm['assuranceType']): [number, number, number] | null => {
switch (type) {
case 'secure':
return [6, 12, 50]
case 'safe':
return [0, 6, 50]
case 'risky':
return [0, 0, 0]
return [0, 0, 100]
case 'custom':
return null
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import styled from '@emotion/styled'
import { ReactNode } from 'react'
import { useNavigate } from 'react-router-dom'

import { SvgAlertsInformative24 } from '@/assets/icons'
import { Banner } from '@/components/Banner'
import { NumberFormat } from '@/components/NumberFormat'
import { Text } from '@/components/Text'
import { Tooltip } from '@/components/Tooltip'
import { CrtFormWrapper } from '@/components/_crt/CrtFormWrapper'
import { absoluteRoutes } from '@/config/routes'
import { useMountEffect } from '@/hooks/useMountEffect'
import { useFee, useJoystream } from '@/providers/joystream'
import { useTransaction } from '@/providers/transactions/transactions.hooks'
import { useUser } from '@/providers/user/user.hooks'
import { sizes } from '@/styles'
import { formatNumber } from '@/utils/number'

import { cliffOptions, vestingOptions } from './TokenIssuanceStep/TokenIssuanceStep.utils'
import { cliffOptions, getDataBasedOnType, vestingOptions } from './TokenIssuanceStep/TokenIssuanceStep.utils'
import { CommonStepProps } from './types'

const cliffBanner = (
Expand All @@ -36,11 +38,16 @@ export const TokenSummaryStep = ({ setPrimaryButtonProps, form }: CommonStepProp
const { joystream, proxyCallback } = useJoystream()
const { channelId, memberId } = useUser()
const handleTransaction = useTransaction()
const { loading, fullFee } = useFee('issueCreatorTokenTx')
const navigate = useNavigate()
const { fullFee } = useFee('issueCreatorTokenTx')

console.log(form)
const handleSubmitTx = async () => {
if (!joystream || !channelId || !memberId) return
const [cliff, vesting, payout] = getDataBasedOnType(form.assuranceType) ?? [
form.cliff,
form.vesting,
form.firstPayout,
]
return handleTransaction({
fee: fullFee,
txFactory: async (handleUpdate) =>
Expand All @@ -52,22 +59,19 @@ export const TokenSummaryStep = ({ setPrimaryButtonProps, form }: CommonStepProp
form.revenueShare,
{
amount: String(form.creatorIssueAmount ?? 0),
cliffAmountPercentage: form.firstPayout ?? 0,
vestingDuration: form.vesting ? monthDurationToBlocks(+form.vesting) : 0,
blocksBeforeCliff: form.cliff ? monthDurationToBlocks(+form.cliff) : 0,
cliffAmountPercentage: payout ?? 0,
vestingDuration: vesting ? monthDurationToBlocks(+vesting) : 0,
blocksBeforeCliff: cliff ? monthDurationToBlocks(+cliff) : 0,
},
proxyCallback(handleUpdate)
),
onTxSync: async (data) => {
console.log(data, ' kurwa')
return undefined
onTxSync: async () => {
navigate(absoluteRoutes.studio.crtDashboard())
},
snackbarSuccessMessage: {
title: 'NFT price changed successfully',
description: 'You can update the price anytime.',
title: `$${form.name} minted successfuly.`,
},
})
// const adw = await
}

useMountEffect(() => {
Expand Down

0 comments on commit 5ea3ea3

Please sign in to comment.