instructions not associated with a decoder are now printed as `raw` instruction

This commit is contained in:
billettc 2020-11-19 08:10:03 -05:00
parent 638620d64d
commit eb1b3801e3
2 changed files with 15 additions and 1 deletions

View File

@ -61,10 +61,22 @@ var getTransactionsCmd = &cobra.Command{
fmt.Print("\nInstructions:\n-------------\n\n")
for _, i := range ct.Transaction.Message.Instructions {
//Missing Initial account instruction ??????
id, err := ct.Transaction.ResolveProgramIDIndex(i.ProgramIDIndex)
errorCheck("resolving programID", err)
decoder := solana.InstructionDecoderRegistry[id.String()]
if decoder == nil {
fmt.Println("raw instruction:")
fmt.Printf("Program: %s Data: %s\n", id.String(), i.Data)
fmt.Println("Accounts:")
for _, accIndex := range i.Accounts {
key := ct.Transaction.Message.AccountKeys[accIndex]
fmt.Printf("%s Is Writable: %t Is Signer: %t\n", key.String(), ct.Transaction.IsWritable(key), ct.Transaction.IsSigner(key))
}
fmt.Printf("\n\n")
continue
}

View File

@ -132,7 +132,9 @@ func (a *NewOrderAccounts) String() string {
out += a.PCVault.String() + " PCVault\n"
out += a.SPLTokenProgram.String() + " SPLTokenProgram\n"
out += a.Rent.String() + " Rent\n"
out += a.SRMDiscountAccount.String() + " SRMDiscountAccount"
if a.SRMDiscountAccount != nil {
out += a.SRMDiscountAccount.String() + " SRMDiscountAccount"
}
return out
}