Fix derive not returning (needsSubscription issues) (#658)
Fix derive not subscribing (needsSubscription issues)
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.38.6",
|
||||
"@polkadot/rpc-provider": "^0.38.6"
|
||||
"@polkadot/api": "0.42.1",
|
||||
"@polkadot/rpc-provider": "0.42.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.38.6"
|
||||
"@polkadot/api": "0.42.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.38.6"
|
||||
"@polkadot/api": "^0.42.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.38.6"
|
||||
"@polkadot/api": "^0.42.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.38.6"
|
||||
"@polkadot/api": "^0.42.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.38.6"
|
||||
"@polkadot/api": "^0.42.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.38.6"
|
||||
"@polkadot/api": "^0.42.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -13,6 +13,6 @@
|
||||
"@polkadot/api": "^0.38.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
"rimraf": "^0.42.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.38.6"
|
||||
"@polkadot/api": "^0.42.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -480,7 +480,19 @@ export default abstract class ApiBase<CodecResult, SubscriptionResult> implement
|
||||
const sectionName = _sectionName as keyof DeriveInterface;
|
||||
|
||||
result[sectionName] = Object.keys(derive[sectionName]).reduce((section, methodName) => {
|
||||
const method = (...params: any[]) => onCall((derive[sectionName] as any)[methodName], params);
|
||||
// FIXME The callback extraction we do way too much - de-dupe
|
||||
const method = (...args: Array<any>) => {
|
||||
let callback: CodecCallback | undefined;
|
||||
let params = args;
|
||||
|
||||
if (args.length && isFunction(args[args.length - 1])) {
|
||||
callback = args[args.length - 1];
|
||||
params = args.slice(0, args.length - 1);
|
||||
}
|
||||
|
||||
return onCall((derive[sectionName] as any)[methodName], params, callback, !!callback);
|
||||
};
|
||||
|
||||
section[methodName] = method;
|
||||
|
||||
return section;
|
||||
|
||||
@@ -13,7 +13,10 @@ describe.skip('e2e queries', () => {
|
||||
let api;
|
||||
|
||||
beforeEach(async (done) => {
|
||||
api = await Api.create();
|
||||
if (!api) {
|
||||
api = await Api.create();
|
||||
}
|
||||
|
||||
jest.setTimeout(30000);
|
||||
done();
|
||||
});
|
||||
@@ -44,6 +47,14 @@ describe.skip('e2e queries', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('subscribes to derive', (done) => {
|
||||
api.derive.chain.subscribeNewHead((header) => {
|
||||
expect(header.blockNumber.isZero()).toBe(false);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('subscribes to queries', (done) => {
|
||||
api.query.system.accountNonce(keyring.ferdie.address(), (nonce) => {
|
||||
expect(nonce instanceof BN).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user