Skip to content

Commit

Permalink
chore: upgrade to polkadot 0.9.40
Browse files Browse the repository at this point in the history
  • Loading branch information
sander2 committed May 22, 2023
1 parent d3676d7 commit 7ef91bd
Show file tree
Hide file tree
Showing 51 changed files with 1,443 additions and 1,376 deletions.
1,912 changes: 989 additions & 923 deletions Cargo.lock

Large diffs are not rendered by default.

446 changes: 224 additions & 222 deletions Cargo.toml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions crates/btc-relay/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ where
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<Result<(), DispatchError>> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.verify_block_header_inclusion(&at, block_hash)
api.verify_block_header_inclusion(at, block_hash)
.map_err(|e| internal_err(format!("execution error: Unable to dry run extrinsic {:?}", e)))
}
}
1 change: 0 additions & 1 deletion crates/btc-relay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ pub mod pallet {
use frame_system::pallet_prelude::*;

#[pallet::pallet]
#[pallet::generate_store(trait Store)]
pub struct Pallet<T>(_);

#[pallet::config]
Expand Down
1 change: 0 additions & 1 deletion crates/clients-info/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ pub mod pallet {
use frame_system::pallet_prelude::*;

#[pallet::pallet]
#[pallet::generate_store(trait Store)]
pub struct Pallet<T>(_);

#[pallet::config]
Expand Down
1 change: 0 additions & 1 deletion crates/collator-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ pub mod pallet {
}

#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
pub struct Pallet<T>(_);

/// The invulnerable, fixed collators.
Expand Down
5 changes: 2 additions & 3 deletions crates/democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ pub mod pallet {
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);

#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);

Expand Down Expand Up @@ -365,7 +364,7 @@ pub mod pallet {
fn on_initialize(n: T::BlockNumber) -> Weight {
Self::begin_block(n).unwrap_or_else(|e| {
sp_runtime::print(e);
Weight::from_ref_time(0 as u64)
Weight::from_parts(0 as u64, 0u64)
})
}
}
Expand Down Expand Up @@ -931,7 +930,7 @@ impl<T: Config> Pallet<T> {
/// # </weight>
fn begin_block(now: T::BlockNumber) -> Result<Weight, DispatchError> {
let max_block_weight = T::BlockWeights::get().max_block;
let mut weight = Weight::from_ref_time(0 as u64);
let mut weight = Weight::from_parts(0 as u64, 0u64);

let next = Self::lowest_unbaked();
let last = Self::referendum_count();
Expand Down
20 changes: 10 additions & 10 deletions crates/dex-general/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ where
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<NumberOrHex> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_amount_in_price(&at, supply, path)
api.get_amount_in_price(at, supply, path)
.map(|price| price.into())
.map_err(runtime_error_into_rpc_err)
}
Expand All @@ -117,9 +117,9 @@ where
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<NumberOrHex> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_amount_out_price(&at, supply, path)
api.get_amount_out_price(at, supply, path)
.map(|price| price.into())
.map_err(runtime_error_into_rpc_err)
}
Expand All @@ -135,10 +135,10 @@ where
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<NumberOrHex> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_estimate_lptoken(
&at,
at,
asset_0,
asset_1,
amount_0_desired,
Expand All @@ -157,9 +157,9 @@ where
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<Option<PairInfo<AccountId, NumberOrHex, AssetId>>> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_pair_by_asset_id(&at, asset_0, asset_1)
api.get_pair_by_asset_id(at, asset_0, asset_1)
.map(|pairs| {
pairs.map(|pair| PairInfo {
asset_0: pair.asset_0,
Expand All @@ -184,9 +184,9 @@ where
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<Option<(AssetBalance, AssetBalance)>> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.calculate_remove_liquidity(&at, asset_0, asset_1, amount)
api.calculate_remove_liquidity(at, asset_0, asset_1, amount)
.map_err(runtime_error_into_rpc_err)
}
}
Expand Down
1 change: 0 additions & 1 deletion crates/dex-general/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ pub mod pallet {
}

#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
pub struct Pallet<T>(_);

#[pallet::storage]
Expand Down
66 changes: 32 additions & 34 deletions crates/dex-stable/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,55 +128,53 @@ where
{
fn get_virtual_price(&self, pool_id: PoolId, at: Option<<Block as BlockT>::Hash>) -> RpcResult<NumberOrHex> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

let price = api
.get_virtual_price(&at, pool_id)
.map_err(runtime_error_into_rpc_err)?;
let price = api.get_virtual_price(at, pool_id).map_err(runtime_error_into_rpc_err)?;

try_into_rpc_balance(price)
}

fn get_a(&self, pool_id: PoolId, at: Option<<Block as BlockT>::Hash>) -> RpcResult<NumberOrHex> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

let price = api.get_a(&at, pool_id).map_err(runtime_error_into_rpc_err)?;
let price = api.get_a(at, pool_id).map_err(runtime_error_into_rpc_err)?;

try_into_rpc_balance(price)
}

fn get_a_precise(&self, pool_id: PoolId, at: Option<<Block as BlockT>::Hash>) -> RpcResult<NumberOrHex> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

let price = api.get_a_precise(&at, pool_id).map_err(runtime_error_into_rpc_err)?;
let price = api.get_a_precise(at, pool_id).map_err(runtime_error_into_rpc_err)?;

try_into_rpc_balance(price)
}

fn get_currencies(&self, pool_id: PoolId, at: Option<<Block as BlockT>::Hash>) -> RpcResult<Vec<CurrencyId>> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_currencies(&at, pool_id).map_err(runtime_error_into_rpc_err)
api.get_currencies(at, pool_id).map_err(runtime_error_into_rpc_err)
}

fn get_currency(&self, pool_id: PoolId, index: u32, at: Option<<Block as BlockT>::Hash>) -> RpcResult<CurrencyId> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_currency(&at, pool_id, index).map_or_else(
api.get_currency(at, pool_id, index).map_or_else(
|e| Err(runtime_error_into_rpc_err(e)),
|v| v.ok_or(runtime_error_into_rpc_err("not found")),
)
}

fn get_lp_currency(&self, pool_id: PoolId, at: Option<<Block as BlockT>::Hash>) -> RpcResult<CurrencyId> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_lp_currency(&at, pool_id).map_or_else(
api.get_lp_currency(at, pool_id).map_or_else(
|e| Err(runtime_error_into_rpc_err(e)),
|v| v.ok_or(runtime_error_into_rpc_err("not found")),
)
Expand All @@ -189,9 +187,9 @@ where
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<u32> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

let currencies = api.get_currencies(&at, pool_id).map_err(runtime_error_into_rpc_err)?;
let currencies = api.get_currencies(at, pool_id).map_err(runtime_error_into_rpc_err)?;

for (i, c) in currencies.iter().enumerate() {
if *c == currency {
Expand All @@ -207,9 +205,9 @@ where
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<Vec<NumberOrHex>> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_currency_precision_multipliers(&at, pool_id)
api.get_currency_precision_multipliers(at, pool_id)
.map_err(runtime_error_into_rpc_err)?
.iter()
.map(|b| try_into_rpc_balance(*b))
Expand All @@ -222,9 +220,9 @@ where
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<Vec<NumberOrHex>> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_currency_balances(&at, pool_id)
api.get_currency_balances(at, pool_id)
.map_err(runtime_error_into_rpc_err)?
.iter()
.map(|b| try_into_rpc_balance(*b))
Expand All @@ -233,17 +231,17 @@ where

fn get_number_of_currencies(&self, pool_id: PoolId, at: Option<<Block as BlockT>::Hash>) -> RpcResult<u32> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_number_of_currencies(&at, pool_id)
api.get_number_of_currencies(at, pool_id)
.map_err(runtime_error_into_rpc_err)
}

fn get_admin_balances(&self, pool_id: PoolId, at: Option<<Block as BlockT>::Hash>) -> RpcResult<Vec<NumberOrHex>> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.get_admin_balances(&at, pool_id)
api.get_admin_balances(at, pool_id)
.map_err(runtime_error_into_rpc_err)?
.iter()
.map(|b| try_into_rpc_balance(*b))
Expand All @@ -257,10 +255,10 @@ where
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<NumberOrHex> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

let balances = api
.get_admin_balances(&at, pool_id)
.get_admin_balances(at, pool_id)
.map_err(runtime_error_into_rpc_err)?;

for (i, balance) in balances.iter().enumerate() {
Expand All @@ -280,10 +278,10 @@ where
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<NumberOrHex> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

let amount = api
.calculate_currency_amount(&at, pool_id, amounts, deposit)
.calculate_currency_amount(at, pool_id, amounts, deposit)
.map_err(runtime_error_into_rpc_err)?;

try_into_rpc_balance(amount)
Expand All @@ -298,10 +296,10 @@ where
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<NumberOrHex> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

let amount = api
.calculate_swap(&at, pool_id, in_index, out_index, in_amount)
.calculate_swap(at, pool_id, in_index, out_index, in_amount)
.map_err(runtime_error_into_rpc_err)?;

try_into_rpc_balance(amount)
Expand All @@ -314,9 +312,9 @@ where
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<Vec<NumberOrHex>> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

api.calculate_remove_liquidity(&at, pool_id, amount)
api.calculate_remove_liquidity(at, pool_id, amount)
.map_err(runtime_error_into_rpc_err)?
.iter()
.map(|b| try_into_rpc_balance(*b))
Expand All @@ -331,10 +329,10 @@ where
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<NumberOrHex> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

let amount = api
.calculate_remove_liquidity_one_currency(&at, pool_id, amount, index)
.calculate_remove_liquidity_one_currency(at, pool_id, amount, index)
.map_err(runtime_error_into_rpc_err)?;

try_into_rpc_balance(amount)
Expand Down
1 change: 0 additions & 1 deletion crates/dex-stable/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ pub mod pallet {
}

#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
pub struct Pallet<T>(_);

/// The id of next pool
Expand Down
1 change: 0 additions & 1 deletion crates/dex-swap-router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ pub mod pallet {
}

#[pallet::pallet]
#[pallet::generate_store(pub (super) trait Store)]
pub struct Pallet<T>(_);

#[pallet::event]
Expand Down
8 changes: 4 additions & 4 deletions crates/escrow/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ where
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<BalanceWrapper<Balance>> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

handle_response(
api.balance_at(&at, account_id, height),
api.balance_at(at, account_id, height),
"Unable to obtain the escrow balance".into(),
)
}
Expand All @@ -96,10 +96,10 @@ where
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<BalanceWrapper<Balance>> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));
let at = at.unwrap_or_else(|| self.client.info().best_hash);

handle_response(
api.total_supply(&at, height),
api.total_supply(at, height),
"Unable to obtain the escrow total supply".into(),
)
}
Expand Down
Loading

0 comments on commit 7ef91bd

Please sign in to comment.