Skip to content

Commit

Permalink
Fix Android ironfish-native-module
Browse files Browse the repository at this point in the history
  • Loading branch information
dguenther committed Apr 24, 2024
1 parent 276c826 commit 98651ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package expo.modules.ironfishnativemodule

import expo.modules.kotlin.records.Field
import expo.modules.kotlin.modules.Module
import expo.modules.kotlin.modules.ModuleDefinition
import expo.modules.kotlin.records.Record

class ExpoKey(
@Field
Expand All @@ -28,7 +30,7 @@ class IronfishNativeModule : Module() {
// The module will be accessible from `requireNativeModule('IronfishNativeModule')` in JavaScript.
Name("IronfishNativeModule")

AsyncFunction("generateKey") { ->
Function("generateKey") { ->
val k = uniffi.rust_lib.generateKey()

ExpoKey(
Expand All @@ -41,25 +43,15 @@ class IronfishNativeModule : Module() {
)
}

Function("spendingKeyToWords") { privateKey: String, languageCode: Long ->
try {
return spendingKeyToWords(privateKey: privateKey, languageCode: languageCode)
} catch (error: Exception) {
error.printStackTrace()
throw error
}
Function("spendingKeyToWords") { privateKey: String, languageCode: Int ->
uniffi.rust_lib.spendingKeyToWords(privateKey, languageCode)
}

Function("wordsToSpendingKey") { words: String, languageCode: Long ->
try {
return wordsToSpendingKey(words: words, languageCode: languageCode)
} catch (error: Exception) {
error.printStackTrace()
throw error
}
Function("wordsToSpendingKey") { words: String, languageCode: Int ->
uniffi.rust_lib.wordsToSpendingKey(words, languageCode)
}

AsyncFunction("generateKeyFromPrivateKey") { privateKey: String ->
Function("generateKeyFromPrivateKey") { privateKey: String ->
val k = uniffi.rust_lib.generateKeyFromPrivateKey(privateKey)

ExpoKey(
Expand All @@ -74,7 +66,7 @@ class IronfishNativeModule : Module() {

Function("isValidPublicAddress") { hexAddress: String ->
try {
uniffi.rust_lib.isValidPublicAddress(hexAddress: hexAddress)
uniffi.rust_lib.isValidPublicAddress(hexAddress)
} catch (error: Exception) {
error.printStackTrace()
throw error
Expand Down
5 changes: 4 additions & 1 deletion packages/mobile-app/data/wallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ class Wallet {
throw new Error(`No account found with name ${name}`)
}

const decodedAccount = decodeAccount(account.viewOnlyAccount);
const decodedAccount = decodeAccount(account.viewOnlyAccount, {
name,
});

decodedAccount.name = name;
decodedAccount.spendingKey = await SecureStore.getItemAsync(decodedAccount.publicAddress, {
keychainAccessible: SecureStore.WHEN_UNLOCKED_THIS_DEVICE_ONLY,
Expand Down

0 comments on commit 98651ed

Please sign in to comment.