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

Update AttestationsRegistry.sol: Gas Optimizations #72

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions contracts/core/AttestationsRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ contract AttestationsRegistry is
*/
function recordAttestations(Attestation[] calldata attestations) external override whenNotPaused {
address issuer = _msgSender();
for (uint256 i = 0; i < attestations.length; i++) {
for (uint256 i; i < attestations.length;) {
if (!_isAuthorized(issuer, attestations[i].collectionId))
revert IssuerNotAuthorized(issuer, attestations[i].collectionId);

Expand All @@ -80,6 +80,9 @@ contract AttestationsRegistry is
attestations[i].value
);
emit AttestationRecorded(attestations[i]);
unchecked{
++i;
}
}
}

Expand All @@ -96,7 +99,7 @@ contract AttestationsRegistry is
revert OwnersAndCollectionIdsLengthMismatch(owners, collectionIds);

address issuer = _msgSender();
for (uint256 i = 0; i < owners.length; i++) {
for (uint256 i; i < owners.length;) {
AttestationData memory attestationData = _attestationsData[collectionIds[i]][owners[i]];

if (!_isAuthorized(issuer, collectionIds[i]))
Expand All @@ -115,6 +118,10 @@ contract AttestationsRegistry is
attestationData.extraData
)
);

unchecked {
++i;
}
}
}

Expand Down Expand Up @@ -241,7 +248,7 @@ contract AttestationsRegistry is
}

/**
* @dev Function that trigger a TransferSingle event from the stateless ERC1155 Badges contract
* @dev Function that triggers a TransferSingle event from the stateless ERC1155 Badges contract
* It enables off-chain apps such as opensea to catch the "shadow mints/burns" of badges
*/
function _triggerBadgeTransferEvent(
Expand Down