Skip to content
Permalink
Browse files

add more chain information

  • Loading branch information...
thanhson1085 committed Dec 20, 2017
1 parent cd890d9 commit 49f49f5b591e15d4f29e9200280ee69b77cfc0a2
Showing with 61 additions and 26 deletions.
  1. +29 −9 app/App.vue
  2. +13 −1 models/blockchain/index.js
  3. +19 −16 sockets/index.js
@@ -5,16 +5,20 @@
<div class="logo">
<img src="https://tomocoin-ico.herokuapp.com/img/logo.svg">
</div>
<md-card class="md-primary" md-with-hover>
<md-card class="md-primary welcome-board" md-with-hover>
<md-ripple>
<md-card-header>
<div class="md-title">Welcome to TomoWallet</div>
<div class="md-subhead">Testnet mode</div>
</md-card-header>

<md-card-content>
The Tomowallet works on two blockchain. The first one is <a href="https://stats.tomocoin.io" targe="_blank">Tomochain</a> - <b>Zero fee</b> and <b>Instant confirmation</b>. The second one is <a href="https://www.rinkeby.io">Rinkeby</a>.
<br/>
The Tomowallet works on two blockchain. The first one is <a href="https://stats.tomocoin.io" target="_blank"><b>Tomochain</b></a> (zero fee and Instant confirmation). The second one is <a href="https://www.rinkeby.io" target="_blank"><b>Ethereum Rinkeby</b></a>.
</md-card-content>
<md-card-content>
This demo will show you how to earn Tomocoins (TMC) from RewardEngine, how to transfer TMC from Tomochain to Ethereum (CashOut) and how to transfer TMC from Ethereum from Tomochain.
</md-card-content>
<md-card-content>
Create a new wallet and let's experience!
</md-card-content>

@@ -57,6 +61,18 @@
:md-content="`Make it safe: <br/><strong>${walletMnemonic}</strong>`" />
</div>
</div>
<md-dialog :md-active.sync="showMainchainInformation">
<md-dialog-title>Ethereum Rinkeby</md-dialog-title>
<md-content>
<p>Tomocoin Smart Contract: <a target='_blank' :href="'https://rinkeby.etherscan.io/token/' + mainchainInformation.tmcAddress">{{ mainchainInformation.tmcAddress }}</a></p>
<p>CashOut Smart Contract: <a target='_blank' :href="'https://rinkeby.etherscan.io/address/' + mainchainInformation.cashOutAddress">{{ mainchainInformation.cashOutAddress }}</a></p>
<p>CashIn Smart Contract: <a target='_blank' :href="'https://rinkeby.etherscan.io/address/' + mainchainInformation.cashInAddress">{{ mainchainInformation.cashInAddress }}</a></p>
<p>Do not send ethers nor tokens to any of the addresses above. They are for test only and we are not likely to have control of them in mainnet.</p>
</md-content>
<md-dialog-actions>
<md-button class="md-primary" @click="showMainchainInformation = false">Close</md-button>
</md-dialog-actions>
</md-dialog>

<div class="sumaryCoin">
<h3>You have total:</h3>
@@ -127,7 +143,8 @@
</md-card-header-text>
</md-card-header>
<md-card-content>
The coins you have in <strong class="main-chain">ethereum</strong>. You can transfer the coins to <strong class="side-chain">tomochain</strong> by clicking <strong>cash in</strong> button.
The coins you have in <strong class="main-chain">ethereum</strong>. You can transfer the coins to <strong class="side-chain">tomochain</strong> by clicking <strong>cash in</strong> button. <a @click="showMainchainInformation = true" href="#">View more ></a>
</md-button>
</md-card-content>
</md-card>
</div>
@@ -217,11 +234,6 @@ import axios from 'axios';
import VueSocketio from 'vue-socket.io';
import { default as Web3} from 'web3';
import { default as contract } from 'truffle-contract'
import RewardEngineArtifacts from '../build/contracts/RewardEngine.json'
import bip39 from 'bip39'
import hdkey from 'ethereumjs-wallet/hdkey'
@@ -252,12 +264,14 @@ export default {
showAlert: false,
showPrivateKey: false,
showBackupKey: false,
showMainchainInformation: false,
msgAlert: '',
expandSumaryCoin: false,
state: localStorage.wallet ? 'mainScreen' : 'getStart',
walletAddress: walletAddress,
walletPrivateKey: walletPrivateKey,
walletMnemonic: walletMnemonic,
mainchainInformation: '',
tmcSidechain: 0,
tmcMainchain: 0,
cashOutValue: '',
@@ -295,7 +309,10 @@ export default {
this.$socket.emit('user', {address: this.walletAddress})
},
user: function(user){
console.log(user);
this.logs = user.logs;
this.mainchainInformation = user.mainchainInformation;
this.sidechainInformation = user.sidechainInformation;
this.tmcSidechain = parseFloat(user.tmcSidechain);
this.tmcMainchain = parseFloat(user.tmcMainchain);
localStorage.logs = JSON.stringify(this.logs);
@@ -577,4 +594,7 @@ export default {
font-size: 15px !important;
color: inherit;
}
.welcome-board a {
color: white !important;
}
</style>
@@ -38,6 +38,17 @@ CashInMainchain.setProvider(mainchain);
const rootAddressSidechain = config.get('rootAddressSidechain');
const rootAddressMainchain = config.get('rootAddressMainchain');

const getMainchainAddresses = () => {
const ret = {};
return TomoCoinMainchain.deployed().then(tc => {
ret.tmcAddress = tc.address;
return CashOutMainchain.deployed().then(com => {
ret.cashOutAddress = com.address;
return ret;
});
});
};

module.exports = {
RewardEngine,
TomoCoinSidechain,
@@ -47,5 +58,6 @@ module.exports = {
CashInSidechain,
CashInMainchain,
rootAddressSidechain,
rootAddressMainchain
rootAddressMainchain,
getMainchainAddresses
};
@@ -10,7 +10,8 @@ const {RewardEngine,
CashInSidechain,
CashInMainchain,
TomoCoinSidechain,
TomoCoinMainchain
TomoCoinMainchain,
getMainchainAddresses
} = require('../models/blockchain');

const q = require('../queues');
@@ -122,21 +123,23 @@ const sockets = (io) => {
db.Wallet.findOne({
walletAddress: data.address
}).then(w => {
if (!w) return false;
socket.emit('user', {
tmcSidechain: parseFloat(w.tmcSidechain || 0),
tmcMainchain: parseFloat(w.tmcMainchain || 0),
logs: w.logs.map(l => {
return {
msg: l.message,
type: l.type,
change: l.change,
time: l.time,
tmcSidechain: parseFloat(l.tmcSidechain),
tmcMainchain: parseFloat(l.tmcMainchain),
total: parseFloat(l.tmcSidechain) + parseFloat(l.tmcMainchain)
}
})
getMainchainAddresses().then(addresses => {
socket.emit('user', {
mainchainInformation: addresses,
tmcSidechain: parseFloat((w || {}).tmcSidechain || 0),
tmcMainchain: parseFloat((w || {}).tmcMainchain || 0),
logs: ((w || {}).logs || []).map(l => {
return {
msg: l.message,
type: l.type,
change: l.change,
time: l.time,
tmcSidechain: parseFloat(l.tmcSidechain),
tmcMainchain: parseFloat(l.tmcMainchain),
total: parseFloat(l.tmcSidechain) + parseFloat(l.tmcMainchain)
}
})
});
});
});
socket.join(data.address);

0 comments on commit 49f49f5

Please sign in to comment.
You can’t perform that action at this time.