Skip to content

Commit

Permalink
Merge pull request #1723 from novasamatech/fix/junction-binding
Browse files Browse the repository at this point in the history
Hotfix: xcm runtime upgrade + assets balance update
  • Loading branch information
antonijzelinskij authored Nov 19, 2024
2 parents f82b380 + eb61b92 commit 2d4cbaf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
buildscript {
ext {
// App version
versionName = '9.0.0'
versionCode = 158
versionName = '9.0.1'
versionCode = 159

applicationId = "io.novafoundation.nova"
releaseApplicationSuffix = "market"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class BalanceListAdapter(
val item = getItem(position) as TokenAssetUi
resolvePayload(holder, position, payloads) {
when (it) {
AssetModel::amount -> holder.bindTotal(item.asset)
amountExtractor -> holder.bindTotal(item.asset)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,23 @@ private fun bindInterior(instance: Any?): MultiLocation.Interior {

return when (asDictEnum.name) {
"Here" -> MultiLocation.Interior.Here
"X1" -> {
val junction = bindJunction(asDictEnum.value)
MultiLocation.Interior.Junctions(listOf(junction))
}

else -> {
val junctions = bindList(asDictEnum.value, ::bindJunction)
val junctions = bindJunctions(asDictEnum.value)
MultiLocation.Interior.Junctions(junctions)
}
}
}

private fun bindJunctions(instance: Any?): List<Junction> {
// Note that Interior.X1 is encoded differently in XCM v3 (a single junction) and V4 (single-element list)
if (instance is List<*>) {
return bindList(instance, ::bindJunction)
} else {
return listOf(bindJunction(instance))
}
}

private fun bindJunction(instance: Any?): Junction {
val asDictEnum = instance.castToDictEnum()

Expand All @@ -56,6 +62,7 @@ private fun bindJunction(instance: Any?): Junction {
val keyBytes = bindByteArray(asDictEnum.value)
Junction.GeneralKey(keyBytes.toHexString(withPrefix = true))
}

"PalletInstance" -> Junction.PalletInstance(bindNumber(asDictEnum.value))
"Parachain" -> Junction.ParachainId(bindNumber(asDictEnum.value))
"GeneralIndex" -> Junction.GeneralIndex(bindNumber(asDictEnum.value))
Expand All @@ -81,6 +88,7 @@ private fun bindGlobalConsensusJunction(instance: Any?): Junction {
val genesis = bindByteArray(asDictEnum.value).toHexString(withPrefix = false)
Junction.GlobalConsensus(chainId = genesis)
}

"Polkadot" -> Junction.GlobalConsensus(chainId = Chain.Geneses.POLKADOT)
"Kusama" -> Junction.GlobalConsensus(chainId = Chain.Geneses.KUSAMA)
"Westend" -> Junction.GlobalConsensus(chainId = Chain.Geneses.WESTEND)
Expand Down

0 comments on commit 2d4cbaf

Please sign in to comment.