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

fix: participation key error handling #58

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/algod/participation/participation.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ func GenerateKeys(
return nil, err
}
if key.StatusCode() != 200 {
if key.JSON400 != nil {
return nil, errors.New(key.JSON400.Message)
}

status := key.Status()
if status != "" {
return nil, errors.New(status)
Expand Down
2 changes: 1 addition & 1 deletion ui/app/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func GenerateCmd(account string, rangeType participation.RangeType, duration int
Key: nil,
Address: "",
Active: false,
Err: &err,
Err: err,
Type: ExceptionModal,
}
}
Expand Down
4 changes: 2 additions & 2 deletions ui/app/modal.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ type ModalEvent struct {
// Address represents the address associated with the modal event. It is used to identify the relevant account or key.
Address string

// Err is a pointer to an error that represents an exceptional condition or failure state for the modal event.
Err *error
// Err is an error that represents an exceptional condition or failure state for the modal event.
Err error

// Type represents the specific category or variant of the modal event.
Type ModalType
Expand Down
7 changes: 7 additions & 0 deletions ui/modal/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ func (m ViewModel) HandleMessage(msg tea.Msg) (*ViewModel, tea.Cmd) {
}

case app.ModalEvent:
if msg.Type == app.ExceptionModal {
m.Open = true
m.exceptionModal.Message = msg.Err.Error()
m.generateModal.SetStep(generate.AddressStep)
m.SetType(app.ExceptionModal)
}

if msg.Type == app.InfoModal {
m.generateModal.SetStep(generate.AddressStep)
}
Expand Down
Loading