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
before · Cargo.lock
552 packageslockfile v1
after · Cargo.lock
559 packageslockfile v1
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
--- 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 }