From 84ae5a110eda2642b5de386ae8862df0deb796f7 Mon Sep 17 00:00:00 2001 From: Czino Date: Wed, 15 Nov 2023 11:29:59 +0100 Subject: [PATCH] Gracefully handle invalid addressIndex type by falling back to new --- android/src/main/java/io/ltbl/bdkrn/BdkRnModule.kt | 4 ++-- ios/BdkRnModule.swift | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/android/src/main/java/io/ltbl/bdkrn/BdkRnModule.kt b/android/src/main/java/io/ltbl/bdkrn/BdkRnModule.kt index fc735ee..ab8954e 100644 --- a/android/src/main/java/io/ltbl/bdkrn/BdkRnModule.kt +++ b/android/src/main/java/io/ltbl/bdkrn/BdkRnModule.kt @@ -395,7 +395,7 @@ class BdkRnModule(reactContext: ReactApplicationContext) : resolvedIndex = (addressIndex as Dynamic).asDouble() ?: "new" } else -> { - result.reject("Invalid address index type", "Address index must be a String or an Int") + resolvedIndex = setAddressIndex("new") } } val addressInfo = getWalletById(id).getAddress(setAddressIndex(resolvedIndex)) @@ -425,7 +425,7 @@ class BdkRnModule(reactContext: ReactApplicationContext) : resolvedIndex = (addressIndex as Dynamic).asDouble() ?: "new" } else -> { - result.reject("Invalid address index type", "Address index must be a String or an Int") + resolvedIndex = setAddressIndex("new") } } val addressInfo = getWalletById(id).getInternalAddress(setAddressIndex(resolvedIndex)) diff --git a/ios/BdkRnModule.swift b/ios/BdkRnModule.swift index c6d6edd..e9ddcd2 100644 --- a/ios/BdkRnModule.swift +++ b/ios/BdkRnModule.swift @@ -501,8 +501,7 @@ class BdkRnModule: NSObject { } else if let indexInt = addressIndex as? Int { resolvedIndex = setAddressIndex(addressIndex: indexInt) } else { - reject("Invalid address index type", "Address index must be a String or an Int", nil) - return + resolvedIndex = setAddressIndex(addressIndex: "new") } let addressInfo = try getWalletById(id: id).getAddress( @@ -530,8 +529,7 @@ class BdkRnModule: NSObject { } else if let indexInt = addressIndex as? Int { resolvedIndex = setAddressIndex(addressIndex: indexInt) } else { - reject("Invalid address index type", "Address index must be a String or an Int", nil) - return + resolvedIndex = setAddressIndex(addressIndex: "new") } let addressInfo = try getWalletById(id: id).getInternalAddress( addressIndex: resolvedIndex