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
before · runtime/Cargo.toml
1[dependencies.aura]2default-features = false3package = 'pallet-aura'4version = '2.0.0-alpha.6'56[dependencies.balances]7default-features = false8package = 'pallet-balances'9version = '2.0.0-alpha.6'1011[dependencies.codec]12default-features = false13features = ['derive']14package = 'parity-scale-codec'15version = '1.3.0'1617[dependencies.frame-executive]18default-features = false19version = '2.0.0-alpha.6'2021[dependencies.frame-support]22default-features = false23version = '2.0.0-alpha.6'2425[dependencies.grandpa]26default-features = false27package = 'pallet-grandpa'28version = '2.0.0-alpha.6'2930[dependencies.randomness-collective-flip]31default-features = false32package = 'pallet-randomness-collective-flip'33version = '2.0.0-alpha.6'3435[dependencies.serde]36features = ['derive']37optional = true38version = '1.0.101'3940[dependencies.sp-api]41default-features = false42version = '2.0.0-alpha.6'4344[dependencies.sp-block-builder]45default-features = false46version = '2.0.0-alpha.6'4748[dependencies.sp-consensus-aura]49default-features = false50version = '0.8.0-alpha.6'5152[dependencies.sp-core]53default-features = false54version = '2.0.0-alpha.6'5556[dependencies.sp-inherents]57default-features = false58version = '2.0.0-alpha.6'5960[dependencies.sp-io]61default-features = false62version = '2.0.0-alpha.6'6364[dependencies.sp-offchain]65default-features = false66version = '2.0.0-alpha.6'6768[dependencies.sp-runtime]69default-features = false70version = '2.0.0-alpha.6'7172[dependencies.sp-session]73default-features = false74version = '2.0.0-alpha.6'7576[dependencies.sp-std]77default-features = false78version = '2.0.0-alpha.6'7980[dependencies.sp-transaction-pool]81default-features = false82version = '2.0.0-alpha.6'8384[dependencies.sp-version]85default-features = false86version = '2.0.0-alpha.6'8788[dependencies.sudo]89default-features = false90package = 'pallet-sudo'91version = '2.0.0-alpha.6'9293[dependencies.system]94default-features = false95package = 'frame-system'96version = '2.0.0-alpha.6'9798[dependencies.nft]99default-features = false100package = 'pallet-nft'101path = '../pallets/nft'102version = '2.0.0-alpha.6'103104[dependencies.timestamp]105default-features = false106package = 'pallet-timestamp'107version = '2.0.0-alpha.6'108109[dependencies.transaction-payment]110default-features = false111package = 'pallet-transaction-payment'112version = '2.0.0-alpha.6'113114[build-dependencies.wasm-builder-runner]115package = 'substrate-wasm-builder-runner'116version = '1.0.5'117118[package]119authors = ['Anonymous']120edition = '2018'121homepage = 'https://substrate.dev'122license = 'Unlicense'123name = 'nft-runtime'124repository = 'https://github.com/paritytech/substrate/'125version = '2.0.0-alpha.6'126127[package.metadata.docs.rs]128targets = ['x86_64-unknown-linux-gnu']129130[features]131default = ['std']132std = [133    'aura/std',134    'balances/std',135    'codec/std',136    'frame-executive/std',137    'frame-support/std',138    'grandpa/std',139    'randomness-collective-flip/std',140    'serde',141    'sp-api/std',142    'sp-block-builder/std',143    'sp-consensus-aura/std',144    'sp-core/std',145    'sp-inherents/std',146    'sp-io/std',147    'sp-offchain/std',148    'sp-runtime/std',149    'sp-session/std',150    'sp-std/std',151    'sp-transaction-pool/std',152    'sp-version/std',153    'sudo/std',154    'system/std',155    'timestamp/std',156    'transaction-payment/std',157    'nft/std',158]
after · runtime/Cargo.toml
1[dependencies.aura]2default-features = false3package = 'pallet-aura'4version = '2.0.0-alpha.6'56[dependencies.balances]7default-features = false8package = 'pallet-balances'9version = '2.0.0-alpha.6'1011[dependencies.codec]12default-features = false13features = ['derive']14package = 'parity-scale-codec'15version = '1.3.0'1617[dependencies.contracts]18default-features = false19package = 'pallet-contracts'20version = '2.0.0-alpha.6'2122[dependencies.contracts-primitives]23default-features = false24package = 'pallet-contracts-primitives'25version = '2.0.0-alpha.6'2627[dependencies.frame-executive]28default-features = false29version = '2.0.0-alpha.6'3031[dependencies.frame-support]32default-features = false33version = '2.0.0-alpha.6'3435[dependencies.grandpa]36default-features = false37package = 'pallet-grandpa'38version = '2.0.0-alpha.6'3940[dependencies.randomness-collective-flip]41default-features = false42package = 'pallet-randomness-collective-flip'43version = '2.0.0-alpha.6'4445[dependencies.serde]46features = ['derive']47optional = true48version = '1.0.101'4950[dependencies.sp-api]51default-features = false52version = '2.0.0-alpha.6'5354[dependencies.sp-block-builder]55default-features = false56version = '2.0.0-alpha.6'5758[dependencies.sp-consensus-aura]59default-features = false60version = '0.8.0-alpha.6'6162[dependencies.sp-core]63default-features = false64version = '2.0.0-alpha.6'6566[dependencies.sp-inherents]67default-features = false68version = '2.0.0-alpha.6'6970[dependencies.sp-io]71default-features = false72version = '2.0.0-alpha.6'7374[dependencies.sp-offchain]75default-features = false76version = '2.0.0-alpha.6'7778[dependencies.sp-runtime]79default-features = false80version = '2.0.0-alpha.6'8182[dependencies.sp-session]83default-features = false84version = '2.0.0-alpha.6'8586[dependencies.sp-std]87default-features = false88version = '2.0.0-alpha.6'8990[dependencies.sp-transaction-pool]91default-features = false92version = '2.0.0-alpha.6'9394[dependencies.sp-version]95default-features = false96version = '2.0.0-alpha.6'9798[dependencies.sudo]99default-features = false100package = 'pallet-sudo'101version = '2.0.0-alpha.6'102103[dependencies.system]104default-features = false105package = 'frame-system'106version = '2.0.0-alpha.6'107108[dependencies.nft]109default-features = false110package = 'pallet-nft'111path = '../pallets/nft'112version = '2.0.0-alpha.6'113114[dependencies.timestamp]115default-features = false116package = 'pallet-timestamp'117version = '2.0.0-alpha.6'118119[dependencies.transaction-payment]120default-features = false121package = 'pallet-transaction-payment'122version = '2.0.0-alpha.6'123124[build-dependencies.wasm-builder-runner]125package = 'substrate-wasm-builder-runner'126version = '1.0.5'127128[package]129authors = ['Anonymous']130edition = '2018'131homepage = 'https://substrate.dev'132license = 'Unlicense'133name = 'nft-runtime'134repository = 'https://github.com/paritytech/substrate/'135version = '2.0.0-alpha.6'136137[package.metadata.docs.rs]138targets = ['x86_64-unknown-linux-gnu']139140[features]141default = ['std']142std = [143    'aura/std',144    'balances/std',145    'codec/std',146    'contracts/std',147    'contracts-primitives/std',148    'frame-executive/std',149    'frame-support/std',150    'grandpa/std',151    'randomness-collective-flip/std',152    'serde',153    'sp-api/std',154    'sp-block-builder/std',155    'sp-consensus-aura/std',156    'sp-core/std',157    'sp-inherents/std',158    'sp-io/std',159    'sp-offchain/std',160    'sp-runtime/std',161    'sp-session/std',162    'sp-std/std',163    'sp-transaction-pool/std',164    'sp-version/std',165    'sudo/std',166    'system/std',167    'timestamp/std',168    'transaction-payment/std',169    'nft/std',170]
modifiedruntime/src/lib.rsdiffbeforeafterboth
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -35,6 +35,7 @@
 pub use sp_runtime::BuildStorage;
 pub use sp_runtime::{Perbill, Permill};
 pub use timestamp::Call as TimestampCall;
