2022-01-31 09:24:25 +00:00
|
|
|
package balance
|
|
|
|
|
|
|
|
import (
|
2024-10-21 13:27:28 +00:00
|
|
|
"context"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
2022-01-31 09:24:25 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
|
|
)
|
|
|
|
|
|
|
|
// LockPrm groups parameters of Lock operation.
|
|
|
|
type LockPrm struct {
|
|
|
|
id []byte
|
|
|
|
user util.Uint160
|
|
|
|
lock util.Uint160
|
|
|
|
amount int64
|
|
|
|
dueEpoch int64
|
|
|
|
|
|
|
|
client.InvokePrmOptional
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetID sets ID.
|
|
|
|
func (l *LockPrm) SetID(id []byte) {
|
|
|
|
l.id = id
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetUser set user.
|
|
|
|
func (l *LockPrm) SetUser(user util.Uint160) {
|
|
|
|
l.user = user
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetLock sets lock.
|
|
|
|
func (l *LockPrm) SetLock(lock util.Uint160) {
|
|
|
|
l.lock = lock
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetAmount sets amount.
|
|
|
|
func (l *LockPrm) SetAmount(amount int64) {
|
|
|
|
l.amount = amount
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetDueEpoch sets end of the lock.
|
|
|
|
func (l *LockPrm) SetDueEpoch(dueEpoch int64) {
|
|
|
|
l.dueEpoch = dueEpoch
|
|
|
|
}
|
|
|
|
|
|
|
|
// Lock locks fund on the user account.
|
2024-10-21 13:27:28 +00:00
|
|
|
func (c *Client) Lock(ctx context.Context, p LockPrm) error {
|
2022-01-31 09:24:25 +00:00
|
|
|
prm := client.InvokePrm{}
|
|
|
|
prm.SetMethod(lockMethod)
|
2022-03-31 08:08:27 +00:00
|
|
|
prm.SetArgs(p.id, p.user, p.lock, p.amount, p.dueEpoch)
|
2022-01-31 09:24:25 +00:00
|
|
|
prm.InvokePrmOptional = p.InvokePrmOptional
|
|
|
|
|
2024-10-21 13:27:28 +00:00
|
|
|
_, err := c.client.Invoke(ctx, prm)
|
2023-11-07 15:13:26 +00:00
|
|
|
return err
|
2022-01-31 09:24:25 +00:00
|
|
|
}
|