Skip to content

Commit 25e8c6d

Browse files
committed
add toString() to non-data class SolType
1 parent 2bffe0f commit 25e8c6d

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

  • etherspace-java/src/main/java/cc/etherspace

etherspace-java/src/main/java/cc/etherspace/Types.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
package cc.etherspace
44

5+
import org.web3j.utils.Numeric
56
import java.math.BigInteger
67
import java.util.*
78

@@ -25,6 +26,10 @@ sealed class SolNumber(val value: BigInteger, val bits: Int, val unsigned: Boole
2526
result = 31 * result + bits
2627
return result
2728
}
29+
30+
override fun toString(): String {
31+
return "SolNumber(value=$value, bits=$bits, unsigned=$unsigned)"
32+
}
2833
}
2934

3035
sealed class SolInt(value: BigInteger, bits: Int) : SolNumber(value, bits, false)
@@ -344,6 +349,10 @@ sealed class SolBytes(val value: ByteArray, val size: Int) : SolType {
344349
result = 31 * result + size
345350
return result
346351
}
352+
353+
override fun toString(): String {
354+
return "SolBytes(value=${Numeric.toHexString(value)}, size=$size)"
355+
}
347356
}
348357

349358
class SolBytes2(value: ByteArray) : SolBytes(value, 2)
@@ -395,6 +404,10 @@ sealed class SolFixedArray<T>(val value: Array<T>) : SolType {
395404
override fun hashCode(): Int {
396405
return Arrays.hashCode(value)
397406
}
407+
408+
override fun toString(): String {
409+
return "SolFixedArray(value=${Arrays.toString(value)})"
410+
}
398411
}
399412

400413
class SolArray1<T>(value: Array<T>) : SolFixedArray<T>(value)

0 commit comments

Comments
 (0)