Skip to content

Commit 9906666

Browse files
authored
feat: introduce ignite cca (#140)
1 parent d5120a7 commit 9906666

File tree

166 files changed

+28897
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+28897
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cca/templates/web linguist-generated=true

_registry/ignite.apps.cca.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"appName": "CCA",
3+
"slug": "cca",
4+
"appDescription": "Scaffold a blockchain frontend in seconds with Ignite",
5+
"ignite": ">28.7.0",
6+
"dependencies": {},
7+
"cosmosSDK": ">0.50.1",
8+
"authors": [
9+
{
10+
"name": "Julien Robert",
11+
"github": "julienrbrt"
12+
}
13+
],
14+
"repositoryUrl": "https://github.com/ignite/apps",
15+
"documentationUrl": "https://github.com/ignite/apps/tree/main/cca/README.md",
16+
"license": {
17+
"name": "MIT",
18+
"url": "https://github.com/ignite/apps/blob/main/LICENSE"
19+
},
20+
"keywords": [
21+
"cca",
22+
"create-cosmos-app",
23+
"telescope",
24+
"cosmjs",
25+
"interchain-js",
26+
"cosmology",
27+
"cli",
28+
"cosmos-sdk",
29+
"ignite app"
30+
],
31+
"supportedPlatforms": [
32+
"mac",
33+
"linux"
34+
]
35+
}

app.ignite.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ apps:
2424
wasm:
2525
description: Scaffold a CosmosWasm-enabled chain with ease
2626
path: ./wasm
27+
cca:
28+
description: Scaffold a blockchain frontend in seconds with Ignite
29+
path: ./cca
2730
example-chain-info:
2831
description: A simple chain information application
2932
path: ./examples/chain-info

cca/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Web App Changelog
2+
3+
## Unreleased
4+
5+
## [`v0.1.0`](https://github.com/ignite/apps/releases/tag/web/v0.1.0)
6+
7+
* First release of the Web app compatible with Ignite >= v28.x.z

cca/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# CCA App
2+
3+
This Ignite App is aimed to extend [Ignite CLI](https://github.com/ignite/cli) and bootstrap the development of a chain frontend.
4+
It uses the widely used [Cosmology create-cosmos-app](https://github.com/cosmology-tech/create-cosmos-app) template and its libraries.
5+
6+
## Prerequisites
7+
8+
* Ignite v28.7.0 or later
9+
* Node.js
10+
* [Corepack](https://yarnpkg.com/corepack)
11+
12+
## Installation
13+
14+
```shell
15+
ignite app install -g github.com/ignite/apps/cca
16+
```
17+
18+
### Usage
19+
20+
Run the app using `ignite chain serve` command.
21+
In another terminal, run the frontend using the following commands:
22+
23+
```shell
24+
ignite s cca
25+
cd web
26+
yarn install
27+
yarn dev
28+
```
29+
30+
Learn more about Cosmos-Kit and Ignite in their respective documentation:
31+
32+
* <https://docs.ignite.com>
33+
* <https://github.com/cosmology-tech/create-cosmos-app>

cca/cmd/cmd.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package cmd
2+
3+
import "github.com/ignite/cli/v28/ignite/services/plugin"
4+
5+
// GetCommands returns the list of web app commands.
6+
func GetCommands() []*plugin.Command {
7+
return []*plugin.Command{
8+
{
9+
PlaceCommandUnder: "scaffold",
10+
Use: "cca",
11+
Short: "Ignite CCA scaffolds a Cosmos SDK chain frontend using a `create-cosmos-app` template",
12+
Flags: []*plugin.Flag{
13+
{
14+
Name: flagPath,
15+
Usage: "path of the app",
16+
Shorthand: "p",
17+
Type: plugin.FlagTypeString,
18+
},
19+
},
20+
},
21+
}
22+
}

cca/cmd/scaffold.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package cmd
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"path/filepath"
7+
8+
"github.com/ignite/apps/cca/templates"
9+
"github.com/ignite/cli/v28/ignite/pkg/cliui"
10+
"github.com/ignite/cli/v28/ignite/services/chain"
11+
"github.com/ignite/cli/v28/ignite/services/plugin"
12+
"github.com/ignite/cli/v28/ignite/services/scaffolder"
13+
)
14+
15+
const (
16+
statusScaffolding = "Scaffolding..."
17+
18+
flagPath = "path"
19+
)
20+
21+
// ExecuteScaffold executes the scaffold cca subcommand.
22+
func ExecuteScaffold(ctx context.Context, cmd *plugin.ExecutedCommand) error {
23+
flags := plugin.Flags(cmd.Flags)
24+
25+
session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding))
26+
defer session.End()
27+
28+
appPath, err := flags.GetString(flagPath)
29+
if err != nil {
30+
return err
31+
}
32+
absPath, err := filepath.Abs(appPath)
33+
if err != nil {
34+
return err
35+
}
36+
37+
c, err := chain.New(absPath, chain.CollectEvents(session.EventBus()))
38+
if err != nil {
39+
return err
40+
}
41+
42+
sc, err := scaffolder.New(absPath)
43+
if err != nil {
44+
return err
45+
}
46+
47+
cfg, err := c.Config()
48+
if err != nil {
49+
return err
50+
}
51+
52+
// add chain registry files
53+
// those are used for the wallet connector
54+
if err = sc.AddChainRegistryFiles(c, cfg); err != nil {
55+
return err
56+
}
57+
58+
// add cca files
59+
if err := templates.Write(c.AppPath()); err != nil {
60+
return fmt.Errorf("failed to write CCA: %w", err)
61+
}
62+
63+
return session.Printf("🎉 Ignite CCA added (`%[1]v`).\n", c.AppPath(), c.Name())
64+
}

0 commit comments

Comments
 (0)