Skip to content

Commit

Permalink
substrate version uplifts polkadot-v0.9.33, ink 4.0.0-beta support (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
shunsukew authored Dec 10, 2022
1 parent 3b6f89d commit 2334dad
Show file tree
Hide file tree
Showing 10 changed files with 741 additions and 1,014 deletions.
1,462 changes: 609 additions & 853 deletions Cargo.lock

Large diffs are not rendered by default.

24 changes: 11 additions & 13 deletions chain-extensions/rmrk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@ description = "RMRK chain extension for WASM contracts"

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33", default-features = false }
log = { version = "0.4.16", optional = true }
num-traits = { version = "0.2", default-features = false }
pallet-contracts = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30", default-features = false, features = ["unstable-interface"] }
pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30", default-features = false }
pallet-contracts-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30", default-features = false }
pallet-uniques = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30", default-features = false }
scale-info = { version = "~2.1.0", default-features = false, features = ["derive"] }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30", default-features = false }
pallet-contracts = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33", default-features = false, features = ["unstable-interface"] }
pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33", default-features = false }
pallet-uniques = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.33", default-features = false }
scale-info = { version = "2", default-features = false, features = ["derive"] }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.33", default-features = false }

# RMRK
pallet-rmrk-core = { git = "https://github.com/AstarNetwork/rmrk-substrate", branch = "polkadot-v0.9.30", default-features = false }
rmrk-traits = { git = "https://github.com/AstarNetwork/rmrk-substrate", branch = "polkadot-v0.9.30", default-features = false }
pallet-rmrk-core = { git = "https://github.com/AstarNetwork/rmrk-substrate", branch = "polkadot-v0.9.33", default-features = false }
rmrk-traits = { git = "https://github.com/AstarNetwork/rmrk-substrate", branch = "polkadot-v0.9.33", default-features = false }

[features]
default = ["std"]
Expand All @@ -36,7 +35,6 @@ std = [
"num-traits/std",
"pallet-contracts/std",
"pallet-contracts-primitives/std",
"pallet-contracts-rpc-runtime-api/std",
"pallet-rmrk-core/std",
"pallet-uniques/std",
"rmrk-traits/std",
Expand Down
15 changes: 3 additions & 12 deletions contracts/crates/rmrk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@ authors = ["Stake Technologies <[email protected]>"]
edition = "2021"

[dependencies]
ink_env = { version = "3", default-features = false }
ink_lang = { version = "3", default-features = false }
ink_metadata = { version = "3", default-features = false, features = ["derive"], optional = true }
ink_prelude = { version = "3", default-features = false }
ink_primitives = { version = "3", default-features = false }
ink_storage = { version = "3", default-features = false }
ink = { version = "~4.0.0-beta", default-features = false }

scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "~2.1.0", default-features = false, features = ["derive"], optional = true }
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true }

[lib]
name = "rmrk_extension"
Expand All @@ -23,12 +18,8 @@ crate-type = ["rlib"]
[features]
default = ["std"]
std = [
"ink_metadata/std",
"ink_env/std",
"ink_storage/std",
"ink_primitives/std",
"ink/std",
"scale/std",
"scale-info/std",
"ink_prelude/std",
]
ink-as-dependency = []
62 changes: 31 additions & 31 deletions contracts/crates/rmrk/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg_attr(not(feature = "std"), no_std)]

use ink_env::AccountId;
use ink_prelude::vec::Vec;
use ink::primitives::AccountId;
use ink::prelude::vec::Vec;
use scale::{Decode, Encode};

#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
Expand Down Expand Up @@ -44,9 +44,9 @@ impl From<scale::Error> for RmrkError {
}
}

