From c634b578201d061bf2fe5c1a9526b33e7f404f67 Mon Sep 17 00:00:00 2001 From: Dzung Do Date: Tue, 14 Jan 2025 14:05:26 +0700 Subject: [PATCH] fix bug logs null --- go.mod | 1 + go.sum | 4 ++-- modules/staking/utils_gentx.go | 7 ++++++- utils/utils.go | 10 ++++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7f0ff3ab3..e79c66eae 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index b0db38418..12b060f8c 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -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= diff --git a/modules/staking/utils_gentx.go b/modules/staking/utils_gentx.go index bbe5c2060..12fe9f854 100644 --- a/modules/staking/utils_gentx.go +++ b/modules/staking/utils_gentx.go @@ -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 @@ -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, diff --git a/utils/utils.go b/utils/utils.go index 711cda5ea..c6c6d78ff 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -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 @@ -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()) +}