77
88 "github.com/tendermint/tendermint/crypto"
99
10- "github.com/cosmos/cosmos-sdk/codec"
1110 sdk "github.com/cosmos/cosmos-sdk/types"
1211)
1312
@@ -62,6 +61,7 @@ type VestingAccount interface {
6261}
6362
6463// AccountDecoder unmarshals account bytes
64+ // TODO: Think about removing
6565type AccountDecoder func (accountBytes []byte ) (Account , error )
6666
6767//-----------------------------------------------------------------------------
@@ -90,32 +90,33 @@ func (acc BaseAccount) String() string {
9090 }
9191
9292 return fmt .Sprintf (`Account:
93- Address: %s
94- Pubkey: %s
93+ Address: %s
94+ Pubkey: %s
9595 Coins: %s
9696 AccountNumber: %d
9797 Sequence: %d` ,
9898 acc .Address , pubkey , acc .Coins , acc .AccountNumber , acc .Sequence ,
9999 )
100100}
101101
102- // Prototype function for BaseAccount
102+ // ProtoBaseAccount - a prototype function for BaseAccount
103103func ProtoBaseAccount () Account {
104104 return & BaseAccount {}
105105}
106106
107+ // NewBaseAccountWithAddress - returns a new base account with a given address
107108func NewBaseAccountWithAddress (addr sdk.AccAddress ) BaseAccount {
108109 return BaseAccount {
109110 Address : addr ,
110111 }
111112}
112113
113- // Implements sdk.Account.
114+ // GetAddress - Implements sdk.Account.
114115func (acc BaseAccount ) GetAddress () sdk.AccAddress {
115116 return acc .Address
116117}
117118
118- // Implements sdk.Account.
119+ // SetAddress - Implements sdk.Account.
119120func (acc * BaseAccount ) SetAddress (addr sdk.AccAddress ) error {
120121 if len (acc .Address ) != 0 {
121122 return errors .New ("cannot override BaseAccount address" )
@@ -124,45 +125,45 @@ func (acc *BaseAccount) SetAddress(addr sdk.AccAddress) error {
124125 return nil
125126}
126127
127- // Implements sdk.Account.
128+ // GetPubKey - Implements sdk.Account.
128129func (acc BaseAccount ) GetPubKey () crypto.PubKey {
129130 return acc .PubKey
130131}
131132
132- // Implements sdk.Account.
133+ // SetPubKey - Implements sdk.Account.
133134func (acc * BaseAccount ) SetPubKey (pubKey crypto.PubKey ) error {
134135 acc .PubKey = pubKey
135136 return nil
136137}
137138
138- // Implements sdk.Account.
139+ // GetCoins - Implements sdk.Account.
139140func (acc * BaseAccount ) GetCoins () sdk.Coins {
140141 return acc .Coins
141142}
142143
143- // Implements sdk.Account.
144+ // SetCoins - Implements sdk.Account.
144145func (acc * BaseAccount ) SetCoins (coins sdk.Coins ) error {
145146 acc .Coins = coins
146147 return nil
147148}
148149
149- // Implements Account
150+ // GetAccountNumber - Implements Account
150151func (acc * BaseAccount ) GetAccountNumber () uint64 {
151152 return acc .AccountNumber
152153}
153154
154- // Implements Account
155+ // SetAccountNumber - Implements Account
155156func (acc * BaseAccount ) SetAccountNumber (accNumber uint64 ) error {
156157 acc .AccountNumber = accNumber
157158 return nil
158159}
159160
160- // Implements sdk.Account.
161+ // GetSequence - Implements sdk.Account.
161162func (acc * BaseAccount ) GetSequence () uint64 {
162163 return acc .Sequence
163164}
164165
165- // Implements sdk.Account.
166+ // SetSequence - Implements sdk.Account.
166167func (acc * BaseAccount ) SetSequence (seq uint64 ) error {
167168 acc .Sequence = seq
168169 return nil
@@ -198,8 +199,8 @@ func (bva BaseVestingAccount) String() string {
198199 }
199200
200201 return fmt .Sprintf (`Vesting Account:
201- Address: %s
202- Pubkey: %s
202+ Address: %s
203+ Pubkey: %s
203204 Coins: %s
204205 AccountNumber: %d
205206 Sequence: %d
@@ -345,6 +346,7 @@ type ContinuousVestingAccount struct {
345346 StartTime int64 // when the coins start to vest
346347}
347348
349+ // NewContinuousVestingAccount returns a new ContinuousVestingAccount
348350func NewContinuousVestingAccount (
349351 baseAcc * BaseAccount , StartTime , EndTime int64 ,
350352) * ContinuousVestingAccount {
@@ -369,8 +371,8 @@ func (cva ContinuousVestingAccount) String() string {
369371 }
370372
371373 return fmt .Sprintf (`Continuous Vesting Account:
372- Address: %s
373- Pubkey: %s
374+ Address: %s
375+ Pubkey: %s
374376 Coins: %s
375377 AccountNumber: %d
376378 Sequence: %d
@@ -454,6 +456,7 @@ type DelayedVestingAccount struct {
454456 * BaseVestingAccount
455457}
456458
459+ // NewDelayedVestingAccount returns a DelayedVestingAccount
457460func NewDelayedVestingAccount (baseAcc * BaseAccount , EndTime int64 ) * DelayedVestingAccount {
458461 baseVestingAcc := & BaseVestingAccount {
459462 BaseAccount : baseAcc ,
@@ -502,17 +505,3 @@ func (dva *DelayedVestingAccount) GetStartTime() int64 {
502505func (dva * DelayedVestingAccount ) GetEndTime () int64 {
503506 return dva .EndTime
504507}
505-
506- //-----------------------------------------------------------------------------
507- // Codec
508-
509- // Most users shouldn't use this, but this comes in handy for tests.
510- func RegisterBaseAccount (cdc * codec.Codec ) {
511- cdc .RegisterInterface ((* Account )(nil ), nil )
512- cdc .RegisterInterface ((* VestingAccount )(nil ), nil )
513- cdc .RegisterConcrete (& BaseAccount {}, "cosmos-sdk/BaseAccount" , nil )
514- cdc .RegisterConcrete (& BaseVestingAccount {}, "cosmos-sdk/BaseVestingAccount" , nil )
515- cdc .RegisterConcrete (& ContinuousVestingAccount {}, "cosmos-sdk/ContinuousVestingAccount" , nil )
516- cdc .RegisterConcrete (& DelayedVestingAccount {}, "cosmos-sdk/DelayedVestingAccount" , nil )
517- codec .RegisterCrypto (cdc )
518- }
0 commit comments