impl ink_env::chain_extension::FromStatusCode for RmrkError {
impl ink::env::chain_extension::FromStatusCode for RmrkError {
fn from_status_code(status_code: u32) -> Result<(), Self> {
ink_env::debug_println!("{}", status_code);
ink::env::debug_println!("{}", status_code);
match status_code {
0 => Ok(()),
1 => Err(Self::StorageOverflow),
Expand Down Expand Up @@ -211,15 +211,15 @@ pub struct Rmrk;
impl Rmrk {
// read
pub fn collections(collection_id: CollectionId) -> Option<CollectionInfo> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x00010004)
::ink::env::chain_extension::ChainExtensionMethod::build(0x00010004)
.input::<CollectionId>()
.output::<Option<CollectionInfo>>()
.ignore_error_code()
.call(&collection_id)
}

pub fn nfts(collection_id: CollectionId, nft_id: NftId) -> Option<NftInfo> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x00010005)
::ink::env::chain_extension::ChainExtensionMethod::build(0x00010005)
.input::<(CollectionId, NftId)>()
.output::<Option<NftInfo>>()
.ignore_error_code()
Expand All @@ -231,7 +231,7 @@ impl Rmrk {
nft_id: NftId,
resource_id: ResourceId,
) -> Option<u32> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x00010006)
::ink::env::chain_extension::ChainExtensionMethod::build(0x00010006)
.input::<(CollectionId, NftId, ResourceId)>()
.output::<Option<u32>>()
.ignore_error_code()
Expand All @@ -242,7 +242,7 @@ impl Rmrk {
parent: (CollectionId, NftId),
child: (CollectionId, NftId),
) -> Option<()> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x00010007)
::ink::env::chain_extension::ChainExtensionMethod::build(0x00010007)
.input::<(
(CollectionId, NftId),
(CollectionId, NftId)
Expand All @@ -257,7 +257,7 @@ impl Rmrk {
nft_id: NftId,
resource_id: ResourceId,
) -> Option<ResourceInfo> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x00010008)
::ink::env::chain_extension::ChainExtensionMethod::build(0x00010008)
.input::<(CollectionId, NftId, ResourceId)>()
.output::<Option<ResourceInfo>>()
.ignore_error_code()
Expand All @@ -269,7 +269,7 @@ impl Rmrk {
nft_id: NftId,
base_id: BaseId,
) -> Option<()> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x00010009)
::ink::env::chain_extension::ChainExtensionMethod::build(0x00010009)
.input::<(CollectionId, NftId, BaseId)>()
.output::<Option<()>>()
.ignore_error_code()
Expand All @@ -283,7 +283,7 @@ impl Rmrk {
base_id: BaseId,
slot_id: SlotId,
) -> Option<()> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x0001000A)
::ink::env::chain_extension::ChainExtensionMethod::build(0x0001000A)
.input::<(
CollectionId,
NftId,
Expand All @@ -307,15 +307,15 @@ impl Rmrk {
nft_id: Option<NftId>,
key: Vec<u8>,
) -> Option<Vec<u8>> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x0001000B)
::ink::env::chain_extension::ChainExtensionMethod::build(0x0001000B)
.input::<(CollectionId, Option<NftId>, Vec<u8>)>()
.output::<Option<Vec<u8>>>()
.ignore_error_code()
.call(&(collection_id, nft_id, key))
}

pub fn lock(collection_id: CollectionId, nft_id: NftId) -> bool {
::ink_env::chain_extension::ChainExtensionMethod::build(0x0001000C)
::ink::env::chain_extension::ChainExtensionMethod::build(0x0001000C)
.input::<(CollectionId, NftId)>()
.output::<bool>()
.ignore_error_code()
Expand All @@ -333,7 +333,7 @@ impl Rmrk {
transferable: bool,
resources: Option<Vec<ResourceInfoMin>>,
) -> Result<(), RmrkError> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x0001000D)
::ink::env::chain_extension::ChainExtensionMethod::build(0x0001000D)
.input::<(
Option<AccountId>,
NftId,
Expand Down Expand Up @@ -368,7 +368,7 @@ impl Rmrk {
transferable: bool,
resources: Option<Vec<ResourceInfoMin>>,
) -> Result<(), RmrkError> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x0001000E)
::ink::env::chain_extension::ChainExtensionMethod::build(0x0001000E)
.input::<(
(CollectionId, NftId),
NftId,
Expand Down Expand Up @@ -399,7 +399,7 @@ impl Rmrk {
max: Option<u32>,
symbol: Vec<u8>,
) -> Result<(), RmrkError> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x0001000F)
::ink::env::chain_extension::ChainExtensionMethod::build(0x0001000F)
.input::<(CollectionId, Vec<u8>, Option<u32>, Vec<u8>)>()
.output()
.handle_error_code::<RmrkError>()
Expand All @@ -410,15 +410,15 @@ impl Rmrk {
collection_id: CollectionId,
nft_id: NftId,
) -> Result<(), RmrkError> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x00010010)
::ink::env::chain_extension::ChainExtensionMethod::build(0x00010010)
.input::<(CollectionId, NftId)>()
.output()
.handle_error_code::<RmrkError>()
.call(&(collection_id, nft_id))
}

