diff --git a/scripts/compare-deposits/compare-deposits.go b/scripts/compare-deposits/compare-deposits.go index db12f60c..8a57acce 100644 --- a/scripts/compare-deposits/compare-deposits.go +++ b/scripts/compare-deposits/compare-deposits.go @@ -3,6 +3,7 @@ package main import ( "context" "errors" + "flag" "fmt" "math/big" "os" @@ -19,7 +20,6 @@ import ( "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neofs-contract/rpc/nns" - "github.com/urfave/cli" ) func initClient(addr string, name string) (*rpcclient.Client, error) { @@ -58,28 +58,47 @@ func getSupply(c *rpcclient.Client, h util.Uint160, height uint32) int64 { return s.Int64() } -func cliMain(c *cli.Context) error { - rpcMain := c.Args().Get(0) - neoFSContract := c.Args().Get(1) - rpcFS := c.Args().Get(2) - if rpcMain == "" { - return errors.New("no arguments given") +var ( + compareDepositsRPCMainAddress string + compareDepositsNeoFSContractAddress string + compareDepositsRPCFSAddress string +) + +func init() { + flag.StringVar(&compareDepositsRPCMainAddress, "mainnet", "", "RPC mainnet address") + flag.StringVar(&compareDepositsNeoFSContractAddress, "fs-contract", "", "NeoFS contract address") + flag.StringVar(&compareDepositsRPCFSAddress, "fschain", "", "RPC FS chain address") +} + +func validateFlags() error { + if compareDepositsRPCMainAddress == "" { + return errors.New("RPC mainnet address need to be provided") + } + if compareDepositsNeoFSContractAddress == "" { + return errors.New("NeoFS contract address need to be provided") } - if neoFSContract == "" { - return errors.New("missing second argument") + if compareDepositsRPCFSAddress == "" { + return errors.New("RPC FS chain address need to be provided") } - if rpcFS == "" { - return errors.New("missing third argument") + return nil +} + +func cliMain() error { + flag.Parse() + + if err := validateFlags(); err != nil { + return err } - fsCont, err := address.StringToUint160(neoFSContract) + + fsCont, err := address.StringToUint160(compareDepositsNeoFSContractAddress) if err != nil { return fmt.Errorf("bad contract address: %w", err) } - cMain, err := initClient(rpcMain, "main") + cMain, err := initClient(compareDepositsRPCMainAddress, "main") if err != nil { return err } - cFS, err := initClient(rpcFS, "FS") + cFS, err := initClient(compareDepositsRPCFSAddress, "FS") if err != nil { return err } @@ -227,13 +246,7 @@ func cliMain(c *cli.Context) error { } func main() { - ctl := cli.NewApp() - ctl.Name = "compare-deposits" - ctl.Version = "1.0" - ctl.Usage = "compare-deposits RPC_MAIN NEOFS_CONTRACT_ADDRESS RPC_FS" - ctl.Action = cliMain - - if err := ctl.Run(os.Args); err != nil { + if err := cliMain(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } diff --git a/scripts/compare-deposits/go.mod b/scripts/compare-deposits/go.mod index c3e3baad..5db62664 100644 --- a/scripts/compare-deposits/go.mod +++ b/scripts/compare-deposits/go.mod @@ -5,13 +5,11 @@ go 1.22 require ( github.com/nspcc-dev/neo-go v0.106.3 github.com/nspcc-dev/neofs-contract v0.20.0 - github.com/urfave/cli v1.22.15 ) require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/golang/snappy v0.0.1 // indirect github.com/google/uuid v1.6.0 // indirect @@ -26,7 +24,6 @@ require ( github.com/prometheus/client_model v0.5.0 // indirect github.com/prometheus/common v0.48.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect - github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954 // indirect github.com/twmb/murmur3 v1.1.8 // indirect go.etcd.io/bbolt v1.3.9 // indirect diff --git a/scripts/compare-deposits/go.sum b/scripts/compare-deposits/go.sum index 0aef104e..f715bfbd 100644 --- a/scripts/compare-deposits/go.sum +++ b/scripts/compare-deposits/go.sum @@ -1,4 +1,3 @@ -github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bits-and-blooms/bitset v1.8.0 h1:FD+XqgOZDUxxZ8hzoBFuV9+cGWY9CslN6d5MS5JVb4c= @@ -11,7 +10,6 @@ github.com/consensys/gnark-crypto v0.12.2-0.20231013160410-1f65e75b6dfb h1:f0BMg github.com/consensys/gnark-crypto v0.12.2-0.20231013160410-1f65e75b6dfb/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= @@ -87,21 +85,12 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954 h1:xQdMZ1WLrgkkvOZ/LDQxjVxMLdby7osSh4ZEVa5sIjs= github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM= github.com/twmb/murmur3 v1.1.8 h1:8Yt9taO/WN3l08xErzjeschgZU2QSrwm1kclYq+0aRg= github.com/twmb/murmur3 v1.1.8/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ= -github.com/urfave/cli v1.22.15 h1:nuqt+pdC/KqswQKhETJjo7pvn/k4xMUxgW6liI7XpnM= -github.com/urfave/cli v1.22.15/go.mod h1:wSan1hmo5zeyLGBjRJbzRTNk8gwoYa2B9n4q9dmRIc0= github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI= github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM= github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw= @@ -171,7 +160,6 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU=