diff --git a/CHANGELOG.md b/CHANGELOG.md index c3e3af0b1c7..71bbff0cf5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -327,19 +327,21 @@ Released with 1.0.0-beta.37 code base. ### Changed -- Remove `notImplemented` flag from ETH2 Beacon Chain package methods schema (#3861) - Fixed mutation of inputs to encoding and decoding functions (#3748) +- Fix default value for `fromBlock` option for `logs` subscriptions (defaults to `latest`) (#3883) +- ethjs-signer test (#3876) - Rename `web3-eth2-base` to `web3-eth2-core` and `web3-eth2-beacon` to `web3-eth2-beaconchain` (#3833) - Bump `ts-node` from version `^8.10.2` to `^9.0.0` (#3856) - Ran `npm audit fix` which fixed 4 vulnerabilities (#3856) - Correct `web3-eth2-beaconchain` type declarations (#3859) and (#3865) - Move interfaces `IBaseAPISchema` and `IBaseAPIMethodSchema` to `index.d.ts` for `web3-eth2-core` (#3878) -- Removes `IETH2BeaconChain` interface in favor of exporting a class type: `ETH2BeaconChain` (#3878) -- Remove `index.d.ts` files in favor of `types.ts` for `web3-eth2-core` and `web3-eth2-beaconchain` (#3878) - Update dependencies for `web3-eth2-core` (#3878) ### Removed +- Remove `notImplemented` flag from ETH2 Beacon Chain package methods schema (#3861) +- Removes `IETH2BeaconChain` interface in favor of exporting a class type: `ETH2BeaconChain` (#3878) +- Remove `index.d.ts` files in favor of `types.ts` for `web3-eth2-core` and `web3-eth2-beaconchain` (#3878) - `schema.ts` from `web3-eth2-core` (#3878) - `dtslint` npm command from `web3-eth2-core` and `web3-eth2-beaconchain` as `index.d.ts` files were removed (#3878) diff --git a/docs/web3-eth-subscribe.rst b/docs/web3-eth-subscribe.rst index 886754351c8..17ccaf21eb1 100644 --- a/docs/web3-eth-subscribe.rst +++ b/docs/web3-eth-subscribe.rst @@ -331,7 +331,7 @@ Parameters 1. ``"logs"`` - ``String``, the type of the subscription. 2. ``Object`` - The subscription options - - ``fromBlock`` - ``Number``: The number of the earliest block. By default ``null``. + - ``fromBlock`` - ``Number``: The ``fromBlock`` dictates at which block the subscription will start from, if it is left empty, the default is ``latest`` (a.k.a the chain head) - ``address`` - ``String|Array``: An address or a list of addresses to only get logs from particular account(s). - ``topics`` - ``Array``: An array of values which must each appear in the log entries. The order is important, if you want to leave topics out use ``null``, e.g. ``[null, '0x00...']``. You can also pass another array for each topic with options for that topic e.g. ``[null, ['option1', 'option2']]`` 3. ``callback`` - ``Function``: (optional) Optional callback, returns an error object as first parameter and the result as second. Will be called for each incoming subscription. diff --git a/packages/web3-core-helpers/src/formatters.js b/packages/web3-core-helpers/src/formatters.js index 0b0e580cbf7..6f9af04de0d 100644 --- a/packages/web3-core-helpers/src/formatters.js +++ b/packages/web3-core-helpers/src/formatters.js @@ -345,6 +345,9 @@ var inputLogFormatter = function (options) { return utils.fromUtf8(value); }; + if (options === undefined) options = {} + // If options !== undefined, don't blow out existing data + if (options.fromBlock === undefined) options = {...options, fromBlock: 'latest'} if (options.fromBlock || options.fromBlock === 0) options.fromBlock = inputBlockNumberFormatter(options.fromBlock); diff --git a/test/contract.js b/test/contract.js index 63d5386ab11..368b7dd8d87 100644 --- a/test/contract.js +++ b/test/contract.js @@ -2745,6 +2745,7 @@ var runTests = function(contractFactory) { assert.equal(payload.method, 'eth_getLogs'); assert.deepEqual(payload.params, [{ address: addressLowercase, + fromBlock: "latest", topics: [ "0x792991ed5ba9322deaef76cff5051ce4bedaaa4d097585970f9ad8f09f54e651", "0x000000000000000000000000" + address2.replace('0x',''),