Skip to content
Snippets Groups Projects
Commit 884aea43 authored by benjamin's avatar benjamin
Browse files

Merge remote-tracking branch 'origin/release' into release

# Conflicts:
#	go.sum
parents f583be73 17a13832
Branches
Tags
1 merge request!60Revert "Fail a test to be sure it works"
......@@ -18,55 +18,31 @@ require (
require (
filippo.io/edwards25519 v1.0.0 // indirect
git.xx.network/elixxir/grpc-web-go-client v0.0.0-20221221204132-2ed1fec765f1 // indirect
github.com/agnivade/wasmbrowsertest v0.6.0 // indirect
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 // indirect
github.com/badoux/checkmail v1.2.1 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/chromedp/cdproto v0.0.0-20221108233440-fad8339618ab // indirect
github.com/chromedp/chromedp v0.8.6 // indirect
github.com/chromedp/sysutil v1.0.0 // indirect
github.com/cloudflare/circl v1.2.0 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/elliotchance/orderedmap v1.4.0 // indirect
github.com/forPelevin/gomoji v1.1.8 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-interpreter/wagon v0.6.0 // indirect
github.com/gobwas/httphead v0.1.0 // indirect
github.com/gobwas/pool v0.2.1 // indirect
github.com/gobwas/ws v1.1.0 // indirect
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/pprof v0.0.0-20221103000818-d260c55eee4c // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.11.7 // indirect
github.com/klauspost/cpuid/v2 v2.1.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20221003100820-41fad3beba17 // indirect
github.com/oasisprotocol/deoxysii v0.0.0-20220228165953-2091330c22b7 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
github.com/pkg/profile v1.6.0 // indirect
github.com/rivo/uniseg v0.4.3 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/sethvargo/go-diceware v0.3.0 // indirect
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
github.com/soheilhy/cmux v0.1.5 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.5.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.12.0 // indirect
github.com/subosito/gotenv v1.4.0 // indirect
github.com/ttacon/builder v0.0.0-20170518171403-c099f663e1c2 // indirect
github.com/ttacon/libphonenumber v1.2.1 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
......@@ -87,9 +63,6 @@ require (
google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc // indirect
google.golang.org/grpc v1.49.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.66.6 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.7 // indirect
src.agwa.name/tlshacks v0.0.0-20220518131152-d2c6f4e2b780 // indirect
)
......@@ -196,6 +196,8 @@ func main() {
js.Global().Set("GetClientVersion", js.FuncOf(wasm.GetClientVersion))
js.Global().Set("GetClientGitVersion", js.FuncOf(wasm.GetClientGitVersion))
js.Global().Set("GetClientDependencies", js.FuncOf(wasm.GetClientDependencies))
js.Global().Set("GetWasmSemanticVersion", js.FuncOf(wasm.GetWasmSemanticVersion))
js.Global().Set("GetXXDKSemanticVersion", js.FuncOf(wasm.GetXXDKSemanticVersion))
<-make(chan bool)
os.Exit(0)
......
......@@ -11,9 +11,11 @@ package storage
import (
"os"
"sync"
"github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/v4/bindings"
)
......@@ -38,17 +40,23 @@ func CheckAndStoreVersions() error {
func checkAndStoreVersions(
currentWasmVer, currentClientVer string, ls *LocalStorage) error {
// Get the stored client and WASM versions, if they exists
storedClientVer, err := initOrLoadStoredSemver(
clientVerKey, currentClientVer, ls)
// Get the stored client version, if it exists
storedClientVer, err :=
initOrLoadStoredSemver(clientVerKey, currentClientVer, ls)
if err != nil {
return err
}
// Get the stored WASM versions, if it exists
storedWasmVer, err := initOrLoadStoredSemver(semverKey, currentWasmVer, ls)
if err != nil {
return err
}
// Store old versions to memory
setOldClientSemVersion(storedClientVer)
setOldWasmSemVersion(storedWasmVer)
// Check if client needs an update
if storedClientVer != currentClientVer {
jww.INFO.Printf("xxDK client out of date; upgrading version: v%s → v%s",
......@@ -96,3 +104,43 @@ func initOrLoadStoredSemver(
// Return the stored version
return string(storedVersion), nil
}
// oldVersions contains the old versions of xxdk WASM and xxdk client that were
// stored in storage before being overwritten on update.
var oldVersions struct {
wasm string
client string
sync.Mutex
}
// GetOldWasmSemVersion returns the old version of xxdk WASM before being
// updated.
func GetOldWasmSemVersion() string {
oldVersions.Lock()
defer oldVersions.Unlock()
return oldVersions.wasm
}
// GetOldClientSemVersion returns the old version of xxdk client before being
// updated.
func GetOldClientSemVersion() string {
oldVersions.Lock()
defer oldVersions.Unlock()
return oldVersions.client
}
// setOldWasmSemVersion sets the old version of xxdk WASM. This should be called
// before it is updated.
func setOldWasmSemVersion(v string) {
oldVersions.Lock()
defer oldVersions.Unlock()
oldVersions.wasm = v
}
// setOldClientSemVersion sets the old version of xxdk client. This should be
// called before it is updated.
func setOldClientSemVersion(v string) {
oldVersions.Lock()
defer oldVersions.Unlock()
oldVersions.client = v
}
......@@ -10,9 +10,12 @@
package wasm
import (
"encoding/json"
"syscall/js"
"gitlab.com/elixxir/client/v4/bindings"
"gitlab.com/elixxir/xxdk-wasm/storage"
"syscall/js"
"gitlab.com/elixxir/xxdk-wasm/utils"
)
// GetVersion returns the current xxDK WASM semantic version.
......@@ -49,3 +52,60 @@ func GetClientGitVersion(js.Value, []js.Value) any {
func GetClientDependencies(js.Value, []js.Value) any {
return bindings.GetDependencies()
}
// VersionInfo contains information about the current and old version of the
// API.
type VersionInfo struct {
Current string `json:"current"`
Updated bool `json:"updated"`
Old string `json:"old"`
}
// GetWasmSemanticVersion returns the current version of the WASM client, it's
// old version before being updated, and if it has been updated.
//
// Returns:
// - JSON of [VersionInfo] (Uint8Array).
// - Throws a TypeError if getting the version failed.
func GetWasmSemanticVersion(js.Value, []js.Value) any {
vi := VersionInfo{
Current: storage.SEMVER,
Updated: false,
Old: storage.GetOldWasmSemVersion(),
}
if vi.Current != vi.Old {
vi.Updated = true
}
data, err := json.Marshal(vi)
if err != nil {
utils.Throw(utils.TypeError, err)
}
return utils.CopyBytesToJS(data)
}
// GetXXDKSemanticVersion returns the current version of the xxdk client, it's
// old version before being updated, and if it has been updated.
//
// Returns:
// - JSON of [VersionInfo] (Uint8Array).
// - Throws a TypeError if getting the version failed.
func GetXXDKSemanticVersion(js.Value, []js.Value) any {
vi := VersionInfo{
Current: bindings.GetVersion(),
Updated: false,
Old: storage.GetOldClientSemVersion(),
}
if vi.Current != vi.Old {
vi.Updated = true
}
data, err := json.Marshal(vi)
if err != nil {
utils.Throw(utils.TypeError, err)
}
return utils.CopyBytesToJS(data)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment