Skip to content
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
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,58 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
# Use REPO_ACCESS token if available for pushing to protected branches
token: ${{ secrets.REPO_ACCESS || secrets.GITHUB_TOKEN }}

- name: Determine next version
id: get_version
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_branches: master
default_bump: minor
dry_run: true

- name: Update version in manager/config.yml
run: |
# Update the version in manager/config.yml
VERSION="${{ steps.get_version.outputs.new_tag }}"
echo "Updating manager/config.yml with version: $VERSION"

# Check if manager/config.yml exists
if [ ! -f manager/config.yml ]; then
echo "Warning: manager/config.yml does not exist. Skipping version update."
exit 0
fi

# Use sed to update the version line in the config file
sed -i "s/^version:.*$/version: \"$VERSION\"/" manager/config.yml

# Verify the update
echo "Updated manager/config.yml content:"
grep "^version:" manager/config.yml || echo "No version field found in manager/config.yml"

# Configure git
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"

# Check if there are changes to commit
if git diff --quiet manager/config.yml; then
echo "No changes to manager/config.yml"
else
# Commit the version update
git add manager/config.yml
git commit -m "ci: bump version to $VERSION in manager/config.yml [skip ci]"

# Try to push to master
echo "Attempting to push version update to master..."
if git push origin HEAD:master; then
echo "Successfully pushed version update to master"
else
echo "Warning: Could not push to master (may be protected). Version in config.yml may not match release tag."
echo "Consider using a Personal Access Token with appropriate permissions in REPO_ACCESS secret."
fi
fi

- name: Create and Push Tag
id: create_tag
Expand All @@ -35,6 +87,7 @@ jobs:
release_branches: master
default_bump: minor
create_annotated_tag: true
custom_tag: ${{ steps.get_version.outputs.new_tag }}

- name: Print the new tag
run: |
Expand Down
2 changes: 2 additions & 0 deletions manager/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ common:
enabled: false
port: 8881

version: "v0.4.48"

storage:
token: ""
url: "http://worker-sai-storage:8880"
Expand Down
4 changes: 2 additions & 2 deletions manager/gateway/cosmos_agregated.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
return validators, nil
}

func (g *CosmosGateway) supply() (*types.TokenSupplyResponse, error) {

Check failure on line 64 in manager/gateway/cosmos_agregated.go

View workflow job for this annotation

GitHub Actions / Go Lint (manager)

func `(*CosmosGateway).supply` is unused (unused)

Check failure on line 64 in manager/gateway/cosmos_agregated.go

View workflow job for this annotation

GitHub Actions / Go Lint (manager)

func `(*CosmosGateway).supply` is unused (unused)
var tokenSupplyResponse = new(types.TokenSupplyResponse)

gatewayReq, err := http.NewRequestWithContext(g.context.Context, "GET", "/cosmos/bank/v1beta1/supply", nil)
Expand Down Expand Up @@ -385,7 +385,7 @@
return g.filterAndPaginateValidators(validatorsResponse, req.Payload)
}

