Skip to content

Commit

Permalink
feat(ui): display network and hide qrcode
Browse files Browse the repository at this point in the history
  • Loading branch information
PhearZero committed Nov 21, 2024
1 parent a9851e2 commit a2f484c
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 46 deletions.
1 change: 1 addition & 0 deletions ui/modal/modal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func Test_Snapshot(t *testing.T) {

t.Run("TransactionModal", func(t *testing.T) {
model := New(lipgloss.NewStyle().Width(80).Height(80).Render(""), true, test.GetState(nil))
model.State.Status.Network = "testnet-v1.0"
model.SetKey(&mock.Keys[0])
model.SetActive(true)
model.SetType(app.TransactionModal)
Expand Down
46 changes: 23 additions & 23 deletions ui/modal/testdata/Test_Snapshot/TransactionModal.golden
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,29 @@



╭──Offline Transaction──────────────╮
│ Scan the QR code with your wallet │
│ █████████████████████████████████ │
██ ▄▄▄▄▄ █▀▀ ▄█▀▄██▀█ ▄█ ▄▄▄▄▄ ██ │
██ █ █ ██▄█ █▀█▄██▄▀ █ █ █ ██ │
██ █▄▄▄█ █▄ ▄▀▄▄▀▀ ▄█ █▄▄▄█ ██
██▄▄▄▄▄▄▄█▄▀▄▀ █▄█ ▀▄▀▄█▄▄▄▄▄▄▄██ │
██ ▀ █ ▀▄██▀█ ▀▀██ ▀██▀██▄█▀ ▀██ │
██▄ ▀▄██▄ ▀▄ ▄▀▀ ▀▀▀█▀█▀ ▄▄█▄ ██
██ ▄▀▄ █▄ ██▀▄█ █ ▄▀██ ▄█▄ █ ██ │
██▀▄▀▀█▀▄▀▀▀ ██▄██▄▀ ▀▀█ ▄▀██ ▄██ │
███▀██▀▄▄ ▄▀▀▀▄▀██▀ ▀▄██ ▀█▀█ ▀██
██▄▀ ▀▄▄▄ ▄ █▀▀ ▀█▀▄▀▀▄▀▄▀▄▄▄▄██ │
██▄█▄▄██▄█▀█▀███ ▄▀ █▀ ▄▄▄ █▀▀ ██
██ ▄▄▄▄▄ ██▄█▄█▄█▀▀▀▀▄ █▄█ ██▄ ██
██ █ █ █▄▄▄█▄▀██ ▄ █▄▄▄ ██▀ ██
██ █▄▄▄█ █▄ ▄█▀ ██▀▀ ██▀ ▀▄▀▄██
██▄▄▄▄▄▄▄█▄█▄███▄▄▄▄█▄▄████▄█▄▄██
click here to open in Lora
╰────────────────────────( esc )────╯
╭──Offline Transaction───────────────────────────╮
Scan the QR code with your wallet │
│ ( make sure you use the testnet-v1.0 network ) │
█████████████████████████████████
██ ▄▄▄▄▄ █▀▀ ▄█▀▄██▀█ ▄█ ▄▄▄▄▄ ██
██ █ █ ██▄█ █▀█▄██▄▀█ █ ██
██▄▄▄█ █▄ ▄▀▄▄▀▀ █ ▄█ █▄▄▄█ ██
██▄▄▄▄▄▄▄█▄▀▄▀ █▄█ ▀▄▀▄█▄▄▄▄▄▄▄██
██ ▀ █ ▀▄██▀█ ▀▀██ ▀██▀██▄█▀ ▀██
██▄ ▀▄██▄ ▀▄ ▄▀▀ ▀▀▀█▀█▀ ▄▄█▄ █
██ ▄▀▄ █▄ ██▀▄█ █ ▄▀██ ▄█▄ █ ██
██▀▄▀▀█▀▄▀▀▀ ██▄██▄▀ ▀▀█ ▄▀██ ▄██
███▀██▀▄▄ ▄▀▀▀▄▀██▀ ▀▄██ ▀█▀█ ▀██
██▄▀ ▀▄▄▄ ▄ █▀▀ ▀█▀▄▀▀▄▀▄▀▄▄▄▄██
██▄█▄▄██▄█▀█▀███ ▄▀ █▀ ▄▄▄ █▀▀ ██
██ ▄▄▄▄▄ ██▄█▄█▄█▀▀▀▀▄ █▄█ ██▄ ██
██ █ █ █▄▄▄█▄▀██ ▄ █▄▄▄ ██▀ ██
██▄▄▄█ █▄ ▄█▀ ██▀▀ ██▀ ▀▄▀▄██
██▄▄▄▄▄▄▄█▄█▄███▄▄▄▄█▄▄████▄█▄▄██
click here to open in Lora │
╰─────────────────────────────────────( esc )────╯



Expand Down
40 changes: 21 additions & 19 deletions ui/modals/transaction/testdata/Test_Snapshot/Offline.golden
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
Scan the QR code with your wallet
█████████████████████████████████
██ ▄▄▄▄▄ █▀▀ ▄█▀▄██▀█ ▄█ ▄▄▄▄▄ ██
██ █ █ ██▄█ █▀█▄██▄▀ █ █ █ ██
██ █▄▄▄█ █▄ ▄▀▄▄▀▀ █ ▄█ █▄▄▄█ ██
██▄▄▄▄▄▄▄█▄▀▄▀ █▄█ ▀▄▀▄█▄▄▄▄▄▄▄██
██ ▀ █ ▀▄██▀█ ▀▀██ ▀██▀██▄█▀ ▀██
██▄ ▀▄██▄ ▀▄ ▄▀▀ ▀▀▀█▀█▀ ▄▄█▄ ██
██ ▄▀▄ █▄ ██▀▄█ █ ▄▀██ ▄█▄ █ ██
██▀▄▀▀█▀▄▀▀▀ ██▄██▄▀ ▀▀█ ▄▀██ ▄██
███▀██▀▄▄ ▄▀▀▀▄▀██▀ ▀▄██ ▀█▀█ ▀██
██▄▀ ▀▄▄▄ ▄ █▀▀ ▀█▀▄▀▀▄▀▄▀▄▄▄▄██
██▄█▄▄██▄█▀█▀███ ▄▀ █▀ ▄▄▄ █▀▀ ██
██ ▄▄▄▄▄ ██▄█▄█▄█▀▀▀▀▄ █▄█ ██▄ ██
██ █ █ █▄▄▄█▄▀██ ▄ █▄▄▄ ██▀ ██
██ █▄▄▄█ █▄ ▄█▀ ██▀▀ ██▀ ▀▄▀▄██
██▄▄▄▄▄▄▄█▄█▄███▄▄▄▄█▄▄████▄█▄▄██

click here to open in Lora
Scan the QR code with your wallet
( make sure you use the testnet-v1.0 network )

█████████████████████████████████
██ ▄▄▄▄▄ █▀▀ ▄█▀▄██▀█ ▄█ ▄▄▄▄▄ ██
██ █ █ ██▄█ █▀█▄██▄▀ █ █ █ ██
██ █▄▄▄█ █▄ ▄▀▄▄▀▀ █ ▄█ █▄▄▄█ ██
██▄▄▄▄▄▄▄█▄▀▄▀ █▄█ ▀▄▀▄█▄▄▄▄▄▄▄██
██ ▀ █ ▀▄██▀█ ▀▀██ ▀██▀██▄█▀ ▀██
██▄ ▀▄██▄ ▀▄ ▄▀▀ ▀▀▀█▀█▀ ▄▄█▄ ██
██ ▄▀▄ █▄ ██▀▄█ █ ▄▀██ ▄█▄ █ ██
██▀▄▀▀█▀▄▀▀▀ ██▄██▄▀ ▀▀█ ▄▀██ ▄██
███▀██▀▄▄ ▄▀▀▀▄▀██▀ ▀▄██ ▀█▀█ ▀██
██▄▀ ▀▄▄▄ ▄ █▀▀ ▀█▀▄▀▀▄▀▄▀▄▄▄▄██
██▄█▄▄██▄█▀█▀███ ▄▀ █▀ ▄▄▄ █▀▀ ██
██ ▄▄▄▄▄ ██▄█▄█▄█▀▀▀▀▄ █▄█ ██▄ ██
██ █ █ █▄▄▄█▄▀██ ▄ █▄▄▄ ██▀ ██
██ █▄▄▄█ █▄ ▄█▀ ██▀▀ ██▀ ▀▄▀▄██
██▄▄▄▄▄▄▄█▄█▄███▄▄▄▄█▄▄████▄█▄▄██

click here to open in Lora
2 changes: 2 additions & 0 deletions ui/modals/transaction/testdata/Test_Snapshot/Online.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Scan the QR code with your wallet
( make sure you use the testnet-v1.0 network )

█████████████████████████████████████████████████████
██ ▄▄▄▄▄ █▀ █▄▀█▀ ▀▄ ▄ █▄ ▄█▄ ▄█▄ ▄▄▀▀ █ ▄▄▄▄▄ ██
██ █ █ ███▀ ▀▄█▄▀█▀▄▄ ▄▄▄█▄▀▄██ █▀█ ▄█ █ █ ██
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

v-test-network network does not support QRCodes

click here to open in Lora
16 changes: 14 additions & 2 deletions ui/modals/transaction/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func Test_Snapshot(t *testing.T) {
t.Run("Offline", func(t *testing.T) {
model := New(test.GetState(nil))
model.Participation = &mock.Keys[0]
model.State.Status.Network = "testnet-v1.0"
model, _ = model.HandleMessage(tea.WindowSizeMsg{
Height: 40,
Width: 80,
Expand All @@ -43,6 +44,18 @@ func Test_Snapshot(t *testing.T) {
golden.RequireEqual(t, []byte(got))
})
t.Run("Online", func(t *testing.T) {
model := New(test.GetState(nil))
model.Participation = &mock.Keys[0]
model.State.Status.Network = "testnet-v1.0"
model, _ = model.HandleMessage(tea.WindowSizeMsg{
Height: 40,
Width: 80,
})
model.UpdateState()
got := ansi.Strip(model.View())
golden.RequireEqual(t, []byte(got))
})
t.Run("Unsupported", func(t *testing.T) {
model := New(test.GetState(nil))
model.Participation = &mock.Keys[0]
model, _ = model.HandleMessage(tea.WindowSizeMsg{
Expand All @@ -53,7 +66,6 @@ func Test_Snapshot(t *testing.T) {
got := ansi.Strip(model.View())
golden.RequireEqual(t, []byte(got))
})

t.Run("Loading", func(t *testing.T) {
model := New(test.GetState(nil))
model.Participation = &mock.Keys[0]
Expand All @@ -71,7 +83,7 @@ func Test_Messages(t *testing.T) {
// Create the Model
m := New(test.GetState(nil))
m.Participation = &mock.Keys[0]

m.State.Status.Network = "testnet-v1.0"
tm := teatest.NewTestModel(
t, m,
teatest.WithInitialTermSize(80, 40),
Expand Down
16 changes: 14 additions & 2 deletions ui/modals/transaction/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,23 @@ func (m ViewModel) View() string {
if err != nil {
return "Something went wrong"
}

Check warning on line 21 in ui/modals/transaction/view.go

View check run for this annotation

Codecov / codecov/patch

ui/modals/transaction/view.go#L20-L21

Added lines #L20 - L21 were not covered by tests

var qrCode string
if m.State.Status.Network == "testnet-v1.0" || m.State.Status.Network == "mainnet-v1.0" {
qrCode = lipgloss.JoinVertical(
lipgloss.Center,
"Scan the QR code with your wallet",
style.Yellow.Render("( make sure you use the "+m.State.Status.Network+" network )"),
"",
qrStyle.Render(txn),
)
} else {
qrCode = style.Red.Render("\n" + m.State.Status.Network + " network does not support QRCodes\n")
}
link, _ := internal.ToLoraDeepLink(m.State.Status.Network, m.Active, *m.Participation)
render := lipgloss.JoinVertical(
lipgloss.Center,
"Scan the QR code with your wallet",
qrStyle.Render(txn),
qrCode,
style.WithHyperlink("click here to open in Lora", link),
)

Expand Down

0 comments on commit a2f484c

Please sign in to comment.