case MsgTypes.REQUEST_CURRENT_NETWORK:
this.requestCurrentNetwork(sendResponse)
break
+ case MsgTypes.REQUEST_CURRENT_CHAIN_TYPE:
+ this.requestCurrentChain(sendResponse)
+ break
case MsgTypes.ENABLE:
Background.authenticate(sendResponse, message.payload)
break
return false;
}
+ // NotificationService.open(new Prompt(PromptTypes.REQUEST_TRANSFER, '', payload ,approved => {
+ // sendResponse(approved);
+ // }));
chrome.windows.create(
{
Background.load(bytom => {
const domain = payload.domain;
if(bytom.settings.domains.find(_domain => _domain === domain)) {
- const currentAccount = Object.assign({}, bytom.currentAccount)
- delete(currentAccount['label'])
- delete(currentAccount['net'])
- currentAccount['accountId'] = currentAccount['guid']
- delete(currentAccount['guid'])
- delete(currentAccount['balance'])
-
- sendResponse(currentAccount);
+ const currentAccount = bytom.currentAccount
+ let account
+ if(bytom.settings.netType === 'vapor'){
+ account = {
+ address: currentAccount.vpAddress,
+ alias:currentAccount.alias,
+ balances: currentAccount.vpBalances|| [],
+ accountId: currentAccount.guid,
+ rootXPub: currentAccount.rootXPub
+ };
+ }else{
+ let balances = currentAccount.balances ||[]
+
+ account ={
+ address: currentAccount.address,
+ alias:currentAccount.alias,
+ balances: currentAccount.balances|| [],
+ accountId: currentAccount.guid,
+ rootXPub: currentAccount.rootXPub
+ };
+ }
+
+ sendResponse(account)
} else{
sendResponse(null);
return false;
})
}
+ requestCurrentChain(sendResponse){
+ Background.load(bytom => {
+ const chain = bytom.settings.netType ==='vapor'?'vapor':'bytom'
+ sendResponse(chain);
+ })
+ }
+
+
send(sendResponse, payload) {
const action = payload.action
if(action){
static authenticate(sendResponse, payload){
Background.load(bytom => {
const domain = payload.domain;
- const currentAccount = Object.assign({}, bytom.currentAccount)
- delete(currentAccount['label'])
- delete(currentAccount['net'])
- currentAccount['accountId'] = currentAccount['guid']
- delete(currentAccount['guid'])
- delete(currentAccount['balance'])
+ const currentAccount = bytom.currentAccount
+
+ let account
+ if(bytom.settings.netType === 'vapor'){
+ let balances = currentAccount.vpBalances ||[]
+
+
+ account ={
+ address: currentAccount.vpAddress,
+ alias:currentAccount.alias,
+ balances: currentAccount.vpBalances || [],
+ accountId: currentAccount.guid,
+ rootXPub: currentAccount.rootXPub
+ };
+
+ }else{
+ account ={
+ address: currentAccount.address,
+ alias:currentAccount.alias,
+ balances: currentAccount.balances|| [],
+ accountId: currentAccount.guid,
+ rootXPub: currentAccount.rootXPub
+ };
+ }
if(bytom.settings.domains.find(_domain => _domain === domain)) {
- sendResponse(currentAccount);
+ sendResponse(account);
} else{
NotificationService.open(new Prompt(PromptTypes.REQUEST_AUTH, payload.domain, {}, approved => {
if(approved === false || approved.hasOwnProperty('isError')) sendResponse(approved);
else {
bytom.settings.domains.unshift(domain);
if(approved === true){
- this.update(() => sendResponse(currentAccount), bytom);
+ this.update(() => sendResponse(account), bytom);
}else{
this.update(() => sendResponse(approved), bytom);
}
stream.onSync(async () => {
const defaultAccount = await this.getDefaultAccount();
const net = await this.getDefaultNetwork();
+ const chain = await this.getDefaultChain()
// Pushing an instance of Bytomdapp to the web application
stream.send(
- NetworkMessage.payload(MsgTypes.PUSH_BYTOM, {defaultAccount, net}),
+ NetworkMessage.payload(MsgTypes.PUSH_BYTOM, {defaultAccount, net, chain}),
EventNames.INJECT
)
EventNames.INJECT
)
}
+ }else if(evt.bytom.newValue.settings.netType!== evt.bytom.oldValue.settings.netType){
+ const chain = await this.getDefaultChain();
+ const defaultAccount = await this.getDefaultAccount();
+ stream.send(
+ NetworkMessage.payload(MsgTypes.UPDATE_BYTOM, {type:'chain', value: chain}),
+ EventNames.INJECT
+ )
+ stream.send(
+ NetworkMessage.payload(MsgTypes.UPDATE_BYTOM, {type:'default_account', value: defaultAccount}),
+ EventNames.INJECT
+ )
}
});
}
.send()
}
+ getDefaultChain(){
+ return InternalMessage.signal(MsgTypes.REQUEST_CURRENT_CHAIN_TYPE)
+ .send()
+ }
+
respond(message, payload) {
if (!isReady) return
resolvers = []
this.default_account = _options.defaultAccount
this.net = _options.net
+ this.chain = _options.chain
_subscribe()
}
export const REQUEST_CURRENT_ACCOUNT = 'defaultAccount';
export const REQUEST_CURRENT_NETWORK = 'currentNetwork';
+export const REQUEST_CURRENT_CHAIN_TYPE = 'currentChain';
export const REQUEST_ACCOUNT_LIST = 'accountList';
export const REQUEST_AUTH = 'enable';
export const REQUEST_SIGN = 'signMessage';
export const REQUEST_ADVANCED_TRANSFER = 'advancedTransfer';
+export const REQUEST_TRANSFER = 'transfer';
export const REQUEST_ADD_NETWORK = 'requestAddNetwork';
export const REQUEST_UNLOCK = 'requestUnlock';
export const UPDATE_VERSION = 'updateVersion';
display:flex;
}
.topbar .topbar-left {
- width:140px;
overflow:hidden;
white-space:nowrap;
}
margin-top: 10px;
padding: 0 20px;
text-align: center;
+ width: 245px;
}
.topbar-left .btn-menu i {
const objectIndex = bytom.accountList.findIndex(a => a.guid == this.currentAccount.guid)
bytom.accountList[objectIndex].vpAddress = accounts.vpAddress
- this[Actions.UPDATE_STORED_BYTOM](bytom)
+ this[Actions.UPDATE_STORED_BYTOM](bytom).then(()=>{
+ this.refreshBalance(this.currentAccount.guid)
+ })
}).catch(e =>{
if(e.message == 'Error: wallet has exist'){
account.listVapor(this.currentAccount.guid).then(accounts => {
const objectIndex = bytom.accountList.findIndex(a => a.guid == this.currentAccount.guid)
bytom.accountList[objectIndex].vpAddress = accounts.vpAddress
- this[Actions.UPDATE_STORED_BYTOM](bytom)
+ this[Actions.UPDATE_STORED_BYTOM](bytom).then(()=>{
+ this.refreshBalance(this.currentAccount.guid)
+ })
})
}
})
}else{
- this[Actions.UPDATE_STORED_BYTOM](bytom)
+ this[Actions.UPDATE_STORED_BYTOM](bytom).then(()=>{
+ this.refreshBalance(this.currentAccount.guid)
+ })
}
- this.refreshBalance(this.currentAccount.guid)
}
},
showQrcode: function () {
</label>
<div class="form-item-content" style=" display: flex;">
<input type="number" v-model="transaction.amount" placeholder="0" @keypress="limitAmount">
- <span class="color-grey" style="width: 40px; font-size: 15px;position: absolute;right: 0;text-transform: uppercase;">{{unit}}</span>
+ <span class="color-grey" style="font-size: 15px;position: absolute;right: 0;text-transform: uppercase;">{{unit}}</span>
</div>
</div>
<div class="form-item">
computed: {
assets(){
if(this.netType === 'vapor'){
- return this.currentAccount.vpBalances
+ if(!this.currentAccount.vpBalances ||this.currentAccount.vpBalances.length == 0){
+ return [this.selectAsset]
+ }else{
+ return this.currentAccount.vpBalances
+ }
}else{
- return this.currentAccount.balances
+ if(!this.currentAccount.balances ||this.currentAccount.balances.length == 0){
+ return [this.selectAsset]
+ }else{
+ return this.currentAccount.balances
+ }
}
},
unit() {
},
watch: {
"transaction.amount": function (newAmount) {
- this.transaction.cost = Number(this.selectAsset[currencyInPrice[this.currency]] * newAmount).toFixed(2);
+ const singlePrice = this.selectAsset[currencyInPrice[this.currency]]||this.selectAsset[this.currency]||0
+ this.transaction.cost = Number( singlePrice * newAmount).toFixed(2);
},
account: function (newAccount) {
this.guid = newAccount.guid;
assetChange: function (val) {
if(val.asset !== this.selectAsset.asset){
this.transaction.asset = val.asset;
- const balances = this.currentAccount.balances
+ const balances = this.netType === 'vapor'?this.currentAccount.vpBalances:this.currentAccount.balances
let balance = 0.00
if(balances.length >0 ) {
const balanceObject = balances.filter(b => b.asset === val.asset)[0]
}
if (this.$route.query.asset != undefined) {
- this.transaction.asset= this.$route.query.asset
+ const currentAssetId = this.$route.query.asset
+
+ this.transaction.asset= currentAssetId
+
+ const assets = this.assets
+ this.selectAsset = assets.filter(b => b.asset === currentAssetId.toLowerCase())[0]
+
+
}
if (this.$route.query.to != undefined) {
this.transaction.to = this.$route.query.to
}
}else{
this.account = this.currentAccount
- }
- const currentAsset = this.currentAccount.balances[0]
+ const currentAsset = this.currentAccount.balances[0]
- if(currentAsset){
- transaction.asset(currentAsset.asset).then(ret => {
- this.selectAsset = Object.assign(ret,currentAsset)
- });
+ if(currentAsset){
+ transaction.asset(currentAsset.asset).then(ret => {
+ this.selectAsset = Object.assign(ret,currentAsset)
+ });
+ }
}
+
}
};
</script>