forked from TrueCloudLab/frostfs-node
[#496] morph/client: add wrapper for neofs contract
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
458fc4f5ae
commit
16e9e726ff
8 changed files with 66 additions and 45 deletions
16
pkg/morph/client/neofs/cheque.go
Normal file
16
pkg/morph/client/neofs/cheque.go
Normal 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)
|
||||
}
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
17
pkg/morph/client/neofs/wrapper/cheque.go
Normal file
17
pkg/morph/client/neofs/wrapper/cheque.go
Normal 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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue