import { Injectable } from "@angular/core" ; import { Observable , of } from "rxjs" ; import { map } from "rxjs/operators" ; import { NetworkProvider } from "@/services/network/network" ; import { HttpClient } from "@/utils/ark-http-client" ; @ Injectable ( { providedIn : "root" } ) export class NeoApiProvider { private static readonly baseUrl = "https://neoscan.io/api/main_net/v1" ; public constructor ( private http , private networkProvider ) { } public doesAddressExist ( address ) { if ( ! this . isValidAddress ( address ) ) { return of ( false ) ; } return this . getBalance ( address ) . pipe ( map ( ( res ) => res . length > 0 ) ) ; } private getBalance ( address ) { return this . http . get < any [ ] > ( `${ NeoApiProvider . baseUrl }/get_last_transactions_by_address/${ address }` ) ; } private isValidAddress ( address ) { return this . networkProvider . isValidAddress ( address , 0x17 ) ; } }