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

Polkadot v1.0.0 #41

Closed
wants to merge 2 commits into from
Closed
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
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ scale-info = { version = "2.3", default-features = false, features = ["derive"]
obce-macro = { path = "macro", default-features = false }

# Substrate deps
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false, optional = true }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false, optional = true }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false, optional = true }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false, optional = true }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false, optional = true }
pallet-contracts = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false, optional = true }
sp-std = { version = "9.0.0", default-features = false, optional = true }
sp-runtime = { version = "25.0.0", default-features = false, optional = true }
sp-core = { version = "22.0.0", default-features = false, optional = true }
frame-support = { version = "22.0.0", default-features = false, optional = true }
frame-system = { version = "22.0.0", default-features = false, optional = true }
pallet-contracts = { version = "21.0.0", default-features = false, optional = true }

# Ink deps
ink = { version = "4.2.0", default-features = false, optional = true }
ink_engine = { version = "4.2.0", default-features = false, optional = true }

[dev-dependencies]
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false, features = ["std"] }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false, features = ["std"] }
frame-support = { version = "22.0.0", default-features = false, features = ["std"] }
frame-system = { version = "22.0.0", default-features = false, features = ["std"] }
ink = { version = "4.2.0", default-features = false, features = ["std"] }
trybuild = "1.0"

Expand Down
2 changes: 1 addition & 1 deletion codegen/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn generate(input: TokenStream) -> Result<TokenStream, Error> {
// whether a user wants to get an identifier of a chain extension
// or a chain extension method itself.
_ => {
return Err(format_err_spanned!(
Err(format_err_spanned!(
path,
"id macro supports only two-segment paths (ChainExtension, ChainExtension::method)"
))
Expand Down
18 changes: 5 additions & 13 deletions codegen/src/implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,24 +262,18 @@ impl TryFrom<&ItemImpl> for ExtensionContext {

fn try_from(impl_item: &ItemImpl) -> Result<Self, Self::Error> {
let Type::Path(path) = impl_item.self_ty.as_ref() else {
return Err(format_err_spanned!(
impl_item,
"the type should be `ExtensionContext`"
));
return Err(format_err_spanned!(impl_item, "the type should be `ExtensionContext`"))
};

let Some(extension) = path.path.segments.last() else {
return Err(format_err_spanned!(
path,
"the type should be `ExtensionContext`"
));
return Err(format_err_spanned!(path, "the type should be `ExtensionContext`"))
};

let PathArguments::AngleBracketed(generic_args) = &extension.arguments else {
return Err(format_err_spanned!(
path,
"`ExtensionContext` should have 5 generics as `<'a, E, T, Env, Extension>`"
));
))
};

let (lifetime1, env, substrate, obce_env, extension) =
Expand Down Expand Up @@ -380,13 +374,11 @@ fn handle_weight_attribute<'a, I: IntoIterator<Item = &'a NestedMeta>>(
) -> Result<(Option<TokenStream>, bool), Error> {
let weight_params = iter.into_iter().find_map(|attr| {
let NestedMeta::Meta(Meta::List(list)) = attr else {
return None;
};

let Some(ident) = list.path.get_ident() else {
return None
};

let ident = list.path.get_ident()?;

(ident == "weight").then_some((&list.nested, ident))
});

Expand Down
2 changes: 1 addition & 1 deletion codegen/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn generate(_: TokenStream, input: TokenStream) -> Result<TokenStream, Error
return Err(format_err_spanned!(
impl_item,
"impl marked as mocked should have a trait present"
));
))
};
let item = impl_item.self_ty;

Expand Down
6 changes: 3 additions & 3 deletions codegen/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ where
{
fn find_by_name(self, name: &str) -> Option<(LitOrPath<'a>, &'a Ident)> {
self.into_iter().find_map(|attr| {
match attr.borrow() {
match attr {
NestedMeta::Meta(Meta::NameValue(value)) => {
if let Some(ident) = value.path.get_ident() {
(ident == name).then_some((LitOrPath::Lit(&value.lit), ident))
Expand Down Expand Up @@ -145,7 +145,7 @@ impl<'a> InputBindings<'a> {
/// Iterate over "special" bindings identifiers.
///
/// For example, it converts `(one: u32, two: u32)` into `(__ink_binding_0, __ink_binding_1)`.
pub fn iter_call_params(&self) -> impl Iterator<Item = Ident> + ExactSizeIterator + '_ {
pub fn iter_call_params(&self) -> impl ExactSizeIterator<Item = Ident> + '_ {
self.bindings
.iter()
.enumerate()
Expand All @@ -155,7 +155,7 @@ impl<'a> InputBindings<'a> {
/// Iterate over raw bindings patterns.
///
/// The provided iterator makes no conversions from the inner values stored inside [`InputBindings`].
pub fn iter_raw_call_params(&self) -> impl Iterator<Item = &Pat> + ExactSizeIterator + '_ {
pub fn iter_raw_call_params(&self) -> impl ExactSizeIterator<Item = &Pat> + '_ {
self.bindings.iter().map(|pat| &*pat.pat)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/rand-extension/chain-extension/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ scale-info = { version = "2", default-features = false, features = ["derive"] }

ink = { version = "4.2.0", default-features = false, optional = true }

pallet-insecure-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false, optional = true }
pallet-insecure-randomness-collective-flip = { version = "10.0.0", default-features = false, optional = true }

[features]
default = ["std"]
Expand Down
42 changes: 30 additions & 12 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/ui/ink/mock/fail_incorrect_inputs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ error[E0308]: mismatched types
| expected `u32`, found `()`
| arguments to this function are incorrect
|
note: associated function defined here
note: method defined here
--> tests/ui/ink/mock/fail_incorrect_inputs.rs:8:8
|
8 | fn method(&self, val: u32) -> u64 {
Expand Down
24 changes: 24 additions & 0 deletions tests/ui/substrate/error/fail_duplicated_ret_val.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,33 @@ error[E0433]: failed to resolve: use of undeclared type `Error`
|
16 | assert_encode_holds(Error::One);
| ^^^^^ use of undeclared type `Error`
|
help: consider importing one of these items
|
1 + use core::error::Error;
|
1 + use core::fmt::Error;
|
1 + use frame_support::dispatch::fmt::Error;
|
1 + use frame_system::Error;
|
and 5 other candidates

error[E0433]: failed to resolve: use of undeclared type `Error`
--> tests/ui/substrate/error/fail_duplicated_ret_val.rs:17:27
|
17 | assert_try_from_holds(Error::One);
| ^^^^^ use of undeclared type `Error`
|
help: consider importing one of these items
|
1 + use core::error::Error;
|
1 + use core::fmt::Error;
|
1 + use frame_support::dispatch::fmt::Error;
|
1 + use frame_system::Error;
|
and 5 other candidates
24 changes: 24 additions & 0 deletions tests/ui/substrate/error/fail_enforced_ret_val.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,33 @@ error[E0433]: failed to resolve: use of undeclared type `Error`
|
14 | assert_encode_holds(Error::One);
| ^^^^^ use of undeclared type `Error`
|
help: consider importing one of these items
|
1 + use core::error::Error;
|
1 + use core::fmt::Error;
|
1 + use frame_support::dispatch::fmt::Error;
|
1 + use frame_system::Error;
|
and 5 other candidates

error[E0433]: failed to resolve: use of undeclared type `Error`
--> tests/ui/substrate/error/fail_enforced_ret_val.rs:15:27
|
15 | assert_try_from_holds(Error::One);
| ^^^^^ use of undeclared type `Error`
|
help: consider importing one of these items
|
1 + use core::error::Error;
|
1 + use core::fmt::Error;
|
1 + use frame_support::dispatch::fmt::Error;
|
1 + use frame_system::Error;
|
and 5 other candidates
Loading