Skip to content

Commit

Permalink
require strong type checking of Escrow in Dispatcher contract
Browse files Browse the repository at this point in the history
  • Loading branch information
WenweiX committed Aug 18, 2023
1 parent 45dabd9 commit 11ed2d2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions contracts/Dispatcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ contract Dispatcher is IbcDispatcher, Ownable {
//
// methods
//
constructor(ZKMintVerifier _verifier, address payable _escrow, string memory initPortPrefix) {
constructor(ZKMintVerifier _verifier, Escrow _escrow, string memory initPortPrefix) {
verifier = _verifier;
escrow = Escrow(_escrow);
require(_escrow != address(0), 'Escrow cannot be zero address');
// require(_escrow != address(0), 'Escrow cannot be zero address');
escrow = _escrow;

// initialize portPrefix
portPrefix = initPortPrefix;
Expand Down
6 changes: 3 additions & 3 deletions test/Dispatcher.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ contract Base is Test {
);
Height ZERO_HEIGHT = Height(0, 0);
uint64 maxTimeout = UINT64_MAX;
address payable escrow = payable(new Escrow());
Escrow escrow = new Escrow();

// Proofs from Polymer chain, to verify packet or channel state on Polymer
Proof emptyProof;
Expand Down Expand Up @@ -491,7 +491,7 @@ contract DispatcherSendPacketTest is ChannelOpenTestBase {
function test_success() public {
bytes memory packet = abi.encodePacked(payload);
for (uint64 index = 0; index < 3; index++) {
uint256 balance = escrow.balance;
uint256 balance = address(escrow).balance;
vm.expectEmit(true, true, true, true);
uint64 packetSeq = index + 1;
emit SendPacket(address(mars), channelId, packet, packetSeq, timeoutTimestamp, fee);
Expand All @@ -502,7 +502,7 @@ contract DispatcherSendPacketTest is ChannelOpenTestBase {
timeoutTimestamp,
fee
);
assertEq(escrow.balance - balance, Ibc.calcEscrowFee(fee));
assertEq(address(escrow).balance - balance, Ibc.calcEscrowFee(fee));

// query escrowed fee per packet
PacketFee memory packetFee = dispatcher.getTotalPacketFees(address(mars), channelId, packetSeq);
Expand Down
4 changes: 2 additions & 2 deletions test/fee.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ contract FeeTest is PacketSenderTest {
assertEq(address(forwardRelayerPayee).balance, fee.recvFee + balanceForwardRelayer1);
assertEq(address(reverseRelayerPayee).balance, fee.ackFee + balanceReverseRelayer1);
assertEq(refundPayee.balance, Ibc.ackRefundAmount(fee) + balanceRefund1);
assertEq(escrow.balance, 0);
assertEq(address(escrow).balance, 0);

// cannot claim ack fee twice
vm.expectRevert();
Expand All @@ -118,7 +118,7 @@ contract FeeTest is PacketSenderTest {
// no forward relayer is invovled in timeout case
assertEq(address(forwardRelayerPayee).balance, 0);
assertEq(refundPayee.balance, Ibc.timeoutRefundAmount(fee) + balanceRefund1);
assertEq(escrow.balance, 0);
assertEq(address(escrow).balance, 0);

// cannot claim timeout fee twice
vm.expectRevert();
Expand Down

0 comments on commit 11ed2d2

Please sign in to comment.