Skip to content
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

Update types to Cosmos SDK 0.43 RC2 #4

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "wasmd-0.18"]
path = wasmd-0.18
url = https://github.com/CosmWasm/wasmd.git
[submodule "cosmos-sdk-0.43"]
path = cosmos-sdk-0.43
url = https://github.com/cosmos/cosmos-sdk
1 change: 1 addition & 0 deletions cosmos-sdk-0.43
Submodule cosmos-sdk-0.43 added at 0ab572
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
],
"scripts": {
"format": "prettier --write --loglevel warn \"./src/**/*.ts\"",
"define-proto": "./scripts/define-proto.sh && yarn format",
"define-proto": "./scripts/define-proto.sh && ./scripts/define-proto-cosmos-sdk.sh && yarn format",
"prepare": "./scripts/prepare.sh",
"build": "rm -rf ./build && tsc && yarn prepare"
},
Expand Down
75 changes: 75 additions & 0 deletions scripts/define-proto-cosmos-sdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail
command -v shellcheck >/dev/null && shellcheck "$0"

OUT_DIR="./src"
COSMOS_SDK_DIR="./cosmos-sdk-0.43/proto"
COSMOS_SDK_THIRD_PARTY_DIR="./cosmos-sdk-0.43/third_party/proto"

PLUGIN_PATH="$(realpath ./bin)/protoc-gen-ts_proto_yarn_2"

mkdir -p "$OUT_DIR"

protoc \
--plugin="$PLUGIN_PATH" \
--ts_proto_yarn_2_out="$OUT_DIR" \
--proto_path="$COSMOS_SDK_DIR" \
--proto_path="$COSMOS_SDK_THIRD_PARTY_DIR" \
--ts_proto_yarn_2_opt="esModuleInterop=true,forceLong=long,useOptionals=true" \
"$COSMOS_SDK_DIR/cosmos/auth/v1beta1/auth.proto" \
"$COSMOS_SDK_DIR/cosmos/auth/v1beta1/genesis.proto" \
"$COSMOS_SDK_DIR/cosmos/auth/v1beta1/query.proto" \
"$COSMOS_SDK_DIR/cosmos/bank/v1beta1/bank.proto" \
"$COSMOS_SDK_DIR/cosmos/bank/v1beta1/genesis.proto" \
"$COSMOS_SDK_DIR/cosmos/bank/v1beta1/query.proto" \
"$COSMOS_SDK_DIR/cosmos/bank/v1beta1/tx.proto" \
"$COSMOS_SDK_DIR/cosmos/base/abci/v1beta1/abci.proto" \
"$COSMOS_SDK_DIR/cosmos/base/kv/v1beta1/kv.proto" \
"$COSMOS_SDK_DIR/cosmos/base/query/v1beta1/pagination.proto" \
"$COSMOS_SDK_DIR/cosmos/base/reflection/v1beta1/reflection.proto" \
"$COSMOS_SDK_DIR/cosmos/base/snapshots/v1beta1/snapshot.proto" \
"$COSMOS_SDK_DIR/cosmos/base/store/v1beta1/commit_info.proto" \
"$COSMOS_SDK_DIR/cosmos/base/store/v1beta1/snapshot.proto" \
"$COSMOS_SDK_DIR/cosmos/base/tendermint/v1beta1/query.proto" \
"$COSMOS_SDK_DIR/cosmos/base/v1beta1/coin.proto" \
"$COSMOS_SDK_DIR/cosmos/capability/v1beta1/capability.proto" \
"$COSMOS_SDK_DIR/cosmos/capability/v1beta1/genesis.proto" \
"$COSMOS_SDK_DIR/cosmos/crisis/v1beta1/genesis.proto" \
"$COSMOS_SDK_DIR/cosmos/crisis/v1beta1/tx.proto" \
"$COSMOS_SDK_DIR/cosmos/crypto/ed25519/keys.proto" \
"$COSMOS_SDK_DIR/cosmos/crypto/multisig/keys.proto" \
"$COSMOS_SDK_DIR/cosmos/crypto/multisig/v1beta1/multisig.proto" \
"$COSMOS_SDK_DIR/cosmos/crypto/secp256k1/keys.proto" \
"$COSMOS_SDK_DIR/cosmos/distribution/v1beta1/distribution.proto" \
"$COSMOS_SDK_DIR/cosmos/distribution/v1beta1/genesis.proto" \
"$COSMOS_SDK_DIR/cosmos/distribution/v1beta1/query.proto" \
"$COSMOS_SDK_DIR/cosmos/distribution/v1beta1/tx.proto" \
"$COSMOS_SDK_DIR/cosmos/evidence/v1beta1/evidence.proto" \
"$COSMOS_SDK_DIR/cosmos/evidence/v1beta1/genesis.proto" \
"$COSMOS_SDK_DIR/cosmos/evidence/v1beta1/query.proto" \
"$COSMOS_SDK_DIR/cosmos/evidence/v1beta1/tx.proto" \
"$COSMOS_SDK_DIR/cosmos/genutil/v1beta1/genesis.proto" \
"$COSMOS_SDK_DIR/cosmos/gov/v1beta1/genesis.proto" \
"$COSMOS_SDK_DIR/cosmos/gov/v1beta1/gov.proto" \
"$COSMOS_SDK_DIR/cosmos/gov/v1beta1/query.proto" \
"$COSMOS_SDK_DIR/cosmos/gov/v1beta1/tx.proto" \
"$COSMOS_SDK_DIR/cosmos/mint/v1beta1/genesis.proto" \
"$COSMOS_SDK_DIR/cosmos/mint/v1beta1/mint.proto" \
"$COSMOS_SDK_DIR/cosmos/mint/v1beta1/query.proto" \
"$COSMOS_SDK_DIR/cosmos/params/v1beta1/params.proto" \
"$COSMOS_SDK_DIR/cosmos/params/v1beta1/query.proto" \
"$COSMOS_SDK_DIR/cosmos/slashing/v1beta1/genesis.proto" \
"$COSMOS_SDK_DIR/cosmos/slashing/v1beta1/query.proto" \
"$COSMOS_SDK_DIR/cosmos/slashing/v1beta1/slashing.proto" \
"$COSMOS_SDK_DIR/cosmos/slashing/v1beta1/tx.proto" \
"$COSMOS_SDK_DIR/cosmos/staking/v1beta1/genesis.proto" \
"$COSMOS_SDK_DIR/cosmos/staking/v1beta1/query.proto" \
"$COSMOS_SDK_DIR/cosmos/staking/v1beta1/staking.proto" \
"$COSMOS_SDK_DIR/cosmos/staking/v1beta1/tx.proto" \
"$COSMOS_SDK_DIR/cosmos/tx/signing/v1beta1/signing.proto" \
"$COSMOS_SDK_DIR/cosmos/tx/v1beta1/service.proto" \
"$COSMOS_SDK_DIR/cosmos/tx/v1beta1/tx.proto" \
"$COSMOS_SDK_DIR/cosmos/upgrade/v1beta1/query.proto" \
"$COSMOS_SDK_DIR/cosmos/upgrade/v1beta1/upgrade.proto" \
"$COSMOS_SDK_DIR/cosmos/vesting/v1beta1/tx.proto" \
"$COSMOS_SDK_DIR/cosmos/vesting/v1beta1/vesting.proto"
160 changes: 160 additions & 0 deletions src/cosmos/auth/v1beta1/query.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
import { PageRequest, PageResponse } from "../../../cosmos/base/query/v1beta1/pagination";
import { Any } from "../../../google/protobuf/any";
import { Params } from "../../../cosmos/auth/v1beta1/auth";

export const protobufPackage = "cosmos.auth.v1beta1";

