Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
issue #17
Browse files Browse the repository at this point in the history
  • Loading branch information
vmangelovv committed Jul 9, 2019
1 parent 5c5f462 commit b66bd10
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 50 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Expand Up @@ -5,4 +5,9 @@
/bower_components
/.history
/cypress
/.nyc_output
/.nyc_output
*.png
*.png
tests/e2e/screenshots/accountPage.js/Test cases for Account Page -- can logout and login again (failed).png
tests/e2e/screenshots/accountPage.js/Test cases for Account Page -- can logout and login again (failed).png
tests/e2e/screenshots/accountPage.js/Test cases for Account Page -- can logout and login again (failed).png
24 changes: 14 additions & 10 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -48,6 +48,8 @@
"node-fetch": "^2.3.0",
"nyc": "^14.1.1",
"qrcode.vue": "^1.6.1",
"request": "^2.88.0",
"request-promise": "^4.2.4",
"sass-loader": "^7.1.0",
"tweetnacl": "^1.0.1",
"uuid": "^3.3.2",
Expand Down
35 changes: 19 additions & 16 deletions src/popup/App.vue
Expand Up @@ -165,7 +165,7 @@ export default {
account: false,
languages: false
},
mainLoading: true
mainLoading: true,
}
},
computed: {
Expand All @@ -178,21 +178,21 @@ export default {
}
},
created: function () {
browser.storage.sync.set({language: 'en'}).then(() => {
this.language = locales['en'];
});
// browser.storage.sync.get('language', langChoose => {
// this.language = locales[langChoose.language];
// });
// fetch api one time
let states = this.$store.state;
if (typeof states.aeAPI == 'undefined') {
this.$store.state.aeAPI = this.fetchApi();
}
browser.storage.sync.set({language: 'en'}).then(() => {
this.language = locales['en'];
});
// browser.storage.sync.get('language', langChoose => {
// this.language = locales[langChoose.language];
// });
// fetch api one time
let states = this.$store.state;
if (typeof states.aeAPI == 'undefined') {
this.$store.state.aeAPI = this.fetchApi();
}
},
mounted: function mounted () {
this.hideLoader();
this.dropdown.settings = false;
this.dropdown.settings = false; this.dropdown.languages = false;
},
methods: {
hideLoader() {
Expand All @@ -204,6 +204,7 @@ export default {
changeAccount (index,subaccount) {
browser.storage.sync.set({activeAccount: index}).then(() => {
this.$store.commit('SET_ACTIVE_ACCOUNT', {publicKey:subaccount.publicKey,index:index});
this.dropdown.account = false;
});
},
hideMenu (event) {
Expand Down Expand Up @@ -252,7 +253,7 @@ export default {
browser.storage.sync.set({isLogged: false}).then(() => {
browser.storage.sync.set({wallet: ''}).then(() => {
browser.storage.sync.set({activeAccount: 0}).then(() => {
this.dropdown.settings = false;
this.dropdown.settings = false; this.dropdown.languages = false;
this.dropdown.account = false;
this.$store.commit('SET_ACTIVE_ACCOUNT', {publicKey:'',index:0});
this.$store.commit('UNSET_SUBACCOUNTS');
Expand All @@ -276,11 +277,11 @@ export default {
this.$store.dispatch('popupAlert', payload)
},
myAccount () {
this.dropdown.settings = false;
this.dropdown.settings = false; this.dropdown.languages = false;
this.$router.push('/account');
},
settings () {
this.dropdown.settings = false;
this.dropdown.settings = false; this.dropdown.languages = false;
this.$router.push('/settings');
},
manageAccounts () {
Expand All @@ -291,6 +292,7 @@ export default {
let blobData = JSON.stringify({"publicKey": this.account.publicKey, "secretKey": this.account.secretKey});
let blob = new Blob([blobData], {type: "application/json;charset=utf-8"});
saveAs(blob, "keypair.json");
this.dropdown.settings = false; this.dropdown.languages = false;
}else if(type == 'keystore') {
let blobData = "";
try {
Expand All @@ -300,6 +302,7 @@ export default {
}
let blob = new Blob([blobData], {type: "application/json;charset=utf-8"});
saveAs(blob, "keystore.json");
this.dropdown.settings = false; this.dropdown.languages = false;
}
},
popupSecondBtnClick(){
Expand Down
77 changes: 74 additions & 3 deletions src/popup/router/pages/Account.vue
@@ -1,6 +1,16 @@
<template>
<div class="popup">
<h3>{{language.pages.account.heading}}</h3>
<div class="currenciesgroup">
<div class="inputGroup-currencies">
<div class="input-group-icon">$</div>
<div class="input-group-area"><input disabled type="text" :value=toUsd></div>
</div>
<div class="inputGroup-currencies">
<div class="input-group-icon">€</div>
<div class="input-group-area"><input disabled type="text" :value=toEur></div>
</div>
</div>
<ae-card fill="primary">
<template slot="avatar">
<ae-identicon :address="account.publicKey" />
Expand Down Expand Up @@ -45,9 +55,11 @@
import Ae from '@aeternity/aepp-sdk/es/ae/universal';
import { mapGetters } from 'vuex';
import locales from '../../locales/locales.json';
import { setInterval, setTimeout, setImmediate } from 'timers';
import { setInterval, setTimeout, setImmediate, clearInterval } from 'timers';
import { getTranscationByPublicAddress } from '../../utils/transactions';
import { getHdWalletAccount } from '../../utils/hdWallet';
import { request } from 'http';
import { fetchData } from '../../utils/helper';
export default {
name: 'Account',
data () {
Expand All @@ -56,7 +68,12 @@ export default {
language: locales['en'],
loading:true,
accountName:'',
pollingTransaction:null
pollingTransaction:null,
toUsd: null,
toEur: null,
timer: '',
eurRate: '',
usdRate: '',
}
},
computed: {
Expand All @@ -79,10 +96,11 @@ export default {
},
created () {
this.pollData();
this.currencyConv();
},
mounted(){
this.updateTransactions();
},
},
methods: {
showAllTranactions() {
this.$router.push('/transactions');
Expand All @@ -91,12 +109,37 @@ export default {
this.polling = setInterval(() => {
this.$store.dispatch('updateBalance');
// this.$store.dispatch('updateBalanceSubaccounts');
this.toUsd = this.balance * this.usdRate;
this.toEur = this.balance * this.eurRate;
}, 1000);
this.pollingTransaction = setInterval(() => {
this.$store.dispatch('updateBalanceSubaccounts');
this.updateTransactions();
}, 5000);
},
async currencyConv () {
browser.storage.sync.get('convertTimer').then(async result => {
var time = new Date().getTime();
if ( result.convertTimer == '' || result.convertTimer == 'undefined' || result.convertTimer <= time) {
const fetched = await fetchData('https://api.coingecko.com/api/v3/simple/price?ids=aeternity&vs_currencies=usd,eur','get','');
browser.storage.sync.set({ rateUsd : fetched.aeternity.usd}).then(() => { });
browser.storage.sync.set({ rateEur : fetched.aeternity.eur}).then(() => { });
// console.log(result.convertTimer);
// console.log('v if');
browser.storage.sync.set({ convertTimer : time+3600000}).then(() => { });
}
// console.log(time);
// console.log(result.convertTimer);
browser.storage.sync.get('rateUsd').then(resusd => {
this.usdRate = resusd.rateUsd;
this.toUsd = resusd.rateUsd * this.balance;
});
browser.storage.sync.get('rateEur').then(reseur => {
this.eurRate = reseur.rateEur;
this.toEur = reseur.rateEur * this.balance;
});
});
},
popupAlert(payload) {
this.$store.dispatch('popupAlert', payload)
},
Expand Down Expand Up @@ -139,4 +182,32 @@ export default {
.transactionHistory {
margin-top:1rem;
}
.inputGroup-currencies{
display: inline-block;
border-collapse: collapse;
width: 49%;
}
.inputGroup-currencies > div{
display: table-cell;
font-weight: bold;
border-bottom: 2px solid #ff0d6a;
vertical-align: middle;
border-radius: 10px;
border-bottom-left-radius: 0;
}
.input-group-icon{
background: #ff0d6a;
color: #fff;
padding: 0 12px;
}
.input-group-area{
width:100%;
}
.inputGroup-currencies input{
border: 0;
display: block;
font-weight: bold;
width: 100%;
padding: 8px;
}
</style>
7 changes: 4 additions & 3 deletions src/popup/router/pages/SeedPhrase.vue
Expand Up @@ -229,18 +229,19 @@ export default {
@import '../../../common/base';
.attentionHolder h1 {
color: red;
font-size: 50px;
font-size: 35px;
margin: 0;
}
.attentionHolder h1 div {
border: 3px solid;
width: 80px;
height: 80px;
width: 60px;
height: 60px;
border-radius: 50%;
margin: auto;
}
.attentionHolder h3 {
word-break: break-word;
margin: 1.5rem 0 1.5rem;
}
.attentionHolder h4, .attentionHolder ul {
margin: 0;
Expand Down
22 changes: 8 additions & 14 deletions src/popup/utils/helper.js
Expand Up @@ -42,23 +42,17 @@ const extractHostName = (url) => {

const fetchData = (url, method, fetchedData) => {
if (method == 'post') {
fetch(url, {
method: method,
fetch('https://jsonplaceholder.typicode.com/posts', {
method: 'POST',
body: fetchedData
}).then(function(response) {
console.log(response);
}).then(function(data) {
console.log(data);
});
})
.then(response => response.json())
.then(json => console.log(json))
}
if (method == 'get') {
fetch(url, {
method: method,
}).then(function(response) {
console.log(response);
}).then(function(data) {
console.log(data);
});
return fetch(url)
.then(response => response.json())
}
};

export {shuffleArray, convertToAE, extractHostName, fetchData};
4 changes: 2 additions & 2 deletions tests/e2e/specs/generateWallet.js
Expand Up @@ -45,7 +45,7 @@ describe('Test cases for Generate wallet', () => {
.visit('popup/popup.html',{onBeforeLoad:(contentWindow) => { onBeforeLoad(contentWindow,'seed') }})
.get('button.nextStep').should('contain','SHOW SEED PHRASE')
.click()
.get('.ae-phraser-container .ae-badge').each((el,index) => {
.get('.seeds-container .ae-badge').each((el,index) => {
let seeds = mnemonic.split(" ");
cy.wrap(el).should('contain',seeds[index]);
});
Expand All @@ -62,7 +62,7 @@ describe('Test cases for Generate wallet', () => {
.get('button').contains('Continue').click()
.visit('popup/popup.html',{onBeforeLoad:(contentWindow) => { onBeforeLoad(contentWindow,'seed') }})
.get('button.nextStep').click()
.get('.ae-phraser-container').should('be.visible')
.get('.seeds-container').should('be.visible')
.get('button.nextStep').click()
.get('.ae-modal-light').should('be.visible')
.get('.ae-modal-light button').contains('OK').click()
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/utils.js
Expand Up @@ -97,7 +97,7 @@ export const generateWallet = () => {
.get('button').contains('Continue').click()
.visit('popup/popup.html',{onBeforeLoad:(contentWindow) => { onBeforeLoad(contentWindow,'seed') }})
.get('button.nextStep').click()
.get('.ae-phraser-container').should('be.visible')
.get('.seeds-container').should('be.visible')
.wait(10000)
.get('button.nextStep').click()
.wrap(seeds).each((num,i) => {
Expand Down
3 changes: 3 additions & 0 deletions webpack.config.js
Expand Up @@ -16,6 +16,9 @@ const config = {
'options/options': './options/options.js',
'main':'./main.js'
},
node: {
fs: 'empty', net: 'empty', tls: 'empty'
},
output: {
path: __dirname + '/dist',
filename: '[name].js',
Expand Down

0 comments on commit b66bd10

Please sign in to comment.