Skip to content

Commit

Permalink
Merge branch 'main' of github.com:ImbueNetwork/imbue into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
f-gate committed Dec 5, 2023
2 parents fff83cd + b232698 commit 40e7f54
Show file tree
Hide file tree
Showing 55 changed files with 2,957 additions and 1,367 deletions.
15 changes: 4 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build-on-self-hosted-runner
name: test-features
on:
workflow_dispatch:
push:
Expand Down Expand Up @@ -45,9 +45,9 @@ jobs:
ephemeral: true

test-features:
needs: create-runner
runs-on: ${{ needs.create-runner.outputs.label }}
steps:
needs: create-runner
runs-on: ${{ needs.create-runner.outputs.label }}
steps:
- uses: actions/checkout@v4

- name: Set HOME
Expand All @@ -60,16 +60,9 @@ jobs:
toolchain: nightly-2023-05-22
target: wasm32-unknown-unknown
override: true
components: rustfmt, clippy

- name: Install Dependencies
run: sudo apt install protobuf-compiler clang build-essential -y

- name: 🫠 rustfmt 🫠
uses: actions-rs/cargo@v1
with:
command: fmt
args: --check

- name: Run tests with benchmarks
run: cargo test --features runtime-benchmarks
37 changes: 37 additions & 0 deletions .github/workflows/fmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: cargo-fmt
on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- "**.md"
pull_request:
branches:
- main
paths-ignore:
- "**.md"

jobs:
cargo-fmt:
runs-on: ${{ needs.create-runner.outputs.label }}
steps:
- uses: actions/checkout@v4

- name: Set HOME
run: echo "HOME=/home/ubuntu" >> ${GITHUB_ENV}

- name: Install minimal nightly Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2023-05-22
target: wasm32-unknown-unknown
override: true
components: rustfmt, clippy

