Skip to content

Commit 6f6cca1

Browse files
committed
chore: Update dependencies and SDK versions
1 parent 4806ccb commit 6f6cca1

File tree

11 files changed

+64
-71
lines changed

11 files changed

+64
-71
lines changed

CHANGELOG.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,3 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8-
9-
## [2.0.3](https://github.com/utnet-org/utility-sdk-rs/compare/unc-sdk-v2.0.2...unc-sdk-v2.0.3) - 2024-05-28
10-
11-
### Other
12-
- Update variable
13-
- Update deprecated items to use the correct version number
14-
- trybuild testcase compilation_tests
15-
- Update unc-sdk and unc-sys dependencies to version 2.0.2

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ members = [
99
exclude = ["examples/"]
1010

1111
[workspace.package]
12-
version = "2.0.5"
12+
version = "2.0.6"
1313

1414
# Special triple # comment for ci.
1515
[patch.crates-io]

unc-contract-standards/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Utility smart contracts standard library.
1313
"""
1414

1515
[dependencies]
16-
unc-sdk = { path = "../unc-sdk", version = "2.0.5", default-features = false, features = ["legacy"] }
16+
unc-sdk = { path = "../unc-sdk", version = "2.0.6", default-features = false, features = ["legacy"] }
1717

1818
[dev-dependencies]
1919
unc-sdk = { path = "../unc-sdk", default-features = false, features = ["unit-testing"] }

unc-sdk/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ required-features = ["abi", "unstable"]
2121
# Provide unc_bidgen macros.
2222
serde = { version = "1", features = ["derive"] }
2323
serde_json = "1"
24-
unc-sdk-macros = { path = "../unc-sdk-macros", version = "2.0.5" }
25-
unc-sys = { path = "../unc-sys", version = "2.0.5" }
24+
unc-sdk-macros = { path = "../unc-sdk-macros", version = "2.0.6" }
25+
unc-sys = { path = "../unc-sys", version = "2.0.6" }
2626
base64 = "0.22.0"
2727
borsh = { version = "1.0.0", features = ["derive"] }
2828
bs58 = "0.5"

unc-sdk/src/store/key.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ pub trait ToKey: self::private::Sealed {
1616
/// Output type for the generated lookup key.
1717
type KeyType: AsRef<[u8]>;
1818

19-
fn to_key<Q: ?Sized>(prefix: &[u8], key: &Q, buffer: &mut Vec<u8>) -> Self::KeyType
19+
fn to_key<Q>(prefix: &[u8], key: &Q, buffer: &mut Vec<u8>) -> Self::KeyType
2020
where
21-
Q: BorshSerialize;
21+
Q: ?Sized + BorshSerialize;
2222
}
2323

2424
/// Sha256 hash helper which hashes through a syscall. This type satisfies the [`ToKey`] trait.
@@ -28,9 +28,9 @@ pub enum Sha256 {}
2828
impl ToKey for Sha256 {
2929
type KeyType = [u8; 32];
3030

31-
fn to_key<Q: ?Sized>(prefix: &[u8], key: &Q, buffer: &mut Vec<u8>) -> Self::KeyType
31+
fn to_key<Q>(prefix: &[u8], key: &Q, buffer: &mut Vec<u8>) -> Self::KeyType
3232
where
33-
Q: BorshSerialize,
33+
Q: ?Sized + BorshSerialize,
3434
{
3535
// Prefix the serialized bytes, then hash the combined value.
3636
buffer.extend(prefix);
@@ -47,9 +47,9 @@ pub enum Keccak256 {}
4747
impl ToKey for Keccak256 {
4848
type KeyType = [u8; 32];
4949

50-
fn to_key<Q: ?Sized>(prefix: &[u8], key: &Q, buffer: &mut Vec<u8>) -> Self::KeyType
50+
fn to_key<Q>(prefix: &[u8], key: &Q, buffer: &mut Vec<u8>) -> Self::KeyType
5151
where
52-
Q: BorshSerialize,
52+
Q: ?Sized + BorshSerialize,
5353
{
5454
// Prefix the serialized bytes, then hash the combined value.
5555
buffer.extend(prefix);
@@ -65,9 +65,9 @@ pub enum Identity {}
6565
impl ToKey for Identity {
6666
type KeyType = Vec<u8>;
6767

68-
fn to_key<Q: ?Sized>(prefix: &[u8], key: &Q, buffer: &mut Vec<u8>) -> Self::KeyType
68+
fn to_key<Q>(prefix: &[u8], key: &Q, buffer: &mut Vec<u8>) -> Self::KeyType
6969
where
70-
Q: BorshSerialize,
70+
Q: ?Sized + BorshSerialize,
7171
{
7272
// Prefix the serialized bytes and return a copy of this buffer.
7373
buffer.extend(prefix);

unc-sdk/src/store/lookup_map/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ where
211211
V::try_from_slice(bytes).unwrap_or_else(|_| env::panic_str(ERR_ELEMENT_DESERIALIZATION))
212212
}
213213

214-
fn load_element<Q: ?Sized>(prefix: &[u8], key: &Q) -> (H::KeyType, Option<V>)
214+
fn load_element<Q>(prefix: &[u8], key: &Q) -> (H::KeyType, Option<V>)
215215
where
216-
Q: BorshSerialize,
216+
Q: ?Sized + BorshSerialize,
217217
K: Borrow<Q>,
218218
{
219219
let key = H::to_key(prefix, key, &mut Vec::new());
@@ -237,10 +237,10 @@ where
237237
/// assert_eq!(map.get(&1), Some(&"a".to_string()));
238238
/// assert_eq!(map.get(&2), None);
239239
/// ```
240-
pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>
240+
pub fn get<Q>(&self, k: &Q) -> Option<&V>
241241
where
242242
K: Borrow<Q>,
243-
Q: BorshSerialize + ToOwned<Owned = K>,
243+
Q: ?Sized + BorshSerialize + ToOwned<Owned = K>,
244244
{
245245
//* ToOwned bound, which forces a clone, is required to be able to keep the key in the cache
246246
let cached = self.cache.get(k.to_owned());
@@ -252,10 +252,10 @@ where
252252
entry.value().as_ref()
253253
}
254254

255-
pub(crate) fn get_mut_inner<Q: ?Sized>(&mut self, k: &Q) -> &mut CacheEntry<V>
255+
pub(crate) fn get_mut_inner<Q>(&mut self, k: &Q) -> &mut CacheEntry<V>
256256
where
257257
K: Borrow<Q>,
258-
Q: BorshSerialize + ToOwned<Owned = K>,
258+
Q: ?Sized + BorshSerialize + ToOwned<Owned = K>,
259259
{
260260
let prefix = &self.prefix;
261261
//* ToOwned bound, which forces a clone, is required to be able to keep the key in the cache
@@ -286,10 +286,10 @@ where
286286
/// assert_eq!(map[&1], "b".to_string());
287287
/// }
288288
/// ```
289-
pub fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V>
289+
pub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
290290
where
291291
K: Borrow<Q>,
292-
Q: BorshSerialize + ToOwned<Owned = K>,
292+
Q: ?Sized + BorshSerialize + ToOwned<Owned = K>,
293293
{
294294
self.get_mut_inner(k).value_mut().as_mut()
295295
}
@@ -336,10 +336,10 @@ where
336336
/// assert_eq!(map.contains_key(&1), true);
337337
/// assert_eq!(map.contains_key(&2), false);
338338
/// ```
339-
pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool
339+
pub fn contains_key<Q>(&self, k: &Q) -> bool
340340
where
341341
K: Borrow<Q>,
342-
Q: BorshSerialize + ToOwned<Owned = K> + Ord,
342+
Q: ?Sized + BorshSerialize + ToOwned<Owned = K> + Ord,
343343
{
344344
// Check cache before checking storage
345345
let contains = self
@@ -378,10 +378,10 @@ where
378378
/// assert_eq!(map.remove(&1), Some("a".to_string()));
379379
/// assert_eq!(map.remove(&1), None);
380380
/// ```
381-
pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<V>
381+
pub fn remove<Q>(&mut self, k: &Q) -> Option<V>
382382
where
383383
K: Borrow<Q>,
384-
Q: BorshSerialize + ToOwned<Owned = K>,
384+
Q: ?Sized + BorshSerialize + ToOwned<Owned = K>,
385385
{
386386
self.get_mut_inner(k).replace(None)
387387
}

unc-sdk/src/store/lookup_set/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ where
107107
///
108108
/// The value may be any borrowed form of the set's value type, but
109109
/// [`BorshSerialize`] on the borrowed form *must* match those for the value type.
110-
pub fn contains<Q: ?Sized>(&self, value: &Q) -> bool
110+
pub fn contains<Q>(&self, value: &Q) -> bool
111111
where
112112
T: Borrow<Q>,
113-
Q: BorshSerialize,
113+
Q: ?Sized + BorshSerialize,
114114
{
115115
let lookup_key = H::to_key(&self.prefix, value, &mut Vec::new());
116116
env::storage_has_key(lookup_key.as_ref())
@@ -130,10 +130,10 @@ where
130130
///
131131
/// The value may be any borrowed form of the set's value type, but
132132
/// [`BorshSerialize`] on the borrowed form *must* match those for the value type.
133-
pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool
133+
pub fn remove<Q>(&mut self, value: &Q) -> bool
134134
where
135135
T: Borrow<Q>,
136-
Q: BorshSerialize,
136+
Q: ?Sized + BorshSerialize,
137137
{
138138
let lookup_key = H::to_key(&self.prefix, value, &mut Vec::new());
139139
env::storage_remove(lookup_key.as_ref())

unc-sdk/src/store/tree_map/mod.rs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,10 @@ where
207207
/// The key may be any borrowed form of the map's key type, but
208208
/// [`BorshSerialize`] and [`ToOwned<Owned = K>`](ToOwned) on the borrowed form *must* match
209209
/// those for the key type.
210-
pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool
210+
pub fn contains_key<Q>(&self, k: &Q) -> bool
211211
where
212212
K: Borrow<Q>,
213-
Q: BorshSerialize + ToOwned<Owned = K> + Ord,
213+
Q: ?Sized + BorshSerialize + ToOwned<Owned = K> + Ord,
214214
{
215215
self.values.contains_key(k)
216216
}
@@ -220,10 +220,10 @@ where
220220
/// The key may be any borrowed form of the map's key type, but
221221
/// [`BorshSerialize`] and [`ToOwned<Owned = K>`](ToOwned) on the borrowed form *must* match
222222
/// those for the key type.
223-
pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>
223+
pub fn get<Q>(&self, k: &Q) -> Option<&V>
224224
where
225225
K: Borrow<Q>,
226-
Q: BorshSerialize + ToOwned<Owned = K>,
226+
Q: ?Sized + BorshSerialize + ToOwned<Owned = K>,
227227
{
228228
self.values.get(k)
229229
}
@@ -243,10 +243,10 @@ where
243243
/// assert_eq!(map.get_key_value(&1), Some((&1, &"a".to_string())));
244244
/// assert_eq!(map.get_key_value(&2), None);
245245
/// ```
246-
pub fn get_key_value<Q: ?Sized>(&self, k: &Q) -> Option<(&K, &V)>
246+
pub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
247247
where
248248
K: Borrow<Q> + BorshDeserialize,
249-
Q: BorshSerialize + ToOwned<Owned = K> + Ord,
249+
Q: ?Sized + BorshSerialize + ToOwned<Owned = K> + Ord,
250250
{
251251
self.values.get(k).map(|v| (expect(self.tree.equal_key(k)), v))
252252
}
@@ -256,10 +256,10 @@ where
256256
/// The key may be any borrowed form of the map's key type, but
257257
/// [`BorshSerialize`] and [`ToOwned<Owned = K>`](ToOwned) on the borrowed form *must* match
258258
/// those for the key type.
259-
pub fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V>
259+
pub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
260260
where
261261
K: Borrow<Q>,
262-
Q: BorshSerialize + ToOwned<Owned = K>,
262+
Q: ?Sized + BorshSerialize + ToOwned<Owned = K>,
263263
{
264264
self.values.get_mut(k)
265265
}
@@ -292,10 +292,10 @@ where
292292
/// The key may be any borrowed form of the map's key type, but
293293
/// [`BorshSerialize`] and [`ToOwned<Owned = K>`](ToOwned) on the borrowed form *must* match
294294
/// those for the key type.
295-
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V>
295+
pub fn remove<Q>(&mut self, key: &Q) -> Option<V>
296296
where
297297
K: Borrow<Q> + BorshDeserialize,
298-
Q: BorshSerialize + ToOwned<Owned = K> + Ord,
298+
Q: ?Sized + BorshSerialize + ToOwned<Owned = K> + Ord,
299299
{
300300
self.remove_entry(key).map(|(_, v)| v)
301301
}
@@ -477,14 +477,14 @@ where
477477
/// The metadata included in the result includes the indices for the node and parent, as well
478478
/// as which edge the found node is of the parent, if one.
479479
#[allow(clippy::type_complexity)]
480-
fn lookup_at<Q: ?Sized>(
480+
fn lookup_at<Q>(
481481
&self,
482482
mut at: FreeListIndex,
483483
key: &Q,
484484
) -> Option<(NodeAndIndex<K>, Option<(FreeListIndex, &Node<K>, Edge)>)>
485485
where
486486
K: Borrow<Q>,
487-
Q: BorshSerialize + Eq + PartialOrd,
487+
Q: ?Sized + BorshSerialize + Eq + PartialOrd,
488488
{
489489
let mut p = None;
490490
let mut curr = Some(expect(self.node(at)));
@@ -665,10 +665,10 @@ where
665665
// - right-most (max) node of the left subtree (containing smaller keys) of node holding `key`
666666
// - or left-most (min) node of the right subtree (containing larger keys) of node holding `key`
667667
//
668-
fn do_remove<Q: ?Sized>(&mut self, key: &Q) -> Option<K>
668+
fn do_remove<Q>(&mut self, key: &Q) -> Option<K>
669669
where
670670
K: Borrow<Q>,
671-
Q: BorshSerialize + Eq + PartialOrd,
671+
Q: ?Sized + BorshSerialize + Eq + PartialOrd,
672672
{
673673
// r_node - node containing key of interest
674674
// remove_parent - immediate parent node of r_node
@@ -875,11 +875,12 @@ where
875875
/// }
876876
/// assert_eq!(Some((&5, &"b".to_string())), map.range(4..).next());
877877
/// ```
878-
pub fn range<'a, R: 'a, Q: 'a>(&'a self, range: R) -> Range<'a, K, V, H>
878+
pub fn range<'a, R: 'a + RangeBounds<Q>, Q: 'a + ?Sized + Ord>(
879+
&'a self,
880+
range: R,
881+
) -> Range<'a, K, V, H>
879882
where
880883
K: BorshDeserialize + Borrow<Q>,
881-
Q: ?Sized + Ord,
882-
R: RangeBounds<Q>,
883884
{
884885
Range::new(self, (range.start_bound(), range.end_bound()))
885886
}
@@ -947,10 +948,10 @@ where
947948
/// assert_eq!(map.remove(&1), Some("a".to_string()));
948949
/// assert_eq!(map.remove(&1), None);
949950
/// ```
950-
pub fn remove_entry<Q: ?Sized>(&mut self, key: &Q) -> Option<(K, V)>
951+
pub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
951952
where
952953
K: Borrow<Q> + BorshDeserialize + Clone,
953-
Q: BorshSerialize + ToOwned<Owned = K> + Eq + PartialOrd,
954+
Q: ?Sized + BorshSerialize + ToOwned<Owned = K> + Eq + PartialOrd,
954955
{
955956
self.values.remove(key).map(|removed_value| {
956957
let removed = self.tree.do_remove(key);

unc-sdk/src/store/unordered_map/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,10 @@ where
444444
/// assert!(map.insert("test".to_string(), 5u8).is_none());
445445
/// assert_eq!(map.get("test"), Some(&5));
446446
/// ```
447-
pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>
447+
pub fn get<Q>(&self, k: &Q) -> Option<&V>
448448
where
449449
K: Borrow<Q>,
450-
Q: BorshSerialize + ToOwned<Owned = K>,
450+
Q: ?Sized + BorshSerialize + ToOwned<Owned = K>,
451451
{
452452
self.values.get(k).map(|v| &v.value)
453453
}
@@ -469,10 +469,10 @@ where
469469
/// *map.get_mut("test").unwrap() = 6;
470470
/// assert_eq!(map["test"], 6);
471471
/// ```
472-
pub fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V>
472+
pub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
473473
where
474474
K: Borrow<Q>,
475-
Q: BorshSerialize + ToOwned<Owned = K>,
475+
Q: ?Sized + BorshSerialize + ToOwned<Owned = K>,
476476
{
477477
self.values.get_mut(k).map(|v| &mut v.value)
478478
}
@@ -530,10 +530,10 @@ where
530530
///
531531
/// assert!(map.contains_key("test"));
532532
/// ```
533-
pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool
533+
pub fn contains_key<Q>(&self, k: &Q) -> bool
534534
where
535535
K: Borrow<Q>,
536-
Q: BorshSerialize + ToOwned<Owned = K> + Ord,
536+
Q: ?Sized + BorshSerialize + ToOwned<Owned = K> + Ord,
537537
{
538538
self.values.contains_key(k)
539539
}
@@ -568,10 +568,10 @@ where
568568
///
569569
/// assert_eq!(map.len(), 0);
570570
/// ```
571-
pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<V>
571+
pub fn remove<Q>(&mut self, k: &Q) -> Option<V>
572572
where
573573
K: Borrow<Q> + BorshDeserialize,
574-
Q: BorshSerialize + ToOwned<Owned = K>,
574+
Q: ?Sized + BorshSerialize + ToOwned<Owned = K>,
575575
{
576576
self.remove_entry(k).map(|(_, v)| v)
577577
}
@@ -603,10 +603,10 @@ where
603603
/// assert_eq!(map.remove(&1), Some("a".to_string()));
604604
/// assert_eq!(map.remove(&1), None);
605605
/// ```
606-
pub fn remove_entry<Q: ?Sized>(&mut self, k: &Q) -> Option<(K, V)>
606+
pub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
607607
where
608608
K: Borrow<Q> + BorshDeserialize,
609-
Q: BorshSerialize + ToOwned<Owned = K>,
609+
Q: ?Sized + BorshSerialize + ToOwned<Owned = K>,
610610
{
611611
// Remove value
612612
let old_value = self.values.remove(k)?;

0 commit comments

Comments
 (0)