Skip to content

Commit

Permalink
fix: vecmap insert issue fixed (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
gcranju authored and Itshyphen committed Aug 8, 2024
1 parent 4738a50 commit 54d466e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion contracts/sui/mock_dapp/sources/dapp_state.move
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module mock_dapp::dapp_state {
use xcall::xcall_state::IDCap;
use sui::object::{Self, UID,ID};
use sui::vec_map::{Self, VecMap};
use sui::vec_map::{Self, VecMap};
use std::vector::{Self};
use std::string::{Self,String};
use xcall::execute_ticket::{Self};
Expand Down Expand Up @@ -62,6 +62,9 @@ module mock_dapp::dapp_state {
}

public fun add_connection(self:&mut DappState,net_id:String,source:String,dest:String,ctx:&mut TxContext){
if (vec_map::contains(&self.connections,&net_id)){
vec_map::remove(&mut self.connections,&net_id);
};
vec_map::insert(&mut self.connections,net_id,Connection{source,destination:dest});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ module xcall::centralized_state {

public(package) fun set_fee(self: &mut State, net_id: String, message_fee: u64, response_fee: u64,caller:address) {
ensure_admin(self,caller);
if (vec_map::contains(&self.message_fee,&net_id)){
vec_map::remove(&mut self.message_fee,&net_id);
};
if (vec_map::contains(&self.response_fee,&net_id)){
vec_map::remove(&mut self.response_fee,&net_id);
};
vec_map::insert(&mut self.message_fee, net_id, message_fee);
vec_map::insert(&mut self.response_fee, net_id, response_fee);
}
Expand Down
3 changes: 3 additions & 0 deletions contracts/sui/xcall/sources/states/xcall_state.move
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ module xcall::xcall_state {


public(package) fun set_connection(self:&mut Storage,net_id:String,package_id:String){
if (vec_map::contains(&self.connections,&net_id)){
vec_map::remove(&mut self.connections,&net_id);
};
vec_map::insert(&mut self.connections,net_id,package_id);
}

Expand Down

0 comments on commit 54d466e

Please sign in to comment.