feat: pallet asset-rate (#13608)

* poc

* fix: remove AssetIdParameter

* tests: add

* docs: add pallet description

* feat: add benches

* refactor: UnknownAssetId

* fix: normalize mock cfg

* fix: benchmarks

* chore: add weights

* refactor: remove storage getter

* chore: apply suggestions from code review

* docs: add native balance to calls

* chore: apply suggestions from code review

* chore: apply ConversionFromAssetBalance

* tests: update balance mock

* chore: apply suggestions from code review

* ci: set publish to false

* docs: fix missing rustdoc

---------

Co-authored-by: parity-processbot <>
This commit is contained in:
William Freudenberger
2023-04-19 09:49:42 +02:00
committed by GitHub
parent cbc8e5f7df
commit 9eb63f216c
10 changed files with 762 additions and 0 deletions
+4
View File
@@ -53,6 +53,7 @@ frame-election-provider-support = { version = "4.0.0-dev", default-features = fa
frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, path = "../../../frame/system/rpc/runtime-api/" }
frame-try-runtime = { version = "0.10.0-dev", default-features = false, path = "../../../frame/try-runtime", optional = true }
pallet-alliance = { version = "4.0.0-dev", default-features = false, path = "../../../frame/alliance" }
pallet-asset-rate = { version = "4.0.0-dev", default-features = false, path = "../../../frame/asset-rate" }
pallet-assets = { version = "4.0.0-dev", default-features = false, path = "../../../frame/assets" }
pallet-authority-discovery = { version = "4.0.0-dev", default-features = false, path = "../../../frame/authority-discovery" }
pallet-authorship = { version = "4.0.0-dev", default-features = false, path = "../../../frame/authorship" }
@@ -201,6 +202,7 @@ std = [
"pallet-transaction-payment/std",
"pallet-transaction-storage/std",
"pallet-treasury/std",
"pallet-asset-rate/std",
"sp-transaction-pool/std",
"pallet-utility/std",
"sp-version/std",
@@ -272,6 +274,7 @@ runtime-benchmarks = [
"pallet-tips/runtime-benchmarks",
"pallet-transaction-storage/runtime-benchmarks",
"pallet-treasury/runtime-benchmarks",
"pallet-asset-rate/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-uniques/runtime-benchmarks",
"pallet-nfts/runtime-benchmarks",
@@ -333,6 +336,7 @@ try-runtime = [
"pallet-timestamp/try-runtime",
"pallet-tips/try-runtime",
"pallet-treasury/try-runtime",
"pallet-asset-rate/try-runtime",
"pallet-utility/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-asset-tx-payment/try-runtime",
+13
View File
@@ -1131,6 +1131,17 @@ impl pallet_treasury::Config for Runtime {
type SpendOrigin = EnsureWithSuccess<EnsureRoot<AccountId>, AccountId, MaxBalance>;
}
impl pallet_asset_rate::Config for Runtime {
type CreateOrigin = EnsureRoot<AccountId>;
type RemoveOrigin = EnsureRoot<AccountId>;
type UpdateOrigin = EnsureRoot<AccountId>;
type Balance = Balance;
type Currency = Balances;
type AssetId = u32;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = pallet_asset_rate::weights::SubstrateWeight<Runtime>;
}
parameter_types! {
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
pub const BountyValueMinimum: Balance = 5 * DOLLARS;
@@ -1765,6 +1776,7 @@ construct_runtime!(
TechnicalMembership: pallet_membership::<Instance1>,
Grandpa: pallet_grandpa,
Treasury: pallet_treasury,
AssetRate: pallet_asset_rate,
Contracts: pallet_contracts,
Sudo: pallet_sudo,
ImOnline: pallet_im_online,
@@ -1922,6 +1934,7 @@ mod benches {
[pallet_tips, Tips]
[pallet_transaction_storage, TransactionStorage]
[pallet_treasury, Treasury]
[pallet_asset_rate, AssetRate]
[pallet_uniques, Uniques]
[pallet_nfts, Nfts]
[pallet_utility, Utility]