Skip to content

Commit

Permalink
Relocate personal RPC endpoints to parity and geth class
Browse files Browse the repository at this point in the history
  • Loading branch information
njgheorghita committed Jan 15, 2019
1 parent 92463a2 commit 7053617
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 11 deletions.
20 changes: 20 additions & 0 deletions web3/geth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from web3.module import (
Module,
)
from web3.personal import (
Personal,
)


class GethPersonal(Personal):
"""
https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal
"""
def __init__(self, w3):
self.w3 = w3


class Geth(Module):
@property
def personal(self):
return GethPersonal(self.web3)
8 changes: 4 additions & 4 deletions web3/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
from web3.eth import (
Eth,
)
from web3.geth import (
Geth,
)
from web3.iban import (
Iban,
)
Expand All @@ -55,9 +58,6 @@
from web3.parity import (
Parity,
)
from web3.personal import (
Personal,
)
from web3.providers.eth_tester import (
EthereumTesterProvider,
)
Expand Down Expand Up @@ -85,12 +85,12 @@ def get_default_modules():
return {
"eth": Eth,
"net": Net,
"personal": Personal,
"version": Version,
"txpool": TxPool,
"miner": Miner,
"admin": Admin,
"parity": Parity,
"geth": Geth,
"testing": Testing,
}

Expand Down
25 changes: 25 additions & 0 deletions web3/parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,42 @@
from web3._utils.toolz import (
assoc,
)
from web3.personal import (
Personal,
)
from web3.module import (
Module,
)


class ParityPersonal(Personal):
"""
https://wiki.parity.io/JSONRPC-personal-module
"""
def __init__(self, w3):
self.w3 = w3

def importRawKey(self, private_key, passphrase):
raise NotImplementedError(
"personal_importRawKey RPC-endpoint is not supported by the Parity client."
)

def lockAccount(self, account):
raise NotImplementedError(
"personal_lockAccount RPC-endpoint is not supported by the Parity client."
)


class Parity(Module):
"""
https://paritytech.github.io/wiki/JSONRPC-parity-module
"""
defaultBlock = "latest"

@property
def personal(self):
return ParityPersonal(self.web3)

def enode(self):
return self.web3.manager.request_blocking(
"parity_enode",
Expand Down
13 changes: 6 additions & 7 deletions web3/personal.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from web3.module import (
Module,
)


class Personal(Module):
class Personal():
"""
https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal
This API is not automatically available on a `web3` instance, rather it should be accessed
through `web3.geth.personal` or `web3.parity.personal`.
All RPC endpoints under the personal namespace should be added here, and NotImplementedErrors
should be raised in subclasses if the endpoints are not supported by the respective client.
"""
def importRawKey(self, private_key, passphrase):
return self.web3.manager.request_blocking(
Expand Down

0 comments on commit 7053617

Please sign in to comment.