@functionland/react-native-fula 1.14.2 → 1.14.4

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.
Files changed (135) hide show
  1. package/LICENSE +20 -21
  2. package/android/build.gradle +90 -50
  3. package/android/gradle.properties +5 -1
  4. package/android/src/main/AndroidManifest.xml +3 -4
  5. package/android/src/main/AndroidManifestNew.xml +2 -0
  6. package/android/src/main/java/land/fx/fula/ConfigRef.java +7 -7
  7. package/android/src/main/java/land/fx/fula/Cryptography.java +62 -62
  8. package/android/src/main/java/land/fx/fula/FulaModule.java +1466 -1466
  9. package/android/src/main/java/land/fx/fula/FulaPackage.java +32 -32
  10. package/android/src/main/java/land/fx/fula/SharedPreferenceHelper.java +65 -65
  11. package/android/src/main/java/land/fx/fula/StaticHelper.java +13 -13
  12. package/android/src/main/java/land/fx/fula/ThreadUtils.java +42 -42
  13. package/ios/Cryptography.swift +36 -0
  14. package/ios/Fula-Bridging-Header.h +3 -0
  15. package/ios/Fula.mm +199 -0
  16. package/ios/Fula.swift +1152 -0
  17. package/ios/{FulaModule.xcodeproj → Fula.xcodeproj}/project.pbxproj +38 -16
  18. package/ios/Fula.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  19. package/ios/Fula.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  20. package/ios/Fula.xcodeproj/project.xcworkspace/xcuserdata/user246549.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  21. package/ios/Fula.xcodeproj/xcuserdata/user246549.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  22. package/ios/UserDataHelper.swift +143 -0
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/commonjs/interfaces/api-lookup.js +266 -266
  25. package/lib/commonjs/interfaces/api-lookup.js.map +1 -1
  26. package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
  27. package/lib/commonjs/protocols/blockchain.js +64 -64
  28. package/lib/commonjs/protocols/blockchain.js.map +1 -1
  29. package/lib/commonjs/protocols/chain-api.js +10 -0
  30. package/lib/commonjs/protocols/chain-api.js.map +1 -1
  31. package/lib/commonjs/protocols/fula.js +99 -99
  32. package/lib/commonjs/protocols/fula.js.map +1 -1
  33. package/lib/commonjs/protocols/fxblox.js +3 -3
  34. package/lib/commonjs/protocols/fxblox.js.map +1 -1
  35. package/lib/commonjs/types/blockchain.js.map +1 -1
  36. package/lib/commonjs/types/fxblox.js.map +1 -1
  37. package/lib/module/index.js +4 -8
  38. package/lib/module/index.js.map +1 -1
  39. package/lib/module/interfaces/api-lookup.js +266 -266
  40. package/lib/module/interfaces/api-lookup.js.map +1 -1
  41. package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
  42. package/lib/module/protocols/blockchain.js +64 -64
  43. package/lib/module/protocols/blockchain.js.map +1 -1
  44. package/lib/module/protocols/chain-api.js +8 -0
  45. package/lib/module/protocols/chain-api.js.map +1 -1
  46. package/lib/module/protocols/fula.js +99 -99
  47. package/lib/module/protocols/fula.js.map +1 -1
  48. package/lib/module/protocols/fxblox.js +3 -3
  49. package/lib/module/protocols/fxblox.js.map +1 -1
  50. package/lib/module/types/blockchain.js.map +1 -1
  51. package/lib/module/types/fxblox.js.map +1 -1
  52. package/lib/typescript/index.d.ts +5 -4
  53. package/lib/typescript/index.d.ts.map +1 -0
  54. package/lib/typescript/interfaces/api-lookup.d.ts +1644 -1643
  55. package/lib/typescript/interfaces/api-lookup.d.ts.map +1 -0
  56. package/lib/typescript/interfaces/fulaNativeModule.d.ts +62 -61
  57. package/lib/typescript/interfaces/fulaNativeModule.d.ts.map +1 -0
  58. package/lib/typescript/protocols/blockchain.d.ts +18 -17
  59. package/lib/typescript/protocols/blockchain.d.ts.map +1 -0
  60. package/lib/typescript/protocols/chain-api.d.ts +7 -6
  61. package/lib/typescript/protocols/chain-api.d.ts.map +1 -0
  62. package/lib/typescript/protocols/fula.d.ts +132 -131
  63. package/lib/typescript/protocols/fula.d.ts.map +1 -0
  64. package/lib/typescript/protocols/fxblox.d.ts +8 -7
  65. package/lib/typescript/protocols/fxblox.d.ts.map +1 -0
  66. package/lib/typescript/types/blockchain.d.ts +69 -68
  67. package/lib/typescript/types/blockchain.d.ts.map +1 -0
  68. package/lib/typescript/types/fxblox.d.ts +9 -8
  69. package/lib/typescript/types/fxblox.d.ts.map +1 -0
  70. package/package.json +43 -28
  71. package/react-native-fula.podspec +47 -19
  72. package/src/index.tsx +4 -4
  73. package/src/interfaces/api-lookup.ts +1647 -1647
  74. package/src/interfaces/fulaNativeModule.ts +122 -122
  75. package/src/protocols/blockchain.ts +504 -504
  76. package/src/protocols/chain-api.ts +8 -0
  77. package/src/protocols/fula.ts +314 -314
  78. package/src/protocols/fxblox.ts +49 -49
  79. package/src/types/blockchain.ts +80 -80
  80. package/src/types/fxblox.ts +8 -8
  81. package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
  82. package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
  83. package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
  84. package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  85. package/android/.gradle/7.5.1/dependencies-accessors/gc.properties +0 -0
  86. package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
  87. package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
  88. package/android/.gradle/7.5.1/fileChanges/last-build.bin +0 -0
  89. package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
  90. package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
  91. package/android/.gradle/7.5.1/fileHashes/resourceHashesCache.bin +0 -0
  92. package/android/.gradle/7.5.1/gc.properties +0 -0
  93. package/android/.gradle/7.6/checksums/checksums.lock +0 -0
  94. package/android/.gradle/7.6/checksums/md5-checksums.bin +0 -0
  95. package/android/.gradle/7.6/checksums/sha1-checksums.bin +0 -0
  96. package/android/.gradle/7.6/dependencies-accessors/dependencies-accessors.lock +0 -0
  97. package/android/.gradle/7.6/dependencies-accessors/gc.properties +0 -0
  98. package/android/.gradle/7.6/executionHistory/executionHistory.bin +0 -0
  99. package/android/.gradle/7.6/executionHistory/executionHistory.lock +0 -0
  100. package/android/.gradle/7.6/fileChanges/last-build.bin +0 -0
  101. package/android/.gradle/7.6/fileHashes/fileHashes.bin +0 -0
  102. package/android/.gradle/7.6/fileHashes/fileHashes.lock +0 -0
  103. package/android/.gradle/7.6/fileHashes/resourceHashesCache.bin +0 -0
  104. package/android/.gradle/7.6/gc.properties +0 -0
  105. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  106. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  107. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  108. package/android/.gradle/file-system.probe +0 -0
  109. package/android/.gradle/vcs-1/gc.properties +0 -0
  110. package/android/.idea/compiler.xml +0 -6
  111. package/android/.idea/gradle.xml +0 -20
  112. package/android/.idea/jarRepositories.xml +0 -50
  113. package/android/.idea/misc.xml +0 -10
  114. package/android/.idea/sonarlint/issuestore/2/a/2afbb999f001938c88fa43fc2ef52abf0f8213e4 +0 -0
  115. package/android/.idea/sonarlint/issuestore/2/e/2e09eb0f0df666781fdff057a0af6101364ebe2f +0 -0
  116. package/android/.idea/sonarlint/issuestore/6/2/62149c3f7c3a14d7a77778e558d274e8c00a5585 +0 -0
  117. package/android/.idea/sonarlint/issuestore/8/0/80a78d662b0659428eb880336106c3c5fc3f0714 +0 -0
  118. package/android/.idea/sonarlint/issuestore/d/2/d2865ef8fc01c40e9fd82977fde2c8378fad0b12 +0 -0
  119. package/android/.idea/sonarlint/issuestore/f/b/fbe448ebfc3eb2d4e308f6b8b043666f5b57235e +0 -0
  120. package/android/.idea/sonarlint/issuestore/index.pb +0 -13
  121. package/android/.idea/sonarlint/securityhotspotstore/2/a/2afbb999f001938c88fa43fc2ef52abf0f8213e4 +0 -0
  122. package/android/.idea/sonarlint/securityhotspotstore/2/e/2e09eb0f0df666781fdff057a0af6101364ebe2f +0 -0
  123. package/android/.idea/sonarlint/securityhotspotstore/6/2/62149c3f7c3a14d7a77778e558d274e8c00a5585 +0 -0
  124. package/android/.idea/sonarlint/securityhotspotstore/8/0/80a78d662b0659428eb880336106c3c5fc3f0714 +0 -0
  125. package/android/.idea/sonarlint/securityhotspotstore/d/2/d2865ef8fc01c40e9fd82977fde2c8378fad0b12 +0 -0
  126. package/android/.idea/sonarlint/securityhotspotstore/f/b/fbe448ebfc3eb2d4e308f6b8b043666f5b57235e +0 -0
  127. package/android/.idea/sonarlint/securityhotspotstore/index.pb +0 -13
  128. package/android/.idea/vcs.xml +0 -6
  129. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  130. package/android/gradle/wrapper/gradle-wrapper.properties +0 -7
  131. package/android/gradlew +0 -291
  132. package/android/gradlew.bat +0 -91
  133. package/android/local.properties +0 -8
  134. package/ios/FulaModule.h +0 -10
  135. package/ios/FulaModule.m +0 -149
