From 7582f9b4e9b4bbff5f17e6d9f8824714689afe72 Mon Sep 17 00:00:00 2001 From: Unique-Divine Date: Tue, 26 Nov 2024 09:12:30 +0530 Subject: [PATCH] fix(precompile-funtoken.go): Fixes a bug where the err != nil check is missing in the bankBalance precompile method --- CHANGELOG.md | 3 ++- evm-e2e/justfile | 3 +++ x/evm/precompile/funtoken.go | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85be6188d..1a684bd47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -101,7 +101,8 @@ tests for race conditions within funtoken precompile - [#2101](https://github.com/NibiruChain/nibiru/pull/2101) - fix(evm): tx receipt proper marshalling - [#2105](https://github.com/NibiruChain/nibiru/pull/2105) - test(evm): precompile call with revert - [#2107](https://github.com/NibiruChain/nibiru/pull/2107) - -feat(evm-funtoken-precompile): Implement methods: balance, bankBalance, whoAmI +- [#2xxx](https://github.com/NibiruChain/nibiru/pull/2xxx) -feat(evm-funtoken-precompile): Implement methods: balance, bankBalance, whoAmI +fix(precompile-funtoken.go): Fixes a bug where the err != nil check is missing in the bankBalance precompile method #### Nibiru EVM | Before Audit 1 - 2024-10-18 diff --git a/evm-e2e/justfile b/evm-e2e/justfile index d8153d37e..042d02dc2 100644 --- a/evm-e2e/justfile +++ b/evm-e2e/justfile @@ -19,3 +19,6 @@ test: # Format fmt: npm run format + +gen-types: + npx hardhat typechain diff --git a/x/evm/precompile/funtoken.go b/x/evm/precompile/funtoken.go index 7aa22af09..4407b26d7 100644 --- a/x/evm/precompile/funtoken.go +++ b/x/evm/precompile/funtoken.go @@ -118,6 +118,7 @@ func (p precompileFunToken) sendToBank( erc20, amount, to, err := p.parseArgsSendToBank(args) if err != nil { + err = ErrInvalidArgs(err) return } @@ -376,6 +377,10 @@ func (p precompileFunToken) bankBalance( } addrEth, addrBech32, bankDenom, err := p.parseArgsBankBalance(args) + if err != nil { + err = ErrInvalidArgs(err) + return + } bankBal := p.evmKeeper.Bank.GetBalance(ctx, addrBech32, bankDenom).Amount.BigInt() return method.Outputs.Pack([]any{ @@ -455,7 +460,8 @@ func (p precompileFunToken) whoAmI( addrEth, addrBech32, err := p.parseArgsWhoAmI(args) if err != nil { - return bz, err + err = ErrInvalidArgs(err) + return } return method.Outputs.Pack([]any{