+pub use contracts::Schedule as ContractsSchedule;
 
 /// Importing a template pallet
 pub use nft;
@@ -201,6 +202,48 @@
     type AccountStore = System;
 }
 
+// Contracts price units.
+pub const MILLICENTS: Balance = 1_000_000_000;
+pub const CENTS: Balance = 1_000 * MILLICENTS;
+pub const DOLLARS: Balance = 100 * CENTS;
+
+parameter_types! {
+    pub const TombstoneDeposit: Balance = 16 * MILLICENTS;
+    pub const RentByteFee: Balance = 4 * MILLICENTS;
+    pub const RentDepositOffset: Balance = 1000 * MILLICENTS;
+	pub const SurchargeReward: Balance = 150 * MILLICENTS;
+	pub const ContractTransactionBaseFee: Balance = 1 * CENTS;
+	pub const ContractTransactionByteFee: Balance = 10 * MILLICENTS;
+	pub const ContractFee: Balance = 1 * CENTS;
+}
+
+impl contracts::Trait for Runtime {
+	type Currency = Balances;
+	type Time = Timestamp;
+	type Randomness = RandomnessCollectiveFlip;
+	type Call = Call;
+	type Event = Event;
+	type DetermineContractAddress = contracts::SimpleAddressDeterminer<Runtime>;
+	type ComputeDispatchFee = contracts::DefaultDispatchFeeComputor<Runtime>;
+	type TrieIdGenerator = contracts::TrieIdFromParentCounter<Runtime>;
+	type GasPayment = ();
+	type RentPayment = ();
+	type SignedClaimHandicap = contracts::DefaultSignedClaimHandicap;
+	type TombstoneDeposit = TombstoneDeposit;
+	type StorageSizeOffset = contracts::DefaultStorageSizeOffset;
+	type RentByteFee = RentByteFee;
+	type RentDepositOffset = RentDepositOffset;
+	type SurchargeReward = SurchargeReward;
+	type TransactionBaseFee = ContractTransactionBaseFee;
+	type TransactionByteFee = ContractTransactionByteFee;
+	type ContractFee = ContractFee;
+	type CallBaseFee = contracts::DefaultCallBaseFee;
+	type InstantiateBaseFee = contracts::DefaultInstantiateBaseFee;
+	type MaxDepth = contracts::DefaultMaxDepth;
+	type MaxValueSize = contracts::DefaultMaxValueSize;
+	type BlockGasLimit = contracts::DefaultBlockGasLimit;
+}
+
 parameter_types! {
     pub const TransactionBaseFee: Balance = 0;
     pub const TransactionByteFee: Balance = 1;
@@ -229,7 +272,7 @@
     pub enum Runtime where
         Block = Block,
         NodeBlock = opaque::Block,
-        UncheckedExtrinsic = UncheckedExtrinsic
+        UncheckedExtrinsic = UncheckedExtrinsic,
     {
         System: system::{Module, Call, Config, Storage, Event<T>},
         RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},
@@ -238,7 +281,8 @@
         Grandpa: grandpa::{Module, Call, Storage, Config, Event},
         Balances: balances::{Module, Call, Storage, Config<T>, Event<T>},
         TransactionPayment: transaction_payment::{Module, Storage},
-        Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},
+		Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},
+		Contracts: contracts::{Module, Call, Config<T>, Storage, Event<T>},
         // Used for the module template in `./template.rs`
         Nft: nft::{Module, Call, Storage, Event<T>},
     }
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 }