Skip to content
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

Release v1.01 #295

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions ci/jobs/build-and-test.sh

This file was deleted.

7 changes: 0 additions & 7 deletions ci/jobs/clippy.sh

This file was deleted.

15 changes: 12 additions & 3 deletions libs/common-types/src/tokens.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_std::vec::Vec;

use frame_support::traits::ConstU32;
use serde::{Deserialize, Serialize};

use sp_runtime::BoundedVec;
#[derive(
Clone,
Copy,
Expand Down Expand Up @@ -49,11 +51,12 @@ pub enum CurrencyId {
pub enum ForeignAssetId {
ETH,
USDT,
ADA,
}

#[derive(
Clone,
Copy,
// Copy,
PartialOrd,
Ord,
PartialEq,
Expand All @@ -70,6 +73,7 @@ pub enum ForeignAssetId {
pub enum ForeignOwnedAccount {
TRON([u8; 22]),
ETH([u8; 20]),
ADA(BoundedVec<u8, ConstU32<104>>),
}

impl ForeignOwnedAccount {
Expand All @@ -85,12 +89,17 @@ impl ForeignOwnedAccount {
CurrencyId::MGX => false,
CurrencyId::ForeignAsset(asset) => match &self {
ForeignOwnedAccount::TRON(_) => match asset {
ForeignAssetId::ETH => false,
ForeignAssetId::USDT => true,
default => false,
},
ForeignOwnedAccount::ETH(_) => match asset {
ForeignAssetId::ETH => true,
ForeignAssetId::USDT => true,
default => false,
},
ForeignOwnedAccount::ADA(_) => match asset {
ForeignAssetId::ADA => true,
default => false,
},
},
}
Expand Down
9 changes: 7 additions & 2 deletions pallets/briefs/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ mod benchmarks {
fn create_brief() {
let (eoa, currency_id) = ForeignOwnedAccount::get_supported_currency_eoa_combo();
let brief_owners = get_max_brief_owners::<T>(currency_id);
let caller: T::AccountId = brief_owners[0].clone();
let caller = create_account_id::<T>("caller", 1, currency_id);
assert_ok!(T::RMultiCurrency::deposit(
CurrencyId::Native,
&caller,
1_000_000_000_000_000u128.saturated_into()
));
let applicant = create_account_id::<T>("applicant", 1, currency_id);
let budget = 10_000u32.into();
let initial_contribution = 5_000u32.into();
Expand Down Expand Up @@ -182,7 +187,7 @@ fn get_brief_owners<T: Config>(mut n: u32, currency: CurrencyId) -> BoundedBrief
}

fn get_max_brief_owners<T: Config>(currency_id: CurrencyId) -> BoundedBriefOwners<T> {
let max_brief_owners: u32 = <T as Config>::MaxBriefOwners::get();
let max_brief_owners: u32 = <T as Config>::MaxBriefOwners::get() - 1;
get_brief_owners::<T>(max_brief_owners, currency_id)
}

Expand Down
7 changes: 5 additions & 2 deletions pallets/briefs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ pub mod pallet {
EoaRequiredForForeignCurrencies,
/// Currency is not supported for this external address.
CurrencyAccountComboNotSupported,
/// You must be a fellow to start this work.
FellowshipRequired,
}

#[pallet::call]
Expand All @@ -186,7 +188,8 @@ pub mod pallet {
let who = ensure_signed(origin)?;

if require_fellowship {
T::EnsureRole::ensure_role(&applicant, pallet_fellowship::Role::Freelancer, None)?;
T::EnsureRole::ensure_role(&applicant, pallet_fellowship::Role::Freelancer, None)
.map_err(|_| Error::<T>::FellowshipRequired)?;
}

ensure!(
Expand All @@ -200,7 +203,7 @@ pub mod pallet {
Error::<T>::EoaRequiredForForeignCurrencies
);
}
if let Some(eoa) = external_owned_address {
if let Some(eoa) = external_owned_address.clone() {
ensure!(
eoa.ensure_supported_currency(currency_id),
Error::<T>::CurrencyAccountComboNotSupported
Expand Down
2 changes: 1 addition & 1 deletion pallets/briefs/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn create_brief_not_approved_applicant() {
None,
true,
),
BadOrigin
Error::<Test>::FellowshipRequired
);
});
}
Expand Down
190 changes: 136 additions & 54 deletions pallets/briefs/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,87 +2,79 @@
//! Autogenerated weights for `pallet_briefs`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-11-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-12-20, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `user`, CPU: `12th Gen Intel(R) Core(TM) i9-12900H`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("local")`, DB CACHE: 1024
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("imbue-dev")`, DB CACHE: `1024`

// Executed Command:
// ./target/debug/imbue
// ./target/release/imbue
// benchmark
// pallet
// --chain
// local
// --execution
// wasm
// --wasm-execution
// compiled
// --pallet
// pallet-briefs
// --extrinsic
// *
// --output
// weights.rs
// --steps
// 50
// --repeat
// 20
// --chain=imbue-dev
// --steps=50
// --repeat=20
// --pallet=pallet_briefs
// --extrinsic=*
// --output=./pallets/briefs/src/weights.rs
// --template=./scripts/frame-weight-template.hbs

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]

use frame_support::{traits::Get, weights::Weight};
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;
use crate::WeightInfoT;

/// Weight functions for `pallet_briefs`.
/// Weights for `pallet_briefs` using the Substrate node and recommended hardware.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> crate::WeightInfoT for WeightInfo<T> {
impl<T: frame_system::Config> WeightInfoT for WeightInfo<T> {
/// Storage: `ImbueBriefs::Briefs` (r:1 w:1)
/// Proof: `ImbueBriefs::Briefs` (`max_values`: None, `max_size`: Some(1725), added: 4200, mode: `MaxEncodedLen`)
/// Proof: `ImbueBriefs::Briefs` (`max_values`: None, `max_size`: Some(1830), added: 4305, mode: `MaxEncodedLen`)
/// Storage: `Deposits::TicketId` (r:1 w:1)
/// Proof: `Deposits::TicketId` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `OrmlTokens::Accounts` (r:1 w:1)
/// Proof: `OrmlTokens::Accounts` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`)
/// Storage: `ImbueBriefs::BriefContributions` (r:1 w:1)
/// Proof: `ImbueBriefs::BriefContributions` (`max_values`: None, `max_size`: Some(2649), added: 5124, mode: `MaxEncodedLen`)
/// Storage: `ImbueBriefs::CounterForBriefs` (r:1 w:1)
/// Proof: `ImbueBriefs::CounterForBriefs` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `Deposits::CurrentDeposits` (r:0 w:1)
/// Proof: `Deposits::CurrentDeposits` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
/// Proof: `Deposits::CurrentDeposits` (`max_values`: None, `max_size`: Some(66), added: 2541, mode: `MaxEncodedLen`)
fn create_brief() -> Weight {
// Proof Size summary in bytes:
// Measured: `334`
// Measured: `1042`
// Estimated: `6114`
// Minimum execution time: 674_565_000 picoseconds.
Weight::from_parts(699_090_000, 0)
.saturating_add(Weight::from_parts(0, 6114))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(6))
// Minimum execution time: 122_948_000 picoseconds.
Weight::from_parts(140_489_000, 6114)
.saturating_add(T::DbWeight::get().reads(6_u64))
.saturating_add(T::DbWeight::get().writes(7_u64))
}
/// Storage: `ImbueBriefs::Briefs` (r:1 w:0)
/// Proof: `ImbueBriefs::Briefs` (`max_values`: None, `max_size`: Some(1725), added: 4200, mode: `MaxEncodedLen`)
/// Proof: `ImbueBriefs::Briefs` (`max_values`: None, `max_size`: Some(1830), added: 4305, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `ImbueBriefs::BriefContributions` (r:1 w:1)
/// Proof: `ImbueBriefs::BriefContributions` (`max_values`: None, `max_size`: Some(2649), added: 5124, mode: `MaxEncodedLen`)
fn contribute_to_brief() -> Weight {
// Proof Size summary in bytes:
// Measured: `2119`
// Measured: `2122`
// Estimated: `6114`
// Minimum execution time: 388_641_000 picoseconds.
Weight::from_parts(404_811_000, 0)
.saturating_add(Weight::from_parts(0, 6114))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
// Minimum execution time: 66_724_000 picoseconds.
Weight::from_parts(75_703_000, 6114)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
/// Storage: `ImbueBriefs::Briefs` (r:1 w:1)
/// Proof: `ImbueBriefs::Briefs` (`max_values`: None, `max_size`: Some(1725), added: 4200, mode: `MaxEncodedLen`)
/// Proof: `ImbueBriefs::Briefs` (`max_values`: None, `max_size`: Some(1830), added: 4305, mode: `MaxEncodedLen`)
/// Storage: `ImbueBriefs::BriefContributions` (r:1 w:1)
/// Proof: `ImbueBriefs::BriefContributions` (`max_values`: None, `max_size`: Some(2649), added: 5124, mode: `MaxEncodedLen`)
/// Storage: `Deposits::CurrentDeposits` (r:1 w:2)
/// Proof: `Deposits::CurrentDeposits` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
/// Proof: `Deposits::CurrentDeposits` (`max_values`: None, `max_size`: Some(66), added: 2541, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:3 w:3)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `ImbueFellowship::Roles` (r:1 w:0)
Expand All @@ -96,23 +88,22 @@ impl<T: frame_system::Config> crate::WeightInfoT for WeightInfo<T> {
/// Storage: `ImbueBriefs::CounterForBriefs` (r:1 w:1)
/// Proof: `ImbueBriefs::CounterForBriefs` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `ImbueProposals::Projects` (r:0 w:1)
/// Proof: `ImbueProposals::Projects` (`max_values`: None, `max_size`: Some(36350), added: 38825, mode: `MaxEncodedLen`)
/// Proof: `ImbueProposals::Projects` (`max_values`: None, `max_size`: Some(36455), added: 38930, mode: `MaxEncodedLen`)
/// Storage: `ImbueProposals::IndividualVoteStore` (r:0 w:1)
/// Proof: `ImbueProposals::IndividualVoteStore` (`max_values`: None, `max_size`: Some(16571), added: 19046, mode: `MaxEncodedLen`)
fn commence_work() -> Weight {
// Proof Size summary in bytes:
// Measured: `2607`
// Measured: `2610`
// Estimated: `8799`
// Minimum execution time: 1_739_406_000 picoseconds.
Weight::from_parts(1_778_978_000, 0)
.saturating_add(Weight::from_parts(0, 8799))
.saturating_add(T::DbWeight::get().reads(11))
.saturating_add(T::DbWeight::get().writes(13))
// Minimum execution time: 276_193_000 picoseconds.
Weight::from_parts(282_041_000, 8799)
.saturating_add(T::DbWeight::get().reads(11_u64))
.saturating_add(T::DbWeight::get().writes(13_u64))
}
/// Storage: `ImbueBriefs::Briefs` (r:1 w:1)
/// Proof: `ImbueBriefs::Briefs` (`max_values`: None, `max_size`: Some(1725), added: 4200, mode: `MaxEncodedLen`)
/// Proof: `ImbueBriefs::Briefs` (`max_values`: None, `max_size`: Some(1830), added: 4305, mode: `MaxEncodedLen`)
/// Storage: `Deposits::CurrentDeposits` (r:1 w:1)
/// Proof: `Deposits::CurrentDeposits` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
/// Proof: `Deposits::CurrentDeposits` (`max_values`: None, `max_size`: Some(66), added: 2541, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `ImbueBriefs::BriefContributions` (r:1 w:1)
Expand All @@ -121,12 +112,103 @@ impl<T: frame_system::Config> crate::WeightInfoT for WeightInfo<T> {
/// Proof: `ImbueBriefs::CounterForBriefs` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn cancel_brief() -> Weight {
// Proof Size summary in bytes:
// Measured: `2353`
// Measured: `2356`
// Estimated: `6114`
// Minimum execution time: 721_794_000 picoseconds.
Weight::from_parts(753_268_000, 0)
.saturating_add(Weight::from_parts(0, 6114))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(5))
// Minimum execution time: 117_915_000 picoseconds.
Weight::from_parts(126_700_000, 6114)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
}

// For backwards compatibility and tests.
impl WeightInfoT for () {
/// Storage: `ImbueBriefs::Briefs` (r:1 w:1)
/// Proof: `ImbueBriefs::Briefs` (`max_values`: None, `max_size`: Some(1830), added: 4305, mode: `MaxEncodedLen`)
/// Storage: `Deposits::TicketId` (r:1 w:1)
/// Proof: `Deposits::TicketId` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `OrmlTokens::Accounts` (r:1 w:1)
/// Proof: `OrmlTokens::Accounts` (`max_values`: None, `max_size`: Some(106), added: 2581, mode: `MaxEncodedLen`)
/// Storage: `ImbueBriefs::BriefContributions` (r:1 w:1)
/// Proof: `ImbueBriefs::BriefContributions` (`max_values`: None, `max_size`: Some(2649), added: 5124, mode: `MaxEncodedLen`)
/// Storage: `ImbueBriefs::CounterForBriefs` (r:1 w:1)
/// Proof: `ImbueBriefs::CounterForBriefs` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `Deposits::CurrentDeposits` (r:0 w:1)
/// Proof: `Deposits::CurrentDeposits` (`max_values`: None, `max_size`: Some(66), added: 2541, mode: `MaxEncodedLen`)
fn create_brief() -> Weight {
// Proof Size summary in bytes:
// Measured: `1042`
// Estimated: `6114`
// Minimum execution time: 122_948_000 picoseconds.
Weight::from_parts(140_489_000, 6114)
.saturating_add(RocksDbWeight::get().reads(6_u64))
.saturating_add(RocksDbWeight::get().writes(7_u64))
}
/// Storage: `ImbueBriefs::Briefs` (r:1 w:0)
/// Proof: `ImbueBriefs::Briefs` (`max_values`: None, `max_size`: Some(1830), added: 4305, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `ImbueBriefs::BriefContributions` (r:1 w:1)
/// Proof: `ImbueBriefs::BriefContributions` (`max_values`: None, `max_size`: Some(2649), added: 5124, mode: `MaxEncodedLen`)
fn contribute_to_brief() -> Weight {
// Proof Size summary in bytes:
// Measured: `2122`
// Estimated: `6114`
// Minimum execution time: 66_724_000 picoseconds.
Weight::from_parts(75_703_000, 6114)
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
/// Storage: `ImbueBriefs::Briefs` (r:1 w:1)
/// Proof: `ImbueBriefs::Briefs` (`max_values`: None, `max_size`: Some(1830), added: 4305, mode: `MaxEncodedLen`)
/// Storage: `ImbueBriefs::BriefContributions` (r:1 w:1)
/// Proof: `ImbueBriefs::BriefContributions` (`max_values`: None, `max_size`: Some(2649), added: 5124, mode: `MaxEncodedLen`)
/// Storage: `Deposits::CurrentDeposits` (r:1 w:2)
/// Proof: `Deposits::CurrentDeposits` (`max_values`: None, `max_size`: Some(66), added: 2541, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:3 w:3)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `ImbueFellowship::Roles` (r:1 w:0)
/// Proof: `ImbueFellowship::Roles` (`max_values`: None, `max_size`: Some(51), added: 2526, mode: `MaxEncodedLen`)
/// Storage: `ImbueFellowship::JuryPointer` (r:1 w:1)
/// Proof: `ImbueFellowship::JuryPointer` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
/// Storage: `ImbueProposals::ProjectCount` (r:1 w:1)
/// Proof: `ImbueProposals::ProjectCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `Deposits::TicketId` (r:1 w:1)
/// Proof: `Deposits::TicketId` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`)
/// Storage: `ImbueBriefs::CounterForBriefs` (r:1 w:1)
/// Proof: `ImbueBriefs::CounterForBriefs` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `ImbueProposals::Projects` (r:0 w:1)
/// Proof: `ImbueProposals::Projects` (`max_values`: None, `max_size`: Some(36455), added: 38930, mode: `MaxEncodedLen`)
/// Storage: `ImbueProposals::IndividualVoteStore` (r:0 w:1)
/// Proof: `ImbueProposals::IndividualVoteStore` (`max_values`: None, `max_size`: Some(16571), added: 19046, mode: `MaxEncodedLen`)
fn commence_work() -> Weight {
// Proof Size summary in bytes:
// Measured: `2610`
// Estimated: `8799`
// Minimum execution time: 276_193_000 picoseconds.
Weight::from_parts(282_041_000, 8799)
.saturating_add(RocksDbWeight::get().reads(11_u64))
.saturating_add(RocksDbWeight::get().writes(13_u64))
}
/// Storage: `ImbueBriefs::Briefs` (r:1 w:1)
/// Proof: `ImbueBriefs::Briefs` (`max_values`: None, `max_size`: Some(1830), added: 4305, mode: `MaxEncodedLen`)
/// Storage: `Deposits::CurrentDeposits` (r:1 w:1)
/// Proof: `Deposits::CurrentDeposits` (`max_values`: None, `max_size`: Some(66), added: 2541, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `ImbueBriefs::BriefContributions` (r:1 w:1)
/// Proof: `ImbueBriefs::BriefContributions` (`max_values`: None, `max_size`: Some(2649), added: 5124, mode: `MaxEncodedLen`)
/// Storage: `ImbueBriefs::CounterForBriefs` (r:1 w:1)
/// Proof: `ImbueBriefs::CounterForBriefs` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn cancel_brief() -> Weight {
// Proof Size summary in bytes:
// Measured: `2356`
// Estimated: `6114`
// Minimum execution time: 117_915_000 picoseconds.
Weight::from_parts(126_700_000, 6114)
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(5_u64))
}
}
Loading
Loading