Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the ability to version the code #206

Merged
merged 13 commits into from
May 17, 2023
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
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ ENV GOPATH=/go
ENV CGO_ENABLED=0
ENV GOOS=linux

RUN go install github.com/jackc/tern@latest

# Download go dependencies
WORKDIR /app
COPY go.mod go.sum ./
Expand Down
3 changes: 0 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (

"github.com/arkeonetwork/arkeo/docs"

"github.com/blang/semver"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
Expand Down Expand Up @@ -525,7 +523,6 @@ func New(
app.BankKeeper,
app.AccountKeeper,
app.StakingKeeper,
semver.MustParse("0.0.0"),
)
arkeoModule := arkeomodule.NewAppModule(appCodec, app.ArkeoKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper)

Expand Down
3 changes: 0 additions & 3 deletions app/app_regtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (

"github.com/arkeonetwork/arkeo/docs"

"github.com/blang/semver"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
Expand Down Expand Up @@ -536,7 +534,6 @@ func New(
app.BankKeeper,
app.AccountKeeper,
app.StakingKeeper,
semver.MustParse("0.0.0"),
)
arkeoModule := arkeomodule.NewAppModule(appCodec, app.ArkeoKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper)

Expand Down
28 changes: 28 additions & 0 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@ package common

import (
"fmt"
"io/ioutil"
"net/url"
"path"
"runtime"
"strconv"
"strings"

"github.com/arkeonetwork/arkeo/common/cosmos"
)

const (
// SuperMajorityFactor - super majority 2/3
SuperMajorityFactor = 3
// SimpleMajorityFactor - simple majority 1/2
SimpleMajorityFactor = 2
)

// GetSafeShare does the same as GetUncappedShare , but GetSafeShare will guarantee the result will not more than total
func GetSafeShare(part, total, allocation cosmos.Int) cosmos.Int {
if part.GTE(total) {
Expand Down Expand Up @@ -60,3 +71,20 @@ func MustParseURL(uri string) *url.URL {
}
return u
}

// GetCurrentVersion - intended for unit tests, fetches the current version of
// arkeo via `version` file
// #nosec G304 this is a method only used for test purpose
func GetCurrentVersion() int64 {
_, filename, _, _ := runtime.Caller(0)
dir := path.Join(path.Dir(filename), "./../")
dat, err := ioutil.ReadFile(path.Join(dir, "version"))
if err != nil {
panic(err)
}
v, err := strconv.ParseInt(strings.TrimSpace(string(dat)), 10, 64)
if err != nil {
panic(err)
}
return v
}
3 changes: 3 additions & 0 deletions common/cosmos/cosmos.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var (
NewDecFromBigInt = sdk.NewDecFromBigInt
NewIntFromBigInt = sdk.NewIntFromBigInt
NewUintFromBigInt = sdkmath.NewUintFromBigInt
ValAddressFromBech32 = sdk.ValAddressFromBech32
AccAddressFromBech32 = sdk.AccAddressFromBech32
VerifyAddressFormat = sdk.VerifyAddressFormat
GetFromBech32 = sdk.GetFromBech32
Expand All @@ -63,6 +64,7 @@ var (
Bech32ifyPubKey = legacybech32.MarshalPubKey
Bech32PubKeyTypeConsPub = legacybech32.ConsPK
Bech32PubKeyTypeAccPub = legacybech32.AccPK
Bech32PubkeyTypeValPK = legacybech32.ValPK
Wrapf = errors.Wrapf
MustSortJSON = sdk.MustSortJSON
CodeUnauthorized = uint32(4)
Expand All @@ -77,6 +79,7 @@ type (
Coin = sdk.Coin
Coins = sdk.Coins
AccAddress = sdk.AccAddress
ValAddress = sdk.ValAddress
Attribute = sdk.Attribute
Result = sdk.Result
Event = sdk.Event
Expand Down
Loading