@@ -20,12 +20,14 @@ public struct Balance
20
20
public readonly string symbol ;
21
21
public readonly BigInteger value ;
22
22
public readonly int decimals ;
23
+ public readonly string [ ] ids ;
23
24
24
- public Balance ( string symbol , BigInteger value , int decimals )
25
+ public Balance ( string symbol , BigInteger value , int decimals , string [ ] ids )
25
26
{
26
27
this . symbol = symbol ;
27
28
this . value = value ;
28
29
this . decimals = decimals ;
30
+ this . ids = ids ;
29
31
}
30
32
}
31
33
@@ -83,6 +85,7 @@ public string Nexus
83
85
private Dictionary < int , Action < DataNode > > _requestCallbacks = new Dictionary < int , Action < DataNode > > ( ) ;
84
86
85
87
private Dictionary < string , Balance > _balanceMap = new Dictionary < string , Balance > ( ) ;
88
+ private Dictionary < string , Balance > _ownershipMap = new Dictionary < string , Balance > ( ) ;
86
89
87
90
#region Events
88
91
public static UnityEvent < bool , string > OnLogin ;
@@ -165,6 +168,7 @@ private void FetchAccount(Action<bool, string> callback)
165
168
this . IsLogged = true ;
166
169
167
170
_balanceMap . Clear ( ) ;
171
+ _ownershipMap . Clear ( ) ;
168
172
169
173
var balances = result . GetNode ( "balances" ) ;
170
174
if ( balances != null )
@@ -174,9 +178,17 @@ private void FetchAccount(Action<bool, string> callback)
174
178
var symbol = child . GetString ( "symbol" ) ;
175
179
var value = child . GetString ( "value" ) ;
176
180
var decimals = child . GetInt32 ( "decimals" ) ;
181
+ var ids_node = child . GetNode ( "ids" ) ;
182
+ var ids_array = new string [ ids_node . ChildCount ] ;
183
+ for ( int i = 0 ; i < ids_node . ChildCount ; i ++ )
184
+ {
185
+ ids_array [ i ] = ids_node . GetString ( i ) ;
186
+ }
177
187
178
188
var amount = BigInteger . Parse ( value ) ;
179
- _balanceMap [ symbol ] = new Balance ( symbol , amount , decimals ) ;
189
+ _balanceMap [ symbol ] = new Balance ( symbol , amount , decimals , ids_array ) ;
190
+ if ( ids_node . ChildCount > 0 )
191
+ _ownershipMap [ symbol ] = new Balance ( symbol , amount , decimals , ids_array ) ;
180
192
}
181
193
}
182
194
@@ -331,6 +343,22 @@ public decimal GetBalance(string symbol)
331
343
332
344
return 0 ;
333
345
}
346
+
347
+ /// <summary>
348
+ /// Returns the NFTs IDs for a specific symbol
349
+ /// </summary>
350
+ /// <param name="symbol"></param>
351
+ /// <returns></returns>
352
+ public string [ ] GetNFTs ( string symbol )
353
+ {
354
+ if ( _ownershipMap . ContainsKey ( symbol ) )
355
+ {
356
+ var temp = _ownershipMap [ symbol ] ;
357
+ return temp . ids ;
358
+ }
359
+
360
+ return Array . Empty < string > ( ) ;
361
+ }
334
362
335
363
/// <summary>
336
364
/// Login to the Dapp
0 commit comments