@functionland/react-native-fula 1.19.0 → 1.29.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,130 +1,130 @@
1
- import { NativeModules, Platform } from 'react-native';
2
-
3
- interface FulaNativeModule {
4
- initFula: (
5
- identity: string, //Private key of did identity
6
- storePath: string, //You can leave empty
7
- bloxAddr: string, //Blox multiadddr needs to be manually entered now
8
- exchange: string, //set to 'noope' for testing
9
- autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write
10
- rootCid: string | null, //if you have the latest rootCid you can send it and it generates the private_ref for filesystem
11
- useRelay: boolean | null, // if true it forces the use of relay
12
- refresh: boolean // if true it forces to refresh the fula object
13
- ) => Promise<{ peerId: string; rootCid: string }>;
14
- newClient: (
15
- identity: string, //Private key of did identity
16
- storePath: string, //You can leave empty
17
- bloxAddr: string, //Blox multiadddr needs to be manually entered now
18
- exchange: string, //set to 'noope' for testing
19
- autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write
20
- useRelay: boolean | null, // if true it forces the use of relay
21
- refresh: boolean // if true it forces to refresh the fula object
22
- ) => Promise<string>;
23
- isReady: (filesystemCheck: boolean) => Promise<boolean>;
24
- logout: (identity: string, storePath: string) => Promise<boolean>;
25
- checkFailedActions: (retry: boolean, timeout: number) => Promise<boolean>;
26
- listFailedActions: (cids: string[]) => Promise<string[]>;
27
- listRecentCidsAsString: () => Promise<string[]>;
28
- clearCidsFromRecent: (cids: string[]) => Promise<boolean>;
29
- checkConnection: (timeout: number) => Promise<boolean>;
30
- get: (key: string) => Promise<string>;
31
- has: (key: Uint8Array) => Promise<boolean>;
32
- push: () => Promise<string>;
33
- put: (content: string, codec: string) => Promise<string>;
34
- mkdir: (path: string) => Promise<string>;
35
- writeFileContent: (path: string, content: string) => Promise<string>;
36
- writeFile: (
37
- fulaTargetFilename: string,
38
- localFilename: string
39
- ) => Promise<string>;
40
- ls: (path: string) => Promise<string>;
41
- rm: (path: string) => Promise<string>;
42
- cp: (sourcePath: string, targetPath: string) => Promise<string>;
43
- mv: (sourcePath: string, targetPath: string) => Promise<string>;
44
- readFile: (
45
- fulaTargetFilename: string,
46
- localFilename: string
47
- ) => Promise<string>;
48
- readFileContent: (path: string) => Promise<string>;
49
- setAuth: (peerId: string, allow: boolean) => Promise<boolean>;
50
-
51
- shutdown: () => Promise<void>;
52
-
53
- testData: (identity: string, bloxAddr: string) => Promise<string>;
54
-
55
- //Blockchain related functions
56
- createAccount: (seed: string) => Promise<string>;
57
- checkAccountExists: (account: string) => Promise<string>;
58
- createPool: (seed: string, poolName: string) => Promise<string>;
59
- listPools: () => Promise<string>;
60
- joinPool: (poolID: string) => Promise<string>;
61
- leavePool: (poolID: number) => Promise<string>;
62
- cancelPoolJoin: (poolID: number) => Promise<string>;
63
- listPoolJoinRequests: (poolID: number) => Promise<string>;
64
- votePoolJoinRequest: (
65
- seed: string,
66
- poolID: number,
67
- account: string,
68
- accept: boolean
69
- ) => Promise<string>;
70
- newReplicationRequest: (
71
- seed: string,
72
- poolID: number,
73
- replicationFactor: number,
74
- cid: string
75
- ) => Promise<string>;
76
- newStoreRequest: (
77
- seed: string,
78
- poolID: number,
79
- uploader: string,
80
- cid: string
81
- ) => Promise<string>;
82
- listAvailableReplicationRequests: (poolID: number) => Promise<string>;
83
- removeReplicationRequest: (
84
- seed: string,
85
- poolID: number,
86
- cid: string
87
- ) => Promise<string>;
88
- removeStorer: (
89
- seed: string,
90
- storer: string,
91
- poolID: number,
92
- cid: string
93
- ) => Promise<string>;
94
- removeStoredReplication: (
95
- seed: string,
96
- uploader: string,
97
- poolID: number,
98
- cid: string
99
- ) => Promise<string>;
100
-
101
- //Hardware
102
- bloxFreeSpace: () => Promise<string>;
103
- wifiRemoveall: () => Promise<string>;
104
- reboot: () => Promise<string>;
105
- getAccount: () => Promise<string>;
106
- assetsBalance: (
107
- account: string,
108
- assetId: string,
109
- classId: string
110
- ) => Promise<string>;
111
- }
112
-
113
- const LINKING_ERROR =
114
- `The package 'react-native-fula/Fula' doesn't seem to be linked. Make sure: \n\n` +
115
- Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
116
- '- You rebuilt the app after installing the package\n' +
117
- '- You are not using Expo managed workflow\n';
118
-
119
- const Fula = NativeModules.FulaModule
120
- ? NativeModules.FulaModule
121
- : new Proxy(
122
- {},
123
- {
124
- get() {
125
- throw new Error(LINKING_ERROR);
126
- },
127
- }
128
- );
129
-
130
- export default Fula as FulaNativeModule;
1
+ import { NativeModules, Platform } from 'react-native';
2
+
3
+ interface FulaNativeModule {
4
+ initFula: (
5
+ identity: string, //Private key of did identity
6
+ storePath: string, //You can leave empty
7
+ bloxAddr: string, //Blox multiadddr needs to be manually entered now
8
+ exchange: string, //set to 'noope' for testing
9
+ autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write
10
+ rootCid: string | null, //if you have the latest rootCid you can send it and it generates the private_ref for filesystem
11
+ useRelay: boolean | null, // if true it forces the use of relay
12
+ refresh: boolean // if true it forces to refresh the fula object
13
+ ) => Promise<{ peerId: string; rootCid: string }>;
14
+ newClient: (
15
+ identity: string, //Private key of did identity
16
+ storePath: string, //You can leave empty
17
+ bloxAddr: string, //Blox multiadddr needs to be manually entered now
18
+ exchange: string, //set to 'noope' for testing
19
+ autoFlush: boolean, //set to false always unless you know what you are doing. This is to write actions to disk explicitly after each write
20
+ useRelay: boolean | null, // if true it forces the use of relay
21
+ refresh: boolean // if true it forces to refresh the fula object
22
+ ) => Promise<string>;
23
+ isReady: (filesystemCheck: boolean) => Promise<boolean>;
24
+ logout: (identity: string, storePath: string) => Promise<boolean>;
25
+ checkFailedActions: (retry: boolean, timeout: number) => Promise<boolean>;
26
+ listFailedActions: (cids: string[]) => Promise<string[]>;
27
+ listRecentCidsAsString: () => Promise<string[]>;
28
+ clearCidsFromRecent: (cids: string[]) => Promise<boolean>;
29
+ checkConnection: (timeout: number) => Promise<boolean>;
30
+ get: (key: string) => Promise<string>;
31
+ has: (key: Uint8Array) => Promise<boolean>;
32
+ push: () => Promise<string>;
33
+ put: (content: string, codec: string) => Promise<string>;
34
+ mkdir: (path: string) => Promise<string>;
35
+ writeFileContent: (path: string, content: string) => Promise<string>;
36
+ writeFile: (
37
+ fulaTargetFilename: string,
38
+ localFilename: string
39
+ ) => Promise<string>;
40
+ ls: (path: string) => Promise<string>;
41
+ rm: (path: string) => Promise<string>;
42
+ cp: (sourcePath: string, targetPath: string) => Promise<string>;
43
+ mv: (sourcePath: string, targetPath: string) => Promise<string>;
44
+ readFile: (
45
+ fulaTargetFilename: string,
46
+ localFilename: string
47
+ ) => Promise<string>;
48
+ readFileContent: (path: string) => Promise<string>;
49
+ setAuth: (peerId: string, allow: boolean) => Promise<boolean>;
50
+
51
+ shutdown: () => Promise<void>;
52
+
53
+ testData: (identity: string, bloxAddr: string) => Promise<string>;
54
+
55
+ //Blockchain related functions
56
+ createAccount: (seed: string) => Promise<string>;
57
+ checkAccountExists: (account: string) => Promise<string>;
58
+ createPool: (seed: string, poolName: string) => Promise<string>;
59
+ listPools: () => Promise<string>;
60
+ joinPool: (poolID: string) => Promise<string>;
61
+ leavePool: (poolID: number) => Promise<string>;
62
+ cancelPoolJoin: (poolID: number) => Promise<string>;
63
+ listPoolJoinRequests: (poolID: number) => Promise<string>;
64
+ votePoolJoinRequest: (
65
+ seed: string,
66
+ poolID: number,
67
+ account: string,
68
+ accept: boolean
69
+ ) => Promise<string>;
70
+ newReplicationRequest: (
71
+ seed: string,
72
+ poolID: number,
73
+ replicationFactor: number,
74
+ cid: string
75
+ ) => Promise<string>;
76
+ newStoreRequest: (
77
+ seed: string,
78
+ poolID: number,
79
+ uploader: string,
80
+ cid: string
81
+ ) => Promise<string>;
82
+ listAvailableReplicationRequests: (poolID: number) => Promise<string>;
83
+ removeReplicationRequest: (
84
+ seed: string,
85
+ poolID: number,
86
+ cid: string
87
+ ) => Promise<string>;
88
+ removeStorer: (
89
+ seed: string,
90
+ storer: string,
91
+ poolID: number,
92
+ cid: string
93
+ ) => Promise<string>;
94
+ removeStoredReplication: (
95
+ seed: string,
96
+ uploader: string,
97
+ poolID: number,
98
+ cid: string
99
+ ) => Promise<string>;
100
+
101
+ //Hardware
102
+ bloxFreeSpace: () => Promise<string>;
103
+ wifiRemoveall: () => Promise<string>;
104
+ reboot: () => Promise<string>;
105
+ getAccount: () => Promise<string>;
106
+ assetsBalance: (
107
+ account: string,
108
+ assetId: string,
109
+ classId: string
110
+ ) => Promise<string>;
111
+ }
112
+
113
+ const LINKING_ERROR =
114
+ `The package 'react-native-fula/Fula' doesn't seem to be linked. Make sure: \n\n` +
115
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
116
+ '- You rebuilt the app after installing the package\n' +
117
+ '- You are not using Expo managed workflow\n';
118
+
119
+ const Fula = NativeModules.FulaModule
120
+ ? NativeModules.FulaModule
121
+ : new Proxy(
122
+ {},
123
+ {
124
+ get() {
125
+ throw new Error(LINKING_ERROR);
126
+ },
127
+ }
128
+ );
129
+
130
+ export default Fula as FulaNativeModule;
@@ -1,4 +1,4 @@
1
- // Auto-generated via `yarn polkadot-types-from-defs`, do not edit
2
- /* eslint-disable */
3
-
4
- //export * from './types.ts';
1
+ // Auto-generated via `yarn polkadot-types-from-defs`, do not edit
2
+ /* eslint-disable */
3
+
4
+ //export * from './types.ts';
@@ -213,6 +213,36 @@ export const checkJoinRequest = async (
213
213
  }
