2022-12-23 17:35:35 +00:00
|
|
|
package frostfscontract
|
2021-06-01 11:35:53 +00:00
|
|
|
|
|
|
|
import (
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
2021-06-01 11:35:53 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
|
|
)
|
|
|
|
|
2022-01-31 10:15:36 +00:00
|
|
|
// ChequePrm groups parameters of Cheque operation.
|
2021-11-10 10:41:27 +00:00
|
|
|
type ChequePrm struct {
|
|
|
|
id []byte
|
|
|
|
user util.Uint160
|
|
|
|
amount int64
|
|
|
|
lock util.Uint160
|
|
|
|
|
|
|
|
client.InvokePrmOptional
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetID sets ID of the cheque.
|
|
|
|
func (c *ChequePrm) SetID(id []byte) {
|
|
|
|
c.id = id
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetUser sets user.
|
|
|
|
func (c *ChequePrm) SetUser(user util.Uint160) {
|
|
|
|
c.user = user
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetAmount sets amount.
|
|
|
|
func (c *ChequePrm) SetAmount(amount int64) {
|
|
|
|
c.amount = amount
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetLock sets lock.
|
|
|
|
func (c *ChequePrm) SetLock(lock util.Uint160) {
|
|
|
|
c.lock = lock
|
|
|
|
}
|
|
|
|
|
2023-02-05 15:59:38 +00:00
|
|
|
// Cheque invokes `cheque` method of FrostFS contract.
|
2022-01-31 10:15:36 +00:00
|
|
|
func (x *Client) Cheque(p ChequePrm) error {
|
2021-11-09 20:52:29 +00:00
|
|
|
prm := client.InvokePrm{}
|
2022-01-29 13:06:36 +00:00
|
|
|
prm.SetMethod(chequeMethod)
|
2022-03-31 08:08:27 +00:00
|
|
|
prm.SetArgs(p.id, p.user, p.amount, p.lock)
|
2022-01-31 10:15:36 +00:00
|
|
|
prm.InvokePrmOptional = p.InvokePrmOptional
|
2021-11-09 20:52:29 +00:00
|
|
|
|
2023-11-07 15:13:26 +00:00
|
|
|
_, err := x.client.Invoke(prm)
|
|
|
|
return err
|
2021-06-01 11:35:53 +00:00
|
|
|
}
|
|
|
|
|
2022-01-31 10:15:36 +00:00
|
|
|
// AlphabetUpdatePrm groups parameters of AlphabetUpdate operation.
|
2021-11-10 10:41:27 +00:00
|
|
|
type AlphabetUpdatePrm struct {
|
|
|
|
id []byte
|
|
|
|
pubs keys.PublicKeys
|
|
|
|
|
|
|
|
client.InvokePrmOptional
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetID sets update ID.
|
|
|
|
func (a *AlphabetUpdatePrm) SetID(id []byte) {
|
|
|
|
a.id = id
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetPubs sets new alphabet public keys.
|
|
|
|
func (a *AlphabetUpdatePrm) SetPubs(pubs keys.PublicKeys) {
|
|
|
|
a.pubs = pubs
|
|
|
|
}
|
|
|
|
|
2021-06-01 11:35:53 +00:00
|
|
|
// AlphabetUpdate update list of alphabet nodes.
|
2022-01-31 10:15:36 +00:00
|
|
|
func (x *Client) AlphabetUpdate(p AlphabetUpdatePrm) error {
|
2021-11-09 20:52:29 +00:00
|
|
|
prm := client.InvokePrm{}
|
2022-01-29 13:06:36 +00:00
|
|
|
prm.SetMethod(alphabetUpdateMethod)
|
2022-01-31 10:15:36 +00:00
|
|
|
prm.SetArgs(p.id, p.pubs)
|
|
|
|
prm.InvokePrmOptional = p.InvokePrmOptional
|
2021-11-09 20:52:29 +00:00
|
|
|
|
2023-11-07 15:13:26 +00:00
|
|
|
_, err := x.client.Invoke(prm)
|
|
|
|
return err
|
2021-06-01 11:35:53 +00:00
|
|
|
}
|