git.delta.rocks / unique-network / refs/commits / fd7a9f1bafd1

difftreelog

A working transfer through smart contract

Greg Zaitsev2020-07-16parent: #97765fe.patch.diff
in: master

15 files changed

addedDockerfile-productiondiffbeforeafterboth
--- /dev/null
+++ b/Dockerfile-production
@@ -0,0 +1,47 @@
+# ===== BUILD ======
+
+FROM phusion/baseimage:0.10.2 as builder
+LABEL maintainer="gz@usetech.com"
+
+ENV WASM_TOOLCHAIN=nightly-2020-05-01
+
+ARG PROFILE=release
+
+RUN apt-get update && \
+	apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold" && \
+	apt-get install -y cmake pkg-config libssl-dev git clang
+
+# Get project and run it
+#RUN git clone https://github.com/usetech-llc/nft_parachain /nft_parachain
+RUN mkdir nft_parachain
+WORKDIR /nft_parachain
+COPY . .
+
+RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \
+	export PATH="$PATH:$HOME/.cargo/bin" && \
+	rustup toolchain uninstall $(rustup toolchain list) && \
+	rustup default 1.44.0 && \
+	rustup toolchain install $WASM_TOOLCHAIN && \
+	rustup target add wasm32-unknown-unknown --toolchain $WASM_TOOLCHAIN && \
+    rustup target list --installed && \
+    rustup show && \
+	cargo build "--$PROFILE" 
+	# && \
+	# cargo test
+
+RUN cd target/release && ls -la
+
+# ===== RUN ======
+
+FROM phusion/baseimage:0.10.2
+ARG PROFILE=release
+
+COPY --from=builder /nft_parachain/target/$PROFILE/nft /usr/local/bin
+
+EXPOSE 9944
+VOLUME ["/chain-data"]
+
+# Copy and run start script
+COPY ["./run.sh", "./run.sh"]
+RUN chmod +x ./run.sh
+CMD ["bash", "-c", "./run.sh"]
addedchain-data-einstein/$NODEdiffbeforeafterboth

no changes

addedchain-data-einstein/asdfdiffbeforeafterboth

no changes

addedchain-data-einstein/{$NODE}diffbeforeafterboth

no changes

addedchain-data-newton/$NODEdiffbeforeafterboth

no changes

addedchain-data-newton/asdfdiffbeforeafterboth

no changes

addedchain-data-newton/{$NODE}diffbeforeafterboth

no changes

addeddocker-compose-production.ymldiffbeforeafterboth
--- /dev/null
+++ b/docker-compose-production.yml
@@ -0,0 +1,35 @@
+version: "3.5"
+
+services:
+  node_einstein:
+    image: nft-parachain
+    ports:
+      - 9944:9944
+    build:
+      context: ./
+      dockerfile: Dockerfile-production
+    volumes:
+      - ./chain-data-einstein:/chain-data
+    networks: 
+      - substrate_network
+    environment:
+      - NODE=einstein
+
+  node_newton:
+    image: nft-parachain
+    ports:
+      - 9945:9944
+    build:
+      context: ./
+      dockerfile: Dockerfile-production
+    volumes:
+      - ./chain-data-newton:/chain-data
+    networks: 
+      - substrate_network
+    environment:
+      - NODE=newton
+
+networks: 
+  substrate_network:
+    driver: bridge
+    name: substrate_network
modifiednode/src/chain_spec.rsdiffbeforeafterboth
--- a/node/src/chain_spec.rs
+++ b/node/src/chain_spec.rs
@@ -104,7 +104,7 @@
     initial_authorities: Vec<(AuraId, GrandpaId)>,
     root_key: AccountId,
     endowed_accounts: Vec<AccountId>,
