Skip to content

Commit

Permalink
Merge pull request #58 from algorandfoundation/fix/error-display-on-g…
Browse files Browse the repository at this point in the history
…enerate

fix: participation key error handling
  • Loading branch information
tasosbit authored Jan 7, 2025
2 parents 485b6ec + 19bb7e2 commit ec8d8bc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
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

0 comments on commit ec8d8bc

Please sign in to comment.