Skip to content

Commit

Permalink
Merge pull request #43 from confio/ica-types
Browse files Browse the repository at this point in the history
Add ibc.applications.interchain_accounts types
  • Loading branch information
webmaster128 authored Oct 11, 2022
2 parents 9dfb90d + 8b2d8cf commit 42c0625
Show file tree
Hide file tree
Showing 10 changed files with 1,501 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ and this project adheres to
- Upgrade ts-proto to 1.126.1 and regenerate code
- Upgrade Cosmos SDK protos to 0.45.8
- Upgrade wasmd protos to 0.28.0
- Add ibc.applications.interchain_accounts types ([#36])

[#36]: https://github.com/confio/cosmjs-types/issues/36

## [0.5.1]

Expand Down
8 changes: 8 additions & 0 deletions scripts/codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ protoc \
"$COSMOS_DIR/upgrade/v1beta1/upgrade.proto" \
"$COSMOS_DIR/vesting/v1beta1/tx.proto" \
"$COSMOS_DIR/vesting/v1beta1/vesting.proto" \
"$IBC_DIR/applications/interchain_accounts/controller/v1/controller.proto" \
"$IBC_DIR/applications/interchain_accounts/controller/v1/query.proto" \
"$IBC_DIR/applications/interchain_accounts/host/v1/host.proto" \
"$IBC_DIR/applications/interchain_accounts/host/v1/query.proto" \
"$IBC_DIR/applications/interchain_accounts/v1/account.proto" \
"$IBC_DIR/applications/interchain_accounts/v1/genesis.proto" \
"$IBC_DIR/applications/interchain_accounts/v1/metadata.proto" \
"$IBC_DIR/applications/interchain_accounts/v1/packet.proto" \
"$IBC_DIR/applications/transfer/v1/genesis.proto" \
"$IBC_DIR/applications/transfer/v1/query.proto" \
"$IBC_DIR/applications/transfer/v1/transfer.proto" \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";

export const protobufPackage = "ibc.applications.interchain_accounts.controller.v1";

/**
* Params defines the set of on-chain interchain accounts parameters.
* The following parameters may be used to disable the controller submodule.
*/
export interface Params {
/** controller_enabled enables or disables the controller submodule. */
controllerEnabled: boolean;
}

function createBaseParams(): Params {
return { controllerEnabled: false };
}

export const Params = {
encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.controllerEnabled === true) {
writer.uint32(8).bool(message.controllerEnabled);
}
return writer;
},

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

fromJSON(object: any): Params {
return { controllerEnabled: isSet(object.controllerEnabled) ? Boolean(object.controllerEnabled) : false };
},

toJSON(message: Params): unknown {
const obj: any = {};
message.controllerEnabled !== undefined && (obj.controllerEnabled = message.controllerEnabled);
return obj;
},

fromPartial<I extends Exact<DeepPartial<Params>, I>>(object: I): Params {
const message = createBaseParams();
message.controllerEnabled = object.controllerEnabled ?? false;
return message;
},
};

type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;

export type DeepPartial<T> = T extends Builtin
? T
: T extends Long
? string | number | Long
: T extends Array<infer U>
? Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;

type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };

if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}

function isSet(value: any): boolean {
return value !== null && value !== undefined;
}
157 changes: 157 additions & 0 deletions src/ibc/applications/interchain_accounts/controller/v1/query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
import { Params } from "./controller";

export const protobufPackage = "ibc.applications.interchain_accounts.controller.v1";

/** QueryParamsRequest is the request type for the Query/Params RPC method. */
export interface QueryParamsRequest {}

/** QueryParamsResponse is the response type for the Query/Params RPC method. */
export interface QueryParamsResponse {
/** params defines the parameters of the module. */
params?: Params;
}

function createBaseQueryParamsRequest(): QueryParamsRequest {
return {};
}

