Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Catch up with address.go in cosmos-sdk v0.45.1 #587

Closed
wants to merge 93 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
fbd42f5
Catch up with address.go in cosmos-sdk v0.45.1
ulbqb Jul 8, 2022
517fa53
Fix
ulbqb Jul 7, 2022
fe9a9cd
Fix x/distribution
ulbqb Jul 11, 2022
4e4a03d
Fix x/evidence
ulbqb Jul 11, 2022
3345ac3
Fix syntax error: x/token
tnasu Jul 11, 2022
6b96aab
Fix syntax error: x/staking, x/stakingplus
tnasu Jul 11, 2022
40c9f6c
Fix syntax error: x/feegrant
ulbqb Jul 11, 2022
ac5ff0e
Merge remote-tracking branch 'remotes/origin/fix/issue578' into fix/i…
ulbqb Jul 11, 2022
3a69b4d
Fix syntax error: x/slashing
tnasu Jul 11, 2022
70f4d6a
Fix syntax error: x/foundation
ulbqb Jul 11, 2022
6388ee5
Fix syntax error: x/gov
ulbqb Jul 11, 2022
cb1dacb
Fix syntax error: x/ibc
tnasu Jul 11, 2022
e0ccf1d
Fix syntax error: x/token
tnasu Jul 11, 2022
d7b042e
Fix syntax error: x/staking
tnasu Jul 11, 2022
b4e2b32
Fix syntax error: x/staking/client/testutil/suite.go
ulbqb Jul 11, 2022
39df525
Fix syntax error: some files
ulbqb Jul 11, 2022
ed2a4f1
Remvoe diff of wasm for main
ulbqb Jul 11, 2022
03c3203
Merge upstream/main
ulbqb Jul 11, 2022
71bc9e8
Fix syntax error: x/wasm
ulbqb Jul 11, 2022
feb9848
Fix wrong usage of AccAddress in `x/wasm`
tnasu Jul 13, 2022
ea8814b
Fix wrong usage of AccAddress in `x/upgrade`
tnasu Jul 13, 2022
7e61c1f
Fix wrong usage of AccAddress in `x/token`
tnasu Jul 13, 2022
ab8b830
fix: types
Kynea0b Jul 13, 2022
048dec7
fix: testutil
Kynea0b Jul 13, 2022
d7d2dbd
Merge pull request #1 from kokeshiM0chi/fix/issue578
ulbqb Jul 13, 2022
1e3f320
Fix wrong usage of Acc/Val/ConAddress in `x/staking` and `x/stakingplus`
tnasu Jul 13, 2022
9a3dd7e
Fix semantic error: server
ulbqb Jul 13, 2022
e8e0f77
Fix semantic error: simapp
ulbqb Jul 13, 2022
891f213
fix: x/auth
Kynea0b Jul 13, 2022
eb64ae3
fix: x/auth 2
Kynea0b Jul 13, 2022
4092593
Merge pull request #2 from kokeshiM0chi/fix/issue578
ulbqb Jul 13, 2022
462f538
Fix a mistaken revert
ulbqb Jul 13, 2022
922b531
fix: x/feegrant
Kynea0b Jul 13, 2022
525de62
Merge pull request #3 from kokeshiM0chi/fix/issue578
ulbqb Jul 13, 2022
fce2363
Fix wrong usage of AccAddress in `x/foundation`
tnasu Jul 13, 2022
0bd9e59
Fix wrong usage of AccAddress in `x/bank` and `x/bankplus`
tnasu Jul 13, 2022
db59db3
Fix wrong usage of AccAddress in `x/ibc` based on v0.42.11
tnasu Jul 13, 2022
3cc3ef4
Fix semantic error: x/gov
ulbqb Jul 14, 2022
4783fb9
Fix semantic error: x/slashing
ulbqb Jul 14, 2022
95b1973
fix: fix syntax error
Kynea0b Jul 14, 2022
354ec27
Merge pull request #4 from kokeshiM0chi/fix/issue578
ulbqb Jul 14, 2022
8e6afcf
Fix a mistaken revert
ulbqb Jul 14, 2022
9b741cd
Fix baseapp/block_gas_test
ulbqb Jul 14, 2022
c68d011
Fix the wrong usage of ValAddress in `x/staking`
tnasu Jul 14, 2022
603cc81
Fix a mistaken revert
ulbqb Jul 14, 2022
c04db89
Fix the wrong usage of ConsAddress in `x/evidence`
tnasu Jul 14, 2022
113ee6c
Fix the wrong usage of ConsAddress in `x/slashing`
tnasu Jul 14, 2022
aea5bdb
fix: x/staking ValAddressFromBech32
Kynea0b Jul 14, 2022
84606a2
Merge pull request #5 from kokeshiM0chi/fix/issue578
ulbqb Jul 14, 2022
38686b2
Fix a mistaken revert and wrong test in x/foundation
ulbqb Jul 15, 2022
5fb1a04
Fix test of address on x/wasm
tnasu Jul 19, 2022
a8a1637
Fix test error of address validation on x/wasm
tnasu Jul 19, 2022
7cfaeb1
Fix error test of gas on x/wasm
tnasu Jul 19, 2022
640175e
Fix ibc relay test error on x/wasm
tnasu Jul 19, 2022
463ecb3
Revert the wrong remove of UpdateContractStatusProposal
tnasu Jul 19, 2022
d9c193c
Fix the wrong error handling
tnasu Jul 19, 2022
e8ab004
Merge remote-tracking branch 'upstream/main' into fix/issue578
Kynea0b Jul 19, 2022
f7555e6
fix: Delete panic in GetSigners()
Kynea0b Jul 19, 2022
b46f8ee
Merge pull request #7 from tnasu/fix/issue578
ulbqb Jul 19, 2022
616e825
Merge remote-tracking branch 'rollback/fix/issue578' into fix/issue578-2
Kynea0b Jul 19, 2022
a76f9f9
fix: Modify test
Kynea0b Jul 19, 2022
ca8bcb1
Fix the GetSigners func in x/auth
ulbqb Jul 19, 2022
9225b71
Merge pull request #8 from kokeshiM0chi/fix/issue578-2
ulbqb Jul 19, 2022
a90b481
Add bytes package
ulbqb Jul 19, 2022
535b903
chore(deps): Bump github.com/spf13/cobra from 1.4.0 to 1.5.0 (#569)
dependabot[bot] Jul 19, 2022
2e61adc
feat: change amino codec path from `lbm-sdk/` to `cosmos-sdk/` (#600)
zemyblue Jul 19, 2022
539a047
Remove prefetch functionality (#596)
torao Jul 19, 2022
a47acef
fix some x/collection conflicts (imcomplete)
torao Jul 19, 2022
c431caf
Merge pull request #9 from torao/fix/issue578
ulbqb Jul 19, 2022
702032a
Merge branch 'main' into fix/issue578
ulbqb Jul 19, 2022
9934f12
Fix the error test of x/staking
tnasu Jul 19, 2022
998364a
Fix syntax error in x/collection
ulbqb Jul 19, 2022
7dad7e7
Fix invalid massage in x/collection
ulbqb Jul 19, 2022
804f348
Fix incorrect address translation
ulbqb Jul 19, 2022
100dc6e
Remove redundant processing
ulbqb Jul 19, 2022
aa03184
Merge pull request #10 from tnasu/fix/issue578
ulbqb Jul 20, 2022
988c136
Fix the error test on x/feegrant, x/foundation, x/gov, and x/ibc
tnasu Jul 20, 2022
7cfc5f4
fix: client
Kynea0b Jul 20, 2022
0d77f95
Fix a bug on x/slashing: https://github.com/cosmos/cosmos-sdk/issues/…
tnasu Jul 20, 2022
801527f
Merge pull request #11 from kokeshiM0chi/fix/issue578-2
ulbqb Jul 20, 2022
c86104d
Merge pull request #12 from tnasu/fix/issue578
ulbqb Jul 20, 2022
fab35b3
Fix base gas in `baseapp`
ulbqb Jul 20, 2022
2680001
Fix `x/bank`
ulbqb Jul 20, 2022
bed6651
Merge pull request #13 from ulbqb/fix/issue578_x_bank
ulbqb Jul 20, 2022
248ca48
Fix incorrect address
ulbqb Jul 20, 2022
d2b0b44
Fix wrong usage of AccAddress in `x/auth`
ulbqb Jul 20, 2022
42d7f58
Fix lint error
ulbqb Jul 20, 2022
01b0c48
Fix to use sdk.AccAddressFromBech32 from sdk.AccAddress
tnasu Jul 20, 2022
76b462f
Ignore err on test
tnasu Jul 20, 2022
fccca83
Merge pull request #14 from tnasu/fix/issue578
ulbqb Jul 20, 2022
ad27def
Fix the error handling when using AccAddressFromBech32
tnasu Jul 21, 2022
916101f
Merge pull request #15 from tnasu/fix/issue578
ulbqb Jul 21, 2022
f137bfb
Fix wrong usage of AccAddress, ValAddress, ConsAddress
ulbqb Jul 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion baseapp/accountwgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func newTestPrivKeys(num int) []*secp256k1.PrivKey {
func getAddrs(privs []*secp256k1.PrivKey) []sdk.AccAddress {
addrs := make([]sdk.AccAddress, 0, len(privs))
for _, priv := range privs {
addrs = append(addrs, sdk.BytesToAccAddress(priv.PubKey().Address()))
addrs = append(addrs, sdk.AccAddress(priv.PubKey().Address()))
}
return addrs
}
Expand Down
2 changes: 1 addition & 1 deletion baseapp/block_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
require.Equal(t, []byte("ok"), okValue)
}
// check block gas is always consumed
baseGas := uint64(40043) // baseGas is the gas consumed before tx msg
baseGas := uint64(37352) // baseGas is the gas consumed before tx msg
expGasConsumed := addUint64Saturating(tc.gasToConsume, baseGas)
if expGasConsumed > txtypes.MaxGasWanted {
// capped by gasLimit
Expand Down
7 changes: 4 additions & 3 deletions client/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,16 @@ func readTxCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Context, err
clientCtx = clientCtx.WithSignModeStr(signModeStr)
}

if clientCtx.FeeGranter == "" || flagSet.Changed(flags.FlagFeeAccount) {
if clientCtx.FeeGranter == nil || flagSet.Changed(flags.FlagFeeAccount) {
granter, _ := flagSet.GetString(flags.FlagFeeAccount)

if granter != "" {
err := sdk.ValidateAccAddress(granter)
granterAcc, err := sdk.AccAddressFromBech32(granter)
if err != nil {
return clientCtx, err
}
clientCtx = clientCtx.WithFeeGranterAddress(sdk.AccAddress(granter))

clientCtx = clientCtx.WithFeeGranterAddress(granterAcc)
}
}

Expand Down
16 changes: 8 additions & 8 deletions client/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,28 +335,28 @@ func (ctx Context) printOutput(out []byte) error {
// address is returned.
func GetFromFields(kr keyring.Keyring, from string, genOnly bool) (sdk.AccAddress, string, keyring.KeyType, error) {
if from == "" {
return "", "", 0, nil
return nil, "", 0, nil
}

if genOnly {
err := sdk.ValidateAccAddress(from)
addr, err := sdk.AccAddressFromBech32(from)
if err != nil {
return sdk.AccAddress(from), "", 0, errors.Wrap(err, "must provide a valid Bech32 address in generate-only mode")
return nil, "", 0, errors.Wrap(err, "must provide a valid Bech32 address in generate-only mode")
}

return sdk.AccAddress(from), "", 0, nil
return addr, "", 0, nil
}

var info keyring.Info
if err := sdk.ValidateAccAddress(from); err == nil {
info, err = kr.KeyByAddress(sdk.AccAddress(from))
if addr, err := sdk.AccAddressFromBech32(from); err == nil {
info, err = kr.KeyByAddress(addr)
if err != nil {
return sdk.AccAddress(from), "", 0, err
return nil, "", 0, err
}
} else {
info, err = kr.Key(from)
if err != nil {
return "", "", 0, err
return nil, "", 0, err
}
}

Expand Down
19 changes: 8 additions & 11 deletions client/debug/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ $ %s debug addr link19wgf6ymq2ur6r59st95e04e49m69z4al4fc982
RunE: func(cmd *cobra.Command, args []string) error {

addrString := args[0]
var addrBytes []byte
var addr []byte

// try hex, then bech32
var err error
addrBytes, err = hex.DecodeString(addrString)
addr, err = hex.DecodeString(addrString)
if err != nil {
var err2 error
addrBytes, err2 = sdk.AccAddressToBytes(addrString)
addr, err2 = sdk.AccAddressFromBech32(addrString)
if err2 != nil {
var err3 error
addrBytes, err3 = sdk.ValAddressToBytes(addrString)
addr, err3 = sdk.ValAddressFromBech32(addrString)

if err3 != nil {
return fmt.Errorf("expected hex or bech32. Got errors: hex: %v, bech32 acc: %v, bech32 val: %v", err, err2, err3)
Expand All @@ -91,13 +91,10 @@ $ %s debug addr link19wgf6ymq2ur6r59st95e04e49m69z4al4fc982
}
}

accAddr := sdk.BytesToAccAddress(addrBytes)
valAddr := sdk.BytesToValAddress(addrBytes)

cmd.Println("Address Bytes:", addrBytes)
cmd.Printf("Address (hex): %X\n", addrBytes)
cmd.Printf("Bech32 Acc: %s\n", accAddr)
cmd.Printf("Bech32 Val: %s\n", valAddr)
cmd.Println("Address:", addr)
cmd.Printf("Address (hex): %X\n", addr)
cmd.Printf("Bech32 Acc: %s\n", sdk.AccAddress(addr))
cmd.Printf("Bech32 Val: %s\n", sdk.ValAddress(addr))
return nil
},
}
Expand Down
3 changes: 1 addition & 2 deletions client/keys/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,10 @@ func fetchKey(kb keyring.Keyring, keyref string) (keyring.Info, error) {
if err == nil || !sdkerr.IsOf(err, sdkerr.ErrIO, sdkerr.ErrKeyNotFound) {
return info, err
}
err = sdk.ValidateAccAddress(keyref)
accAddr, err := sdk.AccAddressFromBech32(keyref)
if err != nil {
return info, err
}
accAddr := sdk.AccAddress(keyref)

info, err = kb.KeyByAddress(accAddr)
return info, sdkerr.Wrap(err, "Invalid key")
Expand Down
4 changes: 1 addition & 3 deletions client/keys/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ func Test_multiSigKey_Properties(t *testing.T) {
require.Equal(t, "myMultisig", tmp.GetName())
require.Equal(t, keyring.TypeMulti, tmp.GetType())
require.Equal(t, "BDF0C827D34CA39919C7688EB5A95383C60B3471", tmp.GetPubKey().Address().String())
acc := tmp.GetAddress()
addrBytes, _ := sdk.AccAddressToBytes(acc.String())
require.Equal(t, "link1hhcvsf7nfj3ejxw8dz8tt22ns0rqkdr3rrh7xy", sdk.MustBech32ifyAddressBytes("link", addrBytes))
require.Equal(t, "link1hhcvsf7nfj3ejxw8dz8tt22ns0rqkdr3rrh7xy", sdk.MustBech32ifyAddressBytes("link", tmp.GetAddress()))
}

func Test_showKeysCmd(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion client/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s *IntegrationTestSuite) TestQueryABCIHeight() {
req := abci.RequestQuery{
Path: fmt.Sprintf("store/%s/key", banktypes.StoreKey),
Height: tc.reqHeight,
Data: banktypes.CreateAccountBalancesPrefix(val.Address.Bytes()),
Data: banktypes.CreateAccountBalancesPrefix(val.Address),
Prove: true,
}

Expand Down
2 changes: 1 addition & 1 deletion client/rpc/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func validatorOutput(validator *octypes.Validator) (ValidatorOutput, error) {
}

return ValidatorOutput{
Address: sdk.BytesToConsAddress(validator.Address),
Address: sdk.ConsAddress(validator.Address),
PubKey: pk,
ProposerPriority: validator.ProposerPriority,
VotingPower: validator.VotingPower,
Expand Down
8 changes: 4 additions & 4 deletions crypto/keyring/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (i localInfo) GetPubKey() cryptotypes.PubKey {

// GetType implements Info interface
func (i localInfo) GetAddress() types.AccAddress {
return types.BytesToAccAddress(i.PubKey.Address())
return i.PubKey.Address().Bytes()
}

// GetType implements Info interface
Expand Down Expand Up @@ -117,7 +117,7 @@ func (i ledgerInfo) GetPubKey() cryptotypes.PubKey {

// GetAddress implements Info interface
func (i ledgerInfo) GetAddress() types.AccAddress {
return types.BytesToAccAddress(i.PubKey.Address())
return i.PubKey.Address().Bytes()
}

// GetPath implements Info interface
Expand Down Expand Up @@ -169,7 +169,7 @@ func (i offlineInfo) GetAlgo() hd.PubKeyType {

// GetAddress implements Info interface
func (i offlineInfo) GetAddress() types.AccAddress {
return types.BytesToAccAddress(i.PubKey.Address())
return i.PubKey.Address().Bytes()
}

// GetPath implements Info interface
Expand Down Expand Up @@ -222,7 +222,7 @@ func (i multiInfo) GetPubKey() cryptotypes.PubKey {

// GetAddress implements Info interface
func (i multiInfo) GetAddress() types.AccAddress {
return types.BytesToAccAddress(i.PubKey.Address())
return i.PubKey.Address().Bytes()
}

// GetPath implements Info interface
Expand Down
2 changes: 1 addition & 1 deletion crypto/keyring/keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ func (ks keystore) NewAccount(name string, mnemonic string, bip39Passphrase stri

// check if the a key already exists with the same address and return an error
// if found
address := sdk.BytesToAccAddress(privKey.PubKey().Address())
address := sdk.AccAddress(privKey.PubKey().Address())
if _, err := ks.KeyByAddress(address); err == nil {
return nil, fmt.Errorf("account with address %s already exists in keyring, delete the key first if you want to recreate it", address)
}
Expand Down
6 changes: 2 additions & 4 deletions crypto/keyring/keyring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ func TestKeyManagementKeyRing(t *testing.T) {
require.NotNil(t, err)
_, err = kb.KeyByAddress(accAddr(i2))
require.NoError(t, err)
addr := sdk.AccAddress("link1yxfu3fldlgux939t0gwaqs82l4x77v2kasa7jf")
err = sdk.ValidateAccAddress(addr.String())
addr, err := sdk.AccAddressFromBech32("link1yxfu3fldlgux939t0gwaqs82l4x77v2kasa7jf")
require.NoError(t, err)
_, err = kb.KeyByAddress(addr)
require.NotNil(t, err)
Expand Down Expand Up @@ -433,8 +432,7 @@ func TestInMemoryKeyManagement(t *testing.T) {
require.NotNil(t, err)
_, err = cstore.KeyByAddress(accAddr(i2))
require.NoError(t, err)
addr := sdk.AccAddress("link1yxfu3fldlgux939t0gwaqs82l4x77v2kasa7jf")
err = sdk.ValidateAccAddress(addr.String())
addr, err := sdk.AccAddressFromBech32("link1yxfu3fldlgux939t0gwaqs82l4x77v2kasa7jf")
require.NoError(t, err)
_, err = cstore.KeyByAddress(addr)
require.NotNil(t, err)
Expand Down
6 changes: 3 additions & 3 deletions crypto/keyring/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ func NewKeyOutput(name string, keyType KeyType, a sdk.Address, pk cryptotypes.Pu
// MkConsKeyOutput create a KeyOutput in with "cons" Bech32 prefixes.
func MkConsKeyOutput(keyInfo Info) (KeyOutput, error) {
pk := keyInfo.GetPubKey()
addr := sdk.BytesToConsAddress(pk.Address())
addr := sdk.ConsAddress(pk.Address())
return NewKeyOutput(keyInfo.GetName(), keyInfo.GetType(), addr, pk)
}

// MkValKeyOutput create a KeyOutput in with "val" Bech32 prefixes.
func MkValKeyOutput(keyInfo Info) (KeyOutput, error) {
pk := keyInfo.GetPubKey()
addr := sdk.BytesToValAddress(pk.Address())
addr := sdk.ValAddress(pk.Address())
return NewKeyOutput(keyInfo.GetName(), keyInfo.GetType(), addr, pk)
}

Expand All @@ -57,7 +57,7 @@ func MkValKeyOutput(keyInfo Info) (KeyOutput, error) {
// public keys will be added.
func MkAccKeyOutput(keyInfo Info) (KeyOutput, error) {
pk := keyInfo.GetPubKey()
addr := sdk.BytesToAccAddress(pk.Address())
addr := sdk.AccAddress(pk.Address())
return NewKeyOutput(keyInfo.GetName(), keyInfo.GetType(), addr, pk)
}

Expand Down
2 changes: 1 addition & 1 deletion crypto/keyring/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestBech32KeysOutput(t *testing.T) {

info, err := NewMultiInfo("multisig", multisigPk)
require.NoError(t, err)
accAddr := sdk.BytesToAccAddress(info.GetPubKey().Address())
accAddr := sdk.AccAddress(info.GetPubKey().Address())
expectedOutput, err := NewKeyOutput(info.GetName(), info.GetType(), accAddr, multisigPk)
require.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion crypto/keys/multisig/multisig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,6 @@ func TestProtoMarshalJSON(t *testing.T) {
require.NoError(err)
ko, err := keyring.MkAccKeyOutput(info)
require.NoError(err)
require.Equal(ko.Address, sdk.BytesToAccAddress(pk2.Address()).String())
require.Equal(ko.Address, sdk.AccAddress(pk2.Address()).String())
require.Equal(ko.PubKey, string(bz))
}
4 changes: 2 additions & 2 deletions crypto/ledger/ledger_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/cosmos/go-bip39"
secp256k1 "github.com/tendermint/btcd/btcec"

"github.com/line/ostracon/crypto"

"github.com/line/lbm-sdk/crypto/hd"
Expand Down Expand Up @@ -83,7 +83,7 @@ func (mock LedgerSECP256K1Mock) GetAddressPubKeySECP256K1(derivationPath []uint3

// Generate the bech32 addr using existing occrypto/etc.
pub := &csecp256k1.PubKey{Key: compressedPublicKey}
addr := sdk.BytesToAccAddress(pub.Address()).String()
addr := sdk.AccAddress(pub.Address()).String()
return pk, addr, err
}

Expand Down
8 changes: 4 additions & 4 deletions crypto/ledger/ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ func checkDefaultPubKey(t *testing.T, priv types.LedgerPrivKey) {
fmt.Sprintf("%x", cdc.Amino.MustMarshalBinaryBare(priv.PubKey())),
"Is your device using test mnemonic: %s ?", testdata.TestMnemonic)
require.Equal(t, expectedPkStr, priv.PubKey().String())
addr := sdk.BytesToAccAddress(priv.PubKey().Address())
addr := sdk.AccAddress(priv.PubKey().Address()).String()
require.Equal(t, "link1tdl7n2acgmec0y5nng0q2fahl9khyct3cgsktn",
addr.String(), "Is your device using test mnemonic: %s ?", testdata.TestMnemonic)
addr, "Is your device using test mnemonic: %s ?", testdata.TestMnemonic)
}

func TestPublicKeyUnsafeHDPath(t *testing.T) {
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestPublicKeySafe(t *testing.T) {
require.Nil(t, ShowAddress(path, priv.PubKey(), sdk.GetConfig().GetBech32AccountAddrPrefix()))
checkDefaultPubKey(t, priv)

addr2 := sdk.BytesToAccAddress(priv.PubKey().Address()).String()
addr2 := sdk.AccAddress(priv.PubKey().Address()).String()
require.Equal(t, addr, addr2)
}

Expand Down Expand Up @@ -147,7 +147,7 @@ func TestPublicKeyHDPath(t *testing.T) {
require.NotNil(t, addr)
require.NotNil(t, priv)

addr2 := sdk.BytesToAccAddress(priv.PubKey().Address()).String()
addr2 := sdk.AccAddress(priv.PubKey().Address()).String()
require.Equal(t, addr2, addr)
require.Equal(t,
expectedAddrs[i], addr,
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ require (
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3
github.com/improbable-eng/grpc-web v0.15.0
github.com/jhump/protoreflect v1.10.3
Expand Down
1 change: 0 additions & 1 deletion server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ func DefaultConfig() *Config {
InterBlockCache: true,
InterBlockCacheSize: cache.DefaultCommitKVStoreCacheSize,
IAVLCacheSize: iavl.DefaultIAVLCacheSize,
Bech32CacheSize: sdk.DefaultBech32CacheSize,
Pruning: storetypes.PruningOptionDefault,
PruningKeepRecent: "0",
PruningKeepEvery: "0",
Expand Down
13 changes: 7 additions & 6 deletions server/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ func GenerateCoinKey(algo keyring.SignatureAlgo) (sdk.AccAddress, string, error)
algo,
)
if err != nil {
return sdk.AccAddress(""), "", err
return sdk.AccAddress{}, "", err
}
return sdk.BytesToAccAddress(info.GetPubKey().Address()), secret, nil

return sdk.AccAddress(info.GetPubKey().Address()), secret, nil
}

// Deprecated: GenerateSaveCoinKey generates a new key mnemonic with its addrress.
Expand All @@ -43,20 +44,20 @@ func GenerateSaveCoinKey(

// ensure no overwrite
if !overwrite && exists {
return sdk.AccAddress(""), "", fmt.Errorf("key already exists, overwrite is disabled")
return sdk.AccAddress{}, "", fmt.Errorf("key already exists, overwrite is disabled")
}

// remove the old key by name if it exists
if exists {
if err := keybase.Delete(keyName); err != nil {
return sdk.AccAddress(""), "", fmt.Errorf("failed to overwrite key")
return sdk.AccAddress{}, "", fmt.Errorf("failed to overwrite key")
}
}

k, mnemonic, err := keybase.NewMnemonic(keyName, keyring.English, sdk.GetConfig().GetFullBIP44Path(), keyring.DefaultBIP39Passphrase, algo)
if err != nil {
return sdk.AccAddress(""), "", err
return sdk.AccAddress{}, "", err
}

return sdk.BytesToAccAddress(k.GetPubKey().Address()), mnemonic, nil
return k.GetAddress(), mnemonic, nil
}
8 changes: 3 additions & 5 deletions server/rosetta/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,7 @@ func sdkEventToBalanceOperations(status string, event abci.Event) (operations []
default:
return nil, false
case banktypes.EventTypeCoinSpent:
spender := sdk.BytesToAccAddress(event.Attributes[0].Value)
err := sdk.ValidateAccAddress(spender.String())
spender, err := sdk.AccAddressFromBech32((string)(event.Attributes[0].Value))
if err != nil {
panic(err)
}
Expand All @@ -355,8 +354,7 @@ func sdkEventToBalanceOperations(status string, event abci.Event) (operations []
accountIdentifier = spender.String()

case banktypes.EventTypeCoinReceived:
receiver := sdk.BytesToAccAddress(event.Attributes[0].Value)
err := sdk.ValidateAccAddress(receiver.String())
receiver, err := sdk.AccAddressFromBech32((string)(event.Attributes[0].Value))
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -710,7 +708,7 @@ func (c converter) SigningComponents(tx authsigning.Tx, metadata *ConstructionMe
if err != nil {
return nil, nil, err
}
if !bytes.Equal(sdk.BytesToAccAddress(pubKey.Address()).Bytes(), signer.Bytes()) {
if !bytes.Equal(pubKey.Address().Bytes(), signer.Bytes()) {
return nil, nil, crgerrs.WrapError(
crgerrs.ErrBadArgument,
fmt.Sprintf("public key at index %d does not match the expected transaction signer: %X <-> %X", i, rosPubKeys[i].Bytes, signer.Bytes()),
Expand Down
Loading