mirror of
https://github.com/pezkuwichain/pezkuwi-wallet-android.git
synced 2026-06-14 05:11:06 +00:00
Prepare for Play Store release: simplify dashboard, clean debug logs
- Simplify dashboard card: remove referral/staking/perwerde fields (not yet on-chain), keep roles + trust score + action button - Remove all debug Log.d/e/w calls added during development (PEZ_STAKE, RuntimeFactory, ExtrinsicBuilder, etc.) - Change Play Store track from beta to production - Add release notes (whatsnew-en-US)
This commit is contained in:
+1
-4
@@ -4,8 +4,5 @@ import java.math.BigInteger
|
||||
|
||||
data class PezkuwiDashboardData(
|
||||
val roles: List<String>,
|
||||
val trustScore: BigInteger,
|
||||
val totalReferrals: Int,
|
||||
val stakedAmount: BigInteger,
|
||||
val perwerdePoints: Int
|
||||
val trustScore: BigInteger
|
||||
)
|
||||
|
||||
+1
-70
@@ -1,15 +1,12 @@
|
||||
package io.novafoundation.nova.feature_assets.data.repository
|
||||
|
||||
import io.novafoundation.nova.common.data.network.runtime.binding.bindInt
|
||||
import io.novafoundation.nova.common.data.network.runtime.binding.bindNumber
|
||||
import io.novafoundation.nova.common.data.network.runtime.binding.castToDictEnum
|
||||
import io.novafoundation.nova.common.data.network.runtime.binding.castToList
|
||||
import io.novafoundation.nova.common.data.network.runtime.binding.castToStruct
|
||||
import io.novafoundation.nova.feature_assets.data.model.PezkuwiDashboardData
|
||||
import io.novafoundation.nova.runtime.ext.ChainGeneses
|
||||
import io.novafoundation.nova.runtime.storage.source.StorageDataSource
|
||||
import io.novasama.substrate_sdk_android.runtime.AccountId
|
||||
import io.novasama.substrate_sdk_android.runtime.definitions.types.composite.DictEnum
|
||||
import io.novasama.substrate_sdk_android.runtime.metadata.moduleOrNull
|
||||
import io.novasama.substrate_sdk_android.runtime.metadata.storage
|
||||
import java.math.BigInteger
|
||||
@@ -23,16 +20,10 @@ class PezkuwiDashboardRepository(
|
||||
|
||||
val roles = queryRoles(chainId, accountId)
|
||||
val trustScore = queryTrustScore(chainId, accountId)
|
||||
val totalReferrals = queryReferrals(chainId, accountId)
|
||||
val stakedAmount = queryStakedAmount(chainId, accountId)
|
||||
val perwerdePoints = queryPerwerdePoints(chainId, accountId)
|
||||
|
||||
return PezkuwiDashboardData(
|
||||
roles = roles,
|
||||
trustScore = trustScore,
|
||||
totalReferrals = totalReferrals,
|
||||
stakedAmount = stakedAmount,
|
||||
perwerdePoints = perwerdePoints
|
||||
trustScore = trustScore
|
||||
)
|
||||
}
|
||||
|
||||
@@ -56,64 +47,4 @@ class PezkuwiDashboardRepository(
|
||||
})
|
||||
}
|
||||
}.getOrDefault(BigInteger.ZERO)
|
||||
|
||||
private suspend fun queryReferrals(chainId: String, accountId: AccountId): Int = runCatching {
|
||||
remoteStorageDataSource.query(chainId) {
|
||||
val referralModule = runtime.metadata.moduleOrNull("Referral") ?: return@query 0
|
||||
referralModule.storage("ReferrerStatsStorage").query(accountId, binding = { decoded ->
|
||||
decoded?.castToStruct()?.let { struct ->
|
||||
bindInt(struct["total_referrals"])
|
||||
} ?: 0
|
||||
})
|
||||
}
|
||||
}.getOrDefault(0)
|
||||
|
||||
private suspend fun queryStakedAmount(chainId: String, accountId: AccountId): BigInteger = runCatching {
|
||||
remoteStorageDataSource.query(chainId) {
|
||||
val stakingModule = runtime.metadata.moduleOrNull("StakingScore") ?: return@query BigInteger.ZERO
|
||||
|
||||
val relayChainKey = DictEnum.Entry("RelayChain", null)
|
||||
val assetHubKey = DictEnum.Entry("AssetHub", null)
|
||||
|
||||
val relayStaked = runCatching {
|
||||
stakingModule.storage("CachedStakingDetails").query(accountId, relayChainKey, binding = { decoded ->
|
||||
decoded?.castToStruct()?.let { struct ->
|
||||
bindNumber(struct["staked_amount"])
|
||||
} ?: BigInteger.ZERO
|
||||
})
|
||||
}.getOrDefault(BigInteger.ZERO)
|
||||
|
||||
val assetHubStaked = runCatching {
|
||||
stakingModule.storage("CachedStakingDetails").query(accountId, assetHubKey, binding = { decoded ->
|
||||
decoded?.castToStruct()?.let { struct ->
|
||||
bindNumber(struct["staked_amount"])
|
||||
} ?: BigInteger.ZERO
|
||||
})
|
||||
}.getOrDefault(BigInteger.ZERO)
|
||||
|
||||
relayStaked.add(assetHubStaked)
|
||||
}
|
||||
}.getOrDefault(BigInteger.ZERO)
|
||||
|
||||
private suspend fun queryPerwerdePoints(chainId: String, accountId: AccountId): Int = runCatching {
|
||||
remoteStorageDataSource.query(chainId) {
|
||||
val perwerdeModule = runtime.metadata.moduleOrNull("Perwerde") ?: return@query 0
|
||||
|
||||
val courseIds = perwerdeModule.storage("StudentCourses").query(accountId, binding = { decoded ->
|
||||
decoded?.castToList()?.map { bindInt(it) } ?: emptyList()
|
||||
})
|
||||
|
||||
if (courseIds.isEmpty()) return@query 0
|
||||
|
||||
courseIds.sumOf { courseId ->
|
||||
runCatching {
|
||||
perwerdeModule.storage("Enrollments").query(courseId, accountId, binding = { decoded ->
|
||||
decoded?.castToStruct()?.let { struct ->
|
||||
bindInt(struct["points_earned"])
|
||||
} ?: 0
|
||||
})
|
||||
}.getOrDefault(0)
|
||||
}
|
||||
}
|
||||
}.getOrDefault(0)
|
||||
}
|
||||
|
||||
+1
-4
@@ -228,10 +228,7 @@ class BalanceListViewModel(
|
||||
.map { data ->
|
||||
PezkuwiDashboardModel(
|
||||
roles = data.roles,
|
||||
trustScore = data.trustScore.toString(),
|
||||
referralPoints = data.totalReferrals.toString(),
|
||||
stakingPoints = data.stakedAmount.toString(),
|
||||
perwerdePoints = data.perwerdePoints.toString()
|
||||
trustScore = data.trustScore.toString()
|
||||
)
|
||||
}
|
||||
.getOrNull()
|
||||
|
||||
+1
-4
@@ -2,8 +2,5 @@ package io.novafoundation.nova.feature_assets.presentation.balance.list.model
|
||||
|
||||
data class PezkuwiDashboardModel(
|
||||
val roles: List<String>,
|
||||
val trustScore: String,
|
||||
val referralPoints: String,
|
||||
val stakingPoints: String,
|
||||
val perwerdePoints: String
|
||||
val trustScore: String
|
||||
)
|
||||
|
||||
-3
@@ -58,9 +58,6 @@ class PezkuwiDashboardHolder(
|
||||
fun bind(model: PezkuwiDashboardModel) {
|
||||
bindRoles(model.roles)
|
||||
binder.pezkuwiDashboardTrustValue.text = model.trustScore
|
||||
binder.pezkuwiDashboardReferralValue.text = model.referralPoints
|
||||
binder.pezkuwiDashboardStakingValue.text = model.stakingPoints
|
||||
binder.pezkuwiDashboardPerwerdeValue.text = model.perwerdePoints
|
||||
}
|
||||
|
||||
private fun bindRoles(roles: List<String>) {
|
||||
|
||||
@@ -37,106 +37,23 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
android:text="@string/pezkuwi_dashboard_trust_score"
|
||||
android:textColor="#B0BEC5"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/pezkuwi_dashboard_trust_score"
|
||||
android:textColor="#B0BEC5"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pezkuwiDashboardTrustValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
<TextView
|
||||
android:id="@+id/pezkuwiDashboardTrustValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/pezkuwi_dashboard_referral"
|
||||
android:textColor="#B0BEC5"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pezkuwiDashboardReferralValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/pezkuwi_dashboard_staking"
|
||||
android:textColor="#B0BEC5"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pezkuwiDashboardStakingValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/pezkuwi_dashboard_perwerde"
|
||||
android:textColor="#B0BEC5"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pezkuwiDashboardPerwerdeValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
android:layout_marginTop="2dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
|
||||
Reference in New Issue
Block a user