Fix message representation for signing (#658)

* Introduce RawContractMessage type

* Add json signbytes test for proposals

* No assumptions on MsgIBCSend.data content

* Smart query uses RawContractMessage

* Revert method signature change to be consistent

* Review comment

* Update after discussions
This commit is contained in:
Alexander Peters
2021-10-25 15:23:19 +02:00
committed by GitHub
parent 465c085e15
commit dfba1395d9
26 changed files with 438 additions and 323 deletions

View File

@@ -20,8 +20,9 @@ message MsgIBCSend {
uint64 timeout_timestamp = 5
[ (gogoproto.moretags) = "yaml:\"timeout_timestamp\"" ];
// data is the payload to transfer
bytes data = 6 [ (gogoproto.casttype) = "encoding/json.RawMessage" ];
// Data is the payload to transfer. We must not make assumption what format or
// content is in here.
bytes data = 6;
}
// MsgIBCCloseChannel port and channel need to be owned by the contract

View File

@@ -42,7 +42,7 @@ message InstantiateContractProposal {
// Label is optional metadata to be stored with a constract instance.
string label = 6;
// Msg json encoded message to be passed to the contract on instantiation
bytes msg = 7;
bytes msg = 7 [ (gogoproto.casttype) = "RawContractMessage" ];
// Funds coins that are transferred to the contract on instantiation
repeated cosmos.base.v1beta1.Coin funds = 8 [
(gogoproto.nullable) = false,
@@ -63,7 +63,7 @@ message MigrateContractProposal {
// CodeID references the new WASM code
uint64 code_id = 5 [ (gogoproto.customname) = "CodeID" ];
// Msg json encoded message to be passed to the contract on migration
bytes msg = 6;
bytes msg = 6 [ (gogoproto.casttype) = "RawContractMessage" ];
}
// UpdateAdminProposal gov proposal content type to set an admin for a contract.

View File

@@ -154,14 +154,14 @@ message QuerySmartContractStateRequest {
// address is the address of the contract
string address = 1;
// QueryData contains the query data passed to the contract
bytes query_data = 2;
bytes query_data = 2 [ (gogoproto.casttype) = "RawContractMessage" ];
}
// QuerySmartContractStateResponse is the response type for the
// Query/SmartContractState RPC method
message QuerySmartContractStateResponse {
// Data contains the json data returned from the smart contract
bytes data = 1 [ (gogoproto.casttype) = "encoding/json.RawMessage" ];
bytes data = 1 [ (gogoproto.casttype) = "RawContractMessage" ];
}
// QueryCodeRequest is the request type for the Query/Code RPC method

View File

@@ -55,7 +55,7 @@ message MsgInstantiateContract {
// Label is optional metadata to be stored with a contract instance.
string label = 4;
// Msg json encoded message to be passed to the contract on instantiation
bytes msg = 5;
bytes msg = 5 [ (gogoproto.casttype) = "RawContractMessage" ];
// Funds coins that are transferred to the contract on instantiation
repeated cosmos.base.v1beta1.Coin funds = 6 [
(gogoproto.nullable) = false,
@@ -77,7 +77,7 @@ message MsgExecuteContract {
// Contract is the address of the smart contract
string contract = 2;
// Msg json encoded message to be passed to the contract
bytes msg = 3;
bytes msg = 3 [ (gogoproto.casttype) = "RawContractMessage" ];
// Funds coins that are transferred to the contract on execution
repeated cosmos.base.v1beta1.Coin funds = 5 [
(gogoproto.nullable) = false,
@@ -100,7 +100,7 @@ message MsgMigrateContract {
// CodeID references the new WASM code
uint64 code_id = 3 [ (gogoproto.customname) = "CodeID" ];
// Msg json encoded message to be passed to the contract on migration
bytes msg = 4;
bytes msg = 4 [ (gogoproto.casttype) = "RawContractMessage" ];
}
// MsgMigrateContractResponse returns contract migration result data.

View File

@@ -117,7 +117,7 @@ message ContractCodeHistoryEntry {
uint64 code_id = 2 [ (gogoproto.customname) = "CodeID" ];
// Updated Tx position when the operation was executed.
AbsoluteTxPosition updated = 3;
bytes msg = 4 [ (gogoproto.casttype) = "encoding/json.RawMessage" ];
bytes msg = 4 [ (gogoproto.casttype) = "RawContractMessage" ];
}
// AbsoluteTxPosition is a unique transaction position that allows for global