-
Notifications
You must be signed in to change notification settings - Fork 670
/
transfer_output.go
41 lines (33 loc) · 1.06 KB
/
transfer_output.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package nftfx
import (
"errors"
"github.com/ava-labs/avalanchego/vms/types"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/vms/components/verify"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"
)
const (
// MaxPayloadSize is the maximum size that can be placed into a payload
MaxPayloadSize = units.KiB
)
var (
errNilTransferOutput = errors.New("nil transfer output")
errPayloadTooLarge = errors.New("payload too large")
_ verify.State = &TransferOutput{}
)
type TransferOutput struct {
GroupID uint32 `serialize:"true" json:"groupID"`
Payload types.JSONByteSlice `serialize:"true" json:"payload"`
secp256k1fx.OutputOwners `serialize:"true"`
}
func (out *TransferOutput) Verify() error {
switch {
case out == nil:
return errNilTransferOutput
case len(out.Payload) > MaxPayloadSize:
return errPayloadTooLarge
default:
return out.OutputOwners.Verify()
}
}
func (out *TransferOutput) VerifyState() error { return out.Verify() }