@functionland/react-native-fula 1.13.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.
- 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/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.idea/gradle.xml +1 -1
- package/android/.idea/misc.xml +2 -1
- package/android/.idea/sonarlint/issuestore/2/a/2afbb999f001938c88fa43fc2ef52abf0f8213e4 +0 -0
- package/android/.idea/sonarlint/issuestore/2/e/2e09eb0f0df666781fdff057a0af6101364ebe2f +0 -0
- package/android/.idea/sonarlint/issuestore/6/2/62149c3f7c3a14d7a77778e558d274e8c00a5585 +0 -0
- package/android/.idea/sonarlint/issuestore/8/0/80a78d662b0659428eb880336106c3c5fc3f0714 +0 -0
- package/android/.idea/sonarlint/issuestore/d/2/d2865ef8fc01c40e9fd82977fde2c8378fad0b12 +0 -0
- package/android/.idea/sonarlint/issuestore/f/b/fbe448ebfc3eb2d4e308f6b8b043666f5b57235e +0 -0
- package/android/.idea/sonarlint/issuestore/index.pb +13 -0
- package/android/.idea/sonarlint/securityhotspotstore/2/a/2afbb999f001938c88fa43fc2ef52abf0f8213e4 +0 -0
- package/android/.idea/sonarlint/securityhotspotstore/2/e/2e09eb0f0df666781fdff057a0af6101364ebe2f +0 -0
- package/android/.idea/sonarlint/securityhotspotstore/6/2/62149c3f7c3a14d7a77778e558d274e8c00a5585 +0 -0
- package/android/.idea/sonarlint/securityhotspotstore/8/0/80a78d662b0659428eb880336106c3c5fc3f0714 +0 -0
- package/android/.idea/sonarlint/securityhotspotstore/d/2/d2865ef8fc01c40e9fd82977fde2c8378fad0b12 +0 -0
- package/android/.idea/sonarlint/securityhotspotstore/f/b/fbe448ebfc3eb2d4e308f6b8b043666f5b57235e +0 -0
- package/android/.idea/sonarlint/securityhotspotstore/index.pb +13 -0
- package/android/build.gradle +70 -70
- package/android/src/main/java/land/fx/fula/FulaModule.java +1460 -1438
- package/lib/commonjs/protocols/chain-api.js +46 -8
- package/lib/commonjs/protocols/chain-api.js.map +1 -1
- package/lib/module/protocols/chain-api.js +48 -8
- package/lib/module/protocols/chain-api.js.map +1 -1
- package/package.json +157 -157
- package/src/protocols/chain-api.ts +127 -80
|
@@ -1,80 +1,127 @@
|
|
|
1
|
-
import { default as EventTypes } from '../interfaces/api-lookup';
|
|
2
|
-
|
|
3
|
-
import { ApiPromise, WsProvider } from '@polkadot/api';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
+
};
|