Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

unresolved import sp_core::to_substrate_wasm_fn_return_value #13582

Closed
2 tasks done
blockcowboy opened this issue Mar 10, 2023 · 5 comments
Closed
2 tasks done

unresolved import sp_core::to_substrate_wasm_fn_return_value #13582

blockcowboy opened this issue Mar 10, 2023 · 5 comments
Labels
J2-unconfirmed Issue might be valid, but it’s not yet known.

Comments

@blockcowboy
Copy link

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Description of bug

NOTE: I tried this recommendation, but it did not work...
https://substrate.stackexchange.com/questions/1079/no-to-substrate-wasm-fn-return-value-in-the-root-when-i-run-cargo-build-in

I built a MacOS target example successfully
I built Substrate example successfully

When I added Substate dependencies to MacOS version I get the following error:

error[E0432]: unresolved import sp_core::to_substrate_wasm_fn_return_value
--> ~/.cargo/git/checkouts/substrate-7e08433d4c370a21/f38bd66/primitives/api/src/lib.rs:80:9
|
80 | pub use sp_core::to_substrate_wasm_fn_return_value;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no to_substrate_wasm_fn_return_value in the root

Can this be my .toml , etc.
Note sp-core compiles but can not find. Using same version as contract pallet for testing.
Compiling sp-core v7.0.0 (https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.37#f38bd667)

#!/bin/bash

##################################################

We call this from an Xcode run script.
##################################################

set -e

if [[ -z "$PROJECT_DIR" ]]; then
echo "Must provide PROJECT_DIR environment variable set to the Xcode project directory." 1>&2
exit 1
fi

cd $PROJECT_DIR

export PATH="$HOME/.cargo/bin:$PATH"

Without this we can't compile on MacOS Big Sur
TimNN/cargo-lipo#41 (comment)
if [[ -n "${DEVELOPER_SDK_DIR:-}" ]]; then
export LIBRARY_PATH="${DEVELOPER_SDK_DIR}/MacOSX.sdk/usr/lib:${LIBRARY_PATH:-}"
fi

TARGETS=""
if [[ "$PLATFORM_NAME" = "iphonesimulator" ]]; then
TARGETS="aarch64-apple-ios-sim,x86_64-apple-ios"
else
TARGETS="x86_64-apple-darwin,aarch64-apple-darwin"
fi

if [ $ENABLE_PREVIEWS == "NO" ]; then
if [[ $CONFIGURATION == "Release" ]]; then
echo "BUIlDING FOR RELEASE ($TARGETS)"

cargo lipo --release --manifest-path ../Cargo.toml --targets $TARGETS
else
echo "BUIlDING FOR DEBUG ($TARGETS)"

cargo lipo --manifest-path ../Cargo.toml --targets $TARGETS
fi

else
echo "Skipping the script because of preview mode"
fi
[package]
name = "macos-rust-analyzer"
version = "0.1.0"
edition = "2021"

build = "build.rs"

[build-dependencies]
swift-bridge-build = "0.1"

[lib]
crate-type = ["staticlib"]

[dependencies]
swift-bridge = "0.1"
ide = {git = "https://github.com/rust-analyzer/rust-analyzer"}
petgraph = "0.6.3"

anyhow = "1.0.43"
frame-metadata = { version = "15.0.0", features = ["v13"] }
hex = "0.4.3"
parity-scale-codec = "3.0.0"
reqwest = { version = "0.11.4", features = ["json"] }
serde = "1"
serde_json = "1"
tokio = { version = "1.10.0", features = ["full"] }
jsonrpsee = { version = "0.12.0", features = ["async-client", "client-ws-transport"] }

Various types and functions useful for interacting with substrate exist in these sp (substrate-primitives) crates:
sp-core = { git = "https://github.com/paritytech/substrate", package = "sp-core", default-features = false, branch = "polkadot-v0.9.37" }
sp_runtime = { git = "https://github.com/paritytech/substrate", package = "sp-runtime", default-features = false, branch = "polkadot-v0.9.37" }
sp_keyring = { git = "https://github.com/paritytech/substrate.git", package = "sp-keyring", default-features = false, branch = "polkadot-v0.9.37" }
sp_version = { git = "https://github.com/paritytech/substrate.git", package = "sp-version", default-features = false, branch = "polkadot-v0.9.37" }

XCM utilized for the 06_storage_iter example.
xcm = { version = "0.9", git = "https://github.com/paritytech/polkadot.git", branch = "master", package = "xcm" }

There are some types we want in the pallet crates (if we liked, we could just redefine them to save bringing these in):
pallet_balances = { git = "https://github.com/paritytech/substrate.git", package = "pallet-balances", default-features = false, branch = "polkadot-v0.9.37" }
pallet_system = { git = "https://github.com/paritytech/substrate.git", package = "frame-system", default-features = false, branch = "polkadot-v0.9.37" }

[profile.dev]
panic = 'unwind'

[profile.release]
panic = 'unwind'

Steps to reproduce

I created Mac version of project here successfully -
https://chinedufn.github.io/swift-bridge/building/xcode-and-cargo/index.html

Added dependencies from this project which caused import error -
https://github.com/paritytech/polkadot-interaction-examples-rs

@github-actions github-actions bot added the J2-unconfirmed Issue might be valid, but it’s not yet known. label Mar 10, 2023
@bkchr
Copy link
Member

bkchr commented Mar 10, 2023

to_substrate_wasm_fn_return_value this is only available when the std feature is not enabled for sp_core.

@blockcowboy
Copy link
Author

default-features = false
Yes, I have default-features = false, do i need to put standard-features = false ?

@bkchr
Copy link
Member

bkchr commented Mar 11, 2023

I would assume that you still have std feature enabled or something. Given the things you said here it is not possible to help you, because there is no context.

@blockcowboy
Copy link
Author

I would assume that you still have std feature enabled or something. Given the things you said here it is not possible to help you, because there is no context.

I resolved the problem. I was using crate versions from examples (dated). BAD IDEA.
If I have time, I need to go back and update those examples so others do not have this problem.
I updated crate versions and added a features flag for entire Cargo.toml
Issue resolved.

@bkchr
Copy link
Member

bkchr commented Mar 11, 2023

Ty for reporting back!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J2-unconfirmed Issue might be valid, but it’s not yet known.
Projects
None yet
Development

No branches or pull requests

2 participants