Skip to content

Commit

Permalink
fix: use contract as refund address
Browse files Browse the repository at this point in the history
  • Loading branch information
redlarva committed Nov 2, 2023
1 parent 65e5f00 commit e2c79a7
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions contracts/evm/contracts/adapters/LayerZeroAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ contract LayerZeroAdapter is ILayerZeroAdapter, Initializable, ILayerZeroReceive
mapping(uint16 => string) private networkIds;
mapping(string => bytes) private adapterParams;
mapping(string => bytes) private remoteEndpoint;
mapping(bytes32 => bool) public seenDeliveryVaaHashes;
address private layerZeroEndpoint;
address private xCall;
address private owner;
Expand Down Expand Up @@ -132,7 +131,7 @@ contract LayerZeroAdapter is ILayerZeroAdapter, Initializable, ILayerZeroReceive
chainIds[_to],
remoteEndpoint[_to],
abi.encodePacked(_msg),
payable(tx.origin),
payable(address(this)),
address(0x0),
adapterParams[_to]
);
Expand All @@ -152,11 +151,8 @@ contract LayerZeroAdapter is ILayerZeroAdapter, Initializable, ILayerZeroReceive
bytes memory payload
) public override {
require(msg.sender == layerZeroEndpoint, "Invalid endpoint caller");
bytes32 hash = keccak256(abi.encodePacked(payload, _nonce));
require(!seenDeliveryVaaHashes[hash], "Message already processed");
string memory nid = networkIds[sourceChain];
require(keccak256(_srcAddress) == keccak256(abi.encodePacked(remoteEndpoint[nid])), "Source address mismatched");
seenDeliveryVaaHashes[hash] = true;
ICallService(xCall).handleMessage(nid, payload);
}

Expand All @@ -174,7 +170,7 @@ contract LayerZeroAdapter is ILayerZeroAdapter, Initializable, ILayerZeroReceive
chainIds[resp.targetNetwork],
remoteEndpoint[resp.targetNetwork],
abi.encodePacked(resp.msg),
payable(msg.sender),
payable(address(this)),
address(0x0),
adapterParams[resp.targetNetwork]
);
Expand All @@ -198,4 +194,6 @@ contract LayerZeroAdapter is ILayerZeroAdapter, Initializable, ILayerZeroReceive
}
return adminAddress;
}

fallback() external payable {}
}

0 comments on commit e2c79a7

Please sign in to comment.