Skip to content

Commit

Permalink
remove commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
open-junius committed Dec 10, 2024
1 parent bc8c514 commit 157032b
Showing 1 changed file with 0 additions and 72 deletions.
72 changes: 0 additions & 72 deletions runtime/src/precompiles/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,76 +105,4 @@ impl StakingPrecompile {
hotkey.copy_from_slice(get_slice(data, 0, 32)?);
Ok(hotkey)
}

// fn dispatch(handle: &mut impl PrecompileHandle, call: RuntimeCall) -> PrecompileResult {
// let account_id =
// <HashedAddressMapping<BlakeTwo256> as AddressMapping<AccountId32>>::into_account_id(
// handle.context().caller,
// );

// // Transfer the amount back to the caller before executing the staking operation
// // let caller = handle.context().caller;
// let amount = handle.context().apparent_value;

// if !amount.is_zero() {
// Self::transfer_back_to_caller(&account_id, amount)?;
// }

// let result = call.dispatch(RawOrigin::Signed(account_id.clone()).into());
// match &result {
// Ok(post_info) => log::info!("Dispatch succeeded. Post info: {:?}", post_info),
// Err(dispatch_error) => log::error!("Dispatch failed. Error: {:?}", dispatch_error),
// }
// match result {
// Ok(_) => Ok(PrecompileOutput {
// exit_status: ExitSucceed::Returned,
// output: vec![],
// }),
// Err(_) => Err(PrecompileFailure::Error {
// exit_status: ExitError::Other("Subtensor call failed".into()),
// }),
// }
// }

// fn transfer_back_to_caller(
// account_id: &AccountId32,
// amount: U256,
// ) -> Result<(), PrecompileFailure> {
// // this is staking smart contract's(0x0000000000000000000000000000000000000801) sr25519 address
// let smart_contract_account_id =
// match AccountId32::from_ss58check("5CwnBK9Ack1mhznmCnwiibCNQc174pYQVktYW3ayRpLm4K2X") {
// Ok(addr) => addr,
// Err(_) => {
// return Err(PrecompileFailure::Error {
// exit_status: ExitError::Other("Invalid SS58 address".into()),
// });
// }
// };
// let amount_sub =
// <Runtime as pallet_evm::Config>::BalanceConverter::into_substrate_balance(amount)
// .ok_or(ExitError::OutOfFund)?;

// // Create a transfer call from the smart contract to the caller
// let transfer_call =
// RuntimeCall::Balances(pallet_balances::Call::<Runtime>::transfer_allow_death {
// dest: account_id.clone().into(),
// value: amount_sub.unique_saturated_into(),
// });

// // Execute the transfer
// let transfer_result =
// transfer_call.dispatch(RawOrigin::Signed(smart_contract_account_id).into());

// if let Err(dispatch_error) = transfer_result {
// log::error!(
// "Transfer back to caller failed. Error: {:?}",
// dispatch_error
// );
// return Err(PrecompileFailure::Error {
// exit_status: ExitError::Other("Transfer back to caller failed".into()),
// });
// }

// Ok(())
// }
}

0 comments on commit 157032b

Please sign in to comment.