github.com/ava-labs/avalanchego@v1.11.11/wallet/chain/c/wallet_with_options.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package c 5 6 import ( 7 "github.com/ava-labs/coreth/plugin/evm" 8 9 "github.com/ava-labs/avalanchego/ids" 10 "github.com/ava-labs/avalanchego/vms/secp256k1fx" 11 "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" 12 13 ethcommon "github.com/ethereum/go-ethereum/common" 14 ) 15 16 var _ Wallet = (*walletWithOptions)(nil) 17 18 func NewWalletWithOptions( 19 wallet Wallet, 20 options ...common.Option, 21 ) Wallet { 22 return &walletWithOptions{ 23 Wallet: wallet, 24 options: options, 25 } 26 } 27 28 type walletWithOptions struct { 29 Wallet 30 options []common.Option 31 } 32 33 func (w *walletWithOptions) Builder() Builder { 34 return NewBuilderWithOptions( 35 w.Wallet.Builder(), 36 w.options..., 37 ) 38 } 39 40 func (w *walletWithOptions) IssueImportTx( 41 chainID ids.ID, 42 to ethcommon.Address, 43 options ...common.Option, 44 ) (*evm.Tx, error) { 45 return w.Wallet.IssueImportTx( 46 chainID, 47 to, 48 common.UnionOptions(w.options, options)..., 49 ) 50 } 51 52 func (w *walletWithOptions) IssueExportTx( 53 chainID ids.ID, 54 outputs []*secp256k1fx.TransferOutput, 55 options ...common.Option, 56 ) (*evm.Tx, error) { 57 return w.Wallet.IssueExportTx( 58 chainID, 59 outputs, 60 common.UnionOptions(w.options, options)..., 61 ) 62 } 63 64 func (w *walletWithOptions) IssueUnsignedAtomicTx( 65 utx evm.UnsignedAtomicTx, 66 options ...common.Option, 67 ) (*evm.Tx, error) { 68 return w.Wallet.IssueUnsignedAtomicTx( 69 utx, 70 common.UnionOptions(w.options, options)..., 71 ) 72 } 73 74 func (w *walletWithOptions) IssueAtomicTx( 75 tx *evm.Tx, 76 options ...common.Option, 77 ) error { 78 return w.Wallet.IssueAtomicTx( 79 tx, 80 common.UnionOptions(w.options, options)..., 81 ) 82 }