Skip to content

Commit

Permalink
Merge pull request #2023 from CosmWasm/reflect-contract-2.0
Browse files Browse the repository at this point in the history
Enable `cosmwasm_2_0` in `reflect` and `ibc-reflect`
  • Loading branch information
chipshort authored Feb 8, 2024
2 parents b23fbba + b131ab5 commit 8f3695e
Show file tree
Hide file tree
Showing 6 changed files with 257 additions and 2 deletions.
2 changes: 1 addition & 1 deletion contracts/ibc-reflect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ cranelift = ["cosmwasm-vm/cranelift"]

[dependencies]
cosmwasm-schema = { path = "../../packages/schema" }
cosmwasm-std = { path = "../../packages/std", features = ["iterator", "stargate"] }
cosmwasm-std = { path = "../../packages/std", features = ["iterator", "stargate", "cosmwasm_2_0"] }
schemars = "0.8.3"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }

Expand Down
131 changes: 131 additions & 0 deletions contracts/ibc-reflect/schema/ibc/packet_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@
}
],
"definitions": {
"AnyMsg": {
"description": "A message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)",
"type": "object",
"required": [
"type_url",
"value"
],
"properties": {
"type_url": {
"type": "string"
},
"value": {
"$ref": "#/definitions/Binary"
}
}
},
"BankMsg": {
"description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto",
"oneOf": [
Expand Down Expand Up @@ -214,6 +230,18 @@
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"any"
],
"properties": {
"any": {
"$ref": "#/definitions/AnyMsg"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
Expand Down Expand Up @@ -252,6 +280,10 @@
}
]
},
"Decimal": {
"description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)",
"type": "string"
},
"Empty": {
"description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)",
"type": "object"
Expand Down Expand Up @@ -290,6 +322,36 @@
}
},
"additionalProperties": false
},
{
"description": "This maps directly to [MsgVoteWeighted](https://github.com/cosmos/cosmos-sdk/blob/v0.45.8/proto/cosmos/gov/v1beta1/tx.proto#L66-L78) in the Cosmos SDK with voter set to the contract address.",
"type": "object",
"required": [
"vote_weighted"
],
"properties": {
"vote_weighted": {
"type": "object",
"required": [
"options",
"proposal_id"
],
"properties": {
"options": {
"type": "array",
"items": {
"$ref": "#/definitions/WeightedVoteOption"
}
},
"proposal_id": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
}
}
},
"additionalProperties": false
}
]
},
Expand Down Expand Up @@ -568,6 +630,60 @@
},
"additionalProperties": false
},
{
"description": "Instantiates a new contracts from previously uploaded Wasm code using a predictable address derivation algorithm implemented in [`cosmwasm_std::instantiate2_address`].\n\nThis is translated to a [MsgInstantiateContract2](https://github.com/CosmWasm/wasmd/blob/v0.29.2/proto/cosmwasm/wasm/v1/tx.proto#L73-L96). `sender` is automatically filled with the current contract's address. `fix_msg` is automatically set to false.",
"type": "object",
"required": [
"instantiate2"
],
"properties": {
"instantiate2": {
"type": "object",
"required": [
"code_id",
"funds",
"label",
"msg",
"salt"
],
"properties": {
"admin": {
"type": [
"string",
"null"
]
},
"code_id": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"funds": {
"type": "array",
"items": {
"$ref": "#/definitions/Coin"
}
},
"label": {
"description": "A human-readable label for the contract.\n\nValid values should: - not be empty - not be bigger than 128 bytes (or some chain-specific limit) - not start / end with whitespace",
"type": "string"
},
"msg": {
"description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)",
"allOf": [
{
"$ref": "#/definitions/Binary"
}
]
},
"salt": {
"$ref": "#/definitions/Binary"
}
}
}
},
"additionalProperties": false
},
{
"description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address.",
"type": "object",
Expand Down Expand Up @@ -652,6 +768,21 @@
"additionalProperties": false
}
]
},
"WeightedVoteOption": {
"type": "object",
"required": [
"option",
"weight"
],
"properties": {
"option": {
"$ref": "#/definitions/VoteOption"
},
"weight": {
"$ref": "#/definitions/Decimal"
}
}
}
}
}
2 changes: 1 addition & 1 deletion contracts/reflect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ cranelift = ["cosmwasm-vm/cranelift"]

