Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
0124c17
Add IBC flag
lumtis Feb 1, 2021
96ace0c
Merge branch 'develop' into feat/ibc-module
lumtis Feb 2, 2021
48ecdc3
Merge branch 'develop' into feat/ibc-module
lumtis Feb 5, 2021
f926b04
Module placeholders
lumtis Feb 5, 2021
f312c7e
Genesis placeholders
lumtis Feb 5, 2021
ad39f2a
Types placeholders
lumtis Feb 5, 2021
d137381
Proto placeholders
lumtis Feb 5, 2021
2460d94
IBC template
lumtis Feb 5, 2021
3de3b3a
Keeper placeholders
lumtis Feb 5, 2021
d2de261
App placeholders
lumtis Feb 5, 2021
3561dd9
Implement content replacemen
lumtis Feb 5, 2021
464ae9a
Add IBC workflow in service
lumtis Feb 5, 2021
100c20d
Lint
lumtis Feb 5, 2021
387806c
Some fixes
lumtis Feb 6, 2021
0feaf81
Fix last errors
lumtis Feb 6, 2021
2b8bbc8
IBC module integration test
lumtis Feb 6, 2021
403f460
Fix keepers bug
lumtis Feb 8, 2021
fcc3b09
Merge branch 'develop' into feat/ibc-module
lumtis Feb 8, 2021
92c8634
Fix import bug
lumtis Feb 8, 2021
716bd8e
Add test type in an IBC module
lumtis Feb 8, 2021
cc81120
Fi x tests
lumtis Feb 8, 2021
038f79c
Channel ordering option
lumtis Feb 9, 2021
534d497
Lint
lumtis Feb 9, 2021
c37e8f1
create specific test package for ibc module
lumtis Feb 9, 2021
795f4f4
Merge branch 'develop' into feat/ibc-module
lumtis Feb 9, 2021
98afa82
Fix integration tests
lumtis Feb 9, 2021
7372590
PLaceholder packet
lumtis Feb 9, 2021
2fbd150
Fix integration test
lumtis Feb 9, 2021
5e5f498
Template for packet scaffolding
lumtis Feb 9, 2021
6fb8c54
Lint
lumtis Feb 9, 2021
4c92bd4
Transmit packet template
lumtis Feb 10, 2021
656a559
Lint
lumtis Feb 10, 2021
927bce1
Initialize packet creation command
lumtis Feb 10, 2021
84d6cd5
Lint
lumtis Feb 10, 2021
6d04f59
Fix template
lumtis Feb 10, 2021
501fb0b
ibc packet command
lumtis Feb 10, 2021
5998c95
Packet scaffolding templates
lumtis Feb 10, 2021
266e2c0
Merge branch 'develop' into feat/ibc-module
lumtis Feb 10, 2021
214ca9c
Lint
lumtis Feb 10, 2021
c7d35fc
Fix packet scaffolding
lumtis Feb 10, 2021
66e0c58
Add integration tests for packets
lumtis Feb 10, 2021
c2cd09c
Test fix
lumtis Feb 10, 2021
282f175
PLaceholder for send message
lumtis Feb 10, 2021
5d2561c
Messages for sending
lumtis Feb 10, 2021
734b16d
Lint
lumtis Feb 10, 2021
20686a4
initialize tx
lumtis Feb 10, 2021
0ef5a62
Fix tx bugs
lumtis Feb 11, 2021
c256749
Scaffold type registry
lumtis Feb 11, 2021
b1f83a4
Merge branch 'develop' into feat/ibc-module
lumtis Feb 11, 2021
5ae79a8
change type appending template
lumtis Feb 11, 2021
9ae53dc
Merge branch 'develop' into feat/ibc-module
lumtis Feb 11, 2021
d87b797
Remove codec registration for packet
lumtis Feb 11, 2021
b49bfaf
Add scoped keeper for the ibc module
lumtis Feb 12, 2021
37266b5
Few comment changes
lumtis Feb 12, 2021
d8aa104
Merge branch 'develop' into feat/ibc-module
lumtis Feb 12, 2021
f1a0e16
Add IBC routing
lumtis Feb 12, 2021
d89348e
No ordering check when ordering is none
lumtis Feb 12, 2021
8ff8691
Handling encoding error in transmit packet
lumtis Feb 12, 2021
ebef129
Fix encoding issue
lumtis Feb 12, 2021
f1415aa
Denis suggestion
lumtis Feb 13, 2021
e7a719d
Old sacffolded app fallback
lumtis Feb 13, 2021
aae2a11
Set default version
lumtis Feb 15, 2021
5e1a8bc
Add module as flag for packet
lumtis Feb 15, 2021
d119c3c
Denis comment
lumtis Feb 16, 2021
d8ba8e6
Remove unused import
lumtis Feb 16, 2021
ac95074
Message module fallback
lumtis Feb 16, 2021
396926d
Change message color
lumtis Feb 16, 2021
3bda859
gomod update
lumtis Feb 17, 2021
cd29e2e
Merge develo
lumtis Feb 18, 2021
52e6266
Fix acknowledgement encoding
lumtis Feb 19, 2021
5948364
Apply suggestions from code review
lumtis Feb 19, 2021
56b3ff2
Ilker suggestions
lumtis Feb 19, 2021
80b5531
Update gomod
lumtis Feb 19, 2021
a67ad97
No timeout disabling (need timeout height option for this)
lumtis Feb 19, 2021
3958212
Merge branch 'develop' into feat/ibc-module
ilgooz Feb 19, 2021
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
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ require (
github.com/stretchr/testify v1.7.0
github.com/tendermint/spn v0.0.0-20201215081711-b9ec9286ed83
github.com/tendermint/tendermint v0.34.3
golang.org/x/crypto v0.0.0-20210218145215-b8e89b74b9df // indirect
golang.org/x/mod v0.4.1
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a
golang.org/x/sys v0.0.0-20210218085108-9555bcde0c6a // indirect
golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b // indirect
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect
google.golang.org/grpc v1.35.0
)
Expand Down
35 changes: 4 additions & 31 deletions go.sum

