git.delta.rocks / unique-network / refs/commits / 7c556ae4447e

difftreelog

Smart contract module added

str-mv2020-07-09parent: #55625a7.patch.diff
in: master

7 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1982,7 +1982,7 @@
  "sha2",
  "smallvec 1.3.0",
  "thiserror",
- "unsigned-varint",
+ "unsigned-varint 0.3.3",
  "void",
  "zeroize",
 ]
@@ -2046,7 +2046,7 @@
  "sha2",
  "smallvec 1.3.0",
  "uint",
- "unsigned-varint",
+ "unsigned-varint 0.3.3",
  "void",
  "wasm-timer",
 ]
@@ -2086,7 +2086,7 @@
  "libp2p-core",
  "log",
  "parking_lot 0.10.2",
- "unsigned-varint",
+ "unsigned-varint 0.3.3",
 ]
 
 [[package]]
@@ -2437,7 +2437,7 @@
  "sha-1",
  "sha2",
  "sha3",
- "unsigned-varint",
+ "unsigned-varint 0.3.3",
 ]
 
 [[package]]
@@ -2448,16 +2448,16 @@
 
 [[package]]
 name = "multistream-select"
-version = "0.8.0"
+version = "0.8.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "74cdcf7cfb3402881e15a1f95116cb033d69b33c83d481e1234777f5ef0c3d2c"
+checksum = "c9157e87afbc2ef0d84cc0345423d715f445edde00141c93721c162de35a05e5"
 dependencies = [
  "bytes 0.5.4",
  "futures 0.3.4",
  "log",
  "pin-project",
  "smallvec 1.3.0",
- "unsigned-varint",
+ "unsigned-varint 0.4.0",
 ]
 
 [[package]]
@@ -2516,8 +2516,10 @@
 version = "2.0.0-alpha.6"
 dependencies = [
  "futures 0.3.4",
+ "jsonrpc-core",
  "log",
  "nft-runtime",
+ "pallet-contracts-rpc",
  "sc-basic-authorship",
  "sc-cli",
  "sc-client",
@@ -2526,6 +2528,7 @@
  "sc-executor",
  "sc-finality-grandpa",
  "sc-network",
+ "sc-rpc",
  "sc-service",
  "sc-transaction-pool",
  "sp-consensus",
@@ -2548,6 +2551,8 @@
  "frame-system",
  "pallet-aura",
  "pallet-balances",
+ "pallet-contracts",
+ "pallet-contracts-primitives",
  "pallet-grandpa",
  "pallet-nft",
  "pallet-randomness-collective-flip",
@@ -2766,6 +2771,71 @@
 ]
 
 [[package]]
+name = "pallet-contracts"
+version = "2.0.0-alpha.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7c2bc13b765baa08a15815c0d836fee239fde73252a6c7babc437796eda561f5"
+dependencies = [
+ "frame-support",
+ "frame-system",
+ "pallet-contracts-primitives",
+ "parity-scale-codec",
+ "parity-wasm",
+ "pwasm-utils",
+ "serde",
+ "sp-core",
+ "sp-io",
+ "sp-runtime",
+ "sp-sandbox",
+ "sp-std",
+ "wasmi-validation",
+]
+
+[[package]]
+name = "pallet-contracts-primitives"
+version = "2.0.0-alpha.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5216edfd33a69a45bdd79f088563479dfdd6ecfb3c477b0f83955b844251c665"
+dependencies = [
+ "parity-scale-codec",
+ "sp-runtime",
+ "sp-std",
+]
+
+[[package]]
+name = "pallet-contracts-rpc"
+version = "0.8.0-alpha.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c575d839564073fa5757f9dfe5863b48eb07108ecda63521740b8bd8ed6f05c3"
+dependencies = [
+ "jsonrpc-core",
+ "jsonrpc-core-client",
+ "jsonrpc-derive",
+ "pallet-contracts-primitives",
+ "pallet-contracts-rpc-runtime-api",
+ "parity-scale-codec",
+ "serde",
+ "sp-api",
+ "sp-blockchain",
+ "sp-core",
+ "sp-rpc",
+ "sp-runtime",
+]
+
+[[package]]
+name = "pallet-contracts-rpc-runtime-api"
+version = "0.8.0-alpha.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "747f66dc20367de627c701675c66af0a53b4309df16c9929c0d23d2e27e436ee"
+dependencies = [
+ "pallet-contracts-primitives",
+ "parity-scale-codec",
+ "sp-api",
+ "sp-runtime",
+ "sp-std",
+]
+
+[[package]]
 name = "pallet-finality-tracker"
 version = "2.0.0-alpha.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2922,7 +2992,7 @@
  "percent-encoding 2.1.0",
  "serde",
  "static_assertions",
