github.com/MetalBlockchain/metalgo@v1.11.9/wallet/chain/x/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 x 5 6 import ( 7 "github.com/MetalBlockchain/metalgo/ids" 8 "github.com/MetalBlockchain/metalgo/vms/avm/txs" 9 "github.com/MetalBlockchain/metalgo/vms/components/avax" 10 "github.com/MetalBlockchain/metalgo/vms/components/verify" 11 "github.com/MetalBlockchain/metalgo/vms/secp256k1fx" 12 "github.com/MetalBlockchain/metalgo/wallet/chain/x/builder" 13 "github.com/MetalBlockchain/metalgo/wallet/chain/x/signer" 14 "github.com/MetalBlockchain/metalgo/wallet/subnet/primary/common" 15 ) 16 17 var _ Wallet = (*walletWithOptions)(nil) 18 19 func NewWalletWithOptions( 20 wallet Wallet, 21 options ...common.Option, 22 ) Wallet { 23 return &walletWithOptions{ 24 wallet: wallet, 25 options: options, 26 } 27 } 28 29 type walletWithOptions struct { 30 wallet Wallet 31 options []common.Option 32 } 33 34 func (w *walletWithOptions) Builder() builder.Builder { 35 return builder.NewWithOptions( 36 w.wallet.Builder(), 37 w.options..., 38 ) 39 } 40 41 func (w *walletWithOptions) Signer() signer.Signer { 42 return w.wallet.Signer() 43 } 44 45 func (w *walletWithOptions) IssueBaseTx( 46 outputs []*avax.TransferableOutput, 47 options ...common.Option, 48 ) (*txs.Tx, error) { 49 return w.wallet.IssueBaseTx( 50 outputs, 51 common.UnionOptions(w.options, options)..., 52 ) 53 } 54 55 func (w *walletWithOptions) IssueCreateAssetTx( 56 name string, 57 symbol string, 58 denomination byte, 59 initialState map[uint32][]verify.State, 60 options ...common.Option, 61 ) (*txs.Tx, error) { 62 return w.wallet.IssueCreateAssetTx( 63 name, 64 symbol, 65 denomination, 66 initialState, 67 common.UnionOptions(w.options, options)..., 68 ) 69 } 70 71 func (w *walletWithOptions) IssueOperationTx( 72 operations []*txs.Operation, 73 options ...common.Option, 74 ) (*txs.Tx, error) { 75 return w.wallet.IssueOperationTx( 76 operations, 77 common.UnionOptions(w.options, options)..., 78 ) 79 } 80 81 func (w *walletWithOptions) IssueOperationTxMintFT( 82 outputs map[ids.ID]*secp256k1fx.TransferOutput, 83 options ...common.Option, 84 ) (*txs.Tx, error) { 85 return w.wallet.IssueOperationTxMintFT( 86 outputs, 87 common.UnionOptions(w.options, options)..., 88 ) 89 } 90 91 func (w *walletWithOptions) IssueOperationTxMintNFT( 92 assetID ids.ID, 93 payload []byte, 94 owners []*secp256k1fx.OutputOwners, 95 options ...common.Option, 96 ) (*txs.Tx, error) { 97 return w.wallet.IssueOperationTxMintNFT( 98 assetID, 99 payload, 100 owners, 101 common.UnionOptions(w.options, options)..., 102 ) 103 } 104 105 func (w *walletWithOptions) IssueOperationTxMintProperty( 106 assetID ids.ID, 107 owner *secp256k1fx.OutputOwners, 108 options ...common.Option, 109 ) (*txs.Tx, error) { 110 return w.wallet.IssueOperationTxMintProperty( 111 assetID, 112 owner, 113 common.UnionOptions(w.options, options)..., 114 ) 115 } 116 117 func (w *walletWithOptions) IssueOperationTxBurnProperty( 118 assetID ids.ID, 119 options ...common.Option, 120 ) (*txs.Tx, error) { 121 return w.wallet.IssueOperationTxBurnProperty( 122 assetID, 123 common.UnionOptions(w.options, options)..., 124 ) 125 } 126 127 func (w *walletWithOptions) IssueImportTx( 128 chainID ids.ID, 129 to *secp256k1fx.OutputOwners, 130 options ...common.Option, 131 ) (*txs.Tx, error) { 132 return w.wallet.IssueImportTx( 133 chainID, 134 to, 135 common.UnionOptions(w.options, options)..., 136 ) 137 } 138 139 func (w *walletWithOptions) IssueExportTx( 140 chainID ids.ID, 141 outputs []*avax.TransferableOutput, 142 options ...common.Option, 143 ) (*txs.Tx, error) { 144 return w.wallet.IssueExportTx( 145 chainID, 146 outputs, 147 common.UnionOptions(w.options, options)..., 148 ) 149 } 150 151 func (w *walletWithOptions) IssueUnsignedTx( 152 utx txs.UnsignedTx, 153 options ...common.Option, 154 ) (*txs.Tx, error) { 155 return w.wallet.IssueUnsignedTx( 156 utx, 157 common.UnionOptions(w.options, options)..., 158 ) 159 } 160 161 func (w *walletWithOptions) IssueTx( 162 tx *txs.Tx, 163 options ...common.Option, 164 ) error { 165 return w.wallet.IssueTx( 166 tx, 167 common.UnionOptions(w.options, options)..., 168 ) 169 }