2021-07-19 11:04:19 +00:00
|
|
|
package morph
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-10-18 12:20:04 +00:00
|
|
|
"errors"
|
2021-07-19 11:04:19 +00:00
|
|
|
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
|
|
|
func getN3Client(v *viper.Viper) (*client.Client, error) {
|
|
|
|
ctx := context.Background() // FIXME(@fyrchik): timeout context
|
|
|
|
endpoint := v.GetString(endpointFlag)
|
2021-10-18 12:20:04 +00:00
|
|
|
if endpoint == "" {
|
|
|
|
return nil, errors.New("missing endpoint")
|
|
|
|
}
|
2021-07-19 11:04:19 +00:00
|
|
|
c, err := client.New(ctx, endpoint, client.Options{})
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if err := c.Init(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return c, nil
|
|
|
|
}
|