From 011889f51fe5018ecd852dde821617ef7b0e5122 Mon Sep 17 00:00:00 2001 From: roiLeo Date: Wed, 8 Feb 2023 13:18:00 +0100 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=94=A7=20bsx/snek=20balance=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/rmrk/Profile/ProfileAssetsList.vue | 6 ++++-- store/identity.ts | 14 +++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/components/rmrk/Profile/ProfileAssetsList.vue b/components/rmrk/Profile/ProfileAssetsList.vue index 623c3f5275..a02bd796c5 100644 --- a/components/rmrk/Profile/ProfileAssetsList.vue +++ b/components/rmrk/Profile/ProfileAssetsList.vue @@ -84,7 +84,7 @@ const updatedBalanceFor = async (balance: Promise, 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'] @@ -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, diff --git a/store/identity.ts b/store/identity.ts index 7912d30a48..edf899bf5e 100644 --- a/store/identity.ts +++ b/store/identity.ts @@ -75,10 +75,12 @@ async function subscribeTokens( cb: (value: BalanceMap) => void ): UnsubscribePromise { if (api.query.tokens) { - const kusamaTokenId = await api.query.assetRegistry - .assetIds('KSM') - .then((value) => unwrapOrNull(value as Option)) - const realKusamaTokenId = kusamaTokenId ? '5' : '1' + // not working? + // const kusamaTokenId = await api.query.assetRegistry + // .assetIds('KSM') + // .then((value) => unwrapOrNull(value as Option)) + // const realKusamaTokenId = kusamaTokenId ? '5' : '1' + const realKusamaTokenId = '5' return api.query.tokens.accounts.multi( [[address, realKusamaTokenId]], ([ksm]: any[]) => @@ -141,7 +143,7 @@ export const actions = { consola.error('[FETCH IDENTITY] Unable to get identity', e) } }, - fetchBalance( + async fetchBalance( { commit, dispatch, rootState }, { address, apiUrl }: ChangeAddressRequest ) { @@ -152,6 +154,8 @@ export const actions = { tokenSub() return } + + const api = await ApiFactory.useApiInstance(endpoint) onApiConnect(endpoint, async (api) => { try { if (balanceSub) { From f5ce3cfcecc18166b85e8d38bbb55fa13428bf25 Mon Sep 17 00:00:00 2001 From: roiLeo Date: Wed, 8 Feb 2023 13:21:09 +0100 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=94=A7=20bsx/snek=20balance=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- store/identity.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/store/identity.ts b/store/identity.ts index edf899bf5e..299c274635 100644 --- a/store/identity.ts +++ b/store/identity.ts @@ -143,7 +143,7 @@ export const actions = { consola.error('[FETCH IDENTITY] Unable to get identity', e) } }, - async fetchBalance( + fetchBalance( { commit, dispatch, rootState }, { address, apiUrl }: ChangeAddressRequest ) { @@ -155,7 +155,6 @@ export const actions = { return } - const api = await ApiFactory.useApiInstance(endpoint) onApiConnect(endpoint, async (api) => { try { if (balanceSub) { From f39e4db181aa0cc42e656e4c67612d57b182d4ce Mon Sep 17 00:00:00 2001 From: roiLeo Date: Wed, 8 Feb 2023 13:43:15 +0100 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=94=A7=20bsx/snek=20Kusama=20assetIds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- store/identity.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/store/identity.ts b/store/identity.ts index 299c274635..055df420e9 100644 --- a/store/identity.ts +++ b/store/identity.ts @@ -75,12 +75,10 @@ async function subscribeTokens( cb: (value: BalanceMap) => void ): UnsubscribePromise { if (api.query.tokens) { - // not working? - // const kusamaTokenId = await api.query.assetRegistry - // .assetIds('KSM') - // .then((value) => unwrapOrNull(value as Option)) - // const realKusamaTokenId = kusamaTokenId ? '5' : '1' - const realKusamaTokenId = '5' + const kusamaTokenId = await api.query.assetRegistry + .assetIds('Kusama') + .then((value) => unwrapOrNull(value as Option)) + const realKusamaTokenId = kusamaTokenId ? '5' : '1' return api.query.tokens.accounts.multi( [[address, realKusamaTokenId]], ([ksm]: any[]) => From 7b8f337c17de7a3ef169686058c032bdddea81b4 Mon Sep 17 00:00:00 2001 From: roiLeo Date: Wed, 8 Feb 2023 15:05:56 +0100 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=94=A7=20bsx/snek=20Kusama=20pallet?= =?UTF-8?q?=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- store/identity.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/store/identity.ts b/store/identity.ts index 055df420e9..b47550e3d3 100644 --- a/store/identity.ts +++ b/store/identity.ts @@ -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('Kusama') + .assetIds(Number(version) > 82 ? 'Kusama' : 'KSM') .then((value) => unwrapOrNull(value as Option)) const realKusamaTokenId = kusamaTokenId ? '5' : '1' return api.query.tokens.accounts.multi(