Bubble isSubscription from rpc-rx (#627)
* Bubble isSubscription from rpc-rx * Fix logic error
This commit is contained in:
@@ -14,7 +14,10 @@ import { isFunction } from '@polkadot/util';
|
||||
import ApiBase from '../Base';
|
||||
import Combinator, { CombinatorCallback, CombinatorFunction } from './Combinator';
|
||||
|
||||
type RxFn = (...params: Array<any>) => Observable<Codec | undefined | null>;
|
||||
interface RxFn {
|
||||
(...params: Array<any>): Observable<Codec | undefined | null>;
|
||||
isSubscription: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* # @polkadot/api/promise
|
||||
@@ -193,8 +196,8 @@ export default class ApiPromise extends ApiBase<OnCall> implements ApiPromiseInt
|
||||
};
|
||||
}
|
||||
|
||||
protected onCall (method: RxFn, params: Array<any>, isSubscription?: boolean): OnCall {
|
||||
if (!params || params.length === 0 || isSubscription === false) {
|
||||
protected onCall (method: RxFn, params: Array<any>, isSubscription: boolean = false): OnCall {
|
||||
if (!params || params.length === 0 || !isSubscription) {
|
||||
return method(...params).pipe(first()).toPromise();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2017-2019 @polkadot/api authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// @ts-check
|
||||
|
||||
import BN from 'bn.js';
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2017-2019 @polkadot/api authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// @ts-check
|
||||
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
|
||||
@@ -46,7 +47,7 @@ describe.skip('e2e transactions', () => {
|
||||
});
|
||||
|
||||
it('makes a transfer (signAndSend)', async (done) => {
|
||||
api.tx.balances
|
||||
const unsubscribe = await api.tx.balances
|
||||
.transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345)
|
||||
.signAndSend(keyring.dave, ({ events, status, type }) => {
|
||||
console.log('Transaction status:', type);
|
||||
@@ -59,9 +60,8 @@ describe.skip('e2e transactions', () => {
|
||||
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
|
||||
});
|
||||
|
||||
if (events.length) {
|
||||
done();
|
||||
}
|
||||
unsubscribe();
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2017-2019 @polkadot/api authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// @ts-check
|
||||
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2017-2019 @polkadot/api authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// @ts-check
|
||||
|
||||
import { first, switchMap } from 'rxjs/operators';
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
|
||||
Reference in New Issue
Block a user