-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: upgraded app with paloma module to SDK v0.50 (#1060)
Co-authored-by: ruthishvitwit <[email protected]> Co-authored-by: deepan95dev <[email protected]> Co-authored-by: Deepan kumar <[email protected]>
- Loading branch information
1 parent
f5b2e36
commit 15ce39e
Showing
16 changed files
with
193 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
package keeper | ||
|
||
import "cosmossdk.io/core/address" | ||
import ( | ||
"errors" | ||
|
||
"cosmossdk.io/core/address" | ||
) | ||
|
||
type err string | ||
|
||
const ErrFailedToParseValAddress err = "failed to parse validator address from bech32" | ||
|
||
func (e err) Error() string { | ||
return string(e) | ||
} | ||
func ValAddressFromBech32(addressCodec address.Codec, valAddr string) ([]byte, error) { | ||
bz, err := addressCodec.StringToBytes(valAddr) | ||
return bz, err | ||
if err != nil { | ||
return nil, errors.Join(ErrFailedToParseValAddress, err) | ||
} | ||
return bz, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package keeper | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/codec/address" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/palomachain/paloma/testutil" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestValAddressConversion(t *testing.T) { | ||
codec := address.Bech32Codec{ | ||
Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(), | ||
} | ||
|
||
validators := testutil.GenValidators(2, 25000) | ||
bech32, err := ValAddressFromBech32(codec, validators[0].GetOperator()) | ||
actual, _ := codec.StringToBytes(validators[0].GetOperator()) | ||
different, _ := ValAddressFromBech32(codec, validators[1].GetOperator()) | ||
assert.NoError(t, err) | ||
assert.NotNil(t, bech32) | ||
assert.Equal(t, bech32, actual) | ||
assert.NotEqual(t, bech32, different) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.