Merge pull request #711 from cosmos/636-ibc-messages-codec
Add ibc support
This commit is contained in:
@@ -18,6 +18,10 @@ and this project adheres to
|
||||
and `StargateClient`. Added `ModuleAccount` and vesting accounts
|
||||
`BaseVestingAccount`, `ContinuousVestingAccount`, `DelayedVestingAccount` and
|
||||
`PeriodicVestingAccount`.
|
||||
- @cosmjs/stargate: Add codecs for IBC channel tx, client query/tx, and
|
||||
connection tx, as well as Tendermint.
|
||||
- @cosmjs/stargate: Add support for IBC message types in
|
||||
`SigningStargateClient`.
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -29,6 +33,8 @@ and this project adheres to
|
||||
- @cosmjs/stargate: Remove `accountFromProto` in favour of `accountFromAny`.
|
||||
- @cosmjs/stargate: Rename `Rpc` interface to `ProtobufRpcClient` and
|
||||
`createRpc` to `createProtobufRpcClient`.
|
||||
- @cosmjs/stargate: Reorganize nesting structure of IBC query client and add
|
||||
support for more methods.
|
||||
- @cosmjs/tendermint-rpc: The fields `CommitSignature.validatorAddress`,
|
||||
`.timestamp` and `.signature` are now optional. They are unset when
|
||||
`blockIdFlag` is `BlockIdFlag.Absent`. The decoding into `CommitSignature` is
|
||||
|
||||
@@ -36,10 +36,15 @@ protoc \
|
||||
"$COSMOS_PROTO_DIR/cosmos/vesting/v1beta1/vesting.proto" \
|
||||
"$COSMOS_PROTO_DIR/ibc/core/channel/v1/channel.proto" \
|
||||
"$COSMOS_PROTO_DIR/ibc/core/channel/v1/query.proto" \
|
||||
"$COSMOS_PROTO_DIR/ibc/core/channel/v1/tx.proto" \
|
||||
"$COSMOS_PROTO_DIR/ibc/core/client/v1/client.proto" \
|
||||
"$COSMOS_PROTO_DIR/ibc/core/client/v1/query.proto" \
|
||||
"$COSMOS_PROTO_DIR/ibc/core/client/v1/tx.proto" \
|
||||
"$COSMOS_PROTO_DIR/ibc/core/commitment/v1/commitment.proto" \
|
||||
"$COSMOS_PROTO_DIR/ibc/core/connection/v1/connection.proto" \
|
||||
"$COSMOS_PROTO_DIR/ibc/core/connection/v1/query.proto" \
|
||||
"$COSMOS_PROTO_DIR/ibc/core/connection/v1/tx.proto" \
|
||||
"$COSMOS_PROTO_DIR/ibc/lightclients/tendermint/v1/tendermint.proto" \
|
||||
"$THIRD_PARTY_PROTO_DIR/confio/proofs.proto" \
|
||||
"$THIRD_PARTY_PROTO_DIR/tendermint/abci/types.proto" \
|
||||
"$THIRD_PARTY_PROTO_DIR/tendermint/crypto/keys.proto" \
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,953 @@
|
||||
/* eslint-disable */
|
||||
import { Any } from "../../../../google/protobuf/any";
|
||||
import {
|
||||
Height,
|
||||
Params,
|
||||
IdentifiedClientState,
|
||||
ConsensusStateWithHeight,
|
||||
} from "../../../../ibc/core/client/v1/client";
|
||||
import { PageRequest, PageResponse } from "../../../../cosmos/base/query/v1beta1/pagination";
|
||||
import Long from "long";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "ibc.core.client.v1";
|
||||
|
||||
/**
|
||||
* QueryClientStateRequest is the request type for the Query/ClientState RPC
|
||||
* method
|
||||
*/
|
||||
export interface QueryClientStateRequest {
|
||||
/** client state unique identifier */
|
||||
clientId: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* QueryClientStateResponse is the response type for the Query/ClientState RPC
|
||||
* method. Besides the client state, it includes a proof and the height from
|
||||
* which the proof was retrieved.
|
||||
*/
|
||||
export interface QueryClientStateResponse {
|
||||
/** client state associated with the request identifier */
|
||||
clientState?: Any;
|
||||
/** merkle proof of existence */
|
||||
proof: Uint8Array;
|
||||
/** height at which the proof was retrieved */
|
||||
proofHeight?: Height;
|
||||
}
|
||||
|
||||
/**
|
||||
* QueryClientStatesRequest is the request type for the Query/ClientStates RPC
|
||||
* method
|
||||
*/
|
||||
export interface QueryClientStatesRequest {
|
||||
/** pagination request */
|
||||
pagination?: PageRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* QueryClientStatesResponse is the response type for the Query/ClientStates RPC
|
||||
* method.
|
||||
*/
|
||||
export interface QueryClientStatesResponse {
|
||||
/** list of stored ClientStates of the chain. */
|
||||
clientStates: IdentifiedClientState[];
|
||||
/** pagination response */
|
||||
pagination?: PageResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* QueryConsensusStateRequest is the request type for the Query/ConsensusState
|
||||
* RPC method. Besides the consensus state, it includes a proof and the height
|
||||
* from which the proof was retrieved.
|
||||
*/
|
||||
export interface QueryConsensusStateRequest {
|
||||
/** client identifier */
|
||||
clientId: string;
|
||||
/** consensus state revision number */
|
||||
revisionNumber: Long;
|
||||
/** consensus state revision height */
|
||||
revisionHeight: Long;
|
||||
/**
|
||||
* latest_height overrrides the height field and queries the latest stored
|
||||
* ConsensusState
|
||||
*/
|
||||
latestHeight: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* QueryConsensusStateResponse is the response type for the Query/ConsensusState
|
||||
* RPC method
|
||||
*/
|
||||
export interface QueryConsensusStateResponse {
|
||||
/** consensus state associated with the client identifier at the given height */
|
||||
consensusState?: Any;
|
||||
/** merkle proof of existence */
|
||||
proof: Uint8Array;
|
||||
/** height at which the proof was retrieved */
|
||||
proofHeight?: Height;
|
||||
}
|
||||
|
||||
/**
|
||||
* QueryConsensusStatesRequest is the request type for the Query/ConsensusStates
|
||||
* RPC method.
|
||||
*/
|
||||
export interface QueryConsensusStatesRequest {
|
||||
/** client identifier */
|
||||
clientId: string;
|
||||
/** pagination request */
|
||||
pagination?: PageRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* QueryConsensusStatesResponse is the response type for the
|
||||
* Query/ConsensusStates RPC method
|
||||
*/
|
||||
export interface QueryConsensusStatesResponse {
|
||||
/** consensus states associated with the identifier */
|
||||
consensusStates: ConsensusStateWithHeight[];
|
||||
/** pagination response */
|
||||
pagination?: PageResponse;
|
||||
}
|
||||
|
||||
/** QueryClientParamsRequest is the request type for the Query/ClientParams RPC method. */
|
||||
export interface QueryClientParamsRequest {}
|
||||
|
||||
/** QueryClientParamsResponse is the response type for the Query/ClientParams RPC method. */
|
||||
export interface QueryClientParamsResponse {
|
||||
/** params defines the parameters of the module. */
|
||||
params?: Params;
|
||||
}
|
||||
|
||||
const baseQueryClientStateRequest: object = { clientId: "" };
|
||||
|
||||
export const QueryClientStateRequest = {
|
||||
encode(message: QueryClientStateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.clientId !== "") {
|
||||
writer.uint32(10).string(message.clientId);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): QueryClientStateRequest {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseQueryClientStateRequest } as QueryClientStateRequest;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.clientId = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): QueryClientStateRequest {
|
||||
const message = { ...baseQueryClientStateRequest } as QueryClientStateRequest;
|
||||
if (object.clientId !== undefined && object.clientId !== null) {
|
||||
message.clientId = String(object.clientId);
|
||||
} else {
|
||||
message.clientId = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: QueryClientStateRequest): unknown {
|
||||
const obj: any = {};
|
||||
message.clientId !== undefined && (obj.clientId = message.clientId);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<QueryClientStateRequest>): QueryClientStateRequest {
|
||||
const message = { ...baseQueryClientStateRequest } as QueryClientStateRequest;
|
||||
if (object.clientId !== undefined && object.clientId !== null) {
|
||||
message.clientId = object.clientId;
|
||||
} else {
|
||||
message.clientId = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseQueryClientStateResponse: object = {};
|
||||
|
||||
export const QueryClientStateResponse = {
|
||||
encode(message: QueryClientStateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.clientState !== undefined) {
|
||||
Any.encode(message.clientState, writer.uint32(10).fork()).ldelim();
|
||||
}
|
||||
if (message.proof.length !== 0) {
|
||||
writer.uint32(18).bytes(message.proof);
|
||||
}
|
||||
if (message.proofHeight !== undefined) {
|
||||
Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): QueryClientStateResponse {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseQueryClientStateResponse } as QueryClientStateResponse;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.clientState = Any.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 2:
|
||||
message.proof = reader.bytes();
|
||||
break;
|
||||
case 3:
|
||||
message.proofHeight = Height.decode(reader, reader.uint32());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): QueryClientStateResponse {
|
||||
const message = { ...baseQueryClientStateResponse } as QueryClientStateResponse;
|
||||
if (object.clientState !== undefined && object.clientState !== null) {
|
||||
message.clientState = Any.fromJSON(object.clientState);
|
||||
} else {
|
||||
message.clientState = undefined;
|
||||
}
|
||||
if (object.proof !== undefined && object.proof !== null) {
|
||||
message.proof = bytesFromBase64(object.proof);
|
||||
}
|
||||
if (object.proofHeight !== undefined && object.proofHeight !== null) {
|
||||
message.proofHeight = Height.fromJSON(object.proofHeight);
|
||||
} else {
|
||||
message.proofHeight = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: QueryClientStateResponse): unknown {
|
||||
const obj: any = {};
|
||||
message.clientState !== undefined &&
|
||||
(obj.clientState = message.clientState ? Any.toJSON(message.clientState) : undefined);
|
||||
message.proof !== undefined &&
|
||||
(obj.proof = base64FromBytes(message.proof !== undefined ? message.proof : new Uint8Array()));
|
||||
message.proofHeight !== undefined &&
|
||||
(obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<QueryClientStateResponse>): QueryClientStateResponse {
|
||||
const message = { ...baseQueryClientStateResponse } as QueryClientStateResponse;
|
||||
if (object.clientState !== undefined && object.clientState !== null) {
|
||||
message.clientState = Any.fromPartial(object.clientState);
|
||||
} else {
|
||||
message.clientState = undefined;
|
||||
}
|
||||
if (object.proof !== undefined && object.proof !== null) {
|
||||
message.proof = object.proof;
|
||||
} else {
|
||||
message.proof = new Uint8Array();
|
||||
}
|
||||
if (object.proofHeight !== undefined && object.proofHeight !== null) {
|
||||
message.proofHeight = Height.fromPartial(object.proofHeight);
|
||||
} else {
|
||||
message.proofHeight = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseQueryClientStatesRequest: object = {};
|
||||
|
||||
export const QueryClientStatesRequest = {
|
||||
encode(message: QueryClientStatesRequest, 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): QueryClientStatesRequest {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseQueryClientStatesRequest } as QueryClientStatesRequest;
|
||||
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): QueryClientStatesRequest {
|
||||
const message = { ...baseQueryClientStatesRequest } as QueryClientStatesRequest;
|
||||
if (object.pagination !== undefined && object.pagination !== null) {
|
||||
message.pagination = PageRequest.fromJSON(object.pagination);
|
||||
} else {
|
||||
message.pagination = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: QueryClientStatesRequest): unknown {
|
||||
const obj: any = {};
|
||||
message.pagination !== undefined &&
|
||||
(obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<QueryClientStatesRequest>): QueryClientStatesRequest {
|
||||
const message = { ...baseQueryClientStatesRequest } as QueryClientStatesRequest;
|
||||
if (object.pagination !== undefined && object.pagination !== null) {
|
||||
message.pagination = PageRequest.fromPartial(object.pagination);
|
||||
} else {
|
||||
message.pagination = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseQueryClientStatesResponse: object = {};
|
||||
|
||||
export const QueryClientStatesResponse = {
|
||||
encode(message: QueryClientStatesResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
for (const v of message.clientStates) {
|
||||
IdentifiedClientState.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): QueryClientStatesResponse {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseQueryClientStatesResponse } as QueryClientStatesResponse;
|
||||
message.clientStates = [];
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.clientStates.push(IdentifiedClientState.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): QueryClientStatesResponse {
|
||||
const message = { ...baseQueryClientStatesResponse } as QueryClientStatesResponse;
|
||||
message.clientStates = [];
|
||||
if (object.clientStates !== undefined && object.clientStates !== null) {
|
||||
for (const e of object.clientStates) {
|
||||
message.clientStates.push(IdentifiedClientState.fromJSON(e));
|
||||
}
|
||||
}
|
||||
if (object.pagination !== undefined && object.pagination !== null) {
|
||||
message.pagination = PageResponse.fromJSON(object.pagination);
|
||||
} else {
|
||||
message.pagination = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: QueryClientStatesResponse): unknown {
|
||||
const obj: any = {};
|
||||
if (message.clientStates) {
|
||||
obj.clientStates = message.clientStates.map((e) => (e ? IdentifiedClientState.toJSON(e) : undefined));
|
||||
} else {
|
||||
obj.clientStates = [];
|
||||
}
|
||||
message.pagination !== undefined &&
|
||||
(obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<QueryClientStatesResponse>): QueryClientStatesResponse {
|
||||
const message = { ...baseQueryClientStatesResponse } as QueryClientStatesResponse;
|
||||
message.clientStates = [];
|
||||
if (object.clientStates !== undefined && object.clientStates !== null) {
|
||||
for (const e of object.clientStates) {
|
||||
message.clientStates.push(IdentifiedClientState.fromPartial(e));
|
||||
}
|
||||
}
|
||||
if (object.pagination !== undefined && object.pagination !== null) {
|
||||
message.pagination = PageResponse.fromPartial(object.pagination);
|
||||
} else {
|
||||
message.pagination = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseQueryConsensusStateRequest: object = {
|
||||
clientId: "",
|
||||
revisionNumber: Long.UZERO,
|
||||
revisionHeight: Long.UZERO,
|
||||
latestHeight: false,
|
||||
};
|
||||
|
||||
export const QueryConsensusStateRequest = {
|
||||
encode(message: QueryConsensusStateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.clientId !== "") {
|
||||
writer.uint32(10).string(message.clientId);
|
||||
}
|
||||
if (!message.revisionNumber.isZero()) {
|
||||
writer.uint32(16).uint64(message.revisionNumber);
|
||||
}
|
||||
if (!message.revisionHeight.isZero()) {
|
||||
writer.uint32(24).uint64(message.revisionHeight);
|
||||
}
|
||||
if (message.latestHeight === true) {
|
||||
writer.uint32(32).bool(message.latestHeight);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): QueryConsensusStateRequest {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseQueryConsensusStateRequest } as QueryConsensusStateRequest;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.clientId = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.revisionNumber = reader.uint64() as Long;
|
||||
break;
|
||||
case 3:
|
||||
message.revisionHeight = reader.uint64() as Long;
|
||||
break;
|
||||
case 4:
|
||||
message.latestHeight = reader.bool();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): QueryConsensusStateRequest {
|
||||
const message = { ...baseQueryConsensusStateRequest } as QueryConsensusStateRequest;
|
||||
if (object.clientId !== undefined && object.clientId !== null) {
|
||||
message.clientId = String(object.clientId);
|
||||
} else {
|
||||
message.clientId = "";
|
||||
}
|
||||
if (object.revisionNumber !== undefined && object.revisionNumber !== null) {
|
||||
message.revisionNumber = Long.fromString(object.revisionNumber);
|
||||
} else {
|
||||
message.revisionNumber = Long.UZERO;
|
||||
}
|
||||
if (object.revisionHeight !== undefined && object.revisionHeight !== null) {
|
||||
message.revisionHeight = Long.fromString(object.revisionHeight);
|
||||
} else {
|
||||
message.revisionHeight = Long.UZERO;
|
||||
}
|
||||
if (object.latestHeight !== undefined && object.latestHeight !== null) {
|
||||
message.latestHeight = Boolean(object.latestHeight);
|
||||
} else {
|
||||
message.latestHeight = false;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: QueryConsensusStateRequest): unknown {
|
||||
const obj: any = {};
|
||||
message.clientId !== undefined && (obj.clientId = message.clientId);
|
||||
message.revisionNumber !== undefined &&
|
||||
(obj.revisionNumber = (message.revisionNumber || Long.UZERO).toString());
|
||||
message.revisionHeight !== undefined &&
|
||||
(obj.revisionHeight = (message.revisionHeight || Long.UZERO).toString());
|
||||
message.latestHeight !== undefined && (obj.latestHeight = message.latestHeight);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<QueryConsensusStateRequest>): QueryConsensusStateRequest {
|
||||
const message = { ...baseQueryConsensusStateRequest } as QueryConsensusStateRequest;
|
||||
if (object.clientId !== undefined && object.clientId !== null) {
|
||||
message.clientId = object.clientId;
|
||||
} else {
|
||||
message.clientId = "";
|
||||
}
|
||||
if (object.revisionNumber !== undefined && object.revisionNumber !== null) {
|
||||
message.revisionNumber = object.revisionNumber as Long;
|
||||
} else {
|
||||
message.revisionNumber = Long.UZERO;
|
||||
}
|
||||
if (object.revisionHeight !== undefined && object.revisionHeight !== null) {
|
||||
message.revisionHeight = object.revisionHeight as Long;
|
||||
} else {
|
||||
message.revisionHeight = Long.UZERO;
|
||||
}
|
||||
if (object.latestHeight !== undefined && object.latestHeight !== null) {
|
||||
message.latestHeight = object.latestHeight;
|
||||
} else {
|
||||
message.latestHeight = false;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseQueryConsensusStateResponse: object = {};
|
||||
|
||||
export const QueryConsensusStateResponse = {
|
||||
encode(message: QueryConsensusStateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.consensusState !== undefined) {
|
||||
Any.encode(message.consensusState, writer.uint32(10).fork()).ldelim();
|
||||
}
|
||||
if (message.proof.length !== 0) {
|
||||
writer.uint32(18).bytes(message.proof);
|
||||
}
|
||||
if (message.proofHeight !== undefined) {
|
||||
Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): QueryConsensusStateResponse {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseQueryConsensusStateResponse } as QueryConsensusStateResponse;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.consensusState = Any.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 2:
|
||||
message.proof = reader.bytes();
|
||||
break;
|
||||
case 3:
|
||||
message.proofHeight = Height.decode(reader, reader.uint32());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): QueryConsensusStateResponse {
|
||||
const message = { ...baseQueryConsensusStateResponse } as QueryConsensusStateResponse;
|
||||
if (object.consensusState !== undefined && object.consensusState !== null) {
|
||||
message.consensusState = Any.fromJSON(object.consensusState);
|
||||
} else {
|
||||
message.consensusState = undefined;
|
||||
}
|
||||
if (object.proof !== undefined && object.proof !== null) {
|
||||
message.proof = bytesFromBase64(object.proof);
|
||||
}
|
||||
if (object.proofHeight !== undefined && object.proofHeight !== null) {
|
||||
message.proofHeight = Height.fromJSON(object.proofHeight);
|
||||
} else {
|
||||
message.proofHeight = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: QueryConsensusStateResponse): unknown {
|
||||
const obj: any = {};
|
||||
message.consensusState !== undefined &&
|
||||
(obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined);
|
||||
message.proof !== undefined &&
|
||||
(obj.proof = base64FromBytes(message.proof !== undefined ? message.proof : new Uint8Array()));
|
||||
message.proofHeight !== undefined &&
|
||||
(obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<QueryConsensusStateResponse>): QueryConsensusStateResponse {
|
||||
const message = { ...baseQueryConsensusStateResponse } as QueryConsensusStateResponse;
|
||||
if (object.consensusState !== undefined && object.consensusState !== null) {
|
||||
message.consensusState = Any.fromPartial(object.consensusState);
|
||||
} else {
|
||||
message.consensusState = undefined;
|
||||
}
|
||||
if (object.proof !== undefined && object.proof !== null) {
|
||||
message.proof = object.proof;
|
||||
} else {
|
||||
message.proof = new Uint8Array();
|
||||
}
|
||||
if (object.proofHeight !== undefined && object.proofHeight !== null) {
|
||||
message.proofHeight = Height.fromPartial(object.proofHeight);
|
||||
} else {
|
||||
message.proofHeight = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseQueryConsensusStatesRequest: object = { clientId: "" };
|
||||
|
||||
export const QueryConsensusStatesRequest = {
|
||||
encode(message: QueryConsensusStatesRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.clientId !== "") {
|
||||
writer.uint32(10).string(message.clientId);
|
||||
}
|
||||
if (message.pagination !== undefined) {
|
||||
PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): QueryConsensusStatesRequest {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseQueryConsensusStatesRequest } as QueryConsensusStatesRequest;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.clientId = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.pagination = PageRequest.decode(reader, reader.uint32());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): QueryConsensusStatesRequest {
|
||||
const message = { ...baseQueryConsensusStatesRequest } as QueryConsensusStatesRequest;
|
||||
if (object.clientId !== undefined && object.clientId !== null) {
|
||||
message.clientId = String(object.clientId);
|
||||
} else {
|
||||
message.clientId = "";
|
||||
}
|
||||
if (object.pagination !== undefined && object.pagination !== null) {
|
||||
message.pagination = PageRequest.fromJSON(object.pagination);
|
||||
} else {
|
||||
message.pagination = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: QueryConsensusStatesRequest): unknown {
|
||||
const obj: any = {};
|
||||
message.clientId !== undefined && (obj.clientId = message.clientId);
|
||||
message.pagination !== undefined &&
|
||||
(obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<QueryConsensusStatesRequest>): QueryConsensusStatesRequest {
|
||||
const message = { ...baseQueryConsensusStatesRequest } as QueryConsensusStatesRequest;
|
||||
if (object.clientId !== undefined && object.clientId !== null) {
|
||||
message.clientId = object.clientId;
|
||||
} else {
|
||||
message.clientId = "";
|
||||
}
|
||||
if (object.pagination !== undefined && object.pagination !== null) {
|
||||
message.pagination = PageRequest.fromPartial(object.pagination);
|
||||
} else {
|
||||
message.pagination = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseQueryConsensusStatesResponse: object = {};
|
||||
|
||||
export const QueryConsensusStatesResponse = {
|
||||
encode(message: QueryConsensusStatesResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
for (const v of message.consensusStates) {
|
||||
ConsensusStateWithHeight.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): QueryConsensusStatesResponse {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseQueryConsensusStatesResponse } as QueryConsensusStatesResponse;
|
||||
message.consensusStates = [];
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.consensusStates.push(ConsensusStateWithHeight.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): QueryConsensusStatesResponse {
|
||||
const message = { ...baseQueryConsensusStatesResponse } as QueryConsensusStatesResponse;
|
||||
message.consensusStates = [];
|
||||
if (object.consensusStates !== undefined && object.consensusStates !== null) {
|
||||
for (const e of object.consensusStates) {
|
||||
message.consensusStates.push(ConsensusStateWithHeight.fromJSON(e));
|
||||
}
|
||||
}
|
||||
if (object.pagination !== undefined && object.pagination !== null) {
|
||||
message.pagination = PageResponse.fromJSON(object.pagination);
|
||||
} else {
|
||||
message.pagination = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: QueryConsensusStatesResponse): unknown {
|
||||
const obj: any = {};
|
||||
if (message.consensusStates) {
|
||||
obj.consensusStates = message.consensusStates.map((e) =>
|
||||
e ? ConsensusStateWithHeight.toJSON(e) : undefined,
|
||||
);
|
||||
} else {
|
||||
obj.consensusStates = [];
|
||||
}
|
||||
message.pagination !== undefined &&
|
||||
(obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<QueryConsensusStatesResponse>): QueryConsensusStatesResponse {
|
||||
const message = { ...baseQueryConsensusStatesResponse } as QueryConsensusStatesResponse;
|
||||
message.consensusStates = [];
|
||||
if (object.consensusStates !== undefined && object.consensusStates !== null) {
|
||||
for (const e of object.consensusStates) {
|
||||
message.consensusStates.push(ConsensusStateWithHeight.fromPartial(e));
|
||||
}
|
||||
}
|
||||
if (object.pagination !== undefined && object.pagination !== null) {
|
||||
message.pagination = PageResponse.fromPartial(object.pagination);
|
||||
} else {
|
||||
message.pagination = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseQueryClientParamsRequest: object = {};
|
||||
|
||||
export const QueryClientParamsRequest = {
|
||||
encode(_: QueryClientParamsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): QueryClientParamsRequest {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseQueryClientParamsRequest } as QueryClientParamsRequest;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(_: any): QueryClientParamsRequest {
|
||||
const message = { ...baseQueryClientParamsRequest } as QueryClientParamsRequest;
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(_: QueryClientParamsRequest): unknown {
|
||||
const obj: any = {};
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(_: DeepPartial<QueryClientParamsRequest>): QueryClientParamsRequest {
|
||||
const message = { ...baseQueryClientParamsRequest } as QueryClientParamsRequest;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseQueryClientParamsResponse: object = {};
|
||||
|
||||
export const QueryClientParamsResponse = {
|
||||
encode(message: QueryClientParamsResponse, 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): QueryClientParamsResponse {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseQueryClientParamsResponse } as QueryClientParamsResponse;
|
||||
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): QueryClientParamsResponse {
|
||||
const message = { ...baseQueryClientParamsResponse } as QueryClientParamsResponse;
|
||||
if (object.params !== undefined && object.params !== null) {
|
||||
message.params = Params.fromJSON(object.params);
|
||||
} else {
|
||||
message.params = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: QueryClientParamsResponse): unknown {
|
||||
const obj: any = {};
|
||||
message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<QueryClientParamsResponse>): QueryClientParamsResponse {
|
||||
const message = { ...baseQueryClientParamsResponse } as QueryClientParamsResponse;
|
||||
if (object.params !== undefined && object.params !== null) {
|
||||
message.params = Params.fromPartial(object.params);
|
||||
} else {
|
||||
message.params = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
/** Query provides defines the gRPC querier service */
|
||||
export interface Query {
|
||||
/** ClientState queries an IBC light client. */
|
||||
ClientState(request: QueryClientStateRequest): Promise<QueryClientStateResponse>;
|
||||
/** ClientStates queries all the IBC light clients of a chain. */
|
||||
ClientStates(request: QueryClientStatesRequest): Promise<QueryClientStatesResponse>;
|
||||
/**
|
||||
* ConsensusState queries a consensus state associated with a client state at
|
||||
* a given height.
|
||||
*/
|
||||
ConsensusState(request: QueryConsensusStateRequest): Promise<QueryConsensusStateResponse>;
|
||||
/**
|
||||
* ConsensusStates queries all the consensus state associated with a given
|
||||
* client.
|
||||
*/
|
||||
ConsensusStates(request: QueryConsensusStatesRequest): Promise<QueryConsensusStatesResponse>;
|
||||
/** ClientParams queries all parameters of the ibc client. */
|
||||
ClientParams(request: QueryClientParamsRequest): Promise<QueryClientParamsResponse>;
|
||||
}
|
||||
|
||||
export class QueryClientImpl implements Query {
|
||||
private readonly rpc: Rpc;
|
||||
constructor(rpc: Rpc) {
|
||||
this.rpc = rpc;
|
||||
}
|
||||
ClientState(request: QueryClientStateRequest): Promise<QueryClientStateResponse> {
|
||||
const data = QueryClientStateRequest.encode(request).finish();
|
||||
const promise = this.rpc.request("ibc.core.client.v1.Query", "ClientState", data);
|
||||
return promise.then((data) => QueryClientStateResponse.decode(new _m0.Reader(data)));
|
||||
}
|
||||
|
||||
ClientStates(request: QueryClientStatesRequest): Promise<QueryClientStatesResponse> {
|
||||
const data = QueryClientStatesRequest.encode(request).finish();
|
||||
const promise = this.rpc.request("ibc.core.client.v1.Query", "ClientStates", data);
|
||||
return promise.then((data) => QueryClientStatesResponse.decode(new _m0.Reader(data)));
|
||||
}
|
||||
|
||||
ConsensusState(request: QueryConsensusStateRequest): Promise<QueryConsensusStateResponse> {
|
||||
const data = QueryConsensusStateRequest.encode(request).finish();
|
||||
const promise = this.rpc.request("ibc.core.client.v1.Query", "ConsensusState", data);
|
||||
return promise.then((data) => QueryConsensusStateResponse.decode(new _m0.Reader(data)));
|
||||
}
|
||||
|
||||
ConsensusStates(request: QueryConsensusStatesRequest): Promise<QueryConsensusStatesResponse> {
|
||||
const data = QueryConsensusStatesRequest.encode(request).finish();
|
||||
const promise = this.rpc.request("ibc.core.client.v1.Query", "ConsensusStates", data);
|
||||
return promise.then((data) => QueryConsensusStatesResponse.decode(new _m0.Reader(data)));
|
||||
}
|
||||
|
||||
ClientParams(request: QueryClientParamsRequest): Promise<QueryClientParamsResponse> {
|
||||
const data = QueryClientParamsRequest.encode(request).finish();
|
||||
const promise = this.rpc.request("ibc.core.client.v1.Query", "ClientParams", data);
|
||||
return promise.then((data) => QueryClientParamsResponse.decode(new _m0.Reader(data)));
|
||||
}
|
||||
}
|
||||
|
||||
interface Rpc {
|
||||
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
|
||||
}
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw "Unable to locate global object";
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (let i = 0; i < arr.byteLength; ++i) {
|
||||
bin.push(String.fromCharCode(arr[i]));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: 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>;
|
||||
@@ -0,0 +1,729 @@
|
||||
/* eslint-disable */
|
||||
import { Any } from "../../../../google/protobuf/any";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
import Long from "long";
|
||||
|
||||
export const protobufPackage = "ibc.core.client.v1";
|
||||
|
||||
/** MsgCreateClient defines a message to create an IBC client */
|
||||
export interface MsgCreateClient {
|
||||
/** light client state */
|
||||
clientState?: Any;
|
||||
/**
|
||||
* consensus state associated with the client that corresponds to a given
|
||||
* height.
|
||||
*/
|
||||
consensusState?: Any;
|
||||
/** signer address */
|
||||
signer: string;
|
||||
}
|
||||
|
||||
/** MsgCreateClientResponse defines the Msg/CreateClient response type. */
|
||||
export interface MsgCreateClientResponse {}
|
||||
|
||||
/**
|
||||
* MsgUpdateClient defines an sdk.Msg to update a IBC client state using
|
||||
* the given header.
|
||||
*/
|
||||
export interface MsgUpdateClient {
|
||||
/** client unique identifier */
|
||||
clientId: string;
|
||||
/** header to update the light client */
|
||||
header?: Any;
|
||||
/** signer address */
|
||||
signer: string;
|
||||
}
|
||||
|
||||
/** MsgUpdateClientResponse defines the Msg/UpdateClient response type. */
|
||||
export interface MsgUpdateClientResponse {}
|
||||
|
||||
/** MsgUpgradeClient defines an sdk.Msg to upgrade an IBC client to a new client state */
|
||||
export interface MsgUpgradeClient {
|
||||
/** client unique identifier */
|
||||
clientId: string;
|
||||
/** upgraded client state */
|
||||
clientState?: Any;
|
||||
/** upgraded consensus state, only contains enough information to serve as a basis of trust in update logic */
|
||||
consensusState?: Any;
|
||||
/** proof that old chain committed to new client */
|
||||
proofUpgradeClient: Uint8Array;
|
||||
/** proof that old chain committed to new consensus state */
|
||||
proofUpgradeConsensusState: Uint8Array;
|
||||
/** signer address */
|
||||
signer: string;
|
||||
}
|
||||
|
||||
/** MsgUpgradeClientResponse defines the Msg/UpgradeClient response type. */
|
||||
export interface MsgUpgradeClientResponse {}
|
||||
|
||||
/**
|
||||
* MsgSubmitMisbehaviour defines an sdk.Msg type that submits Evidence for
|
||||
* light client misbehaviour.
|
||||
*/
|
||||
export interface MsgSubmitMisbehaviour {
|
||||
/** client unique identifier */
|
||||
clientId: string;
|
||||
/** misbehaviour used for freezing the light client */
|
||||
misbehaviour?: Any;
|
||||
/** signer address */
|
||||
signer: string;
|
||||
}
|
||||
|
||||
/** MsgSubmitMisbehaviourResponse defines the Msg/SubmitMisbehaviour response type. */
|
||||
export interface MsgSubmitMisbehaviourResponse {}
|
||||
|
||||
const baseMsgCreateClient: object = { signer: "" };
|
||||
|
||||
export const MsgCreateClient = {
|
||||
encode(message: MsgCreateClient, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.clientState !== undefined) {
|
||||
Any.encode(message.clientState, writer.uint32(10).fork()).ldelim();
|
||||
}
|
||||
if (message.consensusState !== undefined) {
|
||||
Any.encode(message.consensusState, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
if (message.signer !== "") {
|
||||
writer.uint32(26).string(message.signer);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): MsgCreateClient {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgCreateClient } as MsgCreateClient;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.clientState = Any.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 2:
|
||||
message.consensusState = Any.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 3:
|
||||
message.signer = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): MsgCreateClient {
|
||||
const message = { ...baseMsgCreateClient } as MsgCreateClient;
|
||||
if (object.clientState !== undefined && object.clientState !== null) {
|
||||
message.clientState = Any.fromJSON(object.clientState);
|
||||
} else {
|
||||
message.clientState = undefined;
|
||||
}
|
||||
if (object.consensusState !== undefined && object.consensusState !== null) {
|
||||
message.consensusState = Any.fromJSON(object.consensusState);
|
||||
} else {
|
||||
message.consensusState = undefined;
|
||||
}
|
||||
if (object.signer !== undefined && object.signer !== null) {
|
||||
message.signer = String(object.signer);
|
||||
} else {
|
||||
message.signer = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: MsgCreateClient): unknown {
|
||||
const obj: any = {};
|
||||
message.clientState !== undefined &&
|
||||
(obj.clientState = message.clientState ? Any.toJSON(message.clientState) : undefined);
|
||||
message.consensusState !== undefined &&
|
||||
(obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined);
|
||||
message.signer !== undefined && (obj.signer = message.signer);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<MsgCreateClient>): MsgCreateClient {
|
||||
const message = { ...baseMsgCreateClient } as MsgCreateClient;
|
||||
if (object.clientState !== undefined && object.clientState !== null) {
|
||||
message.clientState = Any.fromPartial(object.clientState);
|
||||
} else {
|
||||
message.clientState = undefined;
|
||||
}
|
||||
if (object.consensusState !== undefined && object.consensusState !== null) {
|
||||
message.consensusState = Any.fromPartial(object.consensusState);
|
||||
} else {
|
||||
message.consensusState = undefined;
|
||||
}
|
||||
if (object.signer !== undefined && object.signer !== null) {
|
||||
message.signer = object.signer;
|
||||
} else {
|
||||
message.signer = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgCreateClientResponse: object = {};
|
||||
|
||||
export const MsgCreateClientResponse = {
|
||||
encode(_: MsgCreateClientResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): MsgCreateClientResponse {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgCreateClientResponse } as MsgCreateClientResponse;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(_: any): MsgCreateClientResponse {
|
||||
const message = { ...baseMsgCreateClientResponse } as MsgCreateClientResponse;
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(_: MsgCreateClientResponse): unknown {
|
||||
const obj: any = {};
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(_: DeepPartial<MsgCreateClientResponse>): MsgCreateClientResponse {
|
||||
const message = { ...baseMsgCreateClientResponse } as MsgCreateClientResponse;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgUpdateClient: object = { clientId: "", signer: "" };
|
||||
|
||||
export const MsgUpdateClient = {
|
||||
encode(message: MsgUpdateClient, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.clientId !== "") {
|
||||
writer.uint32(10).string(message.clientId);
|
||||
}
|
||||
if (message.header !== undefined) {
|
||||
Any.encode(message.header, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
if (message.signer !== "") {
|
||||
writer.uint32(26).string(message.signer);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateClient {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgUpdateClient } as MsgUpdateClient;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.clientId = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.header = Any.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 3:
|
||||
message.signer = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): MsgUpdateClient {
|
||||
const message = { ...baseMsgUpdateClient } as MsgUpdateClient;
|
||||
if (object.clientId !== undefined && object.clientId !== null) {
|
||||
message.clientId = String(object.clientId);
|
||||
} else {
|
||||
message.clientId = "";
|
||||
}
|
||||
if (object.header !== undefined && object.header !== null) {
|
||||
message.header = Any.fromJSON(object.header);
|
||||
} else {
|
||||
message.header = undefined;
|
||||
}
|
||||
if (object.signer !== undefined && object.signer !== null) {
|
||||
message.signer = String(object.signer);
|
||||
} else {
|
||||
message.signer = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: MsgUpdateClient): unknown {
|
||||
const obj: any = {};
|
||||
message.clientId !== undefined && (obj.clientId = message.clientId);
|
||||
message.header !== undefined && (obj.header = message.header ? Any.toJSON(message.header) : undefined);
|
||||
message.signer !== undefined && (obj.signer = message.signer);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<MsgUpdateClient>): MsgUpdateClient {
|
||||
const message = { ...baseMsgUpdateClient } as MsgUpdateClient;
|
||||
if (object.clientId !== undefined && object.clientId !== null) {
|
||||
message.clientId = object.clientId;
|
||||
} else {
|
||||
message.clientId = "";
|
||||
}
|
||||
if (object.header !== undefined && object.header !== null) {
|
||||
message.header = Any.fromPartial(object.header);
|
||||
} else {
|
||||
message.header = undefined;
|
||||
}
|
||||
if (object.signer !== undefined && object.signer !== null) {
|
||||
message.signer = object.signer;
|
||||
} else {
|
||||
message.signer = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgUpdateClientResponse: object = {};
|
||||
|
||||
export const MsgUpdateClientResponse = {
|
||||
encode(_: MsgUpdateClientResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateClientResponse {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgUpdateClientResponse } as MsgUpdateClientResponse;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(_: any): MsgUpdateClientResponse {
|
||||
const message = { ...baseMsgUpdateClientResponse } as MsgUpdateClientResponse;
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(_: MsgUpdateClientResponse): unknown {
|
||||
const obj: any = {};
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(_: DeepPartial<MsgUpdateClientResponse>): MsgUpdateClientResponse {
|
||||
const message = { ...baseMsgUpdateClientResponse } as MsgUpdateClientResponse;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgUpgradeClient: object = { clientId: "", signer: "" };
|
||||
|
||||
export const MsgUpgradeClient = {
|
||||
encode(message: MsgUpgradeClient, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.clientId !== "") {
|
||||
writer.uint32(10).string(message.clientId);
|
||||
}
|
||||
if (message.clientState !== undefined) {
|
||||
Any.encode(message.clientState, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
if (message.consensusState !== undefined) {
|
||||
Any.encode(message.consensusState, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
if (message.proofUpgradeClient.length !== 0) {
|
||||
writer.uint32(34).bytes(message.proofUpgradeClient);
|
||||
}
|
||||
if (message.proofUpgradeConsensusState.length !== 0) {
|
||||
writer.uint32(42).bytes(message.proofUpgradeConsensusState);
|
||||
}
|
||||
if (message.signer !== "") {
|
||||
writer.uint32(50).string(message.signer);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpgradeClient {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgUpgradeClient } as MsgUpgradeClient;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.clientId = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.clientState = Any.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 3:
|
||||
message.consensusState = Any.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 4:
|
||||
message.proofUpgradeClient = reader.bytes();
|
||||
break;
|
||||
case 5:
|
||||
message.proofUpgradeConsensusState = reader.bytes();
|
||||
break;
|
||||
case 6:
|
||||
message.signer = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): MsgUpgradeClient {
|
||||
const message = { ...baseMsgUpgradeClient } as MsgUpgradeClient;
|
||||
if (object.clientId !== undefined && object.clientId !== null) {
|
||||
message.clientId = String(object.clientId);
|
||||
} else {
|
||||
message.clientId = "";
|
||||
}
|
||||
if (object.clientState !== undefined && object.clientState !== null) {
|
||||
message.clientState = Any.fromJSON(object.clientState);
|
||||
} else {
|
||||
message.clientState = undefined;
|
||||
}
|
||||
if (object.consensusState !== undefined && object.consensusState !== null) {
|
||||
message.consensusState = Any.fromJSON(object.consensusState);
|
||||
} else {
|
||||
message.consensusState = undefined;
|
||||
}
|
||||
if (object.proofUpgradeClient !== undefined && object.proofUpgradeClient !== null) {
|
||||
message.proofUpgradeClient = bytesFromBase64(object.proofUpgradeClient);
|
||||
}
|
||||
if (object.proofUpgradeConsensusState !== undefined && object.proofUpgradeConsensusState !== null) {
|
||||
message.proofUpgradeConsensusState = bytesFromBase64(object.proofUpgradeConsensusState);
|
||||
}
|
||||
if (object.signer !== undefined && object.signer !== null) {
|
||||
message.signer = String(object.signer);
|
||||
} else {
|
||||
message.signer = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: MsgUpgradeClient): unknown {
|
||||
const obj: any = {};
|
||||
message.clientId !== undefined && (obj.clientId = message.clientId);
|
||||
message.clientState !== undefined &&
|
||||
(obj.clientState = message.clientState ? Any.toJSON(message.clientState) : undefined);
|
||||
message.consensusState !== undefined &&
|
||||
(obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined);
|
||||
message.proofUpgradeClient !== undefined &&
|
||||
(obj.proofUpgradeClient = base64FromBytes(
|
||||
message.proofUpgradeClient !== undefined ? message.proofUpgradeClient : new Uint8Array(),
|
||||
));
|
||||
message.proofUpgradeConsensusState !== undefined &&
|
||||
(obj.proofUpgradeConsensusState = base64FromBytes(
|
||||
message.proofUpgradeConsensusState !== undefined
|
||||
? message.proofUpgradeConsensusState
|
||||
: new Uint8Array(),
|
||||
));
|
||||
message.signer !== undefined && (obj.signer = message.signer);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<MsgUpgradeClient>): MsgUpgradeClient {
|
||||
const message = { ...baseMsgUpgradeClient } as MsgUpgradeClient;
|
||||
if (object.clientId !== undefined && object.clientId !== null) {
|
||||
message.clientId = object.clientId;
|
||||
} else {
|
||||
message.clientId = "";
|
||||
}
|
||||
if (object.clientState !== undefined && object.clientState !== null) {
|
||||
message.clientState = Any.fromPartial(object.clientState);
|
||||
} else {
|
||||
message.clientState = undefined;
|
||||
}
|
||||
if (object.consensusState !== undefined && object.consensusState !== null) {
|
||||
message.consensusState = Any.fromPartial(object.consensusState);
|
||||
} else {
|
||||
message.consensusState = undefined;
|
||||
}
|
||||
if (object.proofUpgradeClient !== undefined && object.proofUpgradeClient !== null) {
|
||||
message.proofUpgradeClient = object.proofUpgradeClient;
|
||||
} else {
|
||||
message.proofUpgradeClient = new Uint8Array();
|
||||
}
|
||||
if (object.proofUpgradeConsensusState !== undefined && object.proofUpgradeConsensusState !== null) {
|
||||
message.proofUpgradeConsensusState = object.proofUpgradeConsensusState;
|
||||
} else {
|
||||
message.proofUpgradeConsensusState = new Uint8Array();
|
||||
}
|
||||
if (object.signer !== undefined && object.signer !== null) {
|
||||
message.signer = object.signer;
|
||||
} else {
|
||||
message.signer = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgUpgradeClientResponse: object = {};
|
||||
|
||||
export const MsgUpgradeClientResponse = {
|
||||
encode(_: MsgUpgradeClientResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpgradeClientResponse {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgUpgradeClientResponse } as MsgUpgradeClientResponse;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(_: any): MsgUpgradeClientResponse {
|
||||
const message = { ...baseMsgUpgradeClientResponse } as MsgUpgradeClientResponse;
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(_: MsgUpgradeClientResponse): unknown {
|
||||
const obj: any = {};
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(_: DeepPartial<MsgUpgradeClientResponse>): MsgUpgradeClientResponse {
|
||||
const message = { ...baseMsgUpgradeClientResponse } as MsgUpgradeClientResponse;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgSubmitMisbehaviour: object = { clientId: "", signer: "" };
|
||||
|
||||
export const MsgSubmitMisbehaviour = {
|
||||
encode(message: MsgSubmitMisbehaviour, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.clientId !== "") {
|
||||
writer.uint32(10).string(message.clientId);
|
||||
}
|
||||
if (message.misbehaviour !== undefined) {
|
||||
Any.encode(message.misbehaviour, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
if (message.signer !== "") {
|
||||
writer.uint32(26).string(message.signer);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): MsgSubmitMisbehaviour {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgSubmitMisbehaviour } as MsgSubmitMisbehaviour;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.clientId = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.misbehaviour = Any.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 3:
|
||||
message.signer = reader.string();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): MsgSubmitMisbehaviour {
|
||||
const message = { ...baseMsgSubmitMisbehaviour } as MsgSubmitMisbehaviour;
|
||||
if (object.clientId !== undefined && object.clientId !== null) {
|
||||
message.clientId = String(object.clientId);
|
||||
} else {
|
||||
message.clientId = "";
|
||||
}
|
||||
if (object.misbehaviour !== undefined && object.misbehaviour !== null) {
|
||||
message.misbehaviour = Any.fromJSON(object.misbehaviour);
|
||||
} else {
|
||||
message.misbehaviour = undefined;
|
||||
}
|
||||
if (object.signer !== undefined && object.signer !== null) {
|
||||
message.signer = String(object.signer);
|
||||
} else {
|
||||
message.signer = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: MsgSubmitMisbehaviour): unknown {
|
||||
const obj: any = {};
|
||||
message.clientId !== undefined && (obj.clientId = message.clientId);
|
||||
message.misbehaviour !== undefined &&
|
||||
(obj.misbehaviour = message.misbehaviour ? Any.toJSON(message.misbehaviour) : undefined);
|
||||
message.signer !== undefined && (obj.signer = message.signer);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<MsgSubmitMisbehaviour>): MsgSubmitMisbehaviour {
|
||||
const message = { ...baseMsgSubmitMisbehaviour } as MsgSubmitMisbehaviour;
|
||||
if (object.clientId !== undefined && object.clientId !== null) {
|
||||
message.clientId = object.clientId;
|
||||
} else {
|
||||
message.clientId = "";
|
||||
}
|
||||
if (object.misbehaviour !== undefined && object.misbehaviour !== null) {
|
||||
message.misbehaviour = Any.fromPartial(object.misbehaviour);
|
||||
} else {
|
||||
message.misbehaviour = undefined;
|
||||
}
|
||||
if (object.signer !== undefined && object.signer !== null) {
|
||||
message.signer = object.signer;
|
||||
} else {
|
||||
message.signer = "";
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMsgSubmitMisbehaviourResponse: object = {};
|
||||
|
||||
export const MsgSubmitMisbehaviourResponse = {
|
||||
encode(_: MsgSubmitMisbehaviourResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): MsgSubmitMisbehaviourResponse {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMsgSubmitMisbehaviourResponse } as MsgSubmitMisbehaviourResponse;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(_: any): MsgSubmitMisbehaviourResponse {
|
||||
const message = { ...baseMsgSubmitMisbehaviourResponse } as MsgSubmitMisbehaviourResponse;
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(_: MsgSubmitMisbehaviourResponse): unknown {
|
||||
const obj: any = {};
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(_: DeepPartial<MsgSubmitMisbehaviourResponse>): MsgSubmitMisbehaviourResponse {
|
||||
const message = { ...baseMsgSubmitMisbehaviourResponse } as MsgSubmitMisbehaviourResponse;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
/** Msg defines the ibc/client Msg service. */
|
||||
export interface Msg {
|
||||
/** CreateClient defines a rpc handler method for MsgCreateClient. */
|
||||
CreateClient(request: MsgCreateClient): Promise<MsgCreateClientResponse>;
|
||||
/** UpdateClient defines a rpc handler method for MsgUpdateClient. */
|
||||
UpdateClient(request: MsgUpdateClient): Promise<MsgUpdateClientResponse>;
|
||||
/** UpgradeClient defines a rpc handler method for MsgUpgradeClient. */
|
||||
UpgradeClient(request: MsgUpgradeClient): Promise<MsgUpgradeClientResponse>;
|
||||
/** SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. */
|
||||
SubmitMisbehaviour(request: MsgSubmitMisbehaviour): Promise<MsgSubmitMisbehaviourResponse>;
|
||||
}
|
||||
|
||||
export class MsgClientImpl implements Msg {
|
||||
private readonly rpc: Rpc;
|
||||
constructor(rpc: Rpc) {
|
||||
this.rpc = rpc;
|
||||
}
|
||||
CreateClient(request: MsgCreateClient): Promise<MsgCreateClientResponse> {
|
||||
const data = MsgCreateClient.encode(request).finish();
|
||||
const promise = this.rpc.request("ibc.core.client.v1.Msg", "CreateClient", data);
|
||||
return promise.then((data) => MsgCreateClientResponse.decode(new _m0.Reader(data)));
|
||||
}
|
||||
|
||||
UpdateClient(request: MsgUpdateClient): Promise<MsgUpdateClientResponse> {
|
||||
const data = MsgUpdateClient.encode(request).finish();
|
||||
const promise = this.rpc.request("ibc.core.client.v1.Msg", "UpdateClient", data);
|
||||
return promise.then((data) => MsgUpdateClientResponse.decode(new _m0.Reader(data)));
|
||||
}
|
||||
|
||||
UpgradeClient(request: MsgUpgradeClient): Promise<MsgUpgradeClientResponse> {
|
||||
const data = MsgUpgradeClient.encode(request).finish();
|
||||
const promise = this.rpc.request("ibc.core.client.v1.Msg", "UpgradeClient", data);
|
||||
return promise.then((data) => MsgUpgradeClientResponse.decode(new _m0.Reader(data)));
|
||||
}
|
||||
|
||||
SubmitMisbehaviour(request: MsgSubmitMisbehaviour): Promise<MsgSubmitMisbehaviourResponse> {
|
||||
const data = MsgSubmitMisbehaviour.encode(request).finish();
|
||||
const promise = this.rpc.request("ibc.core.client.v1.Msg", "SubmitMisbehaviour", data);
|
||||
return promise.then((data) => MsgSubmitMisbehaviourResponse.decode(new _m0.Reader(data)));
|
||||
}
|
||||
}
|
||||
|
||||
interface Rpc {
|
||||
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
|
||||
}
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw "Unable to locate global object";
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (let i = 0; i < arr.byteLength; ++i) {
|
||||
bin.push(String.fromCharCode(arr[i]));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: 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>;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,794 @@
|
||||
/* eslint-disable */
|
||||
import { Duration } from "../../../../google/protobuf/duration";
|
||||
import { Height } from "../../../../ibc/core/client/v1/client";
|
||||
import { MerkleRoot } from "../../../../ibc/core/commitment/v1/commitment";
|
||||
import { SignedHeader } from "../../../../tendermint/types/types";
|
||||
import { ValidatorSet } from "../../../../tendermint/types/validator";
|
||||
import Long from "long";
|
||||
import { Timestamp } from "../../../../google/protobuf/timestamp";
|
||||
import { ProofSpec } from "../../../../confio/proofs";
|
||||
import _m0 from "protobufjs/minimal";
|
||||
|
||||
export const protobufPackage = "ibc.lightclients.tendermint.v1";
|
||||
|
||||
/**
|
||||
* ClientState from Tendermint tracks the current validator set, latest height,
|
||||
* and a possible frozen height.
|
||||
*/
|
||||
export interface ClientState {
|
||||
chainId: string;
|
||||
trustLevel?: Fraction;
|
||||
/**
|
||||
* duration of the period since the LastestTimestamp during which the
|
||||
* submitted headers are valid for upgrade
|
||||
*/
|
||||
trustingPeriod?: Duration;
|
||||
/** duration of the staking unbonding period */
|
||||
unbondingPeriod?: Duration;
|
||||
/** defines how much new (untrusted) header's Time can drift into the future. */
|
||||
maxClockDrift?: Duration;
|
||||
/** Block height when the client was frozen due to a misbehaviour */
|
||||
frozenHeight?: Height;
|
||||
/** Latest height the client was updated to */
|
||||
latestHeight?: Height;
|
||||
/** Proof specifications used in verifying counterparty state */
|
||||
proofSpecs: ProofSpec[];
|
||||
/**
|
||||
* Path at which next upgraded client will be committed.
|
||||
* Each element corresponds to the key for a single CommitmentProof in the chained proof.
|
||||
* NOTE: ClientState must stored under `{upgradePath}/{upgradeHeight}/clientState`
|
||||
* ConsensusState must be stored under `{upgradepath}/{upgradeHeight}/consensusState`
|
||||
* For SDK chains using the default upgrade module, upgrade_path should be []string{"upgrade", "upgradedIBCState"}`
|
||||
*/
|
||||
upgradePath: string[];
|
||||
/**
|
||||
* This flag, when set to true, will allow governance to recover a client
|
||||
* which has expired
|
||||
*/
|
||||
allowUpdateAfterExpiry: boolean;
|
||||
/**
|
||||
* This flag, when set to true, will allow governance to unfreeze a client
|
||||
* whose chain has experienced a misbehaviour event
|
||||
*/
|
||||
allowUpdateAfterMisbehaviour: boolean;
|
||||
}
|
||||
|
||||
/** ConsensusState defines the consensus state from Tendermint. */
|
||||
export interface ConsensusState {
|
||||
/**
|
||||
* timestamp that corresponds to the block height in which the ConsensusState
|
||||
* was stored.
|
||||
*/
|
||||
timestamp?: Date;
|
||||
/** commitment root (i.e app hash) */
|
||||
root?: MerkleRoot;
|
||||
nextValidatorsHash: Uint8Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Misbehaviour is a wrapper over two conflicting Headers
|
||||
* that implements Misbehaviour interface expected by ICS-02
|
||||
*/
|
||||
export interface Misbehaviour {
|
||||
clientId: string;
|
||||
header1?: Header;
|
||||
header2?: Header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Header defines the Tendermint client consensus Header.
|
||||
* It encapsulates all the information necessary to update from a trusted
|
||||
* Tendermint ConsensusState. The inclusion of TrustedHeight and
|
||||
* TrustedValidators allows this update to process correctly, so long as the
|
||||
* ConsensusState for the TrustedHeight exists, this removes race conditions
|
||||
* among relayers The SignedHeader and ValidatorSet are the new untrusted update
|
||||
* fields for the client. The TrustedHeight is the height of a stored
|
||||
* ConsensusState on the client that will be used to verify the new untrusted
|
||||
* header. The Trusted ConsensusState must be within the unbonding period of
|
||||
* current time in order to correctly verify, and the TrustedValidators must
|
||||
* hash to TrustedConsensusState.NextValidatorsHash since that is the last
|
||||
* trusted validator set at the TrustedHeight.
|
||||
*/
|
||||
export interface Header {
|
||||
signedHeader?: SignedHeader;
|
||||
validatorSet?: ValidatorSet;
|
||||
trustedHeight?: Height;
|
||||
trustedValidators?: ValidatorSet;
|
||||
}
|
||||
|
||||
/** Fraction defines the protobuf message type for tmmath.Fraction that only supports positive values. */
|
||||
export interface Fraction {
|
||||
numerator: Long;
|
||||
denominator: Long;
|
||||
}
|
||||
|
||||
const baseClientState: object = {
|
||||
chainId: "",
|
||||
upgradePath: "",
|
||||
allowUpdateAfterExpiry: false,
|
||||
allowUpdateAfterMisbehaviour: false,
|
||||
};
|
||||
|
||||
export const ClientState = {
|
||||
encode(message: ClientState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.chainId !== "") {
|
||||
writer.uint32(10).string(message.chainId);
|
||||
}
|
||||
if (message.trustLevel !== undefined) {
|
||||
Fraction.encode(message.trustLevel, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
if (message.trustingPeriod !== undefined) {
|
||||
Duration.encode(message.trustingPeriod, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
if (message.unbondingPeriod !== undefined) {
|
||||
Duration.encode(message.unbondingPeriod, writer.uint32(34).fork()).ldelim();
|
||||
}
|
||||
if (message.maxClockDrift !== undefined) {
|
||||
Duration.encode(message.maxClockDrift, writer.uint32(42).fork()).ldelim();
|
||||
}
|
||||
if (message.frozenHeight !== undefined) {
|
||||
Height.encode(message.frozenHeight, writer.uint32(50).fork()).ldelim();
|
||||
}
|
||||
if (message.latestHeight !== undefined) {
|
||||
Height.encode(message.latestHeight, writer.uint32(58).fork()).ldelim();
|
||||
}
|
||||
for (const v of message.proofSpecs) {
|
||||
ProofSpec.encode(v!, writer.uint32(66).fork()).ldelim();
|
||||
}
|
||||
for (const v of message.upgradePath) {
|
||||
writer.uint32(74).string(v!);
|
||||
}
|
||||
if (message.allowUpdateAfterExpiry === true) {
|
||||
writer.uint32(80).bool(message.allowUpdateAfterExpiry);
|
||||
}
|
||||
if (message.allowUpdateAfterMisbehaviour === true) {
|
||||
writer.uint32(88).bool(message.allowUpdateAfterMisbehaviour);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): ClientState {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseClientState } as ClientState;
|
||||
message.proofSpecs = [];
|
||||
message.upgradePath = [];
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.chainId = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.trustLevel = Fraction.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 3:
|
||||
message.trustingPeriod = Duration.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 4:
|
||||
message.unbondingPeriod = Duration.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 5:
|
||||
message.maxClockDrift = Duration.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 6:
|
||||
message.frozenHeight = Height.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 7:
|
||||
message.latestHeight = Height.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 8:
|
||||
message.proofSpecs.push(ProofSpec.decode(reader, reader.uint32()));
|
||||
break;
|
||||
case 9:
|
||||
message.upgradePath.push(reader.string());
|
||||
break;
|
||||
case 10:
|
||||
message.allowUpdateAfterExpiry = reader.bool();
|
||||
break;
|
||||
case 11:
|
||||
message.allowUpdateAfterMisbehaviour = reader.bool();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): ClientState {
|
||||
const message = { ...baseClientState } as ClientState;
|
||||
message.proofSpecs = [];
|
||||
message.upgradePath = [];
|
||||
if (object.chainId !== undefined && object.chainId !== null) {
|
||||
message.chainId = String(object.chainId);
|
||||
} else {
|
||||
message.chainId = "";
|
||||
}
|
||||
if (object.trustLevel !== undefined && object.trustLevel !== null) {
|
||||
message.trustLevel = Fraction.fromJSON(object.trustLevel);
|
||||
} else {
|
||||
message.trustLevel = undefined;
|
||||
}
|
||||
if (object.trustingPeriod !== undefined && object.trustingPeriod !== null) {
|
||||
message.trustingPeriod = Duration.fromJSON(object.trustingPeriod);
|
||||
} else {
|
||||
message.trustingPeriod = undefined;
|
||||
}
|
||||
if (object.unbondingPeriod !== undefined && object.unbondingPeriod !== null) {
|
||||
message.unbondingPeriod = Duration.fromJSON(object.unbondingPeriod);
|
||||
} else {
|
||||
message.unbondingPeriod = undefined;
|
||||
}
|
||||
if (object.maxClockDrift !== undefined && object.maxClockDrift !== null) {
|
||||
message.maxClockDrift = Duration.fromJSON(object.maxClockDrift);
|
||||
} else {
|
||||
message.maxClockDrift = undefined;
|
||||
}
|
||||
if (object.frozenHeight !== undefined && object.frozenHeight !== null) {
|
||||
message.frozenHeight = Height.fromJSON(object.frozenHeight);
|
||||
} else {
|
||||
message.frozenHeight = undefined;
|
||||
}
|
||||
if (object.latestHeight !== undefined && object.latestHeight !== null) {
|
||||
message.latestHeight = Height.fromJSON(object.latestHeight);
|
||||
} else {
|
||||
message.latestHeight = undefined;
|
||||
}
|
||||
if (object.proofSpecs !== undefined && object.proofSpecs !== null) {
|
||||
for (const e of object.proofSpecs) {
|
||||
message.proofSpecs.push(ProofSpec.fromJSON(e));
|
||||
}
|
||||
}
|
||||
if (object.upgradePath !== undefined && object.upgradePath !== null) {
|
||||
for (const e of object.upgradePath) {
|
||||
message.upgradePath.push(String(e));
|
||||
}
|
||||
}
|
||||
if (object.allowUpdateAfterExpiry !== undefined && object.allowUpdateAfterExpiry !== null) {
|
||||
message.allowUpdateAfterExpiry = Boolean(object.allowUpdateAfterExpiry);
|
||||
} else {
|
||||
message.allowUpdateAfterExpiry = false;
|
||||
}
|
||||
if (object.allowUpdateAfterMisbehaviour !== undefined && object.allowUpdateAfterMisbehaviour !== null) {
|
||||
message.allowUpdateAfterMisbehaviour = Boolean(object.allowUpdateAfterMisbehaviour);
|
||||
} else {
|
||||
message.allowUpdateAfterMisbehaviour = false;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: ClientState): unknown {
|
||||
const obj: any = {};
|
||||
message.chainId !== undefined && (obj.chainId = message.chainId);
|
||||
message.trustLevel !== undefined &&
|
||||
(obj.trustLevel = message.trustLevel ? Fraction.toJSON(message.trustLevel) : undefined);
|
||||
message.trustingPeriod !== undefined &&
|
||||
(obj.trustingPeriod = message.trustingPeriod ? Duration.toJSON(message.trustingPeriod) : undefined);
|
||||
message.unbondingPeriod !== undefined &&
|
||||
(obj.unbondingPeriod = message.unbondingPeriod ? Duration.toJSON(message.unbondingPeriod) : undefined);
|
||||
message.maxClockDrift !== undefined &&
|
||||
(obj.maxClockDrift = message.maxClockDrift ? Duration.toJSON(message.maxClockDrift) : undefined);
|
||||
message.frozenHeight !== undefined &&
|
||||
(obj.frozenHeight = message.frozenHeight ? Height.toJSON(message.frozenHeight) : undefined);
|
||||
message.latestHeight !== undefined &&
|
||||
(obj.latestHeight = message.latestHeight ? Height.toJSON(message.latestHeight) : undefined);
|
||||
if (message.proofSpecs) {
|
||||
obj.proofSpecs = message.proofSpecs.map((e) => (e ? ProofSpec.toJSON(e) : undefined));
|
||||
} else {
|
||||
obj.proofSpecs = [];
|
||||
}
|
||||
if (message.upgradePath) {
|
||||
obj.upgradePath = message.upgradePath.map((e) => e);
|
||||
} else {
|
||||
obj.upgradePath = [];
|
||||
}
|
||||
message.allowUpdateAfterExpiry !== undefined &&
|
||||
(obj.allowUpdateAfterExpiry = message.allowUpdateAfterExpiry);
|
||||
message.allowUpdateAfterMisbehaviour !== undefined &&
|
||||
(obj.allowUpdateAfterMisbehaviour = message.allowUpdateAfterMisbehaviour);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<ClientState>): ClientState {
|
||||
const message = { ...baseClientState } as ClientState;
|
||||
message.proofSpecs = [];
|
||||
message.upgradePath = [];
|
||||
if (object.chainId !== undefined && object.chainId !== null) {
|
||||
message.chainId = object.chainId;
|
||||
} else {
|
||||
message.chainId = "";
|
||||
}
|
||||
if (object.trustLevel !== undefined && object.trustLevel !== null) {
|
||||
message.trustLevel = Fraction.fromPartial(object.trustLevel);
|
||||
} else {
|
||||
message.trustLevel = undefined;
|
||||
}
|
||||
if (object.trustingPeriod !== undefined && object.trustingPeriod !== null) {
|
||||
message.trustingPeriod = Duration.fromPartial(object.trustingPeriod);
|
||||
} else {
|
||||
message.trustingPeriod = undefined;
|
||||
}
|
||||
if (object.unbondingPeriod !== undefined && object.unbondingPeriod !== null) {
|
||||
message.unbondingPeriod = Duration.fromPartial(object.unbondingPeriod);
|
||||
} else {
|
||||
message.unbondingPeriod = undefined;
|
||||
}
|
||||
if (object.maxClockDrift !== undefined && object.maxClockDrift !== null) {
|
||||
message.maxClockDrift = Duration.fromPartial(object.maxClockDrift);
|
||||
} else {
|
||||
message.maxClockDrift = undefined;
|
||||
}
|
||||
if (object.frozenHeight !== undefined && object.frozenHeight !== null) {
|
||||
message.frozenHeight = Height.fromPartial(object.frozenHeight);
|
||||
} else {
|
||||
message.frozenHeight = undefined;
|
||||
}
|
||||
if (object.latestHeight !== undefined && object.latestHeight !== null) {
|
||||
message.latestHeight = Height.fromPartial(object.latestHeight);
|
||||
} else {
|
||||
message.latestHeight = undefined;
|
||||
}
|
||||
if (object.proofSpecs !== undefined && object.proofSpecs !== null) {
|
||||
for (const e of object.proofSpecs) {
|
||||
message.proofSpecs.push(ProofSpec.fromPartial(e));
|
||||
}
|
||||
}
|
||||
if (object.upgradePath !== undefined && object.upgradePath !== null) {
|
||||
for (const e of object.upgradePath) {
|
||||
message.upgradePath.push(e);
|
||||
}
|
||||
}
|
||||
if (object.allowUpdateAfterExpiry !== undefined && object.allowUpdateAfterExpiry !== null) {
|
||||
message.allowUpdateAfterExpiry = object.allowUpdateAfterExpiry;
|
||||
} else {
|
||||
message.allowUpdateAfterExpiry = false;
|
||||
}
|
||||
if (object.allowUpdateAfterMisbehaviour !== undefined && object.allowUpdateAfterMisbehaviour !== null) {
|
||||
message.allowUpdateAfterMisbehaviour = object.allowUpdateAfterMisbehaviour;
|
||||
} else {
|
||||
message.allowUpdateAfterMisbehaviour = false;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseConsensusState: object = {};
|
||||
|
||||
export const ConsensusState = {
|
||||
encode(message: ConsensusState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.timestamp !== undefined) {
|
||||
Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(10).fork()).ldelim();
|
||||
}
|
||||
if (message.root !== undefined) {
|
||||
MerkleRoot.encode(message.root, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
if (message.nextValidatorsHash.length !== 0) {
|
||||
writer.uint32(26).bytes(message.nextValidatorsHash);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): ConsensusState {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseConsensusState } as ConsensusState;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.timestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
|
||||
break;
|
||||
case 2:
|
||||
message.root = MerkleRoot.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 3:
|
||||
message.nextValidatorsHash = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): ConsensusState {
|
||||
const message = { ...baseConsensusState } as ConsensusState;
|
||||
if (object.timestamp !== undefined && object.timestamp !== null) {
|
||||
message.timestamp = fromJsonTimestamp(object.timestamp);
|
||||
} else {
|
||||
message.timestamp = undefined;
|
||||
}
|
||||
if (object.root !== undefined && object.root !== null) {
|
||||
message.root = MerkleRoot.fromJSON(object.root);
|
||||
} else {
|
||||
message.root = undefined;
|
||||
}
|
||||
if (object.nextValidatorsHash !== undefined && object.nextValidatorsHash !== null) {
|
||||
message.nextValidatorsHash = bytesFromBase64(object.nextValidatorsHash);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: ConsensusState): unknown {
|
||||
const obj: any = {};
|
||||
message.timestamp !== undefined &&
|
||||
(obj.timestamp = message.timestamp !== undefined ? message.timestamp.toISOString() : null);
|
||||
message.root !== undefined && (obj.root = message.root ? MerkleRoot.toJSON(message.root) : undefined);
|
||||
message.nextValidatorsHash !== undefined &&
|
||||
(obj.nextValidatorsHash = base64FromBytes(
|
||||
message.nextValidatorsHash !== undefined ? message.nextValidatorsHash : new Uint8Array(),
|
||||
));
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<ConsensusState>): ConsensusState {
|
||||
const message = { ...baseConsensusState } as ConsensusState;
|
||||
if (object.timestamp !== undefined && object.timestamp !== null) {
|
||||
message.timestamp = object.timestamp;
|
||||
} else {
|
||||
message.timestamp = undefined;
|
||||
}
|
||||
if (object.root !== undefined && object.root !== null) {
|
||||
message.root = MerkleRoot.fromPartial(object.root);
|
||||
} else {
|
||||
message.root = undefined;
|
||||
}
|
||||
if (object.nextValidatorsHash !== undefined && object.nextValidatorsHash !== null) {
|
||||
message.nextValidatorsHash = object.nextValidatorsHash;
|
||||
} else {
|
||||
message.nextValidatorsHash = new Uint8Array();
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseMisbehaviour: object = { clientId: "" };
|
||||
|
||||
export const Misbehaviour = {
|
||||
encode(message: Misbehaviour, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.clientId !== "") {
|
||||
writer.uint32(10).string(message.clientId);
|
||||
}
|
||||
if (message.header1 !== undefined) {
|
||||
Header.encode(message.header1, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
if (message.header2 !== undefined) {
|
||||
Header.encode(message.header2, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): Misbehaviour {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseMisbehaviour } as Misbehaviour;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.clientId = reader.string();
|
||||
break;
|
||||
case 2:
|
||||
message.header1 = Header.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 3:
|
||||
message.header2 = Header.decode(reader, reader.uint32());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Misbehaviour {
|
||||
const message = { ...baseMisbehaviour } as Misbehaviour;
|
||||
if (object.clientId !== undefined && object.clientId !== null) {
|
||||
message.clientId = String(object.clientId);
|
||||
} else {
|
||||
message.clientId = "";
|
||||
}
|
||||
if (object.header1 !== undefined && object.header1 !== null) {
|
||||
message.header1 = Header.fromJSON(object.header1);
|
||||
} else {
|
||||
message.header1 = undefined;
|
||||
}
|
||||
if (object.header2 !== undefined && object.header2 !== null) {
|
||||
message.header2 = Header.fromJSON(object.header2);
|
||||
} else {
|
||||
message.header2 = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: Misbehaviour): unknown {
|
||||
const obj: any = {};
|
||||
message.clientId !== undefined && (obj.clientId = message.clientId);
|
||||
message.header1 !== undefined &&
|
||||
(obj.header1 = message.header1 ? Header.toJSON(message.header1) : undefined);
|
||||
message.header2 !== undefined &&
|
||||
(obj.header2 = message.header2 ? Header.toJSON(message.header2) : undefined);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<Misbehaviour>): Misbehaviour {
|
||||
const message = { ...baseMisbehaviour } as Misbehaviour;
|
||||
if (object.clientId !== undefined && object.clientId !== null) {
|
||||
message.clientId = object.clientId;
|
||||
} else {
|
||||
message.clientId = "";
|
||||
}
|
||||
if (object.header1 !== undefined && object.header1 !== null) {
|
||||
message.header1 = Header.fromPartial(object.header1);
|
||||
} else {
|
||||
message.header1 = undefined;
|
||||
}
|
||||
if (object.header2 !== undefined && object.header2 !== null) {
|
||||
message.header2 = Header.fromPartial(object.header2);
|
||||
} else {
|
||||
message.header2 = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseHeader: object = {};
|
||||
|
||||
export const Header = {
|
||||
encode(message: Header, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.signedHeader !== undefined) {
|
||||
SignedHeader.encode(message.signedHeader, writer.uint32(10).fork()).ldelim();
|
||||
}
|
||||
if (message.validatorSet !== undefined) {
|
||||
ValidatorSet.encode(message.validatorSet, writer.uint32(18).fork()).ldelim();
|
||||
}
|
||||
if (message.trustedHeight !== undefined) {
|
||||
Height.encode(message.trustedHeight, writer.uint32(26).fork()).ldelim();
|
||||
}
|
||||
if (message.trustedValidators !== undefined) {
|
||||
ValidatorSet.encode(message.trustedValidators, writer.uint32(34).fork()).ldelim();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): Header {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseHeader } as Header;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.signedHeader = SignedHeader.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 2:
|
||||
message.validatorSet = ValidatorSet.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 3:
|
||||
message.trustedHeight = Height.decode(reader, reader.uint32());
|
||||
break;
|
||||
case 4:
|
||||
message.trustedValidators = ValidatorSet.decode(reader, reader.uint32());
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Header {
|
||||
const message = { ...baseHeader } as Header;
|
||||
if (object.signedHeader !== undefined && object.signedHeader !== null) {
|
||||
message.signedHeader = SignedHeader.fromJSON(object.signedHeader);
|
||||
} else {
|
||||
message.signedHeader = undefined;
|
||||
}
|
||||
if (object.validatorSet !== undefined && object.validatorSet !== null) {
|
||||
message.validatorSet = ValidatorSet.fromJSON(object.validatorSet);
|
||||
} else {
|
||||
message.validatorSet = undefined;
|
||||
}
|
||||
if (object.trustedHeight !== undefined && object.trustedHeight !== null) {
|
||||
message.trustedHeight = Height.fromJSON(object.trustedHeight);
|
||||
} else {
|
||||
message.trustedHeight = undefined;
|
||||
}
|
||||
if (object.trustedValidators !== undefined && object.trustedValidators !== null) {
|
||||
message.trustedValidators = ValidatorSet.fromJSON(object.trustedValidators);
|
||||
} else {
|
||||
message.trustedValidators = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: Header): unknown {
|
||||
const obj: any = {};
|
||||
message.signedHeader !== undefined &&
|
||||
(obj.signedHeader = message.signedHeader ? SignedHeader.toJSON(message.signedHeader) : undefined);
|
||||
message.validatorSet !== undefined &&
|
||||
(obj.validatorSet = message.validatorSet ? ValidatorSet.toJSON(message.validatorSet) : undefined);
|
||||
message.trustedHeight !== undefined &&
|
||||
(obj.trustedHeight = message.trustedHeight ? Height.toJSON(message.trustedHeight) : undefined);
|
||||
message.trustedValidators !== undefined &&
|
||||
(obj.trustedValidators = message.trustedValidators
|
||||
? ValidatorSet.toJSON(message.trustedValidators)
|
||||
: undefined);
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<Header>): Header {
|
||||
const message = { ...baseHeader } as Header;
|
||||
if (object.signedHeader !== undefined && object.signedHeader !== null) {
|
||||
message.signedHeader = SignedHeader.fromPartial(object.signedHeader);
|
||||
} else {
|
||||
message.signedHeader = undefined;
|
||||
}
|
||||
if (object.validatorSet !== undefined && object.validatorSet !== null) {
|
||||
message.validatorSet = ValidatorSet.fromPartial(object.validatorSet);
|
||||
} else {
|
||||
message.validatorSet = undefined;
|
||||
}
|
||||
if (object.trustedHeight !== undefined && object.trustedHeight !== null) {
|
||||
message.trustedHeight = Height.fromPartial(object.trustedHeight);
|
||||
} else {
|
||||
message.trustedHeight = undefined;
|
||||
}
|
||||
if (object.trustedValidators !== undefined && object.trustedValidators !== null) {
|
||||
message.trustedValidators = ValidatorSet.fromPartial(object.trustedValidators);
|
||||
} else {
|
||||
message.trustedValidators = undefined;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
const baseFraction: object = { numerator: Long.UZERO, denominator: Long.UZERO };
|
||||
|
||||
export const Fraction = {
|
||||
encode(message: Fraction, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (!message.numerator.isZero()) {
|
||||
writer.uint32(8).uint64(message.numerator);
|
||||
}
|
||||
if (!message.denominator.isZero()) {
|
||||
writer.uint32(16).uint64(message.denominator);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): Fraction {
|
||||
const reader = input instanceof Uint8Array ? new _m0.Reader(input) : input;
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = { ...baseFraction } as Fraction;
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
message.numerator = reader.uint64() as Long;
|
||||
break;
|
||||
case 2:
|
||||
message.denominator = reader.uint64() as Long;
|
||||
break;
|
||||
default:
|
||||
reader.skipType(tag & 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Fraction {
|
||||
const message = { ...baseFraction } as Fraction;
|
||||
if (object.numerator !== undefined && object.numerator !== null) {
|
||||
message.numerator = Long.fromString(object.numerator);
|
||||
} else {
|
||||
message.numerator = Long.UZERO;
|
||||
}
|
||||
if (object.denominator !== undefined && object.denominator !== null) {
|
||||
message.denominator = Long.fromString(object.denominator);
|
||||
} else {
|
||||
message.denominator = Long.UZERO;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
toJSON(message: Fraction): unknown {
|
||||
const obj: any = {};
|
||||
message.numerator !== undefined && (obj.numerator = (message.numerator || Long.UZERO).toString());
|
||||
message.denominator !== undefined && (obj.denominator = (message.denominator || Long.UZERO).toString());
|
||||
return obj;
|
||||
},
|
||||
|
||||
fromPartial(object: DeepPartial<Fraction>): Fraction {
|
||||
const message = { ...baseFraction } as Fraction;
|
||||
if (object.numerator !== undefined && object.numerator !== null) {
|
||||
message.numerator = object.numerator as Long;
|
||||
} else {
|
||||
message.numerator = Long.UZERO;
|
||||
}
|
||||
if (object.denominator !== undefined && object.denominator !== null) {
|
||||
message.denominator = object.denominator as Long;
|
||||
} else {
|
||||
message.denominator = Long.UZERO;
|
||||
}
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
declare var self: any | undefined;
|
||||
declare var window: any | undefined;
|
||||
var globalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
if (typeof self !== "undefined") return self;
|
||||
if (typeof window !== "undefined") return window;
|
||||
if (typeof global !== "undefined") return global;
|
||||
throw "Unable to locate global object";
|
||||
})();
|
||||
|
||||
const atob: (b64: string) => string =
|
||||
globalThis.atob || ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
||||
function bytesFromBase64(b64: string): Uint8Array {
|
||||
const bin = atob(b64);
|
||||
const arr = new Uint8Array(bin.length);
|
||||
for (let i = 0; i < bin.length; ++i) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
const btoa: (bin: string) => string =
|
||||
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
||||
function base64FromBytes(arr: Uint8Array): string {
|
||||
const bin: string[] = [];
|
||||
for (let i = 0; i < arr.byteLength; ++i) {
|
||||
bin.push(String.fromCharCode(arr[i]));
|
||||
}
|
||||
return btoa(bin.join(""));
|
||||
}
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | undefined | Long;
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: 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>;
|
||||
|
||||
function toTimestamp(date: Date): Timestamp {
|
||||
const seconds = numberToLong(date.getTime() / 1_000);
|
||||
const nanos = (date.getTime() % 1_000) * 1_000_000;
|
||||
return { seconds, nanos };
|
||||
}
|
||||
|
||||
function fromTimestamp(t: Timestamp): Date {
|
||||
let millis = t.seconds.toNumber() * 1_000;
|
||||
millis += t.nanos / 1_000_000;
|
||||
return new Date(millis);
|
||||
}
|
||||
|
||||
function fromJsonTimestamp(o: any): Date {
|
||||
if (o instanceof Date) {
|
||||
return o;
|
||||
} else if (typeof o === "string") {
|
||||
return new Date(o);
|
||||
} else {
|
||||
return fromTimestamp(Timestamp.fromJSON(o));
|
||||
}
|
||||
}
|
||||
|
||||
function numberToLong(number: number) {
|
||||
return Long.fromNumber(number);
|
||||
}
|
||||
|
||||
if (_m0.util.Long !== Long) {
|
||||
_m0.util.Long = Long as any;
|
||||
_m0.configure();
|
||||
}
|
||||
@@ -14,220 +14,562 @@ async function makeClientWithIbc(rpcUrl: string): Promise<[QueryClient & IbcExte
|
||||
describe("IbcExtension", () => {
|
||||
describe("unverified", () => {
|
||||
describe("channel", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
describe("channel", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channel(ibcTest.portId, ibcTest.channelId);
|
||||
expect(response.channel).toEqual(ibcTest.channel);
|
||||
expect(response.proofHeight).toBeDefined();
|
||||
expect(response.proofHeight).not.toBeNull();
|
||||
const response = await client.ibc.unverified.channel.channel(ibcTest.portId, ibcTest.channelId);
|
||||
expect(response.channel).toEqual(ibcTest.channel);
|
||||
expect(response.proofHeight).toBeDefined();
|
||||
expect(response.proofHeight).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("channels", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channel.channels();
|
||||
expect(response.channels).toEqual([ibcTest.identifiedChannel]);
|
||||
expect(response.pagination).toBeDefined();
|
||||
expect(response.height).toBeDefined();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("allChannels", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channel.allChannels();
|
||||
expect(response.channels).toEqual([ibcTest.identifiedChannel]);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("connectionChannels", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channel.connectionChannels(ibcTest.connectionId);
|
||||
expect(response.channels).toEqual([ibcTest.identifiedChannel]);
|
||||
expect(response.pagination).toBeDefined();
|
||||
expect(response.height).toBeDefined();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("allConnectionChannels", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channel.allConnectionChannels(ibcTest.connectionId);
|
||||
expect(response.channels).toEqual([ibcTest.identifiedChannel]);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("clientState", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channel.clientState(ibcTest.portId, ibcTest.channelId);
|
||||
expect(response.identifiedClientState).toEqual({
|
||||
clientId: ibcTest.clientId,
|
||||
clientState: {
|
||||
typeUrl: "/ibc.lightclients.tendermint.v1.ClientState",
|
||||
value: jasmine.any(Uint8Array),
|
||||
},
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("consensusState", () => {
|
||||
xit("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channel.consensusState(
|
||||
ibcTest.portId,
|
||||
ibcTest.channelId,
|
||||
// TODO: Find valid values
|
||||
0,
|
||||
0,
|
||||
);
|
||||
expect(response.consensusState).toEqual({
|
||||
typeUrl: "/haha",
|
||||
value: jasmine.any(Uint8Array),
|
||||
});
|
||||
expect(response.clientId).toEqual(ibcTest.clientId);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("packetCommitment", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channel.packetCommitment(
|
||||
ibcTest.portId,
|
||||
ibcTest.channelId,
|
||||
Long.fromInt(ibcTest.commitment.sequence, true),
|
||||
);
|
||||
expect(response.commitment).toEqual(ibcTest.commitment.data);
|
||||
expect(response.proofHeight).toBeDefined();
|
||||
expect(response.proofHeight).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("packetCommitments", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channel.packetCommitments(
|
||||
ibcTest.portId,
|
||||
ibcTest.channelId,
|
||||
);
|
||||
expect(response.commitments).toEqual([ibcTest.packetState]);
|
||||
expect(response.pagination).toBeDefined();
|
||||
expect(response.height).toBeDefined();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("allPacketCommitments", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channel.allPacketCommitments(
|
||||
ibcTest.portId,
|
||||
ibcTest.channelId,
|
||||
);
|
||||
expect(response.commitments).toEqual([ibcTest.packetState]);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("packetReceipt", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channel.packetReceipt(
|
||||
ibcTest.portId,
|
||||
ibcTest.channelId,
|
||||
1,
|
||||
);
|
||||
expect(response.received).toEqual(false);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("packetAcknowledgement", () => {
|
||||
it("works", async () => {
|
||||
pending("We don't have an acknowledgement for testing at the moment");
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channel.packetAcknowledgement(
|
||||
ibcTest.portId,
|
||||
ibcTest.channelId,
|
||||
ibcTest.commitment.sequence,
|
||||
);
|
||||
expect(response.acknowledgement).toEqual(ibcTest.packetAcknowledgements[0].data);
|
||||
expect(response.proofHeight).toBeDefined();
|
||||
expect(response.proofHeight).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("packetAcknowledgements", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channel.packetAcknowledgements(
|
||||
ibcTest.portId,
|
||||
ibcTest.channelId,
|
||||
);
|
||||
expect(response.acknowledgements).toEqual(ibcTest.packetAcknowledgements);
|
||||
expect(response.pagination).toBeDefined();
|
||||
expect(response.height).toBeDefined();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("allPacketAcknowledgements", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channel.allPacketAcknowledgements(
|
||||
ibcTest.portId,
|
||||
ibcTest.channelId,
|
||||
);
|
||||
expect(response.acknowledgements).toEqual(ibcTest.packetAcknowledgements);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("unreceivedPackets", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channel.unreceivedPackets(
|
||||
ibcTest.portId,
|
||||
ibcTest.channelId,
|
||||
[1, 2, 3],
|
||||
);
|
||||
expect(response.sequences).toEqual([1, 2, 3].map((n) => Long.fromInt(n, true)));
|
||||
expect(response.height).toBeDefined();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("unreceivedAcks", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channel.unreceivedAcks(
|
||||
ibcTest.portId,
|
||||
ibcTest.channelId,
|
||||
[1, 2, 3, 4, 5, 6, 7],
|
||||
);
|
||||
expect(response.sequences).toEqual([Long.fromInt(ibcTest.commitment.sequence, true)]);
|
||||
expect(response.height).toBeDefined();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("nextSequenceReceive", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channel.nextSequenceReceive(
|
||||
ibcTest.portId,
|
||||
ibcTest.channelId,
|
||||
);
|
||||
expect(response.nextSequenceReceive).toEqual(Long.fromInt(1, true));
|
||||
expect(response.proofHeight).toBeDefined();
|
||||
expect(response.proofHeight).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("channels", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
describe("client", () => {
|
||||
describe("state", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.channels();
|
||||
expect(response.channels).toEqual([ibcTest.identifiedChannel]);
|
||||
expect(response.pagination).toBeDefined();
|
||||
expect(response.pagination).not.toBeNull();
|
||||
expect(response.height).toBeDefined();
|
||||
expect(response.height).not.toBeNull();
|
||||
const response = await client.ibc.unverified.client.state(ibcTest.clientId);
|
||||
expect(response.clientState).toEqual({
|
||||
typeUrl: "/ibc.lightclients.tendermint.v1.ClientState",
|
||||
value: jasmine.any(Uint8Array),
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("states", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.client.states();
|
||||
expect(response.clientStates).toEqual([
|
||||
{
|
||||
clientId: ibcTest.clientId,
|
||||
clientState: {
|
||||
typeUrl: "/ibc.lightclients.tendermint.v1.ClientState",
|
||||
value: jasmine.any(Uint8Array),
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(response.pagination).toBeDefined();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("allStates", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.client.allStates();
|
||||
expect(response.clientStates).toEqual([
|
||||
{
|
||||
clientId: ibcTest.clientId,
|
||||
clientState: {
|
||||
typeUrl: "/ibc.lightclients.tendermint.v1.ClientState",
|
||||
value: jasmine.any(Uint8Array),
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("consensusState", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.client.consensusState(ibcTest.clientId);
|
||||
expect(response.consensusState).toEqual({
|
||||
typeUrl: "/ibc.lightclients.tendermint.v1.ConsensusState",
|
||||
value: jasmine.any(Uint8Array),
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("consensusStates", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.client.consensusStates(ibcTest.clientId);
|
||||
expect(response.consensusStates).toEqual(
|
||||
jasmine.arrayContaining([
|
||||
{
|
||||
height: jasmine.anything(),
|
||||
consensusState: {
|
||||
typeUrl: "/ibc.lightclients.tendermint.v1.ConsensusState",
|
||||
value: jasmine.any(Uint8Array),
|
||||
},
|
||||
},
|
||||
]),
|
||||
);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("allConsensusStates", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.client.allConsensusStates(ibcTest.clientId);
|
||||
expect(response.consensusStates).toEqual(
|
||||
jasmine.arrayContaining([
|
||||
{
|
||||
height: jasmine.anything(),
|
||||
consensusState: {
|
||||
typeUrl: "/ibc.lightclients.tendermint.v1.ConsensusState",
|
||||
value: jasmine.any(Uint8Array),
|
||||
},
|
||||
},
|
||||
]),
|
||||
);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("params", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.client.params();
|
||||
expect(response.params).toEqual({
|
||||
allowedClients: ["06-solomachine", "07-tendermint"],
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("stateTm", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.client.stateTm(ibcTest.clientId);
|
||||
expect(response.chainId).toEqual("ibc-1");
|
||||
// TODO: Fill these expectations out
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("statesTm", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.client.statesTm();
|
||||
expect(response).toEqual(
|
||||
jasmine.arrayContaining([
|
||||
jasmine.objectContaining({
|
||||
chainId: "ibc-1",
|
||||
}),
|
||||
]),
|
||||
);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("allStatesTm", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.client.allStatesTm();
|
||||
expect(response).toEqual(
|
||||
jasmine.arrayContaining([
|
||||
jasmine.objectContaining({
|
||||
chainId: "ibc-1",
|
||||
}),
|
||||
]),
|
||||
);
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("consensusStateTm", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.client.consensusStateTm(ibcTest.clientId);
|
||||
expect(response.nextValidatorsHash).toEqual(jasmine.any(Uint8Array));
|
||||
// TODO: Fill out these expectations
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("connectionChannels", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.connectionChannels(ibcTest.connectionId);
|
||||
expect(response.channels).toEqual([ibcTest.identifiedChannel]);
|
||||
expect(response.pagination).toBeDefined();
|
||||
expect(response.pagination).not.toBeNull();
|
||||
expect(response.height).toBeDefined();
|
||||
expect(response.height).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("packetCommitment", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.packetCommitment(
|
||||
ibcTest.portId,
|
||||
ibcTest.channelId,
|
||||
ibcTest.commitment.sequence,
|
||||
);
|
||||
expect(response.commitment).toEqual(ibcTest.commitment.data);
|
||||
expect(response.proofHeight).toBeDefined();
|
||||
expect(response.proofHeight).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("packetCommitments", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.packetCommitments(ibcTest.portId, ibcTest.channelId);
|
||||
expect(response.commitments).toEqual([ibcTest.packetState]);
|
||||
expect(response.pagination).toBeDefined();
|
||||
expect(response.pagination).not.toBeNull();
|
||||
expect(response.height).toBeDefined();
|
||||
expect(response.height).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("packetAcknowledgement", () => {
|
||||
it("works", async () => {
|
||||
pending("We don't have an acknowledgement for testing at the moment");
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.packetAcknowledgement(
|
||||
ibcTest.portId,
|
||||
ibcTest.channelId,
|
||||
ibcTest.commitment.sequence,
|
||||
);
|
||||
expect(response.acknowledgement).toEqual(ibcTest.packetAcknowledgements[0].data);
|
||||
expect(response.proofHeight).toBeDefined();
|
||||
expect(response.proofHeight).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("packetAcknowledgements", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.packetAcknowledgements(
|
||||
ibcTest.portId,
|
||||
ibcTest.channelId,
|
||||
);
|
||||
expect(response.acknowledgements).toEqual(ibcTest.packetAcknowledgements);
|
||||
expect(response.pagination).toBeDefined();
|
||||
expect(response.pagination).not.toBeNull();
|
||||
expect(response.height).toBeDefined();
|
||||
expect(response.height).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("unreceivedPackets", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.unreceivedPackets(ibcTest.portId, ibcTest.channelId, [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
]);
|
||||
expect(response.sequences).toEqual([1, 2, 3].map((n) => Long.fromInt(n, true)));
|
||||
expect(response.height).toBeDefined();
|
||||
expect(response.height).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("unreceivedAcks", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.unreceivedAcks(ibcTest.portId, ibcTest.channelId, [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
]);
|
||||
expect(response.sequences).toEqual([Long.fromInt(ibcTest.commitment.sequence, true)]);
|
||||
expect(response.height).toBeDefined();
|
||||
expect(response.height).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("nextSequenceReceive", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.nextSequenceReceive(ibcTest.portId, ibcTest.channelId);
|
||||
expect(response.nextSequenceReceive).toEqual(Long.fromInt(1, true));
|
||||
expect(response.proofHeight).toBeDefined();
|
||||
expect(response.proofHeight).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
// Queries for ibc.connection
|
||||
|
||||
describe("connection", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
describe("connection", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.connection(ibcTest.connectionId);
|
||||
expect(response.connection).toEqual(ibcTest.connection);
|
||||
expect(response.proofHeight).toBeDefined();
|
||||
expect(response.proofHeight).not.toBeNull();
|
||||
const response = await client.ibc.unverified.connection.connection(ibcTest.connectionId);
|
||||
expect(response.connection).toEqual(ibcTest.connection);
|
||||
expect(response.proofHeight).toBeDefined();
|
||||
expect(response.proofHeight).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("connections", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
describe("connections", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.connections();
|
||||
expect(response.connections).toEqual([ibcTest.identifiedConnection]);
|
||||
expect(response.pagination).toBeDefined();
|
||||
expect(response.pagination).not.toBeNull();
|
||||
expect(response.height).toBeDefined();
|
||||
expect(response.height).not.toBeNull();
|
||||
const response = await client.ibc.unverified.connection.connections();
|
||||
expect(response.connections).toEqual([ibcTest.identifiedConnection]);
|
||||
expect(response.pagination).toBeDefined();
|
||||
expect(response.height).toBeDefined();
|
||||
|
||||
tmClient.disconnect();
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("clientConnections", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
describe("allConnections", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.clientConnections(ibcTest.clientId);
|
||||
expect(response.connectionPaths).toEqual([ibcTest.connectionId]);
|
||||
expect(response.proofHeight).toBeDefined();
|
||||
expect(response.proofHeight).not.toBeNull();
|
||||
const response = await client.ibc.unverified.connection.allConnections();
|
||||
expect(response.connections).toEqual([ibcTest.identifiedConnection]);
|
||||
|
||||
tmClient.disconnect();
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("clientConnections", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.connection.clientConnections(ibcTest.clientId);
|
||||
expect(response.connectionPaths).toEqual([ibcTest.connectionId]);
|
||||
expect(response.proofHeight).toBeDefined();
|
||||
expect(response.proofHeight).not.toBeNull();
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("clientState", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
const response = await client.ibc.unverified.connection.clientState(ibcTest.connectionId);
|
||||
expect(response.identifiedClientState).toEqual({
|
||||
clientId: ibcTest.clientId,
|
||||
clientState: {
|
||||
typeUrl: "/ibc.lightclients.tendermint.v1.ClientState",
|
||||
value: jasmine.any(Uint8Array),
|
||||
},
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe("consensusState", () => {
|
||||
xit("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const [client, tmClient] = await makeClientWithIbc(simapp.tendermintUrl);
|
||||
|
||||
// TODO: Find valid values
|
||||
const response = await client.ibc.unverified.connection.consensusState(ibcTest.connectionId, 1, 1);
|
||||
expect(response.clientId).toEqual(ibcTest.clientId);
|
||||
expect(response.consensusState).toEqual({
|
||||
typeUrl: "/ibc.lightclients.tendermint.v1.ConsensusState",
|
||||
value: jasmine.any(Uint8Array),
|
||||
});
|
||||
|
||||
tmClient.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,8 +3,11 @@ import { toAscii } from "@cosmjs/encoding";
|
||||
import { Uint64 } from "@cosmjs/math";
|
||||
import Long from "long";
|
||||
|
||||
import { Any } from "../codec/google/protobuf/any";
|
||||
import { Channel } from "../codec/ibc/core/channel/v1/channel";
|
||||
import {
|
||||
QueryChannelClientStateResponse,
|
||||
QueryChannelConsensusStateResponse,
|
||||
QueryChannelResponse,
|
||||
QueryChannelsResponse,
|
||||
QueryClientImpl as ChannelQuery,
|
||||
@@ -14,76 +17,155 @@ import {
|
||||
QueryPacketAcknowledgementsResponse,
|
||||
QueryPacketCommitmentResponse,
|
||||
QueryPacketCommitmentsResponse,
|
||||
QueryPacketReceiptResponse,
|
||||
QueryUnreceivedAcksResponse,
|
||||
QueryUnreceivedPacketsResponse,
|
||||
} from "../codec/ibc/core/channel/v1/query";
|
||||
import { Height } from "../codec/ibc/core/client/v1/client";
|
||||
import {
|
||||
QueryClientImpl as ClientQuery,
|
||||
QueryClientParamsResponse,
|
||||
QueryClientStateResponse,
|
||||
QueryClientStatesResponse,
|
||||
QueryConsensusStateRequest,
|
||||
QueryConsensusStateResponse,
|
||||
QueryConsensusStatesResponse,
|
||||
} from "../codec/ibc/core/client/v1/query";
|
||||
import {
|
||||
QueryClientConnectionsResponse,
|
||||
QueryClientImpl as ConnectionQuery,
|
||||
QueryConnectionClientStateResponse,
|
||||
QueryConnectionConsensusStateRequest,
|
||||
QueryConnectionConsensusStateResponse,
|
||||
QueryConnectionResponse,
|
||||
QueryConnectionsResponse,
|
||||
} from "../codec/ibc/core/connection/v1/query";
|
||||
import {
|
||||
ClientState as TendermintClientState,
|
||||
ConsensusState as TendermintConsensusState,
|
||||
} from "../codec/ibc/lightclients/tendermint/v1/tendermint";
|
||||
import { QueryClient } from "./queryclient";
|
||||
import { createPagination, createProtobufRpcClient } from "./utils";
|
||||
|
||||
function decodeTendermintClientStateAny(clientState: Any | undefined): TendermintClientState {
|
||||
if (clientState?.typeUrl !== "/ibc.lightclients.tendermint.v1.ClientState") {
|
||||
throw new Error(`Unexpected client state type: ${clientState?.typeUrl}`);
|
||||
}
|
||||
return TendermintClientState.decode(clientState.value);
|
||||
}
|
||||
|
||||
function decodeTendermintConsensusStateAny(clientState: Any | undefined): TendermintConsensusState {
|
||||
if (clientState?.typeUrl !== "/ibc.lightclients.tendermint.v1.ConsensusState") {
|
||||
throw new Error(`Unexpected client state type: ${clientState?.typeUrl}`);
|
||||
}
|
||||
return TendermintConsensusState.decode(clientState.value);
|
||||
}
|
||||
|
||||
export interface IbcExtension {
|
||||
readonly ibc: {
|
||||
readonly channel: (portId: string, channelId: string) => Promise<Channel | null>;
|
||||
readonly packetCommitment: (portId: string, channelId: string, sequence: number) => Promise<Uint8Array>;
|
||||
readonly packetAcknowledgement: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
sequence: number,
|
||||
) => Promise<Uint8Array>;
|
||||
readonly nextSequenceReceive: (portId: string, channelId: string) => Promise<number | null>;
|
||||
readonly unverified: {
|
||||
// Queries for ibc.core.channel.v1
|
||||
readonly channel: (portId: string, channelId: string) => Promise<QueryChannelResponse>;
|
||||
readonly channels: (paginationKey?: Uint8Array) => Promise<QueryChannelsResponse>;
|
||||
readonly connectionChannels: (
|
||||
connection: string,
|
||||
paginationKey?: Uint8Array,
|
||||
) => Promise<QueryConnectionChannelsResponse>;
|
||||
readonly packetCommitment: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
sequence: number,
|
||||
) => Promise<QueryPacketCommitmentResponse>;
|
||||
readonly packetCommitments: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
paginationKey?: Uint8Array,
|
||||
) => Promise<QueryPacketCommitmentsResponse>;
|
||||
readonly channel: {
|
||||
readonly channel: (portId: string, channelId: string) => Promise<Channel | null>;
|
||||
readonly packetCommitment: (portId: string, channelId: string, sequence: number) => Promise<Uint8Array>;
|
||||
readonly packetAcknowledgement: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
sequence: number,
|
||||
) => Promise<QueryPacketAcknowledgementResponse>;
|
||||
readonly packetAcknowledgements: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
paginationKey?: Uint8Array,
|
||||
) => Promise<QueryPacketAcknowledgementsResponse>;
|
||||
readonly unreceivedPackets: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
packetCommitmentSequences: readonly number[],
|
||||
) => Promise<QueryUnreceivedPacketsResponse>;
|
||||
readonly unreceivedAcks: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
packetCommitmentSequences: readonly number[],
|
||||
) => Promise<QueryUnreceivedAcksResponse>;
|
||||
readonly nextSequenceReceive: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
) => Promise<QueryNextSequenceReceiveResponse>;
|
||||
|
||||
// Queries for ibc.core.connection.v1
|
||||
|
||||
readonly connection: (connectionId: string) => Promise<QueryConnectionResponse>;
|
||||
readonly connections: (paginationKey?: Uint8Array) => Promise<QueryConnectionsResponse>;
|
||||
readonly clientConnections: (clientId: string) => Promise<QueryClientConnectionsResponse>;
|
||||
) => Promise<Uint8Array>;
|
||||
readonly nextSequenceReceive: (portId: string, channelId: string) => Promise<number | null>;
|
||||
};
|
||||
readonly unverified: {
|
||||
readonly channel: {
|
||||
readonly channel: (portId: string, channelId: string) => Promise<QueryChannelResponse>;
|
||||
readonly channels: (paginationKey?: Uint8Array) => Promise<QueryChannelsResponse>;
|
||||
readonly allChannels: () => Promise<QueryChannelsResponse>;
|
||||
readonly connectionChannels: (
|
||||
connection: string,
|
||||
paginationKey?: Uint8Array,
|
||||
) => Promise<QueryConnectionChannelsResponse>;
|
||||
readonly allConnectionChannels: (connection: string) => Promise<QueryConnectionChannelsResponse>;
|
||||
readonly clientState: (portId: string, channelId: string) => Promise<QueryChannelClientStateResponse>;
|
||||
readonly consensusState: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
revisionNumber: number,
|
||||
revisionHeight: number,
|
||||
) => Promise<QueryChannelConsensusStateResponse>;
|
||||
readonly packetCommitment: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
sequence: Long,
|
||||
) => Promise<QueryPacketCommitmentResponse>;
|
||||
readonly packetCommitments: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
paginationKey?: Uint8Array,
|
||||
) => Promise<QueryPacketCommitmentsResponse>;
|
||||
readonly allPacketCommitments: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
) => Promise<QueryPacketCommitmentsResponse>;
|
||||
readonly packetReceipt: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
sequence: number,
|
||||
) => Promise<QueryPacketReceiptResponse>;
|
||||
readonly packetAcknowledgement: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
sequence: number,
|
||||
) => Promise<QueryPacketAcknowledgementResponse>;
|
||||
readonly packetAcknowledgements: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
paginationKey?: Uint8Array,
|
||||
) => Promise<QueryPacketAcknowledgementsResponse>;
|
||||
readonly allPacketAcknowledgements: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
) => Promise<QueryPacketAcknowledgementsResponse>;
|
||||
readonly unreceivedPackets: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
packetCommitmentSequences: readonly number[],
|
||||
) => Promise<QueryUnreceivedPacketsResponse>;
|
||||
readonly unreceivedAcks: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
packetAckSequences: readonly number[],
|
||||
) => Promise<QueryUnreceivedAcksResponse>;
|
||||
readonly nextSequenceReceive: (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
) => Promise<QueryNextSequenceReceiveResponse>;
|
||||
};
|
||||
readonly client: {
|
||||
readonly state: (clientId: string) => Promise<QueryClientStateResponse>;
|
||||
readonly states: (paginationKey?: Uint8Array) => Promise<QueryClientStatesResponse>;
|
||||
readonly allStates: () => Promise<QueryClientStatesResponse>;
|
||||
readonly consensusState: (clientId: string, height?: number) => Promise<QueryConsensusStateResponse>;
|
||||
readonly consensusStates: (
|
||||
clientId: string,
|
||||
paginationKey?: Uint8Array,
|
||||
) => Promise<QueryConsensusStatesResponse>;
|
||||
readonly allConsensusStates: (clientId: string) => Promise<QueryConsensusStatesResponse>;
|
||||
readonly params: () => Promise<QueryClientParamsResponse>;
|
||||
readonly stateTm: (clientId: string) => Promise<TendermintClientState>;
|
||||
readonly statesTm: (paginationKey?: Uint8Array) => Promise<TendermintClientState[]>;
|
||||
readonly allStatesTm: () => Promise<TendermintClientState[]>;
|
||||
readonly consensusStateTm: (clientId: string, height?: Height) => Promise<TendermintConsensusState>;
|
||||
};
|
||||
readonly connection: {
|
||||
readonly connection: (connectionId: string) => Promise<QueryConnectionResponse>;
|
||||
readonly connections: (paginationKey?: Uint8Array) => Promise<QueryConnectionsResponse>;
|
||||
readonly allConnections: () => Promise<QueryConnectionsResponse>;
|
||||
readonly clientConnections: (clientId: string) => Promise<QueryClientConnectionsResponse>;
|
||||
readonly clientState: (connectionId: string) => Promise<QueryConnectionClientStateResponse>;
|
||||
readonly consensusState: (
|
||||
connectionId: string,
|
||||
revisionNumber: number,
|
||||
revisionHeight: number,
|
||||
) => Promise<QueryConnectionConsensusStateResponse>;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -93,139 +175,324 @@ export function setupIbcExtension(base: QueryClient): IbcExtension {
|
||||
// Use these services to get easy typed access to query methods
|
||||
// These cannot be used for proof verification
|
||||
const channelQueryService = new ChannelQuery(rpc);
|
||||
const clientQueryService = new ClientQuery(rpc);
|
||||
const connectionQueryService = new ConnectionQuery(rpc);
|
||||
|
||||
return {
|
||||
ibc: {
|
||||
channel: async (portId: string, channelId: string) => {
|
||||
// keeper: https://github.com/cosmos/cosmos-sdk/blob/3bafd8255a502e5a9cee07391cf8261538245dfd/x/ibc/04-channel/keeper/keeper.go#L55-L65
|
||||
// key: https://github.com/cosmos/cosmos-sdk/blob/ef0a7344af345882729598bc2958a21143930a6b/x/ibc/24-host/keys.go#L117-L120
|
||||
const key = toAscii(`channelEnds/ports/${portId}/channels/${channelId}`);
|
||||
const responseData = await base.queryVerified("ibc", key);
|
||||
return responseData.length ? Channel.decode(responseData) : null;
|
||||
},
|
||||
packetCommitment: async (portId: string, channelId: string, sequence: number) => {
|
||||
// keeper: https://github.com/cosmos/cosmos-sdk/blob/3bafd8255a502e5a9cee07391cf8261538245dfd/x/ibc/04-channel/keeper/keeper.go#L128-L133
|
||||
// key: https://github.com/cosmos/cosmos-sdk/blob/ef0a7344af345882729598bc2958a21143930a6b/x/ibc/24-host/keys.go#L183-L185
|
||||
const key = toAscii(`commitments/ports/${portId}/channels/${channelId}/packets/${sequence}`);
|
||||
const responseData = await base.queryVerified("ibc", key);
|
||||
// keeper code doesn't parse, but returns raw
|
||||
return responseData;
|
||||
},
|
||||
packetAcknowledgement: async (portId: string, channelId: string, sequence: number) => {
|
||||
// keeper: https://github.com/cosmos/cosmos-sdk/blob/3bafd8255a502e5a9cee07391cf8261538245dfd/x/ibc/04-channel/keeper/keeper.go#L159-L166
|
||||
// key: https://github.com/cosmos/cosmos-sdk/blob/ef0a7344af345882729598bc2958a21143930a6b/x/ibc/24-host/keys.go#L153-L156
|
||||
const key = toAscii(`acks/ports/${portId}/channels/${channelId}/acknowledgements/${sequence}`);
|
||||
const responseData = await base.queryVerified("ibc", key);
|
||||
// keeper code doesn't parse, but returns raw
|
||||
return responseData;
|
||||
},
|
||||
nextSequenceReceive: async (portId: string, channelId: string) => {
|
||||
// keeper: https://github.com/cosmos/cosmos-sdk/blob/3bafd8255a502e5a9cee07391cf8261538245dfd/x/ibc/04-channel/keeper/keeper.go#L92-L101
|
||||
// key: https://github.com/cosmos/cosmos-sdk/blob/ef0a7344af345882729598bc2958a21143930a6b/x/ibc/24-host/keys.go#L133-L136
|
||||
const key = toAscii(`seqAcks/ports/${portId}/channels/${channelId}/nextSequenceAck`);
|
||||
const responseData = await base.queryVerified("ibc", key);
|
||||
return responseData.length ? Uint64.fromBytes(responseData).toNumber() : null;
|
||||
},
|
||||
|
||||
unverified: {
|
||||
// Queries for ibc.core.channel.v1
|
||||
channel: {
|
||||
channel: async (portId: string, channelId: string) => {
|
||||
const response = await channelQueryService.Channel({ portId: portId, channelId: channelId });
|
||||
return response;
|
||||
},
|
||||
channels: async (paginationKey?: Uint8Array) => {
|
||||
const request = {
|
||||
pagination: createPagination(paginationKey),
|
||||
};
|
||||
const response = await channelQueryService.Channels(request);
|
||||
return response;
|
||||
},
|
||||
connectionChannels: async (connection: string, paginationKey?: Uint8Array) => {
|
||||
const request = {
|
||||
connection: connection,
|
||||
pagination: createPagination(paginationKey),
|
||||
};
|
||||
const response = await channelQueryService.ConnectionChannels(request);
|
||||
return response;
|
||||
// keeper: https://github.com/cosmos/cosmos-sdk/blob/3bafd8255a502e5a9cee07391cf8261538245dfd/x/ibc/04-channel/keeper/keeper.go#L55-L65
|
||||
// key: https://github.com/cosmos/cosmos-sdk/blob/ef0a7344af345882729598bc2958a21143930a6b/x/ibc/24-host/keys.go#L117-L120
|
||||
const key = toAscii(`channelEnds/ports/${portId}/channels/${channelId}`);
|
||||
const responseData = await base.queryVerified("ibc", key);
|
||||
return responseData.length ? Channel.decode(responseData) : null;
|
||||
},
|
||||
packetCommitment: async (portId: string, channelId: string, sequence: number) => {
|
||||
const response = await channelQueryService.PacketCommitment({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
sequence: Long.fromNumber(sequence, true),
|
||||
});
|
||||
return response;
|
||||
},
|
||||
packetCommitments: async (portId: string, channelId: string, paginationKey?: Uint8Array) => {
|
||||
const request = {
|
||||
channelId: channelId,
|
||||
portId: portId,
|
||||
pagination: createPagination(paginationKey),
|
||||
};
|
||||
const response = await channelQueryService.PacketCommitments(request);
|
||||
return response;
|
||||
// keeper: https://github.com/cosmos/cosmos-sdk/blob/3bafd8255a502e5a9cee07391cf8261538245dfd/x/ibc/04-channel/keeper/keeper.go#L128-L133
|
||||
// key: https://github.com/cosmos/cosmos-sdk/blob/ef0a7344af345882729598bc2958a21143930a6b/x/ibc/24-host/keys.go#L183-L185
|
||||
const key = toAscii(`commitments/ports/${portId}/channels/${channelId}/packets/${sequence}`);
|
||||
const responseData = await base.queryVerified("ibc", key);
|
||||
// keeper code doesn't parse, but returns raw
|
||||
return responseData;
|
||||
},
|
||||
packetAcknowledgement: async (portId: string, channelId: string, sequence: number) => {
|
||||
const response = await channelQueryService.PacketAcknowledgement({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
sequence: Long.fromNumber(sequence, true),
|
||||
});
|
||||
return response;
|
||||
},
|
||||
packetAcknowledgements: async (portId: string, channelId: string, paginationKey?: Uint8Array) => {
|
||||
const response = await channelQueryService.PacketAcknowledgements({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
pagination: createPagination(paginationKey),
|
||||
});
|
||||
return response;
|
||||
},
|
||||
unreceivedPackets: async (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
packetCommitmentSequences: readonly number[],
|
||||
) => {
|
||||
const response = await channelQueryService.UnreceivedPackets({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
packetCommitmentSequences: packetCommitmentSequences.map((s) => Long.fromNumber(s, true)),
|
||||
});
|
||||
return response;
|
||||
},
|
||||
unreceivedAcks: async (portId: string, channelId: string, packetAckSequences: readonly number[]) => {
|
||||
const response = await channelQueryService.UnreceivedAcks({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
packetAckSequences: packetAckSequences.map((s) => Long.fromNumber(s, true)),
|
||||
});
|
||||
return response;
|
||||
// keeper: https://github.com/cosmos/cosmos-sdk/blob/3bafd8255a502e5a9cee07391cf8261538245dfd/x/ibc/04-channel/keeper/keeper.go#L159-L166
|
||||
// key: https://github.com/cosmos/cosmos-sdk/blob/ef0a7344af345882729598bc2958a21143930a6b/x/ibc/24-host/keys.go#L153-L156
|
||||
const key = toAscii(`acks/ports/${portId}/channels/${channelId}/acknowledgements/${sequence}`);
|
||||
const responseData = await base.queryVerified("ibc", key);
|
||||
// keeper code doesn't parse, but returns raw
|
||||
return responseData;
|
||||
},
|
||||
nextSequenceReceive: async (portId: string, channelId: string) => {
|
||||
const response = await channelQueryService.NextSequenceReceive({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
});
|
||||
return response;
|
||||
// keeper: https://github.com/cosmos/cosmos-sdk/blob/3bafd8255a502e5a9cee07391cf8261538245dfd/x/ibc/04-channel/keeper/keeper.go#L92-L101
|
||||
// key: https://github.com/cosmos/cosmos-sdk/blob/ef0a7344af345882729598bc2958a21143930a6b/x/ibc/24-host/keys.go#L133-L136
|
||||
const key = toAscii(`seqAcks/ports/${portId}/channels/${channelId}/nextSequenceAck`);
|
||||
const responseData = await base.queryVerified("ibc", key);
|
||||
return responseData.length ? Uint64.fromBytes(responseData).toNumber() : null;
|
||||
},
|
||||
|
||||
// Queries for ibc.core.connection.v1
|
||||
|
||||
connection: async (connectionId: string) => {
|
||||
const response = await connectionQueryService.Connection({ connectionId: connectionId });
|
||||
return response;
|
||||
},
|
||||
unverified: {
|
||||
channel: {
|
||||
channel: async (portId: string, channelId: string) =>
|
||||
channelQueryService.Channel({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
}),
|
||||
channels: async (paginationKey?: Uint8Array) =>
|
||||
channelQueryService.Channels({
|
||||
pagination: createPagination(paginationKey),
|
||||
}),
|
||||
allChannels: async () => {
|
||||
const channels = [];
|
||||
let response: QueryChannelsResponse;
|
||||
let key: Uint8Array | undefined;
|
||||
do {
|
||||
response = await channelQueryService.Channels({
|
||||
pagination: createPagination(key),
|
||||
});
|
||||
channels.push(...response.channels);
|
||||
key = response.pagination?.nextKey;
|
||||
} while (key);
|
||||
return {
|
||||
channels: channels,
|
||||
height: response.height,
|
||||
};
|
||||
},
|
||||
connectionChannels: async (connection: string, paginationKey?: Uint8Array) =>
|
||||
channelQueryService.ConnectionChannels({
|
||||
connection: connection,
|
||||
pagination: createPagination(paginationKey),
|
||||
}),
|
||||
allConnectionChannels: async (connection: string) => {
|
||||
const channels = [];
|
||||
let response: QueryConnectionChannelsResponse;
|
||||
let key: Uint8Array | undefined;
|
||||
do {
|
||||
response = await channelQueryService.ConnectionChannels({
|
||||
connection: connection,
|
||||
pagination: createPagination(key),
|
||||
});
|
||||
channels.push(...response.channels);
|
||||
key = response.pagination?.nextKey;
|
||||
} while (key);
|
||||
return {
|
||||
channels: channels,
|
||||
height: response.height,
|
||||
};
|
||||
},
|
||||
clientState: async (portId: string, channelId: string) =>
|
||||
channelQueryService.ChannelClientState({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
}),
|
||||
consensusState: async (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
revisionNumber: number,
|
||||
revisionHeight: number,
|
||||
) =>
|
||||
channelQueryService.ChannelConsensusState({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
revisionNumber: Long.fromNumber(revisionNumber, true),
|
||||
revisionHeight: Long.fromNumber(revisionHeight, true),
|
||||
}),
|
||||
packetCommitment: async (portId: string, channelId: string, sequence: Long) =>
|
||||
channelQueryService.PacketCommitment({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
sequence: sequence,
|
||||
}),
|
||||
packetCommitments: async (portId: string, channelId: string, paginationKey?: Uint8Array) =>
|
||||
channelQueryService.PacketCommitments({
|
||||
channelId: channelId,
|
||||
portId: portId,
|
||||
pagination: createPagination(paginationKey),
|
||||
}),
|
||||
allPacketCommitments: async (portId: string, channelId: string) => {
|
||||
const commitments = [];
|
||||
let response: QueryPacketCommitmentsResponse;
|
||||
let key: Uint8Array | undefined;
|
||||
do {
|
||||
response = await channelQueryService.PacketCommitments({
|
||||
channelId: channelId,
|
||||
portId: portId,
|
||||
pagination: createPagination(key),
|
||||
});
|
||||
commitments.push(...response.commitments);
|
||||
key = response.pagination?.nextKey;
|
||||
} while (key);
|
||||
return {
|
||||
commitments: commitments,
|
||||
height: response.height,
|
||||
};
|
||||
},
|
||||
packetReceipt: async (portId: string, channelId: string, sequence: number) =>
|
||||
channelQueryService.PacketReceipt({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
sequence: Long.fromNumber(sequence, true),
|
||||
}),
|
||||
packetAcknowledgement: async (portId: string, channelId: string, sequence: number) =>
|
||||
channelQueryService.PacketAcknowledgement({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
sequence: Long.fromNumber(sequence, true),
|
||||
}),
|
||||
packetAcknowledgements: async (portId: string, channelId: string, paginationKey?: Uint8Array) =>
|
||||
channelQueryService.PacketAcknowledgements({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
pagination: createPagination(paginationKey),
|
||||
}),
|
||||
allPacketAcknowledgements: async (portId: string, channelId: string) => {
|
||||
const acknowledgements = [];
|
||||
let response: QueryPacketAcknowledgementsResponse;
|
||||
let key: Uint8Array | undefined;
|
||||
do {
|
||||
response = await channelQueryService.PacketAcknowledgements({
|
||||
channelId: channelId,
|
||||
portId: portId,
|
||||
pagination: createPagination(key),
|
||||
});
|
||||
acknowledgements.push(...response.acknowledgements);
|
||||
key = response.pagination?.nextKey;
|
||||
} while (key);
|
||||
return {
|
||||
acknowledgements: acknowledgements,
|
||||
height: response.height,
|
||||
};
|
||||
},
|
||||
unreceivedPackets: async (
|
||||
portId: string,
|
||||
channelId: string,
|
||||
packetCommitmentSequences: readonly number[],
|
||||
) =>
|
||||
channelQueryService.UnreceivedPackets({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
packetCommitmentSequences: packetCommitmentSequences.map((s) => Long.fromNumber(s, true)),
|
||||
}),
|
||||
unreceivedAcks: async (portId: string, channelId: string, packetAckSequences: readonly number[]) =>
|
||||
channelQueryService.UnreceivedAcks({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
packetAckSequences: packetAckSequences.map((s) => Long.fromNumber(s, true)),
|
||||
}),
|
||||
nextSequenceReceive: async (portId: string, channelId: string) =>
|
||||
channelQueryService.NextSequenceReceive({
|
||||
portId: portId,
|
||||
channelId: channelId,
|
||||
}),
|
||||
},
|
||||
connections: async (paginationKey?: Uint8Array) => {
|
||||
const request = {
|
||||
pagination: createPagination(paginationKey),
|
||||
};
|
||||
const response = await connectionQueryService.Connections(request);
|
||||
return response;
|
||||
client: {
|
||||
state: (clientId: string) => clientQueryService.ClientState({ clientId }),
|
||||
states: (paginationKey?: Uint8Array) =>
|
||||
clientQueryService.ClientStates({
|
||||
pagination: createPagination(paginationKey),
|
||||
}),
|
||||
allStates: async () => {
|
||||
const clientStates = [];
|
||||
let response: QueryClientStatesResponse;
|
||||
let key: Uint8Array | undefined;
|
||||
do {
|
||||
response = await clientQueryService.ClientStates({
|
||||
pagination: createPagination(key),
|
||||
});
|
||||
clientStates.push(...response.clientStates);
|
||||
key = response.pagination?.nextKey;
|
||||
} while (key);
|
||||
return {
|
||||
clientStates: clientStates,
|
||||
};
|
||||
},
|
||||
consensusState: (clientId: string, consensusHeight?: number) =>
|
||||
clientQueryService.ConsensusState(
|
||||
QueryConsensusStateRequest.fromPartial({
|
||||
clientId: clientId,
|
||||
revisionHeight:
|
||||
consensusHeight !== undefined ? Long.fromNumber(consensusHeight, true) : undefined,
|
||||
latestHeight: consensusHeight === undefined,
|
||||
}),
|
||||
),
|
||||
consensusStates: (clientId: string, paginationKey?: Uint8Array) =>
|
||||
clientQueryService.ConsensusStates({
|
||||
clientId: clientId,
|
||||
pagination: createPagination(paginationKey),
|
||||
}),
|
||||
allConsensusStates: async (clientId: string) => {
|
||||
const consensusStates = [];
|
||||
let response: QueryConsensusStatesResponse;
|
||||
let key: Uint8Array | undefined;
|
||||
do {
|
||||
response = await clientQueryService.ConsensusStates({
|
||||
clientId: clientId,
|
||||
pagination: createPagination(key),
|
||||
});
|
||||
consensusStates.push(...response.consensusStates);
|
||||
key = response.pagination?.nextKey;
|
||||
} while (key);
|
||||
return {
|
||||
consensusStates: consensusStates,
|
||||
};
|
||||
},
|
||||
params: () => clientQueryService.ClientParams({}),
|
||||
stateTm: async (clientId: string) => {
|
||||
const response = await clientQueryService.ClientState({ clientId });
|
||||
return decodeTendermintClientStateAny(response.clientState);
|
||||
},
|
||||
statesTm: async (paginationKey?: Uint8Array) => {
|
||||
const { clientStates } = await clientQueryService.ClientStates({
|
||||
pagination: createPagination(paginationKey),
|
||||
});
|
||||
return clientStates.map(({ clientState }) => decodeTendermintClientStateAny(clientState));
|
||||
},
|
||||
allStatesTm: async () => {
|
||||
const clientStates = [];
|
||||
let response: QueryClientStatesResponse;
|
||||
let key: Uint8Array | undefined;
|
||||
do {
|
||||
response = await clientQueryService.ClientStates({
|
||||
pagination: createPagination(key),
|
||||
});
|
||||
clientStates.push(...response.clientStates);
|
||||
key = response.pagination?.nextKey;
|
||||
} while (key);
|
||||
return clientStates.map(({ clientState }) => decodeTendermintClientStateAny(clientState));
|
||||
},
|
||||
consensusStateTm: async (clientId: string, consensusHeight?: Height) => {
|
||||
const response = await clientQueryService.ConsensusState(
|
||||
QueryConsensusStateRequest.fromPartial({
|
||||
clientId: clientId,
|
||||
revisionHeight: consensusHeight?.revisionHeight,
|
||||
revisionNumber: consensusHeight?.revisionNumber,
|
||||
latestHeight: consensusHeight === undefined,
|
||||
}),
|
||||
);
|
||||
return decodeTendermintConsensusStateAny(response.consensusState);
|
||||
},
|
||||
},
|
||||
clientConnections: async (clientId: string) => {
|
||||
const response = await connectionQueryService.ClientConnections({ clientId: clientId });
|
||||
return response;
|
||||
connection: {
|
||||
connection: async (connectionId: string) =>
|
||||
connectionQueryService.Connection({
|
||||
connectionId: connectionId,
|
||||
}),
|
||||
connections: async (paginationKey?: Uint8Array) =>
|
||||
connectionQueryService.Connections({
|
||||
pagination: createPagination(paginationKey),
|
||||
}),
|
||||
allConnections: async () => {
|
||||
const connections = [];
|
||||
let response: QueryConnectionsResponse;
|
||||
let key: Uint8Array | undefined;
|
||||
do {
|
||||
response = await connectionQueryService.Connections({
|
||||
pagination: createPagination(key),
|
||||
});
|
||||
connections.push(...response.connections);
|
||||
key = response.pagination?.nextKey;
|
||||
} while (key);
|
||||
return {
|
||||
connections: connections,
|
||||
height: response.height,
|
||||
};
|
||||
},
|
||||
clientConnections: async (clientId: string) =>
|
||||
connectionQueryService.ClientConnections({
|
||||
clientId: clientId,
|
||||
}),
|
||||
clientState: async (connectionId: string) =>
|
||||
connectionQueryService.ConnectionClientState({
|
||||
connectionId: connectionId,
|
||||
}),
|
||||
consensusState: async (connectionId: string, revisionHeight: number) =>
|
||||
connectionQueryService.ConnectionConsensusState(
|
||||
QueryConnectionConsensusStateRequest.fromPartial({
|
||||
connectionId: connectionId,
|
||||
revisionHeight: Long.fromNumber(revisionHeight, true),
|
||||
}),
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -39,6 +39,30 @@ import {
|
||||
} from "./codec/cosmos/staking/v1beta1/tx";
|
||||
import { SignMode } from "./codec/cosmos/tx/signing/v1beta1/signing";
|
||||
import { TxRaw } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
import {
|
||||
MsgAcknowledgement,
|
||||
MsgChannelCloseConfirm,
|
||||
MsgChannelCloseInit,
|
||||
MsgChannelOpenAck,
|
||||
MsgChannelOpenConfirm,
|
||||
MsgChannelOpenInit,
|
||||
MsgChannelOpenTry,
|
||||
MsgRecvPacket,
|
||||
MsgTimeout,
|
||||
MsgTimeoutOnClose,
|
||||
} from "./codec/ibc/core/channel/v1/tx";
|
||||
import {
|
||||
MsgCreateClient,
|
||||
MsgSubmitMisbehaviour,
|
||||
MsgUpdateClient,
|
||||
MsgUpgradeClient,
|
||||
} from "./codec/ibc/core/client/v1/tx";
|
||||
import {
|
||||
MsgConnectionOpenAck,
|
||||
MsgConnectionOpenConfirm,
|
||||
MsgConnectionOpenInit,
|
||||
MsgConnectionOpenTry,
|
||||
} from "./codec/ibc/core/connection/v1/tx";
|
||||
import { BroadcastTxResponse, StargateClient } from "./stargateclient";
|
||||
|
||||
const defaultGasPrice = GasPrice.fromString("0.025ucosm");
|
||||
@@ -55,6 +79,24 @@ export const defaultRegistryTypes: ReadonlyArray<[string, GeneratedType]> = [
|
||||
["/cosmos.staking.v1beta1.MsgDelegate", MsgDelegate],
|
||||
["/cosmos.staking.v1beta1.MsgEditValidator", MsgEditValidator],
|
||||
["/cosmos.staking.v1beta1.MsgUndelegate", MsgUndelegate],
|
||||
["/ibc.core.channel.v1.MsgChannelOpenInit", MsgChannelOpenInit],
|
||||
["/ibc.core.channel.v1.MsgChannelOpenTry", MsgChannelOpenTry],
|
||||
["/ibc.core.channel.v1.MsgChannelOpenAck", MsgChannelOpenAck],
|
||||
["/ibc.core.channel.v1.MsgChannelOpenConfirm", MsgChannelOpenConfirm],
|
||||
["/ibc.core.channel.v1.MsgChannelCloseInit", MsgChannelCloseInit],
|
||||
["/ibc.core.channel.v1.MsgChannelCloseConfirm", MsgChannelCloseConfirm],
|
||||
["/ibc.core.channel.v1.MsgRecvPacket", MsgRecvPacket],
|
||||
["/ibc.core.channel.v1.MsgTimeout ", MsgTimeout],
|
||||
["/ibc.core.channel.v1.MsgTimeoutOnClose", MsgTimeoutOnClose],
|
||||
["/ibc.core.channel.v1.MsgAcknowledgement", MsgAcknowledgement],
|
||||
["/ibc.core.client.v1.MsgCreateClient", MsgCreateClient],
|
||||
["/ibc.core.client.v1.MsgUpdateClient", MsgUpdateClient],
|
||||
["/ibc.core.client.v1.MsgUpgradeClient", MsgUpgradeClient],
|
||||
["/ibc.core.client.v1.MsgSubmitMisbehaviour", MsgSubmitMisbehaviour],
|
||||
["/ibc.core.connection.v1.MsgConnectionOpenInit", MsgConnectionOpenInit],
|
||||
["/ibc.core.connection.v1.MsgConnectionOpenTry", MsgConnectionOpenTry],
|
||||
["/ibc.core.connection.v1.MsgConnectionOpenAck", MsgConnectionOpenAck],
|
||||
["/ibc.core.connection.v1.MsgConnectionOpenConfirm", MsgConnectionOpenConfirm],
|
||||
];
|
||||
|
||||
function createDefaultRegistry(): Registry {
|
||||
|
||||
Reference in New Issue
Block a user