From 070379ae5bde0c8ea21aa59d54c9462fe1c773cc Mon Sep 17 00:00:00 2001 From: Agusx1211 Date: Fri, 31 May 2024 10:19:11 +0000 Subject: [PATCH] Use snake case for attributes --- .../wrappers/clawback/ClawbackMetadata.sol | 28 ++++++++--------- .../wrappers/clawback/ClawbackMetadata.t.sol | 30 +++++++++---------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/tokens/wrappers/clawback/ClawbackMetadata.sol b/src/tokens/wrappers/clawback/ClawbackMetadata.sol index 23ffd0f..c6ae45e 100644 --- a/src/tokens/wrappers/clawback/ClawbackMetadata.sol +++ b/src/tokens/wrappers/clawback/ClawbackMetadata.sol @@ -72,48 +72,48 @@ contract ClawbackMetadata is IMetadataProvider, IERC165 { bool hasTokenId = details.tokenType == IClawbackFunctions.TokenType.ERC721 || details.tokenType == IClawbackFunctions.TokenType.ERC1155; properties = new MetadataProperty[](hasTokenId ? 8 : 7); - properties[0] = MetadataProperty("tokenType", _toTokenTypeStr(details.tokenType)); - properties[1] = MetadataProperty("tokenAddress", details.tokenAddr.toHexStringChecksummed()); - properties[2] = MetadataProperty("templateId", details.templateId.toString()); - properties[3] = MetadataProperty("lockedAt", details.lockedAt.toString()); + properties[0] = MetadataProperty("token_type", _toTokenTypeStr(details.tokenType)); + properties[1] = MetadataProperty("token_address", details.tokenAddr.toHexStringChecksummed()); + properties[2] = MetadataProperty("template_id", details.templateId.toString()); + properties[3] = MetadataProperty("locked_at", details.lockedAt.toString()); properties[4] = MetadataProperty("duration", template.duration.toString()); - properties[5] = MetadataProperty("destructionOnly", _boolToString(template.destructionOnly)); - properties[6] = MetadataProperty("transferOpen", _boolToString(template.transferOpen)); + properties[5] = MetadataProperty("destruction_only", _boolToString(template.destructionOnly)); + properties[6] = MetadataProperty("transfer_open", _boolToString(template.transferOpen)); if (hasTokenId) { - properties[7] = MetadataProperty("tokenId", details.tokenId.toString()); + properties[7] = MetadataProperty("token_id", details.tokenId.toString()); } // From contract if (details.tokenType == IClawbackFunctions.TokenType.ERC20) { properties = _safeAddStringProperty( - properties, "originalName", details.tokenAddr, abi.encodeWithSelector(IERC20Metadata.name.selector) + properties, "original_name", details.tokenAddr, abi.encodeWithSelector(IERC20Metadata.name.selector) ); properties = _safeAddStringProperty( - properties, "originalSymbol", details.tokenAddr, abi.encodeWithSelector(IERC20Metadata.symbol.selector) + properties, "original_symbol", details.tokenAddr, abi.encodeWithSelector(IERC20Metadata.symbol.selector) ); properties = _safeAddUint256Property( properties, - "originalDecimals", + "original_decimals", details.tokenAddr, abi.encodeWithSelector(IERC20Metadata.decimals.selector) ); } else if (details.tokenType == IClawbackFunctions.TokenType.ERC721) { properties = _safeAddStringProperty( - properties, "originalName", details.tokenAddr, abi.encodeWithSelector(IERC721Metadata.name.selector) + properties, "original_name", details.tokenAddr, abi.encodeWithSelector(IERC721Metadata.name.selector) ); properties = _safeAddStringProperty( - properties, "originalSymbol", details.tokenAddr, abi.encodeWithSelector(IERC721Metadata.symbol.selector) + properties, "original_symbol", details.tokenAddr, abi.encodeWithSelector(IERC721Metadata.symbol.selector) ); properties = _safeAddStringProperty( properties, - "originalURI", + "original_URI", details.tokenAddr, abi.encodeWithSelector(IERC721Metadata.tokenURI.selector, details.tokenId) ); } else if (details.tokenType == IClawbackFunctions.TokenType.ERC1155) { properties = _safeAddStringProperty( properties, - "originalURI", + "original_URI", details.tokenAddr, abi.encodeWithSelector(IERC1155MetadataURI.uri.selector, details.tokenId) ); diff --git a/test/tokens/wrappers/clawback/ClawbackMetadata.t.sol b/test/tokens/wrappers/clawback/ClawbackMetadata.t.sol index 340eb99..070d4ba 100644 --- a/test/tokens/wrappers/clawback/ClawbackMetadata.t.sol +++ b/test/tokens/wrappers/clawback/ClawbackMetadata.t.sol @@ -55,9 +55,9 @@ contract ClawbackMetadataTest is ClawbackTestBase { _checkCommonProperties(properties, details, template, "ERC-20"); - _hasProperty(properties, "originalName", erc20.name()); - _hasProperty(properties, "originalSymbol", erc20.symbol()); - _hasProperty(properties, "originalDecimals", erc20.decimals().toString()); + _hasProperty(properties, "original_name", erc20.name()); + _hasProperty(properties, "original_symbol", erc20.symbol()); + _hasProperty(properties, "original_decimals", erc20.decimals().toString()); } function testMetadataPropertiesERC721(DetailsParam memory detailsParam, IClawbackFunctions.Template memory template) @@ -75,10 +75,10 @@ contract ClawbackMetadataTest is ClawbackTestBase { _checkCommonProperties(properties, details, template, "ERC-721"); - _hasProperty(properties, "tokenId", details.tokenId.toString()); - _hasProperty(properties, "originalName", erc721.name()); - _hasProperty(properties, "originalSymbol", erc721.symbol()); - _hasProperty(properties, "originalURI", erc721.tokenURI(details.tokenId)); + _hasProperty(properties, "token_id", details.tokenId.toString()); + _hasProperty(properties, "original_name", erc721.name()); + _hasProperty(properties, "original_symbol", erc721.symbol()); + _hasProperty(properties, "original_URI", erc721.tokenURI(details.tokenId)); } function testMetadataPropertiesERC1155( @@ -94,8 +94,8 @@ contract ClawbackMetadataTest is ClawbackTestBase { _checkCommonProperties(properties, details, template, "ERC-1155"); - _hasProperty(properties, "tokenId", details.tokenId.toString()); - _hasProperty(properties, "originalURI", erc1155.uri(details.tokenId)); + _hasProperty(properties, "token_id", details.tokenId.toString()); + _hasProperty(properties, "original_URI", erc1155.uri(details.tokenId)); } function _checkCommonProperties( @@ -104,12 +104,12 @@ contract ClawbackMetadataTest is ClawbackTestBase { IClawbackFunctions.Template memory template, string memory tokenTypeStr ) internal { - _hasProperty(properties, "tokenType", tokenTypeStr); - _hasProperty(properties, "tokenAddress", details.tokenAddr.toHexStringChecksummed()); - _hasProperty(properties, "templateId", details.templateId.toString()); - _hasProperty(properties, "lockedAt", details.lockedAt.toString()); - _hasProperty(properties, "destructionOnly", template.destructionOnly ? "true" : "false"); - _hasProperty(properties, "transferOpen", template.transferOpen ? "true" : "false"); + _hasProperty(properties, "token_type", tokenTypeStr); + _hasProperty(properties, "token_address", details.tokenAddr.toHexStringChecksummed()); + _hasProperty(properties, "template_id", details.templateId.toString()); + _hasProperty(properties, "locked_at", details.lockedAt.toString()); + _hasProperty(properties, "destruction_only", template.destructionOnly ? "true" : "false"); + _hasProperty(properties, "transfer_open", template.transferOpen ? "true" : "false"); _hasProperty(properties, "duration", template.duration.toString()); }