Skip to content

Commit

Permalink
Create Agent (#47)
Browse files Browse the repository at this point in the history
* add hashed description

* use existing account

* add call filter
  • Loading branch information
alistair-singh authored Jul 20, 2023
1 parent c92cd37 commit bc252fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
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

0 comments on commit bc252fe

Please sign in to comment.