214
214
  };
215
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
+
216
246
  function isAccountInfo(obj: any): obj is { data: { free: any } } {
217
247
  return 'data' in obj && 'free' in obj.data;
218
248
  }
@@ -1,89 +1,96 @@
1
- export interface SeededResponse {
2
- seed: string;
3
- account: string;
4
- }
5
-
6
- export interface AccountExistsResponse {
7
- account: string;
8
- exists: boolean;
9
- }
10
-
11
- export interface PoolCreateResponse {
12
- owner: string;
13
- poolID: number;
14
- }
15
-
16
- export interface GetAccountResponse {
17
- account: string;
18
- }
19
-
20
- export interface AssetsBalanceResponse {
21
- amount: string;
22
- }
23
-
24
- export interface PoolJoinResponse {
25
- account: string;
26
- poolID: number;
27
- }
28
-
29
- export interface PoolCancelJoinResponse {
30
- account: string;
31
- poolID: number;
32
- }
33
-
34
- export interface PoolRequestsResponse {
35
- poolRequests: PoolRequest[];
36
- }
37
-
38
- export interface PoolListResponse {
39
- pools: Pool[];
40
- }
41
-
42
- export interface PoolVoteResponse {
43
- account: string;
44
- poolID: number;
45
- }
46
-
47
- export interface PoolLeaveResponse {
48
- account: string;
49
- poolID: number;
50
- }
51
-
52
- export interface ManifestUploadResponse {
53
- uploader: string;
54
- storage: string[];
55
- manifestMetadata: ManifestMetadata;
56
- poolID: number;
57
- }
58
-
59
- export interface PoolRequest {
60
- poolID: number;
61
- account: string;
62
- voted: string[];
63
- positiveVotes: number;
64
- peerID: string;
65
- }
66
-
67
- export interface Pool {
68
- poolID: number;
69
- owner: string;
70
- poolName: string;
71
- parent: string;
72
- participants: string[];
73
- }
74
-
75
- export interface ManifestMetadata {
76
- job: ManifestJob;
77
- }
78
-
79
- export interface ManifestJob {
80
- work: string;
81
- engine: string;
82
- uri: string;
83
- }
84
- export interface BloxFreeSpaceResponse {
85
- size: number;
86
- avail: number;
87
- used: number;
88
- used_percentage: number;
89
- }
1
+ export interface SeededResponse {
2
+ seed: string;
3
+ account: string;
4
+ }
5
+
6
+ export interface AccountExistsResponse {
7
+ account: string;
8
+ exists: boolean;
9
+ }
10
+
11
+ export interface PoolCreateResponse {
12
+ owner: string;
13
+ poolID: number;
14
+ }
15
+
16
+ export interface GetAccountResponse {
17
+ account: string;
18
+ }
19
+
20
+ export interface AssetsBalanceResponse {
21
+ amount: string;
22
+ }
23
+
24
+ export interface PoolJoinResponse {
25
+ account: string;
26
+ poolID: number;
27
+ }
28
+
29
+ export interface PoolCancelJoinResponse {
30
+ account: string;
31
+ poolID: number;
32
+ }
33
+
34
+ export interface PoolRequestsResponse {
35
+ poolRequests: PoolRequest[];
36
+ }
37
+
38
+ export interface PoolListResponse {
39
+ pools: Pool[];
40
+ }
41
+
42
+ export interface PoolVoteResponse {
43
+ account: string;
44
+ poolID: number;
45
+ }
46
+
47
+ export interface PoolLeaveResponse {
48
+ account: string;
49
+ poolID: number;
50
+ }
51
+
52
+ export interface ManifestUploadResponse {
53
+ uploader: string;
54
+ storage: string[];
55
+ manifestMetadata: ManifestMetadata;
56
+ poolID: number;
57
+ }
58
+
59
+ export interface PoolRequest {
60
+ poolID: number;
61
+ account: string;
62
+ voted: string[];
63
+ positiveVotes: number;
64
+ peerID: string;
65
+ }
66
+
67
+ export interface PoolUsers {
68
+ poolID: number;
69
+ account: string;
70
+ requestPoolId: string;
71
+ peerID: string;
72
+ }
73
+
74
+ export interface Pool {
75
+ poolID: number;
76
+ owner: string;
77
+ poolName: string;
78
+ parent: string;
79
+ participants: string[];
80
+ }
81
+
82
+ export interface ManifestMetadata {
83
+ job: ManifestJob;
84
+ }
85
+
86
+ export interface ManifestJob {
87
+ work: string;
88
+ engine: string;
89
+ uri: string;
90
+ }
91
+ export interface BloxFreeSpaceResponse {
92
+ size: number;
93
+ avail: number;
94
+ used: number;
95
+ used_percentage: number;
96
+ }