From a4af73352a5c02b89ceeabb3bd7d4e69287613cc Mon Sep 17 00:00:00 2001 From: Ross Savage <551697+dangeross@users.noreply.github.com> Date: Thu, 27 Jun 2024 13:07:41 +0200 Subject: [PATCH] Fix handling of f32 type (#336) --- lib/bindings/langs/react-native/src/gen_kotlin/mod.rs | 2 +- .../langs/react-native/src/gen_kotlin/templates/Helpers.kt | 1 + .../src/main/java/com/breezliquidsdk/BreezLiquidSDKMapper.kt | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/bindings/langs/react-native/src/gen_kotlin/mod.rs b/lib/bindings/langs/react-native/src/gen_kotlin/mod.rs index 0eaf099..3000442 100644 --- a/lib/bindings/langs/react-native/src/gen_kotlin/mod.rs +++ b/lib/bindings/langs/react-native/src/gen_kotlin/mod.rs @@ -212,7 +212,7 @@ pub mod filters { Type::Int32 => format!("{name}.getInt(\"{field_name}\")"), Type::UInt64 => format!("{name}.getDouble(\"{field_name}\").toULong()"), Type::Int64 => format!("{name}.getDouble(\"{field_name}\").toLong()"), - Type::Float32 => format!("{name}.getDouble(\"{field_name}\")"), + Type::Float32 => format!("{name}.getDouble(\"{field_name}\").toFloat()"), Type::Float64 => format!("{name}.getDouble(\"{field_name}\")"), Type::Boolean => format!("{name}.getBoolean(\"{field_name}\")"), Type::String => format!("{name}.getString(\"{field_name}\"){mandatory_suffix}"), diff --git a/lib/bindings/langs/react-native/src/gen_kotlin/templates/Helpers.kt b/lib/bindings/langs/react-native/src/gen_kotlin/templates/Helpers.kt index 7be9f00..2a115ff 100644 --- a/lib/bindings/langs/react-native/src/gen_kotlin/templates/Helpers.kt +++ b/lib/bindings/langs/react-native/src/gen_kotlin/templates/Helpers.kt @@ -36,6 +36,7 @@ fun pushToMap(map: WritableMap, key: String, value: Any?) { is Boolean -> map.putBoolean(key, value) is Byte -> map.putInt(key, value.toInt()) is Double -> map.putDouble(key, value) + is Float -> map.putDouble(key, value.toDouble()) is Int -> map.putInt(key, value) is Long -> map.putDouble(key, value.toDouble()) is ReadableArray -> map.putArray(key, value) diff --git a/packages/react-native/android/src/main/java/com/breezliquidsdk/BreezLiquidSDKMapper.kt b/packages/react-native/android/src/main/java/com/breezliquidsdk/BreezLiquidSDKMapper.kt index c59caa7..b2af96f 100644 --- a/packages/react-native/android/src/main/java/com/breezliquidsdk/BreezLiquidSDKMapper.kt +++ b/packages/react-native/android/src/main/java/com/breezliquidsdk/BreezLiquidSDKMapper.kt @@ -134,7 +134,7 @@ fun asConfig(config: ReadableMap): Config? { val workingDir = config.getString("workingDir")!! val network = config.getString("network")?.let { asLiquidNetwork(it) }!! val paymentTimeoutSec = config.getDouble("paymentTimeoutSec").toULong() - val zeroConfMinFeeRate = config.getDouble("zeroConfMinFeeRate") + val zeroConfMinFeeRate = config.getDouble("zeroConfMinFeeRate").toFloat() val zeroConfMaxAmountSat = if (hasNonNullKey( config, @@ -2331,6 +2331,7 @@ fun pushToMap( is Boolean -> map.putBoolean(key, value) is Byte -> map.putInt(key, value.toInt()) is Double -> map.putDouble(key, value) + is Float -> map.putDouble(key, value.toDouble()) is Int -> map.putInt(key, value) is Long -> map.putDouble(key, value.toDouble()) is ReadableArray -> map.putArray(key, value)