-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bump substrate and api-client (#225)
* bump substrate fe5bf49290d166b9552f65e751d46ec592173ebd * bump rust-toolchain: nightly-2022-05-31 * unpatch encointer pallets * WIP merge updates * runtime compiles * node compiles * [client] use master branch of api-client * add scale-codec to api-client-extension * [client] define community currency `AssetTip` * [client] compiles * updated api-client for hotfix; bootstrapping script works * remove patches * remove ac_primitives dependency * fmt * fix asset type * Rename `AssetTip` to `CommunityCurrencyTip` * change api-client branch to master
- Loading branch information
Showing
18 changed files
with
1,718 additions
and
1,043 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
51 changes: 51 additions & 0 deletions
51
client/encointer-api-client-extension/src/extrinsic_params.rs
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,51 @@ | ||
use codec::{Decode, Encode}; | ||
use encointer_primitives::communities::CommunityIdentifier; | ||
use substrate_api_client::{ | ||
BaseExtrinsicParams, BaseExtrinsicParamsBuilder, SubstrateDefaultSignedExtra, | ||
UncheckedExtrinsicV4, | ||
}; | ||
|
||
/// A struct representing the signed extra and additional parameters required | ||
/// to construct a transaction and pay in asset fees | ||
pub type CommunityCurrencyTipExtrinsicParams = BaseExtrinsicParams<CommunityCurrencyTip>; | ||
/// A builder which leads to [`CommunityCurrencyTipExtrinsicParams`] being constructed. | ||
/// This is what you provide to methods like `sign_and_submit()`. | ||
pub type CommunityCurrencyTipExtrinsicParamsBuilder = | ||
BaseExtrinsicParamsBuilder<CommunityCurrencyTip>; | ||
|
||
pub type EncointerXt<Call> = | ||
UncheckedExtrinsicV4<Call, SubstrateDefaultSignedExtra<CommunityCurrencyTip>>; | ||
|
||
/// A tip payment made in the form of a specific asset. | ||
#[derive(Copy, Clone, Debug, Default, Decode, Encode, Eq, PartialEq)] | ||
pub struct CommunityCurrencyTip { | ||
#[codec(compact)] | ||
tip: u128, | ||
asset: Option<CommunityIdentifier>, | ||
} | ||
|
||
impl CommunityCurrencyTip { | ||
/// Create a new tip of the amount provided. | ||
pub fn new(amount: u128) -> Self { | ||
CommunityCurrencyTip { tip: amount, asset: None } | ||
} | ||
|
||
/// Designate the tip as being of a particular asset class. | ||
/// If this is not set, then the native currency is used. | ||
pub fn of_community(mut self, asset: CommunityIdentifier) -> Self { | ||
self.asset = Some(asset); | ||
self | ||
} | ||
} | ||
|
||
impl From<u128> for CommunityCurrencyTip { | ||
fn from(n: u128) -> Self { | ||
CommunityCurrencyTip::new(n) | ||
} | ||
} | ||
|
||
impl From<CommunityCurrencyTip> for u128 { | ||
fn from(tip: CommunityCurrencyTip) -> Self { | ||
tip.tip | ||
} | ||
} |
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.