Skip to content

Commit

Permalink
update StorageKey
Browse files Browse the repository at this point in the history
  • Loading branch information
MagicGordon committed Sep 13, 2024
1 parent 0f96b24 commit 49283dd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ref-exchange/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Version 1.9.5
```
Hk44vRVYyGPrRPf7ndcn5m8LAd9YiVBsiKMhXqwfS4B6
3hF1UzsT5mzxbJLMA8BD7gmCH1BL8cWjvFmSZYREpZXK
```
1. add client echo limit

Expand Down
16 changes: 10 additions & 6 deletions ref-exchange/src/client_echo_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub fn read_ce_tw_from_storage() -> UnorderedSet<AccountId> {
if let Some(content) = env::storage_read(CLIENT_ECHO_TOKEN_ID_WHITHELIST.as_bytes()) {
UnorderedSet::try_from_slice(&content).expect("deserialize client echo token id whitelist failed.")
} else {
UnorderedSet::new(StorageKey::ClientEchoTokenIdWhitelist)
UnorderedSet::new(StorageKey::ClientEchoTokenIdWhitelistItem)
}
}

Expand All @@ -19,7 +19,7 @@ pub fn read_ce_sw_from_storage() -> UnorderedSet<AccountId> {
if let Some(content) = env::storage_read(CLIENT_ECHO_SENDER_ID_WHITHELIST.as_bytes()) {
UnorderedSet::try_from_slice(&content).expect("deserialize client echo sender id whitelist failed.")
} else {
UnorderedSet::new(StorageKey::ClientEchoSenderIdWhitelist)
UnorderedSet::new(StorageKey::ClientEchoSenderIdWhitelistItem)
}
}

Expand All @@ -45,7 +45,8 @@ impl Contract {
assert!(self.is_owner_or_guardians(), "{}", ERR100_NOT_ALLOWED);
let mut client_echo_token_id_whitelist = read_ce_tw_from_storage();
for token_id in token_ids {
assert!(client_echo_token_id_whitelist.insert(token_id.as_ref()), "Token id already exist");
let is_success = client_echo_token_id_whitelist.insert(token_id.as_ref());
assert!(is_success, "Token id already exist");
}
write_ce_tw_to_storage(client_echo_token_id_whitelist);
}
Expand All @@ -56,7 +57,8 @@ impl Contract {
self.assert_owner();
let mut client_echo_token_id_whitelist = read_ce_tw_from_storage();
for token_id in token_ids {
assert!(client_echo_token_id_whitelist.remove(token_id.as_ref()), "Invalid token id");
let is_success = client_echo_token_id_whitelist.remove(token_id.as_ref());
assert!(is_success, "Invalid token id");
}
write_ce_tw_to_storage(client_echo_token_id_whitelist);
}
Expand All @@ -72,7 +74,8 @@ impl Contract {
assert!(self.is_owner_or_guardians(), "{}", ERR100_NOT_ALLOWED);
let mut client_echo_sender_id_whitelist = read_ce_sw_from_storage();
for sender_id in sender_ids {
assert!(client_echo_sender_id_whitelist.insert(sender_id.as_ref()), "Sender id already exist");
let is_success = client_echo_sender_id_whitelist.insert(sender_id.as_ref());
assert!(is_success, "Sender id already exist");
}
write_ce_sw_to_storage(client_echo_sender_id_whitelist);
}
Expand All @@ -83,7 +86,8 @@ impl Contract {
self.assert_owner();
let mut client_echo_sender_id_whitelist = read_ce_sw_from_storage();
for sender_id in sender_ids {
assert!(client_echo_sender_id_whitelist.remove(sender_id.as_ref()), "Invalid sender id");
let is_success = client_echo_sender_id_whitelist.remove(sender_id.as_ref());
assert!(is_success, "Invalid sender id");
}
write_ce_sw_to_storage(client_echo_sender_id_whitelist);
}
Expand Down
4 changes: 2 additions & 2 deletions ref-exchange/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ pub(crate) enum StorageKey {
ShadowRecord {account_id: AccountId},
UnitShareCumulativeInfo,
PoolLimit,
ClientEchoTokenIdWhitelist,
ClientEchoSenderIdWhitelist,
ClientEchoTokenIdWhitelistItem,
ClientEchoSenderIdWhitelistItem,
}

#[derive(BorshDeserialize, BorshSerialize, Serialize, Deserialize, Eq, PartialEq, Clone)]
Expand Down
Binary file modified releases/ref_exchange_release.wasm
Binary file not shown.

0 comments on commit 49283dd

Please sign in to comment.