github.com/ava-labs/avalanchego@v1.11.11/vms/nftfx/transfer_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 nftfx 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 errNilTransferOperation = errors.New("nil transfer operation") 15 16 type TransferOperation struct { 17 Input secp256k1fx.Input `serialize:"true" json:"input"` 18 Output TransferOutput `serialize:"true" json:"output"` 19 } 20 21 func (op *TransferOperation) InitCtx(ctx *snow.Context) { 22 op.Output.OutputOwners.InitCtx(ctx) 23 } 24 25 func (op *TransferOperation) Cost() (uint64, error) { 26 return op.Input.Cost() 27 } 28 29 func (op *TransferOperation) Outs() []verify.State { 30 return []verify.State{&op.Output} 31 } 32 33 func (op *TransferOperation) Verify() error { 34 switch { 35 case op == nil: 36 return errNilTransferOperation 37 default: 38 return verify.All(&op.Input, &op.Output) 39 } 40 }