2021-05-19 09:21:33 +00:00
|
|
|
package neofsid
|
|
|
|
|
|
|
|
import (
|
2021-05-19 12:46:45 +00:00
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
2021-05-19 09:21:33 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/neofsid"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ClientWrapper is a wrapper over NeoFS ID contract
|
|
|
|
// client which provides convenient methods for
|
|
|
|
// working with a contract.
|
|
|
|
//
|
|
|
|
// Working ClientWrapper must be created via Wrap.
|
|
|
|
type ClientWrapper neofsid.Client
|
|
|
|
|
2021-05-19 12:46:45 +00:00
|
|
|
// NewFromMorph wraps client to work with NeoFS ID contract.
|
|
|
|
func NewFromMorph(cli *client.Client, contract util.Uint160, fee fixedn.Fixed8) (*ClientWrapper, error) {
|
|
|
|
sc, err := client.NewStatic(cli, contract, fee)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("could not create client of NeoFS ID contract: %w", err)
|
2021-05-19 09:21:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 12:46:45 +00:00
|
|
|
return (*ClientWrapper)(neofsid.New(sc)), nil
|
2021-05-19 09:21:33 +00:00
|
|
|
}
|