-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mobx store #3
Comments
Here is how I use the pools part to add the missing information!
My code is not perfect but it works great! 👍 import {
assets,
getUserPools,
convertPoolsToDisplayValues,
getPricesFromCoinGecko,
OsmosisApiClient
} from '@cosmology/core';
const api = new OsmosisApiClient();
const lcdPools = await api.getAccountLockedLongerDuration(this.myAddress)
const lcdPoolsLocked = await api.getAccountLockedCoins(this.myAddress)
const allPools = await api.getPools()
const getAllPrices = await getPricesFromCoinGecko()
const convertPools = await convertPoolsToDisplayValues({ prices: getAllPrices, pools: allPools.pools })
const userPools = await getUserPools({ pools: convertPools, lockedPools: lcdPoolsLocked.coins})
const myPools = this.myPools // UI part
myLcdPools.locks.forEach(async function(item){
const poolId = item.coins[0].denom.replace('gamm/pool/', '')
const foundPoolId = userPools.find(element => element.poolId === poolId)
const myPretyDataPool = await api.getPoolPretty(poolId)
const foundPoolImage1 = assets.find(element => element.symbol === myPretyDataPool.poolAssetsPretty[0].symbol);
const foundPoolImage2 = assets.find(element => element.symbol === myPretyDataPool.poolAssetsPretty[1].symbol);
myPretyDataPool.myAmount = item.coins[0].amount
myPretyDataPool.myAmountDollars = Number(foundPoolId.value).toFixed(2)
myPretyDataPool.imgPool1 = foundPoolImage1.logo_URIs.png
myPretyDataPool.imgPool2 = foundPoolImage2.logo_URIs.png
myPretyDataPool.show = false, // UI part
myPools.push(myPretyDataPool);
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue is more for design and listing out queries that are needed.
e.g. currently do get number of tokens in a pool
convertPoolsToDisplayValues
getUserPools({pools, lockedPools})
instead, if we used a mobx store, we could wrap this all into a single call and it gets cached and we get simplicity and speed
The text was updated successfully, but these errors were encountered: