Skip to content

Commit

Permalink
Fix build for android (#445)
Browse files Browse the repository at this point in the history
Co-authored-by: Wojciech Szymczyk <[email protected]>
  • Loading branch information
DelevoXDG and THenry14 authored Mar 20, 2024
1 parent 2131ce4 commit d28b008
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'org.bouncycastle:bcprov-jdk18on:1.76'
implementation("com.squareup.okhttp3:okhttp:4.11.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
implementation 'org.bouncycastle:bcprov-jdk18on:1.77'
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1'
implementation 'org.jetbrains.kotlin:kotlin-reflect:1.9.23'
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import java.util.*

internal object NativeLoader {
private val operatingSystem: SystemType by lazy {
val system = System.getProperty("os.name", "generic").lowercase(Locale.ENGLISH)
val system = System.getProperty("os.name", "generic")?.lowercase(Locale.ENGLISH) ?: throw UnknownOS()
when {
system.contains("mac") || system.contains("darwin") -> SystemType.MacOS
system.contains("win") -> SystemType.Windows
Expand Down Expand Up @@ -57,6 +57,8 @@ internal object NativeLoader {
class UnsupportedPlatform(system: String, architecture: String) :
RuntimeException("Unsupported platfrom $system:$architecture")

class UnknownOS : RuntimeException("Failed to fetch OS name")

private fun getLibPath(system: SystemType, architecture: String, name: String): String {
return when (system) {
SystemType.MacOS -> "/darwin/$name.dylib"
Expand Down
6 changes: 3 additions & 3 deletions lib/src/main/kotlin/com/swmansion/starknet/data/TypedData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -331,23 +331,23 @@ data class TypedData private constructor(
private fun boolFromPrimitive(primitive: JsonPrimitive): Felt {
val felt = feltFromPrimitive(primitive, allowBoolean = true, allowShortString = false)

require(felt.value < BigInteger.TWO) { "Expected boolean value, got [$primitive]." }
require(felt.value < BigInteger.valueOf(2)) { "Expected boolean value, got [$primitive]." }

return felt
}

private fun u128fromPrimitive(primitive: JsonPrimitive): Felt {
val felt = feltFromPrimitive(primitive, allowShortString = false)

require(felt.value < BigInteger.TWO.pow(128)) { "Value [$primitive] is out of range for '${BasicType.U128.name}'." }
require(felt.value < BigInteger.valueOf(2).pow(128)) { "Value [$primitive] is out of range for '${BasicType.U128.name}'." }

return felt
}

private fun i128fromPrimitive(primitive: JsonPrimitive): Felt {
val felt = feltFromPrimitive(primitive, allowSigned = true, allowShortString = false)

require(felt.value < BigInteger.TWO.pow(127) || felt.value >= Felt.PRIME - BigInteger.TWO.pow(127)) { "Value [$primitive] is out of range for '${BasicType.I128.name}'." }
require(felt.value < BigInteger.valueOf(2).pow(127) || felt.value >= Felt.PRIME - BigInteger.valueOf(2).pow(127)) { "Value [$primitive] is out of range for '${BasicType.I128.name}'." }

return felt
}
Expand Down

0 comments on commit d28b008

Please sign in to comment.