@functionland/react-native-fula 1.32.0 → 1.33.1

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 (35) hide show
  1. package/android/build.gradle +110 -110
  2. package/android/src/main/java/land/fx/fula/FulaModule.java +1473 -1438
  3. package/ios/Fula.mm +16 -0
  4. package/ios/Fula.swift +114 -43
  5. package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
  6. package/lib/commonjs/protocols/blockchain.js +23 -1
  7. package/lib/commonjs/protocols/blockchain.js.map +1 -1
  8. package/lib/commonjs/protocols/chain-api.js +13 -11
  9. package/lib/commonjs/protocols/chain-api.js.map +1 -1
  10. package/lib/commonjs/protocols/fxblox.js +26 -7
  11. package/lib/commonjs/protocols/fxblox.js.map +1 -1
  12. package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
  13. package/lib/module/protocols/blockchain.js +21 -0
  14. package/lib/module/protocols/blockchain.js.map +1 -1
  15. package/lib/module/protocols/chain-api.js +13 -11
  16. package/lib/module/protocols/chain-api.js.map +1 -1
  17. package/lib/module/protocols/fxblox.js +24 -6
  18. package/lib/module/protocols/fxblox.js.map +1 -1
  19. package/lib/typescript/interfaces/fulaNativeModule.d.ts +4 -2
  20. package/lib/typescript/interfaces/fulaNativeModule.d.ts.map +1 -1
  21. package/lib/typescript/protocols/blockchain.d.ts +1 -0
  22. package/lib/typescript/protocols/blockchain.d.ts.map +1 -1
  23. package/lib/typescript/protocols/fxblox.d.ts +1 -0
  24. package/lib/typescript/protocols/fxblox.d.ts.map +1 -1
  25. package/lib/typescript/types/blockchain.d.ts +4 -0
  26. package/lib/typescript/types/blockchain.d.ts.map +1 -1
  27. package/lib/typescript/types/fxblox.d.ts +4 -0
  28. package/lib/typescript/types/fxblox.d.ts.map +1 -1
  29. package/package.json +1 -1
  30. package/src/interfaces/fulaNativeModule.ts +14 -4
  31. package/src/protocols/blockchain.ts +27 -0
  32. package/src/protocols/chain-api.ts +289 -289
  33. package/src/protocols/fxblox.ts +27 -6
  34. package/src/types/blockchain.ts +5 -0
  35. package/src/types/fxblox.ts +5 -0
