Skip to content

Commit

Permalink
OnboardingAPI: Fix doc sending to issuer and update remark copy (#1541)
Browse files Browse the repository at this point in the history
* Fix order of middleware to prevent undefined error

* Update verbiage for remark signing

* Point envs to mainnet for testing
  • Loading branch information
sophialittlejohn authored Aug 21, 2023
1 parent 5aa1b52 commit 392c832
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,27 @@ 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: {
isAgreed: hasSignedAgreement,
},
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 =
Expand Down
11 changes: 8 additions & 3 deletions centrifuge-app/src/pages/Onboarding/queries/useSignRemark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion onboarding-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 392c832

Please sign in to comment.