-
Notifications
You must be signed in to change notification settings - Fork 3
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
refactor: using require instead of revert where possible #107
Changes from all commits
0000000
0000000
0000000
0000000
0000000
0000000
0000000
e71e8f6
0000000
0000000
0000000
0000000
0000000
0000000
0000000
0000000
0000000
0000000
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,26 +35,26 @@ contract IBCStore is IIBCStore, IICS24HostErrors, Ownable { | |
/// @inheritdoc IIBCStore | ||
function commitPacket(IICS26RouterMsgs.Packet memory packet) public onlyOwner { | ||
bytes32 path = ICS24Host.packetCommitmentKeyCalldata(packet.sourceChannel, packet.sequence); | ||
if (commitments[path] != 0) { | ||
revert IBCPacketCommitmentAlreadyExists( | ||
require( | ||
commitments[path] == 0, | ||
IBCPacketCommitmentAlreadyExists( | ||
ICS24Host.packetCommitmentPathCalldata(packet.sourceChannel, packet.sequence) | ||
); | ||
} | ||
) | ||
); | ||
|
||
bytes32 commitment = ICS24Host.packetCommitmentBytes32(packet); | ||
emit PacketCommitted(path, commitment); | ||
commitments[path] = commitment; | ||
emit PacketCommitted(path, commitment); | ||
Comment on lines
-45
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes more logical sense for this to be at the end. This event should probably be removed on another issue to clean up unnecessary events There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I added an issue for implementing spec events, and specified in that issue that we should clean up events all over the place at the same time: #108 |
||
} | ||
|
||
/// @inheritdoc IIBCStore | ||
function deletePacketCommitment(IICS26RouterMsgs.Packet memory packet) public onlyOwner returns (bytes32) { | ||
bytes32 path = ICS24Host.packetCommitmentKeyCalldata(packet.sourceChannel, packet.sequence); | ||
bytes32 commitment = commitments[path]; | ||
if (commitment == 0) { | ||
revert IBCPacketCommitmentNotFound( | ||
ICS24Host.packetCommitmentPathCalldata(packet.sourceChannel, packet.sequence) | ||
); | ||
} | ||
require( | ||
commitment != 0, | ||
IBCPacketCommitmentNotFound(ICS24Host.packetCommitmentPathCalldata(packet.sourceChannel, packet.sequence)) | ||
); | ||
|
||
delete commitments[path]; | ||
return commitment; | ||
|
@@ -63,23 +63,25 @@ contract IBCStore is IIBCStore, IICS24HostErrors, Ownable { | |
/// @inheritdoc IIBCStore | ||
function setPacketReceipt(IICS26RouterMsgs.Packet memory packet) public onlyOwner { | ||
bytes32 path = ICS24Host.packetReceiptCommitmentKeyCalldata(packet.destChannel, packet.sequence); | ||
if (commitments[path] != 0) { | ||
revert IBCPacketReceiptAlreadyExists( | ||
require( | ||
commitments[path] == 0, | ||
IBCPacketReceiptAlreadyExists( | ||
ICS24Host.packetReceiptCommitmentPathCalldata(packet.destChannel, packet.sequence) | ||
); | ||
} | ||
) | ||
); | ||
|
||
commitments[path] = ICS24Host.PACKET_RECEIPT_SUCCESSFUL_KECCAK256; | ||
} | ||
|
||
/// @inheritdoc IIBCStore | ||
function commitPacketAcknowledgement(IICS26RouterMsgs.Packet memory packet, bytes[] memory acks) public onlyOwner { | ||
bytes32 path = ICS24Host.packetAcknowledgementCommitmentKeyCalldata(packet.destChannel, packet.sequence); | ||
if (commitments[path] != 0) { | ||
revert IBCPacketAcknowledgementAlreadyExists( | ||
require( | ||
commitments[path] == 0, | ||
IBCPacketAcknowledgementAlreadyExists( | ||
ICS24Host.packetAcknowledgementCommitmentPathCalldata(packet.destChannel, packet.sequence) | ||
); | ||
} | ||
) | ||
); | ||
|
||
bytes32 commitment = ICS24Host.packetAcknowledgementCommitmentBytes32(acks); | ||
emit AckCommitted(path, commitment); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand why this one is necessary right now, but I created an issue to re-introduce this one as soon as this is fixed in solhint: #109