Skip to content

Commit

Permalink
converting camelCase to snake_case on frontend to remove need of flag…
Browse files Browse the repository at this point in the history
… on validator client (#217)

* converting camelcase to snakecase on frontend to remove need of flag

* addressing a few missed items

* fix to make delete account usable again, fix for N/A displayed data
  • Loading branch information
james-prysm authored Dec 9, 2021
1 parent 75b549f commit 5cda2a4
Show file tree
Hide file tree
Showing 43 changed files with 456 additions and 671 deletions.
6 changes: 3 additions & 3 deletions src/app/modules/auth/guards/hasWallet.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ErrorHandler, Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
import { Observable } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { HasUsedWebResponse } from 'src/app/proto/validator/accounts/v2/web_api';
import { InitializeAuthResponse } from 'src/app/proto/validator/accounts/v2/web_api';
import { AuthenticationService } from '../services/authentication.service';

import { LANDING_URL } from '../../core/constants';
Expand All @@ -22,7 +22,7 @@ export class HasWalletGuard implements CanActivate {
| Promise<boolean | UrlTree>
| boolean | UrlTree {
return this.authenticationService.checkHasUsedWeb().pipe(
map((res: HasUsedWebResponse) => {
map((res: InitializeAuthResponse) => {
const urlSegment = route.url[0];
const urlCases = [
{path: ONBOARDING_URL, hasWallet: true, result: this.router.parseUrl(LANDING_URL)},
Expand All @@ -31,7 +31,7 @@ export class HasWalletGuard implements CanActivate {
{path: LANDING_URL, hasWallet: false, result: this.router.parseUrl(ONBOARDING_URL)}
];
const foundUrlCase = urlCases.find((urlCase) => {
return urlCase.path === urlSegment.path && urlCase.hasWallet === res.hasWallet;
return urlCase.path === urlSegment.path && urlCase.hasWallet === res.has_wallet;
});
return foundUrlCase ? foundUrlCase.result : false;
}),
Expand Down
10 changes: 4 additions & 6 deletions src/app/modules/auth/services/authentication.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { tap } from 'rxjs/operators';
import { AuthRequest, AuthResponse, ChangePasswordRequest, HasUsedWebResponse } from 'src/app/proto/validator/accounts/v2/web_api';
import { InitializeAuthResponse } from 'src/app/proto/validator/accounts/v2/web_api';
import { EnvironmenterService } from '../../core/services/environmenter.service';


Expand All @@ -16,7 +16,7 @@ export class AuthenticationService {
private environmenter: EnvironmenterService
) {
}
hasSignedUp = false;

shortLivedToken = '';
private apiUrl = this.environmenter.env.validatorEndpoint;

Expand All @@ -36,10 +36,8 @@ export class AuthenticationService {
window.localStorage.removeItem(this.TOKENEXPIRATIONNAME);
}

checkHasUsedWeb(): Observable<HasUsedWebResponse> {
return this.http.get<HasUsedWebResponse>(`${this.apiUrl}/initialize`).pipe(
tap((res: HasUsedWebResponse) => this.hasSignedUp = res.hasSignedUp),
);
checkHasUsedWeb(): Observable<InitializeAuthResponse> {
return this.http.get<InitializeAuthResponse>(`${this.apiUrl}/initialize`);
}

getToken(): string | null{
Expand Down
10 changes: 0 additions & 10 deletions src/app/modules/core/interceptors/mock.interceptor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ describe('MockInterceptor', () => {
});

describe('intercept HTTP requests', () => {
it('should retrieve a mock for the validator API calls', inject([HttpClient, HttpTestingController],
(http: HttpClient, mock: HttpTestingController) => {
const endpoint = VALIDATOR_API_PREFIX + '/login';
http.get(endpoint).subscribe((res) => {
expect(res).toEqual(Mocks[endpoint]);
});
mock.verify();
})
);

it('should retrieve a mock for the beacon node API calls', inject([HttpClient, HttpTestingController],
(http: HttpClient, mock: HttpTestingController) => {
const endpoint = VALIDATOR_API_PREFIX + '/beacon/participation';
Expand Down
Loading

0 comments on commit 5cda2a4

Please sign in to comment.