pub fn destroy_collection(collection_id: CollectionId) -> Result<(), RmrkError> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x00010011)
::ink::env::chain_extension::ChainExtensionMethod::build(0x00010011)
.input::<CollectionId>()
.output()
.handle_error_code::<RmrkError>()
Expand All @@ -430,7 +430,7 @@ impl Rmrk {
nft_id: NftId,
new_owner: AccountIdOrCollectionNftTuple,
) -> Result<(), RmrkError> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x00010012)
::ink::env::chain_extension::ChainExtensionMethod::build(0x00010012)
.input::<(CollectionId, NftId, AccountIdOrCollectionNftTuple)>()
.output()
.handle_error_code::<RmrkError>()
Expand All @@ -442,7 +442,7 @@ impl Rmrk {
nft_id: NftId,
new_owner: AccountIdOrCollectionNftTuple,
) -> Result<(), RmrkError> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x00010013)
::ink::env::chain_extension::ChainExtensionMethod::build(0x00010013)
.input::<(CollectionId, NftId, AccountIdOrCollectionNftTuple)>()
.output()
.handle_error_code::<RmrkError>()
Expand All @@ -453,7 +453,7 @@ impl Rmrk {
collection_id: CollectionId,
nft_id: NftId,
) -> Result<(), RmrkError> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x00010014)
::ink::env::chain_extension::ChainExtensionMethod::build(0x00010014)
.input::<(CollectionId, NftId)>()
.output()
.handle_error_code::<RmrkError>()
Expand All @@ -464,7 +464,7 @@ impl Rmrk {
collection_id: CollectionId,
new_issuer: AccountId,
) -> Result<(), RmrkError> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x00010015)
::ink::env::chain_extension::ChainExtensionMethod::build(0x00010015)
.input::<(CollectionId, AccountId)>()
.output()
.handle_error_code::<RmrkError>()
Expand All @@ -477,7 +477,7 @@ impl Rmrk {
key: Vec<u8>,
value: Vec<u8>,
) -> Result<(), RmrkError> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x00010016)
::ink::env::chain_extension::ChainExtensionMethod::build(0x00010016)
.input::<(
CollectionId,
Option<NftId>,
Expand All @@ -495,7 +495,7 @@ impl Rmrk {
}

pub fn lock_collection(collection_id: CollectionId) -> Result<(), RmrkError> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x00010017)
::ink::env::chain_extension::ChainExtensionMethod::build(0x00010017)
.input::<CollectionId>()
.output()
.handle_error_code::<RmrkError>()
Expand All @@ -508,7 +508,7 @@ impl Rmrk {
resource: BasicResource,
resource_id: ResourceId,
) -> Result<(), RmrkError> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x00010018)
::ink::env::chain_extension::ChainExtensionMethod::build(0x00010018)
.input::<(CollectionId, NftId, BasicResource, ResourceId)>()
.output()
.handle_error_code::<RmrkError>()
Expand All @@ -521,7 +521,7 @@ impl Rmrk {
resource: ComposableResource,
resource_id: ResourceId,
) -> Result<(), RmrkError> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x00010019)
::ink::env::chain_extension::ChainExtensionMethod::build(0x00010019)
.input::<(CollectionId, NftId, ComposableResource, ResourceId)>()
.output()
.handle_error_code::<RmrkError>()
Expand All @@ -534,7 +534,7 @@ impl Rmrk {
resource: SlotResource,
resource_id: ResourceId,
) -> Result<(), RmrkError> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x0001001A)
::ink::env::chain_extension::ChainExtensionMethod::build(0x0001001A)
.input::<(CollectionId, NftId, SlotResource, ResourceId)>()
.output()
.handle_error_code::<RmrkError>()
Expand All @@ -546,7 +546,7 @@ impl Rmrk {
nft_id: NftId,
resource_id: ResourceId,
) -> Result<(), RmrkError> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x0001001B)
::ink::env::chain_extension::ChainExtensionMethod::build(0x0001001B)
.input::<(CollectionId, NftId, ResourceId)>()
.output()
.handle_error_code::<RmrkError>()
Expand All @@ -558,7 +558,7 @@ impl Rmrk {
nft_id: NftId,
resource_id: ResourceId,
) -> Result<(), RmrkError> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x0001001C)
::ink::env::chain_extension::ChainExtensionMethod::build(0x0001001C)
.input::<(CollectionId, NftId, ResourceId)>()
.output()
.handle_error_code::<RmrkError>()
Expand All @@ -570,7 +570,7 @@ impl Rmrk {
nft_id: NftId,
resource_id: ResourceId,
) -> Result<(), RmrkError> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x0001001D)
::ink::env::chain_extension::ChainExtensionMethod::build(0x0001001D)
.input::<(CollectionId, NftId, ResourceId)>()
.output()
.handle_error_code::<RmrkError>()
Expand All @@ -582,7 +582,7 @@ impl Rmrk {
nft_id: NftId,
priorities: Vec<ResourceId>,
) -> Result<(), RmrkError> {
::ink_env::chain_extension::ChainExtensionMethod::build(0x0001001E)
::ink::env::chain_extension::ChainExtensionMethod::build(0x0001001E)
.input::<(CollectionId, NftId, Vec<ResourceId>)>()
.output()
.handle_error_code::<RmrkError>()
Expand Down
15 changes: 3 additions & 12 deletions contracts/examples/rmrk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@ authors = ["[your_name] <[your_email]>"]
edition = "2021"

[dependencies]
ink_env = { version = "3", default-features = false }
ink_lang = { version = "3", default-features = false }
ink_metadata = { version = "3", default-features = false, features = ["derive"], optional = true }
ink_prelude = { version = "3", default-features = false }
ink_primitives = { version = "3", default-features = false }
ink_storage = { version = "3", default-features = false }
ink = { version = "~4.0.0-beta", default-features = false }

scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "~2.1.0", default-features = false, features = ["derive"], optional = true }
scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true }

rmrk_extension = { path = "../../crates/rmrk", default-features = false }

Expand All @@ -28,13 +23,9 @@ crate-type = [
[features]
default = ["std"]
std = [
"ink_metadata/std",
"ink_env/std",
"ink_storage/std",
"ink_primitives/std",
"ink/std",
"scale/std",
"scale-info/std",
"rmrk_extension/std",
"ink_prelude/std",
]
ink-as-dependency = []
10 changes: 4 additions & 6 deletions contracts/examples/rmrk/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#![cfg_attr(not(feature = "std"), no_std)]

use ink_lang as ink;

#[ink::contract]
mod rmrk {
use ink_prelude::vec::Vec;
use rmrk_extension::*;
use ink::prelude::vec::Vec;

#[ink(storage)]
pub struct RmrkExample {}
Expand Down Expand Up @@ -361,9 +359,9 @@ mod rmrk {
mod tests {
/// Imports all the definitions from the outer scope so we can use them here.
use super::*;

/// Imports `ink_lang` so we can use `#[ink::test]`.
use ink_lang as ink;
use ink::env::{
test,
};

/// We test if the default constructor does its job.
#[ink::test]
Expand Down
Loading

0 comments on commit 2334dad

Please sign in to comment.