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

Custom TransactionSigner and eth-account module improvements. #2367

Merged
merged 84 commits into from
Feb 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
b0b4d42
web3 socket provider types fixed in web3-providers module
Feb 10, 2019
6c7cbfe
POC eth-accounts module refactoring
Feb 10, 2019
bb5f07e
eth-accounts module simplified and TransactionSigner moved to eth module
Feb 10, 2019
dff64f0
eth-accounts module simplified and SendTransactionMethod handlin in c…
Feb 11, 2019
bb3c21c
eth_chainId method implemented
Feb 18, 2019
3de3d21
Merge branch '1.0' into issue/2356
nivida Feb 18, 2019
fcc3d6c
Merge branch 'issues/2378' into issue/2356
Feb 18, 2019
d98cef2
MethodFactory and TransactionSigner updated with ChainIdMethod in the…
Feb 18, 2019
4b174ed
AllEventsLogDecoder fixed
Feb 19, 2019
f4ef0fa
Revert "AllEventsLogDecoder fixed"
Feb 19, 2019
96b731d
Merge branch '1.0' into issue/2356
nivida Feb 20, 2019
b112742
throIfMissing removed because it isn't required
Feb 20, 2019
c2d4083
Merge branch '1.0' into issue/2356
nivida Feb 21, 2019
0827f58
Dependency handling updated, funcDocs added and todo's added
Feb 21, 2019
8142c1a
Merge branch 'issue/2356' of github.com:ethereum/web3.js into issue/2356
Feb 21, 2019
86242db
Proxy added in Accounts constructor for security reasons.
Feb 21, 2019
f9048c7
TransactionSigner updated and hasWallets removed ffrom the AbstractMe…
Feb 21, 2019
7ba1ee0
TransactionSigner export added in index.js
Feb 21, 2019
67fb030
signTransaction in Account and Accounts class updated
Feb 21, 2019
7d2b675
models folder created and AccountsModuleFactory updated
Feb 21, 2019
5f84479
SendTransactionMethod updated, Account factory method parameters upda…
Feb 21, 2019
82967cf
Dependency handling updated in eth-accounts module
Feb 21, 2019
56efe5c
Tranasaction validation from TransactionSigner moved to SendTransacti…
Feb 21, 2019
051a87d
setting of a custom transaction signer in the eth module constructor …
Feb 21, 2019
6cf0b43
SignMethod updated, signers removed , SendTransactionMethod updated a…
Feb 21, 2019
6bfeb95
eslint executed
Feb 21, 2019
243f44b
short sentence added to the signTransaction method because this metho…
Feb 21, 2019
adf8b80
unnecessary dependency removed in SignMethod
Feb 21, 2019
1819c5a
SendTransactionMethod updated if any custom signer got defined which …
Feb 21, 2019
b78ae98
SendTransactionMethod signing workflow improved
Feb 21, 2019
78994b3
codestyle improvements
Feb 21, 2019
19ba31e
Merge branch '1.0' into issue/2356
nivida Feb 21, 2019
9129509
AccountsTest updated and not required test cases moved to new test files
Feb 22, 2019
6b770d5
TransactionSignerTest template created
Feb 22, 2019
9a1ca27
Merge branch 'issue/2356' of github.com:ethereum/web3.js into issue/2356
Feb 22, 2019
800cc3d
Account, Accounts and AccountsModuleFactory updated
Feb 22, 2019
8533bd4
SendTransactionMeethod updated and signTransaction in eth-accounts up…
Feb 22, 2019
ffe3990
index.js updated and factory removed in eth-accounts module
Feb 22, 2019
00218c2
Proxy added to Wallet
Feb 22, 2019
14f1c93
AccountsTest updated
Feb 22, 2019
3e5515b
utils method mocks fixed in AccountsTest
Feb 22, 2019
a785dae
AccountsTest and AccountTest fixed
Feb 22, 2019
72a48b4
Wallet class removed and logic moved to the Accounts module. Proxy im…
Feb 22, 2019
77374ac
Accounts updated
Feb 22, 2019
06bfe7b
Accounts and AccountsTest updated
Feb 22, 2019
3b604ce
code style improvements
Feb 22, 2019
a6c24f9
possibility added for using the API of the wallet like this: accounts…
Feb 22, 2019
24f33d6
SendTransactionMethod updated and started with updating the regarding…
Feb 23, 2019
16422d9
Readability of the SendTransactionMethod class improved
Feb 23, 2019
ae1a7f2
ongoing work of test and SendTransactionMethod improved
Feb 25, 2019
db23477
error case for local signing added and SendTransactionMethod updated
Feb 25, 2019
b8af36a
SendTransactionMethod updated and SendTransactionMethodTest fixed
Feb 25, 2019
60f8d88
TransactionSigner and MessageSigner in tests removed
Feb 25, 2019
847497e
SignMethod tested and updated
Feb 26, 2019
9e74e02
Dependency handling fixed in eth-accounts index.js file
Feb 26, 2019
8e34e80
Readability of the TransactionSigner improved and eslint executed
Feb 26, 2019
2565a34
transaction mapping moved to TransactionSigner and Accounts signTrans…
Feb 26, 2019
949b694
TransactionSigner and TransactionSignerTest updated
Feb 26, 2019
1390ca5
Merge branch '1.0' into issue/2356
nivida Feb 26, 2019
dc6818b
factory pattern updated in eth module instead of updating the factory…
Feb 26, 2019
de24e56
EthTest updated
Feb 26, 2019
f89f6ac
core-method, core and eth-accounts module tests updated
Feb 26, 2019
2c085d6
eth-contract tests updated
Feb 26, 2019
f94db26
Merge branch '1.0' into issue/2356
nivida Feb 26, 2019
be3191d
tests fixed and code style improved
Feb 26, 2019
e24877b
Merge branch 'issue/2356' of github.com:ethereum/web3.js into issue/2356
Feb 26, 2019
e230dc1
Merge branch '1.0' into issue/2356
nivida Feb 26, 2019
b1be9ab
Merge branch '1.0' into issue/2356
nivida Feb 26, 2019
3dc1987
dependency handling of the transaction signer fixed
Feb 26, 2019
ddbfad8
Merge branch 'issue/2356' of github.com:ethereum/web3.js into issue/2356
Feb 26, 2019
cdc5e05
dependency handling checked and the eth module transactionSigner sett…
Feb 26, 2019
a1aeeb7
tests updated
Feb 26, 2019
8a4a097
linter executed and errors fixed
Feb 26, 2019
7e3c1f8
contract handling tested and fixed
Feb 26, 2019
0325c48
fixes for contract send methods in the browser
Feb 27, 2019
39de6ec
workflow logic for local or remote signing fixed in SendTransactionMe…
Feb 27, 2019
3448130
core-method module fixed
Feb 27, 2019
06dea03
eth-contract module tests fixed
Feb 27, 2019
304517c
SignMethod updated
Feb 27, 2019
faf0743
SignMethod updated
Feb 27, 2019
2ed7046
SignMethod and SignMethodTest fixed
Feb 27, 2019
13c6857
documentation updated
Feb 27, 2019
5f4b969
Accounts method hashMessage readded
Feb 27, 2019
13eb73d
privatKey check in TransactionSigner fixed and link in documentation …
Feb 27, 2019
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
48 changes: 46 additions & 2 deletions docs/include_package-core.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

