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