gitlab.com/flarenetwork/coreth@v0.1.1/plugin/evm/export_tx.go (about)

     1  // (c) 2021, Flare Networks Limited. All rights reserved.
     2  //
     3  // This file is a derived work, based on the avalanchego library whose original
     4  // notice appears below. It is distributed under a license compatible with the
     5  // licensing terms of the original code from which it is derived.
     6  // Please see the file LICENSE_AVALABS for licensing terms of the original work.
     7  // Please see the file LICENSE for licensing terms.
     8  //
     9  // (c) 2019-2020, Ava Labs, Inc. All rights reserved.
    10  
    11  package evm
    12  
    13  import (
    14  	"fmt"
    15  	"math/big"
    16  
    17  	"gitlab.com/flarenetwork/coreth/core/state"
    18  	"gitlab.com/flarenetwork/coreth/params"
    19  
    20  	"github.com/ava-labs/avalanchego/database"
    21  	"github.com/ava-labs/avalanchego/ids"
    22  	"github.com/ava-labs/avalanchego/snow"
    23  	"github.com/ava-labs/avalanchego/utils/crypto"
    24  	"github.com/ava-labs/avalanchego/vms/components/avax"
    25  )
    26  
    27  // UnsignedExportTx is an unsigned ExportTx
    28  type UnsignedExportTx struct {
    29  	avax.Metadata
    30  	// ID of the network on which this tx was issued
    31  	NetworkID uint32 `serialize:"true" json:"networkID"`
    32  	// ID of this blockchain.
    33  	BlockchainID ids.ID `serialize:"true" json:"blockchainID"`
    34  	// Which chain to send the funds to
    35  	DestinationChain ids.ID `serialize:"true" json:"destinationChain"`
    36  	// Inputs
    37  	Ins []EVMInput `serialize:"true" json:"inputs"`
    38  	// Outputs that are exported to the chain
    39  	ExportedOutputs []*avax.TransferableOutput `serialize:"true" json:"exportedOutputs"`
    40  }
    41  
    42  // InputUTXOs returns an empty set
    43  func (tx *UnsignedExportTx) InputUTXOs() ids.Set { return ids.Set{} }
    44  
    45  // Verify this transaction is well-formed
    46  func (tx *UnsignedExportTx) Verify(
    47  	avmID ids.ID,
    48  	ctx *snow.Context,
    49  	rules params.Rules,
    50  ) error {
    51  	return errWrongChainID
    52  }
    53  
    54  func (tx *UnsignedExportTx) Cost() (uint64, error) {
    55  	return 0, fmt.Errorf("exportTx transactions disabled")
    56  }
    57  
    58  // Amount of [assetID] burned by this transaction
    59  func (tx *UnsignedExportTx) Burned(assetID ids.ID) (uint64, error) {
    60  	return 0, fmt.Errorf("exportTx transactions disabled")
    61  }
    62  
    63  // SemanticVerify this transaction is valid.
    64  func (tx *UnsignedExportTx) SemanticVerify(
    65  	vm *VM,
    66  	stx *Tx,
    67  	_ *Block,
    68  	baseFee *big.Int,
    69  	rules params.Rules,
    70  ) error {
    71  	return fmt.Errorf("exportTx transactions disabled")
    72  }
    73  
    74  // Accept this transaction.
    75  func (tx *UnsignedExportTx) Accept(ctx *snow.Context, batch database.Batch) error {
    76  	return fmt.Errorf("exportTx transactions disabled")
    77  }
    78  
    79  // newExportTx returns a new ExportTx
    80  func (vm *VM) newExportTx(
    81  	assetID ids.ID, // AssetID of the tokens to export
    82  	amount uint64, // Amount of tokens to export
    83  	chainID ids.ID, // Chain to send the UTXOs to
    84  	to ids.ShortID, // Address of chain recipient
    85  	baseFee *big.Int, // fee to use post-AP3
    86  	keys []*crypto.PrivateKeySECP256K1R, // Pay the fee and provide the tokens
    87  ) (*Tx, error) {
    88  	return nil, errWrongChainID
    89  }
    90  
    91  // EVMStateTransfer executes the state update from the atomic export transaction
    92  func (tx *UnsignedExportTx) EVMStateTransfer(ctx *snow.Context, state *state.StateDB) error {
    93  	return errInsufficientFunds
    94  }