Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Problem: need to add JSON-RPC endpoint personal_listWallets #748

Merged
merged 4 commits into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (rpc) [tharsis#733](https://github.com/tharsis/ethermint/pull/733) add JSON_RPC endpoint `personal_unpair`
* (rpc) [tharsis#740](https://github.com/tharsis/ethermint/pull/740) add JSON_RPC endpoint `personal_initializeWallet`
* (rpc) [tharsis#743](https://github.com/tharsis/ethermint/pull/743) add JSON_RPC endpoint `debug_traceBlockByHash`
* (rpc) [tharsis#748](https://github.com/tharsis/ethermint/pull/748) add JSON_RPC endpoint `personal_listWallets`

### Bug Fixes

Expand Down
16 changes: 16 additions & 0 deletions rpc/ethereum/namespaces/personal/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,19 @@ func (api *PrivateAccountAPI) InitializeWallet(_ context.Context, url string) (s
// TODO: Smartcard wallet not supported yet, refer to: https://github.com/ethereum/go-ethereum/blob/master/accounts/scwallet/README.md
return "", fmt.Errorf("smartcard wallet not supported yet")
}

// RawWallet is a JSON representation of an accounts.Wallet interface, with its
// data contents extracted into plain fields.
type RawWallet struct {
URL string `json:"url"`
Status string `json:"status"`
Failure string `json:"failure,omitempty"`
Accounts []accounts.Account `json:"accounts,omitempty"`
}

// ListWallets will return a list of wallets this node manages.
func (api *PrivateAccountAPI) ListWallets() []RawWallet {
api.logger.Debug("personal_ListWallets")
api.logger.Info("currently wallet level that manages accounts is not supported")
return ([]RawWallet)(nil)
}
8 changes: 8 additions & 0 deletions tests/rpc/personal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,11 @@ func TestPersonal_InitializeWallet(t *testing.T) {
_, err := CallWithError("personal_initializeWallet", []interface{}{""})
require.Equal(t, "smartcard wallet not supported yet", err.Error())
}

func TestPersonal_ListWallets(t *testing.T) {
rpcRes := Call(t, "personal_listWallets", []interface{}{})
var res []hexutil.Bytes
err := json.Unmarshal(rpcRes.Result, &res)
require.NoError(t, err)
require.Equal(t, ([]hexutil.Bytes)(nil), res)
}