Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
fix account type method
Browse files Browse the repository at this point in the history
  • Loading branch information
crypto-facs committed Jun 8, 2022
1 parent b567624 commit d5ad136
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion types/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (acc *EthAccount) SetCodeHash(codeHash common.Hash) error {

// Type returns the type of Ethereum Account (EOA or Contract)
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 AccountTypeContract
Expand Down
4 changes: 2 additions & 2 deletions types/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func TestAccountTestSuite(t *testing.T) {
}

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.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())
}

0 comments on commit d5ad136

Please sign in to comment.