-
Notifications
You must be signed in to change notification settings - Fork 8
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
Relayer fees #51
base: main
Are you sure you want to change the base?
Relayer fees #51
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ mod types; | |
|
||
/// Contract module | ||
#[ink::contract] | ||
#[allow(clippy::large_enum_variant)] | ||
pub mod contract { | ||
|
||
use crate::{errors::ShielderError, merkle::MerkleTree, traits::psp22::PSP22Error, types::Set}; | ||
|
@@ -111,6 +112,85 @@ pub mod contract { | |
) | ||
.returns::<Result<(), PSP22Error>>() | ||
.invoke()?, | ||
OpPub::DepositRelayer { | ||
amount, | ||
token, | ||
user, | ||
fee, | ||
fee_token, | ||
relayer, | ||
} => { | ||
build_call::<DefaultEnvironment>() | ||
.call(AccountId::from(token.bytes)) | ||
.call_v1() | ||
.gas_limit(0) | ||
.transferred_value(0) | ||
.exec_input( | ||
ExecutionInput::new(Selector::new(ink::selector_bytes!( | ||
"PSP22::transfer_from" | ||
))) | ||
.push_arg(AccountId::from(user.bytes)) | ||
.push_arg(self.env().account_id()) | ||
.push_arg(amount) | ||
.push_arg([].to_vec() as ink::prelude::vec::Vec<u8>), | ||
) | ||
.returns::<Result<(), PSP22Error>>() | ||
.invoke()?; | ||
Comment on lines
+123
to
+138
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please reduce repetitions across this module - you can crate functions dedicated for |
||
build_call::<DefaultEnvironment>() | ||
.call(AccountId::from(fee_token.bytes)) | ||
.call_v1() | ||
.gas_limit(0) | ||
.transferred_value(0) | ||
.exec_input( | ||
ExecutionInput::new(Selector::new(ink::selector_bytes!( | ||
"PSP22::transfer" | ||
))) | ||
.push_arg(AccountId::from(relayer.bytes)) | ||
.push_arg(fee) | ||
.push_arg([].to_vec() as ink::prelude::vec::Vec<u8>), | ||
) | ||
.returns::<Result<(), PSP22Error>>() | ||
.invoke()?; | ||
} | ||
OpPub::WithdrawRelayer { | ||
amount, | ||
token, | ||
user, | ||
fee, | ||
fee_token, | ||
relayer, | ||
} => { | ||
build_call::<DefaultEnvironment>() | ||
.call(AccountId::from(token.bytes)) | ||
.call_v1() | ||
.gas_limit(0) | ||
.transferred_value(0) | ||
.exec_input( | ||
ExecutionInput::new(Selector::new(ink::selector_bytes!( | ||
"PSP22::transfer" | ||
))) | ||
.push_arg(AccountId::from(user.bytes)) | ||
.push_arg(amount) | ||
.push_arg([].to_vec() as ink::prelude::vec::Vec<u8>), | ||
) | ||
.returns::<Result<(), PSP22Error>>() | ||
.invoke()?; | ||
build_call::<DefaultEnvironment>() | ||
.call(AccountId::from(fee_token.bytes)) | ||
.call_v1() | ||
.gas_limit(0) | ||
.transferred_value(0) | ||
.exec_input( | ||
ExecutionInput::new(Selector::new(ink::selector_bytes!( | ||
"PSP22::transfer" | ||
))) | ||
.push_arg(AccountId::from(relayer.bytes)) | ||
.push_arg(fee) | ||
.push_arg([].to_vec() as ink::prelude::vec::Vec<u8>), | ||
) | ||
.returns::<Result<(), PSP22Error>>() | ||
.invoke()?; | ||
} | ||
}; | ||
Ok(()) | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,9 @@ pub fn init_bob(session: &mut Session<MinimalSandbox>) -> Result<AccountId32> { | |
init_acc_with_balance(session, &res)?; | ||
Ok(res) | ||
} | ||
|
||
pub fn init_relayer(session: &mut Session<MinimalSandbox>) -> Result<AccountId32> { | ||
let res = AccountId32::new([4u8; 32]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please use constants for all actors in this module |
||
init_acc_with_balance(session, &res)?; | ||
Ok(res) | ||
} |
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.
nit: things like removing psp submodule can be easily done in separate mini PRs