@@ -17,6 +17,7 @@ import {
17
17
export interface L2Claim {
18
18
claimSecret : Fr ;
19
19
claimAmount : Fr ;
20
+ messageHash : `0x${string } `;
20
21
}
21
22
22
23
function stringifyEthAddress ( address : EthAddress | Hex , name ?: string ) {
@@ -94,13 +95,17 @@ export class FeeJuicePortalManager {
94
95
95
96
this . logger . info ( 'Sending L1 Fee Juice to L2 to be claimed publicly' ) ;
96
97
const args = [ to . toString ( ) , amount , claimSecretHash . toString ( ) ] as const ;
98
+
99
+ const { result : messageHash } = await this . contract . simulate . depositToAztecPublic ( args ) ;
100
+
97
101
await this . publicClient . waitForTransactionReceipt ( {
98
102
hash : await this . contract . write . depositToAztecPublic ( args ) ,
99
103
} ) ;
100
104
101
105
return {
102
106
claimAmount : new Fr ( amount ) ,
103
107
claimSecret,
108
+ messageHash,
104
109
} ;
105
110
}
106
111
@@ -163,13 +168,34 @@ export class L1PortalManager {
163
168
164
169
await this . tokenManager . approve ( amount , this . contract . address , 'TokenPortal' ) ;
165
170
171
+ let messageHash : `0x${string } `;
172
+
166
173
if ( privateTransfer ) {
174
+ const secret = Fr . random ( ) ;
175
+ const secretHash = computeSecretHash ( secret ) ;
167
176
this . logger . info ( 'Sending L1 tokens to L2 to be claimed privately' ) ;
177
+ ( { result : messageHash } = await this . contract . simulate . depositToAztecPrivate ( [
178
+ secretHash . toString ( ) ,
179
+ amount ,
180
+ claimSecretHash . toString ( ) ,
181
+ ] ) ) ;
182
+
168
183
await this . publicClient . waitForTransactionReceipt ( {
169
- hash : await this . contract . write . depositToAztecPrivate ( [ Fr . ZERO . toString ( ) , amount , claimSecretHash . toString ( ) ] ) ,
184
+ hash : await this . contract . write . depositToAztecPrivate ( [
185
+ secretHash . toString ( ) ,
186
+ amount ,
187
+ claimSecretHash . toString ( ) ,
188
+ ] ) ,
170
189
} ) ;
190
+ this . logger . info ( `Redeem shield secret: ${ secret . toString ( ) } , secret hash: ${ secretHash . toString ( ) } ` ) ;
171
191
} else {
172
192
this . logger . info ( 'Sending L1 tokens to L2 to be claimed publicly' ) ;
193
+ ( { result : messageHash } = await this . contract . simulate . depositToAztecPublic ( [
194
+ to . toString ( ) ,
195
+ amount ,
196
+ claimSecretHash . toString ( ) ,
197
+ ] ) ) ;
198
+
173
199
await this . publicClient . waitForTransactionReceipt ( {
174
200
hash : await this . contract . write . depositToAztecPublic ( [ to . toString ( ) , amount , claimSecretHash . toString ( ) ] ) ,
175
201
} ) ;
@@ -178,6 +204,7 @@ export class L1PortalManager {
178
204
return {
179
205
claimAmount : new Fr ( amount ) ,
180
206
claimSecret,
207
+ messageHash,
181
208
} ;
182
209
}
183
210
}
0 commit comments