github.com/MetalBlockchain/metalgo@v1.11.9/vms/platformvm/fx/fx.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package fx
     5  
     6  import (
     7  	"github.com/MetalBlockchain/metalgo/snow"
     8  	"github.com/MetalBlockchain/metalgo/vms/components/verify"
     9  	"github.com/MetalBlockchain/metalgo/vms/secp256k1fx"
    10  )
    11  
    12  var (
    13  	_ Fx    = (*secp256k1fx.Fx)(nil)
    14  	_ Owner = (*secp256k1fx.OutputOwners)(nil)
    15  	_ Owned = (*secp256k1fx.TransferOutput)(nil)
    16  )
    17  
    18  // Fx is the interface a feature extension must implement to support the
    19  // Platform Chain.
    20  type Fx interface {
    21  	// Initialize this feature extension to be running under this VM. Should
    22  	// return an error if the VM is incompatible.
    23  	Initialize(vm interface{}) error
    24  
    25  	// Notify this Fx that the VM is in bootstrapping
    26  	Bootstrapping() error
    27  
    28  	// Notify this Fx that the VM is bootstrapped
    29  	Bootstrapped() error
    30  
    31  	// VerifyTransfer verifies that the specified transaction can spend the
    32  	// provided utxo with no restrictions on the destination. If the transaction
    33  	// can't spend the output based on the input and credential, a non-nil error
    34  	// should be returned.
    35  	VerifyTransfer(tx, in, cred, utxo interface{}) error
    36  
    37  	// VerifyPermission returns nil iff [cred] proves that [controlGroup]
    38  	// assents to [tx]
    39  	VerifyPermission(tx, in, cred, controlGroup interface{}) error
    40  
    41  	// CreateOutput creates a new output with the provided control group worth
    42  	// the specified amount
    43  	CreateOutput(amount uint64, controlGroup interface{}) (interface{}, error)
    44  }
    45  
    46  type Owner interface {
    47  	verify.IsNotState
    48  
    49  	verify.Verifiable
    50  	snow.ContextInitializable
    51  }
    52  
    53  type Owned interface {
    54  	Owners() interface{}
    55  }