-
Notifications
You must be signed in to change notification settings - Fork 26
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
Define Angular Services for Voluntary Exit #164
Conversation
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: accoints
-> accounts
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: Controle
-> Control
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
).
There was a problem hiding this comment.
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.
Are you sure you want exit these account? | ||
|
||
Once these accounts are exited, the action cannot be | ||
reverted. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
this.walletService | ||
.accounts() | ||
.pipe(map((x) => this.searchbyPublicKey(publicKey, x.accounts))) | ||
.subscribe((accs) => { | ||
accs.forEach((acc) => { | ||
this.keys.push(acc); | ||
}); | ||
}); | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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`, |
There was a problem hiding this comment.
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 = |
There was a problem hiding this comment.
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.
@@ -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); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
Are you sure you want exit these account? | ||
|
||
Once these accounts are exited, the action cannot be | ||
reverted. |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here: confirmation
src/app/modules/core/mocks/index.ts
Outdated
@@ -116,6 +116,7 @@ export const generateBalancesForEpoch = (url: string) => { | |||
|
|||
export const Mocks: IMocks = { | |||
'/v2/validator/wallet/recover': {}, | |||
'/v2/validator/wallet/account/exit': {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'/v2/validator/wallet/account/exit': {}, | |
'/v2/validator/wallet/accounts/exit': {}, |
* The key from the accounts that will be removed | ||
*/ | ||
publicKeys: string[]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 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: |
We should also have a way to "select all" accounts to exit |
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? |
The list is encapsulated by a virtual scroller i thought that you would have noticed that. |
There was a problem hiding this 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
There was a problem hiding this 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.
this.snackMsgService.open( | ||
`Successfully exited ${exitedKeys} key(s)`, | ||
'Success', | ||
{ | ||
direction: 'rtl', | ||
politeness: 'assertive', | ||
duration: 4000, | ||
} | ||
); |
There was a problem hiding this comment.
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?
prysm-web-ui/src/app/modules/wallet/pages/import/import.component.ts
Lines 49 to 51 in 1d44a70
this.snackBar.open('Successfully imported keystores', 'Close', { | |
duration: 4000, | |
}); |
|
||
<span | ||
*ngIf="exitAccountFormGroup?.get('confirmation')?.hasError('incorectValue')"> | ||
You must type agree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You must type agree | |
You must type 'agree' |
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