• R/O
  • HTTP
  • SSH
  • HTTPS

Byone: Commit

Bytom Wallet for Chrome


Commit MetaInfo

Revision1e54f3d8424fcc59e2b635d02cc92341f60f8853 (tree)
Zeit2021-09-29 16:39:21
Autorxietao <nanshuo_xt@163....>
Commiterxietao

Log Message

Merge: merge pro

Ändern Zusammenfassung

Diff

--- /dev/null
+++ b/.prettierrc.js
@@ -0,0 +1,6 @@
1+module.exports = {
2+ singleQuote: true,
3+ semi: false,
4+ printWidth: 80,
5+ trailingComma: 'none',
6+}
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
11 {
22 "name": "Byone",
33 "description": "Bytom Chrome Extension Wallet",
4- "version": "3.1.1",
4+ "version": "3.3.0",
55 "author": "zhiting.fly@8btc.com",
66 "license": "MIT",
77 "private": true,
@@ -19,6 +19,7 @@
1919 "axios": "^0.18.0",
2020 "babel-preset-es2015": "^6.24.1",
2121 "bignumber.js": "^9.0.0",
22+ "bytom": "^0.2.3",
2223 "bytom-js-sdk": "^1.4.0",
2324 "bytomjs-lib": "0.0.2",
2425 "clipboard": "^2.0.1",
--- a/src/assets/bapp/bapp.json
+++ b/src/assets/bapp/bapp.json
@@ -30,7 +30,7 @@
3030 {
3131 "icon":"vote.jpg",
3232 "color":"linear-gradient(94.25deg, rgba(255, 255, 255, 0) 21.9%, rgba(255, 255, 255, 0.1) 81.37%), #0A57EB",
33- "link":"https://staking.bymov.io/staking",
33+ "link":"https://staking.blockmeta.com",
3434 "domainsMeta": {
3535 "icon": "https://supertx.bymov.io/favicon.ico"
3636 }
--- a/src/assets/language/cn.js
+++ b/src/assets/language/cn.js
@@ -12,16 +12,18 @@ const cn = {
1212 wallets:"钱包",
1313 backup:"备份",
1414 expand:"展开",
15- setting:"设置"
15+ setting:"设置",
16+ bapp: 'BApp'
1617 },
1718 common:{
18- veto: '取消投票',
19+ veto: '取消质押',
1920 cross_chain_in: '跨入Vapor',
2021 spend : '花费',
2122 coinbase: 'Coinbase',
2223 control : '接受',
2324 cross_chain_out: '跨出Vapor',
24- vote: '投票',
25+ out_crosschain: '跨出Vapor',
26+ vote: '质押',
2527 transfer:'转账',
2628 issue:'资产发行',
2729 retire:'资产销毁',
@@ -64,7 +66,8 @@ const cn = {
6466 },
6567 transfer: {
6668 address: '接收地址',
67- bytomAddress:'主链地址(bm开头)',
69+ bytomAddress:'主链地址(bn开头)',
70+ bytom1Address:'主链地址(bm开头)',
6871 vaporAddress:'侧链地址(vp开头)',
6972 quantity: '数量',
7073 fee: '手续费',
@@ -103,6 +106,7 @@ const cn = {
103106 listAsset: {
104107 all:'全部',
105108 fail:'失败',
109+ confirming: '确认中',
106110 main:'主链',
107111 side:'侧链',
108112 },
@@ -117,34 +121,34 @@ const cn = {
117121 direction:'跨链方向'
118122 },
119123 listVote:{
120- title:'节点投票',
121- myVote:'我的投票',
122- totalVote:'全网投票',
123- voteRecord:'投票记录',
124- voteRules:'投票规则',
125- cancelVote:'取消投票',
124+ title:'节点质押',
125+ myVote:'我的质押',
126+ totalVote:'全网质押',
127+ voteRecord:'质押记录',
128+ voteRules:'质押规则',
129+ cancelVote:'取消质押',
126130 bp:'正式共识节点',
127131 standbyBP:'备选共识节点',
128132 bpName:'节点名称',
129133 bpPubkey:'节点公钥',
130- vote:'投票',
134+ vote:'质押',
131135 votes:'票数',
132- voteVotes:'投票票数',
133- voteAccount:'投票账户',
134- vetoAccount:'取消投票账户',
136+ voteVotes:'质押票数',
137+ voteAccount:'质押账户',
138+ vetoAccount:'取消质押账户',
135139 },
136140 listCancel:{
137- voted:'已投票',
141+ voted:'已质押',
138142 cancel:'可取消',
139143 selectVote:'选择节点',
140- availableVeto:'可取消投票数'
144+ availableVeto:'可取消质押数'
141145 },
142146 vote:{
143147 selectNode:'选择节点',
144- voteDetials:'投票详情',
145- vetoDetials:'取消投票详情',
146- confirmVote:'确认投票',
147- confirmVeto:'确认取消投票',
148+ voteDetials:'质押详情',
149+ vetoDetials:'取消质押详情',
150+ confirmVote:'确认质押',
151+ confirmVeto:'确认取消质押',
148152 amountPlaceHolder:"可用"
149153 },
150154 signMessage:{
@@ -186,7 +190,7 @@ const cn = {
186190 copy: '点击复制',
187191 send: '转账',
188192 receive: '收款',
189- vote:'投票',
193+ vote:'质押',
190194 crossChain:'跨链',
191195 record: '交易记录',
192196 asset:'我的资产',
@@ -313,6 +317,7 @@ const cn = {
313317 currency:'货币单位',
314318 network:'网络',
315319 version:'版本号:',
320+ chain: '链切换',
316321 enLange:"展开视图",
317322 deleteWallet:'删除钱包',
318323 deleteHint:'执行删除钱包操作前请确认您已备份好钱包,否则将无法找回!',
--- a/src/assets/language/en.js
+++ b/src/assets/language/en.js
@@ -14,6 +14,7 @@ const en = {
1414 coinbase: 'Coinbase',
1515 control : 'Received ',
1616 cross_chain_out: 'Cross Out Vapor',
17+ out_crosschain: 'Cross Out Vapor',
1718 vote: 'Vote',
1819 transfer:'Transfer',
1920 issue:'Issue',
@@ -64,7 +65,7 @@ const en = {
6465 },
6566 transfer: {
6667 address: 'Address',
67- bytomAddress:'Bytom address (start with bm)',
68+ bytomAddress:'Bytom address (start with bn)',
6869 vaporAddress:'Vapor address (start with vp)',
6970 quantity: ' Amount',
7071 fee: 'Fee',
@@ -103,6 +104,7 @@ const en = {
103104 listAsset: {
104105 all:'All',
105106 fail:'Failed',
107+ confirming: 'Confirming',
106108 main:'Chain',
107109 side:'Sidechain',
108110 },
@@ -311,6 +313,7 @@ const en = {
311313 lang: 'Language',
312314 currency:'Currency',
313315 network:'Networks',
316+ chain: 'Chain',
314317 enLange:"Expand view",
315318 deleteWallet:'Delete wallet',
316319 deleteHint:'Please confirm you has backed up your wallet.',
--- a/src/background.js
+++ b/src/background.js
@@ -126,10 +126,6 @@ export default class Background {
126126 sendResponse(Error.typeMissed('asset'));
127127 return false;
128128 }
129- if(typeof requestBody.to === 'string' && requestBody.amount === undefined){
130- sendResponse(Error.typeMissed('amount'));
131- return false;
132- }
133129
134130 const {domain} = payload;
135131 const data={
@@ -190,12 +186,16 @@ export default class Background {
190186 if(bytom.settings.domains.find(_domain => _domain === domain)) {
191187 const currentAccount = bytom.currentAccount
192188 const {vpAddress, address} = currentAccount
189+ const classicAddress = currentAccount.bytom1.address
190+ const isClassic = bytom.settings.netType === 'bytom1'
193191 let account = {
194- addresses: [vpAddress, address],
192+ addresses: [vpAddress, isClassic?classicAddress:address],
195193 rootXPub: currentAccount.xpub
196194 }
197195 if(bytom.settings.netType === 'vapor'){
198196 account.address = vpAddress;
197+ }else if(bytom.settings.netType === 'bytom1'){
198+ account.address = classicAddress;
199199 }else{
200200 account.address = address;
201201 }
@@ -217,7 +217,7 @@ export default class Background {
217217
218218 requestCurrentChain(sendResponse){
219219 Background.load(bytom => {
220- const chain = bytom.settings.netType ==='vapor'?'vapor':'bytom'
220+ const chain = bytom.settings.netType ==='vapor'?'vapor':bytom.settings.netType==='bytom'?'bytom':bytom.settings.netType
221221 sendResponse(chain);
222222 })
223223 }
@@ -288,16 +288,28 @@ export default class Background {
288288 if(!currentAccount){
289289 sendResponse(Error.signatureAccountMissing())
290290 }else{
291-
292291 const {vpAddress, address} = currentAccount
292+ const classicAddress = currentAccount.bytom1.address
293+ const isClassic = bytom.settings.netType === 'bytom1'
294+
293295 let account = {
294- addresses: [vpAddress, address],
295- rootXPub: currentAccount.xpub
296+ // for bytom1
297+ addresses: [vpAddress, isClassic? classicAddress: address],
298+ rootXPub: currentAccount.xpub,
299+ // for bytom2
300+ xpub: currentAccount.xpub,
301+ net: bytom.settings.network,
302+ chain: bytom.settings.netType
296303 }
297304 if(bytom.settings.netType === 'vapor'){
298305 account.address = vpAddress;
306+ account.account = vpAddress
307+ }else if(bytom.settings.netType === 'bytom1'){
308+ account.address = classicAddress;
309+ account.account = classicAddress
299310 }else{
300311 account.address = address;
312+ account.account = address
301313 }
302314
303315
@@ -305,7 +317,8 @@ export default class Background {
305317 sendResponse(account);
306318 } else{
307319 NotificationService.open(new Prompt(PromptTypes.REQUEST_AUTH, payload.domain, payload, approved => {
308- if(approved === false || approved.hasOwnProperty('isError')) sendResponse(approved);
320+ if (approved === false) sendResponse(Error.forbidden())
321+ else if(approved.hasOwnProperty('isError')) sendResponse(approved);
309322 else {
310323 bytom.settings.domains.unshift(domain);
311324 bytom.settings.domainsMeta[domain] = domainAttrs;
@@ -330,7 +343,8 @@ export default class Background {
330343 if(index !== -1) {
331344 payload.type = 'dis'
332345 NotificationService.open(new Prompt(PromptTypes.REQUEST_AUTH, payload.domain, payload, approved => {
333- if(approved === false || approved.hasOwnProperty('isError')) sendResponse(approved);
346+ if (approved === false) sendResponse(Error.forbidden())
347+ else if(approved.hasOwnProperty('isError')) sendResponse(approved);
334348 else {
335349 bytom.settings.domains.splice(index, 1);
336350 delete bytom.settings.domainsMeta[domain];
--- a/src/inject.js
+++ b/src/inject.js
@@ -3,6 +3,7 @@ import { EncryptedStream } from 'extension-streams'
33 import * as MsgTypes from './messages/types'
44 import * as EventNames from '@/messages/event'
55 import Bytomdapp from './dapp'
6+import { provider } from 'bytom'
67
78 /***
89 * This is the javascript which gets injected into
@@ -22,7 +23,18 @@ class Inject {
2223 msg.hasOwnProperty('type') &&
2324 msg.type === MsgTypes.PUSH_BYTOM
2425 ) {
26+ // window.bytom only for ofmf business get vpAddress, other mov-web business use bytom2
2527 window.bytom = new Bytomdapp(stream, msg.payload)
28+ new provider.ByoneProvider({
29+ logger: true,
30+ stream,
31+ net: msg.payload.net,
32+ chain: msg.payload.chain,
33+ account: msg.payload.defaultAccount && {
34+ address: msg.payload.defaultAccount.address,
35+ xpub: msg.payload.defaultAccount.rootXPub
36+ }
37+ })
2638 }
2739
2840 if (
@@ -36,20 +48,46 @@ class Inject {
3648 switch (p.type){
3749 case 'default_account':{
3850 window.bytom.emit(MsgTypes.ACCOUNT_CHANGED, [p.value])
51+ window.bytom2.setAccount(p.value && {
52+ address: p.value.address,
53+ xpub: p.value.rootXPub
54+ })
3955 break
4056 }
4157 case 'net':{
4258 window.bytom.emit(MsgTypes.NETWORK_CHANGED, p.value)
59+ window.bytom2.setNet(p.value)
4360 break
4461 }
4562 case 'chain':{
4663 window.bytom.emit(MsgTypes.NET_TYPE_CHANGED, p.value)
64+ window.bytom2.setChain(p.value)
4765 break
4866 }
49-
5067 }
5168 }
5269 }
70+
71+ if (
72+ msg &&
73+ msg.hasOwnProperty('type') &&
74+ msg.type === MsgTypes.ENABLE
75+ ) {
76+ window.bytom.defaultAccount = window.bytom.default_account = {
77+ address: msg.payload.address,
78+ addresses: msg.payload.addresses,
79+ xpub: msg.payload.xpub
80+ }
81+ }
82+
83+ if (
84+ msg &&
85+ msg.hasOwnProperty('type') &&
86+ msg.type === MsgTypes.DISABLE
87+ ) {
88+ console.log('disabledisable')
89+ window.bytom.defaultAccount = window.bytom.default_account = null
90+ }
5391 })
5492
5593 // Syncing the streams between the extension and the web application
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -2,7 +2,7 @@
22 "manifest_version": 2,
33 "name": "Byone",
44 "description": "Bytom Wallet Chrome extension.",
5- "version": "3.1.1",
5+ "version": "3.3.0",
66 "author": "Bytom frontend, zhitinglin",
77 "web_accessible_resources": ["js/inject.js"],
88 "browser_action": {
--- a/src/messages/event.js
+++ b/src/messages/event.js
@@ -1,2 +1,2 @@
1-export const INJECT = 'bytom-inject-js'
2-export const BYTOM = 'bytom-content-js'
1+export const INJECT = 'bytom2-inject-js'
2+export const BYTOM = 'bytom2-content-js'
--- a/src/migrations/migrator.js
+++ b/src/migrations/migrator.js
@@ -11,11 +11,18 @@ const mathematicalVersion = version => {
1111 const fnToVersion = fnName => fnName.replace(/[m]/g, '').replace(/[_]/g,'.');
1212
1313 export default async bytom => {
14+ console.log('check update');
15+
1416 bytom.meta.regenerateVersion();
1517 if(!bytom.meta.needsUpdating()) return false;
1618
1719 const lastVersion = mathematicalVersion(bytom.meta.lastVersion);
1820 const nextVersions = Object.keys(migrators).filter(v => mathematicalVersion(v) > lastVersion);
21+
22+ console.log('lastVersion', lastVersion);
23+ console.log('nextVersions', nextVersions);
24+ console.log('migrators', migrators);
25+
1926 if(nextVersions.length) {
2027 await Promise.all(nextVersions.map(async version => await migrators[version](bytom)));
2128 bytom.meta.lastVersion = fnToVersion(nextVersions[nextVersions.length-1]);
--- /dev/null
+++ b/src/migrations/versions/3.3.0.js
@@ -0,0 +1,63 @@
1+import { wallet } from '@/models/wallet'
2+
3+async function eachAccount (accountsObject, net) {
4+ wallet.setNet(net)
5+ for (const [name, account] of Object.entries(accountsObject)) {
6+ // only bytom1 account, need to create bytom2 account
7+ if (account.address.startsWith('bm') || account.address.startsWith('tm')) {
8+ account.bytom1 = {
9+ address: account.address,
10+ guid: account.guid
11+ }
12+ wallet.setChain('bytom')
13+ const bytom2Account = await wallet.createAccount(account.xpub, account.guid)
14+ account.address = bytom2Account.address
15+ }
16+ // only bytom2 account, need to create bytom1 account
17+ if ((account.address.startsWith('bn') || account.address.startsWith('tn')) && !account.bytom1) {
18+ wallet.setChain('bytom1')
19+ const bytom1Account = await wallet.createAccount(account.xpub, account.guid)
20+ account.bytom1 = {
21+ address: bytom1Account.address,
22+ guid: bytom1Account.guid
23+ }
24+ }
25+ }
26+}
27+
28+export const m3_3_0 = async bytom => {
29+ console.log('begin update config');
30+
31+ if (bytom.keychain.pairs && bytom.keychain.pairs.mainnet) {
32+ await eachAccount(bytom.keychain.pairs.mainnet, 'mainnet')
33+ } else {
34+ bytom.keychain.pairs.mainnet = {}
35+ }
36+
37+ if (bytom.keychain.pairs && bytom.keychain.pairs.testnet) {
38+ await eachAccount(bytom.keychain.pairs.testnet, 'testnet')
39+ } else {
40+ bytom.keychain.pairs.testnet = {}
41+ }
42+
43+ if (bytom.settings.netType === 'vapor') {
44+ wallet.setChain('vapor')
45+ } else if (bytom.settings.chainType === 'bytom1') {
46+ wallet.setChain('bytom1')
47+ } else {
48+ wallet.setChain('bytom')
49+ }
50+
51+ if (bytom.settings.network === 'testnet') {
52+ const alias = Object.keys(bytom.keychain.pairs.testnet)[0]
53+ bytom.currentAccount = bytom.keychain.pairs.testnet[alias]
54+ } else {
55+ const alias = Object.keys(bytom.keychain.pairs.mainnet)[0]
56+ bytom.currentAccount = bytom.keychain.pairs.mainnet[alias]
57+ }
58+ wallet.setNet(bytom.settings.network)
59+
60+ console.log('update config success');
61+
62+ return true;
63+};
--- a/src/migrations/versions/version.js
+++ b/src/migrations/versions/version.js
@@ -1,2 +1 @@
1-export * from './3.0.0';
2-export * from './3.0.5';
1+export * from './3.3.0';
--- a/src/models/account.js
+++ b/src/models/account.js
@@ -5,8 +5,47 @@ import _ from 'lodash'
55 import {getDomains, camelize} from '@/utils/utils.js'
66 import * as Sentry from "@sentry/browser";
77
8+import { wallet, setChain, setNet } from './wallet'
9+
810 let account = {
9- setupNet: bytom.setupNet
11+ // setupNet: bytom.setupNet
12+ setupNet: (net) => {
13+ // older version compat
14+ const network = net.substr(0, 7)
15+ const chain = net.substr(7)
16+ setNet(network)
17+ setChain(chain === 'vapor' ? chain : window.store.state.bytom.settings.chainType === 'bytom1' ? 'bytom1' : 'bytom')
18+ bytom.setupNet(net)
19+ }
20+}
21+
22+function findOrCreateAccount (pubkey, guid, chain) {
23+ const currentChain = wallet.chain
24+ setChain(chain)
25+ // return bytom.wallet.list(pubkey).then(async (wallet) =>{
26+ return wallet.getWallets(pubkey).then(async (res) =>{
27+ if (res.length > 0) {
28+ return {
29+ guid: res[0].guid,
30+ address: res[0].addresses ? res[0].addresses[0] : res[0].address
31+ }
32+ } else {
33+ // return bytom.accounts.createNewAccount(pubkey, 'byone')
34+ return wallet.createAccount(pubkey, guid)
35+ }
36+ }).finally(() => {
37+ setChain(currentChain)
38+ })
39+}
40+
41+function createAccount (pubkey, guid, chain) {
42+ // bytom.setupNet(`${net}${chain}`)
43+ // return bytom.accounts.createNewAccount(pubkey, 'byone')
44+ const currentChain = wallet.chain
45+ setChain(chain)
46+ return wallet.createAccount(pubkey, guid).finally(() => {
47+ setChain(currentChain)
48+ })
1049 }
1150
1251 account.createKey = function(accountAlias, keyAlias, passwd, context) {
@@ -25,7 +64,8 @@ account.createKey = function(accountAlias, keyAlias, passwd, context) {
2564 _bytom.keychain.removeUnverifyIdentity(_bytom.settings.network);
2665 _bytom.settings.netType = 'bytom';
2766
28- const resultObj = bytom.keys.createKey(keyAlias, passwd)
67+ // const resultObj = bytom.keys.createKey(keyAlias, passwd)
68+ const resultObj = wallet.createKey(keyAlias, passwd)
2969
3070 resultObj.alias = accountAlias
3171 resultObj.keyAlias = keyAlias
@@ -50,27 +90,53 @@ account.createAccount = function( context) {
5090 let retPromise = new Promise((resolve, reject) => {
5191 const _bytom = context.bytom.clone();
5292 const currentAccount = _bytom.currentAccount
53-
5493 const keystore = currentAccount.keystore
55- bytom.setupNet(`${context.net}bytom`)
56- bytom.accounts.createNewAccount(keystore.xpub, 'byone').then( async (ret) => {
57- let resultObj = Object.assign(currentAccount, ret)
58- resultObj.vMnemonic = true;
5994
60- const domains = await getDomains();
61- _bytom.settings.domains = Array.from(new Set(_bytom.settings.domains.concat(domains)))
95+ createAccount(keystore.xpub, null, 'bytom1').then((bytom1Account) => {
96+ return createAccount(keystore.xpub, bytom1Account.guid, 'bytom').then(async (bytom2Account) => {
97+ let resultObj = Object.assign(currentAccount, bytom2Account)
98+ resultObj.vMnemonic = true;
99+ resultObj.bytom1 = bytom1Account
100+
101+ const domains = await getDomains();
102+ _bytom.settings.domains = Array.from(new Set(_bytom.settings.domains.concat(domains)))
103+
104+ _bytom.keychain.pairs[_bytom.settings.network][currentAccount.alias] = resultObj
105+ _bytom.currentAccount = resultObj
106+
107+ if (_bytom.settings.chainType === 'bytom2') {
108+ setChain('bytom')
109+ } else {
110+ setChain('bytom1')
111+ }
62112
63- _bytom.keychain.pairs[_bytom.settings.network][currentAccount.alias] = resultObj
64- _bytom.currentAccount = resultObj
65- context[Actions.UPDATE_STORED_BYTOM](_bytom).then(() => {
66- resolve(resultObj)
67- }).catch(e => { throw e })
113+ context[Actions.UPDATE_STORED_BYTOM](_bytom).then(() => {
114+ resolve(resultObj)
115+ }).catch(e => { throw e })
116+ })
68117 })
118+ // Promise.all([
119+ // createAccount(keystore.xpub, 'bytom1')
120+ // ]).then(async ([bytom2Account, bytom1Account]) => {
121+ // let resultObj = Object.assign(currentAccount, bytom2Account)
122+ // resultObj.vMnemonic = true;
123+ // resultObj.bytom1 = bytom1Account
124+
125+ // const domains = await getDomains();
126+ // _bytom.settings.domains = Array.from(new Set(_bytom.settings.domains.concat(domains)))
127+
128+ // _bytom.keychain.pairs[_bytom.settings.network][currentAccount.alias] = resultObj
129+ // _bytom.currentAccount = resultObj
130+ // context[Actions.UPDATE_STORED_BYTOM](_bytom).then(() => {
131+ // resolve(resultObj)
132+ // }).catch(e => { throw e })
133+ // })
69134 })
70135 return retPromise
71136 }
72137
73138 account.restoreByMnemonic = function(accountAlias, mnemonic, passwd, context) {
139+
74140 let retPromise = new Promise((resolve, reject) => {
75141 const keyAlias = `${accountAlias}-key-${uuid.v4()}`
76142
@@ -82,44 +148,38 @@ account.restoreByMnemonic = function(accountAlias, mnemonic, passwd, context) {
82148 }
83149
84150 _bytom.keychain.removeUnverifyIdentity(_bytom.settings.network);
85-
86- const res = bytom.keys.restoreFromMnemonic(keyAlias, passwd, mnemonic)
87-
88151 _bytom.settings.netType = 'bytom';
89152
90- bytom.setupNet(`${context.net}bytom`)
91- bytom.wallet.list(res.xpub).then(async (wallet) =>{
92- let walletInfo
93- if(wallet.length>0){
94- let ret = {
95- guid:wallet[0].guid,
96- address:wallet[0].addresses[0]
97- }
153+ // const res = bytom.keys.restoreFromMnemonic(keyAlias, passwd, mnemonic)
154+ const res = wallet.restoreFromMnemonic(keyAlias, passwd, mnemonic)
98155
99- walletInfo = Promise.resolve(ret)
100- }else{
101- walletInfo = bytom.accounts.createNewAccount(res.xpub, 'byone')
102- }
103-
104- const domains = await getDomains();
105- _bytom.settings.domains = Array.from(new Set(_bytom.settings.domains.concat(domains)))
106-
107- walletInfo.then(ret => {
108- let resultObj = Object.assign(res, ret)
156+ // findOrCreateAccount(res.xpub, null, 'bytom1'),
157+ findOrCreateAccount(res.xpub, null, 'bytom1').then((bytom1Account) => {
158+ findOrCreateAccount(res.xpub, bytom1Account.guid, 'bytom').then(async (bytom2Account) => {
159+ const domains = await getDomains();
160+ _bytom.settings.domains = Array.from(new Set(_bytom.settings.domains.concat(domains)))
161+
162+ let resultObj = Object.assign(res, bytom2Account)
109163 resultObj.alias = accountAlias
110164 resultObj.keyAlias = keyAlias
111165 resultObj.vMnemonic = true
166+ resultObj.bytom1 = bytom1Account
112167
113168 _bytom.keychain.pairs[_bytom.settings.network][accountAlias] = resultObj
114169 _bytom.currentAccount = resultObj
115170
171+ if (_bytom.settings.chainType === 'bytom2') {
172+ setChain('bytom')
173+ } else {
174+ setChain('bytom1')
175+ }
176+
116177 context[Actions.UPDATE_STORED_BYTOM](_bytom).then(() => {
117- resolve(ret)
178+ resolve(bytom2Account)
179+ })
180+ .catch(error => {
181+ reject(error)
118182 })
119- .catch(error => {
120- reject(error)
121- })
122-
123183 })
124184 })
125185 })
@@ -137,47 +197,43 @@ account.restoreByKeystore = function(accountAlias, keystore, password, context)
137197 }
138198
139199 _bytom.keychain.removeUnverifyIdentity(_bytom.settings.network);
140-
141- const res = bytom.keys.restoreFromKeystore(password, keystore)
142-
143200 _bytom.settings.netType = 'bytom';
144201
145- bytom.setupNet(`${context.net}bytom`)
146- bytom.wallet.list(res.xpub).then(async (wallet) =>{
147- let walletInfo
148- if(wallet.length>0){
149- let ret = {
150- guid:wallet[0].guid,
151- address:wallet[0].addresses[0]
152- }
153-
154- walletInfo = Promise.resolve(ret)
155- }else{
156- walletInfo = bytom.accounts.createNewAccount(res.xpub, 'byone')
157- }
158-
159-
160- const domains = await getDomains();
161- _bytom.settings.domains = Array.from(new Set(_bytom.settings.domains.concat(domains)))
202+ // older keystore compat
203+ if (keystore.key_images && keystore.key_images.xkeys) {
204+ keystore = keystore.key_images.xkeys[0]
205+ }
162206
163- walletInfo.then(ret => {
164- let resultObj = Object.assign(ret, {})
207+ // const res = bytom.keys.restoreFromKeystore(password, keystore)
208+ const res = wallet.restoreFromKeystore(password, keystore)
209+ findOrCreateAccount(res.xpub, null, 'bytom1').then((bytom1Account) => {
210+ findOrCreateAccount(res.xpub, bytom1Account.guid, 'bytom').then(async (bytom2Account) => {
211+ const domains = await getDomains();
212+ _bytom.settings.domains = Array.from(new Set(_bytom.settings.domains.concat(domains)))
213+
214+ let resultObj = Object.assign(bytom2Account, {})
165215 resultObj.alias = accountAlias
166216 resultObj.keyAlias = res.keyAlias
167217 resultObj.vMnemonic = true
168218 resultObj.keystore = keystore
169219 resultObj.xpub = res.xpub
220+ resultObj.bytom1 = bytom1Account
170221
171222 _bytom.keychain.pairs[_bytom.settings.network][accountAlias] = resultObj
172223 _bytom.currentAccount = resultObj
173224
225+ if (_bytom.settings.chainType === 'bytom2') {
226+ setChain('bytom')
227+ } else {
228+ setChain('bytom1')
229+ }
230+
174231 context[Actions.UPDATE_STORED_BYTOM](_bytom).then(() => {
175- resolve(ret)
232+ resolve(bytom2Account)
176233 })
177234 .catch(error => {
178235 reject(error)
179236 })
180-
181237 })
182238 })
183239 })
@@ -185,53 +241,66 @@ account.restoreByKeystore = function(accountAlias, keystore, password, context)
185241 }
186242
187243 account.copy = function(guid) {
188- let retPromise = new Promise((resolve, reject) => {
189- bytom.accounts
190- .copyAccountUseServer(guid, 'btm')
191- .then(ret => {
192- resolve(ret)
193- })
194- .catch(error => {
195- reject(error)
196- })
197- })
198- return retPromise
244+ return wallet.copyToVapor(guid, 'btm')
245+ // let retPromise = new Promise((resolve, reject) => {
246+ // bytom.accounts
247+ // .copyAccountUseServer(guid, 'btm')
248+ // .then(ret => {
249+ // resolve(ret)
250+ // })
251+ // .catch(error => {
252+ // reject(error)
253+ // })
254+ // })
255+ // return retPromise
199256 }
200257
201-account.listVapor = function(guid) {
202- let retPromise = new Promise((resolve, reject) => {
203- bytom.accounts
204- .listVaporAccountUseServer(guid)
205- .then(ret => {
206- resolve(ret)
207- })
208- .catch(error => {
209- reject(error)
210- })
211- })
212- return retPromise
213-}
258+// account.listVapor = function(guid) {
259+// let retPromise = new Promise((resolve, reject) => {
260+// bytom.accounts
261+// .listVaporAccountUseServer(guid)
262+// .then(ret => {
263+// resolve(ret)
264+// })
265+// .catch(error => {
266+// reject(error)
267+// })
268+// })
269+// return retPromise
270+// }
214271
215272 account.balance = function(address , context) {
216273 let retPromise = new Promise((resolve, reject) => {
217- bytom.accounts
218- .listAddressUseServer(address)
274+ wallet.getBalances(address)
275+ // bytom.accounts
276+ // .listAddressUseServer(address)
219277 .then(address => {
220- let balances = address.balances || []
221- let votes = address.votes || []
222278 const _bytom = context.bytom.clone();
279+ const isVapor = _bytom.settings.netType === 'vapor'
280+ const isBytom1 = _bytom.settings.chainType === 'bytom1'
281+
282+ // if (address.address !== context.bytom.currentAccount[isVapor ? 'vpAddress' : 'address']) {
283+ // return
284+ // }
285+ const currentAddress = isVapor ? _bytom.currentAccount.vpAddress : isBytom1 ? _bytom.currentAccount.bytom1.address : _bytom.currentAccount.address
286+ if (address.address !== currentAddress) {
287+ return
288+ }
223289
290+ let balances = address.balances || []
291+ let votes = address.votes || []
224292
225- const isVapor = _bytom.settings.netType === 'vapor'
226- const _currentBalance = isVapor? _bytom.currentAccount.vpBalances : _bytom.currentAccount.balances
293+ const currentBalance = isVapor? _bytom.currentAccount.vpBalances : isBytom1 ? _bytom.currentAccount.bytom1.balances : _bytom.currentAccount.balances
294+ const currentVotes = isBytom1 ? _bytom.currentAccount.bytom1.votes : _bytom.currentAccount.votes
227295
228296 Sentry.configureScope(function(scope) {
229297 if(!isVapor) {
230298 scope.setTag("wallet.address", address.address);
231299 }
232300 });
233- const balanceNotEqual = !_.isEqual(_currentBalance, balances)
234- const voteNotEqual = ( isVapor && !_.isEqual(_bytom.currentAccount.votes, votes))
301+
302+ const balanceNotEqual = !_.isEqual(currentBalance, balances)
303+ const voteNotEqual = !_.isEqual(currentVotes, votes)
235304
236305 if(balanceNotEqual || voteNotEqual) {
237306 //update AccountList
@@ -240,15 +309,23 @@ account.balance = function(address , context) {
240309 if (isVapor) {
241310 _bytom.currentAccount.vpBalances = balances;
242311 _bytom.keychain.pairs[_bytom.settings.network][_bytom.currentAccount.alias].vpBalances =balances
312+ } else if (isBytom1) {
313+ _bytom.currentAccount.bytom1.balances = balances
314+ _bytom.keychain.pairs[_bytom.settings.network][_bytom.currentAccount.alias].bytom1.balances = balances
243315 } else {
244316 _bytom.currentAccount.balances = balances;
245- _bytom.keychain.pairs[_bytom.settings.network][_bytom.currentAccount.alias].balances = balances
317+ _bytom.keychain.pairs[_bytom.settings.network][_bytom.currentAccount.alias].balances = balances
246318 }
247319 }
248320
249321 if (voteNotEqual) {
250- _bytom.currentAccount.votes = votes;
322+ if (isBytom1) {
323+ _bytom.currentAccount.bytom1.votes = votes;
324+ _bytom.keychain.pairs[_bytom.settings.network][_bytom.currentAccount.alias].bytom1.votes = votes
325+ } else {
326+ _bytom.currentAccount.votes = votes;
251327 _bytom.keychain.pairs[_bytom.settings.network][_bytom.currentAccount.alias].votes = votes
328+ }
252329 }
253330
254331 context[Actions.UPDATE_STORED_BYTOM](_bytom)
@@ -263,21 +340,23 @@ account.balance = function(address , context) {
263340 return retPromise
264341 }
265342
266-account.list = function() {
267- return bytom.accounts
268- .listAccountUseServer()
269-}
343+// account.list = function() {
344+// return bytom.accounts
345+// .listAccountUseServer()
346+// }
347+
270348 account.listKeyByXpubOld = function(xpub){
271349 return bytom.keys
272350 .getKeyByXPub(xpub)
273351 }
274352
275-account.backup = function() {
276- return bytom.wallet.backup()
277-}
353+// account.backup = function() {
354+// return bytom.wallet.backup()
355+// }
278356
279357 account.isValidMnemonic = function(mnemonic) {
280- return bytom.keys.isValidMnemonic(mnemonic)
358+ // return bytom.keys.isValidMnemonic(mnemonic)
359+ return wallet.isValidMnemonic(mnemonic)
281360 }
282361
283362 account.isValidKeystore = function(keystore, context) {
@@ -339,10 +418,10 @@ account.isAliasValid = function(alias, context){
339418
340419 account.decryptMnemonic = function(vault,password, context) {
341420 const keystore = context.bytom.currentAccount.keystore;
342- return bytom.keys.decryptMnemonic(vault, password, keystore)
421+ // return bytom.keys.decryptMnemonic(vault, password, keystore)
422+ return wallet.decryptMnemonic(vault, password, keystore)
343423 }
344424
345-
346425 account.createOld = function(accountAlias, keyAlias, passwd, success, error) {
347426 let retPromise = new Promise((resolve, reject) => {
348427 if(!keyAlias){
@@ -368,7 +447,8 @@ account.createOld = function(accountAlias, keyAlias, passwd, success, error) {
368447 }
369448
370449 account.isValidPassword = function(keystore, password){
371- return bytom.keys.verifyPassword(keystore, password)
450+ // return bytom.keys.verifyPassword(keystore, password)
451+ return wallet.isValidPassword(password, keystore)
372452 }
373453
374454 export default account
--- a/src/models/query.js
+++ b/src/models/query.js
@@ -1,13 +1,16 @@
11 import bytom from "./bytom";
2+import { wallet } from './wallet'
23
34 let query = {};
45
56 query.chainStatus = function() {
6- return bytom.query.getVoteStatus();
7+ return wallet.getVoteStatus()
8+ // return bytom.query.getVoteStatus();
79 };
810
911 query.blockStatus = function() {
10- return bytom.query.getblockcount();
12+ // return bytom.query.getblockcount();
13+ return wallet.getChainStatus()
1114 };
1215
1316 export default query;
--- a/src/models/transaction.js
+++ b/src/models/transaction.js
@@ -1,16 +1,22 @@
11 import bytom from "./bytom";
22 import { snakeize } from "@/utils/utils";
33 import { networks } from '@/utils/constants'
4-
4+import { wallet } from './wallet'
55
66 let transaction = {};
77
8-transaction.list = function(guid, asset_id, start, limit, tx_types) {
8+transaction.list = function(address, asset_id, start, limit, tx_types) {
99 const filter = {asset_id}
1010 if(tx_types){
11- filter.tx_types = tx_types
11+ filter.txType = tx_types[0]
1212 }
13- return bytom.transaction.list(guid, filter, null, start, limit);
13+ // return bytom.transaction.list(guid, filter, null, start, limit);
14+ return wallet.getTransactions({
15+ address,
16+ limit,
17+ start,
18+ filter
19+ })
1420 };
1521
1622 transaction.listDelayTransaction = function(address, start, limit, network) {
@@ -19,9 +25,9 @@ transaction.listDelayTransaction = function(address, start, limit, network) {
1925 }
2026
2127 let baseURL = networks[network]
22- if(network==='testnet'){
23- baseURL = baseURL+':3008'
24- }
28+ // if(network==='testnet'){
29+ // baseURL = baseURL+':3008'
30+ // }
2531 return bytom.transaction.listDelayTransaction(baseURL, address, start, limit);
2632 };
2733
@@ -29,8 +35,9 @@ transaction.convertArgument = function(argArray) {
2935 let fn = function asyncConvert(object){
3036 const type = object.type
3137 const value = object.value
32- return bytom.transaction.convertArgument(type, value)
33- .then(resp => resp.value);
38+ // return bytom.transaction.convertArgument(type, value)
39+ // .then(resp => resp.value);
40+ return wallet.convertArgument(type, value)
3441 };
3542
3643 let actionFunction = argArray.map(fn)
@@ -38,25 +45,35 @@ transaction.convertArgument = function(argArray) {
3845 };
3946
4047 transaction.chainStatus = function() {
41- return bytom.query.getblockcount();
48+ return wallet.getChainStatus()
49+ // return bytom.query.getblockcount();
4250 };
4351
4452 transaction.asset = function(asset_id) {
45- return bytom.query.asset(asset_id);
53+ return wallet.getAsset(asset_id)
54+ // return bytom.query.asset(asset_id);
4655 };
4756
4857 transaction.build = function(address, to, asset, amount, fee, confirmations) {
49- let retPromise = new Promise((resolve, reject) => {
50- bytom.transaction
51- .buildPayment(address, to, asset, amount.toString(), confirmations)
52- .then(res => {
53- resolve(res);
54- })
55- .catch(error => {
56- reject(error);
57- });
58- });
59- return retPromise;
58+ return wallet.buildPayment({
59+ address,
60+ asset,
61+ confirmations,
62+ recipients: {
63+ [to]: amount.toString()
64+ }
65+ })
66+ // let retPromise = new Promise((resolve, reject) => {
67+ // bytom.transaction
68+ // .buildPayment(address, to, asset, amount.toString(), confirmations)
69+ // .then(res => {
70+ // resolve(res);
71+ // })
72+ // .catch(error => {
73+ // reject(error);
74+ // });
75+ // });
76+ // return retPromise;
6077 };
6178
6279 transaction.buildCrossChain = function(address, to, asset, amount, confirmations) {
@@ -74,31 +91,45 @@ transaction.buildCrossChain = function(address, to, asset, amount, confirmations
7491 };
7592
7693 transaction.buildVote = function(address, vote, amount, confirmations, memo) {
77- let retPromise = new Promise((resolve, reject) => {
78- bytom.transaction
79- .buildVote(address, vote, amount.toString(), confirmations, memo)
80- .then(res => {
81- resolve(res);
82- })
83- .catch(error => {
84- reject(error);
85- });
86- });
87- return retPromise;
94+ return wallet.buildVote({
95+ address,
96+ amount: amount.toString(),
97+ vote,
98+ confirmations,
99+ memo
100+ })
101+ // let retPromise = new Promise((resolve, reject) => {
102+ // bytom.transaction
103+ // .buildVote(address, vote, amount.toString(), confirmations, memo)
104+ // .then(res => {
105+ // resolve(res);
106+ // })
107+ // .catch(error => {
108+ // reject(error);
109+ // });
110+ // });
111+ // return retPromise;
88112 };
89113
90114 transaction.buildVeto = function(address, vote, amount, confirmations, memo) {
91- let retPromise = new Promise((resolve, reject) => {
92- bytom.transaction
93- .buildVeto(address, vote, amount.toString(), confirmations, memo)
94- .then(res => {
95- resolve(res);
96- })
97- .catch(error => {
98- reject(error);
99- });
100- });
101- return retPromise;
115+ return wallet.buildVeto({
116+ address,
117+ vote,
118+ amount: amount.toString(),
119+ confirmations,
120+ memo
121+ })
122+ // let retPromise = new Promise((resolve, reject) => {
123+ // bytom.transaction
124+ // .buildVeto(address, vote, amount.toString(), confirmations, memo)
125+ // .then(res => {
126+ // resolve(res);
127+ // })
128+ // .catch(error => {
129+ // reject(error);
130+ // });
131+ // });
132+ // return retPromise;
102133 };
103134
104135 transaction.buildTransaction = function(address, inputs, outputs, gas, confirmations) {
@@ -133,19 +164,19 @@ transaction.signTransaction = function(address, transaction, password, context)
133164 return retPromise;
134165 };
135166
136-transaction.decodeTransaction = function(rawTx) {
137- let retPromise = new Promise((resolve, reject) => {
138- bytom.transaction
139- .decodeTransaction(rawTx)
140- .then(res => {
141- resolve(res);
142- })
143- .catch(error => {
144- reject(error);
145- });
146- });
147- return retPromise;
148-};
167+// transaction.decodeTransaction = function(rawTx) {
168+// let retPromise = new Promise((resolve, reject) => {
169+// bytom.transaction
170+// .decodeTransaction(rawTx)
171+// .then(res => {
172+// resolve(res);
173+// })
174+// .catch(error => {
175+// reject(error);
176+// });
177+// });
178+// return retPromise;
179+// };
149180
150181 transaction.transfer = function(transaction, password, address, context) {
151182 let retPromise = new Promise((resolve, reject) => {
@@ -153,9 +184,23 @@ transaction.transfer = function(transaction, password, address, context) {
153184 const {to, asset, amount, confirmations} = transaction
154185 // transfer to multi address
155186 if (typeof to === 'object') {
156- return bytom.transaction.buildPayment(address, to, asset, null, confirmations)
187+ return wallet.buildPayment({
188+ address,
189+ recipients: to,
190+ asset,
191+ confirmations
192+ })
193+ // return bytom.transaction.buildPayment(address, to, asset, null, confirmations)
157194 } else {
158- return bytom.transaction.buildPayment(address, to.trim(), asset, amount.toString(), confirmations)
195+ return wallet.buildPayment({
196+ address,
197+ recipients: {
198+ [to.trim()]: amount.toString()
199+ },
200+ asset,
201+ confirmations
202+ })
203+ // return bytom.transaction.buildPayment(address, to.trim(), asset, amount.toString(), confirmations)
159204 }
160205 }
161206 build().then(result => {
@@ -185,8 +230,13 @@ function signSubmit (txObject, password, address, context) {
185230 context
186231 )
187232 .then(ret => {
188- return bytom.transaction
189- .submitPayment(address, ret.raw_transaction, ret.signatures)
233+ return wallet.submitPayment({
234+ address,
235+ rawTransaction: ret.raw_transaction,
236+ signatures: ret.signatures
237+ })
238+ // return bytom.transaction
239+ // .submitPayment(address, ret.raw_transaction, ret.signatures)
190240 .then(res3 => {
191241 const object = {
192242 transactionHash: res3.txHash
@@ -208,8 +258,15 @@ function signSubmit (txObject, password, address, context) {
208258 transaction.signMessage = function(message, password, address, context) {
209259 const keyArray = context.bytom.keychain.findByAddress(address, context.bytom.settings.network);
210260 const key = typeof keyArray.keystore ==='string'? keyArray.keystore :JSON.stringify(keyArray.keystore);
211-
212- return bytom.keys.signMessageJsPromise(message, password,key);
261+ // return bytom.keys.signMessageJsPromise(message, password,key);
262+ return new Promise((resolve, reject) => {
263+ try {
264+ const data = wallet.signMessageOffline(message, password, key)
265+ resolve(data)
266+ } catch(e) {
267+ reject(e)
268+ }
269+ })
213270 };
214271
215272 transaction.advancedTransfer = function(address, transaction, password, arrayData, context) {
@@ -225,8 +282,13 @@ transaction.advancedTransfer = function(address, transaction, password, arrayDat
225282 if(arrayData){
226283 signatures[0] = arrayData
227284 }
228- bytom.transaction
229- .submitPayment(address, ret.raw_transaction, signatures)
285+ wallet.submitPayment({
286+ address,
287+ rawTransaction: ret.raw_transaction,
288+ signatures
289+ })
290+ // bytom.transaction
291+ // .submitPayment(address, ret.raw_transaction, signatures)
230292 .then(res3 => {
231293 const object ={
232294 transactionHash: res3.txHash
@@ -251,15 +313,25 @@ function signTx(address, transaction, password, context){
251313 if(!keyArray){
252314 throw 'Account not found.'
253315 }else{
254- const key = JSON.stringify(keyArray.keystore)
255- return bytom.transaction._signTransactionJsPromise(transaction,
256- password,
257- key)
316+ // const key = JSON.stringify(keyArray.keystore)
317+ return new Promise((resolve, reject) => {
318+ try {
319+ console.log(transaction, password, keyArray.keystore);
320+ const data = wallet.signTransactionOffline(transaction, password, keyArray.keystore)
321+ resolve(data)
322+ } catch(e) {
323+ reject(e)
324+ }
325+ })
326+ // return bytom.transaction._signTransactionJsPromise(transaction,
327+ // password,
328+ // key)
258329 }
259330 }
260331
261332 transaction.estimateFee = function(address, asset_amounts, confirmations){
262- return bytom.transaction.estimateFee(address, asset_amounts, confirmations)
333+ return wallet.estimateTxFee(address, asset_amounts, confirmations)
334+ // return bytom.transaction.estimateFee(address, asset_amounts, confirmations)
263335 }
264336
265337 export default transaction;
--- /dev/null
+++ b/src/models/wallet.js
@@ -0,0 +1,27 @@
1+import { Wallet, provider } from 'bytom'
2+
3+const blockCenterProvider = new provider.BlockCenterProvider({
4+ beforeRequest (config) {
5+ config.headers = Object.assign(config.header || {}, {
6+ from: 'byone',
7+ version: window.__bytom && window.__bytom.meta.version,
8+ device_id: window.__bytom && window.__bytom.settings.clientId
9+ })
10+ return config
11+ }
12+})
13+export const wallet = new Wallet({
14+ blockCenterProvider,
15+ net: 'mainnet',
16+ chain: 'bytom'
17+})
18+
19+export function setNet(net) {
20+ wallet.setNet(net)
21+}
22+
23+export function setChain(chain) {
24+ wallet.setChain(chain)
25+}
26+
27+window.wallet = wallet
--- a/src/popup.js
+++ b/src/popup.js
@@ -113,6 +113,17 @@ store.dispatch(Actions.LOAD_BYTOM).then(() => {
113113 },
114114 );
115115
116+ // store.watch(
117+ // (state, getters) => getters.chainType,
118+ // (newValue, oldValue) => {
119+ // console.log('change');
120+ // if(newValue !== oldValue){
121+ // wallet.setChain(getters.chainType)
122+ // // account.setupNet(`${store.getters.net}${store.getters.netType}`)
123+ // }
124+ // },
125+ // );
126+
116127 const lang = store.getters.language === 'zh'?'cn':'en'
117128
118129 getDomains(lang).then(({domains, domainMeta})=>{
--- a/src/prompt.js
+++ b/src/prompt.js
@@ -35,7 +35,7 @@ import { Integrations } from '@sentry/tracing';
3535 import BytomObj from "./utils/Bytom";
3636
3737 import { updateLockTime, isNeedLock } from '@/models/lock'
38-
38+import { wallet } from './models/wallet.js'
3939 store.dispatch(Actions.LOAD_BYTOM).then(() => {
4040 Vue.use(VueI18n)
4141 const i18n = new VueI18n({
@@ -115,6 +115,15 @@ store.dispatch(Actions.LOAD_BYTOM).then(() => {
115115 },
116116 );
117117
118+ // store.watch(
119+ // (state, getters) => getters.chainType,
120+ // (newValue, oldValue) => {
121+ // wallet.setChain(getters.chainType === 'bytom2' ? 'bytom' : 'bytom1')
122+ // console.log(getters.chainType === 'bytom2' ? 'bytom' : 'bytom1');
123+ // console.log(wallet.chain);
124+ // },
125+ // );
126+
118127 getDomains().then(({domains, domainMeta})=>{
119128 const _bytom = store.state.bytom.clone()
120129
--- a/src/router.js
+++ b/src/router.js
@@ -16,6 +16,7 @@ export const RouteNames = {
1616 SETTINGS_LANG:'settings-language',
1717 SETTINGS_CURRENCY:'settings-currency',
1818 SETTINGS_NETWORK:'settings-network',
19+ SETTINGS_CHAIN:'settings-chain',
1920 SETTINGS_DELETE:'settings-delete',
2021
2122 TRANSFER:'transfer',
@@ -168,6 +169,14 @@ const routers = [
168169 }
169170 },
170171 {
172+ path: '/settings-chain',
173+ name: RouteNames.SETTINGS_CHAIN,
174+ meta: { title: '切换链' },
175+ component: resolve => {
176+ require(['@/views/settings/chainSelection.vue'], resolve)
177+ }
178+ },
179+ {
171180 path: '/settings-delete',
172181 name: RouteNames.SETTINGS_DELETE,
173182 meta: { title: '删除钱包' },
--- a/src/store/store.js
+++ b/src/store/store.js
@@ -24,6 +24,18 @@ const state = {
2424 const getters = {
2525 meta:state => state.bytom.meta,
2626 currentAccount:state => state.bytom.currentAccount,
27+ currentAddress: state => {
28+ if (!state.bytom || !state.bytom.currentAccount) return
29+ if (state.bytom.settings.netType === 'vapor') return state.bytom.currentAccount.vpAddress
30+ if (state.bytom.settings.chainType === 'bytom1') return state.bytom.currentAccount.bytom1 && state.bytom.currentAccount.bytom1.address
31+ return state.bytom.currentAccount.address
32+ },
33+ currentBalances: state => {
34+ if (!state.bytom || !state.bytom.currentAccount) return
35+ if (state.bytom.settings.netType === 'vapor') return state.bytom.currentAccount.vpBalances
36+ if (state.bytom.settings.chainType === 'bytom1') return state.bytom.currentAccount.bytom1 && state.bytom.currentAccount.bytom1.balances
37+ return state.bytom.currentAccount.balances
38+ },
2739 accountList:state => state.bytom.accountList,
2840 net:state => state.bytom.settings.network,
2941 netType:state => state.bytom.settings.netType,
@@ -32,13 +44,15 @@ const getters = {
3244 vMnemonic:state => state.bytom.currentAccount.vMnemonic,
3345 currency:state => state.bytom.settings.currency,
3446 clientId:state => state.bytom.settings.clientId,
47+ chainType:state => state.bytom.settings.chainType,
48+
3549 pairs: state => state.bytom.keychain.pairs,
3650
3751 // FOR PROMPTS ONLY
3852 messages:state => state.prompt.data.messages || [],
3953 };
4054
41-export const store = new Vuex.Store({
55+export const store = window.store = new Vuex.Store({
4256 state,
4357 getters,
4458 mutations,
--- a/src/utils/Bytom.js
+++ b/src/utils/Bytom.js
@@ -9,6 +9,7 @@ export default class BytomObj {
99 this.settings = Settings.placeholder();
1010 this.keychain = Keychain.placeholder();
1111 this.histories = [];
12+ window.__bytom = this
1213 }
1314
1415 static placeholder(){ return new BytomObj(); }
--- a/src/utils/Keychain.js
+++ b/src/utils/Keychain.js
@@ -14,7 +14,7 @@ export default class Keychain {
1414
1515 findIdentity(publicKey, net){ return Object.values(this.pairs[net]).find(id => id.xpub === publicKey); }
1616 findByGuid(guid, net){ return Object.values(this.pairs[net]).find(id => id.guid === guid); }
17- findByAddress(address, net){ return Object.values(this.pairs[net]).find(id => id.address === address || id.vpAddress=== address); }
17+ findByAddress(address, net){ return Object.values(this.pairs[net]).find(id => id.address === address || id.vpAddress=== address || id.bytom1.address === address); }
1818
1919 removeByAlias(alias, net){
2020 if(this.pairs[net][alias]){
--- a/src/utils/Settings.js
+++ b/src/utils/Settings.js
@@ -7,6 +7,7 @@ export default class Settings {
77 this.domains = []
88 this.language = uiLang||'en';
99 this.netType ='bytom';
10+ this.chainType = 'bytom2'
1011 this.network ='mainnet';
1112 // this.network ='testnet';
1213 this.currency = uiLang ==='en'?'inUsd':"inCny"
--- a/src/utils/address.js
+++ b/src/utils/address.js
@@ -18,7 +18,7 @@ export default class address {
1818 const vpArray = ['vp', 'tp', 'sp']
1919 return vpArray.includes( address.substring(0,2) )
2020 }else{
21- const bmArray = ['bm', 'tm', 'sm']
21+ const bmArray = ['bm', 'tm', 'sm', 'bn', 'tn']
2222 return bmArray.includes( address.substring(0,2) )
2323 }
2424 }
--- a/src/utils/constants.js
+++ b/src/utils/constants.js
@@ -22,14 +22,22 @@ export const camelize = (object) => {
2222
2323 export const networks = {
2424 mainnet:'https://bcapi.movapi.com',
25- testnet: localStorage.getItem('testnet') || 'http://52.83.11.181'
25+ testnet: localStorage.getItem('testnet') || 'https://test-bcapi.movapi.com',
26+}
27+
28+export const blockmetaNetworks = {
29+ mainnet: 'http://bcapi.movapi.com/blockmeta/bytom2/v1',
30+ testnet: 'http://btm2test.blockmeta.com/api/v1'
2631 }
2732
2833 export const networksJS = {
29- mainnetbytom: `${networks['mainnet']}/bytom/v3/`,
34+ mainnetbytom: `${networks['mainnet']}/bycoin/bytom2/v1/`,
3035 mainnetvapor: `${networks['mainnet']}/vapor/v3/` ,
31- testnetbytom: `${networks['testnet']}:4000/bytom/v3/`,
32- testnetvapor: `${networks['testnet']}:3000/vapor/v3/` ,
36+ mainnetbytom1: `${networks['mainnet']}/bytom/v3/`,
37+
38+ testnetbytom: `${networks['testnet']}/bycoin/bytom2/v1/`,
39+ testnetvapor: `${networks['testnet']}/vapor/v3/` ,
40+ testnetbytom1: `${networks['testnet']}/bytom/v3/`,
3341 }
3442
3543
@@ -54,5 +62,5 @@ export const decimalsMap = {
5462 }
5563
5664 //Todo: update to production
57-export const bappRequestUrl = 'https://raw.githubusercontent.com/movnetwork/Byone/master/src/assets/bapp/bapp.json'
58-export const bappImgUrl = 'https://raw.githubusercontent.com/movnetwork/Byone/master/src/assets/img/bapp/'
65+export const bappRequestUrl = 'https://raw.githubusercontent.com/movnetwork/Byone/pro/src/assets/bapp/bapp.json'
66+export const bappImgUrl = 'https://raw.githubusercontent.com/movnetwork/Byone/pro/src/assets/img/bapp/'
--- a/src/utils/errors/Error.js
+++ b/src/utils/errors/Error.js
@@ -32,8 +32,12 @@ export default class Error {
3232 return new Error(ErrorTypes.TYPE_DISAUTH, `The current domain is no auth, it can't be disauth`, ErrorCodes.TYPE_DISAUTH)
3333 }
3434
35+ static forbidden() {
36+ return new Error(ErrorTypes.FORBIDDEN, `Authorization denied`, ErrorCodes.FORBIDDEN)
37+ }
38+
3539 static promptClosedWithoutAction(){
36- return new Error(ErrorTypes.PROMPT_CLOSED, "The user closed the prompt without any action.", ErrorCodes.TIMED_OUT)
40+ return new Error(ErrorTypes.PROMPT_CLOSED, "The user closed the prompt without any action.", ErrorCodes.FORBIDDEN)
3741 }
3842
3943 static signatureError(_type, _message){
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -66,21 +66,23 @@ export function getDomains(lang = 'en'){
6666 }
6767
6868 updateDomainMeta(bappData, domainMeta, lang)
69-
70- return fetch(bappRequestUrl)
71- .then(response => response.json())
72- .then(json => {
73- if(!_.isEqual(json, bappData)){
74- domains = json.list.filter( l => l.link!== undefined).map(a => a.link.split('/')[2]);
75- updateDomainMeta(json, domainMeta, lang)
76- }
77-
78- domains.push(crossChainLink)
79- return {domains, domainMeta};
80- }).catch((e)=>{
81- domains.push(crossChainLink)
82- return {domains, domainMeta};
83- });
69+ return Promise.resolve({
70+ domains, domainMeta
71+ })
72+ // return fetch(bappRequestUrl)
73+ // .then(response => response.json())
74+ // .then(json => {
75+ // if(!_.isEqual(json, bappData)){
76+ // domains = json.list.filter( l => l.link!== undefined).map(a => a.link.split('/')[2]);
77+ // updateDomainMeta(json, domainMeta, lang)
78+ // }
79+
80+ // domains.push(crossChainLink)
81+ // return {domains, domainMeta};
82+ // }).catch((e)=>{
83+ // domains.push(crossChainLink)
84+ // return {domains, domainMeta};
85+ // });
8486 }
8587
8688 function updateDomainMeta(jsonData, domainMeta, lang){
--- a/src/views/assetList.vue
+++ b/src/views/assetList.vue
@@ -114,8 +114,10 @@ font-size: 15px;
114114 </section>
115115 <section class="transaction-title">
116116 <div :class="{'color-black': (type==='all') }" @click="changeType('all')" >{{ $t('listAsset.all') }}</div>
117- <div :class="{'color-black': (type==='transfer_in') }" @click="changeType('transfer_in')" >{{ $t('common.transfer_in') }}</div>
117+ <!-- <div :class="{'color-black': (type==='transfer_in') }" @click="changeType('transfer_in')" >{{ $t('common.transfer_in') }}</div> -->
118118 <div :class="{'color-black': (type==='transfer_out') }" @click="changeType('transfer_out')" >{{ $t('common.transfer_out') }}</div>
119+ <div :class="{'color-black': (type==='vote') }" @click="changeType('vote')" >{{ $t('common.vote') }}</div>
120+ <div :class="{'color-black': (type==='cross_chain') }" @click="changeType('cross_chain')" >{{ $t('common.cross_chain') }}</div>
119121 </section>
120122
121123 <section class="transactions">
@@ -126,14 +128,14 @@ font-size: 15px;
126128 <div class="font-bold">
127129 {{transaction.type}}
128130 </div>
129- <div class="addr color-grey" >{{transaction.address}}</div>
130-
131+ <div class="addr color-grey" v-if="!transaction.vote">{{transaction.address}}</div>
132+ <div class="addr color-grey" v-else>{{formatVoteAddress(transaction)}}</div>
131133 </div>
132134 <div class="text-align-right">
133135 <div class="value">{{transaction.direct}}{{transaction.val}} {{currentAsset.asset.symbol}}</div>
134136
135- <div class="addr color-red" v-if="!transaction.status">
136- {{ $t('listAsset.fail') }}
137+ <div class="addr color-red" v-if="!transaction.blockHeight">
138+ {{ $t('listAsset.confirming') }}
137139 </div>
138140 <div class="addr color-grey" v-else-if="transaction.hasOwnProperty('blockTimestamp')">
139141 {{transaction.submissionTimestamp | moment}}
@@ -160,11 +162,12 @@ font-size: 15px;
160162 </template>
161163
162164 <script>
165+import axios from 'axios'
163166 import address from "@/utils/address";
164167 import query from "@/models/query";
165168 import transaction from "@/models/transaction";
166169 import { camelize } from "@/utils/utils";
167-import { BTM } from "@/utils/constants";
170+import { BTM, blockmetaNetworks } from "@/utils/constants";
168171 import { mapActions, mapGetters, mapState } from 'vuex'
169172 import * as Actions from '@/store/constants';
170173 import _ from 'lodash';
@@ -202,13 +205,13 @@ export default {
202205 },
203206 },
204207 computed: {
205- address: function(){
206- if(this.netType === 'vapor'){
207- return this.currentAccount.vpAddress
208- }else{
209- return this.currentAccount.address
210- }
211- },
208+ // address: function(){
209+ // if(this.netType === 'vapor'){
210+ // return this.currentAccount.vpAddress
211+ // }else{
212+ // return this.currentAccount.address
213+ // }
214+ // },
212215 ...mapState([
213216 'bytom',
214217 'currentAsset',
@@ -218,12 +221,17 @@ export default {
218221 'language',
219222 'currentAccount',
220223 'currency',
221- 'netType'
224+ 'netType',
225+ 'net',
226+ 'currentAddress'
222227 ])
223228 },
224229 methods: {
225230 img:function (symbol) {
226- const _symbol = symbol.toLowerCase();
231+ let _symbol = symbol.toLowerCase();
232+ if (_symbol === 'btm') {
233+ _symbol = 'btm2'
234+ }
227235 if(this.netType === 'vapor'){
228236 return `https://cdn.blockmeta.com/resources/logo/vapor/${_symbol}.png`
229237 }else{
@@ -252,6 +260,16 @@ export default {
252260 formatCurrency: function (num) {
253261 return Num.formatCurrency(num, this.currency)
254262 },
263+ formatVoteAddress: function (transaction) {
264+ const node = this.listVote[transaction.vote]
265+ if (node) {
266+ if (this.language ==='zh') {
267+ return node.name || '-'
268+ } else {
269+ return node.nameEn || '-'
270+ }
271+ }
272+ },
255273 itemBalance: function(asset){
256274 if(asset.asset.assetId === BTM){
257275 return Num.formatNue(asset.balance,8)
@@ -286,17 +304,23 @@ export default {
286304 let type_txs
287305 switch (type){
288306 case 'transfer_out':
289- type_txs = ["transfer_out"];
307+ type_txs = ["ordinary"];
290308 break;
291309 case 'transfer_in':
292- type_txs = ["transfer_in"];
310+ type_txs = ["ordinary"];
311+ break;
312+ case 'vote':
313+ type_txs = ["vote"];
314+ break;
315+ case 'cross_chain':
316+ type_txs = ["cross_chain"];
293317 break;
294318 default:
295319 type_txs = []
296320 break;
297321 }
298322
299- transaction.list(this.address, this.currentAsset.asset.assetId, start, limit, type_txs).then(transactions => {
323+ transaction.list(this.currentAddress, this.currentAsset.asset.assetId, start, limit, type_txs).then(transactions => {
300324 if (transactions == null) {
301325 return;
302326 }
@@ -318,11 +342,11 @@ export default {
318342 .filter(b => b.asset.assetId === assetID);
319343
320344 const inputAddresses = transaction.inputs
321- .filter(input => input.asset.assetId === assetID && input.address !== this.address)
345+ .filter(input => input.asset.assetId === assetID && input.address !== this.currentAddress)
322346 .map(input => input.address)
323347
324348 const outputAddresses = transaction.outputs
325- .filter(output => output.asset.assetId === assetID && output.address !== this.address)
349+ .filter(output => output.asset.assetId === assetID && output.address !== this.currentAddress)
326350 .map(output => output.address)
327351
328352 if(balanceObject.length ===1 ){
@@ -349,11 +373,11 @@ export default {
349373 transaction.type = this.$t("common.transfer_out");
350374 }
351375
352- const resultAddr = outputAddresses.pop() || this.address
376+ const resultAddr = outputAddresses.pop() || this.currentAddress
353377 transaction.address = (resultAddr && resultAddr.includes(' '))?resultAddr:address.short(resultAddr);
354378 }
355379
356- if(transaction.types.includes('in_crosschain')){
380+ if(transaction.types.includes('cross_chain')){
357381 const chain = this.netType ==='vapor'? this.$t("listAsset.main"):this.$t("listAsset.side")
358382 let symbol = this.currentAsset.asset.symbol
359383 if(symbol =='SUP' ){
@@ -364,16 +388,19 @@ export default {
364388 symbol='ETH'
365389 }
366390 transaction.address = `${symbol} ${chain}`
391+ transaction.type = this.$t("common.cross_chain")
367392 }else if(transaction.types.includes('vote')){
368393 const pubKey = transaction.outputs.find( i => i.type ==='vote').vote
369- const item = this.listVote[pubKey]
370- transaction.address = item? (((this.language ==='zh' || this.language ==='cn')? (item.name ==='-'? null: item.name):item.nameEn)||address.short(item.pubKey)):'-'
394+ // const item = this.listVote[pubKey]
395+ // transaction.address = item? (((this.language ==='zh' || this.language ==='cn')? (item.name ==='-'? null: item.name):item.nameEn)||address.short(item.pubKey)):'-'
371396 transaction.type = this.$t("common.vote")
397+ transaction.vote = pubKey
372398 }else if(transaction.types.includes('veto')){
373399 const pubKey = transaction.inputs.find( i => i.type ==='veto').vote
374- const item = this.listVote[pubKey]
375- transaction.address = item? (((this.language ==='zh' || this.language ==='cn')? (item.name ==='-'? null: item.name):item.nameEn)||address.short(item.pubKey)):'-'
400+ // const item = this.listVote[pubKey]
401+ // transaction.address = item? (((this.language ==='zh' || this.language ==='cn')? (item.name ==='-'? null: item.name):item.nameEn)||address.short(item.pubKey)):'-'
376402 transaction.type = this.$t("common.veto")
403+ transaction.vote = pubKey
377404 }
378405 transaction.val = val ;
379406
@@ -384,8 +411,8 @@ export default {
384411 }
385412 transaction.val = 0
386413 let resultAddr = transaction.outputs
387- .find(output => output.address !== this.address)
388- resultAddr = resultAddr? resultAddr.address : this.address
414+ .find(output => output.address !== this.currentAddress)
415+ resultAddr = resultAddr? resultAddr.address : this.currentAddress
389416
390417 transaction.address = address.short(resultAddr)
391418
@@ -403,12 +430,12 @@ export default {
403430 // this.refreshTransactions( this.start, limit, this.type).then(transactions => {
404431 // this.transactions = transactions
405432 // });
406- if(Object.keys(this.listVote).length == 0 && this.netType === 'vapor'){
407- query.chainStatus().then(resp => {
408- if(resp){
433+ if(Object.keys(this.listVote).length == 0 && this.netType === 'bytom'){
434+ axios.get(`${blockmetaNetworks[this.net]}/node/external-info`).then(resp => {
435+ if (resp.data && resp.data.code === 200) {
409436 const votes = {}
410- resp.consensusNodes.map( (item) => {
411- votes[item.pubKey] = item
437+ resp.data.data.forEach((item) => {
438+ votes[item.pub_key] = item
412439 });
413440 this[Actions.SET_LIST_VOTE](votes)
414441 }
--- a/src/views/backup/backupMnemonic.vue
+++ b/src/views/backup/backupMnemonic.vue
@@ -9,6 +9,7 @@
99 text-align: center;
1010 color: rgba(0, 0, 0, 0.88);
1111 margin: 10px 0;
12+ white-space: pre;
1213 }
1314
1415 .mnemnonic-box{
--- a/src/views/delayTxList.vue
+++ b/src/views/delayTxList.vue
@@ -155,11 +155,12 @@ export default {
155155 },
156156 computed: {
157157 address: function(){
158- if(this.netType === 'vapor'){
159- return this.currentAccount.vpAddress
160- }else{
161- return this.currentAccount.address
162- }
158+ return this.currentAddress
159+ // if(this.netType === 'vapor'){
160+ // return this.currentAccount.vpAddress
161+ // }else{
162+ // return this.currentAccount.address
163+ // }
163164 },
164165 ...mapState([
165166 'bytom',
@@ -169,6 +170,7 @@ export default {
169170 ...mapGetters([
170171 'language',
171172 'currentAccount',
173+ 'currentAddress',
172174 'currency',
173175 'netType',
174176 'net'
--- a/src/views/home.vue
+++ b/src/views/home.vue
@@ -319,12 +319,12 @@ input:checked + .slider:before {
319319 </section>
320320 <section v-if="address!=undefined" class="transaction-title">
321321 <h3 class="color-black">{{ $t('main.asset') }}</h3>
322- <a class="delay-btn" @click="delayOpen"><i class="iconfont icon_SBell"></i>{{ $t('delayTx.title') }}</a>
322+ <!-- <a class="delay-btn" @click="delayOpen"><i class="iconfont icon_SBell"></i>{{ $t('delayTx.title') }}</a> -->
323323 </section>
324324 <section class="assets">
325- <div v-if=" balances && balances.length > 0">
325+ <div v-if=" currentBalances && currentBalances.length > 0">
326326 <ul class="list">
327- <li class="list-item" v-for="(balance, index) in balances" :key="index" @click="assetOpen(balance)">
327+ <li class="list-item" v-for="(balance, index) in currentBalances" :key="index" @click="assetOpen(balance)">
328328 <div class="symbol" v-if="balance.asset.symbol!== 'Asset'">
329329 <img :src="img(balance.asset.symbol)" alt="" class="c-icon" v-on:error="onImgError">
330330 <div class="uppercase">
@@ -410,6 +410,7 @@ export default {
410410 symbol: "BTM",
411411 decimals: 8
412412 } ,
413+ balance: 0,
413414 availableBalance: 0,
414415 inBtc: "0",
415416 inCny: "0",
@@ -421,6 +422,7 @@ export default {
421422 },
422423 watch: {
423424 '$route'(to, from) {
425+ this.refreshBalance(this.address)
424426 if (to.name.startsWith('menu')) {
425427 this.maskShow = true
426428 } else if (from.name.startsWith('menu')) {
@@ -443,19 +445,19 @@ export default {
443445 return;
444446 }
445447
446- let addr
447- if(this.netType === 'vapor'){
448- addr = newVal.vpAddress
449- }else{
450- addr = newVal.address
451- }
452- this.refreshBalance(addr)
448+ // let addr
449+ // if(this.netType === 'vapor'){
450+ // addr = newVal.vpAddress
451+ // }else{
452+ // addr = newVal.address
453+ // }
454+ // this.refreshBalance(addr)
453455 },
454456 },
455457 computed: {
456458 accountBalance: function () {
457459 let balance
458- const balances = this.balances
460+ const balances = this.currentBalances
459461
460462 if(balances && balances.length >0 ){
461463 const currency = camelize(this.currency)
@@ -469,14 +471,14 @@ export default {
469471 const vpAddress = this.currentAccount.vpAddress
470472 if(!vpAddress){
471473 const bytom = this.bytom.clone();
472- return account.copy(this.currentAccount.guid).then(accounts => {
474+ return account.copy(this.currentAccount.bytom1.guid).then(accounts => {
473475 //update currentAccount
474476 bytom.currentAccount.vpAddress = accounts.address
475477 //update AccountList
476478 bytom.keychain.pairs[this.net][bytom.currentAccount.alias].vpAddress = accounts.address
477479
478480 this[Actions.UPDATE_STORED_BYTOM](bytom).then(() => {
479- this.setupRefreshTimer()
481+ // this.setupRefreshTimer()
480482 })
481483
482484 return accounts.address
@@ -484,30 +486,39 @@ export default {
484486 }else return vpAddress
485487
486488 }else{
487- return this.currentAccount.address
488- }
489- },
490- balances: function(){
491- if(this.netType === 'vapor'){
492- return this.currentAccount.vpBalances
493- }else{
494- return this.currentAccount.balances
489+ return this.currentAddress
490+ // return this.currentAccount.address
495491 }
496492 },
493+ // balances: function(){
494+ // if(this.netType === 'vapor'){
495+ // return this.currentAccount.vpBalances
496+ // }else if (this.chainType === 'bytom1'){
497+ // return this.currentAccount.bytom1.balances
498+ // } else {
499+ // return this.currentAccount.balances
500+ // }
501+ // },
497502 ...mapState([
498503 'bytom'
499504 ]),
500505 ...mapGetters([
501506 'currentAccount',
507+ 'currentAddress',
508+ 'currentBalances',
502509 'accountList',
503510 'net',
504511 'netType',
512+ 'chainType',
505513 'currency'
506514 ])
507515 },
508516 methods: {
509517 img:function (symbol) {
510- const _symbol = symbol.toLowerCase();
518+ let _symbol = symbol.toLowerCase();
519+ if (_symbol === 'btm') {
520+ _symbol = 'btm2'
521+ }
511522 if(this.netType === 'vapor'){
512523 return `https://cdn.blockmeta.com/resources/logo/vapor/${_symbol}.png`
513524 }else{
@@ -544,20 +555,20 @@ export default {
544555 },
545556 netTypeToggle: function () {
546557 const bytom = this.bytom.clone();
547- const newNetType = this.isVapor? 'vapor':'bytom'
558+ const newNetType = this.isVapor ? 'vapor' : bytom.settings.chainType === 'bytom2' ? 'bytom' : 'bytom1'
548559
549560 bytom.settings.netType = newNetType;
550561
551562 account.setupNet(`${this.net}${newNetType}`)
552563 if(this.isVapor && !this.currentAccount.vpAddress){
553- account.copy(this.currentAccount.guid).then(accounts => {
564+ account.copy(this.currentAccount.bytom1.guid).then(accounts => {
554565 //update currentAccount
555566 bytom.currentAccount.vpAddress = accounts.address
556567 //update AccountList
557568 bytom.keychain.pairs[this.net][bytom.currentAccount.alias].vpAddress = accounts.address
558569
559570 this[Actions.UPDATE_STORED_BYTOM](bytom).then(()=>{
560- this.setupRefreshTimer()
571+ this.refreshBalance(this.address)
561572 })
562573 }).catch(error =>{
563574 let e = error
@@ -570,7 +581,8 @@ export default {
570581 })
571582 }else{
572583 this[Actions.UPDATE_STORED_BYTOM](bytom).then(()=>{
573- this.setupRefreshTimer()
584+ this.refreshBalance(this.address)
585+ // this.setupRefreshTimer()
574586 })
575587 }
576588 },
@@ -597,12 +609,12 @@ export default {
597609 this.$router.push('asset')
598610 },
599611 refreshBalance: function (address) {
600- if(address){
601- account.balance(address, this)
612+ // if(address){
613+ account.balance(this.currentAddress, this)
602614 .catch(error => {
603615 console.log(error);
604616 });
605- }
617+ // }
606618 },
607619 ...mapActions([
608620 Actions.UPDATE_STORED_BYTOM,
--- a/src/views/prompts/authentication.vue
+++ b/src/views/prompts/authentication.vue
@@ -61,7 +61,7 @@
6161 display: flex;
6262 justify-content: center;
6363 align-items: center;
64- width: 114px;
64+ width: 140px;
6565 border-radius: 12px;
6666 margin-left: auto;
6767 margin-right: auto;
--- a/src/views/prompts/bappPrompt.vue
+++ b/src/views/prompts/bappPrompt.vue
@@ -300,7 +300,7 @@
300300 import account from "@/models/account";
301301 import add from "@/utils/address";
302302 import { camelize, removeFromArray } from "@/utils/utils";
303- import bytomjslib from 'bytomjs-lib'
303+ // import bytomjslib from 'bytomjs-lib'
304304 import BigNumber from "bignumber.js"
305305
306306 export default {
@@ -326,11 +326,12 @@
326326 }
327327 },
328328 address: function () {
329- if (this.netType === 'vapor') {
330- return this.currentAccount.vpAddress
331- } else {
332- return this.currentAccount.address
333- }
329+ return this.currentAddress
330+ // if (this.netType === 'vapor') {
331+ // return this.currentAccount.vpAddress
332+ // } else {
333+ // return this.currentAccount.address
334+ // }
334335 },
335336 shortAddress: function () {
336337 if(this.prompt.data && this.prompt.data.type ==='transfer') {
@@ -338,11 +339,12 @@
338339 }else if(this.prompt.data && this.prompt.data.type ==='message'){
339340 return add.short(this.transaction.address);
340341 }else{
341- if (this.netType === 'vapor') {
342- return add.short(this.currentAccount.vpAddress);
343- } else {
344- return add.short(this.currentAccount.address);
345- }
342+ return add.short(this.currentAddress)
343+ // if (this.netType === 'vapor') {
344+ // return add.short(this.currentAccount.vpAddress);
345+ // } else {
346+ // return add.short(this.currentAccount.address);
347+ // }
346348 }
347349 },
348350 detail(){
@@ -377,6 +379,7 @@
377379 ]),
378380 ...mapGetters([
379381 'currentAccount',
382+ 'currentAddress',
380383 'net',
381384 'netType',
382385 'domainsMeta'
@@ -413,7 +416,9 @@
413416 return transaction.advancedTransfer(this.address, result[0], this.password, arrayData, this)
414417 .then((resp) => {
415418 loader.hide();
416- this.prompt.responder(resp);
419+ this.prompt.responder({
420+ hash: resp.transactionHash
421+ });
417422 this.$toast.success(
418423 this.$t("transfer.success")
419424 );
@@ -436,7 +441,9 @@
436441 } else if(this.prompt.data.type ==='transfer'){
437442 transaction.transfer(this.transaction, this.password, this.address, this).then(result => {
438443 loader.hide();
439- this.prompt.responder(result);
444+ this.prompt.responder({
445+ hash: result[0].transactionHash
446+ });
440447 this.$toast.success(
441448 this.$t("transfer.success")
442449 );
@@ -521,8 +528,9 @@
521528 return transaction.asset(assetID)
522529 }
523530 }, mounted() {
524- this.prompt = window.data || apis.extension.getBackgroundPage().notification || null;
531+ console.log('mounted')
525532 console.log(this.prompt)
533+ this.prompt = window.data || apis.extension.getBackgroundPage().notification || null;
526534
527535 const params = this.prompt.data
528536 if (params !== undefined) {
@@ -619,15 +627,15 @@
619627 }
620628 case "signTransaction":{
621629 const param = data[0] || data
622-
623630 const _tx = camelize(param)
624631 const rawTransaction = _tx.rawTransaction
625632
626- const tx = this.netType === 'vapor'?
627- bytomjslib.vapor.Transaction.decodeRawTransaction(rawTransaction):
628- bytomjslib.bytom.Transaction.decodeRawTransaction(rawTransaction)
629-
630- this.transaction.fee = tx.fee/100000000
633+ // const tx = this.netType === 'vapor'?
634+ // bytomjslib.vapor.Transaction.decodeRawTransaction(rawTransaction):
635+ // bytomjslib.bytom.Transaction.decodeRawTransaction(rawTransaction)
636+ const tx = _tx.tx
637+ // this.transaction.fee = new BigNumber(tx.fee / 100000000).toString()
638+ this.transaction.fee = tx.fee
631639 this.transaction.input = tx.inputs
632640 this.transaction.output = tx.outputs
633641
@@ -639,7 +647,7 @@
639647 const asset = _.union(inputAsset, outputAsset)
640648 let that = this;
641649
642- let types = ["transfer"]
650+ let types = ["transfer", "vote"]
643651 const promise =
644652 asset
645653 .map((assetId) => {
@@ -653,7 +661,7 @@
653661 const amount = inputAmount.minus(outputAmount)
654662
655663 const balanced_outputs = tx.outputs.find( o => o.amount === amount.toNumber())
656- if(balanced_outputs.type == 'cross_chain_out'){
664+ if(balanced_outputs.type == 'out_crosschain'){
657665 that.transaction.types = (that.$t('common.cross_chain'));
658666 }
659667
@@ -685,7 +693,8 @@
685693 types = removeFromArray(types, remove);
686694 types = types.map(ty => this.$t(`common.${ty}`)).join(', ');
687695
688- this.transaction.types = types
696+ // this.transaction.types = types
697+ this.transaction.types = tx.types.map(ty => this.$t(`common.${ty}`)).join(', ');
689698
690699 Promise.all(promise).then(function(output) {
691700 that.transaction.amounts = output
--- a/src/views/received.vue
+++ b/src/views/received.vue
@@ -103,37 +103,45 @@
103103 export default {
104104 data() {
105105 return {
106- addr: "111",
106+ addr: "",
107107 qrcode: Object,
108108 clipboard: new ClipboardJS(".address-text"),
109109 addressTitle: this.$t("main.copy"),
110- currentCoin:'BTM'
110+ currentCoin: 'BTM'
111111 };
112112 },
113113 computed: {
114114 coins: function(){
115- let symbols
116- if(this.netType === 'vapor'){
117- symbols = this.currentAccount.vpBalances.map(a => a.asset.symbol)
118- }else{
119- symbols = this.currentAccount.balances.map(a => a.asset.symbol)
120- }
115+ let symbols = this.currentBalances.map(a => a.asset.symbol)
116+ // if(this.netType === 'vapor'){
117+ // symbols = this.currentAccount.vpBalances.map(a => a.asset.symbol)
118+ // }else{
119+ // symbols = this.currentAccount.balances.map(a => a.asset.symbol)
120+ // }
121121 if(symbols.length >1){
122122 const index = symbols.indexOf("BTM")
123- symbols.splice(index,1)
124- symbols.unshift("BTM")
123+ if (index > -1) {
124+ symbols.splice(index,1)
125+ symbols.unshift("BTM")
126+ }
125127 }
126128
127129 return symbols || []
128130 },
129131 ...mapGetters([
130132 'currentAccount',
131- 'netType'
133+ 'currentAddress',
134+ 'currentBalances',
135+ 'netType',
136+ 'chainType'
132137 ])
133138 },
134139 methods: {
135140 img:function (symbol) {
136- const _symbol = symbol.toLowerCase();
141+ let _symbol = symbol.toLowerCase();
142+ if (_symbol === 'btm') {
143+ _symbol = 'btm2'
144+ }
137145 if(this.netType === 'vapor'){
138146 return `https://cdn.blockmeta.com/resources/logo/vapor/${_symbol}.png`
139147 }else{
@@ -160,14 +168,23 @@
160168 },
161169 },
162170 mounted() {
163- if (this.currentAccount.address != undefined) {
171+ if (this.chainType === 'bytom1') {
172+ this.currentCoin = 'BTMC'
173+ }
174+ if (this.currentAddress != undefined) {
175+ let text
164176 if(this.netType === 'vapor'){
165177 this.addr = this.currentAccount.vpAddress;
178+ text = `vapor:${this.addr}`
179+ }else if(this.chainType === 'bytom1') {
180+ this.addr = this.currentAddress;
181+ text = `bytom:${this.addr}`
166182 }else{
167- this.addr = this.currentAccount.address;
183+ this.addr = this.currentAddress;
184+ text = `bytom2:${this.addr}`
168185 }
169186 this.qrcode = new QRCode( "qrcode", {
170- text: this.addr,
187+ text,
171188 width: 150,
172189 height: 150,
173190 colorDark: "#000000",
--- a/src/views/sendTransaction/advancedTransfer.vue
+++ b/src/views/sendTransaction/advancedTransfer.vue
@@ -170,17 +170,19 @@ export default {
170170 },
171171 computed: {
172172 address: function(){
173- if(this.netType === 'vapor'){
174- return this.currentAccount.vpAddress
175- }else{
176- return this.currentAccount.address
177- }
173+ return this.currentAddress
174+ // if(this.netType === 'vapor'){
175+ // return this.currentAccount.vpAddress
176+ // }else{
177+ // return this.currentAccount.address
178+ // }
178179 },
179180 ...mapState([
180181 'bytom'
181182 ]),
182183 ...mapGetters([
183184 'currentAccount',
185+ 'currentAddress',
184186 'net',
185187 'netType',
186188 ])
--- a/src/views/sendTransaction/assetSelection.vue
+++ b/src/views/sendTransaction/assetSelection.vue
@@ -57,18 +57,21 @@ export default {
5757 },
5858 computed: {
5959 assets: function () {
60- if(this.netType === 'vapor'){
61- return this.currentAccount.vpBalances.map(a => {return {label:a.asset.symbol, value:a.asset.symbol}})
62- }else{
63- return this.currentAccount.balances.map(a => {return {label:a.asset.symbol, value:a.asset.symbol}})
64- }
60+ return this.currentBalances.map(a => {return {label:a.asset.symbol, value:a.asset.symbol}})
61+ // if(this.netType === 'vapor'){
62+ // return this.currentAccount.vpBalances.map(a => {return {label:a.asset.symbol, value:a.asset.symbol}})
63+ // }else{
64+ // return this.currentAccount.balances.map(a => {return {label:a.asset.symbol, value:a.asset.symbol}})
65+ // }
6566
6667 },
6768 ...mapState([
68- 'currentAsset'
69+ 'currentAsset',
70+ 'bytom'
6971 ]),
7072 ...mapGetters([
7173 'currentAccount',
74+ 'currentBalances',
7275 'netType'
7376 ])
7477 },
@@ -77,12 +80,13 @@ export default {
7780 this.asset = event.target.value
7881 },
7982 setAsset(asset){
80- let balance
81- if(this.netType === 'vapor'){
82- balance = this.currentAccount.vpBalances.find(b => b.asset.symbol ==asset)
83- }else{
84- balance = this.currentAccount.balances.find(b => b.asset.symbol ==asset)
85- }
83+
84+ let balance = this.currentBalances.find(b => b.asset.symbol ==asset)
85+ // if(this.netType === 'vapor'){
86+ // balance = this.currentAccount.vpBalances.find(b => b.asset.symbol ==asset)
87+ // }else{
88+ // balance = this.currentAccount.balances.find(b => b.asset.symbol ==asset)
89+ // }
8690 if(balance){
8791 this[Actions.SET_CURRENT_ASSET](balance.asset)
8892 }
--- a/src/views/sendTransaction/crossChainTransaction.vue
+++ b/src/views/sendTransaction/crossChainTransaction.vue
@@ -235,11 +235,12 @@ export default {
235235 }
236236 },
237237 address(){
238- if(this.transaction.type === 'toVapor'){
239- return this.currentAccount.address
240- }else{
241- return this.currentAccount.vpAddress
242- }
238+ return this.currentAddress
239+ // if(this.transaction.type === 'toVapor'){
240+ // return this.currentAccount.address
241+ // }else{
242+ // return this.currentAccount.vpAddress
243+ // }
243244 },
244245 unit() {
245246 return this.selectAsset.asset.symbol;
@@ -268,6 +269,7 @@ export default {
268269 ]),
269270 ...mapGetters([
270271 'currentAccount',
272+ 'currentAddress',
271273 'accountList',
272274 'net',
273275 'netType',
--- a/src/views/sendTransaction/signTransaction.vue
+++ b/src/views/sendTransaction/signTransaction.vue
@@ -154,7 +154,7 @@ import account from "@/models/account";
154154 import { camelize, removeFromArray } from "@/utils/utils";
155155 import { decimalsMap } from "@/utils/constants"
156156 import BigNumber from "bignumber.js"
157-import bytomjslib from 'bytomjs-lib'
157+// import bytomjslib from 'bytomjs-lib'
158158
159159
160160 export default {
@@ -180,6 +180,7 @@ export default {
180180 ]),
181181 ...mapGetters([
182182 'currentAccount',
183+ 'currentAddress',
183184 'net',
184185 'netType',
185186 ])
@@ -243,15 +244,16 @@ export default {
243244 const param = Array.isArray(this.prompt.data)? this.prompt.data[0] : this.prompt.data
244245 const _tx = camelize(param)
245246 const rawTransaction = _tx.rawTransaction
246- const currentAddress = this.netType === 'vapor'?
247- this.currentAccount.vpAddress:
248- this.currentAccount.address
247+ // const currentAddress = this.netType === 'vapor'?
248+ // this.currentAccount.vpAddress:
249+ // this.currentAccount.address
250+ const currentAddress = this.currentAddress
249251
250252 account.setupNet(`${this.net}${this.netType}`)
251-
252- const tx = this.netType === 'vapor'?
253- bytomjslib.vapor.Transaction.decodeRawTransaction(rawTransaction):
254- bytomjslib.bytom.Transaction.decodeRawTransaction(rawTransaction)
253+ const tx = _tx.tx
254+ // const tx = this.netType === 'vapor'?
255+ // bytomjslib.vapor.Transaction.decodeRawTransaction(rawTransaction):
256+ // bytomjslib.bytom.Transaction.decodeRawTransaction(rawTransaction)
255257 this.transaction.fee = tx.fee/100000000
256258 this.transaction.input = tx.inputs
257259 this.transaction.output = tx.outputs
--- a/src/views/sendTransaction/transfer.vue
+++ b/src/views/sendTransaction/transfer.vue
@@ -130,7 +130,7 @@ input.form-item-content:active
130130 <div class="form-item">
131131 <label class="form-item-label">{{ $t('transfer.address') }}</label>
132132 <input class="form-item-content"
133- :placeholder="netType=='vapor'? $t('transfer.vaporAddress'): $t('transfer.bytomAddress')"
133+ :placeholder="netType=='vapor'? $t('transfer.vaporAddress'): chainType === 'bytom1' ? $t('transfer.bytom1Address') : $t('transfer.bytomAddress')"
134134 type="text"
135135 id="to"
136136 name="to"
@@ -228,7 +228,7 @@ export default {
228228 selectAsset:{
229229 assetId: "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
230230 name: "Bytom",
231- symbol: "BTM"
231+ symbol: window.store.getters.netType !== 'vapor' && window.store.getters.chainType === 'bytom1' ? "BTMC" : "BTM"
232232 }
233233 };
234234 },
@@ -245,31 +245,36 @@ export default {
245245 },
246246 computed: {
247247 assets(){
248- if(this.netType === 'vapor'){
249- if(!this.currentAccount.vpBalances ||this.currentAccount.vpBalances.length == 0){
250- return [this.selectAsset]
251- }else{
252- return this.currentAccount.vpBalances.map(b=>b.asset)
253- }
254- }else{
255- if(!this.currentAccount.balances ||this.currentAccount.balances.length == 0){
256- return [this.selectAsset]
257- }else{
258- return this.currentAccount.balances.map(b=>b.asset)
259- }
248+ if (!this.currentBalances || !this.currentBalances.length) {
249+ return [this.selectAsset]
250+ } else {
251+ return this.currentBalances.map(item => item.asset)
260252 }
253+ // if(this.netType === 'vapor'){
254+ // if(!this.currentAccount.vpBalances ||this.currentAccount.vpBalances.length == 0){
255+ // return [this.selectAsset]
256+ // }else{
257+ // return this.currentAccount.vpBalances.map(b=>b.asset)
258+ // }
259+ // }else{
260+ // if(!this.currentAccount.balances ||this.currentAccount.balances.length == 0){
261+ // return [this.selectAsset]
262+ // }else{
263+ // return this.currentAccount.balances.map(b=>b.asset)
264+ // }
265+ // }
261266 },
262267 currentBalance(){
263268 const assetId = this.selectAsset.assetId
264- let balances
269+ // let balances
265270
266- if(this.netType === 'vapor'){
267- balances = this.currentAccount.vpBalances
268- }else{
269- balances = this.currentAccount.balances
270- }
271+ // if(this.netType === 'vapor'){
272+ // balances = this.currentAccount.vpBalances
273+ // }else{
274+ // balances = this.currentAccount.balances
275+ // }
271276
272- const balance = balances.find(b => b.asset.assetId === assetId)
277+ const balance = this.currentBalances.find(b => b.asset.assetId === assetId)
273278 return balance? balance.availableBalance:0;
274279 },
275280 unit() {
@@ -282,9 +287,12 @@ export default {
282287 ...mapGetters([
283288 'language',
284289 'currentAccount',
290+ 'currentBalances',
291+ 'currentAddress',
285292 'accountList',
286293 'currency',
287- 'netType'
294+ 'netType',
295+ 'chainType',
288296 ])
289297 },
290298 watch: {
@@ -335,12 +343,15 @@ export default {
335343 const asset_amount={}
336344 asset_amount[this.selectAsset.assetId] = this.transaction.amount || 0;
337345
338- return transaction.estimateFee(this.address, asset_amount).then( (resp) =>{
346+ return transaction.estimateFee(this.currentAddress, asset_amount).then( (resp) =>{
339347 this.transaction.fee = resp.fee
340348 })
341349 },
342350 img:function (symbol) {
343- const _symbol = symbol.toLowerCase();
351+ let _symbol = symbol.toLowerCase();
352+ if (_symbol === 'btm') {
353+ _symbol = 'btm2'
354+ }
344355 if(this.netType === 'vapor'){
345356 return `https://cdn.blockmeta.com/resources/logo/vapor/${_symbol}.png`
346357 }else{
@@ -431,7 +442,7 @@ export default {
431442
432443 this.transaction.asset = this.selectAsset.assetId;
433444 this.transaction.to = this.transaction.to.trim();
434- transaction.transfer(this.transaction, password, this.address, this).then(result => {
445+ transaction.transfer(this.transaction, password, this.currentAddress, this).then(result => {
435446 loader.hide();
436447 this.$router.push('/')
437448
--- /dev/null
+++ b/src/views/settings/chainSelection.vue
@@ -0,0 +1,82 @@
1+<style lang="scss" scoped>
2+ .header{
3+ display: flex;
4+ margin-bottom: 20px;
5+ h1{
6+ margin-left: 12px;
7+ font-size: 20px;
8+ }
9+ }
10+
11+ .selction-section{
12+ height: calc( 100% - 149px );
13+ overflow: scroll;
14+ }
15+
16+</style>
17+
18+<template>
19+ <div class="warp-menu bg-grey">
20+ <section class="header">
21+ <BackButton :small="true" />
22+ <h1 class="color-black">
23+ <div class="welcome-title">{{ $t("setting.network") }}</div>
24+ </h1>
25+ </section>
26+ <section class="selction-section">
27+ <SelectionPage :value="data" :options="options" :onChange="changeNetwork"></SelectionPage>
28+ </section>
29+
30+ </div>
31+</template>
32+
33+<script>
34+import { mapActions, mapGetters, mapState } from 'vuex'
35+import * as Actions from '@/store/constants';
36+import _ from 'lodash';
37+import Bytom from '@/utils/Bytom'
38+import { wallet } from '@/models/wallet'
39+
40+export default {
41+ name: "",
42+ data() {
43+ return {
44+ data :'',
45+ options: [
46+ { label: 'Bytom', value: "bytom2" },
47+ { label: 'Bytom Classic', value: "bytom1" }
48+ ],
49+ };
50+ },
51+ computed: {
52+ ...mapState([
53+ 'bytom',
54+ ]),
55+ ...mapGetters([
56+ 'net',
57+ 'chainType'
58+ ])
59+ },
60+ methods: {
61+ changeNetwork(event){
62+ const bytom = this.bytom.clone();
63+ const chainType = event.target.value === 'bytom2' ? 'bytom' : 'bytom1'
64+ bytom.settings.chainType = event.target.value;
65+ bytom.settings.netType = chainType
66+ this.data = event.target.value
67+ this[Actions.UPDATE_STORED_BYTOM](bytom)
68+ this[Actions.SET_BYTOM](Bytom.fromJson(bytom))
69+ wallet.setChain(chainType)
70+ },
71+ ...mapActions([
72+ Actions.UPDATE_STORED_BYTOM,
73+ Actions.SET_BYTOM
74+ ])
75+ },
76+ mounted() {
77+ if(this.bytom && this.bytom.settings.chainType){
78+ this.data = this.bytom.settings.chainType
79+ }
80+ },
81+ };
82+</script>
--- a/src/views/settings/settings.vue
+++ b/src/views/settings/settings.vue
@@ -70,6 +70,14 @@
7070 {{ $t(`main.${net}`) }} <i class="iconfont icon_arrow_1"></i>
7171 </div>
7272 </div>
73+ <div class="row" @click="$router.push({ name: 'settings-chain'})">
74+ <div class="label color-black">
75+ <p>{{ $t("setting.chain") }}</p>
76+ </div>
77+ <div class="value">
78+ {{ currentChain }} <i class="iconfont icon_arrow_1"></i>
79+ </div>
80+ </div>
7381 <div class="row" @click="$router.push({ name: 'settings-delete'})">
7482 <div class="label color-grey-36">
7583 <p>{{ $t("setting.deleteWallet") }}</p>
@@ -104,6 +112,9 @@ export default {
104112 return 'English'
105113 }
106114 },
115+ currentChain() {
116+ return this.chainType === 'bytom1' ? 'Bytom Classic' : 'Bytom'
117+ },
107118 link(){
108119 return `${apis.runtime.getURL('pages/prompt.html')}`;
109120 },
@@ -122,7 +133,8 @@ export default {
122133 ...mapGetters([
123134 'language',
124135 'currency',
125- 'net'
136+ 'net',
137+ 'chainType'
126138 ])
127139 },
128140 methods: {
--- a/src/views/sideMenu/homeMenu.vue
+++ b/src/views/sideMenu/homeMenu.vue
@@ -84,7 +84,7 @@
8484 <div class="menu-content">
8585 <div class="list accounts">
8686 <div v-for="(account, index) in accountList" :key="index" @click="accountSelected(account)">
87- <div :class="(currentAccount != undefined && account.address == currentAccount.address) ? 'list-item active': 'list-item'">
87+ <div :class="(currentAccount != undefined && account.address == currentAddress) ? 'list-item active': 'list-item'">
8888 <div class="wallet">
8989 <i class="iconfont icon-wallet"></i>
9090 </div>
@@ -143,6 +143,7 @@
143143 ]),
144144 ...mapGetters([
145145 'currentAccount',
146+ 'currentAddress',
146147 'accountList'
147148 ])
148149 },
--- a/src/views/transferDetail.vue
+++ b/src/views/transferDetail.vue
@@ -262,6 +262,7 @@
262262 ]),
263263 ...mapGetters([
264264 'currentAccount',
265+ 'currentAddress',
265266 'netType'
266267 ])
267268 },
@@ -269,11 +270,12 @@
269270 let params = this.$route.params;
270271
271272 let transaction = params.transaction;
272- if(this.netType === 'vapor'){
273- this.selfAddress = this.currentAccount.vpAddress;
274- }else{
275- this.selfAddress = this.currentAccount.address;
276- }
273+ // if(this.netType === 'vapor'){
274+ // this.selfAddress = this.currentAccount.vpAddress;
275+ // }else{
276+ // this.selfAddress = this.currentAccount.address;
277+ // }
278+ this.selfAddress = this.currentAddress
277279 console.log(params.transaction)
278280 if(transaction.type =='vote' || transaction.type =='veto'){
279281 const node =_.find(this.listVote, {pubKey: transaction.pubkey})
--- a/yarn.lock
+++ b/yarn.lock
@@ -23,6 +23,62 @@
2323 chalk "^2.0.0"
2424 js-tokens "^4.0.0"
2525
26+"@bytomjs/bytom@^0.2.3":
27+ version "0.2.3"
28+ resolved "https://registry.yarnpkg.com/@bytomjs/bytom/-/bytom-0.2.3.tgz#79a44abdfb060c7683d14f64cd9eb43eeda8f885"
29+ integrity sha512-8a+lOxfYzXEZ6uNqH9T+/l04AJt/vja3JC0+I1Z6bTHruj2c0aE/5B9qQUwXAhIKp1qzdyRFs6rFym4i2yEgGw==
30+ dependencies:
31+ "@bytomjs/provider" "^0.2.3"
32+ "@bytomjs/utils" "^0.2.3"
33+
34+"@bytomjs/crypto@^0.2.3":
35+ version "0.2.3"
36+ resolved "https://registry.yarnpkg.com/@bytomjs/crypto/-/crypto-0.2.3.tgz#6c3973fd616169f716a5ff3768eca7cb32d3df34"
37+ integrity sha512-214jakuv4WyYndWh4BRNf4G1bbYm+KYeqHAvUxGtkWVCEwvY+tJDYcEIrt1OrZvqs2YYdZmlNdKDl2C10QQlfg==
38+ dependencies:
39+ "@bytomjs/utils" "^0.2.3"
40+ bech32 "^2.0.0"
41+ bip39 "^3.0.0"
42+ bn.js "^5.2.0"
43+ create-hmac "^1.1.7"
44+ js-sha3 "^0.8.0"
45+ scrypt-js "^3.0.1"
46+
47+"@bytomjs/node@^0.2.3":
48+ version "0.2.3"
49+ resolved "https://registry.yarnpkg.com/@bytomjs/node/-/node-0.2.3.tgz#1f0a4ab5e0fd6311086e1ce157b33b220e1691fe"
50+ integrity sha512-kMwKxa5M67xQzhRcS+OPZcpdnUmjPmWzEljUoyZR03oEmyTEBQKm+yq1FEystbVyhLv8gWK39NSDw8syFCKNRw==
51+ dependencies:
52+ "@bytomjs/provider" "^0.2.3"
53+ "@bytomjs/utils" "^0.2.3"
54+ "@types/btoa" "^1.2.3"
55+ btoa "^1.2.1"
56+
57+"@bytomjs/provider@^0.2.3":
58+ version "0.2.3"
59+ resolved "https://registry.yarnpkg.com/@bytomjs/provider/-/provider-0.2.3.tgz#e3141e4b65a880b5dc30f2f09925912ce635a458"
60+ integrity sha512-XjD7HzmLngd3RgTHMm6IPXnR49wMpeWNLXWzFtvpeOK7pvy0ppRFr3PjNFiHAlhmtZ7gbZ1UHBMcKuBoLJR30A==
61+ dependencies:
62+ "@bytomjs/utils" "^0.2.3"
63+ axios "^0.21.1"
64+
65+"@bytomjs/utils@^0.2.3":
66+ version "0.2.3"
67+ resolved "https://registry.yarnpkg.com/@bytomjs/utils/-/utils-0.2.3.tgz#747ee540321cc6f08ac69298ebc5177855c6c560"
68+ integrity sha512-QZc/dpErm/olWY+0zyU5Bb+Ge2Mu85uTUIw5vLGA17cN2Wg6LBS4+4r4oTtcNDJ9VH2OnKzzl4uDxfNqUBvRHQ==
69+ dependencies:
70+ extend "^3.0.2"
71+
72+"@bytomjs/wallet@^0.2.3":
73+ version "0.2.3"
74+ resolved "https://registry.yarnpkg.com/@bytomjs/wallet/-/wallet-0.2.3.tgz#0f91612267aecb85717a62296aaf8d24d8f03579"
75+ integrity sha512-B8tC0wKdbJnIbxgCyDOBDIiLx/E9AQ5VWXu3OHKe+b2lavyJaa9drC7GGN55uBfX4ejZBq2OwmFx3LF/YLNzLw==
76+ dependencies:
77+ "@bytomjs/bytom" "^0.2.3"
78+ "@bytomjs/crypto" "^0.2.3"
79+ "@bytomjs/utils" "^0.2.3"
80+ crypto-js "^4.0.0"
81+
2682 "@sentry/browser@^5.22.3":
2783 version "5.30.0"
2884 resolved "https://registry.npm.taobao.org/@sentry/browser/download/@sentry/browser-5.30.0.tgz?cache=0&sync_timestamp=1613646081458&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40sentry%2Fbrowser%2Fdownload%2F%40sentry%2Fbrowser-5.30.0.tgz#c28f49d551db3172080caef9f18791a7fd39e3b3"
@@ -96,6 +152,23 @@
96152 "@sentry/types" "5.30.0"
97153 tslib "^1.9.3"
98154
155+"@types/btoa@^1.2.3":
156+ version "1.2.3"
157+ resolved "https://registry.yarnpkg.com/@types/btoa/-/btoa-1.2.3.tgz#2c8e7093f902bf8f0e10992a731a4996aa1a5732"
158+ integrity sha512-ANNCZICS/ofxhzUl8V1DniBJs+sFQ+Yg5am1ZwVEf/sxoKY/J2+h5Fuw3xUErlZ7eJLdgzukBjZwnsV6+/2Rmg==
159+ dependencies:
160+ "@types/node" "*"
161+
162+"@types/node@*":
163+ version "16.9.2"
164+ resolved "https://registry.yarnpkg.com/@types/node/-/node-16.9.2.tgz#81f5a039d6ed1941f8cc57506c74e7c2b8fc64b9"
165+ integrity sha512-ZHty/hKoOLZvSz6BtP1g7tc7nUeJhoCf3flLjh8ZEv1vFKBWHXcnMbJMyN/pftSljNyy0kNW/UqI3DccnBnZ8w==
166+
167+"@types/node@11.11.6":
168+ version "11.11.6"
169+ resolved "https://registry.yarnpkg.com/@types/node/-/node-11.11.6.tgz#df929d1bb2eee5afdda598a41930fe50b43eaa6a"
170+ integrity sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ==
171+
99172 abbrev@1:
100173 version "1.1.1"
101174 resolved "https://registry.npm.taobao.org/abbrev/download/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"
@@ -486,6 +559,13 @@ axios@^0.18.0:
486559 follow-redirects "1.5.10"
487560 is-buffer "^2.0.2"
488561
562+axios@^0.21.1:
563+ version "0.21.4"
564+ resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575"
565+ integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==
566+ dependencies:
567+ follow-redirects "^1.14.0"
568+
489569 babel-code-frame@^6.26.0:
490570 version "6.26.0"
491571 resolved "https://registry.npm.taobao.org/babel-code-frame/download/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b"
@@ -1131,6 +1211,11 @@ bech32@^1.1.4:
11311211 resolved "https://registry.npm.taobao.org/bech32/download/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9"
11321212 integrity sha1-44yfN78Xm46xauOncrQMNW1IMuk=
11331213
1214+bech32@^2.0.0:
1215+ version "2.0.0"
1216+ resolved "https://registry.yarnpkg.com/bech32/-/bech32-2.0.0.tgz#078d3686535075c8c79709f054b1b226a133b355"
1217+ integrity sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg==
1218+
11341219 big.js@^3.1.3:
11351220 version "3.2.0"
11361221 resolved "https://registry.npm.taobao.org/big.js/download/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e"
@@ -1163,6 +1248,16 @@ bindings@^1.5.0:
11631248 dependencies:
11641249 file-uri-to-path "1.0.0"
11651250
1251+bip39@^3.0.0:
1252+ version "3.0.4"
1253+ resolved "https://registry.yarnpkg.com/bip39/-/bip39-3.0.4.tgz#5b11fed966840b5e1b8539f0f54ab6392969b2a0"
1254+ integrity sha512-YZKQlb752TrUWqHWj7XAwCSjYEgGAk+/Aas3V7NyjQeZYsztO8JnQUaCWhcnL4T+jL8nvB8typ2jRPzTlgugNw==
1255+ dependencies:
1256+ "@types/node" "11.11.6"
1257+ create-hash "^1.1.0"
1258+ pbkdf2 "^3.0.9"
1259+ randombytes "^2.0.1"
1260+
11661261 bl@^1.0.0:
11671262 version "1.2.3"
11681263 resolved "https://registry.npm.taobao.org/bl/download/bl-1.2.3.tgz?cache=0&sync_timestamp=1612867098220&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbl%2Fdownload%2Fbl-1.2.3.tgz#1e8dd80142eac80d7158c9dccc047fb620e035e7"
@@ -1197,7 +1292,7 @@ bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9:
11971292 resolved "https://registry.npm.taobao.org/bn.js/download/bn.js-4.11.9.tgz#26d556829458f9d1e81fc48952493d0ba3507828"
11981293 integrity sha1-JtVWgpRY+dHoH8SJUkk9C6NQeCg=
11991294
1200-bn.js@^5.0.0, bn.js@^5.1.1:
1295+bn.js@^5.0.0, bn.js@^5.1.1, bn.js@^5.2.0:
12011296 version "5.2.0"
12021297 resolved "https://registry.npm.taobao.org/bn.js/download/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002"
12031298 integrity sha1-NYhgZ0OWxpl3canQUfzBtX1K4AI=
@@ -1348,6 +1443,11 @@ browserslist@^3.2.6:
13481443 caniuse-lite "^1.0.30000844"
13491444 electron-to-chromium "^1.3.47"
13501445
1446+btoa@^1.2.1:
1447+ version "1.2.1"
1448+ resolved "https://registry.yarnpkg.com/btoa/-/btoa-1.2.1.tgz#01a9909f8b2c93f6bf680ba26131eb30f7fa3d73"
1449+ integrity sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==
1450+
13511451 buffer-alloc-unsafe@^1.1.0:
13521452 version "1.1.0"
13531453 resolved "https://registry.npm.taobao.org/buffer-alloc-unsafe/download/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0"
@@ -1426,6 +1526,17 @@ bytom-js-sdk@^1.4.0:
14261526 axios "^0.18.0"
14271527 eslint "^5.6.1"
14281528
1529+bytom@^0.2.3:
1530+ version "0.2.3"
1531+ resolved "https://registry.yarnpkg.com/bytom/-/bytom-0.2.3.tgz#316637c622dd8a2e11202a47cf36c38a769dd48d"
1532+ integrity sha512-o9dAhLvQ6/l92s/4uQbPt5HL39xOi1ONAT7I4XnW5O44ByJtnQSnJJ+hRVW0svcStiGSVBUQdX1dhca0oGjAPQ==
1533+ dependencies:
1534+ "@bytomjs/bytom" "^0.2.3"
1535+ "@bytomjs/crypto" "^0.2.3"
1536+ "@bytomjs/node" "^0.2.3"
1537+ "@bytomjs/provider" "^0.2.3"
1538+ "@bytomjs/wallet" "^0.2.3"
1539+
14291540 bytomjs-lib@0.0.2:
14301541 version "0.0.2"
14311542 resolved "https://registry.npm.taobao.org/bytomjs-lib/download/bytomjs-lib-0.0.2.tgz#e3dc34dcb1ebfb8476298301c479eb52fd6c979e"
@@ -2128,6 +2239,11 @@ crypto-browserify@^3.11.0:
21282239 randombytes "^2.0.0"
21292240 randomfill "^1.0.3"
21302241
2242+crypto-js@^4.0.0:
2243+ version "4.1.1"
2244+ resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.1.1.tgz#9e485bcf03521041bd85844786b83fb7619736cf"
2245+ integrity sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==
2246+
21312247 css-color-names@0.0.4:
21322248 version "0.0.4"
21332249 resolved "https://registry.npm.taobao.org/css-color-names/download/css-color-names-0.0.4.tgz#808adc2e79cf84738069b646cb20ec27beb629e0"
@@ -2980,7 +3096,7 @@ extend-shallow@^3.0.0, extend-shallow@^3.0.2:
29803096 assign-symbols "^1.0.0"
29813097 is-extendable "^1.0.1"
29823098
2983-extend@~3.0.2:
3099+extend@^3.0.2, extend@~3.0.2:
29843100 version "3.0.2"
29853101 resolved "https://registry.npm.taobao.org/extend/download/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa"
29863102 integrity sha1-+LETa0Bx+9jrFAr/hYsQGewpFfo=
@@ -3206,6 +3322,11 @@ follow-redirects@^1.0.0:
32063322 resolved "https://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.13.2.tgz#dd73c8effc12728ba5cf4259d760ea5fb83e3147"
32073323 integrity sha1-3XPI7/wScoulz0JZ12DqX7g+MUc=
32083324
3325+follow-redirects@^1.14.0:
3326+ version "1.14.4"
3327+ resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379"
3328+ integrity sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==
3329+
32093330 for-in@^0.1.3:
32103331 version "0.1.8"
32113332 resolved "https://registry.npm.taobao.org/for-in/download/for-in-0.1.8.tgz#d8773908e31256109952b1fdb9b3fa867d2775e1"
@@ -5387,6 +5508,17 @@ pbkdf2@^3.0.3:
53875508 safe-buffer "^5.0.1"
53885509 sha.js "^2.4.8"
53895510
5511+pbkdf2@^3.0.9:
5512+ version "3.1.2"
5513+ resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.1.2.tgz#dd822aa0887580e52f1a039dc3eda108efae3075"
5514+ integrity sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==
5515+ dependencies:
5516+ create-hash "^1.1.2"
5517+ create-hmac "^1.1.4"
5518+ ripemd160 "^2.0.1"
5519+ safe-buffer "^5.0.1"
5520+ sha.js "^2.4.8"
5521+
53905522 performance-now@^2.1.0:
53915523 version "2.1.0"
53925524 resolved "https://registry.npm.taobao.org/performance-now/download/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
@@ -6358,6 +6490,11 @@ schema-utils@^0.4.5:
63586490 ajv "^6.1.0"
63596491 ajv-keywords "^3.1.0"
63606492
6493+scrypt-js@^3.0.1:
6494+ version "3.0.1"
6495+ resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-3.0.1.tgz#d314a57c2aef69d1ad98a138a21fe9eafa9ee312"
6496+ integrity sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==
6497+
63616498 scss-tokenizer@^0.2.3:
63626499 version "0.2.3"
63636500 resolved "https://registry.npm.taobao.org/scss-tokenizer/download/scss-tokenizer-0.2.3.tgz#8eb06db9a9723333824d3f5530641149847ce5d1"
Show on old repository browser