diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..1689437
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+v21
diff --git a/index.html b/index.html
index 5a37989..235569d 100644
--- a/index.html
+++ b/index.html
@@ -167,7 +167,7 @@
@@ -602,6 +602,7 @@
Unlock pad
}
function render(s){
+ if(s.version) $("appVer").textContent=s.version+" · server";
var rows=s.positions||[], html="";
if(!(s.wallet||"").trim()){
html='
No Polymarket wallet.
Tap ⚙, paste an address (0x…), then Save.
';
diff --git a/server.go b/server.go
index ac70740..1cc98b2 100644
--- a/server.go
+++ b/server.go
@@ -16,6 +16,7 @@
package main
import (
+ _ "embed"
"encoding/json"
"fmt"
"io"
@@ -31,6 +32,9 @@ import (
"time"
)
+//go:embed VERSION
+var serverVersion string
+
/* ------------------------- config ------------------------- */
type Coin struct {
@@ -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"`
@@ -1028,6 +1033,7 @@ func refreshFast() {
})
}
state = State{
+ Version: strings.TrimSpace(serverVersion),
Updated: time.Now().Unix(),
Wallet: wallet,
CandleDays: c.CandleDays,
diff --git a/server_test.go b/server_test.go
index a74d320..30b765f 100644
--- a/server_test.go
+++ b/server_test.go
@@ -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 {
@@ -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 {