Skip to content

Commit

Permalink
imp: remove unnecessary PortId ownership in get_app
Browse files Browse the repository at this point in the history
  • Loading branch information
Farhad-Shabani committed Sep 20, 2024
1 parent 741dfd4 commit d80f21d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub mod ChannelHandlerComponent {
fn recv_packet_execute(
ref self: ComponentState<TContractState>, msg: MsgRecvPacket, chan_end_on_b: ChannelEnd
) {
let app = self.get_app(msg.packet.port_id_on_b.clone());
let app = self.get_app(@msg.packet.port_id_on_b);

let ack = app.on_recv_packet(msg.packet.clone());

Expand Down Expand Up @@ -250,7 +250,7 @@ pub mod ChannelHandlerComponent {
client_comp.get_client(client_type)
}

fn get_app(self: @ComponentState<TContractState>, port_id: PortId) -> ApplicationContract {
fn get_app(self: @ComponentState<TContractState>, port_id: @PortId) -> ApplicationContract {
let router_comp = get_dep_component!(self, RouterHandler);

router_comp.get_app(port_id)
Expand Down
6 changes: 3 additions & 3 deletions cairo-contracts/packages/core/src/router/component.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub mod RouterHandlerComponent {
fn get_app_address(
self: @ComponentState<TContractState>, port_id: ByteArray
) -> Option<ContractAddress> {
let app_address = self.read_app_address(PortIdImpl::new(port_id));
let app_address = self.read_app_address(@PortIdImpl::new(port_id));

if app_address.is_non_zero() {
Option::Some(app_address)
Expand All @@ -56,7 +56,7 @@ pub mod RouterHandlerComponent {
pub(crate) impl RouterInternalImpl<
TContractState, +HasComponent<TContractState>, +Drop<TContractState>
> of RouterInternalTrait<TContractState> {
fn get_app(self: @ComponentState<TContractState>, port_id: PortId) -> ApplicationContract {
fn get_app(self: @ComponentState<TContractState>, port_id: @PortId) -> ApplicationContract {
let maybe_app_address = self.read_app_address(port_id);

assert(maybe_app_address.is_non_zero(), RouterErrors::UNSUPPORTED_PORT_ID);
Expand All @@ -70,7 +70,7 @@ pub mod RouterHandlerComponent {
TContractState, +HasComponent<TContractState>, +Drop<TContractState>
> of RouterReaderTrait<TContractState> {
fn read_app_address(
self: @ComponentState<TContractState>, port_id: PortId
self: @ComponentState<TContractState>, port_id: @PortId
) -> ContractAddress {
self.port_id_to_app.read(port_id.key())
}
Expand Down

0 comments on commit d80f21d

Please sign in to comment.