Bytom Wallet for Chrome
Revision | 1e54f3d8424fcc59e2b635d02cc92341f60f8853 (tree) |
---|---|
Zeit | 2021-09-29 16:39:21 |
Autor | xietao <nanshuo_xt@163....> |
Commiter | xietao |
Merge: merge pro
@@ -0,0 +1,6 @@ | ||
1 | +module.exports = { | |
2 | + singleQuote: true, | |
3 | + semi: false, | |
4 | + printWidth: 80, | |
5 | + trailingComma: 'none', | |
6 | +} |
@@ -1,7 +1,7 @@ | ||
1 | 1 | { |
2 | 2 | "name": "Byone", |
3 | 3 | "description": "Bytom Chrome Extension Wallet", |
4 | - "version": "3.1.1", | |
4 | + "version": "3.3.0", | |
5 | 5 | "author": "zhiting.fly@8btc.com", |
6 | 6 | "license": "MIT", |
7 | 7 | "private": true, |
@@ -19,6 +19,7 @@ | ||
19 | 19 | "axios": "^0.18.0", |
20 | 20 | "babel-preset-es2015": "^6.24.1", |
21 | 21 | "bignumber.js": "^9.0.0", |
22 | + "bytom": "^0.2.3", | |
22 | 23 | "bytom-js-sdk": "^1.4.0", |
23 | 24 | "bytomjs-lib": "0.0.2", |
24 | 25 | "clipboard": "^2.0.1", |
@@ -30,7 +30,7 @@ | ||
30 | 30 | { |
31 | 31 | "icon":"vote.jpg", |
32 | 32 | "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", | |
34 | 34 | "domainsMeta": { |
35 | 35 | "icon": "https://supertx.bymov.io/favicon.ico" |
36 | 36 | } |
@@ -12,16 +12,18 @@ const cn = { | ||
12 | 12 | wallets:"钱包", |
13 | 13 | backup:"备份", |
14 | 14 | expand:"展开", |
15 | - setting:"设置" | |
15 | + setting:"设置", | |
16 | + bapp: 'BApp' | |
16 | 17 | }, |
17 | 18 | common:{ |
18 | - veto: '取消投票', | |
19 | + veto: '取消质押', | |
19 | 20 | cross_chain_in: '跨入Vapor', |
20 | 21 | spend : '花费', |
21 | 22 | coinbase: 'Coinbase', |
22 | 23 | control : '接受', |
23 | 24 | cross_chain_out: '跨出Vapor', |
24 | - vote: '投票', | |
25 | + out_crosschain: '跨出Vapor', | |
26 | + vote: '质押', | |
25 | 27 | transfer:'转账', |
26 | 28 | issue:'资产发行', |
27 | 29 | retire:'资产销毁', |
@@ -64,7 +66,8 @@ const cn = { | ||
64 | 66 | }, |
65 | 67 | transfer: { |
66 | 68 | address: '接收地址', |
67 | - bytomAddress:'主链地址(bm开头)', | |
69 | + bytomAddress:'主链地址(bn开头)', | |
70 | + bytom1Address:'主链地址(bm开头)', | |
68 | 71 | vaporAddress:'侧链地址(vp开头)', |
69 | 72 | quantity: '数量', |
70 | 73 | fee: '手续费', |
@@ -103,6 +106,7 @@ const cn = { | ||
103 | 106 | listAsset: { |
104 | 107 | all:'全部', |
105 | 108 | fail:'失败', |
109 | + confirming: '确认中', | |
106 | 110 | main:'主链', |
107 | 111 | side:'侧链', |
108 | 112 | }, |
@@ -117,34 +121,34 @@ const cn = { | ||
117 | 121 | direction:'跨链方向' |
118 | 122 | }, |
119 | 123 | 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:'取消质押', | |
126 | 130 | bp:'正式共识节点', |
127 | 131 | standbyBP:'备选共识节点', |
128 | 132 | bpName:'节点名称', |
129 | 133 | bpPubkey:'节点公钥', |
130 | - vote:'投票', | |
134 | + vote:'质押', | |
131 | 135 | votes:'票数', |
132 | - voteVotes:'投票票数', | |
133 | - voteAccount:'投票账户', | |
134 | - vetoAccount:'取消投票账户', | |
136 | + voteVotes:'质押票数', | |
137 | + voteAccount:'质押账户', | |
138 | + vetoAccount:'取消质押账户', | |
135 | 139 | }, |
136 | 140 | listCancel:{ |
137 | - voted:'已投票', | |
141 | + voted:'已质押', | |
138 | 142 | cancel:'可取消', |
139 | 143 | selectVote:'选择节点', |
140 | - availableVeto:'可取消投票数' | |
144 | + availableVeto:'可取消质押数' | |
141 | 145 | }, |
142 | 146 | vote:{ |
143 | 147 | selectNode:'选择节点', |
144 | - voteDetials:'投票详情', | |
145 | - vetoDetials:'取消投票详情', | |
146 | - confirmVote:'确认投票', | |
147 | - confirmVeto:'确认取消投票', | |
148 | + voteDetials:'质押详情', | |
149 | + vetoDetials:'取消质押详情', | |
150 | + confirmVote:'确认质押', | |
151 | + confirmVeto:'确认取消质押', | |
148 | 152 | amountPlaceHolder:"可用" |
149 | 153 | }, |
150 | 154 | signMessage:{ |
@@ -186,7 +190,7 @@ const cn = { | ||
186 | 190 | copy: '点击复制', |
187 | 191 | send: '转账', |
188 | 192 | receive: '收款', |
189 | - vote:'投票', | |
193 | + vote:'质押', | |
190 | 194 | crossChain:'跨链', |
191 | 195 | record: '交易记录', |
192 | 196 | asset:'我的资产', |
@@ -313,6 +317,7 @@ const cn = { | ||
313 | 317 | currency:'货币单位', |
314 | 318 | network:'网络', |
315 | 319 | version:'版本号:', |
320 | + chain: '链切换', | |
316 | 321 | enLange:"展开视图", |
317 | 322 | deleteWallet:'删除钱包', |
318 | 323 | deleteHint:'执行删除钱包操作前请确认您已备份好钱包,否则将无法找回!', |
@@ -14,6 +14,7 @@ const en = { | ||
14 | 14 | coinbase: 'Coinbase', |
15 | 15 | control : 'Received ', |
16 | 16 | cross_chain_out: 'Cross Out Vapor', |
17 | + out_crosschain: 'Cross Out Vapor', | |
17 | 18 | vote: 'Vote', |
18 | 19 | transfer:'Transfer', |
19 | 20 | issue:'Issue', |
@@ -64,7 +65,7 @@ const en = { | ||
64 | 65 | }, |
65 | 66 | transfer: { |
66 | 67 | address: 'Address', |
67 | - bytomAddress:'Bytom address (start with bm)', | |
68 | + bytomAddress:'Bytom address (start with bn)', | |
68 | 69 | vaporAddress:'Vapor address (start with vp)', |
69 | 70 | quantity: ' Amount', |
70 | 71 | fee: 'Fee', |
@@ -103,6 +104,7 @@ const en = { | ||
103 | 104 | listAsset: { |
104 | 105 | all:'All', |
105 | 106 | fail:'Failed', |
107 | + confirming: 'Confirming', | |
106 | 108 | main:'Chain', |
107 | 109 | side:'Sidechain', |
108 | 110 | }, |
@@ -311,6 +313,7 @@ const en = { | ||
311 | 313 | lang: 'Language', |
312 | 314 | currency:'Currency', |
313 | 315 | network:'Networks', |
316 | + chain: 'Chain', | |
314 | 317 | enLange:"Expand view", |
315 | 318 | deleteWallet:'Delete wallet', |
316 | 319 | deleteHint:'Please confirm you has backed up your wallet.', |
@@ -126,10 +126,6 @@ export default class Background { | ||
126 | 126 | sendResponse(Error.typeMissed('asset')); |
127 | 127 | return false; |
128 | 128 | } |
129 | - if(typeof requestBody.to === 'string' && requestBody.amount === undefined){ | |
130 | - sendResponse(Error.typeMissed('amount')); | |
131 | - return false; | |
132 | - } | |
133 | 129 | |
134 | 130 | const {domain} = payload; |
135 | 131 | const data={ |
@@ -190,12 +186,16 @@ export default class Background { | ||
190 | 186 | if(bytom.settings.domains.find(_domain => _domain === domain)) { |
191 | 187 | const currentAccount = bytom.currentAccount |
192 | 188 | const {vpAddress, address} = currentAccount |
189 | + const classicAddress = currentAccount.bytom1.address | |
190 | + const isClassic = bytom.settings.netType === 'bytom1' | |
193 | 191 | let account = { |
194 | - addresses: [vpAddress, address], | |
192 | + addresses: [vpAddress, isClassic?classicAddress:address], | |
195 | 193 | rootXPub: currentAccount.xpub |
196 | 194 | } |
197 | 195 | if(bytom.settings.netType === 'vapor'){ |
198 | 196 | account.address = vpAddress; |
197 | + }else if(bytom.settings.netType === 'bytom1'){ | |
198 | + account.address = classicAddress; | |
199 | 199 | }else{ |
200 | 200 | account.address = address; |
201 | 201 | } |
@@ -217,7 +217,7 @@ export default class Background { | ||
217 | 217 | |
218 | 218 | requestCurrentChain(sendResponse){ |
219 | 219 | 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 | |
221 | 221 | sendResponse(chain); |
222 | 222 | }) |
223 | 223 | } |
@@ -288,16 +288,28 @@ export default class Background { | ||
288 | 288 | if(!currentAccount){ |
289 | 289 | sendResponse(Error.signatureAccountMissing()) |
290 | 290 | }else{ |
291 | - | |
292 | 291 | const {vpAddress, address} = currentAccount |
292 | + const classicAddress = currentAccount.bytom1.address | |
293 | + const isClassic = bytom.settings.netType === 'bytom1' | |
294 | + | |
293 | 295 | 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 | |
296 | 303 | } |
297 | 304 | if(bytom.settings.netType === 'vapor'){ |
298 | 305 | account.address = vpAddress; |
306 | + account.account = vpAddress | |
307 | + }else if(bytom.settings.netType === 'bytom1'){ | |
308 | + account.address = classicAddress; | |
309 | + account.account = classicAddress | |
299 | 310 | }else{ |
300 | 311 | account.address = address; |
312 | + account.account = address | |
301 | 313 | } |
302 | 314 | |
303 | 315 |
@@ -305,7 +317,8 @@ export default class Background { | ||
305 | 317 | sendResponse(account); |
306 | 318 | } else{ |
307 | 319 | 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); | |
309 | 322 | else { |
310 | 323 | bytom.settings.domains.unshift(domain); |
311 | 324 | bytom.settings.domainsMeta[domain] = domainAttrs; |
@@ -330,7 +343,8 @@ export default class Background { | ||
330 | 343 | if(index !== -1) { |
331 | 344 | payload.type = 'dis' |
332 | 345 | 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); | |
334 | 348 | else { |
335 | 349 | bytom.settings.domains.splice(index, 1); |
336 | 350 | delete bytom.settings.domainsMeta[domain]; |
@@ -3,6 +3,7 @@ import { EncryptedStream } from 'extension-streams' | ||
3 | 3 | import * as MsgTypes from './messages/types' |
4 | 4 | import * as EventNames from '@/messages/event' |
5 | 5 | import Bytomdapp from './dapp' |
6 | +import { provider } from 'bytom' | |
6 | 7 | |
7 | 8 | /*** |
8 | 9 | * This is the javascript which gets injected into |
@@ -22,7 +23,18 @@ class Inject { | ||
22 | 23 | msg.hasOwnProperty('type') && |
23 | 24 | msg.type === MsgTypes.PUSH_BYTOM |
24 | 25 | ) { |
26 | + // window.bytom only for ofmf business get vpAddress, other mov-web business use bytom2 | |
25 | 27 | 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 | + }) | |
26 | 38 | } |
27 | 39 | |
28 | 40 | if ( |
@@ -36,20 +48,46 @@ class Inject { | ||
36 | 48 | switch (p.type){ |
37 | 49 | case 'default_account':{ |
38 | 50 | 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 | + }) | |
39 | 55 | break |
40 | 56 | } |
41 | 57 | case 'net':{ |
42 | 58 | window.bytom.emit(MsgTypes.NETWORK_CHANGED, p.value) |
59 | + window.bytom2.setNet(p.value) | |
43 | 60 | break |
44 | 61 | } |
45 | 62 | case 'chain':{ |
46 | 63 | window.bytom.emit(MsgTypes.NET_TYPE_CHANGED, p.value) |
64 | + window.bytom2.setChain(p.value) | |
47 | 65 | break |
48 | 66 | } |
49 | - | |
50 | 67 | } |
51 | 68 | } |
52 | 69 | } |
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 | + } | |
53 | 91 | }) |
54 | 92 | |
55 | 93 | // Syncing the streams between the extension and the web application |
@@ -2,7 +2,7 @@ | ||
2 | 2 | "manifest_version": 2, |
3 | 3 | "name": "Byone", |
4 | 4 | "description": "Bytom Wallet Chrome extension.", |
5 | - "version": "3.1.1", | |
5 | + "version": "3.3.0", | |
6 | 6 | "author": "Bytom frontend, zhitinglin", |
7 | 7 | "web_accessible_resources": ["js/inject.js"], |
8 | 8 | "browser_action": { |
@@ -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' |
@@ -11,11 +11,18 @@ const mathematicalVersion = version => { | ||
11 | 11 | const fnToVersion = fnName => fnName.replace(/[m]/g, '').replace(/[_]/g,'.'); |
12 | 12 | |
13 | 13 | export default async bytom => { |
14 | + console.log('check update'); | |
15 | + | |
14 | 16 | bytom.meta.regenerateVersion(); |
15 | 17 | if(!bytom.meta.needsUpdating()) return false; |
16 | 18 | |
17 | 19 | const lastVersion = mathematicalVersion(bytom.meta.lastVersion); |
18 | 20 | 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 | + | |
19 | 26 | if(nextVersions.length) { |
20 | 27 | await Promise.all(nextVersions.map(async version => await migrators[version](bytom))); |
21 | 28 | bytom.meta.lastVersion = fnToVersion(nextVersions[nextVersions.length-1]); |
@@ -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 | +}; |
@@ -1,2 +1 @@ | ||
1 | -export * from './3.0.0'; | |
2 | -export * from './3.0.5'; | |
1 | +export * from './3.3.0'; |
@@ -5,8 +5,47 @@ import _ from 'lodash' | ||
5 | 5 | import {getDomains, camelize} from '@/utils/utils.js' |
6 | 6 | import * as Sentry from "@sentry/browser"; |
7 | 7 | |
8 | +import { wallet, setChain, setNet } from './wallet' | |
9 | + | |
8 | 10 | 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 | + }) | |
10 | 49 | } |
11 | 50 | |
12 | 51 | account.createKey = function(accountAlias, keyAlias, passwd, context) { |
@@ -25,7 +64,8 @@ account.createKey = function(accountAlias, keyAlias, passwd, context) { | ||
25 | 64 | _bytom.keychain.removeUnverifyIdentity(_bytom.settings.network); |
26 | 65 | _bytom.settings.netType = 'bytom'; |
27 | 66 | |
28 | - const resultObj = bytom.keys.createKey(keyAlias, passwd) | |
67 | + // const resultObj = bytom.keys.createKey(keyAlias, passwd) | |
68 | + const resultObj = wallet.createKey(keyAlias, passwd) | |
29 | 69 | |
30 | 70 | resultObj.alias = accountAlias |
31 | 71 | resultObj.keyAlias = keyAlias |
@@ -50,27 +90,53 @@ account.createAccount = function( context) { | ||
50 | 90 | let retPromise = new Promise((resolve, reject) => { |
51 | 91 | const _bytom = context.bytom.clone(); |
52 | 92 | const currentAccount = _bytom.currentAccount |
53 | - | |
54 | 93 | 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; | |
59 | 94 | |
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 | + } | |
62 | 112 | |
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 | + }) | |
68 | 117 | }) |
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 | + // }) | |
69 | 134 | }) |
70 | 135 | return retPromise |
71 | 136 | } |
72 | 137 | |
73 | 138 | account.restoreByMnemonic = function(accountAlias, mnemonic, passwd, context) { |
139 | + | |
74 | 140 | let retPromise = new Promise((resolve, reject) => { |
75 | 141 | const keyAlias = `${accountAlias}-key-${uuid.v4()}` |
76 | 142 |
@@ -82,44 +148,38 @@ account.restoreByMnemonic = function(accountAlias, mnemonic, passwd, context) { | ||
82 | 148 | } |
83 | 149 | |
84 | 150 | _bytom.keychain.removeUnverifyIdentity(_bytom.settings.network); |
85 | - | |
86 | - const res = bytom.keys.restoreFromMnemonic(keyAlias, passwd, mnemonic) | |
87 | - | |
88 | 151 | _bytom.settings.netType = 'bytom'; |
89 | 152 | |
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) | |
98 | 155 | |
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) | |
109 | 163 | resultObj.alias = accountAlias |
110 | 164 | resultObj.keyAlias = keyAlias |
111 | 165 | resultObj.vMnemonic = true |
166 | + resultObj.bytom1 = bytom1Account | |
112 | 167 | |
113 | 168 | _bytom.keychain.pairs[_bytom.settings.network][accountAlias] = resultObj |
114 | 169 | _bytom.currentAccount = resultObj |
115 | 170 | |
171 | + if (_bytom.settings.chainType === 'bytom2') { | |
172 | + setChain('bytom') | |
173 | + } else { | |
174 | + setChain('bytom1') | |
175 | + } | |
176 | + | |
116 | 177 | context[Actions.UPDATE_STORED_BYTOM](_bytom).then(() => { |
117 | - resolve(ret) | |
178 | + resolve(bytom2Account) | |
179 | + }) | |
180 | + .catch(error => { | |
181 | + reject(error) | |
118 | 182 | }) |
119 | - .catch(error => { | |
120 | - reject(error) | |
121 | - }) | |
122 | - | |
123 | 183 | }) |
124 | 184 | }) |
125 | 185 | }) |
@@ -137,47 +197,43 @@ account.restoreByKeystore = function(accountAlias, keystore, password, context) | ||
137 | 197 | } |
138 | 198 | |
139 | 199 | _bytom.keychain.removeUnverifyIdentity(_bytom.settings.network); |
140 | - | |
141 | - const res = bytom.keys.restoreFromKeystore(password, keystore) | |
142 | - | |
143 | 200 | _bytom.settings.netType = 'bytom'; |
144 | 201 | |
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 | + } | |
162 | 206 | |
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, {}) | |
165 | 215 | resultObj.alias = accountAlias |
166 | 216 | resultObj.keyAlias = res.keyAlias |
167 | 217 | resultObj.vMnemonic = true |
168 | 218 | resultObj.keystore = keystore |
169 | 219 | resultObj.xpub = res.xpub |
220 | + resultObj.bytom1 = bytom1Account | |
170 | 221 | |
171 | 222 | _bytom.keychain.pairs[_bytom.settings.network][accountAlias] = resultObj |
172 | 223 | _bytom.currentAccount = resultObj |
173 | 224 | |
225 | + if (_bytom.settings.chainType === 'bytom2') { | |
226 | + setChain('bytom') | |
227 | + } else { | |
228 | + setChain('bytom1') | |
229 | + } | |
230 | + | |
174 | 231 | context[Actions.UPDATE_STORED_BYTOM](_bytom).then(() => { |
175 | - resolve(ret) | |
232 | + resolve(bytom2Account) | |
176 | 233 | }) |
177 | 234 | .catch(error => { |
178 | 235 | reject(error) |
179 | 236 | }) |
180 | - | |
181 | 237 | }) |
182 | 238 | }) |
183 | 239 | }) |
@@ -185,53 +241,66 @@ account.restoreByKeystore = function(accountAlias, keystore, password, context) | ||
185 | 241 | } |
186 | 242 | |
187 | 243 | 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 | |
199 | 256 | } |
200 | 257 | |
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 | +// } | |
214 | 271 | |
215 | 272 | account.balance = function(address , context) { |
216 | 273 | let retPromise = new Promise((resolve, reject) => { |
217 | - bytom.accounts | |
218 | - .listAddressUseServer(address) | |
274 | + wallet.getBalances(address) | |
275 | + // bytom.accounts | |
276 | + // .listAddressUseServer(address) | |
219 | 277 | .then(address => { |
220 | - let balances = address.balances || [] | |
221 | - let votes = address.votes || [] | |
222 | 278 | 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 | + } | |
223 | 289 | |
290 | + let balances = address.balances || [] | |
291 | + let votes = address.votes || [] | |
224 | 292 | |
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 | |
227 | 295 | |
228 | 296 | Sentry.configureScope(function(scope) { |
229 | 297 | if(!isVapor) { |
230 | 298 | scope.setTag("wallet.address", address.address); |
231 | 299 | } |
232 | 300 | }); |
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) | |
235 | 304 | |
236 | 305 | if(balanceNotEqual || voteNotEqual) { |
237 | 306 | //update AccountList |
@@ -240,15 +309,23 @@ account.balance = function(address , context) { | ||
240 | 309 | if (isVapor) { |
241 | 310 | _bytom.currentAccount.vpBalances = balances; |
242 | 311 | _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 | |
243 | 315 | } else { |
244 | 316 | _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 | |
246 | 318 | } |
247 | 319 | } |
248 | 320 | |
249 | 321 | 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; | |
251 | 327 | _bytom.keychain.pairs[_bytom.settings.network][_bytom.currentAccount.alias].votes = votes |
328 | + } | |
252 | 329 | } |
253 | 330 | |
254 | 331 | context[Actions.UPDATE_STORED_BYTOM](_bytom) |
@@ -263,21 +340,23 @@ account.balance = function(address , context) { | ||
263 | 340 | return retPromise |
264 | 341 | } |
265 | 342 | |
266 | -account.list = function() { | |
267 | - return bytom.accounts | |
268 | - .listAccountUseServer() | |
269 | -} | |
343 | +// account.list = function() { | |
344 | +// return bytom.accounts | |
345 | +// .listAccountUseServer() | |
346 | +// } | |
347 | + | |
270 | 348 | account.listKeyByXpubOld = function(xpub){ |
271 | 349 | return bytom.keys |
272 | 350 | .getKeyByXPub(xpub) |
273 | 351 | } |
274 | 352 | |
275 | -account.backup = function() { | |
276 | - return bytom.wallet.backup() | |
277 | -} | |
353 | +// account.backup = function() { | |
354 | +// return bytom.wallet.backup() | |
355 | +// } | |
278 | 356 | |
279 | 357 | account.isValidMnemonic = function(mnemonic) { |
280 | - return bytom.keys.isValidMnemonic(mnemonic) | |
358 | + // return bytom.keys.isValidMnemonic(mnemonic) | |
359 | + return wallet.isValidMnemonic(mnemonic) | |
281 | 360 | } |
282 | 361 | |
283 | 362 | account.isValidKeystore = function(keystore, context) { |
@@ -339,10 +418,10 @@ account.isAliasValid = function(alias, context){ | ||
339 | 418 | |
340 | 419 | account.decryptMnemonic = function(vault,password, context) { |
341 | 420 | 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) | |
343 | 423 | } |
344 | 424 | |
345 | - | |
346 | 425 | account.createOld = function(accountAlias, keyAlias, passwd, success, error) { |
347 | 426 | let retPromise = new Promise((resolve, reject) => { |
348 | 427 | if(!keyAlias){ |
@@ -368,7 +447,8 @@ account.createOld = function(accountAlias, keyAlias, passwd, success, error) { | ||
368 | 447 | } |
369 | 448 | |
370 | 449 | 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) | |
372 | 452 | } |
373 | 453 | |
374 | 454 | export default account |
@@ -1,13 +1,16 @@ | ||
1 | 1 | import bytom from "./bytom"; |
2 | +import { wallet } from './wallet' | |
2 | 3 | |
3 | 4 | let query = {}; |
4 | 5 | |
5 | 6 | query.chainStatus = function() { |
6 | - return bytom.query.getVoteStatus(); | |
7 | + return wallet.getVoteStatus() | |
8 | + // return bytom.query.getVoteStatus(); | |
7 | 9 | }; |
8 | 10 | |
9 | 11 | query.blockStatus = function() { |
10 | - return bytom.query.getblockcount(); | |
12 | + // return bytom.query.getblockcount(); | |
13 | + return wallet.getChainStatus() | |
11 | 14 | }; |
12 | 15 | |
13 | 16 | export default query; |
@@ -1,16 +1,22 @@ | ||
1 | 1 | import bytom from "./bytom"; |
2 | 2 | import { snakeize } from "@/utils/utils"; |
3 | 3 | import { networks } from '@/utils/constants' |
4 | - | |
4 | +import { wallet } from './wallet' | |
5 | 5 | |
6 | 6 | let transaction = {}; |
7 | 7 | |
8 | -transaction.list = function(guid, asset_id, start, limit, tx_types) { | |
8 | +transaction.list = function(address, asset_id, start, limit, tx_types) { | |
9 | 9 | const filter = {asset_id} |
10 | 10 | if(tx_types){ |
11 | - filter.tx_types = tx_types | |
11 | + filter.txType = tx_types[0] | |
12 | 12 | } |
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 | + }) | |
14 | 20 | }; |
15 | 21 | |
16 | 22 | transaction.listDelayTransaction = function(address, start, limit, network) { |
@@ -19,9 +25,9 @@ transaction.listDelayTransaction = function(address, start, limit, network) { | ||
19 | 25 | } |
20 | 26 | |
21 | 27 | let baseURL = networks[network] |
22 | - if(network==='testnet'){ | |
23 | - baseURL = baseURL+':3008' | |
24 | - } | |
28 | + // if(network==='testnet'){ | |
29 | + // baseURL = baseURL+':3008' | |
30 | + // } | |
25 | 31 | return bytom.transaction.listDelayTransaction(baseURL, address, start, limit); |
26 | 32 | }; |
27 | 33 |
@@ -29,8 +35,9 @@ transaction.convertArgument = function(argArray) { | ||
29 | 35 | let fn = function asyncConvert(object){ |
30 | 36 | const type = object.type |
31 | 37 | 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) | |
34 | 41 | }; |
35 | 42 | |
36 | 43 | let actionFunction = argArray.map(fn) |
@@ -38,25 +45,35 @@ transaction.convertArgument = function(argArray) { | ||
38 | 45 | }; |
39 | 46 | |
40 | 47 | transaction.chainStatus = function() { |
41 | - return bytom.query.getblockcount(); | |
48 | + return wallet.getChainStatus() | |
49 | + // return bytom.query.getblockcount(); | |
42 | 50 | }; |
43 | 51 | |
44 | 52 | 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); | |
46 | 55 | }; |
47 | 56 | |
48 | 57 | 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; | |
60 | 77 | }; |
61 | 78 | |
62 | 79 | transaction.buildCrossChain = function(address, to, asset, amount, confirmations) { |
@@ -74,31 +91,45 @@ transaction.buildCrossChain = function(address, to, asset, amount, confirmations | ||
74 | 91 | }; |
75 | 92 | |
76 | 93 | 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; | |
88 | 112 | }; |
89 | 113 | |
90 | 114 | 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; | |
102 | 133 | }; |
103 | 134 | |
104 | 135 | transaction.buildTransaction = function(address, inputs, outputs, gas, confirmations) { |
@@ -133,19 +164,19 @@ transaction.signTransaction = function(address, transaction, password, context) | ||
133 | 164 | return retPromise; |
134 | 165 | }; |
135 | 166 | |
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 | +// }; | |
149 | 180 | |
150 | 181 | transaction.transfer = function(transaction, password, address, context) { |
151 | 182 | let retPromise = new Promise((resolve, reject) => { |
@@ -153,9 +184,23 @@ transaction.transfer = function(transaction, password, address, context) { | ||
153 | 184 | const {to, asset, amount, confirmations} = transaction |
154 | 185 | // transfer to multi address |
155 | 186 | 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) | |
157 | 194 | } 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) | |
159 | 204 | } |
160 | 205 | } |
161 | 206 | build().then(result => { |
@@ -185,8 +230,13 @@ function signSubmit (txObject, password, address, context) { | ||
185 | 230 | context |
186 | 231 | ) |
187 | 232 | .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) | |
190 | 240 | .then(res3 => { |
191 | 241 | const object = { |
192 | 242 | transactionHash: res3.txHash |
@@ -208,8 +258,15 @@ function signSubmit (txObject, password, address, context) { | ||
208 | 258 | transaction.signMessage = function(message, password, address, context) { |
209 | 259 | const keyArray = context.bytom.keychain.findByAddress(address, context.bytom.settings.network); |
210 | 260 | 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 | + }) | |
213 | 270 | }; |
214 | 271 | |
215 | 272 | transaction.advancedTransfer = function(address, transaction, password, arrayData, context) { |
@@ -225,8 +282,13 @@ transaction.advancedTransfer = function(address, transaction, password, arrayDat | ||
225 | 282 | if(arrayData){ |
226 | 283 | signatures[0] = arrayData |
227 | 284 | } |
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) | |
230 | 292 | .then(res3 => { |
231 | 293 | const object ={ |
232 | 294 | transactionHash: res3.txHash |
@@ -251,15 +313,25 @@ function signTx(address, transaction, password, context){ | ||
251 | 313 | if(!keyArray){ |
252 | 314 | throw 'Account not found.' |
253 | 315 | }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) | |
258 | 329 | } |
259 | 330 | } |
260 | 331 | |
261 | 332 | 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) | |
263 | 335 | } |
264 | 336 | |
265 | 337 | export default transaction; |
@@ -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 |
@@ -113,6 +113,17 @@ store.dispatch(Actions.LOAD_BYTOM).then(() => { | ||
113 | 113 | }, |
114 | 114 | ); |
115 | 115 | |
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 | + | |
116 | 127 | const lang = store.getters.language === 'zh'?'cn':'en' |
117 | 128 | |
118 | 129 | getDomains(lang).then(({domains, domainMeta})=>{ |
@@ -35,7 +35,7 @@ import { Integrations } from '@sentry/tracing'; | ||
35 | 35 | import BytomObj from "./utils/Bytom"; |
36 | 36 | |
37 | 37 | import { updateLockTime, isNeedLock } from '@/models/lock' |
38 | - | |
38 | +import { wallet } from './models/wallet.js' | |
39 | 39 | store.dispatch(Actions.LOAD_BYTOM).then(() => { |
40 | 40 | Vue.use(VueI18n) |
41 | 41 | const i18n = new VueI18n({ |
@@ -115,6 +115,15 @@ store.dispatch(Actions.LOAD_BYTOM).then(() => { | ||
115 | 115 | }, |
116 | 116 | ); |
117 | 117 | |
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 | + | |
118 | 127 | getDomains().then(({domains, domainMeta})=>{ |
119 | 128 | const _bytom = store.state.bytom.clone() |
120 | 129 |
@@ -16,6 +16,7 @@ export const RouteNames = { | ||
16 | 16 | SETTINGS_LANG:'settings-language', |
17 | 17 | SETTINGS_CURRENCY:'settings-currency', |
18 | 18 | SETTINGS_NETWORK:'settings-network', |
19 | + SETTINGS_CHAIN:'settings-chain', | |
19 | 20 | SETTINGS_DELETE:'settings-delete', |
20 | 21 | |
21 | 22 | TRANSFER:'transfer', |
@@ -168,6 +169,14 @@ const routers = [ | ||
168 | 169 | } |
169 | 170 | }, |
170 | 171 | { |
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 | + { | |
171 | 180 | path: '/settings-delete', |
172 | 181 | name: RouteNames.SETTINGS_DELETE, |
173 | 182 | meta: { title: '删除钱包' }, |
@@ -24,6 +24,18 @@ const state = { | ||
24 | 24 | const getters = { |
25 | 25 | meta:state => state.bytom.meta, |
26 | 26 | 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 | + }, | |
27 | 39 | accountList:state => state.bytom.accountList, |
28 | 40 | net:state => state.bytom.settings.network, |
29 | 41 | netType:state => state.bytom.settings.netType, |
@@ -32,13 +44,15 @@ const getters = { | ||
32 | 44 | vMnemonic:state => state.bytom.currentAccount.vMnemonic, |
33 | 45 | currency:state => state.bytom.settings.currency, |
34 | 46 | clientId:state => state.bytom.settings.clientId, |
47 | + chainType:state => state.bytom.settings.chainType, | |
48 | + | |
35 | 49 | pairs: state => state.bytom.keychain.pairs, |
36 | 50 | |
37 | 51 | // FOR PROMPTS ONLY |
38 | 52 | messages:state => state.prompt.data.messages || [], |
39 | 53 | }; |
40 | 54 | |
41 | -export const store = new Vuex.Store({ | |
55 | +export const store = window.store = new Vuex.Store({ | |
42 | 56 | state, |
43 | 57 | getters, |
44 | 58 | mutations, |
@@ -9,6 +9,7 @@ export default class BytomObj { | ||
9 | 9 | this.settings = Settings.placeholder(); |
10 | 10 | this.keychain = Keychain.placeholder(); |
11 | 11 | this.histories = []; |
12 | + window.__bytom = this | |
12 | 13 | } |
13 | 14 | |
14 | 15 | static placeholder(){ return new BytomObj(); } |
@@ -14,7 +14,7 @@ export default class Keychain { | ||
14 | 14 | |
15 | 15 | findIdentity(publicKey, net){ return Object.values(this.pairs[net]).find(id => id.xpub === publicKey); } |
16 | 16 | 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); } | |
18 | 18 | |
19 | 19 | removeByAlias(alias, net){ |
20 | 20 | if(this.pairs[net][alias]){ |
@@ -7,6 +7,7 @@ export default class Settings { | ||
7 | 7 | this.domains = [] |
8 | 8 | this.language = uiLang||'en'; |
9 | 9 | this.netType ='bytom'; |
10 | + this.chainType = 'bytom2' | |
10 | 11 | this.network ='mainnet'; |
11 | 12 | // this.network ='testnet'; |
12 | 13 | this.currency = uiLang ==='en'?'inUsd':"inCny" |
@@ -18,7 +18,7 @@ export default class address { | ||
18 | 18 | const vpArray = ['vp', 'tp', 'sp'] |
19 | 19 | return vpArray.includes( address.substring(0,2) ) |
20 | 20 | }else{ |
21 | - const bmArray = ['bm', 'tm', 'sm'] | |
21 | + const bmArray = ['bm', 'tm', 'sm', 'bn', 'tn'] | |
22 | 22 | return bmArray.includes( address.substring(0,2) ) |
23 | 23 | } |
24 | 24 | } |
@@ -22,14 +22,22 @@ export const camelize = (object) => { | ||
22 | 22 | |
23 | 23 | export const networks = { |
24 | 24 | 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' | |
26 | 31 | } |
27 | 32 | |
28 | 33 | export const networksJS = { |
29 | - mainnetbytom: `${networks['mainnet']}/bytom/v3/`, | |
34 | + mainnetbytom: `${networks['mainnet']}/bycoin/bytom2/v1/`, | |
30 | 35 | 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/`, | |
33 | 41 | } |
34 | 42 | |
35 | 43 |
@@ -54,5 +62,5 @@ export const decimalsMap = { | ||
54 | 62 | } |
55 | 63 | |
56 | 64 | //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/' |
@@ -32,8 +32,12 @@ export default class Error { | ||
32 | 32 | return new Error(ErrorTypes.TYPE_DISAUTH, `The current domain is no auth, it can't be disauth`, ErrorCodes.TYPE_DISAUTH) |
33 | 33 | } |
34 | 34 | |
35 | + static forbidden() { | |
36 | + return new Error(ErrorTypes.FORBIDDEN, `Authorization denied`, ErrorCodes.FORBIDDEN) | |
37 | + } | |
38 | + | |
35 | 39 | 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) | |
37 | 41 | } |
38 | 42 | |
39 | 43 | static signatureError(_type, _message){ |
@@ -66,21 +66,23 @@ export function getDomains(lang = 'en'){ | ||
66 | 66 | } |
67 | 67 | |
68 | 68 | 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 | + // }); | |
84 | 86 | } |
85 | 87 | |
86 | 88 | function updateDomainMeta(jsonData, domainMeta, lang){ |
@@ -114,8 +114,10 @@ font-size: 15px; | ||
114 | 114 | </section> |
115 | 115 | <section class="transaction-title"> |
116 | 116 | <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> --> | |
118 | 118 | <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> | |
119 | 121 | </section> |
120 | 122 | |
121 | 123 | <section class="transactions"> |
@@ -126,14 +128,14 @@ font-size: 15px; | ||
126 | 128 | <div class="font-bold"> |
127 | 129 | {{transaction.type}} |
128 | 130 | </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> | |
131 | 133 | </div> |
132 | 134 | <div class="text-align-right"> |
133 | 135 | <div class="value">{{transaction.direct}}{{transaction.val}} {{currentAsset.asset.symbol}}</div> |
134 | 136 | |
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') }} | |
137 | 139 | </div> |
138 | 140 | <div class="addr color-grey" v-else-if="transaction.hasOwnProperty('blockTimestamp')"> |
139 | 141 | {{transaction.submissionTimestamp | moment}} |
@@ -160,11 +162,12 @@ font-size: 15px; | ||
160 | 162 | </template> |
161 | 163 | |
162 | 164 | <script> |
165 | +import axios from 'axios' | |
163 | 166 | import address from "@/utils/address"; |
164 | 167 | import query from "@/models/query"; |
165 | 168 | import transaction from "@/models/transaction"; |
166 | 169 | import { camelize } from "@/utils/utils"; |
167 | -import { BTM } from "@/utils/constants"; | |
170 | +import { BTM, blockmetaNetworks } from "@/utils/constants"; | |
168 | 171 | import { mapActions, mapGetters, mapState } from 'vuex' |
169 | 172 | import * as Actions from '@/store/constants'; |
170 | 173 | import _ from 'lodash'; |
@@ -202,13 +205,13 @@ export default { | ||
202 | 205 | }, |
203 | 206 | }, |
204 | 207 | 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 | + // }, | |
212 | 215 | ...mapState([ |
213 | 216 | 'bytom', |
214 | 217 | 'currentAsset', |
@@ -218,12 +221,17 @@ export default { | ||
218 | 221 | 'language', |
219 | 222 | 'currentAccount', |
220 | 223 | 'currency', |
221 | - 'netType' | |
224 | + 'netType', | |
225 | + 'net', | |
226 | + 'currentAddress' | |
222 | 227 | ]) |
223 | 228 | }, |
224 | 229 | methods: { |
225 | 230 | img:function (symbol) { |
226 | - const _symbol = symbol.toLowerCase(); | |
231 | + let _symbol = symbol.toLowerCase(); | |
232 | + if (_symbol === 'btm') { | |
233 | + _symbol = 'btm2' | |
234 | + } | |
227 | 235 | if(this.netType === 'vapor'){ |
228 | 236 | return `https://cdn.blockmeta.com/resources/logo/vapor/${_symbol}.png` |
229 | 237 | }else{ |
@@ -252,6 +260,16 @@ export default { | ||
252 | 260 | formatCurrency: function (num) { |
253 | 261 | return Num.formatCurrency(num, this.currency) |
254 | 262 | }, |
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 | + }, | |
255 | 273 | itemBalance: function(asset){ |
256 | 274 | if(asset.asset.assetId === BTM){ |
257 | 275 | return Num.formatNue(asset.balance,8) |
@@ -286,17 +304,23 @@ export default { | ||
286 | 304 | let type_txs |
287 | 305 | switch (type){ |
288 | 306 | case 'transfer_out': |
289 | - type_txs = ["transfer_out"]; | |
307 | + type_txs = ["ordinary"]; | |
290 | 308 | break; |
291 | 309 | 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"]; | |
293 | 317 | break; |
294 | 318 | default: |
295 | 319 | type_txs = [] |
296 | 320 | break; |
297 | 321 | } |
298 | 322 | |
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 => { | |
300 | 324 | if (transactions == null) { |
301 | 325 | return; |
302 | 326 | } |
@@ -318,11 +342,11 @@ export default { | ||
318 | 342 | .filter(b => b.asset.assetId === assetID); |
319 | 343 | |
320 | 344 | 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) | |
322 | 346 | .map(input => input.address) |
323 | 347 | |
324 | 348 | 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) | |
326 | 350 | .map(output => output.address) |
327 | 351 | |
328 | 352 | if(balanceObject.length ===1 ){ |
@@ -349,11 +373,11 @@ export default { | ||
349 | 373 | transaction.type = this.$t("common.transfer_out"); |
350 | 374 | } |
351 | 375 | |
352 | - const resultAddr = outputAddresses.pop() || this.address | |
376 | + const resultAddr = outputAddresses.pop() || this.currentAddress | |
353 | 377 | transaction.address = (resultAddr && resultAddr.includes(' '))?resultAddr:address.short(resultAddr); |
354 | 378 | } |
355 | 379 | |
356 | - if(transaction.types.includes('in_crosschain')){ | |
380 | + if(transaction.types.includes('cross_chain')){ | |
357 | 381 | const chain = this.netType ==='vapor'? this.$t("listAsset.main"):this.$t("listAsset.side") |
358 | 382 | let symbol = this.currentAsset.asset.symbol |
359 | 383 | if(symbol =='SUP' ){ |
@@ -364,16 +388,19 @@ export default { | ||
364 | 388 | symbol='ETH' |
365 | 389 | } |
366 | 390 | transaction.address = `${symbol} ${chain}` |
391 | + transaction.type = this.$t("common.cross_chain") | |
367 | 392 | }else if(transaction.types.includes('vote')){ |
368 | 393 | 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)):'-' | |
371 | 396 | transaction.type = this.$t("common.vote") |
397 | + transaction.vote = pubKey | |
372 | 398 | }else if(transaction.types.includes('veto')){ |
373 | 399 | 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)):'-' | |
376 | 402 | transaction.type = this.$t("common.veto") |
403 | + transaction.vote = pubKey | |
377 | 404 | } |
378 | 405 | transaction.val = val ; |
379 | 406 |
@@ -384,8 +411,8 @@ export default { | ||
384 | 411 | } |
385 | 412 | transaction.val = 0 |
386 | 413 | 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 | |
389 | 416 | |
390 | 417 | transaction.address = address.short(resultAddr) |
391 | 418 |
@@ -403,12 +430,12 @@ export default { | ||
403 | 430 | // this.refreshTransactions( this.start, limit, this.type).then(transactions => { |
404 | 431 | // this.transactions = transactions |
405 | 432 | // }); |
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) { | |
409 | 436 | const votes = {} |
410 | - resp.consensusNodes.map( (item) => { | |
411 | - votes[item.pubKey] = item | |
437 | + resp.data.data.forEach((item) => { | |
438 | + votes[item.pub_key] = item | |
412 | 439 | }); |
413 | 440 | this[Actions.SET_LIST_VOTE](votes) |
414 | 441 | } |
@@ -9,6 +9,7 @@ | ||
9 | 9 | text-align: center; |
10 | 10 | color: rgba(0, 0, 0, 0.88); |
11 | 11 | margin: 10px 0; |
12 | + white-space: pre; | |
12 | 13 | } |
13 | 14 | |
14 | 15 | .mnemnonic-box{ |
@@ -155,11 +155,12 @@ export default { | ||
155 | 155 | }, |
156 | 156 | computed: { |
157 | 157 | 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 | + // } | |
163 | 164 | }, |
164 | 165 | ...mapState([ |
165 | 166 | 'bytom', |
@@ -169,6 +170,7 @@ export default { | ||
169 | 170 | ...mapGetters([ |
170 | 171 | 'language', |
171 | 172 | 'currentAccount', |
173 | + 'currentAddress', | |
172 | 174 | 'currency', |
173 | 175 | 'netType', |
174 | 176 | 'net' |
@@ -319,12 +319,12 @@ input:checked + .slider:before { | ||
319 | 319 | </section> |
320 | 320 | <section v-if="address!=undefined" class="transaction-title"> |
321 | 321 | <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> --> | |
323 | 323 | </section> |
324 | 324 | <section class="assets"> |
325 | - <div v-if=" balances && balances.length > 0"> | |
325 | + <div v-if=" currentBalances && currentBalances.length > 0"> | |
326 | 326 | <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)"> | |
328 | 328 | <div class="symbol" v-if="balance.asset.symbol!== 'Asset'"> |
329 | 329 | <img :src="img(balance.asset.symbol)" alt="" class="c-icon" v-on:error="onImgError"> |
330 | 330 | <div class="uppercase"> |
@@ -410,6 +410,7 @@ export default { | ||
410 | 410 | symbol: "BTM", |
411 | 411 | decimals: 8 |
412 | 412 | } , |
413 | + balance: 0, | |
413 | 414 | availableBalance: 0, |
414 | 415 | inBtc: "0", |
415 | 416 | inCny: "0", |
@@ -421,6 +422,7 @@ export default { | ||
421 | 422 | }, |
422 | 423 | watch: { |
423 | 424 | '$route'(to, from) { |
425 | + this.refreshBalance(this.address) | |
424 | 426 | if (to.name.startsWith('menu')) { |
425 | 427 | this.maskShow = true |
426 | 428 | } else if (from.name.startsWith('menu')) { |
@@ -443,19 +445,19 @@ export default { | ||
443 | 445 | return; |
444 | 446 | } |
445 | 447 | |
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) | |
453 | 455 | }, |
454 | 456 | }, |
455 | 457 | computed: { |
456 | 458 | accountBalance: function () { |
457 | 459 | let balance |
458 | - const balances = this.balances | |
460 | + const balances = this.currentBalances | |
459 | 461 | |
460 | 462 | if(balances && balances.length >0 ){ |
461 | 463 | const currency = camelize(this.currency) |
@@ -469,14 +471,14 @@ export default { | ||
469 | 471 | const vpAddress = this.currentAccount.vpAddress |
470 | 472 | if(!vpAddress){ |
471 | 473 | const bytom = this.bytom.clone(); |
472 | - return account.copy(this.currentAccount.guid).then(accounts => { | |
474 | + return account.copy(this.currentAccount.bytom1.guid).then(accounts => { | |
473 | 475 | //update currentAccount |
474 | 476 | bytom.currentAccount.vpAddress = accounts.address |
475 | 477 | //update AccountList |
476 | 478 | bytom.keychain.pairs[this.net][bytom.currentAccount.alias].vpAddress = accounts.address |
477 | 479 | |
478 | 480 | this[Actions.UPDATE_STORED_BYTOM](bytom).then(() => { |
479 | - this.setupRefreshTimer() | |
481 | + // this.setupRefreshTimer() | |
480 | 482 | }) |
481 | 483 | |
482 | 484 | return accounts.address |
@@ -484,30 +486,39 @@ export default { | ||
484 | 486 | }else return vpAddress |
485 | 487 | |
486 | 488 | }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 | |
495 | 491 | } |
496 | 492 | }, |
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 | + // }, | |
497 | 502 | ...mapState([ |
498 | 503 | 'bytom' |
499 | 504 | ]), |
500 | 505 | ...mapGetters([ |
501 | 506 | 'currentAccount', |
507 | + 'currentAddress', | |
508 | + 'currentBalances', | |
502 | 509 | 'accountList', |
503 | 510 | 'net', |
504 | 511 | 'netType', |
512 | + 'chainType', | |
505 | 513 | 'currency' |
506 | 514 | ]) |
507 | 515 | }, |
508 | 516 | methods: { |
509 | 517 | img:function (symbol) { |
510 | - const _symbol = symbol.toLowerCase(); | |
518 | + let _symbol = symbol.toLowerCase(); | |
519 | + if (_symbol === 'btm') { | |
520 | + _symbol = 'btm2' | |
521 | + } | |
511 | 522 | if(this.netType === 'vapor'){ |
512 | 523 | return `https://cdn.blockmeta.com/resources/logo/vapor/${_symbol}.png` |
513 | 524 | }else{ |
@@ -544,20 +555,20 @@ export default { | ||
544 | 555 | }, |
545 | 556 | netTypeToggle: function () { |
546 | 557 | const bytom = this.bytom.clone(); |
547 | - const newNetType = this.isVapor? 'vapor':'bytom' | |
558 | + const newNetType = this.isVapor ? 'vapor' : bytom.settings.chainType === 'bytom2' ? 'bytom' : 'bytom1' | |
548 | 559 | |
549 | 560 | bytom.settings.netType = newNetType; |
550 | 561 | |
551 | 562 | account.setupNet(`${this.net}${newNetType}`) |
552 | 563 | if(this.isVapor && !this.currentAccount.vpAddress){ |
553 | - account.copy(this.currentAccount.guid).then(accounts => { | |
564 | + account.copy(this.currentAccount.bytom1.guid).then(accounts => { | |
554 | 565 | //update currentAccount |
555 | 566 | bytom.currentAccount.vpAddress = accounts.address |
556 | 567 | //update AccountList |
557 | 568 | bytom.keychain.pairs[this.net][bytom.currentAccount.alias].vpAddress = accounts.address |
558 | 569 | |
559 | 570 | this[Actions.UPDATE_STORED_BYTOM](bytom).then(()=>{ |
560 | - this.setupRefreshTimer() | |
571 | + this.refreshBalance(this.address) | |
561 | 572 | }) |
562 | 573 | }).catch(error =>{ |
563 | 574 | let e = error |
@@ -570,7 +581,8 @@ export default { | ||
570 | 581 | }) |
571 | 582 | }else{ |
572 | 583 | this[Actions.UPDATE_STORED_BYTOM](bytom).then(()=>{ |
573 | - this.setupRefreshTimer() | |
584 | + this.refreshBalance(this.address) | |
585 | + // this.setupRefreshTimer() | |
574 | 586 | }) |
575 | 587 | } |
576 | 588 | }, |
@@ -597,12 +609,12 @@ export default { | ||
597 | 609 | this.$router.push('asset') |
598 | 610 | }, |
599 | 611 | refreshBalance: function (address) { |
600 | - if(address){ | |
601 | - account.balance(address, this) | |
612 | + // if(address){ | |
613 | + account.balance(this.currentAddress, this) | |
602 | 614 | .catch(error => { |
603 | 615 | console.log(error); |
604 | 616 | }); |
605 | - } | |
617 | + // } | |
606 | 618 | }, |
607 | 619 | ...mapActions([ |
608 | 620 | Actions.UPDATE_STORED_BYTOM, |
@@ -61,7 +61,7 @@ | ||
61 | 61 | display: flex; |
62 | 62 | justify-content: center; |
63 | 63 | align-items: center; |
64 | - width: 114px; | |
64 | + width: 140px; | |
65 | 65 | border-radius: 12px; |
66 | 66 | margin-left: auto; |
67 | 67 | margin-right: auto; |
@@ -300,7 +300,7 @@ | ||
300 | 300 | import account from "@/models/account"; |
301 | 301 | import add from "@/utils/address"; |
302 | 302 | import { camelize, removeFromArray } from "@/utils/utils"; |
303 | - import bytomjslib from 'bytomjs-lib' | |
303 | + // import bytomjslib from 'bytomjs-lib' | |
304 | 304 | import BigNumber from "bignumber.js" |
305 | 305 | |
306 | 306 | export default { |
@@ -326,11 +326,12 @@ | ||
326 | 326 | } |
327 | 327 | }, |
328 | 328 | 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 | + // } | |
334 | 335 | }, |
335 | 336 | shortAddress: function () { |
336 | 337 | if(this.prompt.data && this.prompt.data.type ==='transfer') { |
@@ -338,11 +339,12 @@ | ||
338 | 339 | }else if(this.prompt.data && this.prompt.data.type ==='message'){ |
339 | 340 | return add.short(this.transaction.address); |
340 | 341 | }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 | + // } | |
346 | 348 | } |
347 | 349 | }, |
348 | 350 | detail(){ |
@@ -377,6 +379,7 @@ | ||
377 | 379 | ]), |
378 | 380 | ...mapGetters([ |
379 | 381 | 'currentAccount', |
382 | + 'currentAddress', | |
380 | 383 | 'net', |
381 | 384 | 'netType', |
382 | 385 | 'domainsMeta' |
@@ -413,7 +416,9 @@ | ||
413 | 416 | return transaction.advancedTransfer(this.address, result[0], this.password, arrayData, this) |
414 | 417 | .then((resp) => { |
415 | 418 | loader.hide(); |
416 | - this.prompt.responder(resp); | |
419 | + this.prompt.responder({ | |
420 | + hash: resp.transactionHash | |
421 | + }); | |
417 | 422 | this.$toast.success( |
418 | 423 | this.$t("transfer.success") |
419 | 424 | ); |
@@ -436,7 +441,9 @@ | ||
436 | 441 | } else if(this.prompt.data.type ==='transfer'){ |
437 | 442 | transaction.transfer(this.transaction, this.password, this.address, this).then(result => { |
438 | 443 | loader.hide(); |
439 | - this.prompt.responder(result); | |
444 | + this.prompt.responder({ | |
445 | + hash: result[0].transactionHash | |
446 | + }); | |
440 | 447 | this.$toast.success( |
441 | 448 | this.$t("transfer.success") |
442 | 449 | ); |
@@ -521,8 +528,9 @@ | ||
521 | 528 | return transaction.asset(assetID) |
522 | 529 | } |
523 | 530 | }, mounted() { |
524 | - this.prompt = window.data || apis.extension.getBackgroundPage().notification || null; | |
531 | + console.log('mounted') | |
525 | 532 | console.log(this.prompt) |
533 | + this.prompt = window.data || apis.extension.getBackgroundPage().notification || null; | |
526 | 534 | |
527 | 535 | const params = this.prompt.data |
528 | 536 | if (params !== undefined) { |
@@ -619,15 +627,15 @@ | ||
619 | 627 | } |
620 | 628 | case "signTransaction":{ |
621 | 629 | const param = data[0] || data |
622 | - | |
623 | 630 | const _tx = camelize(param) |
624 | 631 | const rawTransaction = _tx.rawTransaction |
625 | 632 | |
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 | |
631 | 639 | this.transaction.input = tx.inputs |
632 | 640 | this.transaction.output = tx.outputs |
633 | 641 |
@@ -639,7 +647,7 @@ | ||
639 | 647 | const asset = _.union(inputAsset, outputAsset) |
640 | 648 | let that = this; |
641 | 649 | |
642 | - let types = ["transfer"] | |
650 | + let types = ["transfer", "vote"] | |
643 | 651 | const promise = |
644 | 652 | asset |
645 | 653 | .map((assetId) => { |
@@ -653,7 +661,7 @@ | ||
653 | 661 | const amount = inputAmount.minus(outputAmount) |
654 | 662 | |
655 | 663 | 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'){ | |
657 | 665 | that.transaction.types = (that.$t('common.cross_chain')); |
658 | 666 | } |
659 | 667 |
@@ -685,7 +693,8 @@ | ||
685 | 693 | types = removeFromArray(types, remove); |
686 | 694 | types = types.map(ty => this.$t(`common.${ty}`)).join(', '); |
687 | 695 | |
688 | - this.transaction.types = types | |
696 | + // this.transaction.types = types | |
697 | + this.transaction.types = tx.types.map(ty => this.$t(`common.${ty}`)).join(', '); | |
689 | 698 | |
690 | 699 | Promise.all(promise).then(function(output) { |
691 | 700 | that.transaction.amounts = output |
@@ -103,37 +103,45 @@ | ||
103 | 103 | export default { |
104 | 104 | data() { |
105 | 105 | return { |
106 | - addr: "111", | |
106 | + addr: "", | |
107 | 107 | qrcode: Object, |
108 | 108 | clipboard: new ClipboardJS(".address-text"), |
109 | 109 | addressTitle: this.$t("main.copy"), |
110 | - currentCoin:'BTM' | |
110 | + currentCoin: 'BTM' | |
111 | 111 | }; |
112 | 112 | }, |
113 | 113 | computed: { |
114 | 114 | 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 | + // } | |
121 | 121 | if(symbols.length >1){ |
122 | 122 | 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 | + } | |
125 | 127 | } |
126 | 128 | |
127 | 129 | return symbols || [] |
128 | 130 | }, |
129 | 131 | ...mapGetters([ |
130 | 132 | 'currentAccount', |
131 | - 'netType' | |
133 | + 'currentAddress', | |
134 | + 'currentBalances', | |
135 | + 'netType', | |
136 | + 'chainType' | |
132 | 137 | ]) |
133 | 138 | }, |
134 | 139 | methods: { |
135 | 140 | img:function (symbol) { |
136 | - const _symbol = symbol.toLowerCase(); | |
141 | + let _symbol = symbol.toLowerCase(); | |
142 | + if (_symbol === 'btm') { | |
143 | + _symbol = 'btm2' | |
144 | + } | |
137 | 145 | if(this.netType === 'vapor'){ |
138 | 146 | return `https://cdn.blockmeta.com/resources/logo/vapor/${_symbol}.png` |
139 | 147 | }else{ |
@@ -160,14 +168,23 @@ | ||
160 | 168 | }, |
161 | 169 | }, |
162 | 170 | 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 | |
164 | 176 | if(this.netType === 'vapor'){ |
165 | 177 | 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}` | |
166 | 182 | }else{ |
167 | - this.addr = this.currentAccount.address; | |
183 | + this.addr = this.currentAddress; | |
184 | + text = `bytom2:${this.addr}` | |
168 | 185 | } |
169 | 186 | this.qrcode = new QRCode( "qrcode", { |
170 | - text: this.addr, | |
187 | + text, | |
171 | 188 | width: 150, |
172 | 189 | height: 150, |
173 | 190 | colorDark: "#000000", |
@@ -170,17 +170,19 @@ export default { | ||
170 | 170 | }, |
171 | 171 | computed: { |
172 | 172 | 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 | + // } | |
178 | 179 | }, |
179 | 180 | ...mapState([ |
180 | 181 | 'bytom' |
181 | 182 | ]), |
182 | 183 | ...mapGetters([ |
183 | 184 | 'currentAccount', |
185 | + 'currentAddress', | |
184 | 186 | 'net', |
185 | 187 | 'netType', |
186 | 188 | ]) |
@@ -57,18 +57,21 @@ export default { | ||
57 | 57 | }, |
58 | 58 | computed: { |
59 | 59 | 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 | + // } | |
65 | 66 | |
66 | 67 | }, |
67 | 68 | ...mapState([ |
68 | - 'currentAsset' | |
69 | + 'currentAsset', | |
70 | + 'bytom' | |
69 | 71 | ]), |
70 | 72 | ...mapGetters([ |
71 | 73 | 'currentAccount', |
74 | + 'currentBalances', | |
72 | 75 | 'netType' |
73 | 76 | ]) |
74 | 77 | }, |
@@ -77,12 +80,13 @@ export default { | ||
77 | 80 | this.asset = event.target.value |
78 | 81 | }, |
79 | 82 | 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 | + // } | |
86 | 90 | if(balance){ |
87 | 91 | this[Actions.SET_CURRENT_ASSET](balance.asset) |
88 | 92 | } |
@@ -235,11 +235,12 @@ export default { | ||
235 | 235 | } |
236 | 236 | }, |
237 | 237 | 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 | + // } | |
243 | 244 | }, |
244 | 245 | unit() { |
245 | 246 | return this.selectAsset.asset.symbol; |
@@ -268,6 +269,7 @@ export default { | ||
268 | 269 | ]), |
269 | 270 | ...mapGetters([ |
270 | 271 | 'currentAccount', |
272 | + 'currentAddress', | |
271 | 273 | 'accountList', |
272 | 274 | 'net', |
273 | 275 | 'netType', |
@@ -154,7 +154,7 @@ import account from "@/models/account"; | ||
154 | 154 | import { camelize, removeFromArray } from "@/utils/utils"; |
155 | 155 | import { decimalsMap } from "@/utils/constants" |
156 | 156 | import BigNumber from "bignumber.js" |
157 | -import bytomjslib from 'bytomjs-lib' | |
157 | +// import bytomjslib from 'bytomjs-lib' | |
158 | 158 | |
159 | 159 | |
160 | 160 | export default { |
@@ -180,6 +180,7 @@ export default { | ||
180 | 180 | ]), |
181 | 181 | ...mapGetters([ |
182 | 182 | 'currentAccount', |
183 | + 'currentAddress', | |
183 | 184 | 'net', |
184 | 185 | 'netType', |
185 | 186 | ]) |
@@ -243,15 +244,16 @@ export default { | ||
243 | 244 | const param = Array.isArray(this.prompt.data)? this.prompt.data[0] : this.prompt.data |
244 | 245 | const _tx = camelize(param) |
245 | 246 | 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 | |
249 | 251 | |
250 | 252 | 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) | |
255 | 257 | this.transaction.fee = tx.fee/100000000 |
256 | 258 | this.transaction.input = tx.inputs |
257 | 259 | this.transaction.output = tx.outputs |
@@ -130,7 +130,7 @@ input.form-item-content:active | ||
130 | 130 | <div class="form-item"> |
131 | 131 | <label class="form-item-label">{{ $t('transfer.address') }}</label> |
132 | 132 | <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')" | |
134 | 134 | type="text" |
135 | 135 | id="to" |
136 | 136 | name="to" |
@@ -228,7 +228,7 @@ export default { | ||
228 | 228 | selectAsset:{ |
229 | 229 | assetId: "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", |
230 | 230 | name: "Bytom", |
231 | - symbol: "BTM" | |
231 | + symbol: window.store.getters.netType !== 'vapor' && window.store.getters.chainType === 'bytom1' ? "BTMC" : "BTM" | |
232 | 232 | } |
233 | 233 | }; |
234 | 234 | }, |
@@ -245,31 +245,36 @@ export default { | ||
245 | 245 | }, |
246 | 246 | computed: { |
247 | 247 | 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) | |
260 | 252 | } |
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 | + // } | |
261 | 266 | }, |
262 | 267 | currentBalance(){ |
263 | 268 | const assetId = this.selectAsset.assetId |
264 | - let balances | |
269 | + // let balances | |
265 | 270 | |
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 | + // } | |
271 | 276 | |
272 | - const balance = balances.find(b => b.asset.assetId === assetId) | |
277 | + const balance = this.currentBalances.find(b => b.asset.assetId === assetId) | |
273 | 278 | return balance? balance.availableBalance:0; |
274 | 279 | }, |
275 | 280 | unit() { |
@@ -282,9 +287,12 @@ export default { | ||
282 | 287 | ...mapGetters([ |
283 | 288 | 'language', |
284 | 289 | 'currentAccount', |
290 | + 'currentBalances', | |
291 | + 'currentAddress', | |
285 | 292 | 'accountList', |
286 | 293 | 'currency', |
287 | - 'netType' | |
294 | + 'netType', | |
295 | + 'chainType', | |
288 | 296 | ]) |
289 | 297 | }, |
290 | 298 | watch: { |
@@ -335,12 +343,15 @@ export default { | ||
335 | 343 | const asset_amount={} |
336 | 344 | asset_amount[this.selectAsset.assetId] = this.transaction.amount || 0; |
337 | 345 | |
338 | - return transaction.estimateFee(this.address, asset_amount).then( (resp) =>{ | |
346 | + return transaction.estimateFee(this.currentAddress, asset_amount).then( (resp) =>{ | |
339 | 347 | this.transaction.fee = resp.fee |
340 | 348 | }) |
341 | 349 | }, |
342 | 350 | img:function (symbol) { |
343 | - const _symbol = symbol.toLowerCase(); | |
351 | + let _symbol = symbol.toLowerCase(); | |
352 | + if (_symbol === 'btm') { | |
353 | + _symbol = 'btm2' | |
354 | + } | |
344 | 355 | if(this.netType === 'vapor'){ |
345 | 356 | return `https://cdn.blockmeta.com/resources/logo/vapor/${_symbol}.png` |
346 | 357 | }else{ |
@@ -431,7 +442,7 @@ export default { | ||
431 | 442 | |
432 | 443 | this.transaction.asset = this.selectAsset.assetId; |
433 | 444 | 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 => { | |
435 | 446 | loader.hide(); |
436 | 447 | this.$router.push('/') |
437 | 448 |
@@ -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> |
@@ -70,6 +70,14 @@ | ||
70 | 70 | {{ $t(`main.${net}`) }} <i class="iconfont icon_arrow_1"></i> |
71 | 71 | </div> |
72 | 72 | </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> | |
73 | 81 | <div class="row" @click="$router.push({ name: 'settings-delete'})"> |
74 | 82 | <div class="label color-grey-36"> |
75 | 83 | <p>{{ $t("setting.deleteWallet") }}</p> |
@@ -104,6 +112,9 @@ export default { | ||
104 | 112 | return 'English' |
105 | 113 | } |
106 | 114 | }, |
115 | + currentChain() { | |
116 | + return this.chainType === 'bytom1' ? 'Bytom Classic' : 'Bytom' | |
117 | + }, | |
107 | 118 | link(){ |
108 | 119 | return `${apis.runtime.getURL('pages/prompt.html')}`; |
109 | 120 | }, |
@@ -122,7 +133,8 @@ export default { | ||
122 | 133 | ...mapGetters([ |
123 | 134 | 'language', |
124 | 135 | 'currency', |
125 | - 'net' | |
136 | + 'net', | |
137 | + 'chainType' | |
126 | 138 | ]) |
127 | 139 | }, |
128 | 140 | methods: { |
@@ -84,7 +84,7 @@ | ||
84 | 84 | <div class="menu-content"> |
85 | 85 | <div class="list accounts"> |
86 | 86 | <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'"> | |
88 | 88 | <div class="wallet"> |
89 | 89 | <i class="iconfont icon-wallet"></i> |
90 | 90 | </div> |
@@ -143,6 +143,7 @@ | ||
143 | 143 | ]), |
144 | 144 | ...mapGetters([ |
145 | 145 | 'currentAccount', |
146 | + 'currentAddress', | |
146 | 147 | 'accountList' |
147 | 148 | ]) |
148 | 149 | }, |
@@ -262,6 +262,7 @@ | ||
262 | 262 | ]), |
263 | 263 | ...mapGetters([ |
264 | 264 | 'currentAccount', |
265 | + 'currentAddress', | |
265 | 266 | 'netType' |
266 | 267 | ]) |
267 | 268 | }, |
@@ -269,11 +270,12 @@ | ||
269 | 270 | let params = this.$route.params; |
270 | 271 | |
271 | 272 | 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 | |
277 | 279 | console.log(params.transaction) |
278 | 280 | if(transaction.type =='vote' || transaction.type =='veto'){ |
279 | 281 | const node =_.find(this.listVote, {pubKey: transaction.pubkey}) |
@@ -23,6 +23,62 @@ | ||
23 | 23 | chalk "^2.0.0" |
24 | 24 | js-tokens "^4.0.0" |
25 | 25 | |
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 | + | |
26 | 82 | "@sentry/browser@^5.22.3": |
27 | 83 | version "5.30.0" |
28 | 84 | 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 @@ | ||
96 | 152 | "@sentry/types" "5.30.0" |
97 | 153 | tslib "^1.9.3" |
98 | 154 | |
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 | + | |
99 | 172 | abbrev@1: |
100 | 173 | version "1.1.1" |
101 | 174 | resolved "https://registry.npm.taobao.org/abbrev/download/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" |
@@ -486,6 +559,13 @@ axios@^0.18.0: | ||
486 | 559 | follow-redirects "1.5.10" |
487 | 560 | is-buffer "^2.0.2" |
488 | 561 | |
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 | + | |
489 | 569 | babel-code-frame@^6.26.0: |
490 | 570 | version "6.26.0" |
491 | 571 | 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: | ||
1131 | 1211 | resolved "https://registry.npm.taobao.org/bech32/download/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" |
1132 | 1212 | integrity sha1-44yfN78Xm46xauOncrQMNW1IMuk= |
1133 | 1213 | |
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 | + | |
1134 | 1219 | big.js@^3.1.3: |
1135 | 1220 | version "3.2.0" |
1136 | 1221 | resolved "https://registry.npm.taobao.org/big.js/download/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e" |
@@ -1163,6 +1248,16 @@ bindings@^1.5.0: | ||
1163 | 1248 | dependencies: |
1164 | 1249 | file-uri-to-path "1.0.0" |
1165 | 1250 | |
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 | + | |
1166 | 1261 | bl@^1.0.0: |
1167 | 1262 | version "1.2.3" |
1168 | 1263 | 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: | ||
1197 | 1292 | resolved "https://registry.npm.taobao.org/bn.js/download/bn.js-4.11.9.tgz#26d556829458f9d1e81fc48952493d0ba3507828" |
1198 | 1293 | integrity sha1-JtVWgpRY+dHoH8SJUkk9C6NQeCg= |
1199 | 1294 | |
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: | |
1201 | 1296 | version "5.2.0" |
1202 | 1297 | resolved "https://registry.npm.taobao.org/bn.js/download/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002" |
1203 | 1298 | integrity sha1-NYhgZ0OWxpl3canQUfzBtX1K4AI= |
@@ -1348,6 +1443,11 @@ browserslist@^3.2.6: | ||
1348 | 1443 | caniuse-lite "^1.0.30000844" |
1349 | 1444 | electron-to-chromium "^1.3.47" |
1350 | 1445 | |
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 | + | |
1351 | 1451 | buffer-alloc-unsafe@^1.1.0: |
1352 | 1452 | version "1.1.0" |
1353 | 1453 | 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: | ||
1426 | 1526 | axios "^0.18.0" |
1427 | 1527 | eslint "^5.6.1" |
1428 | 1528 | |
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 | + | |
1429 | 1540 | bytomjs-lib@0.0.2: |
1430 | 1541 | version "0.0.2" |
1431 | 1542 | 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: | ||
2128 | 2239 | randombytes "^2.0.0" |
2129 | 2240 | randomfill "^1.0.3" |
2130 | 2241 | |
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 | + | |
2131 | 2247 | css-color-names@0.0.4: |
2132 | 2248 | version "0.0.4" |
2133 | 2249 | 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: | ||
2980 | 3096 | assign-symbols "^1.0.0" |
2981 | 3097 | is-extendable "^1.0.1" |
2982 | 3098 | |
2983 | -extend@~3.0.2: | |
3099 | +extend@^3.0.2, extend@~3.0.2: | |
2984 | 3100 | version "3.0.2" |
2985 | 3101 | resolved "https://registry.npm.taobao.org/extend/download/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" |
2986 | 3102 | integrity sha1-+LETa0Bx+9jrFAr/hYsQGewpFfo= |
@@ -3206,6 +3322,11 @@ follow-redirects@^1.0.0: | ||
3206 | 3322 | resolved "https://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.13.2.tgz#dd73c8effc12728ba5cf4259d760ea5fb83e3147" |
3207 | 3323 | integrity sha1-3XPI7/wScoulz0JZ12DqX7g+MUc= |
3208 | 3324 | |
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 | + | |
3209 | 3330 | for-in@^0.1.3: |
3210 | 3331 | version "0.1.8" |
3211 | 3332 | resolved "https://registry.npm.taobao.org/for-in/download/for-in-0.1.8.tgz#d8773908e31256109952b1fdb9b3fa867d2775e1" |
@@ -5387,6 +5508,17 @@ pbkdf2@^3.0.3: | ||
5387 | 5508 | safe-buffer "^5.0.1" |
5388 | 5509 | sha.js "^2.4.8" |
5389 | 5510 | |
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 | + | |
5390 | 5522 | performance-now@^2.1.0: |
5391 | 5523 | version "2.1.0" |
5392 | 5524 | 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: | ||
6358 | 6490 | ajv "^6.1.0" |
6359 | 6491 | ajv-keywords "^3.1.0" |
6360 | 6492 | |
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 | + | |
6361 | 6498 | scss-tokenizer@^0.2.3: |
6362 | 6499 | version "0.2.3" |
6363 | 6500 | resolved "https://registry.npm.taobao.org/scss-tokenizer/download/scss-tokenizer-0.2.3.tgz#8eb06db9a9723333824d3f5530641149847ce5d1" |