@functionland/react-native-fula 1.12.1 → 1.14.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.
Files changed (39) hide show
  1. package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
  3. package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
  4. package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
  5. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  6. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  7. package/android/.idea/gradle.xml +1 -1
  8. package/android/.idea/misc.xml +2 -1
  9. package/android/.idea/sonarlint/issuestore/2/a/2afbb999f001938c88fa43fc2ef52abf0f8213e4 +0 -0
  10. package/android/.idea/sonarlint/issuestore/2/e/2e09eb0f0df666781fdff057a0af6101364ebe2f +0 -0
  11. package/android/.idea/sonarlint/issuestore/6/2/62149c3f7c3a14d7a77778e558d274e8c00a5585 +0 -0
  12. package/android/.idea/sonarlint/issuestore/8/0/80a78d662b0659428eb880336106c3c5fc3f0714 +0 -0
  13. package/android/.idea/sonarlint/issuestore/d/2/d2865ef8fc01c40e9fd82977fde2c8378fad0b12 +0 -0
  14. package/android/.idea/sonarlint/issuestore/f/b/fbe448ebfc3eb2d4e308f6b8b043666f5b57235e +0 -0
  15. package/android/.idea/sonarlint/issuestore/index.pb +13 -0
  16. package/android/.idea/sonarlint/securityhotspotstore/2/a/2afbb999f001938c88fa43fc2ef52abf0f8213e4 +0 -0
  17. package/android/.idea/sonarlint/securityhotspotstore/2/e/2e09eb0f0df666781fdff057a0af6101364ebe2f +0 -0
  18. package/android/.idea/sonarlint/securityhotspotstore/6/2/62149c3f7c3a14d7a77778e558d274e8c00a5585 +0 -0
  19. package/android/.idea/sonarlint/securityhotspotstore/8/0/80a78d662b0659428eb880336106c3c5fc3f0714 +0 -0
  20. package/android/.idea/sonarlint/securityhotspotstore/d/2/d2865ef8fc01c40e9fd82977fde2c8378fad0b12 +0 -0
  21. package/android/.idea/sonarlint/securityhotspotstore/f/b/fbe448ebfc3eb2d4e308f6b8b043666f5b57235e +0 -0
  22. package/android/.idea/sonarlint/securityhotspotstore/index.pb +13 -0
  23. package/android/build.gradle +2 -2
  24. package/android/src/main/java/land/fx/fula/Cryptography.java +62 -62
  25. package/android/src/main/java/land/fx/fula/FulaModule.java +33 -11
  26. package/lib/commonjs/interfaces/fulaNativeModule.js.map +1 -1
  27. package/lib/commonjs/protocols/chain-api.js +46 -8
  28. package/lib/commonjs/protocols/chain-api.js.map +1 -1
  29. package/lib/commonjs/protocols/fula.js +98 -98
  30. package/lib/commonjs/protocols/fula.js.map +1 -1
  31. package/lib/module/interfaces/fulaNativeModule.js.map +1 -1
  32. package/lib/module/protocols/chain-api.js +48 -8
  33. package/lib/module/protocols/chain-api.js.map +1 -1
  34. package/lib/module/protocols/fula.js +98 -98
  35. package/lib/module/protocols/fula.js.map +1 -1
  36. package/package.json +1 -1
  37. package/src/interfaces/fulaNativeModule.ts +122 -122
  38. package/src/protocols/chain-api.ts +127 -80
  39. package/src/protocols/fula.ts +314 -314
@@ -1,80 +1,127 @@
1
- import { default as EventTypes } from '../interfaces/api-lookup';
2
-
3
- import { ApiPromise, WsProvider } from '@polkadot/api';
4
- import type * as BType from '../types/blockchain';
5
-
6
- const types = {
7
- FulaPoolPool: EventTypes.FulaPoolPool,
8
- }
9
-
10
- export const init = async (wsAddress: string = 'wss://node.testnet.fx.land'): Promise<ApiPromise> => {
11
- const provider = new WsProvider(wsAddress);
12
- const api = await ApiPromise.create({ types, provider }).catch((err) => {
13
- console.log(err);
14
- return Promise.reject(err);
15
- });
16
- return api;
17
- };
18
-
19
- export const disconnectApi = async (api: ApiPromise): Promise<void> => {
20
- await api.disconnect();
21
- };
22
-
23
- /*
24
- 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
25
- */
26
- export const listPools = async (api: ApiPromise|undefined, start: number=1, length: number=10): Promise<BType.PoolListResponse> => {
27
- console.log(
28
- 'listPools in react-native started'
29
- );
30
- try {
31
- if(api == undefined) {
32
- api = await init();
33
- }
34
- const pools: BType.PoolListResponse = { pools: [] };
35
- const lastPoolId = await api.query.pool.lastPoolId();
36
- let finalReturnedId: number = Number(lastPoolId.toHuman());
37
- if (Number(lastPoolId.toHuman()) > start + length) {
38
- finalReturnedId = start + length;
39
- }
40
- for(let i=start; i<=finalReturnedId;i++) {
41
- const poolInfo = await api.query.pool
42
- .pools(i).catch((err) => {
43
- console.log(err);
44
- return Promise.reject(err);
45
- });
46
- if(poolInfo != null) {
47
- let formattedPoolInfo: BType.Pool = JSON.parse(JSON.stringify(poolInfo.toHuman()));
48
- pools.pools.push(formattedPoolInfo);
49
- }
50
- }
51
- return Promise.resolve(pools);
52
- } catch (err) {
53
- return Promise.reject(err);
54
- }
55
- }
56
-
57
- /*
58
- checkJoinRequest: This function takes poolId and AccontId and returns a promise of an object that contains request to the pools.
59
- */
60
- export const checkJoinRequest = async (api: ApiPromise|undefined, poolId: number, accountId: string): Promise<BType.PoolRequest|null> => {
61
- console.log(
62
- 'checkJoinRequest in react-native started'
63
- );
64
- try {
65
- if(api == undefined) {
66
- api = await init();
67
- }
68
-
69
- const poolRequest = await api.query.pool.poolRequests(poolId, accountId);
70
-
71
- if(poolRequest != null) {
72
- let formattedPoolRequest: BType.PoolRequest = JSON.parse(JSON.stringify(poolRequest.toHuman()));
73
- return Promise.resolve(formattedPoolRequest);
74
- }
75
- return Promise.resolve(null);
76
-
77
- } catch (err) {
78
- return Promise.reject(err);
79
- }
80
- }
1
+ import { default as EventTypes } from '../interfaces/api-lookup';
2
+
3
+ import { ApiPromise, WsProvider } from '@polkadot/api';
4
+ //import { Keyring } from '@polkadot/keyring';
5
+ import type * as BType from '../types/blockchain';
6
+
7
+ const types = {
8
+ FulaPoolPool: EventTypes.FulaPoolPool,
9
+ };
10
+
11
+ export const init = async (
12
+ wsAddress: string = 'wss://node3.functionyard.fx.land'
13
+ ): Promise<ApiPromise> => {
14
+ const provider = new WsProvider(wsAddress);
15
+ const api = await ApiPromise.create({ types, provider }).catch((err) => {
16
+ console.log(err);
17
+ return Promise.reject(err);
18
+ });
19
+ return api;
20
+ };
21
+
22
+ export const disconnectApi = async (api: ApiPromise): Promise<void> => {
23
+ await api.disconnect();
24
+ };
25
+
26
+ /*
27
+ createAccount: This function takes a seed and returns am account
28
+ */
29
+ /*export const uploadManifest = async (
30
+ api: ApiPromise | undefined,
31
+ seed: string,
32
+ manifest: typeof EventTypes.FunctionlandFulaCall._enum.upload_manifest
33
+ ): Promise<BType.ManifestUploadResponse> => {
34
+ console.log('uploadManifest in react-native started');
35
+ try {
36
+ if (api === undefined) {
37
+ api = await init();
38
+ }
39
+
40
+ // Simple transaction
41
+ const keyring = new Keyring({ type: 'sr25519' });
42
+ const userKey = keyring.addFromUri(seed, { name: 'account' });
43
+ console.log(
44
+ `${userKey.meta.name}: has address ${userKey.address} with publicKey [${userKey.publicKey}]`
45
+ );
46
+ const submitExtrinsic = await api.tx.manifest.upload(manifest);
47
+ const unsub = await submitExtrinsic
48
+ .signAndSend(userKey, ({ status, events }) => {
49
+ if (status.isInBlock || status.isFinalized) {
50
+ console.log(events);
51
+ unsub();
52
+ return Promise.resolve({ success: true });
53
+ }
54
+ })
55
+ .catch((error) => {
56
+ console.log(':( transaction failed', error);
57
+ return Promise.reject(error);
58
+ });
59
+ } catch (err) {
60
+ return Promise.reject(err);
61
+ }
62
+ };*/
63
+
64
+ /*
65
+ 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
66
+ */
67
+ export const listPools = async (
68
+ api: ApiPromise | undefined,
69
+ start: number = 1,
70
+ length: number = 10
71
+ ): Promise<BType.PoolListResponse> => {
72
+ console.log('listPools in react-native started');
73
+ try {
74
+ if (api === undefined) {
75
+ api = await init();
76
+ }
77
+ const pools: BType.PoolListResponse = { pools: [] };
78
+ const lastPoolId = await api.query.pool.lastPoolId();
79
+ let finalReturnedId: number = Number(lastPoolId.toHuman());
80
+ if (Number(lastPoolId.toHuman()) > start + length) {
81
+ finalReturnedId = start + length;
82
+ }
83
+ for (let i = start; i <= finalReturnedId; i++) {
84
+ const poolInfo = await api.query.pool.pools(i).catch((err) => {
85
+ console.log(err);
86
+ return Promise.reject(err);
87
+ });
88
+ if (poolInfo != null) {
89
+ let formattedPoolInfo: BType.Pool = JSON.parse(
90
+ JSON.stringify(poolInfo.toHuman())
91
+ );
92
+ pools.pools.push(formattedPoolInfo);
93
+ }
94
+ }
95
+ return Promise.resolve(pools);
96
+ } catch (err) {
97
+ return Promise.reject(err);
98
+ }
99
+ };
100
+
101
+ /*
102
+ checkJoinRequest: This function takes poolId and AccontId and returns a promise of an object that contains request to the pools.
103
+ */
104
+ export const checkJoinRequest = async (
105
+ api: ApiPromise | undefined,
106
+ poolId: number,
107
+ accountId: string
108
+ ): Promise<BType.PoolRequest | null> => {
109
+ console.log('checkJoinRequest in react-native started');
110
+ try {
111
+ if (api === undefined) {
112
+ api = await init();
113
+ }
114
+
115
+ const poolRequest = await api.query.pool.poolRequests(poolId, accountId);
116
+
117
+ if (poolRequest != null) {
118
+ let formattedPoolRequest: BType.PoolRequest = JSON.parse(
119
+ JSON.stringify(poolRequest.toHuman())
120
+ );
121
+ return Promise.resolve(formattedPoolRequest);
122
+ }
123
+ return Promise.resolve(null);
124
+ } catch (err) {
125
+ return Promise.reject(err);
126
+ }
127
+ };