call services api directly, make endpoint configurable
This commit is contained in:
		
							parent
							
								
									65046c4cb8
								
							
						
					
					
						commit
						614432426a
					
				@ -40,6 +40,7 @@ __MAINNET_BLOCK_AUDIT_START_HEIGHT__=${MAINNET_BLOCK_AUDIT_START_HEIGHT:=0}
 | 
				
			|||||||
__TESTNET_BLOCK_AUDIT_START_HEIGHT__=${TESTNET_BLOCK_AUDIT_START_HEIGHT:=0}
 | 
					__TESTNET_BLOCK_AUDIT_START_HEIGHT__=${TESTNET_BLOCK_AUDIT_START_HEIGHT:=0}
 | 
				
			||||||
__SIGNET_BLOCK_AUDIT_START_HEIGHT__=${SIGNET_BLOCK_AUDIT_START_HEIGHT:=0}
 | 
					__SIGNET_BLOCK_AUDIT_START_HEIGHT__=${SIGNET_BLOCK_AUDIT_START_HEIGHT:=0}
 | 
				
			||||||
__ACCELERATOR__=${ACCELERATOR:=false}
 | 
					__ACCELERATOR__=${ACCELERATOR:=false}
 | 
				
			||||||
 | 
					__SERVICES_API__=${SERVICES_API:=false}
 | 
				
			||||||
__PUBLIC_ACCELERATIONS__=${PUBLIC_ACCELERATIONS:=false}
 | 
					__PUBLIC_ACCELERATIONS__=${PUBLIC_ACCELERATIONS:=false}
 | 
				
			||||||
__HISTORICAL_PRICE__=${HISTORICAL_PRICE:=true}
 | 
					__HISTORICAL_PRICE__=${HISTORICAL_PRICE:=true}
 | 
				
			||||||
__ADDITIONAL_CURRENCIES__=${ADDITIONAL_CURRENCIES:=false}
 | 
					__ADDITIONAL_CURRENCIES__=${ADDITIONAL_CURRENCIES:=false}
 | 
				
			||||||
@ -69,6 +70,7 @@ export __MAINNET_BLOCK_AUDIT_START_HEIGHT__
 | 
				
			|||||||
export __TESTNET_BLOCK_AUDIT_START_HEIGHT__
 | 
					export __TESTNET_BLOCK_AUDIT_START_HEIGHT__
 | 
				
			||||||
export __SIGNET_BLOCK_AUDIT_START_HEIGHT__
 | 
					export __SIGNET_BLOCK_AUDIT_START_HEIGHT__
 | 
				
			||||||
export __ACCELERATOR__
 | 
					export __ACCELERATOR__
 | 
				
			||||||
 | 
					export __SERVICES_API__
 | 
				
			||||||
export __PUBLIC_ACCELERATIONS__
 | 
					export __PUBLIC_ACCELERATIONS__
 | 
				
			||||||
export __HISTORICAL_PRICE__
 | 
					export __HISTORICAL_PRICE__
 | 
				
			||||||
export __ADDITIONAL_CURRENCIES__
 | 
					export __ADDITIONAL_CURRENCIES__
 | 
				
			||||||
 | 
				
			|||||||
