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

Updated JSON-RPC for Parity and added Geth calls #147

Merged
merged 12 commits into from Aug 9, 2017
Merged

Updated JSON-RPC for Parity and added Geth calls #147

merged 12 commits into from Aug 9, 2017

Conversation

iikirilov
Copy link
Contributor

Response to changes of Parity namespace as detailed in this PR.

Implemented parity_accounts Module.

Implemented Geth personal Module.

Implemented tests for all Response/Request.

@@ -62,6 +63,43 @@ public void setVersion(int version) {
this.version = version;
}

@Override
public int hashCode() {
Copy link
Contributor

@conor10 conor10 Aug 7, 2017

Choose a reason for hiding this comment

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

With the hashCode and equals methods, please can you use the same implementations as per https://github.com/web3j/web3j/blob/master/src/main/java/org/web3j/protocol/core/methods/response/TransactionReceipt.java#L159
This is to ensure the code remains consistent throughout.

}

@Override
public Request<?, PersonalUnlockAccount> personalUnlockAccount(
Copy link
Contributor

Choose a reason for hiding this comment

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

You shouldn't need to duplicate the logic in this second method - you should be able to use a single implementation, and override the implementation. Example here https://github.com/web3j/web3j/blob/master/src/main/java/org/web3j/protocol/parity/JsonRpc2_0Parity.java#L134


@Override
public Request<?, BooleanResponse> parityChangePassword(
String accountId, String oldPass, String newPass) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would use oldPassword & newPassword here as the parameter names - no need to shorten them


@Override
public Request<?, ParityDeriveAddress> parityDeriveAddressHash(
String accountId, String password, Map<String, Object> hashType, boolean toSave) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You should create a class for hashType rather then using a map here. For example see https://github.com/web3j/web3j/blob/master/src/main/java/org/web3j/protocol/core/methods/request/Transaction.java

@Override
public Request<?, ParityDeriveAddress> parityDeriveAddressIndex(
String accountId, String password,
List<Map<String, Object>> indexType, boolean toSave) {
Copy link
Contributor

Choose a reason for hiding this comment

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

HashType can be used here too

public Request<?, PersonalUnlockAccount> personalUnlockAccount(
String accountId, String password) {
public Request<?, BooleanResponse> paritySetAccountName(
String accountId, String newAccountName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

These parameters should be "address" and "name".

}

@Override
public Request<?, EthSendTransaction> personalConfirmRequest(
public Request<?, EthSendTransaction> signerConfirmRequest(
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better to use a custom type here instead of the existing Transaction type which has a lot of unused fields for this method.

Copy link
Contributor

Choose a reason for hiding this comment

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

On second thoughts - you can get rid of the signer module methods - given its only a subset of them anyway. I'd question how useful they are for web3j users.


PersonalSign personalSign = deserialiseResponse(PersonalSign.class);
//CHECKSTYLE:OFF
assertThat(personalSign.getSignedMessage(),is("0xf1aabd691c887ee5c98af871239534f194a51fdeb801b1601d77c45afa74dae67ddd81aa5bb8a54b7974ef5be10b55a8535b040883501f76d14cb74e05e5635d1c"));
Copy link
Contributor

Choose a reason for hiding this comment

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

the "is(...)" should be on a new line

Copy link
Contributor

@conor10 conor10 left a comment

Choose a reason for hiding this comment

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

Good work so far - there's a few further small changes that should be made.
Have you tested these methods against actual Parity and Geth clients?

@iikirilov
Copy link
Contributor Author

iikirilov commented Aug 8, 2017

I've used netbeans to autogenerate equals and hashcode, hence the discrepancy.
Have tested with Geth but not Parity. Will get this all sorted and tested today!

@codecov-io
Copy link

codecov-io commented Aug 8, 2017

Codecov Report

Merging #147 into master will decrease coverage by 2.08%.
The diff coverage is 43.22%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #147      +/-   ##
============================================
- Coverage     80.12%   78.03%   -2.09%     
- Complexity     1199     1228      +29     
============================================
  Files           171      179       +8     
  Lines          4302     4335      +33     
  Branches        632      656      +24     
============================================
- Hits           3447     3383      -64     
- Misses          712      778      +66     
- Partials        143      174      +31
Impacted Files Coverage Δ Complexity Δ
.../admin/methods/response/PersonalUnlockAccount.java 100% <ø> (ø) 2 <0> (?)
...rc/main/java/org/web3j/protocol/parity/Parity.java 100% <ø> (ø) 1 <0> (ø) ⬇️
.../protocol/admin/methods/response/PersonalSign.java 100% <ø> (ø) 2 <0> (?)
...l/admin/methods/response/PersonalListAccounts.java 100% <ø> (ø) 2 <0> (?)
...tocol/geth/methods/response/PersonalEcRecover.java 100% <ø> (ø) 2 <0> (?)
...l/parity/methods/response/ParityDeriveAddress.java 100% <100%> (ø) 2 <2> (?)
...l/admin/methods/response/NewAccountIdentifier.java 100% <100%> (ø) 2 <2> (?)
...rity/methods/response/ParityAddressesResponse.java 100% <100%> (ø) 2 <2> (?)
...methods/response/ParityDefaultAddressResponse.java 100% <100%> (ø) 2 <2> (?)
...l/parity/methods/response/ParityExportAccount.java 100% <100%> (ø) 2 <2> (?)
... and 22 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7db9d31...93983c7. Read the comment docs.

@conor10 conor10 merged commit 9a9d382 into hyperledger:master Aug 9, 2017
@conor10
Copy link
Contributor

conor10 commented Aug 9, 2017

Great work!

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.

None yet

3 participants