diff --git a/evm/src/contracts/CircleIntegration/Logic.sol b/evm/src/contracts/CircleIntegration/Logic.sol index 6a38fbb..b770b5c 100644 --- a/evm/src/contracts/CircleIntegration/Logic.sol +++ b/evm/src/contracts/CircleIntegration/Logic.sol @@ -30,15 +30,15 @@ abstract contract Logic is ICircleIntegration, Governance { bytes calldata payload ) public payable returns (uint64 wormholeSequence) { // Is the foreign Wormhole Circle Integration registered? - bytes32 targetCaller = getRegisteredEmitters()[transferParams.targetChain]; - require(targetCaller != 0, "target contract not registered"); + bytes32 destinationCaller = getRegisteredEmitters()[transferParams.targetChain]; + require(destinationCaller != 0, "target contract not registered"); // Approve the Token Messenger to spend tokens. setTokenMessengerApproval(transferParams.token, transferParams.amount); // Invoke Token Messenger to burn tokens and emit a CCTP token burn message. (wormholeSequence,) = burnAndPublish( - targetCaller, + destinationCaller, getChainToDomain()[transferParams.targetChain], transferParams.token, transferParams.amount, diff --git a/evm/src/contracts/WormholeCctpTokenMessenger.sol b/evm/src/contracts/WormholeCctpTokenMessenger.sol index 3d9e437..da71f68 100644 --- a/evm/src/contracts/WormholeCctpTokenMessenger.sol +++ b/evm/src/contracts/WormholeCctpTokenMessenger.sol @@ -15,8 +15,11 @@ import {WormholeCctpMessages} from "src/libraries/WormholeCctpMessages.sol"; /** * @notice A way to associate a CCTP token burn message with a Wormhole message. * @dev To construct the contract, the addresses to the Wormhole Core Bridge and CCTP Token - * Messenger must be provided. Using the CCTP Token Messenger, the Message Transmitter and Token - * Minter are derived. + * Messenger must be provided. Using the CCTP Token Messenger, the Message Transmitter and Token + * Minter are derived. + * + * NOTE: For more information on CCTP message formats, please refer to the following: + * https://developers.circle.com/stablecoins/docs/message-format. */ abstract contract WormholeCctpTokenMessenger { using Utils for address; @@ -35,7 +38,7 @@ abstract contract WormholeCctpTokenMessenger { error CallerNotMintRecipient(bytes32, bytes32); /** - * @dev The CCTP message's source domain, target domain and nonce must match the VAA's. + * @dev The CCTP message's source domain, destination domain and nonce must match the VAA's. * NOTE: This nonce is the one acting as the CCTP message sequence (and not the arbitrary one * specified when publishing Wormhole messages). */ @@ -98,7 +101,7 @@ abstract contract WormholeCctpTokenMessenger { /** * @dev Method to burn tokens via CCTP Token Messenger and publish a Wormhole message associated * with the CCTP Token Burn message. The Wormhole message encodes a `Deposit` (ID == 1), which - * has the same source domain, target domain and nonce as the CCTP Token Burn message. + * has the same source domain, destination domain and nonce as the CCTP Token Burn message. * * NOTE: This method does not protect against re-entrancy here because it relies on the CCTP * Token Messenger to protect against any possible re-entrancy. We are leaning on the fact that @@ -106,8 +109,8 @@ abstract contract WormholeCctpTokenMessenger { * burn (and in turn, mint on another network). */ function burnAndPublish( - bytes32 targetCaller, - uint32 targetCctpDomain, + bytes32 destinationCaller, + uint32 destinationCctpDomain, address token, uint256 amount, bytes32 mintRecipient, @@ -120,7 +123,7 @@ abstract contract WormholeCctpTokenMessenger { // Invoke Token Messenger to burn tokens and emit a CCTP token burn message. cctpNonce = _tokenMessenger.depositForBurnWithCaller( - amount, targetCctpDomain, mintRecipient, token, targetCaller + amount, destinationCctpDomain, mintRecipient, token, destinationCaller ); // Publish deposit message via Wormhole Core Bridge. @@ -129,7 +132,7 @@ abstract contract WormholeCctpTokenMessenger { token.encodeDeposit( amount, _localCctpDomain, // sourceCctpDomain - targetCctpDomain, + destinationCctpDomain, cctpNonce, msg.sender.toUniversalAddress(), // burnSource mintRecipient, @@ -167,14 +170,14 @@ abstract contract WormholeCctpTokenMessenger { // Decode the deposit message so we can match the Wormhole message with the CCTP message. uint32 sourceCctpDomain; - uint32 targetCctpDomain; + uint32 destinationCctpDomain; uint64 cctpNonce; bytes32 mintRecipient; ( token, amount, sourceCctpDomain, - targetCctpDomain, + destinationCctpDomain, cctpNonce, burnSource, mintRecipient, @@ -187,7 +190,7 @@ abstract contract WormholeCctpTokenMessenger { cctpAttestation, mintRecipient, sourceCctpDomain, - targetCctpDomain, + destinationCctpDomain, cctpNonce, token, true // revertCustomErrors @@ -212,7 +215,7 @@ abstract contract WormholeCctpTokenMessenger { bytes32 token, uint256 amount, uint32 sourceCctpDomain, - uint32 targetCctpDomain, + uint32 destinationCctpDomain, uint64 cctpNonce, bytes32 burnSource, bytes32 mintRecipient, @@ -230,7 +233,7 @@ abstract contract WormholeCctpTokenMessenger { token, amount, sourceCctpDomain, - targetCctpDomain, + destinationCctpDomain, cctpNonce, burnSource, mintRecipient, @@ -243,7 +246,7 @@ abstract contract WormholeCctpTokenMessenger { cctpAttestation, mintRecipient, sourceCctpDomain, - targetCctpDomain, + destinationCctpDomain, cctpNonce, token, false // revertCustomErrors @@ -289,7 +292,7 @@ abstract contract WormholeCctpTokenMessenger { bytes calldata cctpAttestation, bytes32 mintRecipient, uint32 vaaSourceCctpDomain, - uint32 vaaTargetCctpDomain, + uint32 vaaDestinationCctpDomain, uint64 vaaCctpNonce, bytes32 burnToken, bool revertCustomErrors @@ -306,7 +309,7 @@ abstract contract WormholeCctpTokenMessenger { // Confirm that the caller passed the correct message pair. { uint32 sourceDomain; - uint32 targetDomain; + uint32 destinationDomain; uint64 nonce; assembly ("memory-safe") { @@ -318,18 +321,18 @@ abstract contract WormholeCctpTokenMessenger { // Source domain is bytes 4..8, so shift 24 bytes to the right. sourceDomain := shr(192, ptr) - // Target domain is bytes 8..12, so shift 20 bytes to the right. - targetDomain := shr(160, ptr) + // Destination domain is bytes 8..12, so shift 20 bytes to the right. + destinationDomain := shr(160, ptr) // Nonce is bytes 12..20, so shift 12 bytes to the right. nonce := shr(96, ptr) } if ( - vaaSourceCctpDomain != sourceDomain || vaaTargetCctpDomain != targetDomain + vaaSourceCctpDomain != sourceDomain || vaaDestinationCctpDomain != destinationDomain || vaaCctpNonce != nonce ) { if (revertCustomErrors) { - revert CctpVaaMismatch(sourceDomain, targetDomain, nonce); + revert CctpVaaMismatch(sourceDomain, destinationDomain, nonce); } else { Utils.revertBuiltIn("invalid message pair"); }