mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 05:11:02 +00:00
be5dc02d3b
* change (ci): docs job optimized; runs every commit; fails on warnings * change (ci): rename jobs; temporary allow failing * change (ci): better warnings filtering * fix (ci): hotfix Docker release * test (ci): run docs job with flags * test (ci): pwd fails * change (ci): pass just //doc dir as an artifact; debug * change (ci): return to the previous structure; undebug * change (ci): typo * rebase on upstream 2 * fix the jobname * Fix some warnings (#7079) * Partial fix for transaction priority (#7034) * Partial fix for priority stuff. * Small fix * Fix tests. * Update frame/transaction-payment/src/lib.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Better doc Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * What happens if we remove wat? (#7056) * What happens if we remove wat? * Update Cargo.lock * Make SlashingSpans Public (#6961) * Make SlashingSpans Public Offchain Applications will often need to inspect this type because it is directly used in staking election, thus worthy of being `pub`. Rest of the slashing api can remain private, only this and the `fn last_non_zero_slash()` of `SlashingSpans` are of interest. * Update frame/staking/src/lib.rs * client/authority-discovery/src/service: Improve docs (#7059) * Decrease poll interval (#7063) * Remove unused code (#7027) Signed-off-by: Jimmy Chu <jimmychu0807@gmail.com> * Disambiguate `BlockNumber` type in `decl_module` (#7061) * Disambiguate `BlockNumber` type in `decl_module` * fix `frame-support-tests` * fix ui tests * fix trait order * Implement `FromStr` for `Ss58AddressFormat` (#7068) * Implement `FromStr` for `Ss58AddressFormat` * Update primitives/core/src/crypto.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Set reserved nodes with offchain worker. (#6996) * add offchain worker api to set reserved nodes. * new offchain api to get node public key. * node public key from converter * refactor set reserved nodes ocw api. * new ndoe authorization pallet * remove unnecessary clone and more. * more * tests for node authorization pallet * remove dependency * fix build * more tests. * refactor * Update primitives/core/src/offchain/testing.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update frame/node-authorization/src/lib.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update frame/node-authorization/src/lib.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update frame/node-authorization/src/lib.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * format code * expose NetworkService * remove NetworkStateInfo in offchain * replace NodePublicKey with PeerId. * set max length of peer id. * clear more * use BTreeSet for set of peers. * decode opaque peer id. * extract NetworkProvider for client offchain. * use OpaquePeerId in node authorization pallet. * fix test * better documentation * fix test * doc * more fix * Update primitives/core/src/offchain/mod.rs Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com> * Update client/offchain/src/api.rs Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com> * derive serialize and deserialize Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com> * Fix some warnings Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> Co-authored-by: Sergei Shulepov <sergei@parity.io> Co-authored-by: Max Inden <mail@max-inden.de> Co-authored-by: s3krit <pugh@s3kr.it> Co-authored-by: Jimmy Chu <jimmy@parity.io> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: kaichao <kaichaosuna@gmail.com> Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com> * Fix more doc errors * More doc fixes * Remove subdb to make `rustdoc` happy * Make the line length check happy * Fix compilation error * Another try * Allow unused Co-authored-by: Dan Forbes <dan@danforbes.dev> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> Co-authored-by: Sergei Shulepov <sergei@parity.io> Co-authored-by: Max Inden <mail@max-inden.de> Co-authored-by: s3krit <pugh@s3kr.it> Co-authored-by: Jimmy Chu <jimmy@parity.io> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: kaichao <kaichaosuna@gmail.com> Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com> Co-authored-by: Bastian Köcher <git@kchr.de>
Generic Asset Module
The Generic Asset module provides functionality for handling accounts and asset balances.
Overview
The Generic Asset module provides functions for:
- Creating a new kind of asset.
- Setting permissions of an asset.
- Getting and setting free balances.
- Retrieving total, reserved and unreserved balances.
- Repatriating a reserved balance to a beneficiary account.
- Transferring a balance between accounts (when not reserved).
- Slashing an account balance.
- Managing total issuance.
- Setting and managing locks.
Terminology
- Staking Asset: The asset for staking, to participate as Validators in the network.
- Spending Asset: The asset for payment, such as paying transfer fees, gas fees, etc.
- Permissions: A set of rules for a kind of asset, defining the allowed operations to the asset, and which accounts are allowed to possess it.
- Total Issuance: The total number of units in existence in a system.
- Free Balance: The portion of a balance that is not reserved. The free balance is the only balance that matters for most operations. When this balance falls below the existential deposit, most functionality of the account is removed. When both it and the reserved balance are deleted, then the account is said to be dead.
- Reserved Balance: Reserved balance still belongs to the account holder, but is suspended. Reserved balance can still be slashed, but only after all the free balance has been slashed. If the reserved balance falls below the existential deposit then it and any related functionality will be deleted. When both it and the free balance are deleted, then the account is said to be dead.
- Imbalance: A condition when some assets were credited or debited without equal and opposite accounting
(i.e. a difference between total issuance and account balances). Functions that result in an imbalance will
return an object of the
Imbalancetrait that can be managed within your runtime logic. (If an imbalance is simply dropped, it should automatically maintain any book-keeping such as total issuance.) - Lock: A freeze on a specified amount of an account's free balance until a specified block number. Multiple locks always operate over the same funds, so they "overlay" rather than "stack".
Implementations
The Generic Asset module provides AssetCurrency, which implements the following traits. If these traits provide
the functionality that you need, you can avoid coupling with the Generic Asset module.
Currency: Functions for dealing with a fungible assets system.ReservableCurrency: Functions for dealing with assets that can be reserved from an account.LockableCurrency: Functions for dealing with accounts that allow liquidity restrictions.Imbalance: Functions for handling imbalances between total issuance in the system and account balances. Must be used when a function creates new assets (e.g. a reward) or destroys some assets (e.g. a system fee).
The Generic Asset module provides two types of AssetCurrency as follows.
StakingAssetCurrency: Currency for staking.SpendingAssetCurrency: Currency for payments such as transfer fee, gas fee.
Interface
Dispatchable Functions
create: Create a new kind of asset.transfer: Transfer some liquid free balance to another account.update_permission: Updates permission for a givenasset_idand an account. The origin of this call must have update permissions.mint: Mint an asset, increases its total issuance. The origin of this call must have mint permissions.burn: Burn an asset, decreases its total issuance. The origin of this call must have burn permissions.create_reserved: Create a new kind of reserved asset. The origin of this call must be root.
Public Functions
total_balance: Get an account's total balance of an asset kind.free_balance: Get an account's free balance of an asset kind.reserved_balance: Get an account's reserved balance of an asset kind.create_asset: Creates an asset.make_transfer: Transfer some liquid free balance from one account to another. This will not emit theTransferredevent.make_transfer_with_event: Transfer some liquid free balance from one account to another. This will emit theTransferredevent.reserve: Moves an amount from free balance to reserved balance.unreserve: Move up to an amount from reserved balance to free balance. This function cannot fail.mint_free: Mint to an account's free balance.burn_free: Burn an account's free balance.slash: Deduct up to an amount from the combined balance ofwho, preferring to deduct from the free balance. This function cannot fail.slash_reserved: Deduct up to an amount from reserved balance of an account. This function cannot fail.repatriate_reserved: Move up to an amount from reserved balance of an account to free balance of another account.check_permission: Check permission to perform burn, mint or update.ensure_can_withdraw: Check if the account is able to make a withdrawal of the given amount for the given reason.
Usage
The following examples show how to use the Generic Asset Pallet in your custom pallet.
Examples from the FRAME pallet
The Fees Pallet uses the Currency trait to handle fee charge/refund, and its types inherit from Currency:
use frame_support::{
dispatch,
traits::{Currency, ExistenceRequirement, WithdrawReason},
};
type AssetOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
fn charge_fee<T: Trait>(transactor: &T::AccountId, amount: AssetOf<T>) -> dispatch::DispatchResult {
// ...
T::Currency::withdraw(
transactor,
amount,
WithdrawReason::TransactionPayment.into(),
ExistenceRequirement::KeepAlive,
)?;
// ...
Ok(())
}
fn refund_fee<T: Trait>(transactor: &T::AccountId, amount: AssetOf<T>) -> dispatch::DispatchResult {
// ...
T::Currency::deposit_into_existing(transactor, amount)?;
// ...
Ok(())
}
Genesis config
The Generic Asset Pallet depends on the GenesisConfig.
License: Apache-2.0