2017-11-13 15:58:36 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
|
|
|
|
"log"
|
|
|
|
|
2017-11-14 15:14:34 +00:00
|
|
|
"fmt"
|
|
|
|
|
2017-12-04 18:54:33 +00:00
|
|
|
"math/big"
|
|
|
|
|
2017-11-13 15:58:36 +00:00
|
|
|
"github.com/8thlight/vulcanizedb/cmd"
|
2017-12-04 21:36:11 +00:00
|
|
|
"github.com/8thlight/vulcanizedb/pkg/contract_summary"
|
2017-11-27 15:21:21 +00:00
|
|
|
"github.com/8thlight/vulcanizedb/pkg/geth"
|
2017-11-13 15:58:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
environment := flag.String("environment", "", "Environment name")
|
|
|
|
contractHash := flag.String("contract-hash", "", "Contract hash to show summary")
|
2017-12-04 18:54:33 +00:00
|
|
|
_blockNumber := flag.Int64("block-number", -1, "Block number of summary")
|
2017-11-13 15:58:36 +00:00
|
|
|
flag.Parse()
|
|
|
|
config := cmd.LoadConfig(*environment)
|
2017-11-27 15:21:21 +00:00
|
|
|
blockchain := geth.NewGethBlockchain(config.Client.IPCPath)
|
2017-12-04 15:53:36 +00:00
|
|
|
repository := cmd.LoadPostgres(config.Database)
|
2017-12-04 18:54:33 +00:00
|
|
|
blockNumber := requestedBlockNumber(_blockNumber)
|
|
|
|
|
2017-12-04 21:36:11 +00:00
|
|
|
contractSummary, err := contract_summary.NewSummary(blockchain, repository, *contractHash, blockNumber)
|
2017-11-13 15:58:36 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
2017-12-04 21:36:11 +00:00
|
|
|
output := contract_summary.GenerateConsoleOutput(contractSummary)
|
2017-11-14 15:14:34 +00:00
|
|
|
fmt.Println(output)
|
2017-11-13 15:58:36 +00:00
|
|
|
}
|
2017-12-04 18:54:33 +00:00
|
|
|
|
|
|
|
func requestedBlockNumber(blockNumber *int64) *big.Int {
|
|
|
|
var _blockNumber *big.Int
|
|
|
|
if *blockNumber == -1 {
|
|
|
|
_blockNumber = nil
|
|
|
|
} else {
|
|
|
|
_blockNumber = big.NewInt(*blockNumber)
|
|
|
|
}
|
|
|
|
return _blockNumber
|
|
|
|
}
|