Skip to content

Commit dd22f0a

Browse files
author
Erfan Shekarchi
committed
corected getAccount
1 parent f26bac3 commit dd22f0a

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

ios/Fula.swift

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,15 +1372,25 @@ class FulaModule: NSObject {
13721372

13731373

13741374
@objc(getAccount:withRejecter:)
1375-
func getAccount(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
1376-
do {
1377-
let account = try self.fula!.getAccount()
1378-
let accountString = String(data: account, encoding: .utf8)
1379-
resolve(accountString)
1380-
} catch let error {
1381-
reject("ERR_FULA", "getAccount: \(error.localizedDescription)", error)
1382-
}
1383-
}
1375+
func getAccount(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
1376+
guard let fulaClient = self.fula else {
1377+
let error = NSError(domain: "FulaModuleError", code: -1, userInfo: [NSLocalizedDescriptionKey: "Fula client is not initialized"])
1378+
reject("ERR_FULA_NOT_INITIALIZED", "Fula client is not initialized", error)
1379+
return
1380+
}
1381+
1382+
do {
1383+
let account = try fulaClient.getAccount()
1384+
guard let accountString = String(data: account, encoding: .utf8) else {
1385+
let conversionError = NSError(domain: "FulaModuleError", code: -2, userInfo: [NSLocalizedDescriptionKey: "Unable to convert account data to String"])
1386+
reject("ERR_FULA_CONVERSION_FAILED", "Unable to convert account data to String", conversionError)
1387+
return
1388+
}
1389+
resolve(accountString)
1390+
} catch let error {
1391+
reject("ERR_FULA", "getAccount: \(error.localizedDescription)", error)
1392+
}
1393+
}
13841394

13851395
@objc(assetsBalance:withAssetId:withClassId:withResolver:withRejecter:)
13861396
func assetsBalance(account: String, assetId: String, classId: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@functionland/react-native-fula",
3-
"version": "1.54.14",
3+
"version": "1.54.15",
44
"description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",

0 commit comments

Comments
 (0)