@@ -1,289 +1,289 @@
1
- import { default as EventTypes } from '../interfaces/lookup';
2
-
3
- import { ApiPromise, WsProvider } from '@polkadot/api';
4
- import { Keyring } from '@polkadot/keyring';
5
- const { cryptoWaitReady } = require('@polkadot/util-crypto');
6
- import type * as BType from '../types/blockchain';
7
-
8
- const types = {
9
- FulaPoolPool: EventTypes.FulaPoolPool,
10
- };
11
-
12
- export const init = async (
13
- wsAddress: string = 'wss://node3.functionyard.fula.network'
14
- ): Promise<ApiPromise> => {
15
- const provider = new WsProvider(wsAddress);
16
- const api = await ApiPromise.create({ types, provider }).catch((err) => {
17
- console.log(err);
18
- return Promise.reject(err);
19
- });
20
- return api;
21
- };
22
-
23
- export const disconnectApi = async (api: ApiPromise): Promise<void> => {
24
- await api.disconnect();
25
- };
26
-
27
- /*function addDoubleSlashToSeed(seed: string): string {
28
- return seed.startsWith('//') ? seed : '//' + seed;
29
- }*/
30
-
31
- /*
32
- createManifest: This function batch uploads manifests
33
- */
34
- function serialize(obj: any): string {
35
- return JSON.stringify(obj);
36
- }
37
-
38
- function createManifest(
39
- cids: string[],
40
- poolId: number,
41
- replicationFactor: number = 4
42
- ): {
43
- manifest: string[]; // or string[]
44
- cids: string[]; // or string[]
45
- poolId: number[];
46
- replicationFactor: number[];
47
- } {
48
- const manifest_metadata = cids.map((cid) => ({
49
- job: {
50
- work: 'Storage',
51
- engine: 'IPFS',
52
- uri: cid,
53
- },
54
- }));
55
-
56
- // Serialize manifest_metadata to Uint8Array or string
57
- const serializedManifest = manifest_metadata.map((item) => serialize(item)); // Implement `serialize` accordingly
58
-
59
- // Serialize cids to Uint8Array or string
60
- const serializedCids = cids.map((cid) => serialize(cid)); // Implement `serialize` accordingly
61
-
62
- // Create arrays for `poolId` and `replicationFactor`
63
- const poolIds = new Array(cids.length).fill(poolId);
64
- const replicationFactors = new Array(cids.length).fill(replicationFactor);
65
-
66
- const batchUploadManifest = {
67
- manifest: serializedManifest,
68
- cids: serializedCids,
69
- poolId: poolIds,
70
- replicationFactor: replicationFactors,
71
- };
72
-
73
- return batchUploadManifest;
74
- }
75
-
76
- export const batchUploadManifest = async (
77
- api: ApiPromise | undefined,
78
- seed: string,
79
- cids_i: string[],
80
- poolId_i: number,
81
- replicationFactor_i: number = 4
82
- ): Promise<{ hash: string }> => {
83
- const { manifest, cids, poolId, replicationFactor } = createManifest(
84
- cids_i,
85
- poolId_i,
86
- replicationFactor_i
87
- );
88
-
89
- console.log('uploadManifest in react-native started');
90
- try {
91
- if (api === undefined) {
92
- api = await init();
93
- }
94
-
95
- // Simple transaction
96
- const keyring = new Keyring({ type: 'sr25519' });
97
- const userKey = keyring.addFromUri(seed, { name: 'account' }, 'sr25519');
98
- console.log(
99
- `${userKey.meta.name}: has address ${userKey.address} with publicKey [${userKey.publicKey}]`
100
- );
101
- if (api?.tx?.fula?.batchUploadManifest) {
102
- const submitExtrinsic = api.tx.fula.batchUploadManifest(
103
- manifest,
104
- cids,
105
- poolId,
106
- replicationFactor
107
- );
108
- let unsub: () => void; // Define a variable to hold the unsub function
109
-
110
- if (submitExtrinsic) {
111
- return new Promise<{ hash: string }>((resolve, reject) => {
112
- submitExtrinsic
113
- .signAndSend(userKey, ({ status }) => {
114
- if (status.isInBlock || status.isFinalized) {
115
- if (unsub) {
116
- unsub(); // Call unsub before resolving the promise
117
- }
118
- resolve({ hash: status.asInBlock.toString() });
119
- }
120
- })
121
- .then((unsubFn) => {
122
- unsub = unsubFn; // Store the unsub function once it becomes available
123
- })
124
- .catch((error) => {
125
- if (unsub) {
126
- unsub(); // Call unsub before rejecting the promise
127
- }
128
- console.log(':( transaction failed', error);
129
- reject(error);
130
- });
131
- });
132
- } else {
133
- return Promise.reject(new TypeError('submitExtrinsic not constructed'));
134
- }
135
- } else {
136
- return Promise.reject(new TypeError('api not initialized'));
137
- }
138
- } catch (err) {
139
- return Promise.reject(err);
140
- }
141
- };
142
-
143
- /*
144
- listPools: This function takes start index and length 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
145
- */
146
- export const listPools = async (
147
- api: ApiPromise | undefined,
148
- start: number = 1,
149
- length: number = 10
150
- ): Promise<BType.PoolListResponse> => {
151
- console.log('listPools in react-native started');
152
- try {
153
- if (api === undefined) {
154
- api = await init();
155
- }
156
- // Type guard to assure TypeScript that api is not undefined
157
- if (!api?.query?.pool?.lastPoolId || !api?.query?.pool?.pools) {
158
- throw new Error('Failed to initialize api or api.query.pool');
159
- }
160
- const pools: BType.PoolListResponse = { pools: [] };
161
- const lastPoolId = await api.query.pool.lastPoolId();
162
- let finalReturnedId: number = Number(lastPoolId.toHuman());
163
- if (Number(lastPoolId.toHuman()) > start + length) {
164
- finalReturnedId = start + length;
165
- }
166
- for (let i = start; i <= finalReturnedId; i++) {
167
- const poolInfo = await api.query.pool.pools(i).catch((err) => {
168
- console.log(err);
169
- return Promise.reject(err);
170
- });
171
- if (poolInfo != null) {
172
- let formattedPoolInfo: BType.Pool = JSON.parse(
173
- JSON.stringify(poolInfo.toHuman())
174
- );
175
- pools.pools.push(formattedPoolInfo);
176
- }
177
- }
178
- return Promise.resolve(pools);
179
- } catch (err) {
180
- return Promise.reject(err);
181
- }
182
- };
183
-
184
- /*
185
- checkJoinRequest: This function takes poolId and AccontId and returns a promise of an object that contains request to the pools.
186
- */
187
- export const checkJoinRequest = async (
188
- api: ApiPromise | undefined,
189
- poolId: number,
190
- accountId: string
191
- ): Promise<BType.PoolRequest | null> => {
192
- console.log('checkJoinRequest in react-native started');
193
- try {
194
- if (api === undefined) {
195
- api = await init();
196
- }
197
- // Type guard to assure TypeScript that api is not undefined
198
- if (!api?.query?.pool?.poolRequests) {
199
- throw new Error('Failed to initialize api or api.query.pool');
200
- }
201
-
202
- const poolRequest = await api.query.pool.poolRequests(poolId, accountId);
203
-
204
- if (poolRequest != null) {
205
- let formattedPoolRequest: BType.PoolRequest = JSON.parse(
206
- JSON.stringify(poolRequest.toHuman())
207
- );
208
- return Promise.resolve(formattedPoolRequest);
209
- }
210
- return Promise.resolve(null);
211
- } catch (err) {
212
- return Promise.reject(err);
213
- }
214
- };
215
-
216
- export const getUserPool = async (
217
- api: ApiPromise | undefined,
218
- accountId: string
219
- ): Promise<BType.PoolUsers | null> => {
220
- console.log('GetUserPool in react-native started');
221
- try {
222
- if (api === undefined) {
223
- api = await init();
224
- }
225
- // Type guard to assure TypeScript that api is not undefined
226
- if (!api?.query?.pool?.users) {
227
- throw new Error(
228
- 'Failed to initialize api or api.query.pool or api.query.pool.users'
229
- );
230
- }
231
-
232
- const poolUsers = await api.query.pool.users(accountId);
233
-
234
- if (poolUsers != null) {
235
- let formattedPoolUsers: BType.PoolUsers = JSON.parse(
236
- JSON.stringify(poolUsers.toHuman())
237
- );
238
- return Promise.resolve(formattedPoolUsers);
239
- }
240
- return Promise.resolve(null);
241
- } catch (err) {
242
- return Promise.reject(err);
243
- }
244
- };
245
-
246
- function isAccountInfo(obj: any): obj is { data: { free: any } } {
247
- return 'data' in obj && 'free' in obj.data;
248
- }
249
- /*
250
- checkAccountExsists: This function takes accountId and checks if the account exists
251
- */
252
- export const checkAccountBalance = async (
253
- api: ApiPromise | undefined,
254
- accountId: string
255
- ): Promise<string> => {
256
- console.log('checkAcocuntExsists in react-native started');
257
- try {
258
- if (api === undefined) {
259
- api = await init();
260
- }
261
- // Type guard to assure TypeScript that api is not undefined
262
- if (!api?.query?.system?.account) {
263
- throw new Error('Failed to initialize api or api.query.account');
264
- }
265
- let balance: any;
266
- let accountInfo = await api.query.system.account(accountId);
267
- if (isAccountInfo(accountInfo)) {
268
- balance = accountInfo.data.free;
269
- }
270
-
271
- if (balance && balance !== '0' && balance > 0) {
272
- return Promise.resolve(balance.toHuman());
273
- }
274
- return Promise.resolve('0');
275
- } catch (err) {
276
- return Promise.reject(err);
277
- }
278
- };
279
-
280
- export const getAccountIdFromSeed = async (seed: string): Promise<string> => {
281
- try {
282
- await cryptoWaitReady();
283
- const keyring = new Keyring({ type: 'sr25519' });
284
- const account = keyring.addFromUri(seed, { name: 'account' }, 'sr25519');
285
- return Promise.resolve(account.address);
286
- } catch (err) {
287
- return Promise.reject(err);
288
- }
289
- };
1
+ import { default as EventTypes } from '../interfaces/lookup';
2
+
3
+ import { ApiPromise, WsProvider } from '@polkadot/api';
4
+ import { Keyring } from '@polkadot/keyring';
5
+ const { cryptoWaitReady } = require('@polkadot/util-crypto');
6
+ import type * as BType from '../types/blockchain';
7
+
8
+ const types = {
9
+ FulaPoolPool: EventTypes.FulaPoolPool,
10
+ };
11
+
12
+ export const init = async (
13
+ wsAddress: string = 'wss://node3.functionyard.fula.network'
14
+ ): Promise<ApiPromise> => {
15
+ const provider = new WsProvider(wsAddress);
16
+ const api = await ApiPromise.create({ types, provider }).catch((err) => {
17
+ console.log(err);
18
+ return Promise.reject(err);
19
+ });
20
+ return api;
21
+ };
22
+
23
+ export const disconnectApi = async (api: ApiPromise): Promise<void> => {
24
+ await api.disconnect();
25
+ };
26
+
27
+ /*function addDoubleSlashToSeed(seed: string): string {
28
+ return seed.startsWith('//') ? seed : '//' + seed;
29
+ }*/
30
+
31
+ /*
32
+ createManifest: This function batch uploads manifests
33
+ */
34
+ function serialize(obj: any): string {
35
+ return JSON.stringify(obj);
36
+ }
37
+
38
+ function createManifest(
39
+ cids: string[],
40
+ poolId: number,
41
+ replicationFactor: number = 4
42
+ ): {
43
+ manifest: string[]; // or string[]
44
+ cids: string[]; // or string[]
45
+ poolId: number[];
46
+ replicationFactor: number[];
47
+ } {
48
+ const manifest_metadata = cids.map((cid) => ({
49
+ job: {
50
+ work: 'Storage',
51
+ engine: 'IPFS',
52
+ uri: cid,
53
+ },
54
+ }));
55
+
56
+ // Serialize manifest_metadata to Uint8Array or string
57
+ const serializedManifest = manifest_metadata.map((item) => serialize(item)); // Implement `serialize` accordingly
58
+
59
+ // Serialize cids to Uint8Array or string
60
+ const serializedCids = cids.map((cid) => serialize(cid)); // Implement `serialize` accordingly
61
+
62
+ // Create arrays for `poolId` and `replicationFactor`
63
+ const poolIds = new Array(cids.length).fill(poolId);
64
+ const replicationFactors = new Array(cids.length).fill(replicationFactor);
65
+
66
+ const batchUploadManifest = {
67
+ manifest: serializedManifest,
68
+ cids: serializedCids,
69
+ poolId: poolIds,
70
+ replicationFactor: replicationFactors,
71
+ };
72
+
73
+ return batchUploadManifest;
74
+ }
75
+
76
+ export const batchUploadManifest = async (
77
+ api: ApiPromise | undefined,
78
+ seed: string,
79
+ cids_i: string[],
80
+ poolId_i: number,
81
+ replicationFactor_i: number = 4
82
+ ): Promise<{ hash: string }> => {
83
+ const { manifest, cids, poolId, replicationFactor } = createManifest(
84
+ cids_i,
85
+ poolId_i,
86
+ replicationFactor_i
87
+ );
88
+
89
+ console.log('uploadManifest in react-native started');
90
+ try {
91
+ if (api === undefined) {
92
+ api = await init();
93
+ }
94
+
95
+ // Simple transaction
96
+ const keyring = new Keyring({ type: 'sr25519' });
97
+ const userKey = keyring.addFromUri(seed, { name: 'account' }, 'sr25519');
98
+ console.log(
99
+ `${userKey.meta.name}: has address ${userKey.address} with publicKey [${userKey.publicKey}]`
100
+ );
101
+ if (api?.tx?.fula?.batchUploadManifest) {
102
+ const submitExtrinsic = api.tx.fula.batchUploadManifest(
103
+ manifest,
104
+ cids,
105
+ poolId,
106
+ replicationFactor
107
+ );
108
+ let unsub: () => void; // Define a variable to hold the unsub function
109
+
110
+ if (submitExtrinsic) {
111
+ return new Promise<{ hash: string }>((resolve, reject) => {
112
+ submitExtrinsic
113
+ .signAndSend(userKey, { nonce: -1 }, ({ status }) => {
114
+ if (status.isInBlock || status.isFinalized) {
115
+ if (unsub) {
116
+ unsub(); // Call unsub before resolving the promise
117
+ }
118
+ resolve({ hash: status.asInBlock.toString() });
119
+ }
120
+ })
121
+ .then((unsubFn) => {
122
+ unsub = unsubFn; // Store the unsub function once it becomes available
123
+ })
124
+ .catch((error) => {
125
+ if (unsub) {
126
+ unsub(); // Call unsub before rejecting the promise
127
+ }
128
+ console.log(':( transaction failed', error);
129
+ reject(error);
130
+ });
131
+ });
132
+ } else {
133
+ return Promise.reject(new TypeError('submitExtrinsic not constructed'));
134
+ }
135
+ } else {
136
+ return Promise.reject(new TypeError('api not initialized'));
137
+ }
138
+ } catch (err) {
139
+ return Promise.reject(err);
140
+ }
141
+ };
142
+
143
+ /*
144
+ listPools: This function takes start index and length 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
145
+ */
146
+ export const listPools = async (
147
+ api: ApiPromise | undefined,
148
+ start: number = 1,
149
+ length: number = 10
150
+ ): Promise<BType.PoolListResponse> => {
151
+ console.log('listPools in react-native started');
152
+ try {
153
+ if (api === undefined) {
154
+ api = await init();
155
+ }
156
+ // Type guard to assure TypeScript that api is not undefined
157
+ if (!api?.query?.pool?.lastPoolId || !api?.query?.pool?.pools) {
158
+ throw new Error('Failed to initialize api or api.query.pool');
159
+ }
160
+ const pools: BType.PoolListResponse = { pools: [] };
161
+ const lastPoolId = await api.query.pool.lastPoolId();
162
+ let finalReturnedId: number = Number(lastPoolId.toHuman());
163
+ if (Number(lastPoolId.toHuman()) > start + length) {
164
+ finalReturnedId = start + length;
165
+ }
166
+ for (let i = start; i <= finalReturnedId; i++) {
167
+ const poolInfo = await api.query.pool.pools(i).catch((err) => {
168
+ console.log(err);
169
+ return Promise.reject(err);
170
+ });
171
+ if (poolInfo != null) {
172
+ let formattedPoolInfo: BType.Pool = JSON.parse(
173
+ JSON.stringify(poolInfo.toHuman())
174
+ );
175
+ pools.pools.push(formattedPoolInfo);
176
+ }
177
+ }
178
+ return Promise.resolve(pools);
179
+ } catch (err) {
180
+ return Promise.reject(err);
181
+ }
182
+ };
183
+
184
+ /*
185
+ checkJoinRequest: This function takes poolId and AccontId and returns a promise of an object that contains request to the pools.
186
+ */
187
+ export const checkJoinRequest = async (
188
+ api: ApiPromise | undefined,
189
+ poolId: number,
190
+ accountId: string
191
+ ): Promise<BType.PoolRequest | null> => {
192
+ console.log('checkJoinRequest in react-native started');
193
+ try {
194
+ if (api === undefined) {
195
+ api = await init();
196
+ }
197
+ // Type guard to assure TypeScript that api is not undefined
198
+ if (!api?.query?.pool?.poolRequests) {
199
+ throw new Error('Failed to initialize api or api.query.pool');
200
+ }
201
+
202
+ const poolRequest = await api.query.pool.poolRequests(poolId, accountId);
203
+
204
+ if (poolRequest != null) {
205
+ let formattedPoolRequest: BType.PoolRequest = JSON.parse(
206
+ JSON.stringify(poolRequest.toHuman())
207
+ );
208
+ return Promise.resolve(formattedPoolRequest);
209
+ }
210
+ return Promise.resolve(null);
211
+ } catch (err) {
212
+ return Promise.reject(err);
213
+ }
214
+ };
215
+
216
+ export const getUserPool = async (
217
+ api: ApiPromise | undefined,
218
+ accountId: string
219
+ ): Promise<BType.PoolUsers | null> => {
220
+ console.log('GetUserPool in react-native started');
221
+ try {
222
+ if (api === undefined) {
223
+ api = await init();
224
+ }
225
+ // Type guard to assure TypeScript that api is not undefined
226
+ if (!api?.query?.pool?.users) {
227
+ throw new Error(
228
+ 'Failed to initialize api or api.query.pool or api.query.pool.users'
229
+ );
230
+ }
231
+
232
+ const poolUsers = await api.query.pool.users(accountId);
233
+
234
+ if (poolUsers != null) {
235
+ let formattedPoolUsers: BType.PoolUsers = JSON.parse(
236
+ JSON.stringify(poolUsers.toHuman())
237
+ );
238
+ return Promise.resolve(formattedPoolUsers);
239
+ }
240
+ return Promise.resolve(null);
241
+ } catch (err) {
242
+ return Promise.reject(err);
243
+ }
244
+ };
245
+
246
+ function isAccountInfo(obj: any): obj is { data: { free: any } } {
247
+ return 'data' in obj && 'free' in obj.data;
248
+ }
249
+ /*
250
+ checkAccountExsists: This function takes accountId and checks if the account exists
251
+ */
252
+ export const checkAccountBalance = async (
253
+ api: ApiPromise | undefined,
254
+ accountId: string
255
+ ): Promise<string> => {
256
+ console.log('checkAcocuntExsists in react-native started');
257
+ try {
258
+ if (api === undefined) {
259
+ api = await init();
260
+ }
261
+ // Type guard to assure TypeScript that api is not undefined
262
+ if (!api?.query?.system?.account) {
263
+ throw new Error('Failed to initialize api or api.query.account');
264
+ }
265
+ let balance: any;
266
+ let accountInfo = await api.query.system.account(accountId);
267
+ if (isAccountInfo(accountInfo)) {
268
+ balance = accountInfo.data.free;
269
+ }
270
+
271
+ if (balance && balance !== '0' && balance > 0) {
272
+ return Promise.resolve(balance.toHuman());
273
+ }
274
+ return Promise.resolve('0');
275
+ } catch (err) {
276
+ return Promise.reject(err);
277
+ }
278
+ };
279
+
280
+ export const getAccountIdFromSeed = async (seed: string): Promise<string> => {
281
+ try {
282
+ await cryptoWaitReady();
283
+ const keyring = new Keyring({ type: 'sr25519' });
284
+ const account = keyring.addFromUri(seed, { name: 'account' }, 'sr25519');
285
+ return Promise.resolve(account.address);
286
+ } catch (err) {
287
+ return Promise.reject(err);
288
+ }
289
+ };
@@ -8,7 +8,7 @@ import type * as BType from '../types/fxblox';
8
8
 
