difftreelog
Smart contract module added
in: master
7 files changed
Cargo.lockdiffbeforeafterboth1982 "sha2",1982 "sha2",1983 "smallvec 1.3.0",1983 "smallvec 1.3.0",1984 "thiserror",1984 "thiserror",1985 "unsigned-varint",1985 "unsigned-varint 0.3.3",1986 "void",1986 "void",1987 "zeroize",1987 "zeroize",1988]1988]2046 "sha2",2046 "sha2",2047 "smallvec 1.3.0",2047 "smallvec 1.3.0",2048 "uint",2048 "uint",2049 "unsigned-varint",2049 "unsigned-varint 0.3.3",2050 "void",2050 "void",2051 "wasm-timer",2051 "wasm-timer",2052]2052]2086 "libp2p-core",2086 "libp2p-core",2087 "log",2087 "log",2088 "parking_lot 0.10.2",2088 "parking_lot 0.10.2",2089 "unsigned-varint",2089 "unsigned-varint 0.3.3",2090]2090]209120912092[[package]]2092[[package]]2437 "sha-1",2437 "sha-1",2438 "sha2",2438 "sha2",2439 "sha3",2439 "sha3",2440 "unsigned-varint",2440 "unsigned-varint 0.3.3",2441]2441]244224422443[[package]]2443[[package]]244824482449[[package]]2449[[package]]2450name = "multistream-select"2450name = "multistream-select"2451version = "0.8.0"2451version = "0.8.2"2452source = "registry+https://github.com/rust-lang/crates.io-index"2452source = "registry+https://github.com/rust-lang/crates.io-index"2453checksum = "74cdcf7cfb3402881e15a1f95116cb033d69b33c83d481e1234777f5ef0c3d2c"2453checksum = "c9157e87afbc2ef0d84cc0345423d715f445edde00141c93721c162de35a05e5"2454dependencies = [2454dependencies = [2455 "bytes 0.5.4",2455 "bytes 0.5.4",2456 "futures 0.3.4",2456 "futures 0.3.4",2457 "log",2457 "log",2458 "pin-project",2458 "pin-project",2459 "smallvec 1.3.0",2459 "smallvec 1.3.0",2460 "unsigned-varint",2460 "unsigned-varint 0.4.0",2461]2461]246224622463[[package]]2463[[package]]2516version = "2.0.0-alpha.6"2516version = "2.0.0-alpha.6"2517dependencies = [2517dependencies = [2518 "futures 0.3.4",2518 "futures 0.3.4",2519 "jsonrpc-core",2519 "log",2520 "log",2520 "nft-runtime",2521 "nft-runtime",2522 "pallet-contracts-rpc",2521 "sc-basic-authorship",2523 "sc-basic-authorship",2522 "sc-cli",2524 "sc-cli",2523 "sc-client",2525 "sc-client",2526 "sc-executor",2528 "sc-executor",2527 "sc-finality-grandpa",2529 "sc-finality-grandpa",2528 "sc-network",2530 "sc-network",2531 "sc-rpc",2529 "sc-service",2532 "sc-service",2530 "sc-transaction-pool",2533 "sc-transaction-pool",2531 "sp-consensus",2534 "sp-consensus",2548 "frame-system",2551 "frame-system",2549 "pallet-aura",2552 "pallet-aura",2550 "pallet-balances",2553 "pallet-balances",2554 "pallet-contracts",2555 "pallet-contracts-primitives",2551 "pallet-grandpa",2556 "pallet-grandpa",2552 "pallet-nft",2557 "pallet-nft",2553 "pallet-randomness-collective-flip",2558 "pallet-randomness-collective-flip",2765 "sp-std",2770 "sp-std",2766]2771]27722773[[package]]2774name = "pallet-contracts"2775version = "2.0.0-alpha.6"2776source = "registry+https://github.com/rust-lang/crates.io-index"2777checksum = "7c2bc13b765baa08a15815c0d836fee239fde73252a6c7babc437796eda561f5"2778dependencies = [2779 "frame-support",2780 "frame-system",2781 "pallet-contracts-primitives",2782 "parity-scale-codec",2783 "parity-wasm",2784 "pwasm-utils",2785 "serde",2786 "sp-core",2787 "sp-io",2788 "sp-runtime",2789 "sp-sandbox",2790 "sp-std",2791 "wasmi-validation",2792]27932794[[package]]2795name = "pallet-contracts-primitives"2796version = "2.0.0-alpha.6"2797source = "registry+https://github.com/rust-lang/crates.io-index"2798checksum = "5216edfd33a69a45bdd79f088563479dfdd6ecfb3c477b0f83955b844251c665"2799dependencies = [2800 "parity-scale-codec",2801 "sp-runtime",2802 "sp-std",2803]28042805[[package]]2806name = "pallet-contracts-rpc"2807version = "0.8.0-alpha.6"2808source = "registry+https://github.com/rust-lang/crates.io-index"2809checksum = "c575d839564073fa5757f9dfe5863b48eb07108ecda63521740b8bd8ed6f05c3"2810dependencies = [2811 "jsonrpc-core",2812 "jsonrpc-core-client",2813 "jsonrpc-derive",2814 "pallet-contracts-primitives",2815 "pallet-contracts-rpc-runtime-api",2816 "parity-scale-codec",2817 "serde",2818 "sp-api",2819 "sp-blockchain",2820 "sp-core",2821 "sp-rpc",2822 "sp-runtime",2823]28242825[[package]]2826name = "pallet-contracts-rpc-runtime-api"2827version = "0.8.0-alpha.6"2828source = "registry+https://github.com/rust-lang/crates.io-index"2829checksum = "747f66dc20367de627c701675c66af0a53b4309df16c9929c0d23d2e27e436ee"2830dependencies = [2831 "pallet-contracts-primitives",2832 "parity-scale-codec",2833 "sp-api",2834 "sp-runtime",2835 "sp-std",2836]276728372768[[package]]2838[[package]]2769name = "pallet-finality-tracker"2839name = "pallet-finality-tracker"2922 "percent-encoding 2.1.0",2992 "percent-encoding 2.1.0",2923 "serde",2993 "serde",2924 "static_assertions",2994 "static_assertions",2925 "unsigned-varint",2995 "unsigned-varint 0.3.3",2926 "url 2.1.1",2996 "url 2.1.1",2927]2997]292829982940 "percent-encoding 2.1.0",3010 "percent-encoding 2.1.0",2941 "serde",3011 "serde",2942 "static_assertions",3012 "static_assertions",2943 "unsigned-varint",3013 "unsigned-varint 0.3.3",2944 "url 2.1.1",3014 "url 2.1.1",2945]3015]294630162956 "sha-1",3026 "sha-1",2957 "sha2",3027 "sha2",2958 "sha3",3028 "sha3",2959 "unsigned-varint",3029 "unsigned-varint 0.3.3",2960]3030]296130312962[[package]]3032[[package]]313732073138[[package]]3208[[package]]3139name = "pin-project"3209name = "pin-project"3140version = "0.4.9"3210version = "0.4.22"3141source = "registry+https://github.com/rust-lang/crates.io-index"3211source = "registry+https://github.com/rust-lang/crates.io-index"3142checksum = "6f6a7f5eee6292c559c793430c55c00aea9d3b3d1905e855806ca4d7253426a2"3212checksum = "12e3a6cdbfe94a5e4572812a0201f8c0ed98c1c452c7b8563ce2276988ef9c17"3143dependencies = [3213dependencies = [3144 "pin-project-internal",3214 "pin-project-internal",3145]3215]314632163147[[package]]3217[[package]]3148name = "pin-project-internal"3218name = "pin-project-internal"3149version = "0.4.9"3219version = "0.4.22"3150source = "registry+https://github.com/rust-lang/crates.io-index"3220source = "registry+https://github.com/rust-lang/crates.io-index"3151checksum = "8988430ce790d8682672117bc06dda364c0be32d3abd738234f19f3240bad99a"3221checksum = "6a0ffd45cf79d88737d7cc85bfd5d2894bee1139b356e616fe85dc389c61aaf7"3152dependencies = [3222dependencies = [3153 "proc-macro2",3223 "proc-macro2",3154 "quote 1.0.3",3224 "quote 1.0.3",3340source = "registry+https://github.com/rust-lang/crates.io-index"3410source = "registry+https://github.com/rust-lang/crates.io-index"3341checksum = "8e86d370532557ae7573551a1ec8235a0f8d6cb276c7c9e6aa490b511c447485"3411checksum = "8e86d370532557ae7573551a1ec8235a0f8d6cb276c7c9e6aa490b511c447485"34123413[[package]]3414name = "pwasm-utils"3415version = "0.12.0"3416source = "registry+https://github.com/rust-lang/crates.io-index"3417checksum = "4f7a12f176deee919f4ba55326ee17491c8b707d0987aed822682c821b660192"3418dependencies = [3419 "byteorder",3420 "log",3421 "parity-wasm",3422]334234233343[[package]]3424[[package]]3344name = "quick-error"3425name = "quick-error"4205 "sp-utils",4286 "sp-utils",4206 "substrate-prometheus-endpoint",4287 "substrate-prometheus-endpoint",4207 "thiserror",4288 "thiserror",4208 "unsigned-varint",4289 "unsigned-varint 0.3.3",4209 "void",4290 "void",4210 "wasm-timer",4291 "wasm-timer",4211 "zeroize",4292 "zeroize",5179 "syn 1.0.17",5260 "syn 1.0.17",5180]5261]52625263[[package]]5264name = "sp-sandbox"5265version = "0.8.0-alpha.6"5266source = "registry+https://github.com/rust-lang/crates.io-index"5267checksum = "6f2441d2ed3b141b74a6eaca28b469420bcd438c3ac43d25eadfe494d905135f"5268dependencies = [5269 "parity-scale-codec",5270 "sp-core",5271 "sp-io",5272 "sp-std",5273 "sp-wasm-interface",5274 "wasmi",5275]518152765182[[package]]5277[[package]]5183name = "sp-serializer"5278name = "sp-serializer"6081 "futures_codec",6176 "futures_codec",6082]6177]61786179[[package]]6180name = "unsigned-varint"6181version = "0.4.0"6182source = "registry+https://github.com/rust-lang/crates.io-index"6183checksum = "669d776983b692a906c881fcd0cfb34271a48e197e4d6cb8df32b05bfc3d3fa5"608361846084[[package]]6185[[package]]6085name = "untrusted"6186name = "untrusted"node/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'
node/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()
+ },
+ }),
}
}
pallets/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 = [
runtime/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',
runtime/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>},
}
smart_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 }