Skip to content

Commit

Permalink
fix currencies formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
onnovisser committed Sep 15, 2023
1 parent 494eb96 commit e3d1a25
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions centrifuge-js/src/modules/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ export function getPoolsModule(inst: Centrifuge) {
api.query.ormlAssetRegistry.metadata(currency).pipe(
take(1),
switchMap((rawCurrencyMeta) => {
const currencyMeta = rawCurrencyMeta.toHuman() as AssetCurrencyData
const currencyMeta = rawCurrencyMeta.toPrimitive() as AssetCurrencyData
return pinPoolMetadata(metadata, poolId, currencyMeta.decimals, options)
}),
switchMap((pinnedMetadata) => {
Expand Down Expand Up @@ -1760,12 +1760,13 @@ export function getPoolsModule(inst: Centrifuge) {
switchMap((api) =>
api.query.poolSystem.pool(poolId).pipe(
switchMap((rawPool) => {
const pool = rawPool.toHuman() as any
return api.query.ormlAssetRegistry.metadata(pool.currency).pipe(
const pool = rawPool.toPrimitive() as any
const curKey = parseCurrencyKey(pool.currency)
return api.query.ormlAssetRegistry.metadata(curKey).pipe(
map((rawCurrencyMeta) => {
const value = rawCurrencyMeta.toHuman() as AssetCurrencyData
const value = rawCurrencyMeta.toPrimitive() as AssetCurrencyData
const currency: CurrencyMetadata = {
key: pool.currency,
key: curKey,
decimals: value.decimals,
name: value.name,
symbol: value.symbol,
Expand Down Expand Up @@ -2137,8 +2138,8 @@ export function getPoolsModule(inst: Centrifuge) {
switchMap((api) => api.query.ormlAssetRegistry.metadata.entries()),
map((rawMetas) => {
const metas = rawMetas.map(([rawKey, rawValue]) => {
const key = parseCurrencyKey((rawKey.toHuman() as any)[0] as CurrencyKey)
const value = rawValue.toHuman() as AssetCurrencyData
const key = parseCurrencyKey((rawKey.toHuman() as any)[0])
const value = rawValue.toPrimitive() as AssetCurrencyData
const currency: CurrencyMetadata = {
key,
decimals: value.decimals,
Expand Down Expand Up @@ -2360,7 +2361,7 @@ export function getPoolsModule(inst: Centrifuge) {
api.query.priceOracle.values.entries(),
api.query.interestAccrual.rates(),
api.query.interestAccrual.lastUpdated(),
api.query.ormlAssetRegistry.metadata((poolValue.toHuman() as any).currency),
api.query.ormlAssetRegistry.metadata((poolValue.toPrimitive() as any).currency),
]).pipe(take(1))
}),
map(
Expand All @@ -2373,7 +2374,7 @@ export function getPoolsModule(inst: Centrifuge) {
interestLastUpdated,
rawCurrency,
]) => {
const currency = rawCurrency.toHuman() as AssetCurrencyData
const currency = rawCurrency.toPrimitive() as AssetCurrencyData
const rates = rateValues.toPrimitive() as InterestAccrual[]

const oraclePrices: Record<
Expand Down

0 comments on commit e3d1a25

Please sign in to comment.