diff --git a/CHANGELOG.md b/CHANGELOG.md index 39e5dd8dd2..60d03b7855 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (rpc) [#955](https://github.com/tharsis/ethermint/pull/955) Fix websocket server push duplicated messages to subscriber. * (ante) [tharsis#964](https://github.com/tharsis/ethermint/pull/964) add NewInfiniteGasMeterWithLimit for storing the user provided gas limit. Fixes block's consumed gas calculation in the block creation phase. (Modified to only fix check tx mode to avoid breaking consensus). * (evm) [\#529](https://github.com/tharsis/ethermint/issues/529) support return value on trace tx response. +* (rpc) [tharsis#1006](https://github.com/tharsis/ethermint/pull/1006) Use `string` as the parameters type to correct ambiguous results. ## [v0.7.2-cronos-6] - 2021-12-17 diff --git a/rpc/ethereum/namespaces/web3/api.go b/rpc/ethereum/namespaces/web3/api.go index 54af350db6..04fbee76bc 100644 --- a/rpc/ethereum/namespaces/web3/api.go +++ b/rpc/ethereum/namespaces/web3/api.go @@ -21,6 +21,6 @@ func (a *PublicAPI) ClientVersion() string { } // Sha3 returns the keccak-256 hash of the passed-in input. -func (a *PublicAPI) Sha3(input hexutil.Bytes) hexutil.Bytes { - return crypto.Keccak256(input) +func (a *PublicAPI) Sha3(input string) hexutil.Bytes { + return crypto.Keccak256(hexutil.Bytes(input)) } diff --git a/tests/e2e/integration_test.go b/tests/e2e/integration_test.go index afcc1bd61a..4d7d94adc0 100644 --- a/tests/e2e/integration_test.go +++ b/tests/e2e/integration_test.go @@ -53,3 +53,37 @@ func (s *IntegrationTestSuite) TestChainID() { func TestIntegrationTestSuite(t *testing.T) { suite.Run(t, new(IntegrationTestSuite)) } + +func (s *IntegrationTestSuite) TestWeb3Sha3() { + testCases := []struct { + name string + arg string + expected string + }{ + { + "normal input", + "0xabcd1234567890", + "0x23e7488ec9097f0126b0338926bfaeb5264b01cb162a0fd4a6d76e1081c2b24a", + }, + { + "0x case", + "0x", + "0x39bef1777deb3dfb14f64b9f81ced092c501fee72f90e93d03bb95ee89df9837", + }, + { + "empty string case", + "", + "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + var result string + + err := s.rpcClient.Call(&result, "web3_sha3", tc.arg) + s.Require().NoError(err) + s.Require().Equal(tc.expected, result) + }) + } +}