Skip to content

Commit

Permalink
chore(protocol): apply small improvements (#16647)
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Apr 4, 2024
1 parent b853c08 commit f0ecb40
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/protocol/contracts/thirdparty/optimism/Bytes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ library Bytes {
}

/// @notice Slices a byte array with a given starting index up to the end of the original byte
/// array. Returns a new array rathern than a pointer to the original.
/// array. Returns a new array rather than a pointer to the original.
/// @param _bytes Byte array to slice.
/// @param _start Starting index of the slice.
/// @return Slice of the input byte array.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,8 @@ library MerkleTrie {
function _parseProof(bytes[] memory _proof) private pure returns (TrieNode[] memory proof_) {
uint256 length = _proof.length;
proof_ = new TrieNode[](length);
for (uint256 i = 0; i < length;) {
for (uint256 i = 0; i < length; ++i) {
proof_[i] = TrieNode({ encoded: _proof[i], decoded: RLPReader.readList(_proof[i]) });
unchecked {
++i;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/tokenvault/BridgedERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ contract BridgedERC1155 is EssentialContract, ERC1155Upgradeable {

// The token URI here is not important as the client will have to read the URI from the
// canonical contract to fetch meta data.
__ERC1155_init(LibBridgedToken.buildURI(_srcToken, _srcChainId));
__ERC1155_init(LibBridgedToken.buildURI(_srcToken, _srcChainId, ""));

srcToken = _srcToken;
srcChainId = _srcChainId;
Expand Down
6 changes: 1 addition & 5 deletions packages/protocol/contracts/tokenvault/BridgedERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,7 @@ contract BridgedERC721 is EssentialContract, ERC721Upgradeable {
// https://github.com/crytic/slither/wiki/Detector-Documentation#abi-encodePacked-collision
// The abi.encodePacked() call below takes multiple dynamic arguments. This is known and
// considered acceptable in terms of risk.
return string(
abi.encodePacked(
LibBridgedToken.buildURI(srcToken, srcChainId), Strings.toString(_tokenId)
)
);
return LibBridgedToken.buildURI(srcToken, srcChainId, Strings.toString(_tokenId));
}

/// @notice Gets the canonical token's address and chain ID.
Expand Down
6 changes: 4 additions & 2 deletions packages/protocol/contracts/tokenvault/LibBridgedToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ library LibBridgedToken {

function buildURI(
address _srcToken,
uint256 _srcChainId
uint256 _srcChainId,
string memory _extraParams
)
internal
pure
Expand All @@ -66,7 +67,8 @@ library LibBridgedToken {
Strings.toHexString(uint160(_srcToken), 20),
"@",
Strings.toString(_srcChainId),
"/tokenURI?uint256="
"/tokenURI?uint256=",
_extraParams
)
);
}
Expand Down

0 comments on commit f0ecb40

Please sign in to comment.