@keystonehq/react-native-keystone-wallet-core 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/README.md +46 -0
  2. package/android/build.gradle +49 -0
  3. package/android/src/main/AndroidManifest.xml +3 -0
  4. package/android/src/main/java/com/reactnativekeystonewalletcore/KeystoneWalletCoreModule.kt +54 -0
  5. package/android/src/main/java/com/reactnativekeystonewalletcore/KeystoneWalletCorePackage.kt +16 -0
  6. package/ios/Frameworks/KeystoneWalletCoreFFI.xcframework/Info.plist +43 -0
  7. package/ios/Frameworks/KeystoneWalletCoreFFI.xcframework/ios-arm64/KeystoneWalletCoreFFI.framework/Headers/keystone_wallet_coreFFI.h +605 -0
  8. package/ios/Frameworks/KeystoneWalletCoreFFI.xcframework/ios-arm64/KeystoneWalletCoreFFI.framework/Info.plist +22 -0
  9. package/ios/Frameworks/KeystoneWalletCoreFFI.xcframework/ios-arm64/KeystoneWalletCoreFFI.framework/KeystoneWalletCoreFFI +0 -0
  10. package/ios/Frameworks/KeystoneWalletCoreFFI.xcframework/ios-arm64/KeystoneWalletCoreFFI.framework/Modules/module.modulemap +4 -0
  11. package/ios/Frameworks/KeystoneWalletCoreFFI.xcframework/ios-arm64-simulator/KeystoneWalletCoreFFI.framework/Headers/keystone_wallet_coreFFI.h +605 -0
  12. package/ios/Frameworks/KeystoneWalletCoreFFI.xcframework/ios-arm64-simulator/KeystoneWalletCoreFFI.framework/Info.plist +22 -0
  13. package/ios/Frameworks/KeystoneWalletCoreFFI.xcframework/ios-arm64-simulator/KeystoneWalletCoreFFI.framework/KeystoneWalletCoreFFI +0 -0
  14. package/ios/Frameworks/KeystoneWalletCoreFFI.xcframework/ios-arm64-simulator/KeystoneWalletCoreFFI.framework/Modules/module.modulemap +4 -0
  15. package/ios/KeystoneWalletCoreModule.m +15 -0
  16. package/ios/KeystoneWalletCoreModule.swift +55 -0
  17. package/ios/keystone_wallet_core.swift +1027 -0
  18. package/lib/commonjs/index.js +24 -0
  19. package/lib/commonjs/index.js.map +1 -0
  20. package/lib/module/index.js +17 -0
  21. package/lib/module/index.js.map +1 -0
  22. package/lib/typescript/index.d.ts +16 -0
  23. package/lib/typescript/index.d.ts.map +1 -0
  24. package/package.json +80 -0
  25. package/react-native-keystone-wallet-core.podspec +28 -0
  26. package/src/index.tsx +46 -0
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # react-native-pczt
2
+
3
+ React Native wrapper for PCZT Rust library.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install react-native-pczt
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```js
14
+ import { createTransparentPczt } from "react-native-pczt";
15
+
16
+ // ...
17
+
18
+ const result = await createTransparentPczt(
19
+ [
20
+ {
21
+ txid: "...",
22
+ vout: 0,
23
+ amount: 1000,
24
+ address: "...",
25
+ seedFingerprint: "...",
26
+ derivationPath: [44, 0, 0, 0, 0],
27
+ publicKey: "...",
28
+ },
29
+ ],
30
+ [
31
+ {
32
+ address: "...",
33
+ amount: 900,
34
+ },
35
+ ],
36
+ 800000
37
+ );
38
+ ```
39
+
40
+ ## iOS Setup
41
+
42
+ The package includes a vendored XCFramework. No extra setup should be required other than `pod install`.
43
+
44
+ ## Android Setup
45
+
46
+ Not yet implemented.
@@ -0,0 +1,49 @@
1
+ buildscript {
2
+ repositories {
3
+ google()
4
+ mavenCentral()
5
+ }
6
+ dependencies {
7
+ classpath "com.android.tools.build:gradle:7.2.1"
8
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0"
9
+ }
10
+ }
11
+
12
+ apply plugin: "com.android.library"
13
+ apply plugin: "kotlin-android"
14
+
15
+ android {
16
+ compileSdkVersion 33
17
+ namespace "com.reactnativekeystonewalletcore"
18
+
19
+ defaultConfig {
20
+ minSdkVersion 21
21
+ targetSdkVersion 33
22
+ versionCode 1
23
+ versionName "1.0"
24
+ }
25
+
26
+ buildTypes {
27
+ release {
28
+ minifyEnabled false
29
+ }
30
+ }
31
+ lintOptions {
32
+ disable "GradleCompatible"
33
+ }
34
+ compileOptions {
35
+ sourceCompatibility JavaVersion.VERSION_1_8
36
+ targetCompatibility JavaVersion.VERSION_1_8
37
+ }
38
+ }
39
+
40
+ repositories {
41
+ mavenCentral()
42
+ google()
43
+ }
44
+
45
+ dependencies {
46
+ implementation "com.facebook.react:react-native:+"
47
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.0"
48
+ implementation project(":KeystoneWalletCoreWrapper")
49
+ }
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.reactnativekeystonewalletcore">
3
+ </manifest>
@@ -0,0 +1,54 @@
1
+ package com.reactnativekeystonewalletcore
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
5
+ import com.facebook.react.bridge.ReactMethod
6
+ import com.facebook.react.bridge.Promise
7
+ import com.facebook.react.bridge.ReadableArray
8
+ import com.facebook.react.bridge.ReadableMap
9
+ import uniffi.keystone_wallet_core.TransparentInput
10
+ import uniffi.keystone_wallet_core.TransparentOutput
11
+ import uniffi.keystone_wallet_core.createTransparentPczt
12
+
13
+ class KeystoneWalletCoreModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
14
+
15
+ override fun getName(): String {
16
+ return "KeystoneWalletCoreModule"
17
+ }
18
+
19
+ @ReactMethod
20
+ fun createTransparentPczt(inputs: ReadableArray, outputs: ReadableArray, blockHeight: Double, promise: Promise) {
21
+ try {
22
+ val kotlinInputs = mutableListOf<TransparentInput>()
23
+ for (i in 0 until inputs.size()) {
24
+ val input = inputs.getMap(i)
25
+ if (input == null) continue
26
+
27
+ kotlinInputs.add(TransparentInput(
28
+ txid = input.getString("txid") ?: "",
29
+ vout = input.getDouble("vout").toUInt(),
30
+ amount = input.getDouble("amount").toULong(),
31
+ address = input.getString("address") ?: "",
32
+ seedFingerprint = input.getString("seedFingerprint") ?: "",
33
+ derivationPath = input.getString("derivationPath") ?: "",
34
+ publicKey = input.getString("publicKey") ?: ""
35
+ ))
36
+ }
37
+
38
+ val kotlinOutputs = mutableListOf<TransparentOutput>()
39
+ for (i in 0 until outputs.size()) {
40
+ val output = outputs.getMap(i)
41
+ if (output == null) continue
42
+ kotlinOutputs.add(TransparentOutput(
43
+ address = output.getString("address") ?: "",
44
+ amount = output.getDouble("amount").toULong()
45
+ ))
46
+ }
47
+
48
+ val result = createTransparentPczt(kotlinInputs, kotlinOutputs, blockHeight.toUInt())
49
+ promise.resolve(result)
50
+ } catch (e: Exception) {
51
+ promise.reject("CREATE_PCZT_ERROR", e.message, e)
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,16 @@
1
+ package com.reactnativekeystonewalletcore
2
+
3
+ import com.facebook.react.ReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.uimanager.ViewManager
7
+
8
+ class KeystoneWalletCorePackage : ReactPackage {
9
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
10
+ return listOf(KeystoneWalletCoreModule(reactContext))
11
+ }
12
+
13
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
14
+ return emptyList()
15
+ }
16
+ }
@@ -0,0 +1,43 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>AvailableLibraries</key>
6
+ <array>
7
+ <dict>
8
+ <key>BinaryPath</key>
9
+ <string>KeystoneWalletCoreFFI.framework/KeystoneWalletCoreFFI</string>
10
+ <key>LibraryIdentifier</key>
11
+ <string>ios-arm64</string>
12
+ <key>LibraryPath</key>
13
+ <string>KeystoneWalletCoreFFI.framework</string>
14
+ <key>SupportedArchitectures</key>
15
+ <array>
16
+ <string>arm64</string>
17
+ </array>
18
+ <key>SupportedPlatform</key>
19
+ <string>ios</string>
20
+ </dict>
21
+ <dict>
22
+ <key>BinaryPath</key>
23
+ <string>KeystoneWalletCoreFFI.framework/KeystoneWalletCoreFFI</string>
24
+ <key>LibraryIdentifier</key>
25
+ <string>ios-arm64-simulator</string>
26
+ <key>LibraryPath</key>
27
+ <string>KeystoneWalletCoreFFI.framework</string>
28
+ <key>SupportedArchitectures</key>
29
+ <array>
30
+ <string>arm64</string>
31
+ </array>
32
+ <key>SupportedPlatform</key>
33
+ <string>ios</string>
34
+ <key>SupportedPlatformVariant</key>
35
+ <string>simulator</string>
36
+ </dict>
37
+ </array>
38
+ <key>CFBundlePackageType</key>
39
+ <string>XFWK</string>
40
+ <key>XCFrameworkFormatVersion</key>
41
+ <string>1.0</string>
42
+ </dict>
43
+ </plist>