[#496] morph/client: add wrapper for neofs contract

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2021-06-01 14:35:53 +03:00 committed by Alex Vanin
parent 458fc4f5ae
commit 16e9e726ff
8 changed files with 66 additions and 45 deletions

View file

@ -0,0 +1,16 @@
package neofscontract
import (
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/util"
)
// Cheque invokes `cheque` method of NeoFS contract.
func (x *Client) Cheque(id []byte, user util.Uint160, amount int64, lock util.Uint160) error {
return x.client.Invoke(x.chequeMethod, id, user.BytesBE(), amount, lock.BytesBE())
}
// AlphabetUpdate update list of alphabet nodes.
func (x *Client) AlphabetUpdate(id []byte, pubs keys.PublicKeys) error {
return x.client.Invoke(x.alphabetUpdateMethod, id, pubs)
}

View file

@ -22,19 +22,25 @@ type Client struct {
type Option func(*cfg)
type cfg struct {
alphabetUpdateMethod,
chequeMethod,
bindKeysMethod,
unbindKeysMethod string
}
func defaultConfig() *cfg {
const (
defaultBindKeysMethod = "bind"
defaultUnbindKeysMethod = "unbind"
defaultBindKeysMethod = "bind"
defaultUnbindKeysMethod = "unbind"
defaultAlphabetUpdateMethod = "alphabetUpdate"
defaultChequeMethod = "cheque"
)
return &cfg{
bindKeysMethod: defaultBindKeysMethod,
unbindKeysMethod: defaultUnbindKeysMethod,
alphabetUpdateMethod: defaultAlphabetUpdateMethod,
chequeMethod: defaultChequeMethod,
bindKeysMethod: defaultBindKeysMethod,
unbindKeysMethod: defaultUnbindKeysMethod,
}
}

View file

@ -0,0 +1,17 @@
package neofscontract
import (
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/util"
neofscontract "github.com/nspcc-dev/neofs-node/pkg/morph/client/neofs"
)
// Cheque invokes `cheque` method of NeoFS contract.
func (x *ClientWrapper) Cheque(id []byte, user util.Uint160, amount int64, lock util.Uint160) error {
return (*neofscontract.Client)(x).Cheque(id, user, amount, lock)
}
// AlphabetUpdate update list of alphabet nodes.
func (x *ClientWrapper) AlphabetUpdate(id []byte, pubs keys.PublicKeys) error {
return (*neofscontract.Client)(x).AlphabetUpdate(id, pubs)
}