1 import bytom from './bytom'
2 import uuid from 'uuid'
3 import * as Actions from '../store/constants';
7 setupNet: bytom.setupNet
10 account.create = function(accountAlias, keyAlias, passwd, context) {
11 let retPromise = new Promise((resolve, reject) => {
13 keyAlias = `${accountAlias}-key-${uuid.v4()}`
16 const _bytom = context.bytom.clone();
18 .createKey(keyAlias, passwd)
20 _bytom.keychain.keys[keyAlias] = res
21 context[Actions.UPDATE_STORED_BYTOM](_bytom).then(() => {
23 .createAccountUseServer(res.xpub, accountAlias)
41 account.copy = function(guid) {
42 let retPromise = new Promise((resolve, reject) => {
44 .copyAccountUseServer(guid, 'btm')
55 account.listVapor = function(guid) {
56 let retPromise = new Promise((resolve, reject) => {
58 .listVaporAccountUseServer(guid)
69 account.balance = function(address) {
70 let retPromise = new Promise((resolve, reject) => {
72 .listAddressUseServer(address)
74 let balances = address.balances || []
75 let votes = address.votes || []
89 account.list = function() {
90 let retPromise = new Promise((resolve, reject) => {
92 .listAccountUseServer()
94 Promise.all(accounts.map(async (account) => {
96 const obj = await this.balance(account.guid)
97 account.balances = obj.balances
98 account.votes = obj.votes
116 account.backup = function() {
117 return bytom.wallet.backup()
120 account.restore = function(walletImage, password) {
121 return bytom.wallet.restore(walletImage, password)
124 export default account