Skip to content

Commit

Permalink
Apply substrate monthly 2022-11 changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Neopallium committed Nov 21, 2022
1 parent e3b189c commit 40b9d51
Show file tree
Hide file tree
Showing 98 changed files with 1,797 additions and 1,731 deletions.
13 changes: 5 additions & 8 deletions node-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use polymesh_primitives::{
AccountId, Balance, Block, BlockNumber, Hash, IdentityId, Index, Moment, Ticker,
};
use sc_client_api::AuxStore;
use sc_consensus_babe::{Config, Epoch};
use sc_consensus_babe::{BabeConfiguration, Epoch};
use sc_consensus_epochs::SharedEpochChanges;
use sc_finality_grandpa::{
FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState,
Expand All @@ -52,7 +52,7 @@ use std::sync::Arc;
/// Extra dependencies for BABE.
pub struct BabeDeps {
/// BABE protocol config.
pub babe_config: Config,
pub babe_config: BabeConfiguration,
/// BABE pending epoch changes.
pub shared_epoch_changes: SharedEpochChanges<Block, Epoch>,
/// The keystore that manages the keys of the node.
Expand Down Expand Up @@ -107,7 +107,6 @@ where
+ Send
+ 'static,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber, Hash>,
C::Api: node_rpc::transaction_payment::TransactionPaymentRuntimeApi<Block, UE>,
C::Api: pallet_staking_rpc::StakingRuntimeApi<Block>,
C::Api: node_rpc::pips::PipsRuntimeApi<Block, AccountId>,
Expand All @@ -131,13 +130,12 @@ where
pips::{Pips, PipsApi},
transaction_payment::{TransactionPayment, TransactionPaymentApi},
};
use pallet_contracts_rpc::{Contracts, ContractsApi};
use pallet_group_rpc::{Group, GroupApi};
use pallet_protocol_fee_rpc::{ProtocolFee, ProtocolFeeApi};
use pallet_staking_rpc::{Staking, StakingApi};
use sc_consensus_babe_rpc::BabeRpcHandler;
use sc_finality_grandpa_rpc::GrandpaRpcHandler;
use substrate_frame_rpc_system::{FullSystem, SystemApi};
use sc_consensus_babe_rpc::{Babe, BabeApiServer};
use sc_finality_grandpa_rpc::{Grandpa, GrandpaApiServer};
use substrate_frame_rpc_system::{System, SystemApiServer};

let mut io = jsonrpc_core::IoHandler::default();
let FullDeps {
Expand Down Expand Up @@ -171,7 +169,6 @@ where
// Making synchronous calls in light client freezes the browser currently,
// more context: https://github.com/PolymeshAssociation/substrate/pull/3480
// These RPCs should use an asynchronous caller instead.
io.extend_with(ContractsApi::to_delegate(Contracts::new(client.clone())));
io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(
client.clone(),
)));
Expand Down
2 changes: 1 addition & 1 deletion pallets/asset/src/checkpoint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ decl_storage! {
}

