2017-11-14 15:14:34 +00:00
|
|
|
package watched_contracts
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/8thlight/vulcanizedb/pkg/core"
|
|
|
|
)
|
|
|
|
|
|
|
|
func GenerateConsoleOutput(summary *ContractSummary) string {
|
|
|
|
return fmt.Sprintf(template(),
|
|
|
|
summary.ContractHash,
|
2017-11-27 15:21:21 +00:00
|
|
|
summary.GetStateAttribute("name"),
|
2017-11-14 15:14:34 +00:00
|
|
|
summary.NumberOfTransactions,
|
|
|
|
transactionToString(summary.LastTransaction),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func template() string {
|
|
|
|
return `********************Contract Summary***********************
|
2017-11-27 14:54:30 +00:00
|
|
|
HASH: %v
|
2017-11-27 15:21:21 +00:00
|
|
|
NAME: %s
|
2017-11-27 14:54:30 +00:00
|
|
|
NUMBER OF TRANSACTIONS: %d
|
|
|
|
LAST TRANSACTION:
|
|
|
|
%s
|
2017-11-14 15:14:34 +00:00
|
|
|
`
|
|
|
|
}
|
|
|
|
|
|
|
|
func transactionToString(transaction *core.Transaction) string {
|
|
|
|
if transaction == nil {
|
|
|
|
return "NONE"
|
|
|
|
} else {
|
|
|
|
return fmt.Sprintf(`Hash: %s
|
2017-11-27 14:54:30 +00:00
|
|
|
To: %s
|
|
|
|
From: %s`, transaction.Hash, transaction.To, transaction.From)
|
2017-11-14 15:14:34 +00:00
|
|
|
}
|
|
|
|
}
|