From 392c832535a3dadf1148b95971b2a5583474f180 Mon Sep 17 00:00:00 2001 From: Sophia Date: Mon, 21 Aug 2023 10:32:37 -0400 Subject: [PATCH] OnboardingAPI: Fix doc sending to issuer and update remark copy (#1541) * Fix order of middleware to prevent undefined error * Update verbiage for remark signing * Point envs to mainnet for testing --- .../Onboarding/SignSubscriptionAgreement.tsx | 15 ++++++++------- .../src/pages/Onboarding/queries/useSignRemark.ts | 11 ++++++++--- .../controllers/emails/signAndSendDocuments.ts | 3 ++- onboarding-api/src/index.ts | 2 +- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/centrifuge-app/src/pages/Onboarding/SignSubscriptionAgreement.tsx b/centrifuge-app/src/pages/Onboarding/SignSubscriptionAgreement.tsx index adcfd44b5e..52b8573a76 100644 --- a/centrifuge-app/src/pages/Onboarding/SignSubscriptionAgreement.tsx +++ b/centrifuge-app/src/pages/Onboarding/SignSubscriptionAgreement.tsx @@ -33,6 +33,11 @@ export const SignSubscriptionAgreement = ({ signedAgreementUrl }: Props) => { const centrifuge = useCentrifuge() const hasSignedAgreement = !!onboardingUser.poolSteps?.[poolId]?.[trancheId]?.signAgreement.completed + const unsignedAgreementUrl = poolMetadata?.onboarding?.tranches?.[trancheId]?.agreement?.uri + ? centrifuge.metadata.parseMetadataUrl(poolMetadata.onboarding.tranches[trancheId].agreement?.uri!) + : !poolId.startsWith('0x') + ? centrifuge.metadata.parseMetadataUrl(GENERIC_SUBSCRIPTION_AGREEMENT) + : null const formik = useFormik({ initialValues: { @@ -40,19 +45,15 @@ export const SignSubscriptionAgreement = ({ signedAgreementUrl }: Props) => { }, validationSchema, onSubmit: () => { - signRemark([`Signed subscription agreement for pool: ${poolId} tranche: ${trancheId}`]) + signRemark([ + `I hereby sign the subscription agreement of pool ${poolId} and tranche ${trancheId}: ${poolMetadata?.onboarding?.tranches?.[trancheId]?.agreement?.uri}`, + ]) }, }) const { mutate: sendDocumentsToIssuer, isLoading: isSending } = useSignAndSendDocuments() const { execute: signRemark, isLoading: isSigningTransaction } = useSignRemark(sendDocumentsToIssuer) - const unsignedAgreementUrl = poolMetadata?.onboarding?.tranches?.[trancheId]?.agreement?.uri - ? centrifuge.metadata.parseMetadataUrl(poolMetadata.onboarding.tranches[trancheId].agreement?.uri!) - : !poolId.startsWith('0x') - ? centrifuge.metadata.parseMetadataUrl(GENERIC_SUBSCRIPTION_AGREEMENT) - : null - // tinlake pools without subdocs cannot accept investors const isPoolClosedToOnboarding = poolId.startsWith('0x') && !unsignedAgreementUrl const isCountrySupported = diff --git a/centrifuge-app/src/pages/Onboarding/queries/useSignRemark.ts b/centrifuge-app/src/pages/Onboarding/queries/useSignRemark.ts index 8ef0443d15..0f450276cb 100644 --- a/centrifuge-app/src/pages/Onboarding/queries/useSignRemark.ts +++ b/centrifuge-app/src/pages/Onboarding/queries/useSignRemark.ts @@ -116,9 +116,14 @@ export const useSignRemark = ( if (selectedAccount && selectedAccount.signer) { const api = await centrifuge.connect(selectedAccount.address, selectedAccount.signer as any) const paymentInfo = await lastValueFrom( - api.remark.signRemark([`Signed subscription agreement for pool: 12324565 tranche: 0xacbdefghijklmn`], { - paymentInfo: selectedAccount.address, - }) + api.remark.signRemark( + [ + `I hereby sign the subscription agreement of pool [POOL_ID] and tranche [TRANCHE_ID]: [IPFS_HASH_OF_TEMPLATE]`, + ], + { + paymentInfo: selectedAccount.address, + } + ) ) const txFee = paymentInfo.partialFee.toDecimal() setExpectedTxFee(txFee) diff --git a/onboarding-api/src/controllers/emails/signAndSendDocuments.ts b/onboarding-api/src/controllers/emails/signAndSendDocuments.ts index 01dca33a63..4e5984223f 100644 --- a/onboarding-api/src/controllers/emails/signAndSendDocuments.ts +++ b/onboarding-api/src/controllers/emails/signAndSendDocuments.ts @@ -47,7 +47,8 @@ export const signAndSendDocumentsController = async ( throw new HttpError(400, 'Country not supported by issuer') } - const remark = `Signed subscription agreement for pool: ${poolId} tranche: ${trancheId}` + const remark = `I hereby sign the subscription agreement of pool ${poolId} and tranche ${trancheId}: ${metadata + .onboarding.tranches[trancheId].agreement?.uri!}` await new NetworkSwitch(wallet.network).validateRemark(wallet, transactionInfo, remark) diff --git a/onboarding-api/src/index.ts b/onboarding-api/src/index.ts index 86ee172898..a3287bbdca 100644 --- a/onboarding-api/src/index.ts +++ b/onboarding-api/src/index.ts @@ -61,7 +61,7 @@ onboarding.post('/setVerifiedIdentity', verifyAuth, setVerifiedIdentityControlle onboarding.post('/uploadTaxInfo', verifyAuth, fileUpload, uploadTaxInfoController) // pool steps -onboarding.post('/signAndSendDocuments', canOnboardToTinlakeTranche, verifyAuth, signAndSendDocumentsController) +onboarding.post('/signAndSendDocuments', verifyAuth, canOnboardToTinlakeTranche, signAndSendDocumentsController) onboarding.post('/updateInvestorStatus', updateInvestorStatusController) // getters