From a3f1d8d89d1b5010b5fc9d7dfeca34c35d8d4f90 Mon Sep 17 00:00:00 2001 From: Adu Date: Wed, 10 Nov 2021 17:09:53 +0800 Subject: [PATCH] rpc: `personal_unpair` (#733) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Problem: need to add rpc endpoint personal_unpair Closes #730 * this is aimed at smartcard wallet which is not supported yet. * will return unsupported error now. * Update rpc/ethereum/namespaces/personal/api.go * add changelog entry and use errors.Is Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com> --- CHANGELOG.md | 1 + rpc/ethereum/namespaces/personal/api.go | 8 ++++++++ tests/rpc/personal_test.go | 12 ++++++++++++ 3 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ad36592..987f2207 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/rpc/ethereum/namespaces/personal/api.go b/rpc/ethereum/namespaces/personal/api.go index 77f29151..b5786e59 100644 --- a/rpc/ethereum/namespaces/personal/api.go +++ b/rpc/ethereum/namespaces/personal/api.go @@ -222,3 +222,11 @@ 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") +} diff --git a/tests/rpc/personal_test.go b/tests/rpc/personal_test.go index 93678654..b0614ee5 100644 --- a/tests/rpc/personal_test.go +++ b/tests/rpc/personal_test.go @@ -2,6 +2,8 @@ package rpc import ( "encoding/json" + "errors" + "fmt" "testing" "github.com/stretchr/testify/require" @@ -142,3 +144,13 @@ 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") + + rpcRes := Call(t, "personal_unpair", []interface{}{"", 0}) + + var res error + err := json.Unmarshal(rpcRes.Result, &res) + require.True(t, errors.Is(err, fmt.Errorf("smartcard wallet not supported yet"))) +}