Comments (4)
CC @KiChjang
from polkadot.
In order to make use of ensure_xcm
, let's first take a look at the code:
pub fn ensure_xcm<OuterOrigin>(o: OuterOrigin) -> Result<MultiLocation, BadOrigin>
// ...
{
match o.into() {
Ok(Origin::Xcm(location)) => Ok(location),
// ...
}
}
Here you can see that it's trying to convert the OuterOrigin
(we call it RuntimeOrigin
nowadays) into an Origin::Xcm
variant. This means that the MultiLocation
origin must have been converted to a FRAME origin before by an origin converter. Currently, there is a single origin converter that does this, and it's called XcmPassthrough
, located in the XCM pallet.
In short, ensure_xcm
only works if you have specifically configured your OriginConverter
to be XcmPassthrough
, otherwise you will never be able to get an Origin::Xcm
to match against.
from polkadot.
@KiChjang Ok, so that's the case, thanks for the answer.
I would like to ask, for example, if I want to write a pallet with a test_call method in it, and another chain calls it via DescendOrigin+Trancact instruction, what operation can I use to get the para_id, caller, and other useful information of the calling chain in the test_call method ?
from polkadot.
The most direct way of doing so is to include them as parameters to test_method
. Outside of that, XcmPassthrough
has the MultiLocation
of the sender, so you can quickly check and see which parachain it came from by matching agains the Parachain
junction.
from polkadot.
Related Issues (20)
- Invalid HOT 2
- node configuration HOT 1
- Polkadot v0.9.44 Release checklist HOT 1
- Polkadot v1.0.0 Release checklist HOT 8
- Launching Rococo Local Testnet
- How to implement Pallet_sudo HOT 4
- Always treat parachain that never produced block for a significant amount of time as unlocked. HOT 4
- Cancel Schedule - AuctionAdmin results on BadOrigin HOT 2
- [Feature request] websocket rate limit flag HOT 4
- ERROR tokio-runtime-worker runtime: panicked at 'Bad input data provided to validate_transaction: Codec error', /build/runtime/kusama/src/lib.rs:1661:1 HOT 3
- Polkadot v1.0.0-testing-next-ignore Release checklist HOT 1
- Polkadot v1.0.0 docker image doesn't work with --dev HOT 16
- Error on EVM pallet integration in relaychain HOT 2
- Errors when building runtimes: type X is not a member of trait Y HOT 1
- ParityDb migration tests are flaky HOT 19
- visual indicator in logs that validator is para-validating / active HOT 1
- build error v1.0.0: associated type BlockNumber not found HOT 5
- Panic when running Polkadot:v0.9.43 in docker HOT 3
- Polkadot {{ env.VERSION }} Release checklist HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polkadot.