Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 7499a1e

Browse files
authored
Merge branch '1.0' into issue/2468
2 parents 3c0cb3a + 6fb8c14 commit 7499a1e

33 files changed

+2868
-225
lines changed

docs/web3-eth-accounts.rst

+5-3
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Returns
163163
- ``s`` - ``String``: Next 32 bytes of the signature
164164
- ``v`` - ``String``: Recovery value + 27
165165
- ``rawTransaction`` - ``String``: The RLP encoded transaction, ready to be send using :ref:`web3.eth.sendSignedTransaction <eth-sendsignedtransaction>`.
166-
166+
- ``transactionHash`` - ``String``: The transaction hash for the RLP encoded transaction.
167167

168168
-------
169169
Example
@@ -182,7 +182,8 @@ Example
182182
v: '0x25',
183183
r: '0xc9cf86333bcb065d140032ecaab5d9281bde80f21b9687b3e94161de42d51895',
184184
s: '0x727a108a0b8d101465414033c3f705a9c7b826e596766046ee1183dbc8aeaa68',
185-
rawTransaction: '0xf869808504e3b29200831e848094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca008025a0c9cf86333bcb065d140032ecaab5d9281bde80f21b9687b3e94161de42d51895a0727a108a0b8d101465414033c3f705a9c7b826e596766046ee1183dbc8aeaa68'
185+
rawTransaction: '0xf869808504e3b29200831e848094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca008025a0c9cf86333bcb065d140032ecaab5d9281bde80f21b9687b3e94161de42d51895a0727a108a0b8d101465414033c3f705a9c7b826e596766046ee1183dbc8aeaa68',
186+
transactionHash: '0xde8db924885b0803d2edc335f745b2b8750c8848744905684c20b987443a9593'
186187
}
187188
188189
web3.eth.accounts.signTransaction({
@@ -199,7 +200,8 @@ Example
199200
r: '0x9ebb6ca057a0535d6186462bc0b465b561c94a295bdb0621fc19208ab149a9c',
200201
s: '0x440ffd775ce91a833ab410777204d5341a6f9fa91216a6f3ee2c051fea6a0428',
201202
v: '0x25',
202-
rawTransaction: '0xf86a8086d55698372431831e848094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca008025a009ebb6ca057a0535d6186462bc0b465b561c94a295bdb0621fc19208ab149a9ca0440ffd775ce91a833ab410777204d5341a6f9fa91216a6f3ee2c051fea6a0428'
203+
rawTransaction: '0xf86a8086d55698372431831e848094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca008025a009ebb6ca057a0535d6186462bc0b465b561c94a295bdb0621fc19208ab149a9ca0440ffd775ce91a833ab410777204d5341a6f9fa91216a6f3ee2c051fea6a0428',
204+
transactionHash: '0xd8f64a42b57be0d565f385378db2f6bf324ce14a594afc05de90436e9ce01f60'
203205
}
204206
205207

docs/web3-eth-admin.rst

+10-2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ getDataDirectory
7474
admin.getDataDirectory([, callback])
7575
7676
Provides absolute path of the running node, which is used by the node to store all its databases.
77+
The RPC method used is ``admin_datadir``.
7778

7879
----------
7980
Parameters
@@ -114,6 +115,7 @@ getNodeInfo
114115
admin.getNodeInfo([, callback])
115116
116117
This property can be queried for all the information known about the running node at the networking granularity..
118+
The RPC method used is ``admin_nodeInfo``.
117119

118120
----------
119121
Parameters
@@ -181,6 +183,7 @@ getPeers
181183
admin.getPeers([, callback])
182184
183185
This will provide all the information known about the connected remote nodes at the networking granularity.
186+
The RPC method used is ``admin_peers``.
184187

185188
----------
186189
Parameters
@@ -258,6 +261,7 @@ setSolc
258261
admin.setSolc(string, [, callback])
259262
260263
Sets the Solidity compiler path to be used by the node when invoking the eth_compileSolidity RPC method
264+
The RPC method used is ``admin_setSolc``.
261265

262266
----------
263267
Parameters
@@ -297,13 +301,14 @@ startRPC
297301
admin.startRPC(host, port, cors, apis [, callback])
298302
299303
It starts an HTTP based JSON RPC API webserver to handle client requests. All the parameters are optional.
304+
The RPC method used is ``admin_startRPC``.
300305

301306
----------
302307
Parameters
303308
----------
304309

305310
1. ``host`` - ``String`` - (optional) The network interface to open the listener socket on (defaults to "localhost").
306-
2. ``port`` - ``string | number`` - (optional) The network port to open the listener socket on (defaults to 8545).
311+
2. ``port`` - ``number`` - (optional) The network port to open the listener socket on (defaults to 8545).
307312
3. ``cors`` - ``string`` - (optional) Cross-origin resource sharing header to use (defaults to "").
308313
4. ``apis`` - ``string`` - (optional) API modules to offer over this interface (defaults to "eth,net,web3").
309314
5. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
@@ -337,13 +342,14 @@ startWS
337342
admin.startWS(host, port, cors, apis [, callback])
338343
339344
It starts an WebSocket based JSON RPC API webserver to handle client requests. All the parameters are optional.
345+
The RPC method used is ``admin_startWS``.
340346

341347
----------
342348
Parameters
343349
----------
344350

345351
1. ``host`` - ``String`` - (optional) The network interface to open the listener socket on (defaults to "localhost").
346-
2. ``port`` - ``string | number`` - (optional) The network port to open the listener socket on (defaults to 8545).
352+
2. ``port`` - ``number`` - (optional) The network port to open the listener socket on (defaults to 8545).
347353
3. ``cors`` - ``string`` - (optional) Cross-origin resource sharing header to use (defaults to "").
348354
4. ``apis`` - ``string`` - (optional) API modules to offer over this interface (defaults to "eth,net,web3").
349355
5. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
@@ -376,6 +382,7 @@ stopRPC
376382
admin.stopRPC([, callback])
377383
378384
This method closes the currently open HTTP RPC endpoint. As the node can only have a single HTTP endpoint running, this method takes no parameters, returning a boolean whether the endpoint was closed or not.
385+
The RPC method used is ``admin_stopRPC``.
379386

380387
----------
381388
Parameters
@@ -410,6 +417,7 @@ stopWS
410417
admin.stopWS([, callback])
411418
412419
This method closes the currently open WebSocket RPC endpoint. As the node can only have a single WebSocket endpoint running, this method takes no parameters, returning a boolean whether the endpoint was closed or not.
420+
The RPC method used is ``admin_stopWS``.
413421

414422
----------
415423
Parameters

docs/web3-eth-miner.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ setExtra
3636
miner.setExtra(extraData, [, callback])
3737
3838
This method allows miner to set extra data during mining the block.
39+
The RPC method used is ``miner_setExtra``.
3940

4041
----------
4142
Parameters
@@ -70,7 +71,7 @@ setGasPrice
7071
miner.setGasPrice(gasPrice, [, callback])
7172
7273
This method allows to set minimal accepted gas price during mining transactions. Any transactions that are below this limit will get excluded from the mining process.
73-
74+
The RPC method used is ``miner_setGasPrice``.
7475
----------
7576
Parameters
7677
----------
@@ -113,6 +114,7 @@ setEtherBase
113114
miner.setEtherBase(address, [, callback])
114115
115116
Sets etherbase, where mining reward will go.
117+
The RPC method used is ``miner_setEtherbase``.
116118

117119
----------
118120
Parameters
@@ -152,6 +154,7 @@ start
152154
miner.start(miningThread, [, callback])
153155
154156
Start the CPU mining process with the given number of threads.
157+
The RPC method used is ``miner_start``.
155158

156159
----------
157160
Parameters
@@ -194,6 +197,7 @@ stop
194197
miner.stop([callback])
195198
196199
Stop the CPU mining process.
200+
The RPC method used is ``miner_stop``.
197201

198202
----------
199203
Parameters

docs/web3-eth-txpool.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
.. include:: include_announcement.rst
44

5-
===============
6-
web3.eth.txpool
7-
===============
5+
==================
6+
Web3 Txpool Module
7+
==================
88

99

1010
The ``web3-eth-txpool`` package gives you access to several non-standard RPC methods to inspect the contents of the transaction pool containing all the currently pending transactions as well as the ones queued for future processing.

packages/web3-core-method/lib/methods/transaction/AbstractObservedTransactionMethod.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ export default class AbstractObservedTransactionMethod extends AbstractMethod {
112112
return;
113113
}
114114

115-
this.promiEvent.emit('confirmation', confirmations, this.afterExecution(receipt));
115+
this.promiEvent.emit(
116+
'confirmation',
117+
confirmations,
118+
this.formatters.outputTransactionFormatter(receipt)
119+
);
116120
},
117121
(error) => {
118122
this.handleError(error, receipt, confirmations);

packages/web3-core-method/src/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,3 @@ export SetExtraMethod from './methods/miner/SetExtraMethod';
142142
export SetGasPriceMethod from './methods/miner/SetGasPriceMethod';
143143
export StartMinerMethod from './methods/miner/StartMinerMethod';
144144
export StopMinerMethod from './methods/miner/StopMinerMethod';
145-

packages/web3-core-method/src/methods/transaction/SendRawTransactionMethod.js

+13
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,17 @@ export default class SendRawTransactionMethod extends AbstractObservedTransactio
3434
constructor(utils, formatters, moduleInstance, transactionObserver) {
3535
super('eth_sendRawTransaction', 1, utils, formatters, moduleInstance, transactionObserver);
3636
}
37+
38+
/**
39+
* This method will be executed after the RPC request.
40+
*
41+
* @method afterExecution
42+
*
43+
* @param {Object} response
44+
*
45+
* @returns {Object}
46+
*/
47+
afterExecution(response) {
48+
return this.formatters.outputTransactionFormatter(response);
49+
}
3750
}

packages/web3-core-method/src/methods/transaction/SendTransactionMethod.js

+13
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,17 @@ export default class SendTransactionMethod extends AbstractObservedTransactionMe
4545
beforeExecution(moduleInstance) {
4646
this.parameters[0] = this.formatters.inputTransactionFormatter(this.parameters[0], moduleInstance);
4747
}
48+
49+
/**
50+
* This method will be executed after the RPC request.
51+
*
52+
* @method afterExecution
53+
*
54+
* @param {Object} response
55+
*
56+
* @returns {Object}
57+
*/
58+
afterExecution(response) {
59+
return this.formatters.outputTransactionFormatter(response);
60+
}
4861
}

packages/web3-core-method/src/observers/TransactionObserver.js

+2-15
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export default class TransactionObserver {
150150

151151
if (receipt) {
152152
if (this.lastBlock) {
153-
const block = await this.getBlockByNumber(this.increaseBlockNumber(this.lastBlock.number));
153+
const block = await this.getBlockByNumber(this.lastBlock.number + 1);
154154

155155
if (block && this.isValidConfirmation(block)) {
156156
this.lastBlock = block;
@@ -164,8 +164,8 @@ export default class TransactionObserver {
164164
}
165165

166166
if (this.isConfirmed()) {
167-
clearInterval(interval);
168167
observer.complete();
168+
clearInterval(interval);
169169
}
170170
}
171171

@@ -269,17 +269,4 @@ export default class TransactionObserver {
269269
isTimeoutTimeExceeded() {
270270
return this.confirmationChecks === this.timeout;
271271
}
272-
273-
/**
274-
* Increases the blockNumber hash by one.
275-
*
276-
* @method increaseBlockNumber
277-
*
278-
* @param {String} blockNumber
279-
*
280-
* @returns {String}
281-
*/
282-
increaseBlockNumber(blockNumber) {
283-
return '0x' + (parseInt(blockNumber, 16) + 1).toString(16);
284-
}
285272
}

packages/web3-core-method/tests/lib/methods/transaction/AbstractObservedTransactionMethodTest.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import {formatters} from 'web3-core-helpers';
12
import PromiEvent from '../../../../lib/PromiEvent';
23
import TransactionObserver from '../../../../src/observers/TransactionObserver';
34
import AbstractObservedTransactionMethod from '../../../../lib/methods/transaction/AbstractObservedTransactionMethod';
45

56
// Mocks
7+
jest.mock('web3-core-helpers');
68
jest.mock('../../../../src/observers/TransactionObserver');
79

810
/**
@@ -43,7 +45,7 @@ describe('AbstractObservedTransactionMethodTest', () => {
4345
'rpcMethod',
4446
5,
4547
{},
46-
{},
48+
formatters,
4749
moduleInstanceMock,
4850
transactionObserverMock
4951
);
@@ -68,6 +70,8 @@ describe('AbstractObservedTransactionMethodTest', () => {
6870
it('calls execute with event listeners and is emitting the expected values', (done) => {
6971
providerMock.send.mockReturnValueOnce(Promise.resolve('transactionHash'));
7072

73+
formatters.outputTransactionFormatter.mockReturnValue({status: false});
74+
7175
observableMock.subscribe = jest.fn((next, error, complete) => {
7276
next({confirmations: 0, receipt: {status: true}});
7377

@@ -88,7 +92,11 @@ describe('AbstractObservedTransactionMethodTest', () => {
8892

8993
expect(transactionHashCallback).toHaveBeenCalledWith('transactionHash');
9094

91-
expect(confirmationCallback).toHaveBeenCalledWith(0, {status: true});
95+
expect(confirmationCallback).toHaveBeenCalledWith(0, {status: false});
96+
97+
expect(formatters.outputTransactionFormatter).toHaveBeenNthCalledWith(1, {status: true});
98+
99+
expect(formatters.outputTransactionFormatter).toHaveBeenCalledTimes(1);
92100

93101
done();
94102
});
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import AbstractObservedTransactionMethod from '../../../../lib/methods/transaction/AbstractObservedTransactionMethod';
22
import SendRawTransactionMethod from '../../../../src/methods/transaction/SendRawTransactionMethod';
3+
import {formatters} from 'web3-core-helpers';
4+
5+
// Mocks
6+
jest.mock('web3-core-helpers');
37

48
/**
59
* SendRawTransactionMethod test
@@ -8,12 +12,20 @@ describe('SendRawTransactionMethodTest', () => {
812
let method;
913

1014
beforeEach(() => {
11-
method = new SendRawTransactionMethod(null, null, null, {});
15+
method = new SendRawTransactionMethod(null, formatters, null, {});
1216
});
1317

1418
it('constructor check', () => {
1519
expect(method).toBeInstanceOf(AbstractObservedTransactionMethod);
1620

1721
expect(method.rpcMethod).toEqual('eth_sendRawTransaction');
1822
});
23+
24+
it('calls afterExecution and returns the expected value', () => {
25+
formatters.outputTransactionFormatter.mockReturnValueOnce({status: true});
26+
27+
expect(method.afterExecution({status: false})).toEqual({status: true});
28+
29+
expect(formatters.outputTransactionFormatter).toHaveBeenCalledWith({status: false});
30+
});
1931
});

packages/web3-core-method/tests/src/methods/transaction/SendTransactionMethodTest.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import {formatters} from 'web3-core-helpers';
66
jest.mock('web3-core-helpers');
77

88
/**
9-
* SendRawTransactionMethod test
9+
* SendTransactionMethod test
1010
*/
11-
describe('SendRawTransactionMethodTest', () => {
11+
describe('SendTransactionMethodTest', () => {
1212
let method;
1313

1414
beforeEach(() => {
@@ -32,4 +32,12 @@ describe('SendRawTransactionMethodTest', () => {
3232

3333
expect(formatters.inputTransactionFormatter).toHaveBeenCalledWith('tx', {});
3434
});
35+
36+
it('calls afterExecution and returns the expected value', () => {
37+
formatters.outputTransactionFormatter.mockReturnValueOnce({status: true});
38+
39+
expect(method.afterExecution({status: false})).toEqual({status: true});
40+
41+
expect(formatters.outputTransactionFormatter).toHaveBeenCalledWith({status: false});
42+
});
3543
});

packages/web3-core-method/tests/src/observers/TransactionObserverTest.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ describe('TransactionObserverTest', () => {
189189

190190
providerMock.supportsSubscriptions.mockReturnValueOnce(false);
191191

192-
const receipt = {blockNumber: '0xa'};
193-
const blockOne = {number: '0xa', hash: '0x0'};
194-
const blockTwo = {number: '0xc', parentHash: '0x0'};
192+
const receipt = {blockNumber: 1};
193+
const blockOne = {number: 1, hash: '0x0'};
194+
const blockTwo = {number: 2, parentHash: '0x0'};
195195

196196
getTransactionReceiptMethodMock.execute
197197
.mockReturnValueOnce(Promise.resolve(receipt))
@@ -222,7 +222,7 @@ describe('TransactionObserverTest', () => {
222222

223223
expect(getTransactionReceiptMethodMock.parameters).toEqual(['transactionHash']);
224224

225-
expect(getBlockByNumberMethodMock.parameters).toEqual(['0xb']);
225+
expect(getBlockByNumberMethodMock.parameters).toEqual([2]);
226226

227227
done();
228228
}
@@ -235,8 +235,8 @@ describe('TransactionObserverTest', () => {
235235

236236
providerMock.supportsSubscriptions.mockReturnValueOnce(false);
237237

238-
const receipt = {blockNumber: '0xa'};
239-
const blockOne = {number: '0xa', hash: '0x0'};
238+
const receipt = {blockNumber: 1};
239+
const blockOne = {number: 1, hash: '0x0'};
240240

241241
getTransactionReceiptMethodMock.execute.mockReturnValueOnce(Promise.resolve(receipt));
242242

0 commit comments

Comments
 (0)