diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..63afc665be --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/juno diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..a3ac068ba4 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +.DEFAULT_GOAL := help + +compile: ## compile: + @mkdir -p build + @go build -o build/juno cmd/main.go + +run: ## run + @./build/juno + +all: compile run ## build and run + +gomod_tidy: ## add missing and remove unused modules + go mod tidy + +gofmt: ## run go formatter + go fmt -x ./... + +help: ## Show this help + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' \ No newline at end of file diff --git a/src/main.go b/cmd/main.go similarity index 81% rename from src/main.go rename to cmd/main.go index db2ba435d0..d1e58d5a94 100644 --- a/src/main.go +++ b/cmd/main.go @@ -3,11 +3,13 @@ package main import ( "context" "fmt" + + "github.com/NethermindEth/juno/configs" "github.com/tarrencev/go-starknet/provider" ) func main() { - baseURL := mainnetGateway + baseURL := configs.MainnetGateway prv := provider.NewProvider(baseURL) // opt := provider.BlockOptions{} ctx := context.Background() diff --git a/configs/gateway.go b/configs/gateway.go new file mode 100644 index 0000000000..f90f06eabc --- /dev/null +++ b/configs/gateway.go @@ -0,0 +1,6 @@ +package configs + +const ( + GoerliGateway = "https://alpha4.starknet.io" + MainnetGateway = "https://alpha-mainnet.starknet.io" +) diff --git a/src/go.mod b/go.mod similarity index 90% rename from src/go.mod rename to go.mod index d7d8309ea3..a4613f2ffb 100644 --- a/src/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module juno +module github.com/NethermindEth/juno go 1.17 diff --git a/src/go.sum b/go.sum similarity index 100% rename from src/go.sum rename to go.sum diff --git a/init/README.md b/init/README.md new file mode 100644 index 0000000000..1544dec4be --- /dev/null +++ b/init/README.md @@ -0,0 +1,3 @@ +# `/init` + +System init (systemd, upstart, sysv) and process manager/supervisor (runit, supervisord) configs. diff --git a/internal/README.md b/internal/README.md new file mode 100644 index 0000000000..285acfa081 --- /dev/null +++ b/internal/README.md @@ -0,0 +1,20 @@ +# `/internal` + +Private application and library code. This is the code you don't want others importing in their applications or libraries. Note that this layout pattern is enforced by the Go compiler itself. See the Go 1.4 [`release notes`](https://golang.org/doc/go1.4#internalpackages) for more details. Note that you are not limited to the top level `internal` directory. You can have more than one `internal` directory at any level of your project tree. + +You can optionally add a bit of extra structure to your internal packages to separate your shared and non-shared internal code. It's not required (especially for smaller projects), but it's nice to have visual clues showing the intended package use. Your actual application code can go in the `/internal/app` directory (e.g., `/internal/app/myapp`) and the code shared by those apps in the `/internal/pkg` directory (e.g., `/internal/pkg/myprivlib`). + +Examples: + +* https://github.com/hashicorp/terraform/tree/master/internal +* https://github.com/influxdata/influxdb/tree/master/internal +* https://github.com/perkeep/perkeep/tree/master/internal +* https://github.com/jaegertracing/jaeger/tree/master/internal +* https://github.com/moby/moby/tree/master/internal +* https://github.com/satellity/satellity/tree/master/internal + +## `/internal/pkg` + +Examples: + +* https://github.com/hashicorp/waypoint/tree/main/internal/pkg diff --git a/pkg/README.md b/pkg/README.md new file mode 100644 index 0000000000..633b8777e6 --- /dev/null +++ b/pkg/README.md @@ -0,0 +1,59 @@ +# `/pkg` + +Library code that's ok to use by external applications (e.g., `/pkg/mypubliclib`). Other projects will import these libraries expecting them to work, so think twice before you put something here :-) Note that the `internal` directory is a better way to ensure your private packages are not importable because it's enforced by Go. The `/pkg` directory is still a good way to explicitly communicate that the code in that directory is safe for use by others. The [`I'll take pkg over internal`](https://travisjeffery.com/b/2019/11/i-ll-take-pkg-over-internal/) blog post by Travis Jeffery provides a good overview of the `pkg` and `internal` directories and when it might make sense to use them. + +It's also a way to group Go code in one place when your root directory contains lots of non-Go components and directories making it easier to run various Go tools (as mentioned in these talks: [`Best Practices for Industrial Programming`](https://www.youtube.com/watch?v=PTE4VJIdHPg) from GopherCon EU 2018, [GopherCon 2018: Kat Zien - How Do You Structure Your Go Apps](https://www.youtube.com/watch?v=oL6JBUk6tj0) and [GoLab 2018 - Massimiliano Pippi - Project layout patterns in Go](https://www.youtube.com/watch?v=3gQa1LWwuzk)). + +Note that this is not a universally accepted pattern and for every popular repo that uses it you can find 10 that don't. It's up to you to decide if you want to use this pattern or not. Regardless of whether or not it's a good pattern more people will know what you mean than not. It might a bit confusing for some of the new Go devs, but it's a pretty simple confusion to resolve and that's one of the goals for this project layout repo. + +Ok not to use it if your app project is really small and where an extra level of nesting doesn't add much value (unless you really want to). Think about it when it's getting big enough and your root directory gets pretty busy (especially if you have a lot of non-Go app components). + +The `pkg` directory origins: The old Go source code used to use `pkg` for its packages and then various Go projects in the community started copying the pattern (see [`this`](https://twitter.com/bradfitz/status/1039512487538970624) Brad Fitzpatrick's tweet for more context). + + +Examples: + +* https://github.com/prometheus/prometheus/tree/master/pkg +* https://github.com/jaegertracing/jaeger/tree/master/pkg +* https://github.com/istio/istio/tree/master/pkg +* https://github.com/GoogleContainerTools/kaniko/tree/master/pkg +* https://github.com/google/gvisor/tree/master/pkg +* https://github.com/google/syzkaller/tree/master/pkg +* https://github.com/perkeep/perkeep/tree/master/pkg +* https://github.com/minio/minio/tree/master/pkg +* https://github.com/heptio/ark/tree/master/pkg +* https://github.com/argoproj/argo/tree/master/pkg +* https://github.com/heptio/sonobuoy/tree/master/pkg +* https://github.com/helm/helm/tree/master/pkg +* https://github.com/kubernetes/kubernetes/tree/master/pkg +* https://github.com/kubernetes/kops/tree/master/pkg +* https://github.com/moby/moby/tree/master/pkg +* https://github.com/grafana/grafana/tree/master/pkg +* https://github.com/influxdata/influxdb/tree/master/pkg +* https://github.com/cockroachdb/cockroach/tree/master/pkg +* https://github.com/derekparker/delve/tree/master/pkg +* https://github.com/etcd-io/etcd/tree/master/pkg +* https://github.com/oklog/oklog/tree/master/pkg +* https://github.com/flynn/flynn/tree/master/pkg +* https://github.com/jesseduffield/lazygit/tree/master/pkg +* https://github.com/gopasspw/gopass/tree/master/pkg +* https://github.com/sosedoff/pgweb/tree/master/pkg +* https://github.com/GoogleContainerTools/skaffold/tree/master/pkg +* https://github.com/knative/serving/tree/master/pkg +* https://github.com/grafana/loki/tree/master/pkg +* https://github.com/bloomberg/goldpinger/tree/master/pkg +* https://github.com/Ne0nd0g/merlin/tree/master/pkg +* https://github.com/jenkins-x/jx/tree/master/pkg +* https://github.com/DataDog/datadog-agent/tree/master/pkg +* https://github.com/dapr/dapr/tree/master/pkg +* https://github.com/cortexproject/cortex/tree/master/pkg +* https://github.com/dexidp/dex/tree/master/pkg +* https://github.com/pusher/oauth2_proxy/tree/master/pkg +* https://github.com/pdfcpu/pdfcpu/tree/master/pkg +* https://github.com/weaveworks/kured/tree/master/pkg +* https://github.com/weaveworks/footloose/tree/master/pkg +* https://github.com/weaveworks/ignite/tree/master/pkg +* https://github.com/tmrts/boilr/tree/master/pkg +* https://github.com/kata-containers/runtime/tree/master/pkg +* https://github.com/okteto/okteto/tree/master/pkg +* https://github.com/solo-io/squash/tree/master/pkg diff --git a/src/gateway.go b/src/gateway.go deleted file mode 100644 index 2bc2f9168c..0000000000 --- a/src/gateway.go +++ /dev/null @@ -1,4 +0,0 @@ -package main - -const goerliGateway string = "https://alpha4.starknet.io" -const mainnetGateway string = "https://alpha-mainnet.starknet.io"