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

build(deps): allow specifying ink version via feature #80

Closed
wants to merge 1 commit 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
6 changes: 4 additions & 2 deletions pop-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ edition = "2021"

[dependencies]
enumflags2 = { version = "0.7.7" }
ink = { version = "5.0.0-rc.3", default-features = false }
inkv4 = { package = "ink", version = "4.3.0", default-features = false, optional = true }
inkv5 = { package = "ink", version = "5.0.0", default-features = false, optional = true }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.6", default-features = false, features = ["derive"] }
sp-io = { version = "23.0.0", default-features = false, features = ["disable_panic_handler", "disable_oom", "disable_allocator"] }
Expand All @@ -24,10 +25,11 @@ crate-type = ["rlib"]
default = ["std"]
std = [
"enumflags2/std",
"ink/std",
"pop-primitives/std",
"scale/std",
"scale-info/std",
"sp-io/std",
"sp-runtime/std",
]
inkv4 = ["dep:inkv4"]
inkv5 = ["dep:inkv5"]
4 changes: 2 additions & 2 deletions pop-api/examples/balance-transfer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ authors = ["[your_name] <[your_email]>"]
edition = "2021"

[dependencies]
ink = { version = "5.0.0-rc.3", default-features = false }
pop-api = { path = "../../../pop-api", default-features = false }
ink = { version = "4.3.0", default-features = false }
pop-api = { path = "../../../pop-api", default-features = false, features = ["inkv4"] }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.6", default-features = false, features = ["derive"], optional = true }

Expand Down
4 changes: 2 additions & 2 deletions pop-api/examples/nfts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ authors = ["[your_name] <[your_email]>"]
edition = "2021"

[dependencies]
ink = { version = "5.0.0-rc.3", default-features = false }
pop-api = { path = "../../../pop-api", default-features = false }
ink = { version = "5.0.0", default-features = false }
pop-api = { path = "../../../pop-api", default-features = false, features = ["inkv5"] }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.6", default-features = false, features = ["derive"], optional = true }

Expand Down
4 changes: 2 additions & 2 deletions pop-api/examples/place-spot-order/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ authors = ["[your_name] <[your_email]>"]
edition = "2021"

[dependencies]
ink = { version = "5.0.0-rc.3", default-features = false }
pop-api = { path = "../../../pop-api", default-features = false }
ink = { version = "5.0.0", default-features = false }
pop-api = { path = "../../../pop-api", default-features = false, features = ["inkv5"] }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.6", default-features = false, features = ["derive"], optional = true }

Expand Down
4 changes: 2 additions & 2 deletions pop-api/examples/read-runtime-state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ authors = ["[your_name] <[your_email]>"]
edition = "2021"

[dependencies]
ink = { version = "5.0.0-rc.3", default-features = false }
pop-api = { path = "../../../pop-api", default-features = false }
ink = { version = "4.3.0", default-features = false }
pop-api = { path = "../../../pop-api", default-features = false, features = ["inkv4"] }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2.6", default-features = false, features = ["derive"], optional = true }

Expand Down
28 changes: 28 additions & 0 deletions pop-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
pub mod primitives;
pub mod v0;

#[cfg(feature = "inkv4")]
extern crate inkv4 as ink;
#[cfg(feature = "inkv5")]
extern crate inkv5 as ink;
#[cfg(all(feature = "inkv4", feature = "inkv5"))]
compile_error!("feature \"inkv4\" and feature \"inkv5\" cannot be enabled at the same time");
#[cfg(not(any(feature = "inkv4", feature = "inkv5")))]
compile_error!("feature \"inkv4\" or feature \"inkv5\" must be enabled");

use crate::PopApiError::{Balances, Nfts, UnknownStatusCode};
use ink::{prelude::vec::Vec, ChainExtensionInstance};
use primitives::{cross_chain::*, storage_keys::*};
Expand Down Expand Up @@ -65,6 +74,25 @@ impl ink::env::Environment for Environment {
type ChainExtension = PopApi;
}

#[cfg(feature = "inkv4")]
#[ink::chain_extension]
pub trait PopApi {
type ErrorCode = PopApiError;

#[ink(extension = 0)]
#[allow(private_interfaces)]
fn dispatch(call: RuntimeCall) -> Result<()>;

#[ink(extension = 1)]
#[allow(private_interfaces)]
fn read_state(key: RuntimeStateKeys) -> Result<Vec<u8>>;

#[ink(extension = 2)]
#[allow(private_interfaces)]
fn send_xcm(xcm: CrossChainMessage) -> Result<()>;
}

#[cfg(feature = "inkv5")]
#[ink::chain_extension(extension = 909)]
pub trait PopApi {
type ErrorCode = PopApiError;
Expand Down
Loading