From 66879ae3c15a6b48f33cd5f7e9b75dc9739d0e73 Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Mon, 9 Feb 2026 08:47:53 +0300 Subject: [PATCH] feat(staking): prepare for Polkadot 2.0 nomination pools on Asset Hub - ChainExt.kt: Handle nomination-pools without local backing type (Polkadot 2.0) - Add hasLocalNominationPoolsBacking() helper function - Default to RELAYCHAIN when no local backing type exists - StakingDashboardUpdateSystem: Improved error logging - StakingDashboardViewModel: Show toast when item is syncing - Update chains.json: relay chain only has relaychain staking --- common/src/main/res/values/strings.xml | 4 +- .../updaters/StakingDashboardUpdateSystem.kt | 4 +- .../domain/nominationPools/ChainExt.kt | 20 ++- .../main/StakingDashboardViewModel.kt | 8 +- pezkuwi-config/chains.json | 125 ++++++++++++------ 5 files changed, 114 insertions(+), 47 deletions(-) diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 7f0e44f..0887243 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -299,9 +299,6 @@ %s://polkadot/migration-accepted?key=%s access Bluetooth - pezkuwi-wallet.app.link - pezkuwi-wallet-alternate.app.link - Press both buttons on your %s to approve the addresses Press confirm button on your %s to approve the addresses @@ -1438,6 +1435,7 @@ More staking options Stake and earn rewards Staking via Pezkuwi DApp browser + Loading staking info… Waiting / year diff --git a/feature-staking-impl/src/main/java/io/novafoundation/nova/feature_staking_impl/data/dashboard/network/updaters/StakingDashboardUpdateSystem.kt b/feature-staking-impl/src/main/java/io/novafoundation/nova/feature_staking_impl/data/dashboard/network/updaters/StakingDashboardUpdateSystem.kt index 8ba1cce..0ca037f 100644 --- a/feature-staking-impl/src/main/java/io/novafoundation/nova/feature_staking_impl/data/dashboard/network/updaters/StakingDashboardUpdateSystem.kt +++ b/feature-staking-impl/src/main/java/io/novafoundation/nova/feature_staking_impl/data/dashboard/network/updaters/StakingDashboardUpdateSystem.kt @@ -90,8 +90,8 @@ class RealStakingDashboardUpdateSystem( sharedRequestsBuilder.subscribe(accountScope) chainUpdates.mergeIfMultiple() - }.catch { - Log.d("StakingDashboardUpdateSystem", "Failed to sync staking dashboard status for ${stakingChain.name}") + }.catch { e -> + Log.e("StakingDashboardUpdateSystem", "Failed to sync staking dashboard status for ${stakingChain.name}", e) } } diff --git a/feature-staking-impl/src/main/java/io/novafoundation/nova/feature_staking_impl/domain/nominationPools/ChainExt.kt b/feature-staking-impl/src/main/java/io/novafoundation/nova/feature_staking_impl/domain/nominationPools/ChainExt.kt index 785f2df..f95ce3b 100644 --- a/feature-staking-impl/src/main/java/io/novafoundation/nova/feature_staking_impl/domain/nominationPools/ChainExt.kt +++ b/feature-staking-impl/src/main/java/io/novafoundation/nova/feature_staking_impl/domain/nominationPools/ChainExt.kt @@ -2,6 +2,24 @@ package io.novafoundation.nova.feature_staking_impl.domain.nominationPools import io.novafoundation.nova.runtime.multiNetwork.chain.model.Chain +/** + * Finds the staking type that backs nomination pools. + * + * In Polkadot 1.0: Both relaychain and nomination-pools exist on the same chain + * In Polkadot 2.0: nomination-pools may exist on Asset Hub without local backing type + * (backing is via XCM from relay chain) + * + * @return The backing staking type, or RELAYCHAIN as default for Polkadot 2.0 compatibility + */ fun Chain.Asset.findStakingTypeBackingNominationPools(): Chain.Asset.StakingType { - return staking.first { it != Chain.Asset.StakingType.NOMINATION_POOLS } + return staking.firstOrNull { it != Chain.Asset.StakingType.NOMINATION_POOLS } + ?: Chain.Asset.StakingType.RELAYCHAIN // Polkadot 2.0: default to RELAYCHAIN for Asset Hub +} + +/** + * Checks if this asset has nomination pools backed by a local staking type. + * Returns false for Polkadot 2.0 Asset Hub where backing is cross-chain. + */ +fun Chain.Asset.hasLocalNominationPoolsBacking(): Boolean { + return staking.any { it != Chain.Asset.StakingType.NOMINATION_POOLS } } diff --git a/feature-staking-impl/src/main/java/io/novafoundation/nova/feature_staking_impl/presentation/dashboard/main/StakingDashboardViewModel.kt b/feature-staking-impl/src/main/java/io/novafoundation/nova/feature_staking_impl/presentation/dashboard/main/StakingDashboardViewModel.kt index 4523ac3..08d9260 100644 --- a/feature-staking-impl/src/main/java/io/novafoundation/nova/feature_staking_impl/presentation/dashboard/main/StakingDashboardViewModel.kt +++ b/feature-staking-impl/src/main/java/io/novafoundation/nova/feature_staking_impl/presentation/dashboard/main/StakingDashboardViewModel.kt @@ -102,7 +102,13 @@ class StakingDashboardViewModel( fun onNoStakeItemClicked(index: Int) = launch { val withoutStakeItems = stakingDashboardFlow.firstLoaded().withoutStake val withoutStakeItem = withoutStakeItems.getOrNull(index) ?: return@launch - val noStakeItemState = withoutStakeItem.stakingState as? NoStake ?: return@launch + val noStakeItemState = withoutStakeItem.stakingState as? NoStake + + if (noStakeItemState == null) { + // Item is still syncing (NotYetResolved state) + showToast(resourceManager.getString(R.string.staking_dashboard_syncing)) + return@launch + } val stakingTypes = noStakeItemState.flowType.allStakingTypes val chain = withoutStakeItem.chain diff --git a/pezkuwi-config/chains.json b/pezkuwi-config/chains.json index 482875a..fd86b3c 100644 --- a/pezkuwi-config/chains.json +++ b/pezkuwi-config/chains.json @@ -2,7 +2,7 @@ { "chainId": "bb4a61ab0c4b8c12f5eab71d0c86c482e03a275ecdafee678dea712474d33d75", "name": "Pezkuwi", - "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/master/icons/chains/Pezkuwi.png", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/HEZ.png", "addressPrefix": 42, "options": [ "crowdloans", @@ -43,11 +43,10 @@ "name": "Hezkurd", "priceId": "hezkurd", "staking": [ - "relaychain", - "nomination-pools" + "relaychain" ], "type": "native", - "icon": "https://pezkuwichain.io/tokens/HEZ.png", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/HEZ.png", "buyProviders": {}, "sellProviders": {}, "typeExtras": null @@ -62,15 +61,14 @@ { "chainId": "96eb58af1bb7288115b5e4ff1590422533e749293f231974536dc6672417d06f", "name": "Zagros Testnet", - "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/master/icons/chains/Pezkuwi.png", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/HEZ.png", "addressPrefix": 42, "options": [ - "testnet", - "fullSyncByDefault" + "testnet" ], "nodes": [ { - "url": "wss://testnet-rpc.pezkuwichain.io", + "url": "wss://zagros-rpc.pezkuwichain.io", "name": "Zagros Node" } ], @@ -85,7 +83,7 @@ "relaychain" ], "type": "native", - "icon": "https://pezkuwichain.io/tokens/HEZ.png" + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/HEZ.png" } ], "additional": { @@ -98,7 +96,7 @@ "chainId": "00d0e1d0581c3cd5c5768652d52f4520184018b44f56a2ae1e0dc9d65c00c948", "parentId": "bb4a61ab0c4b8c12f5eab71d0c86c482e03a275ecdafee678dea712474d33d75", "name": "Pezkuwi Asset Hub", - "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/master/icons/chains/PezkuwiAssetHub.png", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/PEZ.png", "addressPrefix": 42, "options": [ "swap-hub", @@ -130,9 +128,11 @@ "precision": 12, "name": "Hezkurd", "priceId": "hezkurd", - "staking": null, + "staking": [ + "nomination-pools" + ], "type": "native", - "icon": "https://pezkuwichain.io/tokens/HEZ.png", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/HEZ.png", "buyProviders": {}, "sellProviders": {}, "typeExtras": null @@ -145,7 +145,7 @@ "priceId": "pezkuwi", "staking": null, "type": "statemine", - "icon": "https://pezkuwichain.io/tokens/PEZ.png", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/PEZ.png", "buyProviders": {}, "sellProviders": {}, "typeExtras": { @@ -160,12 +160,57 @@ "priceId": "tether", "staking": null, "type": "statemine", - "icon": "https://pezkuwichain.io/tokens/wUSDT.png", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "buyProviders": {}, "sellProviders": {}, "typeExtras": { "assetId": "1000" } + }, + { + "assetId": 1001, + "symbol": "DOT", + "precision": 10, + "name": "Polkadot", + "priceId": "polkadot", + "staking": null, + "type": "statemine", + "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/DOT.svg", + "buyProviders": {}, + "sellProviders": {}, + "typeExtras": { + "assetId": "1001" + } + }, + { + "assetId": 1002, + "symbol": "ETH", + "precision": 18, + "name": "Ethereum", + "priceId": "ethereum", + "staking": null, + "type": "statemine", + "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/ETH.svg", + "buyProviders": {}, + "sellProviders": {}, + "typeExtras": { + "assetId": "1002" + } + }, + { + "assetId": 1003, + "symbol": "BTC", + "precision": 8, + "name": "Bitcoin", + "priceId": "bitcoin", + "staking": null, + "type": "statemine", + "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/WBTC.svg", + "buyProviders": {}, + "sellProviders": {}, + "typeExtras": { + "assetId": "1003" + } } ], "additional": { @@ -179,7 +224,7 @@ "chainId": "58269e9c184f721e0309332d90cafc410df1519a5dc27a5fd9b3bf5fd2d129f8", "parentId": "bb4a61ab0c4b8c12f5eab71d0c86c482e03a275ecdafee678dea712474d33d75", "name": "Pezkuwi People", - "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/master/icons/chains/PezkuwiPeople.png", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/chains/PezkuwiPeople.png", "addressPrefix": 42, "options": [ "proxy", @@ -211,7 +256,7 @@ "priceId": "hezkurd", "staking": null, "type": "native", - "icon": "https://pezkuwichain.io/tokens/HEZ.png", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/HEZ.png", "buyProviders": {}, "sellProviders": {}, "typeExtras": null @@ -560,7 +605,7 @@ "precision": 6, "priceId": "tether", "type": "statemine", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "assetId": "1984" } @@ -943,7 +988,7 @@ "precision": 6, "priceId": "tether", "type": "orml", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "currencyIdScale": "0x050700", "currencyIdType": "acala_primitives.currency.CurrencyId", @@ -1234,7 +1279,7 @@ "precision": 6, "type": "statemine", "priceId": "tether", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "assetId": "311091173110107856861649819128533077277" } @@ -1645,7 +1690,7 @@ "precision": 6, "priceId": "tether", "type": "statemine", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "assetId": "311091173110107856861649819128533077277" } @@ -2005,7 +2050,7 @@ "precision": 6, "type": "statemine", "priceId": "tether", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "assetId": "4294969280" } @@ -2183,7 +2228,7 @@ "precision": 6, "priceId": "tether", "type": "orml", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "currencyIdScale": "0x0800", "currencyIdType": "bifrost_primitives.currency.CurrencyId", @@ -2381,7 +2426,7 @@ "precision": 6, "type": "orml", "priceId": "tether", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "currencyIdScale": "0x0e000000", "currencyIdType": "u32", @@ -2610,7 +2655,7 @@ "precision": 6, "priceId": "tether", "type": "statemine", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "assetId": "102" } @@ -3048,7 +3093,7 @@ "precision": 6, "priceId": "tether", "type": "statemine", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "assetId": "14" } @@ -3437,7 +3482,7 @@ "precision": 6, "type": "orml", "priceId": "tether", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "currencyIdScale": "0x050c00", "currencyIdType": "acala_primitives.currency.CurrencyId", @@ -3638,7 +3683,7 @@ "precision": 6, "type": "statemine", "priceId": "tether", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "assetId": "4294969280" } @@ -3888,7 +3933,7 @@ "precision": 6, "priceId": "tether", "type": "statemine", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "assetId": "102" } @@ -4010,7 +4055,7 @@ "precision": 6, "priceId": "tether", "type": "statemine", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "assetId": "1984" } @@ -4391,7 +4436,7 @@ "precision": 6, "priceId": "tether", "type": "orml", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "currencyIdScale": "0x0103000000", "currencyIdType": "interbtc_primitives.CurrencyId", @@ -4483,7 +4528,7 @@ "symbol": "qUSDT", "precision": 6, "type": "orml", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "currencyIdScale": "0x0203000000", "currencyIdType": "interbtc_primitives.CurrencyId", @@ -4566,7 +4611,7 @@ "precision": 6, "priceId": "tether", "type": "orml", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "currencyIdScale": "0x82000000000000000000000000000000", "currencyIdType": "u128", @@ -4996,7 +5041,7 @@ "precision": 6, "priceId": "tether", "type": "orml", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "currencyIdScale": "0x0a000000", "currencyIdType": "u32", @@ -5631,7 +5676,7 @@ "symbol": "USDT", "precision": 6, "priceId": "tether", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "type": "orml", "typeExtras": { "currencyIdScale": "0x0102000000", @@ -5696,7 +5741,7 @@ "assetId": 12, "symbol": "qUSDT", "precision": 6, - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "type": "orml", "typeExtras": { "currencyIdScale": "0x0203000000", @@ -6101,7 +6146,7 @@ "precision": 12, "priceId": "tether", "type": "statemine", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "assetId": "3496813586714279103986568049643838918" } @@ -6322,7 +6367,7 @@ "precision": 6, "priceId": "tether", "type": "orml", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "currencyIdScale": "0x0802", "currencyIdType": "bifrost_primitives.currency.CurrencyId", @@ -6902,7 +6947,7 @@ "precision": 6, "priceId": "tether", "type": "orml", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "currencyIdScale": "0x0101", "currencyIdType": "spacewalk_primitives.CurrencyId", @@ -7269,7 +7314,7 @@ "precision": 6, "priceId": "tether", "type": "orml", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "typeExtras": { "currencyIdScale": "0x0101", "currencyIdType": "spacewalk_primitives.CurrencyId", @@ -8556,7 +8601,7 @@ "symbol": "USDT", "precision": 6, "priceId": "tether", - "icon": "https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/USDT.svg", + "icon": "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/main/icons/tokens/wUSDT.png", "type": "statemine", "typeExtras": { "assetId": "1984",