Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ protocol for future versions of Polkadot.
- Introduce conditional compilation for messages, constructors and events ‒ [#1458](https://github.com/paritytech/ink/pull/1458)
- Add `Mapping::take()` function allowing to get a value removing it from storage ‒ [#1461](https://github.com/paritytech/ink/pull/1461)


### Changed
- Update `scale-info` requirement to `2.3` ‒ [#1467](https://github.com/paritytech/ink/pull/1467)
- Merge `Mapping::insert(key, val)` and `Mapping::insert_return_size(key, val)` into one method - [#1463](https://github.com/paritytech/ink/pull/1463)

### Removed
- Remove `ink_env::random` function ‒ [#1442](https://github.com/paritytech/ink/pull/1442)
Expand Down
14 changes: 2 additions & 12 deletions crates/storage/src/lazy/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,11 @@ where
V: Packed,
KeyType: StorageKey,
{
/// Insert the given `value` to the contract storage.
#[inline]
pub fn insert<Q, R>(&mut self, key: Q, value: &R)
where
Q: scale::EncodeLike<K>,
R: Storable + scale::EncodeLike<V>,
{
ink_env::set_contract_storage(&(&KeyType::KEY, key), value);
}

/// Insert the given `value` to the contract storage.
///
/// Returns the size of the pre-existing value at the specified key if any.
/// Returns the size in bytes of the pre-existing value at the specified key if any.
#[inline]
pub fn insert_return_size<Q, R>(&mut self, key: Q, value: &R) -> Option<u32>
pub fn insert<Q, R>(&mut self, key: Q, value: &R) -> Option<u32>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the docs can you also specify the returned size is in bytes?

where
Q: scale::EncodeLike<K>,
R: Storable + scale::EncodeLike<V>,
Expand Down