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

feat: ibc protobufs #7

Merged
merged 6 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions scripts/gen-protobufs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ const REPOS = [
repo: "osmosis-labs/osmosis",
paths: ["proto"],
},
{
repo: "cosmos/ibc-go#main",
paths: ["proto"],
}
];

const __dirname = dirname(fileURLToPath(import.meta.url));
Expand Down
26 changes: 26 additions & 0 deletions src/client/models/MsgTransfer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { PlainMessage } from "@bufbuild/protobuf";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's name this file and function MsgIbcTransfer to make it more obvious what it does

import { IbcApplicationsTransferV1MsgTransfer as ProtoMsgTransfer } from "cosmes/protobufs";

import { DeepPrettify } from "../../typeutils/prettify";
import { Adapter } from "./Adapter";

type Data = DeepPrettify<PlainMessage<ProtoMsgTransfer>>;

export class MsgTransfer implements Adapter {
private readonly data: Data;

constructor(data: Data) {
this.data = data;
}

public toProto() {
return new ProtoMsgTransfer(this.data);
}

public toAmino() {
return {
type: "ibc/MsgTransfer",
value: this.data,
};
}
}
134 changes: 134 additions & 0 deletions src/protobufs/capability/v1/capability_pb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file capability/v1/capability.proto (package capability.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck

import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, protoInt64 } from "@bufbuild/protobuf";

/**
* Capability defines an implementation of an object capability. The index
* provided to a Capability must be globally unique.
*
* @generated from message capability.v1.Capability
*/
export class Capability extends Message<Capability> {
/**
* @generated from field: uint64 index = 1;
*/
index = protoInt64.zero;

constructor(data?: PartialMessage<Capability>) {
super();
proto3.util.initPartial(data, this);
}

static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "capability.v1.Capability";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "index", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Capability {
return new Capability().fromBinary(bytes, options);
}

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Capability {
return new Capability().fromJson(jsonValue, options);
}

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Capability {
return new Capability().fromJsonString(jsonString, options);
}

static equals(a: Capability | PlainMessage<Capability> | undefined, b: Capability | PlainMessage<Capability> | undefined): boolean {
return proto3.util.equals(Capability, a, b);
}
}

/**
* Owner defines a single capability owner. An owner is defined by the name of
* capability and the module name.
*
* @generated from message capability.v1.Owner
*/
export class Owner extends Message<Owner> {
/**
* @generated from field: string module = 1;
*/
module = "";

/**
* @generated from field: string name = 2;
*/
name = "";

constructor(data?: PartialMessage<Owner>) {
super();
proto3.util.initPartial(data, this);
}

static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "capability.v1.Owner";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "module", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Owner {
return new Owner().fromBinary(bytes, options);
}

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Owner {
return new Owner().fromJson(jsonValue, options);
}

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Owner {
return new Owner().fromJsonString(jsonString, options);
}

static equals(a: Owner | PlainMessage<Owner> | undefined, b: Owner | PlainMessage<Owner> | undefined): boolean {
return proto3.util.equals(Owner, a, b);
}
}

/**
* CapabilityOwners defines a set of owners of a single Capability. The set of
* owners must be unique.
*
* @generated from message capability.v1.CapabilityOwners
*/
export class CapabilityOwners extends Message<CapabilityOwners> {
/**
* @generated from field: repeated capability.v1.Owner owners = 1;
*/
owners: Owner[] = [];

constructor(data?: PartialMessage<CapabilityOwners>) {
super();
proto3.util.initPartial(data, this);
}

static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "capability.v1.CapabilityOwners";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "owners", kind: "message", T: Owner, repeated: true },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): CapabilityOwners {
return new CapabilityOwners().fromBinary(bytes, options);
}

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): CapabilityOwners {
return new CapabilityOwners().fromJson(jsonValue, options);
}

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): CapabilityOwners {
return new CapabilityOwners().fromJsonString(jsonString, options);
}

static equals(a: CapabilityOwners | PlainMessage<CapabilityOwners> | undefined, b: CapabilityOwners | PlainMessage<CapabilityOwners> | undefined): boolean {
return proto3.util.equals(CapabilityOwners, a, b);
}
}

108 changes: 108 additions & 0 deletions src/protobufs/capability/v1/genesis_pb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file capability/v1/genesis.proto (package capability.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck

import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, protoInt64 } from "@bufbuild/protobuf";
import { CapabilityOwners } from "./capability_pb.js";

/**
* GenesisOwners defines the capability owners with their corresponding index.
*
* @generated from message capability.v1.GenesisOwners
*/
export class GenesisOwners extends Message<GenesisOwners> {
/**
* index is the index of the capability owner.
*
* @generated from field: uint64 index = 1;
*/
index = protoInt64.zero;

/**
* index_owners are the owners at the given index.
*
* @generated from field: capability.v1.CapabilityOwners index_owners = 2;
*/
indexOwners?: CapabilityOwners;

constructor(data?: PartialMessage<GenesisOwners>) {
super();
proto3.util.initPartial(data, this);
}

static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "capability.v1.GenesisOwners";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "index", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 2, name: "index_owners", kind: "message", T: CapabilityOwners },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GenesisOwners {
return new GenesisOwners().fromBinary(bytes, options);
}

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GenesisOwners {
return new GenesisOwners().fromJson(jsonValue, options);
}

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GenesisOwners {
return new GenesisOwners().fromJsonString(jsonString, options);
}

static equals(a: GenesisOwners | PlainMessage<GenesisOwners> | undefined, b: GenesisOwners | PlainMessage<GenesisOwners> | undefined): boolean {
return proto3.util.equals(GenesisOwners, a, b);
}
}

/**
* GenesisState defines the capability module's genesis state.
*
* @generated from message capability.v1.GenesisState
*/
export class GenesisState extends Message<GenesisState> {
/**
* index is the capability global index.
*
* @generated from field: uint64 index = 1;
*/
index = protoInt64.zero;

/**
* owners represents a map from index to owners of the capability index
* index key is string to allow amino marshalling.
*
* @generated from field: repeated capability.v1.GenesisOwners owners = 2;
*/
owners: GenesisOwners[] = [];

constructor(data?: PartialMessage<GenesisState>) {
super();
proto3.util.initPartial(data, this);
}

static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "capability.v1.GenesisState";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "index", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 2, name: "owners", kind: "message", T: GenesisOwners, repeated: true },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GenesisState {
return new GenesisState().fromBinary(bytes, options);
}

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GenesisState {
return new GenesisState().fromJson(jsonValue, options);
}

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GenesisState {
return new GenesisState().fromJsonString(jsonString, options);
}

static equals(a: GenesisState | PlainMessage<GenesisState> | undefined, b: GenesisState | PlainMessage<GenesisState> | undefined): boolean {
return proto3.util.equals(GenesisState, a, b);
}
}

10 changes: 10 additions & 0 deletions src/protobufs/cosmos/autocli/v1/options_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ export class ServiceCommandDescriptor extends Message<ServiceCommandDescriptor>
*/
subCommands: { [key: string]: ServiceCommandDescriptor } = {};

/**
* enhance_custom_commands specifies whether to skip the service when generating commands, if a custom command already exists,
* or enhance the existing command. If set to true, the custom command will be enhanced with the services from gRPC.
* otherwise when a custom command exists, no commands will be generated for the service.
*
* @generated from field: bool enhance_custom_command = 4;
*/
enhanceCustomCommand = false;

constructor(data?: PartialMessage<ServiceCommandDescriptor>) {
super();
proto3.util.initPartial(data, this);
Expand All @@ -99,6 +108,7 @@ export class ServiceCommandDescriptor extends Message<ServiceCommandDescriptor>
{ no: 1, name: "service", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "rpc_command_options", kind: "message", T: RpcCommandOptions, repeated: true },
{ no: 3, name: "sub_commands", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "message", T: ServiceCommandDescriptor} },
{ no: 4, name: "enhance_custom_command", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ServiceCommandDescriptor {
Expand Down
14 changes: 13 additions & 1 deletion src/protobufs/cosmos/bank/v1beta1/query_cosmes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* eslint-disable */
// @ts-nocheck

import { QueryAllBalancesRequest, QueryAllBalancesResponse, QueryBalanceRequest, QueryBalanceResponse, QueryDenomMetadataRequest, QueryDenomMetadataResponse, QueryDenomOwnersRequest, QueryDenomOwnersResponse, QueryDenomsMetadataRequest, QueryDenomsMetadataResponse, QueryParamsRequest, QueryParamsResponse, QuerySendEnabledRequest, QuerySendEnabledResponse, QuerySpendableBalanceByDenomRequest, QuerySpendableBalanceByDenomResponse, QuerySpendableBalancesRequest, QuerySpendableBalancesResponse, QuerySupplyOfRequest, QuerySupplyOfResponse, QueryTotalSupplyRequest, QueryTotalSupplyResponse } from "./query_pb.js";
import { QueryAllBalancesRequest, QueryAllBalancesResponse, QueryBalanceRequest, QueryBalanceResponse, QueryDenomMetadataByQueryStringRequest, QueryDenomMetadataByQueryStringResponse, QueryDenomMetadataRequest, QueryDenomMetadataResponse, QueryDenomOwnersRequest, QueryDenomOwnersResponse, QueryDenomsMetadataRequest, QueryDenomsMetadataResponse, QueryParamsRequest, QueryParamsResponse, QuerySendEnabledRequest, QuerySendEnabledResponse, QuerySpendableBalanceByDenomRequest, QuerySpendableBalanceByDenomResponse, QuerySpendableBalancesRequest, QuerySpendableBalancesResponse, QuerySupplyOfRequest, QuerySupplyOfResponse, QueryTotalSupplyRequest, QueryTotalSupplyResponse } from "./query_pb.js";

const TYPE_NAME = "cosmos.bank.v1beta1.Query";

Expand Down Expand Up @@ -124,6 +124,18 @@ export const QueryDenomMetadataService = {
Response: QueryDenomMetadataResponse,
} as const;

/**
* DenomsMetadata queries the client metadata of a given coin denomination.
*
* @generated from rpc cosmos.bank.v1beta1.Query.DenomMetadataByQueryString
*/
export const QueryDenomMetadataByQueryStringService = {
typeName: TYPE_NAME,
method: "DenomMetadataByQueryString",
Request: QueryDenomMetadataByQueryStringRequest,
Response: QueryDenomMetadataByQueryStringResponse,
} as const;

/**
* DenomsMetadata queries the client metadata for all registered coin
* denominations.
Expand Down
Loading
Loading