9
9
  export const wifiRemoveall = (): Promise<BType.wifiRemoveallResponse> => {
10
10
  console.log('wifiRemoveall in react-native started');
11
- let res = Fula.wifiRemoveall()
11
+ let res2 = Fula.wifiRemoveall()
12
12
  .then((res) => {
13
13
  try {
14
14
  let jsonRes: BType.wifiRemoveallResponse = JSON.parse(res);
@@ -16,7 +16,7 @@ export const wifiRemoveall = (): Promise<BType.wifiRemoveallResponse> => {
16
16
  } catch (e) {
17
17
  try {
18
18
  return JSON.parse(res);
19
- } catch (e) {
19
+ } catch (e2) {
20
20
  return res;
21
21
  }
22
22
  }
@@ -24,12 +24,12 @@ export const wifiRemoveall = (): Promise<BType.wifiRemoveallResponse> => {
24
24
  .catch((err) => {
25
25
  return err;
26
26
  });
27
- return res;
27
+ return res2;
28
28
  };
29
29
 
30
30
  export const reboot = (): Promise<BType.rebootResponse> => {
31
31
  console.log('reboot in react-native started');
32
- let res = Fula.reboot()
32
+ let res2 = Fula.reboot()
33
33
  .then((res) => {
34
34
  try {
35
35
  let jsonRes: BType.rebootResponse = JSON.parse(res);
@@ -37,7 +37,7 @@ export const reboot = (): Promise<BType.rebootResponse> => {
37
37
  } catch (e) {
38
38
  try {
39
39
  return JSON.parse(res);
40
- } catch (e) {
40
+ } catch (e2) {
41
41
  return res;
42
42
  }
43
43
  }
@@ -45,5 +45,26 @@ export const reboot = (): Promise<BType.rebootResponse> => {
45
45
  .catch((err) => {
46
46
  return err;
47
47
  });
48
- return res;
48
+ return res2;
49
+ };
50
+
51
+ export const eraseBlData = (): Promise<BType.rebootResponse> => {
52
+ console.log('eraseBlData in react-native started');
53
+ let res2 = Fula.eraseBlData()
54
+ .then((res) => {
55
+ try {
56
+ let jsonRes: BType.eraseBlDataResponse = JSON.parse(res);
57
+ return jsonRes;
58
+ } catch (e) {
59
+ try {
60
+ return JSON.parse(res);
61
+ } catch (e2) {
62
+ return res;
63
+ }
64
+ }
65
+ })
66
+ .catch((err) => {
67
+ return err;
68
+ });
69
+ return res2;
49
70
  };
@@ -21,6 +21,11 @@ export interface AssetsBalanceResponse {
21
21
  amount: string;
22
22
  }
23
23
 
24
+ export interface TransferToFulaResponse {
25
+ msg: string;
26
+ description: string;
27
+ }
28
+
24
29
  export interface PoolJoinResponse {
25
30
  account: string;
26
31
  poolID: number;
@@ -6,3 +6,8 @@ export interface rebootResponse {
6
6
  status: boolean;
7
7
  msg: string;
8
8
  }
9
+
10
+ export interface eraseBlDataResponse {
11
+ status: boolean;
12
+ msg: string;
13
+ }