Skip to content

Commit

Permalink
add show mnemonic call to rn
Browse files Browse the repository at this point in the history
  • Loading branch information
RCasatta committed Nov 11, 2024
1 parent f3328ce commit 6efde37
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sdk/libportal-react-native/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

implementation "net.java.dev.jna:jna:5.14.0@aar"
implementation "xyz.twenty_two:libportal-android:0.1.0-SNAPSHOT@aar"
implementation "xyz.twenty-two:libportal-android:0.2.1-SNAPSHOT@aar"
}

Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ class LibportalReactNativeModule(reactContext: ReactApplicationContext) :
}
}

@ReactMethod
fun showMnemonic(promise: Promise) {
try {
scope.launch {
instance!!.showMnemonic()
promise.resolve(null)
}
} catch (e: Exception) {
promise.reject(e)
}
}

@ReactMethod
fun displayAddress(index: Int, promise: Promise) {
try {
Expand Down
6 changes: 3 additions & 3 deletions sdk/libportal-react-native/example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
buildscript {
ext {
buildToolsVersion = "33.0.1"
buildToolsVersion = "34.0.0"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "23.1.7779620"
kotlinVersion = "1.8.0"
}
Expand Down
3 changes: 3 additions & 0 deletions sdk/libportal-react-native/ios/LibportalReactNative.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ @interface RCT_EXTERN_MODULE(LibportalReactNative, NSObject)
RCT_EXTERN_METHOD(resume: (RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(showMnemonic: (RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(displayAddress: (nonnull NSNumber)index
withResolver:(RCTPromiseResolveBlock)resolve
withRejecter:(RCTPromiseRejectBlock)reject)
Expand Down
12 changes: 12 additions & 0 deletions sdk/libportal-react-native/ios/LibportalReactNative.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,18 @@ class LibportalReactNative: NSObject {
}
}
}

@objc func showMnemonic(_ resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
Task {
do {
try await self.sdk?.showMnemonic()
resolve(nil)
}
catch {
reject("Error", error.localizedDescription, error)
}
}
}

@objc func displayAddress(_ index: NSNumber, withResolver resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
let index = UInt32(truncating: index)
Expand Down
4 changes: 4 additions & 0 deletions sdk/libportal-react-native/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ export class PortalSdk {
return LibportalReactNative.resume();
}

showMnemonic(): Promise<void> {
return LibportalReactNative.showMnemonic();
}

displayAddress(index: number): Promise<string> {
return LibportalReactNative.displayAddress(index);
}
Expand Down

0 comments on commit 6efde37

Please sign in to comment.