Add getter to AccountMetaSlice

This commit is contained in:
gagliardetto 2022-01-31 21:44:51 +01:00
parent 838b9c4428
commit 4a1d072b7a
2 changed files with 12 additions and 0 deletions

View File

@ -120,6 +120,15 @@ func (slice AccountMetaSlice) GetAccounts() (out []*AccountMeta) {
return out
}
// Get returns the AccountMeta at the desired index.
// If the index is not present, it returns nil.
func (slice AccountMetaSlice) Get(index int) *AccountMeta {
if len(slice) > index {
return slice[index]
}
return nil
}
// GetSigners returns the accounts that are signers.
func (slice AccountMetaSlice) GetSigners() []*AccountMeta {
signers := make([]*AccountMeta, 0)

View File

@ -48,6 +48,9 @@ func Account(name string, pubKey solana.PublicKey) string {
}
func Meta(name string, meta *solana.AccountMeta) string {
if meta == nil {
return Shakespeare(name) + ": " + "<nil>"
}
out := Shakespeare(name) + ": " + text.ColorizeBG(meta.PublicKey.String())
out += " ["
if meta.IsWritable {