Skip to content

Commit

Permalink
finish and test WormholeOverride, fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nonergodic committed Sep 29, 2024
1 parent cdd6025 commit c0565c7
Show file tree
Hide file tree
Showing 11 changed files with 371 additions and 385 deletions.
5 changes: 1 addition & 4 deletions src/WormholeRelayer/CCTPAndTokenBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ abstract contract CCTPAndTokenSender is CCTPAndTokenBase {
USDC,
targetAddressBytes32
);
return MessageKey(
CCTPMessageLib.CCTP_KEY_TYPE,
abi.encodePacked(getCCTPDomain(wormhole.chainId()), nonce)
);
return MessageKey(CCTP_KEY_TYPE, abi.encodePacked(getCCTPDomain(wormhole.chainId()), nonce));
}

// Publishes a CCTP transfer of 'amount' of USDC
Expand Down
10 changes: 2 additions & 8 deletions src/WormholeRelayer/CCTPBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@ import "wormhole-sdk/Utils.sol";
import "./Base.sol";

library CCTPMessageLib {
// The second standardized key type is a CCTP Key
// representing a CCTP transfer of USDC
// The second standardized key type is a CCTP Key representing a CCTP transfer of USDC
// (on the IWormholeRelayer interface)

// Note - the default delivery provider only will relay CCTP transfers that were sent
// in the same transaction that this message was emitted!
// (This will always be the case if 'CCTPSender' is used)

uint8 constant CCTP_KEY_TYPE = 2;

// encoded using abi.encodePacked(domain, nonce)
struct CCTPKey {
uint32 domain;
Expand Down Expand Up @@ -117,10 +114,7 @@ abstract contract CCTPSender is CCTPBase {
USDC,
targetAddressBytes32
);
return MessageKey(
CCTPMessageLib.CCTP_KEY_TYPE,
abi.encodePacked(getCCTPDomain(wormhole.chainId()), nonce)
);
return MessageKey(CCTP_KEY_TYPE, abi.encodePacked(getCCTPDomain(wormhole.chainId()), nonce));
}

// Publishes a CCTP transfer of 'amount' of USDC
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/IWormholeRelayer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct VaaKey {

// 0-127 are reserved for standardized KeyTypes, 128-255 are for custom use
uint8 constant VAA_KEY_TYPE = 1;
uint8 constant CCTP_KEY_TYPE = 2;

struct MessageKey {
uint8 keyType; // 0-127 are reserved for standardized KeyTypes, 128-255 are for custom use
Expand Down
6 changes: 2 additions & 4 deletions src/testing/WormholeCctpSimulator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ contract WormholeCctpSimulator {
wormhole.setUpOverride();
messageTransmitter.setUpOverride();

foreignNonce = 0xBBBBBBBBBBBBBBBB;
foreignSequence = 0xAAAAAAAAAAAAAAAA;
foreignNonce = 0xBBBBBBBBBBBBBBBB;
//default value - can be overridden if desired
foreignCaller = 0xCA11E2000CA11E200CA11E200CA11E200CA11E200CA11E200CA11E2000CA11E2;

Expand Down Expand Up @@ -134,10 +133,9 @@ contract WormholeCctpSimulator {
(burnMsg, encodedCctpMessage, cctpAttestation) = _craftCctpTokenBurnMessage(amount);

//craft the associated VAA
(, encodedVaa) = wormhole.craftVaa(
encodedVaa = wormhole.craftVaa(
foreignChain,
foreignSender,
foreignSequence++,
WormholeCctpMessages.encodeDeposit(
burnMsg.burnToken,
amount,
Expand Down
Loading

0 comments on commit c0565c7

Please sign in to comment.