orbis1-sdk-rn 0.0.8 → 0.0.9
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.
|
@@ -32,6 +32,7 @@ import org.rgbtools.Token
|
|
|
32
32
|
import org.rgbtools.Invoice
|
|
33
33
|
import com.rgb.AppConstants
|
|
34
34
|
import com.rgb.NativeRgbSpec
|
|
35
|
+
import java.io.File
|
|
35
36
|
|
|
36
37
|
@ReactModule(name = RgbModule.NAME)
|
|
37
38
|
class RgbModule(reactContext: ReactApplicationContext) :
|
|
@@ -76,6 +77,15 @@ class RgbModule(reactContext: ReactApplicationContext) :
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
|
|
80
|
+
private fun emptyRgbDataDir(dir: File) {
|
|
81
|
+
if (!dir.exists() || !dir.isDirectory) return
|
|
82
|
+
dir.listFiles()?.forEach { child ->
|
|
83
|
+
if (!child.deleteRecursively()) {
|
|
84
|
+
throw IllegalStateException("Failed to delete ${child.absolutePath}")
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
79
89
|
override fun generateKeys(bitcoinNetwork: String, promise: Promise) {
|
|
80
90
|
coroutineScope.launch(Dispatchers.IO) {
|
|
81
91
|
try {
|
|
@@ -132,6 +142,8 @@ class RgbModule(reactContext: ReactApplicationContext) :
|
|
|
132
142
|
try {
|
|
133
143
|
val rgbDir = AppConstants.rgbDir
|
|
134
144
|
?: throw IllegalStateException("RGB directory not initialized.")
|
|
145
|
+
WalletStore.clear()
|
|
146
|
+
emptyRgbDataDir(rgbDir)
|
|
135
147
|
org.rgbtools.restoreBackup(path, password, rgbDir.absolutePath)
|
|
136
148
|
|
|
137
149
|
withContext(Dispatchers.Main) {
|
package/ios/Rgb.swift
CHANGED
|
@@ -49,6 +49,18 @@ public class RgbSwiftHelper: NSObject {
|
|
|
49
49
|
return error.localizedDescription
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
private static func emptyRgbDataDir(at url: URL) throws {
|
|
53
|
+
let fileManager = FileManager.default
|
|
54
|
+
guard fileManager.fileExists(atPath: url.path) else { return }
|
|
55
|
+
let contents = try fileManager.contentsOfDirectory(
|
|
56
|
+
at: url,
|
|
57
|
+
includingPropertiesForKeys: nil
|
|
58
|
+
)
|
|
59
|
+
for item in contents {
|
|
60
|
+
try fileManager.removeItem(at: item)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
52
64
|
private static func getNetwork(_ network: String) -> BitcoinNetwork {
|
|
53
65
|
switch network.uppercased() {
|
|
54
66
|
case "MAINNET":
|
|
@@ -139,7 +151,9 @@ public class RgbSwiftHelper: NSObject {
|
|
|
139
151
|
guard let rgbDir = constants.rgbDir else {
|
|
140
152
|
return ["error": "RGB directory not initialized."] as NSDictionary
|
|
141
153
|
}
|
|
142
|
-
|
|
154
|
+
|
|
155
|
+
WalletStore.shared.clear()
|
|
156
|
+
try Self.emptyRgbDataDir(at: rgbDir)
|
|
143
157
|
try restoreBackup(backupPath: path, password: password, dataDir: rgbDir.path)
|
|
144
158
|
return [:] as NSDictionary
|
|
145
159
|
} catch {
|
package/package.json
CHANGED