telescope
telescope copied to clipboard
recoil integration
Teams are using recoil — we can look to DaoDao for inspiration
https://github.com/DA0-DA0/dao-dao-ui/blob/03a0c9f7490a0bace1eba5347b269a4db30049fe/packages/state/recoil/selectors/chain.ts
// Get the SUM of native tokens delegated across all validators
export const nativeDelegatedBalanceSelector = selectorFamily<
Coin,
WithChainId<{ address: string }>
>({
key: 'nativeDelegatedBalance',
get:
({ address, chainId }) =>
async ({ get }) => {
const client = get(stargateClientForChainSelector(chainId))
get(refreshWalletBalancesIdAtom(address))
const balance = await client.getBalanceStaked(address)
// Only allow native denom
if (!balance || balance.denom !== NATIVE_DENOM) {
return {
amount: '0',
denom: NATIVE_DENOM,
}
}
return balance
},
})
export const nativeSupplySelector = selectorFamily<
number,
WithChainId<{ denom: string }>
>({
key: 'nativeSupply',
get:
({ denom, chainId }) =>
async ({ get }) => {
const client = get(cosmosRpcClientForChainSelector(chainId))
return Number(
(
await client.bank.v1beta1.supplyOf({
denom,
})
).amount.amount
)
},
})