Skip to content

Commit

Permalink
Merge pull request #18 from lvaccaro/Possibly-fix-applyUpdate-crash
Browse files Browse the repository at this point in the history
Update LwkRnModule.swift
  • Loading branch information
lvaccaro authored Dec 14, 2024
2 parents 25f2f1b + 3baa12c commit 2ab84c4
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions ios/LwkRnModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,36 @@ class LwkRnModule: NSObject {
}
@objc
func applyUpdate(_
wolletId: String,
updateId: String,
resolve: RCTPromiseResolveBlock,
reject: RCTPromiseRejectBlock
wolletId: String,
updateId: String,
resolve: RCTPromiseResolveBlock,
reject: RCTPromiseRejectBlock
) -> Void {
guard let wollet = _wollets[wolletId] else {
reject("WALLET_NOT_FOUND",
"Wallet with ID \(wolletId) not found",
NSError(domain: "WalletError",
code: -1,
userInfo: ["walletId": wolletId]))
return
}

guard let update = _updates[updateId] else {
reject("UPDATE_NOT_FOUND",
"Update with ID \(updateId) not found",
NSError(domain: "UpdateError",
code: -2,
userInfo: ["updateId": updateId]))
return
}

do {
let wollet = _wollets[wolletId]
let update = _updates[updateId]
try wollet!.applyUpdate(update: update!)
try wollet.applyUpdate(update: update)
resolve(nil)
} catch {
reject("Wollet applyUpdate error", error.localizedDescription, error)
reject("UPDATE_FAILED",
"Failed to apply update: \(error.localizedDescription)",
error)
}
}

Expand Down

0 comments on commit 2ab84c4

Please sign in to comment.