diff --git a/src/testing/WormholeRelayer/DeliveryInstructionDecoder.sol b/src/testing/WormholeRelayer/DeliveryInstructionSerde.sol similarity index 87% rename from src/testing/WormholeRelayer/DeliveryInstructionDecoder.sol rename to src/testing/WormholeRelayer/DeliveryInstructionSerde.sol index 5caf71d..f9dd02c 100644 --- a/src/testing/WormholeRelayer/DeliveryInstructionDecoder.sol +++ b/src/testing/WormholeRelayer/DeliveryInstructionSerde.sol @@ -42,6 +42,30 @@ struct DeliveryOverride { bytes32 redeliveryHash; } +function encode(DeliveryInstruction memory strct) + pure + returns (bytes memory encoded) +{ + encoded = abi.encodePacked( + PAYLOAD_ID_DELIVERY_INSTRUCTION, + strct.targetChain, + strct.targetAddress, + encodeBytes(strct.payload), + strct.requestedReceiverValue, + strct.extraReceiverValue + ); + encoded = abi.encodePacked( + encoded, + encodeBytes(strct.encodedExecutionInfo), + strct.refundChain, + strct.refundAddress, + strct.refundDeliveryProvider, + strct.sourceDeliveryProvider, + strct.senderAddress, + encodeMessageKeyArray(strct.messageKeys) + ); +} + function decodeDeliveryInstruction( bytes memory encoded ) pure returns (DeliveryInstruction memory strct) { @@ -63,6 +87,22 @@ function decodeDeliveryInstruction( encoded.checkLength(offset); } +function encode(RedeliveryInstruction memory strct) + pure + returns (bytes memory encoded) +{ + bytes memory vaaKey = abi.encodePacked(VAA_KEY_TYPE, encodeVaaKey(strct.deliveryVaaKey)); + encoded = abi.encodePacked( + PAYLOAD_ID_REDELIVERY_INSTRUCTION, + vaaKey, + strct.targetChain, + strct.newRequestedReceiverValue, + encodeBytes(strct.newEncodedExecutionInfo), + strct.newSourceDeliveryProvider, + strct.newSenderAddress + ); +} + function decodeRedeliveryInstruction( bytes memory encoded ) pure returns (RedeliveryInstruction memory strct) { diff --git a/src/testing/WormholeRelayer/MockOffchainRelayer.sol b/src/testing/WormholeRelayer/MockOffchainRelayer.sol index 75c9469..68abfc7 100644 --- a/src/testing/WormholeRelayer/MockOffchainRelayer.sol +++ b/src/testing/WormholeRelayer/MockOffchainRelayer.sol @@ -14,7 +14,7 @@ import {CCTPMessageLib} from "wormhole-sdk/WormholeRelayer/CCTPBase.sol"; import {VM_ADDRESS} from "wormhole-sdk/testing/Constants.sol"; import "wormhole-sdk/testing/WormholeOverride.sol"; import "wormhole-sdk/testing/CctpOverride.sol"; -import "wormhole-sdk/testing/WormholeRelayer/DeliveryInstructionDecoder.sol"; +import "wormhole-sdk/testing/WormholeRelayer/DeliveryInstructionSerde.sol"; import "wormhole-sdk/testing/WormholeRelayer/ExecutionParameters.sol"; using BytesParsing for bytes; diff --git a/src/testing/WormholeRelayerTest.sol b/src/testing/WormholeRelayerTest.sol index 5f7613d..7ced3d4 100644 --- a/src/testing/WormholeRelayerTest.sol +++ b/src/testing/WormholeRelayerTest.sol @@ -15,7 +15,7 @@ import "./UsdcDealer.sol"; import "./WormholeOverride.sol"; import "./CctpOverride.sol"; import "./ERC20Mock.sol"; -import "./WormholeRelayer/DeliveryInstructionDecoder.sol"; +import "./WormholeRelayer/DeliveryInstructionSerde.sol"; import "./WormholeRelayer/ExecutionParameters.sol"; import "./WormholeRelayer/MockOffchainRelayer.sol";