-
Notifications
You must be signed in to change notification settings - Fork 586
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
imp: add query and sudo message types to encapsulate all variants of calls #4133
Merged
crodriguezvega
merged 10 commits into
feat/wasm-clients
from
carlos/query-sudo-message-to-encapsulate-calls
Aug 1, 2023
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
85c00b9
defined query and sudo message types to encapsulate all variants for …
crodriguezvega 741989d
pass client message
crodriguezvega a0febb6
add ClientMessage from #4049
crodriguezvega d0347f1
Merge branch 'feat/wasm-clients' into carlos/query-sudo-message-to-en…
crodriguezvega 253c67d
Merge branch 'feat/wasm-clients' into carlos/query-sudo-message-to-en…
crodriguezvega 5480a3f
address review comments
crodriguezvega e682c49
linter
crodriguezvega 2aef107
gofumpt
crodriguezvega bad6712
review comment
crodriguezvega 9e25172
more gofumpt
crodriguezvega 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 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,121 @@ | ||
package types | ||
|
||
import ( | ||
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" | ||
"github.com/cosmos/ibc-go/v7/modules/core/exported" | ||
) | ||
|
||
// instantiateMessage | ||
type instantiateMessage struct { | ||
ClientState *ClientState `json:"client_state"` | ||
ConsensusState *ConsensusState `json:"consensus_state"` | ||
} | ||
|
||
// queryMsg is used to encode query messages | ||
// omitempty tag is mandatory for JSON serialization | ||
// to be compatible with Rust contract enum matching | ||
type queryMsg struct { | ||
Status *statusMsg `json:"status,omitempty"` | ||
ExportMetadata *exportMetadataMsg `json:"export_metadata,omitempty"` | ||
TimestampAtHeight *timestampAtHeightMsg `json:"timestamp_at_height,omitempty"` | ||
VerifyClientMessage *verifyClientMessageMsg `json:"verify_client_message,omitempty"` | ||
VerifyMembership *verifyMembershipMsg `json:"verify_membership,omitempty"` | ||
VerifyNonMembership *verifyNonMembershipMsg `json:"verify_non_membership,omitempty"` | ||
CheckForMisbehaviour *checkForMisbehaviourMsg `json:"check_for_misbehaviour,omitempty"` | ||
} | ||
|
||
type statusMsg struct{} | ||
type exportMetadataMsg struct{} | ||
type timestampAtHeightMsg struct { | ||
Height exported.Height `json:"height"` | ||
} | ||
type verifyClientMessageMsg struct { | ||
ClientMessage *ClientMessage `json:"client_message"` | ||
} | ||
type verifyMembershipMsg struct { | ||
Height exported.Height `json:"height"` | ||
DelayTimePeriod uint64 `json:"delay_time_period"` | ||
DelayBlockPeriod uint64 `json:"delay_block_period"` | ||
Proof []byte `json:"proof"` | ||
Path exported.Path `json:"path"` | ||
Value []byte `json:"value"` | ||
} | ||
type verifyNonMembershipMsg struct { | ||
Height exported.Height `json:"height"` | ||
DelayTimePeriod uint64 `json:"delay_time_period"` | ||
DelayBlockPeriod uint64 `json:"delay_block_period"` | ||
Proof []byte `json:"proof"` | ||
Path exported.Path `json:"path"` | ||
} | ||
type checkForMisbehaviourMsg struct { | ||
ClientMessage *ClientMessage `json:"client_message"` | ||
} | ||
|
||
// sudoMsg is used to encode sudo messages | ||
// omitempty tag is mandatory for JSON serialization | ||
// to be compatible with Rust contract enum matching | ||
type sudoMsg struct { | ||
UpdateState *updateStateMsg `json:"update_state,omitempty"` | ||
UpdateStateOnMisbehaviour *updateStateOnMisbehaviourMsg `json:"update_state_on_misbehaviour,omitempty"` | ||
VerifyUpgradeAndUpdateState *verifyUpgradeAndUpdateStateMsg `json:"verify_upgrade_and_update_state,omitempty"` | ||
CheckSubstituteAndUpdateState *checkSubstituteAndUpdateStateMsg `json:"check_substitute_and_update_state,omitempty"` | ||
} | ||
|
||
type updateStateMsg struct { | ||
ClientMessage *ClientMessage `json:"client_message"` | ||
} | ||
type updateStateOnMisbehaviourMsg struct { | ||
ClientMessage *ClientMessage `json:"client_message"` | ||
} | ||
type verifyUpgradeAndUpdateStateMsg struct { | ||
UpgradeClientState exported.ClientState `json:"upgrade_client_state"` | ||
UpgradeConsensusState exported.ConsensusState `json:"upgrade_consensus_state"` | ||
ProofUpgradeClient []byte `json:"proof_upgrade_client"` | ||
ProofUpgradeConsensusState []byte `json:"proof_upgrade_consensus_state"` | ||
} | ||
type checkSubstituteAndUpdateStateMsg struct{} | ||
|
||
// ContractResult defines the expected result returned by a contract call | ||
type ContractResult interface { | ||
Validate() bool | ||
Error() string | ||
} | ||
|
||
type contractResult struct { | ||
IsValid bool `json:"is_valid,omitempty"` | ||
ErrorMsg string `json:"error_msg,omitempty"` | ||
Data []byte `json:"data,omitempty"` | ||
} | ||
|
||
func (r contractResult) Validate() bool { | ||
return r.IsValid | ||
} | ||
|
||
func (r contractResult) Error() string { | ||
return r.ErrorMsg | ||
} | ||
|
||
type statusResult struct { | ||
contractResult | ||
Status exported.Status `json:"status"` | ||
} | ||
|
||
type exportMetadataResult struct { | ||
contractResult | ||
GenesisMetadata []clienttypes.GenesisMetadata `json:"genesis_metadata"` | ||
} | ||
|
||
type timestampAtHeightResult struct { | ||
contractResult | ||
Timestamp uint64 `json:"timestamp"` | ||
} | ||
|
||
type checkForMisbehaviourResult struct { | ||
contractResult | ||
FoundMisbehaviour bool `json:"found_misbehaviour"` | ||
} | ||
|
||
type updateStateResult struct { | ||
contractResult | ||
Heights []exported.Height `json:"heights"` | ||
} |
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
Oops, something went wrong.
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.
gofumpt disagrees with you guys, @damiannolan and @chatton, and wants to put here a type block. I respect your opinion a lot, guys, you know that, but my religion doesn't allow me to break the 11th commandment: "You will never fight against your beloved linter". :)