Skip to content

Commit 528ce3a

Browse files
authored
Currency support (#132)
* Add balance chart * beautified balance chart * WIP Icon * WIP portfolio * beautified portfolio * added settings panel * added settings panel * added settings panel * added settings panel * updated * implemented preferences with store * removed 'new' tag for power tools * added currency support * finalized currency support * added currency support for llama urls, and more * added currency support for dashboard * added currency support for dashboard * added currency support for dashboard * added currency support for dashboard * fixed bug with wallet ui / settings * Fixes * Update APIContext.tsx * Fix build & start fixing balance chart * included debug logs in configurable user settings; added .env override for debug mode * changed title of debug info * renamed variable * fixed a bug * small ui enhancements * added some ui goodies * fixed z-index for wallet menu * added glass effect to wallet menu --------- Authored-by: Secret Jupiter
1 parent 4177e5d commit 528ce3a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1093
-545
lines changed

example.env

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
# Local Development helper
2-
VITE_DEBUG_MODE=false
3-
41
# Mixpanel
52
VITE_MIXPANEL_ENABLED=false
63
VITE_MIXPANEL_PROJECT_TOKEN=
74

5+
# Overrides debug mode in user settings
6+
VITE_DEBUG_MODE=false
7+
8+
89
# Transak
910
TRANSAK_API_KEY=

package-lock.json

+48-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"@evmos/eip712": "^0.3.2",
1919
"@evmos/proto": "^0.2.1",
2020
"@evmos/transactions": "^0.3.2",
21+
"@floating-ui/react": "^0.26.9",
2122
"@fortawesome/fontawesome-free": "^6.2.1",
2223
"@fortawesome/fontawesome-svg-core": "^6.2.1",
2324
"@fortawesome/free-brands-svg-icons": "^6.2.1",
@@ -57,7 +58,7 @@
5758
"react-socks": "^2.2.0",
5859
"sass": "^1.69.5",
5960
"secretjs": "^1.12.4",
60-
"tailwindcss": "^3.3.5",
61+
"tailwindcss": "^3.4.1",
6162
"vite": "^5.0.12",
6263
"vite-tsconfig-paths": "^4.2.1",
6364
"yup": "^1.3.2",

src/App.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,24 @@ import Dashboard from 'pages/dashboard/Dashboard'
2626
import DefaultLayout from 'layouts/DefaultLayout'
2727
import Powertools from 'pages/powertools/Powertools'
2828
import { useSecretNetworkClientStore } from 'store/secretNetworkClient'
29+
import { useUserPreferencesStore } from 'store/UserPreferences'
30+
import { debugModeOverride } from 'utils/commons'
31+
32+
const { debugMode } = useUserPreferencesStore.getState()
2933

3034
if (import.meta.env.VITE_MIXPANEL_ENABLED === 'true') {
3135
mixpanel.init(import.meta.env.VITE_MIXPANEL_PROJECT_TOKEN, { debug: true })
3236
mixpanel.identify('Dashboard-App')
3337

3438
mixpanel.track('Dashboard has been opened', {})
35-
console.debug('[Mixpanel] Enabled')
39+
40+
if (debugMode || debugModeOverride) {
41+
console.debug('[Mixpanel] Enabled')
42+
}
3643
} else {
37-
console.debug('[Mixpanel] Disabled')
44+
if (debugMode || debugModeOverride) {
45+
console.debug('[Mixpanel] Disabled')
46+
}
3847
}
3948

4049
export const websiteName = 'Secret Dashboard'

src/components/BalanceUI.tsx

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import BigNumber from 'bignumber.js'
2-
import { useEffect, useState } from 'react'
2+
import { useContext, useEffect, useState } from 'react'
33
import { Chain, Token, chains, tokens } from 'utils/config'
44
import { useTokenPricesStore } from 'store/TokenPrices'
55
import { GetBalanceError, useSecretNetworkClientStore } from 'store/secretNetworkClient'
66
import { faKey } from '@fortawesome/free-solid-svg-icons'
77
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
8+
import { toCurrencyString } from 'utils/commons'
9+
import { APIContext } from 'context/APIContext'
10+
import { useUserPreferencesStore } from 'store/UserPreferences'
811

912
interface IProps {
1013
token: Token
@@ -32,7 +35,7 @@ export default function BalanceUI({
3235
const { getValuePrice, priceMapping } = useTokenPricesStore()
3336

3437
const [balance, setBalance] = useState<number | string>(null)
35-
const [usdPriceString, setUsdPriceString] = useState<string>(null)
38+
const [currencyPriceString, setCurrencyPriceString] = useState<string>(null)
3639
const tokenName = (isSecretToken ? 's' : '') + token.name
3740

3841
useEffect(() => {
@@ -62,9 +65,19 @@ export default function BalanceUI({
6265
}
6366
}, [balanceMapping, ibcBalanceMapping, token, isSecretToken, chain])
6467

68+
const { convertCurrency } = useContext(APIContext)
69+
const { currency } = useUserPreferencesStore()
70+
6571
useEffect(() => {
6672
if (priceMapping !== null && balance !== null) {
67-
setUsdPriceString(getValuePrice(token, BigNumber(balance)))
73+
const valuePrice = getValuePrice(token, BigNumber(balance))
74+
if (valuePrice) {
75+
const priceInCurrency = convertCurrency('USD', valuePrice, currency)
76+
if (priceInCurrency !== null) {
77+
setCurrencyPriceString(toCurrencyString(priceInCurrency, currency))
78+
}
79+
} else {
80+
}
6881
}
6982
}, [priceMapping, token, balance])
7083

@@ -90,7 +103,7 @@ export default function BalanceUI({
90103
).toLocaleString(undefined, {
91104
maximumFractionDigits: token.decimals
92105
})} ${isSecretToken && !token.is_snip20 ? 's' : ''}${token.name} ${
93-
token.coingecko_id && usdPriceString ? ` (${usdPriceString})` : ''
106+
token.coingecko_id && currencyPriceString ? ` (${currencyPriceString})` : ''
94107
}`}</span>
95108
</>
96109
)}

src/components/Navigation.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ export function Navigation({
167167
>
168168
<FontAwesomeIcon icon={faReact} className="mr-2" />
169169
<span>Power Tools</span>
170-
<span className="ml-2 bg-purple-100 text-purple-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-purple-900 dark:text-purple-300">
170+
{/* <span className="ml-2 bg-purple-100 text-purple-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-purple-900 dark:text-purple-300">
171171
New
172-
</span>
172+
</span> */}
173173
</NavLink>
174174
</li>
175175
<li>

0 commit comments

Comments
 (0)