github.com/ava-labs/avalanchego@v1.11.11/vms/avm/txs/import_tx.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package txs 5 6 import ( 7 "github.com/ava-labs/avalanchego/ids" 8 "github.com/ava-labs/avalanchego/utils/set" 9 "github.com/ava-labs/avalanchego/vms/components/avax" 10 "github.com/ava-labs/avalanchego/vms/secp256k1fx" 11 ) 12 13 var ( 14 _ UnsignedTx = (*ImportTx)(nil) 15 _ secp256k1fx.UnsignedTx = (*ImportTx)(nil) 16 ) 17 18 // ImportTx is a transaction that imports an asset from another blockchain. 19 type ImportTx struct { 20 BaseTx `serialize:"true"` 21 22 // Which chain to consume the funds from 23 SourceChain ids.ID `serialize:"true" json:"sourceChain"` 24 25 // The inputs to this transaction 26 ImportedIns []*avax.TransferableInput `serialize:"true" json:"importedInputs"` 27 } 28 29 // InputUTXOs track which UTXOs this transaction is consuming. 30 func (t *ImportTx) InputUTXOs() []*avax.UTXOID { 31 utxos := t.BaseTx.InputUTXOs() 32 for _, in := range t.ImportedIns { 33 in.Symbol = true 34 utxos = append(utxos, &in.UTXOID) 35 } 36 return utxos 37 } 38 39 func (t *ImportTx) InputIDs() set.Set[ids.ID] { 40 inputs := t.BaseTx.InputIDs() 41 for _, in := range t.ImportedIns { 42 inputs.Add(in.InputID()) 43 } 44 return inputs 45 } 46 47 // NumCredentials returns the number of expected credentials 48 func (t *ImportTx) NumCredentials() int { 49 return t.BaseTx.NumCredentials() + len(t.ImportedIns) 50 } 51 52 func (t *ImportTx) Visit(v Visitor) error { 53 return v.ImportTx(t) 54 }