Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(grpc): refactor CreateWallet and add RestoreWallet API endpoint #1256

Merged

Conversation

ambersun1234
Copy link
Contributor

Description

This pr remove the mnemonic from CreateWallet request, instead we return the mnemonic
and add RestoreWallet endpoint which takes a mnemonic as a input, and restore it

Related issue(s)

#1210

@ambersun1234 ambersun1234 requested a review from b00f April 30, 2024 16:13
Copy link

codecov bot commented Apr 30, 2024

Codecov Report

Attention: Patch coverage is 35.55556% with 29 lines in your changes are missing coverage. Please review.

Project coverage is 76.03%. Comparing base (dd77837) to head (3d8f9ad).
Report is 3 commits behind head on main.

❗ Current head 3d8f9ad differs from pull request most recent head 3d1275d. Consider uploading reports for the commit 3d1275d to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1256      +/-   ##
==========================================
- Coverage   76.12%   76.03%   -0.09%     
==========================================
  Files         203      203              
  Lines       10637    10661      +24     
==========================================
+ Hits         8097     8106       +9     
- Misses       2149     2164      +15     
  Partials      391      391              

node/node.go Outdated Show resolved Hide resolved
}

func (w *Manager) walletExists(walletName string) bool {
walletPath := util.MakeAbs(filepath.Join(w.walletDirectory, walletName))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can avoid repeating this line by defining a function like:
func getWalletPath(walletName string) string { ... }

wallet/manager.go Outdated Show resolved Hide resolved
www/grpc/proto/wallet.proto Outdated Show resolved Hide resolved
@@ -80,7 +80,7 @@ func setup(t *testing.T, conf *Config) *testData {
server := NewServer(
conf, mockState,
mockSync, mockNet,
mockConsMgr, wallet.NewWalletManager(mockState.Genesis().ChainType()),
mockConsMgr, wallet.NewWalletManager(mockState.Genesis().ChainType(), conf.WalletsDir),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For test you can use TempDirPath function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way we construct temp dir is using os.MkdirTemp, and it'll return different value every time, so we cannot use TempDirPath here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, let's find a solution for that.
Look at the gRPC service as an object that has no knowledge about wallet. (path, chain-type, etc...)

wallet/manager.go Outdated Show resolved Hide resolved
@ambersun1234 ambersun1234 requested a review from b00f May 5, 2024 09:14
@ambersun1234 ambersun1234 merged commit a96b7ac into pactus-project:main May 5, 2024
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants