Skip to content

Commit

Permalink
Merge pull request #1 from mangata-finance/feature/bridge
Browse files Browse the repository at this point in the history
Feature/bridge
  • Loading branch information
gleb-urvanov committed Nov 26, 2020
2 parents 7845f91 + 4585979 commit 04ccae9
Show file tree
Hide file tree
Showing 39 changed files with 2,624 additions and 8 deletions.
194 changes: 193 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ Find manual setup instructions at the

### Local target

Recommended rustc version for the build is `nightly-2020-10-01`

Environment variables for ethereum apps should be set up before the build:
```bash
ETH_APP_ID=0xdd514baa317bf095ddba2c0a847765feb389c6a0
ENV ERC20_APP_ID=0x00e392c04743359e39f00cd268a5390d27ef6b44
```
build node:
```bash
cargo build --release
```
Expand Down
7 changes: 6 additions & 1 deletion devops/dockerfiles/node-and-runtime/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ LABEL description="Compiles all workspace artifacts"
WORKDIR /mangata
COPY . /mangata

RUN WASM_BUILD_TOOLCHAIN=nightly-2020-05-23 cargo build --release
ENV ETH_APP_ID=0xdd514baa317bf095ddba2c0a847765feb389c6a0
ENV ERC20_APP_ID=0x00e392c04743359e39f00cd268a5390d27ef6b44

RUN rustup toolchain install nightly-2020-10-01
RUN rustup target add wasm32-unknown-unknown --toolchain nightly-2020-10-01
RUN WASM_BUILD_TOOLCHAIN=nightly-2020-10-01 cargo build --release

FROM debian:stretch
LABEL description="mangata node"
Expand Down
2 changes: 1 addition & 1 deletion devops/dockerfiles/rust-builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM liuchong/rustup:1.46.0 AS builder
FROM liuchong/rustup:1.45.2 AS builder
LABEL description="Rust and WASM build environment for mangata and substrate"

WORKDIR /setup
Expand Down
11 changes: 10 additions & 1 deletion node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use sp_core::{Pair, Public, sr25519};
use mangata_runtime::{
AccountId, BabeConfig, BalancesConfig, GenesisConfig, GrandpaConfig, SessionConfig,
SudoConfig, SystemConfig, WASM_BINARY, Signature, StakerStatus, StakingConfig, SessionKeys
SudoConfig, SystemConfig, WASM_BINARY, Signature, StakerStatus, StakingConfig, SessionKeys, VerifierConfig
};
use sp_consensus_babe::{AuthorityId as BabeId};
use sp_finality_grandpa::AuthorityId as GrandpaId;
Expand Down Expand Up @@ -63,6 +63,8 @@ pub fn development_config() -> Result<ChainSpec, String> {
vec![
authority_keys_from_seed("Alice"),
],
// Initial relay account
get_account_id_from_seed::<sr25519::Public>("Relay"),
// Sudo account
get_account_id_from_seed::<sr25519::Public>("Alice"),
// Pre-funded accounts
Expand All @@ -71,6 +73,7 @@ pub fn development_config() -> Result<ChainSpec, String> {
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Relay"),
],
true,
),
Expand Down Expand Up @@ -103,6 +106,8 @@ pub fn local_testnet_config() -> Result<ChainSpec, String> {
authority_keys_from_seed("Alice"),
authority_keys_from_seed("Bob"),
],
// Initial relay account
get_account_id_from_seed::<sr25519::Public>("Relay"),
// Sudo account
get_account_id_from_seed::<sr25519::Public>("Alice"),
// Pre-funded accounts
Expand Down Expand Up @@ -139,6 +144,7 @@ pub fn local_testnet_config() -> Result<ChainSpec, String> {
fn testnet_genesis(
wasm_binary: &[u8],
initial_authorities: Vec<(BabeId, GrandpaId, AccountId)>,
relay_key: AccountId,
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
_enable_println: bool,
Expand Down Expand Up @@ -181,5 +187,8 @@ fn testnet_genesis(
// Assign network admin rights.
key: root_key,
}),
verifier: Some(VerifierConfig {
key: relay_key,
}),
}
}
13 changes: 13 additions & 0 deletions pallets/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,27 @@ impl<T: Trait> Module<T> {
Ok(())
}

pub fn assets_issue(origin: &T::AccountId, total: &T::Balance) -> T::AssetId {
let id = Self::next_asset_id();
<NextAssetId<T>>::mutate(|id| *id += One::one());

<Balances<T>>::insert((id, &origin), total);
<TotalSupply<T>>::insert(id, total);

// Self::deposit_event(RawEvent::Issued(id, origin, total));
id
}

pub fn assets_mint(id: &T::AssetId, to: &T::AccountId, amount: &T::Balance) -> T::Balance {
<Balances<T>>::mutate((id, to), |balance| *balance += *amount);
<TotalSupply<T>>::mutate((id), |total| *total += *amount);
<Balances<T>>::get((id, to))
}

pub fn assets_burn(id: &T::AssetId, to: &T::AccountId, amount: &T::Balance) -> T::Balance {
//TODO ensure amount
<Balances<T>>::mutate((id, to), |balance| *balance -= *amount);
<TotalSupply<T>>::mutate((id), |total| *total -= *amount);
<Balances<T>>::get((id, to))
}
}
Expand Down
Loading

0 comments on commit 04ccae9

Please sign in to comment.