github.com/ava-labs/avalanchego@v1.11.11/vms/secp256k1fx/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 secp256k1fx
     5  
     6  import (
     7  	"errors"
     8  
     9  	"github.com/ava-labs/avalanchego/snow"
    10  	"github.com/ava-labs/avalanchego/vms/components/verify"
    11  )
    12  
    13  var errNilMintOperation = errors.New("nil mint operation")
    14  
    15  type MintOperation struct {
    16  	MintInput      Input          `serialize:"true" json:"mintInput"`
    17  	MintOutput     MintOutput     `serialize:"true" json:"mintOutput"`
    18  	TransferOutput TransferOutput `serialize:"true" json:"transferOutput"`
    19  }
    20  
    21  func (op *MintOperation) InitCtx(ctx *snow.Context) {
    22  	op.MintOutput.OutputOwners.InitCtx(ctx)
    23  	op.TransferOutput.OutputOwners.InitCtx(ctx)
    24  }
    25  
    26  func (op *MintOperation) Cost() (uint64, error) {
    27  	return op.MintInput.Cost()
    28  }
    29  
    30  func (op *MintOperation) Outs() []verify.State {
    31  	return []verify.State{&op.MintOutput, &op.TransferOutput}
    32  }
    33  
    34  func (op *MintOperation) Verify() error {
    35  	switch {
    36  	case op == nil:
    37  		return errNilMintOperation
    38  	default:
    39  		return verify.All(&op.MintInput, &op.MintOutput, &op.TransferOutput)
    40  	}
    41  }