Skip to content

Commit

Permalink
Custom network + IPFS support (#616)
Browse files Browse the repository at this point in the history
Add support for custom networks and IPFS urls
  • Loading branch information
Gustavo Antunes authored and MajorLift committed Oct 11, 2023
1 parent f21b66a commit 5779f3c
Show file tree
Hide file tree
Showing 9 changed files with 347 additions and 111 deletions.
16 changes: 10 additions & 6 deletions src/assets/AssetsContractController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,17 @@ describe('AssetsContractController', () => {
expect(tokenId).toStrictEqual('https://api.godsunchained.com/card/0');
});

it('should return empty string as URI when address given is not an ERC-721 collectible', async () => {
it('should throw an error when address given is not an ERC-721 collectible', async () => {
assetsContract.configure({ provider: MAINNET_PROVIDER });
const tokenId = await assetsContract.getCollectibleTokenURI(
'0x0000000000000000000000000000000000000000',
'0',
);
expect(tokenId).toStrictEqual('');
const result = async () => {
await assetsContract.getCollectibleTokenURI(
'0x0000000000000000000000000000000000000000',
'0',
);
};

const error = 'Contract does not support ERC721 metadata interface.';
await expect(result).rejects.toThrow(error);
});

it('should get ERC-721 collectible name', async () => {
Expand Down
2 changes: 2 additions & 0 deletions src/assets/AssetsDetectionController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ describe('AssetsDetectionController', () => {
description: 'Description 2573',
image: 'image/2573.png',
name: 'ID 2573',
standard: 'ERC721',
},
);
await assetsDetection.detectCollectibles();
Expand All @@ -456,6 +457,7 @@ describe('AssetsDetectionController', () => {
description: 'Description 2573',
image: 'image/2573.png',
name: 'ID 2573',
standard: 'ERC721',
tokenId: '2573',
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/assets/CollectibleStandards/ERC721/ERC721Standard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class ERC721Standard {
contract,
);
if (!supportsMetadata) {
return '';
throw new Error('Contract does not support ERC721 metadata interface.');
}
return new Promise<string>((resolve, reject) => {
contract.tokenURI(tokenId, (error: Error, result: string) => {
Expand Down
Loading

0 comments on commit 5779f3c

Please sign in to comment.