-
Notifications
You must be signed in to change notification settings - Fork 431
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
Add xcm integration #1912
Add xcm integration #1912
Changes from all commits
3896cdf
4a778e8
b296b4d
6aae647
6a932a3
08f1087
79b1b00
e633876
d786de3
c283a6a
00e0553
ffec19e
87f5cc7
47ac7ad
3f24a9a
d1aa5ac
011b775
e346592
a6a0fae
8625f32
3bd6899
39dfd97
9b00d5b
f3a19d6
3445b55
dc26cc6
f1dbd38
0b189f8
20be373
ab1f53f
e1e4a4c
cd3bc7e
c47d711
17504a7
fede0a5
3d9be73
cfb1421
78e649b
7402b0d
c84a04d
fca97da
1044421
2d66e41
b51c96c
4ee01a8
f4234c1
37ece22
61016bb
ad7b06f
4bd4f04
25a36d6
1dbad34
172959a
891b548
dc8730d
70769af
b83a535
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,3 +132,4 @@ DRink | |
^ | ||
externalities | ||
sandbox_client | ||
xcm |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ use pallet_contracts_uapi::{ | |
ReturnErrorCode, | ||
ReturnFlags, | ||
}; | ||
use xcm::VersionedXcm; | ||
|
||
impl CryptoHash for Blake2x128 { | ||
fn hash(input: &[u8], output: &mut <Self as HashOutput>::Type) { | ||
|
@@ -726,4 +727,40 @@ impl TypedEnvBackend for EnvInstance { | |
let enc_code_hash = scope.take_encoded(code_hash); | ||
ext::unlock_delegate_dependency(enc_code_hash) | ||
} | ||
|
||
fn xcm_execute<E, Call>(&mut self, msg: &VersionedXcm<Call>) -> Result<()> | ||
where | ||
E: Environment, | ||
Call: scale::Encode, | ||
{ | ||
let mut scope = self.scoped_buffer(); | ||
|
||
// Double encoding the message as the host fn expects an encoded message. | ||
let enc_msg = scope.take_encoded(&scale::Encode::encode(msg)); | ||
ascjones marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#[allow(deprecated)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the function already marked deprecated? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unstable host api (which is still the case for this one as of this release of polkadot-sdk) are marked as deprecated so that they can trigger a warning if you try to use them without specifying |
||
ext::xcm_execute(enc_msg).map_err(Into::into) | ||
} | ||
|
||
fn xcm_send<E, Call>( | ||
&mut self, | ||
dest: &xcm::VersionedLocation, | ||
msg: &VersionedXcm<Call>, | ||
) -> Result<xcm::v4::XcmHash> | ||
where | ||
E: Environment, | ||
Call: scale::Encode, | ||
{ | ||
let mut scope = self.scoped_buffer(); | ||
let output = scope.take(32); | ||
scope.append_encoded(dest); | ||
let enc_dest = scope.take_appended(); | ||
|
||
// Double encoding the message as the host fn expects an encoded message. | ||
scope.append_encoded(&scale::Encode::encode(msg)); | ||
let enc_msg = scope.take_appended(); | ||
#[allow(deprecated)] | ||
ext::xcm_send(enc_dest, enc_msg, output.try_into().unwrap())?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could possibly use |
||
let hash: xcm::v4::XcmHash = scale::Decode::decode(&mut &output[..])?; | ||
Ok(hash) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[package] | ||
name = "contract-xcm" | ||
version = "4.0.0" | ||
authors = ["Parity Technologies <admin@parity.io>"] | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies] | ||
ink = { path = "../../../crates/ink", default-features = false } | ||
frame-support = { version = "32.0.0", default-features = false } | ||
pallet-balances = { version = "33.0.0", default-features = false } | ||
|
||
[dev-dependencies] | ||
ink_e2e = { path = "../../../crates/e2e", features = ["sandbox"] } | ||
|
||
[lib] | ||
path = "lib.rs" | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
"ink/std", | ||
"pallet-balances/std", | ||
"frame-support/std", | ||
] | ||
ink-as-dependency = [] | ||
e2e-tests = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests look like they pass (on my machine anyway) so we can enable them now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for building the risc-v example, I did you try that as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah no sorry I did not see it was part of the riscv step