From 9e21ca25ced2787dd5220582eaf2dbbbbff19a03 Mon Sep 17 00:00:00 2001 From: Alexander Bezobchuk Date: Mon, 28 Jan 2019 14:50:27 -0500 Subject: [PATCH] Remove Pubkey field from BaseAccount#String (#3407) --- x/auth/account.go | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/x/auth/account.go b/x/auth/account.go index e67e081ae..2bf2fce0c 100644 --- a/x/auth/account.go +++ b/x/auth/account.go @@ -83,12 +83,20 @@ type BaseAccount struct { // String implements fmt.Stringer func (acc BaseAccount) String() string { - return fmt.Sprintf(`Account %s: + var pubkey string + + if acc.PubKey != nil { + pubkey = sdk.MustBech32ifyAccPub(acc.PubKey) + } + + return fmt.Sprintf(`Account: + Address: %s + Pubkey: %s Coins: %s - PubKey: %s AccountNumber: %d - Sequence: %d`, acc.Address, acc.Coins, - acc.PubKey.Address(), acc.AccountNumber, acc.Sequence) + Sequence: %d`, + acc.Address, pubkey, acc.Coins, acc.AccountNumber, acc.Sequence, + ) } // Prototype function for BaseAccount @@ -183,8 +191,15 @@ type BaseVestingAccount struct { // String implements fmt.Stringer func (bva BaseVestingAccount) String() string { + var pubkey string + + if bva.PubKey != nil { + pubkey = sdk.MustBech32ifyAccPub(bva.PubKey) + } + return fmt.Sprintf(`Vesting Account: - Address: %s + Address: %s + Pubkey: %s Coins: %s AccountNumber: %d Sequence: %d @@ -192,10 +207,8 @@ func (bva BaseVestingAccount) String() string { DelegatedFree: %s DelegatedVesting: %s EndTime: %d `, - bva.Address, bva.Coins, - bva.AccountNumber, bva.Sequence, - bva.OriginalVesting, bva.DelegatedFree, - bva.DelegatedVesting, bva.EndTime, + bva.Address, pubkey, bva.Coins, bva.AccountNumber, bva.Sequence, + bva.OriginalVesting, bva.DelegatedFree, bva.DelegatedVesting, bva.EndTime, ) } @@ -395,8 +408,15 @@ func NewContinuousVestingAccount( } func (cva ContinuousVestingAccount) String() string { + var pubkey string + + if cva.PubKey != nil { + pubkey = sdk.MustBech32ifyAccPub(cva.PubKey) + } + return fmt.Sprintf(`Continuous Vesting Account: - Address: %s + Address: %s + Pubkey: %s Coins: %s AccountNumber: %d Sequence: %d @@ -405,10 +425,9 @@ func (cva ContinuousVestingAccount) String() string { DelegatedVesting: %s StartTime: %d EndTime: %d `, - cva.Address, cva.Coins, - cva.AccountNumber, cva.Sequence, - cva.OriginalVesting, cva.DelegatedFree, - cva.DelegatedVesting, cva.StartTime, cva.EndTime, + cva.Address, pubkey, cva.Coins, cva.AccountNumber, cva.Sequence, + cva.OriginalVesting, cva.DelegatedFree, cva.DelegatedVesting, + cva.StartTime, cva.EndTime, ) }