"async": "2.6.1",
"buffer-crc32": "0.2.13",
"glob": "7.1.2",
- "lodash": "4.17.10",
+ "lodash": "4.17.15",
"readable-stream": "2.3.6",
"tar-stream": "1.6.1",
"walkdir": "0.0.11",
"glob": "7.1.2",
"graceful-fs": "4.1.11",
"lazystream": "1.0.0",
- "lodash": "4.17.10",
+ "lodash": "4.17.15",
"normalize-path": "2.1.1",
"readable-stream": "2.3.6"
}
"integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==",
"dev": true,
"requires": {
- "lodash": "4.17.10"
+ "lodash": "4.17.15"
}
},
"async-each": {
"convert-source-map": "1.5.1",
"debug": "2.6.9",
"json5": "0.5.1",
- "lodash": "4.17.10",
+ "lodash": "4.17.15",
"minimatch": "3.0.4",
"path-is-absolute": "1.0.1",
"private": "0.1.8",
"babel-types": "6.26.0",
"detect-indent": "4.0.0",
"jsesc": "1.3.0",
- "lodash": "4.17.10",
+ "lodash": "4.17.15",
"source-map": "0.5.7",
"trim-right": "1.0.1"
},
"babel-helper-function-name": "6.24.1",
"babel-runtime": "6.26.0",
"babel-types": "6.26.0",
- "lodash": "4.17.10"
+ "lodash": "4.17.15"
}
},
"babel-helper-explode-assignable-expression": {
"requires": {
"babel-runtime": "6.26.0",
"babel-types": "6.26.0",
- "lodash": "4.17.10"
+ "lodash": "4.17.15"
}
},
"babel-helper-remap-async-to-generator": {
"babel-template": "6.26.0",
"babel-traverse": "6.26.0",
"babel-types": "6.26.0",
- "lodash": "4.17.10"
+ "lodash": "4.17.15"
}
},
"babel-plugin-transform-es2015-classes": {
"babel-runtime": "6.26.0",
"core-js": "2.5.7",
"home-or-tmp": "2.0.0",
- "lodash": "4.17.10",
+ "lodash": "4.17.15",
"mkdirp": "0.5.1",
"source-map-support": "0.4.18"
}
"babel-traverse": "6.26.0",
"babel-types": "6.26.0",
"babylon": "6.18.0",
- "lodash": "4.17.10"
+ "lodash": "4.17.15"
}
},
"babel-traverse": {
"debug": "2.6.9",
"globals": "9.18.0",
"invariant": "2.2.4",
- "lodash": "4.17.10"
+ "lodash": "4.17.15"
},
"dependencies": {
"debug": {
"requires": {
"babel-runtime": "6.26.0",
"esutils": "2.0.2",
- "lodash": "4.17.10",
+ "lodash": "4.17.15",
"to-fast-properties": "1.0.3"
}
},
"js-yaml": "3.12.0",
"json-stable-stringify-without-jsonify": "1.0.1",
"levn": "0.3.0",
- "lodash": "4.17.10",
+ "lodash": "4.17.15",
"minimatch": "3.0.4",
"mkdirp": "0.5.1",
"natural-compare": "1.4.0",
"dev": true,
"requires": {
"glob": "7.1.2",
- "lodash": "4.17.10",
+ "lodash": "4.17.15",
"minimatch": "3.0.4"
}
},
"requires": {
"html-minifier": "3.5.20",
"loader-utils": "0.2.17",
- "lodash": "4.17.10",
+ "lodash": "4.17.15",
"pretty-error": "2.1.1",
"tapable": "1.0.0",
"toposort": "1.0.7",
"requires": {
"http-proxy": "1.17.0",
"is-glob": "3.1.0",
- "lodash": "4.17.10",
+ "lodash": "4.17.15",
"micromatch": "2.3.11"
},
"dependencies": {
"cli-width": "2.2.0",
"external-editor": "3.0.3",
"figures": "2.0.0",
- "lodash": "4.17.10",
+ "lodash": "4.17.15",
"mute-stream": "0.0.7",
"run-async": "2.3.0",
"rxjs": "6.3.3",
}
},
"lodash": {
- "version": "4.17.10",
- "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz",
- "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg=="
+ "version": "4.17.15",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
+ "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
},
"lodash.assign": {
"version": "4.2.0",
"dev": true,
"requires": {
"glob": "7.1.2",
- "lodash": "4.17.10",
+ "lodash": "4.17.15",
"scss-tokenizer": "0.2.3",
"yargs": "7.1.0"
}
"dev": true,
"requires": {
"chalk": "2.4.1",
- "lodash": "4.17.10",
+ "lodash": "4.17.15",
"webpack-sources": "1.1.0",
"websocket-driver": "0.7.0"
}
"integrity": "sha512-TmSe1HZKeOPey3oy1Ov2iS3guIZjWvMT2BBJDzzT5jScHTjVC3mpjJofgueEzaEd6ibhxRDD6MIblDr8tzh8iQ==",
"dev": true,
"requires": {
- "lodash": "4.17.10"
+ "lodash": "4.17.15"
}
},
"webpack-sources": {
"requires": {
"archiver-utils": "1.3.0",
"compress-commons": "1.2.2",
- "lodash": "4.17.10",
+ "lodash": "4.17.15",
"readable-stream": "2.3.6"
}
}
"extension-streams": "^1.0.7",
"file-saver": "^2.0.0-rc.3",
"iview": "^3.0.0",
+ "lodash": "^4.17.15",
"moment": "^2.22.2",
"qrcodejs2": "0.0.2",
"uuid": "^3.3.2",
import * as PromptTypes from './prompts/PromptTypes'
import Error from './utils/errors/Error'
-import accountAction from "@/models/account";
-import bytom from "@/models/bytom";
let prompt = null;
export default class Background {
constructor() {
this.setupInternalMessaging()
- this.setupBytom()
- }
-
- setupBytom(){
- const network = localStorage.bytomNet||'mainnet'
- bytom.setupNet(network)
-
- window.addEventListener('storage', storageEventHandler, false);
- function storageEventHandler(evt){
- if(evt.key === 'bytomNet'){
- bytom.setupNet( evt.newValue )
- chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
- chrome.tabs.sendMessage(tabs[0].id, {action: "updateNetAndAccounts"}, function(response) {});
- });
- }else if(evt.key === 'currentAccount'){
- chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
- chrome.tabs.sendMessage(tabs[0].id, {action: "updateAccount"}, function(response) {});
- });
- }
- }
}
setupInternalMessaging() {
Background.load(bytom => {
const domain = payload.domain;
if(bytom.settings.domains.find(_domain => _domain === domain)) {
- const currentAccount = JSON.parse(localStorage.currentAccount)
+ const currentAccount = Object.assign({}, bytom.currentAccount)
delete(currentAccount['label'])
delete(currentAccount['net'])
currentAccount['accountId'] = currentAccount['guid']
}
requestCurrentNetwork(sendResponse){
- sendResponse(localStorage.bytomNet)
+ Background.load(bytom => {
+ sendResponse(bytom.settings.network);
+ })
}
send(sendResponse, payload) {
static authenticate(sendResponse, payload){
Background.load(bytom => {
const domain = payload.domain;
- const currentAccount = JSON.parse(localStorage.currentAccount)
+ const currentAccount = Object.assign({}, bytom.currentAccount)
delete(currentAccount['label'])
delete(currentAccount['net'])
currentAccount['accountId'] = currentAccount['guid']
import * as MsgTypes from './messages/types'
import * as EventNames from '@/messages/event'
import {strippedHost} from '@/utils/GenericTools'
+import _ from 'lodash';
let stream = new WeakMap()
document.dispatchEvent(new CustomEvent('chromeBytomLoaded'))
})
- chrome.runtime.onMessage.addListener(async (obj) => {
- switch (obj.action) {
- case 'updateAccount':
- const defaultAccount = await this.getDefaultAccount();
- if(defaultAccount){
- stream.send(
- NetworkMessage.payload(MsgTypes.UPDATE_BYTOM, {type:'default_account', value: defaultAccount}),
- EventNames.INJECT
- )
- }
- break
- case 'updateNetAndAccounts':
- const net = await this.getDefaultNetwork();
+ chrome.storage.onChanged.addListener(async (evt) => {
+ if(evt.bytom.newValue.settings.network !== evt.bytom.oldValue.settings.network){
+ const net = await this.getDefaultNetwork();
+ const defaultAccount = await this.getDefaultAccount();
+ stream.send(
+ NetworkMessage.payload(MsgTypes.UPDATE_BYTOM, {type:'net', value: net}),
+ EventNames.INJECT
+ )
+ stream.send(
+ NetworkMessage.payload(MsgTypes.UPDATE_BYTOM, {type:'default_account', value: defaultAccount}),
+ EventNames.INJECT
+ )
+ }else if(!_.isEqual(evt.bytom.newValue.currentAccount,evt.bytom.oldValue.currentAccount)){
+ const defaultAccount = await this.getDefaultAccount();
+ if(defaultAccount){
stream.send(
- NetworkMessage.payload(MsgTypes.UPDATE_BYTOM, {type:'net', value: net}),
+ NetworkMessage.payload(MsgTypes.UPDATE_BYTOM, {type:'default_account', value: defaultAccount}),
EventNames.INJECT
)
- break
+ }
}
- return true;
- })
+ });
}
import account from "@/models/account";
import transaction from "@/models/transaction";
import { BTM } from "@/utils/constants";
-import { mapGetters, mapState } from 'vuex'
+import { mapActions, mapGetters, mapState } from 'vuex'
+import * as Actions from '@/store/constants';
+import _ from 'lodash';
+
const EnterActive = 'animated faster fadeInLeft';
const LeaveActive = 'animated faster fadeOutLeft';
this.maskShow = false
}
- //account toggle by the list from menu
- if (to.name == 'home' && to.params.selectedAccount != undefined) {
- this.currentAccount = to.params.selectedAccount
- this.refreshAccounts();
- }
-
// remove transition for some page
this.enterActive = EnterActive
this.leaveActive = LeaveActive
this.enterActive = ''
this.leaveActive = ''
}
+ if (from.name == 'transfer-confirm') {
+ this.refreshTransactions(this.currentAccount.guid, this.currentAccount.address).then(transactions => {
+ this.transactions = transactions
+ });
+ }
},
currentAccount(newVal, oldVal) {
if (newVal.guid == undefined){
account.setupNet(this.net);
},
networkToggle: function (val) {
- localStorage.bytomNet = this.network;
- account.setupNet(this.network);
- this.currentAccount = {}
- this.refreshAccounts();
+ // localStorage.bytomNet = this.network;
+ // account.setupNet(this.network);
+ // this.currentAccount = {}
+ // this.refreshAccounts();
},
showQrcode: function () {
this.$router.push('received')
},
refreshBalance: function (guid) {
account.balance(guid)
+ .then((balances)=>{
+ if(!_.isEqual(this.currentAccount.balances, balances)){
+ const bytom = this.bytom.clone();
+
+ bytom.currentAccount.balances = balances;
+
+ account.setupNet(this.net)
+ account.list().then(accounts => {
+ bytom.accountList = accounts;
+ this[Actions.UPDATE_STORED_BYTOM](bytom)
+ })
+ }
+ })
.catch(error => {
console.log(error);
});
});
return formattedTransactions;
},
+ ...mapActions([
+ Actions.UPDATE_STORED_BYTOM,
+ ])
},
mounted() {
this.setupNetwork();
<tbody>
<tr class="row">
<td class="col label">{{ $t('transfer.from') }}</td>
- <td class="col value">{{account.alias}}</td>
+ <td class="col value">{{currentAccount.alias}}</td>
</tr>
<div class="divider"></div>
<tr class="row">
<td class="col label">Output</td>
<td class="col value" v-bind:class="{ hide: !full }" >{{transaction.output}}</td>
</tr>
- <tr class="row">
+ <tr v-if="transaction.args" class="row">
<td class="col label">Args</td>
<td class="col value" v-bind:class="{ hide: !full }" >{{transaction.args}}</td>
</tr>
import { LocalStream } from 'extension-streams';
import {apis} from '@/utils/BrowserApis';
import NotificationService from '../../services/NotificationService'
+import { mapActions, mapGetters, mapState } from 'vuex'
export default {
data() {
return {
full: false,
// full2: false,
- account: {},
+ // account: {},
transaction: {
input: "",
output: "",
};
},
computed: {
+ ...mapGetters([
+ 'currentAccount',
+ ])
},
watch: {
},
onCancel: this.onCancel
});
- transaction.buildTransaction(this.account.guid, this.transaction.input, this.transaction.output, this.transaction.fee * 100000000, this.transaction.confirmations).then(async (result) => {
+ transaction.buildTransaction(this.currentAccount.guid, this.transaction.input, this.transaction.output, this.transaction.fee * 100000000, this.transaction.confirmations).then(async (result) => {
let arrayData
if(this.transaction.args){
arrayData = await transaction.convertArgument(this.transaction.args)
}
- return transaction.advancedTransfer(this.account.guid, result, this.password, arrayData)
+ return transaction.advancedTransfer(this.currentAccount.guid, result, this.password, arrayData)
.then((resp) => {
loader.hide();
this.prompt.responder(resp);
});
}
}, mounted() {
- this.account = JSON.parse(localStorage.currentAccount);
-
this.prompt = window.data || apis.extension.getBackgroundPage().notification || null;
if(this.prompt.data !== undefined){
import getLang from "@/assets/language/sdk";
import Confirm from "./transferConfirm";
import { BTM } from "@/utils/constants";
+import { mapActions, mapGetters, mapState } from 'vuex'
+import * as Actions from '@/store/constants';
export default {
components: {
}
],
show: false,
- accounts: [],
assets: {
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff: "BTM"
},
computed: {
unit() {
return this.assets[this.transaction.asset];
- }
+ },
+ ...mapState([
+ 'bytom'
+ ]),
+ ...mapGetters([
+ 'currentAccount',
+ 'accountList'
+ ])
},
watch: {
selectAsset: function (val) {
this.guid = newAccount.guid;
},
guid: function (newGuid) {
- this.accounts.forEach(account => {
+ this.accountList.forEach(account => {
if (account.guid == newGuid.guid) {
this.account = account;
return;
});
}
}, mounted() {
- if (this.$route.params.account != undefined) {
- this.account = this.$route.params.account;
- }
-
//detect injection
if(this.$route.query.type === 'popup'){
if (this.$route.query.from != undefined) {
this.guid = this.$route.query.from
- }else{
- this.account = JSON.parse(localStorage.currentAccount);
+ this.account = this.accountList.filter(e => e.guid === this.guid)[0]
}
if (this.$route.query.asset != undefined) {
if(this.$route.query.confirmations != undefined) {
this.transaction.confirmations = this.$route.query.confirmations
}
+ }else{
+ this.account = this.currentAccount
}
-
-
- account.setupNet(localStorage.bytomNet);
- account.list().then(accounts => {
- this.accounts = accounts;
- this.accounts.forEach(function (ele) {
- ele.label = ele.alias
- ele.value = ele.guid
- });
- if (!this.guid) {
- this.account = accounts[0]
- }else{
- this.account = this.accounts.filter(e => e.guid === this.guid)[0]
- }
- });
}
};
</script>
onCancel: this.onCancel
});
account.create(this.formItem.accAlias, null, this.formItem.passwd1).then(currentAccount => {
- // localStorage.login = true;
this[Actions.CREATE_NEW_BYTOM](this.selected.value).then(() =>{
loader.hide();
this.formItem = {};
return;
}
account.restore(this.restore.fileTxt).then(res => {
- // localStorage.login = true;
this[Actions.IMPORT_BYTOM]().then(() =>{
this.$router.push('/');
});