@ -25,5 +25,6 @@
 | 
				
			|||||||
  "HISTORICAL_PRICE": true,
 | 
					  "HISTORICAL_PRICE": true,
 | 
				
			||||||
  "ADDITIONAL_CURRENCIES": false,
 | 
					  "ADDITIONAL_CURRENCIES": false,
 | 
				
			||||||
  "ACCELERATOR": false,
 | 
					  "ACCELERATOR": false,
 | 
				
			||||||
  "PUBLIC_ACCELERATIONS": false
 | 
					  "PUBLIC_ACCELERATIONS": false,
 | 
				
			||||||
 | 
					  "SERVICES_API": "https://mempool.space/api/v1/services"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -25,9 +25,6 @@ export interface IUser {
 | 
				
			|||||||
  ogRank: number | null;
 | 
					  ogRank: number | null;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Todo - move to config.json
 | 
					 | 
				
			||||||
const SERVICES_API_PREFIX = `/api/v1/services`;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@Injectable({
 | 
					@Injectable({
 | 
				
			||||||
  providedIn: 'root'
 | 
					  providedIn: 'root'
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
@ -98,7 +95,7 @@ export class ServicesApiServices {
 | 
				
			|||||||
      return of(null);
 | 
					      return of(null);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return this.httpClient.get<any>(`${SERVICES_API_PREFIX}/account`);
 | 
					    return this.httpClient.get<any>(`${this.stateService.env.SERVICES_API}/account`);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getUserMenuGroups$(): Observable<MenuGroup[]> {
 | 
					  getUserMenuGroups$(): Observable<MenuGroup[]> {
 | 
				
			||||||
@ -107,7 +104,7 @@ export class ServicesApiServices {
 | 
				
			|||||||
      return of(null);
 | 
					      return of(null);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return this.httpClient.get<MenuGroup[]>(`${SERVICES_API_PREFIX}/account/menu`);
 | 
					    return this.httpClient.get<MenuGroup[]>(`${this.stateService.env.SERVICES_API}/account/menu`);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  logout$(): Observable<any> {
 | 
					  logout$(): Observable<any> {
 | 
				
			||||||
@ -117,59 +114,59 @@ export class ServicesApiServices {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    localStorage.removeItem('auth');
 | 
					    localStorage.removeItem('auth');
 | 
				
			||||||
    return this.httpClient.post(`${SERVICES_API_PREFIX}/auth/logout`, {});
 | 
					    return this.httpClient.post(`${this.stateService.env.SERVICES_API}/auth/logout`, {});
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getJWT$() {
 | 
					  getJWT$() {
 | 
				
			||||||
    return this.httpClient.get<any>(`${SERVICES_API_PREFIX}/auth/getJWT`);
 | 
					    return this.httpClient.get<any>(`${this.stateService.env.SERVICES_API}/auth/getJWT`);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getServicesBackendInfo$(): Observable<IBackendInfo> {
 | 
					  getServicesBackendInfo$(): Observable<IBackendInfo> {
 | 
				
			||||||
    return this.httpClient.get<IBackendInfo>(`${SERVICES_API_PREFIX}/version`);
 | 
					    return this.httpClient.get<IBackendInfo>(`${this.stateService.env.SERVICES_API}/version`);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  estimate$(txInput: string) {
 | 
					  estimate$(txInput: string) {
 | 
				
			||||||
    return this.httpClient.post<any>(`${SERVICES_API_PREFIX}/accelerator/estimate`, { txInput: txInput }, { observe: 'response' });
 | 
					    return this.httpClient.post<any>(`${this.stateService.env.SERVICES_API}/accelerator/estimate`, { txInput: txInput }, { observe: 'response' });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  accelerate$(txInput: string, userBid: number, accelerationUUID: string) {
 | 
					  accelerate$(txInput: string, userBid: number, accelerationUUID: string) {
 | 
				
			||||||
    return this.httpClient.post<any>(`${SERVICES_API_PREFIX}/accelerator/accelerate`, { txInput: txInput, userBid: userBid, accelerationUUID: accelerationUUID });
 | 
					    return this.httpClient.post<any>(`${this.stateService.env.SERVICES_API}/accelerator/accelerate`, { txInput: txInput, userBid: userBid, accelerationUUID: accelerationUUID });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  accelerateWithCashApp$(txInput: string, token: string, cashtag: string, referenceId: string, accelerationUUID: string) {
 | 
					  accelerateWithCashApp$(txInput: string, token: string, cashtag: string, referenceId: string, accelerationUUID: string) {
 | 
				
			||||||
    return this.httpClient.post<any>(`${SERVICES_API_PREFIX}/accelerator/accelerate/cashapp`, { txInput: txInput, token: token, cashtag: cashtag, referenceId: referenceId, accelerationUUID: accelerationUUID });
 | 
					    return this.httpClient.post<any>(`${this.stateService.env.SERVICES_API}/accelerator/accelerate/cashapp`, { txInput: txInput, token: token, cashtag: cashtag, referenceId: referenceId, accelerationUUID: accelerationUUID });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getAccelerations$(): Observable<Acceleration[]> {
 | 
					  getAccelerations$(): Observable<Acceleration[]> {
 | 
				
			||||||
    return this.httpClient.get<Acceleration[]>(`${SERVICES_API_PREFIX}/accelerator/accelerations`);
 | 
					    return this.httpClient.get<Acceleration[]>(`${this.stateService.env.SERVICES_API}/accelerator/accelerations`);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getAggregatedAccelerationHistory$(params: AccelerationHistoryParams): Observable<any> {
 | 
					  getAggregatedAccelerationHistory$(params: AccelerationHistoryParams): Observable<any> {
 | 
				
			||||||
    return this.httpClient.get<any>(`${SERVICES_API_PREFIX}/accelerator/accelerations/history/aggregated`, { params: { ...params }, observe: 'response' });
 | 
					    return this.httpClient.get<any>(`${this.stateService.env.SERVICES_API}/accelerator/accelerations/history/aggregated`, { params: { ...params }, observe: 'response' });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getAccelerationHistory$(params: AccelerationHistoryParams): Observable<Acceleration[]> {
 | 
					  getAccelerationHistory$(params: AccelerationHistoryParams): Observable<Acceleration[]> {
 | 
				
			||||||
    return this.httpClient.get<Acceleration[]>(`${SERVICES_API_PREFIX}/accelerator/accelerations/history`, { params: { ...params } });
 | 
					    return this.httpClient.get<Acceleration[]>(`${this.stateService.env.SERVICES_API}/accelerator/accelerations/history`, { params: { ...params } });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getAccelerationHistoryObserveResponse$(params: AccelerationHistoryParams): Observable<any> {
 | 
					  getAccelerationHistoryObserveResponse$(params: AccelerationHistoryParams): Observable<any> {
 | 
				
			||||||
    return this.httpClient.get<any>(`${SERVICES_API_PREFIX}/accelerator/accelerations/history`, { params: { ...params }, observe: 'response'});
 | 
					    return this.httpClient.get<any>(`${this.stateService.env.SERVICES_API}/accelerator/accelerations/history`, { params: { ...params }, observe: 'response'});
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getAccelerationStats$(params: AccelerationHistoryParams): Observable<AccelerationStats> {
 | 
					  getAccelerationStats$(params: AccelerationHistoryParams): Observable<AccelerationStats> {
 | 
				
			||||||
    return this.httpClient.get<AccelerationStats>(`${SERVICES_API_PREFIX}/accelerator/accelerations/stats`, { params: { ...params } });
 | 
					    return this.httpClient.get<AccelerationStats>(`${this.stateService.env.SERVICES_API}/accelerator/accelerations/stats`, { params: { ...params } });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  setupSquare$(): Observable<{squareAppId: string, squareLocationId: string}> {
 | 
					  setupSquare$(): Observable<{squareAppId: string, squareLocationId: string}> {
 | 
				
			||||||
    return this.httpClient.get<{squareAppId: string, squareLocationId: string}>(`${SERVICES_API_PREFIX}/square/setup`);
 | 
					    return this.httpClient.get<{squareAppId: string, squareLocationId: string}>(`${this.stateService.env.SERVICES_API}/square/setup`);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getFaucetStatus$() {
 | 
					  getFaucetStatus$() {
 | 
				
			||||||
    return this.httpClient.get<{ address?: string, min: number, max: number, code: 'ok' | 'faucet_not_available' | 'faucet_maximum_reached' | 'faucet_too_soon'}>(`${SERVICES_API_PREFIX}/testnet4/faucet/status`, { responseType: 'json' });
 | 
					    return this.httpClient.get<{ address?: string, min: number, max: number, code: 'ok' | 'faucet_not_available' | 'faucet_maximum_reached' | 'faucet_too_soon'}>(`${this.stateService.env.SERVICES_API}/testnet4/faucet/status`, { responseType: 'json' });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  requestTestnet4Coins$(address: string, sats: number) {
 | 
					  requestTestnet4Coins$(address: string, sats: number) {
 | 
				
			||||||
    return this.httpClient.get<{txid: string}>(`${SERVICES_API_PREFIX}/testnet4/faucet/request?address=${address}&sats=${sats}`, { responseType: 'json' });
 | 
					    return this.httpClient.get<{txid: string}>(`${this.stateService.env.SERVICES_API}/testnet4/faucet/request?address=${address}&sats=${sats}`, { responseType: 'json' });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  generateBTCPayAcceleratorInvoice$(txid: string, sats: number): Observable<any> {
 | 
					  generateBTCPayAcceleratorInvoice$(txid: string, sats: number): Observable<any> {
 | 
				
			||||||
@ -177,14 +174,14 @@ export class ServicesApiServices {
 | 
				
			|||||||
      product: txid,
 | 
					      product: txid,
 | 
				
			||||||
      amount: sats,
 | 
					      amount: sats,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    return this.httpClient.post<any>(`${SERVICES_API_PREFIX}/payments/bitcoin`, params);
 | 
					    return this.httpClient.post<any>(`${this.stateService.env.SERVICES_API}/payments/bitcoin`, params);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  retreiveInvoice$(invoiceId: string): Observable<any[]> {
 | 
					  retreiveInvoice$(invoiceId: string): Observable<any[]> {
 | 
				
			||||||
    return this.httpClient.get<any[]>(`${SERVICES_API_PREFIX}/payments/bitcoin/invoice?id=${invoiceId}`);
 | 
					    return this.httpClient.get<any[]>(`${this.stateService.env.SERVICES_API}/payments/bitcoin/invoice?id=${invoiceId}`);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getPaymentStatus$(orderId: string): Observable<any[]> {
 | 
					  getPaymentStatus$(orderId: string): Observable<any[]> {
 | 
				
			||||||
    return this.httpClient.get<any[]>(`${SERVICES_API_PREFIX}/payments/bitcoin/check?order_id=${orderId}`);
 | 
					    return this.httpClient.get<any[]>(`${this.stateService.env.SERVICES_API}/payments/bitcoin/check?order_id=${orderId}`);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -75,6 +75,7 @@ export interface Env {
 | 
				
			|||||||
  ADDITIONAL_CURRENCIES: boolean;
 | 
					  ADDITIONAL_CURRENCIES: boolean;
 | 
				
			||||||
  GIT_COMMIT_HASH_MEMPOOL_SPACE?: string;
 | 
					  GIT_COMMIT_HASH_MEMPOOL_SPACE?: string;
 | 
				
			||||||
  PACKAGE_JSON_VERSION_MEMPOOL_SPACE?: string;
 | 
					  PACKAGE_JSON_VERSION_MEMPOOL_SPACE?: string;
 | 
				
			||||||
 | 
					  SERVICES_API?: string;
 | 
				
			||||||
  customize?: Customization;
 | 
					  customize?: Customization;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -109,6 +110,7 @@ const defaultEnv: Env = {
 | 
				
			|||||||
  'ACCELERATOR': false,
 | 
					  'ACCELERATOR': false,
 | 
				
			||||||
  'PUBLIC_ACCELERATIONS': false,
 | 
					  'PUBLIC_ACCELERATIONS': false,
 | 
				
			||||||
  'ADDITIONAL_CURRENCIES': false,
 | 
					  'ADDITIONAL_CURRENCIES': false,
 | 
				
			||||||
 | 
					  'SERVICES_API': 'https://mempool.space/api/v1/services',
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Injectable({
 | 
					@Injectable({
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user