Skip to content

Commit

Permalink
add bold token to uri and strings for attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
cupOJoseph committed Sep 4, 2024
1 parent f73d7f5 commit 61a05d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 11 additions & 6 deletions contracts/src/NFTMetadata/MetadataNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import "./utils/baseSVG.sol";
import "./utils/bauhaus.sol";

import "openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol";

import {ITroveManager} from "src/Interfaces/ITroveManager.sol";

interface IMetadataNFT {
Expand Down Expand Up @@ -36,7 +38,8 @@ contract MetadataNFT is IMetadataNFT {
}

function uri(TroveData memory _troveData) public view returns (string memory) {
return json.formattedMetadata(name, description, renderSVGImage(_troveData), attributes);
string memory attr = attributes(_troveData);
return json.formattedMetadata(name, description, renderSVGImage(_troveData), attr);
}

function renderSVGImage(TroveData memory _troveData) internal view returns (string memory) {
Expand All @@ -50,19 +53,21 @@ contract MetadataNFT is IMetadataNFT {
//include: collateral token address, collateral amount, debt token address, debt amount, interest rate, status
return string.concat(
'[{"trait_type": "Collateral Token", "value": "',
_troveData._collToken,
Strings.toString(_troveData._collToken),
'"}, {"trait_type": "Collateral Amount", "value": "',
_troveData._collAmount,
Strings.toString(_troveData._collAmount),
'"}, {"trait_type": "Debt Token", "value": "',
_troveData._boldToken,
Strings.toString(_troveData._boldToken),
'"}, {"trait_type": "Debt Amount", "value": "',
_troveData._debtAmount,
Strings.toString(_troveData._debtAmount),
'"}, {"trait_type": "Interest Rate", "value": "',
_troveData._interestRate,
Strings.toString(_troveData._interestRate),
'"}, {"trait_type": "Status", "value": "',
_status2Str(_troveData._status),
'"} ]'
);


}

function dynamicTextComponents(TroveData memory _troveData) public view returns (string memory) {
Expand Down
2 changes: 2 additions & 0 deletions contracts/src/TroveNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {ITroveManager} from "./Interfaces/ITroveManager.sol";
contract TroveNFT is ERC721, ITroveNFT {
ITroveManager public immutable troveManager;
IERC20Metadata internal immutable collToken;
IBoldToken internal immutable boldToken;

IMetadataNFT public immutable metadataNFT;

Expand All @@ -28,6 +29,7 @@ contract TroveNFT is ERC721, ITroveNFT {
troveManager = _addressesRegistry.troveManager();
collToken = _addressesRegistry.collToken();
metadataNFT = _addressesRegistry.metadataNFT();
boldToken = _addressesRegistry.boldToken();
}

function tokenURI(uint256 _tokenId) public view override(ERC721, IERC721Metadata) returns (string memory) {
Expand Down

0 comments on commit 61a05d4

Please sign in to comment.