-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update: usages of the composables which now rely on a provider * update: move composable content to a top level global provider pattern * fix: linting errors * update: uptick version * update: shuffle providers to its own folder in src * fix: imports * update: provider structure change * update: provider is kill * update: uptick version * fix: type and lint errors * fix: patch overidden registry change * fix: linting errors
- Loading branch information
Showing
16 changed files
with
570 additions
and
356 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { defineComponent, h } from 'vue'; | ||
import App from './App.vue'; | ||
import * as providerMap from './providers'; | ||
|
||
const providers = Object.values(providerMap); | ||
|
||
export default defineComponent({ | ||
components: { | ||
App, | ||
...providerMap | ||
}, | ||
|
||
render() { | ||
function renderProviders(providers) { | ||
if (!providers.length) return h(App); | ||
|
||
const [provider, ...remainingProviders] = providers; | ||
return h( | ||
provider, | ||
{}, | ||
{ | ||
default() { | ||
return [renderProviders(remainingProviders)]; | ||
} | ||
} | ||
); | ||
} | ||
|
||
return renderProviders(providers); | ||
} | ||
}); |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,22 @@ | ||
import { Token, TokenMap } from '@/types'; | ||
import { getAddress } from '@ethersproject/address'; | ||
import { keyBy, orderBy, uniqBy } from 'lodash'; | ||
import { computed } from 'vue'; | ||
import { useStore } from 'vuex'; | ||
import useAccountBalances from './useAccountBalances'; | ||
import useTokenStore from './useTokensStore'; | ||
|
||
type TokenRequest = { | ||
query?: string; | ||
queryAddress?: string; | ||
}; | ||
import { | ||
TokenRequest, | ||
TokensProviderPayload, | ||
TokensProviderSymbol | ||
} from '@/providers/tokens.provider'; | ||
import { inject, onBeforeMount } from 'vue'; | ||
|
||
export default function useTokens(request?: TokenRequest) { | ||
const store = useStore(); | ||
const prices = computed(() => store.state.market.prices); | ||
const { allTokens: _allTokens } = useTokenStore(); | ||
const { balances } = useAccountBalances(); | ||
|
||
const tokensList = computed(() => { | ||
const _tokens = uniqBy<Token>( | ||
orderBy( | ||
// populate token data into list of tokens | ||
Object.values(_allTokens.value).map(token => { | ||
const balance = | ||
(balances.value || {})[token.address.toLowerCase()]?.balance || '0'; | ||
const price = prices.value[token.address.toLowerCase()]?.price || 0; | ||
const value = balance * price; | ||
const price24HChange = | ||
prices.value[token.address.toLowerCase()]?.price24HChange || 0; | ||
const value24HChange = (value / 100) * price24HChange; | ||
return { | ||
...token, | ||
address: getAddress(token.address), // Enforce that we use checksummed addresses | ||
value, | ||
price, | ||
price24HChange, | ||
balance, | ||
value24HChange | ||
}; | ||
}), | ||
['value', 'balance'], | ||
['desc', 'desc'] | ||
), | ||
'address' | ||
); | ||
|
||
if (request?.queryAddress) { | ||
const queryAddressLC = request?.queryAddress?.toLowerCase(); | ||
|
||
return _tokens.filter( | ||
token => token.address?.toLowerCase() === queryAddressLC | ||
); | ||
} | ||
|
||
// search functionality, this can be better | ||
if (request?.query) { | ||
const queryLC = request?.query?.toLowerCase(); | ||
const { tokens, updateTokenRequest } = inject( | ||
TokensProviderSymbol | ||
) as TokensProviderPayload; | ||
|
||
return _tokens.filter( | ||
token => | ||
token.name.toLowerCase().includes(queryLC) || | ||
token.symbol.toLowerCase().includes(queryLC) | ||
); | ||
onBeforeMount(() => { | ||
if (request) { | ||
updateTokenRequest(request); | ||
} | ||
|
||
return _tokens; | ||
}); | ||
|
||
const tokens = computed(() => keyBy(tokensList.value, 'address') as TokenMap); | ||
|
||
return { tokens }; | ||
return { | ||
tokens | ||
}; | ||
} |
Oops, something went wrong.
5f2ef2f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
staging-kovan-app – ./
staging.kovan.app.balancer.fi
staging-kovan-app-balancer.vercel.app
staging-kovan-app.vercel.app
staging-kovan-app-git-develop-balancer.vercel.app
5f2ef2f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
staging-app – ./
staging-app-balancer.vercel.app
staging.app.balancer.fi
staging-app-tau.vercel.app
staging-app-git-develop-balancer.vercel.app
5f2ef2f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
beta-polygon – ./
beta-polygon.vercel.app
beta-polygon-balancer.vercel.app
beta-polygon-git-develop-balancer.vercel.app
5f2ef2f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
gnosis – ./
gnosis-git-develop-balancer.vercel.app
gnosis.balancer.fi
gnosis-balancer.vercel.app
frontend-v2-gamma.vercel.app