react-native-rgb 0.2.2 → 0.2.3
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/AppConstants.swift +36 -50
- package/ios/Rgb.mm +219 -220
- package/ios/Rgb.swift +3 -7
- package/lib/typescript/docs/docusaurus.config.d.ts +4 -0
- package/lib/typescript/docs/docusaurus.config.d.ts.map +1 -0
- package/lib/typescript/docs/sidebars.d.ts +14 -0
- package/lib/typescript/docs/sidebars.d.ts.map +1 -0
- package/lib/typescript/docs/src/components/HomepageFeatures/index.d.ts +3 -0
- package/lib/typescript/docs/src/components/HomepageFeatures/index.d.ts.map +1 -0
- package/lib/typescript/docs/src/pages/index.d.ts +2 -0
- package/lib/typescript/docs/src/pages/index.d.ts.map +1 -0
- package/package.json +3 -2
package/ios/AppConstants.swift
CHANGED
|
@@ -5,67 +5,53 @@ import Foundation
|
|
|
5
5
|
public class AppConstants: NSObject {
|
|
6
6
|
@objc public static let shared = AppConstants()
|
|
7
7
|
|
|
8
|
-
let rgbDirName = ""
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"ssl://electrum.iriswallet.com:50003",
|
|
25
|
-
"https://blockstream.info/api"
|
|
26
|
-
]
|
|
27
|
-
private var callCount = 0
|
|
8
|
+
private let rgbDirName = ""
|
|
9
|
+
private var _rgbDir: URL? = nil
|
|
10
|
+
private let queue = DispatchQueue(label: "com.rgb.appconstants")
|
|
11
|
+
|
|
12
|
+
var rgbDir: URL? {
|
|
13
|
+
get {
|
|
14
|
+
return queue.sync {
|
|
15
|
+
return _rgbDir
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
set {
|
|
19
|
+
queue.sync {
|
|
20
|
+
self._rgbDir = newValue
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
28
24
|
|
|
29
25
|
private override init() {
|
|
30
26
|
super.init()
|
|
31
27
|
}
|
|
32
28
|
|
|
33
29
|
@objc public func initContext() {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
queue.sync {
|
|
31
|
+
let fileManager = FileManager.default
|
|
32
|
+
let documentsPath = fileManager.urls(for: .documentDirectory, in: .userDomainMask)[0]
|
|
33
|
+
_rgbDir = documentsPath.appendingPathComponent(rgbDirName)
|
|
34
|
+
|
|
35
|
+
// Create directory if it doesn't exist
|
|
36
|
+
if let rgbDir = _rgbDir {
|
|
37
|
+
try? fileManager.createDirectory(at: rgbDir, withIntermediateDirectories: true, attributes: nil)
|
|
38
|
+
}
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
@objc public func ensureInitialized() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
case "REGTEST":
|
|
57
|
-
return regtestElectrumURL
|
|
58
|
-
case "MAINNET":
|
|
59
|
-
return getNextMainnetUrl()
|
|
60
|
-
default:
|
|
61
|
-
return testnetElectrumURL
|
|
43
|
+
queue.sync {
|
|
44
|
+
if _rgbDir == nil {
|
|
45
|
+
let fileManager = FileManager.default
|
|
46
|
+
let documentsPath = fileManager.urls(for: .documentDirectory, in: .userDomainMask)[0]
|
|
47
|
+
_rgbDir = documentsPath.appendingPathComponent(rgbDirName)
|
|
48
|
+
|
|
49
|
+
// Create directory if it doesn't exist
|
|
50
|
+
if let rgbDir = _rgbDir {
|
|
51
|
+
try? fileManager.createDirectory(at: rgbDir, withIntermediateDirectories: true, attributes: nil)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
62
54
|
}
|
|
63
55
|
}
|
|
64
|
-
|
|
65
|
-
private func getNextMainnetUrl() -> String {
|
|
66
|
-
let url = mainnetUrls[callCount % mainnetUrls.count]
|
|
67
|
-
callCount += 1
|
|
68
|
-
return url
|
|
69
|
-
}
|
|
70
56
|
}
|
|
71
57
|
|