From 9e3c1860740fb6b5b33aef0b37b43eebb2e82d90 Mon Sep 17 00:00:00 2001 From: nonergodic Date: Thu, 9 May 2024 01:22:58 -0700 Subject: [PATCH] enable decodeDeposit from bytes directly --- src/libraries/WormholeCctpMessages.sol | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/libraries/WormholeCctpMessages.sol b/src/libraries/WormholeCctpMessages.sol index 8e74e4e..ef4841d 100644 --- a/src/libraries/WormholeCctpMessages.sol +++ b/src/libraries/WormholeCctpMessages.sol @@ -136,6 +136,7 @@ library WormholeCctpMessages { ); } + // left in for backwards compatibility function decodeDeposit(IWormhole.VM memory vaa) internal pure @@ -150,7 +151,23 @@ library WormholeCctpMessages { bytes memory payload ) { - bytes memory encoded = vaa.payload; + return decodeDeposit(vaa.payload); + } + + function decodeDeposit(bytes memory encoded) + internal + pure + returns ( + bytes32 token, + uint256 amount, + uint32 sourceCctpDomain, + uint32 targetCctpDomain, + uint64 cctpNonce, + bytes32 burnSource, + bytes32 mintRecipient, + bytes memory payload + ) + { uint256 offset = _checkPayloadId(encoded, 0, DEPOSIT); (token, offset) = encoded.asBytes32Unchecked(offset);