From 5fcbb651b43b588625392107cb72b05f0991e737 Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Mon, 25 Jan 2021 11:39:26 -0600 Subject: [PATCH 1/6] Add default for fromBlock options --- packages/web3-core-helpers/src/formatters.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/web3-core-helpers/src/formatters.js b/packages/web3-core-helpers/src/formatters.js index 0b0e580cbf7..9ee16a70b9f 100644 --- a/packages/web3-core-helpers/src/formatters.js +++ b/packages/web3-core-helpers/src/formatters.js @@ -345,6 +345,8 @@ var inputLogFormatter = function (options) { return utils.fromUtf8(value); }; + if (options === undefined) options = {} + if (options.fromBlock === undefined) options = {...options, fromBlock: 'latest'} if (options.fromBlock || options.fromBlock === 0) options.fromBlock = inputBlockNumberFormatter(options.fromBlock); From 83c5e394893c424f0beef4dda0214a12bfd55f50 Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Mon, 25 Jan 2021 12:01:24 -0600 Subject: [PATCH 2/6] Add comment --- packages/web3-core-helpers/src/formatters.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/web3-core-helpers/src/formatters.js b/packages/web3-core-helpers/src/formatters.js index 9ee16a70b9f..6f9af04de0d 100644 --- a/packages/web3-core-helpers/src/formatters.js +++ b/packages/web3-core-helpers/src/formatters.js @@ -346,7 +346,8 @@ var inputLogFormatter = function (options) { }; if (options === undefined) options = {} - if (options.fromBlock === undefined) options = {...options, fromBlock: 'latest'} + // 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); From 27090d58089646a9df07a0ec38c8b834b5c0fcf6 Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Mon, 25 Jan 2021 12:09:01 -0600 Subject: [PATCH 3/6] Update --- CHANGELOG.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbc2f5d4a2f..57114c35199 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -309,15 +309,15 @@ Released with 1.0.0-beta.37 code base. - Grammar changes to inputAddressFormatter error message - Fixed vulnerable dependencies -## [Unreleased] - -## [1.3.2] +## [1.3.3] ### Fixed - Fix EIP-1193 provider subscriptions (#3864) -## [1.3.3] +## [Unreleased] + +## [1.3.4] ### Changed @@ -327,9 +327,12 @@ Released with 1.0.0-beta.37 code base. - Bump `ts-node` from version `^8.10.2` to `^9.0.0` - Ran `npm audit fix` which fixed 4 vulnerabilities - Correct `web3-eth2-beaconchain` type declarations +- Fix default value for `fromBlock` option for `logs` subscriptions (defaults to `latest`) ### Added + - Deprecation of bzz warning ### Removed + - ethjs-signer test (#3876) From 4520d9939340561282877c0a7874c70fc2a2705a Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Mon, 25 Jan 2021 14:33:39 -0600 Subject: [PATCH 4/6] Add expected fromBlock property to test --- test/contract.js | 1 + 1 file changed, 1 insertion(+) 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',''), From 38ab5c952383db5a40a1065f98ec5f04d5607472 Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Mon, 25 Jan 2021 14:57:45 -0600 Subject: [PATCH 5/6] Merge conflict --- CHANGELOG.md | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 998e9423a48..71bbff0cf5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -315,9 +315,7 @@ Released with 1.0.0-beta.37 code base. - Fix EIP-1193 provider subscriptions (#3864) -## [Unreleased] - -## [1.3.4] +## [1.3.3] ### Fixed @@ -329,32 +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) -- Rename `web3-eth2-base` to `web3-eth2-core` and `web3-eth2-beacon` to `web3-eth2-beaconchain` -- Bump `ts-node` from version `^8.10.2` to `^9.0.0` -- Ran `npm audit fix` which fixed 4 vulnerabilities -- Correct `web3-eth2-beaconchain` type declarations -- Fix default value for `fromBlock` option for `logs` subscriptions (defaults to `latest`) - -### Added - -- Deprecation of bzz warning - -### Removed - +- 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) From fc13d069ba95f6479886b8145abd30f05fea3059 Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Mon, 25 Jan 2021 16:57:19 -0600 Subject: [PATCH 6/6] Update docs --- docs/web3-eth-subscribe.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.