decl_module! {
pub struct Module<T: Config> for enum Call where origin: T::Origin {
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin {
type Error = Error<T>;

fn deposit_event() = default;
Expand Down
76 changes: 40 additions & 36 deletions pallets/asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ use core::result::Result as StdResult;
use currency::*;
use frame_support::{
decl_error, decl_module, decl_storage,
dispatch::{DispatchError, DispatchResult},
dispatch::{DispatchError, DispatchResult, Weight},
ensure, fail,
traits::Get,
};
Expand Down Expand Up @@ -358,7 +358,7 @@ type Identity<T> = identity::Module<T>;

// Public interface for this runtime module.
decl_module! {
pub struct Module<T: Config> for enum Call where origin: T::Origin {
pub struct Module<T: Config> for enum Call where origin: T::RuntimeOrigin {

type Error = Error<T>;

Expand All @@ -375,25 +375,25 @@ decl_module! {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
use frame_support::weights::constants::WEIGHT_PER_MICROS;
// Keep track of upgrade cost.
let mut weight = 0u64;
let mut weight = Weight::zero();
storage_migrate_on!(StorageVersion, 1, {
let mut total_len = 0u64;
let mut total_len = Weight::zero();
// Get list of assets with invalid asset_types.
let fix_list = Tokens::iter()
.filter(|(_, token)| {
total_len += 1;
total_len += Weight::from_ref_time(1);
// Check if the asset_type is invalid.
Self::ensure_asset_type_valid(token.asset_type).is_err()
}).map(|(ticker, _)| ticker).collect::<Vec<_>>();

// Calculate weight based on the number of assets
// and how many need to be fixed.
// Based on storage read/write cost: read 50 micros, write 200 micros.
let fix_len = fix_list.len() as u64;
let fix_len = Weight::from_ref_time(fix_list.len() as u64);
weight = weight
.saturating_add(total_len.saturating_mul(50 * WEIGHT_PER_MICROS))
.saturating_add(fix_len.saturating_mul(50 * WEIGHT_PER_MICROS))
.saturating_add(fix_len.saturating_mul(200 * WEIGHT_PER_MICROS));
.saturating_add(total_len.saturating_mul(50u64 * WEIGHT_PER_MICROS.ref_time()))
.saturating_add(fix_len.saturating_mul(50u64 * WEIGHT_PER_MICROS.ref_time()))
.saturating_add(fix_len.saturating_mul(200u64 * WEIGHT_PER_MICROS.ref_time()));

// Replace invalid asset_types with the default AssetType.
for ticker in fix_list {
Expand Down Expand Up @@ -987,7 +987,7 @@ decl_error! {
}
}

impl<T: Config> AssetFnTrait<T::AccountId, T::Origin> for Module<T> {
impl<T: Config> AssetFnTrait<T::AccountId, T::RuntimeOrigin> for Module<T> {
fn ensure_granular(ticker: &Ticker, value: Balance) -> DispatchResult {
Self::ensure_granular(ticker, value)
}
Expand All @@ -998,7 +998,7 @@ impl<T: Config> AssetFnTrait<T::AccountId, T::Origin> for Module<T> {
}

fn create_asset(
origin: T::Origin,
origin: T::RuntimeOrigin,
name: AssetName,
ticker: Ticker,
divisible: bool,
Expand All @@ -1019,7 +1019,7 @@ impl<T: Config> AssetFnTrait<T::AccountId, T::Origin> for Module<T> {
)
}

fn register_ticker(origin: T::Origin, ticker: Ticker) -> DispatchResult {
fn register_ticker(origin: T::RuntimeOrigin, ticker: Ticker) -> DispatchResult {
Self::base_register_ticker(origin, ticker)
}

Expand All @@ -1044,7 +1044,7 @@ impl<T: Config> AssetFnTrait<T::AccountId, T::Origin> for Module<T> {
ScopeIdOf::insert(ticker, did, did);
}

fn issue(origin: T::Origin, ticker: Ticker, total_supply: Balance) -> DispatchResult {
fn issue(origin: T::RuntimeOrigin, ticker: Ticker, total_supply: Balance) -> DispatchResult {
Self::issue(origin, ticker, total_supply)
}
}
Expand Down Expand Up @@ -1129,7 +1129,7 @@ impl<T: Config> Module<T> {
Ok(())
}

pub fn base_register_ticker(origin: T::Origin, ticker: Ticker) -> DispatchResult {
pub fn base_register_ticker(origin: T::RuntimeOrigin, ticker: Ticker) -> DispatchResult {
let to_did = Identity::<T>::ensure_perms(origin)?;
let expiry = Self::ticker_registration_checks(&ticker, to_did, false, || {
Self::ticker_registration_config()
Expand All @@ -1150,7 +1150,7 @@ impl<T: Config> Module<T> {
}

fn ensure_agent_with_custody_and_perms(
origin: T::Origin,
origin: T::RuntimeOrigin,
ticker: Ticker,
portfolio_kind: PortfolioKind,
) -> Result<PortfolioId, DispatchError> {
Expand Down Expand Up @@ -1581,7 +1581,7 @@ impl<T: Config> Module<T> {
}

/// Accepts and executes the ticker transfer.
fn base_accept_ticker_transfer(origin: T::Origin, auth_id: u64) -> DispatchResult {
fn base_accept_ticker_transfer(origin: T::RuntimeOrigin, auth_id: u64) -> DispatchResult {
let to = Identity::<T>::ensure_perms(origin)?;
<Identity<T>>::accept_auth_with(&to.into(), auth_id, |data, auth_by| {
let ticker = extract_auth!(data, TransferTicker(t));
Expand All @@ -1606,7 +1606,7 @@ impl<T: Config> Module<T> {
}

/// Accept and process a token ownership transfer.
fn base_accept_token_ownership_transfer(origin: T::Origin, id: u64) -> DispatchResult {
fn base_accept_token_ownership_transfer(origin: T::RuntimeOrigin, id: u64) -> DispatchResult {
let to = Identity::<T>::ensure_perms(origin)?;
<Identity<T>>::accept_auth_with(&to.into(), id, |data, auth_by| {
let ticker = extract_auth!(data, TransferAssetOwnership(t));
Expand Down Expand Up @@ -1723,7 +1723,7 @@ impl<T: Config> Module<T> {
}

fn base_create_asset(
origin: T::Origin,
origin: T::RuntimeOrigin,
name: AssetName,
ticker: Ticker,
divisible: bool,
Expand Down Expand Up @@ -1867,7 +1867,7 @@ impl<T: Config> Module<T> {
Ok(did)
}

fn set_freeze(origin: T::Origin, ticker: Ticker, freeze: bool) -> DispatchResult {
fn set_freeze(origin: T::RuntimeOrigin, ticker: Ticker, freeze: bool) -> DispatchResult {
let did = <ExternalAgents<T>>::ensure_perms(origin, ticker)?;
Self::ensure_asset_exists(&ticker)?;

Expand All @@ -1886,7 +1886,11 @@ impl<T: Config> Module<T> {
Ok(())
}

fn base_rename_asset(origin: T::Origin, ticker: Ticker, name: AssetName) -> DispatchResult {
fn base_rename_asset(
origin: T::RuntimeOrigin,
ticker: Ticker,
name: AssetName,
) -> DispatchResult {
Self::ensure_asset_name_bounded(&name)?;
Self::ensure_asset_exists(&ticker)?;
let did = <ExternalAgents<T>>::ensure_perms(origin, ticker)?;
Expand All @@ -1906,7 +1910,7 @@ impl<T: Config> Module<T> {
}

fn base_redeem(
origin: T::Origin,
origin: T::RuntimeOrigin,
ticker: Ticker,
value: Balance,
portfolio_kind: PortfolioKind,
Expand Down Expand Up @@ -1975,7 +1979,7 @@ impl<T: Config> Module<T> {
Ok(())
}

fn base_make_divisible(origin: T::Origin, ticker: Ticker) -> DispatchResult {
fn base_make_divisible(origin: T::RuntimeOrigin, ticker: Ticker) -> DispatchResult {
let did = <ExternalAgents<T>>::ensure_perms(origin, ticker)?;

Tokens::try_mutate(&ticker, |token| -> DispatchResult {
Expand All @@ -1988,7 +1992,7 @@ impl<T: Config> Module<T> {
}

fn base_add_documents(
origin: T::Origin,
origin: T::RuntimeOrigin,
docs: Vec<Document>,
ticker: Ticker,
) -> DispatchResult {
Expand Down Expand Up @@ -2020,7 +2024,7 @@ impl<T: Config> Module<T> {
}

fn base_remove_documents(
origin: T::Origin,
origin: T::RuntimeOrigin,
ids: Vec<DocumentId>,
ticker: Ticker,
) -> DispatchResult {
Expand All @@ -2033,7 +2037,7 @@ impl<T: Config> Module<T> {
}

fn base_set_funding_round(
origin: T::Origin,
origin: T::RuntimeOrigin,
ticker: Ticker,
name: FundingRoundName,
) -> DispatchResult {
Expand All @@ -2055,7 +2059,7 @@ impl<T: Config> Module<T> {
}

fn base_update_identifiers(
origin: T::Origin,
origin: T::RuntimeOrigin,
ticker: Ticker,
identifiers: Vec<AssetIdentifier>,
) -> DispatchResult {
Expand Down Expand Up @@ -2110,7 +2114,7 @@ impl<T: Config> Module<T> {
}

fn base_set_asset_metadata(
origin: T::Origin,
origin: T::RuntimeOrigin,
ticker: Ticker,
key: AssetMetadataKey,
value: AssetMetadataValue,
Expand Down Expand Up @@ -2157,7 +2161,7 @@ impl<T: Config> Module<T> {
}

fn base_set_asset_metadata_details(
origin: T::Origin,
origin: T::RuntimeOrigin,
ticker: Ticker,
key: AssetMetadataKey,
detail: AssetMetadataValueDetail<T::Moment>,
Expand Down Expand Up @@ -2185,7 +2189,7 @@ impl<T: Config> Module<T> {
}

fn base_register_and_set_local_asset_metadata(
origin: T::Origin,
origin: T::RuntimeOrigin,
ticker: Ticker,
name: AssetMetadataName,
spec: AssetMetadataSpec,
Expand All @@ -2202,7 +2206,7 @@ impl<T: Config> Module<T> {
}

fn base_register_asset_metadata_local_type(
origin: T::Origin,
origin: T::RuntimeOrigin,
ticker: Ticker,
name: AssetMetadataName,
spec: AssetMetadataSpec,
Expand Down Expand Up @@ -2245,7 +2249,7 @@ impl<T: Config> Module<T> {
}

fn base_register_asset_metadata_global_type(
origin: T::Origin,
origin: T::RuntimeOrigin,
name: AssetMetadataName,
spec: AssetMetadataSpec,
) -> DispatchResult {
Expand Down Expand Up @@ -2276,7 +2280,7 @@ impl<T: Config> Module<T> {
}

fn base_claim_classic_ticker(
origin: T::Origin,
origin: T::RuntimeOrigin,
ticker: Ticker,
ethereum_signature: ethereum::EcdsaSignature,
) -> DispatchResult {
Expand Down Expand Up @@ -2321,7 +2325,7 @@ impl<T: Config> Module<T> {
}

fn base_reserve_classic_ticker(
origin: T::Origin,
origin: T::RuntimeOrigin,
classic_ticker_import: ClassicTickerImport,
contract_did: IdentityId,
config: TickerRegistrationConfig<T::Moment>,
Expand Down Expand Up @@ -2351,7 +2355,7 @@ impl<T: Config> Module<T> {
}

fn base_controller_transfer(
origin: T::Origin,
origin: T::RuntimeOrigin,
ticker: Ticker,
value: Balance,
from_portfolio: PortfolioId,
Expand Down Expand Up @@ -2536,7 +2540,7 @@ impl<T: Config> Module<T> {
}

fn base_register_custom_asset_type(
origin: T::Origin,
origin: T::RuntimeOrigin,
ty: Vec<u8>,
) -> Result<CustomAssetTypeId, DispatchError> {
let did = Identity::<T>::ensure_perms(origin)?;
Expand Down Expand Up @@ -2565,7 +2569,7 @@ impl<T: Config> Module<T> {
}

fn base_update_asset_type(
origin: T::Origin,
origin: T::RuntimeOrigin,
ticker: Ticker,
asset_type: AssetType,
) -> DispatchResult {
Expand Down
Loading

0 comments on commit 40b9d51

Please sign in to comment.