Last active
February 4, 2020 13:05
-
-
Save LefterisJP/c3123ba1266ff5ed015683b4ca8db70f to your computer and use it in GitHub Desktop.
Diff_so_far.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/electron-app/src/components/settings/AccountAssetBalances.vue b/electron-app/src/components/settings/AccountAssetBalances.vue | |
index 2f02196..ef64a33 100644 | |
--- a/electron-app/src/components/settings/AccountAssetBalances.vue | |
+++ b/electron-app/src/components/settings/AccountAssetBalances.vue | |
@@ -21,6 +21,13 @@ | |
<template #item.amount="{ item }"> | |
{{ item.amount | formatPrice(floatingPrecision) }} | |
</template> | |
+ <template #item.usdValue="{ item }"> | |
+ {{ | |
+ item.usdValue | |
+ | calculatePrice(exchangeRate(currency.ticker_symbol)) | |
+ | formatPrice(floatingPrecision) | |
+ }} | |
+ </template> | |
</v-data-table> | |
</v-col> | |
</v-row> | |
@@ -31,26 +38,32 @@ import { Component, Prop, Vue } from 'vue-property-decorator'; | |
import CryptoIcon from '@/components/CryptoIcon.vue'; | |
import { AssetBalances } from '@/model/blockchain-balances'; | |
import { createNamespacedHelpers } from 'vuex'; | |
+import { Currency } from '@/model/currency'; | |
const { mapGetters } = createNamespacedHelpers('balances'); | |
const { mapGetters: mapSessionGetters } = createNamespacedHelpers('session'); | |
+const { mapGetters: mapBalancesGetters } = createNamespacedHelpers('tokens'); | |
@Component({ | |
components: { CryptoIcon }, | |
computed: { | |
...mapGetters(['accountTokens']), | |
- ...mapSessionGetters(['floatingPrecision']) | |
+ ...mapSessionGetters(['floatingPrecision', 'currency']), | |
+ ...mapBalancesGetters(['exchangeRate', 'hasTokens']) | |
} | |
}) | |
export default class AccountAssetBalances extends Vue { | |
@Prop({ required: true }) | |
account!: string; | |
+ currency!: Currency; | |
accountTokens!: (account: string) => AssetBalances[]; | |
floatingPrecision!: number; | |
+ exchangeRate!: (currency: string) => number; | |
headers = [ | |
{ text: 'Asset', value: 'asset' }, | |
- { text: 'Amount', value: 'amount' } | |
+ { text: 'Amount', value: 'amount' }, | |
+ { text: 'USD Value', value: 'usdValue' } | |
]; | |
get tokens(): AssetBalances[] { | |
diff --git a/electron-app/src/model/blockchain-balances.ts b/electron-app/src/model/blockchain-balances.ts | |
index 5ab227a..768e19f 100644 | |
--- a/electron-app/src/model/blockchain-balances.ts | |
+++ b/electron-app/src/model/blockchain-balances.ts | |
@@ -18,9 +18,8 @@ export interface ApiBalances { | |
} | |
export interface ApiEthBalance { | |
- [asset: string]: string; | |
- readonly ETH: string; | |
- readonly usd_value: string; | |
+ readonly assets: ApiBalances; | |
+ readonly total_usd_value: string; | |
} | |
export interface ApiEthBalances { | |
@@ -28,9 +27,8 @@ export interface ApiEthBalances { | |
} | |
export interface EthBalance { | |
- readonly eth: BigNumber; | |
- readonly usdValue: BigNumber; | |
- readonly tokens: AccountTokens; | |
+ readonly totalUsdValue: BigNumber; | |
+ readonly assets: Balances; | |
} | |
export interface EthBalances { | |
@@ -52,10 +50,6 @@ export interface AccountBalance { | |
readonly usdValue: BigNumber; | |
} | |
-export interface AccountTokens { | |
- [token: string]: BigNumber; | |
-} | |
- | |
export interface AssetBalance { | |
readonly asset: string; | |
readonly amount: BigNumber; | |
diff --git a/electron-app/src/utils/conversion.ts b/electron-app/src/utils/conversion.ts | |
index 80d6184..dfad629 100644 | |
--- a/electron-app/src/utils/conversion.ts | |
+++ b/electron-app/src/utils/conversion.ts | |
@@ -1,5 +1,5 @@ | |
import { | |
- AccountTokens, | |
+ ApiBalance, | |
ApiBalances, | |
ApiEthBalances, | |
AssetBalances, | |
@@ -8,7 +8,6 @@ import { | |
} from '@/model/blockchain-balances'; | |
import { bigNumberify } from '@/utils/bignumbers'; | |
-import omit from 'lodash/omit'; | |
import transform from 'lodash/transform'; | |
import { ApiAssetBalances } from '@/typing/types'; | |
@@ -19,20 +18,21 @@ export function convertEthBalances(apiBalances: ApiEthBalances): EthBalances { | |
continue; | |
} | |
- const balance = apiBalances[account]; | |
- const tokens = omit(balance, ['ETH', 'usd_value']); | |
- const accountTokens = transform( | |
- tokens, | |
- (result: AccountTokens, value: string, key: string) => { | |
- result[key] = bigNumberify(value); | |
+ const api_balance = apiBalances[account]; | |
+ const accountAssets = transform( | |
+ api_balance.assets, | |
+ (result: Balances, value: ApiBalance, key: string) => { | |
+ result[key] = { | |
+ amount: bigNumberify(value.amount as string), | |
+ usdValue: bigNumberify(value.usd_value as string) | |
+ }; | |
}, | |
{} | |
); | |
balances[account] = { | |
- eth: bigNumberify(balance.ETH as string), | |
- usdValue: bigNumberify(balance.usd_value as string), | |
- tokens: accountTokens | |
+ assets: accountAssets, | |
+ totalUsdValue: bigNumberify(api_balance.total_usd_value as string) | |
}; | |
} | |
return balances; | |
@@ -63,7 +63,6 @@ export function convertAssetBalances( | |
} | |
const data = assetBalances[asset]; | |
- | |
assets[asset] = { | |
amount: bigNumberify(data.amount), | |
usdValue: bigNumberify(data.usd_value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment