Skip to content

Commit

Permalink
corected getAccount
Browse files Browse the repository at this point in the history
  • Loading branch information
Erfan Shekarchi committed Apr 4, 2024
1 parent f26bac3 commit dd22f0a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
28 changes: 19 additions & 9 deletions ios/Fula.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1372,15 +1372,25 @@ class FulaModule: NSObject {


@objc(getAccount:withRejecter:)
func getAccount(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
do {
let account = try self.fula!.getAccount()
let accountString = String(data: account, encoding: .utf8)
resolve(accountString)
} catch let error {
reject("ERR_FULA", "getAccount: \(error.localizedDescription)", error)
}
}
func getAccount(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
guard let fulaClient = self.fula else {
let error = NSError(domain: "FulaModuleError", code: -1, userInfo: [NSLocalizedDescriptionKey: "Fula client is not initialized"])
reject("ERR_FULA_NOT_INITIALIZED", "Fula client is not initialized", error)
return
}

do {
let account = try fulaClient.getAccount()
guard let accountString = String(data: account, encoding: .utf8) else {
let conversionError = NSError(domain: "FulaModuleError", code: -2, userInfo: [NSLocalizedDescriptionKey: "Unable to convert account data to String"])
reject("ERR_FULA_CONVERSION_FAILED", "Unable to convert account data to String", conversionError)
return
}
resolve(accountString)
} catch let error {
reject("ERR_FULA", "getAccount: \(error.localizedDescription)", error)
}
}

@objc(assetsBalance:withAssetId:withClassId:withResolver:withRejecter:)
func assetsBalance(account: String, assetId: String, classId: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@functionland/react-native-fula",
"version": "1.54.14",
"version": "1.54.15",
"description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down

0 comments on commit dd22f0a

Please sign in to comment.