- name: 🫠 rustfmt 🫠
uses: actions-rs/cargo@v1
with:
command: fmt
args: --check
37 changes: 7 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ members = [
"pallets/proposals",
"pallets/briefs",
"pallets/grants",
"pallets/crowdfunding",
"pallets/deposits",
"pallets/disputes",
"pallets/fellowship",
Expand Down
28 changes: 7 additions & 21 deletions libs/common-types/src/milestone_origin.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::{sp_runtime::traits::AccountIdConversion, PalletId};
use scale_info::TypeInfo;
use xcm::latest::{Junction, Junctions::*, MultiLocation};

/// A wrapper around
pub trait TreasuryOriginConverter<AccountId: Into<[u8; 32]>> {
fn get_multi_location(
&self,
recipiant: AccountId,
) -> Result<MultiLocation, TreasuryOriginError>;
pub trait TreasuryOriginConverter {
fn get_multi_location(&self) -> Result<MultiLocation, TreasuryOriginError>;
}

impl<AccountId: Into<[u8; 32]>> TreasuryOriginConverter<AccountId> for TreasuryOrigin {
fn get_multi_location(
&self,
recipiant: AccountId,
) -> Result<MultiLocation, TreasuryOriginError> {
impl TreasuryOriginConverter for TreasuryOrigin {
fn get_multi_location(&self) -> Result<MultiLocation, TreasuryOriginError> {
match &self {
TreasuryOrigin::Kusama => Ok(MultiLocation::new(
1,
X1(Junction::AccountId32 {
id: recipiant.into(),
id: PalletId(*b"py/trsry").into_account_truncating(),
network: None,
}),
)),
TreasuryOrigin::Imbue => Ok(MultiLocation::new(
0,
X1(Junction::AccountId32 {
id: recipiant.into(),
id: PalletId(*b"py/trsry").into_account_truncating(),
network: None,
}),
)),
Expand All @@ -43,15 +38,6 @@ pub enum TreasuryOriginError {
NetworkUnsupported,
}

#[derive(
Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen,
)]
pub enum FundingType {
Proposal,
Brief,
Grant(TreasuryOrigin),
}

#[derive(
Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen,
)]
Expand Down
6 changes: 3 additions & 3 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ async fn start_node_impl(
config: parachain_config,
keystore: params.keystore_container.keystore(),
backend,
network: network.clone(),
network,
sync_service: sync_service.clone(),
system_rpc_tx,
tx_handler_controller,
Expand Down Expand Up @@ -318,7 +318,7 @@ async fn start_node_impl(
&task_manager,
relay_chain_interface.clone(),
transaction_pool,
sync_service.clone(),
sync_service,
params.keystore_container.keystore(),
relay_chain_slot_duration,
para_id,
Expand Down Expand Up @@ -395,7 +395,7 @@ fn start_consensus(
client.clone(),
transaction_pool,
prometheus_registry,
telemetry.clone(),
telemetry,
);

let proposer = Proposer::new(proposer_factory);
Expand Down
6 changes: 4 additions & 2 deletions pallets/briefs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-li
common-traits = { path = "../../libs/common-traits", default-features = false }
common-types = { path = "../../libs/common-types", default-features = false }
pallet-deposits = {path= "../deposits", default-features = false }
pallet-fellowship = { path = "../fellowship", default-features = false }
pallet-proposals = {path= "../proposals", default-features = false }

[dev-dependencies]
Expand All @@ -54,7 +55,7 @@ common-types = { path = "../../libs/common-types" }
common-runtime = { path = "../../runtime/common"}
pallet-proposals = {path= "../proposals"}
pallet-deposits = {path= "../deposits"}

pallet-disputes = {path= "../disputes"}

[features]
default = [ 'std' ]
Expand All @@ -70,7 +71,7 @@ std = [
"pallet-balances/std",
"pallet-deposits/std",
"pallet-proposals/std",
"pallet-timestamp/std",
"pallet-fellowship/std",
"scale-info/std",
"serde/std",
"sp-api/std",
Expand Down Expand Up @@ -102,6 +103,7 @@ try-runtime = [
"pallet-proposals/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-fellowship/try-runtime",
"pallet-xcm/try-runtime",
"sp-runtime/try-runtime",
]
43 changes: 35 additions & 8 deletions pallets/briefs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ mod benchmarking;
#[cfg(any(feature = "runtime-benchmarks", test))]
mod test_utils;

pub mod migrations;
//pub mod migrations;

#[frame_support::pallet]
pub mod pallet {
use common_types::{milestone_origin::FundingType, CurrencyId};
use common_types::CurrencyId;
use frame_support::{
pallet_prelude::*, sp_runtime::Saturating, traits::Get, weights::Weight, BoundedBTreeMap,
};
use frame_system::pallet_prelude::*;
use orml_traits::{MultiCurrency, MultiReservableCurrency};
use pallet_deposits::traits::DepositHandler;
use pallet_fellowship::traits::SelectJury;
use pallet_proposals::traits::IntoProposal;
use pallet_proposals::{Contribution, ProposedMilestone};
use pallet_proposals::{Contribution, FundingPath, ProposedMilestone};
use sp_arithmetic::per_things::Percent;
use sp_core::H256;
use sp_runtime::traits::Zero;
Expand Down Expand Up @@ -70,8 +71,8 @@ pub mod pallet {
#[pallet::config]
pub trait Config: frame_system::Config {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// The currency type.
type RMultiCurrency: MultiReservableCurrency<AccountIdOf<Self>, CurrencyId = CurrencyId>;
type AuthorityOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// The type that allows for evolution from brief to proposal.
type IntoProposal: IntoProposal<AccountIdOf<Self>, BalanceOf<Self>, BlockNumberFor<Self>>;
/// The maximum amount of owners to a brief.
Expand All @@ -82,7 +83,9 @@ pub mod pallet {
/// Storage deposits.
type BriefStorageItem: Get<StorageItemOf<Self>>;
type DepositHandler: DepositHandler<BalanceOf<Self>, AccountIdOf<Self>>;

/// The type that selects a list of jury members.
type JurySelector: SelectJury<AccountIdOf<Self>>;
/// The weight info for the extrinsics.
type WeightInfo: WeightInfoT;
}

Expand Down Expand Up @@ -147,6 +150,8 @@ pub mod pallet {
FreelancerApprovalRequired,
/// Milestones total do not add up to 100%.
MilestonesTotalPercentageMustEqual100,
/// too many milestones here mate fixed with https://github.com/ImbueNetwork/imbue/issues/267
TooManyMilestones,
}

#[pallet::call]
Expand Down Expand Up @@ -291,13 +296,35 @@ pub mod pallet {
let contributions = BriefContributions::<T>::get(brief_id);

<T as Config>::DepositHandler::return_deposit(brief.deposit_id)?;

let refund_locations =
<T as Config>::IntoProposal::convert_contributions_to_refund_locations(
&contributions
.clone()
.into_inner()
.try_into()
.map_err(|_| Error::<T>::TooManyBriefOwners)?,
);

<T as Config>::IntoProposal::convert_to_proposal(
brief.currency_id,
contributions.into_inner(),
contributions
.into_inner()
.try_into()
.map_err(|_| Error::<T>::TooManyBriefOwners)?,
brief_id,
brief.applicant,
brief.milestones.into(),
FundingType::Brief,
brief
.milestones
.to_vec()
.try_into()
.map_err(|_| Error::<T>::TooManyMilestones)?,
refund_locations,
<T::JurySelector as SelectJury<AccountIdOf<T>>>::select_jury()
.to_vec()
.try_into()
.map_err(|_| Error::<T>::TooManyMilestones)?,
FundingPath::TakeFromReserved,
)?;

BriefContributions::<T>::remove(brief_id);
Expand Down
Loading

0 comments on commit 40e7f54

Please sign in to comment.