Skip to content

Commit

Permalink
Use snake case for attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Agusx1211 committed May 31, 2024
1 parent 4642544 commit 070379a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
28 changes: 14 additions & 14 deletions src/tokens/wrappers/clawback/ClawbackMetadata.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
Expand Down
30 changes: 15 additions & 15 deletions test/tokens/wrappers/clawback/ClawbackMetadata.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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());
}

Expand Down

0 comments on commit 070379a

Please sign in to comment.