diff --git a/precompiles/bank/method_withdraw.go b/precompiles/bank/method_withdraw.go index 66df0ca05e..e0893b08c2 100644 --- a/precompiles/bank/method_withdraw.go +++ b/precompiles/bank/method_withdraw.go @@ -55,7 +55,7 @@ func (c *Contract) withdraw( return nil, err } - // Safety check: token has to be a valid whitelisted ZRC20 and not be paused. + // Safety check: token has to be a non-paused whitelisted ZRC20. if err := c.fungibleKeeper.IsValidZRC20(ctx, zrc20Addr); err != nil { return nil, &ptypes.ErrInvalidToken{ Got: zrc20Addr.String(), diff --git a/x/fungible/keeper/zrc20_unlock_token.go b/x/fungible/keeper/zrc20_unlock_token.go index d932e1bcd7..9d6243b2da 100644 --- a/x/fungible/keeper/zrc20_unlock_token.go +++ b/x/fungible/keeper/zrc20_unlock_token.go @@ -32,6 +32,14 @@ func (k Keeper) UnlockZRC20( return fmt.Errorf("zrc20 address cannot be zero") } + if err := k.IsValidZRC20(ctx, zrc20Address); err != nil { + return err + } + + if err := k.CheckFungibleZRC20Balance(ctx, zrc20ABI, zrc20Address, amount); err != nil { + return err + } + args := []interface{}{to, amount} res, err := k.CallEVM( ctx, diff --git a/x/fungible/types/keys.go b/x/fungible/types/keys.go index 777cfd7c41..7e81328c15 100644 --- a/x/fungible/types/keys.go +++ b/x/fungible/types/keys.go @@ -27,17 +27,11 @@ func KeyPrefix(p string) []byte { } var ( - ModuleAddress = authtypes.NewModuleAddress(ModuleName) - //ModuleAddressEVM common.EVMAddress + ModuleAddress = authtypes.NewModuleAddress(ModuleName) ModuleAddressEVM = common.BytesToAddress(ModuleAddress.Bytes()) AdminAddress = "zeta1rx9r8hff0adaqhr5tuadkzj4e7ns2ntg446vtt" ) -func init() { - //fmt.Printf("ModuleAddressEVM of %s: %s\n", ModuleName, ModuleAddressEVM.String()) - // 0x735b14BB79463307AAcBED86DAf3322B1e6226aB -} - const ( SystemContractKey = "SystemContract-value-" )