@functionland/react-native-fula 1.46.0 → 1.53.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.
- package/README.md +19 -1
- package/android/build.gradle +12 -7
- package/android/gradle.properties +4 -4
- package/android/src/main/java/land/fx/fula/FulaModule.java +113 -4
- package/ios/Fula.mm +20 -2
- package/ios/Fula.swift +99 -7
- package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/commonjs/interfaces/lookup.js +0 -1
- package/lib/commonjs/interfaces/lookup.js.map +1 -1
- package/lib/commonjs/protocols/blockchain.js +33 -5
- package/lib/commonjs/protocols/blockchain.js.map +1 -1
- package/lib/commonjs/protocols/chain-api.js +5 -5
- package/lib/commonjs/protocols/chain-api.js.map +1 -1
- package/lib/commonjs/protocols/fula.js +77 -5
- package/lib/commonjs/protocols/fula.js.map +1 -1
- package/lib/commonjs/protocols/fxblox.js +25 -1
- package/lib/commonjs/protocols/fxblox.js.map +1 -1
- package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
- package/lib/module/interfaces/lookup.js +0 -2
- package/lib/module/interfaces/lookup.js.map +1 -1
- package/lib/module/protocols/blockchain.js +30 -3
- package/lib/module/protocols/blockchain.js.map +1 -1
- package/lib/module/protocols/chain-api.js +5 -5
- package/lib/module/protocols/chain-api.js.map +1 -1
- package/lib/module/protocols/fula.js +73 -3
- package/lib/module/protocols/fula.js.map +1 -1
- package/lib/module/protocols/fxblox.js +23 -0
- package/lib/module/protocols/fxblox.js.map +1 -1
- package/lib/typescript/interfaces/fulaNativeModule.d.ts +6 -3
- package/lib/typescript/interfaces/fulaNativeModule.d.ts.map +1 -1
- package/lib/typescript/protocols/blockchain.d.ts +5 -3
- package/lib/typescript/protocols/blockchain.d.ts.map +1 -1
- package/lib/typescript/protocols/fula.d.ts +9 -0
- package/lib/typescript/protocols/fula.d.ts.map +1 -1
- package/lib/typescript/protocols/fxblox.d.ts +1 -0
- package/lib/typescript/protocols/fxblox.d.ts.map +1 -1
- package/lib/typescript/types/blockchain.d.ts +5 -0
- package/lib/typescript/types/blockchain.d.ts.map +1 -1
- package/lib/typescript/types/fxblox.d.ts +7 -0
- package/lib/typescript/types/fxblox.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/interfaces/fulaNativeModule.ts +14 -10
- package/src/interfaces/lookup.ts +1 -1
- package/src/protocols/blockchain.ts +56 -14
- package/src/protocols/chain-api.ts +5 -5
- package/src/protocols/fula.ts +84 -4
- package/src/protocols/fxblox.ts +25 -0
- package/src/types/blockchain.ts +9 -3
- package/src/types/fxblox.ts +8 -0
package/README.md
CHANGED
|
@@ -197,6 +197,24 @@ curl -H "Content-Type: application/json" -d "{\"id\":\"1\", \"jsonrpc\":\"2.0\",
|
|
|
197
197
|
yarn build:polkadot
|
|
198
198
|
```
|
|
199
199
|
|
|
200
|
+
## Testing
|
|
201
|
+
|
|
202
|
+
Open a cmd or terminal as admin (sudo)
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
corepack enable
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Then cd to the `react-native-fula` folder (no need for admin, sudo) and run:
|
|
209
|
+
```
|
|
210
|
+
yarn install
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
to run the example app, run:
|
|
214
|
+
```
|
|
215
|
+
yarn example android
|
|
216
|
+
```
|
|
217
|
+
|
|
200
218
|
## Roadmap
|
|
201
219
|
|
|
202
220
|
Please note the following might not be done in order:
|
|
@@ -205,7 +223,7 @@ Please note the following might not be done in order:
|
|
|
205
223
|
- [x] Add WNFS tree encryption key generation from an input (deterministically)
|
|
206
224
|
- [x] Improve ead function to use a stream. ( :100: v1 Release here )
|
|
207
225
|
- [x] Connect to backend
|
|
208
|
-
- [
|
|
226
|
+
- [x] Connect to Blockchain codes using APIs
|
|
209
227
|
|
|
210
228
|
## Other related libraries
|
|
211
229
|
|
package/android/build.gradle
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import com.android.Version
|
|
2
|
+
|
|
1
3
|
buildscript {
|
|
2
4
|
repositories {
|
|
3
5
|
google()
|
|
@@ -5,7 +7,7 @@ buildscript {
|
|
|
5
7
|
}
|
|
6
8
|
|
|
7
9
|
dependencies {
|
|
8
|
-
classpath "com.android.tools.build:gradle:
|
|
10
|
+
classpath "com.android.tools.build:gradle:8.2.2"
|
|
9
11
|
}
|
|
10
12
|
}
|
|
11
13
|
|
|
@@ -30,8 +32,8 @@ def getExtOrIntegerDefault(name) {
|
|
|
30
32
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Fula_" + name]).toInteger()
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
def supportsNamespace() {
|
|
34
|
-
def parsed =
|
|
35
|
+
static def supportsNamespace() {
|
|
36
|
+
def parsed = Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
35
37
|
def major = parsed[0].toInteger()
|
|
36
38
|
def minor = parsed[1].toInteger()
|
|
37
39
|
|
|
@@ -72,10 +74,13 @@ android {
|
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
compileOptions {
|
|
75
|
-
sourceCompatibility JavaVersion.
|
|
76
|
-
targetCompatibility JavaVersion.
|
|
77
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
78
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
79
|
+
}
|
|
80
|
+
ndkVersion '26.2.11394342'
|
|
81
|
+
buildFeatures {
|
|
82
|
+
buildConfig true
|
|
77
83
|
}
|
|
78
|
-
ndkVersion '25.1.8937393'
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
repositories {
|
|
@@ -94,7 +99,7 @@ dependencies {
|
|
|
94
99
|
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
95
100
|
//noinspection GradleDynamicVersion
|
|
96
101
|
implementation "com.facebook.react:react-native:+"
|
|
97
|
-
implementation 'com.github.functionland:fula-build-aar:v1.
|
|
102
|
+
implementation 'com.github.functionland:fula-build-aar:v1.53.0' // From jitpack.io
|
|
98
103
|
implementation 'com.github.functionland:wnfs-android:v1.8.1' // From jitpack.io
|
|
99
104
|
implementation 'commons-io:commons-io:20030203.000550'
|
|
100
105
|
implementation 'commons-codec:commons-codec:1.15'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
Fula_kotlinVersion=1.
|
|
1
|
+
Fula_kotlinVersion=1.9.22
|
|
2
2
|
Fula_minSdkVersion=26
|
|
3
|
-
Fula_targetSdkVersion=
|
|
4
|
-
Fula_compileSdkVersion=
|
|
5
|
-
Fula_ndkversion=
|
|
3
|
+
Fula_targetSdkVersion=33
|
|
4
|
+
Fula_compileSdkVersion=33
|
|
5
|
+
Fula_ndkversion=26.2.11394342
|
|
@@ -1346,10 +1346,11 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
1346
1346
|
}
|
|
1347
1347
|
|
|
1348
1348
|
@ReactMethod
|
|
1349
|
-
public void listPoolJoinRequests(
|
|
1349
|
+
public void listPoolJoinRequests(String poolIDStr, Promise promise) {
|
|
1350
1350
|
ThreadUtils.runOnExecutor(() -> {
|
|
1351
|
-
Log.d("ReactNative", "listPoolJoinRequests: poolID = " +
|
|
1351
|
+
Log.d("ReactNative", "listPoolJoinRequests: poolID = " + poolIDStr);
|
|
1352
1352
|
try {
|
|
1353
|
+
long poolID = Long.parseLong(poolIDStr);
|
|
1353
1354
|
byte[] result = this.fula.poolRequests(poolID);
|
|
1354
1355
|
String resultString = toString(result);
|
|
1355
1356
|
promise.resolve(resultString);
|
|
@@ -1377,10 +1378,11 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
1377
1378
|
}
|
|
1378
1379
|
|
|
1379
1380
|
@ReactMethod
|
|
1380
|
-
public void listAvailableReplicationRequests(
|
|
1381
|
+
public void listAvailableReplicationRequests(String poolIDStr, Promise promise) {
|
|
1381
1382
|
ThreadUtils.runOnExecutor(() -> {
|
|
1382
|
-
Log.d("ReactNative", "listAvailableReplicationRequests: poolID = " +
|
|
1383
|
+
Log.d("ReactNative", "listAvailableReplicationRequests: poolID = " + poolIDStr);
|
|
1383
1384
|
try {
|
|
1385
|
+
long poolID = Long.parseLong(poolIDStr);
|
|
1384
1386
|
byte[] result = this.fula.manifestAvailable(poolID);
|
|
1385
1387
|
String resultString = toString(result);
|
|
1386
1388
|
promise.resolve(resultString);
|
|
@@ -1427,6 +1429,42 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
1427
1429
|
});
|
|
1428
1430
|
}
|
|
1429
1431
|
|
|
1432
|
+
@ReactMethod
|
|
1433
|
+
private void listRecentCidsAsStringWithChildren(Promise promise) throws Exception {
|
|
1434
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
1435
|
+
try {
|
|
1436
|
+
if (this.fula != null) {
|
|
1437
|
+
Log.d("ReactNative", "listRecentCidsAsStringWithChildren");
|
|
1438
|
+
fulamobile.StringIterator recentLinks = this.fula.listRecentCidsAsStringWithChildren();
|
|
1439
|
+
ArrayList<String> recentLinksList = new ArrayList<>();
|
|
1440
|
+
while (recentLinks.hasNext()) {
|
|
1441
|
+
recentLinksList.add(recentLinks.next());
|
|
1442
|
+
}
|
|
1443
|
+
if (!recentLinksList.isEmpty()) {
|
|
1444
|
+
// return the whole list
|
|
1445
|
+
Log.d("ReactNative", "listRecentCidsAsStringWithChildren found: "+ recentLinksList);
|
|
1446
|
+
WritableArray recentLinksArray = Arguments.createArray();
|
|
1447
|
+
for (String link : recentLinksList) {
|
|
1448
|
+
recentLinksArray.pushString(link);
|
|
1449
|
+
}
|
|
1450
|
+
promise.resolve(recentLinksArray);
|
|
1451
|
+
} else {
|
|
1452
|
+
promise.resolve(false);
|
|
1453
|
+
}
|
|
1454
|
+
} else {
|
|
1455
|
+
throw new Exception("listRecentCidsAsStringWithChildren: Fula is not initialized");
|
|
1456
|
+
}
|
|
1457
|
+
} catch (Exception e) {
|
|
1458
|
+
Log.d("ReactNative", "listRecentCidsAsStringWithChildren failed with Error: " + e.getMessage());
|
|
1459
|
+
try {
|
|
1460
|
+
throw (e);
|
|
1461
|
+
} catch (Exception ex) {
|
|
1462
|
+
throw new RuntimeException(ex);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
});
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1430
1468
|
@ReactMethod
|
|
1431
1469
|
public void clearCidsFromRecent(ReadableArray cidArray, Promise promise) {
|
|
1432
1470
|
ThreadUtils.runOnExecutor(() -> {
|
|
@@ -1453,6 +1491,61 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
1453
1491
|
});
|
|
1454
1492
|
}
|
|
1455
1493
|
|
|
1494
|
+
@ReactMethod
|
|
1495
|
+
public void batchUploadManifest(ReadableArray cidArray, String poolIDStr, String replicationFactorStr, Promise promise) {
|
|
1496
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
1497
|
+
try {
|
|
1498
|
+
long poolID = Long.parseLong(poolIDStr);
|
|
1499
|
+
long replicationFactor = Long.parseLong(replicationFactorStr);
|
|
1500
|
+
if (this.fula != null) {
|
|
1501
|
+
StringBuilder cidStrBuilder = new StringBuilder();
|
|
1502
|
+
for (int i = 0; i < cidArray.size(); i++) {
|
|
1503
|
+
if (i > 0) {
|
|
1504
|
+
cidStrBuilder.append("|");
|
|
1505
|
+
}
|
|
1506
|
+
cidStrBuilder.append(cidArray.getString(i));
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
byte[] cidsBytes = cidStrBuilder.toString().getBytes(StandardCharsets.UTF_8);
|
|
1510
|
+
this.fula.batchUploadManifest(cidsBytes, poolID, replicationFactor);
|
|
1511
|
+
promise.resolve(true); // Indicate success
|
|
1512
|
+
} else {
|
|
1513
|
+
throw new Exception("BatchUploadManifest: Fula is not initialized");
|
|
1514
|
+
}
|
|
1515
|
+
} catch (Exception e) {
|
|
1516
|
+
Log.d("ReactNative", "BatchUploadManifest failed with Error: " + e.getMessage());
|
|
1517
|
+
promise.reject("Error", e.getMessage());
|
|
1518
|
+
}
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
@ReactMethod
|
|
1523
|
+
public void replicateInPool(ReadableArray cidArray, String account, String poolIDStr, Promise promise) {
|
|
1524
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
1525
|
+
try {
|
|
1526
|
+
long poolID = Long.parseLong(poolIDStr);
|
|
1527
|
+
if (this.fula != null) {
|
|
1528
|
+
StringBuilder cidStrBuilder = new StringBuilder();
|
|
1529
|
+
for (int i = 0; i < cidArray.size(); i++) {
|
|
1530
|
+
if (i > 0) {
|
|
1531
|
+
cidStrBuilder.append("|");
|
|
1532
|
+
}
|
|
1533
|
+
cidStrBuilder.append(cidArray.getString(i));
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
byte[] cidsBytes = cidStrBuilder.toString().getBytes(StandardCharsets.UTF_8);
|
|
1537
|
+
byte[] res = this.fula.replicateInPool(cidsBytes, account, poolID);
|
|
1538
|
+
String receivedJsonString = new String(res, StandardCharsets.UTF_8);
|
|
1539
|
+
promise.resolve(receivedJsonString); // Indicate success
|
|
1540
|
+
} else {
|
|
1541
|
+
throw new Exception("replicateInPool: Fula is not initialized");
|
|
1542
|
+
}
|
|
1543
|
+
} catch (Exception e) {
|
|
1544
|
+
Log.d("ReactNative", "replicateInPool failed with Error: " + e.getMessage());
|
|
1545
|
+
promise.reject("Error", e.getMessage());
|
|
1546
|
+
}
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1456
1549
|
|
|
1457
1550
|
////////////////////////////////////////////////////////////////
|
|
1458
1551
|
///////////////// Blox Hardware Methods ////////////////////////
|
|
@@ -1522,6 +1615,22 @@ public class FulaModule extends ReactContextBaseJavaModule {
|
|
|
1522
1615
|
});
|
|
1523
1616
|
}
|
|
1524
1617
|
|
|
1618
|
+
@ReactMethod
|
|
1619
|
+
public void getDatastoreSize(Promise promise) {
|
|
1620
|
+
ThreadUtils.runOnExecutor(() -> {
|
|
1621
|
+
Log.d("ReactNative", "getDatastoreSize");
|
|
1622
|
+
try {
|
|
1623
|
+
byte[] result = this.fula.getDatastoreSize();
|
|
1624
|
+
String resultString = toString(result);
|
|
1625
|
+
Log.d("ReactNative", "result string="+resultString);
|
|
1626
|
+
promise.resolve(resultString);
|
|
1627
|
+
} catch (Exception e) {
|
|
1628
|
+
Log.d("ReactNative", "an error happened="+e.getMessage());
|
|
1629
|
+
promise.reject(e);
|
|
1630
|
+
}
|
|
1631
|
+
});
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1525
1634
|
@ReactMethod
|
|
1526
1635
|
public void reboot(Promise promise) {
|
|
1527
1636
|
ThreadUtils.runOnExecutor(() -> {
|
package/ios/Fula.mm
CHANGED
|
@@ -106,6 +106,22 @@ RCT_EXTERN_METHOD(setAuth:(NSString *)peerIdString
|
|
|
106
106
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
107
107
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
108
108
|
|
|
109
|
+
RCT_EXTERN_METHOD(clearCidsFromRecent:(NSArray *)cidArray
|
|
110
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
111
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
112
|
+
|
|
113
|
+
RCT_EXTERN_METHOD(listRecentCidsAsString:(RCTPromiseResolveBlock)resolve
|
|
114
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
115
|
+
|
|
116
|
+
RCT_EXTERN_METHOD(listRecentCidsAsStringWithChildren:(RCTPromiseResolveBlock)resolve
|
|
117
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
118
|
+
|
|
119
|
+
RCT_EXTERN_METHOD(batchUploadManifest:(NSArray *)cidArray
|
|
120
|
+
withPoolId:(NSString *) poolIdStr
|
|
121
|
+
withReplicationFactor:(NSString *) replicationFactorStr
|
|
122
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
123
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
124
|
+
|
|
109
125
|
RCT_EXTERN_METHOD(shutdown:(RCTPromiseResolveBlock)resolve
|
|
110
126
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
111
127
|
|
|
@@ -129,7 +145,7 @@ RCT_EXTERN_METHOD(cancelPoolJoin:(NSString *)poolID
|
|
|
129
145
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
130
146
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
131
147
|
|
|
132
|
-
RCT_EXTERN_METHOD(listPoolJoinRequests:(
|
|
148
|
+
RCT_EXTERN_METHOD(listPoolJoinRequests:(NSString *)poolIDStr
|
|
133
149
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
134
150
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
135
151
|
|
|
@@ -138,7 +154,7 @@ RCT_EXTERN_METHOD(leavePool:(NSString *)poolID
|
|
|
138
154
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
139
155
|
|
|
140
156
|
|
|
141
|
-
RCT_EXTERN_METHOD(listAvailableReplicationRequests:(
|
|
157
|
+
RCT_EXTERN_METHOD(listAvailableReplicationRequests:(NSString *)poolIDStr
|
|
142
158
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
143
159
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
144
160
|
|
|
@@ -173,6 +189,8 @@ RCT_EXTERN_METHOD(getFolderSize:(NSString *)folderPath
|
|
|
173
189
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
174
190
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
175
191
|
|
|
192
|
+
RCT_EXTERN_METHOD(getDatastoreSize:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
|
|
193
|
+
|
|
176
194
|
+ (BOOL)requiresMainQueueSetup
|
|
177
195
|
{
|
|
178
196
|
return NO;
|
package/ios/Fula.swift
CHANGED
|
@@ -1061,6 +1061,73 @@ class FulaModule: NSObject {
|
|
|
1061
1061
|
}
|
|
1062
1062
|
}
|
|
1063
1063
|
|
|
1064
|
+
@objc(listRecentCidsAsStringWithChildren:withRejecter:)
|
|
1065
|
+
func listRecentCidsAsStringWithChildren(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
1066
|
+
DispatchQueue.global(qos: .default).async {
|
|
1067
|
+
do {
|
|
1068
|
+
guard let fulaClient = self.fula else {
|
|
1069
|
+
throw MyError.runtimeError("Fula client is not initialized")
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
let recentLinksIterator = try fulaClient.listRecentCidsAsStringWithChildren()
|
|
1073
|
+
var recentLinksList = [String]()
|
|
1074
|
+
|
|
1075
|
+
while recentLinksIterator.hasNext() {
|
|
1076
|
+
var error: NSError?
|
|
1077
|
+
let nextLink = try recentLinksIterator.next(&error)
|
|
1078
|
+
|
|
1079
|
+
if let error = error {
|
|
1080
|
+
throw error
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
recentLinksList.append(nextLink)
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
if !recentLinksList.isEmpty {
|
|
1087
|
+
// Return the whole list
|
|
1088
|
+
resolve(recentLinksList)
|
|
1089
|
+
} else {
|
|
1090
|
+
resolve(false)
|
|
1091
|
+
}
|
|
1092
|
+
} catch let error {
|
|
1093
|
+
print("ReactNative", "listRecentCidsAsStringWithChildren failed with Error: \(error.localizedDescription)")
|
|
1094
|
+
reject("ERR_FULA_LIST_RECENT_CIDS_WITH_CHILDREN", "Failed to list recent CIDs as string with children", error)
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
@objc(batchUploadManifest:withPoolId:withReplicationFactor:withResolver:withRejecter:)
|
|
1100
|
+
func batchUploadManifest(cidArray: NSArray, poolIDStr: String, replicationFactorStr: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
1101
|
+
DispatchQueue.global(qos: .default).async {
|
|
1102
|
+
do {
|
|
1103
|
+
guard let fulaClient = self.fula else {
|
|
1104
|
+
throw MyError.runtimeError("Fula client is not initialized")
|
|
1105
|
+
}
|
|
1106
|
+
guard let poolID = Int64(poolIDStr) else {
|
|
1107
|
+
reject("ERR_FULA", "Invalid poolID - not a valid number: \(poolIDStr)")
|
|
1108
|
+
return
|
|
1109
|
+
}
|
|
1110
|
+
guard let replicationFactor = Int64(replicationFactorStr) else {
|
|
1111
|
+
reject("ERR_FULA", "Invalid replicationFactorStr - not a valid number: \(replicationFactorStr)")
|
|
1112
|
+
return
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
// Concatenate all CID strings into a single string separated by "|"
|
|
1116
|
+
let concatenatedCids = (cidArray as? [String])?.joined(separator: "|")
|
|
1117
|
+
|
|
1118
|
+
guard let cidsData = concatenatedCids?.data(using: .utf8) else {
|
|
1119
|
+
throw MyError.runtimeError("Unable to encode CIDs as data")
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
try fulaClient.batchUploadManifest(cidsData, poolID, replicationFactor)
|
|
1123
|
+
resolve(true)
|
|
1124
|
+
} catch let error {
|
|
1125
|
+
print("ReactNative", "batchUploadManifest failed with Error: \(error.localizedDescription)")
|
|
1126
|
+
reject("ERR_FULA_BATCH_UPLOAD_MANIFEST", "Failed to batch upload CIDs", error)
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1064
1131
|
|
|
1065
1132
|
|
|
1066
1133
|
@objc(shutdown:withRejecter:)
|
|
@@ -1134,12 +1201,19 @@ class FulaModule: NSObject {
|
|
|
1134
1201
|
}
|
|
1135
1202
|
|
|
1136
1203
|
@objc(listPoolJoinRequests:withResolver:withRejecter:)
|
|
1137
|
-
func listPoolJoinRequests(
|
|
1138
|
-
print("ReactNative", "listPoolJoinRequests:
|
|
1204
|
+
func listPoolJoinRequests(poolIDStr: String, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) -> Void {
|
|
1205
|
+
print("ReactNative", "listPoolJoinRequests: poolIDStr = ", poolIDStr)
|
|
1139
1206
|
do {
|
|
1140
|
-
let
|
|
1141
|
-
|
|
1142
|
-
|
|
1207
|
+
if let poolID = Int64(poolIDStr) {
|
|
1208
|
+
// Conversion successful - use longPoolID
|
|
1209
|
+
|
|
1210
|
+
let result = try fula!.poolRequests(poolID)
|
|
1211
|
+
let resultString = result.toUTF8String()!
|
|
1212
|
+
resolve(resultString)
|
|
1213
|
+
} else {
|
|
1214
|
+
// Handle invalid input (e.g., "abc", "123.45")
|
|
1215
|
+
reject("ERR_FULA", "Invalid poolIDStr - not a valid number: \(poolIDStr)")
|
|
1216
|
+
}
|
|
1143
1217
|
} catch let error {
|
|
1144
1218
|
print("listPoolJoinRequests", error.localizedDescription)
|
|
1145
1219
|
reject("ERR_FULA", "listPoolJoinRequests", error)
|
|
@@ -1148,9 +1222,13 @@ class FulaModule: NSObject {
|
|
|
1148
1222
|
}
|
|
1149
1223
|
|
|
1150
1224
|
@objc(listAvailableReplicationRequests:withResolver:withRejecter:)
|
|
1151
|
-
func listAvailableReplicationRequests(
|
|
1152
|
-
print("ReactNative", "listAvailableReplicationRequests:
|
|
1225
|
+
func listAvailableReplicationRequests(poolIDStr: String, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) -> Void {
|
|
1226
|
+
print("ReactNative", "listAvailableReplicationRequests: poolIDStr = ", poolIDStr)
|
|
1153
1227
|
do {
|
|
1228
|
+
guard let poolID = Int64(poolIDStr) else {
|
|
1229
|
+
reject("ERR_FULA", "Invalid poolID - not a valid number: \(poolIDStr)")
|
|
1230
|
+
return
|
|
1231
|
+
}
|
|
1154
1232
|
let result = try fula!.manifestAvailable(poolID)
|
|
1155
1233
|
let resultString = result.toUTF8String()!
|
|
1156
1234
|
resolve(resultString)
|
|
@@ -1334,6 +1412,20 @@ class FulaModule: NSObject {
|
|
|
1334
1412
|
}
|
|
1335
1413
|
}
|
|
1336
1414
|
|
|
1415
|
+
@objc(getDatastoreSize:withResolver:withRejecter:)
|
|
1416
|
+
func getDatastoreSize(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
1417
|
+
do {
|
|
1418
|
+
let result = try fula!.getDatastoreSize()
|
|
1419
|
+
let resultString = result.toUTF8String()!
|
|
1420
|
+
resolve(resultString)
|
|
1421
|
+
} catch let error {
|
|
1422
|
+
print("getDatastoreSize", error.localizedDescription)
|
|
1423
|
+
reject("ERR_FULA", "getDatastoreSize", error)
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
//Add Replicate In Pool (replicateInPool)
|
|
1428
|
+
|
|
1337
1429
|
}
|
|
1338
1430
|
|
|
1339
1431
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","Fula","NativeModules","FulaModule","Proxy","get","Error","_default","exports"],"sourceRoot":"../../../src","sources":["interfaces/fulaNativeModule.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","Fula","NativeModules","FulaModule","Proxy","get","Error","_default","exports"],"sourceRoot":"../../../src","sources":["interfaces/fulaNativeModule.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAuIA,MAAMC,aAAa,GAChB,iFAAgF,GACjFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,IAAI,GAAGC,0BAAa,CAACC,UAAU,GACjCD,0BAAa,CAACC,UAAU,GACxB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACV,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAAC,IAAAW,QAAA,GAAAC,OAAA,CAAAR,OAAA,GAESC,IAAI"}
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
|
8
8
|
/* eslint-disable */
|
|
9
|
-
/* eslint-disable sort-keys */
|
|
10
9
|
var _default = exports.default = {
|
|
11
10
|
/**
|
|
12
11
|
* Lookup3: frame_system::AccountInfo<Index, pallet_balances::types::AccountData<Balance>>
|