diff --git a/cmd/spawn/module.go b/cmd/spawn/module.go index afab81c2..d359ffea 100644 --- a/cmd/spawn/module.go +++ b/cmd/spawn/module.go @@ -433,7 +433,8 @@ func AddModuleToAppGo(logger *slog.Logger, extName string, feats *features) erro logger.Debug("initParamsKeeper register", "extName", extName, "start", start, "end", end) appGoLines = append(appGoLines[:end-3], append([]string{fmt.Sprintf(` paramsKeeper.Subspace(%stypes.ModuleName)`, extName)}, appGoLines[end-3:]...)...) - return os.WriteFile(appGoPath, []byte(strings.Join(appGoLines, "\n")), 0644) + // 777 is used as some users have weird setup / group environments w/ MacOS. 766 is more ideal but .sh files need to be executed. + return os.WriteFile(appGoPath, []byte(strings.Join(appGoLines, "\n")), 0777) } // appendNewImportsToSource appends new imports to the source file at the end of the import block (before the closing `)` ). diff --git a/docs/versioned_docs/version-v0.50.x/01-setup/01-system-setup.md b/docs/versioned_docs/version-v0.50.x/01-setup/01-system-setup.md index 3d34662c..ea3460cc 100644 --- a/docs/versioned_docs/version-v0.50.x/01-setup/01-system-setup.md +++ b/docs/versioned_docs/version-v0.50.x/01-setup/01-system-setup.md @@ -26,25 +26,30 @@ If you do not have these components installed, follow the instructions below to ## Install Dependencies +Install [VSCode](https://code.visualstudio.com/download) if you do not already have a file editor. Once installed, the following extensions are useful +- [Golang Syntax Highlighting](https://marketplace.visualstudio.com/items?itemName=golang.Go) +- [Protobuf 3 Highlighting](https://marketplace.visualstudio.com/items?itemName=zxh404.vscode-proto3) +- [Improved Errors](https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens) + + ```bash - # Base - brew install make - brew install gcc - brew install wget - brew install jq + # Setup Homebrew (https://brew.sh/) + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + sudo echo 'export PATH=$PATH:/opt/homebrew/bin' >> ~/.zshrc - # Github CLI - https://github.com/cli/cli - brew install gh - gh auth login + # Base + brew install make wget jq gh gcc go - # Golang - brew install go + # (optional) Github CLI login + # gh auth login # Docker brew install --cask docker - open -a Docker # start docker desktop + + # Start docker desktop + open -a Docker # settings -> General -> Start Docker Desktop when you sign in to your computer # Apply & Restart @@ -55,13 +60,13 @@ If you do not have these components installed, follow the instructions below to + ```bash # Install WSL in powershell wsl --install - Restart-Computer # Setup WSL Ubuntu Image - wsl.exe --install Ubuntu-24.04 + wsl.exe --install -d Ubuntu-24.04 # Open wsl instance wsl @@ -69,18 +74,19 @@ If you do not have these components installed, follow the instructions below to # update and add snap if not already installed sudo apt update && sudo apt install snapd - # Install Go (Snap) - sudo snap install go --channel=1.23/stable --classic + # Install Go (https://go.dev/wiki/Ubuntu) + sudo apt update + sudo apt install golang -y # Install Base - sudo apt install make gcc git jq wget + sudo apt install make gcc git jq wget -y - # Install github-cli - sudo snap install gh + # Optional: Install github-cli + # sudo snap install gh # Install docker - https://docs.docker.com/desktop/wsl/#turn-on-docker-desktop-wsl-2 - # or snap: + # If you can't use snap, setup from: + # - https://docs.docker.com/desktop/wsl/#turn-on-docker-desktop-wsl-2 sudo snap install docker # Fix versioning for interaction of commands @@ -90,9 +96,13 @@ If you do not have these components installed, follow the instructions below to git config --global user.email "yourEmail@gmail.com" git config --global user.name "Your Name" ``` + + After installing VSCode and having your system setup, open a terminal and run `code` to open vscode. You can open the current directory with `code .`, where `.` in computer terms stands for the current directory. + + ```bash # Base diff --git a/docs/versioned_docs/version-v0.50.x/01-setup/02-install-spawn.md b/docs/versioned_docs/version-v0.50.x/01-setup/02-install-spawn.md index de158227..b31868a7 100644 --- a/docs/versioned_docs/version-v0.50.x/01-setup/02-install-spawn.md +++ b/docs/versioned_docs/version-v0.50.x/01-setup/02-install-spawn.md @@ -42,21 +42,33 @@ spawn local-ic heighliner +``` -# If you get "command 'spawn' not found", run the following -# Linux / Windows / Some MacOS -echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.bashrc -source ~/.bashrc - -# MacOS -echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.zshrc -source ~/.zshrc +## Command not found error -# Legacy MacOS Go -echo 'export PATH=$PATH:$HOME/go/bin' >> ~/.zshrc -source ~/.zshrc +If you get "command 'spawn' not found", run: -# Sometimes it can be good to also clear your cache -# especially WSL users -go clean -cache +```bash +# Gets your operating system +unameOut="$(uname -s)" +case "${unameOut}" in + Linux*) machine=Linux;; + Darwin*) machine=Mac;; + CYGWIN*) machine=Cygwin;; + MINGW*) machine=MinGw;; + MSYS_NT*) machine=MSys;; + *) machine="UNKNOWN:${unameOut}" +esac +echo "Your operating system is: $machine" +echo -e "\nAdding the go binary location to your PATH for global access.\n\tIt will now prompt you for your password." + +# Adds the location of the binaries to your PATH for global execution. +cmd='export PATH=$PATH:$(go env GOPATH)/bin' +if [ $machine == "Linux" ]; then + sudo echo "$cmd" >> ~/.bashrc && source ~/.bashrc +elif [ $machine == "Mac" ]; then + sudo echo "$cmd" >> ~/.zshrc && source ~/.zshrc +else + echo 'Please add the following to your PATH: $(go env GOPATH)/bin' +fi ``` diff --git a/docs/versioned_docs/version-v0.50.x/02-build-your-application/01-nameservice.md b/docs/versioned_docs/version-v0.50.x/02-build-your-application/01-nameservice.md index f1b43a68..2892d2c9 100644 --- a/docs/versioned_docs/version-v0.50.x/02-build-your-application/01-nameservice.md +++ b/docs/versioned_docs/version-v0.50.x/02-build-your-application/01-nameservice.md @@ -18,6 +18,14 @@ Building your first Cosmos-SDK blockchain with Spawn. This tutorial focuses on a * Interacting with the network ::: +## How a Name Service works + +Imagine you have a set of labeled containers, each with a unique name like "Essentials" "Electronics" and "Books". The label on each container is called the key, and what’s stored inside is the value. For example, the key "Books" leads you to a container full of books, while "Essentials" might have things like toiletries or basic supplies. + +In a nameservice, this key-value system lets you quickly find or access specific data by referencing a unique name, or key, which reliably points you to the related value. This is useful for mapping names to specific information or resources, so with just the name, you can always find exactly what you're looking for. + +For this tutorial we map a human readable name (like `"alice"`) to a complex wallet address (like `roll1efd63aw40lxf3n4mhf7dzhjkr453axur57cawh`) so it is easier to understand and view as a user. + ## Prerequisites - [System Setup](../01-setup/01-system-setup.md) - [Install Spawn](../01-setup/02-install-spawn.md) diff --git a/docs/versioned_docs/version-v0.50.x/02-build-your-application/03-application-logic.md b/docs/versioned_docs/version-v0.50.x/02-build-your-application/03-application-logic.md index 0944632c..ee393b4c 100644 --- a/docs/versioned_docs/version-v0.50.x/02-build-your-application/03-application-logic.md +++ b/docs/versioned_docs/version-v0.50.x/02-build-your-application/03-application-logic.md @@ -7,7 +7,8 @@ slug: /build/name-service-application # Save Storage Structure -You now need to set the data structure in the keeper to store the wallet to name pair. Keeper's are where the data is stored for future use. +You now need to set the data structure in the keeper to store the wallet to name pair. Keepers are where the data is stored for future use and handle the business logic. +Think of it like a box where you store your data and the methods used to modify this data. It is self contained and only gets further access if you allow the keeper to do so (shown in [part 2](../02-build-your-application/08-ibc-module.md)). ```go title="x/nameservice/keeper/keeper.go" @@ -34,8 +35,6 @@ func NewKeeper() Keeper { } ``` -![keeper NewKeeper NameMapping](https://github.com/rollchains/spawn/assets/31943163/47ed4a41-4df2-4a5d-9ac5-bfb23aeefd94) - --- ## Application Logic diff --git a/docs/versioned_docs/version-v0.50.x/02-build-your-application/05-testnet.md b/docs/versioned_docs/version-v0.50.x/02-build-your-application/05-testnet.md index eb6e1cdc..f64331a8 100644 --- a/docs/versioned_docs/version-v0.50.x/02-build-your-application/05-testnet.md +++ b/docs/versioned_docs/version-v0.50.x/02-build-your-application/05-testnet.md @@ -28,9 +28,9 @@ The chain will begin to create (mint) new blocks. You can see the logs of the ne ### Interact Set Name -Using the newly built binary *(rolld from the --bin flag when the chain was created)*, you are going to execute the `set` transaction to your name. In this example, use "alice". This links account `acc1` address to the desired name in the keeper. +Using the newly built binary executable *(rolld from the --bin flag when the chain was created)*, you are going to execute the `set` action to your name. In this example, use "alice". This links account `acc1` address to the desired name in the keeper. -Then, resolve this name with the nameservice lookup. `$(rolld keys show acc1 -a)` is a substitute for the acc1's address. You can also use just `roll1hj5fveer5cjtn4wd6wstzugjfdxzl0xpg2te87` here. +You can either query or set data in the network using the command executable. If you wish to perform an action you submit a transaction (tx). If you wish to read data you are querying (q). The next sub command specifies which module will receive the action on. In this case, the `nameservice` module since our module is named nameservice. Then the `set` command is called, which was defined in the autocli.go. ```bash rolld tx nameservice set alice --from=acc1 --yes diff --git a/simapp/app/tools.go b/simapp/app/tools.go new file mode 100644 index 00000000..48b47d3c --- /dev/null +++ b/simapp/app/tools.go @@ -0,0 +1,8 @@ +// Description: This file is used to import all the packages that are used in the application, but may not be required currently. +// This is done to avoid the unused import errors when building modules. Leave this file unchanged. + +package app + +import ( + _ "cosmossdk.io/orm" +) diff --git a/spawn/cfg.go b/spawn/cfg.go index f3e401b3..38f58c0b 100644 --- a/spawn/cfg.go +++ b/spawn/cfg.go @@ -458,7 +458,7 @@ func debugErrorFile(logger *slog.Logger, newDirname string) string { } fullPath := path.Join(debugDir, fname) - if err := os.WriteFile(fullPath, []byte(errFileText), 0644); err != nil { + if err := os.WriteFile(fullPath, []byte(errFileText), 0766); err != nil { logger.Error("Error saving debug file", "err", err) } diff --git a/spawn/file_content.go b/spawn/file_content.go index 2a625024..5afc298d 100644 --- a/spawn/file_content.go +++ b/spawn/file_content.go @@ -254,9 +254,10 @@ func (fc *FileContent) Save() error { return nil } - if err := os.MkdirAll(path.Dir(fc.NewPath), 0755); err != nil { + // 777 is used as some users have weird setup / group environments w/ MacOS. 766 is more ideal but .sh files need to be executed. + if err := os.MkdirAll(path.Dir(fc.NewPath), 0777); err != nil { return err } - return os.WriteFile(fc.NewPath, []byte(fc.Contents), 0644) + return os.WriteFile(fc.NewPath, []byte(fc.Contents), 0777) } diff --git a/spawn/metadata.go b/spawn/metadata.go index 6752be1f..3d113a96 100644 --- a/spawn/metadata.go +++ b/spawn/metadata.go @@ -68,5 +68,5 @@ func (mf MetadataFile) SaveJSON(loc string) error { return err } - return os.WriteFile(loc, bz, 0644) + return os.WriteFile(loc, bz, 0666) } diff --git a/spawn/proto_parser.go b/spawn/proto_parser.go index 0753bdf4..6cdc2a14 100644 --- a/spawn/proto_parser.go +++ b/spawn/proto_parser.go @@ -405,7 +405,7 @@ func ApplyMissingRPCMethodsToGoSourceFiles(logger *slog.Logger, missingRPCMethod // append to the file content after a new line at the end content = append(content, []byte("\n"+code)...) - if err := os.WriteFile(fileLoc, content, 0644); err != nil { + if err := os.WriteFile(fileLoc, content, 0666); err != nil { logger.Error("error", "err", err) return err } diff --git a/spawn/types/chain_registry.go b/spawn/types/chain_registry.go index f2ffbe77..7ef5a87e 100644 --- a/spawn/types/chain_registry.go +++ b/spawn/types/chain_registry.go @@ -137,5 +137,5 @@ func (v ChainRegistryFormat) SaveJSON(loc string) error { return err } - return os.WriteFile(loc, bz, 0644) + return os.WriteFile(loc, bz, 0666) } diff --git a/spawn/types/chain_registry_assets_list.go b/spawn/types/chain_registry_assets_list.go index 318bafd2..2cc2661f 100644 --- a/spawn/types/chain_registry_assets_list.go +++ b/spawn/types/chain_registry_assets_list.go @@ -49,5 +49,5 @@ func (v ChainRegistryAssetsList) SaveJSON(loc string) error { return err } - return os.WriteFile(loc, bz, 0644) + return os.WriteFile(loc, bz, 0666) } diff --git a/spawn/version_check.go b/spawn/version_check.go index ff2eb7e0..c013ef48 100644 --- a/spawn/version_check.go +++ b/spawn/version_check.go @@ -209,7 +209,7 @@ func DoOutdatedNotificationRunCheck(logger *slog.Logger) bool { } func WriteLastTimeToFile(logger *slog.Logger, lastCheckFile string, t time.Time) error { - return os.WriteFile(lastCheckFile, []byte(t.Format(time.RFC3339)), 0644) + return os.WriteFile(lastCheckFile, []byte(t.Format(time.RFC3339)), 0666) } // GetLatestVersionCheckFile grabs the check file used to determine when to run the version check. @@ -236,7 +236,7 @@ func GetLatestVersionCheckFile(logger *slog.Logger) (string, error) { } epoch := time.Unix(0, 0) - if err := os.WriteFile(lastCheckFile, []byte(epoch.Format(time.RFC3339)), 0644); err != nil { + if err := os.WriteFile(lastCheckFile, []byte(epoch.Format(time.RFC3339)), 0666); err != nil { logger.Error("Error writing last check file", "err", err) return "", err }