difftreelog
A working transfer through smart contract
in: master
15 files changed
Dockerfile-productiondiffbeforeafterbothno changes
chain-data-einstein/$NODEdiffbeforeafterbothno syntactic changes
chain-data-einstein/asdfdiffbeforeafterbothno syntactic changes
chain-data-einstein/{$NODE}diffbeforeafterbothno syntactic changes
chain-data-newton/$NODEdiffbeforeafterbothno syntactic changes
chain-data-newton/asdfdiffbeforeafterbothno syntactic changes
chain-data-newton/{$NODE}diffbeforeafterbothno syntactic changes
docker-compose-production.ymldiffbeforeafterbothno changes
node/src/chain_spec.rsdiffbeforeafterboth104 initial_authorities: Vec<(AuraId, GrandpaId)>,104 initial_authorities: Vec<(AuraId, GrandpaId)>,105 root_key: AccountId,105 root_key: AccountId,106 endowed_accounts: Vec<AccountId>,106 endowed_accounts: Vec<AccountId>,107 _enable_println: bool,107 enable_println: bool,108) -> GenesisConfig {108) -> GenesisConfig {109 GenesisConfig {109 GenesisConfig {110 system: Some(SystemConfig {110 system: Some(SystemConfig {130 sudo: Some(SudoConfig { key: root_key }),130 sudo: Some(SudoConfig { key: root_key }),131 contracts: Some(ContractsConfig {131 contracts: Some(ContractsConfig {132 current_schedule: ContractsSchedule {132 current_schedule: ContractsSchedule {133 // enable_println,133 enable_println,134 ..Default::default()134 ..Default::default()135 },135 },136 }),136 }),runtime/src/lib.rsdiffbeforeafterboth239 type AccountStore = System;239 type AccountStore = System;240}240}241242pub const MILLICENTS: Balance = 1_000_000_000;243pub const CENTS: Balance = 1_000 * MILLICENTS;244pub const DOLLARS: Balance = 100 * CENTS;241245242parameter_types! {246parameter_types! {243 pub const TombstoneDeposit: Balance = 1;247 pub const TombstoneDeposit: Balance = 16 * MILLICENTS;244 pub const RentByteFee: Balance = 1;248 pub const RentByteFee: Balance = 4 * MILLICENTS;245 pub const RentDepositOffset: Balance = 1000;249 pub const RentDepositOffset: Balance = 1000 * MILLICENTS;246 pub const SurchargeReward: Balance = 150;250 pub const SurchargeReward: Balance = 150 * MILLICENTS;247}251}248252249impl contracts::Trait for Runtime {253impl contracts::Trait for Runtime {smart_contract/ink-types-node-runtime/Cargo.lockdiffbeforeafterbothno changes
smart_contract/ink-types-node-runtime/Cargo.tomldiffbeforeafterboth3535363637[dev-dependencies]37[dev-dependencies]38node-runtime = { git = "https://github.com/paritytech/substrate/", package = "node-runtime", features = ["std"] }38node-runtime = { git = "https://github.com/usetech-llc/nft_parachain/", package = "nft", features = ["std"] }393940[features]40[features]41default = ["std"]41default = ["std"]smart_contract/ink-types-node-runtime/examples/calls/lib.rsdiffbeforeafterboth445#[ink::contract(version = "0.1.0", env = NodeRuntimeTypes)]5#[ink::contract(version = "0.1.0", env = NodeRuntimeTypes)]6mod calls {6mod calls {7 // use ink_core::env;7 use ink_core::env;8 // use ink_prelude::*;8 use ink_prelude::*;9 use ink_types_node_runtime::{calls as runtime_calls, NodeRuntimeTypes};9 use ink_types_node_runtime::{calls as runtime_calls, NodeRuntimeTypes};101011 /// This simple dummy contract dispatches substrate runtime calls11 /// This simple dummy contract dispatches substrate runtime calls23 let transfer_call = runtime_calls::transfer_balance(dest, value);23 let transfer_call = runtime_calls::transfer_balance(dest, value);24 // dispatch the call to the runtime24 // dispatch the call to the runtime25 let result = self.env().invoke_runtime(&transfer_call);25 let result = self.env().invoke_runtime(&transfer_call);26 // let _ = self.env().invoke_runtime(&transfer_call);262727 // report result to console28 // report result to console28 // NOTE: println should only be used on a development chain)29 // NOTE: println should only be used on a development chain)29 // env::println(&format!(30 env::println(&format!(30 // "Balance transfer invoke_runtime result {:?}",31 "Balance transfer invoke_runtime result {:?}",31 // result32 result32 // ));33 ));33 }34 }34 }35 }3536smart_contract/ink-types-node-runtime/src/calls.rsdiffbeforeafterboth18use scale::{Codec, Decode, Encode};18use scale::{Codec, Decode, Encode};19use pallet_indices::address::Address;19use pallet_indices::address::Address;20use sp_runtime::traits::Member;20use sp_runtime::traits::Member;21use crate::{AccountId, AccountIndex, Balance, NodeRuntimeTypes};21use crate::{AccountId, Balance, NodeRuntimeTypes};222223/// Default runtime Call type, a subset of the runtime Call module variants23/// Default runtime Call type, a subset of the runtime Call module variants24///24///25/// The codec indices of the modules *MUST* match those in the concrete runtime.25/// The codec indices of the modules *MUST* match those in the concrete runtime.26#[derive(Encode, Decode)]26#[derive(Encode, Decode)]27#[cfg_attr(feature = "std", derive(Clone, PartialEq, Eq))]27#[cfg_attr(feature = "std", derive(Clone, PartialEq, Eq))]28pub enum Call {28pub enum Call {29 #[codec(index = "6")]29 #[codec(index = "5")]30 Balances(Balances<NodeRuntimeTypes, AccountIndex>),30 Balances(Balances<NodeRuntimeTypes>),31}31}323233impl From<Balances<NodeRuntimeTypes, AccountIndex>> for Call {33impl From<Balances<NodeRuntimeTypes>> for Call {34 fn from(balances_call: Balances<NodeRuntimeTypes, AccountIndex>) -> Call {34 fn from(balances_call: Balances<NodeRuntimeTypes>) -> Call {35 Call::Balances(balances_call)35 Call::Balances(balances_call)36 }36 }37}37}38/// Generic Balance Call, could be used with other runtimes38/// Generic Balance Call, could be used with other runtimes39#[derive(Encode, Decode, Clone, PartialEq, Eq)]39#[derive(Encode, Decode, Clone, PartialEq, Eq)]40pub enum Balances<T, AccountIndex>40pub enum Balances<T>41where41where42 T: EnvTypes,42 T: EnvTypes,43 T::AccountId: Member + Codec,43 T::AccountId: Member + Codec,44 AccountIndex: Member + Codec,45{44{46 #[allow(non_camel_case_types)]45 #[allow(non_camel_case_types)]47 transfer(Address<T::AccountId, AccountIndex>, #[codec(compact)] T::Balance),46 transfer(T::AccountId, #[codec(compact)] T::Balance),48 #[allow(non_camel_case_types)]49 set_balance(50 Address<T::AccountId, AccountIndex>,51 #[codec(compact)] T::Balance,52 #[codec(compact)] T::Balance,53 ),54}47}554856/// Construct a `Balances::transfer` call49/// Construct a `Balances::transfer` call57pub fn transfer_balance(account: AccountId, balance: Balance) -> Call {50pub fn transfer_balance(account: AccountId, balance: Balance) -> Call {58 Balances::<NodeRuntimeTypes, AccountIndex>::transfer(account.into(), balance).into()51 Balances::<NodeRuntimeTypes>::transfer(account.into(), balance).into()59}52}605361#[cfg(test)]54#[cfg(test)]62mod tests {55mod tests {63 use crate::{calls, AccountIndex, NodeRuntimeTypes};56 use crate::{calls, NodeRuntimeTypes};64 use super::Call;57 use super::Call;655866 use node_runtime::{self, Runtime};59 use node_runtime::{self, Runtime};756876 let contract_address = calls::Address::Index(account_index);69 let contract_address = calls::Address::Index(account_index);77 let contract_transfer =70 let contract_transfer =78 calls::Balances::<NodeRuntimeTypes, AccountIndex>::transfer(contract_address, balance);71 calls::Balances::<NodeRuntimeTypes>::transfer(contract_address, balance);79 let contract_call = Call::Balances(contract_transfer);72 let contract_call = Call::Balances(contract_transfer);807381 let srml_address = address::Address::Index(account_index);74 let srml_address = address::Address::Index(account_index);subkeydiffbeforeafterbothno changes