Regenerate protobuf codec

This commit is contained in:
Ethan Frey 2021-04-28 21:58:29 +02:00
parent 2662e3e2c9
commit 00444bf2bb
6 changed files with 135 additions and 126 deletions

View File

@ -37,7 +37,7 @@
"coverage": "nyc --reporter=text --reporter=lcov yarn test --quiet",
"pack-web": "yarn build-or-skip && webpack --mode development --config webpack.web.config.js",
"preget-proto": "shx rm -rf proto",
"get-proto": "WASM_REF=v0.16.0-alpha1 COSMOS_SDK_REF=v0.42.0 ./scripts/get-proto.sh",
"get-proto": "WASM_REF=v0.16.0-alpha2 COSMOS_SDK_REF=v0.42.4 ./scripts/get-proto.sh",
"define-proto": "./scripts/define-proto.sh",
"postdefine-proto": "prettier --write \"src/codec/**/*.ts\""
},

View File

@ -5,7 +5,7 @@ command -v shellcheck >/dev/null && shellcheck "$0"
ROOT_PROTO_DIR="./proto"
COSMOS_PROTO_DIR="$ROOT_PROTO_DIR/cosmos/cosmos-sdk/proto"
THIRD_PARTY_PROTO_DIR="$ROOT_PROTO_DIR/cosmos/cosmos-sdk/third_party/proto"
WASMD_PROTO_DIR="$ROOT_PROTO_DIR/cosmwasm/wasmd"
WASMD_PROTO_DIR="$ROOT_PROTO_DIR/cosmwasm/wasmd/proto"
OUT_DIR="./src/codec/"
mkdir -p "$OUT_DIR"
@ -17,9 +17,9 @@ protoc \
--proto_path="$THIRD_PARTY_PROTO_DIR" \
--proto_path="$WASMD_PROTO_DIR" \
--ts_proto_opt="esModuleInterop=true,forceLong=long,useOptionals=true" \
"$WASMD_PROTO_DIR/x/wasm/internal/types/types.proto" \
"$WASMD_PROTO_DIR/x/wasm/internal/types/query.proto" \
"$WASMD_PROTO_DIR/x/wasm/internal/types/tx.proto" \
"$WASMD_PROTO_DIR/cosmwasm/wasm/v1beta1/types.proto" \
"$WASMD_PROTO_DIR/cosmwasm/wasm/v1beta1/query.proto" \
"$WASMD_PROTO_DIR/cosmwasm/wasm/v1beta1/tx.proto" \
"$COSMOS_PROTO_DIR/cosmos/base/v1beta1/coin.proto" \
"$COSMOS_PROTO_DIR/cosmos/base/query/v1beta1/pagination.proto"

View File

@ -0,0 +1,10 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
export const protobufPackage = "cosmos_proto";
if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}

View File

