From 61a05d4fc6d7a9e2641c7436cbff015cf6a7bf7d Mon Sep 17 00:00:00 2001 From: Joseph Schiarizzi <9449596+cupOJoseph@users.noreply.github.com> Date: Thu, 5 Sep 2024 01:15:54 +0900 Subject: [PATCH] add bold token to uri and strings for attributes --- contracts/src/NFTMetadata/MetadataNFT.sol | 17 +++++++++++------ contracts/src/TroveNFT.sol | 2 ++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/contracts/src/NFTMetadata/MetadataNFT.sol b/contracts/src/NFTMetadata/MetadataNFT.sol index d961da4c..8e421f69 100644 --- a/contracts/src/NFTMetadata/MetadataNFT.sol +++ b/contracts/src/NFTMetadata/MetadataNFT.sol @@ -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 { @@ -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) { @@ -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) { diff --git a/contracts/src/TroveNFT.sol b/contracts/src/TroveNFT.sol index b373e2cb..97440176 100644 --- a/contracts/src/TroveNFT.sol +++ b/contracts/src/TroveNFT.sol @@ -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; @@ -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) {