Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
f-gate committed Dec 6, 2023
1 parent 41f2e73 commit 4327c2e
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 44 deletions.
30 changes: 10 additions & 20 deletions libs/common-types/src/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ pub enum CurrencyId {
ForeignAsset(ForeignAssetId),
}


#[derive(
Clone,
Copy,
Expand All @@ -52,7 +51,6 @@ pub enum ForeignAssetId {
USDT,
}


#[derive(
Clone,
Copy,
Expand All @@ -68,7 +66,7 @@ pub enum ForeignAssetId {
Serialize,
Deserialize,
)]
/// The foreign owned account describes the chain
/// The foreign owned account describes the chain
pub enum ForeignOwnedAccount {
TRON([u8; 22]),
ETH([u8; 20]),
Expand All @@ -85,23 +83,15 @@ impl ForeignOwnedAccount {
CurrencyId::AUSD => false,
CurrencyId::KAR => false,
CurrencyId::MGX => false,
CurrencyId::ForeignAsset(asset) => {

match &self {
ForeignOwnedAccount::TRON(_) => {
match asset {
ForeignAssetId::ETH => false,
ForeignAssetId::USDT => true
}
},
ForeignOwnedAccount::ETH(_) => {
match asset {
ForeignAssetId::ETH => true,
ForeignAssetId::USDT => true
}
}
}

CurrencyId::ForeignAsset(asset) => match &self {
ForeignOwnedAccount::TRON(_) => match asset {
ForeignAssetId::ETH => false,
ForeignAssetId::USDT => true,
},
ForeignOwnedAccount::ETH(_) => match asset {
ForeignAssetId::ETH => true,
ForeignAssetId::USDT => true,
},
},
}
}
Expand Down
12 changes: 9 additions & 3 deletions pallets/briefs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,16 @@ pub mod pallet {
);

if let CurrencyId::ForeignAsset(_) = currency_id {
ensure!(external_owned_address.is_some(), Error::<T>::EoaRequiredForForeignCurrencies);
ensure!(
external_owned_address.is_some(),
Error::<T>::EoaRequiredForForeignCurrencies
);
}
if let Some(eoa) = external_owned_address {
ensure!(eoa.ensure_supported_currency(currency_id), Error::<T>::CurrencyAccountComboNotSupported);
ensure!(
eoa.ensure_supported_currency(currency_id),
Error::<T>::CurrencyAccountComboNotSupported
);
}

let total_percentage = milestones
Expand Down Expand Up @@ -414,7 +420,7 @@ pub mod pallet {
applicant: AccountIdOf<T>,
milestones: BoundedProposedMilestones<T>,
deposit_id: DepositIdOf<T>,
eoa: Option<common_types::ForeignOwnedAccount>
eoa: Option<common_types::ForeignOwnedAccount>,
) -> Self {
Self {
created_at,
Expand Down
10 changes: 4 additions & 6 deletions pallets/briefs/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ mod v0 {
pub(crate) mod v1 {
use super::*;


pub fn migrate_to_v1<T: Config>(weight: &mut Weight) {
if v2::StorageVersion::<T>::get() == v2::Release::V0 {
v2::BriefsV2::<T>::translate(|_, brief: v0::BriefDataV0<T>| {
Expand Down Expand Up @@ -97,7 +96,6 @@ pub mod v2 {
pub type BriefsV2<T: Config> =
CountedStorageMap<Pallet<T>, Blake2_128Concat, BriefHash, BriefDataV2<T>, OptionQuery>;


#[derive(Encode, Decode, PartialEq, Eq, Clone, Debug, MaxEncodedLen, TypeInfo)]
#[scale_info(skip_type_params(T))]
pub struct BriefDataV2<T: Config> {
Expand All @@ -109,7 +107,6 @@ pub mod v2 {
pub milestones: BoundedProposedMilestones<T>,
pub deposit_id: crate::DepositIdOf<T>,
}


#[storage_alias]
pub type StorageVersion<T: Config> = StorageValue<Pallet<T>, Release, ValueQuery>;
Expand Down Expand Up @@ -175,7 +172,10 @@ pub mod v3 {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
let onchain = Pallet::<T>::on_chain_storage_version();
ensure!(onchain == 2, "onchain must be version 2 to run the migration.");
ensure!(
onchain == 2,
"onchain must be version 2 to run the migration."
);
Ok(<Vec<u8> as Default>::default())
}

Expand All @@ -184,7 +184,6 @@ pub mod v3 {
let onchain = Pallet::<T>::on_chain_storage_version();
let mut weight: Weight = Default::default();
if current == 3 && onchain == 2 {

Briefs::<T>::drain().for_each(|(key, brief)| {
let migrated_brief = BriefData {
created_at: brief.created_at,
Expand Down Expand Up @@ -224,7 +223,6 @@ pub mod v3 {
}
}


#[cfg(test)]
mod test {
use super::*;
Expand Down
20 changes: 10 additions & 10 deletions pallets/briefs/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn create_brief_with_no_contribution_ok() {
gen_hash(1),
CurrencyId::Native,
get_milestones(10),
None,
None,
));
});
}
Expand All @@ -72,7 +72,7 @@ fn create_brief_no_contribution_and_contribute() {
brief_id,
CurrencyId::Native,
get_milestones(10),
None,
None,
));

(0..5).for_each(|_| {
Expand Down Expand Up @@ -114,7 +114,7 @@ fn contribute_to_brief_not_brief_owner() {
brief_id,
CurrencyId::Native,
get_milestones(10),
None,
None,
));

assert_noop!(
Expand Down Expand Up @@ -143,7 +143,7 @@ fn contribute_to_brief_more_than_total_ok() {
brief_id,
CurrencyId::Native,
get_milestones(10),
None,
None,
));
assert_ok!(BriefsMod::contribute_to_brief(
RuntimeOrigin::signed(BOB),
Expand All @@ -168,7 +168,7 @@ fn create_brief_already_exists() {
brief_id,
CurrencyId::Native,
get_milestones(10),
None,
None,
));

assert_noop!(
Expand Down Expand Up @@ -203,7 +203,7 @@ fn only_applicant_can_start_work() {
brief_id,
CurrencyId::Native,
get_milestones(10),
None,
None,
));

assert_noop!(
Expand Down Expand Up @@ -233,7 +233,7 @@ fn initial_contribution_and_extra_contribution_aggregates() {
brief_id,
CurrencyId::Native,
get_milestones(10),
None,
None,
));

assert_ok!(BriefsMod::contribute_to_brief(
Expand Down Expand Up @@ -270,7 +270,7 @@ fn reserved_funds_are_transferred_to_project_kitty() {
brief_id,
CurrencyId::Native,
get_milestones(10),
None,
None,
);

assert_ok!(BriefsMod::commence_work(
Expand Down Expand Up @@ -303,7 +303,7 @@ fn cancel_brief_works() {
brief_id,
CurrencyId::Native,
get_milestones(10),
None,
None,
));

assert_ok!(BriefsMod::contribute_to_brief(
Expand Down Expand Up @@ -370,7 +370,7 @@ fn cancel_brief_not_brief_owner() {
brief_id,
CurrencyId::Native,
get_milestones(10),
None,
None,
));

assert_noop!(
Expand Down
12 changes: 9 additions & 3 deletions pallets/grants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,21 @@ pub mod pallet {
amount_requested: BalanceOf<T>,
treasury_origin: TreasuryOrigin,
grant_id: GrantId,
external_owned_address: Option<common_types::ForeignOwnedAccount>
external_owned_address: Option<common_types::ForeignOwnedAccount>,
) -> DispatchResultWithPostInfo {
let submitter = ensure_signed(origin)?;

if let CurrencyId::ForeignAsset(_) = currency_id {
ensure!(external_owned_address.is_some(), Error::<T>::EoaRequiredForForeignCurrencies);
ensure!(
external_owned_address.is_some(),
Error::<T>::EoaRequiredForForeignCurrencies
);
}
if let Some(eoa) = external_owned_address {
ensure!(eoa.ensure_supported_currency(currency_id), Error::<T>::CurrencyAccountComboNotSupported);
ensure!(
eoa.ensure_supported_currency(currency_id),
Error::<T>::CurrencyAccountComboNotSupported
);
}

let percentage_sum = proposed_milestones
Expand Down
2 changes: 1 addition & 1 deletion pallets/proposals/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ pub struct Project<T: Config> {
pub on_creation_funding: FundingPath,
/// The amount of funds refunded.
pub refunded_funds: BalanceOf<T>,
/// The payment address used when the currency_id is of type foreign.
/// The payment address used when the currency_id is of type foreign.
pub external_owned_address: Option<common_types::ForeignOwnedAccount>,
}

Expand Down
2 changes: 1 addition & 1 deletion pallets/proposals/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub trait IntoProposal<AccountId, Balance: AtLeast32BitUnsigned, BlockNumber> {
>,
jury: BoundedVec<AccountId, Self::MaxJuryMembers>,
on_creation_funding: FundingPath,
eoa: Option<common_types::ForeignOwnedAccount>
eoa: Option<common_types::ForeignOwnedAccount>,
) -> Result<(), DispatchError>;

/// Use when the contributors are the refund locations.
Expand Down

0 comments on commit 4327c2e

Please sign in to comment.