From f93227e168b4a846cecd8d5cdf58ada82fbc87ac Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 16 Jan 2025 00:28:29 +0100 Subject: [PATCH 1/6] feat: expose chain-registry structs --- ignite/pkg/chainregistry/chainregistry.go | 160 ++++++++++++++ ignite/services/scaffolder/chain_registry.go | 208 +++---------------- 2 files changed, 186 insertions(+), 182 deletions(-) create mode 100644 ignite/pkg/chainregistry/chainregistry.go diff --git a/ignite/pkg/chainregistry/chainregistry.go b/ignite/pkg/chainregistry/chainregistry.go new file mode 100644 index 0000000000..529517b721 --- /dev/null +++ b/ignite/pkg/chainregistry/chainregistry.go @@ -0,0 +1,160 @@ +// package chainregistry is a package that contains the chain.json and assetlist.json structs. +// It is allowed to create or parse chain.json and assetlist.json files for/from the chain registry. +package chainregistry + +import ( + "encoding/json" + "os" +) + +const ( + // DefaultChainType is the default chain type for the chain.json + // More value are allowed by the chain registry schema, but Ignite only scaffolds Cosmos chains. + DefaultChainType = "cosmos" + + // DefaultChainStatus is the default chain status for the chain.json + // More value are allowed by the chain registry schema, but Ignite only scaffolds upcoming chains. + DefaultChainStatus = "upcoming" + + // DefaultNetworkType is the default network type for the chain.json + // More value are allowed by the chain registry schema, but Ignite only scaffolds devnet chains. + DefaultNetworkType = "devnet" +) + +// Chain represents the chain.json file from the chain registry. +// https://raw.githubusercontent.com/cosmos/chain-registry/master/chain.schema.json +type Chain struct { + ChainName string `json:"chain_name"` + Status string `json:"status"` + NetworkType string `json:"network_type"` + Website string `json:"website"` + PrettyName string `json:"pretty_name"` + ChainType string `json:"chain_type"` + ChainID string `json:"chain_id"` + Bech32Prefix string `json:"bech32_prefix"` + DaemonName string `json:"daemon_name"` + NodeHome string `json:"node_home"` + KeyAlgos []string `json:"key_algos"` + Slip44 int `json:"slip44"` + Fees Fees `json:"fees"` + Staking Staking `json:"staking"` + Codebase Codebase `json:"codebase"` + Description string `json:"description"` + Apis Apis `json:"apis"` +} + +type Staking struct { + StakingTokens []StakingToken `json:"staking_tokens"` +} + +type StakingToken struct { + Denom string `json:"denom"` +} + +type Codebase struct { + GitRepo string `json:"git_repo"` + Genesis CodebaseGenesis `json:"genesis"` + RecommendedVersion string `json:"recommended_version"` + CompatibleVersions []string `json:"compatible_versions"` + Consensus CodebaseInfo `json:"consensus"` + Sdk CodebaseInfo `json:"sdk"` + Ibc CodebaseInfo `json:"ibc,omitempty"` + Cosmwasm CodebaseInfoEnabled `json:"cosmwasm,omitempty"` +} + +type CodebaseGenesis struct { + GenesisURL string `json:"genesis_url"` +} + +type CodebaseInfo struct { + Type string `json:"type"` + Version string `json:"version"` + Repo string `json:"repo,omitempty"` + Tag string `json:"tag,omitempty"` +} + +type CodebaseInfoEnabled struct { + Version string `json:"version,omitempty"` + Repo string `json:"repo,omitempty"` + Tag string `json:"tag,omitempty"` + Enabled bool `json:"enabled"` +} + +type Fees struct { + FeeTokens []FeeToken `json:"fee_tokens"` +} + +type FeeToken struct { + Denom string `json:"denom"` + FixedMinGasPrice float64 `json:"fixed_min_gas_price"` + LowGasPrice float64 `json:"low_gas_price"` + AverageGasPrice float64 `json:"average_gas_price"` + HighGasPrice float64 `json:"high_gas_price"` +} + +type Apis struct { + RPC []ApiProvider `json:"rpc"` + Rest []ApiProvider `json:"rest"` + Grpc []ApiProvider `json:"grpc"` +} + +type ApiProvider struct { + Address string `json:"address"` + Provider string `json:"provider"` +} + +// SaveJSON saves the chainJSON to the given out directory. +func (c Chain) SaveJSON(out string) error { + bz, err := json.MarshalIndent(c, "", " ") + if err != nil { + return err + } + + return os.WriteFile(out, bz, 0o600) +} + +// AssetList represents the assetlist.json file from the chain registry. +// https://raw.githubusercontent.com/cosmos/chain-registry/master/assetlist.schema.json +// https://github.com/cosmos/chain-registry?tab=readme-ov-file#assetlists +type AssetList struct { + ChainName string `json:"chain_name"` + Assets []Asset `json:"assets"` +} + +type Asset struct { + Description string `json:"description"` + DenomUnits []DenomUnit `json:"denom_units"` + Base string `json:"base"` + Name string `json:"name"` + Display string `json:"display"` + Symbol string `json:"symbol"` + LogoURIs LogoURIs `json:"logo_URIs"` + CoingeckoID string `json:"coingecko_id,omitempty"` + Socials Socials `json:"socials,omitempty"` + TypeAsset string `json:"type_asset"` +} + +type DenomUnit struct { + Denom string `json:"denom"` + Exponent int `json:"exponent"` +} + +type LogoURIs struct { + Png string `json:"png"` + Svg string `json:"svg"` +} + +type Socials struct { + Website string `json:"website"` + Twitter string `json:"twitter"` +} + +// SaveJSON saves the assetlist.json to the given out directory. +func (c AssetList) SaveJSON(out string) error { + bz, err := json.MarshalIndent(c, "", " ") + if err != nil { + return err + } + + return os.WriteFile(out, bz, 0o600) +} diff --git a/ignite/services/scaffolder/chain_registry.go b/ignite/services/scaffolder/chain_registry.go index 29a9043cb4..e8e00213d7 100644 --- a/ignite/services/scaffolder/chain_registry.go +++ b/ignite/services/scaffolder/chain_registry.go @@ -2,7 +2,6 @@ package scaffolder import ( "bufio" - "encoding/json" "fmt" "os" "path/filepath" @@ -11,172 +10,17 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" chainconfig "github.com/ignite/cli/v29/ignite/config/chain" + "github.com/ignite/cli/v29/ignite/pkg/chainregistry" "github.com/ignite/cli/v29/ignite/pkg/errors" "github.com/ignite/cli/v29/ignite/pkg/xgit" "github.com/ignite/cli/v29/ignite/services/chain" ) const ( - // DefaultChainType is the default chain type for the chain.json - // More value are allowed by the chain registry schema, but Ignite only scaffolds Cosmos chains. - DefaultChainType = "cosmos" - - // DefaultChainStatus is the default chain status for the chain.json - // More value are allowed by the chain registry schema, but Ignite only scaffolds upcoming chains. - DefaultChainStatus = "upcoming" - - // DefaultNetworkType is the default network type for the chain.json - // More value are allowed by the chain registry schema, but Ignite only scaffolds devnet chains. - DefaultNetworkType = "devnet" - chainFilename = "chain.json" assetListFilename = "assetlist.json" ) -// https://raw.githubusercontent.com/cosmos/chain-registry/master/chain.schema.json -type chainJSON struct { - ChainName string `json:"chain_name"` - Status string `json:"status"` - NetworkType string `json:"network_type"` - Website string `json:"website"` - PrettyName string `json:"pretty_name"` - ChainType string `json:"chain_type"` - ChainID string `json:"chain_id"` - Bech32Prefix string `json:"bech32_prefix"` - DaemonName string `json:"daemon_name"` - NodeHome string `json:"node_home"` - KeyAlgos []string `json:"key_algos"` - Slip44 int `json:"slip44"` - Fees struct { - FeeTokens []feeToken `json:"fee_tokens"` - } `json:"fees"` - Staking staking `json:"staking"` - Codebase codebase `json:"codebase"` - Description string `json:"description"` - Apis apis `json:"apis"` -} - -type staking struct { - StakingTokens []stakingToken `json:"staking_tokens"` -} - -type stakingToken struct { - Denom string `json:"denom"` -} - -type codebase struct { - GitRepo string `json:"git_repo"` - Genesis codebaseGenesis `json:"genesis"` - RecommendedVersion string `json:"recommended_version"` - CompatibleVersions []string `json:"compatible_versions"` - Consensus codebaseConsensus `json:"consensus"` - Sdk codebaseSDK `json:"sdk"` - Ibc codebaseIBC `json:"ibc,omitempty"` - Cosmwasm codebaseCosmwasm `json:"cosmwasm,omitempty"` -} - -type codebaseGenesis struct { - GenesisURL string `json:"genesis_url"` -} - -type codebaseConsensus struct { - Type string `json:"type"` - Version string `json:"version"` -} - -type codebaseSDK struct { - Type string `json:"type"` - Version string `json:"version"` -} - -type codebaseIBC struct { - Type string `json:"type"` - Version string `json:"version"` -} - -type codebaseCosmwasm struct { - Version string `json:"version,omitempty"` - Enabled bool `json:"enabled"` -} - -type fees struct { - FeeTokens []feeToken `json:"fee_tokens"` -} - -type feeToken struct { - Denom string `json:"denom"` - FixedMinGasPrice float64 `json:"fixed_min_gas_price"` - LowGasPrice float64 `json:"low_gas_price"` - AverageGasPrice float64 `json:"average_gas_price"` - HighGasPrice float64 `json:"high_gas_price"` -} - -type apis struct { - RPC []apiProvider `json:"rpc"` - Rest []apiProvider `json:"rest"` - Grpc []apiProvider `json:"grpc"` -} - -type apiProvider struct { - Address string `json:"address"` - Provider string `json:"provider"` -} - -// SaveJSON saves the chainJSON to the given out directory. -func (c chainJSON) SaveJSON(out string) error { - bz, err := json.MarshalIndent(c, "", " ") - if err != nil { - return err - } - - return os.WriteFile(out, bz, 0o600) -} - -// https://raw.githubusercontent.com/cosmos/chain-registry/master/assetlist.schema.json -// https://github.com/cosmos/chain-registry?tab=readme-ov-file#assetlists -type assetListJSON struct { - ChainName string `json:"chain_name"` - Assets []asset `json:"assets"` -} - -type asset struct { - Description string `json:"description"` - DenomUnits []denomUnit `json:"denom_units"` - Base string `json:"base"` - Name string `json:"name"` - Display string `json:"display"` - Symbol string `json:"symbol"` - LogoURIs logoURIs `json:"logo_URIs"` - CoingeckoID string `json:"coingecko_id,omitempty"` - Socials socials `json:"socials,omitempty"` - TypeAsset string `json:"type_asset"` -} - -type denomUnit struct { - Denom string `json:"denom"` - Exponent int `json:"exponent"` -} - -type socials struct { - Website string `json:"website"` - Twitter string `json:"twitter"` -} - -type logoURIs struct { - Png string `json:"png"` - Svg string `json:"svg"` -} - -// SaveJSON saves the assetList to the given out directory. -func (c assetListJSON) SaveJSON(out string) error { - bz, err := json.MarshalIndent(c, "", " ") - if err != nil { - return err - } - - return os.WriteFile(out, bz, 0o600) -} - // AddChainRegistryFiles generates the chain registry files in the scaffolded chains. func (s Scaffolder) AddChainRegistryFiles(chain *chain.Chain, cfg *chainconfig.Config) error { binaryName, err := chain.Binary() @@ -197,14 +41,14 @@ func (s Scaffolder) AddChainRegistryFiles(chain *chain.Chain, cfg *chainconfig.C chainGitURL, _ /* do not fail on non-existing git repo */ := xgit.RepositoryURL(chain.AppPath()) var ( - consensus codebaseConsensus - cosmwasm codebaseCosmwasm - ibc codebaseIBC + consensus chainregistry.CodebaseInfo + ibc chainregistry.CodebaseInfo + cosmwasm chainregistry.CodebaseInfoEnabled ) consensusVersion, err := getVersionOfFromGoMod(chain, "github.com/cometbft/cometbft") if err == nil { - consensus = codebaseConsensus{ + consensus = chainregistry.CodebaseInfo{ Type: "cometbft", Version: consensusVersion, } @@ -212,7 +56,7 @@ func (s Scaffolder) AddChainRegistryFiles(chain *chain.Chain, cfg *chainconfig.C cosmwasmVersion, err := getVersionOfFromGoMod(chain, "github.com/CosmWasm/wasmd") if err == nil { - cosmwasm = codebaseCosmwasm{ + cosmwasm = chainregistry.CodebaseInfoEnabled{ Version: cosmwasmVersion, Enabled: true, } @@ -220,7 +64,7 @@ func (s Scaffolder) AddChainRegistryFiles(chain *chain.Chain, cfg *chainconfig.C ibcVersion, err := getVersionOfFromGoMod(chain, "github.com/cosmos/ibc-go") if err == nil { - ibc = codebaseIBC{ + ibc = chainregistry.CodebaseInfo{ Type: "go", Version: ibcVersion, } @@ -236,12 +80,12 @@ func (s Scaffolder) AddChainRegistryFiles(chain *chain.Chain, cfg *chainconfig.C } } - chainData := chainJSON{ + chainData := chainregistry.Chain{ ChainName: chain.Name(), PrettyName: chain.Name(), - ChainType: DefaultChainType, - Status: DefaultChainStatus, - NetworkType: DefaultNetworkType, + ChainType: chainregistry.DefaultChainType, + Status: chainregistry.DefaultChainStatus, + NetworkType: chainregistry.DefaultNetworkType, Website: "https://example.com", ChainID: chainID, Bech32Prefix: "cosmos", @@ -249,8 +93,8 @@ func (s Scaffolder) AddChainRegistryFiles(chain *chain.Chain, cfg *chainconfig.C NodeHome: chainHome, KeyAlgos: []string{"secp256k1"}, Slip44: 118, - Fees: fees{ - FeeTokens: []feeToken{ + Fees: chainregistry.Fees{ + FeeTokens: []chainregistry.FeeToken{ { Denom: defaultDenom, FixedMinGasPrice: 0.025, @@ -260,18 +104,18 @@ func (s Scaffolder) AddChainRegistryFiles(chain *chain.Chain, cfg *chainconfig.C }, }, }, - Staking: staking{ - StakingTokens: []stakingToken{ + Staking: chainregistry.Staking{ + StakingTokens: []chainregistry.StakingToken{ { Denom: defaultDenom, }, }, }, - Codebase: codebase{ + Codebase: chainregistry.Codebase{ GitRepo: chainGitURL, RecommendedVersion: "v1.0.0", CompatibleVersions: []string{"v1.0.0"}, - Sdk: codebaseSDK{ + Sdk: chainregistry.CodebaseInfo{ Type: "cosmos", Version: chain.Version.String(), }, @@ -279,20 +123,20 @@ func (s Scaffolder) AddChainRegistryFiles(chain *chain.Chain, cfg *chainconfig.C Ibc: ibc, Cosmwasm: cosmwasm, }, - Apis: apis{ - RPC: []apiProvider{ + Apis: chainregistry.Apis{ + RPC: []chainregistry.ApiProvider{ { Address: "http://localhost:26657", Provider: "localhost", }, }, - Rest: []apiProvider{ + Rest: []chainregistry.ApiProvider{ { Address: "http://localhost:1317", Provider: "localhost", }, }, - Grpc: []apiProvider{ + Grpc: []chainregistry.ApiProvider{ { Address: "localhost:9090", Provider: "localhost", @@ -301,12 +145,12 @@ func (s Scaffolder) AddChainRegistryFiles(chain *chain.Chain, cfg *chainconfig.C }, } - assetListData := assetListJSON{ + assetListData := chainregistry.AssetList{ ChainName: chainData.ChainName, - Assets: []asset{ + Assets: []chainregistry.Asset{ { Description: fmt.Sprintf("The native token of the %s chain", chainData.ChainName), - DenomUnits: []denomUnit{ + DenomUnits: []chainregistry.DenomUnit{ { Denom: defaultDenom, Exponent: 0, @@ -315,12 +159,12 @@ func (s Scaffolder) AddChainRegistryFiles(chain *chain.Chain, cfg *chainconfig.C Base: defaultDenom, Name: chainData.ChainName, Symbol: strings.ToUpper(defaultDenom), - LogoURIs: logoURIs{ + LogoURIs: chainregistry.LogoURIs{ Png: "https://ignite.com/favicon.ico", Svg: "https://ignite.com/favicon.ico", }, TypeAsset: "sdk.coin", - Socials: socials{ + Socials: chainregistry.Socials{ Website: "https://ignite.com", Twitter: "https://x.com/ignite", }, From a7150ccfde8967417ea1ba9793e948b802259a2b Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 16 Jan 2025 00:30:54 +0100 Subject: [PATCH 2/6] updates --- ignite/pkg/chainregistry/chainregistry.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ignite/pkg/chainregistry/chainregistry.go b/ignite/pkg/chainregistry/chainregistry.go index 529517b721..b0d41ae5ee 100644 --- a/ignite/pkg/chainregistry/chainregistry.go +++ b/ignite/pkg/chainregistry/chainregistry.go @@ -1,5 +1,5 @@ -// package chainregistry is a package that contains the chain.json and assetlist.json structs. -// It is allowed to create or parse chain.json and assetlist.json files for/from the chain registry. +// package chainregistry is a package that contains the chain.json and assetlist.json structs from the chain registry. +// Useful when parsing or creating chain.json and assetlist.json files. package chainregistry import ( From 52b7c6374120e73dd87b6445c0638926887d5966 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 16 Jan 2025 00:32:25 +0100 Subject: [PATCH 3/6] split --- ignite/pkg/chainregistry/asset.go | 52 +++++++++++++++++++ .../{chainregistry.go => chain.go} | 48 ----------------- ignite/pkg/chainregistry/doc.go | 3 ++ 3 files changed, 55 insertions(+), 48 deletions(-) create mode 100644 ignite/pkg/chainregistry/asset.go rename ignite/pkg/chainregistry/{chainregistry.go => chain.go} (69%) create mode 100644 ignite/pkg/chainregistry/doc.go diff --git a/ignite/pkg/chainregistry/asset.go b/ignite/pkg/chainregistry/asset.go new file mode 100644 index 0000000000..5ec491322d --- /dev/null +++ b/ignite/pkg/chainregistry/asset.go @@ -0,0 +1,52 @@ +package chainregistry + +import ( + "encoding/json" + "os" +) + +// AssetList represents the assetlist.json file from the chain registry. +// https://raw.githubusercontent.com/cosmos/chain-registry/master/assetlist.schema.json +// https://github.com/cosmos/chain-registry?tab=readme-ov-file#assetlists +type AssetList struct { + ChainName string `json:"chain_name"` + Assets []Asset `json:"assets"` +} + +type Asset struct { + Description string `json:"description"` + DenomUnits []DenomUnit `json:"denom_units"` + Base string `json:"base"` + Name string `json:"name"` + Display string `json:"display"` + Symbol string `json:"symbol"` + LogoURIs LogoURIs `json:"logo_URIs"` + CoingeckoID string `json:"coingecko_id,omitempty"` + Socials Socials `json:"socials,omitempty"` + TypeAsset string `json:"type_asset"` +} + +type DenomUnit struct { + Denom string `json:"denom"` + Exponent int `json:"exponent"` +} + +type LogoURIs struct { + Png string `json:"png"` + Svg string `json:"svg"` +} + +type Socials struct { + Website string `json:"website"` + Twitter string `json:"twitter"` +} + +// SaveJSON saves the assetlist.json to the given out directory. +func (c AssetList) SaveJSON(out string) error { + bz, err := json.MarshalIndent(c, "", " ") + if err != nil { + return err + } + + return os.WriteFile(out, bz, 0o600) +} diff --git a/ignite/pkg/chainregistry/chainregistry.go b/ignite/pkg/chainregistry/chain.go similarity index 69% rename from ignite/pkg/chainregistry/chainregistry.go rename to ignite/pkg/chainregistry/chain.go index b0d41ae5ee..8e7db169e4 100644 --- a/ignite/pkg/chainregistry/chainregistry.go +++ b/ignite/pkg/chainregistry/chain.go @@ -1,5 +1,3 @@ -// package chainregistry is a package that contains the chain.json and assetlist.json structs from the chain registry. -// Useful when parsing or creating chain.json and assetlist.json files. package chainregistry import ( @@ -112,49 +110,3 @@ func (c Chain) SaveJSON(out string) error { return os.WriteFile(out, bz, 0o600) } - -// AssetList represents the assetlist.json file from the chain registry. -// https://raw.githubusercontent.com/cosmos/chain-registry/master/assetlist.schema.json -// https://github.com/cosmos/chain-registry?tab=readme-ov-file#assetlists -type AssetList struct { - ChainName string `json:"chain_name"` - Assets []Asset `json:"assets"` -} - -type Asset struct { - Description string `json:"description"` - DenomUnits []DenomUnit `json:"denom_units"` - Base string `json:"base"` - Name string `json:"name"` - Display string `json:"display"` - Symbol string `json:"symbol"` - LogoURIs LogoURIs `json:"logo_URIs"` - CoingeckoID string `json:"coingecko_id,omitempty"` - Socials Socials `json:"socials,omitempty"` - TypeAsset string `json:"type_asset"` -} - -type DenomUnit struct { - Denom string `json:"denom"` - Exponent int `json:"exponent"` -} - -type LogoURIs struct { - Png string `json:"png"` - Svg string `json:"svg"` -} - -type Socials struct { - Website string `json:"website"` - Twitter string `json:"twitter"` -} - -// SaveJSON saves the assetlist.json to the given out directory. -func (c AssetList) SaveJSON(out string) error { - bz, err := json.MarshalIndent(c, "", " ") - if err != nil { - return err - } - - return os.WriteFile(out, bz, 0o600) -} diff --git a/ignite/pkg/chainregistry/doc.go b/ignite/pkg/chainregistry/doc.go new file mode 100644 index 0000000000..d6d2df8e44 --- /dev/null +++ b/ignite/pkg/chainregistry/doc.go @@ -0,0 +1,3 @@ +// package chainregistry is a package that contains the chain.json and assetlist.json structs from the chain registry. +// Useful when parsing or creating chain.json and assetlist.json files. +package chainregistry From 098411616ea1c0e3d49e8260dbcadc76411e639f Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 16 Jan 2025 00:42:21 +0100 Subject: [PATCH 4/6] structure --- ignite/pkg/chainregistry/chain.go | 58 ++++++++------------ ignite/pkg/chainregistry/consts.go | 37 +++++++++++++ ignite/services/scaffolder/chain_registry.go | 14 ++--- 3 files changed, 66 insertions(+), 43 deletions(-) create mode 100644 ignite/pkg/chainregistry/consts.go diff --git a/ignite/pkg/chainregistry/chain.go b/ignite/pkg/chainregistry/chain.go index 8e7db169e4..29b567ca78 100644 --- a/ignite/pkg/chainregistry/chain.go +++ b/ignite/pkg/chainregistry/chain.go @@ -5,40 +5,26 @@ import ( "os" ) -const ( - // DefaultChainType is the default chain type for the chain.json - // More value are allowed by the chain registry schema, but Ignite only scaffolds Cosmos chains. - DefaultChainType = "cosmos" - - // DefaultChainStatus is the default chain status for the chain.json - // More value are allowed by the chain registry schema, but Ignite only scaffolds upcoming chains. - DefaultChainStatus = "upcoming" - - // DefaultNetworkType is the default network type for the chain.json - // More value are allowed by the chain registry schema, but Ignite only scaffolds devnet chains. - DefaultNetworkType = "devnet" -) - // Chain represents the chain.json file from the chain registry. // https://raw.githubusercontent.com/cosmos/chain-registry/master/chain.schema.json type Chain struct { - ChainName string `json:"chain_name"` - Status string `json:"status"` - NetworkType string `json:"network_type"` - Website string `json:"website"` - PrettyName string `json:"pretty_name"` - ChainType string `json:"chain_type"` - ChainID string `json:"chain_id"` - Bech32Prefix string `json:"bech32_prefix"` - DaemonName string `json:"daemon_name"` - NodeHome string `json:"node_home"` - KeyAlgos []string `json:"key_algos"` - Slip44 int `json:"slip44"` - Fees Fees `json:"fees"` - Staking Staking `json:"staking"` - Codebase Codebase `json:"codebase"` - Description string `json:"description"` - Apis Apis `json:"apis"` + ChainName string `json:"chain_name"` + Status ChainStatus `json:"status"` + NetworkType NetworkType `json:"network_type"` + Website string `json:"website"` + PrettyName string `json:"pretty_name"` + ChainType ChainType `json:"chain_type"` + ChainID string `json:"chain_id"` + Bech32Prefix string `json:"bech32_prefix"` + DaemonName string `json:"daemon_name"` + NodeHome string `json:"node_home"` + KeyAlgos []string `json:"key_algos"` + Slip44 int `json:"slip44"` + Fees Fees `json:"fees"` + Staking Staking `json:"staking"` + Codebase Codebase `json:"codebase"` + Description string `json:"description"` + APIs APIs `json:"apis"` } type Staking struct { @@ -90,13 +76,13 @@ type FeeToken struct { HighGasPrice float64 `json:"high_gas_price"` } -type Apis struct { - RPC []ApiProvider `json:"rpc"` - Rest []ApiProvider `json:"rest"` - Grpc []ApiProvider `json:"grpc"` +type APIs struct { + RPC []APIProvider `json:"rpc"` + Rest []APIProvider `json:"rest"` + Grpc []APIProvider `json:"grpc"` } -type ApiProvider struct { +type APIProvider struct { Address string `json:"address"` Provider string `json:"provider"` } diff --git a/ignite/pkg/chainregistry/consts.go b/ignite/pkg/chainregistry/consts.go new file mode 100644 index 0000000000..4f86b19613 --- /dev/null +++ b/ignite/pkg/chainregistry/consts.go @@ -0,0 +1,37 @@ +package chainregistry + +type NetworkType string + +const ( + // NetworkTypeMainnet is the mainnet network type + NetworkTypeMainnet NetworkType = "mainnet" + + // NetworkTypeTestnet is the testnet network type + NetworkTypeTestnet NetworkType = "testnet" + + // NetworkTypeDevnet is the devnet network type + NetworkTypeDevnet NetworkType = "devnet" +) + +type ChainType string + +const ( + // ChainTypeCosmos is the cosmos chain type + ChainTypeCosmos ChainType = "cosmos" + + // ChainTypeEip155 is the eip155 chain type + ChainTypeEip155 ChainType = "eip155" +) + +type ChainStatus string + +const ( + // ChainStatusActive is the live chain status + ChainStatusActive ChainStatus = "live" + + // ChainStatusUpcoming is the upcoming chain status + ChainStatusUpcoming ChainStatus = "upcoming" + + // ChainStatusKilled is the inactive chain status + ChainStatusKilled ChainStatus = "killed" +) diff --git a/ignite/services/scaffolder/chain_registry.go b/ignite/services/scaffolder/chain_registry.go index e8e00213d7..c1f3940ef0 100644 --- a/ignite/services/scaffolder/chain_registry.go +++ b/ignite/services/scaffolder/chain_registry.go @@ -83,9 +83,9 @@ func (s Scaffolder) AddChainRegistryFiles(chain *chain.Chain, cfg *chainconfig.C chainData := chainregistry.Chain{ ChainName: chain.Name(), PrettyName: chain.Name(), - ChainType: chainregistry.DefaultChainType, - Status: chainregistry.DefaultChainStatus, - NetworkType: chainregistry.DefaultNetworkType, + ChainType: chainregistry.ChainTypeCosmos, + Status: chainregistry.ChainStatusUpcoming, + NetworkType: chainregistry.NetworkTypeDevnet, Website: "https://example.com", ChainID: chainID, Bech32Prefix: "cosmos", @@ -123,20 +123,20 @@ func (s Scaffolder) AddChainRegistryFiles(chain *chain.Chain, cfg *chainconfig.C Ibc: ibc, Cosmwasm: cosmwasm, }, - Apis: chainregistry.Apis{ - RPC: []chainregistry.ApiProvider{ + APIs: chainregistry.APIs{ + RPC: []chainregistry.APIProvider{ { Address: "http://localhost:26657", Provider: "localhost", }, }, - Rest: []chainregistry.ApiProvider{ + Rest: []chainregistry.APIProvider{ { Address: "http://localhost:1317", Provider: "localhost", }, }, - Grpc: []chainregistry.ApiProvider{ + Grpc: []chainregistry.APIProvider{ { Address: "localhost:9090", Provider: "localhost", From a34d2d0a8f74f4cf79e6857052cda7f3c01f0887 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 16 Jan 2025 00:49:05 +0100 Subject: [PATCH 5/6] updates --- ignite/pkg/chainregistry/chain.go | 2 +- ignite/pkg/chainregistry/consts.go | 13 +++++++++++++ ignite/services/scaffolder/chain_registry.go | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ignite/pkg/chainregistry/chain.go b/ignite/pkg/chainregistry/chain.go index 29b567ca78..1ea64de095 100644 --- a/ignite/pkg/chainregistry/chain.go +++ b/ignite/pkg/chainregistry/chain.go @@ -18,7 +18,7 @@ type Chain struct { Bech32Prefix string `json:"bech32_prefix"` DaemonName string `json:"daemon_name"` NodeHome string `json:"node_home"` - KeyAlgos []string `json:"key_algos"` + KeyAlgos []KeyAlgos `json:"key_algos"` Slip44 int `json:"slip44"` Fees Fees `json:"fees"` Staking Staking `json:"staking"` diff --git a/ignite/pkg/chainregistry/consts.go b/ignite/pkg/chainregistry/consts.go index 4f86b19613..f90166e841 100644 --- a/ignite/pkg/chainregistry/consts.go +++ b/ignite/pkg/chainregistry/consts.go @@ -35,3 +35,16 @@ const ( // ChainStatusKilled is the inactive chain status ChainStatusKilled ChainStatus = "killed" ) + +type KeyAlgos string + +const ( + // KeyAlgoSecp256k1 is the secp256k1 key algorithm + KeyAlgoSecp256k1 KeyAlgos = "secp256k1" + + // KeyAlgosEthSecp256k1 is the secp256k1 key algorithm with ethereum compatibility + KeyAlgosEthSecp256k1 KeyAlgos = "ethsecp256k1" + + // KeyAlgoEd25519 is the ed25519 key algorithm + KeyAlgoEd25519 KeyAlgos = "ed25519" +) diff --git a/ignite/services/scaffolder/chain_registry.go b/ignite/services/scaffolder/chain_registry.go index c1f3940ef0..459b7e1b45 100644 --- a/ignite/services/scaffolder/chain_registry.go +++ b/ignite/services/scaffolder/chain_registry.go @@ -91,7 +91,7 @@ func (s Scaffolder) AddChainRegistryFiles(chain *chain.Chain, cfg *chainconfig.C Bech32Prefix: "cosmos", DaemonName: binaryName, NodeHome: chainHome, - KeyAlgos: []string{"secp256k1"}, + KeyAlgos: []chainregistry.KeyAlgos{chainregistry.KeyAlgoSecp256k1}, Slip44: 118, Fees: chainregistry.Fees{ FeeTokens: []chainregistry.FeeToken{ From 62e718d41c9fccfad82567d8ab9effcf921e37b6 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 16 Jan 2025 00:53:53 +0100 Subject: [PATCH 6/6] lint --- ignite/pkg/chainregistry/consts.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ignite/pkg/chainregistry/consts.go b/ignite/pkg/chainregistry/consts.go index f90166e841..3f10b59e0b 100644 --- a/ignite/pkg/chainregistry/consts.go +++ b/ignite/pkg/chainregistry/consts.go @@ -3,48 +3,48 @@ package chainregistry type NetworkType string const ( - // NetworkTypeMainnet is the mainnet network type + // NetworkTypeMainnet is the mainnet network type. NetworkTypeMainnet NetworkType = "mainnet" - // NetworkTypeTestnet is the testnet network type + // NetworkTypeTestnet is the testnet network type. NetworkTypeTestnet NetworkType = "testnet" - // NetworkTypeDevnet is the devnet network type + // NetworkTypeDevnet is the devnet network type. NetworkTypeDevnet NetworkType = "devnet" ) type ChainType string const ( - // ChainTypeCosmos is the cosmos chain type + // ChainTypeCosmos is the cosmos chain type. ChainTypeCosmos ChainType = "cosmos" - // ChainTypeEip155 is the eip155 chain type + // ChainTypeEip155 is the eip155 chain type. ChainTypeEip155 ChainType = "eip155" ) type ChainStatus string const ( - // ChainStatusActive is the live chain status + // ChainStatusActive is the live chain status. ChainStatusActive ChainStatus = "live" - // ChainStatusUpcoming is the upcoming chain status + // ChainStatusUpcoming is the upcoming chain status. ChainStatusUpcoming ChainStatus = "upcoming" - // ChainStatusKilled is the inactive chain status + // ChainStatusKilled is the inactive chain status. ChainStatusKilled ChainStatus = "killed" ) type KeyAlgos string const ( - // KeyAlgoSecp256k1 is the secp256k1 key algorithm + // KeyAlgoSecp256k1 is the secp256k1 key algorithm. KeyAlgoSecp256k1 KeyAlgos = "secp256k1" - // KeyAlgosEthSecp256k1 is the secp256k1 key algorithm with ethereum compatibility + // KeyAlgosEthSecp256k1 is the secp256k1 key algorithm with ethereum compatibility. KeyAlgosEthSecp256k1 KeyAlgos = "ethsecp256k1" - // KeyAlgoEd25519 is the ed25519 key algorithm + // KeyAlgoEd25519 is the ed25519 key algorithm. KeyAlgoEd25519 KeyAlgos = "ed25519" )