diff --git a/package.json b/package.json index c53d7dac..69e7f35e 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "ses": "^0.11.0", "shx": "^0.3.2", "source-map-support": "^0.5.19", - "ts-proto": "^1.53.0", + "ts-proto": "^1.67.0", "typedoc": "^0.19", "typescript": "~4.0", "webpack": "^4.43.0", diff --git a/packages/cosmwasm-stargate/src/codec/cosmos/base/query/v1beta1/pagination.ts b/packages/cosmwasm-stargate/src/codec/cosmos/base/query/v1beta1/pagination.ts index 54fe9e9e..45715b50 100644 --- a/packages/cosmwasm-stargate/src/codec/cosmos/base/query/v1beta1/pagination.ts +++ b/packages/cosmwasm-stargate/src/codec/cosmos/base/query/v1beta1/pagination.ts @@ -66,10 +66,18 @@ const basePageRequest: object = { offset: Long.UZERO, limit: Long.UZERO, countTo export const PageRequest = { encode(message: PageRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.key); - writer.uint32(16).uint64(message.offset); - writer.uint32(24).uint64(message.limit); - writer.uint32(32).bool(message.countTotal); + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (!message.offset.isZero()) { + writer.uint32(16).uint64(message.offset); + } + if (!message.limit.isZero()) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } return writer; }, @@ -123,6 +131,16 @@ export const PageRequest = { return message; }, + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.offset !== undefined && (obj.offset = (message.offset || Long.UZERO).toString()); + message.limit !== undefined && (obj.limit = (message.limit || Long.UZERO).toString()); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + return obj; + }, + fromPartial(object: DeepPartial): PageRequest { const message = { ...basePageRequest } as PageRequest; if (object.key !== undefined && object.key !== null) { @@ -147,24 +165,18 @@ export const PageRequest = { } return message; }, - - toJSON(message: PageRequest): unknown { - const obj: any = {}; - message.key !== undefined && - (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); - message.offset !== undefined && (obj.offset = (message.offset || Long.UZERO).toString()); - message.limit !== undefined && (obj.limit = (message.limit || Long.UZERO).toString()); - message.countTotal !== undefined && (obj.countTotal = message.countTotal); - return obj; - }, }; const basePageResponse: object = { total: Long.UZERO }; export const PageResponse = { encode(message: PageResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.nextKey); - writer.uint32(16).uint64(message.total); + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (!message.total.isZero()) { + writer.uint32(16).uint64(message.total); + } return writer; }, @@ -202,6 +214,14 @@ export const PageResponse = { return message; }, + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes(message.nextKey !== undefined ? message.nextKey : new Uint8Array())); + message.total !== undefined && (obj.total = (message.total || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): PageResponse { const message = { ...basePageResponse } as PageResponse; if (object.nextKey !== undefined && object.nextKey !== null) { @@ -216,14 +236,6 @@ export const PageResponse = { } return message; }, - - toJSON(message: PageResponse): unknown { - const obj: any = {}; - message.nextKey !== undefined && - (obj.nextKey = base64FromBytes(message.nextKey !== undefined ? message.nextKey : new Uint8Array())); - message.total !== undefined && (obj.total = (message.total || Long.UZERO).toString()); - return obj; - }, }; declare var self: any | undefined; @@ -233,7 +245,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/cosmwasm-stargate/src/codec/cosmos/base/v1beta1/coin.ts b/packages/cosmwasm-stargate/src/codec/cosmos/base/v1beta1/coin.ts index 9e54cfd1..e682a9a7 100644 --- a/packages/cosmwasm-stargate/src/codec/cosmos/base/v1beta1/coin.ts +++ b/packages/cosmwasm-stargate/src/codec/cosmos/base/v1beta1/coin.ts @@ -40,8 +40,12 @@ const baseCoin: object = { denom: "", amount: "" }; export const Coin = { encode(message: Coin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.denom); - writer.uint32(18).string(message.amount); + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } return writer; }, @@ -81,6 +85,13 @@ export const Coin = { return message; }, + toJSON(message: Coin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + fromPartial(object: DeepPartial): Coin { const message = { ...baseCoin } as Coin; if (object.denom !== undefined && object.denom !== null) { @@ -95,21 +106,18 @@ export const Coin = { } return message; }, - - toJSON(message: Coin): unknown { - const obj: any = {}; - message.denom !== undefined && (obj.denom = message.denom); - message.amount !== undefined && (obj.amount = message.amount); - return obj; - }, }; const baseDecCoin: object = { denom: "", amount: "" }; export const DecCoin = { encode(message: DecCoin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.denom); - writer.uint32(18).string(message.amount); + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } return writer; }, @@ -149,6 +157,13 @@ export const DecCoin = { return message; }, + toJSON(message: DecCoin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + fromPartial(object: DeepPartial): DecCoin { const message = { ...baseDecCoin } as DecCoin; if (object.denom !== undefined && object.denom !== null) { @@ -163,20 +178,15 @@ export const DecCoin = { } return message; }, - - toJSON(message: DecCoin): unknown { - const obj: any = {}; - message.denom !== undefined && (obj.denom = message.denom); - message.amount !== undefined && (obj.amount = message.amount); - return obj; - }, }; const baseIntProto: object = { int: "" }; export const IntProto = { encode(message: IntProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.int); + if (message.int !== "") { + writer.uint32(10).string(message.int); + } return writer; }, @@ -208,6 +218,12 @@ export const IntProto = { return message; }, + toJSON(message: IntProto): unknown { + const obj: any = {}; + message.int !== undefined && (obj.int = message.int); + return obj; + }, + fromPartial(object: DeepPartial): IntProto { const message = { ...baseIntProto } as IntProto; if (object.int !== undefined && object.int !== null) { @@ -217,19 +233,15 @@ export const IntProto = { } return message; }, - - toJSON(message: IntProto): unknown { - const obj: any = {}; - message.int !== undefined && (obj.int = message.int); - return obj; - }, }; const baseDecProto: object = { dec: "" }; export const DecProto = { encode(message: DecProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.dec); + if (message.dec !== "") { + writer.uint32(10).string(message.dec); + } return writer; }, @@ -261,6 +273,12 @@ export const DecProto = { return message; }, + toJSON(message: DecProto): unknown { + const obj: any = {}; + message.dec !== undefined && (obj.dec = message.dec); + return obj; + }, + fromPartial(object: DeepPartial): DecProto { const message = { ...baseDecProto } as DecProto; if (object.dec !== undefined && object.dec !== null) { @@ -270,12 +288,6 @@ export const DecProto = { } return message; }, - - toJSON(message: DecProto): unknown { - const obj: any = {}; - message.dec !== undefined && (obj.dec = message.dec); - return obj; - }, }; type Builtin = Date | Function | Uint8Array | string | number | undefined | Long; diff --git a/packages/cosmwasm-stargate/src/codec/x/wasm/internal/types/query.ts b/packages/cosmwasm-stargate/src/codec/x/wasm/internal/types/query.ts index ccb65792..9ea49552 100644 --- a/packages/cosmwasm-stargate/src/codec/x/wasm/internal/types/query.ts +++ b/packages/cosmwasm-stargate/src/codec/x/wasm/internal/types/query.ts @@ -136,7 +136,9 @@ const baseQueryContractInfoRequest: object = { address: "" }; export const QueryContractInfoRequest = { encode(message: QueryContractInfoRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.address); + if (message.address !== "") { + writer.uint32(10).string(message.address); + } return writer; }, @@ -168,6 +170,12 @@ export const QueryContractInfoRequest = { return message; }, + toJSON(message: QueryContractInfoRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + return obj; + }, + fromPartial(object: DeepPartial): QueryContractInfoRequest { const message = { ...baseQueryContractInfoRequest } as QueryContractInfoRequest; if (object.address !== undefined && object.address !== null) { @@ -177,20 +185,16 @@ export const QueryContractInfoRequest = { } return message; }, - - toJSON(message: QueryContractInfoRequest): unknown { - const obj: any = {}; - message.address !== undefined && (obj.address = message.address); - return obj; - }, }; const baseQueryContractInfoResponse: object = { address: "" }; export const QueryContractInfoResponse = { encode(message: QueryContractInfoResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.address); - if (message.contractInfo !== undefined && message.contractInfo !== undefined) { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.contractInfo !== undefined) { ContractInfo.encode(message.contractInfo, writer.uint32(18).fork()).ldelim(); } return writer; @@ -232,6 +236,14 @@ export const QueryContractInfoResponse = { return message; }, + toJSON(message: QueryContractInfoResponse): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.contractInfo !== undefined && + (obj.contractInfo = message.contractInfo ? ContractInfo.toJSON(message.contractInfo) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryContractInfoResponse { const message = { ...baseQueryContractInfoResponse } as QueryContractInfoResponse; if (object.address !== undefined && object.address !== null) { @@ -246,22 +258,16 @@ export const QueryContractInfoResponse = { } return message; }, - - toJSON(message: QueryContractInfoResponse): unknown { - const obj: any = {}; - message.address !== undefined && (obj.address = message.address); - message.contractInfo !== undefined && - (obj.contractInfo = message.contractInfo ? ContractInfo.toJSON(message.contractInfo) : undefined); - return obj; - }, }; const baseQueryContractHistoryRequest: object = { address: "" }; export const QueryContractHistoryRequest = { encode(message: QueryContractHistoryRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.address); - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -303,6 +309,14 @@ export const QueryContractHistoryRequest = { return message; }, + toJSON(message: QueryContractHistoryRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryContractHistoryRequest { const message = { ...baseQueryContractHistoryRequest } as QueryContractHistoryRequest; if (object.address !== undefined && object.address !== null) { @@ -317,14 +331,6 @@ export const QueryContractHistoryRequest = { } return message; }, - - toJSON(message: QueryContractHistoryRequest): unknown { - const obj: any = {}; - message.address !== undefined && (obj.address = message.address); - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryContractHistoryResponse: object = {}; @@ -334,7 +340,7 @@ export const QueryContractHistoryResponse = { for (const v of message.entries) { ContractCodeHistoryEntry.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -378,6 +384,18 @@ export const QueryContractHistoryResponse = { return message; }, + toJSON(message: QueryContractHistoryResponse): unknown { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map((e) => (e ? ContractCodeHistoryEntry.toJSON(e) : undefined)); + } else { + obj.entries = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryContractHistoryResponse { const message = { ...baseQueryContractHistoryResponse } as QueryContractHistoryResponse; message.entries = []; @@ -393,26 +411,16 @@ export const QueryContractHistoryResponse = { } return message; }, - - toJSON(message: QueryContractHistoryResponse): unknown { - const obj: any = {}; - if (message.entries) { - obj.entries = message.entries.map((e) => (e ? ContractCodeHistoryEntry.toJSON(e) : undefined)); - } else { - obj.entries = []; - } - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryContractsByCodeRequest: object = { codeId: Long.UZERO }; export const QueryContractsByCodeRequest = { encode(message: QueryContractsByCodeRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.codeId); - if (message.pagination !== undefined && message.pagination !== undefined) { + if (!message.codeId.isZero()) { + writer.uint32(8).uint64(message.codeId); + } + if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -454,6 +462,14 @@ export const QueryContractsByCodeRequest = { return message; }, + toJSON(message: QueryContractsByCodeRequest): unknown { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryContractsByCodeRequest { const message = { ...baseQueryContractsByCodeRequest } as QueryContractsByCodeRequest; if (object.codeId !== undefined && object.codeId !== null) { @@ -468,22 +484,16 @@ export const QueryContractsByCodeRequest = { } return message; }, - - toJSON(message: QueryContractsByCodeRequest): unknown { - const obj: any = {}; - message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseContractInfoWithAddress: object = { address: "" }; export const ContractInfoWithAddress = { encode(message: ContractInfoWithAddress, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.address); - if (message.contractInfo !== undefined && message.contractInfo !== undefined) { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.contractInfo !== undefined) { ContractInfo.encode(message.contractInfo, writer.uint32(18).fork()).ldelim(); } return writer; @@ -525,6 +535,14 @@ export const ContractInfoWithAddress = { return message; }, + toJSON(message: ContractInfoWithAddress): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.contractInfo !== undefined && + (obj.contractInfo = message.contractInfo ? ContractInfo.toJSON(message.contractInfo) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ContractInfoWithAddress { const message = { ...baseContractInfoWithAddress } as ContractInfoWithAddress; if (object.address !== undefined && object.address !== null) { @@ -539,14 +557,6 @@ export const ContractInfoWithAddress = { } return message; }, - - toJSON(message: ContractInfoWithAddress): unknown { - const obj: any = {}; - message.address !== undefined && (obj.address = message.address); - message.contractInfo !== undefined && - (obj.contractInfo = message.contractInfo ? ContractInfo.toJSON(message.contractInfo) : undefined); - return obj; - }, }; const baseQueryContractsByCodeResponse: object = {}; @@ -556,7 +566,7 @@ export const QueryContractsByCodeResponse = { for (const v of message.contractInfos) { ContractInfoWithAddress.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -600,6 +610,20 @@ export const QueryContractsByCodeResponse = { return message; }, + toJSON(message: QueryContractsByCodeResponse): unknown { + const obj: any = {}; + if (message.contractInfos) { + obj.contractInfos = message.contractInfos.map((e) => + e ? ContractInfoWithAddress.toJSON(e) : undefined, + ); + } else { + obj.contractInfos = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryContractsByCodeResponse { const message = { ...baseQueryContractsByCodeResponse } as QueryContractsByCodeResponse; message.contractInfos = []; @@ -615,28 +639,16 @@ export const QueryContractsByCodeResponse = { } return message; }, - - toJSON(message: QueryContractsByCodeResponse): unknown { - const obj: any = {}; - if (message.contractInfos) { - obj.contractInfos = message.contractInfos.map((e) => - e ? ContractInfoWithAddress.toJSON(e) : undefined, - ); - } else { - obj.contractInfos = []; - } - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryAllContractStateRequest: object = { address: "" }; export const QueryAllContractStateRequest = { encode(message: QueryAllContractStateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.address); - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -678,6 +690,14 @@ export const QueryAllContractStateRequest = { return message; }, + toJSON(message: QueryAllContractStateRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllContractStateRequest { const message = { ...baseQueryAllContractStateRequest } as QueryAllContractStateRequest; if (object.address !== undefined && object.address !== null) { @@ -692,14 +712,6 @@ export const QueryAllContractStateRequest = { } return message; }, - - toJSON(message: QueryAllContractStateRequest): unknown { - const obj: any = {}; - message.address !== undefined && (obj.address = message.address); - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryAllContractStateResponse: object = {}; @@ -709,7 +721,7 @@ export const QueryAllContractStateResponse = { for (const v of message.models) { Model.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -753,6 +765,18 @@ export const QueryAllContractStateResponse = { return message; }, + toJSON(message: QueryAllContractStateResponse): unknown { + const obj: any = {}; + if (message.models) { + obj.models = message.models.map((e) => (e ? Model.toJSON(e) : undefined)); + } else { + obj.models = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllContractStateResponse { const message = { ...baseQueryAllContractStateResponse } as QueryAllContractStateResponse; message.models = []; @@ -768,26 +792,18 @@ export const QueryAllContractStateResponse = { } return message; }, - - toJSON(message: QueryAllContractStateResponse): unknown { - const obj: any = {}; - if (message.models) { - obj.models = message.models.map((e) => (e ? Model.toJSON(e) : undefined)); - } else { - obj.models = []; - } - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryRawContractStateRequest: object = { address: "" }; export const QueryRawContractStateRequest = { encode(message: QueryRawContractStateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.address); - writer.uint32(18).bytes(message.queryData); + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.queryData.length !== 0) { + writer.uint32(18).bytes(message.queryData); + } return writer; }, @@ -825,6 +841,16 @@ export const QueryRawContractStateRequest = { return message; }, + toJSON(message: QueryRawContractStateRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.queryData !== undefined && + (obj.queryData = base64FromBytes( + message.queryData !== undefined ? message.queryData : new Uint8Array(), + )); + return obj; + }, + fromPartial(object: DeepPartial): QueryRawContractStateRequest { const message = { ...baseQueryRawContractStateRequest } as QueryRawContractStateRequest; if (object.address !== undefined && object.address !== null) { @@ -839,23 +865,15 @@ export const QueryRawContractStateRequest = { } return message; }, - - toJSON(message: QueryRawContractStateRequest): unknown { - const obj: any = {}; - message.address !== undefined && (obj.address = message.address); - message.queryData !== undefined && - (obj.queryData = base64FromBytes( - message.queryData !== undefined ? message.queryData : new Uint8Array(), - )); - return obj; - }, }; const baseQueryRawContractStateResponse: object = {}; export const QueryRawContractStateResponse = { encode(message: QueryRawContractStateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.data); + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } return writer; }, @@ -885,6 +903,13 @@ export const QueryRawContractStateResponse = { return message; }, + toJSON(message: QueryRawContractStateResponse): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): QueryRawContractStateResponse { const message = { ...baseQueryRawContractStateResponse } as QueryRawContractStateResponse; if (object.data !== undefined && object.data !== null) { @@ -894,21 +919,18 @@ export const QueryRawContractStateResponse = { } return message; }, - - toJSON(message: QueryRawContractStateResponse): unknown { - const obj: any = {}; - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); - return obj; - }, }; const baseQuerySmartContractStateRequest: object = { address: "" }; export const QuerySmartContractStateRequest = { encode(message: QuerySmartContractStateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.address); - writer.uint32(18).bytes(message.queryData); + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.queryData.length !== 0) { + writer.uint32(18).bytes(message.queryData); + } return writer; }, @@ -946,6 +968,16 @@ export const QuerySmartContractStateRequest = { return message; }, + toJSON(message: QuerySmartContractStateRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.queryData !== undefined && + (obj.queryData = base64FromBytes( + message.queryData !== undefined ? message.queryData : new Uint8Array(), + )); + return obj; + }, + fromPartial(object: DeepPartial): QuerySmartContractStateRequest { const message = { ...baseQuerySmartContractStateRequest } as QuerySmartContractStateRequest; if (object.address !== undefined && object.address !== null) { @@ -960,23 +992,15 @@ export const QuerySmartContractStateRequest = { } return message; }, - - toJSON(message: QuerySmartContractStateRequest): unknown { - const obj: any = {}; - message.address !== undefined && (obj.address = message.address); - message.queryData !== undefined && - (obj.queryData = base64FromBytes( - message.queryData !== undefined ? message.queryData : new Uint8Array(), - )); - return obj; - }, }; const baseQuerySmartContractStateResponse: object = {}; export const QuerySmartContractStateResponse = { encode(message: QuerySmartContractStateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.data); + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } return writer; }, @@ -1006,6 +1030,13 @@ export const QuerySmartContractStateResponse = { return message; }, + toJSON(message: QuerySmartContractStateResponse): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): QuerySmartContractStateResponse { const message = { ...baseQuerySmartContractStateResponse } as QuerySmartContractStateResponse; if (object.data !== undefined && object.data !== null) { @@ -1015,20 +1046,15 @@ export const QuerySmartContractStateResponse = { } return message; }, - - toJSON(message: QuerySmartContractStateResponse): unknown { - const obj: any = {}; - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); - return obj; - }, }; const baseQueryCodeRequest: object = { codeId: Long.UZERO }; export const QueryCodeRequest = { encode(message: QueryCodeRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.codeId); + if (!message.codeId.isZero()) { + writer.uint32(8).uint64(message.codeId); + } return writer; }, @@ -1060,6 +1086,12 @@ export const QueryCodeRequest = { return message; }, + toJSON(message: QueryCodeRequest): unknown { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryCodeRequest { const message = { ...baseQueryCodeRequest } as QueryCodeRequest; if (object.codeId !== undefined && object.codeId !== null) { @@ -1069,23 +1101,27 @@ export const QueryCodeRequest = { } return message; }, - - toJSON(message: QueryCodeRequest): unknown { - const obj: any = {}; - message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); - return obj; - }, }; const baseCodeInfoResponse: object = { codeId: Long.UZERO, creator: "", source: "", builder: "" }; export const CodeInfoResponse = { encode(message: CodeInfoResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.codeId); - writer.uint32(18).string(message.creator); - writer.uint32(26).bytes(message.dataHash); - writer.uint32(34).string(message.source); - writer.uint32(42).string(message.builder); + if (!message.codeId.isZero()) { + writer.uint32(8).uint64(message.codeId); + } + if (message.creator !== "") { + writer.uint32(18).string(message.creator); + } + if (message.dataHash.length !== 0) { + writer.uint32(26).bytes(message.dataHash); + } + if (message.source !== "") { + writer.uint32(34).string(message.source); + } + if (message.builder !== "") { + writer.uint32(42).string(message.builder); + } return writer; }, @@ -1147,6 +1183,17 @@ export const CodeInfoResponse = { return message; }, + toJSON(message: CodeInfoResponse): unknown { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + message.creator !== undefined && (obj.creator = message.creator); + message.dataHash !== undefined && + (obj.dataHash = base64FromBytes(message.dataHash !== undefined ? message.dataHash : new Uint8Array())); + message.source !== undefined && (obj.source = message.source); + message.builder !== undefined && (obj.builder = message.builder); + return obj; + }, + fromPartial(object: DeepPartial): CodeInfoResponse { const message = { ...baseCodeInfoResponse } as CodeInfoResponse; if (object.codeId !== undefined && object.codeId !== null) { @@ -1176,27 +1223,18 @@ export const CodeInfoResponse = { } return message; }, - - toJSON(message: CodeInfoResponse): unknown { - const obj: any = {}; - message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); - message.creator !== undefined && (obj.creator = message.creator); - message.dataHash !== undefined && - (obj.dataHash = base64FromBytes(message.dataHash !== undefined ? message.dataHash : new Uint8Array())); - message.source !== undefined && (obj.source = message.source); - message.builder !== undefined && (obj.builder = message.builder); - return obj; - }, }; const baseQueryCodeResponse: object = {}; export const QueryCodeResponse = { encode(message: QueryCodeResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.codeInfo !== undefined && message.codeInfo !== undefined) { + if (message.codeInfo !== undefined) { CodeInfoResponse.encode(message.codeInfo, writer.uint32(10).fork()).ldelim(); } - writer.uint32(18).bytes(message.data); + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } return writer; }, @@ -1234,6 +1272,15 @@ export const QueryCodeResponse = { return message; }, + toJSON(message: QueryCodeResponse): unknown { + const obj: any = {}; + message.codeInfo !== undefined && + (obj.codeInfo = message.codeInfo ? CodeInfoResponse.toJSON(message.codeInfo) : undefined); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): QueryCodeResponse { const message = { ...baseQueryCodeResponse } as QueryCodeResponse; if (object.codeInfo !== undefined && object.codeInfo !== null) { @@ -1248,22 +1295,13 @@ export const QueryCodeResponse = { } return message; }, - - toJSON(message: QueryCodeResponse): unknown { - const obj: any = {}; - message.codeInfo !== undefined && - (obj.codeInfo = message.codeInfo ? CodeInfoResponse.toJSON(message.codeInfo) : undefined); - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); - return obj; - }, }; const baseQueryCodesRequest: object = {}; export const QueryCodesRequest = { encode(message: QueryCodesRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); } return writer; @@ -1297,6 +1335,13 @@ export const QueryCodesRequest = { return message; }, + toJSON(message: QueryCodesRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryCodesRequest { const message = { ...baseQueryCodesRequest } as QueryCodesRequest; if (object.pagination !== undefined && object.pagination !== null) { @@ -1306,13 +1351,6 @@ export const QueryCodesRequest = { } return message; }, - - toJSON(message: QueryCodesRequest): unknown { - const obj: any = {}; - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryCodesResponse: object = {}; @@ -1322,7 +1360,7 @@ export const QueryCodesResponse = { for (const v of message.codeInfos) { CodeInfoResponse.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -1366,6 +1404,18 @@ export const QueryCodesResponse = { return message; }, + toJSON(message: QueryCodesResponse): unknown { + const obj: any = {}; + if (message.codeInfos) { + obj.codeInfos = message.codeInfos.map((e) => (e ? CodeInfoResponse.toJSON(e) : undefined)); + } else { + obj.codeInfos = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryCodesResponse { const message = { ...baseQueryCodesResponse } as QueryCodesResponse; message.codeInfos = []; @@ -1381,18 +1431,6 @@ export const QueryCodesResponse = { } return message; }, - - toJSON(message: QueryCodesResponse): unknown { - const obj: any = {}; - if (message.codeInfos) { - obj.codeInfos = message.codeInfos.map((e) => (e ? CodeInfoResponse.toJSON(e) : undefined)); - } else { - obj.codeInfos = []; - } - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); - return obj; - }, }; /** Query provides defines the gRPC querier service */ @@ -1480,7 +1518,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/cosmwasm-stargate/src/codec/x/wasm/internal/types/tx.ts b/packages/cosmwasm-stargate/src/codec/x/wasm/internal/types/tx.ts index 8f7a610b..63e0a243 100644 --- a/packages/cosmwasm-stargate/src/codec/x/wasm/internal/types/tx.ts +++ b/packages/cosmwasm-stargate/src/codec/x/wasm/internal/types/tx.ts @@ -115,11 +115,19 @@ const baseMsgStoreCode: object = { sender: "", source: "", builder: "" }; export const MsgStoreCode = { encode(message: MsgStoreCode, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.sender); - writer.uint32(18).bytes(message.wasmByteCode); - writer.uint32(26).string(message.source); - writer.uint32(34).string(message.builder); - if (message.instantiatePermission !== undefined && message.instantiatePermission !== undefined) { + if (message.sender !== "") { + writer.uint32(10).string(message.sender); + } + if (message.wasmByteCode.length !== 0) { + writer.uint32(18).bytes(message.wasmByteCode); + } + if (message.source !== "") { + writer.uint32(26).string(message.source); + } + if (message.builder !== "") { + writer.uint32(34).string(message.builder); + } + if (message.instantiatePermission !== undefined) { AccessConfig.encode(message.instantiatePermission, writer.uint32(42).fork()).ldelim(); } return writer; @@ -183,6 +191,22 @@ export const MsgStoreCode = { return message; }, + toJSON(message: MsgStoreCode): unknown { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.wasmByteCode !== undefined && + (obj.wasmByteCode = base64FromBytes( + message.wasmByteCode !== undefined ? message.wasmByteCode : new Uint8Array(), + )); + message.source !== undefined && (obj.source = message.source); + message.builder !== undefined && (obj.builder = message.builder); + message.instantiatePermission !== undefined && + (obj.instantiatePermission = message.instantiatePermission + ? AccessConfig.toJSON(message.instantiatePermission) + : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MsgStoreCode { const message = { ...baseMsgStoreCode } as MsgStoreCode; if (object.sender !== undefined && object.sender !== null) { @@ -212,29 +236,15 @@ export const MsgStoreCode = { } return message; }, - - toJSON(message: MsgStoreCode): unknown { - const obj: any = {}; - message.sender !== undefined && (obj.sender = message.sender); - message.wasmByteCode !== undefined && - (obj.wasmByteCode = base64FromBytes( - message.wasmByteCode !== undefined ? message.wasmByteCode : new Uint8Array(), - )); - message.source !== undefined && (obj.source = message.source); - message.builder !== undefined && (obj.builder = message.builder); - message.instantiatePermission !== undefined && - (obj.instantiatePermission = message.instantiatePermission - ? AccessConfig.toJSON(message.instantiatePermission) - : undefined); - return obj; - }, }; const baseMsgStoreCodeResponse: object = { codeId: Long.UZERO }; export const MsgStoreCodeResponse = { encode(message: MsgStoreCodeResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.codeId); + if (!message.codeId.isZero()) { + writer.uint32(8).uint64(message.codeId); + } return writer; }, @@ -266,6 +276,12 @@ export const MsgStoreCodeResponse = { return message; }, + toJSON(message: MsgStoreCodeResponse): unknown { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): MsgStoreCodeResponse { const message = { ...baseMsgStoreCodeResponse } as MsgStoreCodeResponse; if (object.codeId !== undefined && object.codeId !== null) { @@ -275,23 +291,27 @@ export const MsgStoreCodeResponse = { } return message; }, - - toJSON(message: MsgStoreCodeResponse): unknown { - const obj: any = {}; - message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); - return obj; - }, }; const baseMsgInstantiateContract: object = { sender: "", admin: "", codeId: Long.UZERO, label: "" }; export const MsgInstantiateContract = { encode(message: MsgInstantiateContract, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.sender); - writer.uint32(18).string(message.admin); - writer.uint32(24).uint64(message.codeId); - writer.uint32(34).string(message.label); - writer.uint32(42).bytes(message.initMsg); + if (message.sender !== "") { + writer.uint32(10).string(message.sender); + } + if (message.admin !== "") { + writer.uint32(18).string(message.admin); + } + if (!message.codeId.isZero()) { + writer.uint32(24).uint64(message.codeId); + } + if (message.label !== "") { + writer.uint32(34).string(message.label); + } + if (message.initMsg.length !== 0) { + writer.uint32(42).bytes(message.initMsg); + } for (const v of message.initFunds) { Coin.encode(v!, writer.uint32(50).fork()).ldelim(); } @@ -366,6 +386,22 @@ export const MsgInstantiateContract = { return message; }, + toJSON(message: MsgInstantiateContract): unknown { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.admin !== undefined && (obj.admin = message.admin); + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + message.label !== undefined && (obj.label = message.label); + message.initMsg !== undefined && + (obj.initMsg = base64FromBytes(message.initMsg !== undefined ? message.initMsg : new Uint8Array())); + if (message.initFunds) { + obj.initFunds = message.initFunds.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.initFunds = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgInstantiateContract { const message = { ...baseMsgInstantiateContract } as MsgInstantiateContract; message.initFunds = []; @@ -401,29 +437,15 @@ export const MsgInstantiateContract = { } return message; }, - - toJSON(message: MsgInstantiateContract): unknown { - const obj: any = {}; - message.sender !== undefined && (obj.sender = message.sender); - message.admin !== undefined && (obj.admin = message.admin); - message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); - message.label !== undefined && (obj.label = message.label); - message.initMsg !== undefined && - (obj.initMsg = base64FromBytes(message.initMsg !== undefined ? message.initMsg : new Uint8Array())); - if (message.initFunds) { - obj.initFunds = message.initFunds.map((e) => (e ? Coin.toJSON(e) : undefined)); - } else { - obj.initFunds = []; - } - return obj; - }, }; const baseMsgInstantiateContractResponse: object = { address: "" }; export const MsgInstantiateContractResponse = { encode(message: MsgInstantiateContractResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.address); + if (message.address !== "") { + writer.uint32(10).string(message.address); + } return writer; }, @@ -455,6 +477,12 @@ export const MsgInstantiateContractResponse = { return message; }, + toJSON(message: MsgInstantiateContractResponse): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + return obj; + }, + fromPartial(object: DeepPartial): MsgInstantiateContractResponse { const message = { ...baseMsgInstantiateContractResponse } as MsgInstantiateContractResponse; if (object.address !== undefined && object.address !== null) { @@ -464,21 +492,21 @@ export const MsgInstantiateContractResponse = { } return message; }, - - toJSON(message: MsgInstantiateContractResponse): unknown { - const obj: any = {}; - message.address !== undefined && (obj.address = message.address); - return obj; - }, }; const baseMsgExecuteContract: object = { sender: "", contract: "" }; export const MsgExecuteContract = { encode(message: MsgExecuteContract, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.sender); - writer.uint32(18).string(message.contract); - writer.uint32(26).bytes(message.msg); + if (message.sender !== "") { + writer.uint32(10).string(message.sender); + } + if (message.contract !== "") { + writer.uint32(18).string(message.contract); + } + if (message.msg.length !== 0) { + writer.uint32(26).bytes(message.msg); + } for (const v of message.sentFunds) { Coin.encode(v!, writer.uint32(42).fork()).ldelim(); } @@ -537,6 +565,20 @@ export const MsgExecuteContract = { return message; }, + toJSON(message: MsgExecuteContract): unknown { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.contract !== undefined && (obj.contract = message.contract); + message.msg !== undefined && + (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); + if (message.sentFunds) { + obj.sentFunds = message.sentFunds.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.sentFunds = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgExecuteContract { const message = { ...baseMsgExecuteContract } as MsgExecuteContract; message.sentFunds = []; @@ -562,27 +604,15 @@ export const MsgExecuteContract = { } return message; }, - - toJSON(message: MsgExecuteContract): unknown { - const obj: any = {}; - message.sender !== undefined && (obj.sender = message.sender); - message.contract !== undefined && (obj.contract = message.contract); - message.msg !== undefined && - (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); - if (message.sentFunds) { - obj.sentFunds = message.sentFunds.map((e) => (e ? Coin.toJSON(e) : undefined)); - } else { - obj.sentFunds = []; - } - return obj; - }, }; const baseMsgExecuteContractResponse: object = {}; export const MsgExecuteContractResponse = { encode(message: MsgExecuteContractResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.data); + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } return writer; }, @@ -612,6 +642,13 @@ export const MsgExecuteContractResponse = { return message; }, + toJSON(message: MsgExecuteContractResponse): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): MsgExecuteContractResponse { const message = { ...baseMsgExecuteContractResponse } as MsgExecuteContractResponse; if (object.data !== undefined && object.data !== null) { @@ -621,23 +658,24 @@ export const MsgExecuteContractResponse = { } return message; }, - - toJSON(message: MsgExecuteContractResponse): unknown { - const obj: any = {}; - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); - return obj; - }, }; const baseMsgMigrateContract: object = { sender: "", contract: "", codeId: Long.UZERO }; export const MsgMigrateContract = { encode(message: MsgMigrateContract, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.sender); - writer.uint32(18).string(message.contract); - writer.uint32(24).uint64(message.codeId); - writer.uint32(34).bytes(message.migrateMsg); + if (message.sender !== "") { + writer.uint32(10).string(message.sender); + } + if (message.contract !== "") { + writer.uint32(18).string(message.contract); + } + if (!message.codeId.isZero()) { + writer.uint32(24).uint64(message.codeId); + } + if (message.migrateMsg.length !== 0) { + writer.uint32(34).bytes(message.migrateMsg); + } return writer; }, @@ -691,6 +729,18 @@ export const MsgMigrateContract = { return message; }, + toJSON(message: MsgMigrateContract): unknown { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.contract !== undefined && (obj.contract = message.contract); + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + message.migrateMsg !== undefined && + (obj.migrateMsg = base64FromBytes( + message.migrateMsg !== undefined ? message.migrateMsg : new Uint8Array(), + )); + return obj; + }, + fromPartial(object: DeepPartial): MsgMigrateContract { const message = { ...baseMsgMigrateContract } as MsgMigrateContract; if (object.sender !== undefined && object.sender !== null) { @@ -715,25 +765,15 @@ export const MsgMigrateContract = { } return message; }, - - toJSON(message: MsgMigrateContract): unknown { - const obj: any = {}; - message.sender !== undefined && (obj.sender = message.sender); - message.contract !== undefined && (obj.contract = message.contract); - message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); - message.migrateMsg !== undefined && - (obj.migrateMsg = base64FromBytes( - message.migrateMsg !== undefined ? message.migrateMsg : new Uint8Array(), - )); - return obj; - }, }; const baseMsgMigrateContractResponse: object = {}; export const MsgMigrateContractResponse = { encode(message: MsgMigrateContractResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.data); + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } return writer; }, @@ -763,6 +803,13 @@ export const MsgMigrateContractResponse = { return message; }, + toJSON(message: MsgMigrateContractResponse): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): MsgMigrateContractResponse { const message = { ...baseMsgMigrateContractResponse } as MsgMigrateContractResponse; if (object.data !== undefined && object.data !== null) { @@ -772,22 +819,21 @@ export const MsgMigrateContractResponse = { } return message; }, - - toJSON(message: MsgMigrateContractResponse): unknown { - const obj: any = {}; - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); - return obj; - }, }; const baseMsgUpdateAdmin: object = { sender: "", newAdmin: "", contract: "" }; export const MsgUpdateAdmin = { encode(message: MsgUpdateAdmin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.sender); - writer.uint32(18).string(message.newAdmin); - writer.uint32(26).string(message.contract); + if (message.sender !== "") { + writer.uint32(10).string(message.sender); + } + if (message.newAdmin !== "") { + writer.uint32(18).string(message.newAdmin); + } + if (message.contract !== "") { + writer.uint32(26).string(message.contract); + } return writer; }, @@ -835,6 +881,14 @@ export const MsgUpdateAdmin = { return message; }, + toJSON(message: MsgUpdateAdmin): unknown { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.newAdmin !== undefined && (obj.newAdmin = message.newAdmin); + message.contract !== undefined && (obj.contract = message.contract); + return obj; + }, + fromPartial(object: DeepPartial): MsgUpdateAdmin { const message = { ...baseMsgUpdateAdmin } as MsgUpdateAdmin; if (object.sender !== undefined && object.sender !== null) { @@ -854,14 +908,6 @@ export const MsgUpdateAdmin = { } return message; }, - - toJSON(message: MsgUpdateAdmin): unknown { - const obj: any = {}; - message.sender !== undefined && (obj.sender = message.sender); - message.newAdmin !== undefined && (obj.newAdmin = message.newAdmin); - message.contract !== undefined && (obj.contract = message.contract); - return obj; - }, }; const baseMsgUpdateAdminResponse: object = {}; @@ -891,23 +937,27 @@ export const MsgUpdateAdminResponse = { return message; }, - fromPartial(_: DeepPartial): MsgUpdateAdminResponse { - const message = { ...baseMsgUpdateAdminResponse } as MsgUpdateAdminResponse; - return message; - }, - toJSON(_: MsgUpdateAdminResponse): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): MsgUpdateAdminResponse { + const message = { ...baseMsgUpdateAdminResponse } as MsgUpdateAdminResponse; + return message; + }, }; const baseMsgClearAdmin: object = { sender: "", contract: "" }; export const MsgClearAdmin = { encode(message: MsgClearAdmin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.sender); - writer.uint32(26).string(message.contract); + if (message.sender !== "") { + writer.uint32(10).string(message.sender); + } + if (message.contract !== "") { + writer.uint32(26).string(message.contract); + } return writer; }, @@ -947,6 +997,13 @@ export const MsgClearAdmin = { return message; }, + toJSON(message: MsgClearAdmin): unknown { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.contract !== undefined && (obj.contract = message.contract); + return obj; + }, + fromPartial(object: DeepPartial): MsgClearAdmin { const message = { ...baseMsgClearAdmin } as MsgClearAdmin; if (object.sender !== undefined && object.sender !== null) { @@ -961,13 +1018,6 @@ export const MsgClearAdmin = { } return message; }, - - toJSON(message: MsgClearAdmin): unknown { - const obj: any = {}; - message.sender !== undefined && (obj.sender = message.sender); - message.contract !== undefined && (obj.contract = message.contract); - return obj; - }, }; const baseMsgClearAdminResponse: object = {}; @@ -997,15 +1047,15 @@ export const MsgClearAdminResponse = { return message; }, - fromPartial(_: DeepPartial): MsgClearAdminResponse { - const message = { ...baseMsgClearAdminResponse } as MsgClearAdminResponse; - return message; - }, - toJSON(_: MsgClearAdminResponse): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): MsgClearAdminResponse { + const message = { ...baseMsgClearAdminResponse } as MsgClearAdminResponse; + return message; + }, }; /** Msg defines the wasm Msg service. */ @@ -1077,7 +1127,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/cosmwasm-stargate/src/codec/x/wasm/internal/types/types.ts b/packages/cosmwasm-stargate/src/codec/x/wasm/internal/types/types.ts index f139ada6..e9e3b7c6 100644 --- a/packages/cosmwasm-stargate/src/codec/x/wasm/internal/types/types.ts +++ b/packages/cosmwasm-stargate/src/codec/x/wasm/internal/types/types.ts @@ -181,7 +181,9 @@ const baseAccessTypeParam: object = { value: 0 }; export const AccessTypeParam = { encode(message: AccessTypeParam, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.value); + if (message.value !== 0) { + writer.uint32(8).int32(message.value); + } return writer; }, @@ -213,6 +215,12 @@ export const AccessTypeParam = { return message; }, + toJSON(message: AccessTypeParam): unknown { + const obj: any = {}; + message.value !== undefined && (obj.value = accessTypeToJSON(message.value)); + return obj; + }, + fromPartial(object: DeepPartial): AccessTypeParam { const message = { ...baseAccessTypeParam } as AccessTypeParam; if (object.value !== undefined && object.value !== null) { @@ -222,20 +230,18 @@ export const AccessTypeParam = { } return message; }, - - toJSON(message: AccessTypeParam): unknown { - const obj: any = {}; - message.value !== undefined && (obj.value = accessTypeToJSON(message.value)); - return obj; - }, }; const baseAccessConfig: object = { permission: 0, address: "" }; export const AccessConfig = { encode(message: AccessConfig, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.permission); - writer.uint32(18).string(message.address); + if (message.permission !== 0) { + writer.uint32(8).int32(message.permission); + } + if (message.address !== "") { + writer.uint32(18).string(message.address); + } return writer; }, @@ -275,6 +281,13 @@ export const AccessConfig = { return message; }, + toJSON(message: AccessConfig): unknown { + const obj: any = {}; + message.permission !== undefined && (obj.permission = accessTypeToJSON(message.permission)); + message.address !== undefined && (obj.address = message.address); + return obj; + }, + fromPartial(object: DeepPartial): AccessConfig { const message = { ...baseAccessConfig } as AccessConfig; if (object.permission !== undefined && object.permission !== null) { @@ -289,24 +302,21 @@ export const AccessConfig = { } return message; }, - - toJSON(message: AccessConfig): unknown { - const obj: any = {}; - message.permission !== undefined && (obj.permission = accessTypeToJSON(message.permission)); - message.address !== undefined && (obj.address = message.address); - return obj; - }, }; const baseParams: object = { instantiateDefaultPermission: 0, maxWasmCodeSize: Long.UZERO }; export const Params = { encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.codeUploadAccess !== undefined && message.codeUploadAccess !== undefined) { + if (message.codeUploadAccess !== undefined) { AccessConfig.encode(message.codeUploadAccess, writer.uint32(10).fork()).ldelim(); } - writer.uint32(16).int32(message.instantiateDefaultPermission); - writer.uint32(24).uint64(message.maxWasmCodeSize); + if (message.instantiateDefaultPermission !== 0) { + writer.uint32(16).int32(message.instantiateDefaultPermission); + } + if (!message.maxWasmCodeSize.isZero()) { + writer.uint32(24).uint64(message.maxWasmCodeSize); + } return writer; }, @@ -354,6 +364,19 @@ export const Params = { return message; }, + toJSON(message: Params): unknown { + const obj: any = {}; + message.codeUploadAccess !== undefined && + (obj.codeUploadAccess = message.codeUploadAccess + ? AccessConfig.toJSON(message.codeUploadAccess) + : undefined); + message.instantiateDefaultPermission !== undefined && + (obj.instantiateDefaultPermission = accessTypeToJSON(message.instantiateDefaultPermission)); + message.maxWasmCodeSize !== undefined && + (obj.maxWasmCodeSize = (message.maxWasmCodeSize || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): Params { const message = { ...baseParams } as Params; if (object.codeUploadAccess !== undefined && object.codeUploadAccess !== null) { @@ -373,30 +396,25 @@ export const Params = { } return message; }, - - toJSON(message: Params): unknown { - const obj: any = {}; - message.codeUploadAccess !== undefined && - (obj.codeUploadAccess = message.codeUploadAccess - ? AccessConfig.toJSON(message.codeUploadAccess) - : undefined); - message.instantiateDefaultPermission !== undefined && - (obj.instantiateDefaultPermission = accessTypeToJSON(message.instantiateDefaultPermission)); - message.maxWasmCodeSize !== undefined && - (obj.maxWasmCodeSize = (message.maxWasmCodeSize || Long.UZERO).toString()); - return obj; - }, }; const baseCodeInfo: object = { creator: "", source: "", builder: "" }; export const CodeInfo = { encode(message: CodeInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.codeHash); - writer.uint32(18).string(message.creator); - writer.uint32(26).string(message.source); - writer.uint32(34).string(message.builder); - if (message.instantiateConfig !== undefined && message.instantiateConfig !== undefined) { + if (message.codeHash.length !== 0) { + writer.uint32(10).bytes(message.codeHash); + } + if (message.creator !== "") { + writer.uint32(18).string(message.creator); + } + if (message.source !== "") { + writer.uint32(26).string(message.source); + } + if (message.builder !== "") { + writer.uint32(34).string(message.builder); + } + if (message.instantiateConfig !== undefined) { AccessConfig.encode(message.instantiateConfig, writer.uint32(42).fork()).ldelim(); } return writer; @@ -460,6 +478,20 @@ export const CodeInfo = { return message; }, + toJSON(message: CodeInfo): unknown { + const obj: any = {}; + message.codeHash !== undefined && + (obj.codeHash = base64FromBytes(message.codeHash !== undefined ? message.codeHash : new Uint8Array())); + message.creator !== undefined && (obj.creator = message.creator); + message.source !== undefined && (obj.source = message.source); + message.builder !== undefined && (obj.builder = message.builder); + message.instantiateConfig !== undefined && + (obj.instantiateConfig = message.instantiateConfig + ? AccessConfig.toJSON(message.instantiateConfig) + : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CodeInfo { const message = { ...baseCodeInfo } as CodeInfo; if (object.codeHash !== undefined && object.codeHash !== null) { @@ -489,31 +521,25 @@ export const CodeInfo = { } return message; }, - - toJSON(message: CodeInfo): unknown { - const obj: any = {}; - message.codeHash !== undefined && - (obj.codeHash = base64FromBytes(message.codeHash !== undefined ? message.codeHash : new Uint8Array())); - message.creator !== undefined && (obj.creator = message.creator); - message.source !== undefined && (obj.source = message.source); - message.builder !== undefined && (obj.builder = message.builder); - message.instantiateConfig !== undefined && - (obj.instantiateConfig = message.instantiateConfig - ? AccessConfig.toJSON(message.instantiateConfig) - : undefined); - return obj; - }, }; const baseContractInfo: object = { codeId: Long.UZERO, creator: "", admin: "", label: "" }; export const ContractInfo = { encode(message: ContractInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.codeId); - writer.uint32(18).string(message.creator); - writer.uint32(26).string(message.admin); - writer.uint32(34).string(message.label); - if (message.created !== undefined && message.created !== undefined) { + if (!message.codeId.isZero()) { + writer.uint32(8).uint64(message.codeId); + } + if (message.creator !== "") { + writer.uint32(18).string(message.creator); + } + if (message.admin !== "") { + writer.uint32(26).string(message.admin); + } + if (message.label !== "") { + writer.uint32(34).string(message.label); + } + if (message.created !== undefined) { AbsoluteTxPosition.encode(message.created, writer.uint32(42).fork()).ldelim(); } return writer; @@ -579,6 +605,17 @@ export const ContractInfo = { return message; }, + toJSON(message: ContractInfo): unknown { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + message.creator !== undefined && (obj.creator = message.creator); + message.admin !== undefined && (obj.admin = message.admin); + message.label !== undefined && (obj.label = message.label); + message.created !== undefined && + (obj.created = message.created ? AbsoluteTxPosition.toJSON(message.created) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ContractInfo { const message = { ...baseContractInfo } as ContractInfo; if (object.codeId !== undefined && object.codeId !== null) { @@ -608,29 +645,24 @@ export const ContractInfo = { } return message; }, - - toJSON(message: ContractInfo): unknown { - const obj: any = {}; - message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); - message.creator !== undefined && (obj.creator = message.creator); - message.admin !== undefined && (obj.admin = message.admin); - message.label !== undefined && (obj.label = message.label); - message.created !== undefined && - (obj.created = message.created ? AbsoluteTxPosition.toJSON(message.created) : undefined); - return obj; - }, }; const baseContractCodeHistoryEntry: object = { operation: 0, codeId: Long.UZERO }; export const ContractCodeHistoryEntry = { encode(message: ContractCodeHistoryEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.operation); - writer.uint32(16).uint64(message.codeId); - if (message.updated !== undefined && message.updated !== undefined) { + if (message.operation !== 0) { + writer.uint32(8).int32(message.operation); + } + if (!message.codeId.isZero()) { + writer.uint32(16).uint64(message.codeId); + } + if (message.updated !== undefined) { AbsoluteTxPosition.encode(message.updated, writer.uint32(26).fork()).ldelim(); } - writer.uint32(34).bytes(message.msg); + if (message.msg.length !== 0) { + writer.uint32(34).bytes(message.msg); + } return writer; }, @@ -684,6 +716,18 @@ export const ContractCodeHistoryEntry = { return message; }, + toJSON(message: ContractCodeHistoryEntry): unknown { + const obj: any = {}; + message.operation !== undefined && + (obj.operation = contractCodeHistoryOperationTypeToJSON(message.operation)); + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + message.updated !== undefined && + (obj.updated = message.updated ? AbsoluteTxPosition.toJSON(message.updated) : undefined); + message.msg !== undefined && + (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): ContractCodeHistoryEntry { const message = { ...baseContractCodeHistoryEntry } as ContractCodeHistoryEntry; if (object.operation !== undefined && object.operation !== null) { @@ -708,26 +752,18 @@ export const ContractCodeHistoryEntry = { } return message; }, - - toJSON(message: ContractCodeHistoryEntry): unknown { - const obj: any = {}; - message.operation !== undefined && - (obj.operation = contractCodeHistoryOperationTypeToJSON(message.operation)); - message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); - message.updated !== undefined && - (obj.updated = message.updated ? AbsoluteTxPosition.toJSON(message.updated) : undefined); - message.msg !== undefined && - (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); - return obj; - }, }; const baseAbsoluteTxPosition: object = { blockHeight: Long.UZERO, txIndex: Long.UZERO }; export const AbsoluteTxPosition = { encode(message: AbsoluteTxPosition, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.blockHeight); - writer.uint32(16).uint64(message.txIndex); + if (!message.blockHeight.isZero()) { + writer.uint32(8).uint64(message.blockHeight); + } + if (!message.txIndex.isZero()) { + writer.uint32(16).uint64(message.txIndex); + } return writer; }, @@ -767,6 +803,13 @@ export const AbsoluteTxPosition = { return message; }, + toJSON(message: AbsoluteTxPosition): unknown { + const obj: any = {}; + message.blockHeight !== undefined && (obj.blockHeight = (message.blockHeight || Long.UZERO).toString()); + message.txIndex !== undefined && (obj.txIndex = (message.txIndex || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): AbsoluteTxPosition { const message = { ...baseAbsoluteTxPosition } as AbsoluteTxPosition; if (object.blockHeight !== undefined && object.blockHeight !== null) { @@ -781,21 +824,18 @@ export const AbsoluteTxPosition = { } return message; }, - - toJSON(message: AbsoluteTxPosition): unknown { - const obj: any = {}; - message.blockHeight !== undefined && (obj.blockHeight = (message.blockHeight || Long.UZERO).toString()); - message.txIndex !== undefined && (obj.txIndex = (message.txIndex || Long.UZERO).toString()); - return obj; - }, }; const baseModel: object = {}; export const Model = { encode(message: Model, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.key); - writer.uint32(18).bytes(message.value); + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } return writer; }, @@ -831,6 +871,15 @@ export const Model = { return message; }, + toJSON(message: Model): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.value !== undefined && + (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): Model { const message = { ...baseModel } as Model; if (object.key !== undefined && object.key !== null) { @@ -845,15 +894,6 @@ export const Model = { } return message; }, - - toJSON(message: Model): unknown { - const obj: any = {}; - message.key !== undefined && - (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); - message.value !== undefined && - (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); - return obj; - }, }; declare var self: any | undefined; @@ -863,7 +903,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/stargate/TEST_VECTORS.md b/packages/proto-signing/TEST_VECTORS.md similarity index 77% rename from packages/stargate/TEST_VECTORS.md rename to packages/proto-signing/TEST_VECTORS.md index dd7547cc..b14601b1 100644 --- a/packages/stargate/TEST_VECTORS.md +++ b/packages/proto-signing/TEST_VECTORS.md @@ -10,17 +10,22 @@ my branch (which can be rebased). ## Setup +Test vectors are generated using those additions: +https://github.com/CosmWasm/cosmos-sdk/pull/58 + ``` git clone https://github.com/CosmWasm/cosmos-sdk.git cd cosmos-sdk -git checkout cosmjs-test-vectors +git checkout cosmjs-test-vectors-v2 -make build-simd-linux # or on OSX: make build-simd-darwin -# this takes a while to download a docker image and make a deterministic build.... +# Use one of those build commands. The first one is native, the other two use a docker build container. +make build +make build-simd-linux +make build-simd-darwin -ls -l ./build/simd +ls -l ./build ./build/simd version -# I got `goz-phase-1-706-g1a67086b6` for commit `1a67086b6` +# I got `goz-phase-1-1170-g2a8d2d35d` for commit `2a8d2d35daab` ``` **IMPORTANT** this stores the proper `simd` binary in `./build/simd`. You may @@ -31,7 +36,7 @@ proper version. ## Prepare the Keys You want to ensure you use the same keys as in the test vector, -[taken from here](https://github.com/cosmos/cosmjs/blob/db1f183/packages/proto-signing/src/signing.spec.ts#L19-L27). +[taken from here](https://github.com/cosmos/cosmjs/blob/v0.24.0-alpha.25/packages/proto-signing/src/testutils.spec.ts#L4-L12). This uses the testgen mnemonic: `economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone` @@ -102,26 +107,29 @@ test that: ## Generating Signatures All current test vectors were signed from account number 1, with increasing -signatures (0, 1, 2). You can produce these with the following commands: +sequences (0, 1, 2). You can produce these with the following commands: ``` -# you may not need `--home /tmp` but I got an odd error without it +# you may need to add `--home /tmp` if you get errors ./build/simd tx sign --offline --sign-mode direct -a 1 -s 0 --from testgen --chain-id simd-testing unsigned_tx.json - -./build/simd tx sign --home /tmp --offline --sign-mode direct -a 1 -s 1 --from testgen --chain-id simd-testing unsigned_tx.json +./build/simd tx sign --offline --sign-mode direct -a 1 -s 1 --from testgen --chain-id simd-testing unsigned_tx.json +./build/simd tx sign --offline --sign-mode direct -a 1 -s 2 --from testgen --chain-id simd-testing unsigned_tx.json ``` -You will get some output that looks more or less like this: +For each sign command you will get output that looks more or less like this: ``` Sign Mode: SIGN_MODE_DIRECT +Body bytes: 0a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d120731323334353637 + +Auth info bytes: 0a4e0a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a02080112130a0d0a0575636f736d12043230303010c09a0c + Sign Bytes: 0a93010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712650a4e0a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a02080112130a0d0a0575636f736d12043230303010c09a0c1a0c73696d642d74657374696e672001 Signature: c9dd20e07464d3a688ff4b710b1fbc027e495e797cfa0b4804da2ed117959227772de059808f765aa29b8f92edf30f4c2c5a438e30d3fe6897daa7141e3ce6f9 Signed TX Bytes: 0a93010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712650a4e0a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a02080112130a0d0a0575636f736d12043230303010c09a0c1a40c9dd20e07464d3a688ff4b710b1fbc027e495e797cfa0b4804da2ed117959227772de059808f765aa29b8f92edf30f4c2c5a438e30d3fe6897daa7141e3ce6f9 - {"body":{"messages":[{"@type":"/cosmos.bank.v1beta1.MsgSend","from_address":"cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6","to_address":"cosmos1qypqxpq9qcrsszg2pvxq6rs0zqg3yyc5lzv7xu","amount":[{"denom":"ucosm","amount":"1234567"}]}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[{"public_key":{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A08EGB7ro1ORuFhjOnZcSgwYlpe0DSFjVNUIkNNQxwKQ"},"mode_info":{"single":{"mode":"SIGN_MODE_DIRECT"}},"sequence":"0"}],"fee":{"amount":[{"denom":"ucosm","amount":"2000"}],"gas_limit":"200000","payer":"","granter":""}},"signatures":["yd0g4HRk06aI/0txCx+8An5JXnl8+gtIBNou0ReVkid3LeBZgI92WqKbj5Lt8w9MLFpDjjDT/miX2qcUHjzm+Q=="]} ``` diff --git a/packages/proto-signing/src/codec/cosmos/bank/v1beta1/bank.ts b/packages/proto-signing/src/codec/cosmos/bank/v1beta1/bank.ts index 33d01f44..43fa84f5 100644 --- a/packages/proto-signing/src/codec/cosmos/bank/v1beta1/bank.ts +++ b/packages/proto-signing/src/codec/cosmos/bank/v1beta1/bank.ts @@ -83,7 +83,9 @@ export const Params = { for (const v of message.sendEnabled) { SendEnabled.encode(v!, writer.uint32(10).fork()).ldelim(); } - writer.uint32(16).bool(message.defaultSendEnabled); + if (message.defaultSendEnabled === true) { + writer.uint32(16).bool(message.defaultSendEnabled); + } return writer; }, @@ -125,6 +127,17 @@ export const Params = { return message; }, + toJSON(message: Params): unknown { + const obj: any = {}; + if (message.sendEnabled) { + obj.sendEnabled = message.sendEnabled.map((e) => (e ? SendEnabled.toJSON(e) : undefined)); + } else { + obj.sendEnabled = []; + } + message.defaultSendEnabled !== undefined && (obj.defaultSendEnabled = message.defaultSendEnabled); + return obj; + }, + fromPartial(object: DeepPartial): Params { const message = { ...baseParams } as Params; message.sendEnabled = []; @@ -140,25 +153,18 @@ export const Params = { } return message; }, - - toJSON(message: Params): unknown { - const obj: any = {}; - if (message.sendEnabled) { - obj.sendEnabled = message.sendEnabled.map((e) => (e ? SendEnabled.toJSON(e) : undefined)); - } else { - obj.sendEnabled = []; - } - message.defaultSendEnabled !== undefined && (obj.defaultSendEnabled = message.defaultSendEnabled); - return obj; - }, }; const baseSendEnabled: object = { denom: "", enabled: false }; export const SendEnabled = { encode(message: SendEnabled, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.denom); - writer.uint32(16).bool(message.enabled); + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.enabled === true) { + writer.uint32(16).bool(message.enabled); + } return writer; }, @@ -198,6 +204,13 @@ export const SendEnabled = { return message; }, + toJSON(message: SendEnabled): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.enabled !== undefined && (obj.enabled = message.enabled); + return obj; + }, + fromPartial(object: DeepPartial): SendEnabled { const message = { ...baseSendEnabled } as SendEnabled; if (object.denom !== undefined && object.denom !== null) { @@ -212,20 +225,15 @@ export const SendEnabled = { } return message; }, - - toJSON(message: SendEnabled): unknown { - const obj: any = {}; - message.denom !== undefined && (obj.denom = message.denom); - message.enabled !== undefined && (obj.enabled = message.enabled); - return obj; - }, }; const baseInput: object = { address: "" }; export const Input = { encode(message: Input, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.address); + if (message.address !== "") { + writer.uint32(10).string(message.address); + } for (const v of message.coins) { Coin.encode(v!, writer.uint32(18).fork()).ldelim(); } @@ -270,6 +278,17 @@ export const Input = { return message; }, + toJSON(message: Input): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + if (message.coins) { + obj.coins = message.coins.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.coins = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Input { const message = { ...baseInput } as Input; message.coins = []; @@ -285,24 +304,15 @@ export const Input = { } return message; }, - - toJSON(message: Input): unknown { - const obj: any = {}; - message.address !== undefined && (obj.address = message.address); - if (message.coins) { - obj.coins = message.coins.map((e) => (e ? Coin.toJSON(e) : undefined)); - } else { - obj.coins = []; - } - return obj; - }, }; const baseOutput: object = { address: "" }; export const Output = { encode(message: Output, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.address); + if (message.address !== "") { + writer.uint32(10).string(message.address); + } for (const v of message.coins) { Coin.encode(v!, writer.uint32(18).fork()).ldelim(); } @@ -347,6 +357,17 @@ export const Output = { return message; }, + toJSON(message: Output): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + if (message.coins) { + obj.coins = message.coins.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.coins = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Output { const message = { ...baseOutput } as Output; message.coins = []; @@ -362,17 +383,6 @@ export const Output = { } return message; }, - - toJSON(message: Output): unknown { - const obj: any = {}; - message.address !== undefined && (obj.address = message.address); - if (message.coins) { - obj.coins = message.coins.map((e) => (e ? Coin.toJSON(e) : undefined)); - } else { - obj.coins = []; - } - return obj; - }, }; const baseSupply: object = {}; @@ -415,6 +425,16 @@ export const Supply = { return message; }, + toJSON(message: Supply): unknown { + const obj: any = {}; + if (message.total) { + obj.total = message.total.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.total = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Supply { const message = { ...baseSupply } as Supply; message.total = []; @@ -425,24 +445,18 @@ export const Supply = { } return message; }, - - toJSON(message: Supply): unknown { - const obj: any = {}; - if (message.total) { - obj.total = message.total.map((e) => (e ? Coin.toJSON(e) : undefined)); - } else { - obj.total = []; - } - return obj; - }, }; const baseDenomUnit: object = { denom: "", exponent: 0, aliases: "" }; export const DenomUnit = { encode(message: DenomUnit, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.denom); - writer.uint32(16).uint32(message.exponent); + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.exponent !== 0) { + writer.uint32(16).uint32(message.exponent); + } for (const v of message.aliases) { writer.uint32(26).string(v!); } @@ -495,6 +509,18 @@ export const DenomUnit = { return message; }, + toJSON(message: DenomUnit): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.exponent !== undefined && (obj.exponent = message.exponent); + if (message.aliases) { + obj.aliases = message.aliases.map((e) => e); + } else { + obj.aliases = []; + } + return obj; + }, + fromPartial(object: DeepPartial): DenomUnit { const message = { ...baseDenomUnit } as DenomUnit; message.aliases = []; @@ -515,30 +541,24 @@ export const DenomUnit = { } return message; }, - - toJSON(message: DenomUnit): unknown { - const obj: any = {}; - message.denom !== undefined && (obj.denom = message.denom); - message.exponent !== undefined && (obj.exponent = message.exponent); - if (message.aliases) { - obj.aliases = message.aliases.map((e) => e); - } else { - obj.aliases = []; - } - return obj; - }, }; const baseMetadata: object = { description: "", base: "", display: "" }; export const Metadata = { encode(message: Metadata, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.description); + if (message.description !== "") { + writer.uint32(10).string(message.description); + } for (const v of message.denomUnits) { DenomUnit.encode(v!, writer.uint32(18).fork()).ldelim(); } - writer.uint32(26).string(message.base); - writer.uint32(34).string(message.display); + if (message.base !== "") { + writer.uint32(26).string(message.base); + } + if (message.display !== "") { + writer.uint32(34).string(message.display); + } return writer; }, @@ -596,6 +616,19 @@ export const Metadata = { return message; }, + toJSON(message: Metadata): unknown { + const obj: any = {}; + message.description !== undefined && (obj.description = message.description); + if (message.denomUnits) { + obj.denomUnits = message.denomUnits.map((e) => (e ? DenomUnit.toJSON(e) : undefined)); + } else { + obj.denomUnits = []; + } + message.base !== undefined && (obj.base = message.base); + message.display !== undefined && (obj.display = message.display); + return obj; + }, + fromPartial(object: DeepPartial): Metadata { const message = { ...baseMetadata } as Metadata; message.denomUnits = []; @@ -621,19 +654,6 @@ export const Metadata = { } return message; }, - - toJSON(message: Metadata): unknown { - const obj: any = {}; - message.description !== undefined && (obj.description = message.description); - if (message.denomUnits) { - obj.denomUnits = message.denomUnits.map((e) => (e ? DenomUnit.toJSON(e) : undefined)); - } else { - obj.denomUnits = []; - } - message.base !== undefined && (obj.base = message.base); - message.display !== undefined && (obj.display = message.display); - return obj; - }, }; type Builtin = Date | Function | Uint8Array | string | number | undefined | Long; diff --git a/packages/proto-signing/src/codec/cosmos/bank/v1beta1/tx.ts b/packages/proto-signing/src/codec/cosmos/bank/v1beta1/tx.ts index cfaacf83..5aeee5b9 100644 --- a/packages/proto-signing/src/codec/cosmos/bank/v1beta1/tx.ts +++ b/packages/proto-signing/src/codec/cosmos/bank/v1beta1/tx.ts @@ -29,8 +29,12 @@ const baseMsgSend: object = { fromAddress: "", toAddress: "" }; export const MsgSend = { encode(message: MsgSend, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.fromAddress); - writer.uint32(18).string(message.toAddress); + if (message.fromAddress !== "") { + writer.uint32(10).string(message.fromAddress); + } + if (message.toAddress !== "") { + writer.uint32(18).string(message.toAddress); + } for (const v of message.amount) { Coin.encode(v!, writer.uint32(26).fork()).ldelim(); } @@ -83,6 +87,18 @@ export const MsgSend = { return message; }, + toJSON(message: MsgSend): unknown { + const obj: any = {}; + message.fromAddress !== undefined && (obj.fromAddress = message.fromAddress); + message.toAddress !== undefined && (obj.toAddress = message.toAddress); + if (message.amount) { + obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.amount = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgSend { const message = { ...baseMsgSend } as MsgSend; message.amount = []; @@ -103,18 +119,6 @@ export const MsgSend = { } return message; }, - - toJSON(message: MsgSend): unknown { - const obj: any = {}; - message.fromAddress !== undefined && (obj.fromAddress = message.fromAddress); - message.toAddress !== undefined && (obj.toAddress = message.toAddress); - if (message.amount) { - obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); - } else { - obj.amount = []; - } - return obj; - }, }; const baseMsgSendResponse: object = {}; @@ -144,15 +148,15 @@ export const MsgSendResponse = { return message; }, - fromPartial(_: DeepPartial): MsgSendResponse { - const message = { ...baseMsgSendResponse } as MsgSendResponse; - return message; - }, - toJSON(_: MsgSendResponse): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): MsgSendResponse { + const message = { ...baseMsgSendResponse } as MsgSendResponse; + return message; + }, }; const baseMsgMultiSend: object = {}; @@ -208,6 +212,21 @@ export const MsgMultiSend = { return message; }, + toJSON(message: MsgMultiSend): unknown { + const obj: any = {}; + if (message.inputs) { + obj.inputs = message.inputs.map((e) => (e ? Input.toJSON(e) : undefined)); + } else { + obj.inputs = []; + } + if (message.outputs) { + obj.outputs = message.outputs.map((e) => (e ? Output.toJSON(e) : undefined)); + } else { + obj.outputs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgMultiSend { const message = { ...baseMsgMultiSend } as MsgMultiSend; message.inputs = []; @@ -224,21 +243,6 @@ export const MsgMultiSend = { } return message; }, - - toJSON(message: MsgMultiSend): unknown { - const obj: any = {}; - if (message.inputs) { - obj.inputs = message.inputs.map((e) => (e ? Input.toJSON(e) : undefined)); - } else { - obj.inputs = []; - } - if (message.outputs) { - obj.outputs = message.outputs.map((e) => (e ? Output.toJSON(e) : undefined)); - } else { - obj.outputs = []; - } - return obj; - }, }; const baseMsgMultiSendResponse: object = {}; @@ -268,15 +272,15 @@ export const MsgMultiSendResponse = { return message; }, - fromPartial(_: DeepPartial): MsgMultiSendResponse { - const message = { ...baseMsgMultiSendResponse } as MsgMultiSendResponse; - return message; - }, - toJSON(_: MsgMultiSendResponse): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): MsgMultiSendResponse { + const message = { ...baseMsgMultiSendResponse } as MsgMultiSendResponse; + return message; + }, }; /** Msg defines the bank Msg service. */ @@ -294,13 +298,13 @@ export class MsgClientImpl implements Msg { } Send(request: MsgSend): Promise { const data = MsgSend.encode(request).finish(); - const promise = this.rpc.request("cosmos.bank.v1beta1.Msg", "methodDesc.name", data); + const promise = this.rpc.request("cosmos.bank.v1beta1.Msg", "Send", data); return promise.then((data) => MsgSendResponse.decode(new _m0.Reader(data))); } MultiSend(request: MsgMultiSend): Promise { const data = MsgMultiSend.encode(request).finish(); - const promise = this.rpc.request("cosmos.bank.v1beta1.Msg", "methodDesc.name", data); + const promise = this.rpc.request("cosmos.bank.v1beta1.Msg", "MultiSend", data); return promise.then((data) => MsgMultiSendResponse.decode(new _m0.Reader(data))); } } diff --git a/packages/proto-signing/src/codec/cosmos/base/v1beta1/coin.ts b/packages/proto-signing/src/codec/cosmos/base/v1beta1/coin.ts index 9e54cfd1..e682a9a7 100644 --- a/packages/proto-signing/src/codec/cosmos/base/v1beta1/coin.ts +++ b/packages/proto-signing/src/codec/cosmos/base/v1beta1/coin.ts @@ -40,8 +40,12 @@ const baseCoin: object = { denom: "", amount: "" }; export const Coin = { encode(message: Coin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.denom); - writer.uint32(18).string(message.amount); + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } return writer; }, @@ -81,6 +85,13 @@ export const Coin = { return message; }, + toJSON(message: Coin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + fromPartial(object: DeepPartial): Coin { const message = { ...baseCoin } as Coin; if (object.denom !== undefined && object.denom !== null) { @@ -95,21 +106,18 @@ export const Coin = { } return message; }, - - toJSON(message: Coin): unknown { - const obj: any = {}; - message.denom !== undefined && (obj.denom = message.denom); - message.amount !== undefined && (obj.amount = message.amount); - return obj; - }, }; const baseDecCoin: object = { denom: "", amount: "" }; export const DecCoin = { encode(message: DecCoin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.denom); - writer.uint32(18).string(message.amount); + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } return writer; }, @@ -149,6 +157,13 @@ export const DecCoin = { return message; }, + toJSON(message: DecCoin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + fromPartial(object: DeepPartial): DecCoin { const message = { ...baseDecCoin } as DecCoin; if (object.denom !== undefined && object.denom !== null) { @@ -163,20 +178,15 @@ export const DecCoin = { } return message; }, - - toJSON(message: DecCoin): unknown { - const obj: any = {}; - message.denom !== undefined && (obj.denom = message.denom); - message.amount !== undefined && (obj.amount = message.amount); - return obj; - }, }; const baseIntProto: object = { int: "" }; export const IntProto = { encode(message: IntProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.int); + if (message.int !== "") { + writer.uint32(10).string(message.int); + } return writer; }, @@ -208,6 +218,12 @@ export const IntProto = { return message; }, + toJSON(message: IntProto): unknown { + const obj: any = {}; + message.int !== undefined && (obj.int = message.int); + return obj; + }, + fromPartial(object: DeepPartial): IntProto { const message = { ...baseIntProto } as IntProto; if (object.int !== undefined && object.int !== null) { @@ -217,19 +233,15 @@ export const IntProto = { } return message; }, - - toJSON(message: IntProto): unknown { - const obj: any = {}; - message.int !== undefined && (obj.int = message.int); - return obj; - }, }; const baseDecProto: object = { dec: "" }; export const DecProto = { encode(message: DecProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.dec); + if (message.dec !== "") { + writer.uint32(10).string(message.dec); + } return writer; }, @@ -261,6 +273,12 @@ export const DecProto = { return message; }, + toJSON(message: DecProto): unknown { + const obj: any = {}; + message.dec !== undefined && (obj.dec = message.dec); + return obj; + }, + fromPartial(object: DeepPartial): DecProto { const message = { ...baseDecProto } as DecProto; if (object.dec !== undefined && object.dec !== null) { @@ -270,12 +288,6 @@ export const DecProto = { } return message; }, - - toJSON(message: DecProto): unknown { - const obj: any = {}; - message.dec !== undefined && (obj.dec = message.dec); - return obj; - }, }; type Builtin = Date | Function | Uint8Array | string | number | undefined | Long; diff --git a/packages/proto-signing/src/codec/cosmos/crypto/multisig/v1beta1/multisig.ts b/packages/proto-signing/src/codec/cosmos/crypto/multisig/v1beta1/multisig.ts index 49842d5f..11fdaf82 100644 --- a/packages/proto-signing/src/codec/cosmos/crypto/multisig/v1beta1/multisig.ts +++ b/packages/proto-signing/src/codec/cosmos/crypto/multisig/v1beta1/multisig.ts @@ -64,6 +64,16 @@ export const MultiSignature = { return message; }, + toJSON(message: MultiSignature): unknown { + const obj: any = {}; + if (message.signatures) { + obj.signatures = message.signatures.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.signatures = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MultiSignature { const message = { ...baseMultiSignature } as MultiSignature; message.signatures = []; @@ -74,24 +84,18 @@ export const MultiSignature = { } return message; }, - - toJSON(message: MultiSignature): unknown { - const obj: any = {}; - if (message.signatures) { - obj.signatures = message.signatures.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); - } else { - obj.signatures = []; - } - return obj; - }, }; const baseCompactBitArray: object = { extraBitsStored: 0 }; export const CompactBitArray = { encode(message: CompactBitArray, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint32(message.extraBitsStored); - writer.uint32(18).bytes(message.elems); + if (message.extraBitsStored !== 0) { + writer.uint32(8).uint32(message.extraBitsStored); + } + if (message.elems.length !== 0) { + writer.uint32(18).bytes(message.elems); + } return writer; }, @@ -129,6 +133,14 @@ export const CompactBitArray = { return message; }, + toJSON(message: CompactBitArray): unknown { + const obj: any = {}; + message.extraBitsStored !== undefined && (obj.extraBitsStored = message.extraBitsStored); + message.elems !== undefined && + (obj.elems = base64FromBytes(message.elems !== undefined ? message.elems : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): CompactBitArray { const message = { ...baseCompactBitArray } as CompactBitArray; if (object.extraBitsStored !== undefined && object.extraBitsStored !== null) { @@ -143,14 +155,6 @@ export const CompactBitArray = { } return message; }, - - toJSON(message: CompactBitArray): unknown { - const obj: any = {}; - message.extraBitsStored !== undefined && (obj.extraBitsStored = message.extraBitsStored); - message.elems !== undefined && - (obj.elems = base64FromBytes(message.elems !== undefined ? message.elems : new Uint8Array())); - return obj; - }, }; declare var self: any | undefined; @@ -160,7 +164,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/proto-signing/src/codec/cosmos/crypto/secp256k1/keys.ts b/packages/proto-signing/src/codec/cosmos/crypto/secp256k1/keys.ts index 13147ba8..984a320a 100644 --- a/packages/proto-signing/src/codec/cosmos/crypto/secp256k1/keys.ts +++ b/packages/proto-signing/src/codec/cosmos/crypto/secp256k1/keys.ts @@ -24,7 +24,9 @@ const basePubKey: object = {}; export const PubKey = { encode(message: PubKey, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.key); + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } return writer; }, @@ -54,6 +56,13 @@ export const PubKey = { return message; }, + toJSON(message: PubKey): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): PubKey { const message = { ...basePubKey } as PubKey; if (object.key !== undefined && object.key !== null) { @@ -63,20 +72,15 @@ export const PubKey = { } return message; }, - - toJSON(message: PubKey): unknown { - const obj: any = {}; - message.key !== undefined && - (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); - return obj; - }, }; const basePrivKey: object = {}; export const PrivKey = { encode(message: PrivKey, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.key); + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } return writer; }, @@ -106,6 +110,13 @@ export const PrivKey = { return message; }, + toJSON(message: PrivKey): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): PrivKey { const message = { ...basePrivKey } as PrivKey; if (object.key !== undefined && object.key !== null) { @@ -115,13 +126,6 @@ export const PrivKey = { } return message; }, - - toJSON(message: PrivKey): unknown { - const obj: any = {}; - message.key !== undefined && - (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); - return obj; - }, }; declare var self: any | undefined; @@ -131,7 +135,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/proto-signing/src/codec/cosmos/tx/signing/v1beta1/signing.ts b/packages/proto-signing/src/codec/cosmos/tx/signing/v1beta1/signing.ts index f39a6141..e49a7573 100644 --- a/packages/proto-signing/src/codec/cosmos/tx/signing/v1beta1/signing.ts +++ b/packages/proto-signing/src/codec/cosmos/tx/signing/v1beta1/signing.ts @@ -156,6 +156,16 @@ export const SignatureDescriptors = { return message; }, + toJSON(message: SignatureDescriptors): unknown { + const obj: any = {}; + if (message.signatures) { + obj.signatures = message.signatures.map((e) => (e ? SignatureDescriptor.toJSON(e) : undefined)); + } else { + obj.signatures = []; + } + return obj; + }, + fromPartial(object: DeepPartial): SignatureDescriptors { const message = { ...baseSignatureDescriptors } as SignatureDescriptors; message.signatures = []; @@ -166,29 +176,21 @@ export const SignatureDescriptors = { } return message; }, - - toJSON(message: SignatureDescriptors): unknown { - const obj: any = {}; - if (message.signatures) { - obj.signatures = message.signatures.map((e) => (e ? SignatureDescriptor.toJSON(e) : undefined)); - } else { - obj.signatures = []; - } - return obj; - }, }; const baseSignatureDescriptor: object = { sequence: Long.UZERO }; export const SignatureDescriptor = { encode(message: SignatureDescriptor, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.publicKey !== undefined && message.publicKey !== undefined) { + if (message.publicKey !== undefined) { Any.encode(message.publicKey, writer.uint32(10).fork()).ldelim(); } - if (message.data !== undefined && message.data !== undefined) { + if (message.data !== undefined) { SignatureDescriptor_Data.encode(message.data, writer.uint32(18).fork()).ldelim(); } - writer.uint32(24).uint64(message.sequence); + if (!message.sequence.isZero()) { + writer.uint32(24).uint64(message.sequence); + } return writer; }, @@ -219,7 +221,7 @@ export const SignatureDescriptor = { fromJSON(object: any): SignatureDescriptor { const message = { ...baseSignatureDescriptor } as SignatureDescriptor; if (object.publicKey !== undefined && object.publicKey !== null) { - message.publicKey = Any.fromPartial(object.publicKey); + message.publicKey = Any.fromJSON(object.publicKey); } else { message.publicKey = undefined; } @@ -236,6 +238,16 @@ export const SignatureDescriptor = { return message; }, + toJSON(message: SignatureDescriptor): unknown { + const obj: any = {}; + message.publicKey !== undefined && + (obj.publicKey = message.publicKey ? Any.toJSON(message.publicKey) : undefined); + message.data !== undefined && + (obj.data = message.data ? SignatureDescriptor_Data.toJSON(message.data) : undefined); + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): SignatureDescriptor { const message = { ...baseSignatureDescriptor } as SignatureDescriptor; if (object.publicKey !== undefined && object.publicKey !== null) { @@ -255,16 +267,6 @@ export const SignatureDescriptor = { } return message; }, - - toJSON(message: SignatureDescriptor): unknown { - const obj: any = {}; - message.publicKey !== undefined && - (obj.publicKey = message.publicKey ? Any.toJSON(message.publicKey) : undefined); - message.data !== undefined && - (obj.data = message.data ? SignatureDescriptor_Data.toJSON(message.data) : undefined); - message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); - return obj; - }, }; const baseSignatureDescriptor_Data: object = {}; @@ -316,6 +318,15 @@ export const SignatureDescriptor_Data = { return message; }, + toJSON(message: SignatureDescriptor_Data): unknown { + const obj: any = {}; + message.single !== undefined && + (obj.single = message.single ? SignatureDescriptor_Data_Single.toJSON(message.single) : undefined); + message.multi !== undefined && + (obj.multi = message.multi ? SignatureDescriptor_Data_Multi.toJSON(message.multi) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): SignatureDescriptor_Data { const message = { ...baseSignatureDescriptor_Data } as SignatureDescriptor_Data; if (object.single !== undefined && object.single !== null) { @@ -330,23 +341,18 @@ export const SignatureDescriptor_Data = { } return message; }, - - toJSON(message: SignatureDescriptor_Data): unknown { - const obj: any = {}; - message.single !== undefined && - (obj.single = message.single ? SignatureDescriptor_Data_Single.toJSON(message.single) : undefined); - message.multi !== undefined && - (obj.multi = message.multi ? SignatureDescriptor_Data_Multi.toJSON(message.multi) : undefined); - return obj; - }, }; const baseSignatureDescriptor_Data_Single: object = { mode: 0 }; export const SignatureDescriptor_Data_Single = { encode(message: SignatureDescriptor_Data_Single, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.mode); - writer.uint32(18).bytes(message.signature); + if (message.mode !== 0) { + writer.uint32(8).int32(message.mode); + } + if (message.signature.length !== 0) { + writer.uint32(18).bytes(message.signature); + } return writer; }, @@ -384,6 +390,16 @@ export const SignatureDescriptor_Data_Single = { return message; }, + toJSON(message: SignatureDescriptor_Data_Single): unknown { + const obj: any = {}; + message.mode !== undefined && (obj.mode = signModeToJSON(message.mode)); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array(), + )); + return obj; + }, + fromPartial(object: DeepPartial): SignatureDescriptor_Data_Single { const message = { ...baseSignatureDescriptor_Data_Single } as SignatureDescriptor_Data_Single; if (object.mode !== undefined && object.mode !== null) { @@ -398,23 +414,13 @@ export const SignatureDescriptor_Data_Single = { } return message; }, - - toJSON(message: SignatureDescriptor_Data_Single): unknown { - const obj: any = {}; - message.mode !== undefined && (obj.mode = signModeToJSON(message.mode)); - message.signature !== undefined && - (obj.signature = base64FromBytes( - message.signature !== undefined ? message.signature : new Uint8Array(), - )); - return obj; - }, }; const baseSignatureDescriptor_Data_Multi: object = {}; export const SignatureDescriptor_Data_Multi = { encode(message: SignatureDescriptor_Data_Multi, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.bitarray !== undefined && message.bitarray !== undefined) { + if (message.bitarray !== undefined) { CompactBitArray.encode(message.bitarray, writer.uint32(10).fork()).ldelim(); } for (const v of message.signatures) { @@ -461,6 +467,18 @@ export const SignatureDescriptor_Data_Multi = { return message; }, + toJSON(message: SignatureDescriptor_Data_Multi): unknown { + const obj: any = {}; + message.bitarray !== undefined && + (obj.bitarray = message.bitarray ? CompactBitArray.toJSON(message.bitarray) : undefined); + if (message.signatures) { + obj.signatures = message.signatures.map((e) => (e ? SignatureDescriptor_Data.toJSON(e) : undefined)); + } else { + obj.signatures = []; + } + return obj; + }, + fromPartial(object: DeepPartial): SignatureDescriptor_Data_Multi { const message = { ...baseSignatureDescriptor_Data_Multi } as SignatureDescriptor_Data_Multi; message.signatures = []; @@ -476,18 +494,6 @@ export const SignatureDescriptor_Data_Multi = { } return message; }, - - toJSON(message: SignatureDescriptor_Data_Multi): unknown { - const obj: any = {}; - message.bitarray !== undefined && - (obj.bitarray = message.bitarray ? CompactBitArray.toJSON(message.bitarray) : undefined); - if (message.signatures) { - obj.signatures = message.signatures.map((e) => (e ? SignatureDescriptor_Data.toJSON(e) : undefined)); - } else { - obj.signatures = []; - } - return obj; - }, }; declare var self: any | undefined; @@ -497,7 +503,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/proto-signing/src/codec/cosmos/tx/v1beta1/tx.ts b/packages/proto-signing/src/codec/cosmos/tx/v1beta1/tx.ts index d9b9750d..5b23d016 100644 --- a/packages/proto-signing/src/codec/cosmos/tx/v1beta1/tx.ts +++ b/packages/proto-signing/src/codec/cosmos/tx/v1beta1/tx.ts @@ -211,10 +211,10 @@ const baseTx: object = {}; export const Tx = { encode(message: Tx, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.body !== undefined && message.body !== undefined) { + if (message.body !== undefined) { TxBody.encode(message.body, writer.uint32(10).fork()).ldelim(); } - if (message.authInfo !== undefined && message.authInfo !== undefined) { + if (message.authInfo !== undefined) { AuthInfo.encode(message.authInfo, writer.uint32(18).fork()).ldelim(); } for (const v of message.signatures) { @@ -269,6 +269,19 @@ export const Tx = { return message; }, + toJSON(message: Tx): unknown { + const obj: any = {}; + message.body !== undefined && (obj.body = message.body ? TxBody.toJSON(message.body) : undefined); + message.authInfo !== undefined && + (obj.authInfo = message.authInfo ? AuthInfo.toJSON(message.authInfo) : undefined); + if (message.signatures) { + obj.signatures = message.signatures.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.signatures = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Tx { const message = { ...baseTx } as Tx; message.signatures = []; @@ -289,27 +302,18 @@ export const Tx = { } return message; }, - - toJSON(message: Tx): unknown { - const obj: any = {}; - message.body !== undefined && (obj.body = message.body ? TxBody.toJSON(message.body) : undefined); - message.authInfo !== undefined && - (obj.authInfo = message.authInfo ? AuthInfo.toJSON(message.authInfo) : undefined); - if (message.signatures) { - obj.signatures = message.signatures.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); - } else { - obj.signatures = []; - } - return obj; - }, }; const baseTxRaw: object = {}; export const TxRaw = { encode(message: TxRaw, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.bodyBytes); - writer.uint32(18).bytes(message.authInfoBytes); + if (message.bodyBytes.length !== 0) { + writer.uint32(10).bytes(message.bodyBytes); + } + if (message.authInfoBytes.length !== 0) { + writer.uint32(18).bytes(message.authInfoBytes); + } for (const v of message.signatures) { writer.uint32(26).bytes(v!); } @@ -358,6 +362,24 @@ export const TxRaw = { return message; }, + toJSON(message: TxRaw): unknown { + const obj: any = {}; + message.bodyBytes !== undefined && + (obj.bodyBytes = base64FromBytes( + message.bodyBytes !== undefined ? message.bodyBytes : new Uint8Array(), + )); + message.authInfoBytes !== undefined && + (obj.authInfoBytes = base64FromBytes( + message.authInfoBytes !== undefined ? message.authInfoBytes : new Uint8Array(), + )); + if (message.signatures) { + obj.signatures = message.signatures.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.signatures = []; + } + return obj; + }, + fromPartial(object: DeepPartial): TxRaw { const message = { ...baseTxRaw } as TxRaw; message.signatures = []; @@ -378,34 +400,24 @@ export const TxRaw = { } return message; }, - - toJSON(message: TxRaw): unknown { - const obj: any = {}; - message.bodyBytes !== undefined && - (obj.bodyBytes = base64FromBytes( - message.bodyBytes !== undefined ? message.bodyBytes : new Uint8Array(), - )); - message.authInfoBytes !== undefined && - (obj.authInfoBytes = base64FromBytes( - message.authInfoBytes !== undefined ? message.authInfoBytes : new Uint8Array(), - )); - if (message.signatures) { - obj.signatures = message.signatures.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); - } else { - obj.signatures = []; - } - return obj; - }, }; const baseSignDoc: object = { chainId: "", accountNumber: Long.UZERO }; export const SignDoc = { encode(message: SignDoc, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.bodyBytes); - writer.uint32(18).bytes(message.authInfoBytes); - writer.uint32(26).string(message.chainId); - writer.uint32(32).uint64(message.accountNumber); + if (message.bodyBytes.length !== 0) { + writer.uint32(10).bytes(message.bodyBytes); + } + if (message.authInfoBytes.length !== 0) { + writer.uint32(18).bytes(message.authInfoBytes); + } + if (message.chainId !== "") { + writer.uint32(26).string(message.chainId); + } + if (!message.accountNumber.isZero()) { + writer.uint32(32).uint64(message.accountNumber); + } return writer; }, @@ -457,6 +469,22 @@ export const SignDoc = { return message; }, + toJSON(message: SignDoc): unknown { + const obj: any = {}; + message.bodyBytes !== undefined && + (obj.bodyBytes = base64FromBytes( + message.bodyBytes !== undefined ? message.bodyBytes : new Uint8Array(), + )); + message.authInfoBytes !== undefined && + (obj.authInfoBytes = base64FromBytes( + message.authInfoBytes !== undefined ? message.authInfoBytes : new Uint8Array(), + )); + message.chainId !== undefined && (obj.chainId = message.chainId); + message.accountNumber !== undefined && + (obj.accountNumber = (message.accountNumber || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): SignDoc { const message = { ...baseSignDoc } as SignDoc; if (object.bodyBytes !== undefined && object.bodyBytes !== null) { @@ -481,22 +509,6 @@ export const SignDoc = { } return message; }, - - toJSON(message: SignDoc): unknown { - const obj: any = {}; - message.bodyBytes !== undefined && - (obj.bodyBytes = base64FromBytes( - message.bodyBytes !== undefined ? message.bodyBytes : new Uint8Array(), - )); - message.authInfoBytes !== undefined && - (obj.authInfoBytes = base64FromBytes( - message.authInfoBytes !== undefined ? message.authInfoBytes : new Uint8Array(), - )); - message.chainId !== undefined && (obj.chainId = message.chainId); - message.accountNumber !== undefined && - (obj.accountNumber = (message.accountNumber || Long.UZERO).toString()); - return obj; - }, }; const baseTxBody: object = { memo: "", timeoutHeight: Long.UZERO }; @@ -506,8 +518,12 @@ export const TxBody = { for (const v of message.messages) { Any.encode(v!, writer.uint32(10).fork()).ldelim(); } - writer.uint32(18).string(message.memo); - writer.uint32(24).uint64(message.timeoutHeight); + if (message.memo !== "") { + writer.uint32(18).string(message.memo); + } + if (!message.timeoutHeight.isZero()) { + writer.uint32(24).uint64(message.timeoutHeight); + } for (const v of message.extensionOptions) { Any.encode(v!, writer.uint32(8186).fork()).ldelim(); } @@ -583,6 +599,31 @@ export const TxBody = { return message; }, + toJSON(message: TxBody): unknown { + const obj: any = {}; + if (message.messages) { + obj.messages = message.messages.map((e) => (e ? Any.toJSON(e) : undefined)); + } else { + obj.messages = []; + } + message.memo !== undefined && (obj.memo = message.memo); + message.timeoutHeight !== undefined && + (obj.timeoutHeight = (message.timeoutHeight || Long.UZERO).toString()); + if (message.extensionOptions) { + obj.extensionOptions = message.extensionOptions.map((e) => (e ? Any.toJSON(e) : undefined)); + } else { + obj.extensionOptions = []; + } + if (message.nonCriticalExtensionOptions) { + obj.nonCriticalExtensionOptions = message.nonCriticalExtensionOptions.map((e) => + e ? Any.toJSON(e) : undefined, + ); + } else { + obj.nonCriticalExtensionOptions = []; + } + return obj; + }, + fromPartial(object: DeepPartial): TxBody { const message = { ...baseTxBody } as TxBody; message.messages = []; @@ -615,31 +656,6 @@ export const TxBody = { } return message; }, - - toJSON(message: TxBody): unknown { - const obj: any = {}; - if (message.messages) { - obj.messages = message.messages.map((e) => (e ? Any.toJSON(e) : undefined)); - } else { - obj.messages = []; - } - message.memo !== undefined && (obj.memo = message.memo); - message.timeoutHeight !== undefined && - (obj.timeoutHeight = (message.timeoutHeight || Long.UZERO).toString()); - if (message.extensionOptions) { - obj.extensionOptions = message.extensionOptions.map((e) => (e ? Any.toJSON(e) : undefined)); - } else { - obj.extensionOptions = []; - } - if (message.nonCriticalExtensionOptions) { - obj.nonCriticalExtensionOptions = message.nonCriticalExtensionOptions.map((e) => - e ? Any.toJSON(e) : undefined, - ); - } else { - obj.nonCriticalExtensionOptions = []; - } - return obj; - }, }; const baseAuthInfo: object = {}; @@ -649,7 +665,7 @@ export const AuthInfo = { for (const v of message.signerInfos) { SignerInfo.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.fee !== undefined && message.fee !== undefined) { + if (message.fee !== undefined) { Fee.encode(message.fee, writer.uint32(18).fork()).ldelim(); } return writer; @@ -693,6 +709,17 @@ export const AuthInfo = { return message; }, + toJSON(message: AuthInfo): unknown { + const obj: any = {}; + if (message.signerInfos) { + obj.signerInfos = message.signerInfos.map((e) => (e ? SignerInfo.toJSON(e) : undefined)); + } else { + obj.signerInfos = []; + } + message.fee !== undefined && (obj.fee = message.fee ? Fee.toJSON(message.fee) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): AuthInfo { const message = { ...baseAuthInfo } as AuthInfo; message.signerInfos = []; @@ -708,30 +735,21 @@ export const AuthInfo = { } return message; }, - - toJSON(message: AuthInfo): unknown { - const obj: any = {}; - if (message.signerInfos) { - obj.signerInfos = message.signerInfos.map((e) => (e ? SignerInfo.toJSON(e) : undefined)); - } else { - obj.signerInfos = []; - } - message.fee !== undefined && (obj.fee = message.fee ? Fee.toJSON(message.fee) : undefined); - return obj; - }, }; const baseSignerInfo: object = { sequence: Long.UZERO }; export const SignerInfo = { encode(message: SignerInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.publicKey !== undefined && message.publicKey !== undefined) { + if (message.publicKey !== undefined) { Any.encode(message.publicKey, writer.uint32(10).fork()).ldelim(); } - if (message.modeInfo !== undefined && message.modeInfo !== undefined) { + if (message.modeInfo !== undefined) { ModeInfo.encode(message.modeInfo, writer.uint32(18).fork()).ldelim(); } - writer.uint32(24).uint64(message.sequence); + if (!message.sequence.isZero()) { + writer.uint32(24).uint64(message.sequence); + } return writer; }, @@ -779,6 +797,16 @@ export const SignerInfo = { return message; }, + toJSON(message: SignerInfo): unknown { + const obj: any = {}; + message.publicKey !== undefined && + (obj.publicKey = message.publicKey ? Any.toJSON(message.publicKey) : undefined); + message.modeInfo !== undefined && + (obj.modeInfo = message.modeInfo ? ModeInfo.toJSON(message.modeInfo) : undefined); + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): SignerInfo { const message = { ...baseSignerInfo } as SignerInfo; if (object.publicKey !== undefined && object.publicKey !== null) { @@ -798,16 +826,6 @@ export const SignerInfo = { } return message; }, - - toJSON(message: SignerInfo): unknown { - const obj: any = {}; - message.publicKey !== undefined && - (obj.publicKey = message.publicKey ? Any.toJSON(message.publicKey) : undefined); - message.modeInfo !== undefined && - (obj.modeInfo = message.modeInfo ? ModeInfo.toJSON(message.modeInfo) : undefined); - message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); - return obj; - }, }; const baseModeInfo: object = {}; @@ -859,6 +877,15 @@ export const ModeInfo = { return message; }, + toJSON(message: ModeInfo): unknown { + const obj: any = {}; + message.single !== undefined && + (obj.single = message.single ? ModeInfo_Single.toJSON(message.single) : undefined); + message.multi !== undefined && + (obj.multi = message.multi ? ModeInfo_Multi.toJSON(message.multi) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ModeInfo { const message = { ...baseModeInfo } as ModeInfo; if (object.single !== undefined && object.single !== null) { @@ -873,22 +900,15 @@ export const ModeInfo = { } return message; }, - - toJSON(message: ModeInfo): unknown { - const obj: any = {}; - message.single !== undefined && - (obj.single = message.single ? ModeInfo_Single.toJSON(message.single) : undefined); - message.multi !== undefined && - (obj.multi = message.multi ? ModeInfo_Multi.toJSON(message.multi) : undefined); - return obj; - }, }; const baseModeInfo_Single: object = { mode: 0 }; export const ModeInfo_Single = { encode(message: ModeInfo_Single, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.mode); + if (message.mode !== 0) { + writer.uint32(8).int32(message.mode); + } return writer; }, @@ -920,6 +940,12 @@ export const ModeInfo_Single = { return message; }, + toJSON(message: ModeInfo_Single): unknown { + const obj: any = {}; + message.mode !== undefined && (obj.mode = signModeToJSON(message.mode)); + return obj; + }, + fromPartial(object: DeepPartial): ModeInfo_Single { const message = { ...baseModeInfo_Single } as ModeInfo_Single; if (object.mode !== undefined && object.mode !== null) { @@ -929,19 +955,13 @@ export const ModeInfo_Single = { } return message; }, - - toJSON(message: ModeInfo_Single): unknown { - const obj: any = {}; - message.mode !== undefined && (obj.mode = signModeToJSON(message.mode)); - return obj; - }, }; const baseModeInfo_Multi: object = {}; export const ModeInfo_Multi = { encode(message: ModeInfo_Multi, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.bitarray !== undefined && message.bitarray !== undefined) { + if (message.bitarray !== undefined) { CompactBitArray.encode(message.bitarray, writer.uint32(10).fork()).ldelim(); } for (const v of message.modeInfos) { @@ -988,6 +1008,18 @@ export const ModeInfo_Multi = { return message; }, + toJSON(message: ModeInfo_Multi): unknown { + const obj: any = {}; + message.bitarray !== undefined && + (obj.bitarray = message.bitarray ? CompactBitArray.toJSON(message.bitarray) : undefined); + if (message.modeInfos) { + obj.modeInfos = message.modeInfos.map((e) => (e ? ModeInfo.toJSON(e) : undefined)); + } else { + obj.modeInfos = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ModeInfo_Multi { const message = { ...baseModeInfo_Multi } as ModeInfo_Multi; message.modeInfos = []; @@ -1003,18 +1035,6 @@ export const ModeInfo_Multi = { } return message; }, - - toJSON(message: ModeInfo_Multi): unknown { - const obj: any = {}; - message.bitarray !== undefined && - (obj.bitarray = message.bitarray ? CompactBitArray.toJSON(message.bitarray) : undefined); - if (message.modeInfos) { - obj.modeInfos = message.modeInfos.map((e) => (e ? ModeInfo.toJSON(e) : undefined)); - } else { - obj.modeInfos = []; - } - return obj; - }, }; const baseFee: object = { gasLimit: Long.UZERO, payer: "", granter: "" }; @@ -1024,9 +1044,15 @@ export const Fee = { for (const v of message.amount) { Coin.encode(v!, writer.uint32(10).fork()).ldelim(); } - writer.uint32(16).uint64(message.gasLimit); - writer.uint32(26).string(message.payer); - writer.uint32(34).string(message.granter); + if (!message.gasLimit.isZero()) { + writer.uint32(16).uint64(message.gasLimit); + } + if (message.payer !== "") { + writer.uint32(26).string(message.payer); + } + if (message.granter !== "") { + writer.uint32(34).string(message.granter); + } return writer; }, @@ -1084,6 +1110,19 @@ export const Fee = { return message; }, + toJSON(message: Fee): unknown { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.amount = []; + } + message.gasLimit !== undefined && (obj.gasLimit = (message.gasLimit || Long.UZERO).toString()); + message.payer !== undefined && (obj.payer = message.payer); + message.granter !== undefined && (obj.granter = message.granter); + return obj; + }, + fromPartial(object: DeepPartial): Fee { const message = { ...baseFee } as Fee; message.amount = []; @@ -1109,19 +1148,6 @@ export const Fee = { } return message; }, - - toJSON(message: Fee): unknown { - const obj: any = {}; - if (message.amount) { - obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); - } else { - obj.amount = []; - } - message.gasLimit !== undefined && (obj.gasLimit = (message.gasLimit || Long.UZERO).toString()); - message.payer !== undefined && (obj.payer = message.payer); - message.granter !== undefined && (obj.granter = message.granter); - return obj; - }, }; declare var self: any | undefined; @@ -1131,7 +1157,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/proto-signing/src/codec/google/protobuf/any.ts b/packages/proto-signing/src/codec/google/protobuf/any.ts index 7e728b6c..80a855cc 100644 --- a/packages/proto-signing/src/codec/google/protobuf/any.ts +++ b/packages/proto-signing/src/codec/google/protobuf/any.ts @@ -124,8 +124,12 @@ const baseAny: object = { typeUrl: "" }; export const Any = { encode(message: Any, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.typeUrl); - writer.uint32(18).bytes(message.value); + if (message.typeUrl !== "") { + writer.uint32(10).string(message.typeUrl); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } return writer; }, @@ -163,6 +167,14 @@ export const Any = { return message; }, + toJSON(message: Any): unknown { + const obj: any = {}; + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + message.value !== undefined && + (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): Any { const message = { ...baseAny } as Any; if (object.typeUrl !== undefined && object.typeUrl !== null) { @@ -177,14 +189,6 @@ export const Any = { } return message; }, - - toJSON(message: Any): unknown { - const obj: any = {}; - message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); - message.value !== undefined && - (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); - return obj; - }, }; declare var self: any | undefined; @@ -194,7 +198,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/proto-signing/src/codec/google/protobuf/descriptor.ts b/packages/proto-signing/src/codec/google/protobuf/descriptor.ts index 9b231ad7..1b4f692c 100644 --- a/packages/proto-signing/src/codec/google/protobuf/descriptor.ts +++ b/packages/proto-signing/src/codec/google/protobuf/descriptor.ts @@ -1152,6 +1152,16 @@ export const FileDescriptorSet = { return message; }, + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => (e ? FileDescriptorProto.toJSON(e) : undefined)); + } else { + obj.file = []; + } + return obj; + }, + fromPartial(object: DeepPartial): FileDescriptorSet { const message = { ...baseFileDescriptorSet } as FileDescriptorSet; message.file = []; @@ -1162,16 +1172,6 @@ export const FileDescriptorSet = { } return message; }, - - toJSON(message: FileDescriptorSet): unknown { - const obj: any = {}; - if (message.file) { - obj.file = message.file.map((e) => (e ? FileDescriptorProto.toJSON(e) : undefined)); - } else { - obj.file = []; - } - return obj; - }, }; const baseFileDescriptorProto: object = { @@ -1185,8 +1185,12 @@ const baseFileDescriptorProto: object = { export const FileDescriptorProto = { encode(message: FileDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.name); - writer.uint32(18).string(message.package); + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } for (const v of message.dependency) { writer.uint32(26).string(v!); } @@ -1212,13 +1216,15 @@ export const FileDescriptorProto = { for (const v of message.extension) { FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); } - if (message.options !== undefined && message.options !== undefined) { + if (message.options !== undefined) { FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); } - if (message.sourceCodeInfo !== undefined && message.sourceCodeInfo !== undefined) { + if (message.sourceCodeInfo !== undefined) { SourceCodeInfo.encode(message.sourceCodeInfo, writer.uint32(74).fork()).ldelim(); } - writer.uint32(98).string(message.syntax); + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } return writer; }, @@ -1366,6 +1372,55 @@ export const FileDescriptorProto = { return message; }, + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => (e ? DescriptorProto.toJSON(e) : undefined)); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => (e ? EnumDescriptorProto.toJSON(e) : undefined)); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => (e ? ServiceDescriptorProto.toJSON(e) : undefined)); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => (e ? FieldDescriptorProto.toJSON(e) : undefined)); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options ? FileOptions.toJSON(message.options) : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + fromPartial(object: DeepPartial): FileDescriptorProto { const message = { ...baseFileDescriptorProto } as FileDescriptorProto; message.dependency = []; @@ -1437,62 +1492,15 @@ export const FileDescriptorProto = { } return message; }, - - toJSON(message: FileDescriptorProto): unknown { - const obj: any = {}; - message.name !== undefined && (obj.name = message.name); - message.package !== undefined && (obj.package = message.package); - if (message.dependency) { - obj.dependency = message.dependency.map((e) => e); - } else { - obj.dependency = []; - } - if (message.publicDependency) { - obj.publicDependency = message.publicDependency.map((e) => e); - } else { - obj.publicDependency = []; - } - if (message.weakDependency) { - obj.weakDependency = message.weakDependency.map((e) => e); - } else { - obj.weakDependency = []; - } - if (message.messageType) { - obj.messageType = message.messageType.map((e) => (e ? DescriptorProto.toJSON(e) : undefined)); - } else { - obj.messageType = []; - } - if (message.enumType) { - obj.enumType = message.enumType.map((e) => (e ? EnumDescriptorProto.toJSON(e) : undefined)); - } else { - obj.enumType = []; - } - if (message.service) { - obj.service = message.service.map((e) => (e ? ServiceDescriptorProto.toJSON(e) : undefined)); - } else { - obj.service = []; - } - if (message.extension) { - obj.extension = message.extension.map((e) => (e ? FieldDescriptorProto.toJSON(e) : undefined)); - } else { - obj.extension = []; - } - message.options !== undefined && - (obj.options = message.options ? FileOptions.toJSON(message.options) : undefined); - message.sourceCodeInfo !== undefined && - (obj.sourceCodeInfo = message.sourceCodeInfo - ? SourceCodeInfo.toJSON(message.sourceCodeInfo) - : undefined); - message.syntax !== undefined && (obj.syntax = message.syntax); - return obj; - }, }; const baseDescriptorProto: object = { name: "", reservedName: "" }; export const DescriptorProto = { encode(message: DescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.name); + if (message.name !== "") { + writer.uint32(10).string(message.name); + } for (const v of message.field) { FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); } @@ -1511,7 +1519,7 @@ export const DescriptorProto = { for (const v of message.oneofDecl) { OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); } - if (message.options !== undefined && message.options !== undefined) { + if (message.options !== undefined) { MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); } for (const v of message.reservedRange) { @@ -1639,6 +1647,58 @@ export const DescriptorProto = { return message; }, + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => (e ? FieldDescriptorProto.toJSON(e) : undefined)); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => (e ? FieldDescriptorProto.toJSON(e) : undefined)); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => (e ? DescriptorProto.toJSON(e) : undefined)); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => (e ? EnumDescriptorProto.toJSON(e) : undefined)); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined, + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => (e ? OneofDescriptorProto.toJSON(e) : undefined)); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options ? MessageOptions.toJSON(message.options) : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined, + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + fromPartial(object: DeepPartial): DescriptorProto { const message = { ...baseDescriptorProto } as DescriptorProto; message.field = []; @@ -1701,67 +1761,19 @@ export const DescriptorProto = { } return message; }, - - toJSON(message: DescriptorProto): unknown { - const obj: any = {}; - message.name !== undefined && (obj.name = message.name); - if (message.field) { - obj.field = message.field.map((e) => (e ? FieldDescriptorProto.toJSON(e) : undefined)); - } else { - obj.field = []; - } - if (message.extension) { - obj.extension = message.extension.map((e) => (e ? FieldDescriptorProto.toJSON(e) : undefined)); - } else { - obj.extension = []; - } - if (message.nestedType) { - obj.nestedType = message.nestedType.map((e) => (e ? DescriptorProto.toJSON(e) : undefined)); - } else { - obj.nestedType = []; - } - if (message.enumType) { - obj.enumType = message.enumType.map((e) => (e ? EnumDescriptorProto.toJSON(e) : undefined)); - } else { - obj.enumType = []; - } - if (message.extensionRange) { - obj.extensionRange = message.extensionRange.map((e) => - e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined, - ); - } else { - obj.extensionRange = []; - } - if (message.oneofDecl) { - obj.oneofDecl = message.oneofDecl.map((e) => (e ? OneofDescriptorProto.toJSON(e) : undefined)); - } else { - obj.oneofDecl = []; - } - message.options !== undefined && - (obj.options = message.options ? MessageOptions.toJSON(message.options) : undefined); - if (message.reservedRange) { - obj.reservedRange = message.reservedRange.map((e) => - e ? DescriptorProto_ReservedRange.toJSON(e) : undefined, - ); - } else { - obj.reservedRange = []; - } - if (message.reservedName) { - obj.reservedName = message.reservedName.map((e) => e); - } else { - obj.reservedName = []; - } - return obj; - }, }; const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; export const DescriptorProto_ExtensionRange = { encode(message: DescriptorProto_ExtensionRange, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.start); - writer.uint32(16).int32(message.end); - if (message.options !== undefined && message.options !== undefined) { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { ExtensionRangeOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); } return writer; @@ -1811,6 +1823,15 @@ export const DescriptorProto_ExtensionRange = { return message; }, + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options ? ExtensionRangeOptions.toJSON(message.options) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): DescriptorProto_ExtensionRange { const message = { ...baseDescriptorProto_ExtensionRange } as DescriptorProto_ExtensionRange; if (object.start !== undefined && object.start !== null) { @@ -1830,23 +1851,18 @@ export const DescriptorProto_ExtensionRange = { } return message; }, - - toJSON(message: DescriptorProto_ExtensionRange): unknown { - const obj: any = {}; - message.start !== undefined && (obj.start = message.start); - message.end !== undefined && (obj.end = message.end); - message.options !== undefined && - (obj.options = message.options ? ExtensionRangeOptions.toJSON(message.options) : undefined); - return obj; - }, }; const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; export const DescriptorProto_ReservedRange = { encode(message: DescriptorProto_ReservedRange, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.start); - writer.uint32(16).int32(message.end); + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } return writer; }, @@ -1886,6 +1902,13 @@ export const DescriptorProto_ReservedRange = { return message; }, + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + fromPartial(object: DeepPartial): DescriptorProto_ReservedRange { const message = { ...baseDescriptorProto_ReservedRange } as DescriptorProto_ReservedRange; if (object.start !== undefined && object.start !== null) { @@ -1900,13 +1923,6 @@ export const DescriptorProto_ReservedRange = { } return message; }, - - toJSON(message: DescriptorProto_ReservedRange): unknown { - const obj: any = {}; - message.start !== undefined && (obj.start = message.start); - message.end !== undefined && (obj.end = message.end); - return obj; - }, }; const baseExtensionRangeOptions: object = {}; @@ -1949,17 +1965,6 @@ export const ExtensionRangeOptions = { return message; }, - fromPartial(object: DeepPartial): ExtensionRangeOptions { - const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; - message.uninterpretedOption = []; - if (object.uninterpretedOption !== undefined && object.uninterpretedOption !== null) { - for (const e of object.uninterpretedOption) { - message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); - } - } - return message; - }, - toJSON(message: ExtensionRangeOptions): unknown { const obj: any = {}; if (message.uninterpretedOption) { @@ -1971,6 +1976,17 @@ export const ExtensionRangeOptions = { } return obj; }, + + fromPartial(object: DeepPartial): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if (object.uninterpretedOption !== undefined && object.uninterpretedOption !== null) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, }; const baseFieldDescriptorProto: object = { @@ -1988,19 +2004,39 @@ const baseFieldDescriptorProto: object = { export const FieldDescriptorProto = { encode(message: FieldDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.name); - writer.uint32(24).int32(message.number); - writer.uint32(32).int32(message.label); - writer.uint32(40).int32(message.type); - writer.uint32(50).string(message.typeName); - writer.uint32(18).string(message.extendee); - writer.uint32(58).string(message.defaultValue); - writer.uint32(72).int32(message.oneofIndex); - writer.uint32(82).string(message.jsonName); - if (message.options !== undefined && message.options !== undefined) { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); } - writer.uint32(136).bool(message.proto3Optional); + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } return writer; }, @@ -2112,6 +2148,23 @@ export const FieldDescriptorProto = { return message; }, + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options ? FieldOptions.toJSON(message.options) : undefined); + message.proto3Optional !== undefined && (obj.proto3Optional = message.proto3Optional); + return obj; + }, + fromPartial(object: DeepPartial): FieldDescriptorProto { const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; if (object.name !== undefined && object.name !== null) { @@ -2171,31 +2224,16 @@ export const FieldDescriptorProto = { } return message; }, - - toJSON(message: FieldDescriptorProto): unknown { - const obj: any = {}; - message.name !== undefined && (obj.name = message.name); - message.number !== undefined && (obj.number = message.number); - message.label !== undefined && (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); - message.type !== undefined && (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); - message.typeName !== undefined && (obj.typeName = message.typeName); - message.extendee !== undefined && (obj.extendee = message.extendee); - message.defaultValue !== undefined && (obj.defaultValue = message.defaultValue); - message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); - message.jsonName !== undefined && (obj.jsonName = message.jsonName); - message.options !== undefined && - (obj.options = message.options ? FieldOptions.toJSON(message.options) : undefined); - message.proto3Optional !== undefined && (obj.proto3Optional = message.proto3Optional); - return obj; - }, }; const baseOneofDescriptorProto: object = { name: "" }; export const OneofDescriptorProto = { encode(message: OneofDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.name); - if (message.options !== undefined && message.options !== undefined) { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); } return writer; @@ -2237,6 +2275,14 @@ export const OneofDescriptorProto = { return message; }, + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options ? OneofOptions.toJSON(message.options) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): OneofDescriptorProto { const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; if (object.name !== undefined && object.name !== null) { @@ -2251,25 +2297,19 @@ export const OneofDescriptorProto = { } return message; }, - - toJSON(message: OneofDescriptorProto): unknown { - const obj: any = {}; - message.name !== undefined && (obj.name = message.name); - message.options !== undefined && - (obj.options = message.options ? OneofOptions.toJSON(message.options) : undefined); - return obj; - }, }; const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; export const EnumDescriptorProto = { encode(message: EnumDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.name); + if (message.name !== "") { + writer.uint32(10).string(message.name); + } for (const v of message.value) { EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); } - if (message.options !== undefined && message.options !== undefined) { + if (message.options !== undefined) { EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); } for (const v of message.reservedRange) { @@ -2347,6 +2387,31 @@ export const EnumDescriptorProto = { return message; }, + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => (e ? EnumValueDescriptorProto.toJSON(e) : undefined)); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options ? EnumOptions.toJSON(message.options) : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined, + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + fromPartial(object: DeepPartial): EnumDescriptorProto { const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; message.value = []; @@ -2379,31 +2444,6 @@ export const EnumDescriptorProto = { } return message; }, - - toJSON(message: EnumDescriptorProto): unknown { - const obj: any = {}; - message.name !== undefined && (obj.name = message.name); - if (message.value) { - obj.value = message.value.map((e) => (e ? EnumValueDescriptorProto.toJSON(e) : undefined)); - } else { - obj.value = []; - } - message.options !== undefined && - (obj.options = message.options ? EnumOptions.toJSON(message.options) : undefined); - if (message.reservedRange) { - obj.reservedRange = message.reservedRange.map((e) => - e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined, - ); - } else { - obj.reservedRange = []; - } - if (message.reservedName) { - obj.reservedName = message.reservedName.map((e) => e); - } else { - obj.reservedName = []; - } - return obj; - }, }; const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; @@ -2413,8 +2453,12 @@ export const EnumDescriptorProto_EnumReservedRange = { message: EnumDescriptorProto_EnumReservedRange, writer: _m0.Writer = _m0.Writer.create(), ): _m0.Writer { - writer.uint32(8).int32(message.start); - writer.uint32(16).int32(message.end); + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } return writer; }, @@ -2454,6 +2498,13 @@ export const EnumDescriptorProto_EnumReservedRange = { return message; }, + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + fromPartial( object: DeepPartial, ): EnumDescriptorProto_EnumReservedRange { @@ -2470,22 +2521,19 @@ export const EnumDescriptorProto_EnumReservedRange = { } return message; }, - - toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { - const obj: any = {}; - message.start !== undefined && (obj.start = message.start); - message.end !== undefined && (obj.end = message.end); - return obj; - }, }; const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; export const EnumValueDescriptorProto = { encode(message: EnumValueDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.name); - writer.uint32(16).int32(message.number); - if (message.options !== undefined && message.options !== undefined) { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { EnumValueOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); } return writer; @@ -2535,6 +2583,15 @@ export const EnumValueDescriptorProto = { return message; }, + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options ? EnumValueOptions.toJSON(message.options) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): EnumValueDescriptorProto { const message = { ...baseEnumValueDescriptorProto } as EnumValueDescriptorProto; if (object.name !== undefined && object.name !== null) { @@ -2554,26 +2611,19 @@ export const EnumValueDescriptorProto = { } return message; }, - - toJSON(message: EnumValueDescriptorProto): unknown { - const obj: any = {}; - message.name !== undefined && (obj.name = message.name); - message.number !== undefined && (obj.number = message.number); - message.options !== undefined && - (obj.options = message.options ? EnumValueOptions.toJSON(message.options) : undefined); - return obj; - }, }; const baseServiceDescriptorProto: object = { name: "" }; export const ServiceDescriptorProto = { encode(message: ServiceDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.name); + if (message.name !== "") { + writer.uint32(10).string(message.name); + } for (const v of message.method) { MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); } - if (message.options !== undefined && message.options !== undefined) { + if (message.options !== undefined) { ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); } return writer; @@ -2625,6 +2675,19 @@ export const ServiceDescriptorProto = { return message; }, + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => (e ? MethodDescriptorProto.toJSON(e) : undefined)); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options ? ServiceOptions.toJSON(message.options) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ServiceDescriptorProto { const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; message.method = []; @@ -2645,19 +2708,6 @@ export const ServiceDescriptorProto = { } return message; }, - - toJSON(message: ServiceDescriptorProto): unknown { - const obj: any = {}; - message.name !== undefined && (obj.name = message.name); - if (message.method) { - obj.method = message.method.map((e) => (e ? MethodDescriptorProto.toJSON(e) : undefined)); - } else { - obj.method = []; - } - message.options !== undefined && - (obj.options = message.options ? ServiceOptions.toJSON(message.options) : undefined); - return obj; - }, }; const baseMethodDescriptorProto: object = { @@ -2670,14 +2720,24 @@ const baseMethodDescriptorProto: object = { export const MethodDescriptorProto = { encode(message: MethodDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.name); - writer.uint32(18).string(message.inputType); - writer.uint32(26).string(message.outputType); - if (message.options !== undefined && message.options !== undefined) { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); } - writer.uint32(40).bool(message.clientStreaming); - writer.uint32(48).bool(message.serverStreaming); + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } return writer; }, @@ -2749,6 +2809,18 @@ export const MethodDescriptorProto = { return message; }, + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options ? MethodOptions.toJSON(message.options) : undefined); + message.clientStreaming !== undefined && (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && (obj.serverStreaming = message.serverStreaming); + return obj; + }, + fromPartial(object: DeepPartial): MethodDescriptorProto { const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; if (object.name !== undefined && object.name !== null) { @@ -2783,18 +2855,6 @@ export const MethodDescriptorProto = { } return message; }, - - toJSON(message: MethodDescriptorProto): unknown { - const obj: any = {}; - message.name !== undefined && (obj.name = message.name); - message.inputType !== undefined && (obj.inputType = message.inputType); - message.outputType !== undefined && (obj.outputType = message.outputType); - message.options !== undefined && - (obj.options = message.options ? MethodOptions.toJSON(message.options) : undefined); - message.clientStreaming !== undefined && (obj.clientStreaming = message.clientStreaming); - message.serverStreaming !== undefined && (obj.serverStreaming = message.serverStreaming); - return obj; - }, }; const baseFileOptions: object = { @@ -2822,26 +2882,66 @@ const baseFileOptions: object = { export const FileOptions = { encode(message: FileOptions, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.javaPackage); - writer.uint32(66).string(message.javaOuterClassname); - writer.uint32(80).bool(message.javaMultipleFiles); - writer.uint32(160).bool(message.javaGenerateEqualsAndHash); - writer.uint32(216).bool(message.javaStringCheckUtf8); - writer.uint32(72).int32(message.optimizeFor); - writer.uint32(90).string(message.goPackage); - writer.uint32(128).bool(message.ccGenericServices); - writer.uint32(136).bool(message.javaGenericServices); - writer.uint32(144).bool(message.pyGenericServices); - writer.uint32(336).bool(message.phpGenericServices); - writer.uint32(184).bool(message.deprecated); - writer.uint32(248).bool(message.ccEnableArenas); - writer.uint32(290).string(message.objcClassPrefix); - writer.uint32(298).string(message.csharpNamespace); - writer.uint32(314).string(message.swiftPrefix); - writer.uint32(322).string(message.phpClassPrefix); - writer.uint32(330).string(message.phpNamespace); - writer.uint32(354).string(message.phpMetadataNamespace); - writer.uint32(362).string(message.rubyPackage); + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } for (const v of message.uninterpretedOption) { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } @@ -3038,6 +3138,40 @@ export const FileOptions = { return message; }, + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined, + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + fromPartial(object: DeepPartial): FileOptions { const message = { ...baseFileOptions } as FileOptions; message.uninterpretedOption = []; @@ -3148,40 +3282,6 @@ export const FileOptions = { } return message; }, - - toJSON(message: FileOptions): unknown { - const obj: any = {}; - message.javaPackage !== undefined && (obj.javaPackage = message.javaPackage); - message.javaOuterClassname !== undefined && (obj.javaOuterClassname = message.javaOuterClassname); - message.javaMultipleFiles !== undefined && (obj.javaMultipleFiles = message.javaMultipleFiles); - message.javaGenerateEqualsAndHash !== undefined && - (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); - message.javaStringCheckUtf8 !== undefined && (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); - message.optimizeFor !== undefined && - (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); - message.goPackage !== undefined && (obj.goPackage = message.goPackage); - message.ccGenericServices !== undefined && (obj.ccGenericServices = message.ccGenericServices); - message.javaGenericServices !== undefined && (obj.javaGenericServices = message.javaGenericServices); - message.pyGenericServices !== undefined && (obj.pyGenericServices = message.pyGenericServices); - message.phpGenericServices !== undefined && (obj.phpGenericServices = message.phpGenericServices); - message.deprecated !== undefined && (obj.deprecated = message.deprecated); - message.ccEnableArenas !== undefined && (obj.ccEnableArenas = message.ccEnableArenas); - message.objcClassPrefix !== undefined && (obj.objcClassPrefix = message.objcClassPrefix); - message.csharpNamespace !== undefined && (obj.csharpNamespace = message.csharpNamespace); - message.swiftPrefix !== undefined && (obj.swiftPrefix = message.swiftPrefix); - message.phpClassPrefix !== undefined && (obj.phpClassPrefix = message.phpClassPrefix); - message.phpNamespace !== undefined && (obj.phpNamespace = message.phpNamespace); - message.phpMetadataNamespace !== undefined && (obj.phpMetadataNamespace = message.phpMetadataNamespace); - message.rubyPackage !== undefined && (obj.rubyPackage = message.rubyPackage); - if (message.uninterpretedOption) { - obj.uninterpretedOption = message.uninterpretedOption.map((e) => - e ? UninterpretedOption.toJSON(e) : undefined, - ); - } else { - obj.uninterpretedOption = []; - } - return obj; - }, }; const baseMessageOptions: object = { @@ -3193,10 +3293,18 @@ const baseMessageOptions: object = { export const MessageOptions = { encode(message: MessageOptions, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).bool(message.messageSetWireFormat); - writer.uint32(16).bool(message.noStandardDescriptorAccessor); - writer.uint32(24).bool(message.deprecated); - writer.uint32(56).bool(message.mapEntry); + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } for (const v of message.uninterpretedOption) { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } @@ -3265,6 +3373,23 @@ export const MessageOptions = { return message; }, + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined, + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MessageOptions { const message = { ...baseMessageOptions } as MessageOptions; message.uninterpretedOption = []; @@ -3295,23 +3420,6 @@ export const MessageOptions = { } return message; }, - - toJSON(message: MessageOptions): unknown { - const obj: any = {}; - message.messageSetWireFormat !== undefined && (obj.messageSetWireFormat = message.messageSetWireFormat); - message.noStandardDescriptorAccessor !== undefined && - (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); - message.deprecated !== undefined && (obj.deprecated = message.deprecated); - message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); - if (message.uninterpretedOption) { - obj.uninterpretedOption = message.uninterpretedOption.map((e) => - e ? UninterpretedOption.toJSON(e) : undefined, - ); - } else { - obj.uninterpretedOption = []; - } - return obj; - }, }; const baseFieldOptions: object = { @@ -3325,12 +3433,24 @@ const baseFieldOptions: object = { export const FieldOptions = { encode(message: FieldOptions, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.ctype); - writer.uint32(16).bool(message.packed); - writer.uint32(48).int32(message.jstype); - writer.uint32(40).bool(message.lazy); - writer.uint32(24).bool(message.deprecated); - writer.uint32(80).bool(message.weak); + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } for (const v of message.uninterpretedOption) { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } @@ -3415,6 +3535,24 @@ export const FieldOptions = { return message; }, + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined, + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + fromPartial(object: DeepPartial): FieldOptions { const message = { ...baseFieldOptions } as FieldOptions; message.uninterpretedOption = []; @@ -3455,24 +3593,6 @@ export const FieldOptions = { } return message; }, - - toJSON(message: FieldOptions): unknown { - const obj: any = {}; - message.ctype !== undefined && (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); - message.packed !== undefined && (obj.packed = message.packed); - message.jstype !== undefined && (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); - message.lazy !== undefined && (obj.lazy = message.lazy); - message.deprecated !== undefined && (obj.deprecated = message.deprecated); - message.weak !== undefined && (obj.weak = message.weak); - if (message.uninterpretedOption) { - obj.uninterpretedOption = message.uninterpretedOption.map((e) => - e ? UninterpretedOption.toJSON(e) : undefined, - ); - } else { - obj.uninterpretedOption = []; - } - return obj; - }, }; const baseOneofOptions: object = {}; @@ -3515,17 +3635,6 @@ export const OneofOptions = { return message; }, - fromPartial(object: DeepPartial): OneofOptions { - const message = { ...baseOneofOptions } as OneofOptions; - message.uninterpretedOption = []; - if (object.uninterpretedOption !== undefined && object.uninterpretedOption !== null) { - for (const e of object.uninterpretedOption) { - message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); - } - } - return message; - }, - toJSON(message: OneofOptions): unknown { const obj: any = {}; if (message.uninterpretedOption) { @@ -3537,14 +3646,29 @@ export const OneofOptions = { } return obj; }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if (object.uninterpretedOption !== undefined && object.uninterpretedOption !== null) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, }; const baseEnumOptions: object = { allowAlias: false, deprecated: false }; export const EnumOptions = { encode(message: EnumOptions, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(16).bool(message.allowAlias); - writer.uint32(24).bool(message.deprecated); + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } for (const v of message.uninterpretedOption) { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } @@ -3597,6 +3721,20 @@ export const EnumOptions = { return message; }, + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined, + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + fromPartial(object: DeepPartial): EnumOptions { const message = { ...baseEnumOptions } as EnumOptions; message.uninterpretedOption = []; @@ -3617,27 +3755,15 @@ export const EnumOptions = { } return message; }, - - toJSON(message: EnumOptions): unknown { - const obj: any = {}; - message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); - message.deprecated !== undefined && (obj.deprecated = message.deprecated); - if (message.uninterpretedOption) { - obj.uninterpretedOption = message.uninterpretedOption.map((e) => - e ? UninterpretedOption.toJSON(e) : undefined, - ); - } else { - obj.uninterpretedOption = []; - } - return obj; - }, }; const baseEnumValueOptions: object = { deprecated: false }; export const EnumValueOptions = { encode(message: EnumValueOptions, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).bool(message.deprecated); + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } for (const v of message.uninterpretedOption) { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } @@ -3682,6 +3808,19 @@ export const EnumValueOptions = { return message; }, + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined, + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + fromPartial(object: DeepPartial): EnumValueOptions { const message = { ...baseEnumValueOptions } as EnumValueOptions; message.uninterpretedOption = []; @@ -3697,26 +3836,15 @@ export const EnumValueOptions = { } return message; }, - - toJSON(message: EnumValueOptions): unknown { - const obj: any = {}; - message.deprecated !== undefined && (obj.deprecated = message.deprecated); - if (message.uninterpretedOption) { - obj.uninterpretedOption = message.uninterpretedOption.map((e) => - e ? UninterpretedOption.toJSON(e) : undefined, - ); - } else { - obj.uninterpretedOption = []; - } - return obj; - }, }; const baseServiceOptions: object = { deprecated: false }; export const ServiceOptions = { encode(message: ServiceOptions, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(264).bool(message.deprecated); + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } for (const v of message.uninterpretedOption) { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } @@ -3761,6 +3889,19 @@ export const ServiceOptions = { return message; }, + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined, + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ServiceOptions { const message = { ...baseServiceOptions } as ServiceOptions; message.uninterpretedOption = []; @@ -3776,27 +3917,18 @@ export const ServiceOptions = { } return message; }, - - toJSON(message: ServiceOptions): unknown { - const obj: any = {}; - message.deprecated !== undefined && (obj.deprecated = message.deprecated); - if (message.uninterpretedOption) { - obj.uninterpretedOption = message.uninterpretedOption.map((e) => - e ? UninterpretedOption.toJSON(e) : undefined, - ); - } else { - obj.uninterpretedOption = []; - } - return obj; - }, }; const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; export const MethodOptions = { encode(message: MethodOptions, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(264).bool(message.deprecated); - writer.uint32(272).int32(message.idempotencyLevel); + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } for (const v of message.uninterpretedOption) { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } @@ -3849,6 +3981,21 @@ export const MethodOptions = { return message; }, + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON(message.idempotencyLevel)); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined, + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MethodOptions { const message = { ...baseMethodOptions } as MethodOptions; message.uninterpretedOption = []; @@ -3869,21 +4016,6 @@ export const MethodOptions = { } return message; }, - - toJSON(message: MethodOptions): unknown { - const obj: any = {}; - message.deprecated !== undefined && (obj.deprecated = message.deprecated); - message.idempotencyLevel !== undefined && - (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON(message.idempotencyLevel)); - if (message.uninterpretedOption) { - obj.uninterpretedOption = message.uninterpretedOption.map((e) => - e ? UninterpretedOption.toJSON(e) : undefined, - ); - } else { - obj.uninterpretedOption = []; - } - return obj; - }, }; const baseUninterpretedOption: object = { @@ -3899,12 +4031,24 @@ export const UninterpretedOption = { for (const v of message.name) { UninterpretedOption_NamePart.encode(v!, writer.uint32(18).fork()).ldelim(); } - writer.uint32(26).string(message.identifierValue); - writer.uint32(32).uint64(message.positiveIntValue); - writer.uint32(40).int64(message.negativeIntValue); - writer.uint32(49).double(message.doubleValue); - writer.uint32(58).bytes(message.stringValue); - writer.uint32(66).string(message.aggregateValue); + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (!message.positiveIntValue.isZero()) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (!message.negativeIntValue.isZero()) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } return writer; }, @@ -3984,6 +4128,27 @@ export const UninterpretedOption = { return message; }, + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => (e ? UninterpretedOption_NamePart.toJSON(e) : undefined)); + } else { + obj.name = []; + } + message.identifierValue !== undefined && (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = (message.positiveIntValue || Long.UZERO).toString()); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = (message.negativeIntValue || Long.ZERO).toString()); + message.doubleValue !== undefined && (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined ? message.stringValue : new Uint8Array(), + )); + message.aggregateValue !== undefined && (obj.aggregateValue = message.aggregateValue); + return obj; + }, + fromPartial(object: DeepPartial): UninterpretedOption { const message = { ...baseUninterpretedOption } as UninterpretedOption; message.name = []; @@ -4024,35 +4189,18 @@ export const UninterpretedOption = { } return message; }, - - toJSON(message: UninterpretedOption): unknown { - const obj: any = {}; - if (message.name) { - obj.name = message.name.map((e) => (e ? UninterpretedOption_NamePart.toJSON(e) : undefined)); - } else { - obj.name = []; - } - message.identifierValue !== undefined && (obj.identifierValue = message.identifierValue); - message.positiveIntValue !== undefined && - (obj.positiveIntValue = (message.positiveIntValue || Long.UZERO).toString()); - message.negativeIntValue !== undefined && - (obj.negativeIntValue = (message.negativeIntValue || Long.ZERO).toString()); - message.doubleValue !== undefined && (obj.doubleValue = message.doubleValue); - message.stringValue !== undefined && - (obj.stringValue = base64FromBytes( - message.stringValue !== undefined ? message.stringValue : new Uint8Array(), - )); - message.aggregateValue !== undefined && (obj.aggregateValue = message.aggregateValue); - return obj; - }, }; const baseUninterpretedOption_NamePart: object = { namePart: "", isExtension: false }; export const UninterpretedOption_NamePart = { encode(message: UninterpretedOption_NamePart, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.namePart); - writer.uint32(16).bool(message.isExtension); + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } return writer; }, @@ -4092,6 +4240,13 @@ export const UninterpretedOption_NamePart = { return message; }, + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && (obj.isExtension = message.isExtension); + return obj; + }, + fromPartial(object: DeepPartial): UninterpretedOption_NamePart { const message = { ...baseUninterpretedOption_NamePart } as UninterpretedOption_NamePart; if (object.namePart !== undefined && object.namePart !== null) { @@ -4106,13 +4261,6 @@ export const UninterpretedOption_NamePart = { } return message; }, - - toJSON(message: UninterpretedOption_NamePart): unknown { - const obj: any = {}; - message.namePart !== undefined && (obj.namePart = message.namePart); - message.isExtension !== undefined && (obj.isExtension = message.isExtension); - return obj; - }, }; const baseSourceCodeInfo: object = {}; @@ -4155,6 +4303,16 @@ export const SourceCodeInfo = { return message; }, + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => (e ? SourceCodeInfo_Location.toJSON(e) : undefined)); + } else { + obj.location = []; + } + return obj; + }, + fromPartial(object: DeepPartial): SourceCodeInfo { const message = { ...baseSourceCodeInfo } as SourceCodeInfo; message.location = []; @@ -4165,16 +4323,6 @@ export const SourceCodeInfo = { } return message; }, - - toJSON(message: SourceCodeInfo): unknown { - const obj: any = {}; - if (message.location) { - obj.location = message.location.map((e) => (e ? SourceCodeInfo_Location.toJSON(e) : undefined)); - } else { - obj.location = []; - } - return obj; - }, }; const baseSourceCodeInfo_Location: object = { @@ -4197,8 +4345,12 @@ export const SourceCodeInfo_Location = { writer.int32(v); } writer.ldelim(); - writer.uint32(26).string(message.leadingComments); - writer.uint32(34).string(message.trailingComments); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } for (const v of message.leadingDetachedComments) { writer.uint32(50).string(v!); } @@ -4285,6 +4437,28 @@ export const SourceCodeInfo_Location = { return message; }, + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map((e) => e); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + fromPartial(object: DeepPartial): SourceCodeInfo_Location { const message = { ...baseSourceCodeInfo_Location } as SourceCodeInfo_Location; message.path = []; @@ -4317,28 +4491,6 @@ export const SourceCodeInfo_Location = { } return message; }, - - toJSON(message: SourceCodeInfo_Location): unknown { - const obj: any = {}; - if (message.path) { - obj.path = message.path.map((e) => e); - } else { - obj.path = []; - } - if (message.span) { - obj.span = message.span.map((e) => e); - } else { - obj.span = []; - } - message.leadingComments !== undefined && (obj.leadingComments = message.leadingComments); - message.trailingComments !== undefined && (obj.trailingComments = message.trailingComments); - if (message.leadingDetachedComments) { - obj.leadingDetachedComments = message.leadingDetachedComments.map((e) => e); - } else { - obj.leadingDetachedComments = []; - } - return obj; - }, }; const baseGeneratedCodeInfo: object = {}; @@ -4381,17 +4533,6 @@ export const GeneratedCodeInfo = { return message; }, - fromPartial(object: DeepPartial): GeneratedCodeInfo { - const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; - message.annotation = []; - if (object.annotation !== undefined && object.annotation !== null) { - for (const e of object.annotation) { - message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); - } - } - return message; - }, - toJSON(message: GeneratedCodeInfo): unknown { const obj: any = {}; if (message.annotation) { @@ -4403,6 +4544,17 @@ export const GeneratedCodeInfo = { } return obj; }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, }; const baseGeneratedCodeInfo_Annotation: object = { path: 0, sourceFile: "", begin: 0, end: 0 }; @@ -4414,9 +4566,15 @@ export const GeneratedCodeInfo_Annotation = { writer.int32(v); } writer.ldelim(); - writer.uint32(18).string(message.sourceFile); - writer.uint32(24).int32(message.begin); - writer.uint32(32).int32(message.end); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } return writer; }, @@ -4481,6 +4639,19 @@ export const GeneratedCodeInfo_Annotation = { return message; }, + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + fromPartial(object: DeepPartial): GeneratedCodeInfo_Annotation { const message = { ...baseGeneratedCodeInfo_Annotation } as GeneratedCodeInfo_Annotation; message.path = []; @@ -4506,19 +4677,6 @@ export const GeneratedCodeInfo_Annotation = { } return message; }, - - toJSON(message: GeneratedCodeInfo_Annotation): unknown { - const obj: any = {}; - if (message.path) { - obj.path = message.path.map((e) => e); - } else { - obj.path = []; - } - message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); - message.begin !== undefined && (obj.begin = message.begin); - message.end !== undefined && (obj.end = message.end); - return obj; - }, }; declare var self: any | undefined; @@ -4528,7 +4686,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/proto-signing/src/codec/tendermint/crypto/keys.ts b/packages/proto-signing/src/codec/tendermint/crypto/keys.ts index 1a99790b..c0c2302f 100644 --- a/packages/proto-signing/src/codec/tendermint/crypto/keys.ts +++ b/packages/proto-signing/src/codec/tendermint/crypto/keys.ts @@ -55,6 +55,15 @@ export const PublicKey = { return message; }, + toJSON(message: PublicKey): unknown { + const obj: any = {}; + message.ed25519 !== undefined && + (obj.ed25519 = message.ed25519 !== undefined ? base64FromBytes(message.ed25519) : undefined); + message.secp256k1 !== undefined && + (obj.secp256k1 = message.secp256k1 !== undefined ? base64FromBytes(message.secp256k1) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): PublicKey { const message = { ...basePublicKey } as PublicKey; if (object.ed25519 !== undefined && object.ed25519 !== null) { @@ -69,15 +78,6 @@ export const PublicKey = { } return message; }, - - toJSON(message: PublicKey): unknown { - const obj: any = {}; - message.ed25519 !== undefined && - (obj.ed25519 = message.ed25519 !== undefined ? base64FromBytes(message.ed25519) : undefined); - message.secp256k1 !== undefined && - (obj.secp256k1 = message.secp256k1 !== undefined ? base64FromBytes(message.secp256k1) : undefined); - return obj; - }, }; declare var self: any | undefined; @@ -87,7 +87,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/proto-signing/src/directsecp256k1hdwallet.spec.ts b/packages/proto-signing/src/directsecp256k1hdwallet.spec.ts index bb8fd105..c13e2434 100644 --- a/packages/proto-signing/src/directsecp256k1hdwallet.spec.ts +++ b/packages/proto-signing/src/directsecp256k1hdwallet.spec.ts @@ -59,7 +59,7 @@ describe("DirectSecp256k1HdWallet", () => { describe("signDirect", () => { it("resolves to valid signature", async () => { - const { sequence, bodyBytes } = testVectors[1]; + const { accountNumber, sequence, bodyBytes } = testVectors[1].inputs; const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic); const pubkey = { typeUrl: "/cosmos.crypto.secp256k1.PubKey", @@ -68,7 +68,6 @@ describe("DirectSecp256k1HdWallet", () => { const fee = coins(2000, "ucosm"); const gasLimit = 200000; const chainId = "simd-testing"; - const accountNumber = 1; const signDoc = makeSignDoc( fromHex(bodyBytes), makeAuthInfoBytes([pubkey], fee, gasLimit, sequence), diff --git a/packages/proto-signing/src/directsecp256k1wallet.spec.ts b/packages/proto-signing/src/directsecp256k1wallet.spec.ts index 1b17d381..40e0773f 100644 --- a/packages/proto-signing/src/directsecp256k1wallet.spec.ts +++ b/packages/proto-signing/src/directsecp256k1wallet.spec.ts @@ -34,7 +34,7 @@ describe("DirectSecp256k1Wallet", () => { describe("signDirect", () => { it("resolves to valid signature", async () => { - const { sequence, bodyBytes } = testVectors[1]; + const { accountNumber, sequence, bodyBytes } = testVectors[1].inputs; const wallet = await DirectSecp256k1Wallet.fromKey(defaultPrivkey); const accounts = await wallet.getAccounts(); const pubkey = { @@ -44,7 +44,6 @@ describe("DirectSecp256k1Wallet", () => { const fee = coins(2000, "ucosm"); const gasLimit = 200000; const chainId = "simd-testing"; - const accountNumber = 1; const signDoc = makeSignDoc( fromHex(bodyBytes), makeAuthInfoBytes([pubkey], fee, gasLimit, sequence), diff --git a/packages/proto-signing/src/signing.spec.ts b/packages/proto-signing/src/signing.spec.ts index 3a49b9f6..40c78104 100644 --- a/packages/proto-signing/src/signing.spec.ts +++ b/packages/proto-signing/src/signing.spec.ts @@ -1,13 +1,11 @@ /* eslint-disable @typescript-eslint/naming-convention */ import { fromBase64, fromHex, toHex } from "@cosmjs/encoding"; -import { PubKey } from "./codec/cosmos/crypto/secp256k1/keys"; import { SignMode } from "./codec/cosmos/tx/signing/v1beta1/signing"; import { Tx, TxRaw } from "./codec/cosmos/tx/v1beta1/tx"; -import { Any } from "./codec/google/protobuf/any"; import { DirectSecp256k1HdWallet } from "./directsecp256k1hdwallet"; -import { Registry, TxBodyValue } from "./registry"; -import { makeAuthInfoBytes, makeSignBytes, makeSignDoc } from "./signing"; +import { Registry } from "./registry"; +import { makeSignBytes, makeSignDoc } from "./signing"; import { faucet, testVectors } from "./testutils.spec"; describe("signing", () => { @@ -16,20 +14,14 @@ describe("signing", () => { const sendAmount = "1234567"; const sendDenom = "ucosm"; - const feeAmount = [ - { - amount: "2000", - denom: "ucosm", - }, - ]; const gasLimit = 200000; - it("correctly parses test vectors", async () => { + it("correctly parses signed transactions from test vectors", async () => { const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic); const [{ address, pubkey: pubkeyBytes }] = await wallet.getAccounts(); const prefixedPubkeyBytes = Uint8Array.from([0x0a, pubkeyBytes.length, ...pubkeyBytes]); - testVectors.forEach(({ signedTxBytes }) => { + testVectors.forEach(({ outputs: { signedTxBytes } }) => { const parsedTestTx = Tx.decode(fromHex(signedTxBytes)); expect(parsedTestTx.signatures.length).toEqual(1); expect(parsedTestTx.authInfo!.signerInfos.length).toEqual(1); @@ -58,59 +50,30 @@ describe("signing", () => { }); }); - it("correctly generates test vectors", async () => { - const myRegistry = new Registry(); + it("correctly generates sign docs and signed transactions from test vectors", async () => { const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic); - const [{ address, pubkey: pubkeyBytes }] = await wallet.getAccounts(); - const publicKey = PubKey.fromPartial({ - key: pubkeyBytes, - }); - const publicKeyBytes = PubKey.encode(publicKey).finish(); - - const txBodyFields: TxBodyValue = { - messages: [ - { - typeUrl: "/cosmos.bank.v1beta1.MsgSend", - value: { - fromAddress: address, - toAddress: toAddress, - amount: [ - { - denom: sendDenom, - amount: sendAmount, - }, - ], - }, - }, - ], - }; - const txBodyBytes = myRegistry.encode({ - typeUrl: "/cosmos.tx.v1beta1.TxBody", - value: txBodyFields, - }); - - const publicKeyAny = Any.fromPartial({ - typeUrl: "/cosmos.crypto.secp256k1.PubKey", - value: publicKeyBytes, - }); - const accountNumber = 1; + const [{ address }] = await wallet.getAccounts(); await Promise.all( - testVectors.map(async ({ sequence, signBytes, signedTxBytes }) => { - const authInfoBytes = makeAuthInfoBytes([publicKeyAny], feeAmount, gasLimit, sequence); - const signDoc = makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber); + testVectors.map(async ({ inputs, outputs }) => { + const signDoc = makeSignDoc( + fromHex(inputs.bodyBytes), + fromHex(inputs.authInfoBytes), + chainId, + inputs.accountNumber, + ); const signDocBytes = makeSignBytes(signDoc); - expect(toHex(signDocBytes)).toEqual(signBytes); + expect(toHex(signDocBytes)).toEqual(outputs.signBytes); const { signature } = await wallet.signDirect(address, signDoc); const txRaw = TxRaw.fromPartial({ - bodyBytes: txBodyBytes, - authInfoBytes: authInfoBytes, + bodyBytes: fromHex(inputs.bodyBytes), + authInfoBytes: fromHex(inputs.authInfoBytes), signatures: [fromBase64(signature.signature)], }); const txRawBytes = Uint8Array.from(TxRaw.encode(txRaw).finish()); const txBytesHex = toHex(txRawBytes); - expect(txBytesHex).toEqual(signedTxBytes); + expect(txBytesHex).toEqual(outputs.signedTxBytes); }), ); }); diff --git a/packages/proto-signing/src/testutils.spec.ts b/packages/proto-signing/src/testutils.spec.ts index 32ac9925..1e3c2350 100644 --- a/packages/proto-signing/src/testutils.spec.ts +++ b/packages/proto-signing/src/testutils.spec.ts @@ -11,38 +11,60 @@ export const faucet = { address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", }; +/** See TEST_VECTORS.md for how those are generated */ export const testVectors = [ { - sequence: 0, - signedTxBytes: - "0a97010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712001800126b0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180012170a0d0a0575636f736d12043230303010c09a0c1a0022001a40d1bb55b0f3e5f9c260a20c8ccf2cb44f19bafccba84c7fb6e2b77fac401b15c9228c33236a701dd7a7c4a481aa5dedb902c982fe565504c4f4e7f39ccfcd73d6", - bodyBytes: - "0a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d120731323334353637", - signBytes: - "0a97010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712001800126b0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180012170a0d0a0575636f736d12043230303010c09a0c1a0022001a0c73696d642d74657374696e672001", - signature: - "c9dd20e07464d3a688ff4b710b1fbc027e495e797cfa0b4804da2ed117959227772de059808f765aa29b8f92edf30f4c2c5a438e30d3fe6897daa7141e3ce6f9", + inputs: { + accountNumber: 1, + sequence: 0, + bodyBytes: + "0a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d120731323334353637", + authInfoBytes: + "0a4e0a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a02080112130a0d0a0575636f736d12043230303010c09a0c", + }, + outputs: { + signBytes: + "0a93010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712650a4e0a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a02080112130a0d0a0575636f736d12043230303010c09a0c1a0c73696d642d74657374696e672001", + signature: + "c9dd20e07464d3a688ff4b710b1fbc027e495e797cfa0b4804da2ed117959227772de059808f765aa29b8f92edf30f4c2c5a438e30d3fe6897daa7141e3ce6f9", + signedTxBytes: + "0a93010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712650a4e0a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a02080112130a0d0a0575636f736d12043230303010c09a0c1a40c9dd20e07464d3a688ff4b710b1fbc027e495e797cfa0b4804da2ed117959227772de059808f765aa29b8f92edf30f4c2c5a438e30d3fe6897daa7141e3ce6f9", + }, }, { - sequence: 1, - signedTxBytes: - "0a97010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712001800126b0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180112170a0d0a0575636f736d12043230303010c09a0c1a0022001a40d6d876ec9c01d03b025443822b1385e29ed559341ec71853ac310219b4bcb4112bf24265a19d805f0cbb1cb39f4ac4fe75235445070aa14845733117a746c248", - bodyBytes: - "0a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d120731323334353637", - signBytes: - "0a97010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712001800126b0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180112170a0d0a0575636f736d12043230303010c09a0c1a0022001a0c73696d642d74657374696e672001", - signature: - "525adc7e61565a509c60497b798c549fbf217bb5cd31b24cc9b419d098cc95330c99ecc4bc72448f85c365a4e3f91299a3d40412fb3751bab82f1940a83a0a4c", + inputs: { + accountNumber: 1, + sequence: 1, + bodyBytes: + "0a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d120731323334353637", + authInfoBytes: + "0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180112130a0d0a0575636f736d12043230303010c09a0c", + }, + outputs: { + signBytes: + "0a93010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180112130a0d0a0575636f736d12043230303010c09a0c1a0c73696d642d74657374696e672001", + signature: + "525adc7e61565a509c60497b798c549fbf217bb5cd31b24cc9b419d098cc95330c99ecc4bc72448f85c365a4e3f91299a3d40412fb3751bab82f1940a83a0a4c", + signedTxBytes: + "0a93010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180112130a0d0a0575636f736d12043230303010c09a0c1a40525adc7e61565a509c60497b798c549fbf217bb5cd31b24cc9b419d098cc95330c99ecc4bc72448f85c365a4e3f91299a3d40412fb3751bab82f1940a83a0a4c", + }, }, { - sequence: 2, - signedTxBytes: - "0a97010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712001800126b0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180212170a0d0a0575636f736d12043230303010c09a0c1a0022001a40c62931c5f283dc72774cb34165ad98169c40de14c13e9c11c696cb439c7c58ab0c2017c95cb9ed874ace06460b61f1296dddb20c9e0609e364d1f38e163b7c7b", - bodyBytes: - "0a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d120731323334353637", - signBytes: - "0a97010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712001800126b0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180212170a0d0a0575636f736d12043230303010c09a0c1a0022001a0c73696d642d74657374696e672001", - signature: - "f3f2ca73806f2abbf6e0fe85f9b8af66f0e9f7f79051fdb8abe5bb8633b17da132e82d577b9d5f7a6dae57a144efc9ccc6eef15167b44b3b22a57240109762af", + inputs: { + accountNumber: 1, + sequence: 2, + bodyBytes: + "0a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d120731323334353637", + authInfoBytes: + "0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180212130a0d0a0575636f736d12043230303010c09a0c", + }, + outputs: { + signBytes: + "0a93010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180212130a0d0a0575636f736d12043230303010c09a0c1a0c73696d642d74657374696e672001", + signature: + "f3f2ca73806f2abbf6e0fe85f9b8af66f0e9f7f79051fdb8abe5bb8633b17da132e82d577b9d5f7a6dae57a144efc9ccc6eef15167b44b3b22a57240109762af", + signedTxBytes: + "0a93010a90010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412700a2d636f736d6f7331706b707472653766646b6c366766727a6c65736a6a766878686c63337234676d6d6b38727336122d636f736d6f7331717970717870713971637273737a673270767871367273307a716733797963356c7a763778751a100a0575636f736d12073132333435363712670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029012040a020801180212130a0d0a0575636f736d12043230303010c09a0c1a40f3f2ca73806f2abbf6e0fe85f9b8af66f0e9f7f79051fdb8abe5bb8633b17da132e82d577b9d5f7a6dae57a144efc9ccc6eef15167b44b3b22a57240109762af", + }, }, ]; diff --git a/packages/stargate/src/codec/confio/proofs.ts b/packages/stargate/src/codec/confio/proofs.ts index c96cabca..0c1e23e3 100644 --- a/packages/stargate/src/codec/confio/proofs.ts +++ b/packages/stargate/src/codec/confio/proofs.ts @@ -342,9 +342,13 @@ const baseExistenceProof: object = {}; export const ExistenceProof = { encode(message: ExistenceProof, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.key); - writer.uint32(18).bytes(message.value); - if (message.leaf !== undefined && message.leaf !== undefined) { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + if (message.leaf !== undefined) { LeafOp.encode(message.leaf, writer.uint32(26).fork()).ldelim(); } for (const v of message.path) { @@ -403,6 +407,21 @@ export const ExistenceProof = { return message; }, + toJSON(message: ExistenceProof): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.value !== undefined && + (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + message.leaf !== undefined && (obj.leaf = message.leaf ? LeafOp.toJSON(message.leaf) : undefined); + if (message.path) { + obj.path = message.path.map((e) => (e ? InnerOp.toJSON(e) : undefined)); + } else { + obj.path = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ExistenceProof { const message = { ...baseExistenceProof } as ExistenceProof; message.path = []; @@ -428,32 +447,19 @@ export const ExistenceProof = { } return message; }, - - toJSON(message: ExistenceProof): unknown { - const obj: any = {}; - message.key !== undefined && - (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); - message.value !== undefined && - (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); - message.leaf !== undefined && (obj.leaf = message.leaf ? LeafOp.toJSON(message.leaf) : undefined); - if (message.path) { - obj.path = message.path.map((e) => (e ? InnerOp.toJSON(e) : undefined)); - } else { - obj.path = []; - } - return obj; - }, }; const baseNonExistenceProof: object = {}; export const NonExistenceProof = { encode(message: NonExistenceProof, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.key); - if (message.left !== undefined && message.left !== undefined) { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.left !== undefined) { ExistenceProof.encode(message.left, writer.uint32(18).fork()).ldelim(); } - if (message.right !== undefined && message.right !== undefined) { + if (message.right !== undefined) { ExistenceProof.encode(message.right, writer.uint32(26).fork()).ldelim(); } return writer; @@ -501,6 +507,16 @@ export const NonExistenceProof = { return message; }, + toJSON(message: NonExistenceProof): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.left !== undefined && (obj.left = message.left ? ExistenceProof.toJSON(message.left) : undefined); + message.right !== undefined && + (obj.right = message.right ? ExistenceProof.toJSON(message.right) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): NonExistenceProof { const message = { ...baseNonExistenceProof } as NonExistenceProof; if (object.key !== undefined && object.key !== null) { @@ -520,16 +536,6 @@ export const NonExistenceProof = { } return message; }, - - toJSON(message: NonExistenceProof): unknown { - const obj: any = {}; - message.key !== undefined && - (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); - message.left !== undefined && (obj.left = message.left ? ExistenceProof.toJSON(message.left) : undefined); - message.right !== undefined && - (obj.right = message.right ? ExistenceProof.toJSON(message.right) : undefined); - return obj; - }, }; const baseCommitmentProof: object = {}; @@ -603,6 +609,18 @@ export const CommitmentProof = { return message; }, + toJSON(message: CommitmentProof): unknown { + const obj: any = {}; + message.exist !== undefined && + (obj.exist = message.exist ? ExistenceProof.toJSON(message.exist) : undefined); + message.nonexist !== undefined && + (obj.nonexist = message.nonexist ? NonExistenceProof.toJSON(message.nonexist) : undefined); + message.batch !== undefined && (obj.batch = message.batch ? BatchProof.toJSON(message.batch) : undefined); + message.compressed !== undefined && + (obj.compressed = message.compressed ? CompressedBatchProof.toJSON(message.compressed) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CommitmentProof { const message = { ...baseCommitmentProof } as CommitmentProof; if (object.exist !== undefined && object.exist !== null) { @@ -627,29 +645,27 @@ export const CommitmentProof = { } return message; }, - - toJSON(message: CommitmentProof): unknown { - const obj: any = {}; - message.exist !== undefined && - (obj.exist = message.exist ? ExistenceProof.toJSON(message.exist) : undefined); - message.nonexist !== undefined && - (obj.nonexist = message.nonexist ? NonExistenceProof.toJSON(message.nonexist) : undefined); - message.batch !== undefined && (obj.batch = message.batch ? BatchProof.toJSON(message.batch) : undefined); - message.compressed !== undefined && - (obj.compressed = message.compressed ? CompressedBatchProof.toJSON(message.compressed) : undefined); - return obj; - }, }; const baseLeafOp: object = { hash: 0, prehashKey: 0, prehashValue: 0, length: 0 }; export const LeafOp = { encode(message: LeafOp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.hash); - writer.uint32(16).int32(message.prehashKey); - writer.uint32(24).int32(message.prehashValue); - writer.uint32(32).int32(message.length); - writer.uint32(42).bytes(message.prefix); + if (message.hash !== 0) { + writer.uint32(8).int32(message.hash); + } + if (message.prehashKey !== 0) { + writer.uint32(16).int32(message.prehashKey); + } + if (message.prehashValue !== 0) { + writer.uint32(24).int32(message.prehashValue); + } + if (message.length !== 0) { + writer.uint32(32).int32(message.length); + } + if (message.prefix.length !== 0) { + writer.uint32(42).bytes(message.prefix); + } return writer; }, @@ -711,6 +727,17 @@ export const LeafOp = { return message; }, + toJSON(message: LeafOp): unknown { + const obj: any = {}; + message.hash !== undefined && (obj.hash = hashOpToJSON(message.hash)); + message.prehashKey !== undefined && (obj.prehashKey = hashOpToJSON(message.prehashKey)); + message.prehashValue !== undefined && (obj.prehashValue = hashOpToJSON(message.prehashValue)); + message.length !== undefined && (obj.length = lengthOpToJSON(message.length)); + message.prefix !== undefined && + (obj.prefix = base64FromBytes(message.prefix !== undefined ? message.prefix : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): LeafOp { const message = { ...baseLeafOp } as LeafOp; if (object.hash !== undefined && object.hash !== null) { @@ -740,26 +767,21 @@ export const LeafOp = { } return message; }, - - toJSON(message: LeafOp): unknown { - const obj: any = {}; - message.hash !== undefined && (obj.hash = hashOpToJSON(message.hash)); - message.prehashKey !== undefined && (obj.prehashKey = hashOpToJSON(message.prehashKey)); - message.prehashValue !== undefined && (obj.prehashValue = hashOpToJSON(message.prehashValue)); - message.length !== undefined && (obj.length = lengthOpToJSON(message.length)); - message.prefix !== undefined && - (obj.prefix = base64FromBytes(message.prefix !== undefined ? message.prefix : new Uint8Array())); - return obj; - }, }; const baseInnerOp: object = { hash: 0 }; export const InnerOp = { encode(message: InnerOp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.hash); - writer.uint32(18).bytes(message.prefix); - writer.uint32(26).bytes(message.suffix); + if (message.hash !== 0) { + writer.uint32(8).int32(message.hash); + } + if (message.prefix.length !== 0) { + writer.uint32(18).bytes(message.prefix); + } + if (message.suffix.length !== 0) { + writer.uint32(26).bytes(message.suffix); + } return writer; }, @@ -803,6 +825,16 @@ export const InnerOp = { return message; }, + toJSON(message: InnerOp): unknown { + const obj: any = {}; + message.hash !== undefined && (obj.hash = hashOpToJSON(message.hash)); + message.prefix !== undefined && + (obj.prefix = base64FromBytes(message.prefix !== undefined ? message.prefix : new Uint8Array())); + message.suffix !== undefined && + (obj.suffix = base64FromBytes(message.suffix !== undefined ? message.suffix : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): InnerOp { const message = { ...baseInnerOp } as InnerOp; if (object.hash !== undefined && object.hash !== null) { @@ -822,30 +854,24 @@ export const InnerOp = { } return message; }, - - toJSON(message: InnerOp): unknown { - const obj: any = {}; - message.hash !== undefined && (obj.hash = hashOpToJSON(message.hash)); - message.prefix !== undefined && - (obj.prefix = base64FromBytes(message.prefix !== undefined ? message.prefix : new Uint8Array())); - message.suffix !== undefined && - (obj.suffix = base64FromBytes(message.suffix !== undefined ? message.suffix : new Uint8Array())); - return obj; - }, }; const baseProofSpec: object = { maxDepth: 0, minDepth: 0 }; export const ProofSpec = { encode(message: ProofSpec, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.leafSpec !== undefined && message.leafSpec !== undefined) { + if (message.leafSpec !== undefined) { LeafOp.encode(message.leafSpec, writer.uint32(10).fork()).ldelim(); } - if (message.innerSpec !== undefined && message.innerSpec !== undefined) { + if (message.innerSpec !== undefined) { InnerSpec.encode(message.innerSpec, writer.uint32(18).fork()).ldelim(); } - writer.uint32(24).int32(message.maxDepth); - writer.uint32(32).int32(message.minDepth); + if (message.maxDepth !== 0) { + writer.uint32(24).int32(message.maxDepth); + } + if (message.minDepth !== 0) { + writer.uint32(32).int32(message.minDepth); + } return writer; }, @@ -901,6 +927,17 @@ export const ProofSpec = { return message; }, + toJSON(message: ProofSpec): unknown { + const obj: any = {}; + message.leafSpec !== undefined && + (obj.leafSpec = message.leafSpec ? LeafOp.toJSON(message.leafSpec) : undefined); + message.innerSpec !== undefined && + (obj.innerSpec = message.innerSpec ? InnerSpec.toJSON(message.innerSpec) : undefined); + message.maxDepth !== undefined && (obj.maxDepth = message.maxDepth); + message.minDepth !== undefined && (obj.minDepth = message.minDepth); + return obj; + }, + fromPartial(object: DeepPartial): ProofSpec { const message = { ...baseProofSpec } as ProofSpec; if (object.leafSpec !== undefined && object.leafSpec !== null) { @@ -925,17 +962,6 @@ export const ProofSpec = { } return message; }, - - toJSON(message: ProofSpec): unknown { - const obj: any = {}; - message.leafSpec !== undefined && - (obj.leafSpec = message.leafSpec ? LeafOp.toJSON(message.leafSpec) : undefined); - message.innerSpec !== undefined && - (obj.innerSpec = message.innerSpec ? InnerSpec.toJSON(message.innerSpec) : undefined); - message.maxDepth !== undefined && (obj.maxDepth = message.maxDepth); - message.minDepth !== undefined && (obj.minDepth = message.minDepth); - return obj; - }, }; const baseInnerSpec: object = { @@ -953,11 +979,21 @@ export const InnerSpec = { writer.int32(v); } writer.ldelim(); - writer.uint32(16).int32(message.childSize); - writer.uint32(24).int32(message.minPrefixLength); - writer.uint32(32).int32(message.maxPrefixLength); - writer.uint32(42).bytes(message.emptyChild); - writer.uint32(48).int32(message.hash); + if (message.childSize !== 0) { + writer.uint32(16).int32(message.childSize); + } + if (message.minPrefixLength !== 0) { + writer.uint32(24).int32(message.minPrefixLength); + } + if (message.maxPrefixLength !== 0) { + writer.uint32(32).int32(message.maxPrefixLength); + } + if (message.emptyChild.length !== 0) { + writer.uint32(42).bytes(message.emptyChild); + } + if (message.hash !== 0) { + writer.uint32(48).int32(message.hash); + } return writer; }, @@ -1036,6 +1072,24 @@ export const InnerSpec = { return message; }, + toJSON(message: InnerSpec): unknown { + const obj: any = {}; + if (message.childOrder) { + obj.childOrder = message.childOrder.map((e) => e); + } else { + obj.childOrder = []; + } + message.childSize !== undefined && (obj.childSize = message.childSize); + message.minPrefixLength !== undefined && (obj.minPrefixLength = message.minPrefixLength); + message.maxPrefixLength !== undefined && (obj.maxPrefixLength = message.maxPrefixLength); + message.emptyChild !== undefined && + (obj.emptyChild = base64FromBytes( + message.emptyChild !== undefined ? message.emptyChild : new Uint8Array(), + )); + message.hash !== undefined && (obj.hash = hashOpToJSON(message.hash)); + return obj; + }, + fromPartial(object: DeepPartial): InnerSpec { const message = { ...baseInnerSpec } as InnerSpec; message.childOrder = []; @@ -1071,24 +1125,6 @@ export const InnerSpec = { } return message; }, - - toJSON(message: InnerSpec): unknown { - const obj: any = {}; - if (message.childOrder) { - obj.childOrder = message.childOrder.map((e) => e); - } else { - obj.childOrder = []; - } - message.childSize !== undefined && (obj.childSize = message.childSize); - message.minPrefixLength !== undefined && (obj.minPrefixLength = message.minPrefixLength); - message.maxPrefixLength !== undefined && (obj.maxPrefixLength = message.maxPrefixLength); - message.emptyChild !== undefined && - (obj.emptyChild = base64FromBytes( - message.emptyChild !== undefined ? message.emptyChild : new Uint8Array(), - )); - message.hash !== undefined && (obj.hash = hashOpToJSON(message.hash)); - return obj; - }, }; const baseBatchProof: object = {}; @@ -1131,6 +1167,16 @@ export const BatchProof = { return message; }, + toJSON(message: BatchProof): unknown { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map((e) => (e ? BatchEntry.toJSON(e) : undefined)); + } else { + obj.entries = []; + } + return obj; + }, + fromPartial(object: DeepPartial): BatchProof { const message = { ...baseBatchProof } as BatchProof; message.entries = []; @@ -1141,16 +1187,6 @@ export const BatchProof = { } return message; }, - - toJSON(message: BatchProof): unknown { - const obj: any = {}; - if (message.entries) { - obj.entries = message.entries.map((e) => (e ? BatchEntry.toJSON(e) : undefined)); - } else { - obj.entries = []; - } - return obj; - }, }; const baseBatchEntry: object = {}; @@ -1202,6 +1238,15 @@ export const BatchEntry = { return message; }, + toJSON(message: BatchEntry): unknown { + const obj: any = {}; + message.exist !== undefined && + (obj.exist = message.exist ? ExistenceProof.toJSON(message.exist) : undefined); + message.nonexist !== undefined && + (obj.nonexist = message.nonexist ? NonExistenceProof.toJSON(message.nonexist) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): BatchEntry { const message = { ...baseBatchEntry } as BatchEntry; if (object.exist !== undefined && object.exist !== null) { @@ -1216,15 +1261,6 @@ export const BatchEntry = { } return message; }, - - toJSON(message: BatchEntry): unknown { - const obj: any = {}; - message.exist !== undefined && - (obj.exist = message.exist ? ExistenceProof.toJSON(message.exist) : undefined); - message.nonexist !== undefined && - (obj.nonexist = message.nonexist ? NonExistenceProof.toJSON(message.nonexist) : undefined); - return obj; - }, }; const baseCompressedBatchProof: object = {}; @@ -1280,6 +1316,21 @@ export const CompressedBatchProof = { return message; }, + toJSON(message: CompressedBatchProof): unknown { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map((e) => (e ? CompressedBatchEntry.toJSON(e) : undefined)); + } else { + obj.entries = []; + } + if (message.lookupInners) { + obj.lookupInners = message.lookupInners.map((e) => (e ? InnerOp.toJSON(e) : undefined)); + } else { + obj.lookupInners = []; + } + return obj; + }, + fromPartial(object: DeepPartial): CompressedBatchProof { const message = { ...baseCompressedBatchProof } as CompressedBatchProof; message.entries = []; @@ -1296,21 +1347,6 @@ export const CompressedBatchProof = { } return message; }, - - toJSON(message: CompressedBatchProof): unknown { - const obj: any = {}; - if (message.entries) { - obj.entries = message.entries.map((e) => (e ? CompressedBatchEntry.toJSON(e) : undefined)); - } else { - obj.entries = []; - } - if (message.lookupInners) { - obj.lookupInners = message.lookupInners.map((e) => (e ? InnerOp.toJSON(e) : undefined)); - } else { - obj.lookupInners = []; - } - return obj; - }, }; const baseCompressedBatchEntry: object = {}; @@ -1362,6 +1398,15 @@ export const CompressedBatchEntry = { return message; }, + toJSON(message: CompressedBatchEntry): unknown { + const obj: any = {}; + message.exist !== undefined && + (obj.exist = message.exist ? CompressedExistenceProof.toJSON(message.exist) : undefined); + message.nonexist !== undefined && + (obj.nonexist = message.nonexist ? CompressedNonExistenceProof.toJSON(message.nonexist) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CompressedBatchEntry { const message = { ...baseCompressedBatchEntry } as CompressedBatchEntry; if (object.exist !== undefined && object.exist !== null) { @@ -1376,24 +1421,19 @@ export const CompressedBatchEntry = { } return message; }, - - toJSON(message: CompressedBatchEntry): unknown { - const obj: any = {}; - message.exist !== undefined && - (obj.exist = message.exist ? CompressedExistenceProof.toJSON(message.exist) : undefined); - message.nonexist !== undefined && - (obj.nonexist = message.nonexist ? CompressedNonExistenceProof.toJSON(message.nonexist) : undefined); - return obj; - }, }; const baseCompressedExistenceProof: object = { path: 0 }; export const CompressedExistenceProof = { encode(message: CompressedExistenceProof, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.key); - writer.uint32(18).bytes(message.value); - if (message.leaf !== undefined && message.leaf !== undefined) { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + if (message.leaf !== undefined) { LeafOp.encode(message.leaf, writer.uint32(26).fork()).ldelim(); } writer.uint32(34).fork(); @@ -1461,6 +1501,21 @@ export const CompressedExistenceProof = { return message; }, + toJSON(message: CompressedExistenceProof): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.value !== undefined && + (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + message.leaf !== undefined && (obj.leaf = message.leaf ? LeafOp.toJSON(message.leaf) : undefined); + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + return obj; + }, + fromPartial(object: DeepPartial): CompressedExistenceProof { const message = { ...baseCompressedExistenceProof } as CompressedExistenceProof; message.path = []; @@ -1486,32 +1541,19 @@ export const CompressedExistenceProof = { } return message; }, - - toJSON(message: CompressedExistenceProof): unknown { - const obj: any = {}; - message.key !== undefined && - (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); - message.value !== undefined && - (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); - message.leaf !== undefined && (obj.leaf = message.leaf ? LeafOp.toJSON(message.leaf) : undefined); - if (message.path) { - obj.path = message.path.map((e) => e); - } else { - obj.path = []; - } - return obj; - }, }; const baseCompressedNonExistenceProof: object = {}; export const CompressedNonExistenceProof = { encode(message: CompressedNonExistenceProof, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.key); - if (message.left !== undefined && message.left !== undefined) { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.left !== undefined) { CompressedExistenceProof.encode(message.left, writer.uint32(18).fork()).ldelim(); } - if (message.right !== undefined && message.right !== undefined) { + if (message.right !== undefined) { CompressedExistenceProof.encode(message.right, writer.uint32(26).fork()).ldelim(); } return writer; @@ -1559,6 +1601,17 @@ export const CompressedNonExistenceProof = { return message; }, + toJSON(message: CompressedNonExistenceProof): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.left !== undefined && + (obj.left = message.left ? CompressedExistenceProof.toJSON(message.left) : undefined); + message.right !== undefined && + (obj.right = message.right ? CompressedExistenceProof.toJSON(message.right) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CompressedNonExistenceProof { const message = { ...baseCompressedNonExistenceProof } as CompressedNonExistenceProof; if (object.key !== undefined && object.key !== null) { @@ -1578,17 +1631,6 @@ export const CompressedNonExistenceProof = { } return message; }, - - toJSON(message: CompressedNonExistenceProof): unknown { - const obj: any = {}; - message.key !== undefined && - (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); - message.left !== undefined && - (obj.left = message.left ? CompressedExistenceProof.toJSON(message.left) : undefined); - message.right !== undefined && - (obj.right = message.right ? CompressedExistenceProof.toJSON(message.right) : undefined); - return obj; - }, }; declare var self: any | undefined; @@ -1598,7 +1640,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/stargate/src/codec/cosmos/auth/v1beta1/auth.ts b/packages/stargate/src/codec/cosmos/auth/v1beta1/auth.ts index e018142b..886ff5b9 100644 --- a/packages/stargate/src/codec/cosmos/auth/v1beta1/auth.ts +++ b/packages/stargate/src/codec/cosmos/auth/v1beta1/auth.ts @@ -37,12 +37,18 @@ const baseBaseAccount: object = { address: "", accountNumber: Long.UZERO, sequen export const BaseAccount = { encode(message: BaseAccount, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.address); - if (message.pubKey !== undefined && message.pubKey !== undefined) { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.pubKey !== undefined) { Any.encode(message.pubKey, writer.uint32(18).fork()).ldelim(); } - writer.uint32(24).uint64(message.accountNumber); - writer.uint32(32).uint64(message.sequence); + if (!message.accountNumber.isZero()) { + writer.uint32(24).uint64(message.accountNumber); + } + if (!message.sequence.isZero()) { + writer.uint32(32).uint64(message.sequence); + } return writer; }, @@ -98,6 +104,16 @@ export const BaseAccount = { return message; }, + toJSON(message: BaseAccount): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pubKey !== undefined && (obj.pubKey = message.pubKey ? Any.toJSON(message.pubKey) : undefined); + message.accountNumber !== undefined && + (obj.accountNumber = (message.accountNumber || Long.UZERO).toString()); + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): BaseAccount { const message = { ...baseBaseAccount } as BaseAccount; if (object.address !== undefined && object.address !== null) { @@ -122,26 +138,18 @@ export const BaseAccount = { } return message; }, - - toJSON(message: BaseAccount): unknown { - const obj: any = {}; - message.address !== undefined && (obj.address = message.address); - message.pubKey !== undefined && (obj.pubKey = message.pubKey ? Any.toJSON(message.pubKey) : undefined); - message.accountNumber !== undefined && - (obj.accountNumber = (message.accountNumber || Long.UZERO).toString()); - message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); - return obj; - }, }; const baseModuleAccount: object = { name: "", permissions: "" }; export const ModuleAccount = { encode(message: ModuleAccount, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.baseAccount !== undefined && message.baseAccount !== undefined) { + if (message.baseAccount !== undefined) { BaseAccount.encode(message.baseAccount, writer.uint32(10).fork()).ldelim(); } - writer.uint32(18).string(message.name); + if (message.name !== "") { + writer.uint32(18).string(message.name); + } for (const v of message.permissions) { writer.uint32(26).string(v!); } @@ -194,6 +202,19 @@ export const ModuleAccount = { return message; }, + toJSON(message: ModuleAccount): unknown { + const obj: any = {}; + message.baseAccount !== undefined && + (obj.baseAccount = message.baseAccount ? BaseAccount.toJSON(message.baseAccount) : undefined); + message.name !== undefined && (obj.name = message.name); + if (message.permissions) { + obj.permissions = message.permissions.map((e) => e); + } else { + obj.permissions = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ModuleAccount { const message = { ...baseModuleAccount } as ModuleAccount; message.permissions = []; @@ -214,19 +235,6 @@ export const ModuleAccount = { } return message; }, - - toJSON(message: ModuleAccount): unknown { - const obj: any = {}; - message.baseAccount !== undefined && - (obj.baseAccount = message.baseAccount ? BaseAccount.toJSON(message.baseAccount) : undefined); - message.name !== undefined && (obj.name = message.name); - if (message.permissions) { - obj.permissions = message.permissions.map((e) => e); - } else { - obj.permissions = []; - } - return obj; - }, }; const baseParams: object = { @@ -239,11 +247,21 @@ const baseParams: object = { export const Params = { encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.maxMemoCharacters); - writer.uint32(16).uint64(message.txSigLimit); - writer.uint32(24).uint64(message.txSizeCostPerByte); - writer.uint32(32).uint64(message.sigVerifyCostEd25519); - writer.uint32(40).uint64(message.sigVerifyCostSecp256k1); + if (!message.maxMemoCharacters.isZero()) { + writer.uint32(8).uint64(message.maxMemoCharacters); + } + if (!message.txSigLimit.isZero()) { + writer.uint32(16).uint64(message.txSigLimit); + } + if (!message.txSizeCostPerByte.isZero()) { + writer.uint32(24).uint64(message.txSizeCostPerByte); + } + if (!message.sigVerifyCostEd25519.isZero()) { + writer.uint32(32).uint64(message.sigVerifyCostEd25519); + } + if (!message.sigVerifyCostSecp256k1.isZero()) { + writer.uint32(40).uint64(message.sigVerifyCostSecp256k1); + } return writer; }, @@ -307,6 +325,20 @@ export const Params = { return message; }, + toJSON(message: Params): unknown { + const obj: any = {}; + message.maxMemoCharacters !== undefined && + (obj.maxMemoCharacters = (message.maxMemoCharacters || Long.UZERO).toString()); + message.txSigLimit !== undefined && (obj.txSigLimit = (message.txSigLimit || Long.UZERO).toString()); + message.txSizeCostPerByte !== undefined && + (obj.txSizeCostPerByte = (message.txSizeCostPerByte || Long.UZERO).toString()); + message.sigVerifyCostEd25519 !== undefined && + (obj.sigVerifyCostEd25519 = (message.sigVerifyCostEd25519 || Long.UZERO).toString()); + message.sigVerifyCostSecp256k1 !== undefined && + (obj.sigVerifyCostSecp256k1 = (message.sigVerifyCostSecp256k1 || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): Params { const message = { ...baseParams } as Params; if (object.maxMemoCharacters !== undefined && object.maxMemoCharacters !== null) { @@ -336,20 +368,6 @@ export const Params = { } return message; }, - - toJSON(message: Params): unknown { - const obj: any = {}; - message.maxMemoCharacters !== undefined && - (obj.maxMemoCharacters = (message.maxMemoCharacters || Long.UZERO).toString()); - message.txSigLimit !== undefined && (obj.txSigLimit = (message.txSigLimit || Long.UZERO).toString()); - message.txSizeCostPerByte !== undefined && - (obj.txSizeCostPerByte = (message.txSizeCostPerByte || Long.UZERO).toString()); - message.sigVerifyCostEd25519 !== undefined && - (obj.sigVerifyCostEd25519 = (message.sigVerifyCostEd25519 || Long.UZERO).toString()); - message.sigVerifyCostSecp256k1 !== undefined && - (obj.sigVerifyCostSecp256k1 = (message.sigVerifyCostSecp256k1 || Long.UZERO).toString()); - return obj; - }, }; type Builtin = Date | Function | Uint8Array | string | number | undefined | Long; diff --git a/packages/stargate/src/codec/cosmos/auth/v1beta1/query.ts b/packages/stargate/src/codec/cosmos/auth/v1beta1/query.ts index 115c83f3..cc5cc5f1 100644 --- a/packages/stargate/src/codec/cosmos/auth/v1beta1/query.ts +++ b/packages/stargate/src/codec/cosmos/auth/v1beta1/query.ts @@ -31,7 +31,9 @@ const baseQueryAccountRequest: object = { address: "" }; export const QueryAccountRequest = { encode(message: QueryAccountRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.address); + if (message.address !== "") { + writer.uint32(10).string(message.address); + } return writer; }, @@ -63,6 +65,12 @@ export const QueryAccountRequest = { return message; }, + toJSON(message: QueryAccountRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + return obj; + }, + fromPartial(object: DeepPartial): QueryAccountRequest { const message = { ...baseQueryAccountRequest } as QueryAccountRequest; if (object.address !== undefined && object.address !== null) { @@ -72,19 +80,13 @@ export const QueryAccountRequest = { } return message; }, - - toJSON(message: QueryAccountRequest): unknown { - const obj: any = {}; - message.address !== undefined && (obj.address = message.address); - return obj; - }, }; const baseQueryAccountResponse: object = {}; export const QueryAccountResponse = { encode(message: QueryAccountResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.account !== undefined && message.account !== undefined) { + if (message.account !== undefined) { Any.encode(message.account, writer.uint32(10).fork()).ldelim(); } return writer; @@ -118,6 +120,13 @@ export const QueryAccountResponse = { return message; }, + toJSON(message: QueryAccountResponse): unknown { + const obj: any = {}; + message.account !== undefined && + (obj.account = message.account ? Any.toJSON(message.account) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAccountResponse { const message = { ...baseQueryAccountResponse } as QueryAccountResponse; if (object.account !== undefined && object.account !== null) { @@ -127,13 +136,6 @@ export const QueryAccountResponse = { } return message; }, - - toJSON(message: QueryAccountResponse): unknown { - const obj: any = {}; - message.account !== undefined && - (obj.account = message.account ? Any.toJSON(message.account) : undefined); - return obj; - }, }; const baseQueryParamsRequest: object = {}; @@ -163,22 +165,22 @@ export const QueryParamsRequest = { return message; }, - fromPartial(_: DeepPartial): QueryParamsRequest { - const message = { ...baseQueryParamsRequest } as QueryParamsRequest; - return message; - }, - toJSON(_: QueryParamsRequest): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, }; const baseQueryParamsResponse: object = {}; export const QueryParamsResponse = { encode(message: QueryParamsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.params !== undefined && message.params !== undefined) { + if (message.params !== undefined) { Params.encode(message.params, writer.uint32(10).fork()).ldelim(); } return writer; @@ -212,6 +214,12 @@ export const QueryParamsResponse = { return message; }, + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { const message = { ...baseQueryParamsResponse } as QueryParamsResponse; if (object.params !== undefined && object.params !== null) { @@ -221,12 +229,6 @@ export const QueryParamsResponse = { } return message; }, - - toJSON(message: QueryParamsResponse): unknown { - const obj: any = {}; - message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); - return obj; - }, }; /** Query defines the gRPC querier service. */ diff --git a/packages/stargate/src/codec/cosmos/bank/v1beta1/bank.ts b/packages/stargate/src/codec/cosmos/bank/v1beta1/bank.ts index 33d01f44..43fa84f5 100644 --- a/packages/stargate/src/codec/cosmos/bank/v1beta1/bank.ts +++ b/packages/stargate/src/codec/cosmos/bank/v1beta1/bank.ts @@ -83,7 +83,9 @@ export const Params = { for (const v of message.sendEnabled) { SendEnabled.encode(v!, writer.uint32(10).fork()).ldelim(); } - writer.uint32(16).bool(message.defaultSendEnabled); + if (message.defaultSendEnabled === true) { + writer.uint32(16).bool(message.defaultSendEnabled); + } return writer; }, @@ -125,6 +127,17 @@ export const Params = { return message; }, + toJSON(message: Params): unknown { + const obj: any = {}; + if (message.sendEnabled) { + obj.sendEnabled = message.sendEnabled.map((e) => (e ? SendEnabled.toJSON(e) : undefined)); + } else { + obj.sendEnabled = []; + } + message.defaultSendEnabled !== undefined && (obj.defaultSendEnabled = message.defaultSendEnabled); + return obj; + }, + fromPartial(object: DeepPartial): Params { const message = { ...baseParams } as Params; message.sendEnabled = []; @@ -140,25 +153,18 @@ export const Params = { } return message; }, - - toJSON(message: Params): unknown { - const obj: any = {}; - if (message.sendEnabled) { - obj.sendEnabled = message.sendEnabled.map((e) => (e ? SendEnabled.toJSON(e) : undefined)); - } else { - obj.sendEnabled = []; - } - message.defaultSendEnabled !== undefined && (obj.defaultSendEnabled = message.defaultSendEnabled); - return obj; - }, }; const baseSendEnabled: object = { denom: "", enabled: false }; export const SendEnabled = { encode(message: SendEnabled, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.denom); - writer.uint32(16).bool(message.enabled); + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.enabled === true) { + writer.uint32(16).bool(message.enabled); + } return writer; }, @@ -198,6 +204,13 @@ export const SendEnabled = { return message; }, + toJSON(message: SendEnabled): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.enabled !== undefined && (obj.enabled = message.enabled); + return obj; + }, + fromPartial(object: DeepPartial): SendEnabled { const message = { ...baseSendEnabled } as SendEnabled; if (object.denom !== undefined && object.denom !== null) { @@ -212,20 +225,15 @@ export const SendEnabled = { } return message; }, - - toJSON(message: SendEnabled): unknown { - const obj: any = {}; - message.denom !== undefined && (obj.denom = message.denom); - message.enabled !== undefined && (obj.enabled = message.enabled); - return obj; - }, }; const baseInput: object = { address: "" }; export const Input = { encode(message: Input, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.address); + if (message.address !== "") { + writer.uint32(10).string(message.address); + } for (const v of message.coins) { Coin.encode(v!, writer.uint32(18).fork()).ldelim(); } @@ -270,6 +278,17 @@ export const Input = { return message; }, + toJSON(message: Input): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + if (message.coins) { + obj.coins = message.coins.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.coins = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Input { const message = { ...baseInput } as Input; message.coins = []; @@ -285,24 +304,15 @@ export const Input = { } return message; }, - - toJSON(message: Input): unknown { - const obj: any = {}; - message.address !== undefined && (obj.address = message.address); - if (message.coins) { - obj.coins = message.coins.map((e) => (e ? Coin.toJSON(e) : undefined)); - } else { - obj.coins = []; - } - return obj; - }, }; const baseOutput: object = { address: "" }; export const Output = { encode(message: Output, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.address); + if (message.address !== "") { + writer.uint32(10).string(message.address); + } for (const v of message.coins) { Coin.encode(v!, writer.uint32(18).fork()).ldelim(); } @@ -347,6 +357,17 @@ export const Output = { return message; }, + toJSON(message: Output): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + if (message.coins) { + obj.coins = message.coins.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.coins = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Output { const message = { ...baseOutput } as Output; message.coins = []; @@ -362,17 +383,6 @@ export const Output = { } return message; }, - - toJSON(message: Output): unknown { - const obj: any = {}; - message.address !== undefined && (obj.address = message.address); - if (message.coins) { - obj.coins = message.coins.map((e) => (e ? Coin.toJSON(e) : undefined)); - } else { - obj.coins = []; - } - return obj; - }, }; const baseSupply: object = {}; @@ -415,6 +425,16 @@ export const Supply = { return message; }, + toJSON(message: Supply): unknown { + const obj: any = {}; + if (message.total) { + obj.total = message.total.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.total = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Supply { const message = { ...baseSupply } as Supply; message.total = []; @@ -425,24 +445,18 @@ export const Supply = { } return message; }, - - toJSON(message: Supply): unknown { - const obj: any = {}; - if (message.total) { - obj.total = message.total.map((e) => (e ? Coin.toJSON(e) : undefined)); - } else { - obj.total = []; - } - return obj; - }, }; const baseDenomUnit: object = { denom: "", exponent: 0, aliases: "" }; export const DenomUnit = { encode(message: DenomUnit, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.denom); - writer.uint32(16).uint32(message.exponent); + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.exponent !== 0) { + writer.uint32(16).uint32(message.exponent); + } for (const v of message.aliases) { writer.uint32(26).string(v!); } @@ -495,6 +509,18 @@ export const DenomUnit = { return message; }, + toJSON(message: DenomUnit): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.exponent !== undefined && (obj.exponent = message.exponent); + if (message.aliases) { + obj.aliases = message.aliases.map((e) => e); + } else { + obj.aliases = []; + } + return obj; + }, + fromPartial(object: DeepPartial): DenomUnit { const message = { ...baseDenomUnit } as DenomUnit; message.aliases = []; @@ -515,30 +541,24 @@ export const DenomUnit = { } return message; }, - - toJSON(message: DenomUnit): unknown { - const obj: any = {}; - message.denom !== undefined && (obj.denom = message.denom); - message.exponent !== undefined && (obj.exponent = message.exponent); - if (message.aliases) { - obj.aliases = message.aliases.map((e) => e); - } else { - obj.aliases = []; - } - return obj; - }, }; const baseMetadata: object = { description: "", base: "", display: "" }; export const Metadata = { encode(message: Metadata, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.description); + if (message.description !== "") { + writer.uint32(10).string(message.description); + } for (const v of message.denomUnits) { DenomUnit.encode(v!, writer.uint32(18).fork()).ldelim(); } - writer.uint32(26).string(message.base); - writer.uint32(34).string(message.display); + if (message.base !== "") { + writer.uint32(26).string(message.base); + } + if (message.display !== "") { + writer.uint32(34).string(message.display); + } return writer; }, @@ -596,6 +616,19 @@ export const Metadata = { return message; }, + toJSON(message: Metadata): unknown { + const obj: any = {}; + message.description !== undefined && (obj.description = message.description); + if (message.denomUnits) { + obj.denomUnits = message.denomUnits.map((e) => (e ? DenomUnit.toJSON(e) : undefined)); + } else { + obj.denomUnits = []; + } + message.base !== undefined && (obj.base = message.base); + message.display !== undefined && (obj.display = message.display); + return obj; + }, + fromPartial(object: DeepPartial): Metadata { const message = { ...baseMetadata } as Metadata; message.denomUnits = []; @@ -621,19 +654,6 @@ export const Metadata = { } return message; }, - - toJSON(message: Metadata): unknown { - const obj: any = {}; - message.description !== undefined && (obj.description = message.description); - if (message.denomUnits) { - obj.denomUnits = message.denomUnits.map((e) => (e ? DenomUnit.toJSON(e) : undefined)); - } else { - obj.denomUnits = []; - } - message.base !== undefined && (obj.base = message.base); - message.display !== undefined && (obj.display = message.display); - return obj; - }, }; type Builtin = Date | Function | Uint8Array | string | number | undefined | Long; diff --git a/packages/stargate/src/codec/cosmos/bank/v1beta1/query.ts b/packages/stargate/src/codec/cosmos/bank/v1beta1/query.ts index 71004988..b1e07e2f 100644 --- a/packages/stargate/src/codec/cosmos/bank/v1beta1/query.ts +++ b/packages/stargate/src/codec/cosmos/bank/v1beta1/query.ts @@ -79,8 +79,12 @@ const baseQueryBalanceRequest: object = { address: "", denom: "" }; export const QueryBalanceRequest = { encode(message: QueryBalanceRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.address); - writer.uint32(18).string(message.denom); + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.denom !== "") { + writer.uint32(18).string(message.denom); + } return writer; }, @@ -120,6 +124,13 @@ export const QueryBalanceRequest = { return message; }, + toJSON(message: QueryBalanceRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.denom !== undefined && (obj.denom = message.denom); + return obj; + }, + fromPartial(object: DeepPartial): QueryBalanceRequest { const message = { ...baseQueryBalanceRequest } as QueryBalanceRequest; if (object.address !== undefined && object.address !== null) { @@ -134,20 +145,13 @@ export const QueryBalanceRequest = { } return message; }, - - toJSON(message: QueryBalanceRequest): unknown { - const obj: any = {}; - message.address !== undefined && (obj.address = message.address); - message.denom !== undefined && (obj.denom = message.denom); - return obj; - }, }; const baseQueryBalanceResponse: object = {}; export const QueryBalanceResponse = { encode(message: QueryBalanceResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.balance !== undefined && message.balance !== undefined) { + if (message.balance !== undefined) { Coin.encode(message.balance, writer.uint32(10).fork()).ldelim(); } return writer; @@ -181,6 +185,13 @@ export const QueryBalanceResponse = { return message; }, + toJSON(message: QueryBalanceResponse): unknown { + const obj: any = {}; + message.balance !== undefined && + (obj.balance = message.balance ? Coin.toJSON(message.balance) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryBalanceResponse { const message = { ...baseQueryBalanceResponse } as QueryBalanceResponse; if (object.balance !== undefined && object.balance !== null) { @@ -190,21 +201,16 @@ export const QueryBalanceResponse = { } return message; }, - - toJSON(message: QueryBalanceResponse): unknown { - const obj: any = {}; - message.balance !== undefined && - (obj.balance = message.balance ? Coin.toJSON(message.balance) : undefined); - return obj; - }, }; const baseQueryAllBalancesRequest: object = { address: "" }; export const QueryAllBalancesRequest = { encode(message: QueryAllBalancesRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.address); - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -246,6 +252,14 @@ export const QueryAllBalancesRequest = { return message; }, + toJSON(message: QueryAllBalancesRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllBalancesRequest { const message = { ...baseQueryAllBalancesRequest } as QueryAllBalancesRequest; if (object.address !== undefined && object.address !== null) { @@ -260,14 +274,6 @@ export const QueryAllBalancesRequest = { } return message; }, - - toJSON(message: QueryAllBalancesRequest): unknown { - const obj: any = {}; - message.address !== undefined && (obj.address = message.address); - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryAllBalancesResponse: object = {}; @@ -277,7 +283,7 @@ export const QueryAllBalancesResponse = { for (const v of message.balances) { Coin.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -321,6 +327,18 @@ export const QueryAllBalancesResponse = { return message; }, + toJSON(message: QueryAllBalancesResponse): unknown { + const obj: any = {}; + if (message.balances) { + obj.balances = message.balances.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.balances = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllBalancesResponse { const message = { ...baseQueryAllBalancesResponse } as QueryAllBalancesResponse; message.balances = []; @@ -336,18 +354,6 @@ export const QueryAllBalancesResponse = { } return message; }, - - toJSON(message: QueryAllBalancesResponse): unknown { - const obj: any = {}; - if (message.balances) { - obj.balances = message.balances.map((e) => (e ? Coin.toJSON(e) : undefined)); - } else { - obj.balances = []; - } - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryTotalSupplyRequest: object = {}; @@ -377,15 +383,15 @@ export const QueryTotalSupplyRequest = { return message; }, - fromPartial(_: DeepPartial): QueryTotalSupplyRequest { - const message = { ...baseQueryTotalSupplyRequest } as QueryTotalSupplyRequest; - return message; - }, - toJSON(_: QueryTotalSupplyRequest): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): QueryTotalSupplyRequest { + const message = { ...baseQueryTotalSupplyRequest } as QueryTotalSupplyRequest; + return message; + }, }; const baseQueryTotalSupplyResponse: object = {}; @@ -428,6 +434,16 @@ export const QueryTotalSupplyResponse = { return message; }, + toJSON(message: QueryTotalSupplyResponse): unknown { + const obj: any = {}; + if (message.supply) { + obj.supply = message.supply.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.supply = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QueryTotalSupplyResponse { const message = { ...baseQueryTotalSupplyResponse } as QueryTotalSupplyResponse; message.supply = []; @@ -438,23 +454,15 @@ export const QueryTotalSupplyResponse = { } return message; }, - - toJSON(message: QueryTotalSupplyResponse): unknown { - const obj: any = {}; - if (message.supply) { - obj.supply = message.supply.map((e) => (e ? Coin.toJSON(e) : undefined)); - } else { - obj.supply = []; - } - return obj; - }, }; const baseQuerySupplyOfRequest: object = { denom: "" }; export const QuerySupplyOfRequest = { encode(message: QuerySupplyOfRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.denom); + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } return writer; }, @@ -486,6 +494,12 @@ export const QuerySupplyOfRequest = { return message; }, + toJSON(message: QuerySupplyOfRequest): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + return obj; + }, + fromPartial(object: DeepPartial): QuerySupplyOfRequest { const message = { ...baseQuerySupplyOfRequest } as QuerySupplyOfRequest; if (object.denom !== undefined && object.denom !== null) { @@ -495,19 +509,13 @@ export const QuerySupplyOfRequest = { } return message; }, - - toJSON(message: QuerySupplyOfRequest): unknown { - const obj: any = {}; - message.denom !== undefined && (obj.denom = message.denom); - return obj; - }, }; const baseQuerySupplyOfResponse: object = {}; export const QuerySupplyOfResponse = { encode(message: QuerySupplyOfResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.amount !== undefined && message.amount !== undefined) { + if (message.amount !== undefined) { Coin.encode(message.amount, writer.uint32(10).fork()).ldelim(); } return writer; @@ -541,6 +549,12 @@ export const QuerySupplyOfResponse = { return message; }, + toJSON(message: QuerySupplyOfResponse): unknown { + const obj: any = {}; + message.amount !== undefined && (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QuerySupplyOfResponse { const message = { ...baseQuerySupplyOfResponse } as QuerySupplyOfResponse; if (object.amount !== undefined && object.amount !== null) { @@ -550,12 +564,6 @@ export const QuerySupplyOfResponse = { } return message; }, - - toJSON(message: QuerySupplyOfResponse): unknown { - const obj: any = {}; - message.amount !== undefined && (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); - return obj; - }, }; const baseQueryParamsRequest: object = {}; @@ -585,22 +593,22 @@ export const QueryParamsRequest = { return message; }, - fromPartial(_: DeepPartial): QueryParamsRequest { - const message = { ...baseQueryParamsRequest } as QueryParamsRequest; - return message; - }, - toJSON(_: QueryParamsRequest): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, }; const baseQueryParamsResponse: object = {}; export const QueryParamsResponse = { encode(message: QueryParamsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.params !== undefined && message.params !== undefined) { + if (message.params !== undefined) { Params.encode(message.params, writer.uint32(10).fork()).ldelim(); } return writer; @@ -634,6 +642,12 @@ export const QueryParamsResponse = { return message; }, + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { const message = { ...baseQueryParamsResponse } as QueryParamsResponse; if (object.params !== undefined && object.params !== null) { @@ -643,12 +657,6 @@ export const QueryParamsResponse = { } return message; }, - - toJSON(message: QueryParamsResponse): unknown { - const obj: any = {}; - message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); - return obj; - }, }; /** Query defines the gRPC querier service. */ diff --git a/packages/stargate/src/codec/cosmos/bank/v1beta1/tx.ts b/packages/stargate/src/codec/cosmos/bank/v1beta1/tx.ts index 568ddadf..5aeee5b9 100644 --- a/packages/stargate/src/codec/cosmos/bank/v1beta1/tx.ts +++ b/packages/stargate/src/codec/cosmos/bank/v1beta1/tx.ts @@ -29,8 +29,12 @@ const baseMsgSend: object = { fromAddress: "", toAddress: "" }; export const MsgSend = { encode(message: MsgSend, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.fromAddress); - writer.uint32(18).string(message.toAddress); + if (message.fromAddress !== "") { + writer.uint32(10).string(message.fromAddress); + } + if (message.toAddress !== "") { + writer.uint32(18).string(message.toAddress); + } for (const v of message.amount) { Coin.encode(v!, writer.uint32(26).fork()).ldelim(); } @@ -83,6 +87,18 @@ export const MsgSend = { return message; }, + toJSON(message: MsgSend): unknown { + const obj: any = {}; + message.fromAddress !== undefined && (obj.fromAddress = message.fromAddress); + message.toAddress !== undefined && (obj.toAddress = message.toAddress); + if (message.amount) { + obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.amount = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgSend { const message = { ...baseMsgSend } as MsgSend; message.amount = []; @@ -103,18 +119,6 @@ export const MsgSend = { } return message; }, - - toJSON(message: MsgSend): unknown { - const obj: any = {}; - message.fromAddress !== undefined && (obj.fromAddress = message.fromAddress); - message.toAddress !== undefined && (obj.toAddress = message.toAddress); - if (message.amount) { - obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); - } else { - obj.amount = []; - } - return obj; - }, }; const baseMsgSendResponse: object = {}; @@ -144,15 +148,15 @@ export const MsgSendResponse = { return message; }, - fromPartial(_: DeepPartial): MsgSendResponse { - const message = { ...baseMsgSendResponse } as MsgSendResponse; - return message; - }, - toJSON(_: MsgSendResponse): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): MsgSendResponse { + const message = { ...baseMsgSendResponse } as MsgSendResponse; + return message; + }, }; const baseMsgMultiSend: object = {}; @@ -208,6 +212,21 @@ export const MsgMultiSend = { return message; }, + toJSON(message: MsgMultiSend): unknown { + const obj: any = {}; + if (message.inputs) { + obj.inputs = message.inputs.map((e) => (e ? Input.toJSON(e) : undefined)); + } else { + obj.inputs = []; + } + if (message.outputs) { + obj.outputs = message.outputs.map((e) => (e ? Output.toJSON(e) : undefined)); + } else { + obj.outputs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgMultiSend { const message = { ...baseMsgMultiSend } as MsgMultiSend; message.inputs = []; @@ -224,21 +243,6 @@ export const MsgMultiSend = { } return message; }, - - toJSON(message: MsgMultiSend): unknown { - const obj: any = {}; - if (message.inputs) { - obj.inputs = message.inputs.map((e) => (e ? Input.toJSON(e) : undefined)); - } else { - obj.inputs = []; - } - if (message.outputs) { - obj.outputs = message.outputs.map((e) => (e ? Output.toJSON(e) : undefined)); - } else { - obj.outputs = []; - } - return obj; - }, }; const baseMsgMultiSendResponse: object = {}; @@ -268,15 +272,15 @@ export const MsgMultiSendResponse = { return message; }, - fromPartial(_: DeepPartial): MsgMultiSendResponse { - const message = { ...baseMsgMultiSendResponse } as MsgMultiSendResponse; - return message; - }, - toJSON(_: MsgMultiSendResponse): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): MsgMultiSendResponse { + const message = { ...baseMsgMultiSendResponse } as MsgMultiSendResponse; + return message; + }, }; /** Msg defines the bank Msg service. */ diff --git a/packages/stargate/src/codec/cosmos/base/abci/v1beta1/abci.ts b/packages/stargate/src/codec/cosmos/base/abci/v1beta1/abci.ts index d759cc32..2feb981f 100644 --- a/packages/stargate/src/codec/cosmos/base/abci/v1beta1/abci.ts +++ b/packages/stargate/src/codec/cosmos/base/abci/v1beta1/abci.ts @@ -154,22 +154,42 @@ const baseTxResponse: object = { export const TxResponse = { encode(message: TxResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int64(message.height); - writer.uint32(18).string(message.txhash); - writer.uint32(26).string(message.codespace); - writer.uint32(32).uint32(message.code); - writer.uint32(42).string(message.data); - writer.uint32(50).string(message.rawLog); + if (!message.height.isZero()) { + writer.uint32(8).int64(message.height); + } + if (message.txhash !== "") { + writer.uint32(18).string(message.txhash); + } + if (message.codespace !== "") { + writer.uint32(26).string(message.codespace); + } + if (message.code !== 0) { + writer.uint32(32).uint32(message.code); + } + if (message.data !== "") { + writer.uint32(42).string(message.data); + } + if (message.rawLog !== "") { + writer.uint32(50).string(message.rawLog); + } for (const v of message.logs) { ABCIMessageLog.encode(v!, writer.uint32(58).fork()).ldelim(); } - writer.uint32(66).string(message.info); - writer.uint32(72).int64(message.gasWanted); - writer.uint32(80).int64(message.gasUsed); - if (message.tx !== undefined && message.tx !== undefined) { + if (message.info !== "") { + writer.uint32(66).string(message.info); + } + if (!message.gasWanted.isZero()) { + writer.uint32(72).int64(message.gasWanted); + } + if (!message.gasUsed.isZero()) { + writer.uint32(80).int64(message.gasUsed); + } + if (message.tx !== undefined) { Any.encode(message.tx, writer.uint32(90).fork()).ldelim(); } - writer.uint32(98).string(message.timestamp); + if (message.timestamp !== "") { + writer.uint32(98).string(message.timestamp); + } return writer; }, @@ -291,6 +311,27 @@ export const TxResponse = { return message; }, + toJSON(message: TxResponse): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + message.txhash !== undefined && (obj.txhash = message.txhash); + message.codespace !== undefined && (obj.codespace = message.codespace); + message.code !== undefined && (obj.code = message.code); + message.data !== undefined && (obj.data = message.data); + message.rawLog !== undefined && (obj.rawLog = message.rawLog); + if (message.logs) { + obj.logs = message.logs.map((e) => (e ? ABCIMessageLog.toJSON(e) : undefined)); + } else { + obj.logs = []; + } + message.info !== undefined && (obj.info = message.info); + message.gasWanted !== undefined && (obj.gasWanted = (message.gasWanted || Long.ZERO).toString()); + message.gasUsed !== undefined && (obj.gasUsed = (message.gasUsed || Long.ZERO).toString()); + message.tx !== undefined && (obj.tx = message.tx ? Any.toJSON(message.tx) : undefined); + message.timestamp !== undefined && (obj.timestamp = message.timestamp); + return obj; + }, + fromPartial(object: DeepPartial): TxResponse { const message = { ...baseTxResponse } as TxResponse; message.logs = []; @@ -356,35 +397,18 @@ export const TxResponse = { } return message; }, - - toJSON(message: TxResponse): unknown { - const obj: any = {}; - message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); - message.txhash !== undefined && (obj.txhash = message.txhash); - message.codespace !== undefined && (obj.codespace = message.codespace); - message.code !== undefined && (obj.code = message.code); - message.data !== undefined && (obj.data = message.data); - message.rawLog !== undefined && (obj.rawLog = message.rawLog); - if (message.logs) { - obj.logs = message.logs.map((e) => (e ? ABCIMessageLog.toJSON(e) : undefined)); - } else { - obj.logs = []; - } - message.info !== undefined && (obj.info = message.info); - message.gasWanted !== undefined && (obj.gasWanted = (message.gasWanted || Long.ZERO).toString()); - message.gasUsed !== undefined && (obj.gasUsed = (message.gasUsed || Long.ZERO).toString()); - message.tx !== undefined && (obj.tx = message.tx ? Any.toJSON(message.tx) : undefined); - message.timestamp !== undefined && (obj.timestamp = message.timestamp); - return obj; - }, }; const baseABCIMessageLog: object = { msgIndex: 0, log: "" }; export const ABCIMessageLog = { encode(message: ABCIMessageLog, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint32(message.msgIndex); - writer.uint32(18).string(message.log); + if (message.msgIndex !== 0) { + writer.uint32(8).uint32(message.msgIndex); + } + if (message.log !== "") { + writer.uint32(18).string(message.log); + } for (const v of message.events) { StringEvent.encode(v!, writer.uint32(26).fork()).ldelim(); } @@ -437,6 +461,18 @@ export const ABCIMessageLog = { return message; }, + toJSON(message: ABCIMessageLog): unknown { + const obj: any = {}; + message.msgIndex !== undefined && (obj.msgIndex = message.msgIndex); + message.log !== undefined && (obj.log = message.log); + if (message.events) { + obj.events = message.events.map((e) => (e ? StringEvent.toJSON(e) : undefined)); + } else { + obj.events = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ABCIMessageLog { const message = { ...baseABCIMessageLog } as ABCIMessageLog; message.events = []; @@ -457,25 +493,15 @@ export const ABCIMessageLog = { } return message; }, - - toJSON(message: ABCIMessageLog): unknown { - const obj: any = {}; - message.msgIndex !== undefined && (obj.msgIndex = message.msgIndex); - message.log !== undefined && (obj.log = message.log); - if (message.events) { - obj.events = message.events.map((e) => (e ? StringEvent.toJSON(e) : undefined)); - } else { - obj.events = []; - } - return obj; - }, }; const baseStringEvent: object = { type: "" }; export const StringEvent = { encode(message: StringEvent, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.type); + if (message.type !== "") { + writer.uint32(10).string(message.type); + } for (const v of message.attributes) { Attribute.encode(v!, writer.uint32(18).fork()).ldelim(); } @@ -520,6 +546,17 @@ export const StringEvent = { return message; }, + toJSON(message: StringEvent): unknown { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + if (message.attributes) { + obj.attributes = message.attributes.map((e) => (e ? Attribute.toJSON(e) : undefined)); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial(object: DeepPartial): StringEvent { const message = { ...baseStringEvent } as StringEvent; message.attributes = []; @@ -535,25 +572,18 @@ export const StringEvent = { } return message; }, - - toJSON(message: StringEvent): unknown { - const obj: any = {}; - message.type !== undefined && (obj.type = message.type); - if (message.attributes) { - obj.attributes = message.attributes.map((e) => (e ? Attribute.toJSON(e) : undefined)); - } else { - obj.attributes = []; - } - return obj; - }, }; const baseAttribute: object = { key: "", value: "" }; export const Attribute = { encode(message: Attribute, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.key); - writer.uint32(18).string(message.value); + if (message.key !== "") { + writer.uint32(10).string(message.key); + } + if (message.value !== "") { + writer.uint32(18).string(message.value); + } return writer; }, @@ -593,6 +623,13 @@ export const Attribute = { return message; }, + toJSON(message: Attribute): unknown { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): Attribute { const message = { ...baseAttribute } as Attribute; if (object.key !== undefined && object.key !== null) { @@ -607,21 +644,18 @@ export const Attribute = { } return message; }, - - toJSON(message: Attribute): unknown { - const obj: any = {}; - message.key !== undefined && (obj.key = message.key); - message.value !== undefined && (obj.value = message.value); - return obj; - }, }; const baseGasInfo: object = { gasWanted: Long.UZERO, gasUsed: Long.UZERO }; export const GasInfo = { encode(message: GasInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.gasWanted); - writer.uint32(16).uint64(message.gasUsed); + if (!message.gasWanted.isZero()) { + writer.uint32(8).uint64(message.gasWanted); + } + if (!message.gasUsed.isZero()) { + writer.uint32(16).uint64(message.gasUsed); + } return writer; }, @@ -661,6 +695,13 @@ export const GasInfo = { return message; }, + toJSON(message: GasInfo): unknown { + const obj: any = {}; + message.gasWanted !== undefined && (obj.gasWanted = (message.gasWanted || Long.UZERO).toString()); + message.gasUsed !== undefined && (obj.gasUsed = (message.gasUsed || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): GasInfo { const message = { ...baseGasInfo } as GasInfo; if (object.gasWanted !== undefined && object.gasWanted !== null) { @@ -675,21 +716,18 @@ export const GasInfo = { } return message; }, - - toJSON(message: GasInfo): unknown { - const obj: any = {}; - message.gasWanted !== undefined && (obj.gasWanted = (message.gasWanted || Long.UZERO).toString()); - message.gasUsed !== undefined && (obj.gasUsed = (message.gasUsed || Long.UZERO).toString()); - return obj; - }, }; const baseResult: object = { log: "" }; export const Result = { encode(message: Result, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.data); - writer.uint32(18).string(message.log); + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } + if (message.log !== "") { + writer.uint32(18).string(message.log); + } for (const v of message.events) { Event.encode(v!, writer.uint32(26).fork()).ldelim(); } @@ -740,6 +778,19 @@ export const Result = { return message; }, + toJSON(message: Result): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + message.log !== undefined && (obj.log = message.log); + if (message.events) { + obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); + } else { + obj.events = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Result { const message = { ...baseResult } as Result; message.events = []; @@ -760,29 +811,16 @@ export const Result = { } return message; }, - - toJSON(message: Result): unknown { - const obj: any = {}; - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); - message.log !== undefined && (obj.log = message.log); - if (message.events) { - obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); - } else { - obj.events = []; - } - return obj; - }, }; const baseSimulationResponse: object = {}; export const SimulationResponse = { encode(message: SimulationResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.gasInfo !== undefined && message.gasInfo !== undefined) { + if (message.gasInfo !== undefined) { GasInfo.encode(message.gasInfo, writer.uint32(10).fork()).ldelim(); } - if (message.result !== undefined && message.result !== undefined) { + if (message.result !== undefined) { Result.encode(message.result, writer.uint32(18).fork()).ldelim(); } return writer; @@ -824,6 +862,14 @@ export const SimulationResponse = { return message; }, + toJSON(message: SimulationResponse): unknown { + const obj: any = {}; + message.gasInfo !== undefined && + (obj.gasInfo = message.gasInfo ? GasInfo.toJSON(message.gasInfo) : undefined); + message.result !== undefined && (obj.result = message.result ? Result.toJSON(message.result) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): SimulationResponse { const message = { ...baseSimulationResponse } as SimulationResponse; if (object.gasInfo !== undefined && object.gasInfo !== null) { @@ -838,22 +884,18 @@ export const SimulationResponse = { } return message; }, - - toJSON(message: SimulationResponse): unknown { - const obj: any = {}; - message.gasInfo !== undefined && - (obj.gasInfo = message.gasInfo ? GasInfo.toJSON(message.gasInfo) : undefined); - message.result !== undefined && (obj.result = message.result ? Result.toJSON(message.result) : undefined); - return obj; - }, }; const baseMsgData: object = { msgType: "" }; export const MsgData = { encode(message: MsgData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.msgType); - writer.uint32(18).bytes(message.data); + if (message.msgType !== "") { + writer.uint32(10).string(message.msgType); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } return writer; }, @@ -891,6 +933,14 @@ export const MsgData = { return message; }, + toJSON(message: MsgData): unknown { + const obj: any = {}; + message.msgType !== undefined && (obj.msgType = message.msgType); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): MsgData { const message = { ...baseMsgData } as MsgData; if (object.msgType !== undefined && object.msgType !== null) { @@ -905,14 +955,6 @@ export const MsgData = { } return message; }, - - toJSON(message: MsgData): unknown { - const obj: any = {}; - message.msgType !== undefined && (obj.msgType = message.msgType); - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); - return obj; - }, }; const baseTxMsgData: object = {}; @@ -955,6 +997,16 @@ export const TxMsgData = { return message; }, + toJSON(message: TxMsgData): unknown { + const obj: any = {}; + if (message.data) { + obj.data = message.data.map((e) => (e ? MsgData.toJSON(e) : undefined)); + } else { + obj.data = []; + } + return obj; + }, + fromPartial(object: DeepPartial): TxMsgData { const message = { ...baseTxMsgData } as TxMsgData; message.data = []; @@ -965,16 +1017,6 @@ export const TxMsgData = { } return message; }, - - toJSON(message: TxMsgData): unknown { - const obj: any = {}; - if (message.data) { - obj.data = message.data.map((e) => (e ? MsgData.toJSON(e) : undefined)); - } else { - obj.data = []; - } - return obj; - }, }; const baseSearchTxsResult: object = { @@ -987,11 +1029,21 @@ const baseSearchTxsResult: object = { export const SearchTxsResult = { encode(message: SearchTxsResult, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.totalCount); - writer.uint32(16).uint64(message.count); - writer.uint32(24).uint64(message.pageNumber); - writer.uint32(32).uint64(message.pageTotal); - writer.uint32(40).uint64(message.limit); + if (!message.totalCount.isZero()) { + writer.uint32(8).uint64(message.totalCount); + } + if (!message.count.isZero()) { + writer.uint32(16).uint64(message.count); + } + if (!message.pageNumber.isZero()) { + writer.uint32(24).uint64(message.pageNumber); + } + if (!message.pageTotal.isZero()) { + writer.uint32(32).uint64(message.pageTotal); + } + if (!message.limit.isZero()) { + writer.uint32(40).uint64(message.limit); + } for (const v of message.txs) { TxResponse.encode(v!, writer.uint32(50).fork()).ldelim(); } @@ -1068,6 +1120,21 @@ export const SearchTxsResult = { return message; }, + toJSON(message: SearchTxsResult): unknown { + const obj: any = {}; + message.totalCount !== undefined && (obj.totalCount = (message.totalCount || Long.UZERO).toString()); + message.count !== undefined && (obj.count = (message.count || Long.UZERO).toString()); + message.pageNumber !== undefined && (obj.pageNumber = (message.pageNumber || Long.UZERO).toString()); + message.pageTotal !== undefined && (obj.pageTotal = (message.pageTotal || Long.UZERO).toString()); + message.limit !== undefined && (obj.limit = (message.limit || Long.UZERO).toString()); + if (message.txs) { + obj.txs = message.txs.map((e) => (e ? TxResponse.toJSON(e) : undefined)); + } else { + obj.txs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): SearchTxsResult { const message = { ...baseSearchTxsResult } as SearchTxsResult; message.txs = []; @@ -1103,21 +1170,6 @@ export const SearchTxsResult = { } return message; }, - - toJSON(message: SearchTxsResult): unknown { - const obj: any = {}; - message.totalCount !== undefined && (obj.totalCount = (message.totalCount || Long.UZERO).toString()); - message.count !== undefined && (obj.count = (message.count || Long.UZERO).toString()); - message.pageNumber !== undefined && (obj.pageNumber = (message.pageNumber || Long.UZERO).toString()); - message.pageTotal !== undefined && (obj.pageTotal = (message.pageTotal || Long.UZERO).toString()); - message.limit !== undefined && (obj.limit = (message.limit || Long.UZERO).toString()); - if (message.txs) { - obj.txs = message.txs.map((e) => (e ? TxResponse.toJSON(e) : undefined)); - } else { - obj.txs = []; - } - return obj; - }, }; declare var self: any | undefined; @@ -1127,7 +1179,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/stargate/src/codec/cosmos/base/query/v1beta1/pagination.ts b/packages/stargate/src/codec/cosmos/base/query/v1beta1/pagination.ts index 54fe9e9e..45715b50 100644 --- a/packages/stargate/src/codec/cosmos/base/query/v1beta1/pagination.ts +++ b/packages/stargate/src/codec/cosmos/base/query/v1beta1/pagination.ts @@ -66,10 +66,18 @@ const basePageRequest: object = { offset: Long.UZERO, limit: Long.UZERO, countTo export const PageRequest = { encode(message: PageRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.key); - writer.uint32(16).uint64(message.offset); - writer.uint32(24).uint64(message.limit); - writer.uint32(32).bool(message.countTotal); + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (!message.offset.isZero()) { + writer.uint32(16).uint64(message.offset); + } + if (!message.limit.isZero()) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } return writer; }, @@ -123,6 +131,16 @@ export const PageRequest = { return message; }, + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.offset !== undefined && (obj.offset = (message.offset || Long.UZERO).toString()); + message.limit !== undefined && (obj.limit = (message.limit || Long.UZERO).toString()); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + return obj; + }, + fromPartial(object: DeepPartial): PageRequest { const message = { ...basePageRequest } as PageRequest; if (object.key !== undefined && object.key !== null) { @@ -147,24 +165,18 @@ export const PageRequest = { } return message; }, - - toJSON(message: PageRequest): unknown { - const obj: any = {}; - message.key !== undefined && - (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); - message.offset !== undefined && (obj.offset = (message.offset || Long.UZERO).toString()); - message.limit !== undefined && (obj.limit = (message.limit || Long.UZERO).toString()); - message.countTotal !== undefined && (obj.countTotal = message.countTotal); - return obj; - }, }; const basePageResponse: object = { total: Long.UZERO }; export const PageResponse = { encode(message: PageResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.nextKey); - writer.uint32(16).uint64(message.total); + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (!message.total.isZero()) { + writer.uint32(16).uint64(message.total); + } return writer; }, @@ -202,6 +214,14 @@ export const PageResponse = { return message; }, + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes(message.nextKey !== undefined ? message.nextKey : new Uint8Array())); + message.total !== undefined && (obj.total = (message.total || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): PageResponse { const message = { ...basePageResponse } as PageResponse; if (object.nextKey !== undefined && object.nextKey !== null) { @@ -216,14 +236,6 @@ export const PageResponse = { } return message; }, - - toJSON(message: PageResponse): unknown { - const obj: any = {}; - message.nextKey !== undefined && - (obj.nextKey = base64FromBytes(message.nextKey !== undefined ? message.nextKey : new Uint8Array())); - message.total !== undefined && (obj.total = (message.total || Long.UZERO).toString()); - return obj; - }, }; declare var self: any | undefined; @@ -233,7 +245,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/stargate/src/codec/cosmos/base/v1beta1/coin.ts b/packages/stargate/src/codec/cosmos/base/v1beta1/coin.ts index 9e54cfd1..e682a9a7 100644 --- a/packages/stargate/src/codec/cosmos/base/v1beta1/coin.ts +++ b/packages/stargate/src/codec/cosmos/base/v1beta1/coin.ts @@ -40,8 +40,12 @@ const baseCoin: object = { denom: "", amount: "" }; export const Coin = { encode(message: Coin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.denom); - writer.uint32(18).string(message.amount); + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } return writer; }, @@ -81,6 +85,13 @@ export const Coin = { return message; }, + toJSON(message: Coin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + fromPartial(object: DeepPartial): Coin { const message = { ...baseCoin } as Coin; if (object.denom !== undefined && object.denom !== null) { @@ -95,21 +106,18 @@ export const Coin = { } return message; }, - - toJSON(message: Coin): unknown { - const obj: any = {}; - message.denom !== undefined && (obj.denom = message.denom); - message.amount !== undefined && (obj.amount = message.amount); - return obj; - }, }; const baseDecCoin: object = { denom: "", amount: "" }; export const DecCoin = { encode(message: DecCoin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.denom); - writer.uint32(18).string(message.amount); + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } return writer; }, @@ -149,6 +157,13 @@ export const DecCoin = { return message; }, + toJSON(message: DecCoin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + fromPartial(object: DeepPartial): DecCoin { const message = { ...baseDecCoin } as DecCoin; if (object.denom !== undefined && object.denom !== null) { @@ -163,20 +178,15 @@ export const DecCoin = { } return message; }, - - toJSON(message: DecCoin): unknown { - const obj: any = {}; - message.denom !== undefined && (obj.denom = message.denom); - message.amount !== undefined && (obj.amount = message.amount); - return obj; - }, }; const baseIntProto: object = { int: "" }; export const IntProto = { encode(message: IntProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.int); + if (message.int !== "") { + writer.uint32(10).string(message.int); + } return writer; }, @@ -208,6 +218,12 @@ export const IntProto = { return message; }, + toJSON(message: IntProto): unknown { + const obj: any = {}; + message.int !== undefined && (obj.int = message.int); + return obj; + }, + fromPartial(object: DeepPartial): IntProto { const message = { ...baseIntProto } as IntProto; if (object.int !== undefined && object.int !== null) { @@ -217,19 +233,15 @@ export const IntProto = { } return message; }, - - toJSON(message: IntProto): unknown { - const obj: any = {}; - message.int !== undefined && (obj.int = message.int); - return obj; - }, }; const baseDecProto: object = { dec: "" }; export const DecProto = { encode(message: DecProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.dec); + if (message.dec !== "") { + writer.uint32(10).string(message.dec); + } return writer; }, @@ -261,6 +273,12 @@ export const DecProto = { return message; }, + toJSON(message: DecProto): unknown { + const obj: any = {}; + message.dec !== undefined && (obj.dec = message.dec); + return obj; + }, + fromPartial(object: DeepPartial): DecProto { const message = { ...baseDecProto } as DecProto; if (object.dec !== undefined && object.dec !== null) { @@ -270,12 +288,6 @@ export const DecProto = { } return message; }, - - toJSON(message: DecProto): unknown { - const obj: any = {}; - message.dec !== undefined && (obj.dec = message.dec); - return obj; - }, }; type Builtin = Date | Function | Uint8Array | string | number | undefined | Long; diff --git a/packages/stargate/src/codec/cosmos/crypto/multisig/v1beta1/multisig.ts b/packages/stargate/src/codec/cosmos/crypto/multisig/v1beta1/multisig.ts index 49842d5f..11fdaf82 100644 --- a/packages/stargate/src/codec/cosmos/crypto/multisig/v1beta1/multisig.ts +++ b/packages/stargate/src/codec/cosmos/crypto/multisig/v1beta1/multisig.ts @@ -64,6 +64,16 @@ export const MultiSignature = { return message; }, + toJSON(message: MultiSignature): unknown { + const obj: any = {}; + if (message.signatures) { + obj.signatures = message.signatures.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.signatures = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MultiSignature { const message = { ...baseMultiSignature } as MultiSignature; message.signatures = []; @@ -74,24 +84,18 @@ export const MultiSignature = { } return message; }, - - toJSON(message: MultiSignature): unknown { - const obj: any = {}; - if (message.signatures) { - obj.signatures = message.signatures.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); - } else { - obj.signatures = []; - } - return obj; - }, }; const baseCompactBitArray: object = { extraBitsStored: 0 }; export const CompactBitArray = { encode(message: CompactBitArray, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint32(message.extraBitsStored); - writer.uint32(18).bytes(message.elems); + if (message.extraBitsStored !== 0) { + writer.uint32(8).uint32(message.extraBitsStored); + } + if (message.elems.length !== 0) { + writer.uint32(18).bytes(message.elems); + } return writer; }, @@ -129,6 +133,14 @@ export const CompactBitArray = { return message; }, + toJSON(message: CompactBitArray): unknown { + const obj: any = {}; + message.extraBitsStored !== undefined && (obj.extraBitsStored = message.extraBitsStored); + message.elems !== undefined && + (obj.elems = base64FromBytes(message.elems !== undefined ? message.elems : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): CompactBitArray { const message = { ...baseCompactBitArray } as CompactBitArray; if (object.extraBitsStored !== undefined && object.extraBitsStored !== null) { @@ -143,14 +155,6 @@ export const CompactBitArray = { } return message; }, - - toJSON(message: CompactBitArray): unknown { - const obj: any = {}; - message.extraBitsStored !== undefined && (obj.extraBitsStored = message.extraBitsStored); - message.elems !== undefined && - (obj.elems = base64FromBytes(message.elems !== undefined ? message.elems : new Uint8Array())); - return obj; - }, }; declare var self: any | undefined; @@ -160,7 +164,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/stargate/src/codec/cosmos/crypto/secp256k1/keys.ts b/packages/stargate/src/codec/cosmos/crypto/secp256k1/keys.ts index 13147ba8..984a320a 100644 --- a/packages/stargate/src/codec/cosmos/crypto/secp256k1/keys.ts +++ b/packages/stargate/src/codec/cosmos/crypto/secp256k1/keys.ts @@ -24,7 +24,9 @@ const basePubKey: object = {}; export const PubKey = { encode(message: PubKey, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.key); + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } return writer; }, @@ -54,6 +56,13 @@ export const PubKey = { return message; }, + toJSON(message: PubKey): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): PubKey { const message = { ...basePubKey } as PubKey; if (object.key !== undefined && object.key !== null) { @@ -63,20 +72,15 @@ export const PubKey = { } return message; }, - - toJSON(message: PubKey): unknown { - const obj: any = {}; - message.key !== undefined && - (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); - return obj; - }, }; const basePrivKey: object = {}; export const PrivKey = { encode(message: PrivKey, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.key); + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } return writer; }, @@ -106,6 +110,13 @@ export const PrivKey = { return message; }, + toJSON(message: PrivKey): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): PrivKey { const message = { ...basePrivKey } as PrivKey; if (object.key !== undefined && object.key !== null) { @@ -115,13 +126,6 @@ export const PrivKey = { } return message; }, - - toJSON(message: PrivKey): unknown { - const obj: any = {}; - message.key !== undefined && - (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); - return obj; - }, }; declare var self: any | undefined; @@ -131,7 +135,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/stargate/src/codec/cosmos/distribution/v1beta1/distribution.ts b/packages/stargate/src/codec/cosmos/distribution/v1beta1/distribution.ts index a187528a..b50ba1b5 100644 --- a/packages/stargate/src/codec/cosmos/distribution/v1beta1/distribution.ts +++ b/packages/stargate/src/codec/cosmos/distribution/v1beta1/distribution.ts @@ -135,10 +135,18 @@ const baseParams: object = { export const Params = { encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.communityTax); - writer.uint32(18).string(message.baseProposerReward); - writer.uint32(26).string(message.bonusProposerReward); - writer.uint32(32).bool(message.withdrawAddrEnabled); + if (message.communityTax !== "") { + writer.uint32(10).string(message.communityTax); + } + if (message.baseProposerReward !== "") { + writer.uint32(18).string(message.baseProposerReward); + } + if (message.bonusProposerReward !== "") { + writer.uint32(26).string(message.bonusProposerReward); + } + if (message.withdrawAddrEnabled === true) { + writer.uint32(32).bool(message.withdrawAddrEnabled); + } return writer; }, @@ -194,6 +202,15 @@ export const Params = { return message; }, + toJSON(message: Params): unknown { + const obj: any = {}; + message.communityTax !== undefined && (obj.communityTax = message.communityTax); + message.baseProposerReward !== undefined && (obj.baseProposerReward = message.baseProposerReward); + message.bonusProposerReward !== undefined && (obj.bonusProposerReward = message.bonusProposerReward); + message.withdrawAddrEnabled !== undefined && (obj.withdrawAddrEnabled = message.withdrawAddrEnabled); + return obj; + }, + fromPartial(object: DeepPartial): Params { const message = { ...baseParams } as Params; if (object.communityTax !== undefined && object.communityTax !== null) { @@ -218,15 +235,6 @@ export const Params = { } return message; }, - - toJSON(message: Params): unknown { - const obj: any = {}; - message.communityTax !== undefined && (obj.communityTax = message.communityTax); - message.baseProposerReward !== undefined && (obj.baseProposerReward = message.baseProposerReward); - message.bonusProposerReward !== undefined && (obj.bonusProposerReward = message.bonusProposerReward); - message.withdrawAddrEnabled !== undefined && (obj.withdrawAddrEnabled = message.withdrawAddrEnabled); - return obj; - }, }; const baseValidatorHistoricalRewards: object = { referenceCount: 0 }; @@ -236,7 +244,9 @@ export const ValidatorHistoricalRewards = { for (const v of message.cumulativeRewardRatio) { DecCoin.encode(v!, writer.uint32(10).fork()).ldelim(); } - writer.uint32(16).uint32(message.referenceCount); + if (message.referenceCount !== 0) { + writer.uint32(16).uint32(message.referenceCount); + } return writer; }, @@ -278,6 +288,19 @@ export const ValidatorHistoricalRewards = { return message; }, + toJSON(message: ValidatorHistoricalRewards): unknown { + const obj: any = {}; + if (message.cumulativeRewardRatio) { + obj.cumulativeRewardRatio = message.cumulativeRewardRatio.map((e) => + e ? DecCoin.toJSON(e) : undefined, + ); + } else { + obj.cumulativeRewardRatio = []; + } + message.referenceCount !== undefined && (obj.referenceCount = message.referenceCount); + return obj; + }, + fromPartial(object: DeepPartial): ValidatorHistoricalRewards { const message = { ...baseValidatorHistoricalRewards } as ValidatorHistoricalRewards; message.cumulativeRewardRatio = []; @@ -293,19 +316,6 @@ export const ValidatorHistoricalRewards = { } return message; }, - - toJSON(message: ValidatorHistoricalRewards): unknown { - const obj: any = {}; - if (message.cumulativeRewardRatio) { - obj.cumulativeRewardRatio = message.cumulativeRewardRatio.map((e) => - e ? DecCoin.toJSON(e) : undefined, - ); - } else { - obj.cumulativeRewardRatio = []; - } - message.referenceCount !== undefined && (obj.referenceCount = message.referenceCount); - return obj; - }, }; const baseValidatorCurrentRewards: object = { period: Long.UZERO }; @@ -315,7 +325,9 @@ export const ValidatorCurrentRewards = { for (const v of message.rewards) { DecCoin.encode(v!, writer.uint32(10).fork()).ldelim(); } - writer.uint32(16).uint64(message.period); + if (!message.period.isZero()) { + writer.uint32(16).uint64(message.period); + } return writer; }, @@ -357,6 +369,17 @@ export const ValidatorCurrentRewards = { return message; }, + toJSON(message: ValidatorCurrentRewards): unknown { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map((e) => (e ? DecCoin.toJSON(e) : undefined)); + } else { + obj.rewards = []; + } + message.period !== undefined && (obj.period = (message.period || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): ValidatorCurrentRewards { const message = { ...baseValidatorCurrentRewards } as ValidatorCurrentRewards; message.rewards = []; @@ -372,17 +395,6 @@ export const ValidatorCurrentRewards = { } return message; }, - - toJSON(message: ValidatorCurrentRewards): unknown { - const obj: any = {}; - if (message.rewards) { - obj.rewards = message.rewards.map((e) => (e ? DecCoin.toJSON(e) : undefined)); - } else { - obj.rewards = []; - } - message.period !== undefined && (obj.period = (message.period || Long.UZERO).toString()); - return obj; - }, }; const baseValidatorAccumulatedCommission: object = {}; @@ -425,6 +437,16 @@ export const ValidatorAccumulatedCommission = { return message; }, + toJSON(message: ValidatorAccumulatedCommission): unknown { + const obj: any = {}; + if (message.commission) { + obj.commission = message.commission.map((e) => (e ? DecCoin.toJSON(e) : undefined)); + } else { + obj.commission = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ValidatorAccumulatedCommission { const message = { ...baseValidatorAccumulatedCommission } as ValidatorAccumulatedCommission; message.commission = []; @@ -435,16 +457,6 @@ export const ValidatorAccumulatedCommission = { } return message; }, - - toJSON(message: ValidatorAccumulatedCommission): unknown { - const obj: any = {}; - if (message.commission) { - obj.commission = message.commission.map((e) => (e ? DecCoin.toJSON(e) : undefined)); - } else { - obj.commission = []; - } - return obj; - }, }; const baseValidatorOutstandingRewards: object = {}; @@ -487,6 +499,16 @@ export const ValidatorOutstandingRewards = { return message; }, + toJSON(message: ValidatorOutstandingRewards): unknown { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map((e) => (e ? DecCoin.toJSON(e) : undefined)); + } else { + obj.rewards = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ValidatorOutstandingRewards { const message = { ...baseValidatorOutstandingRewards } as ValidatorOutstandingRewards; message.rewards = []; @@ -497,24 +519,18 @@ export const ValidatorOutstandingRewards = { } return message; }, - - toJSON(message: ValidatorOutstandingRewards): unknown { - const obj: any = {}; - if (message.rewards) { - obj.rewards = message.rewards.map((e) => (e ? DecCoin.toJSON(e) : undefined)); - } else { - obj.rewards = []; - } - return obj; - }, }; const baseValidatorSlashEvent: object = { validatorPeriod: Long.UZERO, fraction: "" }; export const ValidatorSlashEvent = { encode(message: ValidatorSlashEvent, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.validatorPeriod); - writer.uint32(18).string(message.fraction); + if (!message.validatorPeriod.isZero()) { + writer.uint32(8).uint64(message.validatorPeriod); + } + if (message.fraction !== "") { + writer.uint32(18).string(message.fraction); + } return writer; }, @@ -554,6 +570,14 @@ export const ValidatorSlashEvent = { return message; }, + toJSON(message: ValidatorSlashEvent): unknown { + const obj: any = {}; + message.validatorPeriod !== undefined && + (obj.validatorPeriod = (message.validatorPeriod || Long.UZERO).toString()); + message.fraction !== undefined && (obj.fraction = message.fraction); + return obj; + }, + fromPartial(object: DeepPartial): ValidatorSlashEvent { const message = { ...baseValidatorSlashEvent } as ValidatorSlashEvent; if (object.validatorPeriod !== undefined && object.validatorPeriod !== null) { @@ -568,14 +592,6 @@ export const ValidatorSlashEvent = { } return message; }, - - toJSON(message: ValidatorSlashEvent): unknown { - const obj: any = {}; - message.validatorPeriod !== undefined && - (obj.validatorPeriod = (message.validatorPeriod || Long.UZERO).toString()); - message.fraction !== undefined && (obj.fraction = message.fraction); - return obj; - }, }; const baseValidatorSlashEvents: object = {}; @@ -618,17 +634,6 @@ export const ValidatorSlashEvents = { return message; }, - fromPartial(object: DeepPartial): ValidatorSlashEvents { - const message = { ...baseValidatorSlashEvents } as ValidatorSlashEvents; - message.validatorSlashEvents = []; - if (object.validatorSlashEvents !== undefined && object.validatorSlashEvents !== null) { - for (const e of object.validatorSlashEvents) { - message.validatorSlashEvents.push(ValidatorSlashEvent.fromPartial(e)); - } - } - return message; - }, - toJSON(message: ValidatorSlashEvents): unknown { const obj: any = {}; if (message.validatorSlashEvents) { @@ -640,6 +645,17 @@ export const ValidatorSlashEvents = { } return obj; }, + + fromPartial(object: DeepPartial): ValidatorSlashEvents { + const message = { ...baseValidatorSlashEvents } as ValidatorSlashEvents; + message.validatorSlashEvents = []; + if (object.validatorSlashEvents !== undefined && object.validatorSlashEvents !== null) { + for (const e of object.validatorSlashEvents) { + message.validatorSlashEvents.push(ValidatorSlashEvent.fromPartial(e)); + } + } + return message; + }, }; const baseFeePool: object = {}; @@ -682,6 +698,16 @@ export const FeePool = { return message; }, + toJSON(message: FeePool): unknown { + const obj: any = {}; + if (message.communityPool) { + obj.communityPool = message.communityPool.map((e) => (e ? DecCoin.toJSON(e) : undefined)); + } else { + obj.communityPool = []; + } + return obj; + }, + fromPartial(object: DeepPartial): FeePool { const message = { ...baseFeePool } as FeePool; message.communityPool = []; @@ -692,25 +718,21 @@ export const FeePool = { } return message; }, - - toJSON(message: FeePool): unknown { - const obj: any = {}; - if (message.communityPool) { - obj.communityPool = message.communityPool.map((e) => (e ? DecCoin.toJSON(e) : undefined)); - } else { - obj.communityPool = []; - } - return obj; - }, }; const baseCommunityPoolSpendProposal: object = { title: "", description: "", recipient: "" }; export const CommunityPoolSpendProposal = { encode(message: CommunityPoolSpendProposal, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.title); - writer.uint32(18).string(message.description); - writer.uint32(26).string(message.recipient); + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.recipient !== "") { + writer.uint32(26).string(message.recipient); + } for (const v of message.amount) { Coin.encode(v!, writer.uint32(34).fork()).ldelim(); } @@ -771,6 +793,19 @@ export const CommunityPoolSpendProposal = { return message; }, + toJSON(message: CommunityPoolSpendProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.recipient !== undefined && (obj.recipient = message.recipient); + if (message.amount) { + obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.amount = []; + } + return obj; + }, + fromPartial(object: DeepPartial): CommunityPoolSpendProposal { const message = { ...baseCommunityPoolSpendProposal } as CommunityPoolSpendProposal; message.amount = []; @@ -796,28 +831,21 @@ export const CommunityPoolSpendProposal = { } return message; }, - - toJSON(message: CommunityPoolSpendProposal): unknown { - const obj: any = {}; - message.title !== undefined && (obj.title = message.title); - message.description !== undefined && (obj.description = message.description); - message.recipient !== undefined && (obj.recipient = message.recipient); - if (message.amount) { - obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); - } else { - obj.amount = []; - } - return obj; - }, }; const baseDelegatorStartingInfo: object = { previousPeriod: Long.UZERO, stake: "", height: Long.UZERO }; export const DelegatorStartingInfo = { encode(message: DelegatorStartingInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.previousPeriod); - writer.uint32(18).string(message.stake); - writer.uint32(24).uint64(message.height); + if (!message.previousPeriod.isZero()) { + writer.uint32(8).uint64(message.previousPeriod); + } + if (message.stake !== "") { + writer.uint32(18).string(message.stake); + } + if (!message.height.isZero()) { + writer.uint32(24).uint64(message.height); + } return writer; }, @@ -865,6 +893,15 @@ export const DelegatorStartingInfo = { return message; }, + toJSON(message: DelegatorStartingInfo): unknown { + const obj: any = {}; + message.previousPeriod !== undefined && + (obj.previousPeriod = (message.previousPeriod || Long.UZERO).toString()); + message.stake !== undefined && (obj.stake = message.stake); + message.height !== undefined && (obj.height = (message.height || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): DelegatorStartingInfo { const message = { ...baseDelegatorStartingInfo } as DelegatorStartingInfo; if (object.previousPeriod !== undefined && object.previousPeriod !== null) { @@ -884,22 +921,15 @@ export const DelegatorStartingInfo = { } return message; }, - - toJSON(message: DelegatorStartingInfo): unknown { - const obj: any = {}; - message.previousPeriod !== undefined && - (obj.previousPeriod = (message.previousPeriod || Long.UZERO).toString()); - message.stake !== undefined && (obj.stake = message.stake); - message.height !== undefined && (obj.height = (message.height || Long.UZERO).toString()); - return obj; - }, }; const baseDelegationDelegatorReward: object = { validatorAddress: "" }; export const DelegationDelegatorReward = { encode(message: DelegationDelegatorReward, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.validatorAddress); + if (message.validatorAddress !== "") { + writer.uint32(10).string(message.validatorAddress); + } for (const v of message.reward) { DecCoin.encode(v!, writer.uint32(18).fork()).ldelim(); } @@ -944,6 +974,17 @@ export const DelegationDelegatorReward = { return message; }, + toJSON(message: DelegationDelegatorReward): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + if (message.reward) { + obj.reward = message.reward.map((e) => (e ? DecCoin.toJSON(e) : undefined)); + } else { + obj.reward = []; + } + return obj; + }, + fromPartial(object: DeepPartial): DelegationDelegatorReward { const message = { ...baseDelegationDelegatorReward } as DelegationDelegatorReward; message.reward = []; @@ -959,17 +1000,6 @@ export const DelegationDelegatorReward = { } return message; }, - - toJSON(message: DelegationDelegatorReward): unknown { - const obj: any = {}; - message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); - if (message.reward) { - obj.reward = message.reward.map((e) => (e ? DecCoin.toJSON(e) : undefined)); - } else { - obj.reward = []; - } - return obj; - }, }; const baseCommunityPoolSpendProposalWithDeposit: object = { @@ -985,11 +1015,21 @@ export const CommunityPoolSpendProposalWithDeposit = { message: CommunityPoolSpendProposalWithDeposit, writer: _m0.Writer = _m0.Writer.create(), ): _m0.Writer { - writer.uint32(10).string(message.title); - writer.uint32(18).string(message.description); - writer.uint32(26).string(message.recipient); - writer.uint32(34).string(message.amount); - writer.uint32(42).string(message.deposit); + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.recipient !== "") { + writer.uint32(26).string(message.recipient); + } + if (message.amount !== "") { + writer.uint32(34).string(message.amount); + } + if (message.deposit !== "") { + writer.uint32(42).string(message.deposit); + } return writer; }, @@ -1053,6 +1093,16 @@ export const CommunityPoolSpendProposalWithDeposit = { return message; }, + toJSON(message: CommunityPoolSpendProposalWithDeposit): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.recipient !== undefined && (obj.recipient = message.recipient); + message.amount !== undefined && (obj.amount = message.amount); + message.deposit !== undefined && (obj.deposit = message.deposit); + return obj; + }, + fromPartial( object: DeepPartial, ): CommunityPoolSpendProposalWithDeposit { @@ -1084,16 +1134,6 @@ export const CommunityPoolSpendProposalWithDeposit = { } return message; }, - - toJSON(message: CommunityPoolSpendProposalWithDeposit): unknown { - const obj: any = {}; - message.title !== undefined && (obj.title = message.title); - message.description !== undefined && (obj.description = message.description); - message.recipient !== undefined && (obj.recipient = message.recipient); - message.amount !== undefined && (obj.amount = message.amount); - message.deposit !== undefined && (obj.deposit = message.deposit); - return obj; - }, }; type Builtin = Date | Function | Uint8Array | string | number | undefined | Long; diff --git a/packages/stargate/src/codec/cosmos/distribution/v1beta1/query.ts b/packages/stargate/src/codec/cosmos/distribution/v1beta1/query.ts index 9962128c..4e264cf4 100644 --- a/packages/stargate/src/codec/cosmos/distribution/v1beta1/query.ts +++ b/packages/stargate/src/codec/cosmos/distribution/v1beta1/query.ts @@ -201,22 +201,22 @@ export const QueryParamsRequest = { return message; }, - fromPartial(_: DeepPartial): QueryParamsRequest { - const message = { ...baseQueryParamsRequest } as QueryParamsRequest; - return message; - }, - toJSON(_: QueryParamsRequest): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, }; const baseQueryParamsResponse: object = {}; export const QueryParamsResponse = { encode(message: QueryParamsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.params !== undefined && message.params !== undefined) { + if (message.params !== undefined) { Params.encode(message.params, writer.uint32(10).fork()).ldelim(); } return writer; @@ -250,6 +250,12 @@ export const QueryParamsResponse = { return message; }, + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { const message = { ...baseQueryParamsResponse } as QueryParamsResponse; if (object.params !== undefined && object.params !== null) { @@ -259,12 +265,6 @@ export const QueryParamsResponse = { } return message; }, - - toJSON(message: QueryParamsResponse): unknown { - const obj: any = {}; - message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); - return obj; - }, }; const baseQueryValidatorOutstandingRewardsRequest: object = { validatorAddress: "" }; @@ -274,7 +274,9 @@ export const QueryValidatorOutstandingRewardsRequest = { message: QueryValidatorOutstandingRewardsRequest, writer: _m0.Writer = _m0.Writer.create(), ): _m0.Writer { - writer.uint32(10).string(message.validatorAddress); + if (message.validatorAddress !== "") { + writer.uint32(10).string(message.validatorAddress); + } return writer; }, @@ -310,6 +312,12 @@ export const QueryValidatorOutstandingRewardsRequest = { return message; }, + toJSON(message: QueryValidatorOutstandingRewardsRequest): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + return obj; + }, + fromPartial( object: DeepPartial, ): QueryValidatorOutstandingRewardsRequest { @@ -323,12 +331,6 @@ export const QueryValidatorOutstandingRewardsRequest = { } return message; }, - - toJSON(message: QueryValidatorOutstandingRewardsRequest): unknown { - const obj: any = {}; - message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); - return obj; - }, }; const baseQueryValidatorOutstandingRewardsResponse: object = {}; @@ -338,7 +340,7 @@ export const QueryValidatorOutstandingRewardsResponse = { message: QueryValidatorOutstandingRewardsResponse, writer: _m0.Writer = _m0.Writer.create(), ): _m0.Writer { - if (message.rewards !== undefined && message.rewards !== undefined) { + if (message.rewards !== undefined) { ValidatorOutstandingRewards.encode(message.rewards, writer.uint32(10).fork()).ldelim(); } return writer; @@ -376,6 +378,13 @@ export const QueryValidatorOutstandingRewardsResponse = { return message; }, + toJSON(message: QueryValidatorOutstandingRewardsResponse): unknown { + const obj: any = {}; + message.rewards !== undefined && + (obj.rewards = message.rewards ? ValidatorOutstandingRewards.toJSON(message.rewards) : undefined); + return obj; + }, + fromPartial( object: DeepPartial, ): QueryValidatorOutstandingRewardsResponse { @@ -389,20 +398,15 @@ export const QueryValidatorOutstandingRewardsResponse = { } return message; }, - - toJSON(message: QueryValidatorOutstandingRewardsResponse): unknown { - const obj: any = {}; - message.rewards !== undefined && - (obj.rewards = message.rewards ? ValidatorOutstandingRewards.toJSON(message.rewards) : undefined); - return obj; - }, }; const baseQueryValidatorCommissionRequest: object = { validatorAddress: "" }; export const QueryValidatorCommissionRequest = { encode(message: QueryValidatorCommissionRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.validatorAddress); + if (message.validatorAddress !== "") { + writer.uint32(10).string(message.validatorAddress); + } return writer; }, @@ -434,6 +438,12 @@ export const QueryValidatorCommissionRequest = { return message; }, + toJSON(message: QueryValidatorCommissionRequest): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorCommissionRequest { const message = { ...baseQueryValidatorCommissionRequest } as QueryValidatorCommissionRequest; if (object.validatorAddress !== undefined && object.validatorAddress !== null) { @@ -443,19 +453,13 @@ export const QueryValidatorCommissionRequest = { } return message; }, - - toJSON(message: QueryValidatorCommissionRequest): unknown { - const obj: any = {}; - message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); - return obj; - }, }; const baseQueryValidatorCommissionResponse: object = {}; export const QueryValidatorCommissionResponse = { encode(message: QueryValidatorCommissionResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.commission !== undefined && message.commission !== undefined) { + if (message.commission !== undefined) { ValidatorAccumulatedCommission.encode(message.commission, writer.uint32(10).fork()).ldelim(); } return writer; @@ -489,6 +493,15 @@ export const QueryValidatorCommissionResponse = { return message; }, + toJSON(message: QueryValidatorCommissionResponse): unknown { + const obj: any = {}; + message.commission !== undefined && + (obj.commission = message.commission + ? ValidatorAccumulatedCommission.toJSON(message.commission) + : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorCommissionResponse { const message = { ...baseQueryValidatorCommissionResponse } as QueryValidatorCommissionResponse; if (object.commission !== undefined && object.commission !== null) { @@ -498,15 +511,6 @@ export const QueryValidatorCommissionResponse = { } return message; }, - - toJSON(message: QueryValidatorCommissionResponse): unknown { - const obj: any = {}; - message.commission !== undefined && - (obj.commission = message.commission - ? ValidatorAccumulatedCommission.toJSON(message.commission) - : undefined); - return obj; - }, }; const baseQueryValidatorSlashesRequest: object = { @@ -517,10 +521,16 @@ const baseQueryValidatorSlashesRequest: object = { export const QueryValidatorSlashesRequest = { encode(message: QueryValidatorSlashesRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.validatorAddress); - writer.uint32(16).uint64(message.startingHeight); - writer.uint32(24).uint64(message.endingHeight); - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.validatorAddress !== "") { + writer.uint32(10).string(message.validatorAddress); + } + if (!message.startingHeight.isZero()) { + writer.uint32(16).uint64(message.startingHeight); + } + if (!message.endingHeight.isZero()) { + writer.uint32(24).uint64(message.endingHeight); + } + if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(34).fork()).ldelim(); } return writer; @@ -578,6 +588,18 @@ export const QueryValidatorSlashesRequest = { return message; }, + toJSON(message: QueryValidatorSlashesRequest): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.startingHeight !== undefined && + (obj.startingHeight = (message.startingHeight || Long.UZERO).toString()); + message.endingHeight !== undefined && + (obj.endingHeight = (message.endingHeight || Long.UZERO).toString()); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorSlashesRequest { const message = { ...baseQueryValidatorSlashesRequest } as QueryValidatorSlashesRequest; if (object.validatorAddress !== undefined && object.validatorAddress !== null) { @@ -602,18 +624,6 @@ export const QueryValidatorSlashesRequest = { } return message; }, - - toJSON(message: QueryValidatorSlashesRequest): unknown { - const obj: any = {}; - message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); - message.startingHeight !== undefined && - (obj.startingHeight = (message.startingHeight || Long.UZERO).toString()); - message.endingHeight !== undefined && - (obj.endingHeight = (message.endingHeight || Long.UZERO).toString()); - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryValidatorSlashesResponse: object = {}; @@ -623,7 +633,7 @@ export const QueryValidatorSlashesResponse = { for (const v of message.slashes) { ValidatorSlashEvent.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -667,6 +677,18 @@ export const QueryValidatorSlashesResponse = { return message; }, + toJSON(message: QueryValidatorSlashesResponse): unknown { + const obj: any = {}; + if (message.slashes) { + obj.slashes = message.slashes.map((e) => (e ? ValidatorSlashEvent.toJSON(e) : undefined)); + } else { + obj.slashes = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorSlashesResponse { const message = { ...baseQueryValidatorSlashesResponse } as QueryValidatorSlashesResponse; message.slashes = []; @@ -682,26 +704,18 @@ export const QueryValidatorSlashesResponse = { } return message; }, - - toJSON(message: QueryValidatorSlashesResponse): unknown { - const obj: any = {}; - if (message.slashes) { - obj.slashes = message.slashes.map((e) => (e ? ValidatorSlashEvent.toJSON(e) : undefined)); - } else { - obj.slashes = []; - } - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryDelegationRewardsRequest: object = { delegatorAddress: "", validatorAddress: "" }; export const QueryDelegationRewardsRequest = { encode(message: QueryDelegationRewardsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddress); - writer.uint32(18).string(message.validatorAddress); + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== "") { + writer.uint32(18).string(message.validatorAddress); + } return writer; }, @@ -741,6 +755,13 @@ export const QueryDelegationRewardsRequest = { return message; }, + toJSON(message: QueryDelegationRewardsRequest): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegationRewardsRequest { const message = { ...baseQueryDelegationRewardsRequest } as QueryDelegationRewardsRequest; if (object.delegatorAddress !== undefined && object.delegatorAddress !== null) { @@ -755,13 +776,6 @@ export const QueryDelegationRewardsRequest = { } return message; }, - - toJSON(message: QueryDelegationRewardsRequest): unknown { - const obj: any = {}; - message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); - message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); - return obj; - }, }; const baseQueryDelegationRewardsResponse: object = {}; @@ -804,6 +818,16 @@ export const QueryDelegationRewardsResponse = { return message; }, + toJSON(message: QueryDelegationRewardsResponse): unknown { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map((e) => (e ? DecCoin.toJSON(e) : undefined)); + } else { + obj.rewards = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegationRewardsResponse { const message = { ...baseQueryDelegationRewardsResponse } as QueryDelegationRewardsResponse; message.rewards = []; @@ -814,23 +838,15 @@ export const QueryDelegationRewardsResponse = { } return message; }, - - toJSON(message: QueryDelegationRewardsResponse): unknown { - const obj: any = {}; - if (message.rewards) { - obj.rewards = message.rewards.map((e) => (e ? DecCoin.toJSON(e) : undefined)); - } else { - obj.rewards = []; - } - return obj; - }, }; const baseQueryDelegationTotalRewardsRequest: object = { delegatorAddress: "" }; export const QueryDelegationTotalRewardsRequest = { encode(message: QueryDelegationTotalRewardsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddress); + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } return writer; }, @@ -862,6 +878,12 @@ export const QueryDelegationTotalRewardsRequest = { return message; }, + toJSON(message: QueryDelegationTotalRewardsRequest): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegationTotalRewardsRequest { const message = { ...baseQueryDelegationTotalRewardsRequest } as QueryDelegationTotalRewardsRequest; if (object.delegatorAddress !== undefined && object.delegatorAddress !== null) { @@ -871,12 +893,6 @@ export const QueryDelegationTotalRewardsRequest = { } return message; }, - - toJSON(message: QueryDelegationTotalRewardsRequest): unknown { - const obj: any = {}; - message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); - return obj; - }, }; const baseQueryDelegationTotalRewardsResponse: object = {}; @@ -932,6 +948,21 @@ export const QueryDelegationTotalRewardsResponse = { return message; }, + toJSON(message: QueryDelegationTotalRewardsResponse): unknown { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map((e) => (e ? DelegationDelegatorReward.toJSON(e) : undefined)); + } else { + obj.rewards = []; + } + if (message.total) { + obj.total = message.total.map((e) => (e ? DecCoin.toJSON(e) : undefined)); + } else { + obj.total = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegationTotalRewardsResponse { const message = { ...baseQueryDelegationTotalRewardsResponse } as QueryDelegationTotalRewardsResponse; message.rewards = []; @@ -948,28 +979,15 @@ export const QueryDelegationTotalRewardsResponse = { } return message; }, - - toJSON(message: QueryDelegationTotalRewardsResponse): unknown { - const obj: any = {}; - if (message.rewards) { - obj.rewards = message.rewards.map((e) => (e ? DelegationDelegatorReward.toJSON(e) : undefined)); - } else { - obj.rewards = []; - } - if (message.total) { - obj.total = message.total.map((e) => (e ? DecCoin.toJSON(e) : undefined)); - } else { - obj.total = []; - } - return obj; - }, }; const baseQueryDelegatorValidatorsRequest: object = { delegatorAddress: "" }; export const QueryDelegatorValidatorsRequest = { encode(message: QueryDelegatorValidatorsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddress); + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } return writer; }, @@ -1001,6 +1019,12 @@ export const QueryDelegatorValidatorsRequest = { return message; }, + toJSON(message: QueryDelegatorValidatorsRequest): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorValidatorsRequest { const message = { ...baseQueryDelegatorValidatorsRequest } as QueryDelegatorValidatorsRequest; if (object.delegatorAddress !== undefined && object.delegatorAddress !== null) { @@ -1010,12 +1034,6 @@ export const QueryDelegatorValidatorsRequest = { } return message; }, - - toJSON(message: QueryDelegatorValidatorsRequest): unknown { - const obj: any = {}; - message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); - return obj; - }, }; const baseQueryDelegatorValidatorsResponse: object = { validators: "" }; @@ -1058,6 +1076,16 @@ export const QueryDelegatorValidatorsResponse = { return message; }, + toJSON(message: QueryDelegatorValidatorsResponse): unknown { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map((e) => e); + } else { + obj.validators = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorValidatorsResponse { const message = { ...baseQueryDelegatorValidatorsResponse } as QueryDelegatorValidatorsResponse; message.validators = []; @@ -1068,16 +1096,6 @@ export const QueryDelegatorValidatorsResponse = { } return message; }, - - toJSON(message: QueryDelegatorValidatorsResponse): unknown { - const obj: any = {}; - if (message.validators) { - obj.validators = message.validators.map((e) => e); - } else { - obj.validators = []; - } - return obj; - }, }; const baseQueryDelegatorWithdrawAddressRequest: object = { delegatorAddress: "" }; @@ -1087,7 +1105,9 @@ export const QueryDelegatorWithdrawAddressRequest = { message: QueryDelegatorWithdrawAddressRequest, writer: _m0.Writer = _m0.Writer.create(), ): _m0.Writer { - writer.uint32(10).string(message.delegatorAddress); + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } return writer; }, @@ -1119,6 +1139,12 @@ export const QueryDelegatorWithdrawAddressRequest = { return message; }, + toJSON(message: QueryDelegatorWithdrawAddressRequest): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + return obj; + }, + fromPartial( object: DeepPartial, ): QueryDelegatorWithdrawAddressRequest { @@ -1130,12 +1156,6 @@ export const QueryDelegatorWithdrawAddressRequest = { } return message; }, - - toJSON(message: QueryDelegatorWithdrawAddressRequest): unknown { - const obj: any = {}; - message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); - return obj; - }, }; const baseQueryDelegatorWithdrawAddressResponse: object = { withdrawAddress: "" }; @@ -1145,7 +1165,9 @@ export const QueryDelegatorWithdrawAddressResponse = { message: QueryDelegatorWithdrawAddressResponse, writer: _m0.Writer = _m0.Writer.create(), ): _m0.Writer { - writer.uint32(10).string(message.withdrawAddress); + if (message.withdrawAddress !== "") { + writer.uint32(10).string(message.withdrawAddress); + } return writer; }, @@ -1177,6 +1199,12 @@ export const QueryDelegatorWithdrawAddressResponse = { return message; }, + toJSON(message: QueryDelegatorWithdrawAddressResponse): unknown { + const obj: any = {}; + message.withdrawAddress !== undefined && (obj.withdrawAddress = message.withdrawAddress); + return obj; + }, + fromPartial( object: DeepPartial, ): QueryDelegatorWithdrawAddressResponse { @@ -1188,12 +1216,6 @@ export const QueryDelegatorWithdrawAddressResponse = { } return message; }, - - toJSON(message: QueryDelegatorWithdrawAddressResponse): unknown { - const obj: any = {}; - message.withdrawAddress !== undefined && (obj.withdrawAddress = message.withdrawAddress); - return obj; - }, }; const baseQueryCommunityPoolRequest: object = {}; @@ -1223,15 +1245,15 @@ export const QueryCommunityPoolRequest = { return message; }, - fromPartial(_: DeepPartial): QueryCommunityPoolRequest { - const message = { ...baseQueryCommunityPoolRequest } as QueryCommunityPoolRequest; - return message; - }, - toJSON(_: QueryCommunityPoolRequest): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): QueryCommunityPoolRequest { + const message = { ...baseQueryCommunityPoolRequest } as QueryCommunityPoolRequest; + return message; + }, }; const baseQueryCommunityPoolResponse: object = {}; @@ -1274,6 +1296,16 @@ export const QueryCommunityPoolResponse = { return message; }, + toJSON(message: QueryCommunityPoolResponse): unknown { + const obj: any = {}; + if (message.pool) { + obj.pool = message.pool.map((e) => (e ? DecCoin.toJSON(e) : undefined)); + } else { + obj.pool = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QueryCommunityPoolResponse { const message = { ...baseQueryCommunityPoolResponse } as QueryCommunityPoolResponse; message.pool = []; @@ -1284,16 +1316,6 @@ export const QueryCommunityPoolResponse = { } return message; }, - - toJSON(message: QueryCommunityPoolResponse): unknown { - const obj: any = {}; - if (message.pool) { - obj.pool = message.pool.map((e) => (e ? DecCoin.toJSON(e) : undefined)); - } else { - obj.pool = []; - } - return obj; - }, }; /** Query defines the gRPC querier service for distribution module. */ diff --git a/packages/stargate/src/codec/cosmos/distribution/v1beta1/tx.ts b/packages/stargate/src/codec/cosmos/distribution/v1beta1/tx.ts index c16c1da3..4bbde5f3 100644 --- a/packages/stargate/src/codec/cosmos/distribution/v1beta1/tx.ts +++ b/packages/stargate/src/codec/cosmos/distribution/v1beta1/tx.ts @@ -56,8 +56,12 @@ const baseMsgSetWithdrawAddress: object = { delegatorAddress: "", withdrawAddres export const MsgSetWithdrawAddress = { encode(message: MsgSetWithdrawAddress, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddress); - writer.uint32(18).string(message.withdrawAddress); + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.withdrawAddress !== "") { + writer.uint32(18).string(message.withdrawAddress); + } return writer; }, @@ -97,6 +101,13 @@ export const MsgSetWithdrawAddress = { return message; }, + toJSON(message: MsgSetWithdrawAddress): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.withdrawAddress !== undefined && (obj.withdrawAddress = message.withdrawAddress); + return obj; + }, + fromPartial(object: DeepPartial): MsgSetWithdrawAddress { const message = { ...baseMsgSetWithdrawAddress } as MsgSetWithdrawAddress; if (object.delegatorAddress !== undefined && object.delegatorAddress !== null) { @@ -111,13 +122,6 @@ export const MsgSetWithdrawAddress = { } return message; }, - - toJSON(message: MsgSetWithdrawAddress): unknown { - const obj: any = {}; - message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); - message.withdrawAddress !== undefined && (obj.withdrawAddress = message.withdrawAddress); - return obj; - }, }; const baseMsgSetWithdrawAddressResponse: object = {}; @@ -147,23 +151,27 @@ export const MsgSetWithdrawAddressResponse = { return message; }, - fromPartial(_: DeepPartial): MsgSetWithdrawAddressResponse { - const message = { ...baseMsgSetWithdrawAddressResponse } as MsgSetWithdrawAddressResponse; - return message; - }, - toJSON(_: MsgSetWithdrawAddressResponse): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): MsgSetWithdrawAddressResponse { + const message = { ...baseMsgSetWithdrawAddressResponse } as MsgSetWithdrawAddressResponse; + return message; + }, }; const baseMsgWithdrawDelegatorReward: object = { delegatorAddress: "", validatorAddress: "" }; export const MsgWithdrawDelegatorReward = { encode(message: MsgWithdrawDelegatorReward, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddress); - writer.uint32(18).string(message.validatorAddress); + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== "") { + writer.uint32(18).string(message.validatorAddress); + } return writer; }, @@ -203,6 +211,13 @@ export const MsgWithdrawDelegatorReward = { return message; }, + toJSON(message: MsgWithdrawDelegatorReward): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + return obj; + }, + fromPartial(object: DeepPartial): MsgWithdrawDelegatorReward { const message = { ...baseMsgWithdrawDelegatorReward } as MsgWithdrawDelegatorReward; if (object.delegatorAddress !== undefined && object.delegatorAddress !== null) { @@ -217,13 +232,6 @@ export const MsgWithdrawDelegatorReward = { } return message; }, - - toJSON(message: MsgWithdrawDelegatorReward): unknown { - const obj: any = {}; - message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); - message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); - return obj; - }, }; const baseMsgWithdrawDelegatorRewardResponse: object = {}; @@ -253,22 +261,24 @@ export const MsgWithdrawDelegatorRewardResponse = { return message; }, - fromPartial(_: DeepPartial): MsgWithdrawDelegatorRewardResponse { - const message = { ...baseMsgWithdrawDelegatorRewardResponse } as MsgWithdrawDelegatorRewardResponse; - return message; - }, - toJSON(_: MsgWithdrawDelegatorRewardResponse): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): MsgWithdrawDelegatorRewardResponse { + const message = { ...baseMsgWithdrawDelegatorRewardResponse } as MsgWithdrawDelegatorRewardResponse; + return message; + }, }; const baseMsgWithdrawValidatorCommission: object = { validatorAddress: "" }; export const MsgWithdrawValidatorCommission = { encode(message: MsgWithdrawValidatorCommission, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.validatorAddress); + if (message.validatorAddress !== "") { + writer.uint32(10).string(message.validatorAddress); + } return writer; }, @@ -300,6 +310,12 @@ export const MsgWithdrawValidatorCommission = { return message; }, + toJSON(message: MsgWithdrawValidatorCommission): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + return obj; + }, + fromPartial(object: DeepPartial): MsgWithdrawValidatorCommission { const message = { ...baseMsgWithdrawValidatorCommission } as MsgWithdrawValidatorCommission; if (object.validatorAddress !== undefined && object.validatorAddress !== null) { @@ -309,12 +325,6 @@ export const MsgWithdrawValidatorCommission = { } return message; }, - - toJSON(message: MsgWithdrawValidatorCommission): unknown { - const obj: any = {}; - message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); - return obj; - }, }; const baseMsgWithdrawValidatorCommissionResponse: object = {}; @@ -348,6 +358,11 @@ export const MsgWithdrawValidatorCommissionResponse = { return message; }, + toJSON(_: MsgWithdrawValidatorCommissionResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial( _: DeepPartial, ): MsgWithdrawValidatorCommissionResponse { @@ -356,11 +371,6 @@ export const MsgWithdrawValidatorCommissionResponse = { } as MsgWithdrawValidatorCommissionResponse; return message; }, - - toJSON(_: MsgWithdrawValidatorCommissionResponse): unknown { - const obj: any = {}; - return obj; - }, }; const baseMsgFundCommunityPool: object = { depositor: "" }; @@ -370,7 +380,9 @@ export const MsgFundCommunityPool = { for (const v of message.amount) { Coin.encode(v!, writer.uint32(10).fork()).ldelim(); } - writer.uint32(18).string(message.depositor); + if (message.depositor !== "") { + writer.uint32(18).string(message.depositor); + } return writer; }, @@ -412,6 +424,17 @@ export const MsgFundCommunityPool = { return message; }, + toJSON(message: MsgFundCommunityPool): unknown { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.amount = []; + } + message.depositor !== undefined && (obj.depositor = message.depositor); + return obj; + }, + fromPartial(object: DeepPartial): MsgFundCommunityPool { const message = { ...baseMsgFundCommunityPool } as MsgFundCommunityPool; message.amount = []; @@ -427,17 +450,6 @@ export const MsgFundCommunityPool = { } return message; }, - - toJSON(message: MsgFundCommunityPool): unknown { - const obj: any = {}; - if (message.amount) { - obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); - } else { - obj.amount = []; - } - message.depositor !== undefined && (obj.depositor = message.depositor); - return obj; - }, }; const baseMsgFundCommunityPoolResponse: object = {}; @@ -467,15 +479,15 @@ export const MsgFundCommunityPoolResponse = { return message; }, - fromPartial(_: DeepPartial): MsgFundCommunityPoolResponse { - const message = { ...baseMsgFundCommunityPoolResponse } as MsgFundCommunityPoolResponse; - return message; - }, - toJSON(_: MsgFundCommunityPoolResponse): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): MsgFundCommunityPoolResponse { + const message = { ...baseMsgFundCommunityPoolResponse } as MsgFundCommunityPoolResponse; + return message; + }, }; /** Msg defines the distribution Msg service. */ diff --git a/packages/stargate/src/codec/cosmos/staking/v1beta1/query.ts b/packages/stargate/src/codec/cosmos/staking/v1beta1/query.ts index 3f76377e..3dbc572d 100644 --- a/packages/stargate/src/codec/cosmos/staking/v1beta1/query.ts +++ b/packages/stargate/src/codec/cosmos/staking/v1beta1/query.ts @@ -268,8 +268,10 @@ const baseQueryValidatorsRequest: object = { status: "" }; export const QueryValidatorsRequest = { encode(message: QueryValidatorsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.status); - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.status !== "") { + writer.uint32(10).string(message.status); + } + if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -311,6 +313,14 @@ export const QueryValidatorsRequest = { return message; }, + toJSON(message: QueryValidatorsRequest): unknown { + const obj: any = {}; + message.status !== undefined && (obj.status = message.status); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorsRequest { const message = { ...baseQueryValidatorsRequest } as QueryValidatorsRequest; if (object.status !== undefined && object.status !== null) { @@ -325,14 +335,6 @@ export const QueryValidatorsRequest = { } return message; }, - - toJSON(message: QueryValidatorsRequest): unknown { - const obj: any = {}; - message.status !== undefined && (obj.status = message.status); - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryValidatorsResponse: object = {}; @@ -342,7 +344,7 @@ export const QueryValidatorsResponse = { for (const v of message.validators) { Validator.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -386,6 +388,18 @@ export const QueryValidatorsResponse = { return message; }, + toJSON(message: QueryValidatorsResponse): unknown { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map((e) => (e ? Validator.toJSON(e) : undefined)); + } else { + obj.validators = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorsResponse { const message = { ...baseQueryValidatorsResponse } as QueryValidatorsResponse; message.validators = []; @@ -401,25 +415,15 @@ export const QueryValidatorsResponse = { } return message; }, - - toJSON(message: QueryValidatorsResponse): unknown { - const obj: any = {}; - if (message.validators) { - obj.validators = message.validators.map((e) => (e ? Validator.toJSON(e) : undefined)); - } else { - obj.validators = []; - } - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryValidatorRequest: object = { validatorAddr: "" }; export const QueryValidatorRequest = { encode(message: QueryValidatorRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.validatorAddr); + if (message.validatorAddr !== "") { + writer.uint32(10).string(message.validatorAddr); + } return writer; }, @@ -451,6 +455,12 @@ export const QueryValidatorRequest = { return message; }, + toJSON(message: QueryValidatorRequest): unknown { + const obj: any = {}; + message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorRequest { const message = { ...baseQueryValidatorRequest } as QueryValidatorRequest; if (object.validatorAddr !== undefined && object.validatorAddr !== null) { @@ -460,19 +470,13 @@ export const QueryValidatorRequest = { } return message; }, - - toJSON(message: QueryValidatorRequest): unknown { - const obj: any = {}; - message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); - return obj; - }, }; const baseQueryValidatorResponse: object = {}; export const QueryValidatorResponse = { encode(message: QueryValidatorResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.validator !== undefined && message.validator !== undefined) { + if (message.validator !== undefined) { Validator.encode(message.validator, writer.uint32(10).fork()).ldelim(); } return writer; @@ -506,6 +510,13 @@ export const QueryValidatorResponse = { return message; }, + toJSON(message: QueryValidatorResponse): unknown { + const obj: any = {}; + message.validator !== undefined && + (obj.validator = message.validator ? Validator.toJSON(message.validator) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorResponse { const message = { ...baseQueryValidatorResponse } as QueryValidatorResponse; if (object.validator !== undefined && object.validator !== null) { @@ -515,21 +526,16 @@ export const QueryValidatorResponse = { } return message; }, - - toJSON(message: QueryValidatorResponse): unknown { - const obj: any = {}; - message.validator !== undefined && - (obj.validator = message.validator ? Validator.toJSON(message.validator) : undefined); - return obj; - }, }; const baseQueryValidatorDelegationsRequest: object = { validatorAddr: "" }; export const QueryValidatorDelegationsRequest = { encode(message: QueryValidatorDelegationsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.validatorAddr); - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.validatorAddr !== "") { + writer.uint32(10).string(message.validatorAddr); + } + if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -571,6 +577,14 @@ export const QueryValidatorDelegationsRequest = { return message; }, + toJSON(message: QueryValidatorDelegationsRequest): unknown { + const obj: any = {}; + message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorDelegationsRequest { const message = { ...baseQueryValidatorDelegationsRequest } as QueryValidatorDelegationsRequest; if (object.validatorAddr !== undefined && object.validatorAddr !== null) { @@ -585,14 +599,6 @@ export const QueryValidatorDelegationsRequest = { } return message; }, - - toJSON(message: QueryValidatorDelegationsRequest): unknown { - const obj: any = {}; - message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryValidatorDelegationsResponse: object = {}; @@ -602,7 +608,7 @@ export const QueryValidatorDelegationsResponse = { for (const v of message.delegationResponses) { DelegationResponse.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -646,6 +652,20 @@ export const QueryValidatorDelegationsResponse = { return message; }, + toJSON(message: QueryValidatorDelegationsResponse): unknown { + const obj: any = {}; + if (message.delegationResponses) { + obj.delegationResponses = message.delegationResponses.map((e) => + e ? DelegationResponse.toJSON(e) : undefined, + ); + } else { + obj.delegationResponses = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorDelegationsResponse { const message = { ...baseQueryValidatorDelegationsResponse } as QueryValidatorDelegationsResponse; message.delegationResponses = []; @@ -661,20 +681,6 @@ export const QueryValidatorDelegationsResponse = { } return message; }, - - toJSON(message: QueryValidatorDelegationsResponse): unknown { - const obj: any = {}; - if (message.delegationResponses) { - obj.delegationResponses = message.delegationResponses.map((e) => - e ? DelegationResponse.toJSON(e) : undefined, - ); - } else { - obj.delegationResponses = []; - } - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryValidatorUnbondingDelegationsRequest: object = { validatorAddr: "" }; @@ -684,8 +690,10 @@ export const QueryValidatorUnbondingDelegationsRequest = { message: QueryValidatorUnbondingDelegationsRequest, writer: _m0.Writer = _m0.Writer.create(), ): _m0.Writer { - writer.uint32(10).string(message.validatorAddr); - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.validatorAddr !== "") { + writer.uint32(10).string(message.validatorAddr); + } + if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -731,6 +739,14 @@ export const QueryValidatorUnbondingDelegationsRequest = { return message; }, + toJSON(message: QueryValidatorUnbondingDelegationsRequest): unknown { + const obj: any = {}; + message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial( object: DeepPartial, ): QueryValidatorUnbondingDelegationsRequest { @@ -749,14 +765,6 @@ export const QueryValidatorUnbondingDelegationsRequest = { } return message; }, - - toJSON(message: QueryValidatorUnbondingDelegationsRequest): unknown { - const obj: any = {}; - message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryValidatorUnbondingDelegationsResponse: object = {}; @@ -769,7 +777,7 @@ export const QueryValidatorUnbondingDelegationsResponse = { for (const v of message.unbondingResponses) { UnbondingDelegation.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -817,6 +825,20 @@ export const QueryValidatorUnbondingDelegationsResponse = { return message; }, + toJSON(message: QueryValidatorUnbondingDelegationsResponse): unknown { + const obj: any = {}; + if (message.unbondingResponses) { + obj.unbondingResponses = message.unbondingResponses.map((e) => + e ? UnbondingDelegation.toJSON(e) : undefined, + ); + } else { + obj.unbondingResponses = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial( object: DeepPartial, ): QueryValidatorUnbondingDelegationsResponse { @@ -836,28 +858,18 @@ export const QueryValidatorUnbondingDelegationsResponse = { } return message; }, - - toJSON(message: QueryValidatorUnbondingDelegationsResponse): unknown { - const obj: any = {}; - if (message.unbondingResponses) { - obj.unbondingResponses = message.unbondingResponses.map((e) => - e ? UnbondingDelegation.toJSON(e) : undefined, - ); - } else { - obj.unbondingResponses = []; - } - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryDelegationRequest: object = { delegatorAddr: "", validatorAddr: "" }; export const QueryDelegationRequest = { encode(message: QueryDelegationRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddr); - writer.uint32(18).string(message.validatorAddr); + if (message.delegatorAddr !== "") { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.validatorAddr !== "") { + writer.uint32(18).string(message.validatorAddr); + } return writer; }, @@ -897,6 +909,13 @@ export const QueryDelegationRequest = { return message; }, + toJSON(message: QueryDelegationRequest): unknown { + const obj: any = {}; + message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); + message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegationRequest { const message = { ...baseQueryDelegationRequest } as QueryDelegationRequest; if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { @@ -911,20 +930,13 @@ export const QueryDelegationRequest = { } return message; }, - - toJSON(message: QueryDelegationRequest): unknown { - const obj: any = {}; - message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); - message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); - return obj; - }, }; const baseQueryDelegationResponse: object = {}; export const QueryDelegationResponse = { encode(message: QueryDelegationResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.delegationResponse !== undefined && message.delegationResponse !== undefined) { + if (message.delegationResponse !== undefined) { DelegationResponse.encode(message.delegationResponse, writer.uint32(10).fork()).ldelim(); } return writer; @@ -958,6 +970,15 @@ export const QueryDelegationResponse = { return message; }, + toJSON(message: QueryDelegationResponse): unknown { + const obj: any = {}; + message.delegationResponse !== undefined && + (obj.delegationResponse = message.delegationResponse + ? DelegationResponse.toJSON(message.delegationResponse) + : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegationResponse { const message = { ...baseQueryDelegationResponse } as QueryDelegationResponse; if (object.delegationResponse !== undefined && object.delegationResponse !== null) { @@ -967,23 +988,18 @@ export const QueryDelegationResponse = { } return message; }, - - toJSON(message: QueryDelegationResponse): unknown { - const obj: any = {}; - message.delegationResponse !== undefined && - (obj.delegationResponse = message.delegationResponse - ? DelegationResponse.toJSON(message.delegationResponse) - : undefined); - return obj; - }, }; const baseQueryUnbondingDelegationRequest: object = { delegatorAddr: "", validatorAddr: "" }; export const QueryUnbondingDelegationRequest = { encode(message: QueryUnbondingDelegationRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddr); - writer.uint32(18).string(message.validatorAddr); + if (message.delegatorAddr !== "") { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.validatorAddr !== "") { + writer.uint32(18).string(message.validatorAddr); + } return writer; }, @@ -1023,6 +1039,13 @@ export const QueryUnbondingDelegationRequest = { return message; }, + toJSON(message: QueryUnbondingDelegationRequest): unknown { + const obj: any = {}; + message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); + message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); + return obj; + }, + fromPartial(object: DeepPartial): QueryUnbondingDelegationRequest { const message = { ...baseQueryUnbondingDelegationRequest } as QueryUnbondingDelegationRequest; if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { @@ -1037,20 +1060,13 @@ export const QueryUnbondingDelegationRequest = { } return message; }, - - toJSON(message: QueryUnbondingDelegationRequest): unknown { - const obj: any = {}; - message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); - message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); - return obj; - }, }; const baseQueryUnbondingDelegationResponse: object = {}; export const QueryUnbondingDelegationResponse = { encode(message: QueryUnbondingDelegationResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.unbond !== undefined && message.unbond !== undefined) { + if (message.unbond !== undefined) { UnbondingDelegation.encode(message.unbond, writer.uint32(10).fork()).ldelim(); } return writer; @@ -1084,6 +1100,13 @@ export const QueryUnbondingDelegationResponse = { return message; }, + toJSON(message: QueryUnbondingDelegationResponse): unknown { + const obj: any = {}; + message.unbond !== undefined && + (obj.unbond = message.unbond ? UnbondingDelegation.toJSON(message.unbond) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryUnbondingDelegationResponse { const message = { ...baseQueryUnbondingDelegationResponse } as QueryUnbondingDelegationResponse; if (object.unbond !== undefined && object.unbond !== null) { @@ -1093,21 +1116,16 @@ export const QueryUnbondingDelegationResponse = { } return message; }, - - toJSON(message: QueryUnbondingDelegationResponse): unknown { - const obj: any = {}; - message.unbond !== undefined && - (obj.unbond = message.unbond ? UnbondingDelegation.toJSON(message.unbond) : undefined); - return obj; - }, }; const baseQueryDelegatorDelegationsRequest: object = { delegatorAddr: "" }; export const QueryDelegatorDelegationsRequest = { encode(message: QueryDelegatorDelegationsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddr); - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.delegatorAddr !== "") { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -1149,6 +1167,14 @@ export const QueryDelegatorDelegationsRequest = { return message; }, + toJSON(message: QueryDelegatorDelegationsRequest): unknown { + const obj: any = {}; + message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorDelegationsRequest { const message = { ...baseQueryDelegatorDelegationsRequest } as QueryDelegatorDelegationsRequest; if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { @@ -1163,14 +1189,6 @@ export const QueryDelegatorDelegationsRequest = { } return message; }, - - toJSON(message: QueryDelegatorDelegationsRequest): unknown { - const obj: any = {}; - message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryDelegatorDelegationsResponse: object = {}; @@ -1180,7 +1198,7 @@ export const QueryDelegatorDelegationsResponse = { for (const v of message.delegationResponses) { DelegationResponse.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -1224,6 +1242,20 @@ export const QueryDelegatorDelegationsResponse = { return message; }, + toJSON(message: QueryDelegatorDelegationsResponse): unknown { + const obj: any = {}; + if (message.delegationResponses) { + obj.delegationResponses = message.delegationResponses.map((e) => + e ? DelegationResponse.toJSON(e) : undefined, + ); + } else { + obj.delegationResponses = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorDelegationsResponse { const message = { ...baseQueryDelegatorDelegationsResponse } as QueryDelegatorDelegationsResponse; message.delegationResponses = []; @@ -1239,20 +1271,6 @@ export const QueryDelegatorDelegationsResponse = { } return message; }, - - toJSON(message: QueryDelegatorDelegationsResponse): unknown { - const obj: any = {}; - if (message.delegationResponses) { - obj.delegationResponses = message.delegationResponses.map((e) => - e ? DelegationResponse.toJSON(e) : undefined, - ); - } else { - obj.delegationResponses = []; - } - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryDelegatorUnbondingDelegationsRequest: object = { delegatorAddr: "" }; @@ -1262,8 +1280,10 @@ export const QueryDelegatorUnbondingDelegationsRequest = { message: QueryDelegatorUnbondingDelegationsRequest, writer: _m0.Writer = _m0.Writer.create(), ): _m0.Writer { - writer.uint32(10).string(message.delegatorAddr); - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.delegatorAddr !== "") { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -1309,6 +1329,14 @@ export const QueryDelegatorUnbondingDelegationsRequest = { return message; }, + toJSON(message: QueryDelegatorUnbondingDelegationsRequest): unknown { + const obj: any = {}; + message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial( object: DeepPartial, ): QueryDelegatorUnbondingDelegationsRequest { @@ -1327,14 +1355,6 @@ export const QueryDelegatorUnbondingDelegationsRequest = { } return message; }, - - toJSON(message: QueryDelegatorUnbondingDelegationsRequest): unknown { - const obj: any = {}; - message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryDelegatorUnbondingDelegationsResponse: object = {}; @@ -1347,7 +1367,7 @@ export const QueryDelegatorUnbondingDelegationsResponse = { for (const v of message.unbondingResponses) { UnbondingDelegation.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -1395,6 +1415,20 @@ export const QueryDelegatorUnbondingDelegationsResponse = { return message; }, + toJSON(message: QueryDelegatorUnbondingDelegationsResponse): unknown { + const obj: any = {}; + if (message.unbondingResponses) { + obj.unbondingResponses = message.unbondingResponses.map((e) => + e ? UnbondingDelegation.toJSON(e) : undefined, + ); + } else { + obj.unbondingResponses = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial( object: DeepPartial, ): QueryDelegatorUnbondingDelegationsResponse { @@ -1414,20 +1448,6 @@ export const QueryDelegatorUnbondingDelegationsResponse = { } return message; }, - - toJSON(message: QueryDelegatorUnbondingDelegationsResponse): unknown { - const obj: any = {}; - if (message.unbondingResponses) { - obj.unbondingResponses = message.unbondingResponses.map((e) => - e ? UnbondingDelegation.toJSON(e) : undefined, - ); - } else { - obj.unbondingResponses = []; - } - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryRedelegationsRequest: object = { @@ -1438,10 +1458,16 @@ const baseQueryRedelegationsRequest: object = { export const QueryRedelegationsRequest = { encode(message: QueryRedelegationsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddr); - writer.uint32(18).string(message.srcValidatorAddr); - writer.uint32(26).string(message.dstValidatorAddr); - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.delegatorAddr !== "") { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.srcValidatorAddr !== "") { + writer.uint32(18).string(message.srcValidatorAddr); + } + if (message.dstValidatorAddr !== "") { + writer.uint32(26).string(message.dstValidatorAddr); + } + if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(34).fork()).ldelim(); } return writer; @@ -1499,6 +1525,16 @@ export const QueryRedelegationsRequest = { return message; }, + toJSON(message: QueryRedelegationsRequest): unknown { + const obj: any = {}; + message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); + message.srcValidatorAddr !== undefined && (obj.srcValidatorAddr = message.srcValidatorAddr); + message.dstValidatorAddr !== undefined && (obj.dstValidatorAddr = message.dstValidatorAddr); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryRedelegationsRequest { const message = { ...baseQueryRedelegationsRequest } as QueryRedelegationsRequest; if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { @@ -1523,16 +1559,6 @@ export const QueryRedelegationsRequest = { } return message; }, - - toJSON(message: QueryRedelegationsRequest): unknown { - const obj: any = {}; - message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); - message.srcValidatorAddr !== undefined && (obj.srcValidatorAddr = message.srcValidatorAddr); - message.dstValidatorAddr !== undefined && (obj.dstValidatorAddr = message.dstValidatorAddr); - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryRedelegationsResponse: object = {}; @@ -1542,7 +1568,7 @@ export const QueryRedelegationsResponse = { for (const v of message.redelegationResponses) { RedelegationResponse.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -1586,6 +1612,20 @@ export const QueryRedelegationsResponse = { return message; }, + toJSON(message: QueryRedelegationsResponse): unknown { + const obj: any = {}; + if (message.redelegationResponses) { + obj.redelegationResponses = message.redelegationResponses.map((e) => + e ? RedelegationResponse.toJSON(e) : undefined, + ); + } else { + obj.redelegationResponses = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryRedelegationsResponse { const message = { ...baseQueryRedelegationsResponse } as QueryRedelegationsResponse; message.redelegationResponses = []; @@ -1601,28 +1641,16 @@ export const QueryRedelegationsResponse = { } return message; }, - - toJSON(message: QueryRedelegationsResponse): unknown { - const obj: any = {}; - if (message.redelegationResponses) { - obj.redelegationResponses = message.redelegationResponses.map((e) => - e ? RedelegationResponse.toJSON(e) : undefined, - ); - } else { - obj.redelegationResponses = []; - } - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryDelegatorValidatorsRequest: object = { delegatorAddr: "" }; export const QueryDelegatorValidatorsRequest = { encode(message: QueryDelegatorValidatorsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddr); - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.delegatorAddr !== "") { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -1664,6 +1692,14 @@ export const QueryDelegatorValidatorsRequest = { return message; }, + toJSON(message: QueryDelegatorValidatorsRequest): unknown { + const obj: any = {}; + message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorValidatorsRequest { const message = { ...baseQueryDelegatorValidatorsRequest } as QueryDelegatorValidatorsRequest; if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { @@ -1678,14 +1714,6 @@ export const QueryDelegatorValidatorsRequest = { } return message; }, - - toJSON(message: QueryDelegatorValidatorsRequest): unknown { - const obj: any = {}; - message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryDelegatorValidatorsResponse: object = {}; @@ -1695,7 +1723,7 @@ export const QueryDelegatorValidatorsResponse = { for (const v of message.validators) { Validator.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -1739,6 +1767,18 @@ export const QueryDelegatorValidatorsResponse = { return message; }, + toJSON(message: QueryDelegatorValidatorsResponse): unknown { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map((e) => (e ? Validator.toJSON(e) : undefined)); + } else { + obj.validators = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorValidatorsResponse { const message = { ...baseQueryDelegatorValidatorsResponse } as QueryDelegatorValidatorsResponse; message.validators = []; @@ -1754,26 +1794,18 @@ export const QueryDelegatorValidatorsResponse = { } return message; }, - - toJSON(message: QueryDelegatorValidatorsResponse): unknown { - const obj: any = {}; - if (message.validators) { - obj.validators = message.validators.map((e) => (e ? Validator.toJSON(e) : undefined)); - } else { - obj.validators = []; - } - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryDelegatorValidatorRequest: object = { delegatorAddr: "", validatorAddr: "" }; export const QueryDelegatorValidatorRequest = { encode(message: QueryDelegatorValidatorRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddr); - writer.uint32(18).string(message.validatorAddr); + if (message.delegatorAddr !== "") { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.validatorAddr !== "") { + writer.uint32(18).string(message.validatorAddr); + } return writer; }, @@ -1813,6 +1845,13 @@ export const QueryDelegatorValidatorRequest = { return message; }, + toJSON(message: QueryDelegatorValidatorRequest): unknown { + const obj: any = {}; + message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); + message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorValidatorRequest { const message = { ...baseQueryDelegatorValidatorRequest } as QueryDelegatorValidatorRequest; if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { @@ -1827,20 +1866,13 @@ export const QueryDelegatorValidatorRequest = { } return message; }, - - toJSON(message: QueryDelegatorValidatorRequest): unknown { - const obj: any = {}; - message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); - message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); - return obj; - }, }; const baseQueryDelegatorValidatorResponse: object = {}; export const QueryDelegatorValidatorResponse = { encode(message: QueryDelegatorValidatorResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.validator !== undefined && message.validator !== undefined) { + if (message.validator !== undefined) { Validator.encode(message.validator, writer.uint32(10).fork()).ldelim(); } return writer; @@ -1874,6 +1906,13 @@ export const QueryDelegatorValidatorResponse = { return message; }, + toJSON(message: QueryDelegatorValidatorResponse): unknown { + const obj: any = {}; + message.validator !== undefined && + (obj.validator = message.validator ? Validator.toJSON(message.validator) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorValidatorResponse { const message = { ...baseQueryDelegatorValidatorResponse } as QueryDelegatorValidatorResponse; if (object.validator !== undefined && object.validator !== null) { @@ -1883,20 +1922,15 @@ export const QueryDelegatorValidatorResponse = { } return message; }, - - toJSON(message: QueryDelegatorValidatorResponse): unknown { - const obj: any = {}; - message.validator !== undefined && - (obj.validator = message.validator ? Validator.toJSON(message.validator) : undefined); - return obj; - }, }; const baseQueryHistoricalInfoRequest: object = { height: Long.ZERO }; export const QueryHistoricalInfoRequest = { encode(message: QueryHistoricalInfoRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int64(message.height); + if (!message.height.isZero()) { + writer.uint32(8).int64(message.height); + } return writer; }, @@ -1928,6 +1962,12 @@ export const QueryHistoricalInfoRequest = { return message; }, + toJSON(message: QueryHistoricalInfoRequest): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryHistoricalInfoRequest { const message = { ...baseQueryHistoricalInfoRequest } as QueryHistoricalInfoRequest; if (object.height !== undefined && object.height !== null) { @@ -1937,19 +1977,13 @@ export const QueryHistoricalInfoRequest = { } return message; }, - - toJSON(message: QueryHistoricalInfoRequest): unknown { - const obj: any = {}; - message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); - return obj; - }, }; const baseQueryHistoricalInfoResponse: object = {}; export const QueryHistoricalInfoResponse = { encode(message: QueryHistoricalInfoResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.hist !== undefined && message.hist !== undefined) { + if (message.hist !== undefined) { HistoricalInfo.encode(message.hist, writer.uint32(10).fork()).ldelim(); } return writer; @@ -1983,6 +2017,12 @@ export const QueryHistoricalInfoResponse = { return message; }, + toJSON(message: QueryHistoricalInfoResponse): unknown { + const obj: any = {}; + message.hist !== undefined && (obj.hist = message.hist ? HistoricalInfo.toJSON(message.hist) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryHistoricalInfoResponse { const message = { ...baseQueryHistoricalInfoResponse } as QueryHistoricalInfoResponse; if (object.hist !== undefined && object.hist !== null) { @@ -1992,12 +2032,6 @@ export const QueryHistoricalInfoResponse = { } return message; }, - - toJSON(message: QueryHistoricalInfoResponse): unknown { - const obj: any = {}; - message.hist !== undefined && (obj.hist = message.hist ? HistoricalInfo.toJSON(message.hist) : undefined); - return obj; - }, }; const baseQueryPoolRequest: object = {}; @@ -2027,22 +2061,22 @@ export const QueryPoolRequest = { return message; }, - fromPartial(_: DeepPartial): QueryPoolRequest { - const message = { ...baseQueryPoolRequest } as QueryPoolRequest; - return message; - }, - toJSON(_: QueryPoolRequest): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): QueryPoolRequest { + const message = { ...baseQueryPoolRequest } as QueryPoolRequest; + return message; + }, }; const baseQueryPoolResponse: object = {}; export const QueryPoolResponse = { encode(message: QueryPoolResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.pool !== undefined && message.pool !== undefined) { + if (message.pool !== undefined) { Pool.encode(message.pool, writer.uint32(10).fork()).ldelim(); } return writer; @@ -2076,6 +2110,12 @@ export const QueryPoolResponse = { return message; }, + toJSON(message: QueryPoolResponse): unknown { + const obj: any = {}; + message.pool !== undefined && (obj.pool = message.pool ? Pool.toJSON(message.pool) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryPoolResponse { const message = { ...baseQueryPoolResponse } as QueryPoolResponse; if (object.pool !== undefined && object.pool !== null) { @@ -2085,12 +2125,6 @@ export const QueryPoolResponse = { } return message; }, - - toJSON(message: QueryPoolResponse): unknown { - const obj: any = {}; - message.pool !== undefined && (obj.pool = message.pool ? Pool.toJSON(message.pool) : undefined); - return obj; - }, }; const baseQueryParamsRequest: object = {}; @@ -2120,22 +2154,22 @@ export const QueryParamsRequest = { return message; }, - fromPartial(_: DeepPartial): QueryParamsRequest { - const message = { ...baseQueryParamsRequest } as QueryParamsRequest; - return message; - }, - toJSON(_: QueryParamsRequest): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, }; const baseQueryParamsResponse: object = {}; export const QueryParamsResponse = { encode(message: QueryParamsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.params !== undefined && message.params !== undefined) { + if (message.params !== undefined) { Params.encode(message.params, writer.uint32(10).fork()).ldelim(); } return writer; @@ -2169,6 +2203,12 @@ export const QueryParamsResponse = { return message; }, + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { const message = { ...baseQueryParamsResponse } as QueryParamsResponse; if (object.params !== undefined && object.params !== null) { @@ -2178,12 +2218,6 @@ export const QueryParamsResponse = { } return message; }, - - toJSON(message: QueryParamsResponse): unknown { - const obj: any = {}; - message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); - return obj; - }, }; /** Query defines the gRPC querier service. */ diff --git a/packages/stargate/src/codec/cosmos/staking/v1beta1/staking.ts b/packages/stargate/src/codec/cosmos/staking/v1beta1/staking.ts index 5f71ba53..24944a9e 100644 --- a/packages/stargate/src/codec/cosmos/staking/v1beta1/staking.ts +++ b/packages/stargate/src/codec/cosmos/staking/v1beta1/staking.ts @@ -256,7 +256,7 @@ const baseHistoricalInfo: object = {}; export const HistoricalInfo = { encode(message: HistoricalInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.header !== undefined && message.header !== undefined) { + if (message.header !== undefined) { Header.encode(message.header, writer.uint32(10).fork()).ldelim(); } for (const v of message.valset) { @@ -303,6 +303,17 @@ export const HistoricalInfo = { return message; }, + toJSON(message: HistoricalInfo): unknown { + const obj: any = {}; + message.header !== undefined && (obj.header = message.header ? Header.toJSON(message.header) : undefined); + if (message.valset) { + obj.valset = message.valset.map((e) => (e ? Validator.toJSON(e) : undefined)); + } else { + obj.valset = []; + } + return obj; + }, + fromPartial(object: DeepPartial): HistoricalInfo { const message = { ...baseHistoricalInfo } as HistoricalInfo; message.valset = []; @@ -318,26 +329,21 @@ export const HistoricalInfo = { } return message; }, - - toJSON(message: HistoricalInfo): unknown { - const obj: any = {}; - message.header !== undefined && (obj.header = message.header ? Header.toJSON(message.header) : undefined); - if (message.valset) { - obj.valset = message.valset.map((e) => (e ? Validator.toJSON(e) : undefined)); - } else { - obj.valset = []; - } - return obj; - }, }; const baseCommissionRates: object = { rate: "", maxRate: "", maxChangeRate: "" }; export const CommissionRates = { encode(message: CommissionRates, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.rate); - writer.uint32(18).string(message.maxRate); - writer.uint32(26).string(message.maxChangeRate); + if (message.rate !== "") { + writer.uint32(10).string(message.rate); + } + if (message.maxRate !== "") { + writer.uint32(18).string(message.maxRate); + } + if (message.maxChangeRate !== "") { + writer.uint32(26).string(message.maxChangeRate); + } return writer; }, @@ -385,6 +391,14 @@ export const CommissionRates = { return message; }, + toJSON(message: CommissionRates): unknown { + const obj: any = {}; + message.rate !== undefined && (obj.rate = message.rate); + message.maxRate !== undefined && (obj.maxRate = message.maxRate); + message.maxChangeRate !== undefined && (obj.maxChangeRate = message.maxChangeRate); + return obj; + }, + fromPartial(object: DeepPartial): CommissionRates { const message = { ...baseCommissionRates } as CommissionRates; if (object.rate !== undefined && object.rate !== null) { @@ -404,24 +418,16 @@ export const CommissionRates = { } return message; }, - - toJSON(message: CommissionRates): unknown { - const obj: any = {}; - message.rate !== undefined && (obj.rate = message.rate); - message.maxRate !== undefined && (obj.maxRate = message.maxRate); - message.maxChangeRate !== undefined && (obj.maxChangeRate = message.maxChangeRate); - return obj; - }, }; const baseCommission: object = {}; export const Commission = { encode(message: Commission, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.commissionRates !== undefined && message.commissionRates !== undefined) { + if (message.commissionRates !== undefined) { CommissionRates.encode(message.commissionRates, writer.uint32(10).fork()).ldelim(); } - if (message.updateTime !== undefined && message.updateTime !== undefined) { + if (message.updateTime !== undefined) { Timestamp.encode(toTimestamp(message.updateTime), writer.uint32(18).fork()).ldelim(); } return writer; @@ -463,6 +469,17 @@ export const Commission = { return message; }, + toJSON(message: Commission): unknown { + const obj: any = {}; + message.commissionRates !== undefined && + (obj.commissionRates = message.commissionRates + ? CommissionRates.toJSON(message.commissionRates) + : undefined); + message.updateTime !== undefined && + (obj.updateTime = message.updateTime !== undefined ? message.updateTime.toISOString() : null); + return obj; + }, + fromPartial(object: DeepPartial): Commission { const message = { ...baseCommission } as Commission; if (object.commissionRates !== undefined && object.commissionRates !== null) { @@ -477,28 +494,27 @@ export const Commission = { } return message; }, - - toJSON(message: Commission): unknown { - const obj: any = {}; - message.commissionRates !== undefined && - (obj.commissionRates = message.commissionRates - ? CommissionRates.toJSON(message.commissionRates) - : undefined); - message.updateTime !== undefined && - (obj.updateTime = message.updateTime !== undefined ? message.updateTime.toISOString() : null); - return obj; - }, }; const baseDescription: object = { moniker: "", identity: "", website: "", securityContact: "", details: "" }; export const Description = { encode(message: Description, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.moniker); - writer.uint32(18).string(message.identity); - writer.uint32(26).string(message.website); - writer.uint32(34).string(message.securityContact); - writer.uint32(42).string(message.details); + if (message.moniker !== "") { + writer.uint32(10).string(message.moniker); + } + if (message.identity !== "") { + writer.uint32(18).string(message.identity); + } + if (message.website !== "") { + writer.uint32(26).string(message.website); + } + if (message.securityContact !== "") { + writer.uint32(34).string(message.securityContact); + } + if (message.details !== "") { + writer.uint32(42).string(message.details); + } return writer; }, @@ -562,6 +578,16 @@ export const Description = { return message; }, + toJSON(message: Description): unknown { + const obj: any = {}; + message.moniker !== undefined && (obj.moniker = message.moniker); + message.identity !== undefined && (obj.identity = message.identity); + message.website !== undefined && (obj.website = message.website); + message.securityContact !== undefined && (obj.securityContact = message.securityContact); + message.details !== undefined && (obj.details = message.details); + return obj; + }, + fromPartial(object: DeepPartial): Description { const message = { ...baseDescription } as Description; if (object.moniker !== undefined && object.moniker !== null) { @@ -591,16 +617,6 @@ export const Description = { } return message; }, - - toJSON(message: Description): unknown { - const obj: any = {}; - message.moniker !== undefined && (obj.moniker = message.moniker); - message.identity !== undefined && (obj.identity = message.identity); - message.website !== undefined && (obj.website = message.website); - message.securityContact !== undefined && (obj.securityContact = message.securityContact); - message.details !== undefined && (obj.details = message.details); - return obj; - }, }; const baseValidator: object = { @@ -615,25 +631,39 @@ const baseValidator: object = { export const Validator = { encode(message: Validator, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.operatorAddress); - if (message.consensusPubkey !== undefined && message.consensusPubkey !== undefined) { + if (message.operatorAddress !== "") { + writer.uint32(10).string(message.operatorAddress); + } + if (message.consensusPubkey !== undefined) { Any.encode(message.consensusPubkey, writer.uint32(18).fork()).ldelim(); } - writer.uint32(24).bool(message.jailed); - writer.uint32(32).int32(message.status); - writer.uint32(42).string(message.tokens); - writer.uint32(50).string(message.delegatorShares); - if (message.description !== undefined && message.description !== undefined) { + if (message.jailed === true) { + writer.uint32(24).bool(message.jailed); + } + if (message.status !== 0) { + writer.uint32(32).int32(message.status); + } + if (message.tokens !== "") { + writer.uint32(42).string(message.tokens); + } + if (message.delegatorShares !== "") { + writer.uint32(50).string(message.delegatorShares); + } + if (message.description !== undefined) { Description.encode(message.description, writer.uint32(58).fork()).ldelim(); } - writer.uint32(64).int64(message.unbondingHeight); - if (message.unbondingTime !== undefined && message.unbondingTime !== undefined) { + if (!message.unbondingHeight.isZero()) { + writer.uint32(64).int64(message.unbondingHeight); + } + if (message.unbondingTime !== undefined) { Timestamp.encode(toTimestamp(message.unbondingTime), writer.uint32(74).fork()).ldelim(); } - if (message.commission !== undefined && message.commission !== undefined) { + if (message.commission !== undefined) { Commission.encode(message.commission, writer.uint32(82).fork()).ldelim(); } - writer.uint32(90).string(message.minSelfDelegation); + if (message.minSelfDelegation !== "") { + writer.uint32(90).string(message.minSelfDelegation); + } return writer; }, @@ -745,6 +775,27 @@ export const Validator = { return message; }, + toJSON(message: Validator): unknown { + const obj: any = {}; + message.operatorAddress !== undefined && (obj.operatorAddress = message.operatorAddress); + message.consensusPubkey !== undefined && + (obj.consensusPubkey = message.consensusPubkey ? Any.toJSON(message.consensusPubkey) : undefined); + message.jailed !== undefined && (obj.jailed = message.jailed); + message.status !== undefined && (obj.status = bondStatusToJSON(message.status)); + message.tokens !== undefined && (obj.tokens = message.tokens); + message.delegatorShares !== undefined && (obj.delegatorShares = message.delegatorShares); + message.description !== undefined && + (obj.description = message.description ? Description.toJSON(message.description) : undefined); + message.unbondingHeight !== undefined && + (obj.unbondingHeight = (message.unbondingHeight || Long.ZERO).toString()); + message.unbondingTime !== undefined && + (obj.unbondingTime = message.unbondingTime !== undefined ? message.unbondingTime.toISOString() : null); + message.commission !== undefined && + (obj.commission = message.commission ? Commission.toJSON(message.commission) : undefined); + message.minSelfDelegation !== undefined && (obj.minSelfDelegation = message.minSelfDelegation); + return obj; + }, + fromPartial(object: DeepPartial): Validator { const message = { ...baseValidator } as Validator; if (object.operatorAddress !== undefined && object.operatorAddress !== null) { @@ -804,27 +855,6 @@ export const Validator = { } return message; }, - - toJSON(message: Validator): unknown { - const obj: any = {}; - message.operatorAddress !== undefined && (obj.operatorAddress = message.operatorAddress); - message.consensusPubkey !== undefined && - (obj.consensusPubkey = message.consensusPubkey ? Any.toJSON(message.consensusPubkey) : undefined); - message.jailed !== undefined && (obj.jailed = message.jailed); - message.status !== undefined && (obj.status = bondStatusToJSON(message.status)); - message.tokens !== undefined && (obj.tokens = message.tokens); - message.delegatorShares !== undefined && (obj.delegatorShares = message.delegatorShares); - message.description !== undefined && - (obj.description = message.description ? Description.toJSON(message.description) : undefined); - message.unbondingHeight !== undefined && - (obj.unbondingHeight = (message.unbondingHeight || Long.ZERO).toString()); - message.unbondingTime !== undefined && - (obj.unbondingTime = message.unbondingTime !== undefined ? message.unbondingTime.toISOString() : null); - message.commission !== undefined && - (obj.commission = message.commission ? Commission.toJSON(message.commission) : undefined); - message.minSelfDelegation !== undefined && (obj.minSelfDelegation = message.minSelfDelegation); - return obj; - }, }; const baseValAddresses: object = { addresses: "" }; @@ -867,6 +897,16 @@ export const ValAddresses = { return message; }, + toJSON(message: ValAddresses): unknown { + const obj: any = {}; + if (message.addresses) { + obj.addresses = message.addresses.map((e) => e); + } else { + obj.addresses = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ValAddresses { const message = { ...baseValAddresses } as ValAddresses; message.addresses = []; @@ -877,24 +917,18 @@ export const ValAddresses = { } return message; }, - - toJSON(message: ValAddresses): unknown { - const obj: any = {}; - if (message.addresses) { - obj.addresses = message.addresses.map((e) => e); - } else { - obj.addresses = []; - } - return obj; - }, }; const baseDVPair: object = { delegatorAddress: "", validatorAddress: "" }; export const DVPair = { encode(message: DVPair, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddress); - writer.uint32(18).string(message.validatorAddress); + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== "") { + writer.uint32(18).string(message.validatorAddress); + } return writer; }, @@ -934,6 +968,13 @@ export const DVPair = { return message; }, + toJSON(message: DVPair): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + return obj; + }, + fromPartial(object: DeepPartial): DVPair { const message = { ...baseDVPair } as DVPair; if (object.delegatorAddress !== undefined && object.delegatorAddress !== null) { @@ -948,13 +989,6 @@ export const DVPair = { } return message; }, - - toJSON(message: DVPair): unknown { - const obj: any = {}; - message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); - message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); - return obj; - }, }; const baseDVPairs: object = {}; @@ -997,6 +1031,16 @@ export const DVPairs = { return message; }, + toJSON(message: DVPairs): unknown { + const obj: any = {}; + if (message.pairs) { + obj.pairs = message.pairs.map((e) => (e ? DVPair.toJSON(e) : undefined)); + } else { + obj.pairs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): DVPairs { const message = { ...baseDVPairs } as DVPairs; message.pairs = []; @@ -1007,25 +1051,21 @@ export const DVPairs = { } return message; }, - - toJSON(message: DVPairs): unknown { - const obj: any = {}; - if (message.pairs) { - obj.pairs = message.pairs.map((e) => (e ? DVPair.toJSON(e) : undefined)); - } else { - obj.pairs = []; - } - return obj; - }, }; const baseDVVTriplet: object = { delegatorAddress: "", validatorSrcAddress: "", validatorDstAddress: "" }; export const DVVTriplet = { encode(message: DVVTriplet, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddress); - writer.uint32(18).string(message.validatorSrcAddress); - writer.uint32(26).string(message.validatorDstAddress); + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorSrcAddress !== "") { + writer.uint32(18).string(message.validatorSrcAddress); + } + if (message.validatorDstAddress !== "") { + writer.uint32(26).string(message.validatorDstAddress); + } return writer; }, @@ -1073,6 +1113,14 @@ export const DVVTriplet = { return message; }, + toJSON(message: DVVTriplet): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorSrcAddress !== undefined && (obj.validatorSrcAddress = message.validatorSrcAddress); + message.validatorDstAddress !== undefined && (obj.validatorDstAddress = message.validatorDstAddress); + return obj; + }, + fromPartial(object: DeepPartial): DVVTriplet { const message = { ...baseDVVTriplet } as DVVTriplet; if (object.delegatorAddress !== undefined && object.delegatorAddress !== null) { @@ -1092,14 +1140,6 @@ export const DVVTriplet = { } return message; }, - - toJSON(message: DVVTriplet): unknown { - const obj: any = {}; - message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); - message.validatorSrcAddress !== undefined && (obj.validatorSrcAddress = message.validatorSrcAddress); - message.validatorDstAddress !== undefined && (obj.validatorDstAddress = message.validatorDstAddress); - return obj; - }, }; const baseDVVTriplets: object = {}; @@ -1142,6 +1182,16 @@ export const DVVTriplets = { return message; }, + toJSON(message: DVVTriplets): unknown { + const obj: any = {}; + if (message.triplets) { + obj.triplets = message.triplets.map((e) => (e ? DVVTriplet.toJSON(e) : undefined)); + } else { + obj.triplets = []; + } + return obj; + }, + fromPartial(object: DeepPartial): DVVTriplets { const message = { ...baseDVVTriplets } as DVVTriplets; message.triplets = []; @@ -1152,25 +1202,21 @@ export const DVVTriplets = { } return message; }, - - toJSON(message: DVVTriplets): unknown { - const obj: any = {}; - if (message.triplets) { - obj.triplets = message.triplets.map((e) => (e ? DVVTriplet.toJSON(e) : undefined)); - } else { - obj.triplets = []; - } - return obj; - }, }; const baseDelegation: object = { delegatorAddress: "", validatorAddress: "", shares: "" }; export const Delegation = { encode(message: Delegation, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddress); - writer.uint32(18).string(message.validatorAddress); - writer.uint32(26).string(message.shares); + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== "") { + writer.uint32(18).string(message.validatorAddress); + } + if (message.shares !== "") { + writer.uint32(26).string(message.shares); + } return writer; }, @@ -1218,6 +1264,14 @@ export const Delegation = { return message; }, + toJSON(message: Delegation): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.shares !== undefined && (obj.shares = message.shares); + return obj; + }, + fromPartial(object: DeepPartial): Delegation { const message = { ...baseDelegation } as Delegation; if (object.delegatorAddress !== undefined && object.delegatorAddress !== null) { @@ -1237,22 +1291,18 @@ export const Delegation = { } return message; }, - - toJSON(message: Delegation): unknown { - const obj: any = {}; - message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); - message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); - message.shares !== undefined && (obj.shares = message.shares); - return obj; - }, }; const baseUnbondingDelegation: object = { delegatorAddress: "", validatorAddress: "" }; export const UnbondingDelegation = { encode(message: UnbondingDelegation, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddress); - writer.uint32(18).string(message.validatorAddress); + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== "") { + writer.uint32(18).string(message.validatorAddress); + } for (const v of message.entries) { UnbondingDelegationEntry.encode(v!, writer.uint32(26).fork()).ldelim(); } @@ -1305,6 +1355,18 @@ export const UnbondingDelegation = { return message; }, + toJSON(message: UnbondingDelegation): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + if (message.entries) { + obj.entries = message.entries.map((e) => (e ? UnbondingDelegationEntry.toJSON(e) : undefined)); + } else { + obj.entries = []; + } + return obj; + }, + fromPartial(object: DeepPartial): UnbondingDelegation { const message = { ...baseUnbondingDelegation } as UnbondingDelegation; message.entries = []; @@ -1325,30 +1387,24 @@ export const UnbondingDelegation = { } return message; }, - - toJSON(message: UnbondingDelegation): unknown { - const obj: any = {}; - message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); - message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); - if (message.entries) { - obj.entries = message.entries.map((e) => (e ? UnbondingDelegationEntry.toJSON(e) : undefined)); - } else { - obj.entries = []; - } - return obj; - }, }; const baseUnbondingDelegationEntry: object = { creationHeight: Long.ZERO, initialBalance: "", balance: "" }; export const UnbondingDelegationEntry = { encode(message: UnbondingDelegationEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int64(message.creationHeight); - if (message.completionTime !== undefined && message.completionTime !== undefined) { + if (!message.creationHeight.isZero()) { + writer.uint32(8).int64(message.creationHeight); + } + if (message.completionTime !== undefined) { Timestamp.encode(toTimestamp(message.completionTime), writer.uint32(18).fork()).ldelim(); } - writer.uint32(26).string(message.initialBalance); - writer.uint32(34).string(message.balance); + if (message.initialBalance !== "") { + writer.uint32(26).string(message.initialBalance); + } + if (message.balance !== "") { + writer.uint32(34).string(message.balance); + } return writer; }, @@ -1404,6 +1460,18 @@ export const UnbondingDelegationEntry = { return message; }, + toJSON(message: UnbondingDelegationEntry): unknown { + const obj: any = {}; + message.creationHeight !== undefined && + (obj.creationHeight = (message.creationHeight || Long.ZERO).toString()); + message.completionTime !== undefined && + (obj.completionTime = + message.completionTime !== undefined ? message.completionTime.toISOString() : null); + message.initialBalance !== undefined && (obj.initialBalance = message.initialBalance); + message.balance !== undefined && (obj.balance = message.balance); + return obj; + }, + fromPartial(object: DeepPartial): UnbondingDelegationEntry { const message = { ...baseUnbondingDelegationEntry } as UnbondingDelegationEntry; if (object.creationHeight !== undefined && object.creationHeight !== null) { @@ -1428,30 +1496,24 @@ export const UnbondingDelegationEntry = { } return message; }, - - toJSON(message: UnbondingDelegationEntry): unknown { - const obj: any = {}; - message.creationHeight !== undefined && - (obj.creationHeight = (message.creationHeight || Long.ZERO).toString()); - message.completionTime !== undefined && - (obj.completionTime = - message.completionTime !== undefined ? message.completionTime.toISOString() : null); - message.initialBalance !== undefined && (obj.initialBalance = message.initialBalance); - message.balance !== undefined && (obj.balance = message.balance); - return obj; - }, }; const baseRedelegationEntry: object = { creationHeight: Long.ZERO, initialBalance: "", sharesDst: "" }; export const RedelegationEntry = { encode(message: RedelegationEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int64(message.creationHeight); - if (message.completionTime !== undefined && message.completionTime !== undefined) { + if (!message.creationHeight.isZero()) { + writer.uint32(8).int64(message.creationHeight); + } + if (message.completionTime !== undefined) { Timestamp.encode(toTimestamp(message.completionTime), writer.uint32(18).fork()).ldelim(); } - writer.uint32(26).string(message.initialBalance); - writer.uint32(34).string(message.sharesDst); + if (message.initialBalance !== "") { + writer.uint32(26).string(message.initialBalance); + } + if (message.sharesDst !== "") { + writer.uint32(34).string(message.sharesDst); + } return writer; }, @@ -1507,6 +1569,18 @@ export const RedelegationEntry = { return message; }, + toJSON(message: RedelegationEntry): unknown { + const obj: any = {}; + message.creationHeight !== undefined && + (obj.creationHeight = (message.creationHeight || Long.ZERO).toString()); + message.completionTime !== undefined && + (obj.completionTime = + message.completionTime !== undefined ? message.completionTime.toISOString() : null); + message.initialBalance !== undefined && (obj.initialBalance = message.initialBalance); + message.sharesDst !== undefined && (obj.sharesDst = message.sharesDst); + return obj; + }, + fromPartial(object: DeepPartial): RedelegationEntry { const message = { ...baseRedelegationEntry } as RedelegationEntry; if (object.creationHeight !== undefined && object.creationHeight !== null) { @@ -1531,27 +1605,21 @@ export const RedelegationEntry = { } return message; }, - - toJSON(message: RedelegationEntry): unknown { - const obj: any = {}; - message.creationHeight !== undefined && - (obj.creationHeight = (message.creationHeight || Long.ZERO).toString()); - message.completionTime !== undefined && - (obj.completionTime = - message.completionTime !== undefined ? message.completionTime.toISOString() : null); - message.initialBalance !== undefined && (obj.initialBalance = message.initialBalance); - message.sharesDst !== undefined && (obj.sharesDst = message.sharesDst); - return obj; - }, }; const baseRedelegation: object = { delegatorAddress: "", validatorSrcAddress: "", validatorDstAddress: "" }; export const Redelegation = { encode(message: Redelegation, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddress); - writer.uint32(18).string(message.validatorSrcAddress); - writer.uint32(26).string(message.validatorDstAddress); + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorSrcAddress !== "") { + writer.uint32(18).string(message.validatorSrcAddress); + } + if (message.validatorDstAddress !== "") { + writer.uint32(26).string(message.validatorDstAddress); + } for (const v of message.entries) { RedelegationEntry.encode(v!, writer.uint32(34).fork()).ldelim(); } @@ -1612,6 +1680,19 @@ export const Redelegation = { return message; }, + toJSON(message: Redelegation): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorSrcAddress !== undefined && (obj.validatorSrcAddress = message.validatorSrcAddress); + message.validatorDstAddress !== undefined && (obj.validatorDstAddress = message.validatorDstAddress); + if (message.entries) { + obj.entries = message.entries.map((e) => (e ? RedelegationEntry.toJSON(e) : undefined)); + } else { + obj.entries = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Redelegation { const message = { ...baseRedelegation } as Redelegation; message.entries = []; @@ -1637,32 +1718,27 @@ export const Redelegation = { } return message; }, - - toJSON(message: Redelegation): unknown { - const obj: any = {}; - message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); - message.validatorSrcAddress !== undefined && (obj.validatorSrcAddress = message.validatorSrcAddress); - message.validatorDstAddress !== undefined && (obj.validatorDstAddress = message.validatorDstAddress); - if (message.entries) { - obj.entries = message.entries.map((e) => (e ? RedelegationEntry.toJSON(e) : undefined)); - } else { - obj.entries = []; - } - return obj; - }, }; const baseParams: object = { maxValidators: 0, maxEntries: 0, historicalEntries: 0, bondDenom: "" }; export const Params = { encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.unbondingTime !== undefined && message.unbondingTime !== undefined) { + if (message.unbondingTime !== undefined) { Duration.encode(message.unbondingTime, writer.uint32(10).fork()).ldelim(); } - writer.uint32(16).uint32(message.maxValidators); - writer.uint32(24).uint32(message.maxEntries); - writer.uint32(32).uint32(message.historicalEntries); - writer.uint32(42).string(message.bondDenom); + if (message.maxValidators !== 0) { + writer.uint32(16).uint32(message.maxValidators); + } + if (message.maxEntries !== 0) { + writer.uint32(24).uint32(message.maxEntries); + } + if (message.historicalEntries !== 0) { + writer.uint32(32).uint32(message.historicalEntries); + } + if (message.bondDenom !== "") { + writer.uint32(42).string(message.bondDenom); + } return writer; }, @@ -1726,6 +1802,17 @@ export const Params = { return message; }, + toJSON(message: Params): unknown { + const obj: any = {}; + message.unbondingTime !== undefined && + (obj.unbondingTime = message.unbondingTime ? Duration.toJSON(message.unbondingTime) : undefined); + message.maxValidators !== undefined && (obj.maxValidators = message.maxValidators); + message.maxEntries !== undefined && (obj.maxEntries = message.maxEntries); + message.historicalEntries !== undefined && (obj.historicalEntries = message.historicalEntries); + message.bondDenom !== undefined && (obj.bondDenom = message.bondDenom); + return obj; + }, + fromPartial(object: DeepPartial): Params { const message = { ...baseParams } as Params; if (object.unbondingTime !== undefined && object.unbondingTime !== null) { @@ -1755,27 +1842,16 @@ export const Params = { } return message; }, - - toJSON(message: Params): unknown { - const obj: any = {}; - message.unbondingTime !== undefined && - (obj.unbondingTime = message.unbondingTime ? Duration.toJSON(message.unbondingTime) : undefined); - message.maxValidators !== undefined && (obj.maxValidators = message.maxValidators); - message.maxEntries !== undefined && (obj.maxEntries = message.maxEntries); - message.historicalEntries !== undefined && (obj.historicalEntries = message.historicalEntries); - message.bondDenom !== undefined && (obj.bondDenom = message.bondDenom); - return obj; - }, }; const baseDelegationResponse: object = {}; export const DelegationResponse = { encode(message: DelegationResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.delegation !== undefined && message.delegation !== undefined) { + if (message.delegation !== undefined) { Delegation.encode(message.delegation, writer.uint32(10).fork()).ldelim(); } - if (message.balance !== undefined && message.balance !== undefined) { + if (message.balance !== undefined) { Coin.encode(message.balance, writer.uint32(18).fork()).ldelim(); } return writer; @@ -1817,6 +1893,15 @@ export const DelegationResponse = { return message; }, + toJSON(message: DelegationResponse): unknown { + const obj: any = {}; + message.delegation !== undefined && + (obj.delegation = message.delegation ? Delegation.toJSON(message.delegation) : undefined); + message.balance !== undefined && + (obj.balance = message.balance ? Coin.toJSON(message.balance) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): DelegationResponse { const message = { ...baseDelegationResponse } as DelegationResponse; if (object.delegation !== undefined && object.delegation !== null) { @@ -1831,25 +1916,18 @@ export const DelegationResponse = { } return message; }, - - toJSON(message: DelegationResponse): unknown { - const obj: any = {}; - message.delegation !== undefined && - (obj.delegation = message.delegation ? Delegation.toJSON(message.delegation) : undefined); - message.balance !== undefined && - (obj.balance = message.balance ? Coin.toJSON(message.balance) : undefined); - return obj; - }, }; const baseRedelegationEntryResponse: object = { balance: "" }; export const RedelegationEntryResponse = { encode(message: RedelegationEntryResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.redelegationEntry !== undefined && message.redelegationEntry !== undefined) { + if (message.redelegationEntry !== undefined) { RedelegationEntry.encode(message.redelegationEntry, writer.uint32(10).fork()).ldelim(); } - writer.uint32(34).string(message.balance); + if (message.balance !== "") { + writer.uint32(34).string(message.balance); + } return writer; }, @@ -1889,6 +1967,16 @@ export const RedelegationEntryResponse = { return message; }, + toJSON(message: RedelegationEntryResponse): unknown { + const obj: any = {}; + message.redelegationEntry !== undefined && + (obj.redelegationEntry = message.redelegationEntry + ? RedelegationEntry.toJSON(message.redelegationEntry) + : undefined); + message.balance !== undefined && (obj.balance = message.balance); + return obj; + }, + fromPartial(object: DeepPartial): RedelegationEntryResponse { const message = { ...baseRedelegationEntryResponse } as RedelegationEntryResponse; if (object.redelegationEntry !== undefined && object.redelegationEntry !== null) { @@ -1903,23 +1991,13 @@ export const RedelegationEntryResponse = { } return message; }, - - toJSON(message: RedelegationEntryResponse): unknown { - const obj: any = {}; - message.redelegationEntry !== undefined && - (obj.redelegationEntry = message.redelegationEntry - ? RedelegationEntry.toJSON(message.redelegationEntry) - : undefined); - message.balance !== undefined && (obj.balance = message.balance); - return obj; - }, }; const baseRedelegationResponse: object = {}; export const RedelegationResponse = { encode(message: RedelegationResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.redelegation !== undefined && message.redelegation !== undefined) { + if (message.redelegation !== undefined) { Redelegation.encode(message.redelegation, writer.uint32(10).fork()).ldelim(); } for (const v of message.entries) { @@ -1966,6 +2044,18 @@ export const RedelegationResponse = { return message; }, + toJSON(message: RedelegationResponse): unknown { + const obj: any = {}; + message.redelegation !== undefined && + (obj.redelegation = message.redelegation ? Redelegation.toJSON(message.redelegation) : undefined); + if (message.entries) { + obj.entries = message.entries.map((e) => (e ? RedelegationEntryResponse.toJSON(e) : undefined)); + } else { + obj.entries = []; + } + return obj; + }, + fromPartial(object: DeepPartial): RedelegationResponse { const message = { ...baseRedelegationResponse } as RedelegationResponse; message.entries = []; @@ -1981,26 +2071,18 @@ export const RedelegationResponse = { } return message; }, - - toJSON(message: RedelegationResponse): unknown { - const obj: any = {}; - message.redelegation !== undefined && - (obj.redelegation = message.redelegation ? Redelegation.toJSON(message.redelegation) : undefined); - if (message.entries) { - obj.entries = message.entries.map((e) => (e ? RedelegationEntryResponse.toJSON(e) : undefined)); - } else { - obj.entries = []; - } - return obj; - }, }; const basePool: object = { notBondedTokens: "", bondedTokens: "" }; export const Pool = { encode(message: Pool, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.notBondedTokens); - writer.uint32(18).string(message.bondedTokens); + if (message.notBondedTokens !== "") { + writer.uint32(10).string(message.notBondedTokens); + } + if (message.bondedTokens !== "") { + writer.uint32(18).string(message.bondedTokens); + } return writer; }, @@ -2040,6 +2122,13 @@ export const Pool = { return message; }, + toJSON(message: Pool): unknown { + const obj: any = {}; + message.notBondedTokens !== undefined && (obj.notBondedTokens = message.notBondedTokens); + message.bondedTokens !== undefined && (obj.bondedTokens = message.bondedTokens); + return obj; + }, + fromPartial(object: DeepPartial): Pool { const message = { ...basePool } as Pool; if (object.notBondedTokens !== undefined && object.notBondedTokens !== null) { @@ -2054,13 +2143,6 @@ export const Pool = { } return message; }, - - toJSON(message: Pool): unknown { - const obj: any = {}; - message.notBondedTokens !== undefined && (obj.notBondedTokens = message.notBondedTokens); - message.bondedTokens !== undefined && (obj.bondedTokens = message.bondedTokens); - return obj; - }, }; type Builtin = Date | Function | Uint8Array | string | number | undefined | Long; diff --git a/packages/stargate/src/codec/cosmos/staking/v1beta1/tx.ts b/packages/stargate/src/codec/cosmos/staking/v1beta1/tx.ts index 882036b6..662f5b36 100644 --- a/packages/stargate/src/codec/cosmos/staking/v1beta1/tx.ts +++ b/packages/stargate/src/codec/cosmos/staking/v1beta1/tx.ts @@ -87,19 +87,25 @@ const baseMsgCreateValidator: object = { minSelfDelegation: "", delegatorAddress export const MsgCreateValidator = { encode(message: MsgCreateValidator, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.description !== undefined && message.description !== undefined) { + if (message.description !== undefined) { Description.encode(message.description, writer.uint32(10).fork()).ldelim(); } - if (message.commission !== undefined && message.commission !== undefined) { + if (message.commission !== undefined) { CommissionRates.encode(message.commission, writer.uint32(18).fork()).ldelim(); } - writer.uint32(26).string(message.minSelfDelegation); - writer.uint32(34).string(message.delegatorAddress); - writer.uint32(42).string(message.validatorAddress); - if (message.pubkey !== undefined && message.pubkey !== undefined) { + if (message.minSelfDelegation !== "") { + writer.uint32(26).string(message.minSelfDelegation); + } + if (message.delegatorAddress !== "") { + writer.uint32(34).string(message.delegatorAddress); + } + if (message.validatorAddress !== "") { + writer.uint32(42).string(message.validatorAddress); + } + if (message.pubkey !== undefined) { Any.encode(message.pubkey, writer.uint32(50).fork()).ldelim(); } - if (message.value !== undefined && message.value !== undefined) { + if (message.value !== undefined) { Coin.encode(message.value, writer.uint32(58).fork()).ldelim(); } return writer; @@ -181,6 +187,20 @@ export const MsgCreateValidator = { return message; }, + toJSON(message: MsgCreateValidator): unknown { + const obj: any = {}; + message.description !== undefined && + (obj.description = message.description ? Description.toJSON(message.description) : undefined); + message.commission !== undefined && + (obj.commission = message.commission ? CommissionRates.toJSON(message.commission) : undefined); + message.minSelfDelegation !== undefined && (obj.minSelfDelegation = message.minSelfDelegation); + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.pubkey !== undefined && (obj.pubkey = message.pubkey ? Any.toJSON(message.pubkey) : undefined); + message.value !== undefined && (obj.value = message.value ? Coin.toJSON(message.value) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MsgCreateValidator { const message = { ...baseMsgCreateValidator } as MsgCreateValidator; if (object.description !== undefined && object.description !== null) { @@ -220,20 +240,6 @@ export const MsgCreateValidator = { } return message; }, - - toJSON(message: MsgCreateValidator): unknown { - const obj: any = {}; - message.description !== undefined && - (obj.description = message.description ? Description.toJSON(message.description) : undefined); - message.commission !== undefined && - (obj.commission = message.commission ? CommissionRates.toJSON(message.commission) : undefined); - message.minSelfDelegation !== undefined && (obj.minSelfDelegation = message.minSelfDelegation); - message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); - message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); - message.pubkey !== undefined && (obj.pubkey = message.pubkey ? Any.toJSON(message.pubkey) : undefined); - message.value !== undefined && (obj.value = message.value ? Coin.toJSON(message.value) : undefined); - return obj; - }, }; const baseMsgCreateValidatorResponse: object = {}; @@ -263,27 +269,33 @@ export const MsgCreateValidatorResponse = { return message; }, - fromPartial(_: DeepPartial): MsgCreateValidatorResponse { - const message = { ...baseMsgCreateValidatorResponse } as MsgCreateValidatorResponse; - return message; - }, - toJSON(_: MsgCreateValidatorResponse): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): MsgCreateValidatorResponse { + const message = { ...baseMsgCreateValidatorResponse } as MsgCreateValidatorResponse; + return message; + }, }; const baseMsgEditValidator: object = { validatorAddress: "", commissionRate: "", minSelfDelegation: "" }; export const MsgEditValidator = { encode(message: MsgEditValidator, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.description !== undefined && message.description !== undefined) { + if (message.description !== undefined) { Description.encode(message.description, writer.uint32(10).fork()).ldelim(); } - writer.uint32(18).string(message.validatorAddress); - writer.uint32(26).string(message.commissionRate); - writer.uint32(34).string(message.minSelfDelegation); + if (message.validatorAddress !== "") { + writer.uint32(18).string(message.validatorAddress); + } + if (message.commissionRate !== "") { + writer.uint32(26).string(message.commissionRate); + } + if (message.minSelfDelegation !== "") { + writer.uint32(34).string(message.minSelfDelegation); + } return writer; }, @@ -339,6 +351,16 @@ export const MsgEditValidator = { return message; }, + toJSON(message: MsgEditValidator): unknown { + const obj: any = {}; + message.description !== undefined && + (obj.description = message.description ? Description.toJSON(message.description) : undefined); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.commissionRate !== undefined && (obj.commissionRate = message.commissionRate); + message.minSelfDelegation !== undefined && (obj.minSelfDelegation = message.minSelfDelegation); + return obj; + }, + fromPartial(object: DeepPartial): MsgEditValidator { const message = { ...baseMsgEditValidator } as MsgEditValidator; if (object.description !== undefined && object.description !== null) { @@ -363,16 +385,6 @@ export const MsgEditValidator = { } return message; }, - - toJSON(message: MsgEditValidator): unknown { - const obj: any = {}; - message.description !== undefined && - (obj.description = message.description ? Description.toJSON(message.description) : undefined); - message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); - message.commissionRate !== undefined && (obj.commissionRate = message.commissionRate); - message.minSelfDelegation !== undefined && (obj.minSelfDelegation = message.minSelfDelegation); - return obj; - }, }; const baseMsgEditValidatorResponse: object = {}; @@ -402,24 +414,28 @@ export const MsgEditValidatorResponse = { return message; }, - fromPartial(_: DeepPartial): MsgEditValidatorResponse { - const message = { ...baseMsgEditValidatorResponse } as MsgEditValidatorResponse; - return message; - }, - toJSON(_: MsgEditValidatorResponse): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): MsgEditValidatorResponse { + const message = { ...baseMsgEditValidatorResponse } as MsgEditValidatorResponse; + return message; + }, }; const baseMsgDelegate: object = { delegatorAddress: "", validatorAddress: "" }; export const MsgDelegate = { encode(message: MsgDelegate, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddress); - writer.uint32(18).string(message.validatorAddress); - if (message.amount !== undefined && message.amount !== undefined) { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== "") { + writer.uint32(18).string(message.validatorAddress); + } + if (message.amount !== undefined) { Coin.encode(message.amount, writer.uint32(26).fork()).ldelim(); } return writer; @@ -469,6 +485,14 @@ export const MsgDelegate = { return message; }, + toJSON(message: MsgDelegate): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.amount !== undefined && (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MsgDelegate { const message = { ...baseMsgDelegate } as MsgDelegate; if (object.delegatorAddress !== undefined && object.delegatorAddress !== null) { @@ -488,14 +512,6 @@ export const MsgDelegate = { } return message; }, - - toJSON(message: MsgDelegate): unknown { - const obj: any = {}; - message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); - message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); - message.amount !== undefined && (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); - return obj; - }, }; const baseMsgDelegateResponse: object = {}; @@ -525,15 +541,15 @@ export const MsgDelegateResponse = { return message; }, - fromPartial(_: DeepPartial): MsgDelegateResponse { - const message = { ...baseMsgDelegateResponse } as MsgDelegateResponse; - return message; - }, - toJSON(_: MsgDelegateResponse): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): MsgDelegateResponse { + const message = { ...baseMsgDelegateResponse } as MsgDelegateResponse; + return message; + }, }; const baseMsgBeginRedelegate: object = { @@ -544,10 +560,16 @@ const baseMsgBeginRedelegate: object = { export const MsgBeginRedelegate = { encode(message: MsgBeginRedelegate, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddress); - writer.uint32(18).string(message.validatorSrcAddress); - writer.uint32(26).string(message.validatorDstAddress); - if (message.amount !== undefined && message.amount !== undefined) { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorSrcAddress !== "") { + writer.uint32(18).string(message.validatorSrcAddress); + } + if (message.validatorDstAddress !== "") { + writer.uint32(26).string(message.validatorDstAddress); + } + if (message.amount !== undefined) { Coin.encode(message.amount, writer.uint32(34).fork()).ldelim(); } return writer; @@ -605,6 +627,15 @@ export const MsgBeginRedelegate = { return message; }, + toJSON(message: MsgBeginRedelegate): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorSrcAddress !== undefined && (obj.validatorSrcAddress = message.validatorSrcAddress); + message.validatorDstAddress !== undefined && (obj.validatorDstAddress = message.validatorDstAddress); + message.amount !== undefined && (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MsgBeginRedelegate { const message = { ...baseMsgBeginRedelegate } as MsgBeginRedelegate; if (object.delegatorAddress !== undefined && object.delegatorAddress !== null) { @@ -629,22 +660,13 @@ export const MsgBeginRedelegate = { } return message; }, - - toJSON(message: MsgBeginRedelegate): unknown { - const obj: any = {}; - message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); - message.validatorSrcAddress !== undefined && (obj.validatorSrcAddress = message.validatorSrcAddress); - message.validatorDstAddress !== undefined && (obj.validatorDstAddress = message.validatorDstAddress); - message.amount !== undefined && (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); - return obj; - }, }; const baseMsgBeginRedelegateResponse: object = {}; export const MsgBeginRedelegateResponse = { encode(message: MsgBeginRedelegateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.completionTime !== undefined && message.completionTime !== undefined) { + if (message.completionTime !== undefined) { Timestamp.encode(toTimestamp(message.completionTime), writer.uint32(10).fork()).ldelim(); } return writer; @@ -678,6 +700,14 @@ export const MsgBeginRedelegateResponse = { return message; }, + toJSON(message: MsgBeginRedelegateResponse): unknown { + const obj: any = {}; + message.completionTime !== undefined && + (obj.completionTime = + message.completionTime !== undefined ? message.completionTime.toISOString() : null); + return obj; + }, + fromPartial(object: DeepPartial): MsgBeginRedelegateResponse { const message = { ...baseMsgBeginRedelegateResponse } as MsgBeginRedelegateResponse; if (object.completionTime !== undefined && object.completionTime !== null) { @@ -687,23 +717,19 @@ export const MsgBeginRedelegateResponse = { } return message; }, - - toJSON(message: MsgBeginRedelegateResponse): unknown { - const obj: any = {}; - message.completionTime !== undefined && - (obj.completionTime = - message.completionTime !== undefined ? message.completionTime.toISOString() : null); - return obj; - }, }; const baseMsgUndelegate: object = { delegatorAddress: "", validatorAddress: "" }; export const MsgUndelegate = { encode(message: MsgUndelegate, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.delegatorAddress); - writer.uint32(18).string(message.validatorAddress); - if (message.amount !== undefined && message.amount !== undefined) { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== "") { + writer.uint32(18).string(message.validatorAddress); + } + if (message.amount !== undefined) { Coin.encode(message.amount, writer.uint32(26).fork()).ldelim(); } return writer; @@ -753,6 +779,14 @@ export const MsgUndelegate = { return message; }, + toJSON(message: MsgUndelegate): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.amount !== undefined && (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MsgUndelegate { const message = { ...baseMsgUndelegate } as MsgUndelegate; if (object.delegatorAddress !== undefined && object.delegatorAddress !== null) { @@ -772,21 +806,13 @@ export const MsgUndelegate = { } return message; }, - - toJSON(message: MsgUndelegate): unknown { - const obj: any = {}; - message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); - message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); - message.amount !== undefined && (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); - return obj; - }, }; const baseMsgUndelegateResponse: object = {}; export const MsgUndelegateResponse = { encode(message: MsgUndelegateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.completionTime !== undefined && message.completionTime !== undefined) { + if (message.completionTime !== undefined) { Timestamp.encode(toTimestamp(message.completionTime), writer.uint32(10).fork()).ldelim(); } return writer; @@ -820,6 +846,14 @@ export const MsgUndelegateResponse = { return message; }, + toJSON(message: MsgUndelegateResponse): unknown { + const obj: any = {}; + message.completionTime !== undefined && + (obj.completionTime = + message.completionTime !== undefined ? message.completionTime.toISOString() : null); + return obj; + }, + fromPartial(object: DeepPartial): MsgUndelegateResponse { const message = { ...baseMsgUndelegateResponse } as MsgUndelegateResponse; if (object.completionTime !== undefined && object.completionTime !== null) { @@ -829,14 +863,6 @@ export const MsgUndelegateResponse = { } return message; }, - - toJSON(message: MsgUndelegateResponse): unknown { - const obj: any = {}; - message.completionTime !== undefined && - (obj.completionTime = - message.completionTime !== undefined ? message.completionTime.toISOString() : null); - return obj; - }, }; /** Msg defines the staking Msg service. */ diff --git a/packages/stargate/src/codec/cosmos/tx/signing/v1beta1/signing.ts b/packages/stargate/src/codec/cosmos/tx/signing/v1beta1/signing.ts index 48f3d120..e49a7573 100644 --- a/packages/stargate/src/codec/cosmos/tx/signing/v1beta1/signing.ts +++ b/packages/stargate/src/codec/cosmos/tx/signing/v1beta1/signing.ts @@ -156,6 +156,16 @@ export const SignatureDescriptors = { return message; }, + toJSON(message: SignatureDescriptors): unknown { + const obj: any = {}; + if (message.signatures) { + obj.signatures = message.signatures.map((e) => (e ? SignatureDescriptor.toJSON(e) : undefined)); + } else { + obj.signatures = []; + } + return obj; + }, + fromPartial(object: DeepPartial): SignatureDescriptors { const message = { ...baseSignatureDescriptors } as SignatureDescriptors; message.signatures = []; @@ -166,29 +176,21 @@ export const SignatureDescriptors = { } return message; }, - - toJSON(message: SignatureDescriptors): unknown { - const obj: any = {}; - if (message.signatures) { - obj.signatures = message.signatures.map((e) => (e ? SignatureDescriptor.toJSON(e) : undefined)); - } else { - obj.signatures = []; - } - return obj; - }, }; const baseSignatureDescriptor: object = { sequence: Long.UZERO }; export const SignatureDescriptor = { encode(message: SignatureDescriptor, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.publicKey !== undefined && message.publicKey !== undefined) { + if (message.publicKey !== undefined) { Any.encode(message.publicKey, writer.uint32(10).fork()).ldelim(); } - if (message.data !== undefined && message.data !== undefined) { + if (message.data !== undefined) { SignatureDescriptor_Data.encode(message.data, writer.uint32(18).fork()).ldelim(); } - writer.uint32(24).uint64(message.sequence); + if (!message.sequence.isZero()) { + writer.uint32(24).uint64(message.sequence); + } return writer; }, @@ -236,6 +238,16 @@ export const SignatureDescriptor = { return message; }, + toJSON(message: SignatureDescriptor): unknown { + const obj: any = {}; + message.publicKey !== undefined && + (obj.publicKey = message.publicKey ? Any.toJSON(message.publicKey) : undefined); + message.data !== undefined && + (obj.data = message.data ? SignatureDescriptor_Data.toJSON(message.data) : undefined); + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): SignatureDescriptor { const message = { ...baseSignatureDescriptor } as SignatureDescriptor; if (object.publicKey !== undefined && object.publicKey !== null) { @@ -255,16 +267,6 @@ export const SignatureDescriptor = { } return message; }, - - toJSON(message: SignatureDescriptor): unknown { - const obj: any = {}; - message.publicKey !== undefined && - (obj.publicKey = message.publicKey ? Any.toJSON(message.publicKey) : undefined); - message.data !== undefined && - (obj.data = message.data ? SignatureDescriptor_Data.toJSON(message.data) : undefined); - message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); - return obj; - }, }; const baseSignatureDescriptor_Data: object = {}; @@ -316,6 +318,15 @@ export const SignatureDescriptor_Data = { return message; }, + toJSON(message: SignatureDescriptor_Data): unknown { + const obj: any = {}; + message.single !== undefined && + (obj.single = message.single ? SignatureDescriptor_Data_Single.toJSON(message.single) : undefined); + message.multi !== undefined && + (obj.multi = message.multi ? SignatureDescriptor_Data_Multi.toJSON(message.multi) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): SignatureDescriptor_Data { const message = { ...baseSignatureDescriptor_Data } as SignatureDescriptor_Data; if (object.single !== undefined && object.single !== null) { @@ -330,23 +341,18 @@ export const SignatureDescriptor_Data = { } return message; }, - - toJSON(message: SignatureDescriptor_Data): unknown { - const obj: any = {}; - message.single !== undefined && - (obj.single = message.single ? SignatureDescriptor_Data_Single.toJSON(message.single) : undefined); - message.multi !== undefined && - (obj.multi = message.multi ? SignatureDescriptor_Data_Multi.toJSON(message.multi) : undefined); - return obj; - }, }; const baseSignatureDescriptor_Data_Single: object = { mode: 0 }; export const SignatureDescriptor_Data_Single = { encode(message: SignatureDescriptor_Data_Single, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.mode); - writer.uint32(18).bytes(message.signature); + if (message.mode !== 0) { + writer.uint32(8).int32(message.mode); + } + if (message.signature.length !== 0) { + writer.uint32(18).bytes(message.signature); + } return writer; }, @@ -384,6 +390,16 @@ export const SignatureDescriptor_Data_Single = { return message; }, + toJSON(message: SignatureDescriptor_Data_Single): unknown { + const obj: any = {}; + message.mode !== undefined && (obj.mode = signModeToJSON(message.mode)); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array(), + )); + return obj; + }, + fromPartial(object: DeepPartial): SignatureDescriptor_Data_Single { const message = { ...baseSignatureDescriptor_Data_Single } as SignatureDescriptor_Data_Single; if (object.mode !== undefined && object.mode !== null) { @@ -398,23 +414,13 @@ export const SignatureDescriptor_Data_Single = { } return message; }, - - toJSON(message: SignatureDescriptor_Data_Single): unknown { - const obj: any = {}; - message.mode !== undefined && (obj.mode = signModeToJSON(message.mode)); - message.signature !== undefined && - (obj.signature = base64FromBytes( - message.signature !== undefined ? message.signature : new Uint8Array(), - )); - return obj; - }, }; const baseSignatureDescriptor_Data_Multi: object = {}; export const SignatureDescriptor_Data_Multi = { encode(message: SignatureDescriptor_Data_Multi, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.bitarray !== undefined && message.bitarray !== undefined) { + if (message.bitarray !== undefined) { CompactBitArray.encode(message.bitarray, writer.uint32(10).fork()).ldelim(); } for (const v of message.signatures) { @@ -461,6 +467,18 @@ export const SignatureDescriptor_Data_Multi = { return message; }, + toJSON(message: SignatureDescriptor_Data_Multi): unknown { + const obj: any = {}; + message.bitarray !== undefined && + (obj.bitarray = message.bitarray ? CompactBitArray.toJSON(message.bitarray) : undefined); + if (message.signatures) { + obj.signatures = message.signatures.map((e) => (e ? SignatureDescriptor_Data.toJSON(e) : undefined)); + } else { + obj.signatures = []; + } + return obj; + }, + fromPartial(object: DeepPartial): SignatureDescriptor_Data_Multi { const message = { ...baseSignatureDescriptor_Data_Multi } as SignatureDescriptor_Data_Multi; message.signatures = []; @@ -476,18 +494,6 @@ export const SignatureDescriptor_Data_Multi = { } return message; }, - - toJSON(message: SignatureDescriptor_Data_Multi): unknown { - const obj: any = {}; - message.bitarray !== undefined && - (obj.bitarray = message.bitarray ? CompactBitArray.toJSON(message.bitarray) : undefined); - if (message.signatures) { - obj.signatures = message.signatures.map((e) => (e ? SignatureDescriptor_Data.toJSON(e) : undefined)); - } else { - obj.signatures = []; - } - return obj; - }, }; declare var self: any | undefined; @@ -497,7 +503,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/stargate/src/codec/cosmos/tx/v1beta1/tx.ts b/packages/stargate/src/codec/cosmos/tx/v1beta1/tx.ts index d9b9750d..5b23d016 100644 --- a/packages/stargate/src/codec/cosmos/tx/v1beta1/tx.ts +++ b/packages/stargate/src/codec/cosmos/tx/v1beta1/tx.ts @@ -211,10 +211,10 @@ const baseTx: object = {}; export const Tx = { encode(message: Tx, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.body !== undefined && message.body !== undefined) { + if (message.body !== undefined) { TxBody.encode(message.body, writer.uint32(10).fork()).ldelim(); } - if (message.authInfo !== undefined && message.authInfo !== undefined) { + if (message.authInfo !== undefined) { AuthInfo.encode(message.authInfo, writer.uint32(18).fork()).ldelim(); } for (const v of message.signatures) { @@ -269,6 +269,19 @@ export const Tx = { return message; }, + toJSON(message: Tx): unknown { + const obj: any = {}; + message.body !== undefined && (obj.body = message.body ? TxBody.toJSON(message.body) : undefined); + message.authInfo !== undefined && + (obj.authInfo = message.authInfo ? AuthInfo.toJSON(message.authInfo) : undefined); + if (message.signatures) { + obj.signatures = message.signatures.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.signatures = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Tx { const message = { ...baseTx } as Tx; message.signatures = []; @@ -289,27 +302,18 @@ export const Tx = { } return message; }, - - toJSON(message: Tx): unknown { - const obj: any = {}; - message.body !== undefined && (obj.body = message.body ? TxBody.toJSON(message.body) : undefined); - message.authInfo !== undefined && - (obj.authInfo = message.authInfo ? AuthInfo.toJSON(message.authInfo) : undefined); - if (message.signatures) { - obj.signatures = message.signatures.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); - } else { - obj.signatures = []; - } - return obj; - }, }; const baseTxRaw: object = {}; export const TxRaw = { encode(message: TxRaw, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.bodyBytes); - writer.uint32(18).bytes(message.authInfoBytes); + if (message.bodyBytes.length !== 0) { + writer.uint32(10).bytes(message.bodyBytes); + } + if (message.authInfoBytes.length !== 0) { + writer.uint32(18).bytes(message.authInfoBytes); + } for (const v of message.signatures) { writer.uint32(26).bytes(v!); } @@ -358,6 +362,24 @@ export const TxRaw = { return message; }, + toJSON(message: TxRaw): unknown { + const obj: any = {}; + message.bodyBytes !== undefined && + (obj.bodyBytes = base64FromBytes( + message.bodyBytes !== undefined ? message.bodyBytes : new Uint8Array(), + )); + message.authInfoBytes !== undefined && + (obj.authInfoBytes = base64FromBytes( + message.authInfoBytes !== undefined ? message.authInfoBytes : new Uint8Array(), + )); + if (message.signatures) { + obj.signatures = message.signatures.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.signatures = []; + } + return obj; + }, + fromPartial(object: DeepPartial): TxRaw { const message = { ...baseTxRaw } as TxRaw; message.signatures = []; @@ -378,34 +400,24 @@ export const TxRaw = { } return message; }, - - toJSON(message: TxRaw): unknown { - const obj: any = {}; - message.bodyBytes !== undefined && - (obj.bodyBytes = base64FromBytes( - message.bodyBytes !== undefined ? message.bodyBytes : new Uint8Array(), - )); - message.authInfoBytes !== undefined && - (obj.authInfoBytes = base64FromBytes( - message.authInfoBytes !== undefined ? message.authInfoBytes : new Uint8Array(), - )); - if (message.signatures) { - obj.signatures = message.signatures.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); - } else { - obj.signatures = []; - } - return obj; - }, }; const baseSignDoc: object = { chainId: "", accountNumber: Long.UZERO }; export const SignDoc = { encode(message: SignDoc, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.bodyBytes); - writer.uint32(18).bytes(message.authInfoBytes); - writer.uint32(26).string(message.chainId); - writer.uint32(32).uint64(message.accountNumber); + if (message.bodyBytes.length !== 0) { + writer.uint32(10).bytes(message.bodyBytes); + } + if (message.authInfoBytes.length !== 0) { + writer.uint32(18).bytes(message.authInfoBytes); + } + if (message.chainId !== "") { + writer.uint32(26).string(message.chainId); + } + if (!message.accountNumber.isZero()) { + writer.uint32(32).uint64(message.accountNumber); + } return writer; }, @@ -457,6 +469,22 @@ export const SignDoc = { return message; }, + toJSON(message: SignDoc): unknown { + const obj: any = {}; + message.bodyBytes !== undefined && + (obj.bodyBytes = base64FromBytes( + message.bodyBytes !== undefined ? message.bodyBytes : new Uint8Array(), + )); + message.authInfoBytes !== undefined && + (obj.authInfoBytes = base64FromBytes( + message.authInfoBytes !== undefined ? message.authInfoBytes : new Uint8Array(), + )); + message.chainId !== undefined && (obj.chainId = message.chainId); + message.accountNumber !== undefined && + (obj.accountNumber = (message.accountNumber || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): SignDoc { const message = { ...baseSignDoc } as SignDoc; if (object.bodyBytes !== undefined && object.bodyBytes !== null) { @@ -481,22 +509,6 @@ export const SignDoc = { } return message; }, - - toJSON(message: SignDoc): unknown { - const obj: any = {}; - message.bodyBytes !== undefined && - (obj.bodyBytes = base64FromBytes( - message.bodyBytes !== undefined ? message.bodyBytes : new Uint8Array(), - )); - message.authInfoBytes !== undefined && - (obj.authInfoBytes = base64FromBytes( - message.authInfoBytes !== undefined ? message.authInfoBytes : new Uint8Array(), - )); - message.chainId !== undefined && (obj.chainId = message.chainId); - message.accountNumber !== undefined && - (obj.accountNumber = (message.accountNumber || Long.UZERO).toString()); - return obj; - }, }; const baseTxBody: object = { memo: "", timeoutHeight: Long.UZERO }; @@ -506,8 +518,12 @@ export const TxBody = { for (const v of message.messages) { Any.encode(v!, writer.uint32(10).fork()).ldelim(); } - writer.uint32(18).string(message.memo); - writer.uint32(24).uint64(message.timeoutHeight); + if (message.memo !== "") { + writer.uint32(18).string(message.memo); + } + if (!message.timeoutHeight.isZero()) { + writer.uint32(24).uint64(message.timeoutHeight); + } for (const v of message.extensionOptions) { Any.encode(v!, writer.uint32(8186).fork()).ldelim(); } @@ -583,6 +599,31 @@ export const TxBody = { return message; }, + toJSON(message: TxBody): unknown { + const obj: any = {}; + if (message.messages) { + obj.messages = message.messages.map((e) => (e ? Any.toJSON(e) : undefined)); + } else { + obj.messages = []; + } + message.memo !== undefined && (obj.memo = message.memo); + message.timeoutHeight !== undefined && + (obj.timeoutHeight = (message.timeoutHeight || Long.UZERO).toString()); + if (message.extensionOptions) { + obj.extensionOptions = message.extensionOptions.map((e) => (e ? Any.toJSON(e) : undefined)); + } else { + obj.extensionOptions = []; + } + if (message.nonCriticalExtensionOptions) { + obj.nonCriticalExtensionOptions = message.nonCriticalExtensionOptions.map((e) => + e ? Any.toJSON(e) : undefined, + ); + } else { + obj.nonCriticalExtensionOptions = []; + } + return obj; + }, + fromPartial(object: DeepPartial): TxBody { const message = { ...baseTxBody } as TxBody; message.messages = []; @@ -615,31 +656,6 @@ export const TxBody = { } return message; }, - - toJSON(message: TxBody): unknown { - const obj: any = {}; - if (message.messages) { - obj.messages = message.messages.map((e) => (e ? Any.toJSON(e) : undefined)); - } else { - obj.messages = []; - } - message.memo !== undefined && (obj.memo = message.memo); - message.timeoutHeight !== undefined && - (obj.timeoutHeight = (message.timeoutHeight || Long.UZERO).toString()); - if (message.extensionOptions) { - obj.extensionOptions = message.extensionOptions.map((e) => (e ? Any.toJSON(e) : undefined)); - } else { - obj.extensionOptions = []; - } - if (message.nonCriticalExtensionOptions) { - obj.nonCriticalExtensionOptions = message.nonCriticalExtensionOptions.map((e) => - e ? Any.toJSON(e) : undefined, - ); - } else { - obj.nonCriticalExtensionOptions = []; - } - return obj; - }, }; const baseAuthInfo: object = {}; @@ -649,7 +665,7 @@ export const AuthInfo = { for (const v of message.signerInfos) { SignerInfo.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.fee !== undefined && message.fee !== undefined) { + if (message.fee !== undefined) { Fee.encode(message.fee, writer.uint32(18).fork()).ldelim(); } return writer; @@ -693,6 +709,17 @@ export const AuthInfo = { return message; }, + toJSON(message: AuthInfo): unknown { + const obj: any = {}; + if (message.signerInfos) { + obj.signerInfos = message.signerInfos.map((e) => (e ? SignerInfo.toJSON(e) : undefined)); + } else { + obj.signerInfos = []; + } + message.fee !== undefined && (obj.fee = message.fee ? Fee.toJSON(message.fee) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): AuthInfo { const message = { ...baseAuthInfo } as AuthInfo; message.signerInfos = []; @@ -708,30 +735,21 @@ export const AuthInfo = { } return message; }, - - toJSON(message: AuthInfo): unknown { - const obj: any = {}; - if (message.signerInfos) { - obj.signerInfos = message.signerInfos.map((e) => (e ? SignerInfo.toJSON(e) : undefined)); - } else { - obj.signerInfos = []; - } - message.fee !== undefined && (obj.fee = message.fee ? Fee.toJSON(message.fee) : undefined); - return obj; - }, }; const baseSignerInfo: object = { sequence: Long.UZERO }; export const SignerInfo = { encode(message: SignerInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.publicKey !== undefined && message.publicKey !== undefined) { + if (message.publicKey !== undefined) { Any.encode(message.publicKey, writer.uint32(10).fork()).ldelim(); } - if (message.modeInfo !== undefined && message.modeInfo !== undefined) { + if (message.modeInfo !== undefined) { ModeInfo.encode(message.modeInfo, writer.uint32(18).fork()).ldelim(); } - writer.uint32(24).uint64(message.sequence); + if (!message.sequence.isZero()) { + writer.uint32(24).uint64(message.sequence); + } return writer; }, @@ -779,6 +797,16 @@ export const SignerInfo = { return message; }, + toJSON(message: SignerInfo): unknown { + const obj: any = {}; + message.publicKey !== undefined && + (obj.publicKey = message.publicKey ? Any.toJSON(message.publicKey) : undefined); + message.modeInfo !== undefined && + (obj.modeInfo = message.modeInfo ? ModeInfo.toJSON(message.modeInfo) : undefined); + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): SignerInfo { const message = { ...baseSignerInfo } as SignerInfo; if (object.publicKey !== undefined && object.publicKey !== null) { @@ -798,16 +826,6 @@ export const SignerInfo = { } return message; }, - - toJSON(message: SignerInfo): unknown { - const obj: any = {}; - message.publicKey !== undefined && - (obj.publicKey = message.publicKey ? Any.toJSON(message.publicKey) : undefined); - message.modeInfo !== undefined && - (obj.modeInfo = message.modeInfo ? ModeInfo.toJSON(message.modeInfo) : undefined); - message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); - return obj; - }, }; const baseModeInfo: object = {}; @@ -859,6 +877,15 @@ export const ModeInfo = { return message; }, + toJSON(message: ModeInfo): unknown { + const obj: any = {}; + message.single !== undefined && + (obj.single = message.single ? ModeInfo_Single.toJSON(message.single) : undefined); + message.multi !== undefined && + (obj.multi = message.multi ? ModeInfo_Multi.toJSON(message.multi) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ModeInfo { const message = { ...baseModeInfo } as ModeInfo; if (object.single !== undefined && object.single !== null) { @@ -873,22 +900,15 @@ export const ModeInfo = { } return message; }, - - toJSON(message: ModeInfo): unknown { - const obj: any = {}; - message.single !== undefined && - (obj.single = message.single ? ModeInfo_Single.toJSON(message.single) : undefined); - message.multi !== undefined && - (obj.multi = message.multi ? ModeInfo_Multi.toJSON(message.multi) : undefined); - return obj; - }, }; const baseModeInfo_Single: object = { mode: 0 }; export const ModeInfo_Single = { encode(message: ModeInfo_Single, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.mode); + if (message.mode !== 0) { + writer.uint32(8).int32(message.mode); + } return writer; }, @@ -920,6 +940,12 @@ export const ModeInfo_Single = { return message; }, + toJSON(message: ModeInfo_Single): unknown { + const obj: any = {}; + message.mode !== undefined && (obj.mode = signModeToJSON(message.mode)); + return obj; + }, + fromPartial(object: DeepPartial): ModeInfo_Single { const message = { ...baseModeInfo_Single } as ModeInfo_Single; if (object.mode !== undefined && object.mode !== null) { @@ -929,19 +955,13 @@ export const ModeInfo_Single = { } return message; }, - - toJSON(message: ModeInfo_Single): unknown { - const obj: any = {}; - message.mode !== undefined && (obj.mode = signModeToJSON(message.mode)); - return obj; - }, }; const baseModeInfo_Multi: object = {}; export const ModeInfo_Multi = { encode(message: ModeInfo_Multi, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.bitarray !== undefined && message.bitarray !== undefined) { + if (message.bitarray !== undefined) { CompactBitArray.encode(message.bitarray, writer.uint32(10).fork()).ldelim(); } for (const v of message.modeInfos) { @@ -988,6 +1008,18 @@ export const ModeInfo_Multi = { return message; }, + toJSON(message: ModeInfo_Multi): unknown { + const obj: any = {}; + message.bitarray !== undefined && + (obj.bitarray = message.bitarray ? CompactBitArray.toJSON(message.bitarray) : undefined); + if (message.modeInfos) { + obj.modeInfos = message.modeInfos.map((e) => (e ? ModeInfo.toJSON(e) : undefined)); + } else { + obj.modeInfos = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ModeInfo_Multi { const message = { ...baseModeInfo_Multi } as ModeInfo_Multi; message.modeInfos = []; @@ -1003,18 +1035,6 @@ export const ModeInfo_Multi = { } return message; }, - - toJSON(message: ModeInfo_Multi): unknown { - const obj: any = {}; - message.bitarray !== undefined && - (obj.bitarray = message.bitarray ? CompactBitArray.toJSON(message.bitarray) : undefined); - if (message.modeInfos) { - obj.modeInfos = message.modeInfos.map((e) => (e ? ModeInfo.toJSON(e) : undefined)); - } else { - obj.modeInfos = []; - } - return obj; - }, }; const baseFee: object = { gasLimit: Long.UZERO, payer: "", granter: "" }; @@ -1024,9 +1044,15 @@ export const Fee = { for (const v of message.amount) { Coin.encode(v!, writer.uint32(10).fork()).ldelim(); } - writer.uint32(16).uint64(message.gasLimit); - writer.uint32(26).string(message.payer); - writer.uint32(34).string(message.granter); + if (!message.gasLimit.isZero()) { + writer.uint32(16).uint64(message.gasLimit); + } + if (message.payer !== "") { + writer.uint32(26).string(message.payer); + } + if (message.granter !== "") { + writer.uint32(34).string(message.granter); + } return writer; }, @@ -1084,6 +1110,19 @@ export const Fee = { return message; }, + toJSON(message: Fee): unknown { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.amount = []; + } + message.gasLimit !== undefined && (obj.gasLimit = (message.gasLimit || Long.UZERO).toString()); + message.payer !== undefined && (obj.payer = message.payer); + message.granter !== undefined && (obj.granter = message.granter); + return obj; + }, + fromPartial(object: DeepPartial): Fee { const message = { ...baseFee } as Fee; message.amount = []; @@ -1109,19 +1148,6 @@ export const Fee = { } return message; }, - - toJSON(message: Fee): unknown { - const obj: any = {}; - if (message.amount) { - obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); - } else { - obj.amount = []; - } - message.gasLimit !== undefined && (obj.gasLimit = (message.gasLimit || Long.UZERO).toString()); - message.payer !== undefined && (obj.payer = message.payer); - message.granter !== undefined && (obj.granter = message.granter); - return obj; - }, }; declare var self: any | undefined; @@ -1131,7 +1157,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/stargate/src/codec/google/protobuf/any.ts b/packages/stargate/src/codec/google/protobuf/any.ts index 7e728b6c..80a855cc 100644 --- a/packages/stargate/src/codec/google/protobuf/any.ts +++ b/packages/stargate/src/codec/google/protobuf/any.ts @@ -124,8 +124,12 @@ const baseAny: object = { typeUrl: "" }; export const Any = { encode(message: Any, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.typeUrl); - writer.uint32(18).bytes(message.value); + if (message.typeUrl !== "") { + writer.uint32(10).string(message.typeUrl); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } return writer; }, @@ -163,6 +167,14 @@ export const Any = { return message; }, + toJSON(message: Any): unknown { + const obj: any = {}; + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + message.value !== undefined && + (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): Any { const message = { ...baseAny } as Any; if (object.typeUrl !== undefined && object.typeUrl !== null) { @@ -177,14 +189,6 @@ export const Any = { } return message; }, - - toJSON(message: Any): unknown { - const obj: any = {}; - message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); - message.value !== undefined && - (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); - return obj; - }, }; declare var self: any | undefined; @@ -194,7 +198,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/stargate/src/codec/google/protobuf/duration.ts b/packages/stargate/src/codec/google/protobuf/duration.ts index ebf25f1b..b56dde8f 100644 --- a/packages/stargate/src/codec/google/protobuf/duration.ts +++ b/packages/stargate/src/codec/google/protobuf/duration.ts @@ -86,8 +86,12 @@ const baseDuration: object = { seconds: Long.ZERO, nanos: 0 }; export const Duration = { encode(message: Duration, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int64(message.seconds); - writer.uint32(16).int32(message.nanos); + if (!message.seconds.isZero()) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } return writer; }, @@ -127,6 +131,13 @@ export const Duration = { return message; }, + toJSON(message: Duration): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = (message.seconds || Long.ZERO).toString()); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + fromPartial(object: DeepPartial): Duration { const message = { ...baseDuration } as Duration; if (object.seconds !== undefined && object.seconds !== null) { @@ -141,13 +152,6 @@ export const Duration = { } return message; }, - - toJSON(message: Duration): unknown { - const obj: any = {}; - message.seconds !== undefined && (obj.seconds = (message.seconds || Long.ZERO).toString()); - message.nanos !== undefined && (obj.nanos = message.nanos); - return obj; - }, }; type Builtin = Date | Function | Uint8Array | string | number | undefined | Long; diff --git a/packages/stargate/src/codec/google/protobuf/timestamp.ts b/packages/stargate/src/codec/google/protobuf/timestamp.ts index 3eaaa1df..a6b054fe 100644 --- a/packages/stargate/src/codec/google/protobuf/timestamp.ts +++ b/packages/stargate/src/codec/google/protobuf/timestamp.ts @@ -117,8 +117,12 @@ const baseTimestamp: object = { seconds: Long.ZERO, nanos: 0 }; export const Timestamp = { encode(message: Timestamp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int64(message.seconds); - writer.uint32(16).int32(message.nanos); + if (!message.seconds.isZero()) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } return writer; }, @@ -158,6 +162,13 @@ export const Timestamp = { return message; }, + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = (message.seconds || Long.ZERO).toString()); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + fromPartial(object: DeepPartial): Timestamp { const message = { ...baseTimestamp } as Timestamp; if (object.seconds !== undefined && object.seconds !== null) { @@ -172,13 +183,6 @@ export const Timestamp = { } return message; }, - - toJSON(message: Timestamp): unknown { - const obj: any = {}; - message.seconds !== undefined && (obj.seconds = (message.seconds || Long.ZERO).toString()); - message.nanos !== undefined && (obj.nanos = message.nanos); - return obj; - }, }; type Builtin = Date | Function | Uint8Array | string | number | undefined | Long; diff --git a/packages/stargate/src/codec/ibc/core/channel/v1/channel.ts b/packages/stargate/src/codec/ibc/core/channel/v1/channel.ts index ec340b11..9d1f25a0 100644 --- a/packages/stargate/src/codec/ibc/core/channel/v1/channel.ts +++ b/packages/stargate/src/codec/ibc/core/channel/v1/channel.ts @@ -227,15 +227,21 @@ const baseChannel: object = { state: 0, ordering: 0, connectionHops: "", version export const Channel = { encode(message: Channel, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.state); - writer.uint32(16).int32(message.ordering); - if (message.counterparty !== undefined && message.counterparty !== undefined) { + if (message.state !== 0) { + writer.uint32(8).int32(message.state); + } + if (message.ordering !== 0) { + writer.uint32(16).int32(message.ordering); + } + if (message.counterparty !== undefined) { Counterparty.encode(message.counterparty, writer.uint32(26).fork()).ldelim(); } for (const v of message.connectionHops) { writer.uint32(34).string(v!); } - writer.uint32(42).string(message.version); + if (message.version !== "") { + writer.uint32(42).string(message.version); + } return writer; }, @@ -301,6 +307,21 @@ export const Channel = { return message; }, + toJSON(message: Channel): unknown { + const obj: any = {}; + message.state !== undefined && (obj.state = stateToJSON(message.state)); + message.ordering !== undefined && (obj.ordering = orderToJSON(message.ordering)); + message.counterparty !== undefined && + (obj.counterparty = message.counterparty ? Counterparty.toJSON(message.counterparty) : undefined); + if (message.connectionHops) { + obj.connectionHops = message.connectionHops.map((e) => e); + } else { + obj.connectionHops = []; + } + message.version !== undefined && (obj.version = message.version); + return obj; + }, + fromPartial(object: DeepPartial): Channel { const message = { ...baseChannel } as Channel; message.connectionHops = []; @@ -331,21 +352,6 @@ export const Channel = { } return message; }, - - toJSON(message: Channel): unknown { - const obj: any = {}; - message.state !== undefined && (obj.state = stateToJSON(message.state)); - message.ordering !== undefined && (obj.ordering = orderToJSON(message.ordering)); - message.counterparty !== undefined && - (obj.counterparty = message.counterparty ? Counterparty.toJSON(message.counterparty) : undefined); - if (message.connectionHops) { - obj.connectionHops = message.connectionHops.map((e) => e); - } else { - obj.connectionHops = []; - } - message.version !== undefined && (obj.version = message.version); - return obj; - }, }; const baseIdentifiedChannel: object = { @@ -359,17 +365,27 @@ const baseIdentifiedChannel: object = { export const IdentifiedChannel = { encode(message: IdentifiedChannel, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.state); - writer.uint32(16).int32(message.ordering); - if (message.counterparty !== undefined && message.counterparty !== undefined) { + if (message.state !== 0) { + writer.uint32(8).int32(message.state); + } + if (message.ordering !== 0) { + writer.uint32(16).int32(message.ordering); + } + if (message.counterparty !== undefined) { Counterparty.encode(message.counterparty, writer.uint32(26).fork()).ldelim(); } for (const v of message.connectionHops) { writer.uint32(34).string(v!); } - writer.uint32(42).string(message.version); - writer.uint32(50).string(message.portId); - writer.uint32(58).string(message.channelId); + if (message.version !== "") { + writer.uint32(42).string(message.version); + } + if (message.portId !== "") { + writer.uint32(50).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(58).string(message.channelId); + } return writer; }, @@ -451,6 +467,23 @@ export const IdentifiedChannel = { return message; }, + toJSON(message: IdentifiedChannel): unknown { + const obj: any = {}; + message.state !== undefined && (obj.state = stateToJSON(message.state)); + message.ordering !== undefined && (obj.ordering = orderToJSON(message.ordering)); + message.counterparty !== undefined && + (obj.counterparty = message.counterparty ? Counterparty.toJSON(message.counterparty) : undefined); + if (message.connectionHops) { + obj.connectionHops = message.connectionHops.map((e) => e); + } else { + obj.connectionHops = []; + } + message.version !== undefined && (obj.version = message.version); + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + fromPartial(object: DeepPartial): IdentifiedChannel { const message = { ...baseIdentifiedChannel } as IdentifiedChannel; message.connectionHops = []; @@ -491,31 +524,18 @@ export const IdentifiedChannel = { } return message; }, - - toJSON(message: IdentifiedChannel): unknown { - const obj: any = {}; - message.state !== undefined && (obj.state = stateToJSON(message.state)); - message.ordering !== undefined && (obj.ordering = orderToJSON(message.ordering)); - message.counterparty !== undefined && - (obj.counterparty = message.counterparty ? Counterparty.toJSON(message.counterparty) : undefined); - if (message.connectionHops) { - obj.connectionHops = message.connectionHops.map((e) => e); - } else { - obj.connectionHops = []; - } - message.version !== undefined && (obj.version = message.version); - message.portId !== undefined && (obj.portId = message.portId); - message.channelId !== undefined && (obj.channelId = message.channelId); - return obj; - }, }; const baseCounterparty: object = { portId: "", channelId: "" }; export const Counterparty = { encode(message: Counterparty, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.portId); - writer.uint32(18).string(message.channelId); + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } return writer; }, @@ -555,6 +575,13 @@ export const Counterparty = { return message; }, + toJSON(message: Counterparty): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + fromPartial(object: DeepPartial): Counterparty { const message = { ...baseCounterparty } as Counterparty; if (object.portId !== undefined && object.portId !== null) { @@ -569,13 +596,6 @@ export const Counterparty = { } return message; }, - - toJSON(message: Counterparty): unknown { - const obj: any = {}; - message.portId !== undefined && (obj.portId = message.portId); - message.channelId !== undefined && (obj.channelId = message.channelId); - return obj; - }, }; const basePacket: object = { @@ -589,16 +609,30 @@ const basePacket: object = { export const Packet = { encode(message: Packet, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.sequence); - writer.uint32(18).string(message.sourcePort); - writer.uint32(26).string(message.sourceChannel); - writer.uint32(34).string(message.destinationPort); - writer.uint32(42).string(message.destinationChannel); - writer.uint32(50).bytes(message.data); - if (message.timeoutHeight !== undefined && message.timeoutHeight !== undefined) { + if (!message.sequence.isZero()) { + writer.uint32(8).uint64(message.sequence); + } + if (message.sourcePort !== "") { + writer.uint32(18).string(message.sourcePort); + } + if (message.sourceChannel !== "") { + writer.uint32(26).string(message.sourceChannel); + } + if (message.destinationPort !== "") { + writer.uint32(34).string(message.destinationPort); + } + if (message.destinationChannel !== "") { + writer.uint32(42).string(message.destinationChannel); + } + if (message.data.length !== 0) { + writer.uint32(50).bytes(message.data); + } + if (message.timeoutHeight !== undefined) { Height.encode(message.timeoutHeight, writer.uint32(58).fork()).ldelim(); } - writer.uint32(64).uint64(message.timeoutTimestamp); + if (!message.timeoutTimestamp.isZero()) { + writer.uint32(64).uint64(message.timeoutTimestamp); + } return writer; }, @@ -684,6 +718,22 @@ export const Packet = { return message; }, + toJSON(message: Packet): unknown { + const obj: any = {}; + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + message.sourcePort !== undefined && (obj.sourcePort = message.sourcePort); + message.sourceChannel !== undefined && (obj.sourceChannel = message.sourceChannel); + message.destinationPort !== undefined && (obj.destinationPort = message.destinationPort); + message.destinationChannel !== undefined && (obj.destinationChannel = message.destinationChannel); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + message.timeoutHeight !== undefined && + (obj.timeoutHeight = message.timeoutHeight ? Height.toJSON(message.timeoutHeight) : undefined); + message.timeoutTimestamp !== undefined && + (obj.timeoutTimestamp = (message.timeoutTimestamp || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): Packet { const message = { ...basePacket } as Packet; if (object.sequence !== undefined && object.sequence !== null) { @@ -728,32 +778,24 @@ export const Packet = { } return message; }, - - toJSON(message: Packet): unknown { - const obj: any = {}; - message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); - message.sourcePort !== undefined && (obj.sourcePort = message.sourcePort); - message.sourceChannel !== undefined && (obj.sourceChannel = message.sourceChannel); - message.destinationPort !== undefined && (obj.destinationPort = message.destinationPort); - message.destinationChannel !== undefined && (obj.destinationChannel = message.destinationChannel); - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); - message.timeoutHeight !== undefined && - (obj.timeoutHeight = message.timeoutHeight ? Height.toJSON(message.timeoutHeight) : undefined); - message.timeoutTimestamp !== undefined && - (obj.timeoutTimestamp = (message.timeoutTimestamp || Long.UZERO).toString()); - return obj; - }, }; const basePacketState: object = { portId: "", channelId: "", sequence: Long.UZERO }; export const PacketState = { encode(message: PacketState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.portId); - writer.uint32(18).string(message.channelId); - writer.uint32(24).uint64(message.sequence); - writer.uint32(34).bytes(message.data); + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (!message.sequence.isZero()) { + writer.uint32(24).uint64(message.sequence); + } + if (message.data.length !== 0) { + writer.uint32(34).bytes(message.data); + } return writer; }, @@ -807,6 +849,16 @@ export const PacketState = { return message; }, + toJSON(message: PacketState): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): PacketState { const message = { ...basePacketState } as PacketState; if (object.portId !== undefined && object.portId !== null) { @@ -831,16 +883,6 @@ export const PacketState = { } return message; }, - - toJSON(message: PacketState): unknown { - const obj: any = {}; - message.portId !== undefined && (obj.portId = message.portId); - message.channelId !== undefined && (obj.channelId = message.channelId); - message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); - return obj; - }, }; const baseAcknowledgement: object = {}; @@ -890,6 +932,14 @@ export const Acknowledgement = { return message; }, + toJSON(message: Acknowledgement): unknown { + const obj: any = {}; + message.result !== undefined && + (obj.result = message.result !== undefined ? base64FromBytes(message.result) : undefined); + message.error !== undefined && (obj.error = message.error); + return obj; + }, + fromPartial(object: DeepPartial): Acknowledgement { const message = { ...baseAcknowledgement } as Acknowledgement; if (object.result !== undefined && object.result !== null) { @@ -904,14 +954,6 @@ export const Acknowledgement = { } return message; }, - - toJSON(message: Acknowledgement): unknown { - const obj: any = {}; - message.result !== undefined && - (obj.result = message.result !== undefined ? base64FromBytes(message.result) : undefined); - message.error !== undefined && (obj.error = message.error); - return obj; - }, }; declare var self: any | undefined; @@ -921,7 +963,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/stargate/src/codec/ibc/core/channel/v1/query.ts b/packages/stargate/src/codec/ibc/core/channel/v1/query.ts index 7a6c053e..512cb5cc 100644 --- a/packages/stargate/src/codec/ibc/core/channel/v1/query.ts +++ b/packages/stargate/src/codec/ibc/core/channel/v1/query.ts @@ -331,8 +331,12 @@ const baseQueryChannelRequest: object = { portId: "", channelId: "" }; export const QueryChannelRequest = { encode(message: QueryChannelRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.portId); - writer.uint32(18).string(message.channelId); + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } return writer; }, @@ -372,6 +376,13 @@ export const QueryChannelRequest = { return message; }, + toJSON(message: QueryChannelRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + fromPartial(object: DeepPartial): QueryChannelRequest { const message = { ...baseQueryChannelRequest } as QueryChannelRequest; if (object.portId !== undefined && object.portId !== null) { @@ -386,24 +397,19 @@ export const QueryChannelRequest = { } return message; }, - - toJSON(message: QueryChannelRequest): unknown { - const obj: any = {}; - message.portId !== undefined && (obj.portId = message.portId); - message.channelId !== undefined && (obj.channelId = message.channelId); - return obj; - }, }; const baseQueryChannelResponse: object = {}; export const QueryChannelResponse = { encode(message: QueryChannelResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.channel !== undefined && message.channel !== undefined) { + if (message.channel !== undefined) { Channel.encode(message.channel, writer.uint32(10).fork()).ldelim(); } - writer.uint32(18).bytes(message.proof); - if (message.proofHeight !== undefined && message.proofHeight !== undefined) { + 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; @@ -451,6 +457,17 @@ export const QueryChannelResponse = { return message; }, + toJSON(message: QueryChannelResponse): unknown { + const obj: any = {}; + message.channel !== undefined && + (obj.channel = message.channel ? Channel.toJSON(message.channel) : 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): QueryChannelResponse { const message = { ...baseQueryChannelResponse } as QueryChannelResponse; if (object.channel !== undefined && object.channel !== null) { @@ -470,24 +487,13 @@ export const QueryChannelResponse = { } return message; }, - - toJSON(message: QueryChannelResponse): unknown { - const obj: any = {}; - message.channel !== undefined && - (obj.channel = message.channel ? Channel.toJSON(message.channel) : 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; - }, }; const baseQueryChannelsRequest: object = {}; export const QueryChannelsRequest = { encode(message: QueryChannelsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); } return writer; @@ -521,6 +527,13 @@ export const QueryChannelsRequest = { return message; }, + toJSON(message: QueryChannelsRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryChannelsRequest { const message = { ...baseQueryChannelsRequest } as QueryChannelsRequest; if (object.pagination !== undefined && object.pagination !== null) { @@ -530,13 +543,6 @@ export const QueryChannelsRequest = { } return message; }, - - toJSON(message: QueryChannelsRequest): unknown { - const obj: any = {}; - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryChannelsResponse: object = {}; @@ -546,10 +552,10 @@ export const QueryChannelsResponse = { for (const v of message.channels) { IdentifiedChannel.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } - if (message.height !== undefined && message.height !== undefined) { + if (message.height !== undefined) { Height.encode(message.height, writer.uint32(26).fork()).ldelim(); } return writer; @@ -601,6 +607,19 @@ export const QueryChannelsResponse = { return message; }, + toJSON(message: QueryChannelsResponse): unknown { + const obj: any = {}; + if (message.channels) { + obj.channels = message.channels.map((e) => (e ? IdentifiedChannel.toJSON(e) : undefined)); + } else { + obj.channels = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryChannelsResponse { const message = { ...baseQueryChannelsResponse } as QueryChannelsResponse; message.channels = []; @@ -621,27 +640,16 @@ export const QueryChannelsResponse = { } return message; }, - - toJSON(message: QueryChannelsResponse): unknown { - const obj: any = {}; - if (message.channels) { - obj.channels = message.channels.map((e) => (e ? IdentifiedChannel.toJSON(e) : undefined)); - } else { - obj.channels = []; - } - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); - message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); - return obj; - }, }; const baseQueryConnectionChannelsRequest: object = { connection: "" }; export const QueryConnectionChannelsRequest = { encode(message: QueryConnectionChannelsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.connection); - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.connection !== "") { + writer.uint32(10).string(message.connection); + } + if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; @@ -683,6 +691,14 @@ export const QueryConnectionChannelsRequest = { return message; }, + toJSON(message: QueryConnectionChannelsRequest): unknown { + const obj: any = {}; + message.connection !== undefined && (obj.connection = message.connection); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryConnectionChannelsRequest { const message = { ...baseQueryConnectionChannelsRequest } as QueryConnectionChannelsRequest; if (object.connection !== undefined && object.connection !== null) { @@ -697,14 +713,6 @@ export const QueryConnectionChannelsRequest = { } return message; }, - - toJSON(message: QueryConnectionChannelsRequest): unknown { - const obj: any = {}; - message.connection !== undefined && (obj.connection = message.connection); - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryConnectionChannelsResponse: object = {}; @@ -714,10 +722,10 @@ export const QueryConnectionChannelsResponse = { for (const v of message.channels) { IdentifiedChannel.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } - if (message.height !== undefined && message.height !== undefined) { + if (message.height !== undefined) { Height.encode(message.height, writer.uint32(26).fork()).ldelim(); } return writer; @@ -769,6 +777,19 @@ export const QueryConnectionChannelsResponse = { return message; }, + toJSON(message: QueryConnectionChannelsResponse): unknown { + const obj: any = {}; + if (message.channels) { + obj.channels = message.channels.map((e) => (e ? IdentifiedChannel.toJSON(e) : undefined)); + } else { + obj.channels = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryConnectionChannelsResponse { const message = { ...baseQueryConnectionChannelsResponse } as QueryConnectionChannelsResponse; message.channels = []; @@ -789,27 +810,18 @@ export const QueryConnectionChannelsResponse = { } return message; }, - - toJSON(message: QueryConnectionChannelsResponse): unknown { - const obj: any = {}; - if (message.channels) { - obj.channels = message.channels.map((e) => (e ? IdentifiedChannel.toJSON(e) : undefined)); - } else { - obj.channels = []; - } - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); - message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); - return obj; - }, }; const baseQueryChannelClientStateRequest: object = { portId: "", channelId: "" }; export const QueryChannelClientStateRequest = { encode(message: QueryChannelClientStateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.portId); - writer.uint32(18).string(message.channelId); + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } return writer; }, @@ -849,6 +861,13 @@ export const QueryChannelClientStateRequest = { return message; }, + toJSON(message: QueryChannelClientStateRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + fromPartial(object: DeepPartial): QueryChannelClientStateRequest { const message = { ...baseQueryChannelClientStateRequest } as QueryChannelClientStateRequest; if (object.portId !== undefined && object.portId !== null) { @@ -863,24 +882,19 @@ export const QueryChannelClientStateRequest = { } return message; }, - - toJSON(message: QueryChannelClientStateRequest): unknown { - const obj: any = {}; - message.portId !== undefined && (obj.portId = message.portId); - message.channelId !== undefined && (obj.channelId = message.channelId); - return obj; - }, }; const baseQueryChannelClientStateResponse: object = {}; export const QueryChannelClientStateResponse = { encode(message: QueryChannelClientStateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.identifiedClientState !== undefined && message.identifiedClientState !== undefined) { + if (message.identifiedClientState !== undefined) { IdentifiedClientState.encode(message.identifiedClientState, writer.uint32(10).fork()).ldelim(); } - writer.uint32(18).bytes(message.proof); - if (message.proofHeight !== undefined && message.proofHeight !== undefined) { + 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; @@ -928,6 +942,19 @@ export const QueryChannelClientStateResponse = { return message; }, + toJSON(message: QueryChannelClientStateResponse): unknown { + const obj: any = {}; + message.identifiedClientState !== undefined && + (obj.identifiedClientState = message.identifiedClientState + ? IdentifiedClientState.toJSON(message.identifiedClientState) + : 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): QueryChannelClientStateResponse { const message = { ...baseQueryChannelClientStateResponse } as QueryChannelClientStateResponse; if (object.identifiedClientState !== undefined && object.identifiedClientState !== null) { @@ -947,19 +974,6 @@ export const QueryChannelClientStateResponse = { } return message; }, - - toJSON(message: QueryChannelClientStateResponse): unknown { - const obj: any = {}; - message.identifiedClientState !== undefined && - (obj.identifiedClientState = message.identifiedClientState - ? IdentifiedClientState.toJSON(message.identifiedClientState) - : 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; - }, }; const baseQueryChannelConsensusStateRequest: object = { @@ -971,10 +985,18 @@ const baseQueryChannelConsensusStateRequest: object = { export const QueryChannelConsensusStateRequest = { encode(message: QueryChannelConsensusStateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.portId); - writer.uint32(18).string(message.channelId); - writer.uint32(24).uint64(message.revisionNumber); - writer.uint32(32).uint64(message.revisionHeight); + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (!message.revisionNumber.isZero()) { + writer.uint32(24).uint64(message.revisionNumber); + } + if (!message.revisionHeight.isZero()) { + writer.uint32(32).uint64(message.revisionHeight); + } return writer; }, @@ -1030,6 +1052,17 @@ export const QueryChannelConsensusStateRequest = { return message; }, + toJSON(message: QueryChannelConsensusStateRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.revisionNumber !== undefined && + (obj.revisionNumber = (message.revisionNumber || Long.UZERO).toString()); + message.revisionHeight !== undefined && + (obj.revisionHeight = (message.revisionHeight || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryChannelConsensusStateRequest { const message = { ...baseQueryChannelConsensusStateRequest } as QueryChannelConsensusStateRequest; if (object.portId !== undefined && object.portId !== null) { @@ -1054,29 +1087,22 @@ export const QueryChannelConsensusStateRequest = { } return message; }, - - toJSON(message: QueryChannelConsensusStateRequest): unknown { - const obj: any = {}; - message.portId !== undefined && (obj.portId = message.portId); - message.channelId !== undefined && (obj.channelId = message.channelId); - message.revisionNumber !== undefined && - (obj.revisionNumber = (message.revisionNumber || Long.UZERO).toString()); - message.revisionHeight !== undefined && - (obj.revisionHeight = (message.revisionHeight || Long.UZERO).toString()); - return obj; - }, }; const baseQueryChannelConsensusStateResponse: object = { clientId: "" }; export const QueryChannelConsensusStateResponse = { encode(message: QueryChannelConsensusStateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.consensusState !== undefined && message.consensusState !== undefined) { + if (message.consensusState !== undefined) { Any.encode(message.consensusState, writer.uint32(10).fork()).ldelim(); } - writer.uint32(18).string(message.clientId); - writer.uint32(26).bytes(message.proof); - if (message.proofHeight !== undefined && message.proofHeight !== undefined) { + if (message.clientId !== "") { + writer.uint32(18).string(message.clientId); + } + if (message.proof.length !== 0) { + writer.uint32(26).bytes(message.proof); + } + if (message.proofHeight !== undefined) { Height.encode(message.proofHeight, writer.uint32(34).fork()).ldelim(); } return writer; @@ -1132,6 +1158,18 @@ export const QueryChannelConsensusStateResponse = { return message; }, + toJSON(message: QueryChannelConsensusStateResponse): unknown { + const obj: any = {}; + message.consensusState !== undefined && + (obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined); + message.clientId !== undefined && (obj.clientId = message.clientId); + 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): QueryChannelConsensusStateResponse { const message = { ...baseQueryChannelConsensusStateResponse } as QueryChannelConsensusStateResponse; if (object.consensusState !== undefined && object.consensusState !== null) { @@ -1156,27 +1194,21 @@ export const QueryChannelConsensusStateResponse = { } return message; }, - - toJSON(message: QueryChannelConsensusStateResponse): unknown { - const obj: any = {}; - message.consensusState !== undefined && - (obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined); - message.clientId !== undefined && (obj.clientId = message.clientId); - 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; - }, }; const baseQueryPacketCommitmentRequest: object = { portId: "", channelId: "", sequence: Long.UZERO }; export const QueryPacketCommitmentRequest = { encode(message: QueryPacketCommitmentRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.portId); - writer.uint32(18).string(message.channelId); - writer.uint32(24).uint64(message.sequence); + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (!message.sequence.isZero()) { + writer.uint32(24).uint64(message.sequence); + } return writer; }, @@ -1224,6 +1256,14 @@ export const QueryPacketCommitmentRequest = { return message; }, + toJSON(message: QueryPacketCommitmentRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryPacketCommitmentRequest { const message = { ...baseQueryPacketCommitmentRequest } as QueryPacketCommitmentRequest; if (object.portId !== undefined && object.portId !== null) { @@ -1243,23 +1283,19 @@ export const QueryPacketCommitmentRequest = { } return message; }, - - toJSON(message: QueryPacketCommitmentRequest): unknown { - const obj: any = {}; - message.portId !== undefined && (obj.portId = message.portId); - message.channelId !== undefined && (obj.channelId = message.channelId); - message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); - return obj; - }, }; const baseQueryPacketCommitmentResponse: object = {}; export const QueryPacketCommitmentResponse = { encode(message: QueryPacketCommitmentResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.commitment); - writer.uint32(18).bytes(message.proof); - if (message.proofHeight !== undefined && message.proofHeight !== undefined) { + if (message.commitment.length !== 0) { + writer.uint32(10).bytes(message.commitment); + } + 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; @@ -1305,6 +1341,19 @@ export const QueryPacketCommitmentResponse = { return message; }, + toJSON(message: QueryPacketCommitmentResponse): unknown { + const obj: any = {}; + message.commitment !== undefined && + (obj.commitment = base64FromBytes( + message.commitment !== undefined ? message.commitment : new Uint8Array(), + )); + 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): QueryPacketCommitmentResponse { const message = { ...baseQueryPacketCommitmentResponse } as QueryPacketCommitmentResponse; if (object.commitment !== undefined && object.commitment !== null) { @@ -1324,28 +1373,19 @@ export const QueryPacketCommitmentResponse = { } return message; }, - - toJSON(message: QueryPacketCommitmentResponse): unknown { - const obj: any = {}; - message.commitment !== undefined && - (obj.commitment = base64FromBytes( - message.commitment !== undefined ? message.commitment : new Uint8Array(), - )); - 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; - }, }; const baseQueryPacketCommitmentsRequest: object = { portId: "", channelId: "" }; export const QueryPacketCommitmentsRequest = { encode(message: QueryPacketCommitmentsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.portId); - writer.uint32(18).string(message.channelId); - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(26).fork()).ldelim(); } return writer; @@ -1395,6 +1435,15 @@ export const QueryPacketCommitmentsRequest = { return message; }, + toJSON(message: QueryPacketCommitmentsRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryPacketCommitmentsRequest { const message = { ...baseQueryPacketCommitmentsRequest } as QueryPacketCommitmentsRequest; if (object.portId !== undefined && object.portId !== null) { @@ -1414,15 +1463,6 @@ export const QueryPacketCommitmentsRequest = { } return message; }, - - toJSON(message: QueryPacketCommitmentsRequest): unknown { - const obj: any = {}; - message.portId !== undefined && (obj.portId = message.portId); - message.channelId !== undefined && (obj.channelId = message.channelId); - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryPacketCommitmentsResponse: object = {}; @@ -1432,10 +1472,10 @@ export const QueryPacketCommitmentsResponse = { for (const v of message.commitments) { PacketState.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } - if (message.height !== undefined && message.height !== undefined) { + if (message.height !== undefined) { Height.encode(message.height, writer.uint32(26).fork()).ldelim(); } return writer; @@ -1487,6 +1527,19 @@ export const QueryPacketCommitmentsResponse = { return message; }, + toJSON(message: QueryPacketCommitmentsResponse): unknown { + const obj: any = {}; + if (message.commitments) { + obj.commitments = message.commitments.map((e) => (e ? PacketState.toJSON(e) : undefined)); + } else { + obj.commitments = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryPacketCommitmentsResponse { const message = { ...baseQueryPacketCommitmentsResponse } as QueryPacketCommitmentsResponse; message.commitments = []; @@ -1507,28 +1560,21 @@ export const QueryPacketCommitmentsResponse = { } return message; }, - - toJSON(message: QueryPacketCommitmentsResponse): unknown { - const obj: any = {}; - if (message.commitments) { - obj.commitments = message.commitments.map((e) => (e ? PacketState.toJSON(e) : undefined)); - } else { - obj.commitments = []; - } - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); - message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); - return obj; - }, }; const baseQueryPacketReceiptRequest: object = { portId: "", channelId: "", sequence: Long.UZERO }; export const QueryPacketReceiptRequest = { encode(message: QueryPacketReceiptRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.portId); - writer.uint32(18).string(message.channelId); - writer.uint32(24).uint64(message.sequence); + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (!message.sequence.isZero()) { + writer.uint32(24).uint64(message.sequence); + } return writer; }, @@ -1576,6 +1622,14 @@ export const QueryPacketReceiptRequest = { return message; }, + toJSON(message: QueryPacketReceiptRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryPacketReceiptRequest { const message = { ...baseQueryPacketReceiptRequest } as QueryPacketReceiptRequest; if (object.portId !== undefined && object.portId !== null) { @@ -1595,23 +1649,19 @@ export const QueryPacketReceiptRequest = { } return message; }, - - toJSON(message: QueryPacketReceiptRequest): unknown { - const obj: any = {}; - message.portId !== undefined && (obj.portId = message.portId); - message.channelId !== undefined && (obj.channelId = message.channelId); - message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); - return obj; - }, }; const baseQueryPacketReceiptResponse: object = { received: false }; export const QueryPacketReceiptResponse = { encode(message: QueryPacketReceiptResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(16).bool(message.received); - writer.uint32(26).bytes(message.proof); - if (message.proofHeight !== undefined && message.proofHeight !== undefined) { + if (message.received === true) { + writer.uint32(16).bool(message.received); + } + if (message.proof.length !== 0) { + writer.uint32(26).bytes(message.proof); + } + if (message.proofHeight !== undefined) { Height.encode(message.proofHeight, writer.uint32(34).fork()).ldelim(); } return writer; @@ -1659,6 +1709,16 @@ export const QueryPacketReceiptResponse = { return message; }, + toJSON(message: QueryPacketReceiptResponse): unknown { + const obj: any = {}; + message.received !== undefined && (obj.received = message.received); + 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): QueryPacketReceiptResponse { const message = { ...baseQueryPacketReceiptResponse } as QueryPacketReceiptResponse; if (object.received !== undefined && object.received !== null) { @@ -1678,25 +1738,21 @@ export const QueryPacketReceiptResponse = { } return message; }, - - toJSON(message: QueryPacketReceiptResponse): unknown { - const obj: any = {}; - message.received !== undefined && (obj.received = message.received); - 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; - }, }; const baseQueryPacketAcknowledgementRequest: object = { portId: "", channelId: "", sequence: Long.UZERO }; export const QueryPacketAcknowledgementRequest = { encode(message: QueryPacketAcknowledgementRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.portId); - writer.uint32(18).string(message.channelId); - writer.uint32(24).uint64(message.sequence); + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (!message.sequence.isZero()) { + writer.uint32(24).uint64(message.sequence); + } return writer; }, @@ -1744,6 +1800,14 @@ export const QueryPacketAcknowledgementRequest = { return message; }, + toJSON(message: QueryPacketAcknowledgementRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryPacketAcknowledgementRequest { const message = { ...baseQueryPacketAcknowledgementRequest } as QueryPacketAcknowledgementRequest; if (object.portId !== undefined && object.portId !== null) { @@ -1763,23 +1827,19 @@ export const QueryPacketAcknowledgementRequest = { } return message; }, - - toJSON(message: QueryPacketAcknowledgementRequest): unknown { - const obj: any = {}; - message.portId !== undefined && (obj.portId = message.portId); - message.channelId !== undefined && (obj.channelId = message.channelId); - message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); - return obj; - }, }; const baseQueryPacketAcknowledgementResponse: object = {}; export const QueryPacketAcknowledgementResponse = { encode(message: QueryPacketAcknowledgementResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.acknowledgement); - writer.uint32(18).bytes(message.proof); - if (message.proofHeight !== undefined && message.proofHeight !== undefined) { + if (message.acknowledgement.length !== 0) { + writer.uint32(10).bytes(message.acknowledgement); + } + 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; @@ -1825,6 +1885,19 @@ export const QueryPacketAcknowledgementResponse = { return message; }, + toJSON(message: QueryPacketAcknowledgementResponse): unknown { + const obj: any = {}; + message.acknowledgement !== undefined && + (obj.acknowledgement = base64FromBytes( + message.acknowledgement !== undefined ? message.acknowledgement : new Uint8Array(), + )); + 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): QueryPacketAcknowledgementResponse { const message = { ...baseQueryPacketAcknowledgementResponse } as QueryPacketAcknowledgementResponse; if (object.acknowledgement !== undefined && object.acknowledgement !== null) { @@ -1844,28 +1917,19 @@ export const QueryPacketAcknowledgementResponse = { } return message; }, - - toJSON(message: QueryPacketAcknowledgementResponse): unknown { - const obj: any = {}; - message.acknowledgement !== undefined && - (obj.acknowledgement = base64FromBytes( - message.acknowledgement !== undefined ? message.acknowledgement : new Uint8Array(), - )); - 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; - }, }; const baseQueryPacketAcknowledgementsRequest: object = { portId: "", channelId: "" }; export const QueryPacketAcknowledgementsRequest = { encode(message: QueryPacketAcknowledgementsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.portId); - writer.uint32(18).string(message.channelId); - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(26).fork()).ldelim(); } return writer; @@ -1915,6 +1979,15 @@ export const QueryPacketAcknowledgementsRequest = { return message; }, + toJSON(message: QueryPacketAcknowledgementsRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryPacketAcknowledgementsRequest { const message = { ...baseQueryPacketAcknowledgementsRequest } as QueryPacketAcknowledgementsRequest; if (object.portId !== undefined && object.portId !== null) { @@ -1934,15 +2007,6 @@ export const QueryPacketAcknowledgementsRequest = { } return message; }, - - toJSON(message: QueryPacketAcknowledgementsRequest): unknown { - const obj: any = {}; - message.portId !== undefined && (obj.portId = message.portId); - message.channelId !== undefined && (obj.channelId = message.channelId); - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryPacketAcknowledgementsResponse: object = {}; @@ -1952,10 +2016,10 @@ export const QueryPacketAcknowledgementsResponse = { for (const v of message.acknowledgements) { PacketState.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } - if (message.height !== undefined && message.height !== undefined) { + if (message.height !== undefined) { Height.encode(message.height, writer.uint32(26).fork()).ldelim(); } return writer; @@ -2007,6 +2071,19 @@ export const QueryPacketAcknowledgementsResponse = { return message; }, + toJSON(message: QueryPacketAcknowledgementsResponse): unknown { + const obj: any = {}; + if (message.acknowledgements) { + obj.acknowledgements = message.acknowledgements.map((e) => (e ? PacketState.toJSON(e) : undefined)); + } else { + obj.acknowledgements = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryPacketAcknowledgementsResponse { const message = { ...baseQueryPacketAcknowledgementsResponse } as QueryPacketAcknowledgementsResponse; message.acknowledgements = []; @@ -2027,19 +2104,6 @@ export const QueryPacketAcknowledgementsResponse = { } return message; }, - - toJSON(message: QueryPacketAcknowledgementsResponse): unknown { - const obj: any = {}; - if (message.acknowledgements) { - obj.acknowledgements = message.acknowledgements.map((e) => (e ? PacketState.toJSON(e) : undefined)); - } else { - obj.acknowledgements = []; - } - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); - message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); - return obj; - }, }; const baseQueryUnreceivedPacketsRequest: object = { @@ -2050,8 +2114,12 @@ const baseQueryUnreceivedPacketsRequest: object = { export const QueryUnreceivedPacketsRequest = { encode(message: QueryUnreceivedPacketsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.portId); - writer.uint32(18).string(message.channelId); + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } writer.uint32(26).fork(); for (const v of message.packetCommitmentSequences) { writer.uint64(v); @@ -2113,6 +2181,20 @@ export const QueryUnreceivedPacketsRequest = { return message; }, + toJSON(message: QueryUnreceivedPacketsRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + if (message.packetCommitmentSequences) { + obj.packetCommitmentSequences = message.packetCommitmentSequences.map((e) => + (e || Long.UZERO).toString(), + ); + } else { + obj.packetCommitmentSequences = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QueryUnreceivedPacketsRequest { const message = { ...baseQueryUnreceivedPacketsRequest } as QueryUnreceivedPacketsRequest; message.packetCommitmentSequences = []; @@ -2133,20 +2215,6 @@ export const QueryUnreceivedPacketsRequest = { } return message; }, - - toJSON(message: QueryUnreceivedPacketsRequest): unknown { - const obj: any = {}; - message.portId !== undefined && (obj.portId = message.portId); - message.channelId !== undefined && (obj.channelId = message.channelId); - if (message.packetCommitmentSequences) { - obj.packetCommitmentSequences = message.packetCommitmentSequences.map((e) => - (e || Long.UZERO).toString(), - ); - } else { - obj.packetCommitmentSequences = []; - } - return obj; - }, }; const baseQueryUnreceivedPacketsResponse: object = { sequences: Long.UZERO }; @@ -2158,7 +2226,7 @@ export const QueryUnreceivedPacketsResponse = { writer.uint64(v); } writer.ldelim(); - if (message.height !== undefined && message.height !== undefined) { + if (message.height !== undefined) { Height.encode(message.height, writer.uint32(18).fork()).ldelim(); } return writer; @@ -2209,6 +2277,17 @@ export const QueryUnreceivedPacketsResponse = { return message; }, + toJSON(message: QueryUnreceivedPacketsResponse): unknown { + const obj: any = {}; + if (message.sequences) { + obj.sequences = message.sequences.map((e) => (e || Long.UZERO).toString()); + } else { + obj.sequences = []; + } + message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryUnreceivedPacketsResponse { const message = { ...baseQueryUnreceivedPacketsResponse } as QueryUnreceivedPacketsResponse; message.sequences = []; @@ -2224,25 +2303,18 @@ export const QueryUnreceivedPacketsResponse = { } return message; }, - - toJSON(message: QueryUnreceivedPacketsResponse): unknown { - const obj: any = {}; - if (message.sequences) { - obj.sequences = message.sequences.map((e) => (e || Long.UZERO).toString()); - } else { - obj.sequences = []; - } - message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); - return obj; - }, }; const baseQueryUnreceivedAcksRequest: object = { portId: "", channelId: "", packetAckSequences: Long.UZERO }; export const QueryUnreceivedAcksRequest = { encode(message: QueryUnreceivedAcksRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.portId); - writer.uint32(18).string(message.channelId); + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } writer.uint32(26).fork(); for (const v of message.packetAckSequences) { writer.uint64(v); @@ -2304,6 +2376,18 @@ export const QueryUnreceivedAcksRequest = { return message; }, + toJSON(message: QueryUnreceivedAcksRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + if (message.packetAckSequences) { + obj.packetAckSequences = message.packetAckSequences.map((e) => (e || Long.UZERO).toString()); + } else { + obj.packetAckSequences = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QueryUnreceivedAcksRequest { const message = { ...baseQueryUnreceivedAcksRequest } as QueryUnreceivedAcksRequest; message.packetAckSequences = []; @@ -2324,18 +2408,6 @@ export const QueryUnreceivedAcksRequest = { } return message; }, - - toJSON(message: QueryUnreceivedAcksRequest): unknown { - const obj: any = {}; - message.portId !== undefined && (obj.portId = message.portId); - message.channelId !== undefined && (obj.channelId = message.channelId); - if (message.packetAckSequences) { - obj.packetAckSequences = message.packetAckSequences.map((e) => (e || Long.UZERO).toString()); - } else { - obj.packetAckSequences = []; - } - return obj; - }, }; const baseQueryUnreceivedAcksResponse: object = { sequences: Long.UZERO }; @@ -2347,7 +2419,7 @@ export const QueryUnreceivedAcksResponse = { writer.uint64(v); } writer.ldelim(); - if (message.height !== undefined && message.height !== undefined) { + if (message.height !== undefined) { Height.encode(message.height, writer.uint32(18).fork()).ldelim(); } return writer; @@ -2398,6 +2470,17 @@ export const QueryUnreceivedAcksResponse = { return message; }, + toJSON(message: QueryUnreceivedAcksResponse): unknown { + const obj: any = {}; + if (message.sequences) { + obj.sequences = message.sequences.map((e) => (e || Long.UZERO).toString()); + } else { + obj.sequences = []; + } + message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryUnreceivedAcksResponse { const message = { ...baseQueryUnreceivedAcksResponse } as QueryUnreceivedAcksResponse; message.sequences = []; @@ -2413,25 +2496,18 @@ export const QueryUnreceivedAcksResponse = { } return message; }, - - toJSON(message: QueryUnreceivedAcksResponse): unknown { - const obj: any = {}; - if (message.sequences) { - obj.sequences = message.sequences.map((e) => (e || Long.UZERO).toString()); - } else { - obj.sequences = []; - } - message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); - return obj; - }, }; const baseQueryNextSequenceReceiveRequest: object = { portId: "", channelId: "" }; export const QueryNextSequenceReceiveRequest = { encode(message: QueryNextSequenceReceiveRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.portId); - writer.uint32(18).string(message.channelId); + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } return writer; }, @@ -2471,6 +2547,13 @@ export const QueryNextSequenceReceiveRequest = { return message; }, + toJSON(message: QueryNextSequenceReceiveRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + fromPartial(object: DeepPartial): QueryNextSequenceReceiveRequest { const message = { ...baseQueryNextSequenceReceiveRequest } as QueryNextSequenceReceiveRequest; if (object.portId !== undefined && object.portId !== null) { @@ -2485,22 +2568,19 @@ export const QueryNextSequenceReceiveRequest = { } return message; }, - - toJSON(message: QueryNextSequenceReceiveRequest): unknown { - const obj: any = {}; - message.portId !== undefined && (obj.portId = message.portId); - message.channelId !== undefined && (obj.channelId = message.channelId); - return obj; - }, }; const baseQueryNextSequenceReceiveResponse: object = { nextSequenceReceive: Long.UZERO }; export const QueryNextSequenceReceiveResponse = { encode(message: QueryNextSequenceReceiveResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.nextSequenceReceive); - writer.uint32(18).bytes(message.proof); - if (message.proofHeight !== undefined && message.proofHeight !== undefined) { + if (!message.nextSequenceReceive.isZero()) { + writer.uint32(8).uint64(message.nextSequenceReceive); + } + 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; @@ -2548,6 +2628,17 @@ export const QueryNextSequenceReceiveResponse = { return message; }, + toJSON(message: QueryNextSequenceReceiveResponse): unknown { + const obj: any = {}; + message.nextSequenceReceive !== undefined && + (obj.nextSequenceReceive = (message.nextSequenceReceive || Long.UZERO).toString()); + 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): QueryNextSequenceReceiveResponse { const message = { ...baseQueryNextSequenceReceiveResponse } as QueryNextSequenceReceiveResponse; if (object.nextSequenceReceive !== undefined && object.nextSequenceReceive !== null) { @@ -2567,17 +2658,6 @@ export const QueryNextSequenceReceiveResponse = { } return message; }, - - toJSON(message: QueryNextSequenceReceiveResponse): unknown { - const obj: any = {}; - message.nextSequenceReceive !== undefined && - (obj.nextSequenceReceive = (message.nextSequenceReceive || Long.UZERO).toString()); - 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; - }, }; /** Query provides defines the gRPC querier service */ @@ -2738,7 +2818,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/stargate/src/codec/ibc/core/client/v1/client.ts b/packages/stargate/src/codec/ibc/core/client/v1/client.ts index 22a33594..b3abb226 100644 --- a/packages/stargate/src/codec/ibc/core/client/v1/client.ts +++ b/packages/stargate/src/codec/ibc/core/client/v1/client.ts @@ -79,8 +79,10 @@ const baseIdentifiedClientState: object = { clientId: "" }; export const IdentifiedClientState = { encode(message: IdentifiedClientState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.clientId); - if (message.clientState !== undefined && message.clientState !== undefined) { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.clientState !== undefined) { Any.encode(message.clientState, writer.uint32(18).fork()).ldelim(); } return writer; @@ -122,6 +124,14 @@ export const IdentifiedClientState = { return message; }, + toJSON(message: IdentifiedClientState): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.clientState !== undefined && + (obj.clientState = message.clientState ? Any.toJSON(message.clientState) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): IdentifiedClientState { const message = { ...baseIdentifiedClientState } as IdentifiedClientState; if (object.clientId !== undefined && object.clientId !== null) { @@ -136,24 +146,16 @@ export const IdentifiedClientState = { } return message; }, - - toJSON(message: IdentifiedClientState): unknown { - const obj: any = {}; - message.clientId !== undefined && (obj.clientId = message.clientId); - message.clientState !== undefined && - (obj.clientState = message.clientState ? Any.toJSON(message.clientState) : undefined); - return obj; - }, }; const baseConsensusStateWithHeight: object = {}; export const ConsensusStateWithHeight = { encode(message: ConsensusStateWithHeight, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.height !== undefined && message.height !== undefined) { + if (message.height !== undefined) { Height.encode(message.height, writer.uint32(10).fork()).ldelim(); } - if (message.consensusState !== undefined && message.consensusState !== undefined) { + if (message.consensusState !== undefined) { Any.encode(message.consensusState, writer.uint32(18).fork()).ldelim(); } return writer; @@ -195,6 +197,14 @@ export const ConsensusStateWithHeight = { return message; }, + toJSON(message: ConsensusStateWithHeight): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); + message.consensusState !== undefined && + (obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ConsensusStateWithHeight { const message = { ...baseConsensusStateWithHeight } as ConsensusStateWithHeight; if (object.height !== undefined && object.height !== null) { @@ -209,21 +219,15 @@ export const ConsensusStateWithHeight = { } return message; }, - - toJSON(message: ConsensusStateWithHeight): unknown { - const obj: any = {}; - message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); - message.consensusState !== undefined && - (obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined); - return obj; - }, }; const baseClientConsensusStates: object = { clientId: "" }; export const ClientConsensusStates = { encode(message: ClientConsensusStates, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.clientId); + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } for (const v of message.consensusStates) { ConsensusStateWithHeight.encode(v!, writer.uint32(18).fork()).ldelim(); } @@ -268,6 +272,19 @@ export const ClientConsensusStates = { return message; }, + toJSON(message: ClientConsensusStates): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + if (message.consensusStates) { + obj.consensusStates = message.consensusStates.map((e) => + e ? ConsensusStateWithHeight.toJSON(e) : undefined, + ); + } else { + obj.consensusStates = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ClientConsensusStates { const message = { ...baseClientConsensusStates } as ClientConsensusStates; message.consensusStates = []; @@ -283,29 +300,22 @@ export const ClientConsensusStates = { } return message; }, - - toJSON(message: ClientConsensusStates): unknown { - const obj: any = {}; - message.clientId !== undefined && (obj.clientId = message.clientId); - if (message.consensusStates) { - obj.consensusStates = message.consensusStates.map((e) => - e ? ConsensusStateWithHeight.toJSON(e) : undefined, - ); - } else { - obj.consensusStates = []; - } - return obj; - }, }; const baseClientUpdateProposal: object = { title: "", description: "", clientId: "" }; export const ClientUpdateProposal = { encode(message: ClientUpdateProposal, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.title); - writer.uint32(18).string(message.description); - writer.uint32(26).string(message.clientId); - if (message.header !== undefined && message.header !== undefined) { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.clientId !== "") { + writer.uint32(26).string(message.clientId); + } + if (message.header !== undefined) { Any.encode(message.header, writer.uint32(34).fork()).ldelim(); } return writer; @@ -363,6 +373,15 @@ export const ClientUpdateProposal = { return message; }, + toJSON(message: ClientUpdateProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.clientId !== undefined && (obj.clientId = message.clientId); + message.header !== undefined && (obj.header = message.header ? Any.toJSON(message.header) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ClientUpdateProposal { const message = { ...baseClientUpdateProposal } as ClientUpdateProposal; if (object.title !== undefined && object.title !== null) { @@ -387,23 +406,18 @@ export const ClientUpdateProposal = { } return message; }, - - toJSON(message: ClientUpdateProposal): unknown { - const obj: any = {}; - message.title !== undefined && (obj.title = message.title); - message.description !== undefined && (obj.description = message.description); - message.clientId !== undefined && (obj.clientId = message.clientId); - message.header !== undefined && (obj.header = message.header ? Any.toJSON(message.header) : undefined); - return obj; - }, }; const baseHeight: object = { revisionNumber: Long.UZERO, revisionHeight: Long.UZERO }; export const Height = { encode(message: Height, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.revisionNumber); - writer.uint32(16).uint64(message.revisionHeight); + if (!message.revisionNumber.isZero()) { + writer.uint32(8).uint64(message.revisionNumber); + } + if (!message.revisionHeight.isZero()) { + writer.uint32(16).uint64(message.revisionHeight); + } return writer; }, @@ -443,6 +457,15 @@ export const Height = { return message; }, + toJSON(message: Height): unknown { + const obj: any = {}; + message.revisionNumber !== undefined && + (obj.revisionNumber = (message.revisionNumber || Long.UZERO).toString()); + message.revisionHeight !== undefined && + (obj.revisionHeight = (message.revisionHeight || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): Height { const message = { ...baseHeight } as Height; if (object.revisionNumber !== undefined && object.revisionNumber !== null) { @@ -457,15 +480,6 @@ export const Height = { } return message; }, - - toJSON(message: Height): unknown { - const obj: any = {}; - message.revisionNumber !== undefined && - (obj.revisionNumber = (message.revisionNumber || Long.UZERO).toString()); - message.revisionHeight !== undefined && - (obj.revisionHeight = (message.revisionHeight || Long.UZERO).toString()); - return obj; - }, }; const baseParams: object = { allowedClients: "" }; @@ -508,6 +522,16 @@ export const Params = { return message; }, + toJSON(message: Params): unknown { + const obj: any = {}; + if (message.allowedClients) { + obj.allowedClients = message.allowedClients.map((e) => e); + } else { + obj.allowedClients = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Params { const message = { ...baseParams } as Params; message.allowedClients = []; @@ -518,16 +542,6 @@ export const Params = { } return message; }, - - toJSON(message: Params): unknown { - const obj: any = {}; - if (message.allowedClients) { - obj.allowedClients = message.allowedClients.map((e) => e); - } else { - obj.allowedClients = []; - } - return obj; - }, }; type Builtin = Date | Function | Uint8Array | string | number | undefined | Long; diff --git a/packages/stargate/src/codec/ibc/core/commitment/v1/commitment.ts b/packages/stargate/src/codec/ibc/core/commitment/v1/commitment.ts index 98d1a396..72a18bfa 100644 --- a/packages/stargate/src/codec/ibc/core/commitment/v1/commitment.ts +++ b/packages/stargate/src/codec/ibc/core/commitment/v1/commitment.ts @@ -46,7 +46,9 @@ const baseMerkleRoot: object = {}; export const MerkleRoot = { encode(message: MerkleRoot, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.hash); + if (message.hash.length !== 0) { + writer.uint32(10).bytes(message.hash); + } return writer; }, @@ -76,6 +78,13 @@ export const MerkleRoot = { return message; }, + toJSON(message: MerkleRoot): unknown { + const obj: any = {}; + message.hash !== undefined && + (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): MerkleRoot { const message = { ...baseMerkleRoot } as MerkleRoot; if (object.hash !== undefined && object.hash !== null) { @@ -85,20 +94,15 @@ export const MerkleRoot = { } return message; }, - - toJSON(message: MerkleRoot): unknown { - const obj: any = {}; - message.hash !== undefined && - (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); - return obj; - }, }; const baseMerklePrefix: object = {}; export const MerklePrefix = { encode(message: MerklePrefix, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.keyPrefix); + if (message.keyPrefix.length !== 0) { + writer.uint32(10).bytes(message.keyPrefix); + } return writer; }, @@ -128,6 +132,15 @@ export const MerklePrefix = { return message; }, + toJSON(message: MerklePrefix): unknown { + const obj: any = {}; + message.keyPrefix !== undefined && + (obj.keyPrefix = base64FromBytes( + message.keyPrefix !== undefined ? message.keyPrefix : new Uint8Array(), + )); + return obj; + }, + fromPartial(object: DeepPartial): MerklePrefix { const message = { ...baseMerklePrefix } as MerklePrefix; if (object.keyPrefix !== undefined && object.keyPrefix !== null) { @@ -137,15 +150,6 @@ export const MerklePrefix = { } return message; }, - - toJSON(message: MerklePrefix): unknown { - const obj: any = {}; - message.keyPrefix !== undefined && - (obj.keyPrefix = base64FromBytes( - message.keyPrefix !== undefined ? message.keyPrefix : new Uint8Array(), - )); - return obj; - }, }; const baseMerklePath: object = { keyPath: "" }; @@ -188,6 +192,16 @@ export const MerklePath = { return message; }, + toJSON(message: MerklePath): unknown { + const obj: any = {}; + if (message.keyPath) { + obj.keyPath = message.keyPath.map((e) => e); + } else { + obj.keyPath = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MerklePath { const message = { ...baseMerklePath } as MerklePath; message.keyPath = []; @@ -198,16 +212,6 @@ export const MerklePath = { } return message; }, - - toJSON(message: MerklePath): unknown { - const obj: any = {}; - if (message.keyPath) { - obj.keyPath = message.keyPath.map((e) => e); - } else { - obj.keyPath = []; - } - return obj; - }, }; const baseMerkleProof: object = {}; @@ -250,6 +254,16 @@ export const MerkleProof = { return message; }, + toJSON(message: MerkleProof): unknown { + const obj: any = {}; + if (message.proofs) { + obj.proofs = message.proofs.map((e) => (e ? CommitmentProof.toJSON(e) : undefined)); + } else { + obj.proofs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MerkleProof { const message = { ...baseMerkleProof } as MerkleProof; message.proofs = []; @@ -260,16 +274,6 @@ export const MerkleProof = { } return message; }, - - toJSON(message: MerkleProof): unknown { - const obj: any = {}; - if (message.proofs) { - obj.proofs = message.proofs.map((e) => (e ? CommitmentProof.toJSON(e) : undefined)); - } else { - obj.proofs = []; - } - return obj; - }, }; declare var self: any | undefined; @@ -279,7 +283,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/stargate/src/codec/ibc/core/connection/v1/connection.ts b/packages/stargate/src/codec/ibc/core/connection/v1/connection.ts index 43d61d9c..b060bbb8 100644 --- a/packages/stargate/src/codec/ibc/core/connection/v1/connection.ts +++ b/packages/stargate/src/codec/ibc/core/connection/v1/connection.ts @@ -152,15 +152,21 @@ const baseConnectionEnd: object = { clientId: "", state: 0, delayPeriod: Long.UZ export const ConnectionEnd = { encode(message: ConnectionEnd, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.clientId); + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } for (const v of message.versions) { Version.encode(v!, writer.uint32(18).fork()).ldelim(); } - writer.uint32(24).int32(message.state); - if (message.counterparty !== undefined && message.counterparty !== undefined) { + if (message.state !== 0) { + writer.uint32(24).int32(message.state); + } + if (message.counterparty !== undefined) { Counterparty.encode(message.counterparty, writer.uint32(34).fork()).ldelim(); } - writer.uint32(40).uint64(message.delayPeriod); + if (!message.delayPeriod.isZero()) { + writer.uint32(40).uint64(message.delayPeriod); + } return writer; }, @@ -226,6 +232,21 @@ export const ConnectionEnd = { return message; }, + toJSON(message: ConnectionEnd): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + if (message.versions) { + obj.versions = message.versions.map((e) => (e ? Version.toJSON(e) : undefined)); + } else { + obj.versions = []; + } + message.state !== undefined && (obj.state = stateToJSON(message.state)); + message.counterparty !== undefined && + (obj.counterparty = message.counterparty ? Counterparty.toJSON(message.counterparty) : undefined); + message.delayPeriod !== undefined && (obj.delayPeriod = (message.delayPeriod || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): ConnectionEnd { const message = { ...baseConnectionEnd } as ConnectionEnd; message.versions = []; @@ -256,37 +277,30 @@ export const ConnectionEnd = { } return message; }, - - toJSON(message: ConnectionEnd): unknown { - const obj: any = {}; - message.clientId !== undefined && (obj.clientId = message.clientId); - if (message.versions) { - obj.versions = message.versions.map((e) => (e ? Version.toJSON(e) : undefined)); - } else { - obj.versions = []; - } - message.state !== undefined && (obj.state = stateToJSON(message.state)); - message.counterparty !== undefined && - (obj.counterparty = message.counterparty ? Counterparty.toJSON(message.counterparty) : undefined); - message.delayPeriod !== undefined && (obj.delayPeriod = (message.delayPeriod || Long.UZERO).toString()); - return obj; - }, }; const baseIdentifiedConnection: object = { id: "", clientId: "", state: 0, delayPeriod: Long.UZERO }; export const IdentifiedConnection = { encode(message: IdentifiedConnection, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.id); - writer.uint32(18).string(message.clientId); + if (message.id !== "") { + writer.uint32(10).string(message.id); + } + if (message.clientId !== "") { + writer.uint32(18).string(message.clientId); + } for (const v of message.versions) { Version.encode(v!, writer.uint32(26).fork()).ldelim(); } - writer.uint32(32).int32(message.state); - if (message.counterparty !== undefined && message.counterparty !== undefined) { + if (message.state !== 0) { + writer.uint32(32).int32(message.state); + } + if (message.counterparty !== undefined) { Counterparty.encode(message.counterparty, writer.uint32(42).fork()).ldelim(); } - writer.uint32(48).uint64(message.delayPeriod); + if (!message.delayPeriod.isZero()) { + writer.uint32(48).uint64(message.delayPeriod); + } return writer; }, @@ -360,6 +374,22 @@ export const IdentifiedConnection = { return message; }, + toJSON(message: IdentifiedConnection): unknown { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + message.clientId !== undefined && (obj.clientId = message.clientId); + if (message.versions) { + obj.versions = message.versions.map((e) => (e ? Version.toJSON(e) : undefined)); + } else { + obj.versions = []; + } + message.state !== undefined && (obj.state = stateToJSON(message.state)); + message.counterparty !== undefined && + (obj.counterparty = message.counterparty ? Counterparty.toJSON(message.counterparty) : undefined); + message.delayPeriod !== undefined && (obj.delayPeriod = (message.delayPeriod || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): IdentifiedConnection { const message = { ...baseIdentifiedConnection } as IdentifiedConnection; message.versions = []; @@ -395,31 +425,19 @@ export const IdentifiedConnection = { } return message; }, - - toJSON(message: IdentifiedConnection): unknown { - const obj: any = {}; - message.id !== undefined && (obj.id = message.id); - message.clientId !== undefined && (obj.clientId = message.clientId); - if (message.versions) { - obj.versions = message.versions.map((e) => (e ? Version.toJSON(e) : undefined)); - } else { - obj.versions = []; - } - message.state !== undefined && (obj.state = stateToJSON(message.state)); - message.counterparty !== undefined && - (obj.counterparty = message.counterparty ? Counterparty.toJSON(message.counterparty) : undefined); - message.delayPeriod !== undefined && (obj.delayPeriod = (message.delayPeriod || Long.UZERO).toString()); - return obj; - }, }; const baseCounterparty: object = { clientId: "", connectionId: "" }; export const Counterparty = { encode(message: Counterparty, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.clientId); - writer.uint32(18).string(message.connectionId); - if (message.prefix !== undefined && message.prefix !== undefined) { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.connectionId !== "") { + writer.uint32(18).string(message.connectionId); + } + if (message.prefix !== undefined) { MerklePrefix.encode(message.prefix, writer.uint32(26).fork()).ldelim(); } return writer; @@ -469,6 +487,15 @@ export const Counterparty = { return message; }, + toJSON(message: Counterparty): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.connectionId !== undefined && (obj.connectionId = message.connectionId); + message.prefix !== undefined && + (obj.prefix = message.prefix ? MerklePrefix.toJSON(message.prefix) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Counterparty { const message = { ...baseCounterparty } as Counterparty; if (object.clientId !== undefined && object.clientId !== null) { @@ -488,15 +515,6 @@ export const Counterparty = { } return message; }, - - toJSON(message: Counterparty): unknown { - const obj: any = {}; - message.clientId !== undefined && (obj.clientId = message.clientId); - message.connectionId !== undefined && (obj.connectionId = message.connectionId); - message.prefix !== undefined && - (obj.prefix = message.prefix ? MerklePrefix.toJSON(message.prefix) : undefined); - return obj; - }, }; const baseClientPaths: object = { paths: "" }; @@ -539,6 +557,16 @@ export const ClientPaths = { return message; }, + toJSON(message: ClientPaths): unknown { + const obj: any = {}; + if (message.paths) { + obj.paths = message.paths.map((e) => e); + } else { + obj.paths = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ClientPaths { const message = { ...baseClientPaths } as ClientPaths; message.paths = []; @@ -549,23 +577,15 @@ export const ClientPaths = { } return message; }, - - toJSON(message: ClientPaths): unknown { - const obj: any = {}; - if (message.paths) { - obj.paths = message.paths.map((e) => e); - } else { - obj.paths = []; - } - return obj; - }, }; const baseConnectionPaths: object = { clientId: "", paths: "" }; export const ConnectionPaths = { encode(message: ConnectionPaths, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.clientId); + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } for (const v of message.paths) { writer.uint32(18).string(v!); } @@ -610,6 +630,17 @@ export const ConnectionPaths = { return message; }, + toJSON(message: ConnectionPaths): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + if (message.paths) { + obj.paths = message.paths.map((e) => e); + } else { + obj.paths = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ConnectionPaths { const message = { ...baseConnectionPaths } as ConnectionPaths; message.paths = []; @@ -625,24 +656,15 @@ export const ConnectionPaths = { } return message; }, - - toJSON(message: ConnectionPaths): unknown { - const obj: any = {}; - message.clientId !== undefined && (obj.clientId = message.clientId); - if (message.paths) { - obj.paths = message.paths.map((e) => e); - } else { - obj.paths = []; - } - return obj; - }, }; const baseVersion: object = { identifier: "", features: "" }; export const Version = { encode(message: Version, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.identifier); + if (message.identifier !== "") { + writer.uint32(10).string(message.identifier); + } for (const v of message.features) { writer.uint32(18).string(v!); } @@ -687,6 +709,17 @@ export const Version = { return message; }, + toJSON(message: Version): unknown { + const obj: any = {}; + message.identifier !== undefined && (obj.identifier = message.identifier); + if (message.features) { + obj.features = message.features.map((e) => e); + } else { + obj.features = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Version { const message = { ...baseVersion } as Version; message.features = []; @@ -702,17 +735,6 @@ export const Version = { } return message; }, - - toJSON(message: Version): unknown { - const obj: any = {}; - message.identifier !== undefined && (obj.identifier = message.identifier); - if (message.features) { - obj.features = message.features.map((e) => e); - } else { - obj.features = []; - } - return obj; - }, }; type Builtin = Date | Function | Uint8Array | string | number | undefined | Long; diff --git a/packages/stargate/src/codec/ibc/core/connection/v1/query.ts b/packages/stargate/src/codec/ibc/core/connection/v1/query.ts index d9321c5f..3a1fdb36 100644 --- a/packages/stargate/src/codec/ibc/core/connection/v1/query.ts +++ b/packages/stargate/src/codec/ibc/core/connection/v1/query.ts @@ -126,7 +126,9 @@ const baseQueryConnectionRequest: object = { connectionId: "" }; export const QueryConnectionRequest = { encode(message: QueryConnectionRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.connectionId); + if (message.connectionId !== "") { + writer.uint32(10).string(message.connectionId); + } return writer; }, @@ -158,6 +160,12 @@ export const QueryConnectionRequest = { return message; }, + toJSON(message: QueryConnectionRequest): unknown { + const obj: any = {}; + message.connectionId !== undefined && (obj.connectionId = message.connectionId); + return obj; + }, + fromPartial(object: DeepPartial): QueryConnectionRequest { const message = { ...baseQueryConnectionRequest } as QueryConnectionRequest; if (object.connectionId !== undefined && object.connectionId !== null) { @@ -167,23 +175,19 @@ export const QueryConnectionRequest = { } return message; }, - - toJSON(message: QueryConnectionRequest): unknown { - const obj: any = {}; - message.connectionId !== undefined && (obj.connectionId = message.connectionId); - return obj; - }, }; const baseQueryConnectionResponse: object = {}; export const QueryConnectionResponse = { encode(message: QueryConnectionResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.connection !== undefined && message.connection !== undefined) { + if (message.connection !== undefined) { ConnectionEnd.encode(message.connection, writer.uint32(10).fork()).ldelim(); } - writer.uint32(18).bytes(message.proof); - if (message.proofHeight !== undefined && message.proofHeight !== undefined) { + 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; @@ -231,6 +235,17 @@ export const QueryConnectionResponse = { return message; }, + toJSON(message: QueryConnectionResponse): unknown { + const obj: any = {}; + message.connection !== undefined && + (obj.connection = message.connection ? ConnectionEnd.toJSON(message.connection) : 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): QueryConnectionResponse { const message = { ...baseQueryConnectionResponse } as QueryConnectionResponse; if (object.connection !== undefined && object.connection !== null) { @@ -250,24 +265,13 @@ export const QueryConnectionResponse = { } return message; }, - - toJSON(message: QueryConnectionResponse): unknown { - const obj: any = {}; - message.connection !== undefined && - (obj.connection = message.connection ? ConnectionEnd.toJSON(message.connection) : 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; - }, }; const baseQueryConnectionsRequest: object = {}; export const QueryConnectionsRequest = { encode(message: QueryConnectionsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); } return writer; @@ -301,6 +305,13 @@ export const QueryConnectionsRequest = { return message; }, + toJSON(message: QueryConnectionsRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryConnectionsRequest { const message = { ...baseQueryConnectionsRequest } as QueryConnectionsRequest; if (object.pagination !== undefined && object.pagination !== null) { @@ -310,13 +321,6 @@ export const QueryConnectionsRequest = { } return message; }, - - toJSON(message: QueryConnectionsRequest): unknown { - const obj: any = {}; - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); - return obj; - }, }; const baseQueryConnectionsResponse: object = {}; @@ -326,10 +330,10 @@ export const QueryConnectionsResponse = { for (const v of message.connections) { IdentifiedConnection.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.pagination !== undefined && message.pagination !== undefined) { + if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } - if (message.height !== undefined && message.height !== undefined) { + if (message.height !== undefined) { Height.encode(message.height, writer.uint32(26).fork()).ldelim(); } return writer; @@ -381,6 +385,19 @@ export const QueryConnectionsResponse = { return message; }, + toJSON(message: QueryConnectionsResponse): unknown { + const obj: any = {}; + if (message.connections) { + obj.connections = message.connections.map((e) => (e ? IdentifiedConnection.toJSON(e) : undefined)); + } else { + obj.connections = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryConnectionsResponse { const message = { ...baseQueryConnectionsResponse } as QueryConnectionsResponse; message.connections = []; @@ -401,26 +418,15 @@ export const QueryConnectionsResponse = { } return message; }, - - toJSON(message: QueryConnectionsResponse): unknown { - const obj: any = {}; - if (message.connections) { - obj.connections = message.connections.map((e) => (e ? IdentifiedConnection.toJSON(e) : undefined)); - } else { - obj.connections = []; - } - message.pagination !== undefined && - (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); - message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); - return obj; - }, }; const baseQueryClientConnectionsRequest: object = { clientId: "" }; export const QueryClientConnectionsRequest = { encode(message: QueryClientConnectionsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.clientId); + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } return writer; }, @@ -452,6 +458,12 @@ export const QueryClientConnectionsRequest = { return message; }, + toJSON(message: QueryClientConnectionsRequest): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + return obj; + }, + fromPartial(object: DeepPartial): QueryClientConnectionsRequest { const message = { ...baseQueryClientConnectionsRequest } as QueryClientConnectionsRequest; if (object.clientId !== undefined && object.clientId !== null) { @@ -461,12 +473,6 @@ export const QueryClientConnectionsRequest = { } return message; }, - - toJSON(message: QueryClientConnectionsRequest): unknown { - const obj: any = {}; - message.clientId !== undefined && (obj.clientId = message.clientId); - return obj; - }, }; const baseQueryClientConnectionsResponse: object = { connectionPaths: "" }; @@ -476,8 +482,10 @@ export const QueryClientConnectionsResponse = { for (const v of message.connectionPaths) { writer.uint32(10).string(v!); } - writer.uint32(18).bytes(message.proof); - if (message.proofHeight !== undefined && message.proofHeight !== undefined) { + 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; @@ -527,6 +535,20 @@ export const QueryClientConnectionsResponse = { return message; }, + toJSON(message: QueryClientConnectionsResponse): unknown { + const obj: any = {}; + if (message.connectionPaths) { + obj.connectionPaths = message.connectionPaths.map((e) => e); + } else { + obj.connectionPaths = []; + } + 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): QueryClientConnectionsResponse { const message = { ...baseQueryClientConnectionsResponse } as QueryClientConnectionsResponse; message.connectionPaths = []; @@ -547,27 +569,15 @@ export const QueryClientConnectionsResponse = { } return message; }, - - toJSON(message: QueryClientConnectionsResponse): unknown { - const obj: any = {}; - if (message.connectionPaths) { - obj.connectionPaths = message.connectionPaths.map((e) => e); - } else { - obj.connectionPaths = []; - } - 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; - }, }; const baseQueryConnectionClientStateRequest: object = { connectionId: "" }; export const QueryConnectionClientStateRequest = { encode(message: QueryConnectionClientStateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.connectionId); + if (message.connectionId !== "") { + writer.uint32(10).string(message.connectionId); + } return writer; }, @@ -599,6 +609,12 @@ export const QueryConnectionClientStateRequest = { return message; }, + toJSON(message: QueryConnectionClientStateRequest): unknown { + const obj: any = {}; + message.connectionId !== undefined && (obj.connectionId = message.connectionId); + return obj; + }, + fromPartial(object: DeepPartial): QueryConnectionClientStateRequest { const message = { ...baseQueryConnectionClientStateRequest } as QueryConnectionClientStateRequest; if (object.connectionId !== undefined && object.connectionId !== null) { @@ -608,23 +624,19 @@ export const QueryConnectionClientStateRequest = { } return message; }, - - toJSON(message: QueryConnectionClientStateRequest): unknown { - const obj: any = {}; - message.connectionId !== undefined && (obj.connectionId = message.connectionId); - return obj; - }, }; const baseQueryConnectionClientStateResponse: object = {}; export const QueryConnectionClientStateResponse = { encode(message: QueryConnectionClientStateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.identifiedClientState !== undefined && message.identifiedClientState !== undefined) { + if (message.identifiedClientState !== undefined) { IdentifiedClientState.encode(message.identifiedClientState, writer.uint32(10).fork()).ldelim(); } - writer.uint32(18).bytes(message.proof); - if (message.proofHeight !== undefined && message.proofHeight !== undefined) { + 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; @@ -672,6 +684,19 @@ export const QueryConnectionClientStateResponse = { return message; }, + toJSON(message: QueryConnectionClientStateResponse): unknown { + const obj: any = {}; + message.identifiedClientState !== undefined && + (obj.identifiedClientState = message.identifiedClientState + ? IdentifiedClientState.toJSON(message.identifiedClientState) + : 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): QueryConnectionClientStateResponse { const message = { ...baseQueryConnectionClientStateResponse } as QueryConnectionClientStateResponse; if (object.identifiedClientState !== undefined && object.identifiedClientState !== null) { @@ -691,19 +716,6 @@ export const QueryConnectionClientStateResponse = { } return message; }, - - toJSON(message: QueryConnectionClientStateResponse): unknown { - const obj: any = {}; - message.identifiedClientState !== undefined && - (obj.identifiedClientState = message.identifiedClientState - ? IdentifiedClientState.toJSON(message.identifiedClientState) - : 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; - }, }; const baseQueryConnectionConsensusStateRequest: object = { @@ -717,9 +729,15 @@ export const QueryConnectionConsensusStateRequest = { message: QueryConnectionConsensusStateRequest, writer: _m0.Writer = _m0.Writer.create(), ): _m0.Writer { - writer.uint32(10).string(message.connectionId); - writer.uint32(16).uint64(message.revisionNumber); - writer.uint32(24).uint64(message.revisionHeight); + if (message.connectionId !== "") { + writer.uint32(10).string(message.connectionId); + } + if (!message.revisionNumber.isZero()) { + writer.uint32(16).uint64(message.revisionNumber); + } + if (!message.revisionHeight.isZero()) { + writer.uint32(24).uint64(message.revisionHeight); + } return writer; }, @@ -767,6 +785,16 @@ export const QueryConnectionConsensusStateRequest = { return message; }, + toJSON(message: QueryConnectionConsensusStateRequest): unknown { + const obj: any = {}; + message.connectionId !== undefined && (obj.connectionId = message.connectionId); + message.revisionNumber !== undefined && + (obj.revisionNumber = (message.revisionNumber || Long.UZERO).toString()); + message.revisionHeight !== undefined && + (obj.revisionHeight = (message.revisionHeight || Long.UZERO).toString()); + return obj; + }, + fromPartial( object: DeepPartial, ): QueryConnectionConsensusStateRequest { @@ -788,16 +816,6 @@ export const QueryConnectionConsensusStateRequest = { } return message; }, - - toJSON(message: QueryConnectionConsensusStateRequest): unknown { - const obj: any = {}; - message.connectionId !== undefined && (obj.connectionId = message.connectionId); - message.revisionNumber !== undefined && - (obj.revisionNumber = (message.revisionNumber || Long.UZERO).toString()); - message.revisionHeight !== undefined && - (obj.revisionHeight = (message.revisionHeight || Long.UZERO).toString()); - return obj; - }, }; const baseQueryConnectionConsensusStateResponse: object = { clientId: "" }; @@ -807,12 +825,16 @@ export const QueryConnectionConsensusStateResponse = { message: QueryConnectionConsensusStateResponse, writer: _m0.Writer = _m0.Writer.create(), ): _m0.Writer { - if (message.consensusState !== undefined && message.consensusState !== undefined) { + if (message.consensusState !== undefined) { Any.encode(message.consensusState, writer.uint32(10).fork()).ldelim(); } - writer.uint32(18).string(message.clientId); - writer.uint32(26).bytes(message.proof); - if (message.proofHeight !== undefined && message.proofHeight !== undefined) { + if (message.clientId !== "") { + writer.uint32(18).string(message.clientId); + } + if (message.proof.length !== 0) { + writer.uint32(26).bytes(message.proof); + } + if (message.proofHeight !== undefined) { Height.encode(message.proofHeight, writer.uint32(34).fork()).ldelim(); } return writer; @@ -868,6 +890,18 @@ export const QueryConnectionConsensusStateResponse = { return message; }, + toJSON(message: QueryConnectionConsensusStateResponse): unknown { + const obj: any = {}; + message.consensusState !== undefined && + (obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined); + message.clientId !== undefined && (obj.clientId = message.clientId); + 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, ): QueryConnectionConsensusStateResponse { @@ -894,18 +928,6 @@ export const QueryConnectionConsensusStateResponse = { } return message; }, - - toJSON(message: QueryConnectionConsensusStateResponse): unknown { - const obj: any = {}; - message.consensusState !== undefined && - (obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined); - message.clientId !== undefined && (obj.clientId = message.clientId); - 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; - }, }; /** Query provides defines the gRPC querier service */ @@ -986,7 +1008,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/stargate/src/codec/tendermint/abci/types.ts b/packages/stargate/src/codec/tendermint/abci/types.ts index 92f6d82e..374cb3c9 100644 --- a/packages/stargate/src/codec/tendermint/abci/types.ts +++ b/packages/stargate/src/codec/tendermint/abci/types.ts @@ -725,6 +725,47 @@ export const Request = { return message; }, + toJSON(message: Request): unknown { + const obj: any = {}; + message.echo !== undefined && (obj.echo = message.echo ? RequestEcho.toJSON(message.echo) : undefined); + message.flush !== undefined && + (obj.flush = message.flush ? RequestFlush.toJSON(message.flush) : undefined); + message.info !== undefined && (obj.info = message.info ? RequestInfo.toJSON(message.info) : undefined); + message.setOption !== undefined && + (obj.setOption = message.setOption ? RequestSetOption.toJSON(message.setOption) : undefined); + message.initChain !== undefined && + (obj.initChain = message.initChain ? RequestInitChain.toJSON(message.initChain) : undefined); + message.query !== undefined && + (obj.query = message.query ? RequestQuery.toJSON(message.query) : undefined); + message.beginBlock !== undefined && + (obj.beginBlock = message.beginBlock ? RequestBeginBlock.toJSON(message.beginBlock) : undefined); + message.checkTx !== undefined && + (obj.checkTx = message.checkTx ? RequestCheckTx.toJSON(message.checkTx) : undefined); + message.deliverTx !== undefined && + (obj.deliverTx = message.deliverTx ? RequestDeliverTx.toJSON(message.deliverTx) : undefined); + message.endBlock !== undefined && + (obj.endBlock = message.endBlock ? RequestEndBlock.toJSON(message.endBlock) : undefined); + message.commit !== undefined && + (obj.commit = message.commit ? RequestCommit.toJSON(message.commit) : undefined); + message.listSnapshots !== undefined && + (obj.listSnapshots = message.listSnapshots + ? RequestListSnapshots.toJSON(message.listSnapshots) + : undefined); + message.offerSnapshot !== undefined && + (obj.offerSnapshot = message.offerSnapshot + ? RequestOfferSnapshot.toJSON(message.offerSnapshot) + : undefined); + message.loadSnapshotChunk !== undefined && + (obj.loadSnapshotChunk = message.loadSnapshotChunk + ? RequestLoadSnapshotChunk.toJSON(message.loadSnapshotChunk) + : undefined); + message.applySnapshotChunk !== undefined && + (obj.applySnapshotChunk = message.applySnapshotChunk + ? RequestApplySnapshotChunk.toJSON(message.applySnapshotChunk) + : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Request { const message = { ...baseRequest } as Request; if (object.echo !== undefined && object.echo !== null) { @@ -804,54 +845,15 @@ export const Request = { } return message; }, - - toJSON(message: Request): unknown { - const obj: any = {}; - message.echo !== undefined && (obj.echo = message.echo ? RequestEcho.toJSON(message.echo) : undefined); - message.flush !== undefined && - (obj.flush = message.flush ? RequestFlush.toJSON(message.flush) : undefined); - message.info !== undefined && (obj.info = message.info ? RequestInfo.toJSON(message.info) : undefined); - message.setOption !== undefined && - (obj.setOption = message.setOption ? RequestSetOption.toJSON(message.setOption) : undefined); - message.initChain !== undefined && - (obj.initChain = message.initChain ? RequestInitChain.toJSON(message.initChain) : undefined); - message.query !== undefined && - (obj.query = message.query ? RequestQuery.toJSON(message.query) : undefined); - message.beginBlock !== undefined && - (obj.beginBlock = message.beginBlock ? RequestBeginBlock.toJSON(message.beginBlock) : undefined); - message.checkTx !== undefined && - (obj.checkTx = message.checkTx ? RequestCheckTx.toJSON(message.checkTx) : undefined); - message.deliverTx !== undefined && - (obj.deliverTx = message.deliverTx ? RequestDeliverTx.toJSON(message.deliverTx) : undefined); - message.endBlock !== undefined && - (obj.endBlock = message.endBlock ? RequestEndBlock.toJSON(message.endBlock) : undefined); - message.commit !== undefined && - (obj.commit = message.commit ? RequestCommit.toJSON(message.commit) : undefined); - message.listSnapshots !== undefined && - (obj.listSnapshots = message.listSnapshots - ? RequestListSnapshots.toJSON(message.listSnapshots) - : undefined); - message.offerSnapshot !== undefined && - (obj.offerSnapshot = message.offerSnapshot - ? RequestOfferSnapshot.toJSON(message.offerSnapshot) - : undefined); - message.loadSnapshotChunk !== undefined && - (obj.loadSnapshotChunk = message.loadSnapshotChunk - ? RequestLoadSnapshotChunk.toJSON(message.loadSnapshotChunk) - : undefined); - message.applySnapshotChunk !== undefined && - (obj.applySnapshotChunk = message.applySnapshotChunk - ? RequestApplySnapshotChunk.toJSON(message.applySnapshotChunk) - : undefined); - return obj; - }, }; const baseRequestEcho: object = { message: "" }; export const RequestEcho = { encode(message: RequestEcho, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.message); + if (message.message !== "") { + writer.uint32(10).string(message.message); + } return writer; }, @@ -883,6 +885,12 @@ export const RequestEcho = { return message; }, + toJSON(message: RequestEcho): unknown { + const obj: any = {}; + message.message !== undefined && (obj.message = message.message); + return obj; + }, + fromPartial(object: DeepPartial): RequestEcho { const message = { ...baseRequestEcho } as RequestEcho; if (object.message !== undefined && object.message !== null) { @@ -892,12 +900,6 @@ export const RequestEcho = { } return message; }, - - toJSON(message: RequestEcho): unknown { - const obj: any = {}; - message.message !== undefined && (obj.message = message.message); - return obj; - }, }; const baseRequestFlush: object = {}; @@ -927,24 +929,30 @@ export const RequestFlush = { return message; }, - fromPartial(_: DeepPartial): RequestFlush { - const message = { ...baseRequestFlush } as RequestFlush; - return message; - }, - toJSON(_: RequestFlush): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): RequestFlush { + const message = { ...baseRequestFlush } as RequestFlush; + return message; + }, }; const baseRequestInfo: object = { version: "", blockVersion: Long.UZERO, p2pVersion: Long.UZERO }; export const RequestInfo = { encode(message: RequestInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.version); - writer.uint32(16).uint64(message.blockVersion); - writer.uint32(24).uint64(message.p2pVersion); + if (message.version !== "") { + writer.uint32(10).string(message.version); + } + if (!message.blockVersion.isZero()) { + writer.uint32(16).uint64(message.blockVersion); + } + if (!message.p2pVersion.isZero()) { + writer.uint32(24).uint64(message.p2pVersion); + } return writer; }, @@ -992,6 +1000,15 @@ export const RequestInfo = { return message; }, + toJSON(message: RequestInfo): unknown { + const obj: any = {}; + message.version !== undefined && (obj.version = message.version); + message.blockVersion !== undefined && + (obj.blockVersion = (message.blockVersion || Long.UZERO).toString()); + message.p2pVersion !== undefined && (obj.p2pVersion = (message.p2pVersion || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): RequestInfo { const message = { ...baseRequestInfo } as RequestInfo; if (object.version !== undefined && object.version !== null) { @@ -1011,23 +1028,18 @@ export const RequestInfo = { } return message; }, - - toJSON(message: RequestInfo): unknown { - const obj: any = {}; - message.version !== undefined && (obj.version = message.version); - message.blockVersion !== undefined && - (obj.blockVersion = (message.blockVersion || Long.UZERO).toString()); - message.p2pVersion !== undefined && (obj.p2pVersion = (message.p2pVersion || Long.UZERO).toString()); - return obj; - }, }; const baseRequestSetOption: object = { key: "", value: "" }; export const RequestSetOption = { encode(message: RequestSetOption, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.key); - writer.uint32(18).string(message.value); + if (message.key !== "") { + writer.uint32(10).string(message.key); + } + if (message.value !== "") { + writer.uint32(18).string(message.value); + } return writer; }, @@ -1067,6 +1079,13 @@ export const RequestSetOption = { return message; }, + toJSON(message: RequestSetOption): unknown { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): RequestSetOption { const message = { ...baseRequestSetOption } as RequestSetOption; if (object.key !== undefined && object.key !== null) { @@ -1081,31 +1100,30 @@ export const RequestSetOption = { } return message; }, - - toJSON(message: RequestSetOption): unknown { - const obj: any = {}; - message.key !== undefined && (obj.key = message.key); - message.value !== undefined && (obj.value = message.value); - return obj; - }, }; const baseRequestInitChain: object = { chainId: "", initialHeight: Long.ZERO }; export const RequestInitChain = { encode(message: RequestInitChain, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.time !== undefined && message.time !== undefined) { + if (message.time !== undefined) { Timestamp.encode(toTimestamp(message.time), writer.uint32(10).fork()).ldelim(); } - writer.uint32(18).string(message.chainId); - if (message.consensusParams !== undefined && message.consensusParams !== undefined) { + if (message.chainId !== "") { + writer.uint32(18).string(message.chainId); + } + if (message.consensusParams !== undefined) { ConsensusParams.encode(message.consensusParams, writer.uint32(26).fork()).ldelim(); } for (const v of message.validators) { ValidatorUpdate.encode(v!, writer.uint32(34).fork()).ldelim(); } - writer.uint32(42).bytes(message.appStateBytes); - writer.uint32(48).int64(message.initialHeight); + if (message.appStateBytes.length !== 0) { + writer.uint32(42).bytes(message.appStateBytes); + } + if (!message.initialHeight.isZero()) { + writer.uint32(48).int64(message.initialHeight); + } return writer; }, @@ -1177,6 +1195,28 @@ export const RequestInitChain = { return message; }, + toJSON(message: RequestInitChain): unknown { + const obj: any = {}; + message.time !== undefined && (obj.time = message.time !== undefined ? message.time.toISOString() : null); + message.chainId !== undefined && (obj.chainId = message.chainId); + message.consensusParams !== undefined && + (obj.consensusParams = message.consensusParams + ? ConsensusParams.toJSON(message.consensusParams) + : undefined); + if (message.validators) { + obj.validators = message.validators.map((e) => (e ? ValidatorUpdate.toJSON(e) : undefined)); + } else { + obj.validators = []; + } + message.appStateBytes !== undefined && + (obj.appStateBytes = base64FromBytes( + message.appStateBytes !== undefined ? message.appStateBytes : new Uint8Array(), + )); + message.initialHeight !== undefined && + (obj.initialHeight = (message.initialHeight || Long.ZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): RequestInitChain { const message = { ...baseRequestInitChain } as RequestInitChain; message.validators = []; @@ -1212,38 +1252,24 @@ export const RequestInitChain = { } return message; }, - - toJSON(message: RequestInitChain): unknown { - const obj: any = {}; - message.time !== undefined && (obj.time = message.time !== undefined ? message.time.toISOString() : null); - message.chainId !== undefined && (obj.chainId = message.chainId); - message.consensusParams !== undefined && - (obj.consensusParams = message.consensusParams - ? ConsensusParams.toJSON(message.consensusParams) - : undefined); - if (message.validators) { - obj.validators = message.validators.map((e) => (e ? ValidatorUpdate.toJSON(e) : undefined)); - } else { - obj.validators = []; - } - message.appStateBytes !== undefined && - (obj.appStateBytes = base64FromBytes( - message.appStateBytes !== undefined ? message.appStateBytes : new Uint8Array(), - )); - message.initialHeight !== undefined && - (obj.initialHeight = (message.initialHeight || Long.ZERO).toString()); - return obj; - }, }; const baseRequestQuery: object = { path: "", height: Long.ZERO, prove: false }; export const RequestQuery = { encode(message: RequestQuery, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.data); - writer.uint32(18).string(message.path); - writer.uint32(24).int64(message.height); - writer.uint32(32).bool(message.prove); + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + if (!message.height.isZero()) { + writer.uint32(24).int64(message.height); + } + if (message.prove === true) { + writer.uint32(32).bool(message.prove); + } return writer; }, @@ -1297,6 +1323,16 @@ export const RequestQuery = { return message; }, + toJSON(message: RequestQuery): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + message.path !== undefined && (obj.path = message.path); + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + message.prove !== undefined && (obj.prove = message.prove); + return obj; + }, + fromPartial(object: DeepPartial): RequestQuery { const message = { ...baseRequestQuery } as RequestQuery; if (object.data !== undefined && object.data !== null) { @@ -1321,27 +1357,19 @@ export const RequestQuery = { } return message; }, - - toJSON(message: RequestQuery): unknown { - const obj: any = {}; - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); - message.path !== undefined && (obj.path = message.path); - message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); - message.prove !== undefined && (obj.prove = message.prove); - return obj; - }, }; const baseRequestBeginBlock: object = {}; export const RequestBeginBlock = { encode(message: RequestBeginBlock, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.hash); - if (message.header !== undefined && message.header !== undefined) { + if (message.hash.length !== 0) { + writer.uint32(10).bytes(message.hash); + } + if (message.header !== undefined) { Header.encode(message.header, writer.uint32(18).fork()).ldelim(); } - if (message.lastCommitInfo !== undefined && message.lastCommitInfo !== undefined) { + if (message.lastCommitInfo !== undefined) { LastCommitInfo.encode(message.lastCommitInfo, writer.uint32(26).fork()).ldelim(); } for (const v of message.byzantineValidators) { @@ -1402,6 +1430,23 @@ export const RequestBeginBlock = { return message; }, + toJSON(message: RequestBeginBlock): unknown { + const obj: any = {}; + message.hash !== undefined && + (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); + message.header !== undefined && (obj.header = message.header ? Header.toJSON(message.header) : undefined); + message.lastCommitInfo !== undefined && + (obj.lastCommitInfo = message.lastCommitInfo + ? LastCommitInfo.toJSON(message.lastCommitInfo) + : undefined); + if (message.byzantineValidators) { + obj.byzantineValidators = message.byzantineValidators.map((e) => (e ? Evidence.toJSON(e) : undefined)); + } else { + obj.byzantineValidators = []; + } + return obj; + }, + fromPartial(object: DeepPartial): RequestBeginBlock { const message = { ...baseRequestBeginBlock } as RequestBeginBlock; message.byzantineValidators = []; @@ -1427,31 +1472,18 @@ export const RequestBeginBlock = { } return message; }, - - toJSON(message: RequestBeginBlock): unknown { - const obj: any = {}; - message.hash !== undefined && - (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); - message.header !== undefined && (obj.header = message.header ? Header.toJSON(message.header) : undefined); - message.lastCommitInfo !== undefined && - (obj.lastCommitInfo = message.lastCommitInfo - ? LastCommitInfo.toJSON(message.lastCommitInfo) - : undefined); - if (message.byzantineValidators) { - obj.byzantineValidators = message.byzantineValidators.map((e) => (e ? Evidence.toJSON(e) : undefined)); - } else { - obj.byzantineValidators = []; - } - return obj; - }, }; const baseRequestCheckTx: object = { type: 0 }; export const RequestCheckTx = { encode(message: RequestCheckTx, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.tx); - writer.uint32(16).int32(message.type); + if (message.tx.length !== 0) { + writer.uint32(10).bytes(message.tx); + } + if (message.type !== 0) { + writer.uint32(16).int32(message.type); + } return writer; }, @@ -1489,6 +1521,14 @@ export const RequestCheckTx = { return message; }, + toJSON(message: RequestCheckTx): unknown { + const obj: any = {}; + message.tx !== undefined && + (obj.tx = base64FromBytes(message.tx !== undefined ? message.tx : new Uint8Array())); + message.type !== undefined && (obj.type = checkTxTypeToJSON(message.type)); + return obj; + }, + fromPartial(object: DeepPartial): RequestCheckTx { const message = { ...baseRequestCheckTx } as RequestCheckTx; if (object.tx !== undefined && object.tx !== null) { @@ -1503,21 +1543,15 @@ export const RequestCheckTx = { } return message; }, - - toJSON(message: RequestCheckTx): unknown { - const obj: any = {}; - message.tx !== undefined && - (obj.tx = base64FromBytes(message.tx !== undefined ? message.tx : new Uint8Array())); - message.type !== undefined && (obj.type = checkTxTypeToJSON(message.type)); - return obj; - }, }; const baseRequestDeliverTx: object = {}; export const RequestDeliverTx = { encode(message: RequestDeliverTx, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.tx); + if (message.tx.length !== 0) { + writer.uint32(10).bytes(message.tx); + } return writer; }, @@ -1547,6 +1581,13 @@ export const RequestDeliverTx = { return message; }, + toJSON(message: RequestDeliverTx): unknown { + const obj: any = {}; + message.tx !== undefined && + (obj.tx = base64FromBytes(message.tx !== undefined ? message.tx : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): RequestDeliverTx { const message = { ...baseRequestDeliverTx } as RequestDeliverTx; if (object.tx !== undefined && object.tx !== null) { @@ -1556,20 +1597,15 @@ export const RequestDeliverTx = { } return message; }, - - toJSON(message: RequestDeliverTx): unknown { - const obj: any = {}; - message.tx !== undefined && - (obj.tx = base64FromBytes(message.tx !== undefined ? message.tx : new Uint8Array())); - return obj; - }, }; const baseRequestEndBlock: object = { height: Long.ZERO }; export const RequestEndBlock = { encode(message: RequestEndBlock, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int64(message.height); + if (!message.height.isZero()) { + writer.uint32(8).int64(message.height); + } return writer; }, @@ -1601,6 +1637,12 @@ export const RequestEndBlock = { return message; }, + toJSON(message: RequestEndBlock): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): RequestEndBlock { const message = { ...baseRequestEndBlock } as RequestEndBlock; if (object.height !== undefined && object.height !== null) { @@ -1610,12 +1652,6 @@ export const RequestEndBlock = { } return message; }, - - toJSON(message: RequestEndBlock): unknown { - const obj: any = {}; - message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); - return obj; - }, }; const baseRequestCommit: object = {}; @@ -1645,15 +1681,15 @@ export const RequestCommit = { return message; }, - fromPartial(_: DeepPartial): RequestCommit { - const message = { ...baseRequestCommit } as RequestCommit; - return message; - }, - toJSON(_: RequestCommit): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): RequestCommit { + const message = { ...baseRequestCommit } as RequestCommit; + return message; + }, }; const baseRequestListSnapshots: object = {}; @@ -1683,25 +1719,27 @@ export const RequestListSnapshots = { return message; }, - fromPartial(_: DeepPartial): RequestListSnapshots { - const message = { ...baseRequestListSnapshots } as RequestListSnapshots; - return message; - }, - toJSON(_: RequestListSnapshots): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): RequestListSnapshots { + const message = { ...baseRequestListSnapshots } as RequestListSnapshots; + return message; + }, }; const baseRequestOfferSnapshot: object = {}; export const RequestOfferSnapshot = { encode(message: RequestOfferSnapshot, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.snapshot !== undefined && message.snapshot !== undefined) { + if (message.snapshot !== undefined) { Snapshot.encode(message.snapshot, writer.uint32(10).fork()).ldelim(); } - writer.uint32(18).bytes(message.appHash); + if (message.appHash.length !== 0) { + writer.uint32(18).bytes(message.appHash); + } return writer; }, @@ -1739,6 +1777,15 @@ export const RequestOfferSnapshot = { return message; }, + toJSON(message: RequestOfferSnapshot): unknown { + const obj: any = {}; + message.snapshot !== undefined && + (obj.snapshot = message.snapshot ? Snapshot.toJSON(message.snapshot) : undefined); + message.appHash !== undefined && + (obj.appHash = base64FromBytes(message.appHash !== undefined ? message.appHash : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): RequestOfferSnapshot { const message = { ...baseRequestOfferSnapshot } as RequestOfferSnapshot; if (object.snapshot !== undefined && object.snapshot !== null) { @@ -1753,24 +1800,21 @@ export const RequestOfferSnapshot = { } return message; }, - - toJSON(message: RequestOfferSnapshot): unknown { - const obj: any = {}; - message.snapshot !== undefined && - (obj.snapshot = message.snapshot ? Snapshot.toJSON(message.snapshot) : undefined); - message.appHash !== undefined && - (obj.appHash = base64FromBytes(message.appHash !== undefined ? message.appHash : new Uint8Array())); - return obj; - }, }; const baseRequestLoadSnapshotChunk: object = { height: Long.UZERO, format: 0, chunk: 0 }; export const RequestLoadSnapshotChunk = { encode(message: RequestLoadSnapshotChunk, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.height); - writer.uint32(16).uint32(message.format); - writer.uint32(24).uint32(message.chunk); + if (!message.height.isZero()) { + writer.uint32(8).uint64(message.height); + } + if (message.format !== 0) { + writer.uint32(16).uint32(message.format); + } + if (message.chunk !== 0) { + writer.uint32(24).uint32(message.chunk); + } return writer; }, @@ -1818,6 +1862,14 @@ export const RequestLoadSnapshotChunk = { return message; }, + toJSON(message: RequestLoadSnapshotChunk): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.UZERO).toString()); + message.format !== undefined && (obj.format = message.format); + message.chunk !== undefined && (obj.chunk = message.chunk); + return obj; + }, + fromPartial(object: DeepPartial): RequestLoadSnapshotChunk { const message = { ...baseRequestLoadSnapshotChunk } as RequestLoadSnapshotChunk; if (object.height !== undefined && object.height !== null) { @@ -1837,23 +1889,21 @@ export const RequestLoadSnapshotChunk = { } return message; }, - - toJSON(message: RequestLoadSnapshotChunk): unknown { - const obj: any = {}; - message.height !== undefined && (obj.height = (message.height || Long.UZERO).toString()); - message.format !== undefined && (obj.format = message.format); - message.chunk !== undefined && (obj.chunk = message.chunk); - return obj; - }, }; const baseRequestApplySnapshotChunk: object = { index: 0, sender: "" }; export const RequestApplySnapshotChunk = { encode(message: RequestApplySnapshotChunk, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint32(message.index); - writer.uint32(18).bytes(message.chunk); - writer.uint32(26).string(message.sender); + if (message.index !== 0) { + writer.uint32(8).uint32(message.index); + } + if (message.chunk.length !== 0) { + writer.uint32(18).bytes(message.chunk); + } + if (message.sender !== "") { + writer.uint32(26).string(message.sender); + } return writer; }, @@ -1899,6 +1949,15 @@ export const RequestApplySnapshotChunk = { return message; }, + toJSON(message: RequestApplySnapshotChunk): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = message.index); + message.chunk !== undefined && + (obj.chunk = base64FromBytes(message.chunk !== undefined ? message.chunk : new Uint8Array())); + message.sender !== undefined && (obj.sender = message.sender); + return obj; + }, + fromPartial(object: DeepPartial): RequestApplySnapshotChunk { const message = { ...baseRequestApplySnapshotChunk } as RequestApplySnapshotChunk; if (object.index !== undefined && object.index !== null) { @@ -1918,15 +1977,6 @@ export const RequestApplySnapshotChunk = { } return message; }, - - toJSON(message: RequestApplySnapshotChunk): unknown { - const obj: any = {}; - message.index !== undefined && (obj.index = message.index); - message.chunk !== undefined && - (obj.chunk = base64FromBytes(message.chunk !== undefined ? message.chunk : new Uint8Array())); - message.sender !== undefined && (obj.sender = message.sender); - return obj; - }, }; const baseResponse: object = {}; @@ -2132,6 +2182,49 @@ export const Response = { return message; }, + toJSON(message: Response): unknown { + const obj: any = {}; + message.exception !== undefined && + (obj.exception = message.exception ? ResponseException.toJSON(message.exception) : undefined); + message.echo !== undefined && (obj.echo = message.echo ? ResponseEcho.toJSON(message.echo) : undefined); + message.flush !== undefined && + (obj.flush = message.flush ? ResponseFlush.toJSON(message.flush) : undefined); + message.info !== undefined && (obj.info = message.info ? ResponseInfo.toJSON(message.info) : undefined); + message.setOption !== undefined && + (obj.setOption = message.setOption ? ResponseSetOption.toJSON(message.setOption) : undefined); + message.initChain !== undefined && + (obj.initChain = message.initChain ? ResponseInitChain.toJSON(message.initChain) : undefined); + message.query !== undefined && + (obj.query = message.query ? ResponseQuery.toJSON(message.query) : undefined); + message.beginBlock !== undefined && + (obj.beginBlock = message.beginBlock ? ResponseBeginBlock.toJSON(message.beginBlock) : undefined); + message.checkTx !== undefined && + (obj.checkTx = message.checkTx ? ResponseCheckTx.toJSON(message.checkTx) : undefined); + message.deliverTx !== undefined && + (obj.deliverTx = message.deliverTx ? ResponseDeliverTx.toJSON(message.deliverTx) : undefined); + message.endBlock !== undefined && + (obj.endBlock = message.endBlock ? ResponseEndBlock.toJSON(message.endBlock) : undefined); + message.commit !== undefined && + (obj.commit = message.commit ? ResponseCommit.toJSON(message.commit) : undefined); + message.listSnapshots !== undefined && + (obj.listSnapshots = message.listSnapshots + ? ResponseListSnapshots.toJSON(message.listSnapshots) + : undefined); + message.offerSnapshot !== undefined && + (obj.offerSnapshot = message.offerSnapshot + ? ResponseOfferSnapshot.toJSON(message.offerSnapshot) + : undefined); + message.loadSnapshotChunk !== undefined && + (obj.loadSnapshotChunk = message.loadSnapshotChunk + ? ResponseLoadSnapshotChunk.toJSON(message.loadSnapshotChunk) + : undefined); + message.applySnapshotChunk !== undefined && + (obj.applySnapshotChunk = message.applySnapshotChunk + ? ResponseApplySnapshotChunk.toJSON(message.applySnapshotChunk) + : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Response { const message = { ...baseResponse } as Response; if (object.exception !== undefined && object.exception !== null) { @@ -2216,56 +2309,15 @@ export const Response = { } return message; }, - - toJSON(message: Response): unknown { - const obj: any = {}; - message.exception !== undefined && - (obj.exception = message.exception ? ResponseException.toJSON(message.exception) : undefined); - message.echo !== undefined && (obj.echo = message.echo ? ResponseEcho.toJSON(message.echo) : undefined); - message.flush !== undefined && - (obj.flush = message.flush ? ResponseFlush.toJSON(message.flush) : undefined); - message.info !== undefined && (obj.info = message.info ? ResponseInfo.toJSON(message.info) : undefined); - message.setOption !== undefined && - (obj.setOption = message.setOption ? ResponseSetOption.toJSON(message.setOption) : undefined); - message.initChain !== undefined && - (obj.initChain = message.initChain ? ResponseInitChain.toJSON(message.initChain) : undefined); - message.query !== undefined && - (obj.query = message.query ? ResponseQuery.toJSON(message.query) : undefined); - message.beginBlock !== undefined && - (obj.beginBlock = message.beginBlock ? ResponseBeginBlock.toJSON(message.beginBlock) : undefined); - message.checkTx !== undefined && - (obj.checkTx = message.checkTx ? ResponseCheckTx.toJSON(message.checkTx) : undefined); - message.deliverTx !== undefined && - (obj.deliverTx = message.deliverTx ? ResponseDeliverTx.toJSON(message.deliverTx) : undefined); - message.endBlock !== undefined && - (obj.endBlock = message.endBlock ? ResponseEndBlock.toJSON(message.endBlock) : undefined); - message.commit !== undefined && - (obj.commit = message.commit ? ResponseCommit.toJSON(message.commit) : undefined); - message.listSnapshots !== undefined && - (obj.listSnapshots = message.listSnapshots - ? ResponseListSnapshots.toJSON(message.listSnapshots) - : undefined); - message.offerSnapshot !== undefined && - (obj.offerSnapshot = message.offerSnapshot - ? ResponseOfferSnapshot.toJSON(message.offerSnapshot) - : undefined); - message.loadSnapshotChunk !== undefined && - (obj.loadSnapshotChunk = message.loadSnapshotChunk - ? ResponseLoadSnapshotChunk.toJSON(message.loadSnapshotChunk) - : undefined); - message.applySnapshotChunk !== undefined && - (obj.applySnapshotChunk = message.applySnapshotChunk - ? ResponseApplySnapshotChunk.toJSON(message.applySnapshotChunk) - : undefined); - return obj; - }, }; const baseResponseException: object = { error: "" }; export const ResponseException = { encode(message: ResponseException, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.error); + if (message.error !== "") { + writer.uint32(10).string(message.error); + } return writer; }, @@ -2297,6 +2349,12 @@ export const ResponseException = { return message; }, + toJSON(message: ResponseException): unknown { + const obj: any = {}; + message.error !== undefined && (obj.error = message.error); + return obj; + }, + fromPartial(object: DeepPartial): ResponseException { const message = { ...baseResponseException } as ResponseException; if (object.error !== undefined && object.error !== null) { @@ -2306,19 +2364,15 @@ export const ResponseException = { } return message; }, - - toJSON(message: ResponseException): unknown { - const obj: any = {}; - message.error !== undefined && (obj.error = message.error); - return obj; - }, }; const baseResponseEcho: object = { message: "" }; export const ResponseEcho = { encode(message: ResponseEcho, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.message); + if (message.message !== "") { + writer.uint32(10).string(message.message); + } return writer; }, @@ -2350,6 +2404,12 @@ export const ResponseEcho = { return message; }, + toJSON(message: ResponseEcho): unknown { + const obj: any = {}; + message.message !== undefined && (obj.message = message.message); + return obj; + }, + fromPartial(object: DeepPartial): ResponseEcho { const message = { ...baseResponseEcho } as ResponseEcho; if (object.message !== undefined && object.message !== null) { @@ -2359,12 +2419,6 @@ export const ResponseEcho = { } return message; }, - - toJSON(message: ResponseEcho): unknown { - const obj: any = {}; - message.message !== undefined && (obj.message = message.message); - return obj; - }, }; const baseResponseFlush: object = {}; @@ -2394,15 +2448,15 @@ export const ResponseFlush = { return message; }, - fromPartial(_: DeepPartial): ResponseFlush { - const message = { ...baseResponseFlush } as ResponseFlush; - return message; - }, - toJSON(_: ResponseFlush): unknown { const obj: any = {}; return obj; }, + + fromPartial(_: DeepPartial): ResponseFlush { + const message = { ...baseResponseFlush } as ResponseFlush; + return message; + }, }; const baseResponseInfo: object = { @@ -2414,11 +2468,21 @@ const baseResponseInfo: object = { export const ResponseInfo = { encode(message: ResponseInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.data); - writer.uint32(18).string(message.version); - writer.uint32(24).uint64(message.appVersion); - writer.uint32(32).int64(message.lastBlockHeight); - writer.uint32(42).bytes(message.lastBlockAppHash); + if (message.data !== "") { + writer.uint32(10).string(message.data); + } + if (message.version !== "") { + writer.uint32(18).string(message.version); + } + if (!message.appVersion.isZero()) { + writer.uint32(24).uint64(message.appVersion); + } + if (!message.lastBlockHeight.isZero()) { + writer.uint32(32).int64(message.lastBlockHeight); + } + if (message.lastBlockAppHash.length !== 0) { + writer.uint32(42).bytes(message.lastBlockAppHash); + } return writer; }, @@ -2480,6 +2544,20 @@ export const ResponseInfo = { return message; }, + toJSON(message: ResponseInfo): unknown { + const obj: any = {}; + message.data !== undefined && (obj.data = message.data); + message.version !== undefined && (obj.version = message.version); + message.appVersion !== undefined && (obj.appVersion = (message.appVersion || Long.UZERO).toString()); + message.lastBlockHeight !== undefined && + (obj.lastBlockHeight = (message.lastBlockHeight || Long.ZERO).toString()); + message.lastBlockAppHash !== undefined && + (obj.lastBlockAppHash = base64FromBytes( + message.lastBlockAppHash !== undefined ? message.lastBlockAppHash : new Uint8Array(), + )); + return obj; + }, + fromPartial(object: DeepPartial): ResponseInfo { const message = { ...baseResponseInfo } as ResponseInfo; if (object.data !== undefined && object.data !== null) { @@ -2509,29 +2587,21 @@ export const ResponseInfo = { } return message; }, - - toJSON(message: ResponseInfo): unknown { - const obj: any = {}; - message.data !== undefined && (obj.data = message.data); - message.version !== undefined && (obj.version = message.version); - message.appVersion !== undefined && (obj.appVersion = (message.appVersion || Long.UZERO).toString()); - message.lastBlockHeight !== undefined && - (obj.lastBlockHeight = (message.lastBlockHeight || Long.ZERO).toString()); - message.lastBlockAppHash !== undefined && - (obj.lastBlockAppHash = base64FromBytes( - message.lastBlockAppHash !== undefined ? message.lastBlockAppHash : new Uint8Array(), - )); - return obj; - }, }; const baseResponseSetOption: object = { code: 0, log: "", info: "" }; export const ResponseSetOption = { encode(message: ResponseSetOption, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint32(message.code); - writer.uint32(26).string(message.log); - writer.uint32(34).string(message.info); + if (message.code !== 0) { + writer.uint32(8).uint32(message.code); + } + if (message.log !== "") { + writer.uint32(26).string(message.log); + } + if (message.info !== "") { + writer.uint32(34).string(message.info); + } return writer; }, @@ -2579,6 +2649,14 @@ export const ResponseSetOption = { return message; }, + toJSON(message: ResponseSetOption): unknown { + const obj: any = {}; + message.code !== undefined && (obj.code = message.code); + message.log !== undefined && (obj.log = message.log); + message.info !== undefined && (obj.info = message.info); + return obj; + }, + fromPartial(object: DeepPartial): ResponseSetOption { const message = { ...baseResponseSetOption } as ResponseSetOption; if (object.code !== undefined && object.code !== null) { @@ -2598,27 +2676,21 @@ export const ResponseSetOption = { } return message; }, - - toJSON(message: ResponseSetOption): unknown { - const obj: any = {}; - message.code !== undefined && (obj.code = message.code); - message.log !== undefined && (obj.log = message.log); - message.info !== undefined && (obj.info = message.info); - return obj; - }, }; const baseResponseInitChain: object = {}; export const ResponseInitChain = { encode(message: ResponseInitChain, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.consensusParams !== undefined && message.consensusParams !== undefined) { + if (message.consensusParams !== undefined) { ConsensusParams.encode(message.consensusParams, writer.uint32(10).fork()).ldelim(); } for (const v of message.validators) { ValidatorUpdate.encode(v!, writer.uint32(18).fork()).ldelim(); } - writer.uint32(26).bytes(message.appHash); + if (message.appHash.length !== 0) { + writer.uint32(26).bytes(message.appHash); + } return writer; }, @@ -2666,6 +2738,22 @@ export const ResponseInitChain = { return message; }, + toJSON(message: ResponseInitChain): unknown { + const obj: any = {}; + message.consensusParams !== undefined && + (obj.consensusParams = message.consensusParams + ? ConsensusParams.toJSON(message.consensusParams) + : undefined); + if (message.validators) { + obj.validators = message.validators.map((e) => (e ? ValidatorUpdate.toJSON(e) : undefined)); + } else { + obj.validators = []; + } + message.appHash !== undefined && + (obj.appHash = base64FromBytes(message.appHash !== undefined ? message.appHash : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): ResponseInitChain { const message = { ...baseResponseInitChain } as ResponseInitChain; message.validators = []; @@ -2686,22 +2774,6 @@ export const ResponseInitChain = { } return message; }, - - toJSON(message: ResponseInitChain): unknown { - const obj: any = {}; - message.consensusParams !== undefined && - (obj.consensusParams = message.consensusParams - ? ConsensusParams.toJSON(message.consensusParams) - : undefined); - if (message.validators) { - obj.validators = message.validators.map((e) => (e ? ValidatorUpdate.toJSON(e) : undefined)); - } else { - obj.validators = []; - } - message.appHash !== undefined && - (obj.appHash = base64FromBytes(message.appHash !== undefined ? message.appHash : new Uint8Array())); - return obj; - }, }; const baseResponseQuery: object = { @@ -2715,17 +2787,33 @@ const baseResponseQuery: object = { export const ResponseQuery = { encode(message: ResponseQuery, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint32(message.code); - writer.uint32(26).string(message.log); - writer.uint32(34).string(message.info); - writer.uint32(40).int64(message.index); - writer.uint32(50).bytes(message.key); - writer.uint32(58).bytes(message.value); - if (message.proofOps !== undefined && message.proofOps !== undefined) { + if (message.code !== 0) { + writer.uint32(8).uint32(message.code); + } + if (message.log !== "") { + writer.uint32(26).string(message.log); + } + if (message.info !== "") { + writer.uint32(34).string(message.info); + } + if (!message.index.isZero()) { + writer.uint32(40).int64(message.index); + } + if (message.key.length !== 0) { + writer.uint32(50).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(58).bytes(message.value); + } + if (message.proofOps !== undefined) { ProofOps.encode(message.proofOps, writer.uint32(66).fork()).ldelim(); } - writer.uint32(72).int64(message.height); - writer.uint32(82).string(message.codespace); + if (!message.height.isZero()) { + writer.uint32(72).int64(message.height); + } + if (message.codespace !== "") { + writer.uint32(82).string(message.codespace); + } return writer; }, @@ -2817,6 +2905,23 @@ export const ResponseQuery = { return message; }, + toJSON(message: ResponseQuery): unknown { + const obj: any = {}; + message.code !== undefined && (obj.code = message.code); + message.log !== undefined && (obj.log = message.log); + message.info !== undefined && (obj.info = message.info); + message.index !== undefined && (obj.index = (message.index || Long.ZERO).toString()); + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.value !== undefined && + (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + message.proofOps !== undefined && + (obj.proofOps = message.proofOps ? ProofOps.toJSON(message.proofOps) : undefined); + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + message.codespace !== undefined && (obj.codespace = message.codespace); + return obj; + }, + fromPartial(object: DeepPartial): ResponseQuery { const message = { ...baseResponseQuery } as ResponseQuery; if (object.code !== undefined && object.code !== null) { @@ -2866,23 +2971,6 @@ export const ResponseQuery = { } return message; }, - - toJSON(message: ResponseQuery): unknown { - const obj: any = {}; - message.code !== undefined && (obj.code = message.code); - message.log !== undefined && (obj.log = message.log); - message.info !== undefined && (obj.info = message.info); - message.index !== undefined && (obj.index = (message.index || Long.ZERO).toString()); - message.key !== undefined && - (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); - message.value !== undefined && - (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); - message.proofOps !== undefined && - (obj.proofOps = message.proofOps ? ProofOps.toJSON(message.proofOps) : undefined); - message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); - message.codespace !== undefined && (obj.codespace = message.codespace); - return obj; - }, }; const baseResponseBeginBlock: object = {}; @@ -2925,6 +3013,16 @@ export const ResponseBeginBlock = { return message; }, + toJSON(message: ResponseBeginBlock): unknown { + const obj: any = {}; + if (message.events) { + obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); + } else { + obj.events = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ResponseBeginBlock { const message = { ...baseResponseBeginBlock } as ResponseBeginBlock; message.events = []; @@ -2935,16 +3033,6 @@ export const ResponseBeginBlock = { } return message; }, - - toJSON(message: ResponseBeginBlock): unknown { - const obj: any = {}; - if (message.events) { - obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); - } else { - obj.events = []; - } - return obj; - }, }; const baseResponseCheckTx: object = { @@ -2958,16 +3046,30 @@ const baseResponseCheckTx: object = { export const ResponseCheckTx = { encode(message: ResponseCheckTx, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint32(message.code); - writer.uint32(18).bytes(message.data); - writer.uint32(26).string(message.log); - writer.uint32(34).string(message.info); - writer.uint32(40).int64(message.gasWanted); - writer.uint32(48).int64(message.gasUsed); + if (message.code !== 0) { + writer.uint32(8).uint32(message.code); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + if (message.log !== "") { + writer.uint32(26).string(message.log); + } + if (message.info !== "") { + writer.uint32(34).string(message.info); + } + if (!message.gasWanted.isZero()) { + writer.uint32(40).int64(message.gasWanted); + } + if (!message.gasUsed.isZero()) { + writer.uint32(48).int64(message.gasUsed); + } for (const v of message.events) { Event.encode(v!, writer.uint32(58).fork()).ldelim(); } - writer.uint32(66).string(message.codespace); + if (message.codespace !== "") { + writer.uint32(66).string(message.codespace); + } return writer; }, @@ -3055,6 +3157,24 @@ export const ResponseCheckTx = { return message; }, + toJSON(message: ResponseCheckTx): unknown { + const obj: any = {}; + message.code !== undefined && (obj.code = message.code); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + message.log !== undefined && (obj.log = message.log); + message.info !== undefined && (obj.info = message.info); + message.gasWanted !== undefined && (obj.gasWanted = (message.gasWanted || Long.ZERO).toString()); + message.gasUsed !== undefined && (obj.gasUsed = (message.gasUsed || Long.ZERO).toString()); + if (message.events) { + obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); + } else { + obj.events = []; + } + message.codespace !== undefined && (obj.codespace = message.codespace); + return obj; + }, + fromPartial(object: DeepPartial): ResponseCheckTx { const message = { ...baseResponseCheckTx } as ResponseCheckTx; message.events = []; @@ -3100,24 +3220,6 @@ export const ResponseCheckTx = { } return message; }, - - toJSON(message: ResponseCheckTx): unknown { - const obj: any = {}; - message.code !== undefined && (obj.code = message.code); - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); - message.log !== undefined && (obj.log = message.log); - message.info !== undefined && (obj.info = message.info); - message.gasWanted !== undefined && (obj.gasWanted = (message.gasWanted || Long.ZERO).toString()); - message.gasUsed !== undefined && (obj.gasUsed = (message.gasUsed || Long.ZERO).toString()); - if (message.events) { - obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); - } else { - obj.events = []; - } - message.codespace !== undefined && (obj.codespace = message.codespace); - return obj; - }, }; const baseResponseDeliverTx: object = { @@ -3131,16 +3233,30 @@ const baseResponseDeliverTx: object = { export const ResponseDeliverTx = { encode(message: ResponseDeliverTx, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint32(message.code); - writer.uint32(18).bytes(message.data); - writer.uint32(26).string(message.log); - writer.uint32(34).string(message.info); - writer.uint32(40).int64(message.gasWanted); - writer.uint32(48).int64(message.gasUsed); + if (message.code !== 0) { + writer.uint32(8).uint32(message.code); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + if (message.log !== "") { + writer.uint32(26).string(message.log); + } + if (message.info !== "") { + writer.uint32(34).string(message.info); + } + if (!message.gasWanted.isZero()) { + writer.uint32(40).int64(message.gasWanted); + } + if (!message.gasUsed.isZero()) { + writer.uint32(48).int64(message.gasUsed); + } for (const v of message.events) { Event.encode(v!, writer.uint32(58).fork()).ldelim(); } - writer.uint32(66).string(message.codespace); + if (message.codespace !== "") { + writer.uint32(66).string(message.codespace); + } return writer; }, @@ -3228,6 +3344,24 @@ export const ResponseDeliverTx = { return message; }, + toJSON(message: ResponseDeliverTx): unknown { + const obj: any = {}; + message.code !== undefined && (obj.code = message.code); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + message.log !== undefined && (obj.log = message.log); + message.info !== undefined && (obj.info = message.info); + message.gasWanted !== undefined && (obj.gasWanted = (message.gasWanted || Long.ZERO).toString()); + message.gasUsed !== undefined && (obj.gasUsed = (message.gasUsed || Long.ZERO).toString()); + if (message.events) { + obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); + } else { + obj.events = []; + } + message.codespace !== undefined && (obj.codespace = message.codespace); + return obj; + }, + fromPartial(object: DeepPartial): ResponseDeliverTx { const message = { ...baseResponseDeliverTx } as ResponseDeliverTx; message.events = []; @@ -3273,24 +3407,6 @@ export const ResponseDeliverTx = { } return message; }, - - toJSON(message: ResponseDeliverTx): unknown { - const obj: any = {}; - message.code !== undefined && (obj.code = message.code); - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); - message.log !== undefined && (obj.log = message.log); - message.info !== undefined && (obj.info = message.info); - message.gasWanted !== undefined && (obj.gasWanted = (message.gasWanted || Long.ZERO).toString()); - message.gasUsed !== undefined && (obj.gasUsed = (message.gasUsed || Long.ZERO).toString()); - if (message.events) { - obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); - } else { - obj.events = []; - } - message.codespace !== undefined && (obj.codespace = message.codespace); - return obj; - }, }; const baseResponseEndBlock: object = {}; @@ -3300,7 +3416,7 @@ export const ResponseEndBlock = { for (const v of message.validatorUpdates) { ValidatorUpdate.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.consensusParamUpdates !== undefined && message.consensusParamUpdates !== undefined) { + if (message.consensusParamUpdates !== undefined) { ConsensusParams.encode(message.consensusParamUpdates, writer.uint32(18).fork()).ldelim(); } for (const v of message.events) { @@ -3357,6 +3473,25 @@ export const ResponseEndBlock = { return message; }, + toJSON(message: ResponseEndBlock): unknown { + const obj: any = {}; + if (message.validatorUpdates) { + obj.validatorUpdates = message.validatorUpdates.map((e) => (e ? ValidatorUpdate.toJSON(e) : undefined)); + } else { + obj.validatorUpdates = []; + } + message.consensusParamUpdates !== undefined && + (obj.consensusParamUpdates = message.consensusParamUpdates + ? ConsensusParams.toJSON(message.consensusParamUpdates) + : undefined); + if (message.events) { + obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); + } else { + obj.events = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ResponseEndBlock { const message = { ...baseResponseEndBlock } as ResponseEndBlock; message.validatorUpdates = []; @@ -3378,33 +3513,18 @@ export const ResponseEndBlock = { } return message; }, - - toJSON(message: ResponseEndBlock): unknown { - const obj: any = {}; - if (message.validatorUpdates) { - obj.validatorUpdates = message.validatorUpdates.map((e) => (e ? ValidatorUpdate.toJSON(e) : undefined)); - } else { - obj.validatorUpdates = []; - } - message.consensusParamUpdates !== undefined && - (obj.consensusParamUpdates = message.consensusParamUpdates - ? ConsensusParams.toJSON(message.consensusParamUpdates) - : undefined); - if (message.events) { - obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); - } else { - obj.events = []; - } - return obj; - }, }; const baseResponseCommit: object = { retainHeight: Long.ZERO }; export const ResponseCommit = { encode(message: ResponseCommit, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(18).bytes(message.data); - writer.uint32(24).int64(message.retainHeight); + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + if (!message.retainHeight.isZero()) { + writer.uint32(24).int64(message.retainHeight); + } return writer; }, @@ -3442,6 +3562,14 @@ export const ResponseCommit = { return message; }, + toJSON(message: ResponseCommit): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + message.retainHeight !== undefined && (obj.retainHeight = (message.retainHeight || Long.ZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): ResponseCommit { const message = { ...baseResponseCommit } as ResponseCommit; if (object.data !== undefined && object.data !== null) { @@ -3456,14 +3584,6 @@ export const ResponseCommit = { } return message; }, - - toJSON(message: ResponseCommit): unknown { - const obj: any = {}; - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); - message.retainHeight !== undefined && (obj.retainHeight = (message.retainHeight || Long.ZERO).toString()); - return obj; - }, }; const baseResponseListSnapshots: object = {}; @@ -3506,6 +3626,16 @@ export const ResponseListSnapshots = { return message; }, + toJSON(message: ResponseListSnapshots): unknown { + const obj: any = {}; + if (message.snapshots) { + obj.snapshots = message.snapshots.map((e) => (e ? Snapshot.toJSON(e) : undefined)); + } else { + obj.snapshots = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ResponseListSnapshots { const message = { ...baseResponseListSnapshots } as ResponseListSnapshots; message.snapshots = []; @@ -3516,23 +3646,15 @@ export const ResponseListSnapshots = { } return message; }, - - toJSON(message: ResponseListSnapshots): unknown { - const obj: any = {}; - if (message.snapshots) { - obj.snapshots = message.snapshots.map((e) => (e ? Snapshot.toJSON(e) : undefined)); - } else { - obj.snapshots = []; - } - return obj; - }, }; const baseResponseOfferSnapshot: object = { result: 0 }; export const ResponseOfferSnapshot = { encode(message: ResponseOfferSnapshot, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.result); + if (message.result !== 0) { + writer.uint32(8).int32(message.result); + } return writer; }, @@ -3564,6 +3686,12 @@ export const ResponseOfferSnapshot = { return message; }, + toJSON(message: ResponseOfferSnapshot): unknown { + const obj: any = {}; + message.result !== undefined && (obj.result = responseOfferSnapshot_ResultToJSON(message.result)); + return obj; + }, + fromPartial(object: DeepPartial): ResponseOfferSnapshot { const message = { ...baseResponseOfferSnapshot } as ResponseOfferSnapshot; if (object.result !== undefined && object.result !== null) { @@ -3573,19 +3701,15 @@ export const ResponseOfferSnapshot = { } return message; }, - - toJSON(message: ResponseOfferSnapshot): unknown { - const obj: any = {}; - message.result !== undefined && (obj.result = responseOfferSnapshot_ResultToJSON(message.result)); - return obj; - }, }; const baseResponseLoadSnapshotChunk: object = {}; export const ResponseLoadSnapshotChunk = { encode(message: ResponseLoadSnapshotChunk, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.chunk); + if (message.chunk.length !== 0) { + writer.uint32(10).bytes(message.chunk); + } return writer; }, @@ -3615,6 +3739,13 @@ export const ResponseLoadSnapshotChunk = { return message; }, + toJSON(message: ResponseLoadSnapshotChunk): unknown { + const obj: any = {}; + message.chunk !== undefined && + (obj.chunk = base64FromBytes(message.chunk !== undefined ? message.chunk : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): ResponseLoadSnapshotChunk { const message = { ...baseResponseLoadSnapshotChunk } as ResponseLoadSnapshotChunk; if (object.chunk !== undefined && object.chunk !== null) { @@ -3624,20 +3755,15 @@ export const ResponseLoadSnapshotChunk = { } return message; }, - - toJSON(message: ResponseLoadSnapshotChunk): unknown { - const obj: any = {}; - message.chunk !== undefined && - (obj.chunk = base64FromBytes(message.chunk !== undefined ? message.chunk : new Uint8Array())); - return obj; - }, }; const baseResponseApplySnapshotChunk: object = { result: 0, refetchChunks: 0, rejectSenders: "" }; export const ResponseApplySnapshotChunk = { encode(message: ResponseApplySnapshotChunk, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.result); + if (message.result !== 0) { + writer.uint32(8).int32(message.result); + } writer.uint32(18).fork(); for (const v of message.refetchChunks) { writer.uint32(v); @@ -3704,6 +3830,22 @@ export const ResponseApplySnapshotChunk = { return message; }, + toJSON(message: ResponseApplySnapshotChunk): unknown { + const obj: any = {}; + message.result !== undefined && (obj.result = responseApplySnapshotChunk_ResultToJSON(message.result)); + if (message.refetchChunks) { + obj.refetchChunks = message.refetchChunks.map((e) => e); + } else { + obj.refetchChunks = []; + } + if (message.rejectSenders) { + obj.rejectSenders = message.rejectSenders.map((e) => e); + } else { + obj.rejectSenders = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ResponseApplySnapshotChunk { const message = { ...baseResponseApplySnapshotChunk } as ResponseApplySnapshotChunk; message.refetchChunks = []; @@ -3725,38 +3867,22 @@ export const ResponseApplySnapshotChunk = { } return message; }, - - toJSON(message: ResponseApplySnapshotChunk): unknown { - const obj: any = {}; - message.result !== undefined && (obj.result = responseApplySnapshotChunk_ResultToJSON(message.result)); - if (message.refetchChunks) { - obj.refetchChunks = message.refetchChunks.map((e) => e); - } else { - obj.refetchChunks = []; - } - if (message.rejectSenders) { - obj.rejectSenders = message.rejectSenders.map((e) => e); - } else { - obj.rejectSenders = []; - } - return obj; - }, }; const baseConsensusParams: object = {}; export const ConsensusParams = { encode(message: ConsensusParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.block !== undefined && message.block !== undefined) { + if (message.block !== undefined) { BlockParams.encode(message.block, writer.uint32(10).fork()).ldelim(); } - if (message.evidence !== undefined && message.evidence !== undefined) { + if (message.evidence !== undefined) { EvidenceParams.encode(message.evidence, writer.uint32(18).fork()).ldelim(); } - if (message.validator !== undefined && message.validator !== undefined) { + if (message.validator !== undefined) { ValidatorParams.encode(message.validator, writer.uint32(26).fork()).ldelim(); } - if (message.version !== undefined && message.version !== undefined) { + if (message.version !== undefined) { VersionParams.encode(message.version, writer.uint32(34).fork()).ldelim(); } return writer; @@ -3814,6 +3940,19 @@ export const ConsensusParams = { return message; }, + toJSON(message: ConsensusParams): unknown { + const obj: any = {}; + message.block !== undefined && + (obj.block = message.block ? BlockParams.toJSON(message.block) : undefined); + message.evidence !== undefined && + (obj.evidence = message.evidence ? EvidenceParams.toJSON(message.evidence) : undefined); + message.validator !== undefined && + (obj.validator = message.validator ? ValidatorParams.toJSON(message.validator) : undefined); + message.version !== undefined && + (obj.version = message.version ? VersionParams.toJSON(message.version) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ConsensusParams { const message = { ...baseConsensusParams } as ConsensusParams; if (object.block !== undefined && object.block !== null) { @@ -3838,27 +3977,18 @@ export const ConsensusParams = { } return message; }, - - toJSON(message: ConsensusParams): unknown { - const obj: any = {}; - message.block !== undefined && - (obj.block = message.block ? BlockParams.toJSON(message.block) : undefined); - message.evidence !== undefined && - (obj.evidence = message.evidence ? EvidenceParams.toJSON(message.evidence) : undefined); - message.validator !== undefined && - (obj.validator = message.validator ? ValidatorParams.toJSON(message.validator) : undefined); - message.version !== undefined && - (obj.version = message.version ? VersionParams.toJSON(message.version) : undefined); - return obj; - }, }; const baseBlockParams: object = { maxBytes: Long.ZERO, maxGas: Long.ZERO }; export const BlockParams = { encode(message: BlockParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int64(message.maxBytes); - writer.uint32(16).int64(message.maxGas); + if (!message.maxBytes.isZero()) { + writer.uint32(8).int64(message.maxBytes); + } + if (!message.maxGas.isZero()) { + writer.uint32(16).int64(message.maxGas); + } return writer; }, @@ -3898,6 +4028,13 @@ export const BlockParams = { return message; }, + toJSON(message: BlockParams): unknown { + const obj: any = {}; + message.maxBytes !== undefined && (obj.maxBytes = (message.maxBytes || Long.ZERO).toString()); + message.maxGas !== undefined && (obj.maxGas = (message.maxGas || Long.ZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): BlockParams { const message = { ...baseBlockParams } as BlockParams; if (object.maxBytes !== undefined && object.maxBytes !== null) { @@ -3912,20 +4049,15 @@ export const BlockParams = { } return message; }, - - toJSON(message: BlockParams): unknown { - const obj: any = {}; - message.maxBytes !== undefined && (obj.maxBytes = (message.maxBytes || Long.ZERO).toString()); - message.maxGas !== undefined && (obj.maxGas = (message.maxGas || Long.ZERO).toString()); - return obj; - }, }; const baseLastCommitInfo: object = { round: 0 }; export const LastCommitInfo = { encode(message: LastCommitInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.round); + if (message.round !== 0) { + writer.uint32(8).int32(message.round); + } for (const v of message.votes) { VoteInfo.encode(v!, writer.uint32(18).fork()).ldelim(); } @@ -3970,6 +4102,17 @@ export const LastCommitInfo = { return message; }, + toJSON(message: LastCommitInfo): unknown { + const obj: any = {}; + message.round !== undefined && (obj.round = message.round); + if (message.votes) { + obj.votes = message.votes.map((e) => (e ? VoteInfo.toJSON(e) : undefined)); + } else { + obj.votes = []; + } + return obj; + }, + fromPartial(object: DeepPartial): LastCommitInfo { const message = { ...baseLastCommitInfo } as LastCommitInfo; message.votes = []; @@ -3985,24 +4128,15 @@ export const LastCommitInfo = { } return message; }, - - toJSON(message: LastCommitInfo): unknown { - const obj: any = {}; - message.round !== undefined && (obj.round = message.round); - if (message.votes) { - obj.votes = message.votes.map((e) => (e ? VoteInfo.toJSON(e) : undefined)); - } else { - obj.votes = []; - } - return obj; - }, }; const baseEvent: object = { type: "" }; export const Event = { encode(message: Event, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.type); + if (message.type !== "") { + writer.uint32(10).string(message.type); + } for (const v of message.attributes) { EventAttribute.encode(v!, writer.uint32(18).fork()).ldelim(); } @@ -4047,6 +4181,17 @@ export const Event = { return message; }, + toJSON(message: Event): unknown { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + if (message.attributes) { + obj.attributes = message.attributes.map((e) => (e ? EventAttribute.toJSON(e) : undefined)); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Event { const message = { ...baseEvent } as Event; message.attributes = []; @@ -4062,26 +4207,21 @@ export const Event = { } return message; }, - - toJSON(message: Event): unknown { - const obj: any = {}; - message.type !== undefined && (obj.type = message.type); - if (message.attributes) { - obj.attributes = message.attributes.map((e) => (e ? EventAttribute.toJSON(e) : undefined)); - } else { - obj.attributes = []; - } - return obj; - }, }; const baseEventAttribute: object = { index: false }; export const EventAttribute = { encode(message: EventAttribute, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.key); - writer.uint32(18).bytes(message.value); - writer.uint32(24).bool(message.index); + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + if (message.index === true) { + writer.uint32(24).bool(message.index); + } return writer; }, @@ -4125,6 +4265,16 @@ export const EventAttribute = { return message; }, + toJSON(message: EventAttribute): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.value !== undefined && + (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + message.index !== undefined && (obj.index = message.index); + return obj; + }, + fromPartial(object: DeepPartial): EventAttribute { const message = { ...baseEventAttribute } as EventAttribute; if (object.key !== undefined && object.key !== null) { @@ -4144,26 +4294,22 @@ export const EventAttribute = { } return message; }, - - toJSON(message: EventAttribute): unknown { - const obj: any = {}; - message.key !== undefined && - (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); - message.value !== undefined && - (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); - message.index !== undefined && (obj.index = message.index); - return obj; - }, }; const baseTxResult: object = { height: Long.ZERO, index: 0 }; export const TxResult = { encode(message: TxResult, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int64(message.height); - writer.uint32(16).uint32(message.index); - writer.uint32(26).bytes(message.tx); - if (message.result !== undefined && message.result !== undefined) { + if (!message.height.isZero()) { + writer.uint32(8).int64(message.height); + } + if (message.index !== 0) { + writer.uint32(16).uint32(message.index); + } + if (message.tx.length !== 0) { + writer.uint32(26).bytes(message.tx); + } + if (message.result !== undefined) { ResponseDeliverTx.encode(message.result, writer.uint32(34).fork()).ldelim(); } return writer; @@ -4219,6 +4365,17 @@ export const TxResult = { return message; }, + toJSON(message: TxResult): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + message.index !== undefined && (obj.index = message.index); + message.tx !== undefined && + (obj.tx = base64FromBytes(message.tx !== undefined ? message.tx : new Uint8Array())); + message.result !== undefined && + (obj.result = message.result ? ResponseDeliverTx.toJSON(message.result) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): TxResult { const message = { ...baseTxResult } as TxResult; if (object.height !== undefined && object.height !== null) { @@ -4243,25 +4400,18 @@ export const TxResult = { } return message; }, - - toJSON(message: TxResult): unknown { - const obj: any = {}; - message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); - message.index !== undefined && (obj.index = message.index); - message.tx !== undefined && - (obj.tx = base64FromBytes(message.tx !== undefined ? message.tx : new Uint8Array())); - message.result !== undefined && - (obj.result = message.result ? ResponseDeliverTx.toJSON(message.result) : undefined); - return obj; - }, }; const baseValidator: object = { power: Long.ZERO }; export const Validator = { encode(message: Validator, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.address); - writer.uint32(24).int64(message.power); + if (message.address.length !== 0) { + writer.uint32(10).bytes(message.address); + } + if (!message.power.isZero()) { + writer.uint32(24).int64(message.power); + } return writer; }, @@ -4299,6 +4449,14 @@ export const Validator = { return message; }, + toJSON(message: Validator): unknown { + const obj: any = {}; + message.address !== undefined && + (obj.address = base64FromBytes(message.address !== undefined ? message.address : new Uint8Array())); + message.power !== undefined && (obj.power = (message.power || Long.ZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): Validator { const message = { ...baseValidator } as Validator; if (object.address !== undefined && object.address !== null) { @@ -4313,24 +4471,18 @@ export const Validator = { } return message; }, - - toJSON(message: Validator): unknown { - const obj: any = {}; - message.address !== undefined && - (obj.address = base64FromBytes(message.address !== undefined ? message.address : new Uint8Array())); - message.power !== undefined && (obj.power = (message.power || Long.ZERO).toString()); - return obj; - }, }; const baseValidatorUpdate: object = { power: Long.ZERO }; export const ValidatorUpdate = { encode(message: ValidatorUpdate, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.pubKey !== undefined && message.pubKey !== undefined) { + if (message.pubKey !== undefined) { PublicKey.encode(message.pubKey, writer.uint32(10).fork()).ldelim(); } - writer.uint32(16).int64(message.power); + if (!message.power.isZero()) { + writer.uint32(16).int64(message.power); + } return writer; }, @@ -4370,6 +4522,14 @@ export const ValidatorUpdate = { return message; }, + toJSON(message: ValidatorUpdate): unknown { + const obj: any = {}; + message.pubKey !== undefined && + (obj.pubKey = message.pubKey ? PublicKey.toJSON(message.pubKey) : undefined); + message.power !== undefined && (obj.power = (message.power || Long.ZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): ValidatorUpdate { const message = { ...baseValidatorUpdate } as ValidatorUpdate; if (object.pubKey !== undefined && object.pubKey !== null) { @@ -4384,24 +4544,18 @@ export const ValidatorUpdate = { } return message; }, - - toJSON(message: ValidatorUpdate): unknown { - const obj: any = {}; - message.pubKey !== undefined && - (obj.pubKey = message.pubKey ? PublicKey.toJSON(message.pubKey) : undefined); - message.power !== undefined && (obj.power = (message.power || Long.ZERO).toString()); - return obj; - }, }; const baseVoteInfo: object = { signedLastBlock: false }; export const VoteInfo = { encode(message: VoteInfo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.validator !== undefined && message.validator !== undefined) { + if (message.validator !== undefined) { Validator.encode(message.validator, writer.uint32(10).fork()).ldelim(); } - writer.uint32(16).bool(message.signedLastBlock); + if (message.signedLastBlock === true) { + writer.uint32(16).bool(message.signedLastBlock); + } return writer; }, @@ -4441,6 +4595,14 @@ export const VoteInfo = { return message; }, + toJSON(message: VoteInfo): unknown { + const obj: any = {}; + message.validator !== undefined && + (obj.validator = message.validator ? Validator.toJSON(message.validator) : undefined); + message.signedLastBlock !== undefined && (obj.signedLastBlock = message.signedLastBlock); + return obj; + }, + fromPartial(object: DeepPartial): VoteInfo { const message = { ...baseVoteInfo } as VoteInfo; if (object.validator !== undefined && object.validator !== null) { @@ -4455,29 +4617,27 @@ export const VoteInfo = { } return message; }, - - toJSON(message: VoteInfo): unknown { - const obj: any = {}; - message.validator !== undefined && - (obj.validator = message.validator ? Validator.toJSON(message.validator) : undefined); - message.signedLastBlock !== undefined && (obj.signedLastBlock = message.signedLastBlock); - return obj; - }, }; const baseEvidence: object = { type: 0, height: Long.ZERO, totalVotingPower: Long.ZERO }; export const Evidence = { encode(message: Evidence, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.type); - if (message.validator !== undefined && message.validator !== undefined) { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (message.validator !== undefined) { Validator.encode(message.validator, writer.uint32(18).fork()).ldelim(); } - writer.uint32(24).int64(message.height); - if (message.time !== undefined && message.time !== undefined) { + if (!message.height.isZero()) { + writer.uint32(24).int64(message.height); + } + if (message.time !== undefined) { Timestamp.encode(toTimestamp(message.time), writer.uint32(34).fork()).ldelim(); } - writer.uint32(40).int64(message.totalVotingPower); + if (!message.totalVotingPower.isZero()) { + writer.uint32(40).int64(message.totalVotingPower); + } return writer; }, @@ -4541,6 +4701,18 @@ export const Evidence = { return message; }, + toJSON(message: Evidence): unknown { + const obj: any = {}; + message.type !== undefined && (obj.type = evidenceTypeToJSON(message.type)); + message.validator !== undefined && + (obj.validator = message.validator ? Validator.toJSON(message.validator) : undefined); + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + message.time !== undefined && (obj.time = message.time !== undefined ? message.time.toISOString() : null); + message.totalVotingPower !== undefined && + (obj.totalVotingPower = (message.totalVotingPower || Long.ZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): Evidence { const message = { ...baseEvidence } as Evidence; if (object.type !== undefined && object.type !== null) { @@ -4570,29 +4742,27 @@ export const Evidence = { } return message; }, - - toJSON(message: Evidence): unknown { - const obj: any = {}; - message.type !== undefined && (obj.type = evidenceTypeToJSON(message.type)); - message.validator !== undefined && - (obj.validator = message.validator ? Validator.toJSON(message.validator) : undefined); - message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); - message.time !== undefined && (obj.time = message.time !== undefined ? message.time.toISOString() : null); - message.totalVotingPower !== undefined && - (obj.totalVotingPower = (message.totalVotingPower || Long.ZERO).toString()); - return obj; - }, }; const baseSnapshot: object = { height: Long.UZERO, format: 0, chunks: 0 }; export const Snapshot = { encode(message: Snapshot, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.height); - writer.uint32(16).uint32(message.format); - writer.uint32(24).uint32(message.chunks); - writer.uint32(34).bytes(message.hash); - writer.uint32(42).bytes(message.metadata); + if (!message.height.isZero()) { + writer.uint32(8).uint64(message.height); + } + if (message.format !== 0) { + writer.uint32(16).uint32(message.format); + } + if (message.chunks !== 0) { + writer.uint32(24).uint32(message.chunks); + } + if (message.hash.length !== 0) { + writer.uint32(34).bytes(message.hash); + } + if (message.metadata.length !== 0) { + writer.uint32(42).bytes(message.metadata); + } return writer; }, @@ -4652,6 +4822,18 @@ export const Snapshot = { return message; }, + toJSON(message: Snapshot): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.UZERO).toString()); + message.format !== undefined && (obj.format = message.format); + message.chunks !== undefined && (obj.chunks = message.chunks); + message.hash !== undefined && + (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); + message.metadata !== undefined && + (obj.metadata = base64FromBytes(message.metadata !== undefined ? message.metadata : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): Snapshot { const message = { ...baseSnapshot } as Snapshot; if (object.height !== undefined && object.height !== null) { @@ -4681,18 +4863,6 @@ export const Snapshot = { } return message; }, - - toJSON(message: Snapshot): unknown { - const obj: any = {}; - message.height !== undefined && (obj.height = (message.height || Long.UZERO).toString()); - message.format !== undefined && (obj.format = message.format); - message.chunks !== undefined && (obj.chunks = message.chunks); - message.hash !== undefined && - (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); - message.metadata !== undefined && - (obj.metadata = base64FromBytes(message.metadata !== undefined ? message.metadata : new Uint8Array())); - return obj; - }, }; export interface ABCIApplication { @@ -4820,7 +4990,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/stargate/src/codec/tendermint/crypto/keys.ts b/packages/stargate/src/codec/tendermint/crypto/keys.ts index 1a99790b..c0c2302f 100644 --- a/packages/stargate/src/codec/tendermint/crypto/keys.ts +++ b/packages/stargate/src/codec/tendermint/crypto/keys.ts @@ -55,6 +55,15 @@ export const PublicKey = { return message; }, + toJSON(message: PublicKey): unknown { + const obj: any = {}; + message.ed25519 !== undefined && + (obj.ed25519 = message.ed25519 !== undefined ? base64FromBytes(message.ed25519) : undefined); + message.secp256k1 !== undefined && + (obj.secp256k1 = message.secp256k1 !== undefined ? base64FromBytes(message.secp256k1) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): PublicKey { const message = { ...basePublicKey } as PublicKey; if (object.ed25519 !== undefined && object.ed25519 !== null) { @@ -69,15 +78,6 @@ export const PublicKey = { } return message; }, - - toJSON(message: PublicKey): unknown { - const obj: any = {}; - message.ed25519 !== undefined && - (obj.ed25519 = message.ed25519 !== undefined ? base64FromBytes(message.ed25519) : undefined); - message.secp256k1 !== undefined && - (obj.secp256k1 = message.secp256k1 !== undefined ? base64FromBytes(message.secp256k1) : undefined); - return obj; - }, }; declare var self: any | undefined; @@ -87,7 +87,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/stargate/src/codec/tendermint/crypto/proof.ts b/packages/stargate/src/codec/tendermint/crypto/proof.ts index e3c07856..c58f3341 100644 --- a/packages/stargate/src/codec/tendermint/crypto/proof.ts +++ b/packages/stargate/src/codec/tendermint/crypto/proof.ts @@ -44,9 +44,15 @@ const baseProof: object = { total: Long.ZERO, index: Long.ZERO }; export const Proof = { encode(message: Proof, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int64(message.total); - writer.uint32(16).int64(message.index); - writer.uint32(26).bytes(message.leafHash); + if (!message.total.isZero()) { + writer.uint32(8).int64(message.total); + } + if (!message.index.isZero()) { + writer.uint32(16).int64(message.index); + } + if (message.leafHash.length !== 0) { + writer.uint32(26).bytes(message.leafHash); + } for (const v of message.aunts) { writer.uint32(34).bytes(v!); } @@ -105,6 +111,20 @@ export const Proof = { return message; }, + toJSON(message: Proof): unknown { + const obj: any = {}; + message.total !== undefined && (obj.total = (message.total || Long.ZERO).toString()); + message.index !== undefined && (obj.index = (message.index || Long.ZERO).toString()); + message.leafHash !== undefined && + (obj.leafHash = base64FromBytes(message.leafHash !== undefined ? message.leafHash : new Uint8Array())); + if (message.aunts) { + obj.aunts = message.aunts.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.aunts = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Proof { const message = { ...baseProof } as Proof; message.aunts = []; @@ -130,28 +150,16 @@ export const Proof = { } return message; }, - - toJSON(message: Proof): unknown { - const obj: any = {}; - message.total !== undefined && (obj.total = (message.total || Long.ZERO).toString()); - message.index !== undefined && (obj.index = (message.index || Long.ZERO).toString()); - message.leafHash !== undefined && - (obj.leafHash = base64FromBytes(message.leafHash !== undefined ? message.leafHash : new Uint8Array())); - if (message.aunts) { - obj.aunts = message.aunts.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); - } else { - obj.aunts = []; - } - return obj; - }, }; const baseValueOp: object = {}; export const ValueOp = { encode(message: ValueOp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.key); - if (message.proof !== undefined && message.proof !== undefined) { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.proof !== undefined) { Proof.encode(message.proof, writer.uint32(18).fork()).ldelim(); } return writer; @@ -191,6 +199,14 @@ export const ValueOp = { return message; }, + toJSON(message: ValueOp): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.proof !== undefined && (obj.proof = message.proof ? Proof.toJSON(message.proof) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ValueOp { const message = { ...baseValueOp } as ValueOp; if (object.key !== undefined && object.key !== null) { @@ -205,23 +221,21 @@ export const ValueOp = { } return message; }, - - toJSON(message: ValueOp): unknown { - const obj: any = {}; - message.key !== undefined && - (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); - message.proof !== undefined && (obj.proof = message.proof ? Proof.toJSON(message.proof) : undefined); - return obj; - }, }; const baseDominoOp: object = { key: "", input: "", output: "" }; export const DominoOp = { encode(message: DominoOp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.key); - writer.uint32(18).string(message.input); - writer.uint32(26).string(message.output); + if (message.key !== "") { + writer.uint32(10).string(message.key); + } + if (message.input !== "") { + writer.uint32(18).string(message.input); + } + if (message.output !== "") { + writer.uint32(26).string(message.output); + } return writer; }, @@ -269,6 +283,14 @@ export const DominoOp = { return message; }, + toJSON(message: DominoOp): unknown { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.input !== undefined && (obj.input = message.input); + message.output !== undefined && (obj.output = message.output); + return obj; + }, + fromPartial(object: DeepPartial): DominoOp { const message = { ...baseDominoOp } as DominoOp; if (object.key !== undefined && object.key !== null) { @@ -288,23 +310,21 @@ export const DominoOp = { } return message; }, - - toJSON(message: DominoOp): unknown { - const obj: any = {}; - message.key !== undefined && (obj.key = message.key); - message.input !== undefined && (obj.input = message.input); - message.output !== undefined && (obj.output = message.output); - return obj; - }, }; const baseProofOp: object = { type: "" }; export const ProofOp = { encode(message: ProofOp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).string(message.type); - writer.uint32(18).bytes(message.key); - writer.uint32(26).bytes(message.data); + if (message.type !== "") { + writer.uint32(10).string(message.type); + } + if (message.key.length !== 0) { + writer.uint32(18).bytes(message.key); + } + if (message.data.length !== 0) { + writer.uint32(26).bytes(message.data); + } return writer; }, @@ -348,6 +368,16 @@ export const ProofOp = { return message; }, + toJSON(message: ProofOp): unknown { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): ProofOp { const message = { ...baseProofOp } as ProofOp; if (object.type !== undefined && object.type !== null) { @@ -367,16 +397,6 @@ export const ProofOp = { } return message; }, - - toJSON(message: ProofOp): unknown { - const obj: any = {}; - message.type !== undefined && (obj.type = message.type); - message.key !== undefined && - (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); - return obj; - }, }; const baseProofOps: object = {}; @@ -419,6 +439,16 @@ export const ProofOps = { return message; }, + toJSON(message: ProofOps): unknown { + const obj: any = {}; + if (message.ops) { + obj.ops = message.ops.map((e) => (e ? ProofOp.toJSON(e) : undefined)); + } else { + obj.ops = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ProofOps { const message = { ...baseProofOps } as ProofOps; message.ops = []; @@ -429,16 +459,6 @@ export const ProofOps = { } return message; }, - - toJSON(message: ProofOps): unknown { - const obj: any = {}; - if (message.ops) { - obj.ops = message.ops.map((e) => (e ? ProofOp.toJSON(e) : undefined)); - } else { - obj.ops = []; - } - return obj; - }, }; declare var self: any | undefined; @@ -448,7 +468,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/stargate/src/codec/tendermint/libs/bits/types.ts b/packages/stargate/src/codec/tendermint/libs/bits/types.ts index 77a2702c..6b0ed9c1 100644 --- a/packages/stargate/src/codec/tendermint/libs/bits/types.ts +++ b/packages/stargate/src/codec/tendermint/libs/bits/types.ts @@ -13,7 +13,9 @@ const baseBitArray: object = { bits: Long.ZERO, elems: Long.UZERO }; export const BitArray = { encode(message: BitArray, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int64(message.bits); + if (!message.bits.isZero()) { + writer.uint32(8).int64(message.bits); + } writer.uint32(18).fork(); for (const v of message.elems) { writer.uint64(v); @@ -67,6 +69,17 @@ export const BitArray = { return message; }, + toJSON(message: BitArray): unknown { + const obj: any = {}; + message.bits !== undefined && (obj.bits = (message.bits || Long.ZERO).toString()); + if (message.elems) { + obj.elems = message.elems.map((e) => (e || Long.UZERO).toString()); + } else { + obj.elems = []; + } + return obj; + }, + fromPartial(object: DeepPartial): BitArray { const message = { ...baseBitArray } as BitArray; message.elems = []; @@ -82,17 +95,6 @@ export const BitArray = { } return message; }, - - toJSON(message: BitArray): unknown { - const obj: any = {}; - message.bits !== undefined && (obj.bits = (message.bits || Long.ZERO).toString()); - if (message.elems) { - obj.elems = message.elems.map((e) => (e || Long.UZERO).toString()); - } else { - obj.elems = []; - } - return obj; - }, }; type Builtin = Date | Function | Uint8Array | string | number | undefined | Long; diff --git a/packages/stargate/src/codec/tendermint/types/params.ts b/packages/stargate/src/codec/tendermint/types/params.ts index 0f423b93..e8bc7d97 100644 --- a/packages/stargate/src/codec/tendermint/types/params.ts +++ b/packages/stargate/src/codec/tendermint/types/params.ts @@ -89,16 +89,16 @@ const baseConsensusParams: object = {}; export const ConsensusParams = { encode(message: ConsensusParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.block !== undefined && message.block !== undefined) { + if (message.block !== undefined) { BlockParams.encode(message.block, writer.uint32(10).fork()).ldelim(); } - if (message.evidence !== undefined && message.evidence !== undefined) { + if (message.evidence !== undefined) { EvidenceParams.encode(message.evidence, writer.uint32(18).fork()).ldelim(); } - if (message.validator !== undefined && message.validator !== undefined) { + if (message.validator !== undefined) { ValidatorParams.encode(message.validator, writer.uint32(26).fork()).ldelim(); } - if (message.version !== undefined && message.version !== undefined) { + if (message.version !== undefined) { VersionParams.encode(message.version, writer.uint32(34).fork()).ldelim(); } return writer; @@ -156,6 +156,19 @@ export const ConsensusParams = { return message; }, + toJSON(message: ConsensusParams): unknown { + const obj: any = {}; + message.block !== undefined && + (obj.block = message.block ? BlockParams.toJSON(message.block) : undefined); + message.evidence !== undefined && + (obj.evidence = message.evidence ? EvidenceParams.toJSON(message.evidence) : undefined); + message.validator !== undefined && + (obj.validator = message.validator ? ValidatorParams.toJSON(message.validator) : undefined); + message.version !== undefined && + (obj.version = message.version ? VersionParams.toJSON(message.version) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ConsensusParams { const message = { ...baseConsensusParams } as ConsensusParams; if (object.block !== undefined && object.block !== null) { @@ -180,28 +193,21 @@ export const ConsensusParams = { } return message; }, - - toJSON(message: ConsensusParams): unknown { - const obj: any = {}; - message.block !== undefined && - (obj.block = message.block ? BlockParams.toJSON(message.block) : undefined); - message.evidence !== undefined && - (obj.evidence = message.evidence ? EvidenceParams.toJSON(message.evidence) : undefined); - message.validator !== undefined && - (obj.validator = message.validator ? ValidatorParams.toJSON(message.validator) : undefined); - message.version !== undefined && - (obj.version = message.version ? VersionParams.toJSON(message.version) : undefined); - return obj; - }, }; const baseBlockParams: object = { maxBytes: Long.ZERO, maxGas: Long.ZERO, timeIotaMs: Long.ZERO }; export const BlockParams = { encode(message: BlockParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int64(message.maxBytes); - writer.uint32(16).int64(message.maxGas); - writer.uint32(24).int64(message.timeIotaMs); + if (!message.maxBytes.isZero()) { + writer.uint32(8).int64(message.maxBytes); + } + if (!message.maxGas.isZero()) { + writer.uint32(16).int64(message.maxGas); + } + if (!message.timeIotaMs.isZero()) { + writer.uint32(24).int64(message.timeIotaMs); + } return writer; }, @@ -249,6 +255,14 @@ export const BlockParams = { return message; }, + toJSON(message: BlockParams): unknown { + const obj: any = {}; + message.maxBytes !== undefined && (obj.maxBytes = (message.maxBytes || Long.ZERO).toString()); + message.maxGas !== undefined && (obj.maxGas = (message.maxGas || Long.ZERO).toString()); + message.timeIotaMs !== undefined && (obj.timeIotaMs = (message.timeIotaMs || Long.ZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): BlockParams { const message = { ...baseBlockParams } as BlockParams; if (object.maxBytes !== undefined && object.maxBytes !== null) { @@ -268,25 +282,21 @@ export const BlockParams = { } return message; }, - - toJSON(message: BlockParams): unknown { - const obj: any = {}; - message.maxBytes !== undefined && (obj.maxBytes = (message.maxBytes || Long.ZERO).toString()); - message.maxGas !== undefined && (obj.maxGas = (message.maxGas || Long.ZERO).toString()); - message.timeIotaMs !== undefined && (obj.timeIotaMs = (message.timeIotaMs || Long.ZERO).toString()); - return obj; - }, }; const baseEvidenceParams: object = { maxAgeNumBlocks: Long.ZERO, maxBytes: Long.ZERO }; export const EvidenceParams = { encode(message: EvidenceParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int64(message.maxAgeNumBlocks); - if (message.maxAgeDuration !== undefined && message.maxAgeDuration !== undefined) { + if (!message.maxAgeNumBlocks.isZero()) { + writer.uint32(8).int64(message.maxAgeNumBlocks); + } + if (message.maxAgeDuration !== undefined) { Duration.encode(message.maxAgeDuration, writer.uint32(18).fork()).ldelim(); } - writer.uint32(24).int64(message.maxBytes); + if (!message.maxBytes.isZero()) { + writer.uint32(24).int64(message.maxBytes); + } return writer; }, @@ -334,6 +344,16 @@ export const EvidenceParams = { return message; }, + toJSON(message: EvidenceParams): unknown { + const obj: any = {}; + message.maxAgeNumBlocks !== undefined && + (obj.maxAgeNumBlocks = (message.maxAgeNumBlocks || Long.ZERO).toString()); + message.maxAgeDuration !== undefined && + (obj.maxAgeDuration = message.maxAgeDuration ? Duration.toJSON(message.maxAgeDuration) : undefined); + message.maxBytes !== undefined && (obj.maxBytes = (message.maxBytes || Long.ZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): EvidenceParams { const message = { ...baseEvidenceParams } as EvidenceParams; if (object.maxAgeNumBlocks !== undefined && object.maxAgeNumBlocks !== null) { @@ -353,16 +373,6 @@ export const EvidenceParams = { } return message; }, - - toJSON(message: EvidenceParams): unknown { - const obj: any = {}; - message.maxAgeNumBlocks !== undefined && - (obj.maxAgeNumBlocks = (message.maxAgeNumBlocks || Long.ZERO).toString()); - message.maxAgeDuration !== undefined && - (obj.maxAgeDuration = message.maxAgeDuration ? Duration.toJSON(message.maxAgeDuration) : undefined); - message.maxBytes !== undefined && (obj.maxBytes = (message.maxBytes || Long.ZERO).toString()); - return obj; - }, }; const baseValidatorParams: object = { pubKeyTypes: "" }; @@ -405,6 +415,16 @@ export const ValidatorParams = { return message; }, + toJSON(message: ValidatorParams): unknown { + const obj: any = {}; + if (message.pubKeyTypes) { + obj.pubKeyTypes = message.pubKeyTypes.map((e) => e); + } else { + obj.pubKeyTypes = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ValidatorParams { const message = { ...baseValidatorParams } as ValidatorParams; message.pubKeyTypes = []; @@ -415,23 +435,15 @@ export const ValidatorParams = { } return message; }, - - toJSON(message: ValidatorParams): unknown { - const obj: any = {}; - if (message.pubKeyTypes) { - obj.pubKeyTypes = message.pubKeyTypes.map((e) => e); - } else { - obj.pubKeyTypes = []; - } - return obj; - }, }; const baseVersionParams: object = { appVersion: Long.UZERO }; export const VersionParams = { encode(message: VersionParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.appVersion); + if (!message.appVersion.isZero()) { + writer.uint32(8).uint64(message.appVersion); + } return writer; }, @@ -463,6 +475,12 @@ export const VersionParams = { return message; }, + toJSON(message: VersionParams): unknown { + const obj: any = {}; + message.appVersion !== undefined && (obj.appVersion = (message.appVersion || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): VersionParams { const message = { ...baseVersionParams } as VersionParams; if (object.appVersion !== undefined && object.appVersion !== null) { @@ -472,20 +490,18 @@ export const VersionParams = { } return message; }, - - toJSON(message: VersionParams): unknown { - const obj: any = {}; - message.appVersion !== undefined && (obj.appVersion = (message.appVersion || Long.UZERO).toString()); - return obj; - }, }; const baseHashedParams: object = { blockMaxBytes: Long.ZERO, blockMaxGas: Long.ZERO }; export const HashedParams = { encode(message: HashedParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int64(message.blockMaxBytes); - writer.uint32(16).int64(message.blockMaxGas); + if (!message.blockMaxBytes.isZero()) { + writer.uint32(8).int64(message.blockMaxBytes); + } + if (!message.blockMaxGas.isZero()) { + writer.uint32(16).int64(message.blockMaxGas); + } return writer; }, @@ -525,6 +541,14 @@ export const HashedParams = { return message; }, + toJSON(message: HashedParams): unknown { + const obj: any = {}; + message.blockMaxBytes !== undefined && + (obj.blockMaxBytes = (message.blockMaxBytes || Long.ZERO).toString()); + message.blockMaxGas !== undefined && (obj.blockMaxGas = (message.blockMaxGas || Long.ZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): HashedParams { const message = { ...baseHashedParams } as HashedParams; if (object.blockMaxBytes !== undefined && object.blockMaxBytes !== null) { @@ -539,14 +563,6 @@ export const HashedParams = { } return message; }, - - toJSON(message: HashedParams): unknown { - const obj: any = {}; - message.blockMaxBytes !== undefined && - (obj.blockMaxBytes = (message.blockMaxBytes || Long.ZERO).toString()); - message.blockMaxGas !== undefined && (obj.blockMaxGas = (message.blockMaxGas || Long.ZERO).toString()); - return obj; - }, }; type Builtin = Date | Function | Uint8Array | string | number | undefined | Long; diff --git a/packages/stargate/src/codec/tendermint/types/types.ts b/packages/stargate/src/codec/tendermint/types/types.ts index 6bb1fc80..fa2ff7b2 100644 --- a/packages/stargate/src/codec/tendermint/types/types.ts +++ b/packages/stargate/src/codec/tendermint/types/types.ts @@ -227,8 +227,12 @@ const basePartSetHeader: object = { total: 0 }; export const PartSetHeader = { encode(message: PartSetHeader, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint32(message.total); - writer.uint32(18).bytes(message.hash); + if (message.total !== 0) { + writer.uint32(8).uint32(message.total); + } + if (message.hash.length !== 0) { + writer.uint32(18).bytes(message.hash); + } return writer; }, @@ -266,6 +270,14 @@ export const PartSetHeader = { return message; }, + toJSON(message: PartSetHeader): unknown { + const obj: any = {}; + message.total !== undefined && (obj.total = message.total); + message.hash !== undefined && + (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): PartSetHeader { const message = { ...basePartSetHeader } as PartSetHeader; if (object.total !== undefined && object.total !== null) { @@ -280,23 +292,19 @@ export const PartSetHeader = { } return message; }, - - toJSON(message: PartSetHeader): unknown { - const obj: any = {}; - message.total !== undefined && (obj.total = message.total); - message.hash !== undefined && - (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); - return obj; - }, }; const basePart: object = { index: 0 }; export const Part = { encode(message: Part, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint32(message.index); - writer.uint32(18).bytes(message.bytes); - if (message.proof !== undefined && message.proof !== undefined) { + if (message.index !== 0) { + writer.uint32(8).uint32(message.index); + } + if (message.bytes.length !== 0) { + writer.uint32(18).bytes(message.bytes); + } + if (message.proof !== undefined) { Proof.encode(message.proof, writer.uint32(26).fork()).ldelim(); } return writer; @@ -344,6 +352,15 @@ export const Part = { return message; }, + toJSON(message: Part): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = message.index); + message.bytes !== undefined && + (obj.bytes = base64FromBytes(message.bytes !== undefined ? message.bytes : new Uint8Array())); + message.proof !== undefined && (obj.proof = message.proof ? Proof.toJSON(message.proof) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Part { const message = { ...basePart } as Part; if (object.index !== undefined && object.index !== null) { @@ -363,23 +380,16 @@ export const Part = { } return message; }, - - toJSON(message: Part): unknown { - const obj: any = {}; - message.index !== undefined && (obj.index = message.index); - message.bytes !== undefined && - (obj.bytes = base64FromBytes(message.bytes !== undefined ? message.bytes : new Uint8Array())); - message.proof !== undefined && (obj.proof = message.proof ? Proof.toJSON(message.proof) : undefined); - return obj; - }, }; const baseBlockID: object = {}; export const BlockID = { encode(message: BlockID, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.hash); - if (message.partSetHeader !== undefined && message.partSetHeader !== undefined) { + if (message.hash.length !== 0) { + writer.uint32(10).bytes(message.hash); + } + if (message.partSetHeader !== undefined) { PartSetHeader.encode(message.partSetHeader, writer.uint32(18).fork()).ldelim(); } return writer; @@ -419,6 +429,15 @@ export const BlockID = { return message; }, + toJSON(message: BlockID): unknown { + const obj: any = {}; + message.hash !== undefined && + (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); + message.partSetHeader !== undefined && + (obj.partSetHeader = message.partSetHeader ? PartSetHeader.toJSON(message.partSetHeader) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): BlockID { const message = { ...baseBlockID } as BlockID; if (object.hash !== undefined && object.hash !== null) { @@ -433,41 +452,54 @@ export const BlockID = { } return message; }, - - toJSON(message: BlockID): unknown { - const obj: any = {}; - message.hash !== undefined && - (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); - message.partSetHeader !== undefined && - (obj.partSetHeader = message.partSetHeader ? PartSetHeader.toJSON(message.partSetHeader) : undefined); - return obj; - }, }; const baseHeader: object = { chainId: "", height: Long.ZERO }; export const Header = { encode(message: Header, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.version !== undefined && message.version !== undefined) { + if (message.version !== undefined) { Consensus.encode(message.version, writer.uint32(10).fork()).ldelim(); } - writer.uint32(18).string(message.chainId); - writer.uint32(24).int64(message.height); - if (message.time !== undefined && message.time !== undefined) { + if (message.chainId !== "") { + writer.uint32(18).string(message.chainId); + } + if (!message.height.isZero()) { + writer.uint32(24).int64(message.height); + } + if (message.time !== undefined) { Timestamp.encode(toTimestamp(message.time), writer.uint32(34).fork()).ldelim(); } - if (message.lastBlockId !== undefined && message.lastBlockId !== undefined) { + if (message.lastBlockId !== undefined) { BlockID.encode(message.lastBlockId, writer.uint32(42).fork()).ldelim(); } - writer.uint32(50).bytes(message.lastCommitHash); - writer.uint32(58).bytes(message.dataHash); - writer.uint32(66).bytes(message.validatorsHash); - writer.uint32(74).bytes(message.nextValidatorsHash); - writer.uint32(82).bytes(message.consensusHash); - writer.uint32(90).bytes(message.appHash); - writer.uint32(98).bytes(message.lastResultsHash); - writer.uint32(106).bytes(message.evidenceHash); - writer.uint32(114).bytes(message.proposerAddress); + if (message.lastCommitHash.length !== 0) { + writer.uint32(50).bytes(message.lastCommitHash); + } + if (message.dataHash.length !== 0) { + writer.uint32(58).bytes(message.dataHash); + } + if (message.validatorsHash.length !== 0) { + writer.uint32(66).bytes(message.validatorsHash); + } + if (message.nextValidatorsHash.length !== 0) { + writer.uint32(74).bytes(message.nextValidatorsHash); + } + if (message.consensusHash.length !== 0) { + writer.uint32(82).bytes(message.consensusHash); + } + if (message.appHash.length !== 0) { + writer.uint32(90).bytes(message.appHash); + } + if (message.lastResultsHash.length !== 0) { + writer.uint32(98).bytes(message.lastResultsHash); + } + if (message.evidenceHash.length !== 0) { + writer.uint32(106).bytes(message.evidenceHash); + } + if (message.proposerAddress.length !== 0) { + writer.uint32(114).bytes(message.proposerAddress); + } return writer; }, @@ -585,6 +617,50 @@ export const Header = { return message; }, + toJSON(message: Header): unknown { + const obj: any = {}; + message.version !== undefined && + (obj.version = message.version ? Consensus.toJSON(message.version) : undefined); + message.chainId !== undefined && (obj.chainId = message.chainId); + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + message.time !== undefined && (obj.time = message.time !== undefined ? message.time.toISOString() : null); + message.lastBlockId !== undefined && + (obj.lastBlockId = message.lastBlockId ? BlockID.toJSON(message.lastBlockId) : undefined); + message.lastCommitHash !== undefined && + (obj.lastCommitHash = base64FromBytes( + message.lastCommitHash !== undefined ? message.lastCommitHash : new Uint8Array(), + )); + message.dataHash !== undefined && + (obj.dataHash = base64FromBytes(message.dataHash !== undefined ? message.dataHash : new Uint8Array())); + message.validatorsHash !== undefined && + (obj.validatorsHash = base64FromBytes( + message.validatorsHash !== undefined ? message.validatorsHash : new Uint8Array(), + )); + message.nextValidatorsHash !== undefined && + (obj.nextValidatorsHash = base64FromBytes( + message.nextValidatorsHash !== undefined ? message.nextValidatorsHash : new Uint8Array(), + )); + message.consensusHash !== undefined && + (obj.consensusHash = base64FromBytes( + message.consensusHash !== undefined ? message.consensusHash : new Uint8Array(), + )); + message.appHash !== undefined && + (obj.appHash = base64FromBytes(message.appHash !== undefined ? message.appHash : new Uint8Array())); + message.lastResultsHash !== undefined && + (obj.lastResultsHash = base64FromBytes( + message.lastResultsHash !== undefined ? message.lastResultsHash : new Uint8Array(), + )); + message.evidenceHash !== undefined && + (obj.evidenceHash = base64FromBytes( + message.evidenceHash !== undefined ? message.evidenceHash : new Uint8Array(), + )); + message.proposerAddress !== undefined && + (obj.proposerAddress = base64FromBytes( + message.proposerAddress !== undefined ? message.proposerAddress : new Uint8Array(), + )); + return obj; + }, + fromPartial(object: DeepPartial
): Header { const message = { ...baseHeader } as Header; if (object.version !== undefined && object.version !== null) { @@ -659,50 +735,6 @@ export const Header = { } return message; }, - - toJSON(message: Header): unknown { - const obj: any = {}; - message.version !== undefined && - (obj.version = message.version ? Consensus.toJSON(message.version) : undefined); - message.chainId !== undefined && (obj.chainId = message.chainId); - message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); - message.time !== undefined && (obj.time = message.time !== undefined ? message.time.toISOString() : null); - message.lastBlockId !== undefined && - (obj.lastBlockId = message.lastBlockId ? BlockID.toJSON(message.lastBlockId) : undefined); - message.lastCommitHash !== undefined && - (obj.lastCommitHash = base64FromBytes( - message.lastCommitHash !== undefined ? message.lastCommitHash : new Uint8Array(), - )); - message.dataHash !== undefined && - (obj.dataHash = base64FromBytes(message.dataHash !== undefined ? message.dataHash : new Uint8Array())); - message.validatorsHash !== undefined && - (obj.validatorsHash = base64FromBytes( - message.validatorsHash !== undefined ? message.validatorsHash : new Uint8Array(), - )); - message.nextValidatorsHash !== undefined && - (obj.nextValidatorsHash = base64FromBytes( - message.nextValidatorsHash !== undefined ? message.nextValidatorsHash : new Uint8Array(), - )); - message.consensusHash !== undefined && - (obj.consensusHash = base64FromBytes( - message.consensusHash !== undefined ? message.consensusHash : new Uint8Array(), - )); - message.appHash !== undefined && - (obj.appHash = base64FromBytes(message.appHash !== undefined ? message.appHash : new Uint8Array())); - message.lastResultsHash !== undefined && - (obj.lastResultsHash = base64FromBytes( - message.lastResultsHash !== undefined ? message.lastResultsHash : new Uint8Array(), - )); - message.evidenceHash !== undefined && - (obj.evidenceHash = base64FromBytes( - message.evidenceHash !== undefined ? message.evidenceHash : new Uint8Array(), - )); - message.proposerAddress !== undefined && - (obj.proposerAddress = base64FromBytes( - message.proposerAddress !== undefined ? message.proposerAddress : new Uint8Array(), - )); - return obj; - }, }; const baseData: object = {}; @@ -745,6 +777,16 @@ export const Data = { return message; }, + toJSON(message: Data): unknown { + const obj: any = {}; + if (message.txs) { + obj.txs = message.txs.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.txs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Data { const message = { ...baseData } as Data; message.txs = []; @@ -755,34 +797,36 @@ export const Data = { } return message; }, - - toJSON(message: Data): unknown { - const obj: any = {}; - if (message.txs) { - obj.txs = message.txs.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); - } else { - obj.txs = []; - } - return obj; - }, }; const baseVote: object = { type: 0, height: Long.ZERO, round: 0, validatorIndex: 0 }; export const Vote = { encode(message: Vote, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.type); - writer.uint32(16).int64(message.height); - writer.uint32(24).int32(message.round); - if (message.blockId !== undefined && message.blockId !== undefined) { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (!message.height.isZero()) { + writer.uint32(16).int64(message.height); + } + if (message.round !== 0) { + writer.uint32(24).int32(message.round); + } + if (message.blockId !== undefined) { BlockID.encode(message.blockId, writer.uint32(34).fork()).ldelim(); } - if (message.timestamp !== undefined && message.timestamp !== undefined) { + if (message.timestamp !== undefined) { Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(42).fork()).ldelim(); } - writer.uint32(50).bytes(message.validatorAddress); - writer.uint32(56).int32(message.validatorIndex); - writer.uint32(66).bytes(message.signature); + if (message.validatorAddress.length !== 0) { + writer.uint32(50).bytes(message.validatorAddress); + } + if (message.validatorIndex !== 0) { + writer.uint32(56).int32(message.validatorIndex); + } + if (message.signature.length !== 0) { + writer.uint32(66).bytes(message.signature); + } return writer; }, @@ -866,6 +910,27 @@ export const Vote = { return message; }, + toJSON(message: Vote): unknown { + const obj: any = {}; + message.type !== undefined && (obj.type = signedMsgTypeToJSON(message.type)); + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + message.round !== undefined && (obj.round = message.round); + message.blockId !== undefined && + (obj.blockId = message.blockId ? BlockID.toJSON(message.blockId) : undefined); + message.timestamp !== undefined && + (obj.timestamp = message.timestamp !== undefined ? message.timestamp.toISOString() : null); + message.validatorAddress !== undefined && + (obj.validatorAddress = base64FromBytes( + message.validatorAddress !== undefined ? message.validatorAddress : new Uint8Array(), + )); + message.validatorIndex !== undefined && (obj.validatorIndex = message.validatorIndex); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array(), + )); + return obj; + }, + fromPartial(object: DeepPartial): Vote { const message = { ...baseVote } as Vote; if (object.type !== undefined && object.type !== null) { @@ -910,36 +975,19 @@ export const Vote = { } return message; }, - - toJSON(message: Vote): unknown { - const obj: any = {}; - message.type !== undefined && (obj.type = signedMsgTypeToJSON(message.type)); - message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); - message.round !== undefined && (obj.round = message.round); - message.blockId !== undefined && - (obj.blockId = message.blockId ? BlockID.toJSON(message.blockId) : undefined); - message.timestamp !== undefined && - (obj.timestamp = message.timestamp !== undefined ? message.timestamp.toISOString() : null); - message.validatorAddress !== undefined && - (obj.validatorAddress = base64FromBytes( - message.validatorAddress !== undefined ? message.validatorAddress : new Uint8Array(), - )); - message.validatorIndex !== undefined && (obj.validatorIndex = message.validatorIndex); - message.signature !== undefined && - (obj.signature = base64FromBytes( - message.signature !== undefined ? message.signature : new Uint8Array(), - )); - return obj; - }, }; const baseCommit: object = { height: Long.ZERO, round: 0 }; export const Commit = { encode(message: Commit, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int64(message.height); - writer.uint32(16).int32(message.round); - if (message.blockId !== undefined && message.blockId !== undefined) { + if (!message.height.isZero()) { + writer.uint32(8).int64(message.height); + } + if (message.round !== 0) { + writer.uint32(16).int32(message.round); + } + if (message.blockId !== undefined) { BlockID.encode(message.blockId, writer.uint32(26).fork()).ldelim(); } for (const v of message.signatures) { @@ -1002,6 +1050,20 @@ export const Commit = { return message; }, + toJSON(message: Commit): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + message.round !== undefined && (obj.round = message.round); + message.blockId !== undefined && + (obj.blockId = message.blockId ? BlockID.toJSON(message.blockId) : undefined); + if (message.signatures) { + obj.signatures = message.signatures.map((e) => (e ? CommitSig.toJSON(e) : undefined)); + } else { + obj.signatures = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Commit { const message = { ...baseCommit } as Commit; message.signatures = []; @@ -1027,32 +1089,24 @@ export const Commit = { } return message; }, - - toJSON(message: Commit): unknown { - const obj: any = {}; - message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); - message.round !== undefined && (obj.round = message.round); - message.blockId !== undefined && - (obj.blockId = message.blockId ? BlockID.toJSON(message.blockId) : undefined); - if (message.signatures) { - obj.signatures = message.signatures.map((e) => (e ? CommitSig.toJSON(e) : undefined)); - } else { - obj.signatures = []; - } - return obj; - }, }; const baseCommitSig: object = { blockIdFlag: 0 }; export const CommitSig = { encode(message: CommitSig, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.blockIdFlag); - writer.uint32(18).bytes(message.validatorAddress); - if (message.timestamp !== undefined && message.timestamp !== undefined) { + if (message.blockIdFlag !== 0) { + writer.uint32(8).int32(message.blockIdFlag); + } + if (message.validatorAddress.length !== 0) { + writer.uint32(18).bytes(message.validatorAddress); + } + if (message.timestamp !== undefined) { Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(26).fork()).ldelim(); } - writer.uint32(34).bytes(message.signature); + if (message.signature.length !== 0) { + writer.uint32(34).bytes(message.signature); + } return writer; }, @@ -1104,6 +1158,22 @@ export const CommitSig = { return message; }, + toJSON(message: CommitSig): unknown { + const obj: any = {}; + message.blockIdFlag !== undefined && (obj.blockIdFlag = blockIDFlagToJSON(message.blockIdFlag)); + message.validatorAddress !== undefined && + (obj.validatorAddress = base64FromBytes( + message.validatorAddress !== undefined ? message.validatorAddress : new Uint8Array(), + )); + message.timestamp !== undefined && + (obj.timestamp = message.timestamp !== undefined ? message.timestamp.toISOString() : null); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array(), + )); + return obj; + }, + fromPartial(object: DeepPartial): CommitSig { const message = { ...baseCommitSig } as CommitSig; if (object.blockIdFlag !== undefined && object.blockIdFlag !== null) { @@ -1128,39 +1198,33 @@ export const CommitSig = { } return message; }, - - toJSON(message: CommitSig): unknown { - const obj: any = {}; - message.blockIdFlag !== undefined && (obj.blockIdFlag = blockIDFlagToJSON(message.blockIdFlag)); - message.validatorAddress !== undefined && - (obj.validatorAddress = base64FromBytes( - message.validatorAddress !== undefined ? message.validatorAddress : new Uint8Array(), - )); - message.timestamp !== undefined && - (obj.timestamp = message.timestamp !== undefined ? message.timestamp.toISOString() : null); - message.signature !== undefined && - (obj.signature = base64FromBytes( - message.signature !== undefined ? message.signature : new Uint8Array(), - )); - return obj; - }, }; const baseProposal: object = { type: 0, height: Long.ZERO, round: 0, polRound: 0 }; export const Proposal = { encode(message: Proposal, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).int32(message.type); - writer.uint32(16).int64(message.height); - writer.uint32(24).int32(message.round); - writer.uint32(32).int32(message.polRound); - if (message.blockId !== undefined && message.blockId !== undefined) { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (!message.height.isZero()) { + writer.uint32(16).int64(message.height); + } + if (message.round !== 0) { + writer.uint32(24).int32(message.round); + } + if (message.polRound !== 0) { + writer.uint32(32).int32(message.polRound); + } + if (message.blockId !== undefined) { BlockID.encode(message.blockId, writer.uint32(42).fork()).ldelim(); } - if (message.timestamp !== undefined && message.timestamp !== undefined) { + if (message.timestamp !== undefined) { Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(50).fork()).ldelim(); } - writer.uint32(58).bytes(message.signature); + if (message.signature.length !== 0) { + writer.uint32(58).bytes(message.signature); + } return writer; }, @@ -1238,6 +1302,23 @@ export const Proposal = { return message; }, + toJSON(message: Proposal): unknown { + const obj: any = {}; + message.type !== undefined && (obj.type = signedMsgTypeToJSON(message.type)); + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + message.round !== undefined && (obj.round = message.round); + message.polRound !== undefined && (obj.polRound = message.polRound); + message.blockId !== undefined && + (obj.blockId = message.blockId ? BlockID.toJSON(message.blockId) : undefined); + message.timestamp !== undefined && + (obj.timestamp = message.timestamp !== undefined ? message.timestamp.toISOString() : null); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array(), + )); + return obj; + }, + fromPartial(object: DeepPartial): Proposal { const message = { ...baseProposal } as Proposal; if (object.type !== undefined && object.type !== null) { @@ -1277,33 +1358,16 @@ export const Proposal = { } return message; }, - - toJSON(message: Proposal): unknown { - const obj: any = {}; - message.type !== undefined && (obj.type = signedMsgTypeToJSON(message.type)); - message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); - message.round !== undefined && (obj.round = message.round); - message.polRound !== undefined && (obj.polRound = message.polRound); - message.blockId !== undefined && - (obj.blockId = message.blockId ? BlockID.toJSON(message.blockId) : undefined); - message.timestamp !== undefined && - (obj.timestamp = message.timestamp !== undefined ? message.timestamp.toISOString() : null); - message.signature !== undefined && - (obj.signature = base64FromBytes( - message.signature !== undefined ? message.signature : new Uint8Array(), - )); - return obj; - }, }; const baseSignedHeader: object = {}; export const SignedHeader = { encode(message: SignedHeader, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.header !== undefined && message.header !== undefined) { + if (message.header !== undefined) { Header.encode(message.header, writer.uint32(10).fork()).ldelim(); } - if (message.commit !== undefined && message.commit !== undefined) { + if (message.commit !== undefined) { Commit.encode(message.commit, writer.uint32(18).fork()).ldelim(); } return writer; @@ -1345,6 +1409,13 @@ export const SignedHeader = { return message; }, + toJSON(message: SignedHeader): unknown { + const obj: any = {}; + message.header !== undefined && (obj.header = message.header ? Header.toJSON(message.header) : undefined); + message.commit !== undefined && (obj.commit = message.commit ? Commit.toJSON(message.commit) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): SignedHeader { const message = { ...baseSignedHeader } as SignedHeader; if (object.header !== undefined && object.header !== null) { @@ -1359,23 +1430,16 @@ export const SignedHeader = { } return message; }, - - toJSON(message: SignedHeader): unknown { - const obj: any = {}; - message.header !== undefined && (obj.header = message.header ? Header.toJSON(message.header) : undefined); - message.commit !== undefined && (obj.commit = message.commit ? Commit.toJSON(message.commit) : undefined); - return obj; - }, }; const baseLightBlock: object = {}; export const LightBlock = { encode(message: LightBlock, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.signedHeader !== undefined && message.signedHeader !== undefined) { + if (message.signedHeader !== undefined) { SignedHeader.encode(message.signedHeader, writer.uint32(10).fork()).ldelim(); } - if (message.validatorSet !== undefined && message.validatorSet !== undefined) { + if (message.validatorSet !== undefined) { ValidatorSet.encode(message.validatorSet, writer.uint32(18).fork()).ldelim(); } return writer; @@ -1417,6 +1481,15 @@ export const LightBlock = { return message; }, + toJSON(message: LightBlock): 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); + return obj; + }, + fromPartial(object: DeepPartial): LightBlock { const message = { ...baseLightBlock } as LightBlock; if (object.signedHeader !== undefined && object.signedHeader !== null) { @@ -1431,29 +1504,24 @@ export const LightBlock = { } return message; }, - - toJSON(message: LightBlock): 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); - return obj; - }, }; const baseBlockMeta: object = { blockSize: Long.ZERO, numTxs: Long.ZERO }; export const BlockMeta = { encode(message: BlockMeta, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.blockId !== undefined && message.blockId !== undefined) { + if (message.blockId !== undefined) { BlockID.encode(message.blockId, writer.uint32(10).fork()).ldelim(); } - writer.uint32(16).int64(message.blockSize); - if (message.header !== undefined && message.header !== undefined) { + if (!message.blockSize.isZero()) { + writer.uint32(16).int64(message.blockSize); + } + if (message.header !== undefined) { Header.encode(message.header, writer.uint32(26).fork()).ldelim(); } - writer.uint32(32).int64(message.numTxs); + if (!message.numTxs.isZero()) { + writer.uint32(32).int64(message.numTxs); + } return writer; }, @@ -1509,6 +1577,16 @@ export const BlockMeta = { return message; }, + toJSON(message: BlockMeta): unknown { + const obj: any = {}; + message.blockId !== undefined && + (obj.blockId = message.blockId ? BlockID.toJSON(message.blockId) : undefined); + message.blockSize !== undefined && (obj.blockSize = (message.blockSize || Long.ZERO).toString()); + message.header !== undefined && (obj.header = message.header ? Header.toJSON(message.header) : undefined); + message.numTxs !== undefined && (obj.numTxs = (message.numTxs || Long.ZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): BlockMeta { const message = { ...baseBlockMeta } as BlockMeta; if (object.blockId !== undefined && object.blockId !== null) { @@ -1533,25 +1611,19 @@ export const BlockMeta = { } return message; }, - - toJSON(message: BlockMeta): unknown { - const obj: any = {}; - message.blockId !== undefined && - (obj.blockId = message.blockId ? BlockID.toJSON(message.blockId) : undefined); - message.blockSize !== undefined && (obj.blockSize = (message.blockSize || Long.ZERO).toString()); - message.header !== undefined && (obj.header = message.header ? Header.toJSON(message.header) : undefined); - message.numTxs !== undefined && (obj.numTxs = (message.numTxs || Long.ZERO).toString()); - return obj; - }, }; const baseTxProof: object = {}; export const TxProof = { encode(message: TxProof, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.rootHash); - writer.uint32(18).bytes(message.data); - if (message.proof !== undefined && message.proof !== undefined) { + if (message.rootHash.length !== 0) { + writer.uint32(10).bytes(message.rootHash); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + if (message.proof !== undefined) { Proof.encode(message.proof, writer.uint32(26).fork()).ldelim(); } return writer; @@ -1597,6 +1669,16 @@ export const TxProof = { return message; }, + toJSON(message: TxProof): unknown { + const obj: any = {}; + message.rootHash !== undefined && + (obj.rootHash = base64FromBytes(message.rootHash !== undefined ? message.rootHash : new Uint8Array())); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + message.proof !== undefined && (obj.proof = message.proof ? Proof.toJSON(message.proof) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): TxProof { const message = { ...baseTxProof } as TxProof; if (object.rootHash !== undefined && object.rootHash !== null) { @@ -1616,16 +1698,6 @@ export const TxProof = { } return message; }, - - toJSON(message: TxProof): unknown { - const obj: any = {}; - message.rootHash !== undefined && - (obj.rootHash = base64FromBytes(message.rootHash !== undefined ? message.rootHash : new Uint8Array())); - message.data !== undefined && - (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); - message.proof !== undefined && (obj.proof = message.proof ? Proof.toJSON(message.proof) : undefined); - return obj; - }, }; declare var self: any | undefined; @@ -1635,7 +1707,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/stargate/src/codec/tendermint/types/validator.ts b/packages/stargate/src/codec/tendermint/types/validator.ts index 60a93350..be7652cb 100644 --- a/packages/stargate/src/codec/tendermint/types/validator.ts +++ b/packages/stargate/src/codec/tendermint/types/validator.ts @@ -30,10 +30,12 @@ export const ValidatorSet = { for (const v of message.validators) { Validator.encode(v!, writer.uint32(10).fork()).ldelim(); } - if (message.proposer !== undefined && message.proposer !== undefined) { + if (message.proposer !== undefined) { Validator.encode(message.proposer, writer.uint32(18).fork()).ldelim(); } - writer.uint32(24).int64(message.totalVotingPower); + if (!message.totalVotingPower.isZero()) { + writer.uint32(24).int64(message.totalVotingPower); + } return writer; }, @@ -83,6 +85,20 @@ export const ValidatorSet = { return message; }, + toJSON(message: ValidatorSet): unknown { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map((e) => (e ? Validator.toJSON(e) : undefined)); + } else { + obj.validators = []; + } + message.proposer !== undefined && + (obj.proposer = message.proposer ? Validator.toJSON(message.proposer) : undefined); + message.totalVotingPower !== undefined && + (obj.totalVotingPower = (message.totalVotingPower || Long.ZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): ValidatorSet { const message = { ...baseValidatorSet } as ValidatorSet; message.validators = []; @@ -103,32 +119,24 @@ export const ValidatorSet = { } return message; }, - - toJSON(message: ValidatorSet): unknown { - const obj: any = {}; - if (message.validators) { - obj.validators = message.validators.map((e) => (e ? Validator.toJSON(e) : undefined)); - } else { - obj.validators = []; - } - message.proposer !== undefined && - (obj.proposer = message.proposer ? Validator.toJSON(message.proposer) : undefined); - message.totalVotingPower !== undefined && - (obj.totalVotingPower = (message.totalVotingPower || Long.ZERO).toString()); - return obj; - }, }; const baseValidator: object = { votingPower: Long.ZERO, proposerPriority: Long.ZERO }; export const Validator = { encode(message: Validator, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(10).bytes(message.address); - if (message.pubKey !== undefined && message.pubKey !== undefined) { + if (message.address.length !== 0) { + writer.uint32(10).bytes(message.address); + } + if (message.pubKey !== undefined) { PublicKey.encode(message.pubKey, writer.uint32(18).fork()).ldelim(); } - writer.uint32(24).int64(message.votingPower); - writer.uint32(32).int64(message.proposerPriority); + if (!message.votingPower.isZero()) { + writer.uint32(24).int64(message.votingPower); + } + if (!message.proposerPriority.isZero()) { + writer.uint32(32).int64(message.proposerPriority); + } return writer; }, @@ -182,6 +190,18 @@ export const Validator = { return message; }, + toJSON(message: Validator): unknown { + const obj: any = {}; + message.address !== undefined && + (obj.address = base64FromBytes(message.address !== undefined ? message.address : new Uint8Array())); + message.pubKey !== undefined && + (obj.pubKey = message.pubKey ? PublicKey.toJSON(message.pubKey) : undefined); + message.votingPower !== undefined && (obj.votingPower = (message.votingPower || Long.ZERO).toString()); + message.proposerPriority !== undefined && + (obj.proposerPriority = (message.proposerPriority || Long.ZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): Validator { const message = { ...baseValidator } as Validator; if (object.address !== undefined && object.address !== null) { @@ -206,28 +226,18 @@ export const Validator = { } return message; }, - - toJSON(message: Validator): unknown { - const obj: any = {}; - message.address !== undefined && - (obj.address = base64FromBytes(message.address !== undefined ? message.address : new Uint8Array())); - message.pubKey !== undefined && - (obj.pubKey = message.pubKey ? PublicKey.toJSON(message.pubKey) : undefined); - message.votingPower !== undefined && (obj.votingPower = (message.votingPower || Long.ZERO).toString()); - message.proposerPriority !== undefined && - (obj.proposerPriority = (message.proposerPriority || Long.ZERO).toString()); - return obj; - }, }; const baseSimpleValidator: object = { votingPower: Long.ZERO }; export const SimpleValidator = { encode(message: SimpleValidator, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.pubKey !== undefined && message.pubKey !== undefined) { + if (message.pubKey !== undefined) { PublicKey.encode(message.pubKey, writer.uint32(10).fork()).ldelim(); } - writer.uint32(16).int64(message.votingPower); + if (!message.votingPower.isZero()) { + writer.uint32(16).int64(message.votingPower); + } return writer; }, @@ -267,6 +277,14 @@ export const SimpleValidator = { return message; }, + toJSON(message: SimpleValidator): unknown { + const obj: any = {}; + message.pubKey !== undefined && + (obj.pubKey = message.pubKey ? PublicKey.toJSON(message.pubKey) : undefined); + message.votingPower !== undefined && (obj.votingPower = (message.votingPower || Long.ZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): SimpleValidator { const message = { ...baseSimpleValidator } as SimpleValidator; if (object.pubKey !== undefined && object.pubKey !== null) { @@ -281,14 +299,6 @@ export const SimpleValidator = { } return message; }, - - toJSON(message: SimpleValidator): unknown { - const obj: any = {}; - message.pubKey !== undefined && - (obj.pubKey = message.pubKey ? PublicKey.toJSON(message.pubKey) : undefined); - message.votingPower !== undefined && (obj.votingPower = (message.votingPower || Long.ZERO).toString()); - return obj; - }, }; declare var self: any | undefined; @@ -298,7 +308,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = diff --git a/packages/stargate/src/codec/tendermint/version/types.ts b/packages/stargate/src/codec/tendermint/version/types.ts index 3aa4960b..3a018249 100644 --- a/packages/stargate/src/codec/tendermint/version/types.ts +++ b/packages/stargate/src/codec/tendermint/version/types.ts @@ -28,8 +28,12 @@ const baseApp: object = { protocol: Long.UZERO, software: "" }; export const App = { encode(message: App, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.protocol); - writer.uint32(18).string(message.software); + if (!message.protocol.isZero()) { + writer.uint32(8).uint64(message.protocol); + } + if (message.software !== "") { + writer.uint32(18).string(message.software); + } return writer; }, @@ -69,6 +73,13 @@ export const App = { return message; }, + toJSON(message: App): unknown { + const obj: any = {}; + message.protocol !== undefined && (obj.protocol = (message.protocol || Long.UZERO).toString()); + message.software !== undefined && (obj.software = message.software); + return obj; + }, + fromPartial(object: DeepPartial): App { const message = { ...baseApp } as App; if (object.protocol !== undefined && object.protocol !== null) { @@ -83,21 +94,18 @@ export const App = { } return message; }, - - toJSON(message: App): unknown { - const obj: any = {}; - message.protocol !== undefined && (obj.protocol = (message.protocol || Long.UZERO).toString()); - message.software !== undefined && (obj.software = message.software); - return obj; - }, }; const baseConsensus: object = { block: Long.UZERO, app: Long.UZERO }; export const Consensus = { encode(message: Consensus, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - writer.uint32(8).uint64(message.block); - writer.uint32(16).uint64(message.app); + if (!message.block.isZero()) { + writer.uint32(8).uint64(message.block); + } + if (!message.app.isZero()) { + writer.uint32(16).uint64(message.app); + } return writer; }, @@ -137,6 +145,13 @@ export const Consensus = { return message; }, + toJSON(message: Consensus): unknown { + const obj: any = {}; + message.block !== undefined && (obj.block = (message.block || Long.UZERO).toString()); + message.app !== undefined && (obj.app = (message.app || Long.UZERO).toString()); + return obj; + }, + fromPartial(object: DeepPartial): Consensus { const message = { ...baseConsensus } as Consensus; if (object.block !== undefined && object.block !== null) { @@ -151,13 +166,6 @@ export const Consensus = { } return message; }, - - toJSON(message: Consensus): unknown { - const obj: any = {}; - message.block !== undefined && (obj.block = (message.block || Long.UZERO).toString()); - message.app !== undefined && (obj.app = (message.app || Long.UZERO).toString()); - return obj; - }, }; type Builtin = Date | Function | Uint8Array | string | number | undefined | Long; diff --git a/yarn.lock b/yarn.lock index d7092311..a2ac247f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8645,25 +8645,33 @@ ts-node@^8: source-map-support "^0.5.6" yn "3.1.1" -ts-poet@^4.4.1: - version "4.4.1" - resolved "https://registry.yarnpkg.com/ts-poet/-/ts-poet-4.4.1.tgz#064c613b1c432d2f62f0d4e59ff060a1c72cc984" - integrity sha512-xnn4/+fhDDpWYrDQ4ATulJK3zwuKleo2U97CU2uWU42RSGMP4AYATGiZGIku+sSYVsa4toBPjtEY93TuR0ztGw== +ts-poet@^4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/ts-poet/-/ts-poet-4.5.0.tgz#bb07ffe379d5a96f5e81da72a00edad45b28e9ca" + integrity sha512-Vs2Zsiz3zf5qdFulFTIEpaLdgWeHXKh+4pv+ycVqEh+ZuUOVGrN0i9lbxVx7DB1FBogExytz3OuaBMJfWffpSQ== dependencies: "@types/prettier" "^1.19.0" lodash "^4.17.15" prettier "^2.0.2" -ts-proto@^1.53.0: - version "1.53.0" - resolved "https://registry.yarnpkg.com/ts-proto/-/ts-proto-1.53.0.tgz#3261b5b029fe154a381ad3d97e247bdddd46f536" - integrity sha512-/capMN0z4SVEyqpmXwH5ibq0DIy+ozgJ4tiq1yk3HgSn+ldXZtku03Wexw6Si08Q30YAQ6uSd205N2HmNjGp5w== +ts-proto-descriptors@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/ts-proto-descriptors/-/ts-proto-descriptors-1.2.0.tgz#47fdef5dc640d2c87fbe0c010678f009e79f63bc" + integrity sha512-0t2WITzCiQ/3H6zPuFrFFOj2jhH6xZNu7agS7aKecKrz7tjRMW9VrmlBlJXslTTC3K7/4phV4qlsP5fOfLxuDg== + dependencies: + protobufjs "^6.8.8" + +ts-proto@^1.67.0: + version "1.67.0" + resolved "https://registry.yarnpkg.com/ts-proto/-/ts-proto-1.67.0.tgz#27c45852e5640daa260750a91341026e49dfce40" + integrity sha512-+a7zleIP3EuZucu8B/HgSqzZarYHSeZ9z2KYK0/P9K8meSuLKBFB5yipYU0VK78FxAdX+u//ZTGvwe2Pzq1XfA== dependencies: "@types/object-hash" "^1.3.0" dataloader "^1.4.0" object-hash "^1.3.1" protobufjs "^6.8.8" - ts-poet "^4.4.1" + ts-poet "^4.5.0" + ts-proto-descriptors "^1.2.0" tsconfig-paths@^3.9.0: version "3.9.0"