From 7df4a7bcaa99699b610f9101a10d9dbdbc3fde8a Mon Sep 17 00:00:00 2001
From: Christoph Otter <chris@confio.gmbh>
Date: Tue, 30 Jul 2024 11:20:23 +0200
Subject: [PATCH 1/3] Add default impl for Storage::range

---
 packages/std/src/traits.rs | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/packages/std/src/traits.rs b/packages/std/src/traits.rs
index 72eb7e56d4..ee9c91fdd2 100644
--- a/packages/std/src/traits.rs
+++ b/packages/std/src/traits.rs
@@ -61,12 +61,17 @@ pub trait Storage {
     /// The bound `start` is inclusive and `end` is exclusive.
     /// If `start` is lexicographically greater than or equal to `end`, an empty range is described, mo matter of the order.
     #[cfg(feature = "iterator")]
+    #[allow(unused_variables)]
     fn range<'a>(
         &'a self,
         start: Option<&[u8]>,
         end: Option<&[u8]>,
         order: Order,
-    ) -> Box<dyn Iterator<Item = Record> + 'a>;
+    ) -> Box<dyn Iterator<Item = Record> + 'a> {
+        // This default implementation is just to avoid breaking code when enabling the `iterator` feature.
+        // Any actual `Storage` impl should override this method.
+        Box::new(std::iter::empty())
+    }
 
     /// Allows iteration over a set of keys, either forwards or backwards.
     ///

From c2a76099c3011b553965aecb9bba713d0f8e9817 Mon Sep 17 00:00:00 2001
From: Christoph Otter <chris@confio.gmbh>
Date: Tue, 30 Jul 2024 11:56:06 +0200
Subject: [PATCH 2/3] Use unimplemented

---
 packages/std/src/traits.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/packages/std/src/traits.rs b/packages/std/src/traits.rs
index ee9c91fdd2..4ea7e81249 100644
--- a/packages/std/src/traits.rs
+++ b/packages/std/src/traits.rs
@@ -70,7 +70,7 @@ pub trait Storage {
     ) -> Box<dyn Iterator<Item = Record> + 'a> {
         // This default implementation is just to avoid breaking code when enabling the `iterator` feature.
         // Any actual `Storage` impl should override this method.
-        Box::new(std::iter::empty())
+        unimplemented!("This storage does not support ranging. Make sure to override the `range` method in your `Storage` implementation.")
     }
 
     /// Allows iteration over a set of keys, either forwards or backwards.

From adc9fd125cec0dfc43d88163c9a90df19a56cb54 Mon Sep 17 00:00:00 2001
From: Christoph Otter <chris@confio.gmbh>
Date: Tue, 30 Jul 2024 12:34:47 +0200
Subject: [PATCH 3/3] Add changelog entry

---
 CHANGELOG.md | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 23f1352c91..177d25ad01 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,8 +12,11 @@ and this project adheres to
 
 - cosmwasm-std: Make fields of `IbcAckCallbackMsg` and `IbcTimeoutCallbackMsg`
   public. ([#2191])
+- cosmwasm-std: Add default implementation for `Storage::range` to make
+  `iterator` feature additive. ([#2197])
 
 [#2191]: https://github.com/CosmWasm/cosmwasm/pull/2191
+[#2197]: https://github.com/CosmWasm/cosmwasm/pull/2197
 
 ## [2.1.0] - 2024-07-11