func (g *CosmosGateway) account(address string) (*types.AccountResponse, error) {
func (g *CosmosGateway) account(address string) (*types.AccountInfo, error) {
accountReq := types.InboundRequest{
Method: "GET",
Path: "/cosmos/auth/v1beta1/accounts/" + address,
Expand All @@ -406,5 +406,5 @@
return nil, err
}

return accountResponse, nil
return accountResponse.Account, nil
}
21 changes: 12 additions & 9 deletions manager/gateway/cosmos_agregated2.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/saiset-co/sai-storage-mongo/external/adapter"
"math"
"net/http"
"strconv"
"strings"

"github.com/saiset-co/sai-storage-mongo/external/adapter"

sekaitypes "github.com/KiraCore/sekai/types"
tmjson "github.com/cometbft/cometbft/libs/json"
types2 "github.com/cometbft/cometbft/types"
Expand Down Expand Up @@ -50,12 +51,12 @@ func (g *CosmosGateway) statusAPI() (interface{}, error) {
result.InterxInfo.LatestBlockHeight = sentryStatus.SyncInfo.LatestBlockHeight
result.InterxInfo.CatchingUp = sentryStatus.SyncInfo.CatchingUp

//result.InterxInfo.Node = config.Config.Node
//result.InterxInfo.KiraAddr = g.address
//result.InterxInfo.Node = sentryStatus.NodeInfo.Other.RpcAddress
result.InterxInfo.KiraAddr = sentryStatus.ValidatorInfo.Address
result.InterxInfo.KiraPubKey = g.PubKey.String()
result.InterxInfo.FaucetAddr = g.PubKey.Address().String()
//result.InterxInfo.InterxVersion = config.Config.InterxVersion
//result.InterxInfo.SekaiVersion = config.Config.SekaiVersion
result.InterxInfo.InterxVersion = cast.ToString(g.context.GetConfig("version", ""))
result.InterxInfo.SekaiVersion = sentryStatus.NodeInfo.Version

return result, nil
}
Expand Down Expand Up @@ -209,7 +210,7 @@ func (g *CosmosGateway) blocks(req types.InboundRequest) (*types.BlocksResultRes
return &result, nil
}

func (g *CosmosGateway) balances(req types.InboundRequest, accountID string) ([]sdk.Coin, error) {
func (g *CosmosGateway) balances(req types.InboundRequest, accountID string) (*types.BalancesResponse, error) {
type BalancesRequest struct {
Limit int `json:"limit,string,omitempty"`
Offset int `json:"offset,string,omitempty"`
Expand Down Expand Up @@ -252,15 +253,17 @@ func (g *CosmosGateway) balances(req types.InboundRequest, accountID string) ([]
return nil, err
}

var result types.BalancesResponse
var result = new(types.BalancesResponse)

err = json.Unmarshal(grpcBytes, &result)
err = json.Unmarshal(grpcBytes, result)
if err != nil {
logger.Logger.Error("[query-balances] Invalid response format", zap.Error(err))
return nil, err
}

return result.Balances, nil
result.Pagination.Total = len(result.Balances)

return result, nil
}

func (g *CosmosGateway) delegations(req types.InboundRequest) (interface{}, error) {
Expand Down
10 changes: 5 additions & 5 deletions manager/gateway/cosmos_agregated4.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,14 @@

var info = types.FaucetAccountInfo{
Address: faucetAddress,
Balances: balances,
Balances: balances.Balances,
}

return info, nil
} else if request.Claim != "" && request.Token != "" {
return g.processFaucet(req)
} else {
err = errors.New("[query-faucet] both claim and token parameters are required")

Check failure on line 429 in manager/gateway/cosmos_agregated4.go

View workflow job for this annotation

GitHub Actions / Go Lint (manager)

ineffectual assignment to err (ineffassign)

Check failure on line 429 in manager/gateway/cosmos_agregated4.go

View workflow job for this annotation

GitHub Actions / Go Lint (manager)

ineffectual assignment to err (ineffassign)
}

return nil, nil
Expand Down Expand Up @@ -470,7 +470,7 @@

left := (int64(lastTime) + g.config.Faucet.TimeLimit) - time.Now().UTC().Unix()
if left > 0 {
err = errors.New(fmt.Sprintf("[faucet] Claim time left: %d", left))

Check failure on line 473 in manager/gateway/cosmos_agregated4.go

View workflow job for this annotation

GitHub Actions / Go Lint (manager)

S1028: should use fmt.Errorf(...) instead of errors.New(fmt.Sprintf(...)) (gosimple)

Check failure on line 473 in manager/gateway/cosmos_agregated4.go

View workflow job for this annotation

GitHub Actions / Go Lint (manager)

S1028: should use fmt.Errorf(...) instead of errors.New(fmt.Sprintf(...)) (gosimple)
logger.Logger.Error("[faucet] Claim time left", zap.Any("Address", request.Claim), zap.Any("Time left", left))
return nil, err
}
Expand All @@ -493,15 +493,15 @@
availableAmount := new(big.Int)
availableAmount.SetString("0", 10)

for _, balance := range faucetBalances {
for _, balance := range faucetBalances.Balances {
if balance.Denom == request.Token {
availableAmount.Set(balance.Amount.BigInt())
}
}

claimAmount := new(big.Int)
claimAmount.SetString("0", 10)
for _, balance := range claimBalances {
for _, balance := range claimBalances.Balances {
if balance.Denom == request.Token {
claimAmount.Set(balance.Amount.BigInt())
}
Expand Down Expand Up @@ -562,13 +562,13 @@
return nil, err
}

accountNumber, err := strconv.ParseUint(accountInfo.Account.AccountNumber, 10, 64)
accountNumber, err := strconv.ParseUint(accountInfo.AccountNumber, 10, 64)
if err != nil {
logger.Logger.Error("[faucet] Invalid account response format", zap.Error(err))
return nil, err
}

sequence, err := strconv.ParseUint(accountInfo.Account.Sequence, 10, 64)
sequence, err := strconv.ParseUint(accountInfo.Sequence, 10, 64)
if err != nil {
logger.Logger.Error("[faucet] Invalid account response format", zap.Error(err))
return nil, err
Expand Down
19 changes: 11 additions & 8 deletions manager/types/cosmos.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ type FaucetAccountInfo struct {
}

type BalancesResponse struct {
Balances []sdk.Coin `json:"balances"`
Balances []sdk.Coin `json:"balances"`
Pagination *Pagination `json:"pagination,omitempty"`
}

type FaucetRequest struct {
Expand Down Expand Up @@ -380,12 +381,14 @@ type CosmosConfig struct {
RateLimit int `json:"rate_limit,float64"`
}

type AccountInfo struct {
Type string `json:"@type"`
Address string `json:"address"`
PubKey interface{} `json:"pubKey"`
AccountNumber string `json:"accountNumber"`
Sequence string `json:"sequence"`
}

type AccountResponse struct {
Account struct {
Type string `json:"@type"`
Address string `json:"address"`
PubKey interface{} `json:"pubKey"`
AccountNumber string `json:"accountNumber"`
Sequence string `json:"sequence"`
} `json:"account"`
Account *AccountInfo `json:"account"`
}
Loading