Files
api/packages/api-observable/src/Calls.ts
T
Jaco Greeff 82dbc93f79 Mortal -> Extrinsic, expand for decoding start (#212)
* Mortal -> Extrinsic, expand for decoding start

* Method, Section -> Rpc{Method, Section}

* Only expose callIndex

* CallIndex -> MethodIndex in spec
2018-10-05 12:29:06 +02:00

51 lines
1.4 KiB
TypeScript

// Copyright 2017-2018 @polkadot/ui-observable authors & contributors
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Observable } from 'rxjs';
import { defaultIfEmpty, map } from 'rxjs/operators';
import { BlockNumber, Hash, Header, SignedBlock, Extrinsic } from '@polkadot/types/index';
import ApiQueries from './Queries';
// Implementation of calls to API endpoints.
export default class ApiCalls extends ApiQueries {
bestNumber = (): Observable<BlockNumber | undefined> => {
return this
.newHead()
.pipe(
map((header?: Header): BlockNumber | undefined =>
header && header.blockNumber
? header.blockNumber
: undefined
)
);
}
chain = (): Observable<Text | undefined> => {
return this._api.system.chain();
}
getBlock = (hash: Uint8Array): Observable<SignedBlock | undefined> => {
return this._api.chain.getBlock(hash);
}
newHead = (): Observable<Header | undefined> => {
return this._api.chain.newHead().pipe(
defaultIfEmpty()
);
}
systemName = (): Observable<Text | undefined> => {
return this._api.system.name();
}
systemVersion = (): Observable<Text | undefined> => {
return this._api.system.version();
}
submitExtrinsic = (extrinsic: Extrinsic): Observable<Hash | undefined> => {
return this._api.author.submitExtrinsic(extrinsic);
}
}