Skip to content

Commit

Permalink
Gracefully handle invalid addressIndex type by falling back to new
Browse files Browse the repository at this point in the history
  • Loading branch information
Czino committed Nov 15, 2023
1 parent 4f47402 commit 84ae5a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions android/src/main/java/io/ltbl/bdkrn/BdkRnModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down
6 changes: 2 additions & 4 deletions ios/BdkRnModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 84ae5a1

Please sign in to comment.