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

Create Agent #47

Merged
merged 3 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 3 additions & 4 deletions parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ use frame_system::{
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
pub use sp_runtime::{MultiAddress, Perbill, Permill};
use xcm::v3::NetworkId::{self, Rococo};
use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin};
use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin, LocalOriginToLocation};

use bp_parachains::SingleParaStoredHeaderDataBuilder;
use bp_runtime::HeaderId;
Expand Down Expand Up @@ -103,7 +103,7 @@ use parachains_common::{
impls::DealWithFees, opaque, AccountId, Balance, BlockNumber, Hash, Header, Index, Signature,
AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION,
};
use xcm_builder::{EnsureXcmOrigin, SignedToAccountId32};
use xcm_builder::EnsureXcmOrigin;
use xcm_executor::XcmExecutor;

/// The address format for describing accounts.
Expand Down Expand Up @@ -673,15 +673,14 @@ parameter_types! {
pub const RelayNetwork: NetworkId = Rococo;
}

pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
impl snowbridge_control::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OwnParaId = ParachainInfo;
type OutboundQueue = EthereumOutboundQueue;
type MessageHasher = BlakeTwo256;
type WeightInfo = ();
type MaxUpgradeDataSize = MaxUpgradeDataSize;
type EnsureCreateAgentOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type CreateAgentOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
}

// Create the runtime by composing the FRAME pallets that were previously configured.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom,
CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, IsConcrete,
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal,
DescribeFamily, EnsureXcmOrigin, HashedDescription, IsConcrete, ParentAsSuperuser,
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation,
TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds,
WithComputedOrigin, WithUniqueTopic,
};
use xcm_executor::{
traits::{ExportXcm, WithOriginFilter},
Expand Down Expand Up @@ -98,6 +99,8 @@ pub type LocationToAccountId = (
SiblingParachainConvertsVia<Sibling, AccountId>,
// Straight up local `AccountId32` origins just alias directly to `AccountId`.
AccountId32Aliases<RelayNetwork, AccountId>,
// Foreign locations alias into accounts according to a hash of their standard description.
HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
);

/// Means for transacting the native currency on this chain.
Expand Down Expand Up @@ -218,7 +221,10 @@ impl Contains<RuntimeCall> for SafeCallFilter {
) | RuntimeCall::EthereumOutboundQueue(
snowbridge_outbound_queue::Call::set_owner { .. }
| snowbridge_outbound_queue::Call::set_operating_mode { .. },
) | RuntimeCall::EthereumControl(snowbridge_control::Call::upgrade { .. },)
) | RuntimeCall::EthereumControl(
snowbridge_control::Call::upgrade { .. }
| snowbridge_control::Call::create_agent { .. },
)
)
}
}
Expand Down