File tree 5 files changed +43
-6
lines changed
common/src/main/java/jp/co/soramitsu/common
runtime/src/main/java/jp/co/soramitsu/runtime/network/rpc
5 files changed +43
-6
lines changed Original file line number Diff line number Diff line change 1
1
buildscript {
2
2
ext {
3
3
// App version
4
- versionName = ' 2.0.12 '
5
- versionCode = 73
4
+ versionName = ' 2.0.13 '
5
+ versionCode = 74
6
6
7
7
// SDK and tools
8
8
compileSdkVersion = 31
Original file line number Diff line number Diff line change @@ -3,6 +3,6 @@ package jp.co.soramitsu.common.data.network.runtime.calls
3
3
import jp.co.soramitsu.fearless_utils.wsrpc.request.runtime.RuntimeRequest
4
4
5
5
class FeeCalculationRequest (extrinsicInHex : String ) : RuntimeRequest(
6
- method = " payment_queryInfo " ,
6
+ method = " payment_queryFeeDetails " ,
7
7
params = listOf(extrinsicInHex)
8
8
)
Original file line number Diff line number Diff line change 1
1
package jp.co.soramitsu.common.data.network.runtime.model
2
2
3
3
import java.math.BigInteger
4
+ import jp.co.soramitsu.fearless_utils.extensions.fromHex
5
+ import jp.co.soramitsu.fearless_utils.extensions.fromUnsignedBytes
6
+ import jp.co.soramitsu.fearless_utils.extensions.requireHexPrefix
4
7
5
8
// todo there were a field which caused an errors:
6
9
// val weight: Long
@@ -11,6 +14,33 @@ import java.math.BigInteger
11
14
// "class":"normal",
12
15
// "partialFee":"15407544760"
13
16
// }
17
+
14
18
class FeeResponse (
15
- val partialFee : BigInteger
19
+ val inclusionFee : InclusionFee
16
20
)
21
+
22
+ class InclusionFee (
23
+ private val baseFee : String? ,
24
+ private val lenFee : String? ,
25
+ private val adjustedWeightFee : String? ,
26
+ ) {
27
+ val sum: BigInteger
28
+ get() = baseFee.decodeBigInt() + lenFee.decodeBigInt() + adjustedWeightFee.decodeBigInt()
29
+
30
+ private fun String?.decodeBigInt (): BigInteger {
31
+ // because substrate returns hexes with different length:
32
+ // 0x3b9aca00
33
+ // 0x3486ced00
34
+ // 0xb320334
35
+ if (this == null ) return BigInteger .ZERO
36
+ return if (this .length.isEven.not ()) {
37
+ val withoutPrefix = removePrefix(" 0x" )
38
+ " 0$withoutPrefix " .requireHexPrefix()
39
+ } else {
40
+ this
41
+ }.fromHex().fromUnsignedBytes()
42
+ }
43
+
44
+ private val Int .isEven: Boolean
45
+ get() = this % 2 == 0
46
+ }
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package jp.co.soramitsu.common.utils
2
2
3
3
import android.content.Context
4
4
import android.text.format.DateUtils
5
+ import android.util.Log
5
6
import java.math.BigDecimal
6
7
import java.math.RoundingMode
7
8
import java.text.DecimalFormat
@@ -83,7 +84,13 @@ fun Long.formatDaysSinceEpoch(context: Context): String? {
83
84
val currentDays = System .currentTimeMillis().daysFromMillis()
84
85
val diff = currentDays - this
85
86
86
- if (diff < 0 ) throw IllegalArgumentException (" Past date should be less than current" )
87
+ if (diff < 0 ) {
88
+ Log .e(
89
+ " jp.co.soramitsu.common.utils.NumberFormattersKt.formatDaysSinceEpoch" ,
90
+ " Error: diff < 0: " ,
91
+ IllegalArgumentException (" Past date should be less than current" )
92
+ )
93
+ }
87
94
88
95
return when (diff) {
89
96
0L -> context.getString(R .string.today)
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ class RpcCalls(
110
110
111
111
val feeResponse = socketFor(chainId).executeAsync(request, mapper = pojo<FeeResponse >().nonNull())
112
112
113
- return feeResponse.partialFee
113
+ return feeResponse.inclusionFee.sum
114
114
}
115
115
116
116
suspend fun submitExtrinsic (chainId : ChainId , extrinsic : String ): String {
You can’t perform that action at this time.
0 commit comments