@@ -9,7 +9,7 @@ import {ITokenMinter} from "src/interfaces/ITokenMinter.sol";
9
9
import {ICircleIntegration} from "src/interfaces/ICircleIntegration.sol " ;
10
10
11
11
import {Utils} from "src/libraries/Utils.sol " ;
12
- import {Deposit, WormholeCctpMessages} from "src/libraries/WormholeCctpMessages.sol " ;
12
+ import {WormholeCctpMessages} from "src/libraries/WormholeCctpMessages.sol " ;
13
13
14
14
import {Governance} from "./Governance.sol " ;
15
15
import {
@@ -63,35 +63,39 @@ abstract contract Logic is ICircleIntegration, Governance {
63
63
{
64
64
require (evmChain () == block .chainid , "invalid evm chain " );
65
65
66
- uint16 chain;
67
- bytes32 emitter;
68
- bytes32 vaaHash;
69
- Deposit memory depositHeader;
70
- (chain, emitter, vaaHash, depositHeader, deposit.payload) =
71
- verifyVaaAndMintLegacy (params.cctpMessage, params.cctpAttestation, params.encodedVaa);
66
+ IWormhole.VM memory vaa;
67
+ (
68
+ vaa,
69
+ deposit.token,
70
+ deposit.amount,
71
+ deposit.sourceDomain,
72
+ deposit.targetDomain,
73
+ deposit.nonce,
74
+ deposit.fromAddress,
75
+ deposit.mintRecipient,
76
+ deposit.payload
77
+ ) = verifyVaaAndMintLegacy (params.cctpMessage, params.cctpAttestation, params.encodedVaa);
72
78
73
79
// NOTE: Reverting with Error(string) comes from the old implementation, so we preserve it.
74
- require (emitter != 0 && emitter == getRegisteredEmitters ()[chain], "unknown emitter " );
80
+ require (
81
+ vaa.emitterAddress != 0
82
+ && vaa.emitterAddress == getRegisteredEmitters ()[vaa.emitterChainId],
83
+ "unknown emitter "
84
+ );
75
85
76
86
mapping (bytes32 => bool ) storage consumedVaas = getConsumedVaas ();
77
87
78
88
// Revert if this message has been consumed already. This check is meant to prevent replay
79
89
// attacks, but it may not be necessary because the CCTP Message Transmitter already keeps
80
90
// track of used nonces.
81
91
// NOTE: Reverting with Error(string) comes from the old implementation, so we preserve it.
82
- require (! consumedVaas[vaaHash ], "message already consumed " );
92
+ require (! consumedVaas[vaa.hash ], "message already consumed " );
83
93
84
94
// Mark as consumed.
85
- consumedVaas[vaaHash ] = true ;
95
+ consumedVaas[vaa.hash ] = true ;
86
96
87
- // Set remaining deposit vars.
88
- deposit.token = depositHeader.token;
89
- deposit.amount = depositHeader.amount;
90
- deposit.sourceDomain = depositHeader.sourceCctpDomain;
91
- deposit.targetDomain = depositHeader.targetCctpDomain;
92
- deposit.nonce = depositHeader.cctpNonce;
93
- deposit.fromAddress = depositHeader.burnSource;
94
- deposit.mintRecipient = depositHeader.mintRecipient;
97
+ // Emit Redeemed event.
98
+ emit Redeemed (vaa.emitterChainId, vaa.emitterAddress, vaa.sequence);
95
99
}
96
100
97
101
// getters
@@ -116,18 +120,22 @@ abstract contract Logic is ICircleIntegration, Governance {
116
120
pure
117
121
returns (DepositWithPayload memory deposit )
118
122
{
119
- Deposit memory depositHeader;
120
- (depositHeader, deposit.payload) = encoded.decodeDepositWithPayload (
121
- false // revertCustomErrors
122
- );
123
-
124
- deposit.token = depositHeader.token;
125
- deposit.amount = depositHeader.amount;
126
- deposit.sourceDomain = depositHeader.sourceCctpDomain;
127
- deposit.targetDomain = depositHeader.targetCctpDomain;
128
- deposit.nonce = depositHeader.cctpNonce;
129
- deposit.fromAddress = depositHeader.burnSource;
130
- deposit.mintRecipient = depositHeader.mintRecipient;
123
+ // This is a hack to get around using the decodeDeposit method. This is not a real VM
124
+ // obviously.
125
+ //
126
+ // Plus, this getter should never be used in practice.
127
+ IWormhole.VM memory fakeVaa;
128
+ fakeVaa.payload = encoded;
129
+ (
130
+ deposit.token,
131
+ deposit.amount,
132
+ deposit.sourceDomain,
133
+ deposit.targetDomain,
134
+ deposit.nonce,
135
+ deposit.fromAddress,
136
+ deposit.mintRecipient,
137
+ deposit.payload
138
+ ) = fakeVaa.decodeDeposit ();
131
139
}
132
140
133
141
/// @inheritdoc ICircleIntegration
@@ -136,15 +144,15 @@ abstract contract Logic is ICircleIntegration, Governance {
136
144
pure
137
145
returns (bytes memory encoded )
138
146
{
139
- encoded = Deposit ({
140
- token: message.token ,
141
- amount: message.amount ,
142
- sourceCctpDomain: message.sourceDomain ,
143
- targetCctpDomain: message.targetDomain ,
144
- cctpNonce: message.nonce ,
145
- burnSource: message.fromAddress ,
146
- mintRecipient: message.mintRecipient
147
- }). encodeWithPayload (message.payload );
147
+ encoded = message.token. encodeDeposit (
148
+ message.amount ,
149
+ message.sourceDomain ,
150
+ message.targetDomain ,
151
+ message.nonce ,
152
+ message.fromAddress ,
153
+ message.mintRecipient ,
154
+ message.payload
155
+ );
148
156
}
149
157
150
158
/// @inheritdoc ICircleIntegration
0 commit comments