- "unsigned-varint",
+ "unsigned-varint 0.3.3",
  "url 2.1.1",
 ]
 
@@ -2940,7 +3010,7 @@
  "percent-encoding 2.1.0",
  "serde",
  "static_assertions",
- "unsigned-varint",
+ "unsigned-varint 0.3.3",
  "url 2.1.1",
 ]
 
@@ -2956,7 +3026,7 @@
  "sha-1",
  "sha2",
  "sha3",
- "unsigned-varint",
+ "unsigned-varint 0.3.3",
 ]
 
 [[package]]
@@ -3137,18 +3207,18 @@
 
 [[package]]
 name = "pin-project"
-version = "0.4.9"
+version = "0.4.22"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6f6a7f5eee6292c559c793430c55c00aea9d3b3d1905e855806ca4d7253426a2"
+checksum = "12e3a6cdbfe94a5e4572812a0201f8c0ed98c1c452c7b8563ce2276988ef9c17"
 dependencies = [
  "pin-project-internal",
 ]
 
 [[package]]
 name = "pin-project-internal"
-version = "0.4.9"
+version = "0.4.22"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8988430ce790d8682672117bc06dda364c0be32d3abd738234f19f3240bad99a"
+checksum = "6a0ffd45cf79d88737d7cc85bfd5d2894bee1139b356e616fe85dc389c61aaf7"
 dependencies = [
  "proc-macro2",
  "quote 1.0.3",
@@ -3341,6 +3411,17 @@
 checksum = "8e86d370532557ae7573551a1ec8235a0f8d6cb276c7c9e6aa490b511c447485"
 
 [[package]]
+name = "pwasm-utils"
+version = "0.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4f7a12f176deee919f4ba55326ee17491c8b707d0987aed822682c821b660192"
+dependencies = [
+ "byteorder",
+ "log",
+ "parity-wasm",
+]
+
+[[package]]
 name = "quick-error"
 version = "1.2.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -4205,7 +4286,7 @@
  "sp-utils",
  "substrate-prometheus-endpoint",
  "thiserror",
- "unsigned-varint",
+ "unsigned-varint 0.3.3",
  "void",
  "wasm-timer",
  "zeroize",
@@ -5180,6 +5261,20 @@
 ]
 
 [[package]]
+name = "sp-sandbox"
+version = "0.8.0-alpha.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6f2441d2ed3b141b74a6eaca28b469420bcd438c3ac43d25eadfe494d905135f"
+dependencies = [
+ "parity-scale-codec",
+ "sp-core",
+ "sp-io",
+ "sp-std",
+ "sp-wasm-interface",
+ "wasmi",
+]
+
+[[package]]
 name = "sp-serializer"
 version = "2.0.0-alpha.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -6082,6 +6177,12 @@
 ]
 
 [[package]]
+name = "unsigned-varint"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "669d776983b692a906c881fcd0cfb34271a48e197e4d6cb8df32b05bfc3d3fa5"
+
+[[package]]
 name = "untrusted"
 version = "0.7.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
modifiednode/Cargo.tomldiffbeforeafterboth
--- a/node/Cargo.toml
+++ b/node/Cargo.toml
@@ -16,6 +16,13 @@
 futures = '0.3.4'
 log = '0.4.8'
 structopt = '0.3.8'
+jsonrpc-core = '14.0.5'
+
+[dependencies.pallet-contracts-rpc]
+version = '0.8.0-alpha.6'
+
+[dependencies.sc-rpc]
+version = '2.0.0-alpha.6'
 
 [dependencies.nft-runtime]
 path = '../runtime'
modifiednode/src/chain_spec.rsdiffbeforeafterboth
--- a/node/src/chain_spec.rs
+++ b/node/src/chain_spec.rs
@@ -7,6 +7,7 @@
 use sp_finality_grandpa::AuthorityId as GrandpaId;
 use sp_runtime::traits::{Verify, IdentifyAccount};
 use sc_service::ChainType;
+use nft_runtime::{ContractsConfig, ContractsSchedule};
 
 // Note this is the URL for the telemetry server
 //const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
@@ -120,5 +121,12 @@
 		sudo: Some(SudoConfig {
 			key: root_key,
 		}),
+		contracts: Some(ContractsConfig {
+			gas_price: 1_000_000_000,
+            current_schedule: ContractsSchedule {
+                 //   enable_println,
+                    ..Default::default()
+            },
+        }),
 	}
 }
