@readyio/react-native-wallet 0.1.62 → 0.1.63

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.
package/ios/ReadyCrypto.m CHANGED
@@ -16,4 +16,10 @@ RCT_EXTERN_METHOD(signCurve25519:(NSString *)privateKey message:(NSString *)mess
16
16
  RCT_EXTERN_METHOD(encryptFile: (NSString *)inputFileUri outputFileUri:(NSString *)outputFileUri resolve: (RCTPromiseResolveBlock)resolve reject: (RCTPromiseRejectBlock)reject)
17
17
 
18
18
  RCT_EXTERN_METHOD(decryptFile: (NSString *)inputFileUri outputFileUri:(NSString *)outputFileUri key:(NSString *)key iv:(NSString *)iv resolve: (RCTPromiseResolveBlock)resolve reject: (RCTPromiseRejectBlock)reject)
19
+
20
+ RCT_EXTERN_METHOD(createWalletFromSeedPhrase:(NSString *)seedPhrase
21
+ path:(NSString *)path
22
+ resolve:(RCTPromiseResolveBlock)resolve
23
+ reject:(RCTPromiseRejectBlock)reject)
24
+
19
25
  @end
@@ -9,6 +9,7 @@ import Foundation
9
9
  import CryptoSwift
10
10
  import SwCrypt
11
11
  import Curve25519
12
+ import WalletCore
12
13
 
13
14
  @objc(ReadyWalletCrypto)
14
15
  class ReadyWalletCrypto: NSObject {
@@ -59,6 +60,47 @@ class ReadyWalletCrypto: NSObject {
59
60
  print("Error",error)
60
61
  }
61
62
  }
63
+
64
+ @objc
65
+ func createWalletFromSeedPhrase(_ seedPhrase: String, path: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
66
+ let param: NSMutableDictionary = NSMutableDictionary()
67
+
68
+ // Initialize the HDWallet with the seed phrase and passphrase
69
+ guard let wallet = HDWallet(mnemonic: seedPhrase, passphrase: "") else {
70
+ param.setValue(false, forKey: "status")
71
+ param.setValue("Invalid seed phrase.", forKey: "error")
72
+ let status = try? JSONSerialization.data(withJSONObject: param, options: .prettyPrinted)
73
+ let jsonStatus = String(data: status!, encoding: .utf8)
74
+ resolve(jsonStatus)
75
+ return
76
+ }
77
+
78
+ // Derive the default Ethereum address
79
+ let derivationPath = path// Ethereum derivation path
80
+ let privateKey = wallet.getKey(coin: .ethereum, derivationPath: derivationPath)
81
+ let publicKey = privateKey.getPublicKeySecp256k1(compressed: true)
82
+ let address = AnyAddress(publicKey: publicKey, coin: .ethereum)
83
+
84
+ // Store the results in the dictionary
85
+ param.setValue(address.description, forKey: "address")
86
+ param.setValue(seedPhrase, forKey: "passphrase")
87
+ param.setValue("0x" + privateKey.data.hexString, forKey: "privateKey")
88
+ param.setValue("0x" + publicKey.data.hexString, forKey: "publicKey")
89
+
90
+ // Convert the dictionary to JSON and resolve the promise
91
+ do {
92
+ let jsonData = try JSONSerialization.data(withJSONObject: param, options: .prettyPrinted)
93
+ let jsonString = String(data: jsonData, encoding: .utf8)
94
+ resolve(jsonString)
95
+ } catch {
96
+ param.setValue(false, forKey: "status")
97
+ param.setValue("Failed to serialize JSON.", forKey: "error")
98
+ let jsonStatus = try? JSONSerialization.data(withJSONObject: param, options: .prettyPrinted)
99
+ let jsonString = String(data: jsonStatus!, encoding: .utf8)
100
+ resolve(jsonString)
101
+ }
102
+ }
103
+
62
104
  @objc
63
105
  func encryptFile(_ inputFileUri:String, outputFileUri:String, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void
64
106
  {
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readyio/react-native-wallet",
3
- "version": "0.1.62",
3
+ "version": "0.1.63",
4
4
  "description": "React native ready wallet sdk for integrate with react native app",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -104,7 +104,7 @@
104
104
  "@react-navigation/material-top-tabs": "^6.6.10",
105
105
  "@react-navigation/native": "^6.1.7",
106
106
  "@react-navigation/native-stack": "6.9.13",
107
- "@sentry/react-native": "^4.2.4",
107
+ "@sentry/react-native": "^5.33.0",
108
108
  "@walletconnect/react-native-compat": "^2.11.0",
109
109
  "@walletconnect/web3wallet": "^1.10.0",
110
110
  "apisauce": "^1.1.1",
@@ -26,6 +26,7 @@ Pod::Spec.new do |s|
26
26
  s.dependency "Curve25519"
27
27
  s.dependency "CCurve25519"
28
28
  s.dependency 'lottie-ios'
29
+ s.dependency 'TrustWalletCore'
29
30
 
30
31
  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
31
32
  # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.