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_initializeWallet #739

Closed
wants to merge 5 commits into from
Closed
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 @@ -49,6 +49,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (rpc) [tharsis#624](https://github.com/tharsis/ethermint/pull/624) Implement new JSON-RPC endpoints from latest geth version
* (evm) [tharsis#662](https://github.com/tharsis/ethermint/pull/662) Disable basefee for non london blocks
* (cmd) [tharsis#712](https://github.com/tharsis/ethermint/pull/712) add tx cli to build evm transaction
* (rpc) [tharsis#733](https://github.com/tharsis/ethermint/pull/733) add JSON_RPC endpoint personal_unpair

### 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 @@ -222,3 +222,19 @@ func (api *PrivateAccountAPI) EcRecover(_ context.Context, data, sig hexutil.Byt

return crypto.PubkeyToAddress(*pubkey), nil
}

// Unpair deletes a pairing between wallet and ethermint.
func (api *PrivateAccountAPI) Unpair(_ context.Context, url, pin string) error {
api.logger.Debug("personal_unpair", "url", url, "pin", pin)
api.logger.Info("personal_unpair for smartcard wallet not supported")
// 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")
}

// InitializeWallet initializes a new wallet at the provided URL, by generating and returning a new private key.
func (api *PrivateAccountAPI) InitializeWallet(_ context.Context, url string) (string, error) {
api.logger.Debug("personal_initializeWallet", "url", url)
api.logger.Info("personal_initializeWallet for smartcard wallet not supported")
// 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")
}
16 changes: 16 additions & 0 deletions tests/rpc/personal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package rpc

import (
"encoding/json"
"errors"
"fmt"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -142,3 +144,17 @@ func TestPersonal_LockAccount(t *testing.T) {
_, err = CallWithError("personal_sign", []interface{}{hexutil.Bytes{0x88}, addr, ""})
require.Error(t, err)
}

func TestPersonal_Unpair(t *testing.T) {
t.Skip("skipping TestPersonal_Unpair")

_, err := CallWithError(t, "personal_unpair", []interface{}{"", 0})
require.True(t, errors.Is(err, fmt.Errorf("smartcard wallet not supported yet")))
}

func TestPersonal_InitializeWallet(t *testing.T) {
t.Skip("skipping TestPersonal_InitializeWallet")

_, err := CallWithError(t, "personal_initializeWallet", []interface{}{""})
require.True(t, errors.Is(err, fmt.Errorf("smartcard wallet not supported yet")))
}