Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce ignite cca #140

Merged
merged 13 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cca/templates/web linguist-generated=true
35 changes: 35 additions & 0 deletions _registry/ignite.apps.cca.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"appName": "CCA",
"slug": "cca",
"appDescription": "Scaffold a blockchain frontend in seconds with Ignite",
"ignite": ">28.7.0",
"dependencies": {},
"cosmosSDK": ">0.50.1",
"authors": [
{
"name": "Julien Robert",
"github": "julienrbrt"
}
],
"repositoryUrl": "https://github.com/ignite/apps",
"documentationUrl": "https://github.com/ignite/apps/tree/main/cca/README.md",
"license": {
"name": "MIT",
"url": "https://github.com/ignite/apps/blob/main/LICENSE"
},
"keywords": [
"cca",
"create-cosmos-app",
"telescope",
"cosmjs",
"interchain-js",
"cosmology",
"cli",
"cosmos-sdk",
"ignite app"
],
"supportedPlatforms": [
"mac",
"linux"
]
}
3 changes: 3 additions & 0 deletions app.ignite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ apps:
wasm:
description: Scaffold a CosmosWasm-enabled chain with ease
path: ./wasm
cca:
description: Scaffold a blockchain frontend in seconds with Ignite
path: ./cca
example-chain-info:
description: A simple chain information application
path: ./examples/chain-info
Expand Down
7 changes: 7 additions & 0 deletions cca/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Web App Changelog

## Unreleased

## [`v0.1.0`](https://github.com/ignite/apps/releases/tag/web/v0.1.0)

* First release of the Web app compatible with Ignite >= v28.x.z
33 changes: 33 additions & 0 deletions cca/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# CCA App

This Ignite App is aimed to extend [Ignite CLI](https://github.com/ignite/cli) and bootstrap the development of a chain frontend.
It uses the widely used [Cosmology create-cosmos-app](https://github.com/cosmology-tech/create-cosmos-app) template and its libraries.

## Prerequisites

* Ignite v28.7.0 or later
* Node.js
* [Corepack](https://yarnpkg.com/corepack)

## Installation

```shell
ignite app install -g github.com/ignite/apps/cca
```

### Usage

Run the app using `ignite chain serve` command.
In another terminal, run the frontend using the following commands:

```shell
ignite s cca
cd web
yarn install
yarn dev
```

Learn more about Cosmos-Kit and Ignite in their respective documentation:

* <https://docs.ignite.com>
* <https://github.com/cosmology-tech/create-cosmos-app>
22 changes: 22 additions & 0 deletions cca/cmd/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cmd

import "github.com/ignite/cli/v28/ignite/services/plugin"

// GetCommands returns the list of web app commands.
func GetCommands() []*plugin.Command {
return []*plugin.Command{
{
PlaceCommandUnder: "scaffold",
Use: "cca",
Short: "Ignite CCA scaffolds a Cosmos SDK chain frontend using a `create-cosmos-app` template",
Flags: []*plugin.Flag{
{
Name: flagPath,
Usage: "path of the app",
Shorthand: "p",
Type: plugin.FlagTypeString,
},
},
},
}
}
64 changes: 64 additions & 0 deletions cca/cmd/scaffold.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package cmd

import (
"context"
"fmt"
"path/filepath"

"github.com/ignite/apps/cca/templates"
"github.com/ignite/cli/v28/ignite/pkg/cliui"
"github.com/ignite/cli/v28/ignite/services/chain"
"github.com/ignite/cli/v28/ignite/services/plugin"
"github.com/ignite/cli/v28/ignite/services/scaffolder"
)

const (
statusScaffolding = "Scaffolding..."

flagPath = "path"
)

// ExecuteScaffold executes the scaffold cca subcommand.
func ExecuteScaffold(ctx context.Context, cmd *plugin.ExecutedCommand) error {
flags := plugin.Flags(cmd.Flags)

session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding))
defer session.End()

appPath, err := flags.GetString(flagPath)
if err != nil {
return err
}
absPath, err := filepath.Abs(appPath)
if err != nil {
return err
}

c, err := chain.New(absPath, chain.CollectEvents(session.EventBus()))
if err != nil {
return err
}

sc, err := scaffolder.New(absPath)
if err != nil {
return err
}

cfg, err := c.Config()
if err != nil {
return err
}

// add chain registry files
// those are used for the wallet connector
if err = sc.AddChainRegistryFiles(c, cfg); err != nil {
return err
}

// add cca files
if err := templates.Write(c.AppPath()); err != nil {
return fmt.Errorf("failed to write CCA: %w", err)
}

return session.Printf("🎉 Ignite CCA added (`%[1]v`).\n", c.AppPath(), c.Name())
}
Loading
Loading