github.com/cosmos/cosmos-sdk@v0.50.10/x/gov/types/v1/deposit.go (about) 1 package v1 2 3 import ( 4 "fmt" 5 6 sdk "github.com/cosmos/cosmos-sdk/types" 7 ) 8 9 // NewDeposit creates a new Deposit instance 10 func NewDeposit(proposalID uint64, depositor sdk.AccAddress, amount sdk.Coins) Deposit { 11 return Deposit{proposalID, depositor.String(), amount} 12 } 13 14 // Deposits is a collection of Deposit objects 15 type Deposits []*Deposit 16 17 // Equal returns true if two slices (order-dependant) of deposits are equal. 18 func (d Deposits) Equal(other Deposits) bool { 19 if len(d) != len(other) { 20 return false 21 } 22 23 for i, deposit := range d { 24 if deposit.String() != other[i].String() { 25 return false 26 } 27 } 28 29 return true 30 } 31 32 // String implements stringer interface 33 func (d Deposits) String() string { 34 if len(d) == 0 { 35 return "[]" 36 } 37 out := fmt.Sprintf("Deposits for Proposal %d:", d[0].ProposalId) 38 for _, dep := range d { 39 out += fmt.Sprintf("\n %s: %s", dep.Depositor, dep.Amount) 40 } 41 return out 42 }