Skip to content

Commit

Permalink
Merge pull request #40 from bnb-chain/develop
Browse files Browse the repository at this point in the history
release: prepare release for v1.0.0
  • Loading branch information
unclezoro authored Oct 7, 2023
2 parents e81a0d7 + a930c65 commit f491ebb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

## v1.0.0
This release includes 1 bugfix.

Bugfixes:
* [#36](https://github.com/bnb-chain/greenfield-cometbft/pull/36) fix: trim the prefix 0 for eth_chainId


## v0.0.3
This release includes the features and bugfixes in the v0.0.3 alpha versions and 1 new bugfix.

Expand Down
12 changes: 10 additions & 2 deletions rpc/jsonrpc/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,20 @@ func NewEthRPCSuccessResponse(id jsonrpcid, res interface{}, method string) RPCR
}

switch method {
// return hex string for eth_blockNumber, eth_chainId, eth_networkId, eth_getBalance
case EthBlockNumber, EthChainID, EthNetworkID, EthGetBalance:
// return hex string for eth_blockNumber, eth_networkId, eth_getBalance
case EthBlockNumber, EthNetworkID, EthGetBalance:
result, err = json.Marshal("0x" + hex.EncodeToString(bz))
if err != nil {
return RPCInternalError(id, fmt.Errorf("error decode response: %w", err))
}
// return hex string for eth_chainId
case EthChainID:
// metamask do not support the Hex signed 2's complement, need to trim the prefix `0`
chainIDStr := strings.TrimLeft(hex.EncodeToString(bz), "0")
result, err = json.Marshal("0x" + chainIDStr)
if err != nil {
return RPCInternalError(id, fmt.Errorf("error decode response: %w", err))
}
// return int string for net_version
case NetVersion:
hexStr := hex.EncodeToString(bz)
Expand Down

0 comments on commit f491ebb

Please sign in to comment.