Skip to content

Commit

Permalink
refactor: returned interface instead of type struct instance from Acc…
Browse files Browse the repository at this point in the history
…ountManagerForKeystore()
  • Loading branch information
Yashk767 committed Apr 10, 2024
1 parent aa262c6 commit 1a93d6c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 4 additions & 1 deletion cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ func (*UtilsStruct) Create(password string) (accounts.Account, error) {
}
log.Debug("Create: .razor directory path: ", razorPath)
accountManager, err := razorUtils.AccountManagerForKeystore()
utils.CheckError("Error in getting accounts manager for keystore: ", err)
if err != nil {
log.Error("Error in getting accounts manager for keystore: ", err)
return accounts.Account{Address: common.Address{0x00}}, err
}

keystorePath := filepath.Join(razorPath, "keystore_files")
account := accountManager.CreateAccount(keystorePath, password)
Expand Down
4 changes: 2 additions & 2 deletions utils/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,11 @@ func (*UtilsStruct) CheckPassword(account types.Account) error {
return nil
}

func (*UtilsStruct) AccountManagerForKeystore() (*accounts.AccountManager, error) {
func (*UtilsStruct) AccountManagerForKeystore() (types.AccountManagerInterface, error) {
razorPath, err := PathInterface.GetDefaultPath()
if err != nil {
log.Error("GetKeystorePath: Error in getting .razor path: ", err)
return &accounts.AccountManager{}, err
return nil, err
}
keystorePath := filepath.Join(razorPath, "keystore_files")

Expand Down
3 changes: 1 addition & 2 deletions utils/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"io/fs"
"math/big"
"os"
"razor/accounts"
"razor/cache"
"razor/core/types"
"razor/pkg/bindings"
Expand Down Expand Up @@ -157,7 +156,7 @@ type Utils interface {
GetStakedTokenManagerWithOpts(client *ethclient.Client, tokenAddress common.Address) (*bindings.StakedToken, bind.CallOpts)
GetStakerSRZRBalance(client *ethclient.Client, staker bindings.StructsStaker) (*big.Int, error)
CheckPassword(account types.Account) error
AccountManagerForKeystore() (*accounts.AccountManager, error)
AccountManagerForKeystore() (types.AccountManagerInterface, error)
}

type EthClientUtils interface {
Expand Down

0 comments on commit 1a93d6c

Please sign in to comment.