Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Mapping::insert_return_size with Mapping::insert #1463

Merged
merged 10 commits into from
Nov 8, 2022
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);
}

ascjones marked this conversation as resolved.
Show resolved Hide resolved
/// 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