Skip to content

Commit

Permalink
update load wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
sukantoraymond committed May 22, 2024
1 parent 8ccf5bf commit a6bbab4
Showing 1 changed file with 1 addition and 33 deletions.
34 changes: 1 addition & 33 deletions subnet/deploy_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package subnet

import (
"avalanche-tooling-sdk-go/avalanche"
"avalanche-tooling-sdk-go/utils"
"context"
"fmt"

Check failure on line 9 in subnet/deploy_subnet.go

View workflow job for this annotation

GitHub Actions / Lint

File is not `gofumpt`-ed (gofumpt)
"github.com/ava-labs/avalanchego/ids"
Expand Down Expand Up @@ -43,11 +42,7 @@ func createSubnetTx(subnet Subnet, wallet primary.Wallet) (*txs.Tx, error) {
}

// createBlockchainTx creates uncommitted createBlockchain transaction
func createBlockchainTx(subnet Subnet, wallet primary.Wallet, network avalanche.Network, keyChain avalanche.Keychain) (*txs.Tx, error) {
wallet, err := loadCacheWallet(network, keyChain, wallet, subnet.SubnetID, subnet.TransferSubnetOwnershipTxID)
if err != nil {
return nil, err
}
func createBlockchainTx(subnet Subnet, wallet primary.Wallet, keyChain avalanche.Keychain) (*txs.Tx, error) {

Check failure on line 45 in subnet/deploy_subnet.go

View workflow job for this annotation

GitHub Actions / Lint

func `createBlockchainTx` is unused (unused)
fxIDs := make([]ids.ID, 0)
options := getMultisigTxOptions(keyChain.Keychain, subnet.SubnetAuthKeys)
// create tx
Expand Down Expand Up @@ -87,30 +82,3 @@ func getMultisigTxOptions(keychain keychain.Keychain, subnetAuthKeys []ids.Short
options = append(options, common.WithChangeOwner(changeOwner))
return options
}

func loadCacheWallet(network avalanche.Network, keyChain avalanche.Keychain, wallet primary.Wallet, preloadTxs ...ids.ID) (primary.Wallet, error) {
var err error
if wallet == nil {
wallet, err = loadWallet(network, keyChain, preloadTxs...)
}
return wallet, err
}

func loadWallet(network avalanche.Network, keyChain avalanche.Keychain, preloadTxs ...ids.ID) (primary.Wallet, error) {
ctx := context.Background()
// filter out ids.Empty txs
filteredTxs := utils.Filter(preloadTxs, func(e ids.ID) bool { return e != ids.Empty })
wallet, err := primary.MakeWallet(
ctx,
&primary.WalletConfig{
URI: network.Endpoint,
AVAXKeychain: keyChain.Keychain,
EthKeychain: secp256k1fx.NewKeychain(),
PChainTxsToFetch: set.Of(filteredTxs...),
},
)
if err != nil {
return nil, err
}
return wallet, nil
}

0 comments on commit a6bbab4

Please sign in to comment.