aligned_layer
aligned_layer copied to clipboard
feat: auto lock when user deposits funds
Description
- This PR addresses an issue where user balances remained unlocked indefinitely after the first time
withdrawwas called. This meant that once a user's funds were unlocked when withdrawing, they remained in an unlocked state permanently, even after the initial unlock period had passed. To solve this, after the funds are withdrawn, the unlockBlock value is reset to 0 to lock the user's account again.
To Test
- Change the
UNLOCK_BLOCK_COUNTconstant inBatcherPaymentServiceto something smaller just to test, like 5 blocks. - Run
make anvil_deploy_aligned_contracts. - Run
make anvil_start_with_block_time. - First, fund the batcher with anvil's 6th address:
cast send 0x7969c5eD335650692Bc04293B07F5BF2e7A673C0 --value 1ether --private-key 0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e
- Then,
unlockthe funds:
cast send 0x7969c5eD335650692Bc04293B07F5BF2e7A673C0 "unlock()" --rpc-url http://localhost:8545 --private-key 0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e
- Then, call
withdraw:
cast send 0x7969c5eD335650692Bc04293B07F5BF2e7A673C0 "withdraw(uint256)" 100 --rpc-url http://localhost:8545 --private-key 0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e
- Finally, call
withdrawagain and it should tell you that the funds are locked.