/** QueryAccountsRequest is the request type for the Query/Accounts RPC method. */
export interface QueryAccountsRequest {
/** pagination defines an optional pagination for the request. */
pagination?: PageRequest;
}

/** QueryAccountsResponse is the response type for the Query/Accounts RPC method. */
export interface QueryAccountsResponse {
/** accounts are the existing accounts */
accounts: Any[];
/** pagination defines the pagination in the response. */
pagination?: PageResponse;
}

/** QueryAccountRequest is the request type for the Query/Account RPC method. */
export interface QueryAccountRequest {
/** address defines the address to query for. */
Expand All @@ -27,6 +42,142 @@ export interface QueryParamsResponse {
params?: Params;
}

const baseQueryAccountsRequest: object = {};

export const QueryAccountsRequest = {
encode(message: QueryAccountsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.pagination !== undefined) {
PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim();
}
return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): QueryAccountsRequest {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = { ...baseQueryAccountsRequest } as QueryAccountsRequest;
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.pagination = PageRequest.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},

fromJSON(object: any): QueryAccountsRequest {
const message = { ...baseQueryAccountsRequest } as QueryAccountsRequest;
if (object.pagination !== undefined && object.pagination !== null) {
message.pagination = PageRequest.fromJSON(object.pagination);
} else {
message.pagination = undefined;
}
return message;
},

toJSON(message: QueryAccountsRequest): unknown {
const obj: any = {};
message.pagination !== undefined &&
(obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined);
return obj;
},

fromPartial(object: DeepPartial<QueryAccountsRequest>): QueryAccountsRequest {
const message = { ...baseQueryAccountsRequest } as QueryAccountsRequest;
if (object.pagination !== undefined && object.pagination !== null) {
message.pagination = PageRequest.fromPartial(object.pagination);
} else {
message.pagination = undefined;
}
return message;
},
};

const baseQueryAccountsResponse: object = {};

export const QueryAccountsResponse = {
encode(message: QueryAccountsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
for (const v of message.accounts) {
Any.encode(v!, writer.uint32(10).fork()).ldelim();
}
if (message.pagination !== undefined) {
PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim();
}
return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): QueryAccountsResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = { ...baseQueryAccountsResponse } as QueryAccountsResponse;
message.accounts = [];
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.accounts.push(Any.decode(reader, reader.uint32()));
break;
case 2:
message.pagination = PageResponse.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},

fromJSON(object: any): QueryAccountsResponse {
const message = { ...baseQueryAccountsResponse } as QueryAccountsResponse;
message.accounts = [];
if (object.accounts !== undefined && object.accounts !== null) {
for (const e of object.accounts) {
message.accounts.push(Any.fromJSON(e));
}
}
if (object.pagination !== undefined && object.pagination !== null) {
message.pagination = PageResponse.fromJSON(object.pagination);
} else {
message.pagination = undefined;
}
return message;
},

toJSON(message: QueryAccountsResponse): unknown {
const obj: any = {};
if (message.accounts) {
obj.accounts = message.accounts.map((e) => (e ? Any.toJSON(e) : undefined));
} else {
obj.accounts = [];
}
message.pagination !== undefined &&
(obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined);
return obj;
},

fromPartial(object: DeepPartial<QueryAccountsResponse>): QueryAccountsResponse {
const message = { ...baseQueryAccountsResponse } as QueryAccountsResponse;
message.accounts = [];
if (object.accounts !== undefined && object.accounts !== null) {
for (const e of object.accounts) {
message.accounts.push(Any.fromPartial(e));
}
}
if (object.pagination !== undefined && object.pagination !== null) {
message.pagination = PageResponse.fromPartial(object.pagination);
} else {
message.pagination = undefined;
}
return message;
},
};

const baseQueryAccountRequest: object = { address: "" };

