From c0b998adeab5138ef94f624917010c93196d66fb Mon Sep 17 00:00:00 2001 From: Aaron Choo Date: Tue, 22 Aug 2023 11:01:08 +0800 Subject: [PATCH] refactor: better transformations to conform to ignite CLI (#22) * chore: add `accounts` key to mainnet config.json * docs: improve docs * refactor: remove unnecessary configs and merge configs * fix: comments typo * fix: set `DefaultNodeHome` correctly * chore: rename and remove keys from config * docs: add genesis docs * refactor: make code conform more to what ignite cli scaffolds * refactor: use `feather-cored` in cmd dir and add `chain_id` to transformations --- Makefile | 6 ++-- README.md | 4 +-- .../cmd/config.go | 0 .../cmd/genaccounts.go | 0 .../cmd/root.go | 0 .../cmd/testnet.go | 0 cmd/{feather-core => feather-cored}/main.go | 2 +- config/config.json | 2 +- transformations.yml | 33 ++++++++++++------- 9 files changed, 29 insertions(+), 18 deletions(-) rename cmd/{feather-core => feather-cored}/cmd/config.go (100%) rename cmd/{feather-core => feather-cored}/cmd/genaccounts.go (100%) rename cmd/{feather-core => feather-cored}/cmd/root.go (100%) rename cmd/{feather-core => feather-cored}/cmd/testnet.go (100%) rename cmd/{feather-core => feather-cored}/main.go (86%) diff --git a/Makefile b/Makefile index 10ffc30..87dd0d4 100644 --- a/Makefile +++ b/Makefile @@ -103,13 +103,13 @@ include contrib/devtools/Makefile all: install lint test install: go.sum - go build -o $(GOBIN)/$(FEATH_CONFIG_APP_BINARY_NAME) -mod=readonly $(BUILD_FLAGS) ./cmd/feather-core + go build -o $(GOBIN)/$(FEATH_CONFIG_APP_BINARY_NAME) -mod=readonly $(BUILD_FLAGS) ./cmd/feather-cored build: go.sum ifeq ($(OS),Windows_NT) exit 1 else - go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/$(FEATH_CONFIG_APP_BINARY_NAME) ./cmd/feather-core + go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/$(FEATH_CONFIG_APP_BINARY_NAME) ./cmd/feather-cored endif build-contract-tests-hooks: @@ -134,7 +134,7 @@ go.sum: go.mod draw-deps: @# requires brew install graphviz or apt-get install graphviz go install github.com/RobotsAndPencils/goviz@latest - @goviz -i ./cmd/feather-core -d 2 | dot -Tpng -o dependency-graph.png + @goviz -i ./cmd/feather-cored -d 2 | dot -Tpng -o dependency-graph.png clean: rm -rf snapcraft-local.yaml build/ diff --git a/README.md b/README.md index 3750d4d..39d277e 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ Edit the `config/config.json` file if you would like to do any of the following: // Human readable name of the chain. "app_name": "feather-core", // Prefix for all addresses on the chain. - "address_prefix": "pfeath", + "address_prefix": "feath", // Staking bond denominator (i.e. coin denom used for staking). "bond_denom": "stake", // Amount of `bond_denom` used for staking at genesis. @@ -91,7 +91,7 @@ Edit the `config/config.json` file if you would like to do any of the following: // List of genesis accounts, with their balances at genesis. "accounts": [ { - "address": "pfeath1...aaa", + "address": "feath1...aaa", "coins": [ { "denom": "stake", diff --git a/cmd/feather-core/cmd/config.go b/cmd/feather-cored/cmd/config.go similarity index 100% rename from cmd/feather-core/cmd/config.go rename to cmd/feather-cored/cmd/config.go diff --git a/cmd/feather-core/cmd/genaccounts.go b/cmd/feather-cored/cmd/genaccounts.go similarity index 100% rename from cmd/feather-core/cmd/genaccounts.go rename to cmd/feather-cored/cmd/genaccounts.go diff --git a/cmd/feather-core/cmd/root.go b/cmd/feather-cored/cmd/root.go similarity index 100% rename from cmd/feather-core/cmd/root.go rename to cmd/feather-cored/cmd/root.go diff --git a/cmd/feather-core/cmd/testnet.go b/cmd/feather-cored/cmd/testnet.go similarity index 100% rename from cmd/feather-core/cmd/testnet.go rename to cmd/feather-cored/cmd/testnet.go diff --git a/cmd/feather-core/main.go b/cmd/feather-cored/main.go similarity index 86% rename from cmd/feather-core/main.go rename to cmd/feather-cored/main.go index f971b73..fbfe8d4 100644 --- a/cmd/feather-core/main.go +++ b/cmd/feather-cored/main.go @@ -7,7 +7,7 @@ import ( svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" "github.com/terra-money/feather-core/app" - "github.com/terra-money/feather-core/cmd/feather-core/cmd" + "github.com/terra-money/feather-core/cmd/feather-cored/cmd" ) func main() { diff --git a/config/config.json b/config/config.json index 0d0ad21..fc2eb4b 100644 --- a/config/config.json +++ b/config/config.json @@ -1,7 +1,7 @@ { "chain_id": "feather-1", "app_name": "feather-core", - "address_prefix": "pfeath", + "address_prefix": "feath", "bond_denom": "stake", "bond_supply": "1000000000", "unbonding_time": "1814400s", diff --git a/transformations.yml b/transformations.yml index 8be2a86..bf9d54b 100644 --- a/transformations.yml +++ b/transformations.yml @@ -4,17 +4,20 @@ ignore: - transformations.yml inputs: - - id: go_module - text: What is the Go module name? (e.g. github.com/entity/chain) + - id: chain_id + text: What is the chain ID? (eg. feather-1) type: text - id: chain_name - text: What is the chain name? (e.g. feather) + text: What is the chain name? (eg. feather-core) type: text - - id: account_prefix - text: What is the account prefix? (e.g. feath) + - id: address_prefix + text: What is the address prefix? (eg. feath) type: text - id: bond_denom - text: What is the bond denom? (e.g. stake) + text: What is the bond denom? (eg. stake) + type: text + - id: go_module + text: What is the Go module name? (typically github.com//) type: text transformations: @@ -45,17 +48,25 @@ transformations: - "docs/static/openapi.yml" - "config/config.json" - - name: account prefix + - name: chain ID + type: replace + # replaces chain_id in config.json + pattern: feather-1 + replacement: "{{ .chain_id }}" + files: + - "config/config.json" + + - name: address prefix type: replace - # replaces account prefixes in config.json - pattern: pfeath - replacement: "{{ .account_prefix }}" + # replaces address_prefix in config.json + pattern: feath + replacement: "{{ .address_prefix }}" files: - "config/config.json" - name: bond denom type: replace - # replaces bond denom in config.json + # replaces bond_denom in config.json pattern: stake replacement: "{{ .bond_denom }}" files: