fix(types): account type method (#1118)

* fix account type method

* update changelog
This commit is contained in:
crypto-facs 2022-06-08 17:53:07 +02:00 committed by GitHub
parent b567624d6a
commit b3fa23e6cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View File

@ -38,6 +38,12 @@ Ref: https://keepachangelog.com/en/1.0.0/
## Unreleased ## Unreleased
### Bug Fixes
* (evm) [tharsis#1118](https://github.com/tharsis/ethermint/pull/1118) Fix `Type()` `Account` method `EmptyCodeHash` comparison
## [v0.16.0] - 2022-06-06
### State Machine Breaking ### State Machine Breaking
* (feemarket) [tharsis#1105](https://github.com/tharsis/ethermint/pull/1105) Update `BaseFee` calculation based on `GasWanted` instead of `GasUsed`. * (feemarket) [tharsis#1105](https://github.com/tharsis/ethermint/pull/1105) Update `BaseFee` calculation based on `GasWanted` instead of `GasUsed`.

View File

@ -75,7 +75,7 @@ func (acc *EthAccount) SetCodeHash(codeHash common.Hash) error {
// Type returns the type of Ethereum Account (EOA or Contract) // Type returns the type of Ethereum Account (EOA or Contract)
func (acc EthAccount) Type() int8 { func (acc EthAccount) Type() int8 {
if bytes.Equal(emptyCodeHash, common.Hex2Bytes(acc.CodeHash)) { if bytes.Equal(emptyCodeHash, common.HexToHash(acc.CodeHash).Bytes()) {
return AccountTypeEOA return AccountTypeEOA
} }
return AccountTypeContract return AccountTypeContract

View File

@ -51,8 +51,8 @@ func TestAccountTestSuite(t *testing.T) {
} }
func (suite *AccountTestSuite) TestAccountType() { func (suite *AccountTestSuite) TestAccountType() {
suite.account.CodeHash = common.Bytes2Hex(crypto.Keccak256(nil)) suite.account.CodeHash = common.BytesToHash(crypto.Keccak256(nil)).Hex()
suite.Require().Equal(types.AccountTypeEOA, suite.account.Type()) suite.Require().Equal(types.AccountTypeEOA, suite.account.Type())
suite.account.CodeHash = common.Bytes2Hex(crypto.Keccak256([]byte{1, 2, 3})) suite.account.CodeHash = common.BytesToHash(crypto.Keccak256([]byte{1, 2, 3})).Hex()
suite.Require().Equal(types.AccountTypeContract, suite.account.Type()) suite.Require().Equal(types.AccountTypeContract, suite.account.Type())
} }