diff --git a/contracts/sui/mock_dapp/sources/dapp_state.move b/contracts/sui/mock_dapp/sources/dapp_state.move index 368288988..6c97e2ef4 100644 --- a/contracts/sui/mock_dapp/sources/dapp_state.move +++ b/contracts/sui/mock_dapp/sources/dapp_state.move @@ -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}; @@ -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}); } diff --git a/contracts/sui/xcall/sources/centralized_connection/centralized_state.move b/contracts/sui/xcall/sources/centralized_connection/centralized_state.move index eed644ce7..d562b3200 100644 --- a/contracts/sui/xcall/sources/centralized_connection/centralized_state.move +++ b/contracts/sui/xcall/sources/centralized_connection/centralized_state.move @@ -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); } diff --git a/contracts/sui/xcall/sources/states/xcall_state.move b/contracts/sui/xcall/sources/states/xcall_state.move index 51921f474..4e6005db0 100644 --- a/contracts/sui/xcall/sources/states/xcall_state.move +++ b/contracts/sui/xcall/sources/states/xcall_state.move @@ -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); }