Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onchain metadata support for multi delegate #25

Merged
merged 11 commits into from Dec 13, 2023

Conversation

mdtanrikulu
Copy link
Member

No description provided.

@mdtanrikulu mdtanrikulu marked this pull request as ready for review November 27, 2023 11:35
require((sources[transferIndex] >> 160) == 0, "Upper 96 bits of source uint256 must be zero");
require(
(sources[transferIndex] >> 160) == 0,
"Upper 96 bits of source uint256 must be zero"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be custom errors.

@@ -108,15 +117,22 @@ contract ERC20MultiDelegate is ERC1155, Ownable {
for (
uint transferIndex = 0;
transferIndex < Math.max(sourcesLength, targetsLength);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC one of the gas optimisation suggestions was to calculate the max outside the loop.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved it

function setUri(string memory uri) external onlyOwner {
_setURI(uri);
emit MetadataURIUpdated(uri);
function setUri(string memory /*uri*/) external view onlyOwner {
Copy link
Member

@Arachnid Arachnid Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just remove this instead - and the ownership functionality with it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, done

contracts/ERC20MultiDelegate.sol Outdated Show resolved Hide resolved
) {
resolvedName = _resolvedName;
} catch {
return "";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A failure to get the primary name shouldn't result in all the metadata being empty. Perhaps just return the hex-encoded address instead?

"text(bytes32,string)",
[namehash, "avatar"]
);
(bytes memory result, ) = metadataResolver.resolve(encodedName, data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs a try block.

return string.concat("data:application/json;base64,", json);
}

function trim(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

009ea33df7aca6f9c65c51ae10df081d

Copying the address-to-hex implementation into /utils/HexUtils.sol, and removing the 0x prefix, would remove the need for this function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a new HexUtils method, which converts address to hex string without hex prefix. ptal if that's okay.

address source = address(0);
address target = address(0);
if (transferIndex < sourcesLength) {
require((sources[transferIndex] >> 160) == 0, "Upper 96 bits of source uint256 must be zero");
if ((sources[transferIndex] >> 160) != 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run lint, and always use braces on if/else blocks.

address source = address(0);
address target = address(0);
if (transferIndex < sourcesLength) {
require((sources[transferIndex] >> 160) == 0, "Upper 96 bits of source uint256 must be zero");
if ((sources[transferIndex] >> 160) != 0)
revert Upper96BitsNotZero();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be less implementation-specific, like InvalidDelegateAddress.

bytes(
string.concat(
'{"name": "',
resolvedName,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and imageUri need to be escaped.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think double quotes and backslash escaping will be enough?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdtanrikulu mdtanrikulu merged commit b0571dd into mdt/2023-10-ens-findings Dec 13, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants