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

fix(pop-api): read_state uses RelayChainDataProvider #34

Merged
merged 2 commits into from
Mar 10, 2024
Merged
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
10 changes: 7 additions & 3 deletions runtime/src/extensions.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use cumulus_pallet_parachain_system::RelaychainDataProvider;
use cumulus_primitives_core::relay_chain::BlockNumber;
use frame_support::{
dispatch::{GetDispatchInfo, RawOrigin},
Expand All @@ -13,7 +14,10 @@
CollectionId, ItemId,
};
use sp_core::crypto::UncheckedFrom;
use sp_runtime::{traits::Dispatchable, DispatchError};
use sp_runtime::{
traits::{BlockNumberProvider, Dispatchable},
DispatchError,
};
use sp_std::{boxed::Box, vec::Vec};
use xcm::{
latest::{prelude::*, OriginKind::SovereignAccount},
Expand Down Expand Up @@ -210,7 +214,7 @@
ParachainSystemKeys::LastRelayChainBlockNumber => {
env.charge_weight(T::DbWeight::get().reads(1_u64))?;
let relay_block_num: BlockNumber =
cumulus_pallet_parachain_system::Pallet::<T>::last_relay_block_number();
RelaychainDataProvider::<T>::current_block_number();
log::debug!(
target:LOG_TARGET,
"{} last relay chain block number is: {:?}.", LOG_PREFIX, relay_block_num
Expand Down Expand Up @@ -306,14 +310,14 @@
AccountId32 { id: (env.ext().address().clone()).into(), network: None }.into();
let message = Xcm::builder()
.withdraw_asset(assets.clone().into())
.buy_execution(assets.clone().into(), Unlimited)

Check warning on line 313 in runtime/src/extensions.rs

View workflow job for this annotation

GitHub Actions / clippy

useless conversion to the same type: `cumulus_primitives_core::Asset`

warning: useless conversion to the same type: `cumulus_primitives_core::Asset` --> runtime/src/extensions.rs:313:20 | 313 | .buy_execution(assets.clone().into(), Unlimited) | ^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `assets.clone()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion = note: `#[warn(clippy::useless_conversion)]` on by default
.transact(
SovereignAccount,
Weight::from_parts(25_000_000, 10_000),
message.encode().into(),
)
.refund_surplus()
.deposit_asset(assets.into(), beneficiary.into())

Check warning on line 320 in runtime/src/extensions.rs

View workflow job for this annotation

GitHub Actions / clippy

useless conversion to the same type: `cumulus_primitives_core::Location`

warning: useless conversion to the same type: `cumulus_primitives_core::Location` --> runtime/src/extensions.rs:320:35 | 320 | .deposit_asset(assets.into(), beneficiary.into()) | ^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `beneficiary` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
.build();
(dest, message)
},
Expand Down Expand Up @@ -608,7 +612,7 @@
new_test_ext().execute_with(|| {
let _ = env_logger::try_init();

let (wasm_binary, _) = load_wasm_module::<Runtime>("../contracts/pop-api-examples/read-runtime-state/target/ink/pop_api_extension_demo.wasm").unwrap();
let (wasm_binary, _) = load_wasm_module::<Runtime>("../contracts/pop-api-examples/read-runtime-state/target/ink/pop_api_read_state_example.wasm").unwrap();

let init_value = 100;

Expand Down
Loading