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"
|
|
|
|
)
|
|
|
|
|
|
|
|
// BurnPrm groups parameters of Burn operation.
|
|
|
|
type BurnPrm struct {
|
|
|
|
to util.Uint160
|
|
|
|
amount int64
|
|
|
|
id []byte
|
|
|
|
|
|
|
|
client.InvokePrmOptional
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetTo sets receiver.
|
|
|
|
func (b *BurnPrm) SetTo(to util.Uint160) {
|
|
|
|
b.to = to
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetAmount sets amount.
|
|
|
|
func (b *BurnPrm) SetAmount(amount int64) {
|
|
|
|
b.amount = amount
|
|
|
|
}
|
|
|
|
|
2022-10-17 12:03:55 +00:00
|
|
|
// SetID sets ID.
|
2022-01-31 09:24:25 +00:00
|
|
|
func (b *BurnPrm) SetID(id []byte) {
|
|
|
|
b.id = id
|
|
|
|
}
|
|
|
|
|
|
|
|
// Burn destroys funds from the account.
|
2024-10-21 13:27:28 +00:00
|
|
|
func (c *Client) Burn(ctx context.Context, p BurnPrm) error {
|
2022-01-31 09:24:25 +00:00
|
|
|
prm := client.InvokePrm{}
|
|
|
|
prm.SetMethod(burnMethod)
|
2022-03-31 08:08:27 +00:00
|
|
|
prm.SetArgs(p.to, p.amount, p.id)
|
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
|
|
|
}
|