refactor: remove gogoproto stringer annotations and MarshalYAML functions (#13850)

This commit is contained in:
Julien Robert
2022-11-28 12:56:00 +00:00
committed by GitHub
parent 68c1517046
commit 41f0ab15e6
63 changed files with 2221 additions and 2617 deletions
-46
View File
@@ -9,11 +9,8 @@ import (
"github.com/cosmos/gogoproto/proto"
"github.com/tendermint/tendermint/crypto"
"sigs.k8s.io/yaml"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@@ -138,18 +135,6 @@ func (acc BaseAccount) Validate() error {
return nil
}
// MarshalYAML returns the YAML representation of an account.
func (acc BaseAccount) MarshalYAML() (interface{}, error) {
registry := codectypes.NewInterfaceRegistry()
cryptocodec.RegisterInterfaces(registry)
bz, err := codec.MarshalYAML(codec.NewProtoCodec(registry), &acc)
if err != nil {
return nil, err
}
return string(bz), err
}
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
func (acc BaseAccount) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
if acc.PubKey == nil {
@@ -251,37 +236,6 @@ type moduleAccountPretty struct {
Permissions []string `json:"permissions"`
}
func (ma ModuleAccount) String() string {
out, err := ma.MarshalYAML()
if err != nil {
panic(err)
}
return out.(string)
}
// MarshalYAML returns the YAML representation of a ModuleAccount.
func (ma ModuleAccount) MarshalYAML() (interface{}, error) {
accAddr, err := sdk.AccAddressFromBech32(ma.Address)
if err != nil {
return nil, err
}
bs, err := yaml.Marshal(moduleAccountPretty{
Address: accAddr,
PubKey: "",
AccountNumber: ma.AccountNumber,
Sequence: ma.Sequence,
Name: ma.Name,
Permissions: ma.Permissions,
})
if err != nil {
return nil, err
}
return string(bs), nil
}
// MarshalJSON returns the JSON representation of a ModuleAccount.
func (ma ModuleAccount) MarshalJSON() ([]byte, error) {
accAddr, err := sdk.AccAddressFromBech32(ma.Address)
+7 -11
View File
@@ -7,7 +7,6 @@ import (
"testing"
"github.com/stretchr/testify/require"
"sigs.k8s.io/yaml"
"cosmossdk.io/depinject"
@@ -51,11 +50,8 @@ func TestBaseAddressPubKey(t *testing.T) {
require.Nil(t, err)
require.EqualValues(t, addr2, acc2.GetAddress())
// no error when calling MarshalYAML with an account with pubkey
_, err = acc.MarshalYAML()
require.Nil(t, err)
// no panic on calling string with an account with pubkey
require.NotEmpty(t, acc.String())
require.NotPanics(t, func() { _ = acc.String() })
}
@@ -127,14 +123,14 @@ func TestGenesisAccountValidate(t *testing.T) {
}
}
func TestModuleAccountMarshalYAML(t *testing.T) {
func TestModuleAccountString(t *testing.T) {
name := "test"
moduleAcc := types.NewEmptyModuleAccount(name, types.Minter, types.Burner, types.Staking)
bs, err := yaml.Marshal(moduleAcc)
require.NoError(t, err)
want := "account_number: 0\naddress: cosmos1n7rdpqvgf37ktx30a2sv2kkszk3m7ncmg5drhe\nname: test\npermissions:\n- minter\n- burner\n- staking\npublic_key: \"\"\nsequence: 0\n"
require.Equal(t, want, string(bs))
want := `base_account:<address:"cosmos1n7rdpqvgf37ktx30a2sv2kkszk3m7ncmg5drhe" > name:"test" permissions:"minter" permissions:"burner" permissions:"staking" `
require.Equal(t, want, moduleAcc.String())
moduleAcc.SetSequence(10)
want = `base_account:<address:"cosmos1n7rdpqvgf37ktx30a2sv2kkszk3m7ncmg5drhe" sequence:10 > name:"test" permissions:"minter" permissions:"burner" permissions:"staking" `
require.Equal(t, want, moduleAcc.String())
}
func TestHasPermissions(t *testing.T) {
+51 -49
View File
@@ -76,8 +76,9 @@ type ModuleAccount struct {
Permissions []string `protobuf:"bytes,3,rep,name=permissions,proto3" json:"permissions,omitempty"`
}
func (m *ModuleAccount) Reset() { *m = ModuleAccount{} }
func (*ModuleAccount) ProtoMessage() {}
func (m *ModuleAccount) Reset() { *m = ModuleAccount{} }
func (m *ModuleAccount) String() string { return proto.CompactTextString(m) }
func (*ModuleAccount) ProtoMessage() {}
func (*ModuleAccount) Descriptor() ([]byte, []int) {
return fileDescriptor_7e1f7e915d020d2d, []int{1}
}
@@ -175,8 +176,9 @@ type Params struct {
SigVerifyCostSecp256k1 uint64 `protobuf:"varint,5,opt,name=sig_verify_cost_secp256k1,json=sigVerifyCostSecp256k1,proto3" json:"sig_verify_cost_secp256k1,omitempty"`
}
func (m *Params) Reset() { *m = Params{} }
func (*Params) ProtoMessage() {}
func (m *Params) Reset() { *m = Params{} }
func (m *Params) String() string { return proto.CompactTextString(m) }
func (*Params) ProtoMessage() {}
func (*Params) Descriptor() ([]byte, []int) {
return fileDescriptor_7e1f7e915d020d2d, []int{3}
}
@@ -252,51 +254,51 @@ func init() {
func init() { proto.RegisterFile("cosmos/auth/v1beta1/auth.proto", fileDescriptor_7e1f7e915d020d2d) }
var fileDescriptor_7e1f7e915d020d2d = []byte{
// 704 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x54, 0x4d, 0x4f, 0xdb, 0x48,
0x18, 0x8e, 0x93, 0x2c, 0x1f, 0x13, 0x60, 0x17, 0x93, 0x65, 0x4d, 0x0e, 0x89, 0x15, 0x09, 0x91,
0x45, 0x8b, 0xbd, 0x49, 0x45, 0xab, 0x72, 0x23, 0x69, 0x0f, 0x88, 0x42, 0x91, 0xa3, 0x72, 0xa8,
0x2a, 0x59, 0x63, 0x67, 0x30, 0x23, 0x32, 0x1e, 0xd7, 0x33, 0x46, 0x31, 0xbf, 0xa0, 0xaa, 0x54,
0xa9, 0x47, 0x8e, 0xa8, 0xbf, 0x80, 0x03, 0x3f, 0xa2, 0xed, 0x09, 0xf5, 0x54, 0xa9, 0x52, 0x54,
0x85, 0x03, 0x55, 0x7f, 0x45, 0xe5, 0x19, 0x07, 0x12, 0xca, 0x25, 0xf2, 0xfb, 0x3c, 0xcf, 0xfb,
0xfd, 0x4e, 0x40, 0xd9, 0xa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6, 0xf2, 0xaa, 0x9c, 0xf9, 0x7a, 0x55, 0xce, 0xbc, 0xfc, 0xd7, 0xc3, 0xfc, 0x30,
0x72, 0x0c, 0x97, 0x92, 0xf4, 0xed, 0x9b, 0xbf, 0x47, 0xe1, 0x71, 0x80, 0x98, 0x33, 0x21, 0xde,
0xdf, 0x83, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x70, 0x41, 0x50, 0x4a, 0x79, 0x04, 0x00, 0x00,
// 702 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x54, 0xcf, 0x4e, 0xdb, 0x48,
0x1c, 0x8e, 0x93, 0x2c, 0x7f, 0x26, 0xc0, 0x2e, 0x26, 0xcb, 0x9a, 0x1c, 0x62, 0x6f, 0xa4, 0x15,
0x59, 0xb4, 0xd8, 0x9b, 0x20, 0x56, 0x5a, 0x6e, 0x24, 0xbb, 0x07, 0xc4, 0xc2, 0x22, 0x47, 0xe5,
0x50, 0x55, 0xb2, 0xc6, 0xce, 0x60, 0x46, 0x64, 0x3c, 0xae, 0x67, 0x8c, 0x62, 0x9e, 0x00, 0x55,
0xaa, 0xd4, 0x47, 0x40, 0x7d, 0x02, 0x0e, 0xbc, 0x42, 0xa5, 0xaa, 0x27, 0xd4, 0x4b, 0x7b, 0x8a,
0xaa, 0x70, 0x00, 0xf5, 0x29, 0x2a, 0xcf, 0x38, 0x90, 0x50, 0x2e, 0xd6, 0xfc, 0xbe, 0xef, 0xfb,
0xfd, 0x9f, 0x31, 0xa8, 0x7a, 0x94, 0x11, 0xca, 0x2c, 0x18, 0xf3, 0x63, 0xeb, 0xb4, 0xe1, 0x22,
0x0e, 0x1b, 0xc2, 0x30, 0xc3, 0x88, 0x72, 0xaa, 0x2e, 0x49, 0xde, 0x14, 0x50, 0xc6, 0x57, 0x16,
0x21, 0xc1, 0x01, 0xb5, 0xc4, 0x57, 0xea, 0x2a, 0x2b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 0xff, 0xff, 0x42, 0x2a, 0x8b, 0xed, 0x71, 0x04, 0x00, 0x00,
}
func (this *Params) Equal(that interface{}) bool {
-8
View File
@@ -2,8 +2,6 @@ package types
import (
"fmt"
"sigs.k8s.io/yaml"
)
// Default parameter values
@@ -51,12 +49,6 @@ func (p Params) SigVerifyCostSecp256r1() uint64 {
return p.SigVerifyCostSecp256k1 / 2
}
// String implements the stringer interface.
func (p Params) String() string {
out, _ := yaml.Marshal(p)
return string(out)
}
func validateTxSigLimit(i interface{}) error {
v, ok := i.(uint64)
if !ok {
+2
View File
@@ -44,6 +44,8 @@ func TestParams_Validate(t *testing.T) {
require.NoError(t, got)
return
}
require.NotEmpty(t, tt.params.String())
require.Equal(t, tt.wantErr, got)
})
}
-8
View File
@@ -5,8 +5,6 @@ import (
"strings"
"time"
"sigs.k8s.io/yaml"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@@ -18,12 +16,6 @@ func (p Period) Duration() time.Duration {
return time.Duration(p.Length) * time.Second
}
// String implements the fmt.Stringer interface
func (p Period) String() string {
out, _ := yaml.Marshal(p)
return string(out)
}
// TotalLength return the total length in seconds for a period
func (p Periods) TotalLength() int64 {
var total int64
+56 -51
View File
@@ -37,8 +37,9 @@ type BaseVestingAccount struct {
EndTime int64 `protobuf:"varint,5,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"`
}
func (m *BaseVestingAccount) Reset() { *m = BaseVestingAccount{} }
func (*BaseVestingAccount) ProtoMessage() {}
func (m *BaseVestingAccount) Reset() { *m = BaseVestingAccount{} }
func (m *BaseVestingAccount) String() string { return proto.CompactTextString(m) }
func (*BaseVestingAccount) ProtoMessage() {}
func (*BaseVestingAccount) Descriptor() ([]byte, []int) {
return fileDescriptor_89e80273ca606d6e, []int{0}
}
@@ -76,8 +77,9 @@ type ContinuousVestingAccount struct {
StartTime int64 `protobuf:"varint,2,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"`
}
func (m *ContinuousVestingAccount) Reset() { *m = ContinuousVestingAccount{} }
func (*ContinuousVestingAccount) ProtoMessage() {}
func (m *ContinuousVestingAccount) Reset() { *m = ContinuousVestingAccount{} }
func (m *ContinuousVestingAccount) String() string { return proto.CompactTextString(m) }
func (*ContinuousVestingAccount) ProtoMessage() {}
func (*ContinuousVestingAccount) Descriptor() ([]byte, []int) {
return fileDescriptor_89e80273ca606d6e, []int{1}
}
@@ -115,8 +117,9 @@ type DelayedVestingAccount struct {
*BaseVestingAccount `protobuf:"bytes,1,opt,name=base_vesting_account,json=baseVestingAccount,proto3,embedded=base_vesting_account" json:"base_vesting_account,omitempty"`
}
func (m *DelayedVestingAccount) Reset() { *m = DelayedVestingAccount{} }
func (*DelayedVestingAccount) ProtoMessage() {}
func (m *DelayedVestingAccount) Reset() { *m = DelayedVestingAccount{} }
func (m *DelayedVestingAccount) String() string { return proto.CompactTextString(m) }
func (*DelayedVestingAccount) ProtoMessage() {}
func (*DelayedVestingAccount) Descriptor() ([]byte, []int) {
return fileDescriptor_89e80273ca606d6e, []int{2}
}
@@ -153,8 +156,9 @@ type Period struct {
Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"`
}
func (m *Period) Reset() { *m = Period{} }
func (*Period) ProtoMessage() {}
func (m *Period) Reset() { *m = Period{} }
func (m *Period) String() string { return proto.CompactTextString(m) }
func (*Period) ProtoMessage() {}
func (*Period) Descriptor() ([]byte, []int) {
return fileDescriptor_89e80273ca606d6e, []int{3}
}
@@ -207,8 +211,9 @@ type PeriodicVestingAccount struct {
VestingPeriods []Period `protobuf:"bytes,3,rep,name=vesting_periods,json=vestingPeriods,proto3" json:"vesting_periods"`
}
func (m *PeriodicVestingAccount) Reset() { *m = PeriodicVestingAccount{} }
func (*PeriodicVestingAccount) ProtoMessage() {}
func (m *PeriodicVestingAccount) Reset() { *m = PeriodicVestingAccount{} }
func (m *PeriodicVestingAccount) String() string { return proto.CompactTextString(m) }
func (*PeriodicVestingAccount) ProtoMessage() {}
func (*PeriodicVestingAccount) Descriptor() ([]byte, []int) {
return fileDescriptor_89e80273ca606d6e, []int{4}
}
@@ -248,8 +253,9 @@ type PermanentLockedAccount struct {
*BaseVestingAccount `protobuf:"bytes,1,opt,name=base_vesting_account,json=baseVestingAccount,proto3,embedded=base_vesting_account" json:"base_vesting_account,omitempty"`
}
func (m *PermanentLockedAccount) Reset() { *m = PermanentLockedAccount{} }
func (*PermanentLockedAccount) ProtoMessage() {}
func (m *PermanentLockedAccount) Reset() { *m = PermanentLockedAccount{} }
func (m *PermanentLockedAccount) String() string { return proto.CompactTextString(m) }
func (*PermanentLockedAccount) ProtoMessage() {}
func (*PermanentLockedAccount) Descriptor() ([]byte, []int) {
return fileDescriptor_89e80273ca606d6e, []int{5}
}
@@ -294,45 +300,44 @@ func init() {
}
var fileDescriptor_89e80273ca606d6e = []byte{
// 599 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xbf, 0x6f, 0xd3, 0x40,
0x18, 0xf5, 0x25, 0x21, 0xd0, 0x0b, 0xf4, 0x87, 0x55, 0xa2, 0xb4, 0x52, 0x9d, 0x60, 0x18, 0xa2,
0x48, 0xb5, 0x49, 0x11, 0x4b, 0x36, 0x52, 0x84, 0x84, 0x60, 0x40, 0x11, 0x62, 0x60, 0x89, 0xce,
0xf6, 0xe1, 0x9c, 0x1a, 0xdf, 0x45, 0xbe, 0x4b, 0xa1, 0x42, 0xec, 0x88, 0xa9, 0x23, 0x12, 0x03,
0x1d, 0x51, 0xc5, 0xd0, 0x3f, 0xa3, 0x1b, 0x19, 0x99, 0x0a, 0x4a, 0x86, 0xfe, 0x1b, 0xc8, 0xe7,
0xb3, 0x6b, 0x25, 0x69, 0xb7, 0x54, 0x2c, 0x89, 0xbf, 0x1f, 0xf7, 0xbd, 0xf7, 0x3e, 0x3f, 0xeb,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, 0x44, 0x81, 0xe4, 0xb9, 0xa8, 0x6f, 0x4a, 0xcd, 0x6f, 0x15, 0x22, 0xde, 0xe6, 0xf7,
0x1c, 0x2c, 0xc7, 0x94, 0x88, 0xfb, 0xdf, 0xf9, 0x41, 0xef, 0xc0, 0x95, 0x04, 0x7d, 0x20, 0x49,
0x72, 0xf5, 0xbd, 0x1b, 0x97, 0xa1, 0xc7, 0x5a, 0xda, 0x4b, 0xd1, 0x6e, 0x62, 0xbd, 0xcb, 0xaa,
0x25, 0xae, 0xf0, 0x96, 0x95, 0x7d, 0x67, 0xf7, 0x32, 0x9b, 0x9a, 0xbf, 0x06, 0xf3, 0x27, 0x90,
0x1b, 0x0a, 0x10, 0xc5, 0x54, 0xbc, 0x64, 0xee, 0x1e, 0xf6, 0xae, 0xd3, 0x62, 0x57, 0xd1, 0x9d,
0xc3, 0xa9, 0xfd, 0xe2, 0x74, 0x6c, 0x80, 0xd1, 0xd8, 0x00, 0x7f, 0xc7, 0x06, 0x38, 0x9c, 0x18,
0xda, 0x68, 0x62, 0x68, 0xbf, 0x27, 0x86, 0xf6, 0xb6, 0x79, 0xa5, 0x4f, 0x3e, 0xa8, 0x2b, 0x45,
0x5d, 0x6f, 0xd2, 0x36, 0x4e, 0x51, 0x5e, 0x2a, 0x8f, 0xfe, 0x05, 0x00, 0x00, 0xff, 0xff, 0x18,
0x83, 0xdb, 0x67, 0xfd, 0x06, 0x00, 0x00,
// 592 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0x3d, 0x6f, 0xd3, 0x40,
0x18, 0xce, 0x25, 0x21, 0xd0, 0x0b, 0xf4, 0xc3, 0x2a, 0x51, 0x5a, 0xa9, 0x4e, 0x30, 0x08, 0x85,
0x08, 0x6c, 0xa5, 0x88, 0x25, 0x1b, 0x29, 0x42, 0x42, 0x30, 0xa0, 0x08, 0x31, 0xb0, 0x44, 0x67,
0x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 0xfa, 0x0e, 0xe0, 0xcd, 0x27, 0xb8, 0x87, 0x0e, 0xd3, 0x1d, 0x5d, 0xa2, 0x94, 0xe6, 0xbd,
0x84, 0x6b, 0x75, 0x82, 0xeb, 0x5c, 0x3a, 0xd6, 0x11, 0x80, 0x85, 0x97, 0x38, 0x22, 0xcc, 0x37,
0x4a, 0xb0, 0xd0, 0xc3, 0x34, 0x10, 0x5d, 0xc9, 0x25, 0xd7, 0xd6, 0x91, 0xd1, 0x85, 0x05, 0x14,
0x4a, 0x8e, 0xcb, 0xfa, 0x8e, 0xf4, 0x7c, 0xeb, 0x6b, 0x16, 0x96, 0x14, 0x19, 0xe2, 0xfd, 0x77,
0x0e, 0x30, 0xda, 0x70, 0x2d, 0x41, 0xef, 0x4b, 0x92, 0x5c, 0x7f, 0xdd, 0xe6, 0x22, 0x74, 0xa5,
0xa5, 0xb5, 0x12, 0x6f, 0x45, 0x29, 0x5d, 0xd5, 0x2d, 0xaa, 0xc2, 0x9b, 0xf5, 0xe4, 0x4d, 0xdd,
0x9a, 0xd8, 0xcf, 0xfc, 0x15, 0x58, 0xc7, 0x40, 0x6e, 0x27, 0x44, 0x14, 0x53, 0xf1, 0x82, 0x79,
0xfb, 0xd8, 0xbf, 0x4c, 0x53, 0x2d, 0xa2, 0x3a, 0x87, 0x4f, 0xeb, 0xf9, 0xe9, 0xc8, 0x04, 0xc3,
0x91, 0x09, 0xfe, 0x8c, 0x4c, 0xf0, 0x79, 0x6c, 0x66, 0x86, 0x63, 0x33, 0xf3, 0x6b, 0x6c, 0x66,
0xde, 0x34, 0xfe, 0xe9, 0x8c, 0xf7, 0xfa, 0xe2, 0xd0, 0x97, 0x98, 0x34, 0x8a, 0x5b, 0x90, 0x57,
0xc7, 0xc3, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x44, 0x3b, 0x1e, 0xcd, 0xe3, 0x06, 0x00, 0x00,
}
func (m *BaseVestingAccount) Marshal() (dAtA []byte, err error) {
-124
View File
@@ -5,9 +5,7 @@ import (
"time"
"cosmossdk.io/math"
"sigs.k8s.io/yaml"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vestexported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported"
@@ -152,46 +150,6 @@ func (bva BaseVestingAccount) Validate() error {
return bva.BaseAccount.Validate()
}
type vestingAccountYAML struct {
Address sdk.AccAddress `json:"address"`
PubKey string `json:"public_key"`
AccountNumber uint64 `json:"account_number"`
Sequence uint64 `json:"sequence"`
OriginalVesting sdk.Coins `json:"original_vesting"`
DelegatedFree sdk.Coins `json:"delegated_free"`
DelegatedVesting sdk.Coins `json:"delegated_vesting"`
EndTime int64 `json:"end_time"`
// custom fields based on concrete vesting type which can be omitted
StartTime int64 `json:"start_time,omitempty"`
VestingPeriods Periods `json:"vesting_periods,omitempty"`
}
func (bva BaseVestingAccount) String() string {
out, _ := bva.MarshalYAML()
return out.(string)
}
// MarshalYAML returns the YAML representation of a BaseVestingAccount.
func (bva BaseVestingAccount) MarshalYAML() (interface{}, error) {
accAddr, err := sdk.AccAddressFromBech32(bva.Address)
if err != nil {
return nil, err
}
out := vestingAccountYAML{
Address: accAddr,
AccountNumber: bva.AccountNumber,
PubKey: getPKString(bva),
Sequence: bva.Sequence,
OriginalVesting: bva.OriginalVesting,
DelegatedFree: bva.DelegatedFree,
DelegatedVesting: bva.DelegatedVesting,
EndTime: bva.EndTime,
}
return marshalYaml(out)
}
// Continuous Vesting Account
var (
@@ -282,32 +240,6 @@ func (cva ContinuousVestingAccount) Validate() error {
return cva.BaseVestingAccount.Validate()
}
func (cva ContinuousVestingAccount) String() string {
out, _ := cva.MarshalYAML()
return out.(string)
}
// MarshalYAML returns the YAML representation of a ContinuousVestingAccount.
func (cva ContinuousVestingAccount) MarshalYAML() (interface{}, error) {
accAddr, err := sdk.AccAddressFromBech32(cva.Address)
if err != nil {
return nil, err
}
out := vestingAccountYAML{
Address: accAddr,
AccountNumber: cva.AccountNumber,
PubKey: getPKString(cva),
Sequence: cva.Sequence,
OriginalVesting: cva.OriginalVesting,
DelegatedFree: cva.DelegatedFree,
DelegatedVesting: cva.DelegatedVesting,
EndTime: cva.EndTime,
StartTime: cva.StartTime,
}
return marshalYaml(out)
}
// Periodic Vesting Account
var (
@@ -427,33 +359,6 @@ func (pva PeriodicVestingAccount) Validate() error {
return pva.BaseVestingAccount.Validate()
}
func (pva PeriodicVestingAccount) String() string {
out, _ := pva.MarshalYAML()
return out.(string)
}
// MarshalYAML returns the YAML representation of a PeriodicVestingAccount.
func (pva PeriodicVestingAccount) MarshalYAML() (interface{}, error) {
accAddr, err := sdk.AccAddressFromBech32(pva.Address)
if err != nil {
return nil, err
}
out := vestingAccountYAML{
Address: accAddr,
AccountNumber: pva.AccountNumber,
PubKey: getPKString(pva),
Sequence: pva.Sequence,
OriginalVesting: pva.OriginalVesting,
DelegatedFree: pva.DelegatedFree,
DelegatedVesting: pva.DelegatedVesting,
EndTime: pva.EndTime,
StartTime: pva.StartTime,
VestingPeriods: pva.VestingPeriods,
}
return marshalYaml(out)
}
// Delayed Vesting Account
var (
@@ -518,11 +423,6 @@ func (dva DelayedVestingAccount) Validate() error {
return dva.BaseVestingAccount.Validate()
}
func (dva DelayedVestingAccount) String() string {
out, _ := dva.MarshalYAML()
return out.(string)
}
//-----------------------------------------------------------------------------
// Permanent Locked Vesting Account
@@ -586,27 +486,3 @@ func (plva PermanentLockedAccount) Validate() error {
return plva.BaseVestingAccount.Validate()
}
func (plva PermanentLockedAccount) String() string {
out, _ := plva.MarshalYAML()
return out.(string)
}
type getPK interface {
GetPubKey() cryptotypes.PubKey
}
func getPKString(g getPK) string {
if pk := g.GetPubKey(); pk != nil {
return pk.String()
}
return ""
}
func marshalYaml(i interface{}) (interface{}, error) {
bz, err := yaml.Marshal(i)
if err != nil {
return nil, err
}
return string(bz), nil
}