hyperweb-io / hyperweb-io/telescope
recoil integration
- Dominant language
- TypeScript
- Stars
- 154
- Forks
- 53
- PR merge metrics
- No merged PRs in 30d
Description
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
```js
// 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
},
})
```
```js
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
)
},
})
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.