-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add domain routing hook #38
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
smol comment will let @JordyRo1 give a detailled review
Hi, can you add some test coverage for your contract, please ? You can deploy your contract by defining a function in the setup.cairo (cf: https://github.com/astraly-labs/hyperlane_starknet/blob/main/contracts/src/tests/setup.cairo). You can use |
@JordyRo1 Tried to add tests. Can you have a look now |
} | ||
|
||
fn post_dispatch(ref self: ContractState, _metadata: Bytes, _message: Message) { | ||
self._get_configured_hook(_message.clone()).post_dispatch(_metadata, _message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The post dispatch function lacks the fee mecanism (represented on the solidity version by msg.value). Since we do not have native token, we will have to transfer erc20 manually. Leave it as it is right, now, I will handle it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can try to add the fee mechanism. Context would be the protocol_fee
hook? Additionally, did you have a look at my test files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, protocol fee hook is the context and since it is a routing hook, it will require to quote_dispatch.
let ownable = IOwnableDispatcher { contract_address: set_routing_hook_addrs.contract_address }; | ||
start_prank(CheatTarget::One(ownable.contract_address), OWNER()); | ||
let destination: u32 = 18; | ||
let hook: ContractAddress = setup_mock_hook().contract_address; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The errror Result: unwrap failed
comes from this setup_mock_hook. Since we already declared the setup_mock_hook for the mailbox setup, calling it again here cause the declaration to fail because the contract is already declared
let token_dispatcher = IERC20Dispatcher { contract_address: self.fee_token.read() }; | ||
let user_balance = token_dispatcher.balance_of(from); | ||
assert(user_balance >= amount, Errors::INSUFFICIENT_BALANCE); | ||
let transfer_flag: bool = token_dispatcher.transfer_from(from, to, amount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check the allowance for the caller before the transfer
Reviewed. The general hook idea is understood, everything seems fine ! |
Implements #29