Skip to content

Commit

Permalink
fix: cleanup and remove network params
Browse files Browse the repository at this point in the history
  • Loading branch information
HashMapsData2Value committed Oct 24, 2024
1 parent 4710fa4 commit 400a4e9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 42 deletions.
12 changes: 2 additions & 10 deletions ui/pages/transaction/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ func (m *ViewModel) UpdateTxnURLAndQRCode() error {
Type: types.KeyRegistrationTx,
Header: types.Header{
Sender: senderAddress,
Fee: 0, //TODO: get proper fee
//FirstValid: types.Round(*m.Data.EffectiveFirstValid),
//LastValid: types.Round(*m.Data.EffectiveLastValid),
GenesisHash: types.Digest(m.NetworkParams.GenesisHash),
GenesisID: m.NetworkParams.Network,
Fee: 1000, //TODO: get proper fee
},
KeyregTxnFields: types.KeyregTxnFields{
VotePK: types.VotePK(m.Data.Key.VoteParticipationKey),
Expand All @@ -75,11 +71,7 @@ func (m *ViewModel) UpdateTxnURLAndQRCode() error {
Type: types.KeyRegistrationTx,
Header: types.Header{
Sender: senderAddress,
Fee: 0, //TODO: get proper fee
//FirstValid: types.Round(*m.Data.EffectiveFirstValid), //TODO: Determine if this is needed
//LastValid: types.Round(*m.Data.EffectiveLastValid),
GenesisHash: types.Digest(m.NetworkParams.GenesisHash),
GenesisID: m.NetworkParams.Network,
Fee: 1000, //TODO: get proper fee
},
}
}
Expand Down
34 changes: 3 additions & 31 deletions ui/pages/transaction/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@ package transaction

import (
"github.com/algorandfoundation/hack-tui/api"
"github.com/algorandfoundation/hack-tui/internal"
"github.com/algorandfoundation/hack-tui/ui/controls"
"github.com/charmbracelet/lipgloss"
)

var green = lipgloss.NewStyle().Foreground(lipgloss.Color("10"))

type NetworkParameters struct {
Network string
GenesisHash []byte
}

type ViewModel struct {
// Width is the last known horizontal lines
Width int
Expand All @@ -26,9 +20,6 @@ type ViewModel struct {
// Participation Key
Data api.ParticipationKey

// Genesis ID and Genesis Hash
NetworkParams NetworkParameters

// client is the API client
Client *api.ClientWithResponses

Expand All @@ -41,28 +32,9 @@ type ViewModel struct {
}

// New creates and instance of the ViewModel with a default controls.Model
func New(state *internal.StateModel, client *api.ClientWithResponses) ViewModel {

// // Open the file
// file, err := os.Open("utx.bytes")
// if err != nil {
// fmt.Printf("Error opening file: %v\n", err)
// panic(err)
// }
// defer file.Close()

// encodedTxn, err := io.ReadAll(file)
// kr, err := encoder.MakeQRKeyRegRequest(encodedTxn)
// qrCode, err := kr.ProduceQRCode()

func New(client *api.ClientWithResponses) ViewModel {
return ViewModel{
Client: client,
NetworkParams: NetworkParameters{
Network: state.Status.Network,
GenesisHash: state.Status.GenesisHash,
},
// urlTxn: kr.String(),
// asciiQR: qrCode,
controls: controls.New(" (a)ccounts | (k)eys | " + green.Render("(t)xn ")),
Client: client,
controls: controls.New(" (a)ccounts | (k)eys | (t)xn "),
}
}
2 changes: 1 addition & 1 deletion ui/viewport.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func MakeViewportViewModel(state *internal.StateModel, client *api.ClientWithRes
accountsPage: accounts.New(state),
keysPage: keys.New("", state.ParticipationKeys),
generatePage: generate.New("", client),
transactionPage: transaction.New(state, client),
transactionPage: transaction.New(client),

// Current Page
page: AccountsPage,
Expand Down

0 comments on commit 400a4e9

Please sign in to comment.