Uses `abi.encodeCall` to typecheck some encoded calls.
This commit is contained in:
parent
f9662f12c8
commit
a41490cc38
|
@ -4,6 +4,7 @@
|
|||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../libraries/external/BytesLib.sol";
|
||||
import "../interfaces/IWormholeReceiver.sol";
|
||||
|
||||
import "./CoreRelayerGovernance.sol";
|
||||
import "./CoreRelayerStructs.sol";
|
||||
|
@ -409,7 +410,7 @@ contract CoreRelayer is CoreRelayerGovernance {
|
|||
(bool success,) = fromWormholeFormat(internalInstruction.targetAddress).call{
|
||||
gas: internalInstruction.executionParameters.gasLimit,
|
||||
value: internalInstruction.receiverValueTarget
|
||||
}(abi.encodeWithSignature("receiveWormholeMessages(bytes[],bytes[])", encodedVMs, new bytes[](0)));
|
||||
}(abi.encodeCall(IWormholeReceiver.receiveWormholeMessages, (encodedVMs, new bytes[](0))));
|
||||
|
||||
uint256 postGas = gasleft();
|
||||
// There's no easy way to measure the exact cost of the CALL instruction.
|
||||
|
|
|
@ -78,14 +78,16 @@ contract XmintHub is ERC20, IWormholeReceiver {
|
|||
function bridgeTokens(uint16 remoteChain, bytes memory payload, uint256 amount) internal {
|
||||
(bool success, bytes memory data) = address(token_bridge).call{value: amount + core_bridge.messageFee()}(
|
||||
//token, amount, receipientChain, recipientAddress, nonce, payload
|
||||
abi.encodeWithSignature(
|
||||
"transferTokensWithPayload(address,uint256,uint16,bytes32,nonce,bytes memory)",
|
||||
address(this),
|
||||
amount,
|
||||
remoteChain,
|
||||
trustedContracts[remoteChain],
|
||||
nonce,
|
||||
payload
|
||||
abi.encodeCall(
|
||||
ITokenBridge.transferTokensWithPayload,
|
||||
(
|
||||
address(this),
|
||||
amount,
|
||||
remoteChain,
|
||||
trustedContracts[remoteChain],
|
||||
nonce,
|
||||
payload
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -55,12 +55,14 @@ contract XmintSpoke is IWormholeReceiver {
|
|||
uint256 bridgeAmount = msg.value - deliveryFeeBuffer - core_bridge.messageFee();
|
||||
|
||||
(bool success, bytes memory data) = address(token_bridge).call{value: bridgeAmount + core_bridge.messageFee()}(
|
||||
abi.encodeWithSignature(
|
||||
"wrapAndTransferETHWithPayload(unit16,bytes32,uint32,bytes)",
|
||||
hub_contract_chain,
|
||||
hub_contract_address,
|
||||
nonce,
|
||||
abi.encode(core_relayer.toWormholeFormat(msg.sender))
|
||||
abi.encodeCall(
|
||||
ITokenBridge.wrapAndTransferETHWithPayload,
|
||||
(
|
||||
hub_contract_chain,
|
||||
hub_contract_address,
|
||||
nonce,
|
||||
abi.encode(core_relayer.toWormholeFormat(msg.sender))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -132,10 +132,12 @@ contract TestCoreRelayer is Test {
|
|||
RelayProviderImplementation relayProviderImplementation = new RelayProviderImplementation();
|
||||
RelayProviderProxy myRelayProvider = new RelayProviderProxy(
|
||||
address(relayProviderSetup),
|
||||
abi.encodeWithSelector(
|
||||
bytes4(keccak256("setup(address,uint16)")),
|
||||
address(relayProviderImplementation),
|
||||
chainId
|
||||
abi.encodeCall(
|
||||
RelayProviderSetup.setup,
|
||||
(
|
||||
address(relayProviderImplementation),
|
||||
chainId
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -150,15 +152,17 @@ contract TestCoreRelayer is Test {
|
|||
CoreRelayerImplementation coreRelayerImplementation = new CoreRelayerImplementation();
|
||||
CoreRelayerProxy myCoreRelayer = new CoreRelayerProxy(
|
||||
address(coreRelayerSetup),
|
||||
abi.encodeWithSelector(
|
||||
bytes4(keccak256("setup(address,uint16,address,address,uint16,bytes32,uint256)")),
|
||||
address(coreRelayerImplementation),
|
||||
chainId,
|
||||
wormhole,
|
||||
defaultRelayProvider,
|
||||
uint16(1), // governance chain id
|
||||
0x0000000000000000000000000000000000000000000000000000000000000004, // governance contract
|
||||
block.chainid
|
||||
abi.encodeCall(
|
||||
CoreRelayerSetup.setup,
|
||||
(
|
||||
address(coreRelayerImplementation),
|
||||
chainId,
|
||||
wormhole,
|
||||
defaultRelayProvider,
|
||||
uint16(1), // governance chain id
|
||||
0x0000000000000000000000000000000000000000000000000000000000000004, // governance contract
|
||||
block.chainid
|
||||
)
|
||||
)
|
||||
);
|
||||
coreRelayer = IWormholeRelayer(address(myCoreRelayer));
|
||||
|
|
|
@ -22,10 +22,12 @@ contract TestRelayProvider is Test {
|
|||
RelayProviderImplementation relayProviderImplementation = new RelayProviderImplementation();
|
||||
RelayProviderProxy myRelayProvider = new RelayProviderProxy(
|
||||
address(relayProviderSetup),
|
||||
abi.encodeWithSelector(
|
||||
bytes4(keccak256("setup(address,uint16)")),
|
||||
address(relayProviderImplementation),
|
||||
TEST_ORACLE_CHAIN_ID
|
||||
abi.encodeCall(
|
||||
RelayProviderSetup.setup,
|
||||
(
|
||||
address(relayProviderImplementation),
|
||||
TEST_ORACLE_CHAIN_ID
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue