Add String() method to Transaction type

This commit is contained in:
gagliardetto 2022-02-09 00:23:00 +01:00
parent 965a81dfc1
commit 3db9225618
1 changed files with 10 additions and 0 deletions

View File

@ -18,6 +18,7 @@
package solana package solana
import ( import (
"bytes"
"errors" "errors"
"fmt" "fmt"
"sort" "sort"
@ -351,6 +352,15 @@ func (tx *Transaction) EncodeTree(encoder *text.TreeEncoder) (int, error) {
return encoder.WriteString(encoder.Tree.String()) return encoder.WriteString(encoder.Tree.String())
} }
func (tx *Transaction) String() string {
buf := new(bytes.Buffer)
_, err := tx.EncodeTree(text.NewTreeEncoder(buf, text.Bold("")))
if err != nil {
panic(err)
}
return buf.String()
}
func (tx *Transaction) EncodeToTree(parent treeout.Branches) { func (tx *Transaction) EncodeToTree(parent treeout.Branches) {
parent.ParentFunc(func(txTree treeout.Branches) { parent.ParentFunc(func(txTree treeout.Branches) {