{
    "Function": "principalTokenURI",
    "File": "src/MarketMetadata.sol",
    "Parent Contracts": [
        "lib/openzeppelin-contracts/contracts/token/common/ERC2981.sol",
        "lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol",
        "lib/openzeppelin-contracts/contracts/interfaces/IERC2981.sol",
        "lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol",
        "lib/openzeppelin-contracts/contracts/access/Ownable2Step.sol",
        "lib/openzeppelin-contracts/contracts/access/Ownable.sol",
        "lib/openzeppelin-contracts/contracts/utils/Context.sol"
    ],
    "High-Level Calls": [
        "IDelegateToken",
        "Strings",
        "Base64",
        "Strings",
        "Strings",
        "IDelegateToken",
        "IDelegateToken",
        "Strings"
    ],
    "Internal Calls": [
        "string.concat()",
        "string.concat()",
        "string.concat()",
        "string.concat()",
        "string.concat()",
        "string.concat()"
    ],
    "Library Calls": [
        "toHexString",
        "encode",
        "toHexString",
        "toString",
        "toString"
    ],
    "Low-Level Calls": [],
    "Code": "function principalTokenURI(address delegateToken, uint256 id) external view returns (string memory) {\n        IDelegateToken dt = IDelegateToken(delegateToken);\n\n        DelegateTokenStructs.DelegateInfo memory delegateInfo = dt.getDelegateInfo(id);\n\n        string memory idstr = Strings.toString(delegateInfo.tokenId);\n        string memory imageUrl = string.concat(delegateTokenBaseURI, \"principal/\", idstr);\n\n        address rightsOwner = address(0);\n        try dt.ownerOf(id) returns (address retrievedOwner) {\n            rightsOwner = retrievedOwner;\n        } catch {}\n\n        string memory rightsOwnerStr = rightsOwner == address(0) ? \"N/A\" : Strings.toHexString(rightsOwner);\n        //slither-disable-next-line timestamp\n        string memory status = rightsOwner == address(0) || delegateInfo.expiry <= block.timestamp ? \"Unlocked\" : \"Locked\";\n\n        string memory firstPartOfMetadataString = string.concat(\n            '{\"name\":\"',\n            string.concat(dt.name(), \" #\", idstr),\n            '\",\"description\":\"DelegateMarket lets you escrow your token for a chosen timeperiod and receive a token representing its delegation rights. This collection represents the principal i.e. the future right to claim the underlying token once the associated delegate token expires.\",\"attributes\":[{\"trait_type\":\"Collection Address\",\"value\":\"',\n            Strings.toHexString(delegateInfo.tokenContract),\n            '\"},{\"trait_type\":\"Token ID\",\"value\":\"',\n            idstr,\n            '\"},{\"trait_type\":\"Unlocks At\",\"display_type\":\"date\",\"value\":',\n            Strings.toString(delegateInfo.expiry)\n        );\n        string memory secondPartOfMetadataString = string.concat(\n            '},{\"trait_type\":\"Delegate Owner Address\",\"value\":\"', rightsOwnerStr, '\"},{\"trait_type\":\"Principal Status\",\"value\":\"', status, '\"}],\"image\":\"', imageUrl, '\"}'\n        );\n        // Build in two parts to avoid stack-too-deep\n        string memory metadataString = string.concat(firstPartOfMetadataString, secondPartOfMetadataString);\n\n        return string.concat(\"data:application/json;base64,\", Base64.encode(bytes(metadataString)));\n    }"
}