Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into enable-taplo-checks
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed Dec 1, 2023
2 parents 9db1b05 + 4c9d5f7 commit c070fcf
Show file tree
Hide file tree
Showing 42 changed files with 2,423 additions and 531 deletions.
23 changes: 22 additions & 1 deletion Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ members = [
"pallets/pool-registry",
"pallets/data-collector",
"pallets/restricted-tokens",
"pallets/restricted-xtokens",
"pallets/transfer-allowlist",
"pallets/rewards",
"runtime/altair",
Expand Down Expand Up @@ -248,6 +249,7 @@ pallet-permissions = { path = "pallets/permissions", default-features = false }
pallet-pool-registry = { path = "pallets/pool-registry", default-features = false }
pallet-pool-system = { path = "pallets/pool-system", default-features = false }
pallet-restricted-tokens = { path = "pallets/restricted-tokens", default-features = false }
pallet-restricted-xtokens = { path = "pallets/restricted-xtokens", default-features = false }
pallet-rewards = { path = "pallets/rewards", default-features = false }
pallet-transfer-allowlist = { path = "pallets/transfer-allowlist", default-features = false }

Expand Down
1 change: 1 addition & 0 deletions libs/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ cfg-primitives = { path = "../primitives", default-features = false }
cfg-traits = { path = "../traits", default-features = false }
cfg-utils = { path = "../utils", default-features = false }


[dev-dependencies]
frame-support = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.43" }
hex = { version = "0.4.3", default_features = false }
Expand Down
2 changes: 1 addition & 1 deletion libs/types/src/locations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use sp_runtime::{
traits::{BlakeTwo256, Hash},
AccountId32,
};
use xcm::{latest::MultiLocation, VersionedMultiLocation};
use xcm::{v3::MultiLocation, VersionedMultiLocation};

use crate::domain_address::DomainAddress;
/// Location types for destinations that can receive restricted transfers
Expand Down
16 changes: 15 additions & 1 deletion pallets/liquidity-pools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ pub type GeneralCurrencyIndexOf<T> =
pub mod pallet {
use cfg_traits::{
investments::{ForeignInvestment, TrancheCurrency},
CurrencyInspect, Permissions, PoolInspect, Seconds, TimeAsSecs, TrancheTokenPrice,
CurrencyInspect, Permissions, PoolInspect, PreConditions, Seconds, TimeAsSecs,
TrancheTokenPrice,
};
use cfg_types::{
permissions::{PermissionScope, PoolRole, Role},
Expand Down Expand Up @@ -278,6 +279,11 @@ pub mod pallet {
/// message.
type TreasuryAccount: Get<Self::AccountId>;

type PreTransferFilter: PreConditions<
(Self::AccountId, DomainAddress, Self::CurrencyId),
Result = DispatchResult,
>;

type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
}

Expand Down Expand Up @@ -565,6 +571,12 @@ pub mod pallet {
// Ensure pool and tranche exist and derive invest id
let invest_id = Self::derive_invest_id(pool_id, tranche_id)?;

T::PreTransferFilter::check((
who.clone(),
domain_address.clone(),
invest_id.clone().into(),
))?;

// Transfer to the domain account for bookkeeping
T::Tokens::transfer(
invest_id.into(),
Expand Down Expand Up @@ -627,6 +639,8 @@ pub mod pallet {
}
}

T::PreTransferFilter::check((who.clone(), receiver.clone(), currency_id))?;

// Transfer to the domain account for bookkeeping
T::Tokens::transfer(
currency_id,
Expand Down
56 changes: 56 additions & 0 deletions pallets/restricted-xtokens/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[package]
name = "pallet-restricted-xtokens"
authors.workspace = true
description = "A wrapper pallet around orml-xtokens to allow restricting transfers"
edition.workspace = true
license.workspace = true
repository.workspace = true
version = "0.0.1"

[dependencies]
codec = { package = "parity-scale-codec", workspace = true }
scale-info = { workspace = true }
serde = { workspace = true, optional = true }

# substrate
frame-support = { workspace = true }
frame-system = { workspace = true }
sp-std = { workspace = true }

# orml
orml-xtokens = { workspace = true }
orml-traits = { workspace = true }

# polkadot
xcm = { workspace = true }

# local
cfg-traits = { workspace = true }

[features]
default = ["std"]
std = [
"serde",
"codec/std",
"sp-std/std",
"cfg-traits/std",
"frame-support/std",
"frame-system/std",
"scale-info/std",
"orml-xtokens/std",
"orml-traits/std",
"xcm/std"
]

runtime-benchmarks = [
"cfg-traits/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"orml-xtokens/runtime-benchmarks",
]
try-runtime = [
"cfg-traits/try-runtime",
"frame-support/try-runtime",
"frame-system/try-runtime",
"orml-xtokens/try-runtime",
]
Loading

0 comments on commit c070fcf

Please sign in to comment.