From 6ba69c47e4986b160633d000c05479cf17a7d200 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Wed, 15 Nov 2023 13:58:37 -0600 Subject: [PATCH 1/3] removing old widgets and removing base64 middleware --- src/app/modules/core/mocks/index.ts | 55 ++------ .../core/services/chain.service.spec.ts | 50 ------- .../modules/core/services/chain.service.ts | 31 ----- .../core/services/validator.service.ts | 5 +- src/app/modules/core/utils/hex-util.spec.ts | 11 -- src/app/modules/core/utils/hex-util.ts | 28 ---- .../activation-queue.component.html | 73 ----------- .../activation-queue.component.spec.ts | 90 ------------- .../activation-queue.component.ts | 122 ------------------ .../validator-participation.component.html | 71 ---------- .../validator-participation.component.spec.ts | 74 ----------- .../validator-participation.component.ts | 78 ----------- .../validator-performance-list.component.html | 2 +- .../validator-performance-list.component.ts | 5 +- src/app/modules/dashboard/dashboard.module.ts | 4 - .../gains-and-losses.component.html | 5 - .../gains-and-losses.component.spec.ts | 9 -- .../shared/pipes/base64-to-hex.pipe.spec.ts | 9 -- .../shared/pipes/base64-to-hex.pipe.ts | 11 -- src/app/modules/shared/shared.module.ts | 2 - .../account-delete.component.html | 2 +- .../account-delete.component.ts | 3 +- .../account-selections.component.html | 2 +- .../accounts-form-selection.component.html | 2 +- .../accounts-form-selection.component.ts | 3 +- .../accounts-table.component.html | 4 +- .../accounts-table.component.ts | 11 +- .../fee-recipient-edit.component.html | 2 +- .../fee-recipient-edit.component.ts | 9 +- .../account-voluntary-exit.component.ts | 4 +- .../pages/accounts/accounts.component.ts | 5 +- src/app/proto/eth/v1alpha1/beacon_chain.ts | 57 +------- src/app/proto/eth/v1alpha1/validator.ts | 92 ------------- 33 files changed, 33 insertions(+), 898 deletions(-) delete mode 100644 src/app/modules/core/services/chain.service.spec.ts delete mode 100644 src/app/modules/core/services/chain.service.ts delete mode 100644 src/app/modules/core/utils/hex-util.spec.ts delete mode 100644 src/app/modules/core/utils/hex-util.ts delete mode 100644 src/app/modules/dashboard/components/activation-queue/activation-queue.component.html delete mode 100644 src/app/modules/dashboard/components/activation-queue/activation-queue.component.spec.ts delete mode 100644 src/app/modules/dashboard/components/activation-queue/activation-queue.component.ts delete mode 100644 src/app/modules/dashboard/components/validator-participation/validator-participation.component.html delete mode 100644 src/app/modules/dashboard/components/validator-participation/validator-participation.component.spec.ts delete mode 100644 src/app/modules/dashboard/components/validator-participation/validator-participation.component.ts delete mode 100644 src/app/modules/shared/pipes/base64-to-hex.pipe.spec.ts delete mode 100644 src/app/modules/shared/pipes/base64-to-hex.pipe.ts diff --git a/src/app/modules/core/mocks/index.ts b/src/app/modules/core/mocks/index.ts index 78ec0b53..1bbe4d2d 100644 --- a/src/app/modules/core/mocks/index.ts +++ b/src/app/modules/core/mocks/index.ts @@ -1,11 +1,9 @@ -import { hexToBase64 } from 'src/app/modules/core/utils/hex-util'; import { ChainHead, ValidatorBalances, - ValidatorBalances_Balance, ValidatorParticipationResponse, ValidatorQueue, + ValidatorBalances_Balance, Validators, ValidatorSummaryResponse, Validators_ValidatorContainer } from 'src/app/proto/eth/v1alpha1/beacon_chain'; import { Peers } from 'src/app/proto/eth/v1alpha1/node'; -import { ValidatorParticipation } from 'src/app/proto/eth/v1alpha1/validator'; import { Account, BackupAccountsResponse, BeaconStatusResponse, GenerateMnemonicResponse, ImportKeystoresResponse, InitializeAuthResponse, ListAccountsResponse, WalletResponse } from 'src/app/proto/validator/accounts/v2/web_api'; @@ -54,30 +52,16 @@ export const mockSlashingProtection = { }; export const mockPublicKeys: string[] = [ - hexToBase64( - '0xaadaf653799229200378369ee7d6d9fdbdcdc2788143ed44f1ad5f2367c735e83a37c5bb80d7fb917de73a61bbcf00c4' - ), - hexToBase64( - '0xb9a7565e5daaabf7e5656b64201685c6c0241df7195a64dcfc82f94b39826562208ea663dc8e340994fe5e2eef05967a' - ), - hexToBase64( - '0xa74a19ce0c8a7909cb38e6645738c8d3f85821e371ecc273f16d02ec8b279153607953522c61e0d9c16c73e4e106dd31' - ), - hexToBase64( - '0x8d4d65e320ebe3f8f45c1941a7f340eef43ff233400253a5532ad40313b4c5b3652ad84915c7ab333d8afb336e1b7407' - ), - hexToBase64( - '0x93b283992d2db593c40d0417ccf6302ed5a26180555ec401c858232dc224b7e5c92aca63646bbf4d0d61df1584459d90' - ), + '0xaadaf653799229200378369ee7d6d9fdbdcdc2788143ed44f1ad5f2367c735e83a37c5bb80d7fb917de73a61bbcf00c4', + '0xb9a7565e5daaabf7e5656b64201685c6c0241df7195a64dcfc82f94b39826562208ea663dc8e340994fe5e2eef05967a', + '0xa74a19ce0c8a7909cb38e6645738c8d3f85821e371ecc273f16d02ec8b279153607953522c61e0d9c16c73e4e106dd31', + '0x8d4d65e320ebe3f8f45c1941a7f340eef43ff233400253a5532ad40313b4c5b3652ad84915c7ab333d8afb336e1b7407', + '0x93b283992d2db593c40d0417ccf6302ed5a26180555ec401c858232dc224b7e5c92aca63646bbf4d0d61df1584459d90', ]; const mockImportedKeys: string[] = [ - hexToBase64( - '0x80027c7b2213480672caf8503b82d41ff9533ba3698c2d70d33fa6c1840b2c115691dfb6de791f415db9df8b0176b9e4' - ), - hexToBase64( - '0x800212f3ac97227ac9e4418ce649f386d90bbc1a95c400b6e0dbbe04da2f9b970e85c32ae89c4fdaaba74b5a2934ed5e' - ), + '0x80027c7b2213480672caf8503b82d41ff9533ba3698c2d70d33fa6c1840b2c115691dfb6de791f415db9df8b0176b9e4', + '0x800212f3ac97227ac9e4418ce649f386d90bbc1a95c400b6e0dbbe04da2f9b970e85c32ae89c4fdaaba74b5a2934ed5e', ]; export const mockDepositDataJSON = [ @@ -499,22 +483,6 @@ export const Mocks: IMocks = { }, ], } as Peers, - '/v2/validator/beacon/participation': { - epoch: 32, - finalized: true, - participation: { - current_epoch_active_gwei: '1446418000000000', - current_epoch_attesting_gwei: '102777000000000', - current_epoch_target_attesting_gwei: '101552000000000', - eligible_ether: '1446290000000000', - global_participation_rate: 0.7861, - previous_epoch_active_gwei: '1446290000000000', - previous_epoch_attesting_gwei: '1143101000000000', - previous_epoch_head_attesting_gwei: '1089546000000000', - previous_epoch_target_attesting_gwei: '1136975000000000', - voted_ether: '1136975000000000', - } as ValidatorParticipation, - } as ValidatorParticipationResponse, '/v2/validator/beacon/summary': { current_effective_balances: ['31000000000', '31000000000', '31000000000'], correctly_voted_head: [true, true, false], @@ -530,13 +498,6 @@ export const Mocks: IMocks = { public_keys: mockPublicKeys, missing_validators: [], } as ValidatorSummaryResponse, - '/v2/validator/beacon/queue': { - churn_limit: 4, - activation_public_keys: [mockPublicKeys[0], mockPublicKeys[1]], - activation_validator_indices: [0, 1], - exit_public_keys: [mockPublicKeys[2]], - exit_validator_indices: [2], - } as ValidatorQueue, '/v2/validator/beacon/validators': { validator_list: mockPublicKeys.map((key, idx) => { return { diff --git a/src/app/modules/core/services/chain.service.spec.ts b/src/app/modules/core/services/chain.service.spec.ts deleted file mode 100644 index be4b2fa6..00000000 --- a/src/app/modules/core/services/chain.service.spec.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { TestBed } from '@angular/core/testing'; -import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; - -import { of } from 'rxjs'; - -import { ChainService } from './chain.service'; -import { BeaconNodeService } from './beacon-node.service'; -import { ValidatorParticipationResponse } from 'src/app/proto/eth/v1alpha1/beacon_chain'; -import { Injectable } from '@angular/core'; -import { EnvironmenterService } from './environmenter.service'; - -@Injectable() -class MockNode { - nodeEndpoint$ = of('/eth/v1alpha1'); -} - -describe('ChainService', () => { - let service: ChainService; - let httpMock: HttpTestingController; - const envSpy = jasmine.createSpyObj('EnvironmenterService', ['env']); - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - providers: [ - ChainService, - { provide: BeaconNodeService, useValue: new MockNode() }, - { provide: EnvironmenterService, useValue: envSpy }, - ] - }); - service = TestBed.inject(ChainService); - httpMock = TestBed.inject(HttpTestingController); - }); - - afterEach(() => { - httpMock.verify(); - }); - - it('should properly query the beacon endpoint for participation', (done) => { - const mockResponse = { - } as ValidatorParticipationResponse; - service.participation$.subscribe(resp => { - expect(resp).toEqual(mockResponse); - done(); - }); - const request = httpMock.expectOne(`undefined/beacon/participation`); - expect(request.request.method).toBe('GET'); - request.flush(mockResponse); - }); -}); diff --git a/src/app/modules/core/services/chain.service.ts b/src/app/modules/core/services/chain.service.ts deleted file mode 100644 index c367e8a9..00000000 --- a/src/app/modules/core/services/chain.service.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Injectable } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; - -import { tap, switchMap, startWith } from 'rxjs/operators'; -import { interval, Observable } from 'rxjs'; - -import { - ValidatorParticipationResponse, ValidatorQueue, -} from 'src/app/proto/eth/v1alpha1/beacon_chain'; -import { MILLISECONDS_PER_EPOCH } from '../constants'; -import { EnvironmenterService } from './environmenter.service'; - -@Injectable({ - providedIn: 'root', -}) -export class ChainService { - constructor( - private http: HttpClient, - private environmenter: EnvironmenterService, - ) { } - - private apiUrl = this.environmenter.env.validatorEndpoint; - // Chain information. - participation$: Observable = interval(MILLISECONDS_PER_EPOCH).pipe( - startWith(0), - switchMap(() => { - return this.http.get(`${this.apiUrl}/beacon/participation`); - }), - ); - activationQueue$: Observable = this.http.get(`${this.apiUrl}/beacon/queue`); -} diff --git a/src/app/modules/core/services/validator.service.ts b/src/app/modules/core/services/validator.service.ts index b7a32be9..7172440a 100644 --- a/src/app/modules/core/services/validator.service.ts +++ b/src/app/modules/core/services/validator.service.ts @@ -7,7 +7,6 @@ import { } from 'src/app/proto/eth/v1alpha1/beacon_chain'; import { VersionResponse } from 'src/app/proto/validator/accounts/v2/web_api'; import { ListFeeRecipientResponse, SetFeeRecipientRequest } from 'src/app/proto/validator/accounts/v2/web_api_keymanager-api'; -import { base64ToHex } from '../utils/hex-util'; import { EnvironmenterService } from './environmenter.service'; import { WalletService } from './wallet.service'; @@ -63,13 +62,13 @@ export class ValidatorService { } getFeeRecipient(publicKey:string): Observable< ListFeeRecipientResponse>{ - return this.http.get(`${this.keymanagerUrl}/validator/${base64ToHex(publicKey)}/feerecipient`).pipe( + return this.http.get(`${this.keymanagerUrl}/validator/${publicKey}/feerecipient`).pipe( catchError((err: HttpErrorResponse) => { let UNSET_RECIPIENT = "set by beacon node"; // just let the user know it's set by the beacon node if it's not set return of({ data: { - pubkey: base64ToHex(publicKey), + pubkey: publicKey, ethaddress: UNSET_RECIPIENT, } }); diff --git a/src/app/modules/core/utils/hex-util.spec.ts b/src/app/modules/core/utils/hex-util.spec.ts deleted file mode 100644 index 45086e72..00000000 --- a/src/app/modules/core/utils/hex-util.spec.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { base64ToHex, hexToBase64 } from './hex-util'; - -describe('fromHexString, hexToBase64', () => { - it('should do a proper round trip conversion', () => { - const original = 'AIIuAOw9jsxQ4De3rj66VIZIDR7EmvrWmg12v9sVjq2bw4no3v7ywHbQgDcb8fD+/A=='; - const hex = base64ToHex(original); - expect(hex).toEqual('0x00822e00ec3d8ecc50e037b7ae3eba5486480d1ec49afad69a0d76bfdb158ead9bc389e8defef2c076d080371bf1f0fefc'); - const base64 = hexToBase64(hex); - expect(base64).toEqual(original); - }); -}); diff --git a/src/app/modules/core/utils/hex-util.ts b/src/app/modules/core/utils/hex-util.ts deleted file mode 100644 index ae7469d1..00000000 --- a/src/app/modules/core/utils/hex-util.ts +++ /dev/null @@ -1,28 +0,0 @@ -export function hexToBase64(hexstring: string): string { - if (!hexstring) { - return ''; - } - let str = hexstring; - if (str.indexOf('0x') !== -1) { - str = str.replace('0x', ''); - } - const matched = str.match(/.{2}/g); - if (!matched) { - return ''; - } - const res = matched.map(c => parseInt(c, 16)); - return btoa( - String.fromCharCode( - ...res, - ) - ); -} - -export function base64ToHex(base64string: string): string { - const res = Array.prototype.reduce.call( - atob(base64string), - (acc, c) => acc + `0${c.charCodeAt(0).toString(16)}`.slice(-2), - '' - ); - return '0x' + res; -} diff --git a/src/app/modules/dashboard/components/activation-queue/activation-queue.component.html b/src/app/modules/dashboard/components/activation-queue/activation-queue.component.html deleted file mode 100644 index f9664185..00000000 --- a/src/app/modules/dashboard/components/activation-queue/activation-queue.component.html +++ /dev/null @@ -1,73 +0,0 @@ - -
- Validator Queue -
-
- {{data.secondsLeftInQueue | amDuration:'seconds'}} left in queue -
-
- {{data.churnLimit.length}} - Activated per epoch -
-
- - person - -
-
- {{data.activationPublicKeys.size}} - Pending activation -
-
- {{data.exitPublicKeys.size}} - Pending exit -
-
-
- -
-
- {{userKeys.length}} of your keys pending activation -
-
-
- {{(key | base64tohex)}} -
-
-
{{activationETAForPosition(position, data) | amDuration:'seconds'}} left
-
- {{position | ordinal}} in line -
-
-
-
- ... -
-
-
-
- -
-
- {{userKeys.length}} of your keys pending exit -
-
-
- {{(key | base64tohex)}} -
-
-
{{activationETAForPosition(position, data) | amDuration:'seconds'}} left
-
- {{position | ordinal}} in line -
-
-
-
- ... -
-
-
diff --git a/src/app/modules/dashboard/components/activation-queue/activation-queue.component.spec.ts b/src/app/modules/dashboard/components/activation-queue/activation-queue.component.spec.ts deleted file mode 100644 index 1f9dc8ae..00000000 --- a/src/app/modules/dashboard/components/activation-queue/activation-queue.component.spec.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; - -import { of } from 'rxjs'; -import { MockService } from 'ng-mocks'; - -import { ActivationQueueComponent, QueueData } from './activation-queue.component'; -import { ValidatorService } from 'src/app/modules/core/services/validator.service'; -import { ValidatorParticipationResponse, ValidatorQueue } from 'src/app/proto/eth/v1alpha1/beacon_chain'; -import { SharedModule } from 'src/app/modules/shared/shared.module'; -import { WalletService } from 'src/app/modules/core/services/wallet.service'; -import { SECONDS_PER_EPOCH } from 'src/app/modules/core/constants'; -import { hexToBase64 } from 'src/app/modules/core/utils/hex-util'; -import { ChainService } from 'src/app/modules/core/services/chain.service'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { EnvironmenterService } from 'src/app/modules/core/services/environmenter.service'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; - -describe('ActivationQueueComponent', () => { - let component: ActivationQueueComponent; - let fixture: ComponentFixture; - const envSpy = jasmine.createSpyObj('EnvironmenterService', ['env']); - const service: ChainService = MockService(ChainService); - const walletService: WalletService = MockService(WalletService); - const defaultQueueResponse = { - churn_limit: 4, - activation_public_keys: [ - hexToBase64('0x123456'), - ], - activation_validator_indices: [1], - exit_public_keys: [], - exit_validator_indices: [], - } as ValidatorQueue; - const defaultKeysResponse = [ - hexToBase64('0x123456'), - ]; - service['activationQueue$'] = of(defaultQueueResponse); - service['participation$'] = of({} as ValidatorParticipationResponse); - walletService['validatingPublicKeys$'] = of(defaultKeysResponse); - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [ ActivationQueueComponent ], - imports: [ - SharedModule, - BrowserAnimationsModule, - HttpClientTestingModule, - ], - providers: [ - { provide: EnvironmenterService, useValue: envSpy }, - { provide: ValidatorService, useValue: service }, - { provide: WalletService, useValue: walletService }, - ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ActivationQueueComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - describe('Position in queue', () => { - it('should determine position in activation array', () => { - const arr = [ - hexToBase64('0x234'), - defaultQueueResponse.activation_public_keys[0], - hexToBase64('0x678') - ]; - const key = defaultQueueResponse.activation_public_keys[0]; - const position = component.positionInArray(arr, key); - expect(position).toEqual(2); - }); - it('should determine proper activation ETA in seconds if position < churn limit', () => { - const data = { - churnLimit: Array.from({ length: 4 }) - } as QueueData; - const estimatedTime = component.activationETAForPosition(0, data); - expect(estimatedTime).toEqual(SECONDS_PER_EPOCH); - }); - it('should determine proper activation ETA in seconds if position > churn limit', () => { - const data = { - churnLimit: Array.from({ length: 1 }) - } as QueueData; - const estimatedTime = component.activationETAForPosition(2, data); - // Expect two epochs for activation if churn limit is 1. - expect(estimatedTime).toEqual(SECONDS_PER_EPOCH * 2); - }); - }); -}); diff --git a/src/app/modules/dashboard/components/activation-queue/activation-queue.component.ts b/src/app/modules/dashboard/components/activation-queue/activation-queue.component.ts deleted file mode 100644 index 4690f4a9..00000000 --- a/src/app/modules/dashboard/components/activation-queue/activation-queue.component.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { Component } from '@angular/core'; - -import { map } from 'rxjs/operators'; -import { zip } from 'rxjs'; -import intersect from 'src/app/modules/core/utils/intersect'; - -import { ValidatorQueue } from 'src/app/proto/eth/v1alpha1/beacon_chain'; -import { WalletService } from 'src/app/modules/core/services/wallet.service'; -import { SECONDS_PER_EPOCH } from 'src/app/modules/core/constants'; -import { ChainService } from 'src/app/modules/core/services/chain.service'; - -export interface QueueData { - originalData: ValidatorQueue; - churnLimit: Array; - activationPublicKeys: Set; - exitPublicKeys: Set; - secondsLeftInQueue: number; - userValidatingPublicKeys: Set; -} - -@Component({ - selector: 'app-activation-queue', - templateUrl: './activation-queue.component.html', - styles: [ - ] -}) -export class ActivationQueueComponent { - constructor( - private chainService: ChainService, - private walletService: WalletService, - ) { } - - validatingPublicKeys$ = this.walletService.validatingPublicKeys$; - - queueData$ = zip( - this.walletService.validatingPublicKeys$, - this.chainService.activationQueue$ - ).pipe( - map(([validatingKeys, queue]) => this.transformData(validatingKeys, queue)), - ); - - userKeysAwaitingActivation( - queueData: QueueData, - ): Array { - // We return the set intersection of those keys in the - // queue with the user's validating public keys. - return Array.from(intersect( - queueData.userValidatingPublicKeys, queueData.activationPublicKeys - )); - } - - userKeysAwaitingExit( - queueData: QueueData, - ): Array { - // We return the set intersection of those keys in the - // queue with the user's validating public keys. - return Array.from(intersect( - queueData.userValidatingPublicKeys, queueData.exitPublicKeys - )); - } - - positionInArray( - data: string[], pubKey: string, - ): number { - let idx = -1; - for (let i = 0; i < data.length; i++) { - if (data[i] === pubKey) { - idx = i; - break; - } - } - // Arrays are indexed at 0, but the number will be displayed - // as an ordinal number to the user. - return idx + 1; - } - - activationETAForPosition(position: number, queueData: QueueData): number { - const epochsLeft = position / queueData.churnLimit.length; - const secondsLeftInQueue = epochsLeft * SECONDS_PER_EPOCH; - if (secondsLeftInQueue < SECONDS_PER_EPOCH) { - return SECONDS_PER_EPOCH; - } - return secondsLeftInQueue; - } - - transformData(validatingKeys: string[], queue: ValidatorQueue): QueueData { - const userValidatingKeysSet = new Set(); - validatingKeys.forEach(key => { - userValidatingKeysSet.add(key); - }); - - const activationKeysSet = new Set(); - const exitKeysSet = new Set(); - - if (queue.activation_public_keys) { - queue.activation_public_keys.forEach((key, _) => { - activationKeysSet.add(key); - }); - } - if (queue.exit_public_keys) { - queue.exit_public_keys.forEach((key, _) => { - exitKeysSet.add(key); - }); - } - let secondsLeftInQueue: number; - if (queue.churn_limit >= activationKeysSet.size) { - secondsLeftInQueue = 1; - } - const epochsLeft = activationKeysSet.size / queue.churn_limit; - secondsLeftInQueue = epochsLeft * SECONDS_PER_EPOCH; - - //converting snake case response to camelcase - return { - originalData: queue, - churnLimit: Array.from({ length: queue.churn_limit }), - activationPublicKeys: activationKeysSet, - exitPublicKeys: exitKeysSet, - secondsLeftInQueue, - userValidatingPublicKeys: userValidatingKeysSet, - }; - } -} diff --git a/src/app/modules/dashboard/components/validator-participation/validator-participation.component.html b/src/app/modules/dashboard/components/validator-participation/validator-participation.component.html deleted file mode 100644 index 01e3d3d5..00000000 --- a/src/app/modules/dashboard/components/validator-participation/validator-participation.component.html +++ /dev/null @@ -1,71 +0,0 @@ - -
- - help_outline - -
-

- --% -

-

- Loading Validator Participation... -

-
- - -
-
- -- / - -- -
-
- Total Voted ETH vs. Eligible ETH -
-
- Epoch -- -
-
-
-
- -
- - help_outline - -
-

- {{participation?.rate | number: '1.2-2'}}% -

-

- Global Validator Participation -

-
- - -
-
- {{participation?.totalVotedETH}} / - {{participation?.totalEligibleETH}} -
-
- Total Voted ETH vs. Eligible ETH -
-
- Epoch {{participation?.epoch}} -
-
-
-
\ No newline at end of file diff --git a/src/app/modules/dashboard/components/validator-participation/validator-participation.component.spec.ts b/src/app/modules/dashboard/components/validator-participation/validator-participation.component.spec.ts deleted file mode 100644 index 5f317ab7..00000000 --- a/src/app/modules/dashboard/components/validator-participation/validator-participation.component.spec.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; - -import { MockService } from 'ng-mocks'; -import { of } from 'rxjs'; - -import { ValidatorParticipationComponent } from './validator-participation.component'; -import { SharedModule } from 'src/app/modules/shared/shared.module'; -import { ChainService } from 'src/app/modules/core/services/chain.service'; -import { ValidatorParticipationResponse } from 'src/app/proto/eth/v1alpha1/beacon_chain'; -import { ValidatorParticipation } from 'src/app/proto/eth/v1alpha1/validator'; -import { MatTooltipModule } from '@angular/material/tooltip'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; - -describe('ValidatorParticipationComponent', () => { - let component: ValidatorParticipationComponent; - let fixture: ComponentFixture; - const service: ChainService = MockService(ChainService); - const defaultParticipationResponse = { - epoch: 32, - finalized: true, - participation: { - current_epoch_active_gwei: '1446418000000000' as any, - current_epoch_attesting_gwei: '102777000000000' as any, - current_epoch_target_attesting_gwei: '101552000000000' as any, - eligible_ether: '1446290000000000' as any, - global_participation_rate: 0.7861, - previous_epoch_active_gwei: '1446290000000000' as any, - previous_epoch_attesting_gwei: '1143101000000000' as any, - previous_epoch_head_attesting_gwei: '1089546000000000' as any, - previous_epoch_target_attesting_gwei: '1136975000000000' as any, - voted_ether: '1136975000000000' as any, - } as ValidatorParticipation, - } as ValidatorParticipationResponse; - (service as any)['participation$'] = of(defaultParticipationResponse); - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [ ValidatorParticipationComponent ], - imports: [ - SharedModule, - BrowserAnimationsModule, - MatTooltipModule, - ], - providers: [ - { provide: ChainService, useValue: service }, - ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ValidatorParticipationComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should display the participation rate', () => { - const elem: HTMLElement = fixture.nativeElement; - expect(elem.textContent).toContain('78'); - }); - - it('should display the epoch', () => { - const elem: HTMLElement = fixture.nativeElement; - expect(elem.textContent).toContain('32'); - }); - - it('should display the voted eth vs. eligible eth', () => { - const votedETH = (component as any).gweiToETH(defaultParticipationResponse?.participation?.voted_ether); - const eligibleETH = (component as any).gweiToETH(defaultParticipationResponse?.participation?.eligible_ether); - const elem: HTMLElement = fixture.nativeElement; - expect(elem.textContent).toContain(votedETH); - expect(elem.textContent).toContain(eligibleETH); - }); -}); diff --git a/src/app/modules/dashboard/components/validator-participation/validator-participation.component.ts b/src/app/modules/dashboard/components/validator-participation/validator-participation.component.ts deleted file mode 100644 index 1b525194..00000000 --- a/src/app/modules/dashboard/components/validator-participation/validator-participation.component.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { Component, OnDestroy, OnInit } from '@angular/core'; - -import { Observable, Subject } from 'rxjs'; -import { map, takeUntil, tap } from 'rxjs/operators'; -import { BigNumber } from 'ethers'; - -import { ChainService } from 'src/app/modules/core/services/chain.service'; -import { ValidatorParticipationResponse } from 'src/app/proto/eth/v1alpha1/beacon_chain'; -import { GWEI_PER_ETHER } from 'src/app/modules/core/constants'; - -interface ParticipationData { - rate: number; - epoch: number; - totalVotedETH: number; - totalEligibleETH: number; -} - -@Component({ - selector: 'app-validator-participation', - templateUrl: './validator-participation.component.html', - styles: [ - ] -}) -export class ValidatorParticipationComponent implements OnInit, OnDestroy { - constructor( - private chainService: ChainService, - ) { } - loading = false; - participation: ParticipationData | null = null; - noFinalityMessage = `If participation drops below 66%, the chain cannot finalize blocks and validator balances will begin to decrease for all inactive validators at a fast rate`; - private destroyed$ = new Subject(); - - ngOnInit(): void { - this.loading = true; - this.chainService.participation$.pipe( - map(this.transformParticipationData.bind(this)), - tap((data: ParticipationData) => { - this.participation = data; - this.loading = false; - }), - takeUntil(this.destroyed$), - ).subscribe(); - } - - ngOnDestroy(): void { - this.destroyed$.next(); - this.destroyed$.complete(); - } - - updateProgressColor(progress: number): string { - if (progress < 66.6) { - return 'warn'; - } else if (progress >= 66.6 && progress < 75) { - return 'accent'; - } else { - return 'primary'; - } - } - - // We transform necessary data for displaying in the component. - // IMPORTANT NOTE: votedEther and eligibleEther in the ValidatorParticipationResponse - // fields are incorrectly named. They are actually represented in gwei. - private transformParticipationData(res: ValidatorParticipationResponse): ParticipationData { - if (!res || !res.participation) { - return {} as ParticipationData; - } - return { - rate: (res.participation.global_participation_rate * 100), - epoch: res.epoch, - totalVotedETH: this.gweiToETH(res.participation.voted_ether).toNumber(), - totalEligibleETH: this.gweiToETH(res.participation.eligible_ether).toNumber(), - } as ParticipationData; - } - - private gweiToETH(num: string): BigNumber { - return BigNumber.from(num).div(GWEI_PER_ETHER); - } -} diff --git a/src/app/modules/dashboard/components/validator-performance-list/validator-performance-list.component.html b/src/app/modules/dashboard/components/validator-performance-list/validator-performance-list.component.html index 739f9ac9..61643fef 100644 --- a/src/app/modules/dashboard/components/validator-performance-list/validator-performance-list.component.html +++ b/src/app/modules/dashboard/components/validator-performance-list/validator-performance-list.component.html @@ -15,7 +15,7 @@ Public key - {{element.publicKey | base64tohex}} + {{element.publicKey }} diff --git a/src/app/modules/dashboard/components/validator-performance-list/validator-performance-list.component.ts b/src/app/modules/dashboard/components/validator-performance-list/validator-performance-list.component.ts index 13559459..90175632 100644 --- a/src/app/modules/dashboard/components/validator-performance-list/validator-performance-list.component.ts +++ b/src/app/modules/dashboard/components/validator-performance-list/validator-performance-list.component.ts @@ -5,13 +5,12 @@ import { MatTableDataSource } from '@angular/material/table'; import { BigNumber } from 'ethers'; import { ValidatorSummaryResponse } from 'src/app/proto/eth/v1alpha1/beacon_chain'; -import { EMPTY, forkJoin, Observable, throwError, zip } from 'rxjs'; +import { forkJoin, Observable, throwError, zip } from 'rxjs'; import { catchError, map, take, tap, takeUntil, filter, switchMap, flatMap, concatMap, mergeMap } from 'rxjs/operators'; import { ValidatorService } from '../../../core/services/validator.service'; import { BaseComponent } from '../../../shared/components/base.component'; import { UserService } from '../../../shared/services/user.service'; import { ListFeeRecipientResponse } from 'src/app/proto/validator/accounts/v2/web_api_keymanager-api'; -import { base64ToHex } from 'src/app/modules/core/utils/hex-util'; export interface ValidatorListItem { publicKey: string; @@ -91,7 +90,7 @@ export class ValidatorPerformanceListComponent return forkJoin(arrayOfRequests).pipe( map((res:ListFeeRecipientResponse[]) => { res.forEach((r)=>{ - let item = list.find((obj)=>base64ToHex(obj.publicKey) === r.data.pubkey) + let item = list.find((obj)=>obj.publicKey === r.data.pubkey) if(item){ item.feeRecipient = r.data.ethaddress } diff --git a/src/app/modules/dashboard/dashboard.module.ts b/src/app/modules/dashboard/dashboard.module.ts index b09d5a75..38a0ca69 100644 --- a/src/app/modules/dashboard/dashboard.module.ts +++ b/src/app/modules/dashboard/dashboard.module.ts @@ -9,9 +9,7 @@ import { ValidatorPerformanceListComponent } from './components/validator-perfor import { SidebarComponent } from './components/sidebar/sidebar.component'; import { SidebarExpandableLinkComponent } from './components/sidebar-expandable-link/sidebar-expandable-link.component'; import { BeaconNodeStatusComponent } from './components/beacon-node-status/beacon-node-status.component'; -import { ValidatorParticipationComponent } from './components/validator-participation/validator-participation.component'; import { ValidatorPerformanceSummaryComponent } from './components/validator-performance-summary/validator-performance-summary.component'; -import { ActivationQueueComponent } from './components/activation-queue/activation-queue.component'; import { VersionComponent } from './components/version/version.component'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { LatestGistFeatureComponent } from './components/latest-gist-feature/latest-gist-feature.component'; @@ -25,9 +23,7 @@ import { GitInfoComponent } from './components/latest-gist-feature/templates/git SidebarComponent, SidebarExpandableLinkComponent, BeaconNodeStatusComponent, - ValidatorParticipationComponent, ValidatorPerformanceSummaryComponent, - ActivationQueueComponent, VersionComponent, LatestGistFeatureComponent, GitInfoComponent, diff --git a/src/app/modules/dashboard/pages/gains-and-losses/gains-and-losses.component.html b/src/app/modules/dashboard/pages/gains-and-losses/gains-and-losses.component.html index f3eb9553..fe7ab095 100644 --- a/src/app/modules/dashboard/pages/gains-and-losses/gains-and-losses.component.html +++ b/src/app/modules/dashboard/pages/gains-and-losses/gains-and-losses.component.html @@ -28,8 +28,6 @@
- -
@@ -40,9 +38,6 @@ - -
-
diff --git a/src/app/modules/dashboard/pages/gains-and-losses/gains-and-losses.component.spec.ts b/src/app/modules/dashboard/pages/gains-and-losses/gains-and-losses.component.spec.ts index 8ffd49d7..02c4ff7c 100644 --- a/src/app/modules/dashboard/pages/gains-and-losses/gains-and-losses.component.spec.ts +++ b/src/app/modules/dashboard/pages/gains-and-losses/gains-and-losses.component.spec.ts @@ -9,10 +9,7 @@ import { ValidatorPerformanceListComponent } from '../../components/validator-pe import { SharedModule } from '../../../shared/shared.module'; import { BeaconNodeStatusComponent } from '../../components/beacon-node-status/beacon-node-status.component'; import { ValidatorPerformanceSummaryComponent } from '../../components/validator-performance-summary/validator-performance-summary.component'; -import { ValidatorParticipationComponent } from '../../components/validator-participation/validator-participation.component'; -import { ActivationQueueComponent } from '../../components/activation-queue/activation-queue.component'; import { ValidatorService } from 'src/app/modules/core/services/validator.service'; -import { ChainService } from 'src/app/modules/core/services/chain.service'; import { ENVIRONMENT } from 'src/environments/token'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; @@ -33,8 +30,6 @@ describe('GainsAndLossesComponent', () => { declarations: [ MockComponent(BeaconNodeStatusComponent), MockComponent(ValidatorPerformanceSummaryComponent), - MockComponent(ValidatorParticipationComponent), - MockComponent(ActivationQueueComponent), MockComponent(ValidatorPerformanceListComponent), GainsAndLossesComponent, ], @@ -43,10 +38,6 @@ describe('GainsAndLossesComponent', () => { provider: ValidatorService, useValue: jasmine.createSpyObj('ValidatorService', ['recentEpochBalances']), }, - { - provider: ChainService, - useValue: jasmine.createSpyObj('ChainService', ['chainHead$']), - }, { provide: ENVIRONMENT, useValue: jasmine.createSpyObj('EnvironmenterService', ['env']) }, ] }) diff --git a/src/app/modules/shared/pipes/base64-to-hex.pipe.spec.ts b/src/app/modules/shared/pipes/base64-to-hex.pipe.spec.ts deleted file mode 100644 index 84ff1cce..00000000 --- a/src/app/modules/shared/pipes/base64-to-hex.pipe.spec.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Base64ToHexPipe } from './base64-to-hex.pipe'; - -describe('Base64ToHexPipe', () => { - it('properly transforms a base64 string to its hex string representation', () => { - const pipe = new Base64ToHexPipe(); - const original = 'AIIuAOw9jsxQ4De3rj66VIZIDR7EmvrWmg12v9sVjq2bw4no3v7ywHbQgDcb8fD+/A=='; - expect(pipe.transform(original)).toEqual('0x00822e00ec3d8ecc50e037b7ae3eba5486480d1ec49afad69a0d76bfdb158ead9bc389e8defef2c076d080371bf1f0fefc'); - }); -}); diff --git a/src/app/modules/shared/pipes/base64-to-hex.pipe.ts b/src/app/modules/shared/pipes/base64-to-hex.pipe.ts deleted file mode 100644 index 95f1c2c7..00000000 --- a/src/app/modules/shared/pipes/base64-to-hex.pipe.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { base64ToHex } from '../../core/utils/hex-util'; - -@Pipe({ - name: 'base64tohex' -}) -export class Base64ToHexPipe implements PipeTransform { - transform(value: string, ...args: unknown[]): string { - return value ? base64ToHex(value) : ''; - } -} diff --git a/src/app/modules/shared/shared.module.ts b/src/app/modules/shared/shared.module.ts index c072dfb8..35eecc26 100644 --- a/src/app/modules/shared/shared.module.ts +++ b/src/app/modules/shared/shared.module.ts @@ -17,7 +17,6 @@ import { ImportAccountsFormComponent } from './components/import-accounts-form/i import { ImportDropzoneComponent } from './components/import-dropzone/import-dropzone.component'; import { ImportProtectionComponent } from './components/import-protection/import-protection.component'; -import { Base64ToHexPipe } from './pipes/base64-to-hex.pipe'; import { OrdinalPipe } from './pipes/ordinal.pipe'; import { PrettyjsonPipe } from './pipes/pretty-json.pipe'; import { EpochPipe } from './pipes/format-epoch.pipe'; @@ -49,7 +48,6 @@ const components = [ ]; const pipes = [ - Base64ToHexPipe, OrdinalPipe, PrettyjsonPipe, BalancePipe, diff --git a/src/app/modules/wallet/components/account-delete/account-delete.component.html b/src/app/modules/wallet/components/account-delete/account-delete.component.html index 02e60021..84340cec 100644 --- a/src/app/modules/wallet/components/account-delete/account-delete.component.html +++ b/src/app/modules/wallet/components/account-delete/account-delete.component.html @@ -34,7 +34,7 @@

- {{pubKey | base64tohex | slice:0:16}}... + {{pubKey | slice:0:16}}... ...{{publicKeys.length - 3}} more diff --git a/src/app/modules/wallet/components/account-delete/account-delete.component.ts b/src/app/modules/wallet/components/account-delete/account-delete.component.ts index 3a24684a..872d9d91 100644 --- a/src/app/modules/wallet/components/account-delete/account-delete.component.ts +++ b/src/app/modules/wallet/components/account-delete/account-delete.component.ts @@ -4,7 +4,6 @@ import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import * as FileSaver from 'file-saver'; import { ToastrService } from 'ngx-toastr'; import { tap } from 'rxjs/operators'; -import { base64ToHex } from 'src/app/modules/core/utils/hex-util'; import { DeleteAccountsRequest,DeleteAccountsData,DeleteAccountsResponse } from 'src/app/proto/validator/accounts/v2/web_api_keymanager-api'; import { WalletService } from '../../../core/services/wallet.service'; import { UtilityValidator } from '../../../onboarding/validators/utility.validator'; @@ -51,7 +50,7 @@ export class AccountDeleteComponent { } confirm(): void { - const hexKeys = this.data.map(key => base64ToHex(key)); + const hexKeys = this.data; const request = { pubkeys: this.deleteKeysType === this.SPECIFIC_KEYS? hexKeys : this.publicKeys, } as DeleteAccountsRequest; diff --git a/src/app/modules/wallet/components/account-selections/account-selections.component.html b/src/app/modules/wallet/components/account-selections/account-selections.component.html index 191480dc..c8fc910c 100644 --- a/src/app/modules/wallet/components/account-selections/account-selections.component.html +++ b/src/app/modules/wallet/components/account-selections/account-selections.component.html @@ -5,7 +5,7 @@
- {{account.publicKey | base64tohex | slice:0:16}}... + {{account.publicKey | slice:0:16}}...
diff --git a/src/app/modules/wallet/components/accounts-form-selection/accounts-form-selection.component.html b/src/app/modules/wallet/components/accounts-form-selection/accounts-form-selection.component.html index ef250f38..3a261f1e 100644 --- a/src/app/modules/wallet/components/accounts-form-selection/accounts-form-selection.component.html +++ b/src/app/modules/wallet/components/accounts-form-selection/accounts-form-selection.component.html @@ -20,7 +20,7 @@ - {{item.validating_public_key|base64tohex|slice:0:16}}... + {{item.validating_public_key|slice:0:16}}... \ No newline at end of file diff --git a/src/app/modules/wallet/components/accounts-form-selection/accounts-form-selection.component.ts b/src/app/modules/wallet/components/accounts-form-selection/accounts-form-selection.component.ts index da024bb7..efa96932 100644 --- a/src/app/modules/wallet/components/accounts-form-selection/accounts-form-selection.component.ts +++ b/src/app/modules/wallet/components/accounts-form-selection/accounts-form-selection.component.ts @@ -9,7 +9,6 @@ import { MatSelectionListChange, } from '@angular/material/list'; import { map } from 'rxjs/operators'; -import { base64ToHex } from 'src/app/modules/core/utils/hex-util'; @Component({ selector: 'app-accounts-form-selection [formGroup]', @@ -69,7 +68,7 @@ export class AccountsFormSelectionComponent implements OnInit { private searchbyPublicKey(publicKey: any, x: Account[]): Account[] { return publicKey - ? x.filter((c) => base64ToHex(c.validating_public_key) === publicKey) + ? x.filter((c) => c.validating_public_key === publicKey) : x; } } diff --git a/src/app/modules/wallet/components/accounts-table/accounts-table.component.html b/src/app/modules/wallet/components/accounts-table/accounts-table.component.html index 10de6243..a936335f 100644 --- a/src/app/modules/wallet/components/accounts-table/accounts-table.component.html +++ b/src/app/modules/wallet/components/accounts-table/accounts-table.component.html @@ -29,7 +29,7 @@ matTooltip="Copy to Clipboard" (click)="copyKeyToClipboard(row.publicKey)" class="cursor-pointer"> - {{row.publicKey | base64tohex | slice:0:8 }}... + {{row.publicKey | slice:0:8 }}... @@ -99,7 +99,7 @@ + [queryParams]="{publicKey:row.publicKey}"> exit_to_app
diff --git a/src/app/modules/wallet/components/fee-recipient/fee-recipient-edit.component.ts b/src/app/modules/wallet/components/fee-recipient/fee-recipient-edit.component.ts index c7573d4b..46d7791c 100644 --- a/src/app/modules/wallet/components/fee-recipient/fee-recipient-edit.component.ts +++ b/src/app/modules/wallet/components/fee-recipient/fee-recipient-edit.component.ts @@ -3,7 +3,6 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { ToastrService } from 'ngx-toastr'; import { ValidatorService } from 'src/app/modules/core/services/validator.service'; -import { base64ToHex } from 'src/app/modules/core/utils/hex-util'; import { UtilityValidator } from '../../../onboarding/validators/utility.validator'; @Component({ @@ -52,22 +51,22 @@ export class EditFeeRecipientComponent implements OnInit { let updateFeeRecipient$; switch(this.confirmGroup.controls['options'].value) { case 'DELETE': - updateFeeRecipient$ = this.validatorService.deleteFeeRecipient(base64ToHex(this.publicKey)); + updateFeeRecipient$ = this.validatorService.deleteFeeRecipient(this.publicKey); break; case 'SET': - updateFeeRecipient$ = this.validatorService.setFeeRecipient(base64ToHex(this.publicKey),{ethaddress:this.confirmGroup.controls['feerecipient'].value}); + updateFeeRecipient$ = this.validatorService.setFeeRecipient(this.publicKey,{ethaddress:this.confirmGroup.controls['feerecipient'].value}); break; } if(updateFeeRecipient$) { updateFeeRecipient$.subscribe(()=>{ this.toastr.success( - `${base64ToHex(this.publicKey).substring(0, 10)}... updated fee recipient`, + `${this.publicKey.substring(0, 10)}... updated fee recipient`, ); this.validatorService.refreshTableDataTrigger$.next(true); this.ref.close(); }, (error) => { this.toastr.error( - `${base64ToHex(this.publicKey).substring(0, 10)}... failed to update fee recipient`,error,{ + `${this.publicKey.substring(0, 10)}... failed to update fee recipient`,error,{ timeOut: 20000, }); this.ref.close(); diff --git a/src/app/modules/wallet/pages/account-voluntary-exit/account-voluntary-exit.component.ts b/src/app/modules/wallet/pages/account-voluntary-exit/account-voluntary-exit.component.ts index 7ed3f912..9af80d9e 100644 --- a/src/app/modules/wallet/pages/account-voluntary-exit/account-voluntary-exit.component.ts +++ b/src/app/modules/wallet/pages/account-voluntary-exit/account-voluntary-exit.component.ts @@ -3,7 +3,6 @@ import { AbstractControlOptions, FormBuilder, FormControl, Validators } from '@angular/forms'; import { ActivatedRoute } from '@angular/router'; -import { base64ToHex } from 'src/app/modules/core/utils/hex-util'; import { AccountVoluntaryExitRequest } from '../../../../proto/validator/accounts/v2/web_api'; @@ -53,8 +52,7 @@ export class AccountVoluntaryExitComponent } const request = { public_keys: Object.keys(this.exitAccountFormGroup.value) - .filter((x) => x !== 'confirmation') - .map((x) => base64ToHex(x)), + .filter((x) => x !== 'confirmation'), } as AccountVoluntaryExitRequest; this.walletService.exitAccounts(request).subscribe((x) => { diff --git a/src/app/modules/wallet/pages/accounts/accounts.component.ts b/src/app/modules/wallet/pages/accounts/accounts.component.ts index 5e5047d7..e2feb807 100644 --- a/src/app/modules/wallet/pages/accounts/accounts.component.ts +++ b/src/app/modules/wallet/pages/accounts/accounts.component.ts @@ -14,7 +14,6 @@ import { } from 'rxjs/operators'; import { zipMap } from 'rxjs-pipe-ext/lib'; -import { base64ToHex } from 'src/app/modules/core/utils/hex-util'; import { ValidatorService } from 'src/app/modules/core/services/validator.service'; import { WalletService } from '../../../core/services/wallet.service'; import { @@ -158,7 +157,7 @@ export class AccountsComponent extends BaseComponent implements OnInit { (v) => acc.validating_public_key === v?.validator?.public_key ); - let feeRecipient = feeRecipients.find(data=> data.pubkey === base64ToHex(acc.validating_public_key)); + let feeRecipient = feeRecipients.find(data=> data.pubkey === acc.validating_public_key); if (!val) { val = { index: 0, @@ -207,7 +206,7 @@ export class AccountsComponent extends BaseComponent implements OnInit { private filterPredicate(el: TableData, f: string): boolean { const inAccountName = el.accountName.indexOf(f) !== -1; - const inPublicKey = base64ToHex(el.publicKey).indexOf(f) !== -1; + const inPublicKey = el.publicKey.indexOf(f) !== -1; const inValidatorIndex = el.index.toString() === f; return inAccountName || inPublicKey || inValidatorIndex; } diff --git a/src/app/proto/eth/v1alpha1/beacon_chain.ts b/src/app/proto/eth/v1alpha1/beacon_chain.ts index 6feb1bb2..efdd616b 100644 --- a/src/app/proto/eth/v1alpha1/beacon_chain.ts +++ b/src/app/proto/eth/v1alpha1/beacon_chain.ts @@ -14,8 +14,7 @@ // limitations under the License. // import { Attestation } from './attestation'; -import { IndexedAttestation, SignedBeaconBlock } from './beacon_block'; -import { Validator, ValidatorParticipation } from './validator'; +import { Validator} from './validator'; /** * Information about the head of the beacon chain. @@ -371,34 +370,6 @@ export interface ValidatorSummaryResponse { inactivity_scores?: string[]; } -export interface ValidatorQueue { - /** - * The amount of ether in gwei allowed to enter or exit the active - * validator set. - */ - churn_limit: number; - /** - * Ordered list of 48 byte public keys awaiting activation. 0th index is the - * next key to be processed. - */ - activation_public_keys: string[]; - /** - * Ordered list of public keys awaiting exit. 0th index is the next key to - * be processed. - */ - exit_public_keys: string[]; - /** - * Ordered list of validator indices awaiting activation. 0th item in the list is the - * next validator index to be processed. - */ - activation_validator_indices: number[]; - /** - * Ordered list of validator indices awaiting exit. 0th item in the list is the - * next validator index to be processed. - */ - exit_validator_indices: number[]; -} - export interface ListValidatorAssignmentsRequest { /** * Epoch to validator assignments for. @@ -479,32 +450,6 @@ export interface ValidatorAssignments_CommitteeAssignment { validatorIndex: number; } -export interface GetValidatorParticipationRequest { - /** - * Epoch to request participation information. - */ - epoch: number | undefined; - /** - * Whether or not to query for the genesis information. - */ - genesis: boolean | undefined; -} - -export interface ValidatorParticipationResponse { - /** - * Epoch which this message is applicable. - */ - epoch: number; - /** - * Whether or not epoch has been finalized. - */ - finalized: boolean; - /** - * The actual validator participation metrics. - */ - participation: ValidatorParticipation | undefined; -} - export interface AttestationPoolRequest { /** * The maximum number of objects to return in the response. diff --git a/src/app/proto/eth/v1alpha1/validator.ts b/src/app/proto/eth/v1alpha1/validator.ts index 7f52c22b..98084734 100644 --- a/src/app/proto/eth/v1alpha1/validator.ts +++ b/src/app/proto/eth/v1alpha1/validator.ts @@ -34,35 +34,6 @@ export interface DomainResponse { signatureDomain: string; } -export interface ValidatorActivationRequest { - /** - * A list of 48 byte validator public keys. - */ - publicKeys: string[]; -} - -export interface ValidatorActivationResponse { - /** - * A list of validator statuses mapped 1-to-1 with the public keys - * in the request. - */ - statuses: ValidatorActivationResponse_Status[]; -} - -export interface ValidatorActivationResponse_Status { - /** - * A 48 byte validator public key. - */ - publicKey: string; - /** - * A wrapper representing a validator's status object. - */ - status: ValidatorStatusResponse | undefined; - /** - * The validators index in the beacon state. - */ - index: number; -} export interface ChainStartResponse { /** @@ -144,21 +115,6 @@ export interface MultipleValidatorStatusRequest { indices: number[]; } -export interface MultipleValidatorStatusResponse { - /** - * A list of 48 byte validator public keys. - */ - publicKeys: string[]; - /** - * A list of ValidatorStatusResponses mapped 1-to-1 with the public keys. - */ - statuses: ValidatorStatusResponse[]; - /** - * A list of validator indices. - */ - indices: number[]; -} - export interface DutiesRequest { /** * Epoch at which validators should perform their duties. @@ -361,54 +317,6 @@ export interface Validator { withdrawable_epoch: string; } -/** - * ValidatorParticipation stores participation metrics during a given epoch. - */ -export interface ValidatorParticipation { - /** - * Percentage of validator participation in the given epoch. This field - * contains a value between 0 and 1. - */ - global_participation_rate: number; - /** - * The total amount of ether, in gwei, that has been used in voting. - */ - voted_ether: string; - /** - * The total amount of ether, in gwei, that is eligible for voting. - */ - eligible_ether: string; - /** - * Total staked gwei that was active (i.e. eligible to vote) during the current epoch. - */ - current_epoch_active_gwei: string; - /** - * Total staked gwei that had attestations included in a block during the current epoch, - * attestations by the same validator do not increase this figure. - */ - current_epoch_attesting_gwei: string; - /** - * Total staked gwei that attested to the majority-elected Casper FFG target epoch during the current epoch. - */ - current_epoch_target_attesting_gwei: string; - /** - * Same as current_epoch_active_gwei but for previous epoch. - */ - previous_epoch_active_gwei: string; - /** - * Same as current_epoch_attesting_gwei but for previous epoch. - */ - previous_epoch_attesting_gwei: string; - /** - * Same as current_epoch_target_attesting_gwei but for previous epoch. - */ - previous_epoch_target_attesting_gwei: string; - /** - * Total staked gwei that attested to a head beacon block that is in the canonical chain. - */ - previous_epoch_head_attesting_gwei: string; -} - // TODO: see if this is still needed /** From be10e83651057fe21af233251a4cda78dd4d6997 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Thu, 16 Nov 2023 16:16:30 -0600 Subject: [PATCH 2/3] removing bad test --- .../interceptors/mock.interceptor.spec.ts | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/app/modules/core/interceptors/mock.interceptor.spec.ts b/src/app/modules/core/interceptors/mock.interceptor.spec.ts index 9e3e2839..cd6addb5 100644 --- a/src/app/modules/core/interceptors/mock.interceptor.spec.ts +++ b/src/app/modules/core/interceptors/mock.interceptor.spec.ts @@ -1,11 +1,10 @@ -import { TestBed, inject } from '@angular/core/testing'; -import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -import { HTTP_INTERCEPTORS, HttpClient } from '@angular/common/http'; +import { TestBed } from '@angular/core/testing'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { HTTP_INTERCEPTORS } from '@angular/common/http'; import { RouterTestingModule } from '@angular/router/testing'; -import { MockInterceptor, VALIDATOR_API_PREFIX } from './mock.interceptor'; +import { MockInterceptor} from './mock.interceptor'; import { EnvironmenterService } from '../services/environmenter.service'; -import { Mocks } from '../mocks'; class MockEnv { env = { production: false }; @@ -30,16 +29,4 @@ describe('MockInterceptor', () => { ] }); }); - - describe('intercept HTTP requests', () => { - 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'; - http.get(endpoint).subscribe((res) => { - expect(res).toEqual(Mocks[endpoint]); - }); - mock.verify(); - }) - ); - }); }); From bfe2fa712e0eef91c30177011aaca5c1ac989af3 Mon Sep 17 00:00:00 2001 From: james-prysm Date: Fri, 17 Nov 2023 14:11:52 -0600 Subject: [PATCH 3/3] optimizing ndjson file --- src/app/modules/core/utils/ndjson.ts | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/app/modules/core/utils/ndjson.ts b/src/app/modules/core/utils/ndjson.ts index 465568ed..e05748f7 100644 --- a/src/app/modules/core/utils/ndjson.ts +++ b/src/app/modules/core/utils/ndjson.ts @@ -19,7 +19,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -import { from, Observable, Observer, Subject } from 'rxjs'; +import { from, Observable, Observer} from 'rxjs'; import { concatMap, filter, map, scan } from 'rxjs/operators'; /* @@ -37,15 +37,13 @@ export function stream(url: string): Observable { const textStream = extractStream(xhr); const jsonStream = collate(textStream).pipe( concatMap((lineArray: string) => from(lineArray)), - map((x: string, _) => JSON.parse(x)), + map((x: string) => JSON.parse(x)), ); - if (options.beforeOpen) { - options.beforeOpen(xhr); - } + options.beforeOpen?.(xhr); - xhr.open(options.method ? options.method : 'GET', url); - xhr.send(options.postData ? options.postData : null); + xhr.open(options.method ?? 'GET', url); + xhr.send(options.postData ?? null); return jsonStream; } @@ -85,16 +83,18 @@ function collate(chunkStream: Observable): Observable { * flag "endWithNewline: true" which adds a trailing newline if one did not * exist in the source. */ -function extractStream(xhr: XMLHttpRequest): Observable { - const options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; +interface ExtractStreamOptions { + endWithNewline?: boolean; +} +function extractStream(xhr: XMLHttpRequest, options: ExtractStreamOptions = {}): Observable { return new Observable((observer: Observer) => { let charactersSeen = 0; const notified = () => { - if (xhr.readyState >= 3 && xhr.responseText.length > charactersSeen) { + if (xhr.readyState >= XMLHttpRequest.LOADING && xhr.responseText.length > charactersSeen) { observer.next(xhr.responseText.substring(charactersSeen)); charactersSeen = xhr.responseText.length; } - if (xhr.readyState === 4) { + if (xhr.readyState === XMLHttpRequest.DONE) { if (options.endWithNewline && xhr.responseText[xhr.responseText.length - 1] !== '\n') { observer.next('\n'); } @@ -103,8 +103,6 @@ function extractStream(xhr: XMLHttpRequest): Observable { }; xhr.onreadystatechange = notified; xhr.onprogress = notified; - xhr.onerror = event => { - observer.error(event); - }; + xhr.onerror = (event: ProgressEvent) => observer.error(event); }); }