Skip to content

Commit

Permalink
apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Artemka374 committed Feb 2, 2023
1 parent f77995c commit f209379
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 29 deletions.
5 changes: 1 addition & 4 deletions contracts/src/traits/timelock_controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ impl Default for Transaction {
fn default() -> Self {
Self {
callee: ZERO_ADDRESS.into(),
selector: Default::default(),
input: Default::default(),
transferred_value: Default::default(),
gas_limit: Default::default(),
..Default::default()
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/upgradeability/diamond/diamond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ where
}

ink::env::call::build_call::<ink::env::DefaultEnvironment>()
.call_type(DelegateCall::new(delegate_code.unwrap()))
.delegate(delegate_code.unwrap())
.call_flags(
ink::env::CallFlags::default()
// We don't plan to use the input data after the delegated call, so the
Expand All @@ -197,7 +197,7 @@ where

default fn _init_call(&self, call: InitCall) -> ! {
ink::env::call::build_call::<ink::env::DefaultEnvironment>()
.call_type(DelegateCall::new(call.hash))
.delegate(call.hash)
.exec_input(ExecutionInput::new(InkSelector::new(call.selector)).push_arg(call.input))
.call_flags(ink::env::CallFlags::default()
// We don't plan to return back to that contract after execution, so we
Expand Down
3 changes: 2 additions & 1 deletion contracts/src/upgradeability/proxy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use openbrush::{
traits::{
Hash,
Storage,
StorageAsRef,
},
};

Expand Down Expand Up @@ -82,7 +83,7 @@ impl<T: Storage<Data>> Internal for T {

default fn _fallback(&self) -> ! {
ink::env::call::build_call::<ink::env::DefaultEnvironment>()
.call_type(DelegateCall::new(self.data().forward_to.clone()))
.delegate(self.data().forward_to.clone())
.call_flags(
ink::env::CallFlags::default()
// We don't plan to use the input data after the delegated call, so the
Expand Down
7 changes: 1 addition & 6 deletions example_project_structure/impls/lending/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,8 @@ pub struct Data {
impl Default for Data {
fn default() -> Self {
Self {
assets_lended: Default::default(),
asset_shares: Default::default(),
shares_asset: Default::default(),
collateral_accepted: Default::default(),
asset_price: Default::default(),
shares_contract_code_hash: Hash::default(),
loan_account: [0u8; 32].into(),
..Default::default()
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions example_project_structure/traits/loan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ impl Default for LoanInfo {
Self {
borrower: [0u8; 32].into(),
collateral_token: [0u8; 32].into(),
collateral_amount: Balance::default(),
borrow_token: [0u8; 32].into(),
borrow_amount: Balance::default(),
liquidation_price: Balance::default(),
timestamp: Timestamp::default(),
liquidated: false,
..Defalt::default()
}
}
}
Expand Down
14 changes: 4 additions & 10 deletions examples/psp22/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ pub mod my_psp22 {
hated_account: AccountId,
}

impl Default for Contract {
fn default() -> Self {
Self {
psp22: Default::default(),
hated_account: [0u8; 32].into(),
}
}
}

impl Transfer for Contract {
// Let's override method to reject transactions to bad account
fn _before_token_transfer(
Expand All @@ -49,7 +40,10 @@ pub mod my_psp22 {
impl Contract {
#[ink(constructor)]
pub fn new(total_supply: Balance) -> Self {
let mut instance = Self::default();
let mut instance = Self {
psp22: Default::default(),
hated_account: [0u8; 32].into(),
};

instance
._mint_to(Self::env().caller(), total_supply)
Expand Down
1 change: 0 additions & 1 deletion lang/codegen/src/trait_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ fn generate_wrapper(ink_trait: ItemTrait) -> proc_macro2::TokenStream {
#[inline]
fn #message_builder_ident(
& self

#( , #input_bindings : #input_types )*
) -> ::ink::env::call::CallBuilder<
::ink::env::DefaultEnvironment,
Expand Down

0 comments on commit f209379

Please sign in to comment.