@functionland/react-native-fula 1.36.4 → 1.39.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.
@@ -1,576 +1,576 @@
1
- import Fula from '../interfaces/fulaNativeModule';
2
- import type * as BType from '../types/blockchain';
3
-
4
- /*
5
- createAccount: This function takes a seed argument, which is used to create an account. The seed must start with "/". The function returns a promise of an object that contains the seed and the account that was created.
6
- */
7
- export const createAccount = (
8
- seed: string //seed that is used to create the account. It must start with "/"
9
- ): Promise<BType.SeededResponse> => {
10
- console.log('createAccount in react-native started', seed);
11
- let res = Fula.createAccount(seed)
12
- .then((res) => {
13
- try {
14
- let jsonRes: BType.SeededResponse = JSON.parse(res);
15
- return jsonRes;
16
- } catch (e) {
17
- try {
18
- return JSON.parse(res);
19
- } catch (e) {
20
- return res;
21
- }
22
- }
23
- })
24
- .catch((err) => {
25
- return err;
26
- });
27
- return res;
28
- };
29
-
30
- /*
31
- checkAccountExists: This function takes an account argument, and returns a promise of an object that contains the account and a boolean exists flag. If exists is true, it means the account exists, otherwise, the account does not exist
32
- */
33
- export const checkAccountExists = (
34
- account: string
35
- ): Promise<BType.AccountExistsResponse> => {
36
- console.log('checkAccountExists in react-native started', account);
37
- let res = Fula.checkAccountExists(account)
38
- .then((res) => {
39
- try {
40
- let jsonRes: BType.AccountExistsResponse = JSON.parse(res);
41
- return jsonRes;
42
- } catch (e) {
43
- try {
44
- return JSON.parse(res);
45
- } catch (e) {
46
- return res;
47
- }
48
- }
49
- })
50
- .catch((err) => {
51
- return err;
52
- });
53
- return res;
54
- };
55
-
56
- /*
57
- createPool: This function takes two arguments: seed and poolName. The seed is used to identify the account that is creating the pool, and the poolName is the name of the pool being created. The function returns a promise of an object that contains the owner of the pool and the poolID of the created pool.
58
- */
59
- export const createPool = (
60
- seed: string,
61
- poolName: string
62
- ): Promise<BType.PoolCreateResponse> => {
63
- console.log('createPool in react-native started', seed, poolName);
64
- let res = Fula.createPool(seed, poolName)
65
- .then((res) => {
66
- try {
67
- let jsonRes: BType.PoolCreateResponse = JSON.parse(res);
68
- return jsonRes;
69
- } catch (e) {
70
- try {
71
- return JSON.parse(res);
72
- } catch (e) {
73
- return res;
74
- }
75
- }
76
- })
77
- .catch((err) => {
78
- return err;
79
- });
80
- return res;
81
- };
82
-
83
- /*
84
- listPools: This function takes no arguments and returns a promise of an object that contains a list of pools. Each pool in the list contains the poolID, owner, poolName, parent, and participants of the pool
85
- */
86
- export const listPools = (): Promise<BType.PoolListResponse> => {
87
- console.log('listPools in react-native started');
88
- let res = Fula.listPools()
89
- .then((res) => {
90
- try {
91
- let jsonRes: BType.PoolListResponse = JSON.parse(res);
92
- return jsonRes;
93
- } catch (e) {
94
- try {
95
- return JSON.parse(res);
96
- } catch (e) {
97
- return res;
98
- }
99
- }
100
- })
101
- .catch((err) => {
102
- return err;
103
- });
104
- return res;
105
- };
106
-
107
- /*
108
- joinPool: This function takes two arguments: seed and poolID. The seed is used to identify the account that is joining the pool, and the poolID is the ID of the pool the account is joining. The function returns a promise of an object that contains the account joining the pool and the poolID of the joined pool.
109
- */
110
-
111
- export const joinPool = (poolID: number): Promise<BType.PoolJoinResponse> => {
112
- console.log('joinPool in react-native started', poolID);
113
- let res = Fula.joinPool(poolID.toString())
114
- .then((res) => {
115
- try {
116
- let jsonRes: BType.PoolJoinResponse = JSON.parse(res);
117
- return jsonRes;
118
- } catch (e) {
119
- try {
120
- return JSON.parse(res);
121
- } catch (e) {
122
- console.error('Error parsing res in joining pool:', e);
123
- throw e; // Rethrow the error to maintain the rejection state
124
- }
125
- }
126
- })
127
- .catch((err) => {
128
- console.error('Error joining pool:', err);
129
- throw err; // Rethrow the error to maintain the rejection state
130
- });
131
- return res;
132
- };
133
-
134
- /*
135
- leavePool: This function takes two arguments: seed and poolID. The seed is used to identify the account that is leaving the pool, and the poolID is the ID of the pool the account is leaving. The function returns a promise of an object that contains the `
136
- */
137
-
138
- export const leavePool = (poolID: number): Promise<BType.PoolLeaveResponse> => {
139
- console.log('leavePool in react-native started', poolID);
140
- let res = Fula.leavePool(poolID)
141
- .then((res) => {
142
- try {
143
- let jsonRes: BType.PoolLeaveResponse = JSON.parse(res);
144
- return jsonRes;
145
- } catch (e) {
146
- try {
147
- return JSON.parse(res);
148
- } catch (e) {
149
- return res;
150
- }
151
- }
152
- })
153
- .catch((err) => {
154
- return err;
155
- });
156
- return res;
157
- };
158
-
159
- export const cancelPoolJoin = (
160
- poolID: number
161
- ): Promise<BType.PoolCancelJoinResponse> => {
162
- console.log('cancelPoolJoin in react-native started', poolID);
163
- let res = Fula.cancelPoolJoin(poolID)
164
- .then((res) => {
165
- try {
166
- let jsonRes: BType.PoolCancelJoinResponse = JSON.parse(res);
167
- return jsonRes;
168
- } catch (e) {
169
- try {
170
- return JSON.parse(res);
171
- } catch (e) {
172
- return res;
173
- }
174
- }
175
- })
176
- .catch((err) => {
177
- return err;
178
- });
179
- return res;
180
- };
181
- export const listPoolJoinRequests = (
182
- poolID: number
183
- ): Promise<BType.PoolRequestsResponse> => {
184
- console.log('listPoolJoinRequests in react-native started', poolID);
185
- let res = Fula.listPoolJoinRequests(poolID)
186
- .then((res) => {
187
- try {
188
- let jsonRes: BType.PoolRequestsResponse = JSON.parse(res);
189
- return jsonRes;
190
- } catch (e) {
191
- try {
192
- return JSON.parse(res);
193
- } catch (e) {
194
- return res;
195
- }
196
- }
197
- })
198
- .catch((err) => {
199
- return err;
200
- });
201
- return res;
202
- };
203
-
204
- /*
205
- seed is used to authorize the request.
206
- poolID is the ID of the pool in which the account is requesting to join.
207
- account is the account that is requesting to join the pool.
208
- accept is a boolean value that indicates whether to accept or reject the join request.
209
- It returns a promise of BType.PoolVoteResponse which includes the account and poolID
210
- */
211
- export const votePoolJoinRequest = (
212
- seed: string,
213
- poolID: number,
214
- account: string,
215
- accept: boolean
216
- ): Promise<BType.PoolVoteResponse> => {
217
- console.log(
218
- 'votePoolJoinRequest in react-native started',
219
- seed,
220
- poolID,
221
- account,
222
- accept
223
- );
224
- let res = Fula.votePoolJoinRequest(seed, poolID, account, accept)
225
- .then((res) => {
226
- try {
227
- let jsonRes: BType.PoolVoteResponse = JSON.parse(res);
228
- return jsonRes;
229
- } catch (e) {
230
- try {
231
- return JSON.parse(res);
232
- } catch (e) {
233
- return res;
234
- }
235
- }
236
- })
237
- .catch((err) => {
238
- return err;
239
- });
240
- return res;
241
- };
242
-
243
- /*
244
- It takes four arguments:
245
-
246
- seed is used to authorize the request.
247
- poolID is the ID of the pool in which the replication request is made.
248
- replicationFactor is the number of copies of the content to be stored.
249
- cid is the content identifier of the content to be replicated.
250
- It returns a promise of BType.ManifestUploadResponse which includes the uploader, storage, ManifestMetadata, and poolID
251
- */
252
- export const newReplicationRequest = (
253
- seed: string,
254
- poolID: number,
255
- replicationFactor: number,
256
- cid: string
257
- ): Promise<BType.ManifestUploadResponse> => {
258
- console.log(
259
- 'newReplicationRequest in react-native started',
260
- seed,
261
- poolID,
262
- replicationFactor,
263
- cid
264
- );
265
- let res = Fula.newReplicationRequest(seed, poolID, replicationFactor, cid)
266
- .then((res) => {
267
- try {
268
- let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
269
- return jsonRes;
270
- } catch (e) {
271
- try {
272
- return JSON.parse(res);
273
- } catch (e) {
274
- return res;
275
- }
276
- }
277
- })
278
- .catch((err) => {
279
- return err;
280
- });
281
- return res;
282
- };
283
-
284
- /*
285
- It takes four arguments:
286
-
287
- seed is used to authorize the request.
288
- poolID is the ID of the pool in which the replication request is made.
289
- uploader is the account of the user making the request
290
- cid is the content identifier of the content to be stored.
291
- It returns a promise of BType.ManifestUploadResponse which includes the uploader, storage, ManifestMetadata, and poolID
292
- */
293
- export const newStoreRequest = (
294
- seed: string,
295
- poolID: number,
296
- uploader: string,
297
- cid: string
298
- ): Promise<BType.ManifestUploadResponse> => {
299
- console.log(
300
- 'newStoreRequest in react-native started',
301
- seed,
302
- poolID,
303
- uploader,
304
- cid
305
- );
306
- let res = Fula.newStoreRequest(seed, poolID, uploader, cid)
307
- .then((res) => {
308
- try {
309
- let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
310
- return jsonRes;
311
- } catch (e) {
312
- try {
313
- return JSON.parse(res);
314
- } catch (e) {
315
- return res;
316
- }
317
- }
318
- })
319
- .catch((err) => {
320
- return err;
321
- });
322
- return res;
323
- };
324
-
325
- /*
326
- It takes one argument:
327
-
328
- poolID is the ID of the pool for which the replication requests are listed
329
- It returns a promise of BType.ManifestUploadResponse[] which is an array of the replication requests, including the uploader, storage, ManifestMetadata, and poolID
330
- */
331
- export const listAvailableReplicationRequests = (
332
- poolID: number
333
- ): Promise<BType.ManifestUploadResponse[]> => {
334
- console.log(
335
- 'listAvailableReplicationRequests in react-native started',
336
- poolID
337
- );
338
- let res = Fula.listAvailableReplicationRequests(poolID)
339
- .then((res) => {
340
- try {
341
- let jsonRes: BType.ManifestUploadResponse[] = JSON.parse(res);
342
- return jsonRes;
343
- } catch (e) {
344
- try {
345
- return JSON.parse(res);
346
- } catch (e) {
347
- return res;
348
- }
349
- }
350
- })
351
- .catch((err) => {
352
- return err;
353
- });
354
- return res;
355
- };
356
-
357
- /*
358
- It takes three arguments:
359
-
360
- seed is the seed of the account that is removing the replication request
361
- poolID is the ID of the pool for which the replication request is being removed
362
- cid is the content ID of the replication request being removed
363
- It returns a promise of BType.ManifestUploadResponse which is the removed replication request, including the uploader, storage, ManifestMetadata, and poolID
364
- */
365
- export const removeReplicationRequest = (
366
- seed: string,
367
- poolID: number,
368
- cid: string
369
- ): Promise<BType.ManifestUploadResponse> => {
370
- console.log(
371
- 'removeReplicationRequest in react-native started',
372
- seed,
373
- poolID,
374
- cid
375
- );
376
- let res = Fula.removeReplicationRequest(seed, poolID, cid)
377
- .then((res) => {
378
- try {
379
- let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
380
- return jsonRes;
381
- } catch (e) {
382
- try {
383
- return JSON.parse(res);
384
- } catch (e) {
385
- return res;
386
- }
387
- }
388
- })
389
- .catch((err) => {
390
- return err;
391
- });
392
- return res;
393
- };
394
-
395
- /*
396
- It takes four arguments:
397
-
398
- seed is the seed of the account that is removing the storer
399
- storer is the address of the storer that is being removed
400
- poolID is the ID of the pool for which the storer is being removed
401
- cid is the content ID of the replication request for which the storer is being removed
402
- It returns a promise of BType.ManifestUploadResponse which is the replication request, including the uploader, storage, ManifestMetadata, and poolID after the storer has been removed.
403
- */
404
- export const removeStorer = (
405
- seed: string,
406
- storer: string,
407
- poolID: number,
408
- cid: string
409
- ): Promise<BType.ManifestUploadResponse> => {
410
- console.log(
411
- 'removeStorer in react-native started',
412
- seed,
413
- storer,
414
- poolID,
415
- cid
416
- );
417
- let res = Fula.removeStorer(seed, storer, poolID, cid)
418
- .then((res) => {
419
- try {
420
- let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
421
- return jsonRes;
422
- } catch (e) {
423
- try {
424
- return JSON.parse(res);
425
- } catch (e) {
426
- return res;
427
- }
428
- }
429
- })
430
- .catch((err) => {
431
- return err;
432
- });
433
- return res;
434
- };
435
-
436
- /*
437
- It takes four arguments:
438
-
439
- seed is the seed of the account that is removing the stored replication
440
- uploader is the address of the uploader that is being removed
441
- poolID is the ID of the pool for which the stored replication is being removed
442
- cid is the content ID of the replication request for which the stored replication is being removed
443
- It returns a promise of BType.ManifestUploadResponse which is the replication request, including the uploader, storage, ManifestMetadata, and poolID after the stored replication has been removed.
444
- */
445
- export const removeStoredReplication = (
446
- seed: string,
447
- uploader: string,
448
- poolID: number,
449
- cid: string
450
- ): Promise<BType.ManifestUploadResponse> => {
451
- console.log(
452
- 'removeStoredReplication in react-native started',
453
- seed,
454
- uploader,
455
- poolID,
456
- cid
457
- );
458
- let res = Fula.removeStoredReplication(seed, uploader, poolID, cid)
459
- .then((res) => {
460
- try {
461
- let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
462
- return jsonRes;
463
- } catch (e) {
464
- try {
465
- return JSON.parse(res);
466
- } catch (e) {
467
- return res;
468
- }
469
- }
470
- })
471
- .catch((err) => {
472
- return err;
473
- });
474
- return res;
475
- };
476
-
477
- /*
478
- bloxFreeSpace: This function takes no arguments and returns a promise of an object that contains the blox free space information.
479
- */
480
- export const bloxFreeSpace = (): Promise<BType.BloxFreeSpaceResponse> => {
481
- console.log('bloxFreeSpace in react-native started');
482
- let res = Fula.bloxFreeSpace()
483
- .then((res) => {
484
- try {
485
- let jsonRes: BType.BloxFreeSpaceResponse = JSON.parse(res);
486
- return jsonRes;
487
- } catch (e) {
488
- try {
489
- return JSON.parse(res);
490
- } catch (e) {
491
- return res;
492
- }
493
- }
494
- })
495
- .catch((err) => {
496
- return err;
497
- });
498
- return res;
499
- };
500
-
501
- export const getAccount = (): Promise<BType.GetAccountResponse> => {
502
- console.log('getAccount in react-native started');
503
- let res = Fula.getAccount()
504
- .then((res) => {
505
- try {
506
- let jsonRes: BType.GetAccountResponse = JSON.parse(res);
507
- return jsonRes;
508
- } catch (e) {
509
- try {
510
- return JSON.parse(res);
511
- } catch (e1) {
512
- console.error('Error parsing res in get account:', e1);
513
- throw e1; // Rethrow the error to maintain the rejection state
514
- }
515
- }
516
- })
517
- .catch((err) => {
518
- console.error('Error getting account:', err);
519
- throw err; // Rethrow the error to maintain the rejection state
520
- });
521
- return res;
522
- };
523
-
524
- export const assetsBalance = (
525
- account: string,
526
- assetId: string,
527
- classId: string
528
- ): Promise<BType.AssetsBalanceResponse> => {
529
- console.log('assetsBalance in react-native started');
530
- let res = Fula.assetsBalance(account, assetId, classId)
531
- .then((res) => {
532
- try {
533
- let jsonRes: BType.AssetsBalanceResponse = JSON.parse(res);
534
- return jsonRes;
535
- } catch (e) {
536
- try {
537
- return JSON.parse(res);
538
- } catch (e1) {
539
- console.error('Error parsing res in get asset balance:', e1);
540
- throw e1; // Rethrow the error to maintain the rejection state
541
- }
542
- }
543
- })
544
- .catch((err) => {
545
- console.error('Error getting asset balance:', err);
546
- throw err; // Rethrow the error to maintain the rejection state
547
- });
548
- return res;
549
- };
550
-
551
- export const transferToFula = (
552
- amount: string,
553
- wallet: string,
554
- chain: string
555
- ): Promise<BType.TransferToFulaResponse> => {
556
- console.log('transferToFula in react-native started');
557
- let res = Fula.transferToFula(amount, wallet, chain)
558
- .then((res) => {
559
- try {
560
- let jsonRes: BType.TransferToFulaResponse = JSON.parse(res);
561
- return jsonRes;
562
- } catch (e) {
563
- try {
564
- return JSON.parse(res);
565
- } catch (e1) {
566
- console.error('Error parsing res in transferToFula:', e1);
567
- throw e1; // Rethrow the error to maintain the rejection state
568
- }
569
- }
570
- })
571
- .catch((err) => {
572
- console.error('Error getting transferToFula:', err);
573
- throw err; // Rethrow the error to maintain the rejection state
574
- });
575
- return res;
576
- };
1
+ import Fula from '../interfaces/fulaNativeModule';
2
+ import type * as BType from '../types/blockchain';
3
+
4
+ /*
5
+ createAccount: This function takes a seed argument, which is used to create an account. The seed must start with "/". The function returns a promise of an object that contains the seed and the account that was created.
6
+ */
7
+ export const createAccount = (
8
+ seed: string //seed that is used to create the account. It must start with "/"
9
+ ): Promise<BType.SeededResponse> => {
10
+ console.log('createAccount in react-native started', seed);
11
+ let res1 = Fula.createAccount(seed)
12
+ .then((res) => {
13
+ try {
14
+ let jsonRes: BType.SeededResponse = JSON.parse(res);
15
+ return jsonRes;
16
+ } catch (e) {
17
+ try {
18
+ return JSON.parse(res);
19
+ } catch (e2) {
20
+ return res;
21
+ }
22
+ }
23
+ })
24
+ .catch((err) => {
25
+ return err;
26
+ });
27
+ return res1;
28
+ };
29
+
30
+ /*
31
+ checkAccountExists: This function takes an account argument, and returns a promise of an object that contains the account and a boolean exists flag. If exists is true, it means the account exists, otherwise, the account does not exist
32
+ */
33
+ export const checkAccountExists = (
34
+ account: string
35
+ ): Promise<BType.AccountExistsResponse> => {
36
+ console.log('checkAccountExists in react-native started', account);
37
+ let res1 = Fula.checkAccountExists(account)
38
+ .then((res) => {
39
+ try {
40
+ let jsonRes: BType.AccountExistsResponse = JSON.parse(res);
41
+ return jsonRes;
42
+ } catch (e) {
43
+ try {
44
+ return JSON.parse(res);
45
+ } catch (e2) {
46
+ return res;
47
+ }
48
+ }
49
+ })
50
+ .catch((err) => {
51
+ return err;
52
+ });
53
+ return res1;
54
+ };
55
+
56
+ /*
57
+ createPool: This function takes two arguments: seed and poolName. The seed is used to identify the account that is creating the pool, and the poolName is the name of the pool being created. The function returns a promise of an object that contains the owner of the pool and the poolID of the created pool.
58
+ */
59
+ export const createPool = (
60
+ seed: string,
61
+ poolName: string
62
+ ): Promise<BType.PoolCreateResponse> => {
63
+ console.log('createPool in react-native started', seed, poolName);
64
+ let res1 = Fula.createPool(seed, poolName)
65
+ .then((res) => {
66
+ try {
67
+ let jsonRes: BType.PoolCreateResponse = JSON.parse(res);
68
+ return jsonRes;
69
+ } catch (e) {
70
+ try {
71
+ return JSON.parse(res);
72
+ } catch (e2) {
73
+ return res;
74
+ }
75
+ }
76
+ })
77
+ .catch((err) => {
78
+ return err;
79
+ });
80
+ return res1;
81
+ };
82
+
83
+ /*
84
+ listPools: This function takes no arguments and returns a promise of an object that contains a list of pools. Each pool in the list contains the poolID, owner, poolName, parent, and participants of the pool
85
+ */
86
+ export const listPools = (): Promise<BType.PoolListResponse> => {
87
+ console.log('listPools in react-native started');
88
+ let res1 = Fula.listPools()
89
+ .then((res) => {
90
+ try {
91
+ let jsonRes: BType.PoolListResponse = JSON.parse(res);
92
+ return jsonRes;
93
+ } catch (e) {
94
+ try {
95
+ return JSON.parse(res);
96
+ } catch (e2) {
97
+ return res;
98
+ }
99
+ }
100
+ })
101
+ .catch((err) => {
102
+ return err;
103
+ });
104
+ return res1;
105
+ };
106
+
107
+ /*
108
+ joinPool: This function takes two arguments: seed and poolID. The seed is used to identify the account that is joining the pool, and the poolID is the ID of the pool the account is joining. The function returns a promise of an object that contains the account joining the pool and the poolID of the joined pool.
109
+ */
110
+
111
+ export const joinPool = (poolID: number): Promise<BType.PoolJoinResponse> => {
112
+ console.log('joinPool in react-native started', poolID);
113
+ let res1 = Fula.joinPool(poolID.toString())
114
+ .then((res) => {
115
+ try {
116
+ let jsonRes: BType.PoolJoinResponse = JSON.parse(res);
117
+ return jsonRes;
118
+ } catch (e) {
119
+ try {
120
+ return JSON.parse(res);
121
+ } catch (e2) {
122
+ console.error('Error parsing res in joining pool:', e);
123
+ return res; // Rethrow the error to maintain the rejection state
124
+ }
125
+ }
126
+ })
127
+ .catch((err) => {
128
+ console.error('Error joining pool:', err);
129
+ throw err; // Rethrow the error to maintain the rejection state
130
+ });
131
+ return res1;
132
+ };
133
+
134
+ /*
135
+ leavePool: This function takes two arguments: seed and poolID. The seed is used to identify the account that is leaving the pool, and the poolID is the ID of the pool the account is leaving. The function returns a promise of an object that contains the `
136
+ */
137
+
138
+ export const leavePool = (poolID: number): Promise<BType.PoolLeaveResponse> => {
139
+ console.log('leavePool in react-native started', poolID);
140
+ let res1 = Fula.leavePool(poolID)
141
+ .then((res) => {
142
+ try {
143
+ let jsonRes: BType.PoolLeaveResponse = JSON.parse(res);
144
+ return jsonRes;
145
+ } catch (e) {
146
+ try {
147
+ return JSON.parse(res);
148
+ } catch (e2) {
149
+ return res;
150
+ }
151
+ }
152
+ })
153
+ .catch((err) => {
154
+ return err;
155
+ });
156
+ return res1;
157
+ };
158
+
159
+ export const cancelPoolJoin = (
160
+ poolID: number
161
+ ): Promise<BType.PoolCancelJoinResponse> => {
162
+ console.log('cancelPoolJoin in react-native started', poolID);
163
+ let res1 = Fula.cancelPoolJoin(poolID)
164
+ .then((res) => {
165
+ try {
166
+ let jsonRes: BType.PoolCancelJoinResponse = JSON.parse(res);
167
+ return jsonRes;
168
+ } catch (e) {
169
+ try {
170
+ return JSON.parse(res);
171
+ } catch (e2) {
172
+ return res;
173
+ }
174
+ }
175
+ })
176
+ .catch((err) => {
177
+ return err;
178
+ });
179
+ return res1;
180
+ };
181
+ export const listPoolJoinRequests = (
182
+ poolID: number
183
+ ): Promise<BType.PoolRequestsResponse> => {
184
+ console.log('listPoolJoinRequests in react-native started', poolID);
185
+ let res1 = Fula.listPoolJoinRequests(poolID)
186
+ .then((res) => {
187
+ try {
188
+ let jsonRes: BType.PoolRequestsResponse = JSON.parse(res);
189
+ return jsonRes;
190
+ } catch (e) {
191
+ try {
192
+ return JSON.parse(res);
193
+ } catch (e2) {
194
+ return res;
195
+ }
196
+ }
197
+ })
198
+ .catch((err) => {
199
+ return err;
200
+ });
201
+ return res1;
202
+ };
203
+
204
+ /*
205
+ seed is used to authorize the request.
206
+ poolID is the ID of the pool in which the account is requesting to join.
207
+ account is the account that is requesting to join the pool.
208
+ accept is a boolean value that indicates whether to accept or reject the join request.
209
+ It returns a promise of BType.PoolVoteResponse which includes the account and poolID
210
+ */
211
+ export const votePoolJoinRequest = (
212
+ seed: string,
213
+ poolID: number,
214
+ account: string,
215
+ accept: boolean
216
+ ): Promise<BType.PoolVoteResponse> => {
217
+ console.log(
218
+ 'votePoolJoinRequest in react-native started',
219
+ seed,
220
+ poolID,
221
+ account,
222
+ accept
223
+ );
224
+ let res1 = Fula.votePoolJoinRequest(seed, poolID, account, accept)
225
+ .then((res) => {
226
+ try {
227
+ let jsonRes: BType.PoolVoteResponse = JSON.parse(res);
228
+ return jsonRes;
229
+ } catch (e) {
230
+ try {
231
+ return JSON.parse(res);
232
+ } catch (e2) {
233
+ return res;
234
+ }
235
+ }
236
+ })
237
+ .catch((err) => {
238
+ return err;
239
+ });
240
+ return res1;
241
+ };
242
+
243
+ /*
244
+ It takes four arguments:
245
+
246
+ seed is used to authorize the request.
247
+ poolID is the ID of the pool in which the replication request is made.
248
+ replicationFactor is the number of copies of the content to be stored.
249
+ cid is the content identifier of the content to be replicated.
250
+ It returns a promise of BType.ManifestUploadResponse which includes the uploader, storage, ManifestMetadata, and poolID
251
+ */
252
+ export const newReplicationRequest = (
253
+ seed: string,
254
+ poolID: number,
255
+ replicationFactor: number,
256
+ cid: string
257
+ ): Promise<BType.ManifestUploadResponse> => {
258
+ console.log(
259
+ 'newReplicationRequest in react-native started',
260
+ seed,
261
+ poolID,
262
+ replicationFactor,
263
+ cid
264
+ );
265
+ let res1 = Fula.newReplicationRequest(seed, poolID, replicationFactor, cid)
266
+ .then((res) => {
267
+ try {
268
+ let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
269
+ return jsonRes;
270
+ } catch (e) {
271
+ try {
272
+ return JSON.parse(res);
273
+ } catch (e2) {
274
+ return res;
275
+ }
276
+ }
277
+ })
278
+ .catch((err) => {
279
+ return err;
280
+ });
281
+ return res1;
282
+ };
283
+
284
+ /*
285
+ It takes four arguments:
286
+
287
+ seed is used to authorize the request.
288
+ poolID is the ID of the pool in which the replication request is made.
289
+ uploader is the account of the user making the request
290
+ cid is the content identifier of the content to be stored.
291
+ It returns a promise of BType.ManifestUploadResponse which includes the uploader, storage, ManifestMetadata, and poolID
292
+ */
293
+ export const newStoreRequest = (
294
+ seed: string,
295
+ poolID: number,
296
+ uploader: string,
297
+ cid: string
298
+ ): Promise<BType.ManifestUploadResponse> => {
299
+ console.log(
300
+ 'newStoreRequest in react-native started',
301
+ seed,
302
+ poolID,
303
+ uploader,
304
+ cid
305
+ );
306
+ let res1 = Fula.newStoreRequest(seed, poolID, uploader, cid)
307
+ .then((res) => {
308
+ try {
309
+ let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
310
+ return jsonRes;
311
+ } catch (e) {
312
+ try {
313
+ return JSON.parse(res);
314
+ } catch (e2) {
315
+ return res;
316
+ }
317
+ }
318
+ })
319
+ .catch((err) => {
320
+ return err;
321
+ });
322
+ return res1;
323
+ };
324
+
325
+ /*
326
+ It takes one argument:
327
+
328
+ poolID is the ID of the pool for which the replication requests are listed
329
+ It returns a promise of BType.ManifestUploadResponse[] which is an array of the replication requests, including the uploader, storage, ManifestMetadata, and poolID
330
+ */
331
+ export const listAvailableReplicationRequests = (
332
+ poolID: number
333
+ ): Promise<BType.ManifestUploadResponse[]> => {
334
+ console.log(
335
+ 'listAvailableReplicationRequests in react-native started',
336
+ poolID
337
+ );
338
+ let res1 = Fula.listAvailableReplicationRequests(poolID)
339
+ .then((res) => {
340
+ try {
341
+ let jsonRes: BType.ManifestUploadResponse[] = JSON.parse(res);
342
+ return jsonRes;
343
+ } catch (e) {
344
+ try {
345
+ return JSON.parse(res);
346
+ } catch (e2) {
347
+ return res;
348
+ }
349
+ }
350
+ })
351
+ .catch((err) => {
352
+ return err;
353
+ });
354
+ return res1;
355
+ };
356
+
357
+ /*
358
+ It takes three arguments:
359
+
360
+ seed is the seed of the account that is removing the replication request
361
+ poolID is the ID of the pool for which the replication request is being removed
362
+ cid is the content ID of the replication request being removed
363
+ It returns a promise of BType.ManifestUploadResponse which is the removed replication request, including the uploader, storage, ManifestMetadata, and poolID
364
+ */
365
+ export const removeReplicationRequest = (
366
+ seed: string,
367
+ poolID: number,
368
+ cid: string
369
+ ): Promise<BType.ManifestUploadResponse> => {
370
+ console.log(
371
+ 'removeReplicationRequest in react-native started',
372
+ seed,
373
+ poolID,
374
+ cid
375
+ );
376
+ let res1 = Fula.removeReplicationRequest(seed, poolID, cid)
377
+ .then((res) => {
378
+ try {
379
+ let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
380
+ return jsonRes;
381
+ } catch (e) {
382
+ try {
383
+ return JSON.parse(res);
384
+ } catch (e2) {
385
+ return res;
386
+ }
387
+ }
388
+ })
389
+ .catch((err) => {
390
+ return err;
391
+ });
392
+ return res1;
393
+ };
394
+
395
+ /*
396
+ It takes four arguments:
397
+
398
+ seed is the seed of the account that is removing the storer
399
+ storer is the address of the storer that is being removed
400
+ poolID is the ID of the pool for which the storer is being removed
401
+ cid is the content ID of the replication request for which the storer is being removed
402
+ It returns a promise of BType.ManifestUploadResponse which is the replication request, including the uploader, storage, ManifestMetadata, and poolID after the storer has been removed.
403
+ */
404
+ export const removeStorer = (
405
+ seed: string,
406
+ storer: string,
407
+ poolID: number,
408
+ cid: string
409
+ ): Promise<BType.ManifestUploadResponse> => {
410
+ console.log(
411
+ 'removeStorer in react-native started',
412
+ seed,
413
+ storer,
414
+ poolID,
415
+ cid
416
+ );
417
+ let res1 = Fula.removeStorer(seed, storer, poolID, cid)
418
+ .then((res) => {
419
+ try {
420
+ let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
421
+ return jsonRes;
422
+ } catch (e) {
423
+ try {
424
+ return JSON.parse(res);
425
+ } catch (e2) {
426
+ return res;
427
+ }
428
+ }
429
+ })
430
+ .catch((err) => {
431
+ return err;
432
+ });
433
+ return res1;
434
+ };
435
+
436
+ /*
437
+ It takes four arguments:
438
+
439
+ seed is the seed of the account that is removing the stored replication
440
+ uploader is the address of the uploader that is being removed
441
+ poolID is the ID of the pool for which the stored replication is being removed
442
+ cid is the content ID of the replication request for which the stored replication is being removed
443
+ It returns a promise of BType.ManifestUploadResponse which is the replication request, including the uploader, storage, ManifestMetadata, and poolID after the stored replication has been removed.
444
+ */
445
+ export const removeStoredReplication = (
446
+ seed: string,
447
+ uploader: string,
448
+ poolID: number,
449
+ cid: string
450
+ ): Promise<BType.ManifestUploadResponse> => {
451
+ console.log(
452
+ 'removeStoredReplication in react-native started',
453
+ seed,
454
+ uploader,
455
+ poolID,
456
+ cid
457
+ );
458
+ let res1 = Fula.removeStoredReplication(seed, uploader, poolID, cid)
459
+ .then((res) => {
460
+ try {
461
+ let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
462
+ return jsonRes;
463
+ } catch (e) {
464
+ try {
465
+ return JSON.parse(res);
466
+ } catch (e2) {
467
+ return res;
468
+ }
469
+ }
470
+ })
471
+ .catch((err) => {
472
+ return err;
473
+ });
474
+ return res1;
475
+ };
476
+
477
+ /*
478
+ bloxFreeSpace: This function takes no arguments and returns a promise of an object that contains the blox free space information.
479
+ */
480
+ export const bloxFreeSpace = (): Promise<BType.BloxFreeSpaceResponse> => {
481
+ console.log('bloxFreeSpace in react-native started');
482
+ let res1 = Fula.bloxFreeSpace()
483
+ .then((res) => {
484
+ try {
485
+ let jsonRes: BType.BloxFreeSpaceResponse = JSON.parse(res);
486
+ return jsonRes;
487
+ } catch (e) {
488
+ try {
489
+ return JSON.parse(res);
490
+ } catch (e2) {
491
+ return res;
492
+ }
493
+ }
494
+ })
495
+ .catch((err) => {
496
+ return err;
497
+ });
498
+ return res1;
499
+ };
500
+
501
+ export const getAccount = (): Promise<BType.GetAccountResponse> => {
502
+ console.log('getAccount in react-native started');
503
+ let res = Fula.getAccount()
504
+ .then((res1) => {
505
+ try {
506
+ let jsonRes: BType.GetAccountResponse = JSON.parse(res1);
507
+ return jsonRes;
508
+ } catch (e) {
509
+ try {
510
+ return JSON.parse(res1);
511
+ } catch (e1) {
512
+ console.error('Error parsing res in get account:', e1);
513
+ throw e1; // Rethrow the error to maintain the rejection state
514
+ }
515
+ }
516
+ })
517
+ .catch((err) => {
518
+ console.error('Error getting account:', err);
519
+ throw err; // Rethrow the error to maintain the rejection state
520
+ });
521
+ return res;
522
+ };
523
+
524
+ export const assetsBalance = (
525
+ account: string,
526
+ assetId: number,
527
+ classId: number
528
+ ): Promise<BType.AssetsBalanceResponse> => {
529
+ console.log('assetsBalance in react-native started');
530
+ let res = Fula.assetsBalance(account, assetId, classId)
531
+ .then((res1) => {
532
+ try {
533
+ let jsonRes: BType.AssetsBalanceResponse = JSON.parse(res1);
534
+ return jsonRes;
535
+ } catch (e) {
536
+ try {
537
+ return JSON.parse(res1);
538
+ } catch (e1) {
539
+ console.error('Error parsing res in get asset balance:', e1);
540
+ throw e1; // Rethrow the error to maintain the rejection state
541
+ }
542
+ }
543
+ })
544
+ .catch((err) => {
545
+ console.error('Error getting asset balance:', err);
546
+ throw err; // Rethrow the error to maintain the rejection state
547
+ });
548
+ return res;
549
+ };
550
+
551
+ export const transferToFula = (
552
+ amount: string,
553
+ wallet: string,
554
+ chain: string
555
+ ): Promise<BType.TransferToFulaResponse> => {
556
+ console.log('transferToFula in react-native started');
557
+ let res = Fula.transferToFula(amount, wallet, chain)
558
+ .then((res1) => {
559
+ try {
560
+ let jsonRes: BType.TransferToFulaResponse = JSON.parse(res1);
561
+ return jsonRes;
562
+ } catch (e) {
563
+ try {
564
+ return JSON.parse(res1);
565
+ } catch (e1) {
566
+ console.error('Error parsing res in transferToFula:', e1);
567
+ throw e1; // Rethrow the error to maintain the rejection state
568
+ }
569
+ }
570
+ })
571
+ .catch((err) => {
572
+ console.error('Error getting transferToFula:', err);
573
+ throw err; // Rethrow the error to maintain the rejection state
574
+ });
575
+ return res;
576
+ };