- 
                Notifications
    You must be signed in to change notification settings 
- Fork 570
feat: improve node tx cmd #2813
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
          
          
            11 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      411b0a3
              
                feat(cosmosclient): more contextualized errors
              
              
                tbruyelle d006d66
              
                fix: node q tx because of empty keyring backend
              
              
                tbruyelle 0c1b6bc
              
                add test removed with TestNew
              
              
                tbruyelle 83f259f
              
                remove unecessary comments
              
              
                tbruyelle 744a2b7
              
                add TODO about wrapper removal condition
              
              
                tbruyelle a3eb4a5
              
                Merge branch 'develop' into fix/node-cmd
              
              
                 b14b9ec
              
                Update ignite/cmd/node.go
              
              
                tbruyelle 4e9fcfb
              
                Merge branch 'develop' into fix/node-cmd
              
              
                 42c51d4
              
                Merge branch 'develop' into fix/node-cmd
              
              
                tbruyelle eaaf008
              
                style: use pkg/errors
              
              
                tbruyelle 3302196
              
                Merge branch 'develop' into fix/node-cmd
              
              
                 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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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,156 @@ | ||
| package cosmosclient | ||
|  | ||
| import ( | ||
| "context" | ||
|  | ||
| "github.com/pkg/errors" | ||
| "github.com/tendermint/tendermint/libs/bytes" | ||
| "github.com/tendermint/tendermint/rpc/client" | ||
| rpcclient "github.com/tendermint/tendermint/rpc/client" | ||
| ctypes "github.com/tendermint/tendermint/rpc/core/types" | ||
| "github.com/tendermint/tendermint/types" | ||
| ) | ||
|  | ||
| // rpcWrapper is a rpclient.Client but with more contextualized errors. | ||
| // Useful because the original implementation may return JSON errors when the | ||
| // requested node is busy, which is confusing for the user. With rpcWrapper, | ||
| // the error is prefixed with 'error while requesting node xxx: JSON error'. | ||
|         
                  tbruyelle marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| // TODO(tb): we may remove this wrapper once https://github.com/tendermint/tendermint/issues/9312 is fixed. | ||
| type rpcWrapper struct { | ||
|         
                  tbruyelle marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| rpcclient.Client | ||
| nodeAddress string | ||
| } | ||
|  | ||
| func rpcError(node string, err error) error { | ||
|         
                  tbruyelle marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| return errors.Wrapf(err, "error while requesting node '%s'", node) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) ABCIInfo(ctx context.Context) (*ctypes.ResultABCIInfo, error) { | ||
| res, err := rpc.Client.ABCIInfo(ctx) | ||
|         
                  tbruyelle marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*ctypes.ResultABCIQuery, error) { | ||
| res, err := rpc.Client.ABCIQuery(ctx, path, data) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) ABCIQueryWithOptions(ctx context.Context, path string, data bytes.HexBytes, opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { | ||
| res, err := rpc.Client.ABCIQueryWithOptions(ctx, path, data, opts) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) { | ||
| res, err := rpc.Client.BroadcastTxCommit(ctx, tx) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) { | ||
| res, err := rpc.Client.BroadcastTxAsync(ctx, tx) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) { | ||
| res, err := rpc.Client.BroadcastTxSync(ctx, tx) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) GenesisChunked(ctx context.Context, n uint) (*ctypes.ResultGenesisChunk, error) { | ||
| res, err := rpc.Client.GenesisChunked(ctx, n) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) BlockchainInfo(ctx context.Context, minHeight int64, maxHeight int64) (*ctypes.ResultBlockchainInfo, error) { | ||
| res, err := rpc.Client.BlockchainInfo(ctx, minHeight, maxHeight) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) NetInfo(ctx context.Context) (*ctypes.ResultNetInfo, error) { | ||
| res, err := rpc.Client.NetInfo(ctx) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) DumpConsensusState(ctx context.Context) (*ctypes.ResultDumpConsensusState, error) { | ||
| res, err := rpc.Client.DumpConsensusState(ctx) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) ConsensusState(ctx context.Context) (*ctypes.ResultConsensusState, error) { | ||
| res, err := rpc.Client.ConsensusState(ctx) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) ConsensusParams(ctx context.Context, height *int64) (*ctypes.ResultConsensusParams, error) { | ||
| res, err := rpc.Client.ConsensusParams(ctx, height) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) Health(ctx context.Context) (*ctypes.ResultHealth, error) { | ||
| res, err := rpc.Client.Health(ctx) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) Block(ctx context.Context, height *int64) (*ctypes.ResultBlock, error) { | ||
| res, err := rpc.Client.Block(ctx, height) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) BlockByHash(ctx context.Context, hash []byte) (*ctypes.ResultBlock, error) { | ||
| res, err := rpc.Client.BlockByHash(ctx, hash) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) BlockResults(ctx context.Context, height *int64) (*ctypes.ResultBlockResults, error) { | ||
| res, err := rpc.Client.BlockResults(ctx, height) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) Commit(ctx context.Context, height *int64) (*ctypes.ResultCommit, error) { | ||
| res, err := rpc.Client.Commit(ctx, height) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) Validators(ctx context.Context, height *int64, page *int, perPage *int) (*ctypes.ResultValidators, error) { | ||
| res, err := rpc.Client.Validators(ctx, height, page, perPage) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) Tx(ctx context.Context, hash []byte, prove bool) (*ctypes.ResultTx, error) { | ||
| res, err := rpc.Client.Tx(ctx, hash, prove) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) TxSearch(ctx context.Context, query string, prove bool, page *int, perPage *int, orderBy string) (*ctypes.ResultTxSearch, error) { | ||
| res, err := rpc.Client.TxSearch(ctx, query, prove, page, perPage, orderBy) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) BlockSearch(ctx context.Context, query string, page *int, perPage *int, orderBy string) (*ctypes.ResultBlockSearch, error) { | ||
| res, err := rpc.Client.BlockSearch(ctx, query, page, perPage, orderBy) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) Status(ctx context.Context) (*ctypes.ResultStatus, error) { | ||
| res, err := rpc.Client.Status(ctx) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) BroadcastEvidence(ctx context.Context, e types.Evidence) (*ctypes.ResultBroadcastEvidence, error) { | ||
| res, err := rpc.Client.BroadcastEvidence(ctx, e) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) UnconfirmedTxs(ctx context.Context, limit *int) (*ctypes.ResultUnconfirmedTxs, error) { | ||
| res, err := rpc.Client.UnconfirmedTxs(ctx, limit) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) NumUnconfirmedTxs(ctx context.Context) (*ctypes.ResultUnconfirmedTxs, error) { | ||
| res, err := rpc.Client.NumUnconfirmedTxs(ctx) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
|  | ||
| func (rpc rpcWrapper) CheckTx(ctx context.Context, tx types.Tx) (*ctypes.ResultCheckTx, error) { | ||
| res, err := rpc.Client.CheckTx(ctx, tx) | ||
| return res, rpcError(rpc.nodeAddress, err) | ||
| } | ||
  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.