File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed
substrate/frame/revive/src Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 1+ title: '[pallet-revive] Allows setting evm balance for non-existing account'
2+ doc:
3+ - audience: Runtime User
4+ description: |-
5+ Allows calling set_evm_balance for a non-existing account on pallet-revive.
6+
7+ crates:
8+ - name: pallet-revive
9+ bump: minor
Original file line number Diff line number Diff line change @@ -1645,8 +1645,12 @@ impl<T: Config> Pallet<T> {
16451645 . map_err ( |_| <Error < T > >:: BalanceConversionFailed ) ?;
16461646 let account_id = T :: AddressMapper :: to_account_id ( & address) ;
16471647 T :: Currency :: set_balance ( & account_id, balance) ;
1648- AccountInfoOf :: < T > :: mutate ( address, |account| {
1649- account. as_mut ( ) . map ( |a| a. dust = dust) ;
1648+ AccountInfoOf :: < T > :: mutate ( & address, |account| {
1649+ if let Some ( account) = account {
1650+ account. dust = dust;
1651+ } else {
1652+ * account = Some ( AccountInfo { dust, ..Default :: default ( ) } ) ;
1653+ }
16501654 } ) ;
16511655
16521656 Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -201,6 +201,17 @@ fn eth_call_transfer_with_dust_works() {
201201 } ) ;
202202}
203203
204+ #[ test]
205+ fn set_evm_balance_for_eoa_works ( ) {
206+ ExtBuilder :: default ( ) . existential_deposit ( 200 ) . build ( ) . execute_with ( || {
207+ let native_with_dust = BalanceWithDust :: new_unchecked :: < Test > ( 100 , 10 ) ;
208+ let evm_balance = Pallet :: < Test > :: convert_native_to_evm ( native_with_dust) ;
209+ let _ = Pallet :: < Test > :: set_evm_balance ( & ALICE_ADDR , evm_balance) ;
210+
211+ assert_eq ! ( Pallet :: <Test >:: evm_balance( & ALICE_ADDR ) , evm_balance) ;
212+ } ) ;
213+ }
214+
204215#[ test]
205216fn set_evm_balance_works ( ) {
206217 let ( binary, _) = compile_module ( "dummy" ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments