Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Polkadot 0.9.26 #146

Merged
merged 20 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fmt
  • Loading branch information
tolak committed Jul 20, 2022
commit b77eef66f5809ffb24fd9a3e7c5585d3774c564c
13 changes: 10 additions & 3 deletions pallets/subbridge/src/fungible_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,16 @@ impl<
);

// Deposit asset into temporary account, then forward through other bridges
let temporary_account =
MultiLocation::new(0, X1(GeneralKey(b"bridge_transfer".to_vec().try_into().expect("less than length limit; qed"))))
.into_account();
let temporary_account = MultiLocation::new(
0,
X1(GeneralKey(
b"bridge_transfer"
.to_vec()
.try_into()
.expect("less than length limit; qed"),
)),
)
.into_account();
if NativeChecker::is_native_asset(what) {
NativeAdapter::deposit_asset(
what,
Expand Down
8 changes: 7 additions & 1 deletion pallets/subbridge/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ mod subbridge_v3_migration_common {
T: chainbridge::Config + xcmbridge::Config + xtransfer::Config,
{
// Remove old chainbridge::BridgeFee storage
let _ = frame_support::migration::clear_storage_prefix(b"ChainBridge", b"BridgeFee", &[], None, None);
let _ = frame_support::migration::clear_storage_prefix(
b"ChainBridge",
b"BridgeFee",
&[],
None,
None,
);

// Create new storage items of fee setting in pallet ChainBridge
chainbridge::BridgeFee::<T>::insert(0, 300_000_000_000_000);
Expand Down
1 change: 0 additions & 1 deletion pallets/subbridge/src/xcmbridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub mod pallet {
#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
#[pallet::storage_version(STORAGE_VERSION)]
// TODO: remove when we Vec get replaced by BoundedVec
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

Expand Down
125 changes: 104 additions & 21 deletions pallets/subbridge/src/xtransfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,16 @@ pub mod pallet {
// use it as sender, asset will be withdrawn from this account.
// TODO: Handle the sitution when forwarding failed. Maybe need to have something like `AssesTrap`
// and `AssetsClaim`.
let temporary_account =
MultiLocation::new(0, X1(GeneralKey(b"bridge_transfer".to_vec().try_into().expect("less than length limit; qed")))).into_account();
let temporary_account = MultiLocation::new(
0,
X1(GeneralKey(
b"bridge_transfer"
.to_vec()
.try_into()
.expect("less than length limit; qed"),
)),
)
.into_account();
Self::do_transfer(
temporary_account.into(),
what.clone(),
Expand Down Expand Up @@ -183,7 +191,7 @@ pub mod pallet {
use frame_support::{assert_noop, assert_ok};
use polkadot_parachain::primitives::Sibling;
use sp_runtime::traits::{AccountIdConversion, ConstU32};
use sp_runtime::{AccountId32, bounded_vec, WeakBoundedVec};
use sp_runtime::{bounded_vec, AccountId32, WeakBoundedVec};

use assets_registry::{
AccountId32Conversion, AssetProperties, ExtractReserveLocation, IntoResourceId,
Expand All @@ -200,8 +208,15 @@ pub mod pallet {
fn test_transfer_unregistered_assets_to_parachain_should_failed() {
TestNet::reset();

let unregistered_asset_location =
MultiLocation::new(0, X1(GeneralKey(b"unregistered".to_vec().try_into().expect("less than length limit; qed"))));
let unregistered_asset_location = MultiLocation::new(
0,
X1(GeneralKey(
b"unregistered"
.to_vec()
.try_into()
.expect("less than length limit; qed"),
)),
);

ParaA::execute_with(|| {
// To parachains via Xcm(according to the dest)
Expand Down Expand Up @@ -230,8 +245,15 @@ pub mod pallet {
fn test_transfer_unregistered_assets_to_solochain_should_failed() {
TestNet::reset();

let unregistered_asset_location =
MultiLocation::new(0, X1(GeneralKey(b"unregistered".to_vec().try_into().expect("less than length limit; qed"))));
let unregistered_asset_location = MultiLocation::new(
0,
X1(GeneralKey(
b"unregistered"
.to_vec()
.try_into()
.expect("less than length limit; qed"),
)),
);

ParaA::execute_with(|| {
// To solo chains via Chainbridge(according to the dest)
Expand All @@ -242,9 +264,19 @@ pub mod pallet {
Box::new(MultiLocation::new(
0,
X3(
GeneralKey(b"cb".to_vec().try_into().expect("less than length limit; qed")),
GeneralKey(
b"cb"
.to_vec()
.try_into()
.expect("less than length limit; qed")
),
GeneralIndex(0),
GeneralKey(b"recipient".to_vec().try_into().expect("less than length limit; qed"))
GeneralKey(
b"recipient"
.to_vec()
.try_into()
.expect("less than length limit; qed")
)
)
)),
None,
Expand All @@ -258,8 +290,15 @@ pub mod pallet {
fn test_transfer_by_chainbridge_without_enabled_should_failed() {
TestNet::reset();

let registered_asset_location =
MultiLocation::new(0, X1(GeneralKey(b"registered".to_vec().try_into().expect("less than length limit; qed"))));
let registered_asset_location = MultiLocation::new(
0,
X1(GeneralKey(
b"registered"
.to_vec()
.try_into()
.expect("less than length limit; qed"),
)),
);
ParaA::execute_with(|| {
// Register asset
assert_ok!(AssetsRegistry::force_register_asset(
Expand All @@ -281,9 +320,19 @@ pub mod pallet {
Box::new(MultiLocation::new(
0,
X3(
GeneralKey(b"cb".to_vec().try_into().expect("less than length limit; qed")),
GeneralKey(
b"cb"
.to_vec()
.try_into()
.expect("less than length limit; qed")
),
GeneralIndex(0),
GeneralKey(b"recipient".to_vec().try_into().expect("less than length limit; qed"))
GeneralKey(
b"recipient"
.to_vec()
.try_into()
.expect("less than length limit; qed")
)
)
)),
None,
Expand All @@ -297,8 +346,15 @@ pub mod pallet {
fn test_transfer_by_chainbridge_without_feeset_should_failed() {
TestNet::reset();

let registered_asset_location =
MultiLocation::new(0, X1(GeneralKey(b"registered".to_vec().try_into().expect("less than length limit; qed"))));
let registered_asset_location = MultiLocation::new(
0,
X1(GeneralKey(
b"registered"
.to_vec()
.try_into()
.expect("less than length limit; qed"),
)),
);
ParaA::execute_with(|| {
// Register asset
assert_ok!(AssetsRegistry::force_register_asset(
Expand Down Expand Up @@ -329,9 +385,19 @@ pub mod pallet {
Box::new(MultiLocation::new(
0,
X3(
GeneralKey(b"cb".to_vec().try_into().expect("less than length limit; qed")),
GeneralKey(
b"cb"
.to_vec()
.try_into()
.expect("less than length limit; qed")
),
GeneralIndex(0),
GeneralKey(b"recipient".to_vec().try_into().expect("less than length limit; qed"))
GeneralKey(
b"recipient"
.to_vec()
.try_into()
.expect("less than length limit; qed")
)
)
)),
None,
Expand All @@ -345,8 +411,15 @@ pub mod pallet {
fn test_transfer_assets_to_local_should_failed() {
TestNet::reset();

let registered_asset_location =
MultiLocation::new(0, X1(GeneralKey(b"registered".to_vec().try_into().expect("less than length limit; qed"))));
let registered_asset_location = MultiLocation::new(
0,
X1(GeneralKey(
b"registered"
.to_vec()
.try_into()
.expect("less than length limit; qed"),
)),
);
ParaA::execute_with(|| {
// Register asset
assert_ok!(AssetsRegistry::force_register_asset(
Expand Down Expand Up @@ -401,7 +474,12 @@ pub mod pallet {
Box::new(MultiLocation::new(
0,
X3(
GeneralKey(b"cb".to_vec().try_into().expect("less than length limit; qed")),
GeneralKey(
b"cb"
.to_vec()
.try_into()
.expect("less than length limit; qed")
),
GeneralIndex(0),
GeneralKey(recipient.clone())
)
Expand Down Expand Up @@ -435,7 +513,12 @@ pub mod pallet {
let dest = MultiLocation::new(
0,
X3(
GeneralKey(b"cb".to_vec().try_into().expect("less than length limit; qed")),
GeneralKey(
b"cb"
.to_vec()
.try_into()
.expect("less than length limit; qed"),
),
GeneralIndex(0),
GeneralKey(recipient.clone()),
),
Expand Down