- 
                Notifications
    You must be signed in to change notification settings 
- Fork 570
feat: scaffold IBC module and IBC packets #731
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
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            75 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      0124c17
              
                Add IBC flag
              
              
                lumtis 96ace0c
              
                Merge branch 'develop' into feat/ibc-module
              
              
                lumtis 48ecdc3
              
                Merge branch 'develop' into feat/ibc-module
              
              
                lumtis f926b04
              
                Module placeholders
              
              
                lumtis f312c7e
              
                Genesis placeholders
              
              
                lumtis ad39f2a
              
                Types placeholders
              
              
                lumtis d137381
              
                Proto placeholders
              
              
                lumtis 2460d94
              
                IBC template
              
              
                lumtis 3de3b3a
              
                Keeper placeholders
              
              
                lumtis d2de261
              
                App placeholders
              
              
                lumtis 3561dd9
              
                Implement content replacemen
              
              
                lumtis 464ae9a
              
                Add IBC workflow in service
              
              
                lumtis 100c20d
              
                Lint
              
              
                lumtis 387806c
              
                Some fixes
              
              
                lumtis 0feaf81
              
                Fix last errors
              
              
                lumtis 2b8bbc8
              
                IBC module integration test
              
              
                lumtis 403f460
              
                Fix keepers bug
              
              
                lumtis fcc3b09
              
                Merge branch 'develop' into feat/ibc-module
              
              
                lumtis 92c8634
              
                Fix import bug
              
              
                lumtis 716bd8e
              
                Add test type in an IBC module
              
              
                lumtis cc81120
              
                Fi x tests
              
              
                lumtis 038f79c
              
                Channel ordering option
              
              
                lumtis 534d497
              
                Lint
              
              
                lumtis c37e8f1
              
                create specific test package for ibc module
              
              
                lumtis 795f4f4
              
                Merge branch 'develop' into feat/ibc-module
              
              
                lumtis 98afa82
              
                Fix integration tests
              
              
                lumtis 7372590
              
                PLaceholder packet
              
              
                lumtis 2fbd150
              
                Fix integration test
              
              
                lumtis 5e5f498
              
                Template for packet scaffolding
              
              
                lumtis 6fb8c54
              
                Lint
              
              
                lumtis 4c92bd4
              
                Transmit packet template
              
              
                lumtis 656a559
              
                Lint
              
              
                lumtis 927bce1
              
                Initialize packet creation command
              
              
                lumtis 84d6cd5
              
                Lint
              
              
                lumtis 6d04f59
              
                Fix template
              
              
                lumtis 501fb0b
              
                ibc packet command
              
              
                lumtis 5998c95
              
                Packet scaffolding templates
              
              
                lumtis 266e2c0
              
                Merge branch 'develop' into feat/ibc-module
              
              
                lumtis 214ca9c
              
                Lint
              
              
                lumtis c7d35fc
              
                Fix packet scaffolding
              
              
                lumtis 66e0c58
              
                Add integration tests for packets
              
              
                lumtis c2cd09c
              
                Test fix
              
              
                lumtis 282f175
              
                PLaceholder for send message
              
              
                lumtis 5d2561c
              
                Messages for sending
              
              
                lumtis 734b16d
              
                Lint
              
              
                lumtis 20686a4
              
                initialize tx
              
              
                lumtis 0ef5a62
              
                Fix tx bugs
              
              
                lumtis c256749
              
                Scaffold type registry
              
              
                lumtis b1f83a4
              
                Merge branch 'develop' into feat/ibc-module
              
              
                lumtis 5ae79a8
              
                change type appending template
              
              
                lumtis 9ae53dc
              
                Merge branch 'develop' into feat/ibc-module
              
              
                lumtis d87b797
              
                Remove codec registration for packet
              
              
                lumtis b49bfaf
              
                Add scoped keeper for the ibc module
              
              
                lumtis 37266b5
              
                Few comment changes
              
              
                lumtis d8aa104
              
                Merge branch 'develop' into feat/ibc-module
              
              
                lumtis f1a0e16
              
                Add IBC routing
              
              
                lumtis d89348e
              
                No ordering check when ordering is none
              
              
                lumtis 8ff8691
              
                Handling encoding error in transmit packet
              
              
                lumtis ebef129
              
                Fix encoding issue
              
              
                lumtis f1415aa
              
                Denis suggestion
              
              
                lumtis e7a719d
              
                Old sacffolded app fallback
              
              
                lumtis aae2a11
              
                Set default version
              
              
                lumtis 5e1a8bc
              
                Add module as flag for packet
              
              
                lumtis d119c3c
              
                Denis comment
              
              
                lumtis d8ba8e6
              
                Remove unused import
              
              
                lumtis ac95074
              
                Message module fallback
              
              
                lumtis 396926d
              
                Change message color
              
              
                lumtis 3bda859
              
                gomod update
              
              
                lumtis cd29e2e
              
                Merge develo
              
              
                lumtis 52e6266
              
                Fix acknowledgement encoding
              
              
                lumtis 5948364
              
                Apply suggestions from code review
              
              
                lumtis 56b3ff2
              
                Ilker suggestions
              
              
                lumtis 80b5531
              
                Update gomod
              
              
                lumtis a67ad97
              
                No timeout disabling (need timeout height option for this)
              
              
                lumtis 3958212
              
                Merge branch 'develop' into feat/ibc-module
              
              
                ilgooz File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              Large diffs are not rendered by default.
      
      Oops, something went wrong.
      
    
  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | 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) | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | 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 | ||
| } | 
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.