Skip to content

Commit

Permalink
feat: add subtensor delegated staking to balances lib (#1624)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecdwm authored Oct 1, 2024
1 parent 2c865c4 commit 6021b64
Show file tree
Hide file tree
Showing 20 changed files with 1,444 additions and 1,157 deletions.
5 changes: 5 additions & 0 deletions .changeset/dry-emus-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@talismn/balances": patch
---

feat: add subtensor delegated staking
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,23 @@ export const useChainTokenBalances = ({ chainId, balances }: ChainTokenBalancesP
}))
)

return [...available, ...locked, ...reserved, ...staked, ...crowdloans]
// STAKED (SUBTENSOR)
const subtensor = tokenBalances.each.flatMap((b) =>
b.subtensor.map((subtensor, index) => ({
key: `${b.id}-subtensor-${index}`,
title: getLockTitle(subtensor, { balance: b }),

description: undefined,
tokens: BigNumber(subtensor.amount.tokens),
fiat: subtensor.amount.fiat(currency),
locked: true,
// only show address when we're viewing balances for all accounts
address: account ? undefined : b.address,
meta: subtensor.meta,
}))
)

return [...available, ...locked, ...reserved, ...staked, ...crowdloans, ...subtensor]
.filter((row) => row && row.tokens.gt(0))
.sort(sortBigBy("tokens", true))
}, [summary, account, t, tokenBalances, currency])
Expand Down
Loading

0 comments on commit 6021b64

Please sign in to comment.