diff --git a/beacon-chain/rpc/eth/beacon/handlers.go b/beacon-chain/rpc/eth/beacon/handlers.go index 358c5889fb..375f8d6be0 100644 --- a/beacon-chain/rpc/eth/beacon/handlers.go +++ b/beacon-chain/rpc/eth/beacon/handlers.go @@ -746,10 +746,10 @@ func (*Server) GetDepositContract(w http.ResponseWriter, r *http.Request) { http2.WriteJson(w, &DepositContractResponse{ Data: &struct { - ChainId uint64 `json:"chain_id"` + ChainId string `json:"chain_id"` Address string `json:"address"` }{ - ChainId: params.BeaconConfig().DepositChainID, + ChainId: strconv.FormatUint(params.BeaconConfig().DepositChainID, 10), Address: params.BeaconConfig().DepositContractAddress, }, }) diff --git a/beacon-chain/rpc/eth/beacon/handlers_test.go b/beacon-chain/rpc/eth/beacon/handlers_test.go index 45478f073b..412761bd15 100644 --- a/beacon-chain/rpc/eth/beacon/handlers_test.go +++ b/beacon-chain/rpc/eth/beacon/handlers_test.go @@ -1654,3 +1654,23 @@ func TestGetGenesis(t *testing.T) { assert.StringContains(t, "Chain genesis info is not yet known", e.Message) }) } + +func TestGetDepositContract(t *testing.T) { + params.SetupTestConfigCleanup(t) + config := params.BeaconConfig().Copy() + config.DepositChainID = uint64(10) + config.DepositContractAddress = "0x4242424242424242424242424242424242424242" + params.OverrideBeaconConfig(config) + + request := httptest.NewRequest(http.MethodGet, "/eth/v1/beacon/states/{state_id}/finality_checkpoints", nil) + writer := httptest.NewRecorder() + writer.Body = &bytes.Buffer{} + + s := &Server{} + s.GetDepositContract(writer, request) + assert.Equal(t, http.StatusOK, writer.Code) + response := DepositContractResponse{} + require.NoError(t, json.Unmarshal(writer.Body.Bytes(), &response)) + assert.Equal(t, "10", response.Data.ChainId) + assert.Equal(t, "0x4242424242424242424242424242424242424242", response.Data.Address) +} diff --git a/beacon-chain/rpc/eth/beacon/structs.go b/beacon-chain/rpc/eth/beacon/structs.go index fb9e805436..465794c7b7 100644 --- a/beacon-chain/rpc/eth/beacon/structs.go +++ b/beacon-chain/rpc/eth/beacon/structs.go @@ -20,7 +20,7 @@ type GetCommitteesResponse struct { type DepositContractResponse struct { Data *struct { - ChainId uint64 `json:"chain_id"` + ChainId string `json:"chain_id"` Address string `json:"address"` } `json:"data"` }