Skip to content
This repository has been archived by the owner on Feb 25, 2019. It is now read-only.

Commit

Permalink
Merge pull request #43 from StellarCN/v1.2.5
Browse files Browse the repository at this point in the history
V1.2.5
  • Loading branch information
imloama authored Feb 23, 2018
2 parents 7226e1d + 0d1ca87 commit 6b18f57
Show file tree
Hide file tree
Showing 15 changed files with 8,090 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ platforms/
plugins/
hooks/
!src/libs/vue-cordova/plugins
!src/store/plugins

npm-debug.log*
yarn-debug.log*
Expand Down
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.github.stellarcn.firefly" version="1.2.3" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget id="com.github.stellarcn.firefly" version="1.2.5" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>firefly</name>
<description>
stellar wallet
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "firefly",
"version": "1.2.3",
"version": "1.2.5",
"description": "stellar mobile wallet",
"author": "",
"private": true,
Expand Down Expand Up @@ -30,20 +30,22 @@
"cordova-plugin-add-swift-support": "^1.7.0",
"cordova-plugin-camera": "^2.4.1",
"cordova-plugin-device": "^1.1.7",
"cordova-plugin-globalization": "^1.0.9",
"cordova-plugin-inappbrowser": "^1.7.2",
"cordova-plugin-qrscanner": "^2.5.0",
"cordova-plugin-splashscreen": "^4.1.0",
"cordova-plugin-statusbar": "^2.3.0",
"cordova-plugin-swift-support": "^3.1.1",
"cordova-plugin-whitelist": "1",
"cordova-sqlite-storage": "^2.1.2",
"cordova-plugin-globalization": "^1.0.9",
"echarts": "^3.8.5",
"ed25519": "0.0.4",
"hammerjs": "^2.0.8",
"lodash": "^4.17.4",
"npm": "^5.5.1",
"nprogress": "^0.2.0",
"raf.js": "^0.0.4",
"shvl": "^1.2.0",
"swiper": "^4.0.7",
"uuid": "^3.1.0",
"vue": "^2.5.4",
Expand Down Expand Up @@ -138,4 +140,4 @@
"ios"
]
}
}
}
6 changes: 4 additions & 2 deletions src/api/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { readAccountData } from './storage'
import { encrypt, decrypt } from './crypt'
import { importAccountFromData } from './qr'
import { getAsset } from './assets'
import { BASE_RESERVE } from './gateways'
var Promise = require('es6-promise').Promise

