Skip to content

Commit ca09f88

Browse files
authored
Merge pull request #125 from syscoin/fix/rollux-nft
fix: solves rollux token nft collection not appearing
2 parents 37cd849 + 375fffd commit ca09f88

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

core/src/assets/CollectiblesController.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Mutex } from 'async-mutex';
22
import { BigNumber } from 'bignumber.js';
33
import BaseController, { BaseConfig, BaseState } from '../BaseController';
44
import { ChainType, SupportCollectibles } from '../Config';
5+
56
import PreferencesController from '../user/PreferencesController';
67
import util, {
78
CollectibleType,
@@ -257,7 +258,7 @@ export class CollectiblesController extends BaseController<CollectiblesConfig, C
257258
return undefined;
258259
}
259260

260-
return await this.fixDataCollectibles(collectibles, chainId, selectedAddress, contractController);
261+
return await this.fixDataCollectibles(collectibles, chainId, selectedAddress, contractController, true);
261262
} catch (e) {
262263
logInfo('PPYang fetchLuxyNFTs e:', e);
263264
return undefined;
@@ -290,7 +291,13 @@ export class CollectiblesController extends BaseController<CollectiblesConfig, C
290291
return await this.fixDataCollectibles(collectibles, chainId, selectedAddress, contractController);
291292
}
292293

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+
) {
294301
const erc721Tokens: string[] = [];
295302
const erc721Ids: string[] = [];
296303

@@ -310,6 +317,7 @@ export class CollectiblesController extends BaseController<CollectiblesConfig, C
310317
const allOwners: any[] = [];
311318
if (erc721Tokens.length > 0) {
312319
let owners: any[] = [];
320+
313321
try {
314322
owners = await contractController.getERC721OwnersInSingleCall(
315323
selectedAddress,
@@ -333,10 +341,13 @@ export class CollectiblesController extends BaseController<CollectiblesConfig, C
333341
});
334342
}
335343
}
344+
336345
if (owners && owners.length === erc721Tokens.length) {
337346
erc721Tokens.forEach((address, index) => {
338347
if (toLowerCaseEquals(owners[index], selectedAddress)) {
339348
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] });
340351
}
341352
});
342353
} else {
@@ -380,11 +391,13 @@ export class CollectiblesController extends BaseController<CollectiblesConfig, C
380391
return undefined;
381392
}
382393
}
394+
383395
const ownedCollectibles: any = [];
384396
collectibles.forEach((collectible: any) => {
385397
const owner = allOwners.find(
386398
(item) => item.address === collectible.asset_contract.address && item.token_id === collectible.token_id,
387399
);
400+
388401
if (owner) {
389402
ownedCollectibles.push({ ...collectible, balanceOf: owner.balanceOf, chainId });
390403
}

0 commit comments

Comments
 (0)