export const QueryAccountRequest = {
Expand Down Expand Up @@ -233,6 +384,8 @@ export const QueryParamsResponse = {

/** Query defines the gRPC querier service. */
export interface Query {
/** Accounts returns all the existing accounts */
Accounts(request: QueryAccountsRequest): Promise<QueryAccountsResponse>;
/** Account returns account details based on address. */
Account(request: QueryAccountRequest): Promise<QueryAccountResponse>;
/** Params queries all parameters. */
Expand All @@ -243,9 +396,16 @@ export class QueryClientImpl implements Query {
private readonly rpc: Rpc;
constructor(rpc: Rpc) {
this.rpc = rpc;
this.Accounts = this.Accounts.bind(this);
this.Account = this.Account.bind(this);
this.Params = this.Params.bind(this);
}
Accounts(request: QueryAccountsRequest): Promise<QueryAccountsResponse> {
const data = QueryAccountsRequest.encode(request).finish();
const promise = this.rpc.request("cosmos.auth.v1beta1.Query", "Accounts", data);
return promise.then((data) => QueryAccountsResponse.decode(new _m0.Reader(data)));
}

Account(request: QueryAccountRequest): Promise<QueryAccountResponse> {
const data = QueryAccountRequest.encode(request).finish();
const promise = this.rpc.request("cosmos.auth.v1beta1.Query", "Account", data);
Expand Down
46 changes: 45 additions & 1 deletion src/cosmos/bank/v1beta1/bank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export interface Output {
/**
* Supply represents a struct that passively keeps track of the total supply
* amounts in the network.
* This message is deprecated now that supply is indexed by denom.
*
* @deprecated
*/
export interface Supply {
total: Coin[];
Expand Down Expand Up @@ -74,6 +77,13 @@ export interface Metadata {
* displayed in clients.
*/
display: string;
/** name defines the name of the token (eg: Cosmos Atom) */
name: string;
/**
* symbol is the token symbol usually shown on exchanges (eg: ATOM). This can
* be the same as the display.
*/
symbol: string;
}

const baseParams: object = { defaultSendEnabled: false };
Expand Down Expand Up @@ -543,7 +553,7 @@ export const DenomUnit = {
},
};

const baseMetadata: object = { description: "", base: "", display: "" };
const baseMetadata: object = { description: "", base: "", display: "", name: "", symbol: "" };

export const Metadata = {
encode(message: Metadata, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
Expand All @@ -559,6 +569,12 @@ export const Metadata = {
if (message.display !== "") {
writer.uint32(34).string(message.display);
}
if (message.name !== "") {
writer.uint32(42).string(message.name);
}
if (message.symbol !== "") {
writer.uint32(50).string(message.symbol);
}
return writer;
},

Expand All @@ -582,6 +598,12 @@ export const Metadata = {
case 4:
message.display = reader.string();
break;
case 5:
message.name = reader.string();
break;
case 6:
message.symbol = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
Expand Down Expand Up @@ -613,6 +635,16 @@ export const Metadata = {
} else {
message.display = "";
}
if (object.name !== undefined && object.name !== null) {
message.name = String(object.name);
} else {
message.name = "";
}
if (object.symbol !== undefined && object.symbol !== null) {
message.symbol = String(object.symbol);
} else {
message.symbol = "";
}
return message;
},

Expand All @@ -626,6 +658,8 @@ export const Metadata = {
}
message.base !== undefined && (obj.base = message.base);
message.display !== undefined && (obj.display = message.display);
message.name !== undefined && (obj.name = message.name);
message.symbol !== undefined && (obj.symbol = message.symbol);
return obj;
},

Expand All @@ -652,6 +686,16 @@ export const Metadata = {
} else {
message.display = "";
}
if (object.name !== undefined && object.name !== null) {
message.name = object.name;
} else {
message.name = "";
}
if (object.symbol !== undefined && object.symbol !== null) {
message.symbol = object.symbol;
} else {
message.symbol = "";
}
return message;
},
};
Expand Down
Loading