// create random account
Expand Down Expand Up @@ -95,7 +96,7 @@ function checkAssetAvailable(assetdata,balances){

// send asset
// return Promise
export function send(seed,address,target,assetdata,amount,memo_type,memo_value){
export function send(seed,address,target,assetdata,amount,memo_type,memo_value,base_reserve){
let amountstr = Number(amount).toFixed(7);//Math.round(amount, 7)
address = address ? address : address(address)
let asset = getAsset(assetdata.code , assetdata.issuer)
Expand All @@ -122,7 +123,8 @@ export function send(seed,address,target,assetdata,amount,memo_type,memo_value){
//新建用户只能发XLM
if(assetdata.code!='XLM')throw new Error('Error.AccountNotFund')
//是否资产不足
if(Number(amount)<20)throw new Error('Error.NotEnoughAssetToFundAccount')
var reserve = 2 * ( base_reserve || BASE_RESERVE )
if(Number(amount)< reserve)throw new Error('Error.NotEnoughAssetToFundAccount')
console.log('创建账户')
//创建账户
var createaccount = StellarSdk.Operation.createAccount({destination: target,startingBalance: amount})
Expand Down
6 changes: 4 additions & 2 deletions src/api/gateways.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import axios from 'axios'

export const APP_NAME = 'firefly'

//app版本号
export const APP_VERSION = '1.2.3'
export const APP_VERSION = '1.2.5'

export const APP_GITHUB = 'https://github.com/stellarcn/firefly'

Expand Down Expand Up @@ -84,7 +86,7 @@ export const ASSETS_ISSUER_HOST = {
}


export const BASE_RESERVE = 10
export const BASE_RESERVE = 0.5

// 默认axios超时时间
export const AXIOS_DEFAULT_TIMEOUT = 5000
Expand Down
30 changes: 30 additions & 0 deletions src/api/trade.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,34 @@ export function getTrades( buyAsset,sellAsset,order="desc", limit = 200){
builder.url.addQuery("limit", limit+'');
builder.url.addQuery("order", order);
return builder.call()
}




// == stream ==
// trade stream instance
var _stream = undefined;

// listen on trade stream
export function listenTradeStream(buyAsset,sellAsset,order="desc", limit = 200){
closeTradeStream();
let builder = getServer().trades().forAssetPair(sellAsset, buyAsset)
builder.url.addQuery("limit", limit+'');
builder.url.addQuery("order", order);

_stream = builder.stream({
onmessage:res=>{
handler(res)
}
});
}

// close orderbook stream
export function closeTradeStream(){
if(_stream){
_stream();
_stream = undefined;
}

}
66 changes: 66 additions & 0 deletions src/api/tradeAggregation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import StellarSdk from 'stellar-sdk'
import {getServer} from './server'

export function getTradeAggregation(base,counter,start_time,end_time,resolution){
return getServer().tradeAggregation(base,counter,start_time,end_time,resolution).call();
}

export function getTradeAggregation5min(base,counter,start_time,end_time){
return getServer().tradeAggregation(base,counter,start_time,end_time,RESOLUTION_5MIN).call();
}

export function getTradeAggregation15min(base,counter,start_time,end_time){
return getServer().tradeAggregation(base,counter,start_time,end_time,RESOLUTION_5MIN).call();
}

export function getTradeAggregation1hour(base,counter,start_time,end_time){
return getServer().tradeAggregation(base,counter,start_time,end_time,RESOLUTION_1HOUR).call();
}

export function getTradeAggregation1day(base,counter,start_time,end_time){
return getServer().tradeAggregation(base,counter,start_time,end_time,RESOLUTION_1DAY).call();
}

export function getTradeAggregation1week(base,counter,start_time,end_time){
return getServer().tradeAggregation(base,counter,start_time,end_time,RESOLUTION_1WEEK).call();
}



//5 minutes (300000), 15 minutes (900000), 1 hour (3600000), 1 day (86400000) and 1 week (604800000)
export const RESOLUTION_5MIN = 300000
export const RESOLUTION_15MIN = 900000
export const RESOLUTION_1HOUR = 3600000
export const RESOLUTION_1DAY = 86400000
export const RESOLUTION_1WEEK = 604800000

// == stream ==
// tradeaggregation stream instance
var _stream = undefined;

// listen on orderbook stream
// @param buyAsset: buying asset
export function listenTradeAggregationStream(options,handler){
closeTradeAggregationStream();
_stream = getServer().tradeAggregation(
options.base,
options.counter,
options.start_time,
options.end_time,
options.resolution || RESOLUTION_5MIN
).stream({
onmessage:res=>{
handler(res)
}
});
}

// close orderbook stream
export function closeTradeAggregationStream(){
if(_stream){
_stream();
_stream = undefined;
}

}

3 changes: 1 addition & 2 deletions src/components/OrderBook.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ export default {
let obj = Object.assign({}, this.bids[i])
obj.num = Number(obj.amount).toFixed(4)
obj.price = Number(obj.price).toFixed(this.decimal)
// obj.amount = (obj.num / obj.price).toFixed(2)
obj.amount = (obj.num * obj.price_r.n / obj.price_r.d).toFixed(2)
obj.amount = (obj.num * obj.price_r.d / obj.price_r.n).toFixed(2)
dep += Number(obj.num)
obj.depth = dep.toFixed(2)
obj.origin = this.bids[i]
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</v-flex>
<v-flex xs6 class="myassets-wrapper">
<div class="myassets-balance">
{{item.balance}}
{{Number(item.balance.toFixed(7))}}
</div>
</v-flex>
<v-flex xs2 class="myassets-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion src/pages/MyAssets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</v-flex>
<v-flex xs8 class="myassets-wrapper">
<div class="myassets-balance third">
<span class="balance">{{item.balance}}</span>
<span class="balance">{{Number(item.balance.toFixed(7))}}</span>
<span class="label">{{$t('Total')}}</span>
</div>
</v-flex>
Expand Down
17 changes: 14 additions & 3 deletions src/pages/Transaction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@
<span class="amount">{{selected.amount}}</span>
<span class="code">{{selected.asset.code}}</span>
</div>
<div class="address">{{account.address | shortaddress}}</div>
<div class="address" @click="copy(account.address)">{{account.address | shortaddress}}</div>
</div>
</card>
<h2 class="details-title">{{$t('Detail')}}</h2>
<card class="details">
<div class="card-content" slot="card-content">
<div class="label">TX</div>
<div class="value" @click="copy(transaction.id)">{{transaction.id | shortaddress}}</div>
<div class="label" v-if="!selected.isInbound">{{$t('To')}}</div>
<div class="label" v-else>{{$t('From')}}</div>
<div class="value">{{selected.counterparty | shortaddress}}</div>
<div class="value" @click="copy(selected.counterparty)">{{selected.counterparty | shortaddress}}</div>
<div class="label">{{$t('DateTime')}}</div>
<div class="value">{{date}}</div>
<div class="label">{{$t('Memo')}}</div>
<div class="value">{{transaction.memo}}</div>
<div class="value" @click="copy(transaction.memo)">{{transaction.memo}}</div>
</div>
</card>
<div style="flex: 1;"></div>
Expand Down Expand Up @@ -104,7 +106,14 @@ export default {
},
addContact(){
this.$router.push({name:'AddContact', params: {address: this.selected.counterparty}});
},
copy(value){
if(cordova.plugins.clipboard){
cordova.plugins.clipboard.copy(value)
this.$toasted.show(this.$t('CopySuccess'))
}
}
},
components: {
Expand Down Expand Up @@ -158,6 +167,8 @@ export default {
color: $secondarycolor.font
padding-top: 8px
padding-bottom: 2px
.value
word-break: break-all
.btn-group
width: 100%
Expand Down
22 changes: 21 additions & 1 deletion src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import AccountsStore from './modules/AccountsStore'
import AppSettingStore from './modules/AppSettingStore'
import AccountStore from './modules/AccountStore'
import AssetStore from './modules/AssetStore'
import createPersist from './plugins/persistence'
import { APP_NAME, APP_VERSION } from '@/api/gateways'
var Base64 = require('js-base64').Base64

Vue.use(Vuex)

Expand Down Expand Up @@ -120,9 +123,26 @@ export default new Vuex.Store({
app: AppSettingStore,
account: AccountStore,
asset: AssetStore
}
},
plugins: [createPersist({
namespace: APP_NAME + '-vuex-',
initialState: {},
serialize,
deserialize,
// never expire
expires: 0
})]

})

function serialize(value){
return Base64.encode(JSON.stringify(value))
}

function deserialize(value){
return JSON.parse(Base64.decode(value))
}

export const IMPORT_ACCOUNT_CHANGE = 'IMPORT_ACCOUNT_CHANGE'
export const CREATE_ACCOUNT_CHANGE = 'CREATE_ACCOUNT_CHANGE'
export const BACK_TO_ACCOUNT = 'BACK_TO_ACCOUNT'
Expand Down
6 changes: 2 additions & 4 deletions src/store/modules/AssetStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ const actions = {
selectAsset({commit}, asset){
commit(SELECT_ASSET,asset)
},
async sendAsset({dispatch,commit}, {seed,address,target,asset,amount,memo_type,memo_value}){
async sendAsset({dispatch,commit, rootState, rootGetters}, {seed,address,target,asset,amount,memo_type,memo_value}){
//seed,address,target,asset,amount,memo_type,memo_value
let data = await send(seed,address,target,asset,amount,memo_type,memo_value)
console.log(`-----send--------`)
console.log(data)
let data = await send(seed,address,target,asset,amount,memo_type,memo_value,rootGetters.base_reserve)
//刷新accountinfo
await dispatch('getAccountInfo',address)
await dispatch('getPayments', address)
Expand Down
Loading

0 comments on commit 6b18f57

Please sign in to comment.