Large diffs are not rendered by default.

131 changes: 131 additions & 0 deletions integration/cmd_ibc_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// +build !relayer

package integration_test

import (
"testing"

"github.com/tendermint/starport/starport/pkg/cmdrunner/step"
)

func TestCreateModuleWithIBC(t *testing.T) {

var (
env = newEnv(t)
path = env.Scaffold("ibcblog", Stargate)
)

env.Must(env.Exec("create an IBC module",
step.NewSteps(step.New(
step.Exec("starport", "module", "create", "foo", "--ibc"),
step.Workdir(path),
)),
))

env.Must(env.Exec("create a type in an IBC module",
step.NewSteps(step.New(
step.Exec("starport", "type", "user", "email", "--module", "foo"),
step.Workdir(path),
)),
))

env.Must(env.Exec("create an IBC module with an ordered channel",
step.NewSteps(step.New(
step.Exec("starport", "module", "create", "--ibc", "orderedfoo", "--ordering", "ordered"),
step.Workdir(path),
)),
))

env.Must(env.Exec("create an IBC module with an unordered channel",
step.NewSteps(step.New(
step.Exec("starport", "module", "create", "--ibc", "unorderedfoo", "--ordering", "unordered"),
step.Workdir(path),
)),
))

env.Must(env.Exec("create an non IBC module",
step.NewSteps(step.New(
step.Exec("starport", "module", "create", "foobar"),
step.Workdir(path),
)),
))

env.EnsureAppIsSteady(path)
}

