@@ -2,6 +2,7 @@ import { Mutex } from 'async-mutex';
2
2
import { BigNumber } from 'bignumber.js' ;
3
3
import BaseController , { BaseConfig , BaseState } from '../BaseController' ;
4
4
import { ChainType , SupportCollectibles } from '../Config' ;
5
+
5
6
import PreferencesController from '../user/PreferencesController' ;
6
7
import util , {
7
8
CollectibleType ,
@@ -257,7 +258,7 @@ export class CollectiblesController extends BaseController<CollectiblesConfig, C
257
258
return undefined ;
258
259
}
259
260
260
- return await this . fixDataCollectibles ( collectibles , chainId , selectedAddress , contractController ) ;
261
+ return await this . fixDataCollectibles ( collectibles , chainId , selectedAddress , contractController , true ) ;
261
262
} catch ( e ) {
262
263
logInfo ( 'PPYang fetchLuxyNFTs e:' , e ) ;
263
264
return undefined ;
@@ -290,7 +291,13 @@ export class CollectiblesController extends BaseController<CollectiblesConfig, C
290
291
return await this . fixDataCollectibles ( collectibles , chainId , selectedAddress , contractController ) ;
291
292
}
292
293
293
- async fixDataCollectibles ( collectibles : any , chainId : string , selectedAddress : string , contractController : any ) {
294
+ async fixDataCollectibles (
295
+ collectibles : any ,
296
+ chainId : string ,
297
+ selectedAddress : string ,
298
+ contractController : any ,
299
+ isLuxy ?: boolean ,
300
+ ) {
294
301
const erc721Tokens : string [ ] = [ ] ;
295
302
const erc721Ids : string [ ] = [ ] ;
296
303
@@ -310,6 +317,7 @@ export class CollectiblesController extends BaseController<CollectiblesConfig, C
310
317
const allOwners : any [ ] = [ ] ;
311
318
if ( erc721Tokens . length > 0 ) {
312
319
let owners : any [ ] = [ ] ;
320
+
313
321
try {
314
322
owners = await contractController . getERC721OwnersInSingleCall (
315
323
selectedAddress ,
@@ -333,10 +341,13 @@ export class CollectiblesController extends BaseController<CollectiblesConfig, C
333
341
} ) ;
334
342
}
335
343
}
344
+
336
345
if ( owners && owners . length === erc721Tokens . length ) {
337
346
erc721Tokens . forEach ( ( address , index ) => {
338
347
if ( toLowerCaseEquals ( owners [ index ] , selectedAddress ) ) {
339
348
allOwners . push ( { balanceOf : new BigNumber ( 1 ) , address, token_id : erc721Ids [ index ] } ) ;
349
+ } else if ( isLuxy && owners [ index ] === '0x0000000000000000000000000000000000000000' ) {
350
+ allOwners . push ( { balanceOf : new BigNumber ( 1 ) , address, token_id : erc721Ids [ index ] } ) ;
340
351
}
341
352
} ) ;
342
353
} else {
@@ -380,11 +391,13 @@ export class CollectiblesController extends BaseController<CollectiblesConfig, C
380
391
return undefined ;
381
392
}
382
393
}
394
+
383
395
const ownedCollectibles : any = [ ] ;
384
396
collectibles . forEach ( ( collectible : any ) => {
385
397
const owner = allOwners . find (
386
398
( item ) => item . address === collectible . asset_contract . address && item . token_id === collectible . token_id ,
387
399
) ;
400
+
388
401
if ( owner ) {
389
402
ownedCollectibles . push ( { ...collectible , balanceOf : owner . balanceOf , chainId } ) ;
390
403
}
0 commit comments