Skip to content

Commit

Permalink
Add fields to metadata and make them editable
Browse files Browse the repository at this point in the history
  • Loading branch information
sophialittlejohn committed Sep 13, 2024
1 parent 216f6e3 commit 319c85a
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 6 deletions.
4 changes: 2 additions & 2 deletions centrifuge-app/src/pages/IssuerCreatePool/TrancheInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ export function TrancheInput({ canRemove, isUpdating }: { canRemove?: boolean; i
</Field>
{index === 0 ? (
<>
{/* For Junior tranche, use interestRatePerSec with "Target APY" label */}
{/* Only most junior tranche has target APY */}
<FieldWithErrorMessage
as={NumberInput}
label={<Tooltips type="targetAPY" variant="secondary" />}
placeholder="0.00"
symbol="%"
name={`tranches.${index}.interestRate`}
name={`tranches.${index}.targetAPY`}
validate={validate.interestRate}
/>
</>
Expand Down
11 changes: 9 additions & 2 deletions centrifuge-app/src/pages/IssuerCreatePool/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export type CreatePoolValues = Omit<
issuerShortDescription: string
ratingAgency: string
ratingValue: string
ratingReport: File | null
ratingReportUrl: string
}

const initialValues: CreatePoolValues = {
Expand Down Expand Up @@ -148,7 +148,7 @@ const initialValues: CreatePoolValues = {

ratingAgency: '',
ratingValue: '',
ratingReport: null,
ratingReportUrl: '',

tranches: [createEmptyTranche('')],
adminMultisig: {
Expand Down Expand Up @@ -462,6 +462,13 @@ function CreatePoolForm() {
url: values.reportUrl,
}
}
if (values.ratingReportUrl) {
metadataValues.poolRating = {
ratingAgency: values.ratingAgency,
ratingValue: values.ratingValue,
ratingReportUrl: values.ratingReportUrl,
}
}

const nonJuniorTranches = metadataValues.tranches.slice(1)
const tranches = [
Expand Down
14 changes: 12 additions & 2 deletions centrifuge-app/src/pages/IssuerPool/Configuration/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { usePool, usePoolMetadata } from '../../../utils/usePools'
import { CreatePoolValues } from '../../IssuerCreatePool'
import { validate } from '../../IssuerCreatePool/validate'

type Values = Pick<CreatePoolValues, 'poolName' | 'poolIcon' | 'assetClass' | 'subAssetClass'> & {
type Values = Pick<CreatePoolValues, 'poolName' | 'poolIcon' | 'assetClass' | 'subAssetClass' | 'investorType'> & {
listed: boolean
}

Expand Down Expand Up @@ -55,6 +55,7 @@ export function Details() {
: 'Private credit',
subAssetClass: metadata?.pool?.asset?.subClass ?? '',
listed: metadata?.pool?.listed ?? false,
investorType: metadata?.pool?.investorType ?? '',
}),
[metadata, iconFile]
)
Expand Down Expand Up @@ -91,6 +92,7 @@ export function Details() {
class: values.assetClass,
subClass: values.subAssetClass,
},
investorType: values.investorType,
listed: values.listed,
},
pod: {
Expand Down Expand Up @@ -221,7 +223,14 @@ export function Details() {
placeholder=""
disabled
/>

<FieldWithErrorMessage
validate={validate.poolName}
name="investorType"
as={TextInput}
label="Investor type"
placeholder="Institutional"
maxLength={100}
/>
{((isDemo && editPoolVisibility) || !isDemo) && (
<Field name="listed" validate={validate.assetClass}>
{({ field }: FieldProps) => (
Expand All @@ -245,6 +254,7 @@ export function Details() {

<LabelValueStack label="Currency" value={currency} />
<LabelValueStack label="Menu listing" value={metadata?.pool?.listed ? 'Published' : 'Not published'} />
<LabelValueStack label="Investor type" value={metadata?.pool?.investorType} />
</Shelf>
)}
</PageSection>
Expand Down
14 changes: 14 additions & 0 deletions centrifuge-app/src/pages/IssuerPool/Configuration/Issuer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Values = Pick<
| 'issuerRepName'
| 'issuerLogo'
| 'issuerDescription'
| 'issuerShortDescription'
| 'executiveSummary'
| 'website'
| 'forum'
Expand All @@ -31,6 +32,9 @@ type Values = Pick<
| 'reportUrl'
| 'reportAuthorName'
| 'reportAuthorTitle'
| 'ratingAgency'
| 'ratingValue'
| 'ratingReportUrl'
> & {
reportAuthorAvatar: string | null | File
}
Expand All @@ -54,6 +58,7 @@ export function Issuer() {
issuerRepName: metadata?.pool?.issuer?.repName ?? '',
issuerLogo: logoFile ?? null,
issuerDescription: metadata?.pool?.issuer?.description ?? '',
issuerShortDescription: metadata?.pool?.issuer?.shortDescription ?? '',
executiveSummary: metadata?.pool?.links?.executiveSummary ? 'executiveSummary.pdf' : ('' as any),
website: metadata?.pool?.links?.website ?? '',
forum: metadata?.pool?.links?.forum ?? '',
Expand All @@ -65,6 +70,9 @@ export function Issuer() {
reportAuthorAvatar: metadata?.pool?.reports?.[0]?.author?.avatar
? `avatar.${metadata.pool.reports[0].author.avatar.mime?.split('/')[1]}`
: null,
ratingAgency: metadata?.pool?.rating?.ratingAgency ?? '',
ratingValue: metadata?.pool?.rating?.ratingValue ?? '',
ratingReportUrl: metadata?.pool?.rating?.ratingReportUrl ?? '',
}),
[metadata, logoFile]
)
Expand Down Expand Up @@ -110,6 +118,7 @@ export function Issuer() {
email: values.email,
logo:
logoChanged && logoUri ? { uri: logoUri, mime: values.issuerLogo!.type } : oldMetadata.pool.issuer.logo,
shortDescription: values.issuerShortDescription,
},
links: {
executiveSummary: execSummaryUri
Expand All @@ -119,6 +128,11 @@ export function Issuer() {
website: values.website,
},
details: values.details,
rating: {
ratingAgency: values.ratingAgency,
ratingValue: values.ratingValue,
ratingReportUrl: values.ratingReportUrl,
},
},
}

Expand Down
20 changes: 20 additions & 0 deletions centrifuge-js/src/modules/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ interface TrancheFormValues {
interestRate: number | ''
minRiskBuffer: number | ''
minInvestment: number | ''
targetAPY?: number | ''
}

export type IssuerDetail = {
Expand Down Expand Up @@ -689,6 +690,11 @@ export interface PoolMetadataInput {
authorAvatar: FileType | null
url: string
}
poolRating?: {
ratingAgency?: string
ratingValue?: string
ratingReportUrl?: string
}

executiveSummary: FileType | null
website: string
Expand Down Expand Up @@ -750,6 +756,11 @@ export type PoolMetadata = {
status: PoolStatus
listed: boolean
reports?: PoolReport[]
rating?: {
ratingAgency?: string
ratingValue?: string
ratingReportUrl?: string
}
}
pod?: {
indexer?: string | null
Expand Down Expand Up @@ -1093,8 +1104,10 @@ export function getPoolsModule(inst: Centrifuge) {

const tranchesById: PoolMetadata['tranches'] = {}
metadata.tranches.forEach((tranche, index) => {
const targetAPY = tranche?.targetAPY ? { targetAPY: tranche.targetAPY } : {}
tranchesById[computeTrancheId(index, poolId)] = {
minInitialInvestment: CurrencyBalance.fromFloat(tranche.minInvestment, currencyDecimals).toString(),
...targetAPY,
}
})

Expand Down Expand Up @@ -1125,6 +1138,13 @@ export function getPoolsModule(inst: Centrifuge) {
status: 'open',
listed: metadata.listed ?? true,
poolFees: metadata.poolFees,
rating: metadata.poolRating
? {
ratingAgency: metadata.poolRating.ratingAgency,
ratingValue: metadata.poolRating.ratingValue,
ratingReportUrl: metadata.poolRating.ratingReportUrl,
}
: undefined,
reports: metadata.poolReport
? [
{
Expand Down

0 comments on commit 319c85a

Please sign in to comment.