mukan-ignite/ignite/pkg/cosmosver/cosmosver.go
Mukan Erkin Törük 26b204bd04
Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
feat: fork Ignite CLI v29 as Mukan Ignite — remove cosmos-sdk restrictions
2026-05-11 03:31:37 +03:00

84 lines
2.1 KiB
Go

package cosmosver
import (
"strings"
"github.com/blang/semver/v4"
)
const prefix = "v"
// Version represents a range of Cosmos SDK versions.
type Version struct {
// Version is the exact sdk version string.
Version string
// Semantic is the parsed version.
Semantic semver.Version
}
var (
StargateFortyVersion = newVersion("0.40.0")
StargateFortyFourVersion = newVersion("0.44.0-alpha")
StargateFortyFiveThreeVersion = newVersion("0.45.3")
StargateFortySevenTwoVersion = newVersion("0.47.2")
StargateFiftyVersion = newVersion("0.50.0") // 0.50.0 has been retracted and replaced with 0.50.1, but we keep it here for compatibility with pseudo versions.
StargateFiftyThreeVersion = newVersion("0.53.0")
)
var (
// Versions is a list of known, sorted Cosmos-SDK versions.
Versions = []Version{
StargateFortyVersion,
StargateFortyFourVersion,
StargateFortyFiveThreeVersion,
StargateFortySevenTwoVersion,
StargateFiftyVersion,
StargateFiftyThreeVersion, // NOTE: v0.50 and v0.53 are API compatible but consensus incompatible when using the new features from v0.53.
}
// Latest is the latest known version of the Cosmos-SDK.
Latest = Versions[len(Versions)-1]
)
func newVersion(version string) Version {
return Version{
Version: "v" + version,
Semantic: semver.MustParse(version),
}
}
// Parse parses a Cosmos-SDK version.
func Parse(version string) (v Version, err error) {
v.Version = version
if v.Semantic, err = semver.Parse(strings.TrimPrefix(version, prefix)); err != nil {
return v, err
}
return
}
// GTE checks if v is greater than or equal to version.
func (v Version) GTE(version Version) bool {
return v.Semantic.GTE(version.Semantic)
}
// LT checks if v is less than version.
func (v Version) LT(version Version) bool {
return v.Semantic.LT(version.Semantic)
}
// LTE checks if v is less than or equal to version.
func (v Version) LTE(version Version) bool {
return v.Semantic.LTE(version.Semantic)
}
// Is checks if v is equal to version.
func (v Version) Is(version Version) bool {
return v.Semantic.EQ(version.Semantic)
}
func (v Version) String() string {
return v.Version
}