@@ -1,504 +1,504 @@
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 = (
112
- seed: string,
113
- poolID: number
114
- ): Promise<BType.PoolJoinResponse> => {
115
- console.log('joinPool in react-native started', seed, poolID);
116
- let res = Fula.joinPool(seed, poolID)
117
- .then((res) => {
118
- try {
119
- let jsonRes: BType.PoolJoinResponse = JSON.parse(res);
120
- return jsonRes;
121
- } catch (e) {
122
- try {
123
- return JSON.parse(res);
124
- } catch (e) {
125
- return res;
126
- }
127
- }
128
- })
129
- .catch((err) => {
130
- return err;
131
- });
132
- return res;
133
- };
134
-
135
- /*
136
- 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 `
137
- */
138
-
139
- export const leavePool = (
140
- seed: string,
141
- poolID: number
142
- ): Promise<BType.PoolLeaveResponse> => {
143
- console.log('leavePool in react-native started', seed, poolID);
144
- let res = Fula.leavePool(seed, poolID)
145
- .then((res) => {
146
- try {
147
- let jsonRes: BType.PoolLeaveResponse = JSON.parse(res);
148
- return jsonRes;
149
- } catch (e) {
150
- try {
151
- return JSON.parse(res);
152
- } catch (e) {
153
- return res;
154
- }
155
- }
156
- })
157
- .catch((err) => {
158
- return err;
159
- });
160
- return res;
161
- };
162
-
163
- export const cancelPoolJoin = (
164
- seed: string,
165
- poolID: number
166
- ): Promise<BType.PoolCancelJoinResponse> => {
167
- console.log('cancelPoolJoin in react-native started', seed, poolID);
168
- let res = Fula.cancelPoolJoin(seed, poolID)
169
- .then((res) => {
170
- try {
171
- let jsonRes: BType.PoolCancelJoinResponse = JSON.parse(res);
172
- return jsonRes;
173
- } catch (e) {
174
- try {
175
- return JSON.parse(res);
176
- } catch (e) {
177
- return res;
178
- }
179
- }
180
- })
181
- .catch((err) => {
182
- return err;
183
- });
184
- return res;
185
- };
186
- export const listPoolJoinRequests = (
187
- poolID: number
188
- ): Promise<BType.PoolRequestsResponse> => {
189
- console.log('listPoolJoinRequests in react-native started', poolID);
190
- let res = Fula.listPoolJoinRequests(poolID)
191
- .then((res) => {
192
- try {
193
- let jsonRes: BType.PoolRequestsResponse = JSON.parse(res);
194
- return jsonRes;
195
- } catch (e) {
196
- try {
197
- return JSON.parse(res);
198
- } catch (e) {
199
- return res;
200
- }
201
- }
202
- })
203
- .catch((err) => {
204
- return err;
205
- });
206
- return res;
207
- };
208
-
209
- /*
210
- seed is used to authorize the request.
211
- poolID is the ID of the pool in which the account is requesting to join.
212
- account is the account that is requesting to join the pool.
213
- accept is a boolean value that indicates whether to accept or reject the join request.
214
- It returns a promise of BType.PoolVoteResponse which includes the account and poolID
215
- */
216
- export const votePoolJoinRequest = (
217
- seed: string,
218
- poolID: number,
219
- account: string,
220
- accept: boolean
221
- ): Promise<BType.PoolVoteResponse> => {
222
- console.log(
223
- 'votePoolJoinRequest in react-native started',
224
- seed,
225
- poolID,
226
- account,
227
- accept
228
- );
229
- let res = Fula.votePoolJoinRequest(seed, poolID, account, accept)
230
- .then((res) => {
231
- try {
232
- let jsonRes: BType.PoolVoteResponse = JSON.parse(res);
233
- return jsonRes;
234
- } catch (e) {
235
- try {
236
- return JSON.parse(res);
237
- } catch (e) {
238
- return res;
239
- }
240
- }
241
- })
242
- .catch((err) => {
243
- return err;
244
- });
245
- return res;
246
- };
247
-
248
- /*
249
- It takes four arguments:
250
-
251
- seed is used to authorize the request.
252
- poolID is the ID of the pool in which the replication request is made.
253
- replicationFactor is the number of copies of the content to be stored.
254
- cid is the content identifier of the content to be replicated.
255
- It returns a promise of BType.ManifestUploadResponse which includes the uploader, storage, ManifestMetadata, and poolID
256
- */
257
- export const newReplicationRequest = (
258
- seed: string,
259
- poolID: number,
260
- replicationFactor: number,
261
- cid: string
262
- ): Promise<BType.ManifestUploadResponse> => {
263
- console.log(
264
- 'newReplicationRequest in react-native started',
265
- seed,
266
- poolID,
267
- replicationFactor,
268
- cid
269
- );
270
- let res = Fula.newReplicationRequest(seed, poolID, replicationFactor, cid)
271
- .then((res) => {
272
- try {
273
- let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
274
- return jsonRes;
275
- } catch (e) {
276
- try {
277
- return JSON.parse(res);
278
- } catch (e) {
279
- return res;
280
- }
281
- }
282
- })
283
- .catch((err) => {
284
- return err;
285
- });
286
- return res;
287
- };
288
-
289
- /*
290
- It takes four arguments:
291
-
292
- seed is used to authorize the request.
293
- poolID is the ID of the pool in which the replication request is made.
294
- uploader is the account of the user making the request
295
- cid is the content identifier of the content to be stored.
296
- It returns a promise of BType.ManifestUploadResponse which includes the uploader, storage, ManifestMetadata, and poolID
297
- */
298
- export const newStoreRequest = (
299
- seed: string,
300
- poolID: number,
301
- uploader: string,
302
- cid: string
303
- ): Promise<BType.ManifestUploadResponse> => {
304
- console.log(
305
- 'newStoreRequest in react-native started',
306
- seed,
307
- poolID,
308
- uploader,
309
- cid
310
- );
311
- let res = Fula.newStoreRequest(seed, poolID, uploader, cid)
312
- .then((res) => {
313
- try {
314
- let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
315
- return jsonRes;
316
- } catch (e) {
317
- try {
318
- return JSON.parse(res);
319
- } catch (e) {
320
- return res;
321
- }
322
- }
323
- })
324
- .catch((err) => {
325
- return err;
326
- });
327
- return res;
328
- };
329
-
330
- /*
331
- It takes one argument:
332
-
333
- poolID is the ID of the pool for which the replication requests are listed
334
- It returns a promise of BType.ManifestUploadResponse[] which is an array of the replication requests, including the uploader, storage, ManifestMetadata, and poolID
335
- */
336
- export const listAvailableReplicationRequests = (
337
- poolID: number
338
- ): Promise<BType.ManifestUploadResponse[]> => {
339
- console.log(
340
- 'listAvailableReplicationRequests in react-native started',
341
- poolID
342
- );
343
- let res = Fula.listAvailableReplicationRequests(poolID)
344
- .then((res) => {
345
- try {
346
- let jsonRes: BType.ManifestUploadResponse[] = JSON.parse(res);
347
- return jsonRes;
348
- } catch (e) {
349
- try {
350
- return JSON.parse(res);
351
- } catch (e) {
352
- return res;
353
- }
354
- }
355
- })
356
- .catch((err) => {
357
- return err;
358
- });
359
- return res;
360
- };
361
-
362
- /*
363
- It takes three arguments:
364
-
365
- seed is the seed of the account that is removing the replication request
366
- poolID is the ID of the pool for which the replication request is being removed
367
- cid is the content ID of the replication request being removed
368
- It returns a promise of BType.ManifestUploadResponse which is the removed replication request, including the uploader, storage, ManifestMetadata, and poolID
369
- */
370
- export const removeReplicationRequest = (
371
- seed: string,
372
- poolID: number,
373
- cid: string
374
- ): Promise<BType.ManifestUploadResponse> => {
375
- console.log(
376
- 'removeReplicationRequest in react-native started',
377
- seed,
378
- poolID,
379
- cid
380
- );
381
- let res = Fula.removeReplicationRequest(seed, poolID, cid)
382
- .then((res) => {
383
- try {
384
- let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
385
- return jsonRes;
386
- } catch (e) {
387
- try {
388
- return JSON.parse(res);
389
- } catch (e) {
390
- return res;
391
- }
392
- }
393
- })
394
- .catch((err) => {
395
- return err;
396
- });
397
- return res;
398
- };
399
-
400
- /*
401
- It takes four arguments:
402
-
403
- seed is the seed of the account that is removing the storer
404
- storer is the address of the storer that is being removed
405
- poolID is the ID of the pool for which the storer is being removed
406
- cid is the content ID of the replication request for which the storer is being removed
407
- 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.
408
- */
409
- export const removeStorer = (
410
- seed: string,
411
- storer: string,
412
- poolID: number,
413
- cid: string
414
- ): Promise<BType.ManifestUploadResponse> => {
415
- console.log(
416
- 'removeStorer in react-native started',
417
- seed,
418
- storer,
419
- poolID,
420
- cid
421
- );
422
- let res = Fula.removeStorer(seed, storer, poolID, cid)
423
- .then((res) => {
424
- try {
425
- let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
426
- return jsonRes;
427
- } catch (e) {
428
- try {
429
- return JSON.parse(res);
430
- } catch (e) {
431
- return res;
432
- }
433
- }
434
- })
435
- .catch((err) => {
436
- return err;
437
- });
438
- return res;
439
- };
440
-
441
- /*
442
- It takes four arguments:
443
-
444
- seed is the seed of the account that is removing the stored replication
445
- uploader is the address of the uploader that is being removed
446
- poolID is the ID of the pool for which the stored replication is being removed
447
- cid is the content ID of the replication request for which the stored replication is being removed
448
- 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.
449
- */
450
- export const removeStoredReplication = (
451
- seed: string,
452
- uploader: string,
453
- poolID: number,
454
- cid: string
455
- ): Promise<BType.ManifestUploadResponse> => {
456
- console.log(
457
- 'removeStoredReplication in react-native started',
458
- seed,
459
- uploader,
460
- poolID,
461
- cid
462
- );
463
- let res = Fula.removeStoredReplication(seed, uploader, poolID, cid)
464
- .then((res) => {
465
- try {
466
- let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
467
- return jsonRes;
468
- } catch (e) {
469
- try {
470
- return JSON.parse(res);
471
- } catch (e) {
472
- return res;
473
- }
474
- }
475
- })
476
- .catch((err) => {
477
- return err;
478
- });
479
- return res;
480
- };
481
-
482
- /*
483
- bloxFreeSpace: This function takes no arguments and returns a promise of an object that contains the blox free space information.
484
- */
485
- export const bloxFreeSpace = (): Promise<BType.BloxFreeSpaceResponse> => {
486
- console.log('bloxFreeSpace in react-native started');
487
- let res = Fula.bloxFreeSpace()
488
- .then((res) => {
489
- try {
490
- let jsonRes: BType.BloxFreeSpaceResponse = JSON.parse(res);
491
- return jsonRes;
492
- } catch (e) {
493
- try {
494
- return JSON.parse(res);
495
- } catch (e) {
496
- return res;
497
- }
498
- }
499
- })
500
- .catch((err) => {
501
- return err;
502
- });
503
- return res;
504
- };
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 = (
112
+ seed: string,
113
+ poolID: number
114
+ ): Promise<BType.PoolJoinResponse> => {
115
+ console.log('joinPool in react-native started', seed, poolID);
116
+ let res = Fula.joinPool(seed, poolID)
117
+ .then((res) => {
118
+ try {
119
+ let jsonRes: BType.PoolJoinResponse = JSON.parse(res);
120
+ return jsonRes;
121
+ } catch (e) {
122
+ try {
123
+ return JSON.parse(res);
124
+ } catch (e) {
125
+ return res;
126
+ }
127
+ }
128
+ })
129
+ .catch((err) => {
130
+ return err;
131
+ });
132
+ return res;
133
+ };
134
+
135
+ /*
136
+ 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 `
137
+ */
138
+
139
+ export const leavePool = (
140
+ seed: string,
141
+ poolID: number
142
+ ): Promise<BType.PoolLeaveResponse> => {
143
+ console.log('leavePool in react-native started', seed, poolID);
144
+ let res = Fula.leavePool(seed, poolID)
145
+ .then((res) => {
146
+ try {
147
+ let jsonRes: BType.PoolLeaveResponse = JSON.parse(res);
148
+ return jsonRes;
149
+ } catch (e) {
150
+ try {
151
+ return JSON.parse(res);
152
+ } catch (e) {
153
+ return res;
154
+ }
155
+ }
156
+ })
157
+ .catch((err) => {
158
+ return err;
159
+ });
160
+ return res;
161
+ };
162
+
163
+ export const cancelPoolJoin = (
164
+ seed: string,
165
+ poolID: number
166
+ ): Promise<BType.PoolCancelJoinResponse> => {
167
+ console.log('cancelPoolJoin in react-native started', seed, poolID);
168
+ let res = Fula.cancelPoolJoin(seed, poolID)
169
+ .then((res) => {
170
+ try {
171
+ let jsonRes: BType.PoolCancelJoinResponse = JSON.parse(res);
172
+ return jsonRes;
173
+ } catch (e) {
174
+ try {
175
+ return JSON.parse(res);
176
+ } catch (e) {
177
+ return res;
178
+ }
179
+ }
180
+ })
181
+ .catch((err) => {
182
+ return err;
183
+ });
184
+ return res;
185
+ };
186
+ export const listPoolJoinRequests = (
187
+ poolID: number
188
+ ): Promise<BType.PoolRequestsResponse> => {
189
+ console.log('listPoolJoinRequests in react-native started', poolID);
190
+ let res = Fula.listPoolJoinRequests(poolID)
191
+ .then((res) => {
192
+ try {
193
+ let jsonRes: BType.PoolRequestsResponse = JSON.parse(res);
194
+ return jsonRes;
195
+ } catch (e) {
196
+ try {
197
+ return JSON.parse(res);
198
+ } catch (e) {
199
+ return res;
200
+ }
201
+ }
202
+ })
203
+ .catch((err) => {
204
+ return err;
205
+ });
206
+ return res;
207
+ };
208
+
209
+ /*
210
+ seed is used to authorize the request.
211
+ poolID is the ID of the pool in which the account is requesting to join.
212
+ account is the account that is requesting to join the pool.
213
+ accept is a boolean value that indicates whether to accept or reject the join request.
214
+ It returns a promise of BType.PoolVoteResponse which includes the account and poolID
215
+ */
216
+ export const votePoolJoinRequest = (
217
+ seed: string,
218
+ poolID: number,
219
+ account: string,
220
+ accept: boolean
221
+ ): Promise<BType.PoolVoteResponse> => {
222
+ console.log(
223
+ 'votePoolJoinRequest in react-native started',
224
+ seed,
225
+ poolID,
226
+ account,
227
+ accept
228
+ );
229
+ let res = Fula.votePoolJoinRequest(seed, poolID, account, accept)
230
+ .then((res) => {
231
+ try {
232
+ let jsonRes: BType.PoolVoteResponse = JSON.parse(res);
233
+ return jsonRes;
234
+ } catch (e) {
235
+ try {
236
+ return JSON.parse(res);
237
+ } catch (e) {
238
+ return res;
239
+ }
240
+ }
241
+ })
242
+ .catch((err) => {
243
+ return err;
244
+ });
245
+ return res;
246
+ };
247
+
248
+ /*
249
+ It takes four arguments:
250
+
251
+ seed is used to authorize the request.
252
+ poolID is the ID of the pool in which the replication request is made.
253
+ replicationFactor is the number of copies of the content to be stored.
254
+ cid is the content identifier of the content to be replicated.
255
+ It returns a promise of BType.ManifestUploadResponse which includes the uploader, storage, ManifestMetadata, and poolID
256
+ */
257
+ export const newReplicationRequest = (
258
+ seed: string,
259
+ poolID: number,
260
+ replicationFactor: number,
261
+ cid: string
262
+ ): Promise<BType.ManifestUploadResponse> => {
263
+ console.log(
264
+ 'newReplicationRequest in react-native started',
265
+ seed,
266
+ poolID,
267
+ replicationFactor,
268
+ cid
269
+ );
270
+ let res = Fula.newReplicationRequest(seed, poolID, replicationFactor, cid)
271
+ .then((res) => {
272
+ try {
273
+ let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
274
+ return jsonRes;
275
+ } catch (e) {
276
+ try {
277
+ return JSON.parse(res);
278
+ } catch (e) {
279
+ return res;
280
+ }
281
+ }
282
+ })
283
+ .catch((err) => {
284
+ return err;
285
+ });
286
+ return res;
287
+ };
288
+
289
+ /*
290
+ It takes four arguments:
291
+
292
+ seed is used to authorize the request.
293
+ poolID is the ID of the pool in which the replication request is made.
294
+ uploader is the account of the user making the request
295
+ cid is the content identifier of the content to be stored.
296
+ It returns a promise of BType.ManifestUploadResponse which includes the uploader, storage, ManifestMetadata, and poolID
297
+ */
298
+ export const newStoreRequest = (
299
+ seed: string,
300
+ poolID: number,
301
+ uploader: string,
302
+ cid: string
303
+ ): Promise<BType.ManifestUploadResponse> => {
304
+ console.log(
305
+ 'newStoreRequest in react-native started',
306
+ seed,
307
+ poolID,
308
+ uploader,
309
+ cid
310
+ );
311
+ let res = Fula.newStoreRequest(seed, poolID, uploader, cid)
312
+ .then((res) => {
313
+ try {
314
+ let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
315
+ return jsonRes;
316
+ } catch (e) {
317
+ try {
318
+ return JSON.parse(res);
319
+ } catch (e) {
320
+ return res;
321
+ }
322
+ }
323
+ })
324
+ .catch((err) => {
325
+ return err;
326
+ });
327
+ return res;
328
+ };
329
+
330
+ /*
331
+ It takes one argument:
332
+
333
+ poolID is the ID of the pool for which the replication requests are listed
334
+ It returns a promise of BType.ManifestUploadResponse[] which is an array of the replication requests, including the uploader, storage, ManifestMetadata, and poolID
335
+ */
336
+ export const listAvailableReplicationRequests = (
337
+ poolID: number
338
+ ): Promise<BType.ManifestUploadResponse[]> => {
339
+ console.log(
340
+ 'listAvailableReplicationRequests in react-native started',
341
+ poolID
342
+ );
343
+ let res = Fula.listAvailableReplicationRequests(poolID)
344
+ .then((res) => {
345
+ try {
346
+ let jsonRes: BType.ManifestUploadResponse[] = JSON.parse(res);
347
+ return jsonRes;
348
+ } catch (e) {
349
+ try {
350
+ return JSON.parse(res);
351
+ } catch (e) {
352
+ return res;
353
+ }
354
+ }
355
+ })
356
+ .catch((err) => {
357
+ return err;
358
+ });
359
+ return res;
360
+ };
361
+
362
+ /*
363
+ It takes three arguments:
364
+
365
+ seed is the seed of the account that is removing the replication request
366
+ poolID is the ID of the pool for which the replication request is being removed
367
+ cid is the content ID of the replication request being removed
368
+ It returns a promise of BType.ManifestUploadResponse which is the removed replication request, including the uploader, storage, ManifestMetadata, and poolID
369
+ */
370
+ export const removeReplicationRequest = (
371
+ seed: string,
372
+ poolID: number,
373
+ cid: string
374
+ ): Promise<BType.ManifestUploadResponse> => {
375
+ console.log(
376
+ 'removeReplicationRequest in react-native started',
377
+ seed,
378
+ poolID,
379
+ cid
380
+ );
381
+ let res = Fula.removeReplicationRequest(seed, poolID, cid)
382
+ .then((res) => {
383
+ try {
384
+ let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
385
+ return jsonRes;
386
+ } catch (e) {
387
+ try {
388
+ return JSON.parse(res);
389
+ } catch (e) {
390
+ return res;
391
+ }
392
+ }
393
+ })
394
+ .catch((err) => {
395
+ return err;
396
+ });
397
+ return res;
398
+ };
399
+
400
+ /*
401
+ It takes four arguments:
402
+
403
+ seed is the seed of the account that is removing the storer
404
+ storer is the address of the storer that is being removed
405
+ poolID is the ID of the pool for which the storer is being removed
406
+ cid is the content ID of the replication request for which the storer is being removed
407
+ 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.
408
+ */
409
+ export const removeStorer = (
410
+ seed: string,
411
+ storer: string,
412
+ poolID: number,
413
+ cid: string
414
+ ): Promise<BType.ManifestUploadResponse> => {
415
+ console.log(
416
+ 'removeStorer in react-native started',
417
+ seed,
418
+ storer,
419
+ poolID,
420
+ cid
421
+ );
422
+ let res = Fula.removeStorer(seed, storer, poolID, cid)
423
+ .then((res) => {
424
+ try {
425
+ let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
426
+ return jsonRes;
427
+ } catch (e) {
428
+ try {
429
+ return JSON.parse(res);
430
+ } catch (e) {
431
+ return res;
432
+ }
433
+ }
434
+ })
435
+ .catch((err) => {
436
+ return err;
437
+ });
438
+ return res;
439
+ };
440
+
441
+ /*
442
+ It takes four arguments:
443
+
444
+ seed is the seed of the account that is removing the stored replication
445
+ uploader is the address of the uploader that is being removed
446
+ poolID is the ID of the pool for which the stored replication is being removed
447
+ cid is the content ID of the replication request for which the stored replication is being removed
448
+ 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.
449
+ */
450
+ export const removeStoredReplication = (
451
+ seed: string,
452
+ uploader: string,
453
+ poolID: number,
454
+ cid: string
455
+ ): Promise<BType.ManifestUploadResponse> => {
456
+ console.log(
457
+ 'removeStoredReplication in react-native started',
458
+ seed,
459
+ uploader,
460
+ poolID,
461
+ cid
462
+ );
463
+ let res = Fula.removeStoredReplication(seed, uploader, poolID, cid)
464
+ .then((res) => {
465
+ try {
466
+ let jsonRes: BType.ManifestUploadResponse = JSON.parse(res);
467
+ return jsonRes;
468
+ } catch (e) {
469
+ try {
470
+ return JSON.parse(res);
471
+ } catch (e) {
472
+ return res;
473
+ }
474
+ }
475
+ })
476
+ .catch((err) => {
477
+ return err;
478
+ });
479
+ return res;
480
+ };
481
+
482
+ /*
483
+ bloxFreeSpace: This function takes no arguments and returns a promise of an object that contains the blox free space information.
484
+ */
485
+ export const bloxFreeSpace = (): Promise<BType.BloxFreeSpaceResponse> => {
486
+ console.log('bloxFreeSpace in react-native started');
487
+ let res = Fula.bloxFreeSpace()
488
+ .then((res) => {
489
+ try {
490
+ let jsonRes: BType.BloxFreeSpaceResponse = JSON.parse(res);
491
+ return jsonRes;
492
+ } catch (e) {
493
+ try {
494
+ return JSON.parse(res);
495
+ } catch (e) {
496
+ return res;
497
+ }
498
+ }
499
+ })
500
+ .catch((err) => {
501
+ return err;
502
+ });
503
+ return res;
504
+ };