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

Keymap's methods now match those of cw-Map #75

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions packages/permit/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ pub struct RevokedPermits;

impl RevokedPermits {
pub fn is_permit_revoked(
storgae: &dyn Storage,
storage: &dyn Storage,
storage_prefix: &str,
account: &str,
permit_name: &str,
) -> bool {
let storage_key = storage_prefix.to_string() + account + permit_name;

storgae.get(storage_key.as_bytes()).is_some()
storage.get(storage_key.as_bytes()).is_some()
}

pub fn revoke_permit(
Expand Down
14 changes: 7 additions & 7 deletions packages/storage/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ pub static JSON_VOTE: Keymap<Addr, Foo, Json> =

You can find more examples of using keymaps in the unit tests of Keymap in `keymap.rs`.

To insert, remove, read from the keymap, do the following:
To save to, remove, and read from the keymap, do the following:

```rust
# use secret_toolkit_storage::{Keymap, KeymapBuilder};
Expand All @@ -357,9 +357,9 @@ let foo = Foo {
votes: 1111,
};

ADDR_VOTE.insert(&mut deps.storage, &user_addr, &foo)?;
ADDR_VOTE.save(&mut deps.storage, &user_addr, &foo)?;
// Compiler knows that this is Foo
let read_foo = ADDR_VOTE.get(deps.as_ref().storage, &user_addr).unwrap();
let read_foo = ADDR_VOTE.load(deps.as_ref().storage, &user_addr).unwrap();
assert_eq!(read_foo, foo);
ADDR_VOTE.remove(&mut deps.storage, &user_addr)?;
assert_eq!(ADDR_VOTE.get_len(deps.as_ref().storage)?, 0);
Expand Down Expand Up @@ -397,8 +397,8 @@ fn test_keymap_iter_keys() -> StdResult<()> {
let key1 = "key1".to_string();
let key2 = "key2".to_string();

keymap.insert(&mut storage, &key1, &foo1)?;
keymap.insert(&mut storage, &key2, &foo2)?;
keymap.save(&mut storage, &key1, &foo1)?;
keymap.save(&mut storage, &key2, &foo2)?;

let mut x = keymap.iter_keys(&storage)?;
let (len, _) = x.size_hint();
Expand Down Expand Up @@ -432,8 +432,8 @@ fn test_keymap_iter() -> StdResult<()> {
number: 1111,
};

keymap.insert(&mut storage, &b"key1".to_vec(), &foo1)?;
keymap.insert(&mut storage, &b"key2".to_vec(), &foo2)?;
keymap.save(&mut storage, &b"key1".to_vec(), &foo1)?;
keymap.save(&mut storage, &b"key2".to_vec(), &foo2)?;

let mut x = keymap.iter(&storage)?;
let (len, _) = x.size_hint();
Expand Down
Loading