File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -19,19 +19,25 @@ const CONFIG = {
19
19
hedera : '0.0.540219' ,
20
20
}
21
21
22
- const hederaTVL = async ( address ) => {
23
- const totalBalances = { }
22
+ const hederaTokens = { }
23
+
24
+ const hederaTVL = async ( address , paginationPath = '' ) => {
24
25
try {
25
- const { balance } = await get ( `${ HEDERA_MIRROR_NODE_URL } /api/v1/accounts/${ address } ?limit=100&order=asc&transactiontype=cryptotransfer&transactions=true` )
26
- balance ?. tokens . forEach ( token => {
27
- // Note: We are filtering this token because its an old version of DOVE
28
- if ( token . token_id === '0.0.624505' ) return
29
- totalBalances [ `hedera:${ token . token_id } ` ] = String ( token . balance )
26
+ let path = `/api/v1/accounts/${ address } /tokens?limit=100&order=desc`
27
+ if ( paginationPath ) {
28
+ path = paginationPath
29
+ }
30
+ const { tokens, links } = await get ( `${ HEDERA_MIRROR_NODE_URL } ${ path } ` )
31
+ tokens . forEach ( token => {
32
+ hederaTokens [ `hedera:${ token . token_id } ` ] = String ( token . balance )
30
33
} )
34
+ if ( links ?. next ) {
35
+ return hederaTVL ( address , links . next )
36
+ }
31
37
} catch ( error ) {
32
38
log ( error )
33
39
}
34
- return totalBalances
40
+ return hederaTokens
35
41
}
36
42
37
43
const evmTVL = async ( api , token , useCoValent = true ) => {
You can’t perform that action at this time.
0 commit comments