github.com/ava-labs/avalanchego@v1.11.11/vms/propertyfx/mint_operation.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package propertyfx
     5  
     6  import (
     7  	"errors"
     8  
     9  	"github.com/ava-labs/avalanchego/snow"
    10  	"github.com/ava-labs/avalanchego/vms/components/verify"
    11  	"github.com/ava-labs/avalanchego/vms/secp256k1fx"
    12  )
    13  
    14  var errNilMintOperation = errors.New("nil mint operation")
    15  
    16  type MintOperation struct {
    17  	MintInput   secp256k1fx.Input `serialize:"true" json:"mintInput"`
    18  	MintOutput  MintOutput        `serialize:"true" json:"mintOutput"`
    19  	OwnedOutput OwnedOutput       `serialize:"true" json:"ownedOutput"`
    20  }
    21  
    22  func (op *MintOperation) InitCtx(ctx *snow.Context) {
    23  	op.MintOutput.OutputOwners.InitCtx(ctx)
    24  	op.OwnedOutput.OutputOwners.InitCtx(ctx)
    25  }
    26  
    27  func (op *MintOperation) Cost() (uint64, error) {
    28  	return op.MintInput.Cost()
    29  }
    30  
    31  func (op *MintOperation) Outs() []verify.State {
    32  	return []verify.State{
    33  		&op.MintOutput,
    34  		&op.OwnedOutput,
    35  	}
    36  }
    37  
    38  func (op *MintOperation) Verify() error {
    39  	switch {
    40  	case op == nil:
    41  		return errNilMintOperation
    42  	default:
    43  		return verify.All(&op.MintInput, &op.MintOutput, &op.OwnedOutput)
    44  	}
    45  }