From 5e7f20932addce8b391deeccac0efcb5c0cdc1e5 Mon Sep 17 00:00:00 2001 From: Farhad Shabani Date: Tue, 30 Jul 2024 17:23:02 -0700 Subject: [PATCH 1/2] fix: remove old transfer contract --- .../src/apps/transfer/component.cairo | 6 +- cairo-contracts/src/contracts/transfer.cairo | 72 ------------------- cairo-contracts/src/core/types.cairo | 12 ---- cairo-contracts/src/presets.cairo | 1 - 4 files changed, 2 insertions(+), 89 deletions(-) delete mode 100644 cairo-contracts/src/contracts/transfer.cairo delete mode 100644 cairo-contracts/src/core/types.cairo diff --git a/cairo-contracts/src/apps/transfer/component.cairo b/cairo-contracts/src/apps/transfer/component.cairo index 379c6f09..936c8bcc 100644 --- a/cairo-contracts/src/apps/transfer/component.cairo +++ b/cairo-contracts/src/apps/transfer/component.cairo @@ -5,7 +5,6 @@ pub mod ICS20TransferComponent { use core::num::traits::Zero; use core::option::OptionTrait; use core::starknet::SyscallResultTrait; - use openzeppelin::utils::serde::SerializedAppend; use starknet::ClassHash; use starknet::ContractAddress; use starknet::get_contract_address; @@ -13,8 +12,7 @@ pub mod ICS20TransferComponent { use starknet_ibc::apps::transfer::interface::{ISendTransfer, IRecvPacket, ITokenAddress}; use starknet_ibc::apps::transfer::types::{ MsgTransfer, PrefixedDenom, Denom, DenomTrait, PacketData, TracePrefix, Memo, - TracePrefixTrait, ERC20TokenTrait, ERC20Token, MAXIMUM_MEMO_LENGTH, ValidateBasicTrait, - PrefixedDenomTrait + TracePrefixTrait, ERC20TokenTrait, ERC20Token, ValidateBasicTrait, PrefixedDenomTrait }; use starknet_ibc::apps::transferrable::interface::ITransferrable; use starknet_ibc::core::channel::types::Packet; @@ -438,7 +436,7 @@ pub mod ICS20TransferComponent { pub(crate) impl TransferEventImpl< TContractState, +HasComponent, +Drop > of TransferEventTrait { - fn emit_send_event(ref self: ComponentState, packet_date: PacketData,) { + fn emit_send_event(ref self: ComponentState, packet_date: PacketData) { self .emit( SendEvent { diff --git a/cairo-contracts/src/contracts/transfer.cairo b/cairo-contracts/src/contracts/transfer.cairo deleted file mode 100644 index 9a900d5b..00000000 --- a/cairo-contracts/src/contracts/transfer.cairo +++ /dev/null @@ -1,72 +0,0 @@ -#[starknet::contract] -pub(crate) mod Transfer { - use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; - use starknet::{ContractAddress, ClassHash}; - use starknet_ibc::apps::transfer::component::ICS20TransferComponent; - - component!(path: ERC20Component, storage: erc20, event: ERC20Event); - component!(path: ICS20TransferComponent, storage: transfer, event: ICS20TransferEvent); - - #[abi(embed_v0)] - impl ERC20MixinImpl = ERC20Component::ERC20MixinImpl; - impl ERC20InternalImpl = ERC20Component::InternalImpl; - - impl TransferValidationImpl = ICS20TransferComponent::TransferValidationImpl; - impl TransferExecutionImpl = ICS20TransferComponent::TransferExecutionImpl; - impl TransferInternalImpl = ICS20TransferComponent::InternalImpl; - - #[storage] - struct Storage { - #[substorage(v0)] - erc20: ERC20Component::Storage, - #[substorage(v0)] - transfer: ICS20TransferComponent::Storage, - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - #[flat] - ERC20Event: ERC20Component::Event, - #[flat] - ICS20TransferEvent: ICS20TransferComponent::Event, - } - - #[constructor] - fn constructor( - ref self: ContractState, - name: ByteArray, - symbol: ByteArray, - fixed_supply: u256, - recipient: ContractAddress, - owner: ContractAddress - ) { - self.erc20.initializer(name, symbol); - } -} - -#[cfg(test)] -mod tests { - use core::starknet::SyscallResultTrait; - use starknet::ContractAddress; - use starknet::contract_address_const; - use starknet::syscalls::deploy_syscall; - use starknet_ibc::Transfer; - use starknet_ibc::apps::transfer::interface::{ITransferDispatcher, ITransferDispatcherTrait,}; - - fn deploy() -> (ITransferDispatcher, ContractAddress) { - let recipient: ContractAddress = contract_address_const::<'sender'>(); - - let (contract_address, _) = deploy_syscall( - Transfer::TEST_CLASS_HASH.try_into().unwrap(), recipient.into(), array![0].span(), false - ) - .unwrap_syscall(); - - (ITransferDispatcher { contract_address }, contract_address) - } - - #[test] - fn test_transfer() { - deploy(); - } -} diff --git a/cairo-contracts/src/core/types.cairo b/cairo-contracts/src/core/types.cairo deleted file mode 100644 index edfe12cc..00000000 --- a/cairo-contracts/src/core/types.cairo +++ /dev/null @@ -1,12 +0,0 @@ -use starknet::ContractAddress; -use starknet::Store; - -#[derive(Drop, Serde, Store)] -pub struct ChannelId { - channel_id: felt252, -} - -#[derive(Drop, Serde, Store)] -pub struct PortId { - port_id: felt252, -} diff --git a/cairo-contracts/src/presets.cairo b/cairo-contracts/src/presets.cairo index 214f2d13..933b295b 100644 --- a/cairo-contracts/src/presets.cairo +++ b/cairo-contracts/src/presets.cairo @@ -1,7 +1,6 @@ mod erc20; mod transfer; -#[cfg(test)] pub use erc20::ERC20; pub use transfer::Transfer; From c7322ea1b70c38e4a30e838bbb256c1109a3f23c Mon Sep 17 00:00:00 2001 From: Farhad Shabani Date: Tue, 30 Jul 2024 17:31:40 -0700 Subject: [PATCH 2/2] fix: CI paths --- .github/workflows/cairo-contracts.yml | 4 ++-- .github/workflows/light-client.yml | 3 +-- .github/workflows/lint.yml | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cairo-contracts.yml b/.github/workflows/cairo-contracts.yml index 25e8de94..c2a740f0 100644 --- a/.github/workflows/cairo-contracts.yml +++ b/.github/workflows/cairo-contracts.yml @@ -2,8 +2,8 @@ name: Cairo Contracts on: pull_request: paths: - - .github/workflows/tests.yaml - - contracts/** + - .github/workflows/cairo-contracts.yaml + - cairo-contracts/** - justfile push: diff --git a/.github/workflows/light-client.yml b/.github/workflows/light-client.yml index a121fc99..92fa0809 100644 --- a/.github/workflows/light-client.yml +++ b/.github/workflows/light-client.yml @@ -2,8 +2,7 @@ name: Light Client on: pull_request: paths: - - .github/workflows/rust.yaml - - contracts/** + - .github/workflows/light-client.yaml - light-client/** - "**/Cargo.toml" - "**/Cargo.lock" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 84eb07d0..8c5461d2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,7 +3,7 @@ on: pull_request: paths: - .github/workflows/lint.yaml - - contracts/** + - cairo-contracts/** - light-client/** - "**/Cargo.toml" - "**/Cargo.lock"