Skip to content

Commit 9fe30c2

Browse files
committed
feat: verify_l1_address
1 parent fdaf990 commit 9fe30c2

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
pub mod Errors {
22
pub const THRESHOLD_TOO_SMALL: felt252 = 'Threshold is too small';
3+
pub const VERIFY_L1_FAILED: felt252 = 'Verify L1 recipient failed.';
4+
pub const L1_RECIPIENT_NOT_VERIFIED: felt252 = 'L1 recipient not verified.';
35
}

packages/usdc_migration/src/usdc_migration.cairo

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ pub mod USDCMigration {
4343
/// The exact amount of legacy token sent to L1 in a single withdraw action.
4444
/// Must be a value from FIXED_BATCH_SIZES.
4545
batch_size: u256,
46+
/// Indicates if L1 recipient address was verified.
47+
l1_recipient_verified: bool,
4648
}
4749

4850
#[event]
@@ -143,6 +145,16 @@ pub mod USDCMigration {
143145
}
144146
}
145147

148+
/// Verify the L1 recipient address is a reachable address.
149+
// TODO: Test.
150+
#[l1_handler]
151+
fn verify_l1_recipient(ref self: ContractState, from_address: felt252) {
152+
// TODO: Not panic here?
153+
assert(from_address == self.l1_recipient.read().into(), Errors::VERIFY_L1_FAILED);
154+
self.l1_recipient_verified.write(true);
155+
// TODO: Emit event?
156+
}
157+
146158
#[generate_trait]
147159
impl USDCMigrationInternalImpl of USDCMigrationInternalTrait {
148160
fn _swap(
@@ -167,7 +179,9 @@ pub mod USDCMigration {
167179
);
168180
}
169181

182+
// TODO: Catch error in tests in every function that calls this.
170183
fn _send_legacy_to_l1(self: @ContractState, amount: u256) {
184+
assert(self.l1_recipient_verified.read(), Errors::L1_RECIPIENT_NOT_VERIFIED);
171185
// TODO: implement this.
172186
// TODO: Event.
173187
return;

0 commit comments

Comments
 (0)