Trie: make NULL available as type option for put value #3020
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
trie.put(key, null)
and
trie.put(key, Uint8Array.from([])
both should (and do) delete the value for that key:
ethereumjs-monorepo/packages/trie/src/trie.ts
Lines 194 to 198 in e2dc88b
--
However,
Null
is left out of the type options for the value paremeter:async put(key: Uint8Array, value: Uint8Array, skipKeyTransform: boolean = false): Promise<void>
The
official
trie tests actually do usenull
as a value. The reason the test does not throw a Type error is that thenull
values are wrapped in a variable with typeany
Since PUT does not actually accept
Null
values outright, users are forced to use empty Uint8Arrays, oras any
to access this part of the implementation.This PR adds
| null
as a type options for thevalue
parameter, bringing into alignment with the implementation itself.