difftreelog
NFTPAR-91: SIT: Connection can be established. Fixed unhandled promise rejection. Fixed unknown type warnings.
in: master
5 files changed
README.mddiffbeforeafterboth--- a/README.md
+++ b/README.md
@@ -191,6 +191,10 @@
"Sponsor": "AccountId",
"UnconfirmedSponsor": "AccountId"
},
+ "ApprovePermissions": {
+ "Approved": "AccountId",
+ "Amount": "u64"
+ },
"RawData": "Vec<u8>",
"Address": "AccountId",
"LookupSource": "AccountId",
tests/src/config.tsdiffbeforeafterboth--- a/tests/src/config.ts
+++ b/tests/src/config.ts
@@ -34,6 +34,20 @@
"ReFungible": "(u32, u32)"
}
},
+ "Ownership": {
+ "Owner": "AccountId",
+ "Fraction": "u128"
+ },
+ "FungibleItemType": {
+ "Collection": "u64",
+ "Owner": "AccountId",
+ "Value": "u128"
+ },
+ "ReFungibleItemType": {
+ "Collection": "u64",
+ "Owner": "Vec<Ownership>",
+ "Data": "Vec<u8>"
+ },
"NftItemType": {
"Collection": "u64",
"Owner": "AccountId",
@@ -57,10 +71,15 @@
"Description": "Vec<u16>",
"TokenPrefix": "Vec<u8>",
"CustomDataSize": "u32",
+ "MintMode": "bool",
"OffchainSchema": "Vec<u8>",
"Sponsor": "AccountId",
"UnconfirmedSponsor": "AccountId"
},
+ "ApprovePermissions": {
+ "Approved": "AccountId",
+ "Amount": "u64"
+ },
"RawData": "Vec<u8>",
"Address": "AccountId",
"LookupSource": "AccountId",
tests/src/connection.test.tsdiffbeforeafterboth--- a/tests/src/connection.test.ts
+++ b/tests/src/connection.test.ts
@@ -15,9 +15,9 @@
});
});
- it('Cannot connect to 0.0.0.0', () => {
- const neverConnectProvider = new WsProvider('ws://0.0.0.0:9944');
- expect((async () => {
+ it('Cannot connect to 255.255.255.255', async () => {
+ const neverConnectProvider = new WsProvider('ws://255.255.255.255:9944');
+ await expect((async () => {
await usingApi(async api => {
const health = await api.rpc.system.health();
}, { provider: neverConnectProvider });
tests/src/substrate/promisify-substrate.tsdiffbeforeafterboth--- a/tests/src/substrate/promisify-substrate.ts
+++ b/tests/src/substrate/promisify-substrate.ts
@@ -4,19 +4,21 @@
export default function promisifySubstrate<T extends (...args: any[]) => any>(api: ApiPromise, action: T): (...args: Parameters<T>) => Promise<PromiseType<ReturnType<T>>> {
return (...args: Parameters<T>) => {
- const promise = new Promise<PromiseType<ReturnType<T>>>((resolve, reject) => {
+ const promise = new Promise<PromiseType<ReturnType<T>>>((resolve: ((result: PromiseType<ReturnType<T>>) => void) | undefined, reject: ((error: any) => void) | undefined) => {
const cleanup = () => {
api.off('disconnected', fail);
api.off('error', fail);
+ resolve = undefined;
+ reject = undefined;
};
const success = (r: any) => {
+ resolve && resolve(r);
cleanup();
- resolve(r);
};
const fail = (error: any) => {
+ reject && reject(error);
cleanup();
- reject(error);
};
api.on('disconnected', fail);
tests/src/substrate/substrate-api.tsdiffbeforeafterboth101011export default async function usingApi(action: (api: ApiPromise) => Promise<void>, settings: ApiOptions | undefined = undefined): Promise<void> {11export default async function usingApi(action: (api: ApiPromise) => Promise<void>, settings: ApiOptions | undefined = undefined): Promise<void> {12 settings = settings || defaultApiOptions();12 settings = settings || defaultApiOptions();13 let api: ApiPromise | undefined = undefined;13 let api: ApiPromise = new ApiPromise(settings);141415 try {15 try {16 api = new ApiPromise(settings);17 await promisifySubstrate(api, () => api && api.isReady)();16 await promisifySubstrate(api, async () => {18 await action(api);17 if(api) {18 await api.isReadyOrError;19 await action(api);20 }21 })();19 } finally {22 } finally {20 api && api.disconnect();23 await api.disconnect();21 }24 }22}25}