gecko/vms/avm/fx.go

50 lines
1.6 KiB
Go

// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package avm
import (
"github.com/ava-labs/gecko/ids"
"github.com/ava-labs/gecko/vms/components/verify"
)
type parsedFx struct {
ID ids.ID
Fx Fx
}
// Fx is the interface a feature extension must implement to support the AVM.
type Fx interface {
// Initialize this feature extension to be running under this VM. Should
// return an error if the VM is incompatible.
Initialize(vm interface{}) error
// VerifyTransfer verifies that the specified transaction can spend the
// provided utxo with no restrictions on the destination. If the transaction
// can't spend the output based on the input and credential, a non-nil error
// should be returned.
VerifyTransfer(tx, utxo, in, cred interface{}) error
// VerifyOperation verifies that the specified transaction can spend the
// provided utxos conditioned on the result being restricted to the provided
// outputs. If the transaction can't spend the output based on the input and
// credential, a non-nil error should be returned.
VerifyOperation(tx interface{}, utxos, ins, creds, outs []interface{}) error
}
// FxTransferable is the interface a feature extension must provide to transfer
// value between features extensions.
type FxTransferable interface {
verify.Verifiable
// Amount returns how much value this output consumes of the asset in its
// transaction.
Amount() uint64
}
// FxAddressable is the interface a feature extension must provide to be able to
// be tracked as a part of the utxo set for a set of addresses
type FxAddressable interface {
Addresses() [][]byte
}