Require ABI filepath for watching a contract
This commit is contained in:
@@ -10,8 +10,13 @@ import (
|
||||
func main() {
|
||||
environment := flag.String("environment", "", "Environment name")
|
||||
contractHash := flag.String("contract-hash", "", "contract-hash=x1234")
|
||||
abiFilepath := flag.String("abi-filepath", "", "path/to/abifile.json")
|
||||
flag.Parse()
|
||||
config := cmd.LoadConfig(*environment)
|
||||
repository := cmd.LoadPostgres(config.Database)
|
||||
repository.CreateWatchedContract(repositories.WatchedContract{Hash: *contractHash})
|
||||
watchedContract := repositories.WatchedContract{
|
||||
Abi: cmd.ReadAbiFile(*abiFilepath),
|
||||
Hash: *contractHash,
|
||||
}
|
||||
repository.CreateWatchedContract(watchedContract)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,10 @@ package cmd
|
||||
import (
|
||||
"log"
|
||||
|
||||
"path/filepath"
|
||||
|
||||
"github.com/8thlight/vulcanizedb/pkg/config"
|
||||
"github.com/8thlight/vulcanizedb/pkg/geth"
|
||||
"github.com/8thlight/vulcanizedb/pkg/repositories"
|
||||
)
|
||||
|
||||
@@ -22,3 +25,14 @@ func LoadPostgres(database config.Database) repositories.Postgres {
|
||||
}
|
||||
return repository
|
||||
}
|
||||
|
||||
func ReadAbiFile(abiFilepath string) string {
|
||||
if !filepath.IsAbs(abiFilepath) {
|
||||
abiFilepath = filepath.Join(config.ProjectRoot(), abiFilepath)
|
||||
}
|
||||
abi, err := geth.ReadAbiFile(abiFilepath)
|
||||
if err != nil {
|
||||
log.Fatalf("Error reading ABI file at \"%s\"\n %v", abiFilepath, err)
|
||||
}
|
||||
return abi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user