// 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 => { return this .newHead() .pipe( map((header?: Header): BlockNumber | undefined => header && header.blockNumber ? header.blockNumber : undefined ) ); } chain = (): Observable => { return this._api.system.chain(); } getBlock = (hash: Uint8Array): Observable => { return this._api.chain.getBlock(hash); } newHead = (): Observable
=> { return this._api.chain.newHead().pipe( defaultIfEmpty() ); } systemName = (): Observable => { return this._api.system.name(); } systemVersion = (): Observable => { return this._api.system.version(); } submitExtrinsic = (extrinsic: Extrinsic): Observable => { return this._api.author.submitExtrinsic(extrinsic); } }