Skip to content

Commit

Permalink
Remove unused wallet interface (#3568)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored Nov 25, 2024
1 parent 48e148d commit 5a75231
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 25 deletions.
2 changes: 1 addition & 1 deletion tests/antithesis/avalanchego/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func main() {
type workload struct {
id int
log logging.Logger
wallet primary.Wallet
wallet *primary.Wallet
addrs set.Set[ids.ShortID]
uris []string
}
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/x/transfer/virtuous.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ var _ = e2e.DescribeXChainSerial("[Virtuous Transfer Tx AVAX]", func() {
xContext := xBuilder.Context()
avaxAssetID := xContext.AVAXAssetID

wallets := make([]primary.Wallet, len(testKeys))
wallets := make([]*primary.Wallet, len(testKeys))
shortAddrs := make([]ids.ShortID, len(testKeys))
for i := range wallets {
shortAddrs[i] = testKeys[i].PublicKey().Address()
Expand Down
6 changes: 3 additions & 3 deletions tests/fixture/e2e/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func NewPrivateKey(tc tests.TestContext) *secp256k1.PrivateKey {
}

// Create a new wallet for the provided keychain against the specified node URI.
func NewWallet(tc tests.TestContext, keychain *secp256k1fx.Keychain, nodeURI tmpnet.NodeURI) primary.Wallet {
func NewWallet(tc tests.TestContext, keychain *secp256k1fx.Keychain, nodeURI tmpnet.NodeURI) *primary.Wallet {
tc.Log().Info("initializing a new wallet",
zap.Stringer("nodeID", nodeURI.NodeID),
zap.String("URI", nodeURI.URI),
Expand All @@ -87,12 +87,12 @@ func NewWallet(tc tests.TestContext, keychain *secp256k1fx.Keychain, nodeURI tmp
}

// OutputWalletBalances outputs the X-Chain and P-Chain balances of the provided wallet.
func OutputWalletBalances(tc tests.TestContext, wallet primary.Wallet) {
func OutputWalletBalances(tc tests.TestContext, wallet *primary.Wallet) {
_, _ = GetWalletBalances(tc, wallet)
}

// GetWalletBalances retrieves the X-Chain and P-Chain balances of the provided wallet.
func GetWalletBalances(tc tests.TestContext, wallet primary.Wallet) (uint64, uint64) {
func GetWalletBalances(tc tests.TestContext, wallet *primary.Wallet) (uint64, uint64) {
require := require.New(tc)
var (
xWallet = wallet.X()
Expand Down
2 changes: 1 addition & 1 deletion tests/fixture/tmpnet/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ type Subnet struct {
}

// Retrieves a wallet configured for use with the subnet
func (s *Subnet) GetWallet(ctx context.Context, uri string) (primary.Wallet, error) {
func (s *Subnet) GetWallet(ctx context.Context, uri string) (*primary.Wallet, error) {
keychain := secp256k1fx.NewKeychain(s.OwningKey)

// Only fetch the subnet transaction if a subnet ID is present. This won't be true when
Expand Down
30 changes: 11 additions & 19 deletions wallet/subnet/primary/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,40 @@ import (
xsigner "github.com/ava-labs/avalanchego/wallet/chain/x/signer"
)

var _ Wallet = (*wallet)(nil)

// Wallet provides chain wallets for the primary network.
type Wallet interface {
P() pwallet.Wallet
X() x.Wallet
C() c.Wallet
}

type wallet struct {
type Wallet struct {
p pwallet.Wallet
x x.Wallet
c c.Wallet
}

func (w *wallet) P() pwallet.Wallet {
func (w *Wallet) P() pwallet.Wallet {
return w.p
}

func (w *wallet) X() x.Wallet {
func (w *Wallet) X() x.Wallet {
return w.x
}

func (w *wallet) C() c.Wallet {
func (w *Wallet) C() c.Wallet {
return w.c
}

// Creates a new default wallet
func NewWallet(p pwallet.Wallet, x x.Wallet, c c.Wallet) Wallet {
return &wallet{
func NewWallet(p pwallet.Wallet, x x.Wallet, c c.Wallet) *Wallet {
return &Wallet{
p: p,
x: x,
c: c,
}
}

// Creates a Wallet with the given set of options
func NewWalletWithOptions(w Wallet, options ...common.Option) Wallet {
func NewWalletWithOptions(w *Wallet, options ...common.Option) *Wallet {
return NewWallet(
pwallet.WithOptions(w.P(), options...),
x.NewWalletWithOptions(w.X(), options...),
c.NewWalletWithOptions(w.C(), options...),
pwallet.WithOptions(w.p, options...),
x.NewWalletWithOptions(w.x, options...),
c.NewWalletWithOptions(w.c, options...),
)
}

Expand Down Expand Up @@ -92,7 +84,7 @@ type WalletConfig struct {
// transactions.
//
// The wallet manages all state locally, and performs all tx signing locally.
func MakeWallet(ctx context.Context, config *WalletConfig) (Wallet, error) {
func MakeWallet(ctx context.Context, config *WalletConfig) (*Wallet, error) {
avaxAddrs := config.AVAXKeychain.Addresses()
avaxState, err := FetchState(ctx, config.URI, avaxAddrs)
if err != nil {
Expand Down

0 comments on commit 5a75231

Please sign in to comment.