This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
Move config parsing to use context #1
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 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,32 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
) | ||
|
||
type contextKey string | ||
|
||
func newContextKey(chainid string) contextKey { | ||
return contextKey(fmt.Sprintf("chain-client-context/%s", chainid)) | ||
} | ||
|
||
// SetChainClientToContext sets the chain client to the context | ||
func SetChainClientOnContext(ctx context.Context, chainid string, client *ChainClient) error { | ||
v := ctx.Value(newContextKey(chainid)) | ||
if v == nil { | ||
return errors.New("chain client not found in context") | ||
} | ||
ptr := v.(*ChainClient) | ||
*ptr = *client | ||
return nil | ||
} | ||
|
||
// GetChainClientFromContext returns the chain client from the context | ||
func GetChainClientFromContext(ctx context.Context, chainid string) *ChainClient { | ||
if v, ok := ctx.Value(newContextKey(chainid)).(*ChainClient); ok { | ||
return v | ||
} | ||
return nil | ||
} |
This file contains 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 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 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 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 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,41 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
"github.com/cosmos/cosmos-sdk/x/auth" | ||
authz "github.com/cosmos/cosmos-sdk/x/authz/module" | ||
"github.com/cosmos/cosmos-sdk/x/bank" | ||
"github.com/cosmos/cosmos-sdk/x/capability" | ||
"github.com/cosmos/cosmos-sdk/x/crisis" | ||
"github.com/cosmos/cosmos-sdk/x/distribution" | ||
distrclient "github.com/cosmos/cosmos-sdk/x/distribution/client" | ||
feegrant "github.com/cosmos/cosmos-sdk/x/feegrant/module" | ||
"github.com/cosmos/cosmos-sdk/x/gov" | ||
"github.com/cosmos/cosmos-sdk/x/mint" | ||
"github.com/cosmos/cosmos-sdk/x/params" | ||
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" | ||
"github.com/cosmos/cosmos-sdk/x/slashing" | ||
"github.com/cosmos/cosmos-sdk/x/staking" | ||
"github.com/cosmos/cosmos-sdk/x/upgrade" | ||
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" | ||
) | ||
|
||
var ModuleBasics = []module.AppModuleBasic{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this for encodings or decoding txs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both |
||
auth.AppModuleBasic{}, | ||
authz.AppModuleBasic{}, | ||
bank.AppModuleBasic{}, | ||
capability.AppModuleBasic{}, | ||
// TODO: add osmosis governance proposal types here | ||
// TODO: add other proposal types here | ||
gov.NewAppModuleBasic( | ||
paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler, | ||
), | ||
crisis.AppModuleBasic{}, | ||
distribution.AppModuleBasic{}, | ||
feegrant.AppModuleBasic{}, | ||
mint.AppModuleBasic{}, | ||
params.AppModuleBasic{}, | ||
slashing.AppModuleBasic{}, | ||
staking.AppModuleBasic{}, | ||
upgrade.AppModuleBasic{}, | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should avoid using block, this was meant for testing that ended up bleeding into prod.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh interesting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I should add a mempool query that sees if we have a TX in the mempool before trying to submit another one