This repository was archived by the owner on Aug 2, 2022. It is now read-only.
Add multi_index::require_find #4227
Labels
dev experience
enhancement
WASM
Bugs that can be fixed by updating WASM code and do not require a hard fork
Milestone
Since
multi_index::get
can easily be misused as documented in issue #4226, contract developers should have an alternative that is safer.That alternative already exists. They can use
multi_index::find
to get aconst_iterator
and then pass thatconst_iterator
intomodify
orerase
.But a common pattern is to check that the iterator actually points to a real object (meaning the table row was found) and throw an assertion error otherwise. In fact,
get
makes this very convenient by taking an optional string argument with the assertion message to throw if the table row cannot be found.multi_index::require_find
would behave similarly toget
in the sense that it asserts that the requested table row was actually found and uses the optionally provided message string as the assertion failure message. However, it would return the safeconst_iterator
just likefind
does.The text was updated successfully, but these errors were encountered: