diff --git a/src/services/api/tic-bg.js b/src/services/api/tic-bg.js index 901d861..8095fe7 100644 --- a/src/services/api/tic-bg.js +++ b/src/services/api/tic-bg.js @@ -3,5 +3,5 @@ export const seckey2pubkey = seckey => ticCrypto.seckey2pubkey(seckey) export const secword2address = secword => ticCrypto.secword2address(secword) export const secword2account = secword => ticCrypto.secword2account(secword) -export const randomSecword = lang => ticCrypto.randomSecword(lang) +// export const randomSecword = lang => ticCrypto.randomSecword(lang) export const isAddress = address => ticCrypto.isAddress(address) diff --git a/src/services/api/tic.js b/src/services/api/tic.js index adcd1c1..7b2d6fa 100644 --- a/src/services/api/tic.js +++ b/src/services/api/tic.js @@ -8,5 +8,5 @@ export default { secword2address: async secword => instance.secword2address(secword), isAddress: async address => instance.isAddress(address), secword2account: async secword => instance.secword2account(secword), - randomSecword: async lang => instance.randomSecword(lang), +// randomSecword: async lang => instance.randomSecword(lang), } diff --git a/src/store/modules/login.js b/src/store/modules/login.js index 60545b2..9798fbb 100644 --- a/src/store/modules/login.js +++ b/src/store/modules/login.js @@ -2,6 +2,7 @@ import router from '../../router' import { i18n } from '../../i18n' import _ from 'lodash' +import ticCrypto from 'tic.crypto' export default { namespaced: true, @@ -38,7 +39,6 @@ export default { async login({ state, commit }) { commit('updateSign', true) const account = (await ticApi.secword2account(state.mnemonic)) || {} - console.log(account) commit('updateSign', false) if (await ticApi.isAddress(account.address)) { commit('updateAccount', _.omit(account, 'seckey'), { root: true }) @@ -48,11 +48,8 @@ export default { } }, async createSecword({ state, commit }) { - alert('entering createSecword') - let secword = await ticApi.randomSecword() // 这句导致报错 "window is not defined"。猜测是 bitcore-mnemonic 不能在前端页面里使用。 - alert('after secword') - console.info('secword=' + secword) - alert('secword=' + secword) + let secword = ticCrypto.randomSecword() // 不能用 webworker 里的randomSecword,会导致报错 "window is not defined"。猜测是 bitcore-mnemonic 用到了window。 + commit('updateMnemonic', secword) }, }, } diff --git a/src/store/modules/owner.js b/src/store/modules/owner.js index 299efdd..a425e39 100644 --- a/src/store/modules/owner.js +++ b/src/store/modules/owner.js @@ -30,6 +30,7 @@ export default { fetching: false, filter: '', balance: 0, + address: '', }, mutations: { @@ -40,6 +41,10 @@ export default { updateBalance(state, balance) { state.balance = balance }, + + updateAddress(state, address) { + state.address = address + } }, actions: { @@ -47,6 +52,7 @@ export default { let account = sessionStorage.getItem('KEY_ACCOUNT') try { account = JSON.parse(account) + commit('updateAddress', account.address) const result = await axios.post('Account/getBalance', { Account: { address: account.address }, }) diff --git a/src/views/Owner.vue b/src/views/Owner.vue index 5be6d33..3c2dfb2 100644 --- a/src/views/Owner.vue +++ b/src/views/Owner.vue @@ -2,6 +2,7 @@