Skip to content

Commit

Permalink
fix bug logs null
Browse files Browse the repository at this point in the history
  • Loading branch information
neitdung committed Jan 14, 2025
1 parent bc84d91 commit c634b57
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ replace (
// use Realio sdk v0.46.11-realio-4
// github.com/cosmos/cosmos-sdk => github.com/realiotech/cosmos-sdk v0.46.11-realio-4
github.com/evmos/os/example_chain => github.com/evmos/os/example_chain v0.0.0-20241002122822-02a9121016ee
github.com/forbole/juno/v6 => github.com/decentrio/juno/v6 v6.0.2-0.20250114070111-5ece210090ec

// github.com/realio-tech/multi-staking-module => ../multi-staking
// github.com/evmos/os => ../evmos-os
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/decentrio/juno/v6 v6.0.2-0.20250114070111-5ece210090ec h1:0LgX44I/xh9AXLmeeiZLZAR8I0MkZDXVTlOO70oWhf4=
github.com/decentrio/juno/v6 v6.0.2-0.20250114070111-5ece210090ec/go.mod h1:O3o+73CiNjsIuPNWBOH3Wv59vvI5zeGfYIZBjsNj4/I=
github.com/decentrio/multi-staking v0.0.0-20241025035539-29cf83199609 h1:1ttWK87XsSBLEXTSkaZo0kcs8nBnCqiIioK55VcvC8I=
github.com/decentrio/multi-staking v0.0.0-20241025035539-29cf83199609/go.mod h1:88BiAAV1Jp1sM4ZR09VAZimN5X34BO/7XTO7/si1tJE=
github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4=
Expand Down Expand Up @@ -533,8 +535,6 @@ github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/firefart/nonamedreturns v1.0.4 h1:abzI1p7mAEPYuR4A+VLKn4eNDOycjYo2phmY9sfv40Y=
github.com/firefart/nonamedreturns v1.0.4/go.mod h1:TDhe/tjI1BXo48CmYbUduTV7BdIga8MAO/xbKdcVsGI=
github.com/forbole/juno/v6 v6.0.1 h1:oOoHU+X/7YjKaGce8xtuT1xS9jF1czhvLr3OCH1ipPo=
github.com/forbole/juno/v6 v6.0.1/go.mod h1:O3o+73CiNjsIuPNWBOH3Wv59vvI5zeGfYIZBjsNj4/I=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
Expand Down
7 changes: 6 additions & 1 deletion modules/staking/utils_gentx.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/forbole/callisto/v4/modules/staking/keybase"
"github.com/forbole/callisto/v4/types"
"github.com/forbole/callisto/v4/utils"
)

// StoreValidatorFromMsgCreateValidator handles properly a MsgCreateValidator instance by
Expand All @@ -24,12 +25,16 @@ func (m *Module) StoreValidatorsFromMsgCreateValidator(height int64, msg *stakin
return fmt.Errorf("error while getting Avatar URL: %s", err)
}

selfDelegateAddr, err := utils.ConvertValidatorPubKeyToBech32String(pubKey)
if err != nil {
return fmt.Errorf("error while getting delegate address: %s", err)
}
// Save the validators
err = m.db.SaveValidatorData(
types.NewValidator(
sdk.ConsAddress(pubKey.Address()).String(),
msg.ValidatorAddress, pubKey.String(),
msg.DelegatorAddress,
selfDelegateAddr,
&msg.Commission.MaxChangeRate,
&msg.Commission.MaxRate,
height,
Expand Down
10 changes: 10 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import (

grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
"google.golang.org/grpc/metadata"

cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/types/bech32"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// RemoveDuplicateValues removes the duplicated values from the given slice
Expand All @@ -30,3 +34,9 @@ func GetHeightRequestContext(context context.Context, height int64) context.Cont
strconv.FormatInt(height, 10),
)
}

// ConvertValidatorPubKeyToBech32String converts the given pubKey to a Bech32 string
func ConvertValidatorPubKeyToBech32String(pubKey cryptotypes.PubKey) (string, error) {
bech32Prefix := sdk.GetConfig().GetBech32ConsensusPubPrefix()
return bech32.ConvertAndEncode(bech32Prefix, pubKey.Bytes())
}

0 comments on commit c634b57

Please sign in to comment.