useFetchTransfers QUERY
Fetches the balances of the networks native asset and ERC20 tokens a DAO.
import { useFetchTransfers } from '@daobox/use-aragon'
Usage
import {
useFetchTransfers,
TransferType,
TransferSortBy,
SortDirection,
} from '@daobox/use-aragon'
function App() {
const { data, isLoading, isError } = useFetchTransfers({
// required
daoAddressOrEns: '0x13c6e4f17bbe606fed867a5cd6389a504724e805',
// optional
type: TransferType.DEPOSIT, // default DEPOSIT and WITHDRAW
sortBy: TransferSortBy.LAST_UPDATED, // default LAST_UPDATED
skip: number, // default 0
limit: number, // default 10
direction: SortDirection.ASC, // default ASC
})
if (isLoading) return <div>Loading...</div>
if (isError) return <div>Error!!!</div>
return (
<pre style={{ whiteSpace: 'pre-wrap' }}>
{data.map((asset, index) => (
<div key={index}>
<h2>{asset.type === native ? 'ETH' : asset.symbol}</h2>
<p>{asset.balance.toString()}</p>
</div>
))}
</pre>
)
}
Required Parameters
- Name
daoAddressOrEns
- Type
- string
- Description
The address or ENS name of the DAO.
Optional Parameters
- Name
sortBy
- Type
- AssetBalanceSortBy
- Description
The type of sort function, currently only
LAST_UPDATED
- Name
direction
- Type
- SortDirection
- Description
The direction of the sort, either
ASC
orDESC
- Name
skip
- Type
- number
- Description
The number of items to skip.
- Name
limit
- Type
- number
- Description
The number of items to get
Return Data
data: AssetBalance[]
Return Data example
{ AssetBalance:
[
{
type: "native",
balance: 100000n,
lastUpdate: <Date>
},
{
type: "erc20",
address: "0x1234567890123456789012345678901234567890"
name: "The Token",
symbol: "TOK",
decimals: 18,
balance: 200000n
lastUpdate: <Date>
},
...
]
}
Return Values
{
data: AssetBalance[] | null,
error: Error | null,
isSuccess: boolean,
isError: boolean,
isLoading: boolean,
isRefetching: boolean,
}