func TestCreateIBCPacket(t *testing.T) {

var (
env = newEnv(t)
path = env.Scaffold("ibcblog2", Stargate)
)

env.Must(env.Exec("create an IBC module",
step.NewSteps(step.New(
step.Exec("starport", "module", "create", "foo", "--ibc"),
step.Workdir(path),
)),
))

env.Must(env.Exec("create a packet",
step.NewSteps(step.New(
step.Exec("starport", "packet", "bar", "text", "--module", "foo"),
step.Workdir(path),
)),
))

env.Must(env.Exec("should prevent creating a packet with no module specified",
step.NewSteps(step.New(
step.Exec("starport", "packet", "bar", "text"),
step.Workdir(path),
)),
ExecShouldError(),
))

env.Must(env.Exec("should prevent creating a packet in a non existent module",
step.NewSteps(step.New(
step.Exec("starport", "packet", "bar", "text", "--module", "nomodule"),
step.Workdir(path),
)),
ExecShouldError(),
))

env.Must(env.Exec("should prevent creating an existing packet",
step.NewSteps(step.New(
step.Exec("starport", "packet", "bar", "post", "--module", "foo"),
step.Workdir(path),
)),
ExecShouldError(),
))

env.Must(env.Exec("create a packet with custom type fields",
step.NewSteps(step.New(
step.Exec("starport", "packet", "ticket", "num:int", "victory:bool", "--module", "foo"),
step.Workdir(path),
)),
))

env.Must(env.Exec("create a packet with no field",
step.NewSteps(step.New(
step.Exec("starport", "packet", "empty", "--module", "foo"),
step.Workdir(path),
)),
))

env.Must(env.Exec("create a non-IBC module",
step.NewSteps(step.New(
step.Exec("starport", "module", "create", "bar"),
step.Workdir(path),
)),
))

env.Must(env.Exec("should prevent creating a packet in a non IBC module",
step.NewSteps(step.New(
step.Exec("starport", "packet", "foo", "text", "--module", "bar"),
step.Workdir(path),
)),
ExecShouldError(),
))

env.EnsureAppIsSteady(path)
}
4 changes: 2 additions & 2 deletions integration/cmd_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func TestCreateTypeInCustomModule(t *testing.T) {
func TestCreateTypeInCustomModuleWithStargate(t *testing.T) {
var (
env = newEnv(t)
path = env.Scaffold("blog", Launchpad)
path = env.Scaffold("blog", Stargate)
)

env.Must(env.Exec("create a module",
Expand Down Expand Up @@ -235,7 +235,7 @@ func TestCreateTypeInCustomModuleWithStargate(t *testing.T) {
)),
))

env.Must(env.Exec("should prevent creating a type in a non existant module",
env.Must(env.Exec("should prevent creating a type in a non existent module",
step.NewSteps(step.New(
step.Exec("starport", "type", "user", "email", "--module", "idontexist"),
step.Workdir(path),
Expand Down
1 change: 1 addition & 0 deletions starport/interface/cli/starport/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func New() *cobra.Command {
c.AddCommand(NewRelayer())
c.AddCommand(NewVersion())
c.AddCommand(NewNetwork())
c.AddCommand(NewIBCPacket())
c.Flags().BoolP("toggle", "t", false, "Help message for toggle")
return c
}
Expand Down
58 changes: 57 additions & 1 deletion starport/interface/cli/starport/cmd/module-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,35 @@ import (

"github.com/spf13/cobra"
"github.com/tendermint/starport/starport/services/scaffolder"
"github.com/tendermint/starport/starport/templates/module"
)

const (
flagIBC = "ibc"
flagIBCOrdering = "ordering"
)

var ibcRouterPlaceholderInstruction = fmt.Sprintf(`
💬 To enable scaffolding of IBC modules, remove these lines from app/app.go:

%s

💬 Then, find the following line:

%s

💬 Finally, add this block of code below:

%s
`,
infoColor(`ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule)
app.IBCKeeper.SetRouter(ibcRouter)`),
infoColor(module.PlaceholderSgAppKeeperDefinition),
infoColor(`ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule)
`+module.PlaceholderIBCAppRouter+`
app.IBCKeeper.SetRouter(ibcRouter)`),
)

// NewModuleCreate creates a new module create command to scaffold an
Expand All @@ -17,13 +46,40 @@ func NewModuleCreate() *cobra.Command {
Args: cobra.MinimumNArgs(1),
RunE: createModuleHandler,
}
c.Flags().Bool(flagIBC, false, "scaffold an IBC module")
c.Flags().String(flagIBCOrdering, "none", "channel ordering of the IBC module [none|ordered|unordered]")
return c
}

func createModuleHandler(cmd *cobra.Command, args []string) error {
var options []scaffolder.ModuleCreationOption

name := args[0]

ibcModule, err := cmd.Flags().GetBool(flagIBC)
if err != nil {
return err
}

ibcOrdering, err := cmd.Flags().GetString(flagIBCOrdering)
if err != nil {
return err
}

// Check if the module must be an IBC module
if ibcModule {
options = append(options, scaffolder.WithIBCChannelOrdering(ibcOrdering), scaffolder.WithIBC())
}

sc := scaffolder.New(appPath)
if err := sc.CreateModule(name); err != nil {
if err := sc.CreateModule(name, options...); err != nil {

// If this is an old scaffolded application that doesn't contain the necessary placeholder
// We give instruction to the user to modify the application
if err == scaffolder.ErrNoIBCRouterPlaceholder {
fmt.Print(ibcRouterPlaceholderInstruction)
}

return err
}
fmt.Printf("\n🎉 Module created %s.\n\n", name)
Expand Down
43 changes: 43 additions & 0 deletions starport/interface/cli/starport/cmd/packet.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package starportcmd

import (
"errors"
"fmt"

"github.com/spf13/cobra"
"github.com/tendermint/starport/starport/services/scaffolder"
)

// NewIBCPacket creates a new packet in the module
func NewIBCPacket() *cobra.Command {
c := &cobra.Command{
Use: "packet [packetName] [field1] [field2] ... --module [module_name]",
Short: "Creates a new interpretable IBC packet.",
Long: "Use starport ibc packet to create a new packet in your IBC module.",
Args: cobra.MinimumNArgs(1),
RunE: createPacketHandler,
}

c.Flags().String(moduleFlag, "", "IBC Module to add the packet into")

return c
}

func createPacketHandler(cmd *cobra.Command, args []string) error {
packet := args[0]
fields := args[1:]
module, err := cmd.Flags().GetString(moduleFlag)
if err != nil {
return err
}
if module == "" {
return errors.New("please specify a module to create the packet into: --module <module_name>")
}

sc := scaffolder.New(appPath)
if err := sc.AddPacket(module, packet, fields...); err != nil {
return err
}
fmt.Printf("\n🎉 Created a packet `%[1]v`.\n\n", args[0])
return nil
}
Loading