Skip to content

Commit

Permalink
fix: operator input in the MAD precompile delegate call (#882)
Browse files Browse the repository at this point in the history
  • Loading branch information
shekohex authored Jan 13, 2025
1 parent a67f744 commit c5844eb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions node/tests/evm_restaking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ fn operator_join_delegator_delegate_erc20() {

let delegate_result = precompile
.delegate(
alice.address().into_word(),
alice.address().to_account_id().0.into(),
U256::ZERO,
*usdc.address(),
delegate_amount,
Expand Down Expand Up @@ -498,7 +498,7 @@ fn operator_join_delegator_delegate_asset_id() {

let delegate_result = precompile
.delegate(
alice.address().into_word(),
alice.address().to_account_id().0.into(),
U256::from(t.usdc_asset_id),
Address::ZERO,
U256::from(delegate_amount),
Expand Down
3 changes: 1 addition & 2 deletions precompiles/multi-asset-delegation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,7 @@ where

let caller = handle.context().caller;
let who = Runtime::AddressMapping::into_account_id(caller);
let operator =
Runtime::AddressMapping::into_account_id(H160::from_slice(&operator.0[12..]));
let operator = Runtime::AccountId::from(WrappedAccountId32(operator.0));

let (deposit_asset, amount) = match (asset_id.as_u128(), token_address.0 .0) {
(0, erc20_token) if erc20_token != [0; 20] => {
Expand Down
8 changes: 8 additions & 0 deletions precompiles/multi-asset-delegation/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ fn test_delegate_assets() {
.execute_returns(());

assert_eq!(Assets::balance(1, delegator_account), 500 - 200); // no change when delegating
assert!(Operators::<Runtime>::get(operator_account)
.unwrap()
.delegations
.iter()
.find(|x| x.delegator == delegator_account
&& x.asset_id == Asset::Custom(1)
&& x.amount == 100)
.is_some());
});
}

Expand Down

0 comments on commit c5844eb

Please sign in to comment.