feat: add automated production release workflow

This commit is contained in:
Prad Nukala
2024-09-23 12:25:15 -04:00
parent 05bda3d1b2
commit c31b324bd3
217 changed files with 19760 additions and 56358 deletions
+13 -16
View File
@@ -6,6 +6,7 @@ import (
"cosmossdk.io/log"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ipfs/boxo/path"
"github.com/onsonr/sonr/x/did/types"
)
@@ -21,7 +22,6 @@ func (k *Keeper) InitGenesis(ctx context.Context, data *types.GenesisState) erro
if err := data.Params.Validate(); err != nil {
return err
}
return k.Params.Set(ctx, data.Params)
}
@@ -55,22 +55,19 @@ func (k Keeper) CheckValidatorExists(ctx sdk.Context, addr string) bool {
return false
}
// GetAverageBlockTime returns the average block time in seconds
func (k Keeper) GetAverageBlockTime(ctx sdk.Context) float64 {
return float64(ctx.BlockTime().Sub(ctx.BlockTime()).Seconds())
}
// GetParams returns the module parameters.
func (k Keeper) GetParams(ctx sdk.Context) *types.Params {
p, err := k.Params.Get(ctx)
// HasPathInIPFS checks if a file is in the local IPFS node
func (k Keeper) HasPathInIPFS(ctx sdk.Context, cid string) (bool, error) {
path, err := path.NewPath(cid)
if err != nil {
p = types.DefaultParams()
return false, err
}
v, err := k.ipfsClient.Unixfs().Get(ctx, path)
if err != nil {
return false, err
}
params := p.ActiveParams(k.HasIPFSConnection())
return &params
}
// GetExpirationBlockHeight returns the block height at which the given duration will have passed
func (k Keeper) GetExpirationBlockHeight(ctx sdk.Context, duration time.Duration) int64 {
return ctx.BlockHeight() + int64(duration.Seconds()/k.GetAverageBlockTime(ctx))
if v == nil {
return false, nil
}
return true, nil
}