modifiedpallets/nft/Cargo.tomldiffbeforeafterboth
--- a/pallets/nft/Cargo.toml
+++ b/pallets/nft/Cargo.toml
@@ -40,8 +40,6 @@
 default-features = false
 version = '2.0.0-alpha.6'
 
-
-
 [features]
 default = ['std']
 std = [
modifiedruntime/Cargo.tomldiffbeforeafterboth
--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -14,6 +14,16 @@
 package = 'parity-scale-codec'
 version = '1.3.0'
 
+[dependencies.contracts]
+default-features = false
+package = 'pallet-contracts'
+version = '2.0.0-alpha.6'
+
+[dependencies.contracts-primitives]
+default-features = false
+package = 'pallet-contracts-primitives'
+version = '2.0.0-alpha.6'
+
 [dependencies.frame-executive]
 default-features = false
 version = '2.0.0-alpha.6'
@@ -133,6 +143,8 @@
     'aura/std',
     'balances/std',
     'codec/std',
+    'contracts/std',
+    'contracts-primitives/std',
     'frame-executive/std',
     'frame-support/std',
     'grandpa/std',
modifiedruntime/src/lib.rsdiffbeforeafterboth
before · runtime/src/lib.rs
1//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.23#![cfg_attr(not(feature = "std"), no_std)]4// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.5#![recursion_limit = "256"]67// Make the WASM binary available.8#[cfg(feature = "std")]9include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1011use grandpa::fg_primitives;12use grandpa::AuthorityList as GrandpaAuthorityList;13use sp_api::impl_runtime_apis;14use sp_consensus_aura::sr25519::AuthorityId as AuraId;15use sp_core::OpaqueMetadata;16use sp_runtime::traits::{17    BlakeTwo256, Block as BlockT, ConvertInto, IdentifyAccount, IdentityLookup, Verify,18};19use sp_runtime::{20    create_runtime_str, generic, impl_opaque_keys,21    transaction_validity::{TransactionSource, TransactionValidity},22    ApplyExtrinsicResult, MultiSignature,23};24use sp_std::prelude::*;25#[cfg(feature = "std")]26use sp_version::NativeVersion;27use sp_version::RuntimeVersion;2829// A few exports that help ease life for downstream crates.30pub use balances::Call as BalancesCall;31pub use frame_support::{32    construct_runtime, parameter_types, traits::Randomness, weights::Weight, StorageValue,33};34#[cfg(any(feature = "std", test))]35pub use sp_runtime::BuildStorage;36pub use sp_runtime::{Perbill, Permill};37pub use timestamp::Call as TimestampCall;3839/// Importing a template pallet40pub use nft;4142/// An index to a block.43pub type BlockNumber = u32;4445/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.46pub type Signature = MultiSignature;4748/// Some way of identifying an account on the chain. We intentionally make it equivalent49/// to the public key of our transaction signing scheme.50pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;5152/// The type for looking up accounts. We don't expect more than 4 billion of them, but you53/// never know...54pub type AccountIndex = u32;5556/// Balance of an account.57pub type Balance = u128;5859/// Index of a transaction in the chain.60pub type Index = u32;6162/// A hash of some data used by the chain.63pub type Hash = sp_core::H256;6465/// Digest item type.66pub type DigestItem = generic::DigestItem<Hash>;6768/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know69/// the specifics of the runtime. They can then be made to be agnostic over specific formats70/// of data like extrinsics, allowing for them to continue syncing the network through upgrades71/// to even the core data structures.72pub mod opaque {73    use super::*;7475    pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;7677    /// Opaque block header type.78    pub type Header = generic::Header<BlockNumber, BlakeTwo256>;79    /// Opaque block type.80    pub type Block = generic::Block<Header, UncheckedExtrinsic>;81    /// Opaque block identifier type.82    pub type BlockId = generic::BlockId<Block>;8384    impl_opaque_keys! {85        pub struct SessionKeys {86            pub aura: Aura,87            pub grandpa: Grandpa,88        }89    }90}9192/// This runtime version.93pub const VERSION: RuntimeVersion = RuntimeVersion {94    spec_name: create_runtime_str!("nft"),95    impl_name: create_runtime_str!("nft"),96    authoring_version: 1,97    spec_version: 1,98    impl_version: 1,99    apis: RUNTIME_API_VERSIONS,100};101102pub const MILLISECS_PER_BLOCK: u64 = 6000;103104pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;105106// These time units are defined in number of blocks.107pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);108pub const HOURS: BlockNumber = MINUTES * 60;109pub const DAYS: BlockNumber = HOURS * 24;110111/// The version information used to identify this runtime when compiled natively.112#[cfg(feature = "std")]113pub fn native_version() -> NativeVersion {114    NativeVersion {115        runtime_version: VERSION,116        can_author_with: Default::default(),117    }118}119120parameter_types! {121    pub const BlockHashCount: BlockNumber = 250;122    pub const MaximumBlockWeight: Weight = 1_000_000_000;123    pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);124    pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;125    pub const Version: RuntimeVersion = VERSION;126}127128impl system::Trait for Runtime {129    /// The identifier used to distinguish between accounts.130    type AccountId = AccountId;131    /// The aggregated dispatch type that is available for extrinsics.132    type Call = Call;133    /// The lookup mechanism to get account ID from whatever is passed in dispatchers.134    type Lookup = IdentityLookup<AccountId>;135    /// The index type for storing how many extrinsics an account has signed.136    type Index = Index;137    /// The index type for blocks.138    type BlockNumber = BlockNumber;139    /// The type for hashing blocks and tries.140    type Hash = Hash;141    /// The hashing algorithm used.142    type Hashing = BlakeTwo256;143    /// The header type.144    type Header = generic::Header<BlockNumber, BlakeTwo256>;145    /// The ubiquitous event type.146    type Event = Event;147    /// The ubiquitous origin type.148    type Origin = Origin;149    /// Maximum number of block number to block hash mappings to keep (oldest pruned first).150    type BlockHashCount = BlockHashCount;151    /// Maximum weight of each block.152    type MaximumBlockWeight = MaximumBlockWeight;153    /// Maximum size of all encoded transactions (in bytes) that are allowed in one block.154    type MaximumBlockLength = MaximumBlockLength;155    /// Portion of the block weight that is available to all normal transactions.156    type AvailableBlockRatio = AvailableBlockRatio;157    /// Version of the runtime.158    type Version = Version;159    /// Converts a module to the index of the module in `construct_runtime!`.160    ///161    /// This type is being generated by `construct_runtime!`.162    type ModuleToIndex = ModuleToIndex;163    /// What to do if a new account is created.164    type OnNewAccount = ();165    /// What to do if an account is fully reaped from the system.166    type OnKilledAccount = ();167    /// The data to be stored in an account.168    type AccountData = balances::AccountData<Balance>;169}170171impl aura::Trait for Runtime {172    type AuthorityId = AuraId;173}174175impl grandpa::Trait for Runtime {176    type Event = Event;177}178179parameter_types! {180    pub const MinimumPeriod: u64 = SLOT_DURATION / 2;181}182183impl timestamp::Trait for Runtime {184    /// A timestamp: milliseconds since the unix epoch.185    type Moment = u64;186    type OnTimestampSet = Aura;187    type MinimumPeriod = MinimumPeriod;188}189190parameter_types! {191    pub const ExistentialDeposit: u128 = 500;192}193194impl balances::Trait for Runtime {195    /// The type for recording an account's balance.196    type Balance = Balance;197    /// The ubiquitous event type.198    type Event = Event;199    type DustRemoval = ();200    type ExistentialDeposit = ExistentialDeposit;201    type AccountStore = System;202}203204parameter_types! {205    pub const TransactionBaseFee: Balance = 0;206    pub const TransactionByteFee: Balance = 1;207}208209impl transaction_payment::Trait for Runtime {210    type Currency = balances::Module<Runtime>;211    type OnTransactionPayment = ();212    type TransactionBaseFee = TransactionBaseFee;213    type TransactionByteFee = TransactionByteFee;214    type WeightToFee = ConvertInto;215    type FeeMultiplierUpdate = ();216}217218impl sudo::Trait for Runtime {219    type Event = Event;220    type Call = Call;221}222223/// Used for the module template in `./template.rs`224impl nft::Trait for Runtime {225    type Event = Event;226}227228construct_runtime!(229    pub enum Runtime where230        Block = Block,231        NodeBlock = opaque::Block,232        UncheckedExtrinsic = UncheckedExtrinsic233    {234        System: system::{Module, Call, Config, Storage, Event<T>},235        RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},236        Timestamp: timestamp::{Module, Call, Storage, Inherent},237        Aura: aura::{Module, Config<T>, Inherent(Timestamp)},238        Grandpa: grandpa::{Module, Call, Storage, Config, Event},239        Balances: balances::{Module, Call, Storage, Config<T>, Event<T>},240        TransactionPayment: transaction_payment::{Module, Storage},241        Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},242        // Used for the module template in `./template.rs`243        Nft: nft::{Module, Call, Storage, Event<T>},244    }245);246247/// The address format for describing accounts.248pub type Address = AccountId;249/// Block header type as expected by this runtime.250pub type Header = generic::Header<BlockNumber, BlakeTwo256>;251/// Block type as expected by this runtime.252pub type Block = generic::Block<Header, UncheckedExtrinsic>;253/// A Block signed with a Justification254pub type SignedBlock = generic::SignedBlock<Block>;255/// BlockId type as expected by this runtime.256pub type BlockId = generic::BlockId<Block>;257/// The SignedExtension to the basic transaction logic.258pub type SignedExtra = (259    system::CheckVersion<Runtime>,260    system::CheckGenesis<Runtime>,261    system::CheckEra<Runtime>,262    system::CheckNonce<Runtime>,263    system::CheckWeight<Runtime>,264    transaction_payment::ChargeTransactionPayment<Runtime>,265);266/// Unchecked extrinsic type as expected by this runtime.267pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;268/// Extrinsic type that has already been checked.269pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;270/// Executive: handles dispatch to the various modules.271pub type Executive =272    frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;273274impl_runtime_apis! {275    impl sp_api::Core<Block> for Runtime {276        fn version() -> RuntimeVersion {277            VERSION278        }279280        fn execute_block(block: Block) {281            Executive::execute_block(block)282        }283284        fn initialize_block(header: &<Block as BlockT>::Header) {285            Executive::initialize_block(header)286        }287    }288289    impl sp_api::Metadata<Block> for Runtime {290        fn metadata() -> OpaqueMetadata {291            Runtime::metadata().into()292        }293    }294295    impl sp_block_builder::BlockBuilder<Block> for Runtime {296        fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {297            Executive::apply_extrinsic(extrinsic)298        }299300        fn finalize_block() -> <Block as BlockT>::Header {301            Executive::finalize_block()302        }303304        fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {305            data.create_extrinsics()306        }307308        fn check_inherents(309            block: Block,310            data: sp_inherents::InherentData,311        ) -> sp_inherents::CheckInherentsResult {312            data.check_extrinsics(&block)313        }314315        fn random_seed() -> <Block as BlockT>::Hash {316            RandomnessCollectiveFlip::random_seed()317        }318    }319320    impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {321        fn validate_transaction(322            source: TransactionSource,323            tx: <Block as BlockT>::Extrinsic,324        ) -> TransactionValidity {325            Executive::validate_transaction(source, tx)326        }327    }328329    impl sp_offchain::OffchainWorkerApi<Block> for Runtime {330        fn offchain_worker(header: &<Block as BlockT>::Header) {331            Executive::offchain_worker(header)332        }333    }334335    impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {336        fn slot_duration() -> u64 {337            Aura::slot_duration()338        }339340        fn authorities() -> Vec<AuraId> {341            Aura::authorities()342        }343    }344345    impl sp_session::SessionKeys<Block> for Runtime {346        fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {347            opaque::SessionKeys::generate(seed)348        }349350        fn decode_session_keys(351            encoded: Vec<u8>,352        ) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {353            opaque::SessionKeys::decode_into_raw_public_keys(&encoded)354        }355    }356357    impl fg_primitives::GrandpaApi<Block> for Runtime {358        fn grandpa_authorities() -> GrandpaAuthorityList {359            Grandpa::grandpa_authorities()360        }361    }362}
after · runtime/src/lib.rs
1//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.23#![cfg_attr(not(feature = "std"), no_std)]4// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.5#![recursion_limit = "256"]67// Make the WASM binary available.8#[cfg(feature = "std")]9include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1011use grandpa::fg_primitives;12use grandpa::AuthorityList as GrandpaAuthorityList;13use sp_api::impl_runtime_apis;14use sp_consensus_aura::sr25519::AuthorityId as AuraId;15use sp_core::OpaqueMetadata;16use sp_runtime::traits::{17    BlakeTwo256, Block as BlockT, ConvertInto, IdentifyAccount, IdentityLookup, Verify,18};19use sp_runtime::{20    create_runtime_str, generic, impl_opaque_keys,21    transaction_validity::{TransactionSource, TransactionValidity},22    ApplyExtrinsicResult, MultiSignature,23};24use sp_std::prelude::*;25#[cfg(feature = "std")]26use sp_version::NativeVersion;27use sp_version::RuntimeVersion;2829// A few exports that help ease life for downstream crates.30pub use balances::Call as BalancesCall;31pub use frame_support::{32    construct_runtime, parameter_types, traits::Randomness, weights::Weight, StorageValue,33};34#[cfg(any(feature = "std", test))]35pub use sp_runtime::BuildStorage;36pub use sp_runtime::{Perbill, Permill};37pub use timestamp::Call as TimestampCall;38pub use contracts::Schedule as ContractsSchedule;3940/// Importing a template pallet41pub use nft;4243/// An index to a block.44pub type BlockNumber = u32;4546/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.47pub type Signature = MultiSignature;4849/// Some way of identifying an account on the chain. We intentionally make it equivalent50/// to the public key of our transaction signing scheme.51pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;5253/// The type for looking up accounts. We don't expect more than 4 billion of them, but you54/// never know...55pub type AccountIndex = u32;5657/// Balance of an account.58pub type Balance = u128;5960/// Index of a transaction in the chain.61pub type Index = u32;6263/// A hash of some data used by the chain.64pub type Hash = sp_core::H256;6566/// Digest item type.67pub type DigestItem = generic::DigestItem<Hash>;6869/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know70/// the specifics of the runtime. They can then be made to be agnostic over specific formats71/// of data like extrinsics, allowing for them to continue syncing the network through upgrades72/// to even the core data structures.73pub mod opaque {74    use super::*;7576    pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;7778    /// Opaque block header type.79    pub type Header = generic::Header<BlockNumber, BlakeTwo256>;80    /// Opaque block type.81    pub type Block = generic::Block<Header, UncheckedExtrinsic>;82    /// Opaque block identifier type.83    pub type BlockId = generic::BlockId<Block>;8485    impl_opaque_keys! {86        pub struct SessionKeys {87            pub aura: Aura,88            pub grandpa: Grandpa,89        }90    }91}9293/// This runtime version.94pub const VERSION: RuntimeVersion = RuntimeVersion {95    spec_name: create_runtime_str!("nft"),96    impl_name: create_runtime_str!("nft"),97    authoring_version: 1,98    spec_version: 1,99    impl_version: 1,100    apis: RUNTIME_API_VERSIONS,101};102103pub const MILLISECS_PER_BLOCK: u64 = 6000;104105pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;106107// These time units are defined in number of blocks.108pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);109pub const HOURS: BlockNumber = MINUTES * 60;110pub const DAYS: BlockNumber = HOURS * 24;111112/// The version information used to identify this runtime when compiled natively.113#[cfg(feature = "std")]114pub fn native_version() -> NativeVersion {115    NativeVersion {116        runtime_version: VERSION,117        can_author_with: Default::default(),118    }119}120121parameter_types! {122    pub const BlockHashCount: BlockNumber = 250;123    pub const MaximumBlockWeight: Weight = 1_000_000_000;124    pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);125    pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;126    pub const Version: RuntimeVersion = VERSION;127}128129impl system::Trait for Runtime {130    /// The identifier used to distinguish between accounts.131    type AccountId = AccountId;132    /// The aggregated dispatch type that is available for extrinsics.133    type Call = Call;134    /// The lookup mechanism to get account ID from whatever is passed in dispatchers.135    type Lookup = IdentityLookup<AccountId>;136    /// The index type for storing how many extrinsics an account has signed.137    type Index = Index;138    /// The index type for blocks.139    type BlockNumber = BlockNumber;140    /// The type for hashing blocks and tries.141    type Hash = Hash;142    /// The hashing algorithm used.143    type Hashing = BlakeTwo256;144    /// The header type.145    type Header = generic::Header<BlockNumber, BlakeTwo256>;146    /// The ubiquitous event type.147    type Event = Event;148    /// The ubiquitous origin type.149    type Origin = Origin;150    /// Maximum number of block number to block hash mappings to keep (oldest pruned first).151    type BlockHashCount = BlockHashCount;152    /// Maximum weight of each block.153    type MaximumBlockWeight = MaximumBlockWeight;154    /// Maximum size of all encoded transactions (in bytes) that are allowed in one block.155    type MaximumBlockLength = MaximumBlockLength;156    /// Portion of the block weight that is available to all normal transactions.157    type AvailableBlockRatio = AvailableBlockRatio;158    /// Version of the runtime.159    type Version = Version;160    /// Converts a module to the index of the module in `construct_runtime!`.161    ///162    /// This type is being generated by `construct_runtime!`.163    type ModuleToIndex = ModuleToIndex;164    /// What to do if a new account is created.165    type OnNewAccount = ();166    /// What to do if an account is fully reaped from the system.167    type OnKilledAccount = ();168    /// The data to be stored in an account.169    type AccountData = balances::AccountData<Balance>;170}171172impl aura::Trait for Runtime {173    type AuthorityId = AuraId;174}175176impl grandpa::Trait for Runtime {177    type Event = Event;178}179180parameter_types! {181    pub const MinimumPeriod: u64 = SLOT_DURATION / 2;182}183184impl timestamp::Trait for Runtime {185    /// A timestamp: milliseconds since the unix epoch.186    type Moment = u64;187    type OnTimestampSet = Aura;188    type MinimumPeriod = MinimumPeriod;189}190191parameter_types! {192    pub const ExistentialDeposit: u128 = 500;193}194195impl balances::Trait for Runtime {196    /// The type for recording an account's balance.197    type Balance = Balance;198    /// The ubiquitous event type.199    type Event = Event;200    type DustRemoval = ();201    type ExistentialDeposit = ExistentialDeposit;202    type AccountStore = System;203}204205// Contracts price units.206pub const MILLICENTS: Balance = 1_000_000_000;207pub const CENTS: Balance = 1_000 * MILLICENTS;208pub const DOLLARS: Balance = 100 * CENTS;209210parameter_types! {211    pub const TombstoneDeposit: Balance = 16 * MILLICENTS;212    pub const RentByteFee: Balance = 4 * MILLICENTS;213    pub const RentDepositOffset: Balance = 1000 * MILLICENTS;214	pub const SurchargeReward: Balance = 150 * MILLICENTS;215	pub const ContractTransactionBaseFee: Balance = 1 * CENTS;216	pub const ContractTransactionByteFee: Balance = 10 * MILLICENTS;217	pub const ContractFee: Balance = 1 * CENTS;218}219220impl contracts::Trait for Runtime {221	type Currency = Balances;222	type Time = Timestamp;223	type Randomness = RandomnessCollectiveFlip;224	type Call = Call;225	type Event = Event;226	type DetermineContractAddress = contracts::SimpleAddressDeterminer<Runtime>;227	type ComputeDispatchFee = contracts::DefaultDispatchFeeComputor<Runtime>;228	type TrieIdGenerator = contracts::TrieIdFromParentCounter<Runtime>;229	type GasPayment = ();230	type RentPayment = ();231	type SignedClaimHandicap = contracts::DefaultSignedClaimHandicap;232	type TombstoneDeposit = TombstoneDeposit;233	type StorageSizeOffset = contracts::DefaultStorageSizeOffset;234	type RentByteFee = RentByteFee;235	type RentDepositOffset = RentDepositOffset;236	type SurchargeReward = SurchargeReward;237	type TransactionBaseFee = ContractTransactionBaseFee;238	type TransactionByteFee = ContractTransactionByteFee;239	type ContractFee = ContractFee;240	type CallBaseFee = contracts::DefaultCallBaseFee;241	type InstantiateBaseFee = contracts::DefaultInstantiateBaseFee;242	type MaxDepth = contracts::DefaultMaxDepth;243	type MaxValueSize = contracts::DefaultMaxValueSize;244	type BlockGasLimit = contracts::DefaultBlockGasLimit;245}246247parameter_types! {248    pub const TransactionBaseFee: Balance = 0;249    pub const TransactionByteFee: Balance = 1;250}251252impl transaction_payment::Trait for Runtime {253    type Currency = balances::Module<Runtime>;254    type OnTransactionPayment = ();255    type TransactionBaseFee = TransactionBaseFee;256    type TransactionByteFee = TransactionByteFee;257    type WeightToFee = ConvertInto;258    type FeeMultiplierUpdate = ();259}260261impl sudo::Trait for Runtime {262    type Event = Event;263    type Call = Call;264}265266/// Used for the module template in `./template.rs`267impl nft::Trait for Runtime {268    type Event = Event;269}270271construct_runtime!(272    pub enum Runtime where273        Block = Block,274        NodeBlock = opaque::Block,275        UncheckedExtrinsic = UncheckedExtrinsic,276    {277        System: system::{Module, Call, Config, Storage, Event<T>},278        RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},279        Timestamp: timestamp::{Module, Call, Storage, Inherent},280        Aura: aura::{Module, Config<T>, Inherent(Timestamp)},281        Grandpa: grandpa::{Module, Call, Storage, Config, Event},282        Balances: balances::{Module, Call, Storage, Config<T>, Event<T>},283        TransactionPayment: transaction_payment::{Module, Storage},284		Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},285		Contracts: contracts::{Module, Call, Config<T>, Storage, Event<T>},286        // Used for the module template in `./template.rs`287        Nft: nft::{Module, Call, Storage, Event<T>},288    }289);290291/// The address format for describing accounts.292pub type Address = AccountId;293/// Block header type as expected by this runtime.294pub type Header = generic::Header<BlockNumber, BlakeTwo256>;295/// Block type as expected by this runtime.296pub type Block = generic::Block<Header, UncheckedExtrinsic>;297/// A Block signed with a Justification298pub type SignedBlock = generic::SignedBlock<Block>;299/// BlockId type as expected by this runtime.300pub type BlockId = generic::BlockId<Block>;301/// The SignedExtension to the basic transaction logic.302pub type SignedExtra = (303    system::CheckVersion<Runtime>,304    system::CheckGenesis<Runtime>,305    system::CheckEra<Runtime>,306    system::CheckNonce<Runtime>,307    system::CheckWeight<Runtime>,308    transaction_payment::ChargeTransactionPayment<Runtime>,309);310/// Unchecked extrinsic type as expected by this runtime.311pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;312/// Extrinsic type that has already been checked.313pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;314/// Executive: handles dispatch to the various modules.315pub type Executive =316    frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;317318impl_runtime_apis! {319    impl sp_api::Core<Block> for Runtime {320        fn version() -> RuntimeVersion {321            VERSION322        }323324        fn execute_block(block: Block) {325            Executive::execute_block(block)326        }327328        fn initialize_block(header: &<Block as BlockT>::Header) {329            Executive::initialize_block(header)330        }331    }332333    impl sp_api::Metadata<Block> for Runtime {334        fn metadata() -> OpaqueMetadata {335            Runtime::metadata().into()336        }337    }338339    impl sp_block_builder::BlockBuilder<Block> for Runtime {340        fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {341            Executive::apply_extrinsic(extrinsic)342        }343344        fn finalize_block() -> <Block as BlockT>::Header {345            Executive::finalize_block()346        }347348        fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {349            data.create_extrinsics()350        }351352        fn check_inherents(353            block: Block,354            data: sp_inherents::InherentData,355        ) -> sp_inherents::CheckInherentsResult {356            data.check_extrinsics(&block)357        }358359        fn random_seed() -> <Block as BlockT>::Hash {360            RandomnessCollectiveFlip::random_seed()361        }362    }363364    impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {365        fn validate_transaction(366            source: TransactionSource,367            tx: <Block as BlockT>::Extrinsic,368        ) -> TransactionValidity {369            Executive::validate_transaction(source, tx)370        }371    }372373    impl sp_offchain::OffchainWorkerApi<Block> for Runtime {374        fn offchain_worker(header: &<Block as BlockT>::Header) {375            Executive::offchain_worker(header)376        }377    }378379    impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {380        fn slot_duration() -> u64 {381            Aura::slot_duration()382        }383384        fn authorities() -> Vec<AuraId> {385            Aura::authorities()386        }387    }388389    impl sp_session::SessionKeys<Block> for Runtime {390        fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {391            opaque::SessionKeys::generate(seed)392        }393394        fn decode_session_keys(395            encoded: Vec<u8>,396        ) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {397            opaque::SessionKeys::decode_into_raw_public_keys(&encoded)398        }399    }400401    impl fg_primitives::GrandpaApi<Block> for Runtime {402        fn grandpa_authorities() -> GrandpaAuthorityList {403            Grandpa::grandpa_authorities()404        }405    }406}
modifiedsmart_contract/nft/Cargo.tomldiffbeforeafterboth
--- a/smart_contract/nft/Cargo.toml
+++ b/smart_contract/nft/Cargo.toml
@@ -10,7 +10,7 @@
 ink_primitives = { version = "2", git = "https://github.com/paritytech/ink", tag = "latest-v2", package = "ink_primitives", default-features = false }
 ink_core = { version = "2", git = "https://github.com/paritytech/ink", tag = "latest-v2", package = "ink_core", default-features = false }
 ink_lang = { version = "2", git = "https://github.com/paritytech/ink", tag = "latest-v2", package = "ink_lang", default-features = false }
-scale = { package = "parity-scale-codec", version = "1.2", default-features = false, features = ["derive"] }
+scale = { package = "parity-scale-codec", version = "1.3", default-features = false, features = ["derive"] }
 
 sp-core = { git = "https://github.com/paritytech/substrate/", package = "sp-core", default-features = false }
 sp-runtime = { git = "https://github.com/paritytech/substrate/", package = "sp-runtime", default-features = false }