Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define Angular Services for Voluntary Exit #164

Merged
merged 6 commits into from
Mar 12, 2021

Conversation

olehyev138
Copy link
Contributor

Created Account voluntary exit page.

On the Accounts action added a new button for navigating to the account voluntary exit page.

On the Account table, there is another action button to navigating to the account voluntary exit page for exiting the selected key.

The Account voluntary exit would require to select the keys for exit and a conformation for exit

@@ -94,4 +94,8 @@ export class WalletService {
recover(request: RecoverWalletRequest): Observable<any> {
return this.http.post(`${this.apiUrl}/wallet/recover`, request);
}

exitAccounts(request: AccountVoluntaryExitRequest): Observable<any> {
return this.http.post(`${this.apiUrl}/wallet/exit-accoints`, request);
Copy link
Contributor

@rkapka rkapka Mar 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: accoints -> accounts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @olehyev138 I think this endpoint will be ${this.apiUrl}/accounts/exit when I implement it in the backend

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update the code

};
}

static MustHaveMoreThanOneControle(grp: FormGroup): ValidationErrors | null {
Copy link
Contributor

@rkapka rkapka Mar 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: Controle -> Control

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I will update this also


<span
*ngIf="exitAccountFormGroup?.get('confirmation')?.hasError('incorectValue')">
You must type agree
Copy link
Contributor

@rkapka rkapka Mar 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also have 'agree' here for better readability.

Confirmation is required. You must type 'agree'

On https://deploy-preview-164--prysm-web-ui.netlify.app/dashboard/wallet/accounts/voluntary-exit the text below the input does not fit on one line, which does not look too good. I assume this is because the control's width is too small.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix this

/**
* Confirmation if the exit should proceed or not
*/
confrimation: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think confrimation is needed at all. Once we submit the request, it will always be true (it doesn't make sense to submit a request when it's false).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove it from the code i thought maybe you would double-check on the back end.

Comment on lines 7 to 10
Are you sure you want exit these account?

Once these accounts are exited, the action cannot be
reverted.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a more suitable wording would be

Please make sure you understand the consequences of performing a voluntary exit. Once an account is exited, the action cannot be reverted

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add in another sentence: "You will not be able to withdraw your ETH if exited until ETH1 is merged with ETH2, which could happen in over a year"

exitAccountFormGroup: FormGroup | undefined | null;
keys: Account[] = [];
ngOnInit(): void {
const publicKey = this.activatedRoute.snapshot.queryParams.publicKey;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a publicKey query parameter when exiting accounts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the idea here that we will use a single public key in the route query parameters to perform the API request? If a user is trying to exit 100 keys at once that might be too big for the route. Is there another way we can pass in a list of public keys we want to exit into this component without using browser query params?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always be one public key since this navigation is through the grid.
I don't think there is a way to pass the keys to this page any other way since we are navigating to that page.
But we could store them in the service and get them from there

Comment on lines +55 to +63
this.walletService
.accounts()
.pipe(map((x) => this.searchbyPublicKey(publicKey, x.accounts)))
.subscribe((accs) => {
accs.forEach((acc) => {
this.keys.push(acc);
});
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should display all keys here, not search by a specific public key.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also related to the previous comment if you want i can remove that feature

}
const request = {
publicKeys: this.keys.map((x) => x.validatingPublicKey),
confrimation: this.exitAccountFormGroup?.get('confirmatio')?.value,
Copy link
Contributor

@rkapka rkapka Mar 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: confirmatio -> confirmation

const removedKeys =
Object.keys(this.exitAccountFormGroup?.controls ?? {}).length - 1;
this.snackMsgService.open(
`Successfully exited from ${removedKeys} keys`,
Copy link
Contributor

@rkapka rkapka Mar 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be

Successfully exited ${removedKeys} key(s)

} as AccountVoluntaryExitRequest;

this.walletService.exitAccounts(request).subscribe((x) => {
const removedKeys =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change the name of the variable to exitedKeys to use the same naming everywhere? Removing/deleteing keys is a different action.

@rkapka rkapka mentioned this pull request Mar 10, 2021
@@ -94,4 +94,8 @@ export class WalletService {
recover(request: RecoverWalletRequest): Observable<any> {
return this.http.post(`${this.apiUrl}/wallet/recover`, request);
}

exitAccounts(request: AccountVoluntaryExitRequest): Observable<any> {
return this.http.post(`${this.apiUrl}/wallet/exit-accoints`, request);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @olehyev138 I think this endpoint will be ${this.apiUrl}/accounts/exit when I implement it in the backend

ngOnDestroy(): void {
this.destroyed$.next();
this.destroyed$.complete();
}

back(): void {
history.back();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, where is history defined? is it a browser global?

Comment on lines 7 to 10
Are you sure you want exit these account?

Once these accounts are exited, the action cannot be
reverted.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add in another sentence: "You will not be able to withdraw your ETH if exited until ETH1 is merged with ETH2, which could happen in over a year"

exitAccountFormGroup: FormGroup | undefined | null;
keys: Account[] = [];
ngOnInit(): void {
const publicKey = this.activatedRoute.snapshot.queryParams.publicKey;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the idea here that we will use a single public key in the route query parameters to perform the API request? If a user is trying to exit 100 keys at once that might be too big for the route. Is there another way we can pass in a list of public keys we want to exit into this component without using browser query params?

} as AbstractControlOptions
);

this.walletService
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible we want to exit N public keys where N is anything from 1 to the total number of keys in the wallet, inclusive. Maybe we can input a list of public keys into this component and then you wont need to query the wallet service

/**
* Confirmation if the exit should proceed or not
*/
confrimation: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here: confirmation

@@ -116,6 +116,7 @@ export const generateBalancesForEpoch = (url: string) => {

export const Mocks: IMocks = {
'/v2/validator/wallet/recover': {},
'/v2/validator/wallet/account/exit': {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'/v2/validator/wallet/account/exit': {},
'/v2/validator/wallet/accounts/exit': {},

* The key from the accounts that will be removed
*/
publicKeys: string[];

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@rauljordan
Copy link
Contributor

Screen Shot 2021-03-10 at 1 38 46 PM

We should probably make import keystores primary color and exit keystores the secondary color above and should have a little bit more spacing between each other.

For some reason, I also can't click on the import keystores button for some reason, it no longer works and does not take me to the import accounts form.

Screen Shot 2021-03-10 at 1 39 22 PM

The form above has a rough UI. There is no title, the padding is weird and perhaps too little, and there is no alignment of elements correctly (proper left justification). It is also not clear that the account is selectable until you however over it. We should be displaying the first 12 or so characters of each public key instead of the name. For example 0x29392323... instead of its name like "merely simple gator". What will this form look like if a user has 100 or more keys, for example? The UI should account for this. For reference of a properly aligned UI, with a title and subtitle text, I would recommend checking the import accounts form in the screenshot below:

Screen Shot 2021-03-10 at 1 40 51 PM

@rauljordan
Copy link
Contributor

We should also have a way to "select all" accounts to exit

@rauljordan
Copy link
Contributor

Screen Shot 2021-03-10 at 4 15 21 PM

This spacing, padding, and layout is still weird. Can we just match the style from the import accounts form? The same paddings, the same style of title (import accounts is not bold)? Check out the screenshot of the import keystores form I added in my previous comment, the paddings are not the same here

Also, what if a user has 100 or 1000 keys, will the form become extremely long or is there anything we can do with making the list selection scrollable?

@olehyev138
Copy link
Contributor Author

Also, what if a user has 100 or 1000 keys, will the form become extremely long or is there anything we can do with making the list selection scrollable?

The list is encapsulated by a virtual scroller i thought that you would have noticed that.
So there won't be issues with a long list

Copy link
Contributor

@rauljordan rauljordan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for doing this! Needs approve from @rkapka for us to be able to merge

Copy link
Contributor

@rkapka rkapka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two more comments.

Comment on lines 121 to 129
this.snackMsgService.open(
`Successfully exited ${exitedKeys} key(s)`,
'Success',
{
direction: 'rtl',
politeness: 'assertive',
duration: 4000,
}
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this snackbar and the below snackbar consistent with each other, as they both indicate a successful operation? Maybe define some utility service to make the code DRY?

this.snackBar.open('Successfully imported keystores', 'Close', {
duration: 4000,
});


<span
*ngIf="exitAccountFormGroup?.get('confirmation')?.hasError('incorectValue')">
You must type agree
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You must type agree
You must type 'agree'

@rkapka rkapka merged commit 5448989 into prysmaticlabs:master Mar 12, 2021
@olehyev138 olehyev138 deleted the feature/voluntary-exit branch March 15, 2021 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants