This commit is contained in:
Slavomir 2021-08-09 16:18:05 +02:00
parent 3af5c3d17a
commit 9a0d5212b1
2 changed files with 14 additions and 18 deletions

View File

@ -46,7 +46,7 @@ func (inst *Transfer) EncodeToTree(parent treeout.Branches) {
instructionBranch.Child("Params").ParentFunc(func(paramsBranch treeout.Branches) { instructionBranch.Child("Params").ParentFunc(func(paramsBranch treeout.Branches) {
paramsBranch.Child(Sf(CC(Shakespeare("Lamports"), ": %v"), Lime(S(inst.Lamports)))) paramsBranch.Child(Sf(CC(Shakespeare("Lamports"), ": %v"), Lime(S(inst.Lamports))))
}) })
instructionBranch.Child("Accounts:").ParentFunc(func(accountsBranch treeout.Branches) { instructionBranch.Child("Accounts").ParentFunc(func(accountsBranch treeout.Branches) {
accountsBranch.Child(Sf(CC(Shakespeare("Funding account"), ": %s"), text.ColorizeBG(inst.AccountMetaSlice[0].PublicKey.String()))) accountsBranch.Child(Sf(CC(Shakespeare("Funding account"), ": %s"), text.ColorizeBG(inst.AccountMetaSlice[0].PublicKey.String())))
accountsBranch.Child(Sf(CC(Shakespeare("Recipient account"), ": %s"), text.ColorizeBG(inst.AccountMetaSlice[1].PublicKey.String()))) accountsBranch.Child(Sf(CC(Shakespeare("Recipient account"), ": %s"), text.ColorizeBG(inst.AccountMetaSlice[1].PublicKey.String())))
}) })

View File

@ -59,28 +59,24 @@ type Message struct {
Instructions []CompiledInstruction `json:"instructions"` Instructions []CompiledInstruction `json:"instructions"`
} }
func (mx *Message) EncodeToTree(parent treeout.Branches) { func (mx *Message) EncodeToTree(txTree treeout.Branches) {
parent.ParentFunc(func(txTree treeout.Branches) { txTree.Child(text.Sf("RecentBlockhash: %s", mx.RecentBlockhash))
txTree.Child(text.Sf("RecentBlockhash: %s", mx.RecentBlockhash))
txTree.Child("AccountKeys[]").ParentFunc(func(accountKeysBranch treeout.Branches) { txTree.Child("AccountKeys[]").ParentFunc(func(accountKeysBranch treeout.Branches) {
for _, key := range mx.AccountKeys { for _, key := range mx.AccountKeys {
accountKeysBranch.Child(text.ColorizeBG(key.String())) accountKeysBranch.Child(text.ColorizeBG(key.String()))
} }
}) })
txTree.Child("Header").ParentFunc(func(message treeout.Branches) { txTree.Child("Header").ParentFunc(func(message treeout.Branches) {
mx.Header.EncodeToTree(message) mx.Header.EncodeToTree(message)
})
}) })
} }
func (header *MessageHeader) EncodeToTree(parent treeout.Branches) { func (header *MessageHeader) EncodeToTree(mxBranch treeout.Branches) {
parent.ParentFunc(func(mxBranch treeout.Branches) { mxBranch.Child(text.Sf("NumRequiredSignatures: %v", header.NumRequiredSignatures))
mxBranch.Child(text.Sf("NumRequiredSignatures: %v", header.NumRequiredSignatures)) mxBranch.Child(text.Sf("NumReadonlySignedAccounts: %v", header.NumReadonlySignedAccounts))
mxBranch.Child(text.Sf("NumReadonlySignedAccounts: %v", header.NumReadonlySignedAccounts)) mxBranch.Child(text.Sf("NumReadonlyUnsignedAccounts: %v", header.NumReadonlyUnsignedAccounts))
mxBranch.Child(text.Sf("NumReadonlyUnsignedAccounts: %v", header.NumReadonlyUnsignedAccounts))
})
} }
func (mx *Message) MarshalBinary() ([]byte, error) { func (mx *Message) MarshalBinary() ([]byte, error) {