Skip to content

Commit

Permalink
Merge pull request #4945 from roiLeo/fix/bsx/balance
Browse files Browse the repository at this point in the history
🔧 bsx/snek balance issue
  • Loading branch information
vikiival authored Feb 9, 2023
2 parents 30fef10 + 985d5ae commit 4ca7282
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions components/rmrk/Profile/ProfileAssetsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const updatedBalanceFor = async (balance: Promise<string>, index: number) => {
const assetToUsdValue = (asset: AssetItem) => {
if (asset.symbol === 'KSM') {
let value = checkInvalidBalanceFilter(asset.balance)
value = roundTo(formatBalance(value, 12, ''), 4)
value = roundTo(formatBalance(value, 12, ''), 4).replace(',', '.')
return calculateExactUsdFromToken(
value,
$store.getters['fiat/getCurrentKSMValue']
Expand All @@ -93,7 +93,9 @@ const assetToUsdValue = (asset: AssetItem) => {
if (asset.symbol === 'BSX') {
let value = checkInvalidBalanceFilter(asset.balance)
value = checkInvalidBalanceFilter(
roundTo(formatBalance(value, 12, ''), 4).replace(',', '')
roundTo(formatBalance(value, 12, ''), 4)
.replace(',', '')
.replace(/\s/g, '')
)
return calculateExactUsdFromToken(
value,
Expand Down
6 changes: 5 additions & 1 deletion store/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ async function subscribeTokens(
cb: (value: BalanceMap) => void
): UnsubscribePromise {
if (api.query.tokens) {
const version = await api.query.system
.lastRuntimeUpgrade()
.then((value) => unwrapOrNull(value)?.specVersion.toNumber())
const kusamaTokenId = await api.query.assetRegistry
.assetIds('KSM')
.assetIds(Number(version) > 82 ? 'Kusama' : 'KSM')
.then((value) => unwrapOrNull(value as Option<u32>))
const realKusamaTokenId = kusamaTokenId ? '5' : '1'
return api.query.tokens.accounts.multi(
Expand Down Expand Up @@ -152,6 +155,7 @@ export const actions = {
tokenSub()
return
}

onApiConnect(endpoint, async (api) => {
try {
if (balanceSub) {
Expand Down

0 comments on commit 4ca7282

Please sign in to comment.