mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 07:01:03 +00:00
1dd000a011
* ci: add quick-check with clippy and rustfmt * chore: rustfmt round * chore: set the same rustfmt config than substrate * chore: fix formatting * cI: remove clippy * ci: switch to nightly for the checks * ci: fix toolchains and naming * ci: Limit the check to formatting * chore: fix formatting * Update .rustfmt.toml * Update .rustfmt.toml Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
73 lines
2.7 KiB
Rust
73 lines
2.7 KiB
Rust
// Copyright (C) 2021 Parity Technologies (UK) Ltd.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
pub mod currency {
|
|
use node_primitives::Balance;
|
|
|
|
/// The existential deposit. Set to 1/10 of its parent Relay Chain (v9020).
|
|
pub const EXISTENTIAL_DEPOSIT: Balance = CENTS / 10;
|
|
|
|
pub const UNITS: Balance = 1_000_000_000_000;
|
|
pub const CENTS: Balance = UNITS / 30_000;
|
|
pub const GRAND: Balance = CENTS * 100_000;
|
|
pub const MILLICENTS: Balance = CENTS / 1_000;
|
|
|
|
pub const fn deposit(items: u32, bytes: u32) -> Balance {
|
|
// map to 1/10 of what the kusama relay chain charges (v9020)
|
|
(items as Balance * 2_000 * CENTS + (bytes as Balance) * 100 * MILLICENTS) / 10
|
|
}
|
|
}
|
|
|
|
/// Fee-related.
|
|
pub mod fee {
|
|
use frame_support::weights::{
|
|
constants::ExtrinsicBaseWeight, WeightToFeeCoefficient, WeightToFeeCoefficients,
|
|
WeightToFeePolynomial,
|
|
};
|
|
use node_primitives::Balance;
|
|
use smallvec::smallvec;
|
|
pub use sp_runtime::Perbill;
|
|
|
|
/// The block saturation level. Fees will be updates based on this value.
|
|
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
|
|
|
|
/// Handles converting a weight scalar to a fee value, based on the scale and granularity of the
|
|
/// node's balance type.
|
|
///
|
|
/// This should typically create a mapping between the following ranges:
|
|
/// - [0, MAXIMUM_BLOCK_WEIGHT]
|
|
/// - [Balance::min, Balance::max]
|
|
///
|
|
/// Yet, it can be used for any other sort of change to weight-fee. Some examples being:
|
|
/// - Setting it to `0` will essentially disable the weight fee.
|
|
/// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged.
|
|
pub struct WeightToFee;
|
|
impl WeightToFeePolynomial for WeightToFee {
|
|
type Balance = Balance;
|
|
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
|
|
// in Kusama, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT:
|
|
// in Statemine, we map to 1/10 of that, or 1/100 CENT
|
|
let p = super::currency::CENTS;
|
|
let q = 100 * Balance::from(ExtrinsicBaseWeight::get());
|
|
smallvec![WeightToFeeCoefficient {
|
|
degree: 1,
|
|
negative: false,
|
|
coeff_frac: Perbill::from_rational(p % q, q),
|
|
coeff_integer: p / q,
|
|
}]
|
|
}
|
|
}
|
|
}
|