-    _enable_println: bool,
+    enable_println: bool,
 ) -> GenesisConfig {
     GenesisConfig {
         system: Some(SystemConfig {
@@ -130,7 +130,7 @@
         sudo: Some(SudoConfig { key: root_key }),
         contracts: Some(ContractsConfig {
             current_schedule: ContractsSchedule {
-                // enable_println,
+                enable_println,
                 ..Default::default()
             },
         }),
modifiedruntime/src/lib.rsdiffbeforeafterboth
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -239,11 +239,15 @@
     type AccountStore = System;
 }
 
+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 = 1;
-    pub const RentByteFee: Balance = 1;
-    pub const RentDepositOffset: Balance = 1000;
-    pub const SurchargeReward: Balance = 150;
+    pub const TombstoneDeposit: Balance = 16 * MILLICENTS;
+    pub const RentByteFee: Balance = 4 * MILLICENTS;
+    pub const RentDepositOffset: Balance = 1000 * MILLICENTS;
+    pub const SurchargeReward: Balance = 150 * MILLICENTS;
 }
 
 impl contracts::Trait for Runtime {
deletedsmart_contract/ink-types-node-runtime/Cargo.lockdiffbeforeafterboth

no changes

modifiedsmart_contract/ink-types-node-runtime/Cargo.tomldiffbeforeafterboth
--- a/smart_contract/ink-types-node-runtime/Cargo.toml
+++ b/smart_contract/ink-types-node-runtime/Cargo.toml
@@ -35,7 +35,7 @@
 
 
 [dev-dependencies]
-node-runtime = { git = "https://github.com/paritytech/substrate/", package = "node-runtime", features = ["std"] }
+node-runtime = { git = "https://github.com/usetech-llc/nft_parachain/", package = "nft", features = ["std"] }
 
 [features]
 default = ["std"]
modifiedsmart_contract/ink-types-node-runtime/examples/calls/lib.rsdiffbeforeafterboth
--- a/smart_contract/ink-types-node-runtime/examples/calls/lib.rs
+++ b/smart_contract/ink-types-node-runtime/examples/calls/lib.rs
@@ -4,8 +4,8 @@
 
 #[ink::contract(version = "0.1.0", env = NodeRuntimeTypes)]
 mod calls {
-    // use ink_core::env;
-    // use ink_prelude::*;
+    use ink_core::env;
+    use ink_prelude::*;
     use ink_types_node_runtime::{calls as runtime_calls, NodeRuntimeTypes};
 
     /// This simple dummy contract dispatches substrate runtime calls
@@ -23,13 +23,14 @@
             let transfer_call = runtime_calls::transfer_balance(dest, value);
             // dispatch the call to the runtime
             let result = self.env().invoke_runtime(&transfer_call);
+            // let _ = self.env().invoke_runtime(&transfer_call);
 
             // report result to console
             // NOTE: println should only be used on a development chain)
-            // env::println(&format!(
-            //     "Balance transfer invoke_runtime result {:?}",
-            //     result
-            // ));
+            env::println(&format!(
+                "Balance transfer invoke_runtime result {:?}",
+                result
+            ));
         }
     }
 
modifiedsmart_contract/ink-types-node-runtime/src/calls.rsdiffbeforeafterboth
--- a/smart_contract/ink-types-node-runtime/src/calls.rs
+++ b/smart_contract/ink-types-node-runtime/src/calls.rs
@@ -18,7 +18,7 @@
 use scale::{Codec, Decode, Encode};
 use pallet_indices::address::Address;
 use sp_runtime::traits::Member;
-use crate::{AccountId, AccountIndex, Balance, NodeRuntimeTypes};
+use crate::{AccountId, Balance, NodeRuntimeTypes};
 
 /// Default runtime Call type, a subset of the runtime Call module variants
 ///
@@ -26,41 +26,34 @@
 #[derive(Encode, Decode)]
 #[cfg_attr(feature = "std", derive(Clone, PartialEq, Eq))]
 pub enum Call {
-    #[codec(index = "6")]
-    Balances(Balances<NodeRuntimeTypes, AccountIndex>),
+    #[codec(index = "5")]
+    Balances(Balances<NodeRuntimeTypes>),
 }
 
-impl From<Balances<NodeRuntimeTypes, AccountIndex>> for Call {
-    fn from(balances_call: Balances<NodeRuntimeTypes, AccountIndex>) -> Call {
+impl From<Balances<NodeRuntimeTypes>> for Call {
+    fn from(balances_call: Balances<NodeRuntimeTypes>) -> Call {
         Call::Balances(balances_call)
     }
 }
 /// Generic Balance Call, could be used with other runtimes
 #[derive(Encode, Decode, Clone, PartialEq, Eq)]
-pub enum Balances<T, AccountIndex>
+pub enum Balances<T>
 where
     T: EnvTypes,
     T::AccountId: Member + Codec,
-    AccountIndex: Member + Codec,
 {
     #[allow(non_camel_case_types)]
-    transfer(Address<T::AccountId, AccountIndex>, #[codec(compact)] T::Balance),
-    #[allow(non_camel_case_types)]
-    set_balance(
-        Address<T::AccountId, AccountIndex>,
-        #[codec(compact)] T::Balance,
-        #[codec(compact)] T::Balance,
-    ),
+    transfer(T::AccountId, #[codec(compact)] T::Balance),
 }
 
 /// Construct a `Balances::transfer` call
 pub fn transfer_balance(account: AccountId, balance: Balance) -> Call {
-    Balances::<NodeRuntimeTypes, AccountIndex>::transfer(account.into(), balance).into()
+    Balances::<NodeRuntimeTypes>::transfer(account.into(), balance).into()
 }
 
 #[cfg(test)]
 mod tests {
-    use crate::{calls, AccountIndex, NodeRuntimeTypes};
+    use crate::{calls, NodeRuntimeTypes};
     use super::Call;
 
     use node_runtime::{self, Runtime};
@@ -75,7 +68,7 @@
 
         let contract_address = calls::Address::Index(account_index);
         let contract_transfer =
-            calls::Balances::<NodeRuntimeTypes, AccountIndex>::transfer(contract_address, balance);
+            calls::Balances::<NodeRuntimeTypes>::transfer(contract_address, balance);
         let contract_call = Call::Balances(contract_transfer);
 
         let srml_address = address::Address::Index(account_index);
addedsubkeydiffbeforeafterboth
--- /dev/null
+++ b/subkey
@@ -0,0 +1,3 @@
+01 sign -h 0x77ed68cbf9574e08209800f223bf8f4ba67fd3707f4e8c10c7486c5a2479bc94
+01 sign -h 0x77ed68cbf9574e08209800f223bf8f4ba67fd3707f4e8c10c7486c5a2479bc94
+01 sign -h 0x77ed68cbf9574e08209800f223bf8f4ba67fd3707f4e8c10c7486c5a2479bc94