options
=====================

Expand All @@ -23,6 +22,8 @@ Module Options

:ref:`transactionPollingTimeout <web3-module-transactionpollingtimeout>`

:ref:`transactionSigner <web3-module-transactionSigner>`

-------
Example
-------
Expand All @@ -38,7 +39,8 @@ Example
defaultGasPrice: 0,
transactionBlockTimeout: 50,
transactionConfirmationBlocks: 24,
transactionPollingTimeout: 480
transactionPollingTimeout: 480,
transactionSigner: new CustomTransactionSigner()
}

const web3 = new Web3('http://localhost:8545', options);
Expand Down Expand Up @@ -207,6 +209,48 @@ Returns

------------------------------------------------------------------------------


.. _web3-module-transactionSigner:

transactionSigner
=================

.. code-block:: javascript

web3.eth.transactionSigner
...



The ``transactionSigner`` property does provide us the possibility to customize the signing process
of the ``Eth`` module and the related sub-modules.

The interface of a ``TransactionSigner``:

.. code-block:: javascript

interface TransactionSigner {
sign(txObject: Transaction): Promise<SignedTransaction>
}

interface SignedTransaction {
messageHash: string,
v: string,
r: string,
s: string,
rawTransaction: string
}



-------
Returns
-------

``TransactionSigner``: A JavaScript class of type TransactionSigner.

------------------------------------------------------------------------------

setProvider
=====================

Expand Down
3 changes: 2 additions & 1 deletion docs/web3-eth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,8 @@ signTransaction

web3.eth.signTransaction(transactionObject [, address] [, callback])

Signs a transaction. This account needs to be unlocked.
The method ``signTransaction`` signs a transaction with the private key of the given address.
This method does only work if you're connected to a Parity node.

----------
Parameters
Expand Down
116 changes: 116 additions & 0 deletions packages/web3-core-helpers/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 10 additions & 13 deletions packages/web3-core-method/lib/factories/AbstractMethodFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
* @date 2018
*/

import SendRawTransactionMethod from '../../src/methods/transaction/SendRawTransactionMethod';
import GetTransactionCountMethod from '../../src/methods/account/GetTransactionCountMethod';
import ChainIdMethod from '../../src/methods/network/ChainIdMethod';

export default class AbstractMethodFactory {
/**
* @param {MethodModuleFactory} methodModuleFactory
Expand Down Expand Up @@ -89,25 +93,18 @@ export default class AbstractMethodFactory {
/* eslint-disable new-cap */
switch (method.Type) {
case 'CALL':
if (method.name === 'SignMethod') {
return new method(
this.utils,
this.formatters,
this.methodModuleFactory.accounts,
this.methodModuleFactory.createMessageSigner()
);
}

return new method(this.utils, this.formatters);
case 'SEND':
if (method.name === 'SendTransactionMethod') {
const transactionConfirmationWorkflow = this.methodModuleFactory.createTransactionConfirmationWorkflow();

return new method(
this.utils,
this.formatters,
this.methodModuleFactory.createTransactionConfirmationWorkflow(),
this.methodModuleFactory.accounts,
this.methodModuleFactory.createTransactionSigner(),
this.methodModuleFactory.createSendRawTransactionMethod()
transactionConfirmationWorkflow,
new SendRawTransactionMethod(this.utils, this.formatters, transactionConfirmationWorkflow),
new ChainIdMethod(this.utils, this.formatters),
new GetTransactionCountMethod(this.utils, this.formatters)
);
}

Expand Down
11 changes: 0 additions & 11 deletions packages/web3-core-method/lib/methods/AbstractMethod.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,4 @@ export default class AbstractMethod {
isHash(parameter) {
return isString(parameter) && parameter.indexOf('0x') === 0;
}

/**
* Checks if accounts is defined and if wallet is not empty
*
* @method hasWallet
*
* @returns {Boolean}
*/
hasWallets() {
return this.accounts && this.accounts.wallet.length > 0;
}
}
Loading