From aeebecd0f57ed8464e1a44e173e020012d3a94bc Mon Sep 17 00:00:00 2001 From: Katty Barroso <51223655+kattylucy@users.noreply.github.com> Date: Wed, 4 Dec 2024 12:04:30 +0100 Subject: [PATCH] Create pool - functionality (#2545) * Fix ts error and change logic for onboarding values * Add create pool existing functionality * Cleanup types * cleanup * Add deposit banner * Fix linter errors * Add metadata values * Cleanup types * Add onboarding functionality and UI fixes * Add proxies functionality * Fix ts errors * Add create pool dialog * Add dialogs * Add review feedback * wip * Add waiting before redirecting to avoid error * Remove default empty pool fee --- .../src/components/Menu/IssuerMenu.tsx | 4 +- centrifuge-app/src/components/Menu/Toggle.tsx | 2 +- centrifuge-app/src/components/Menu/index.tsx | 4 + .../pages/IssuerCreatePool/AdminMultisig.tsx | 2 +- .../IssuerCreatePool/IssuerCategories.tsx | 40 +- .../IssuerCreatePool/PoolDetailsSection.tsx | 5 +- .../IssuerCreatePool/PoolSetupSection.tsx | 165 +++++-- .../IssuerCreatePool/PoolStructureSection.tsx | 100 +++-- .../src/pages/IssuerCreatePool/index.tsx | 419 +++++++++++++++++- .../src/pages/IssuerCreatePool/types.ts | 52 ++- .../src/pages/IssuerCreatePool/utils.ts | 33 ++ .../src/pages/IssuerCreatePool/validate.ts | 3 +- centrifuge-js/src/modules/pools.ts | 112 ++--- fabric/src/components/Dialog/index.tsx | 16 +- fabric/src/components/Toast/index.tsx | 2 +- fabric/src/icon-svg/icon-chevron-down.svg | 2 +- 16 files changed, 772 insertions(+), 189 deletions(-) create mode 100644 centrifuge-app/src/pages/IssuerCreatePool/utils.ts diff --git a/centrifuge-app/src/components/Menu/IssuerMenu.tsx b/centrifuge-app/src/components/Menu/IssuerMenu.tsx index 24ad7b9a81..1e2385649a 100644 --- a/centrifuge-app/src/components/Menu/IssuerMenu.tsx +++ b/centrifuge-app/src/components/Menu/IssuerMenu.tsx @@ -62,9 +62,9 @@ export function IssuerMenu({ defaultOpen = false, children }: IssuerMenuProps) { Issuer {isLarge && (open ? ( - + ) : ( - + ))} diff --git a/centrifuge-app/src/components/Menu/Toggle.tsx b/centrifuge-app/src/components/Menu/Toggle.tsx index 8737377fe0..08838a5cfa 100644 --- a/centrifuge-app/src/components/Menu/Toggle.tsx +++ b/centrifuge-app/src/components/Menu/Toggle.tsx @@ -10,7 +10,7 @@ export const Toggle = styled(Text)<{ isActive?: boolean; stacked?: boolean }>` width: 100%; grid-template-columns: ${({ stacked, theme }) => stacked ? '1fr' : `${theme.sizes.iconSmall}px 1fr ${theme.sizes.iconSmall}px`}; - color: ${({ isActive, theme }) => (isActive ? theme.colors.textGold : theme.colors.textInverted)}; + color: ${({ theme }) => theme.colors.textInverted}; border-radius: 4px; background-color: ${({ isActive }) => (isActive ? LIGHT_BACKGROUND : 'transparent')}; diff --git a/centrifuge-app/src/components/Menu/index.tsx b/centrifuge-app/src/components/Menu/index.tsx index 1c3e321919..5fe10a79d2 100644 --- a/centrifuge-app/src/components/Menu/index.tsx +++ b/centrifuge-app/src/components/Menu/index.tsx @@ -40,6 +40,10 @@ const StyledRouterLinkButton = styled(RouterLinkButton)` background-color: ${COLOR}; color: white; } + + &:active { + border-color: transparent; + } } ` diff --git a/centrifuge-app/src/pages/IssuerCreatePool/AdminMultisig.tsx b/centrifuge-app/src/pages/IssuerCreatePool/AdminMultisig.tsx index 68476ce014..5ac4c2de4e 100644 --- a/centrifuge-app/src/pages/IssuerCreatePool/AdminMultisig.tsx +++ b/centrifuge-app/src/pages/IssuerCreatePool/AdminMultisig.tsx @@ -1,9 +1,9 @@ import { useWallet } from '@centrifuge/centrifuge-react' import { Button } from '@centrifuge/fabric' import { useFormikContext } from 'formik' -import { CreatePoolValues } from '.' import { PageSection } from '../../components/PageSection' import { MultisigForm } from '../IssuerPool/Access/MultisigForm' +import { CreatePoolValues } from './types' export function AdminMultisigSection() { const form = useFormikContext() diff --git a/centrifuge-app/src/pages/IssuerCreatePool/IssuerCategories.tsx b/centrifuge-app/src/pages/IssuerCreatePool/IssuerCategories.tsx index 4d70a2f345..311c7e76a7 100644 --- a/centrifuge-app/src/pages/IssuerCreatePool/IssuerCategories.tsx +++ b/centrifuge-app/src/pages/IssuerCreatePool/IssuerCategories.tsx @@ -1,5 +1,5 @@ import { PoolMetadataInput } from '@centrifuge/centrifuge-js' -import { Box, IconButton, IconTrash, Select, Text, TextInput } from '@centrifuge/fabric' +import { Box, Grid, IconButton, IconTrash, Select, Text, TextInput } from '@centrifuge/fabric' import { Field, FieldArray, FieldProps, useFormikContext } from 'formik' import { AddButton } from './PoolDetailsSection' import { StyledGrid } from './PoolStructureSection' @@ -38,24 +38,32 @@ export const IssuerCategoriesSection = () => { {({ push, remove }) => ( <> - {form.values.issuerCategories.map((_, index) => ( + {form.values.issuerCategories.map((category, index) => ( <> - - {({ field, meta }: FieldProps) => ( - form.setFieldValue(field.name, event.target.value)} + onBlur={field.onBlur} + value={field.value} + options={PROVIDERS} + placeholder="Please select..." + /> + )} + + {category.type === 'other' && ( + + {({ field, meta }: FieldProps) => ( + + )} + )} - - + - {({ field, meta }: FieldProps) => ( + {({ field }: FieldProps) => ( { const form = useFormikContext() const createLabel = (label: string) => `${label}${isTestEnv ? '' : '*'}` - console.log(form.values) - return ( @@ -193,7 +191,6 @@ export const PoolDetailsSection = () => { placeholder="Type here..." maxLength={1000} errorMessage={meta.touched && meta.error ? meta.error : undefined} - // disabled={waitingForStoredIssuer} /> )} @@ -299,9 +296,9 @@ export const PoolDetailsSection = () => { onFileChange={(file) => { form.setFieldValue('reportAuthorAvatar', file) }} - accept="application/pdf" label="Reviewer avatar" placeholder="Choose file" + accept="image/*" small /> )} diff --git a/centrifuge-app/src/pages/IssuerCreatePool/PoolSetupSection.tsx b/centrifuge-app/src/pages/IssuerCreatePool/PoolSetupSection.tsx index b3bfede001..971334ca03 100644 --- a/centrifuge-app/src/pages/IssuerCreatePool/PoolSetupSection.tsx +++ b/centrifuge-app/src/pages/IssuerCreatePool/PoolSetupSection.tsx @@ -1,4 +1,5 @@ -import { PoolMetadataInput } from '@centrifuge/centrifuge-js' +import { addressToHex, evmToSubstrateAddress, PoolMetadataInput } from '@centrifuge/centrifuge-js' +import { useCentEvmChainId } from '@centrifuge/centrifuge-react' import { Box, Checkbox, @@ -18,6 +19,7 @@ import { useTheme } from 'styled-components' import { FieldWithErrorMessage } from '../../../src/components/FieldWithErrorMessage' import { Tooltips } from '../../../src/components/Tooltips' import { feeCategories } from '../../../src/config' +import { isEvmAddress } from '../../../src/utils/address' import { AddButton } from './PoolDetailsSection' import { CheckboxOption, Line, StyledGrid } from './PoolStructureSection' @@ -28,8 +30,30 @@ const FEE_TYPES = [ const FEE_POSISTIONS = [{ label: 'Top of waterfall', value: 'Top of waterfall' }] +const TaxDocument = () => { + const form = useFormikContext() + + return ( + + Tax document requirement + + + {({ field }: FieldProps) => ( + form.setFieldValue('onboarding.taxInfoRequired', val.target.checked ? true : false)} + /> + )} + + + ) +} + export const PoolSetupSection = () => { const theme = useTheme() + const chainId = useCentEvmChainId() const form = useFormikContext() const { values } = form @@ -73,7 +97,24 @@ export const PoolSetupSection = () => { values.adminMultisig?.signers?.map((_, index) => ( - {({ field }: FieldProps) => } + {({ field, form }: FieldProps) => ( + { + form.setFieldValue(`adminMultisig.signers.${index}`, val.target.value) + }} + onBlur={() => { + const value = form.values.adminMultisig.signers[index] + if (value) { + const transformedValue = isEvmAddress(value) + ? evmToSubstrateAddress(value, chainId ?? 0) + : value + form.setFieldValue(`adminMultisig.signers.${index}`, transformedValue) + } + }} + /> + )} )) @@ -88,7 +129,7 @@ export const PoolSetupSection = () => { { - if (form.values.adminMultisig && form.values.adminMultisig.signers?.length <= 10) { + if (values.adminMultisig && values.adminMultisig.signers?.length <= 10) { push('') } }} @@ -103,19 +144,19 @@ export const PoolSetupSection = () => { - + {({ field, meta, form }: FieldProps) => (