export const QueryParamsRequest = {
encode(_: QueryParamsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
return writer;
},

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

fromJSON(_: any): QueryParamsRequest {
return {};
},

toJSON(_: QueryParamsRequest): unknown {
const obj: any = {};
return obj;
},

fromPartial<I extends Exact<DeepPartial<QueryParamsRequest>, I>>(_: I): QueryParamsRequest {
const message = createBaseQueryParamsRequest();
return message;
},
};

function createBaseQueryParamsResponse(): QueryParamsResponse {
return { params: undefined };
}

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

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

fromJSON(object: any): QueryParamsResponse {
return { params: isSet(object.params) ? Params.fromJSON(object.params) : undefined };
},

toJSON(message: QueryParamsResponse): unknown {
const obj: any = {};
message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined);
return obj;
},

fromPartial<I extends Exact<DeepPartial<QueryParamsResponse>, I>>(object: I): QueryParamsResponse {
const message = createBaseQueryParamsResponse();
message.params =
object.params !== undefined && object.params !== null ? Params.fromPartial(object.params) : undefined;
return message;
},
};

/** Query provides defines the gRPC querier service. */
export interface Query {
/** Params queries all parameters of the ICA controller submodule. */
Params(request: QueryParamsRequest): Promise<QueryParamsResponse>;
}

export class QueryClientImpl implements Query {
private readonly rpc: Rpc;
constructor(rpc: Rpc) {
this.rpc = rpc;
this.Params = this.Params.bind(this);
}
Params(request: QueryParamsRequest): Promise<QueryParamsResponse> {
const data = QueryParamsRequest.encode(request).finish();
const promise = this.rpc.request(
"ibc.applications.interchain_accounts.controller.v1.Query",
"Params",
data,
);
return promise.then((data) => QueryParamsResponse.decode(new _m0.Reader(data)));
}
}

interface Rpc {
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
}

type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;

export type DeepPartial<T> = T extends Builtin
? T
: T extends Long
? string | number | Long
: T extends Array<infer U>
? Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;

type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };

if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}

function isSet(value: any): boolean {
return value !== null && value !== undefined;
}
108 changes: 108 additions & 0 deletions src/ibc/applications/interchain_accounts/host/v1/host.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";

export const protobufPackage = "ibc.applications.interchain_accounts.host.v1";

/**
* Params defines the set of on-chain interchain accounts parameters.
* The following parameters may be used to disable the host submodule.
*/
export interface Params {
/** host_enabled enables or disables the host submodule. */
hostEnabled: boolean;
/** allow_messages defines a list of sdk message typeURLs allowed to be executed on a host chain. */
allowMessages: string[];
}

function createBaseParams(): Params {
return { hostEnabled: false, allowMessages: [] };
}

export const Params = {
encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.hostEnabled === true) {
writer.uint32(8).bool(message.hostEnabled);
}
for (const v of message.allowMessages) {
writer.uint32(18).string(v!);
}
return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): Params {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseParams();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.hostEnabled = reader.bool();
break;
case 2:
message.allowMessages.push(reader.string());
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},

fromJSON(object: any): Params {
return {
hostEnabled: isSet(object.hostEnabled) ? Boolean(object.hostEnabled) : false,
allowMessages: Array.isArray(object?.allowMessages)
? object.allowMessages.map((e: any) => String(e))
: [],
};
},

toJSON(message: Params): unknown {
const obj: any = {};
message.hostEnabled !== undefined && (obj.hostEnabled = message.hostEnabled);
if (message.allowMessages) {
obj.allowMessages = message.allowMessages.map((e) => e);
} else {
obj.allowMessages = [];
}
return obj;
},

fromPartial<I extends Exact<DeepPartial<Params>, I>>(object: I): Params {
const message = createBaseParams();
message.hostEnabled = object.hostEnabled ?? false;
message.allowMessages = object.allowMessages?.map((e) => e) || [];
return message;
},
};

type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;

export type DeepPartial<T> = T extends Builtin
? T
: T extends Long
? string | number | Long
: T extends Array<infer U>
? Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;

type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };

if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}

function isSet(value: any): boolean {
return value !== null && value !== undefined;
}
Loading

0 comments on commit 42c0625

Please sign in to comment.