Skip to content

Commit

Permalink
fix: fee pool balances (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmic-vagabond authored Nov 11, 2024
1 parent b8eab22 commit ec6b101
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/s3 v1.53.1
github.com/cosmos/cosmos-sdk v0.47.11
github.com/cosmos/ibc-go/v7 v7.4.0
github.com/elys-network/elys v0.49.3
github.com/elys-network/elys v0.49.4
github.com/spf13/cobra v1.8.0
github.com/vbauerster/mpb/v8 v8.7.3
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1432,8 +1432,8 @@ github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkg
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/elys-network/bandchain-packet v0.0.3-sdk47 h1:W4sP/JOXAoABhsV+ck1NTphLuqpuxGg+uul1nDLbgxk=
github.com/elys-network/bandchain-packet v0.0.3-sdk47/go.mod h1:/CtU24lu2E4RbPRcZFJfEagwW6TUdFcxv7pX0cYYSgk=
github.com/elys-network/elys v0.49.3 h1:if9mEdby8K2R5mGJFUdH6XH/l9K2UeLOt0Ghc45IToE=
github.com/elys-network/elys v0.49.3/go.mod h1:tRqOX2Tv3ex0XmQcrrR1Sqq8JWBsJ7sXZwYFrQAId40=
github.com/elys-network/elys v0.49.4 h1:85f7F65oxJbpTffoEZqVv84tQ/6+qUYak8dihnx1bNE=
github.com/elys-network/elys v0.49.4/go.mod h1:ELyvrVJGoVGsAKMefApF99Wl+EpOEL/JA+QwiDsU7B4=
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
Expand Down
7 changes: 7 additions & 0 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,13 @@ type KeyOutput struct {
Mnemonic string `json:"mnemonic"`
}

// LegacyStatusOutput represents the JSON structure of the output from the status command
type LegacyStatusOutput struct {
SyncInfo struct {
LatestBlockHeight string `json:"latest_block_height"`
} `json:"SyncInfo"`
}

// StatusOutput represents the JSON structure of the output from the status command
type StatusOutput struct {
SyncInfo struct {
Expand Down
15 changes: 11 additions & 4 deletions utils/query-block-height.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@ func QueryBlockHeight(cmdPath, node string) (string, error) {
return "-1", err
}

// Unmarshal the JSON output
// Try unmarshalling into StatusOutput first
var statusOutput types.StatusOutput
if err := json.Unmarshal(output, &statusOutput); err != nil {
return "-1", err
if err := json.Unmarshal(output, &statusOutput); err == nil {
return statusOutput.SyncInfo.LatestBlockHeight, nil
}

// If the first unmarshal fails, try unmarshalling into LegacyStatusOutput
var legacyStatusOutput types.LegacyStatusOutput
if err := json.Unmarshal(output, &legacyStatusOutput); err == nil {
return legacyStatusOutput.SyncInfo.LatestBlockHeight, nil
}

return statusOutput.SyncInfo.LatestBlockHeight, nil
// If both attempts fail, return an error
return "-1", err
}
2 changes: 1 addition & 1 deletion utils/update-genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func UpdateGenesis(validatorBalance, homePath, genesisFilePath string) {
genesis.AppState.Distribution = genesisInit.AppState.Distribution

// temporary fix for distribution params
genesis.AppState.Distribution.FeePool.CommunityPool = sdk.NewDecCoins(sdk.NewDecCoin("ueden", sdk.NewInt(501155396873)), sdk.NewDecCoin("uedenb", sdk.NewInt(1670513830814)))
genesis.AppState.Distribution.FeePool.CommunityPool = sdk.NewDecCoins(sdk.NewDecCoin("ueden", sdk.NewInt(559826739880)), sdk.NewDecCoin("uedenb", sdk.NewInt(1866085077053)))

log.Printf("community pool: %v", genesis.AppState.Distribution.FeePool.CommunityPool)

Expand Down

0 comments on commit ec6b101

Please sign in to comment.