-
Notifications
You must be signed in to change notification settings - Fork 668
/
mint_operation.go
45 lines (36 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
// Copyright (C) 2019-2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package propertyfx
import (
"errors"
"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/avalanchego/vms/components/verify"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"
)
var errNilMintOperation = errors.New("nil mint operation")
type MintOperation struct {
MintInput secp256k1fx.Input `serialize:"true" json:"mintInput"`
MintOutput MintOutput `serialize:"true" json:"mintOutput"`
OwnedOutput OwnedOutput `serialize:"true" json:"ownedOutput"`
}
func (op *MintOperation) InitCtx(ctx *snow.Context) {
op.MintOutput.OutputOwners.InitCtx(ctx)
op.OwnedOutput.OutputOwners.InitCtx(ctx)
}
func (op *MintOperation) Cost() (uint64, error) {
return op.MintInput.Cost()
}
func (op *MintOperation) Outs() []verify.State {
return []verify.State{
&op.MintOutput,
&op.OwnedOutput,
}
}
func (op *MintOperation) Verify() error {
switch {
case op == nil:
return errNilMintOperation
default:
return verify.All(&op.MintInput, &op.MintOutput, &op.OwnedOutput)
}
}