github.com/MetalBlockchain/metalgo@v1.11.9/wallet/chain/p/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 p 5 6 import ( 7 "time" 8 9 "github.com/MetalBlockchain/metalgo/ids" 10 "github.com/MetalBlockchain/metalgo/vms/components/avax" 11 "github.com/MetalBlockchain/metalgo/vms/platformvm/txs" 12 "github.com/MetalBlockchain/metalgo/vms/secp256k1fx" 13 "github.com/MetalBlockchain/metalgo/wallet/chain/p/builder" 14 "github.com/MetalBlockchain/metalgo/wallet/subnet/primary/common" 15 16 vmsigner "github.com/MetalBlockchain/metalgo/vms/platformvm/signer" 17 walletsigner "github.com/MetalBlockchain/metalgo/wallet/chain/p/signer" 18 ) 19 20 var _ Wallet = (*walletWithOptions)(nil) 21 22 func NewWalletWithOptions( 23 wallet Wallet, 24 options ...common.Option, 25 ) Wallet { 26 return &walletWithOptions{ 27 wallet: wallet, 28 options: options, 29 } 30 } 31 32 type walletWithOptions struct { 33 wallet Wallet 34 options []common.Option 35 } 36 37 func (w *walletWithOptions) Builder() builder.Builder { 38 return builder.NewWithOptions( 39 w.wallet.Builder(), 40 w.options..., 41 ) 42 } 43 44 func (w *walletWithOptions) Signer() walletsigner.Signer { 45 return w.wallet.Signer() 46 } 47 48 func (w *walletWithOptions) IssueBaseTx( 49 outputs []*avax.TransferableOutput, 50 options ...common.Option, 51 ) (*txs.Tx, error) { 52 return w.wallet.IssueBaseTx( 53 outputs, 54 common.UnionOptions(w.options, options)..., 55 ) 56 } 57 58 func (w *walletWithOptions) IssueAddValidatorTx( 59 vdr *txs.Validator, 60 rewardsOwner *secp256k1fx.OutputOwners, 61 shares uint32, 62 options ...common.Option, 63 ) (*txs.Tx, error) { 64 return w.wallet.IssueAddValidatorTx( 65 vdr, 66 rewardsOwner, 67 shares, 68 common.UnionOptions(w.options, options)..., 69 ) 70 } 71 72 func (w *walletWithOptions) IssueAddSubnetValidatorTx( 73 vdr *txs.SubnetValidator, 74 options ...common.Option, 75 ) (*txs.Tx, error) { 76 return w.wallet.IssueAddSubnetValidatorTx( 77 vdr, 78 common.UnionOptions(w.options, options)..., 79 ) 80 } 81 82 func (w *walletWithOptions) IssueRemoveSubnetValidatorTx( 83 nodeID ids.NodeID, 84 subnetID ids.ID, 85 options ...common.Option, 86 ) (*txs.Tx, error) { 87 return w.wallet.IssueRemoveSubnetValidatorTx( 88 nodeID, 89 subnetID, 90 common.UnionOptions(w.options, options)..., 91 ) 92 } 93 94 func (w *walletWithOptions) IssueAddDelegatorTx( 95 vdr *txs.Validator, 96 rewardsOwner *secp256k1fx.OutputOwners, 97 options ...common.Option, 98 ) (*txs.Tx, error) { 99 return w.wallet.IssueAddDelegatorTx( 100 vdr, 101 rewardsOwner, 102 common.UnionOptions(w.options, options)..., 103 ) 104 } 105 106 func (w *walletWithOptions) IssueCreateChainTx( 107 subnetID ids.ID, 108 genesis []byte, 109 vmID ids.ID, 110 fxIDs []ids.ID, 111 chainName string, 112 options ...common.Option, 113 ) (*txs.Tx, error) { 114 return w.wallet.IssueCreateChainTx( 115 subnetID, 116 genesis, 117 vmID, 118 fxIDs, 119 chainName, 120 common.UnionOptions(w.options, options)..., 121 ) 122 } 123 124 func (w *walletWithOptions) IssueCreateSubnetTx( 125 owner *secp256k1fx.OutputOwners, 126 options ...common.Option, 127 ) (*txs.Tx, error) { 128 return w.wallet.IssueCreateSubnetTx( 129 owner, 130 common.UnionOptions(w.options, options)..., 131 ) 132 } 133 134 func (w *walletWithOptions) IssueTransferSubnetOwnershipTx( 135 subnetID ids.ID, 136 owner *secp256k1fx.OutputOwners, 137 options ...common.Option, 138 ) (*txs.Tx, error) { 139 return w.wallet.IssueTransferSubnetOwnershipTx( 140 subnetID, 141 owner, 142 common.UnionOptions(w.options, options)..., 143 ) 144 } 145 146 func (w *walletWithOptions) IssueImportTx( 147 sourceChainID ids.ID, 148 to *secp256k1fx.OutputOwners, 149 options ...common.Option, 150 ) (*txs.Tx, error) { 151 return w.wallet.IssueImportTx( 152 sourceChainID, 153 to, 154 common.UnionOptions(w.options, options)..., 155 ) 156 } 157 158 func (w *walletWithOptions) IssueExportTx( 159 chainID ids.ID, 160 outputs []*avax.TransferableOutput, 161 options ...common.Option, 162 ) (*txs.Tx, error) { 163 return w.wallet.IssueExportTx( 164 chainID, 165 outputs, 166 common.UnionOptions(w.options, options)..., 167 ) 168 } 169 170 func (w *walletWithOptions) IssueTransformSubnetTx( 171 subnetID ids.ID, 172 assetID ids.ID, 173 initialSupply uint64, 174 maxSupply uint64, 175 minConsumptionRate uint64, 176 maxConsumptionRate uint64, 177 minValidatorStake uint64, 178 maxValidatorStake uint64, 179 minStakeDuration time.Duration, 180 maxStakeDuration time.Duration, 181 minDelegationFee uint32, 182 minDelegatorStake uint64, 183 maxValidatorWeightFactor byte, 184 uptimeRequirement uint32, 185 options ...common.Option, 186 ) (*txs.Tx, error) { 187 return w.wallet.IssueTransformSubnetTx( 188 subnetID, 189 assetID, 190 initialSupply, 191 maxSupply, 192 minConsumptionRate, 193 maxConsumptionRate, 194 minValidatorStake, 195 maxValidatorStake, 196 minStakeDuration, 197 maxStakeDuration, 198 minDelegationFee, 199 minDelegatorStake, 200 maxValidatorWeightFactor, 201 uptimeRequirement, 202 common.UnionOptions(w.options, options)..., 203 ) 204 } 205 206 func (w *walletWithOptions) IssueAddPermissionlessValidatorTx( 207 vdr *txs.SubnetValidator, 208 signer vmsigner.Signer, 209 assetID ids.ID, 210 validationRewardsOwner *secp256k1fx.OutputOwners, 211 delegationRewardsOwner *secp256k1fx.OutputOwners, 212 shares uint32, 213 options ...common.Option, 214 ) (*txs.Tx, error) { 215 return w.wallet.IssueAddPermissionlessValidatorTx( 216 vdr, 217 signer, 218 assetID, 219 validationRewardsOwner, 220 delegationRewardsOwner, 221 shares, 222 common.UnionOptions(w.options, options)..., 223 ) 224 } 225 226 func (w *walletWithOptions) IssueAddPermissionlessDelegatorTx( 227 vdr *txs.SubnetValidator, 228 assetID ids.ID, 229 rewardsOwner *secp256k1fx.OutputOwners, 230 options ...common.Option, 231 ) (*txs.Tx, error) { 232 return w.wallet.IssueAddPermissionlessDelegatorTx( 233 vdr, 234 assetID, 235 rewardsOwner, 236 common.UnionOptions(w.options, options)..., 237 ) 238 } 239 240 func (w *walletWithOptions) IssueUnsignedTx( 241 utx txs.UnsignedTx, 242 options ...common.Option, 243 ) (*txs.Tx, error) { 244 return w.wallet.IssueUnsignedTx( 245 utx, 246 common.UnionOptions(w.options, options)..., 247 ) 248 } 249 250 func (w *walletWithOptions) IssueTx( 251 tx *txs.Tx, 252 options ...common.Option, 253 ) error { 254 return w.wallet.IssueTx( 255 tx, 256 common.UnionOptions(w.options, options)..., 257 ) 258 }