[dependencies]
cosmwasm-schema = { path = "../../packages/schema" }
cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["std", "staking", "stargate", "cosmwasm_1_4"] }
cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["std", "staking", "stargate", "cosmwasm_2_0"] }
schemars = "0.8.3"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
thiserror = "1.0.26"
Expand Down
28 changes: 28 additions & 0 deletions contracts/reflect/schema/raw/execute.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@
}
],
"definitions": {
"AnyMsg": {
"description": "A message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)",
"type": "object",
"required": [
"type_url",
"value"
],
"properties": {
"type_url": {
"type": "string"
},
"value": {
"$ref": "#/definitions/Binary"
}
}
},
"BankMsg": {
"description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto",
"oneOf": [
Expand Down Expand Up @@ -199,6 +215,18 @@
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"any"
],
"properties": {
"any": {
"$ref": "#/definitions/AnyMsg"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
Expand Down
34 changes: 34 additions & 0 deletions contracts/reflect/schema/raw/query.json
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,28 @@
}
]
},
"GrpcQuery": {
"description": "Queries the chain using a grpc query. This allows to query information that is not exposed in our API. The chain needs to allowlist the supported queries. The drawback of this query is that you have to handle the protobuf encoding and decoding yourself.\n\nThe returned data is protobuf encoded. The protobuf type depends on the query.\n\nTo find the path, as well as the request and response types, you can query the chain's gRPC endpoint using a tool like [grpcurl](https://github.com/fullstorydev/grpcurl).",
"type": "object",
"required": [
"data",
"path"
],
"properties": {
"data": {
"description": "The expected protobuf message type (not [Any](https://protobuf.dev/programming-guides/proto3/#any)), binary encoded",
"allOf": [
{
"$ref": "#/definitions/Binary"
}
]
},
"path": {
"description": "The fully qualified endpoint path used for routing. It follows the format `/service_path/method_name`, eg. \"/cosmos.authz.v1beta1.Query/Grants\"",
"type": "string"
}
}
},
"IbcQuery": {
"description": "These are queries to the various IBC modules to see the state of the contract's IBC connection. These will return errors if the contract is not \"ibc enabled\"",
"oneOf": [
Expand Down Expand Up @@ -523,6 +545,18 @@
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"grpc"
],
"properties": {
"grpc": {
"$ref": "#/definitions/GrpcQuery"
}
},
"additionalProperties": false
}
]
},
Expand Down
62 changes: 62 additions & 0 deletions contracts/reflect/schema/reflect.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@
}
],
"definitions": {
"AnyMsg": {
"description": "A message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)",
"type": "object",
"required": [
"type_url",
"value"
],
"properties": {
"type_url": {
"type": "string"
},
"value": {
"$ref": "#/definitions/Binary"
}
}
},
"BankMsg": {
"description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto",
"oneOf": [
Expand Down Expand Up @@ -209,6 +225,18 @@
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"any"
],
"properties": {
"any": {
"$ref": "#/definitions/AnyMsg"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
Expand Down Expand Up @@ -1336,6 +1364,28 @@
}
]
},
"GrpcQuery": {
"description": "Queries the chain using a grpc query. This allows to query information that is not exposed in our API. The chain needs to allowlist the supported queries. The drawback of this query is that you have to handle the protobuf encoding and decoding yourself.\n\nThe returned data is protobuf encoded. The protobuf type depends on the query.\n\nTo find the path, as well as the request and response types, you can query the chain's gRPC endpoint using a tool like [grpcurl](https://github.com/fullstorydev/grpcurl).",
"type": "object",
"required": [
"data",
"path"
],
"properties": {
"data": {
"description": "The expected protobuf message type (not [Any](https://protobuf.dev/programming-guides/proto3/#any)), binary encoded",
"allOf": [
{
"$ref": "#/definitions/Binary"
}
]
},
"path": {
"description": "The fully qualified endpoint path used for routing. It follows the format `/service_path/method_name`, eg. \"/cosmos.authz.v1beta1.Query/Grants\"",
"type": "string"
}
}
},
"IbcQuery": {
"description": "These are queries to the various IBC modules to see the state of the contract's IBC connection. These will return errors if the contract is not \"ibc enabled\"",
"oneOf": [
Expand Down Expand Up @@ -1535,6 +1585,18 @@
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"grpc"
],
"properties": {
"grpc": {
"$ref": "#/definitions/GrpcQuery"
}
},
"additionalProperties": false
}
]
},
Expand Down

0 comments on commit 8f3695e

Please sign in to comment.