Skip to content

Commit ee78bad

Browse files
fix the kv_exists bug
Signed-off-by: Valentyn Faychuk <[email protected]>
1 parent 88d8987 commit ee78bad

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

contract_samples/rust/sdk/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ where
264264
unsafe {
265265
let cache = &mut *self.cache.get();
266266
if !cache.contains_key(&storage_key) {
267-
if kv_get::<V>(&storage_key).is_some() {
267+
if kv_exists(&storage_key) {
268268
cache.insert(storage_key.clone(), LazyCell::with_prefix(storage_key.clone()));
269269
} else {
270270
return None;
@@ -280,7 +280,7 @@ where
280280
unsafe {
281281
let cache = &mut *self.cache.get();
282282
if !cache.contains_key(&storage_key) {
283-
if kv_get::<V>(&storage_key).is_some() {
283+
if kv_exists(&storage_key) {
284284
cache.insert(storage_key.clone(), LazyCell::with_prefix(storage_key.clone()));
285285
} else {
286286
return None;

contract_samples/rust/sdk/src/storage.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ pub fn kv_exists(key: impl Payload) -> bool {
134134
}
135135
#[cfg(not(any(test, feature = "testing")))]
136136
unsafe {
137-
let ptr = import_kv_exists(key_bytes.as_ptr(), key_bytes.len());
138-
*(ptr as *const i32) == 1
137+
let result = import_kv_exists(key_bytes.as_ptr(), key_bytes.len());
138+
result == 1
139139
}
140140
}
141141

0 commit comments

Comments
 (0)