@ -1,25 +1,34 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
import { ContractInfo, ContractCodeHistoryEntry, Model } from "../../../../x/wasm/internal/types/types";
import { PageRequest, PageResponse } from "../../../../cosmos/base/query/v1beta1/pagination";
import { ContractInfo, ContractCodeHistoryEntry, Model } from "../../../cosmwasm/wasm/v1beta1/types";
import { PageRequest, PageResponse } from "../../../cosmos/base/query/v1beta1/pagination";
export const protobufPackage = "cosmwasm.wasm.v1beta1";
/** QueryContractInfoRequest is the request type for the Query/ContractInfo RPC method */
/**
* QueryContractInfoRequest is the request type for the Query/ContractInfo RPC
* method
*/
export interface QueryContractInfoRequest {
/** address is the address of the contract to query */
address: string;
}
/** QueryContractInfoResponse is the response type for the Query/ContractInfo RPC method */
/**
* QueryContractInfoResponse is the response type for the Query/ContractInfo RPC
* method
*/
export interface QueryContractInfoResponse {
/** address is the address of the contract */
address: string;
contractInfo?: ContractInfo;
}
/** QueryContractHistoryRequest is the request type for the Query/ContractHistory RPC method */
/**
* QueryContractHistoryRequest is the request type for the Query/ContractHistory
* RPC method
*/
export interface QueryContractHistoryRequest {
/** address is the address of the contract to query */
address: string;
@ -27,14 +36,20 @@ export interface QueryContractHistoryRequest {
pagination?: PageRequest;
}
/** QueryContractHistoryResponse is the response type for the Query/ContractHistory RPC method */
/**
* QueryContractHistoryResponse is the response type for the
* Query/ContractHistory RPC method
*/
export interface QueryContractHistoryResponse {
entries: ContractCodeHistoryEntry[];
/** pagination defines the pagination in the response. */
pagination?: PageResponse;
}
/** QueryContractsByCodeRequest is the request type for the Query/ContractsByCode RPC method */
/**
* QueryContractsByCodeRequest is the request type for the Query/ContractsByCode
* RPC method
*/
export interface QueryContractsByCodeRequest {
/** grpc-gateway_out does not support Go style CodID */
codeId: Long;
@ -42,20 +57,21 @@ export interface QueryContractsByCodeRequest {
pagination?: PageRequest;
}
/** ContractInfoWithAddress adds the address (key) to the ContractInfo representation */
export interface ContractInfoWithAddress {
address: string;
contractInfo?: ContractInfo;
}
/** QueryContractsByCodeResponse is the response type for the Query/ContractsByCode RPC method */
/**
* QueryContractsByCodeResponse is the response type for the
* Query/ContractsByCode RPC method
*/
export interface QueryContractsByCodeResponse {
contractInfos: ContractInfoWithAddress[];
/** contracts are a set of contract addresses */
contracts: string[];
/** pagination defines the pagination in the response. */
pagination?: PageResponse;
}
/** QueryAllContractStateRequest is the request type for the Query/AllContractState RPC method */
/**
* QueryAllContractStateRequest is the request type for the
* Query/AllContractState RPC method
*/
export interface QueryAllContractStateRequest {
/** address is the address of the contract */
address: string;
@ -63,27 +79,39 @@ export interface QueryAllContractStateRequest {
pagination?: PageRequest;
}
/** QueryAllContractStateResponse is the response type for the Query/AllContractState RPC method */
/**
* QueryAllContractStateResponse is the response type for the
* Query/AllContractState RPC method
*/
export interface QueryAllContractStateResponse {
models: Model[];
/** pagination defines the pagination in the response. */
pagination?: PageResponse;
}
/** QueryRawContractStateRequest is the request type for the Query/RawContractState RPC method */
/**
* QueryRawContractStateRequest is the request type for the
* Query/RawContractState RPC method
*/
export interface QueryRawContractStateRequest {
/** address is the address of the contract */
address: string;
queryData: Uint8Array;
}
/** QueryRawContractStateResponse is the response type for the Query/RawContractState RPC method */
/**
* QueryRawContractStateResponse is the response type for the
* Query/RawContractState RPC method
*/
export interface QueryRawContractStateResponse {
/** Data contains the raw store data */
data: Uint8Array;
}
/** QuerySmartContractStateRequest is the request type for the Query/SmartContractState RPC method */
/**
* QuerySmartContractStateRequest is the request type for the
* Query/SmartContractState RPC method
*/
export interface QuerySmartContractStateRequest {
/** address is the address of the contract */
address: string;
@ -91,7 +119,10 @@ export interface QuerySmartContractStateRequest {
queryData: Uint8Array;
}
/** QuerySmartContractStateResponse is the response type for the Query/SmartContractState RPC method */
/**
* QuerySmartContractStateResponse is the response type for the
* Query/SmartContractState RPC method
*/
export interface QuerySmartContractStateResponse {
/** Data contains the json data returned from the smart contract */
data: Uint8Array;
@ -486,85 +517,12 @@ export const QueryContractsByCodeRequest = {
},
};
const baseContractInfoWithAddress: object = { address: "" };
export const ContractInfoWithAddress = {
encode(message: ContractInfoWithAddress, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.address !== "") {
writer.uint32(10).string(message.address);
}
if (message.contractInfo !== undefined) {
ContractInfo.encode(message.contractInfo, writer.uint32(18).fork()).ldelim();
}
return writer;
},
decode(input: _m0.Reader | Uint8Array, length?: number): ContractInfoWithAddress {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = { ...baseContractInfoWithAddress } as ContractInfoWithAddress;
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.address = reader.string();
break;
case 2:
message.contractInfo = ContractInfo.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromJSON(object: any): ContractInfoWithAddress {
const message = { ...baseContractInfoWithAddress } as ContractInfoWithAddress;
if (object.address !== undefined && object.address !== null) {
message.address = String(object.address);
} else {
message.address = "";
}
if (object.contractInfo !== undefined && object.contractInfo !== null) {
message.contractInfo = ContractInfo.fromJSON(object.contractInfo);
} else {
message.contractInfo = undefined;
}
return message;
},
toJSON(message: ContractInfoWithAddress): unknown {
const obj: any = {};
message.address !== undefined && (obj.address = message.address);
message.contractInfo !== undefined &&
(obj.contractInfo = message.contractInfo ? ContractInfo.toJSON(message.contractInfo) : undefined);
return obj;
},
fromPartial(object: DeepPartial<ContractInfoWithAddress>): ContractInfoWithAddress {
const message = { ...baseContractInfoWithAddress } as ContractInfoWithAddress;
if (object.address !== undefined && object.address !== null) {
message.address = object.address;
} else {
message.address = "";
}
if (object.contractInfo !== undefined && object.contractInfo !== null) {
message.contractInfo = ContractInfo.fromPartial(object.contractInfo);
} else {
message.contractInfo = undefined;
}
return message;
},
};
const baseQueryContractsByCodeResponse: object = {};
const baseQueryContractsByCodeResponse: object = { contracts: "" };
export const QueryContractsByCodeResponse = {
encode(message: QueryContractsByCodeResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
for (const v of message.contractInfos) {
ContractInfoWithAddress.encode(v!, writer.uint32(10).fork()).ldelim();
for (const v of message.contracts) {
writer.uint32(10).string(v!);
}
if (message.pagination !== undefined) {
PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim();
@ -576,12 +534,12 @@ export const QueryContractsByCodeResponse = {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = { ...baseQueryContractsByCodeResponse } as QueryContractsByCodeResponse;
message.contractInfos = [];
message.contracts = [];
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.contractInfos.push(ContractInfoWithAddress.decode(reader, reader.uint32()));
message.contracts.push(reader.string());
break;
case 2:
message.pagination = PageResponse.decode(reader, reader.uint32());
@ -596,10 +554,10 @@ export const QueryContractsByCodeResponse = {
fromJSON(object: any): QueryContractsByCodeResponse {
const message = { ...baseQueryContractsByCodeResponse } as QueryContractsByCodeResponse;
message.contractInfos = [];
if (object.contractInfos !== undefined && object.contractInfos !== null) {
for (const e of object.contractInfos) {
message.contractInfos.push(ContractInfoWithAddress.fromJSON(e));
message.contracts = [];
if (object.contracts !== undefined && object.contracts !== null) {
for (const e of object.contracts) {
message.contracts.push(String(e));
}
}
if (object.pagination !== undefined && object.pagination !== null) {
@ -612,12 +570,10 @@ export const QueryContractsByCodeResponse = {
toJSON(message: QueryContractsByCodeResponse): unknown {
const obj: any = {};
if (message.contractInfos) {
obj.contractInfos = message.contractInfos.map((e) =>
e ? ContractInfoWithAddress.toJSON(e) : undefined,
);
if (message.contracts) {
obj.contracts = message.contracts.map((e) => e);
} else {
obj.contractInfos = [];
obj.contracts = [];
}
message.pagination !== undefined &&
(obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined);
@ -626,10 +582,10 @@ export const QueryContractsByCodeResponse = {
fromPartial(object: DeepPartial<QueryContractsByCodeResponse>): QueryContractsByCodeResponse {
const message = { ...baseQueryContractsByCodeResponse } as QueryContractsByCodeResponse;
message.contractInfos = [];
if (object.contractInfos !== undefined && object.contractInfos !== null) {
for (const e of object.contractInfos) {
message.contractInfos.push(ContractInfoWithAddress.fromPartial(e));
message.contracts = [];
if (object.contracts !== undefined && object.contracts !== null) {
for (const e of object.contracts) {
message.contracts.push(e);
}
}
if (object.pagination !== undefined && object.pagination !== null) {

View File

@ -1,8 +1,8 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
import { AccessConfig } from "../../../../x/wasm/internal/types/types";
import { Coin } from "../../../../cosmos/base/v1beta1/coin";
import { AccessConfig } from "../../../cosmwasm/wasm/v1beta1/types";
import { Coin } from "../../../cosmos/base/v1beta1/coin";
export const protobufPackage = "cosmwasm.wasm.v1beta1";
@ -12,11 +12,17 @@ export interface MsgStoreCode {
sender: string;
/** WASMByteCode can be raw or gzip compressed */
wasmByteCode: Uint8Array;
/** Source is a valid absolute HTTPS URI to the contract's source code, optional */
/**
* Source is a valid absolute HTTPS URI to the contract's source code,
* optional
*/
source: string;
/** Builder is a valid docker image name with tag, optional */
builder: string;
/** InstantiatePermission access control to apply on contract creation, optional */
/**
* InstantiatePermission access control to apply on contract creation,
* optional
*/
instantiatePermission?: AccessConfig;
}
@ -26,7 +32,10 @@ export interface MsgStoreCodeResponse {
codeId: Long;
}
/** MsgInstantiateContract create a new smart contract instance for the given code id. */
/**
* MsgInstantiateContract create a new smart contract instance for the given
* code id.
*/
export interface MsgInstantiateContract {
/** Sender is the that actor that signed the messages */
sender: string;

View File

@ -1,6 +1,7 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
import { Any } from "../../../google/protobuf/any";
export const protobufPackage = "cosmwasm.wasm.v1beta1";
@ -126,7 +127,10 @@ export interface CodeInfo {
codeHash: Uint8Array;
/** Creator address who initially stored the code */
creator: string;
/** Source is a valid absolute HTTPS URI to the contract's source code, optional */
/**
* Source is a valid absolute HTTPS URI to the contract's source code,
* optional
*/
source: string;
/** Builder is a valid docker image name with tag, optional */
builder: string;
@ -146,10 +150,16 @@ export interface ContractInfo {
label: string;
/**
* Created Tx position when the contract was instantiated.
* This data should kept internal and not be exposed via query results. Just use for sorting
* This data should kept internal and not be exposed via query results. Just
* use for sorting
*/
created?: AbsoluteTxPosition;
ibcPortId: string;
/**
* Extension is an extension point to store custom metadata within the
* persistence model.
*/
extension?: Any;
}
/** ContractCodeHistoryEntry metadata to a contract. */
@ -162,11 +172,17 @@ export interface ContractCodeHistoryEntry {
msg: Uint8Array;
}
/** AbsoluteTxPosition is a unique transaction position that allows for global ordering of transactions. */
/**
* AbsoluteTxPosition is a unique transaction position that allows for global
* ordering of transactions.
*/
export interface AbsoluteTxPosition {
/** BlockHeight is the block the contract was created at */
blockHeight: Long;
/** TxIndex is a monotonic counter within the block (actual transaction index, or gas consumed) */
/**
* TxIndex is a monotonic counter within the block (actual transaction index,
* or gas consumed)
*/
txIndex: Long;
}
@ -548,6 +564,9 @@ export const ContractInfo = {
if (message.ibcPortId !== "") {
writer.uint32(50).string(message.ibcPortId);
}
if (message.extension !== undefined) {
Any.encode(message.extension, writer.uint32(58).fork()).ldelim();
}
return writer;
},
@ -576,6 +595,9 @@ export const ContractInfo = {
case 6:
message.ibcPortId = reader.string();
break;
case 7:
message.extension = Any.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
break;
@ -616,6 +638,11 @@ export const ContractInfo = {
} else {
message.ibcPortId = "";
}
if (object.extension !== undefined && object.extension !== null) {
message.extension = Any.fromJSON(object.extension);
} else {
message.extension = undefined;
}
return message;
},
@ -628,6 +655,8 @@ export const ContractInfo = {
message.created !== undefined &&
(obj.created = message.created ? AbsoluteTxPosition.toJSON(message.created) : undefined);
message.ibcPortId !== undefined && (obj.ibcPortId = message.ibcPortId);
message.extension !== undefined &&
(obj.extension = message.extension ? Any.toJSON(message.extension) : undefined);
return obj;
},
@ -663,6 +692,11 @@ export const ContractInfo = {
} else {
message.ibcPortId = "";
}
if (object.extension !== undefined && object.extension !== null) {
message.extension = Any.fromPartial(object.extension);
} else {
message.extension = undefined;
}
return message;
},
};