File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -84,11 +84,13 @@ const getResultsForAddress = async (
84
84
85
85
if ( ! nameRecord || ! nameRecord . targetAddress ) return null ;
86
86
87
+ const addrHasActivity = await addressHasActivity ( client , nameRecord . targetAddress ) ;
88
+
87
89
return [
88
90
{
89
91
id : nameRecord . targetAddress ,
90
92
label : nameRecord . targetAddress ,
91
- type : 'address' ,
93
+ type : addrHasActivity ? 'address' : 'object ',
92
94
} ,
93
95
] ;
94
96
}
@@ -120,6 +122,28 @@ const getResultsForAddress = async (
120
122
] ;
121
123
} ;
122
124
125
+ async function addressHasActivity ( client : IotaClient , address : string ) : Promise < boolean > {
126
+ const normalized = normalizeIotaObjectId ( address ) ;
127
+ if ( ! isValidIotaAddress ( normalized ) ) return false ;
128
+ try {
129
+ const fromOrTo = await client . queryTransactionBlocks ( {
130
+ filter : { FromOrToAddress : { addr : normalized } } ,
131
+ limit : 1 ,
132
+ } ) ;
133
+ if ( fromOrTo ?. data ?. length > 0 ) return true ;
134
+
135
+ const ownedObjects = await client . getOwnedObjects ( {
136
+ owner : normalized ,
137
+ limit : 1 ,
138
+ } ) ;
139
+ if ( ownedObjects . data . length > 0 ) return true ;
140
+
141
+ return false ;
142
+ } catch ( e ) {
143
+ return false ;
144
+ }
145
+ }
146
+
123
147
// Query for validator by pool id or iota address.
124
148
const getResultsForValidatorByPoolIdOrIotaAddress = async (
125
149
systemStateSummary : LatestIotaSystemStateSummary | null ,
You can’t perform that action at this time.
0 commit comments