Skip to content

Commit

Permalink
fix: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
JordyRo1 committed May 15, 2024
1 parent 6e364f4 commit f029dc3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 37 deletions.
20 changes: 8 additions & 12 deletions contracts/src/contracts/isms/multisig/messageid_multisig_ism.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ pub mod messageid_multisig_ism {
use hyperlane_starknet::contracts::libs::checkpoint_lib::checkpoint_lib::CheckpointLib;
use hyperlane_starknet::contracts::libs::message::{Message, MessageTrait};
use hyperlane_starknet::contracts::libs::multisig::message_id_ism_metadata::message_id_ism_metadata::MessageIdIsmMetadata;
use hyperlane_starknet::interfaces::{ ModuleType,
IInterchainSecurityModule, IInterchainSecurityModuleDispatcher,
use hyperlane_starknet::interfaces::{
ModuleType, IInterchainSecurityModule, IInterchainSecurityModuleDispatcher,
IInterchainSecurityModuleDispatcherTrait,
};
use openzeppelin::access::ownable::OwnableComponent;
use openzeppelin::upgrades::{interface::IUpgradeable, upgradeable::UpgradeableComponent};
use starknet::ContractAddress;
use starknet::EthAddress;
use starknet::eth_signature::is_eth_signature_valid;
use starknet::secp256_trait::{Signature, signature_from_vrs};
component!(path: OwnableComponent, storage: ownable, event: OwnableEvent);
component!(path: UpgradeableComponent, storage: upgradeable, event: UpgradeableEvent);
#[abi(embed_v0)]
impl OwnableImpl = OwnableComponent::OwnableImpl<ContractState>;
impl OwnableInternalImpl = OwnableComponent::InternalImpl<ContractState>;
impl UpgradeableInternalImpl = UpgradeableComponent::InternalImpl<ContractState>;
use starknet::ContractAddress;
use starknet::EthAddress;
use starknet::eth_signature::is_eth_signature_valid;
use starknet::secp256_trait::{Signature, signature_from_vrs};
#[storage]
struct Storage {
validators: LegacyMap<u32, EthAddress>,
Expand All @@ -47,7 +47,7 @@ pub mod messageid_multisig_ism {
UpgradeableEvent: UpgradeableComponent::Event,
}


#[constructor]
fn constructor(ref self: ContractState, _owner: ContractAddress) {
self.ownable.initializer(_owner);
Expand All @@ -59,11 +59,7 @@ pub mod messageid_multisig_ism {
ModuleType::MESSAGE_ID_MULTISIG(starknet::get_contract_address())
}

fn verify(
self: @ContractState,
_metadata: Bytes,
_message: Message,
) -> bool {
fn verify(self: @ContractState, _metadata: Bytes, _message: Message,) -> bool {
assert(_metadata.clone().data().len() > 0, Errors::EMPTY_METADATA);
let digest = digest(_metadata.clone(), _message.clone());
let (validators, threshold) = self.validators_and_threshold(_message);
Expand Down
24 changes: 10 additions & 14 deletions contracts/src/contracts/mocks/ism.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,26 @@ pub mod ism {
ModuleType::MESSAGE_ID_MULTISIG(starknet::get_contract_address())
}

fn verify(
self: @ContractState,
_metadata: Bytes,
_message: Message,
) -> bool {
fn verify(self: @ContractState, _metadata: Bytes, _message: Message,) -> bool {
true
}

fn validators_and_threshold(
self: @ContractState, _message: Message
) -> (Span<EthAddress>, u32) {
(array![].span(),0)
(array![].span(), 0)
}
fn get_validators(self: @ContractState) -> Span<EthAddress>{

fn get_validators(self: @ContractState) -> Span<EthAddress> {
array![].span()
}
fn get_threshold(self: @ContractState) -> u32{

fn get_threshold(self: @ContractState) -> u32 {
0
}
fn set_validators(ref self: ContractState, _validators: Span<EthAddress>){}
fn set_threshold(ref self: ContractState, _threshold: u32){}

fn set_validators(ref self: ContractState, _validators: Span<EthAddress>) {}

fn set_threshold(ref self: ContractState, _threshold: u32) {}
}
}
6 changes: 1 addition & 5 deletions contracts/src/interfaces.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,7 @@ pub trait IInterchainSecurityModule<TContractState> {
/// * `_metadata` - Off-chain metadata provided by a relayer, specific to the security model encoded by
/// the module (e.g. validator signatures)
/// * `_message` - Hyperlane encoded interchain message
fn verify(
self: @TContractState,
_metadata: Bytes,
_message: Message,
) -> bool;
fn verify(self: @TContractState, _metadata: Bytes, _message: Message,) -> bool;

fn validators_and_threshold(
self: @TContractState, _message: Message
Expand Down
5 changes: 3 additions & 2 deletions contracts/src/tests/setup.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use hyperlane_starknet::contracts::mocks::message_recipient::message_recipient;
use hyperlane_starknet::interfaces::{
IMailboxDispatcher, IMailboxDispatcherTrait, IMessageRecipientDispatcher,
IMessageRecipientDispatcherTrait, IInterchainSecurityModule,
IInterchainSecurityModuleDispatcher, IInterchainSecurityModuleDispatcherTrait, IValidatorAnnounceDispatcher,
IValidatorAnnounceDispatcherTrait, IMailboxClientDispatcher, IMailboxClientDispatcherTrait
IInterchainSecurityModuleDispatcher, IInterchainSecurityModuleDispatcherTrait,
IValidatorAnnounceDispatcher, IValidatorAnnounceDispatcherTrait, IMailboxClientDispatcher,
IMailboxClientDispatcherTrait
};
use snforge_std::{
declare, ContractClassTrait, CheatTarget, EventSpy, EventAssertions, spy_events, SpyOn
Expand Down
9 changes: 5 additions & 4 deletions contracts/src/tests/test_multisig.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ use hyperlane_starknet::contracts::mailbox::mailbox;
use hyperlane_starknet::interfaces::IMessageRecipientDispatcherTrait;
use hyperlane_starknet::interfaces::{
IMailbox, IMailboxDispatcher, IMailboxDispatcherTrait, ModuleType,
IInterchainSecurityModuleDispatcher, IInterchainSecurityModuleDispatcherTrait, IInterchainSecurityModule
IInterchainSecurityModuleDispatcher, IInterchainSecurityModuleDispatcherTrait,
IInterchainSecurityModule
};
use hyperlane_starknet::tests::setup::{
setup, mock_setup, setup_messageid_multisig_ism, OWNER, NEW_OWNER,
VALIDATOR_ADDRESS, VALIDATOR_PUBLIC_KEY, setup_validator_announce, get_message_and_signature,
LOCAL_DOMAIN, DESTINATION_DOMAIN, RECIPIENT_ADDRESS
setup, mock_setup, setup_messageid_multisig_ism, OWNER, NEW_OWNER, VALIDATOR_ADDRESS,
VALIDATOR_PUBLIC_KEY, setup_validator_announce, get_message_and_signature, LOCAL_DOMAIN,
DESTINATION_DOMAIN, RECIPIENT_ADDRESS
};
use openzeppelin::access::ownable::OwnableComponent;
use openzeppelin::access::ownable::interface::{IOwnableDispatcher, IOwnableDispatcherTrait};
Expand Down

0 comments on commit f029dc3

Please sign in to comment.