Newer
Older
////////////////////////////////////////////////////////////////////////////////
// //
// Use of this source code is governed by a license that can be found in the //
////////////////////////////////////////////////////////////////////////////////
//go:build js && wasm

Richard T. Carback III
committed
"gitlab.com/elixxir/client/v4/bindings"
"gitlab.com/elixxir/xxdk-wasm/storage"

Jono Wenger
committed
// GetVersion returns the current xxDK WASM semantic version.
// - Current version (string).
func GetVersion(js.Value, []js.Value) any {
return storage.SEMVER

Jono Wenger
committed
}
// GetClientVersion returns the current client xxDK semantic version
// ([xxdk.SEMVER]).
//
// Returns:
// - Current version (string).
func GetClientVersion(js.Value, []js.Value) any {

Jono Wenger
committed
// GetClientGitVersion returns the current client xxDK git version
// ([xxdk.GITVERSION]).
// - Git version (string).
func GetClientGitVersion(js.Value, []js.Value) any {

Jono Wenger
committed
// GetClientDependencies returns the client's dependencies
// ([xxdk.DEPENDENCIES]).
// - Dependency list (string).
func GetClientDependencies(js.Value, []js.Value) any {
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// 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)
}