diff --git a/contracts/FleekERC721.sol b/contracts/FleekERC721.sol index 2cee076..956882d 100644 --- a/contracts/FleekERC721.sol +++ b/contracts/FleekERC721.sol @@ -59,27 +59,32 @@ contract FleekERC721 is ERC721, FleekAccessControl { /** * @dev Generates a SVG image. */ - function _generateSVG(string memory name, string memory ENS) internal pure returns (string memory) { + function _generateSVG(string memory name, string memory ENS) internal view returns (string memory) { return ( string( abi.encodePacked( - '', - "", - "", - '', - '', - "", - '', - 'Fleek NFAs', - "", - '', - '', - name, - '', - ENS, - "", - "", - "" + _baseURI(), + Base64.encode( + abi.encodePacked( + '', + "", + "", + '', + '', + "", + '', + 'Fleek NFAs', + "", + '', + '', + name, + '', + ENS, + "", + "", + "" + ) + ) ) ) ); diff --git a/test/FleekERC721.ts b/test/FleekERC721.ts index ab98e48..482763a 100644 --- a/test/FleekERC721.ts +++ b/test/FleekERC721.ts @@ -139,7 +139,7 @@ describe('FleekERC721', () => { }); it('should return the token URI', async () => { - /**const { contract } = fixture; + const { contract } = fixture; const tokenURI = await contract.tokenURI(tokenId); const tokenURIDecoded = Buffer.from( @@ -149,28 +149,35 @@ describe('FleekERC721', () => { const parsedURI = JSON.parse(tokenURIDecoded); - console.log(parsedURI.image); + const imageDecoded = Buffer.from( + parsedURI.image.replace('data:application/json;base64,', ''), + 'base64' + ).toString('ascii'); + + parsedURI.image = imageDecoded; expect(parsedURI).to.eql({ owner: fixture.owner.address.toLowerCase(), name: MINT_PARAMS.name, description: MINT_PARAMS.description, - image: ''+""+ - +"" - +'' - +'' - +"" - +'' - +'Fleek NFAs' - +"" - +'' - +'' - +MINT_PARAMS.name - +'' - +MINT_PARAMS.ens - +"" - +"" - +"", + image: + '' + + '' + + '' + + '' + + '' + + '' + + '' + + 'Fleek NFAs' + + '' + + '' + + '' + + MINT_PARAMS.name + + '' + + MINT_PARAMS.ens + + '' + + '' + + '', external_url: MINT_PARAMS.externalUrl, attributes: [ { @@ -190,7 +197,7 @@ describe('FleekERC721', () => { value: '0', }, ], - });**/ + }); }); }); diff --git a/test/foundry/apps.t.sol b/test/foundry/apps.t.sol index b130ddb..5689423 100644 --- a/test/foundry/apps.t.sol +++ b/test/foundry/apps.t.sol @@ -111,27 +111,32 @@ contract FleekTest is Test { assertEq(second_mint, 1); } - function _generateSVG(string memory name, string memory ENS) internal returns (string memory) { + function _generateSVG(string memory name, string memory ENS) internal pure returns (string memory) { return ( string( abi.encodePacked( - '', - "", - "" - '', - '', - "", - '', - 'Fleek NFAs', - "", - '', - '', - name, - '', - ENS, - "", - "", - "" + "data:application/json;base64,", + Base64.encode( + abi.encodePacked( + '', + "", + "", + '', + '', + "", + '', + 'Fleek NFAs', + "", + '', + '', + name, + '', + ENS, + "", + "", + "" + ) + ) ) ) );