-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Proper initialization of the bridge pot account balances in g…
…enesis (#698)" (#728) * Revert "Proper initialization of the bridge pot account balances in genesis (#698)" This reverts commit 311a930. * Fix features-snapshot
- Loading branch information
1 parent
f302192
commit 265483a
Showing
16 changed files
with
128 additions
and
441 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "bridge-pot-currency-swap" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies] | ||
primitives-currency-swap = { version = "0.1", path = "../primitives-currency-swap", default-features = false } | ||
|
||
frame-support = { default-features = false, git = "https://github.com/humanode-network/substrate", branch = "locked/polkadot-v0.9.38" } | ||
|
||
[features] | ||
default = ["std"] | ||
std = ["frame-support/std", "primitives-currency-swap/std"] | ||
try-runtime = ["frame-support/try-runtime", "primitives-currency-swap/try-runtime"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//! Bridge pot currency swap implementation. | ||
// Either generate code at stadard mode, or `no_std`, based on the `std` feature presence. | ||
#![cfg_attr(not(feature = "std"), no_std)] | ||
|
||
use frame_support::{ | ||
sp_runtime::traits::Convert, | ||
sp_std::marker::PhantomData, | ||
traits::{fungible::Inspect, Currency, Get}, | ||
}; | ||
|
||
pub mod existence_optional; | ||
pub mod existence_required; | ||
|
||
pub use existence_optional::Marker as ExistenceOptional; | ||
pub use existence_required::Marker as ExistenceRequired; | ||
|
||
/// The config for the generic bridge pot currency swap logic. | ||
pub trait Config { | ||
/// The type representing the account key for the currency to swap from. | ||
type AccountIdFrom; | ||
|
||
/// The type representing the account key for the currency to swap to. | ||
type AccountIdTo; | ||
|
||
/// The currency to swap from. | ||
type CurrencyFrom: Currency<Self::AccountIdFrom> | ||
+ Inspect< | ||
Self::AccountIdFrom, | ||
Balance = <Self::CurrencyFrom as Currency<Self::AccountIdFrom>>::Balance, | ||
>; | ||
|
||
/// The currency to swap to. | ||
type CurrencyTo: Currency<Self::AccountIdTo> | ||
+ Inspect< | ||
Self::AccountIdTo, | ||
Balance = <Self::CurrencyTo as Currency<Self::AccountIdTo>>::Balance, | ||
>; | ||
|
||
/// The converter to determine how the balance amount should be converted from one currency to | ||
/// another. | ||
type BalanceConverter: Convert< | ||
<Self::CurrencyFrom as Currency<Self::AccountIdFrom>>::Balance, | ||
<Self::CurrencyTo as Currency<Self::AccountIdTo>>::Balance, | ||
>; | ||
|
||
/// The account to land the balances to when receiving the funds as part of the swap operation. | ||
type PotFrom: Get<Self::AccountIdFrom>; | ||
|
||
/// The account to take the balances from when sending the funds as part of the swap operation. | ||
type PotTo: Get<Self::AccountIdTo>; | ||
} | ||
|
||
/// A [`primitives_currency_swap::CurrencySwap`] implementation that does the swap using two | ||
/// "pot" accounts for each of end swapped currencies. | ||
pub struct CurrencySwap<T: Config, ExistenceRequirement>(PhantomData<(T, ExistenceRequirement)>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.