Skip to content

Commit

Permalink
refactor: better transformations to conform to ignite CLI (#22)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
AaronCQL committed Aug 22, 2023
1 parent 906b2d5 commit c0b998a
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 18 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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/
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cmd/feather-core/main.go → cmd/feather-cored/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion config/config.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
33 changes: 22 additions & 11 deletions transformations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/<user>/<chain_name>)
type: text

transformations:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c0b998a

Please sign in to comment.