/
mint_operation.go
50 lines (43 loc) · 1.09 KB
/
mint_operation.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
42
43
44
45
46
47
48
49
50
package nftfx
import (
"errors"
"github.com/ava-labs/gecko/vms/components/verify"
"github.com/ava-labs/gecko/vms/secp256k1fx"
)
var (
errNilMintOperation = errors.New("nil mint operation")
)
// MintOperation ...
type MintOperation struct {
MintInput secp256k1fx.Input `serialize:"true" json:"mintInput"`
GroupID uint32 `serialize:"true" json:"groupID"`
Payload []byte `serialize:"true" json:"payload"`
Outputs []*secp256k1fx.OutputOwners `serialize:"true" json:"outputs"`
}
// Outs ...
func (op *MintOperation) Outs() []verify.State {
outs := []verify.State{}
for _, out := range op.Outputs {
outs = append(outs, &TransferOutput{
GroupID: op.GroupID,
Payload: op.Payload,
OutputOwners: *out,
})
}
return outs
}
// Verify ...
func (op *MintOperation) Verify() error {
switch {
case op == nil:
return errNilMintOperation
case len(op.Payload) > MaxPayloadSize:
return errPayloadTooLarge
}
for _, out := range op.Outputs {
if err := out.Verify(); err != nil {
return err
}
}
return op.MintInput.Verify()
}