diff --git a/centrifuge-app/src/pages/Loan/ChargeFeesFields.tsx b/centrifuge-app/src/pages/Loan/ChargeFeesFields.tsx
index dbe4a7dd0..2781b6733 100644
--- a/centrifuge-app/src/pages/Loan/ChargeFeesFields.tsx
+++ b/centrifuge-app/src/pages/Loan/ChargeFeesFields.tsx
@@ -9,7 +9,7 @@ import {
import { Box, CurrencyInput, IconMinusCircle, IconPlusCircle, Select, Shelf, Stack, Text } from '@centrifuge/fabric'
import { Field, FieldArray, FieldProps, useFormikContext } from 'formik'
import React from 'react'
-import { combineLatest, of, switchMap } from 'rxjs'
+import { combineLatest, map, of } from 'rxjs'
import { Dec } from '../../utils/Decimal'
import { useBorrower } from '../../utils/usePermissions'
import { usePool, usePoolFees, usePoolMetadata } from '../../utils/usePools'
@@ -175,7 +175,7 @@ export function useChargePoolFees(poolId: string, loanId: string) {
let feeTx = api.tx.poolFees.chargeFee(fee.id, feeAmount.toString())
return cent.remark
.remark([[{ Loan: [poolId, loanId] }], feeTx], { batch: true })
- .pipe(switchMap((tx) => [wrapProxyCallsForAccount(api, tx, borrower, 'Borrow')]))
+ .pipe(map((tx) => wrapProxyCallsForAccount(api, tx, borrower, 'Borrow')))
})
return combineLatest(fees)
},
diff --git a/centrifuge-app/src/pages/Loan/ExternalFinanceForm.tsx b/centrifuge-app/src/pages/Loan/ExternalFinanceForm.tsx
index 729786591..9048b227f 100644
--- a/centrifuge-app/src/pages/Loan/ExternalFinanceForm.tsx
+++ b/centrifuge-app/src/pages/Loan/ExternalFinanceForm.tsx
@@ -175,27 +175,29 @@ export function ExternalFinanceForm({ loan, source }: { loan: ExternalLoan; sour
Transaction summary
-
-
- Available balance
-
-
-
- {formatBalance(maxAvailable, displayCurrency, 2)}
-
-
-
-
- Principal amount
+ Available balance
+
+
+
+ {formatBalance(maxAvailable, displayCurrency, 2)}
+
- {formatBalance(totalFinance, displayCurrency, 2)}
-
- {poolFees.renderSummary()}
+
+
+
+ Principal amount
+
+ {formatBalance(totalFinance, displayCurrency, 2)}
+
+
+
+ {poolFees.renderSummary()}
+
{source === 'reserve' ? (
diff --git a/centrifuge-app/src/pages/Loan/ExternalRepayForm.tsx b/centrifuge-app/src/pages/Loan/ExternalRepayForm.tsx
index 0892b2575..8e3fce6bf 100644
--- a/centrifuge-app/src/pages/Loan/ExternalRepayForm.tsx
+++ b/centrifuge-app/src/pages/Loan/ExternalRepayForm.tsx
@@ -172,7 +172,7 @@ export function ExternalRepayForm({ loan, destination }: { loan: ExternalLoan; d
totalRepay,
principalAmount,
}
- }, [loan, balance, repayForm.values])
+ }, [loan, balance, repayForm.values, destination])
if (loan.status === 'Closed' || ('valuationMethod' in loan.pricing && loan.pricing.valuationMethod !== 'oracle')) {
return null
diff --git a/centrifuge-app/src/pages/Loan/FinanceForm.tsx b/centrifuge-app/src/pages/Loan/FinanceForm.tsx
index 43682e680..62c12ace4 100644
--- a/centrifuge-app/src/pages/Loan/FinanceForm.tsx
+++ b/centrifuge-app/src/pages/Loan/FinanceForm.tsx
@@ -113,7 +113,10 @@ function InternalFinanceForm({ loan, source }: { loan: LoanType; source: string
} else if (source === 'other') {
if (!financeForm.values.category) throw new Error('No category selected')
const increaseDebtTx = api.tx.loans.increaseDebt(poolId, loan.id, { internal: principal })
- const categoryHex = Buffer.from(financeForm.values.category).toString('hex')
+ const encoded = new TextEncoder().encode(financeForm.values.category)
+ const categoryHex = Array.from(encoded)
+ .map((byte) => byte.toString(16).padStart(2, '0'))
+ .join('')
financeTx = cent.remark.remark([[{ Named: categoryHex }], increaseDebtTx], { batch: true })
} else {
const repay = { principal, interest: new BN(0), unscheduled: new BN(0) }
@@ -241,34 +244,36 @@ function InternalFinanceForm({ loan, source }: { loan: LoanType; source: string
Transaction summary
-
-
- Available balance
-
-
-
- {maxAvailable === UNLIMITED ? 'No limit' : formatBalance(maxAvailable, displayCurrency, 2)}
-
-
-
-
- {isCashLoan(loan) ? 'Deposit amount' : 'Financing amount'}
+ Available balance
+
+
+
+ {maxAvailable === UNLIMITED ? 'No limit' : formatBalance(maxAvailable, displayCurrency, 2)}
+
- {formatBalance(totalFinance, displayCurrency, 2)}
-
- {poolFees.renderSummary()}
+
+
+
+ {isCashLoan(loan) ? 'Deposit amount' : 'Financing amount'}
+
+ {formatBalance(totalFinance, displayCurrency, 2)}
+
+
+
+ {poolFees.renderSummary()}
+
{source === 'reserve' ? (
@@ -638,9 +643,3 @@ function divideBetweenCurrencies(
return divideBetweenCurrencies(remainder, rest, withdrawAddresses, ignoredCurrencies, combinedResult)
}
-
-const stringToHex = (str: string) =>
- str
- .split('')
- .map((char) => ('00' + char.charCodeAt(0).toString(16)).slice(-2))
- .join('')
diff --git a/centrifuge-app/src/pages/Loan/RepayForm.tsx b/centrifuge-app/src/pages/Loan/RepayForm.tsx
index 6bd9c90da..cd255d2c9 100644
--- a/centrifuge-app/src/pages/Loan/RepayForm.tsx
+++ b/centrifuge-app/src/pages/Loan/RepayForm.tsx
@@ -99,7 +99,10 @@ function InternalRepayForm({ loan, destination }: { loan: ActiveLoan | CreatedLo
} else if (destination === 'other') {
if (!repayForm.values.category) throw new Error('No category selected')
const decreaseDebtTx = api.tx.loans.decreaseDebt(pool.id, loan.id, { internal: principal })
- const categoryHex = Buffer.from(repayForm.values.category).toString('hex')
+ const encoded = new TextEncoder().encode(repayForm.values.category)
+ const categoryHex = Array.from(encoded)
+ .map((byte) => byte.toString(16).padStart(2, '0'))
+ .join('')
repayTx = cent.remark.remark([[{ Named: categoryHex }], decreaseDebtTx], { batch: true })
} else {
const repay = { principal, interest, unscheduled: amountAdditional }