Skip to content

Commit 36a5d2a

Browse files
doc: add comments excusing balance check verification (#115)
1 parent 13bdbf0 commit 36a5d2a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/token_migration/src/token_migration.cairo

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,16 @@ pub mod TokenMigration {
237237
// Swap `amount` of legacy token for new token.
238238
let from_balance_before = from_token.balance_of(token_supplier);
239239
from_token.transfer_from(sender: user, recipient: token_supplier, :amount);
240+
// Defensive check: transfer_from should panic on failure,
241+
// but verify balance change in case the token contract misbehaves.
240242
assert(
241243
from_balance_before + amount == from_token.balance_of(token_supplier),
242244
Errors::TRANSFER_FROM_CALLER_FAILED,
243245
);
244246
let to_balance_before = to_token.balance_of(token_supplier);
245247
to_token.transfer_from(sender: token_supplier, recipient: user, :amount);
248+
// Defensive check: transfer_from should panic on failure,
249+
// but verify balance change in case the token contract misbehaves.
246250
assert(
247251
to_balance_before - amount == to_token.balance_of(token_supplier),
248252
Errors::TRANSFER_TO_CALLER_FAILED,

0 commit comments

Comments
 (0)