Skip to content
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
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v21
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
<div class="list" id="cxList"><div class="empty">Connecting to server&hellip;</div></div>
</div>
</main>
<footer><span id="footL">polyDisplay &middot; pull down to reload</span><span id="appVer">v20 &middot; server</span></footer>
<footer><span id="footL">polyDisplay &middot; pull down to reload</span><span id="appVer">server</span></footer>
</div>

<div class="modal" id="modal">
Expand Down Expand Up @@ -602,6 +602,7 @@ <h3>Unlock pad</h3>
}

function render(s){
if(s.version) $("appVer").textContent=s.version+" · server";
var rows=s.positions||[], html="";
if(!(s.wallet||"").trim()){
html='<div class="empty">No Polymarket wallet.<br>Tap &#9881;, paste an address (0x&hellip;), then Save.</div>';
Expand Down
6 changes: 6 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package main

import (
_ "embed"
"encoding/json"
"fmt"
"io"
Expand All @@ -31,6 +32,9 @@ import (
"time"
)

//go:embed VERSION
var serverVersion string

/* ------------------------- config ------------------------- */

type Coin struct {
Expand Down Expand Up @@ -261,6 +265,7 @@ type PnL struct {
}

type State struct {
Version string `json:"version"`
Updated int64 `json:"updated"`
Wallet string `json:"wallet"`
CandleDays int `json:"candleDays"`
Expand Down Expand Up @@ -1028,6 +1033,7 @@ func refreshFast() {
})
}
state = State{
Version: strings.TrimSpace(serverVersion),
Updated: time.Now().Unix(),
Wallet: wallet,
CandleDays: c.CandleDays,
Expand Down
20 changes: 20 additions & 0 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,23 @@ func TestDefaultConfigHasNoWallet(t *testing.T) {
}
}

func TestEmbeddedServerVersion(t *testing.T) {
if got := strings.TrimSpace(serverVersion); got != "v21" {
t.Fatalf("server version = %q, want v21", got)
}
b, err := os.ReadFile("index.html")
if err != nil {
t.Fatal(err)
}
html := string(b)
if strings.Contains(html, `id="appVer">v21`) {
t.Error("client version is hard-coded instead of coming from server state")
}
if !strings.Contains(html, `$("appVer").textContent=s.version+" · server"`) {
t.Error("client does not render the server-reported version")
}
}

func TestEnvExampleIsPolymarketCore(t *testing.T) {
b, err := os.ReadFile(".env.example")
if err != nil {
Expand Down Expand Up @@ -789,6 +806,9 @@ func TestRefreshFastSkipsPolymarketWithoutWallet(t *testing.T) {
if state.Wallet != "" || state.Note != "" {
t.Errorf("wallet=%q note=%q, want both empty", state.Wallet, state.Note)
}
if state.Version != "v21" {
t.Errorf("state version=%q, want v21", state.Version)
}
}

func binaryLicenseSkip(path string) bool {
Expand Down
Loading