diff --git a/CHANGELOG.md b/CHANGELOG.md index 59d7cc2e..3b761d02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,14 @@ and this project adheres to ## [Unreleased] +## [0.6.1] - 2022-12-22 + +### Changed + +- Bring back fromJSON/toJSON ([#55]) + +[#55]: https://github.com/confio/cosmjs-types/pull/55 + ## [0.6.0] - 2022-12-08 ### Changed @@ -60,7 +68,8 @@ No changelog, sorry. Maybe the diff helps. - wasmd 0.18 types (cosmwasm/wasm/v1/\*) -[unreleased]: https://github.com/confio/cosmjs-types/compare/v0.6.0...HEAD +[unreleased]: https://github.com/confio/cosmjs-types/compare/v0.6.1...HEAD +[0.6.1]: https://github.com/confio/cosmjs-types/compare/v0.6.0...v0.6.1 [0.6.0]: https://github.com/confio/cosmjs-types/compare/v0.5.2...v0.6.0 [0.5.2]: https://github.com/confio/cosmjs-types/compare/v0.5.1...v0.5.2 [0.5.1]: https://github.com/confio/cosmjs-types/compare/v0.5.0...v0.5.1 diff --git a/scripts/codegen.js b/scripts/codegen.js index 0a263bce..0be14477 100755 --- a/scripts/codegen.js +++ b/scripts/codegen.js @@ -53,8 +53,10 @@ telescope({ ] }, methods: { - fromJSON: false, - toJSON: false + // There are users who need those functions. CosmJS does not need them directly. + // See https://github.com/cosmos/cosmjs/pull/1329 + fromJSON: true, + toJSON: true, }, typingsFormat: { useDeepPartial: true, diff --git a/src/confio/proofs.ts b/src/confio/proofs.ts index bac4b445..ffe1f9e4 100644 --- a/src/confio/proofs.ts +++ b/src/confio/proofs.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../helpers"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact } from "../helpers"; export const protobufPackage = "ics23"; export enum HashOp { /** NO_HASH - NO_HASH is the default if no data passed. Note this is an illegal argument some places. */ @@ -440,6 +440,32 @@ export const ExistenceProof = { return message; }, + fromJSON(object: any): ExistenceProof { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), + leaf: isSet(object.leaf) ? LeafOp.fromJSON(object.leaf) : undefined, + path: Array.isArray(object?.path) ? object.path.map((e: any) => InnerOp.fromJSON(e)) : [], + }; + }, + + 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, I>>(object: I): ExistenceProof { const message = createBaseExistenceProof(); message.key = object.key ?? new Uint8Array(); @@ -506,6 +532,24 @@ export const NonExistenceProof = { return message; }, + fromJSON(object: any): NonExistenceProof { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + left: isSet(object.left) ? ExistenceProof.fromJSON(object.left) : undefined, + right: isSet(object.right) ? ExistenceProof.fromJSON(object.right) : undefined, + }; + }, + + 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, I>>(object: I): NonExistenceProof { const message = createBaseNonExistenceProof(); message.key = object.key ?? new Uint8Array(); @@ -583,6 +627,27 @@ export const CommitmentProof = { return message; }, + fromJSON(object: any): CommitmentProof { + return { + exist: isSet(object.exist) ? ExistenceProof.fromJSON(object.exist) : undefined, + nonexist: isSet(object.nonexist) ? NonExistenceProof.fromJSON(object.nonexist) : undefined, + batch: isSet(object.batch) ? BatchProof.fromJSON(object.batch) : undefined, + compressed: isSet(object.compressed) ? CompressedBatchProof.fromJSON(object.compressed) : undefined, + }; + }, + + 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, I>>(object: I): CommitmentProof { const message = createBaseCommitmentProof(); message.exist = @@ -676,6 +741,27 @@ export const LeafOp = { return message; }, + fromJSON(object: any): LeafOp { + return { + hash: isSet(object.hash) ? hashOpFromJSON(object.hash) : 0, + prehashKey: isSet(object.prehashKey) ? hashOpFromJSON(object.prehashKey) : 0, + prehashValue: isSet(object.prehashValue) ? hashOpFromJSON(object.prehashValue) : 0, + length: isSet(object.length) ? lengthOpFromJSON(object.length) : 0, + prefix: isSet(object.prefix) ? bytesFromBase64(object.prefix) : new Uint8Array(), + }; + }, + + 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, I>>(object: I): LeafOp { const message = createBaseLeafOp(); message.hash = object.hash ?? 0; @@ -742,6 +828,24 @@ export const InnerOp = { return message; }, + fromJSON(object: any): InnerOp { + return { + hash: isSet(object.hash) ? hashOpFromJSON(object.hash) : 0, + prefix: isSet(object.prefix) ? bytesFromBase64(object.prefix) : new Uint8Array(), + suffix: isSet(object.suffix) ? bytesFromBase64(object.suffix) : new Uint8Array(), + }; + }, + + 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, I>>(object: I): InnerOp { const message = createBaseInnerOp(); message.hash = object.hash ?? 0; @@ -815,6 +919,26 @@ export const ProofSpec = { return message; }, + fromJSON(object: any): ProofSpec { + return { + leafSpec: isSet(object.leafSpec) ? LeafOp.fromJSON(object.leafSpec) : undefined, + innerSpec: isSet(object.innerSpec) ? InnerSpec.fromJSON(object.innerSpec) : undefined, + maxDepth: isSet(object.maxDepth) ? Number(object.maxDepth) : 0, + minDepth: isSet(object.minDepth) ? Number(object.minDepth) : 0, + }; + }, + + 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 = Math.round(message.maxDepth)); + message.minDepth !== undefined && (obj.minDepth = Math.round(message.minDepth)); + return obj; + }, + fromPartial, I>>(object: I): ProofSpec { const message = createBaseProofSpec(); message.leafSpec = @@ -926,6 +1050,37 @@ export const InnerSpec = { return message; }, + fromJSON(object: any): InnerSpec { + return { + childOrder: Array.isArray(object?.childOrder) ? object.childOrder.map((e: any) => Number(e)) : [], + childSize: isSet(object.childSize) ? Number(object.childSize) : 0, + minPrefixLength: isSet(object.minPrefixLength) ? Number(object.minPrefixLength) : 0, + maxPrefixLength: isSet(object.maxPrefixLength) ? Number(object.maxPrefixLength) : 0, + emptyChild: isSet(object.emptyChild) ? bytesFromBase64(object.emptyChild) : new Uint8Array(), + hash: isSet(object.hash) ? hashOpFromJSON(object.hash) : 0, + }; + }, + + toJSON(message: InnerSpec): unknown { + const obj: any = {}; + + if (message.childOrder) { + obj.childOrder = message.childOrder.map((e) => Math.round(e)); + } else { + obj.childOrder = []; + } + + message.childSize !== undefined && (obj.childSize = Math.round(message.childSize)); + message.minPrefixLength !== undefined && (obj.minPrefixLength = Math.round(message.minPrefixLength)); + message.maxPrefixLength !== undefined && (obj.maxPrefixLength = Math.round(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, I>>(object: I): InnerSpec { const message = createBaseInnerSpec(); message.childOrder = object.childOrder?.map((e) => e) || []; @@ -975,6 +1130,24 @@ export const BatchProof = { return message; }, + fromJSON(object: any): BatchProof { + return { + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => BatchEntry.fromJSON(e)) : [], + }; + }, + + 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, I>>(object: I): BatchProof { const message = createBaseBatchProof(); message.entries = object.entries?.map((e) => BatchEntry.fromPartial(e)) || []; @@ -1028,6 +1201,22 @@ export const BatchEntry = { return message; }, + fromJSON(object: any): BatchEntry { + return { + exist: isSet(object.exist) ? ExistenceProof.fromJSON(object.exist) : undefined, + nonexist: isSet(object.nonexist) ? NonExistenceProof.fromJSON(object.nonexist) : undefined, + }; + }, + + 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, I>>(object: I): BatchEntry { const message = createBaseBatchEntry(); message.exist = @@ -1088,6 +1277,35 @@ export const CompressedBatchProof = { return message; }, + fromJSON(object: any): CompressedBatchProof { + return { + entries: Array.isArray(object?.entries) + ? object.entries.map((e: any) => CompressedBatchEntry.fromJSON(e)) + : [], + lookupInners: Array.isArray(object?.lookupInners) + ? object.lookupInners.map((e: any) => InnerOp.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): CompressedBatchProof { const message = createBaseCompressedBatchProof(); message.entries = object.entries?.map((e) => CompressedBatchEntry.fromPartial(e)) || []; @@ -1142,6 +1360,22 @@ export const CompressedBatchEntry = { return message; }, + fromJSON(object: any): CompressedBatchEntry { + return { + exist: isSet(object.exist) ? CompressedExistenceProof.fromJSON(object.exist) : undefined, + nonexist: isSet(object.nonexist) ? CompressedNonExistenceProof.fromJSON(object.nonexist) : undefined, + }; + }, + + 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, I>>(object: I): CompressedBatchEntry { const message = createBaseCompressedBatchEntry(); message.exist = @@ -1232,6 +1466,32 @@ export const CompressedExistenceProof = { return message; }, + fromJSON(object: any): CompressedExistenceProof { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), + leaf: isSet(object.leaf) ? LeafOp.fromJSON(object.leaf) : undefined, + path: Array.isArray(object?.path) ? object.path.map((e: any) => Number(e)) : [], + }; + }, + + 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) => Math.round(e)); + } else { + obj.path = []; + } + + return obj; + }, + fromPartial, I>>( object: I, ): CompressedExistenceProof { @@ -1300,6 +1560,25 @@ export const CompressedNonExistenceProof = { return message; }, + fromJSON(object: any): CompressedNonExistenceProof { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + left: isSet(object.left) ? CompressedExistenceProof.fromJSON(object.left) : undefined, + right: isSet(object.right) ? CompressedExistenceProof.fromJSON(object.right) : undefined, + }; + }, + + 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, I>>( object: I, ): CompressedNonExistenceProof { diff --git a/src/cosmos/auth/v1beta1/auth.ts b/src/cosmos/auth/v1beta1/auth.ts index 33bb984d..d708e0c8 100644 --- a/src/cosmos/auth/v1beta1/auth.ts +++ b/src/cosmos/auth/v1beta1/auth.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import { Any } from "../../../google/protobuf/any"; -import { Long, DeepPartial, Exact } from "../../../helpers"; +import { Long, isSet, DeepPartial, Exact } from "../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "cosmos.auth.v1beta1"; /** @@ -96,6 +96,25 @@ export const BaseAccount = { return message; }, + fromJSON(object: any): BaseAccount { + return { + address: isSet(object.address) ? String(object.address) : "", + pubKey: isSet(object.pubKey) ? Any.fromJSON(object.pubKey) : undefined, + accountNumber: isSet(object.accountNumber) ? Long.fromValue(object.accountNumber) : Long.UZERO, + sequence: isSet(object.sequence) ? Long.fromValue(object.sequence) : Long.UZERO, + }; + }, + + 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, I>>(object: I): BaseAccount { const message = createBaseBaseAccount(); message.address = object.address ?? ""; @@ -168,6 +187,29 @@ export const ModuleAccount = { return message; }, + fromJSON(object: any): ModuleAccount { + return { + baseAccount: isSet(object.baseAccount) ? BaseAccount.fromJSON(object.baseAccount) : undefined, + name: isSet(object.name) ? String(object.name) : "", + permissions: Array.isArray(object?.permissions) ? object.permissions.map((e: any) => String(e)) : [], + }; + }, + + 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, I>>(object: I): ModuleAccount { const message = createBaseModuleAccount(); message.baseAccount = @@ -253,6 +295,38 @@ export const Params = { return message; }, + fromJSON(object: any): Params { + return { + maxMemoCharacters: isSet(object.maxMemoCharacters) + ? Long.fromValue(object.maxMemoCharacters) + : Long.UZERO, + txSigLimit: isSet(object.txSigLimit) ? Long.fromValue(object.txSigLimit) : Long.UZERO, + txSizeCostPerByte: isSet(object.txSizeCostPerByte) + ? Long.fromValue(object.txSizeCostPerByte) + : Long.UZERO, + sigVerifyCostEd25519: isSet(object.sigVerifyCostEd25519) + ? Long.fromValue(object.sigVerifyCostEd25519) + : Long.UZERO, + sigVerifyCostSecp256k1: isSet(object.sigVerifyCostSecp256k1) + ? Long.fromValue(object.sigVerifyCostSecp256k1) + : Long.UZERO, + }; + }, + + 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, I>>(object: I): Params { const message = createBaseParams(); message.maxMemoCharacters = diff --git a/src/cosmos/auth/v1beta1/genesis.ts b/src/cosmos/auth/v1beta1/genesis.ts index ddf8d92a..e167d9c7 100644 --- a/src/cosmos/auth/v1beta1/genesis.ts +++ b/src/cosmos/auth/v1beta1/genesis.ts @@ -2,7 +2,7 @@ import { Params } from "./auth"; import { Any } from "../../../google/protobuf/any"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../helpers"; export const protobufPackage = "cosmos.auth.v1beta1"; /** GenesisState defines the auth module's genesis state. */ @@ -60,6 +60,26 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + accounts: Array.isArray(object?.accounts) ? object.accounts.map((e: any) => Any.fromJSON(e)) : [], + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + + if (message.accounts) { + obj.accounts = message.accounts.map((e) => (e ? Any.toJSON(e) : undefined)); + } else { + obj.accounts = []; + } + + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.params = diff --git a/src/cosmos/auth/v1beta1/query.ts b/src/cosmos/auth/v1beta1/query.ts index 47f27fe9..2626ba2b 100644 --- a/src/cosmos/auth/v1beta1/query.ts +++ b/src/cosmos/auth/v1beta1/query.ts @@ -3,7 +3,7 @@ import { PageRequest, PageResponse } from "../../base/query/v1beta1/pagination"; import { Any } from "../../../google/protobuf/any"; import { Params } from "./auth"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../helpers"; +import { isSet, DeepPartial, Exact, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.auth.v1beta1"; /** * QueryAccountsRequest is the request type for the Query/Accounts RPC method. @@ -87,6 +87,19 @@ export const QueryAccountsRequest = { return message; }, + fromJSON(object: any): QueryAccountsRequest { + return { + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryAccountsRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryAccountsRequest { const message = createBaseQueryAccountsRequest(); message.pagination = @@ -143,6 +156,27 @@ export const QueryAccountsResponse = { return message; }, + fromJSON(object: any): QueryAccountsResponse { + return { + accounts: Array.isArray(object?.accounts) ? object.accounts.map((e: any) => Any.fromJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryAccountsResponse): unknown { + const obj: any = {}; + + if (message.accounts) { + obj.accounts = message.accounts.map((e) => (e ? Any.toJSON(e) : undefined)); + } else { + obj.accounts = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryAccountsResponse { const message = createBaseQueryAccountsResponse(); message.accounts = object.accounts?.map((e) => Any.fromPartial(e)) || []; @@ -191,6 +225,18 @@ export const QueryAccountRequest = { return message; }, + fromJSON(object: any): QueryAccountRequest { + return { + address: isSet(object.address) ? String(object.address) : "", + }; + }, + + toJSON(message: QueryAccountRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + return obj; + }, + fromPartial, I>>(object: I): QueryAccountRequest { const message = createBaseQueryAccountRequest(); message.address = object.address ?? ""; @@ -235,6 +281,19 @@ export const QueryAccountResponse = { return message; }, + fromJSON(object: any): QueryAccountResponse { + return { + account: isSet(object.account) ? Any.fromJSON(object.account) : undefined, + }; + }, + + toJSON(message: QueryAccountResponse): unknown { + const obj: any = {}; + message.account !== undefined && + (obj.account = message.account ? Any.toJSON(message.account) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryAccountResponse { const message = createBaseQueryAccountResponse(); message.account = @@ -270,6 +329,15 @@ export const QueryParamsRequest = { return message; }, + fromJSON(_: any): QueryParamsRequest { + return {}; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryParamsRequest { const message = createBaseQueryParamsRequest(); return message; @@ -313,6 +381,18 @@ export const QueryParamsResponse = { return message; }, + fromJSON(object: any): QueryParamsResponse { + return { + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + }; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryParamsResponse { const message = createBaseQueryParamsResponse(); message.params = diff --git a/src/cosmos/authz/v1beta1/authz.ts b/src/cosmos/authz/v1beta1/authz.ts index df4ce10b..8a3ad8a0 100644 --- a/src/cosmos/authz/v1beta1/authz.ts +++ b/src/cosmos/authz/v1beta1/authz.ts @@ -2,7 +2,7 @@ import { Any } from "../../../google/protobuf/any"; import { Timestamp } from "../../../google/protobuf/timestamp"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../helpers"; +import { isSet, DeepPartial, Exact, fromJsonTimestamp, fromTimestamp } from "../../../helpers"; export const protobufPackage = "cosmos.authz.v1beta1"; /** * GenericAuthorization gives the grantee unrestricted permissions to execute @@ -73,6 +73,18 @@ export const GenericAuthorization = { return message; }, + fromJSON(object: any): GenericAuthorization { + return { + msg: isSet(object.msg) ? String(object.msg) : "", + }; + }, + + toJSON(message: GenericAuthorization): unknown { + const obj: any = {}; + message.msg !== undefined && (obj.msg = message.msg); + return obj; + }, + fromPartial, I>>(object: I): GenericAuthorization { const message = createBaseGenericAuthorization(); message.msg = object.msg ?? ""; @@ -126,6 +138,21 @@ export const Grant = { return message; }, + fromJSON(object: any): Grant { + return { + authorization: isSet(object.authorization) ? Any.fromJSON(object.authorization) : undefined, + expiration: isSet(object.expiration) ? fromJsonTimestamp(object.expiration) : undefined, + }; + }, + + toJSON(message: Grant): unknown { + const obj: any = {}; + message.authorization !== undefined && + (obj.authorization = message.authorization ? Any.toJSON(message.authorization) : undefined); + message.expiration !== undefined && (obj.expiration = fromTimestamp(message.expiration).toISOString()); + return obj; + }, + fromPartial, I>>(object: I): Grant { const message = createBaseGrant(); message.authorization = @@ -204,6 +231,25 @@ export const GrantAuthorization = { return message; }, + fromJSON(object: any): GrantAuthorization { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + grantee: isSet(object.grantee) ? String(object.grantee) : "", + authorization: isSet(object.authorization) ? Any.fromJSON(object.authorization) : undefined, + expiration: isSet(object.expiration) ? fromJsonTimestamp(object.expiration) : undefined, + }; + }, + + toJSON(message: GrantAuthorization): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + message.authorization !== undefined && + (obj.authorization = message.authorization ? Any.toJSON(message.authorization) : undefined); + message.expiration !== undefined && (obj.expiration = fromTimestamp(message.expiration).toISOString()); + return obj; + }, + fromPartial, I>>(object: I): GrantAuthorization { const message = createBaseGrantAuthorization(); message.granter = object.granter ?? ""; diff --git a/src/cosmos/authz/v1beta1/genesis.ts b/src/cosmos/authz/v1beta1/genesis.ts index e88a09cc..5ea32643 100644 --- a/src/cosmos/authz/v1beta1/genesis.ts +++ b/src/cosmos/authz/v1beta1/genesis.ts @@ -46,6 +46,26 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + authorization: Array.isArray(object?.authorization) + ? object.authorization.map((e: any) => GrantAuthorization.fromJSON(e)) + : [], + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + + if (message.authorization) { + obj.authorization = message.authorization.map((e) => (e ? GrantAuthorization.toJSON(e) : undefined)); + } else { + obj.authorization = []; + } + + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.authorization = object.authorization?.map((e) => GrantAuthorization.fromPartial(e)) || []; diff --git a/src/cosmos/authz/v1beta1/query.ts b/src/cosmos/authz/v1beta1/query.ts index e604891a..31c51ae2 100644 --- a/src/cosmos/authz/v1beta1/query.ts +++ b/src/cosmos/authz/v1beta1/query.ts @@ -2,7 +2,7 @@ import { PageRequest, PageResponse } from "../../base/query/v1beta1/pagination"; import { Grant, GrantAuthorization } from "./authz"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../helpers"; +import { isSet, DeepPartial, Exact, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.authz.v1beta1"; /** QueryGrantsRequest is the request type for the Query/Grants RPC method. */ @@ -124,6 +124,25 @@ export const QueryGrantsRequest = { return message; }, + fromJSON(object: any): QueryGrantsRequest { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + grantee: isSet(object.grantee) ? String(object.grantee) : "", + msgTypeUrl: isSet(object.msgTypeUrl) ? String(object.msgTypeUrl) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryGrantsRequest): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + message.msgTypeUrl !== undefined && (obj.msgTypeUrl = message.msgTypeUrl); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryGrantsRequest { const message = createBaseQueryGrantsRequest(); message.granter = object.granter ?? ""; @@ -183,6 +202,27 @@ export const QueryGrantsResponse = { return message; }, + fromJSON(object: any): QueryGrantsResponse { + return { + grants: Array.isArray(object?.grants) ? object.grants.map((e: any) => Grant.fromJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryGrantsResponse): unknown { + const obj: any = {}; + + if (message.grants) { + obj.grants = message.grants.map((e) => (e ? Grant.toJSON(e) : undefined)); + } else { + obj.grants = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryGrantsResponse { const message = createBaseQueryGrantsResponse(); message.grants = object.grants?.map((e) => Grant.fromPartial(e)) || []; @@ -240,6 +280,21 @@ export const QueryGranterGrantsRequest = { return message; }, + fromJSON(object: any): QueryGranterGrantsRequest { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryGranterGrantsRequest): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryGranterGrantsRequest { @@ -299,6 +354,29 @@ export const QueryGranterGrantsResponse = { return message; }, + fromJSON(object: any): QueryGranterGrantsResponse { + return { + grants: Array.isArray(object?.grants) + ? object.grants.map((e: any) => GrantAuthorization.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryGranterGrantsResponse): unknown { + const obj: any = {}; + + if (message.grants) { + obj.grants = message.grants.map((e) => (e ? GrantAuthorization.toJSON(e) : undefined)); + } else { + obj.grants = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryGranterGrantsResponse { @@ -358,6 +436,21 @@ export const QueryGranteeGrantsRequest = { return message; }, + fromJSON(object: any): QueryGranteeGrantsRequest { + return { + grantee: isSet(object.grantee) ? String(object.grantee) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryGranteeGrantsRequest): unknown { + const obj: any = {}; + message.grantee !== undefined && (obj.grantee = message.grantee); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryGranteeGrantsRequest { @@ -417,6 +510,29 @@ export const QueryGranteeGrantsResponse = { return message; }, + fromJSON(object: any): QueryGranteeGrantsResponse { + return { + grants: Array.isArray(object?.grants) + ? object.grants.map((e: any) => GrantAuthorization.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryGranteeGrantsResponse): unknown { + const obj: any = {}; + + if (message.grants) { + obj.grants = message.grants.map((e) => (e ? GrantAuthorization.toJSON(e) : undefined)); + } else { + obj.grants = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryGranteeGrantsResponse { diff --git a/src/cosmos/authz/v1beta1/tx.ts b/src/cosmos/authz/v1beta1/tx.ts index 14cf4135..9071ecc8 100644 --- a/src/cosmos/authz/v1beta1/tx.ts +++ b/src/cosmos/authz/v1beta1/tx.ts @@ -2,7 +2,7 @@ import { Grant } from "./authz"; import { Any } from "../../../google/protobuf/any"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../helpers"; +import { isSet, DeepPartial, Exact, bytesFromBase64, base64FromBytes, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.authz.v1beta1"; /** * MsgGrant is a request type for Grant method. It declares authorization to the grantee @@ -107,6 +107,22 @@ export const MsgGrant = { return message; }, + fromJSON(object: any): MsgGrant { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + grantee: isSet(object.grantee) ? String(object.grantee) : "", + grant: isSet(object.grant) ? Grant.fromJSON(object.grant) : undefined, + }; + }, + + toJSON(message: MsgGrant): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + message.grant !== undefined && (obj.grant = message.grant ? Grant.toJSON(message.grant) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgGrant { const message = createBaseMsgGrant(); message.granter = object.granter ?? ""; @@ -154,6 +170,24 @@ export const MsgExecResponse = { return message; }, + fromJSON(object: any): MsgExecResponse { + return { + results: Array.isArray(object?.results) ? object.results.map((e: any) => bytesFromBase64(e)) : [], + }; + }, + + toJSON(message: MsgExecResponse): unknown { + const obj: any = {}; + + if (message.results) { + obj.results = message.results.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.results = []; + } + + return obj; + }, + fromPartial, I>>(object: I): MsgExecResponse { const message = createBaseMsgExecResponse(); message.results = object.results?.map((e) => e) || []; @@ -207,6 +241,26 @@ export const MsgExec = { return message; }, + fromJSON(object: any): MsgExec { + return { + grantee: isSet(object.grantee) ? String(object.grantee) : "", + msgs: Array.isArray(object?.msgs) ? object.msgs.map((e: any) => Any.fromJSON(e)) : [], + }; + }, + + toJSON(message: MsgExec): unknown { + const obj: any = {}; + message.grantee !== undefined && (obj.grantee = message.grantee); + + if (message.msgs) { + obj.msgs = message.msgs.map((e) => (e ? Any.toJSON(e) : undefined)); + } else { + obj.msgs = []; + } + + return obj; + }, + fromPartial, I>>(object: I): MsgExec { const message = createBaseMsgExec(); message.grantee = object.grantee ?? ""; @@ -242,6 +296,15 @@ export const MsgGrantResponse = { return message; }, + fromJSON(_: any): MsgGrantResponse { + return {}; + }, + + toJSON(_: MsgGrantResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgGrantResponse { const message = createBaseMsgGrantResponse(); return message; @@ -303,6 +366,22 @@ export const MsgRevoke = { return message; }, + fromJSON(object: any): MsgRevoke { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + grantee: isSet(object.grantee) ? String(object.grantee) : "", + msgTypeUrl: isSet(object.msgTypeUrl) ? String(object.msgTypeUrl) : "", + }; + }, + + toJSON(message: MsgRevoke): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + message.msgTypeUrl !== undefined && (obj.msgTypeUrl = message.msgTypeUrl); + return obj; + }, + fromPartial, I>>(object: I): MsgRevoke { const message = createBaseMsgRevoke(); message.granter = object.granter ?? ""; @@ -339,6 +418,15 @@ export const MsgRevokeResponse = { return message; }, + fromJSON(_: any): MsgRevokeResponse { + return {}; + }, + + toJSON(_: MsgRevokeResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgRevokeResponse { const message = createBaseMsgRevokeResponse(); return message; diff --git a/src/cosmos/bank/v1beta1/authz.ts b/src/cosmos/bank/v1beta1/authz.ts index 8ec953fb..9eb22de7 100644 --- a/src/cosmos/bank/v1beta1/authz.ts +++ b/src/cosmos/bank/v1beta1/authz.ts @@ -51,6 +51,26 @@ export const SendAuthorization = { return message; }, + fromJSON(object: any): SendAuthorization { + return { + spendLimit: Array.isArray(object?.spendLimit) + ? object.spendLimit.map((e: any) => Coin.fromJSON(e)) + : [], + }; + }, + + toJSON(message: SendAuthorization): unknown { + const obj: any = {}; + + if (message.spendLimit) { + obj.spendLimit = message.spendLimit.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.spendLimit = []; + } + + return obj; + }, + fromPartial, I>>(object: I): SendAuthorization { const message = createBaseSendAuthorization(); message.spendLimit = object.spendLimit?.map((e) => Coin.fromPartial(e)) || []; diff --git a/src/cosmos/bank/v1beta1/bank.ts b/src/cosmos/bank/v1beta1/bank.ts index 16c0a3e9..24ee7489 100644 --- a/src/cosmos/bank/v1beta1/bank.ts +++ b/src/cosmos/bank/v1beta1/bank.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Coin } from "../../base/v1beta1/coin"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../helpers"; export const protobufPackage = "cosmos.bank.v1beta1"; /** Params defines the parameters for the bank module. */ @@ -144,6 +144,28 @@ export const Params = { return message; }, + fromJSON(object: any): Params { + return { + sendEnabled: Array.isArray(object?.sendEnabled) + ? object.sendEnabled.map((e: any) => SendEnabled.fromJSON(e)) + : [], + defaultSendEnabled: isSet(object.defaultSendEnabled) ? Boolean(object.defaultSendEnabled) : false, + }; + }, + + 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, I>>(object: I): Params { const message = createBaseParams(); message.sendEnabled = object.sendEnabled?.map((e) => SendEnabled.fromPartial(e)) || []; @@ -198,6 +220,20 @@ export const SendEnabled = { return message; }, + fromJSON(object: any): SendEnabled { + return { + denom: isSet(object.denom) ? String(object.denom) : "", + enabled: isSet(object.enabled) ? Boolean(object.enabled) : false, + }; + }, + + toJSON(message: SendEnabled): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.enabled !== undefined && (obj.enabled = message.enabled); + return obj; + }, + fromPartial, I>>(object: I): SendEnabled { const message = createBaseSendEnabled(); message.denom = object.denom ?? ""; @@ -252,6 +288,26 @@ export const Input = { return message; }, + fromJSON(object: any): Input { + return { + address: isSet(object.address) ? String(object.address) : "", + coins: Array.isArray(object?.coins) ? object.coins.map((e: any) => Coin.fromJSON(e)) : [], + }; + }, + + 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, I>>(object: I): Input { const message = createBaseInput(); message.address = object.address ?? ""; @@ -306,6 +362,26 @@ export const Output = { return message; }, + fromJSON(object: any): Output { + return { + address: isSet(object.address) ? String(object.address) : "", + coins: Array.isArray(object?.coins) ? object.coins.map((e: any) => Coin.fromJSON(e)) : [], + }; + }, + + 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, I>>(object: I): Output { const message = createBaseOutput(); message.address = object.address ?? ""; @@ -351,6 +427,24 @@ export const Supply = { return message; }, + fromJSON(object: any): Supply { + return { + total: Array.isArray(object?.total) ? object.total.map((e: any) => Coin.fromJSON(e)) : [], + }; + }, + + 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, I>>(object: I): Supply { const message = createBaseSupply(); message.total = object.total?.map((e) => Coin.fromPartial(e)) || []; @@ -413,6 +507,28 @@ export const DenomUnit = { return message; }, + fromJSON(object: any): DenomUnit { + return { + denom: isSet(object.denom) ? String(object.denom) : "", + exponent: isSet(object.exponent) ? Number(object.exponent) : 0, + aliases: Array.isArray(object?.aliases) ? object.aliases.map((e: any) => String(e)) : [], + }; + }, + + toJSON(message: DenomUnit): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.exponent !== undefined && (obj.exponent = Math.round(message.exponent)); + + if (message.aliases) { + obj.aliases = message.aliases.map((e) => e); + } else { + obj.aliases = []; + } + + return obj; + }, + fromPartial, I>>(object: I): DenomUnit { const message = createBaseDenomUnit(); message.denom = object.denom ?? ""; @@ -504,6 +620,36 @@ export const Metadata = { return message; }, + fromJSON(object: any): Metadata { + return { + description: isSet(object.description) ? String(object.description) : "", + denomUnits: Array.isArray(object?.denomUnits) + ? object.denomUnits.map((e: any) => DenomUnit.fromJSON(e)) + : [], + base: isSet(object.base) ? String(object.base) : "", + display: isSet(object.display) ? String(object.display) : "", + name: isSet(object.name) ? String(object.name) : "", + symbol: isSet(object.symbol) ? String(object.symbol) : "", + }; + }, + + 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); + message.name !== undefined && (obj.name = message.name); + message.symbol !== undefined && (obj.symbol = message.symbol); + return obj; + }, + fromPartial, I>>(object: I): Metadata { const message = createBaseMetadata(); message.description = object.description ?? ""; diff --git a/src/cosmos/bank/v1beta1/genesis.ts b/src/cosmos/bank/v1beta1/genesis.ts index bdd4f1cf..70766eef 100644 --- a/src/cosmos/bank/v1beta1/genesis.ts +++ b/src/cosmos/bank/v1beta1/genesis.ts @@ -2,7 +2,7 @@ import { Params, Metadata } from "./bank"; import { Coin } from "../../base/v1beta1/coin"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../helpers"; export const protobufPackage = "cosmos.bank.v1beta1"; /** GenesisState defines the bank module's genesis state. */ @@ -99,6 +99,42 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + balances: Array.isArray(object?.balances) ? object.balances.map((e: any) => Balance.fromJSON(e)) : [], + supply: Array.isArray(object?.supply) ? object.supply.map((e: any) => Coin.fromJSON(e)) : [], + denomMetadata: Array.isArray(object?.denomMetadata) + ? object.denomMetadata.map((e: any) => Metadata.fromJSON(e)) + : [], + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + + if (message.balances) { + obj.balances = message.balances.map((e) => (e ? Balance.toJSON(e) : undefined)); + } else { + obj.balances = []; + } + + if (message.supply) { + obj.supply = message.supply.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.supply = []; + } + + if (message.denomMetadata) { + obj.denomMetadata = message.denomMetadata.map((e) => (e ? Metadata.toJSON(e) : undefined)); + } else { + obj.denomMetadata = []; + } + + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.params = @@ -156,6 +192,26 @@ export const Balance = { return message; }, + fromJSON(object: any): Balance { + return { + address: isSet(object.address) ? String(object.address) : "", + coins: Array.isArray(object?.coins) ? object.coins.map((e: any) => Coin.fromJSON(e)) : [], + }; + }, + + toJSON(message: Balance): 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, I>>(object: I): Balance { const message = createBaseBalance(); message.address = object.address ?? ""; diff --git a/src/cosmos/bank/v1beta1/query.ts b/src/cosmos/bank/v1beta1/query.ts index 6c46ba05..e858002d 100644 --- a/src/cosmos/bank/v1beta1/query.ts +++ b/src/cosmos/bank/v1beta1/query.ts @@ -3,7 +3,7 @@ import { PageRequest, PageResponse } from "../../base/query/v1beta1/pagination"; import { Coin } from "../../base/v1beta1/coin"; import { Params, Metadata } from "./bank"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../helpers"; +import { isSet, DeepPartial, Exact, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.bank.v1beta1"; /** QueryBalanceRequest is the request type for the Query/Balance RPC method. */ @@ -194,6 +194,20 @@ export const QueryBalanceRequest = { return message; }, + fromJSON(object: any): QueryBalanceRequest { + return { + address: isSet(object.address) ? String(object.address) : "", + denom: isSet(object.denom) ? String(object.denom) : "", + }; + }, + + toJSON(message: QueryBalanceRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.denom !== undefined && (obj.denom = message.denom); + return obj; + }, + fromPartial, I>>(object: I): QueryBalanceRequest { const message = createBaseQueryBalanceRequest(); message.address = object.address ?? ""; @@ -239,6 +253,19 @@ export const QueryBalanceResponse = { return message; }, + fromJSON(object: any): QueryBalanceResponse { + return { + balance: isSet(object.balance) ? Coin.fromJSON(object.balance) : undefined, + }; + }, + + toJSON(message: QueryBalanceResponse): unknown { + const obj: any = {}; + message.balance !== undefined && + (obj.balance = message.balance ? Coin.toJSON(message.balance) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryBalanceResponse { const message = createBaseQueryBalanceResponse(); message.balance = @@ -293,6 +320,21 @@ export const QueryAllBalancesRequest = { return message; }, + fromJSON(object: any): QueryAllBalancesRequest { + return { + address: isSet(object.address) ? String(object.address) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>(object: I): QueryAllBalancesRequest { const message = createBaseQueryAllBalancesRequest(); message.address = object.address ?? ""; @@ -350,6 +392,27 @@ export const QueryAllBalancesResponse = { return message; }, + fromJSON(object: any): QueryAllBalancesResponse { + return { + balances: Array.isArray(object?.balances) ? object.balances.map((e: any) => Coin.fromJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryAllBalancesResponse { @@ -409,6 +472,21 @@ export const QuerySpendableBalancesRequest = { return message; }, + fromJSON(object: any): QuerySpendableBalancesRequest { + return { + address: isSet(object.address) ? String(object.address) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QuerySpendableBalancesRequest): 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, I>>( object: I, ): QuerySpendableBalancesRequest { @@ -468,6 +546,27 @@ export const QuerySpendableBalancesResponse = { return message; }, + fromJSON(object: any): QuerySpendableBalancesResponse { + return { + balances: Array.isArray(object?.balances) ? object.balances.map((e: any) => Coin.fromJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QuerySpendableBalancesResponse): 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, I>>( object: I, ): QuerySpendableBalancesResponse { @@ -518,6 +617,19 @@ export const QueryTotalSupplyRequest = { return message; }, + fromJSON(object: any): QueryTotalSupplyRequest { + return { + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryTotalSupplyRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryTotalSupplyRequest { const message = createBaseQueryTotalSupplyRequest(); message.pagination = @@ -574,6 +686,27 @@ export const QueryTotalSupplyResponse = { return message; }, + fromJSON(object: any): QueryTotalSupplyResponse { + return { + supply: Array.isArray(object?.supply) ? object.supply.map((e: any) => Coin.fromJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryTotalSupplyResponse): unknown { + const obj: any = {}; + + if (message.supply) { + obj.supply = message.supply.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.supply = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryTotalSupplyResponse { @@ -624,6 +757,18 @@ export const QuerySupplyOfRequest = { return message; }, + fromJSON(object: any): QuerySupplyOfRequest { + return { + denom: isSet(object.denom) ? String(object.denom) : "", + }; + }, + + toJSON(message: QuerySupplyOfRequest): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + return obj; + }, + fromPartial, I>>(object: I): QuerySupplyOfRequest { const message = createBaseQuerySupplyOfRequest(); message.denom = object.denom ?? ""; @@ -668,6 +813,18 @@ export const QuerySupplyOfResponse = { return message; }, + fromJSON(object: any): QuerySupplyOfResponse { + return { + amount: isSet(object.amount) ? Coin.fromJSON(object.amount) : undefined, + }; + }, + + toJSON(message: QuerySupplyOfResponse): unknown { + const obj: any = {}; + message.amount !== undefined && (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QuerySupplyOfResponse { const message = createBaseQuerySupplyOfResponse(); message.amount = @@ -703,6 +860,15 @@ export const QueryParamsRequest = { return message; }, + fromJSON(_: any): QueryParamsRequest { + return {}; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryParamsRequest { const message = createBaseQueryParamsRequest(); return message; @@ -746,6 +912,18 @@ export const QueryParamsResponse = { return message; }, + fromJSON(object: any): QueryParamsResponse { + return { + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + }; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryParamsResponse { const message = createBaseQueryParamsResponse(); message.params = @@ -791,6 +969,19 @@ export const QueryDenomsMetadataRequest = { return message; }, + fromJSON(object: any): QueryDenomsMetadataRequest { + return { + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryDenomsMetadataRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryDenomsMetadataRequest { @@ -849,6 +1040,29 @@ export const QueryDenomsMetadataResponse = { return message; }, + fromJSON(object: any): QueryDenomsMetadataResponse { + return { + metadatas: Array.isArray(object?.metadatas) + ? object.metadatas.map((e: any) => Metadata.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryDenomsMetadataResponse): unknown { + const obj: any = {}; + + if (message.metadatas) { + obj.metadatas = message.metadatas.map((e) => (e ? Metadata.toJSON(e) : undefined)); + } else { + obj.metadatas = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryDenomsMetadataResponse { @@ -899,6 +1113,18 @@ export const QueryDenomMetadataRequest = { return message; }, + fromJSON(object: any): QueryDenomMetadataRequest { + return { + denom: isSet(object.denom) ? String(object.denom) : "", + }; + }, + + toJSON(message: QueryDenomMetadataRequest): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + return obj; + }, + fromPartial, I>>( object: I, ): QueryDenomMetadataRequest { @@ -945,6 +1171,19 @@ export const QueryDenomMetadataResponse = { return message; }, + fromJSON(object: any): QueryDenomMetadataResponse { + return { + metadata: isSet(object.metadata) ? Metadata.fromJSON(object.metadata) : undefined, + }; + }, + + toJSON(message: QueryDenomMetadataResponse): unknown { + const obj: any = {}; + message.metadata !== undefined && + (obj.metadata = message.metadata ? Metadata.toJSON(message.metadata) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryDenomMetadataResponse { diff --git a/src/cosmos/bank/v1beta1/tx.ts b/src/cosmos/bank/v1beta1/tx.ts index 0e38c6e4..5f8823f5 100644 --- a/src/cosmos/bank/v1beta1/tx.ts +++ b/src/cosmos/bank/v1beta1/tx.ts @@ -2,7 +2,7 @@ import { Coin } from "../../base/v1beta1/coin"; import { Input, Output } from "./bank"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../helpers"; +import { isSet, DeepPartial, Exact, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.bank.v1beta1"; /** MsgSend represents a message to send coins from one account to another. */ @@ -79,6 +79,28 @@ export const MsgSend = { return message; }, + fromJSON(object: any): MsgSend { + return { + fromAddress: isSet(object.fromAddress) ? String(object.fromAddress) : "", + toAddress: isSet(object.toAddress) ? String(object.toAddress) : "", + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromJSON(e)) : [], + }; + }, + + 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, I>>(object: I): MsgSend { const message = createBaseMsgSend(); message.fromAddress = object.fromAddress ?? ""; @@ -115,6 +137,15 @@ export const MsgSendResponse = { return message; }, + fromJSON(_: any): MsgSendResponse { + return {}; + }, + + toJSON(_: MsgSendResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgSendResponse { const message = createBaseMsgSendResponse(); return message; @@ -167,6 +198,31 @@ export const MsgMultiSend = { return message; }, + fromJSON(object: any): MsgMultiSend { + return { + inputs: Array.isArray(object?.inputs) ? object.inputs.map((e: any) => Input.fromJSON(e)) : [], + outputs: Array.isArray(object?.outputs) ? object.outputs.map((e: any) => Output.fromJSON(e)) : [], + }; + }, + + 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, I>>(object: I): MsgMultiSend { const message = createBaseMsgMultiSend(); message.inputs = object.inputs?.map((e) => Input.fromPartial(e)) || []; @@ -202,6 +258,15 @@ export const MsgMultiSendResponse = { return message; }, + fromJSON(_: any): MsgMultiSendResponse { + return {}; + }, + + toJSON(_: MsgMultiSendResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgMultiSendResponse { const message = createBaseMsgMultiSendResponse(); return message; diff --git a/src/cosmos/base/abci/v1beta1/abci.ts b/src/cosmos/base/abci/v1beta1/abci.ts index d9619ef5..8e206afe 100644 --- a/src/cosmos/base/abci/v1beta1/abci.ts +++ b/src/cosmos/base/abci/v1beta1/abci.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Any } from "../../../../google/protobuf/any"; import { Event } from "../../../../tendermint/abci/types"; -import { Long, DeepPartial, Exact } from "../../../../helpers"; +import { Long, isSet, DeepPartial, Exact, bytesFromBase64, base64FromBytes } from "../../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "cosmos.base.abci.v1beta1"; /** @@ -313,6 +313,54 @@ export const TxResponse = { return message; }, + fromJSON(object: any): TxResponse { + return { + height: isSet(object.height) ? Long.fromValue(object.height) : Long.ZERO, + txhash: isSet(object.txhash) ? String(object.txhash) : "", + codespace: isSet(object.codespace) ? String(object.codespace) : "", + code: isSet(object.code) ? Number(object.code) : 0, + data: isSet(object.data) ? String(object.data) : "", + rawLog: isSet(object.rawLog) ? String(object.rawLog) : "", + logs: Array.isArray(object?.logs) ? object.logs.map((e: any) => ABCIMessageLog.fromJSON(e)) : [], + info: isSet(object.info) ? String(object.info) : "", + gasWanted: isSet(object.gasWanted) ? Long.fromValue(object.gasWanted) : Long.ZERO, + gasUsed: isSet(object.gasUsed) ? Long.fromValue(object.gasUsed) : Long.ZERO, + tx: isSet(object.tx) ? Any.fromJSON(object.tx) : undefined, + timestamp: isSet(object.timestamp) ? String(object.timestamp) : "", + events: Array.isArray(object?.events) ? object.events.map((e: any) => Event.fromJSON(e)) : [], + }; + }, + + 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 = Math.round(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); + + if (message.events) { + obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); + } else { + obj.events = []; + } + + return obj; + }, + fromPartial, I>>(object: I): TxResponse { const message = createBaseTxResponse(); message.height = @@ -392,6 +440,28 @@ export const ABCIMessageLog = { return message; }, + fromJSON(object: any): ABCIMessageLog { + return { + msgIndex: isSet(object.msgIndex) ? Number(object.msgIndex) : 0, + log: isSet(object.log) ? String(object.log) : "", + events: Array.isArray(object?.events) ? object.events.map((e: any) => StringEvent.fromJSON(e)) : [], + }; + }, + + toJSON(message: ABCIMessageLog): unknown { + const obj: any = {}; + message.msgIndex !== undefined && (obj.msgIndex = Math.round(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, I>>(object: I): ABCIMessageLog { const message = createBaseABCIMessageLog(); message.msgIndex = object.msgIndex ?? 0; @@ -447,6 +517,28 @@ export const StringEvent = { return message; }, + fromJSON(object: any): StringEvent { + return { + type: isSet(object.type) ? String(object.type) : "", + attributes: Array.isArray(object?.attributes) + ? object.attributes.map((e: any) => Attribute.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): StringEvent { const message = createBaseStringEvent(); message.type = object.type ?? ""; @@ -501,6 +593,20 @@ export const Attribute = { return message; }, + fromJSON(object: any): Attribute { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "", + }; + }, + + toJSON(message: Attribute): unknown { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial, I>>(object: I): Attribute { const message = createBaseAttribute(); message.key = object.key ?? ""; @@ -555,6 +661,20 @@ export const GasInfo = { return message; }, + fromJSON(object: any): GasInfo { + return { + gasWanted: isSet(object.gasWanted) ? Long.fromValue(object.gasWanted) : Long.UZERO, + gasUsed: isSet(object.gasUsed) ? Long.fromValue(object.gasUsed) : Long.UZERO, + }; + }, + + 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, I>>(object: I): GasInfo { const message = createBaseGasInfo(); message.gasWanted = @@ -622,6 +742,29 @@ export const Result = { return message; }, + fromJSON(object: any): Result { + return { + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + log: isSet(object.log) ? String(object.log) : "", + events: Array.isArray(object?.events) ? object.events.map((e: any) => Event.fromJSON(e)) : [], + }; + }, + + 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, I>>(object: I): Result { const message = createBaseResult(); message.data = object.data ?? new Uint8Array(); @@ -677,6 +820,21 @@ export const SimulationResponse = { return message; }, + fromJSON(object: any): SimulationResponse { + return { + gasInfo: isSet(object.gasInfo) ? GasInfo.fromJSON(object.gasInfo) : undefined, + result: isSet(object.result) ? Result.fromJSON(object.result) : undefined, + }; + }, + + 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, I>>(object: I): SimulationResponse { const message = createBaseSimulationResponse(); message.gasInfo = @@ -735,6 +893,21 @@ export const MsgData = { return message; }, + fromJSON(object: any): MsgData { + return { + msgType: isSet(object.msgType) ? String(object.msgType) : "", + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + }; + }, + + 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, I>>(object: I): MsgData { const message = createBaseMsgData(); message.msgType = object.msgType ?? ""; @@ -780,6 +953,24 @@ export const TxMsgData = { return message; }, + fromJSON(object: any): TxMsgData { + return { + data: Array.isArray(object?.data) ? object.data.map((e: any) => MsgData.fromJSON(e)) : [], + }; + }, + + 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, I>>(object: I): TxMsgData { const message = createBaseTxMsgData(); message.data = object.data?.map((e) => MsgData.fromPartial(e)) || []; @@ -869,6 +1060,34 @@ export const SearchTxsResult = { return message; }, + fromJSON(object: any): SearchTxsResult { + return { + totalCount: isSet(object.totalCount) ? Long.fromValue(object.totalCount) : Long.UZERO, + count: isSet(object.count) ? Long.fromValue(object.count) : Long.UZERO, + pageNumber: isSet(object.pageNumber) ? Long.fromValue(object.pageNumber) : Long.UZERO, + pageTotal: isSet(object.pageTotal) ? Long.fromValue(object.pageTotal) : Long.UZERO, + limit: isSet(object.limit) ? Long.fromValue(object.limit) : Long.UZERO, + txs: Array.isArray(object?.txs) ? object.txs.map((e: any) => TxResponse.fromJSON(e)) : [], + }; + }, + + 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, I>>(object: I): SearchTxsResult { const message = createBaseSearchTxsResult(); message.totalCount = diff --git a/src/cosmos/base/kv/v1beta1/kv.ts b/src/cosmos/base/kv/v1beta1/kv.ts index 0708b74d..c6e9c045 100644 --- a/src/cosmos/base/kv/v1beta1/kv.ts +++ b/src/cosmos/base/kv/v1beta1/kv.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../../helpers"; +import { DeepPartial, Exact, isSet, bytesFromBase64, base64FromBytes } from "../../../../helpers"; export const protobufPackage = "cosmos.base.kv.v1beta1"; /** Pairs defines a repeated slice of Pair objects. */ @@ -51,6 +51,24 @@ export const Pairs = { return message; }, + fromJSON(object: any): Pairs { + return { + pairs: Array.isArray(object?.pairs) ? object.pairs.map((e: any) => Pair.fromJSON(e)) : [], + }; + }, + + toJSON(message: Pairs): unknown { + const obj: any = {}; + + if (message.pairs) { + obj.pairs = message.pairs.map((e) => (e ? Pair.toJSON(e) : undefined)); + } else { + obj.pairs = []; + } + + return obj; + }, + fromPartial, I>>(object: I): Pairs { const message = createBasePairs(); message.pairs = object.pairs?.map((e) => Pair.fromPartial(e)) || []; @@ -104,6 +122,22 @@ export const Pair = { return message; }, + fromJSON(object: any): Pair { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), + }; + }, + + toJSON(message: Pair): 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, I>>(object: I): Pair { const message = createBasePair(); message.key = object.key ?? new Uint8Array(); diff --git a/src/cosmos/base/query/v1beta1/pagination.ts b/src/cosmos/base/query/v1beta1/pagination.ts index 97b259f4..ba180de6 100644 --- a/src/cosmos/base/query/v1beta1/pagination.ts +++ b/src/cosmos/base/query/v1beta1/pagination.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -import { Long, DeepPartial, Exact } from "../../../../helpers"; +import { Long, isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact } from "../../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "cosmos.base.query.v1beta1"; /** @@ -145,6 +145,27 @@ export const PageRequest = { return message; }, + fromJSON(object: any): PageRequest { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + offset: isSet(object.offset) ? Long.fromValue(object.offset) : Long.UZERO, + limit: isSet(object.limit) ? Long.fromValue(object.limit) : Long.UZERO, + countTotal: isSet(object.countTotal) ? Boolean(object.countTotal) : false, + reverse: isSet(object.reverse) ? Boolean(object.reverse) : false, + }; + }, + + 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); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + fromPartial, I>>(object: I): PageRequest { const message = createBasePageRequest(); message.key = object.key ?? new Uint8Array(); @@ -204,6 +225,21 @@ export const PageResponse = { return message; }, + fromJSON(object: any): PageResponse { + return { + nextKey: isSet(object.nextKey) ? bytesFromBase64(object.nextKey) : new Uint8Array(), + total: isSet(object.total) ? Long.fromValue(object.total) : Long.UZERO, + }; + }, + + 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, I>>(object: I): PageResponse { const message = createBasePageResponse(); message.nextKey = object.nextKey ?? new Uint8Array(); diff --git a/src/cosmos/base/reflection/v1beta1/reflection.ts b/src/cosmos/base/reflection/v1beta1/reflection.ts index 7fda9321..dbf3122d 100644 --- a/src/cosmos/base/reflection/v1beta1/reflection.ts +++ b/src/cosmos/base/reflection/v1beta1/reflection.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../../helpers"; +import { DeepPartial, Exact, isSet, Rpc } from "../../../../helpers"; export const protobufPackage = "cosmos.base.reflection.v1beta1"; /** ListAllInterfacesRequest is the request type of the ListAllInterfaces RPC. */ @@ -56,6 +56,15 @@ export const ListAllInterfacesRequest = { return message; }, + fromJSON(_: any): ListAllInterfacesRequest { + return {}; + }, + + toJSON(_: ListAllInterfacesRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): ListAllInterfacesRequest { const message = createBaseListAllInterfacesRequest(); return message; @@ -99,6 +108,26 @@ export const ListAllInterfacesResponse = { return message; }, + fromJSON(object: any): ListAllInterfacesResponse { + return { + interfaceNames: Array.isArray(object?.interfaceNames) + ? object.interfaceNames.map((e: any) => String(e)) + : [], + }; + }, + + toJSON(message: ListAllInterfacesResponse): unknown { + const obj: any = {}; + + if (message.interfaceNames) { + obj.interfaceNames = message.interfaceNames.map((e) => e); + } else { + obj.interfaceNames = []; + } + + return obj; + }, + fromPartial, I>>( object: I, ): ListAllInterfacesResponse { @@ -145,6 +174,18 @@ export const ListImplementationsRequest = { return message; }, + fromJSON(object: any): ListImplementationsRequest { + return { + interfaceName: isSet(object.interfaceName) ? String(object.interfaceName) : "", + }; + }, + + toJSON(message: ListImplementationsRequest): unknown { + const obj: any = {}; + message.interfaceName !== undefined && (obj.interfaceName = message.interfaceName); + return obj; + }, + fromPartial, I>>( object: I, ): ListImplementationsRequest { @@ -191,6 +232,26 @@ export const ListImplementationsResponse = { return message; }, + fromJSON(object: any): ListImplementationsResponse { + return { + implementationMessageNames: Array.isArray(object?.implementationMessageNames) + ? object.implementationMessageNames.map((e: any) => String(e)) + : [], + }; + }, + + toJSON(message: ListImplementationsResponse): unknown { + const obj: any = {}; + + if (message.implementationMessageNames) { + obj.implementationMessageNames = message.implementationMessageNames.map((e) => e); + } else { + obj.implementationMessageNames = []; + } + + return obj; + }, + fromPartial, I>>( object: I, ): ListImplementationsResponse { diff --git a/src/cosmos/base/snapshots/v1beta1/snapshot.ts b/src/cosmos/base/snapshots/v1beta1/snapshot.ts index 7c590347..ad18ee10 100644 --- a/src/cosmos/base/snapshots/v1beta1/snapshot.ts +++ b/src/cosmos/base/snapshots/v1beta1/snapshot.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -import { Long, DeepPartial, Exact } from "../../../../helpers"; +import { Long, isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact } from "../../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "cosmos.base.snapshots.v1beta1"; /** Snapshot contains Tendermint state sync snapshot info. */ @@ -127,6 +127,28 @@ export const Snapshot = { return message; }, + fromJSON(object: any): Snapshot { + return { + height: isSet(object.height) ? Long.fromValue(object.height) : Long.UZERO, + format: isSet(object.format) ? Number(object.format) : 0, + chunks: isSet(object.chunks) ? Number(object.chunks) : 0, + hash: isSet(object.hash) ? bytesFromBase64(object.hash) : new Uint8Array(), + metadata: isSet(object.metadata) ? Metadata.fromJSON(object.metadata) : undefined, + }; + }, + + toJSON(message: Snapshot): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.UZERO).toString()); + message.format !== undefined && (obj.format = Math.round(message.format)); + message.chunks !== undefined && (obj.chunks = Math.round(message.chunks)); + message.hash !== undefined && + (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); + message.metadata !== undefined && + (obj.metadata = message.metadata ? Metadata.toJSON(message.metadata) : undefined); + return obj; + }, + fromPartial, I>>(object: I): Snapshot { const message = createBaseSnapshot(); message.height = @@ -179,6 +201,28 @@ export const Metadata = { return message; }, + fromJSON(object: any): Metadata { + return { + chunkHashes: Array.isArray(object?.chunkHashes) + ? object.chunkHashes.map((e: any) => bytesFromBase64(e)) + : [], + }; + }, + + toJSON(message: Metadata): unknown { + const obj: any = {}; + + if (message.chunkHashes) { + obj.chunkHashes = message.chunkHashes.map((e) => + base64FromBytes(e !== undefined ? e : new Uint8Array()), + ); + } else { + obj.chunkHashes = []; + } + + return obj; + }, + fromPartial, I>>(object: I): Metadata { const message = createBaseMetadata(); message.chunkHashes = object.chunkHashes?.map((e) => e) || []; @@ -250,6 +294,32 @@ export const SnapshotItem = { return message; }, + fromJSON(object: any): SnapshotItem { + return { + store: isSet(object.store) ? SnapshotStoreItem.fromJSON(object.store) : undefined, + iavl: isSet(object.iavl) ? SnapshotIAVLItem.fromJSON(object.iavl) : undefined, + extension: isSet(object.extension) ? SnapshotExtensionMeta.fromJSON(object.extension) : undefined, + extensionPayload: isSet(object.extensionPayload) + ? SnapshotExtensionPayload.fromJSON(object.extensionPayload) + : undefined, + }; + }, + + toJSON(message: SnapshotItem): unknown { + const obj: any = {}; + message.store !== undefined && + (obj.store = message.store ? SnapshotStoreItem.toJSON(message.store) : undefined); + message.iavl !== undefined && + (obj.iavl = message.iavl ? SnapshotIAVLItem.toJSON(message.iavl) : undefined); + message.extension !== undefined && + (obj.extension = message.extension ? SnapshotExtensionMeta.toJSON(message.extension) : undefined); + message.extensionPayload !== undefined && + (obj.extensionPayload = message.extensionPayload + ? SnapshotExtensionPayload.toJSON(message.extensionPayload) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): SnapshotItem { const message = createBaseSnapshotItem(); message.store = @@ -309,6 +379,18 @@ export const SnapshotStoreItem = { return message; }, + fromJSON(object: any): SnapshotStoreItem { + return { + name: isSet(object.name) ? String(object.name) : "", + }; + }, + + toJSON(message: SnapshotStoreItem): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial, I>>(object: I): SnapshotStoreItem { const message = createBaseSnapshotStoreItem(); message.name = object.name ?? ""; @@ -380,6 +462,26 @@ export const SnapshotIAVLItem = { return message; }, + fromJSON(object: any): SnapshotIAVLItem { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), + version: isSet(object.version) ? Long.fromValue(object.version) : Long.ZERO, + height: isSet(object.height) ? Number(object.height) : 0, + }; + }, + + toJSON(message: SnapshotIAVLItem): 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.version !== undefined && (obj.version = (message.version || Long.ZERO).toString()); + message.height !== undefined && (obj.height = Math.round(message.height)); + return obj; + }, + fromPartial, I>>(object: I): SnapshotIAVLItem { const message = createBaseSnapshotIAVLItem(); message.key = object.key ?? new Uint8Array(); @@ -437,6 +539,20 @@ export const SnapshotExtensionMeta = { return message; }, + fromJSON(object: any): SnapshotExtensionMeta { + return { + name: isSet(object.name) ? String(object.name) : "", + format: isSet(object.format) ? Number(object.format) : 0, + }; + }, + + toJSON(message: SnapshotExtensionMeta): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.format !== undefined && (obj.format = Math.round(message.format)); + return obj; + }, + fromPartial, I>>(object: I): SnapshotExtensionMeta { const message = createBaseSnapshotExtensionMeta(); message.name = object.name ?? ""; @@ -482,6 +598,19 @@ export const SnapshotExtensionPayload = { return message; }, + fromJSON(object: any): SnapshotExtensionPayload { + return { + payload: isSet(object.payload) ? bytesFromBase64(object.payload) : new Uint8Array(), + }; + }, + + toJSON(message: SnapshotExtensionPayload): unknown { + const obj: any = {}; + message.payload !== undefined && + (obj.payload = base64FromBytes(message.payload !== undefined ? message.payload : new Uint8Array())); + return obj; + }, + fromPartial, I>>( object: I, ): SnapshotExtensionPayload { diff --git a/src/cosmos/base/store/v1beta1/commit_info.ts b/src/cosmos/base/store/v1beta1/commit_info.ts index 1040c58c..eac08288 100644 --- a/src/cosmos/base/store/v1beta1/commit_info.ts +++ b/src/cosmos/base/store/v1beta1/commit_info.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -import { Long, DeepPartial, Exact } from "../../../../helpers"; +import { Long, isSet, DeepPartial, Exact, bytesFromBase64, base64FromBytes } from "../../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "cosmos.base.store.v1beta1"; /** @@ -76,6 +76,28 @@ export const CommitInfo = { return message; }, + fromJSON(object: any): CommitInfo { + return { + version: isSet(object.version) ? Long.fromValue(object.version) : Long.ZERO, + storeInfos: Array.isArray(object?.storeInfos) + ? object.storeInfos.map((e: any) => StoreInfo.fromJSON(e)) + : [], + }; + }, + + toJSON(message: CommitInfo): unknown { + const obj: any = {}; + message.version !== undefined && (obj.version = (message.version || Long.ZERO).toString()); + + if (message.storeInfos) { + obj.storeInfos = message.storeInfos.map((e) => (e ? StoreInfo.toJSON(e) : undefined)); + } else { + obj.storeInfos = []; + } + + return obj; + }, + fromPartial, I>>(object: I): CommitInfo { const message = createBaseCommitInfo(); message.version = @@ -131,6 +153,21 @@ export const StoreInfo = { return message; }, + fromJSON(object: any): StoreInfo { + return { + name: isSet(object.name) ? String(object.name) : "", + commitId: isSet(object.commitId) ? CommitID.fromJSON(object.commitId) : undefined, + }; + }, + + toJSON(message: StoreInfo): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.commitId !== undefined && + (obj.commitId = message.commitId ? CommitID.toJSON(message.commitId) : undefined); + return obj; + }, + fromPartial, I>>(object: I): StoreInfo { const message = createBaseStoreInfo(); message.name = object.name ?? ""; @@ -188,6 +225,21 @@ export const CommitID = { return message; }, + fromJSON(object: any): CommitID { + return { + version: isSet(object.version) ? Long.fromValue(object.version) : Long.ZERO, + hash: isSet(object.hash) ? bytesFromBase64(object.hash) : new Uint8Array(), + }; + }, + + toJSON(message: CommitID): unknown { + const obj: any = {}; + message.version !== undefined && (obj.version = (message.version || Long.ZERO).toString()); + message.hash !== undefined && + (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): CommitID { const message = createBaseCommitID(); message.version = diff --git a/src/cosmos/base/store/v1beta1/listening.ts b/src/cosmos/base/store/v1beta1/listening.ts index cc96120d..245d4e26 100644 --- a/src/cosmos/base/store/v1beta1/listening.ts +++ b/src/cosmos/base/store/v1beta1/listening.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../../helpers"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact } from "../../../../helpers"; export const protobufPackage = "cosmos.base.store.v1beta1"; /** * StoreKVPair is a KVStore KVPair used for listening to state changes (Sets and Deletes) @@ -84,6 +84,26 @@ export const StoreKVPair = { return message; }, + fromJSON(object: any): StoreKVPair { + return { + storeKey: isSet(object.storeKey) ? String(object.storeKey) : "", + delete: isSet(object.delete) ? Boolean(object.delete) : false, + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), + }; + }, + + toJSON(message: StoreKVPair): unknown { + const obj: any = {}; + message.storeKey !== undefined && (obj.storeKey = message.storeKey); + message.delete !== undefined && (obj.delete = message.delete); + 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, I>>(object: I): StoreKVPair { const message = createBaseStoreKVPair(); message.storeKey = object.storeKey ?? ""; diff --git a/src/cosmos/base/store/v1beta1/snapshot.ts b/src/cosmos/base/store/v1beta1/snapshot.ts index e57e4fb6..d76843e6 100644 --- a/src/cosmos/base/store/v1beta1/snapshot.ts +++ b/src/cosmos/base/store/v1beta1/snapshot.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../../../helpers"; +import { isSet, DeepPartial, Exact, Long, bytesFromBase64, base64FromBytes } from "../../../../helpers"; export const protobufPackage = "cosmos.base.store.v1beta1"; /** SnapshotItem is an item contained in a rootmulti.Store snapshot. */ @@ -68,6 +68,22 @@ export const SnapshotItem = { return message; }, + fromJSON(object: any): SnapshotItem { + return { + store: isSet(object.store) ? SnapshotStoreItem.fromJSON(object.store) : undefined, + iavl: isSet(object.iavl) ? SnapshotIAVLItem.fromJSON(object.iavl) : undefined, + }; + }, + + toJSON(message: SnapshotItem): unknown { + const obj: any = {}; + message.store !== undefined && + (obj.store = message.store ? SnapshotStoreItem.toJSON(message.store) : undefined); + message.iavl !== undefined && + (obj.iavl = message.iavl ? SnapshotIAVLItem.toJSON(message.iavl) : undefined); + return obj; + }, + fromPartial, I>>(object: I): SnapshotItem { const message = createBaseSnapshotItem(); message.store = @@ -119,6 +135,18 @@ export const SnapshotStoreItem = { return message; }, + fromJSON(object: any): SnapshotStoreItem { + return { + name: isSet(object.name) ? String(object.name) : "", + }; + }, + + toJSON(message: SnapshotStoreItem): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial, I>>(object: I): SnapshotStoreItem { const message = createBaseSnapshotStoreItem(); message.name = object.name ?? ""; @@ -190,6 +218,26 @@ export const SnapshotIAVLItem = { return message; }, + fromJSON(object: any): SnapshotIAVLItem { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), + version: isSet(object.version) ? Long.fromValue(object.version) : Long.ZERO, + height: isSet(object.height) ? Number(object.height) : 0, + }; + }, + + toJSON(message: SnapshotIAVLItem): 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.version !== undefined && (obj.version = (message.version || Long.ZERO).toString()); + message.height !== undefined && (obj.height = Math.round(message.height)); + return obj; + }, + fromPartial, I>>(object: I): SnapshotIAVLItem { const message = createBaseSnapshotIAVLItem(); message.key = object.key ?? new Uint8Array(); diff --git a/src/cosmos/base/tendermint/v1beta1/query.ts b/src/cosmos/base/tendermint/v1beta1/query.ts index 4a828e71..349d2ca5 100644 --- a/src/cosmos/base/tendermint/v1beta1/query.ts +++ b/src/cosmos/base/tendermint/v1beta1/query.ts @@ -4,7 +4,7 @@ import { Any } from "../../../../google/protobuf/any"; import { BlockID } from "../../../../tendermint/types/types"; import { Block } from "../../../../tendermint/types/block"; import { DefaultNodeInfo } from "../../../../tendermint/p2p/types"; -import { Long, DeepPartial, Exact, Rpc } from "../../../../helpers"; +import { Long, isSet, DeepPartial, Exact, Rpc } from "../../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "cosmos.base.tendermint.v1beta1"; /** GetValidatorSetByHeightRequest is the request type for the Query/GetValidatorSetByHeight RPC method. */ @@ -157,6 +157,21 @@ export const GetValidatorSetByHeightRequest = { return message; }, + fromJSON(object: any): GetValidatorSetByHeightRequest { + return { + height: isSet(object.height) ? Long.fromValue(object.height) : Long.ZERO, + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: GetValidatorSetByHeightRequest): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): GetValidatorSetByHeightRequest { @@ -226,6 +241,31 @@ export const GetValidatorSetByHeightResponse = { return message; }, + fromJSON(object: any): GetValidatorSetByHeightResponse { + return { + blockHeight: isSet(object.blockHeight) ? Long.fromValue(object.blockHeight) : Long.ZERO, + validators: Array.isArray(object?.validators) + ? object.validators.map((e: any) => Validator.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: GetValidatorSetByHeightResponse): unknown { + const obj: any = {}; + message.blockHeight !== undefined && (obj.blockHeight = (message.blockHeight || Long.ZERO).toString()); + + 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, I>>( object: I, ): GetValidatorSetByHeightResponse { @@ -280,6 +320,19 @@ export const GetLatestValidatorSetRequest = { return message; }, + fromJSON(object: any): GetLatestValidatorSetRequest { + return { + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: GetLatestValidatorSetRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): GetLatestValidatorSetRequest { @@ -347,6 +400,31 @@ export const GetLatestValidatorSetResponse = { return message; }, + fromJSON(object: any): GetLatestValidatorSetResponse { + return { + blockHeight: isSet(object.blockHeight) ? Long.fromValue(object.blockHeight) : Long.ZERO, + validators: Array.isArray(object?.validators) + ? object.validators.map((e: any) => Validator.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: GetLatestValidatorSetResponse): unknown { + const obj: any = {}; + message.blockHeight !== undefined && (obj.blockHeight = (message.blockHeight || Long.ZERO).toString()); + + 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, I>>( object: I, ): GetLatestValidatorSetResponse { @@ -428,6 +506,25 @@ export const Validator = { return message; }, + fromJSON(object: any): Validator { + return { + address: isSet(object.address) ? String(object.address) : "", + pubKey: isSet(object.pubKey) ? Any.fromJSON(object.pubKey) : undefined, + votingPower: isSet(object.votingPower) ? Long.fromValue(object.votingPower) : Long.ZERO, + proposerPriority: isSet(object.proposerPriority) ? Long.fromValue(object.proposerPriority) : Long.ZERO, + }; + }, + + toJSON(message: Validator): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pubKey !== undefined && (obj.pubKey = message.pubKey ? Any.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, I>>(object: I): Validator { const message = createBaseValidator(); message.address = object.address ?? ""; @@ -482,6 +579,18 @@ export const GetBlockByHeightRequest = { return message; }, + fromJSON(object: any): GetBlockByHeightRequest { + return { + height: isSet(object.height) ? Long.fromValue(object.height) : Long.ZERO, + }; + }, + + toJSON(message: GetBlockByHeightRequest): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): GetBlockByHeightRequest { const message = createBaseGetBlockByHeightRequest(); message.height = @@ -536,6 +645,21 @@ export const GetBlockByHeightResponse = { return message; }, + fromJSON(object: any): GetBlockByHeightResponse { + return { + blockId: isSet(object.blockId) ? BlockID.fromJSON(object.blockId) : undefined, + block: isSet(object.block) ? Block.fromJSON(object.block) : undefined, + }; + }, + + toJSON(message: GetBlockByHeightResponse): unknown { + const obj: any = {}; + message.blockId !== undefined && + (obj.blockId = message.blockId ? BlockID.toJSON(message.blockId) : undefined); + message.block !== undefined && (obj.block = message.block ? Block.toJSON(message.block) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): GetBlockByHeightResponse { @@ -577,6 +701,15 @@ export const GetLatestBlockRequest = { return message; }, + fromJSON(_: any): GetLatestBlockRequest { + return {}; + }, + + toJSON(_: GetLatestBlockRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): GetLatestBlockRequest { const message = createBaseGetLatestBlockRequest(); return message; @@ -629,6 +762,21 @@ export const GetLatestBlockResponse = { return message; }, + fromJSON(object: any): GetLatestBlockResponse { + return { + blockId: isSet(object.blockId) ? BlockID.fromJSON(object.blockId) : undefined, + block: isSet(object.block) ? Block.fromJSON(object.block) : undefined, + }; + }, + + toJSON(message: GetLatestBlockResponse): unknown { + const obj: any = {}; + message.blockId !== undefined && + (obj.blockId = message.blockId ? BlockID.toJSON(message.blockId) : undefined); + message.block !== undefined && (obj.block = message.block ? Block.toJSON(message.block) : undefined); + return obj; + }, + fromPartial, I>>(object: I): GetLatestBlockResponse { const message = createBaseGetLatestBlockResponse(); message.blockId = @@ -668,6 +816,15 @@ export const GetSyncingRequest = { return message; }, + fromJSON(_: any): GetSyncingRequest { + return {}; + }, + + toJSON(_: GetSyncingRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): GetSyncingRequest { const message = createBaseGetSyncingRequest(); return message; @@ -711,6 +868,18 @@ export const GetSyncingResponse = { return message; }, + fromJSON(object: any): GetSyncingResponse { + return { + syncing: isSet(object.syncing) ? Boolean(object.syncing) : false, + }; + }, + + toJSON(message: GetSyncingResponse): unknown { + const obj: any = {}; + message.syncing !== undefined && (obj.syncing = message.syncing); + return obj; + }, + fromPartial, I>>(object: I): GetSyncingResponse { const message = createBaseGetSyncingResponse(); message.syncing = object.syncing ?? false; @@ -745,6 +914,15 @@ export const GetNodeInfoRequest = { return message; }, + fromJSON(_: any): GetNodeInfoRequest { + return {}; + }, + + toJSON(_: GetNodeInfoRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): GetNodeInfoRequest { const message = createBaseGetNodeInfoRequest(); return message; @@ -797,6 +975,30 @@ export const GetNodeInfoResponse = { return message; }, + fromJSON(object: any): GetNodeInfoResponse { + return { + defaultNodeInfo: isSet(object.defaultNodeInfo) + ? DefaultNodeInfo.fromJSON(object.defaultNodeInfo) + : undefined, + applicationVersion: isSet(object.applicationVersion) + ? VersionInfo.fromJSON(object.applicationVersion) + : undefined, + }; + }, + + toJSON(message: GetNodeInfoResponse): unknown { + const obj: any = {}; + message.defaultNodeInfo !== undefined && + (obj.defaultNodeInfo = message.defaultNodeInfo + ? DefaultNodeInfo.toJSON(message.defaultNodeInfo) + : undefined); + message.applicationVersion !== undefined && + (obj.applicationVersion = message.applicationVersion + ? VersionInfo.toJSON(message.applicationVersion) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): GetNodeInfoResponse { const message = createBaseGetNodeInfoResponse(); message.defaultNodeInfo = @@ -911,6 +1113,38 @@ export const VersionInfo = { return message; }, + fromJSON(object: any): VersionInfo { + return { + name: isSet(object.name) ? String(object.name) : "", + appName: isSet(object.appName) ? String(object.appName) : "", + version: isSet(object.version) ? String(object.version) : "", + gitCommit: isSet(object.gitCommit) ? String(object.gitCommit) : "", + buildTags: isSet(object.buildTags) ? String(object.buildTags) : "", + goVersion: isSet(object.goVersion) ? String(object.goVersion) : "", + buildDeps: Array.isArray(object?.buildDeps) ? object.buildDeps.map((e: any) => Module.fromJSON(e)) : [], + cosmosSdkVersion: isSet(object.cosmosSdkVersion) ? String(object.cosmosSdkVersion) : "", + }; + }, + + toJSON(message: VersionInfo): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.appName !== undefined && (obj.appName = message.appName); + message.version !== undefined && (obj.version = message.version); + message.gitCommit !== undefined && (obj.gitCommit = message.gitCommit); + message.buildTags !== undefined && (obj.buildTags = message.buildTags); + message.goVersion !== undefined && (obj.goVersion = message.goVersion); + + if (message.buildDeps) { + obj.buildDeps = message.buildDeps.map((e) => (e ? Module.toJSON(e) : undefined)); + } else { + obj.buildDeps = []; + } + + message.cosmosSdkVersion !== undefined && (obj.cosmosSdkVersion = message.cosmosSdkVersion); + return obj; + }, + fromPartial, I>>(object: I): VersionInfo { const message = createBaseVersionInfo(); message.name = object.name ?? ""; @@ -980,6 +1214,22 @@ export const Module = { return message; }, + fromJSON(object: any): Module { + return { + path: isSet(object.path) ? String(object.path) : "", + version: isSet(object.version) ? String(object.version) : "", + sum: isSet(object.sum) ? String(object.sum) : "", + }; + }, + + toJSON(message: Module): unknown { + const obj: any = {}; + message.path !== undefined && (obj.path = message.path); + message.version !== undefined && (obj.version = message.version); + message.sum !== undefined && (obj.sum = message.sum); + return obj; + }, + fromPartial, I>>(object: I): Module { const message = createBaseModule(); message.path = object.path ?? ""; diff --git a/src/cosmos/base/v1beta1/coin.ts b/src/cosmos/base/v1beta1/coin.ts index d62827f9..25a1eaee 100644 --- a/src/cosmos/base/v1beta1/coin.ts +++ b/src/cosmos/base/v1beta1/coin.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../helpers"; export const protobufPackage = "cosmos.base.v1beta1"; /** * Coin defines a token with a denomination and an amount. @@ -81,6 +81,20 @@ export const Coin = { return message; }, + fromJSON(object: any): Coin { + return { + denom: isSet(object.denom) ? String(object.denom) : "", + amount: isSet(object.amount) ? String(object.amount) : "", + }; + }, + + toJSON(message: Coin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + fromPartial, I>>(object: I): Coin { const message = createBaseCoin(); message.denom = object.denom ?? ""; @@ -135,6 +149,20 @@ export const DecCoin = { return message; }, + fromJSON(object: any): DecCoin { + return { + denom: isSet(object.denom) ? String(object.denom) : "", + amount: isSet(object.amount) ? String(object.amount) : "", + }; + }, + + toJSON(message: DecCoin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + fromPartial, I>>(object: I): DecCoin { const message = createBaseDecCoin(); message.denom = object.denom ?? ""; @@ -180,6 +208,18 @@ export const IntProto = { return message; }, + fromJSON(object: any): IntProto { + return { + int: isSet(object.int) ? String(object.int) : "", + }; + }, + + toJSON(message: IntProto): unknown { + const obj: any = {}; + message.int !== undefined && (obj.int = message.int); + return obj; + }, + fromPartial, I>>(object: I): IntProto { const message = createBaseIntProto(); message.int = object.int ?? ""; @@ -224,6 +264,18 @@ export const DecProto = { return message; }, + fromJSON(object: any): DecProto { + return { + dec: isSet(object.dec) ? String(object.dec) : "", + }; + }, + + toJSON(message: DecProto): unknown { + const obj: any = {}; + message.dec !== undefined && (obj.dec = message.dec); + return obj; + }, + fromPartial, I>>(object: I): DecProto { const message = createBaseDecProto(); message.dec = object.dec ?? ""; diff --git a/src/cosmos/capability/v1beta1/capability.ts b/src/cosmos/capability/v1beta1/capability.ts index 8a160086..362e6d08 100644 --- a/src/cosmos/capability/v1beta1/capability.ts +++ b/src/cosmos/capability/v1beta1/capability.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -import { Long, DeepPartial, Exact } from "../../../helpers"; +import { Long, isSet, DeepPartial, Exact } from "../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "cosmos.capability.v1beta1"; /** @@ -65,6 +65,18 @@ export const Capability = { return message; }, + fromJSON(object: any): Capability { + return { + index: isSet(object.index) ? Long.fromValue(object.index) : Long.UZERO, + }; + }, + + toJSON(message: Capability): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = (message.index || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): Capability { const message = createBaseCapability(); message.index = @@ -119,6 +131,20 @@ export const Owner = { return message; }, + fromJSON(object: any): Owner { + return { + module: isSet(object.module) ? String(object.module) : "", + name: isSet(object.name) ? String(object.name) : "", + }; + }, + + toJSON(message: Owner): unknown { + const obj: any = {}; + message.module !== undefined && (obj.module = message.module); + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial, I>>(object: I): Owner { const message = createBaseOwner(); message.module = object.module ?? ""; @@ -164,6 +190,24 @@ export const CapabilityOwners = { return message; }, + fromJSON(object: any): CapabilityOwners { + return { + owners: Array.isArray(object?.owners) ? object.owners.map((e: any) => Owner.fromJSON(e)) : [], + }; + }, + + toJSON(message: CapabilityOwners): unknown { + const obj: any = {}; + + if (message.owners) { + obj.owners = message.owners.map((e) => (e ? Owner.toJSON(e) : undefined)); + } else { + obj.owners = []; + } + + return obj; + }, + fromPartial, I>>(object: I): CapabilityOwners { const message = createBaseCapabilityOwners(); message.owners = object.owners?.map((e) => Owner.fromPartial(e)) || []; diff --git a/src/cosmos/capability/v1beta1/genesis.ts b/src/cosmos/capability/v1beta1/genesis.ts index 2e0e66c4..15054a78 100644 --- a/src/cosmos/capability/v1beta1/genesis.ts +++ b/src/cosmos/capability/v1beta1/genesis.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import { CapabilityOwners } from "./capability"; -import { Long, DeepPartial, Exact } from "../../../helpers"; +import { Long, isSet, DeepPartial, Exact } from "../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "cosmos.capability.v1beta1"; /** GenesisOwners defines the capability owners with their corresponding index. */ @@ -71,6 +71,21 @@ export const GenesisOwners = { return message; }, + fromJSON(object: any): GenesisOwners { + return { + index: isSet(object.index) ? Long.fromValue(object.index) : Long.UZERO, + indexOwners: isSet(object.indexOwners) ? CapabilityOwners.fromJSON(object.indexOwners) : undefined, + }; + }, + + toJSON(message: GenesisOwners): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = (message.index || Long.UZERO).toString()); + message.indexOwners !== undefined && + (obj.indexOwners = message.indexOwners ? CapabilityOwners.toJSON(message.indexOwners) : undefined); + return obj; + }, + fromPartial, I>>(object: I): GenesisOwners { const message = createBaseGenesisOwners(); message.index = @@ -129,6 +144,26 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + index: isSet(object.index) ? Long.fromValue(object.index) : Long.UZERO, + owners: Array.isArray(object?.owners) ? object.owners.map((e: any) => GenesisOwners.fromJSON(e)) : [], + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = (message.index || Long.UZERO).toString()); + + if (message.owners) { + obj.owners = message.owners.map((e) => (e ? GenesisOwners.toJSON(e) : undefined)); + } else { + obj.owners = []; + } + + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.index = diff --git a/src/cosmos/crisis/v1beta1/genesis.ts b/src/cosmos/crisis/v1beta1/genesis.ts index 9355c5aa..5b6d4edf 100644 --- a/src/cosmos/crisis/v1beta1/genesis.ts +++ b/src/cosmos/crisis/v1beta1/genesis.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Coin } from "../../base/v1beta1/coin"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../helpers"; export const protobufPackage = "cosmos.crisis.v1beta1"; /** GenesisState defines the crisis module's genesis state. */ @@ -50,6 +50,19 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + constantFee: isSet(object.constantFee) ? Coin.fromJSON(object.constantFee) : undefined, + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.constantFee !== undefined && + (obj.constantFee = message.constantFee ? Coin.toJSON(message.constantFee) : undefined); + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.constantFee = diff --git a/src/cosmos/crisis/v1beta1/tx.ts b/src/cosmos/crisis/v1beta1/tx.ts index cc0b1166..1edc3dd1 100644 --- a/src/cosmos/crisis/v1beta1/tx.ts +++ b/src/cosmos/crisis/v1beta1/tx.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../helpers"; +import { isSet, DeepPartial, Exact, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.crisis.v1beta1"; /** MsgVerifyInvariant represents a message to verify a particular invariance. */ @@ -68,6 +68,22 @@ export const MsgVerifyInvariant = { return message; }, + fromJSON(object: any): MsgVerifyInvariant { + return { + sender: isSet(object.sender) ? String(object.sender) : "", + invariantModuleName: isSet(object.invariantModuleName) ? String(object.invariantModuleName) : "", + invariantRoute: isSet(object.invariantRoute) ? String(object.invariantRoute) : "", + }; + }, + + toJSON(message: MsgVerifyInvariant): unknown { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.invariantModuleName !== undefined && (obj.invariantModuleName = message.invariantModuleName); + message.invariantRoute !== undefined && (obj.invariantRoute = message.invariantRoute); + return obj; + }, + fromPartial, I>>(object: I): MsgVerifyInvariant { const message = createBaseMsgVerifyInvariant(); message.sender = object.sender ?? ""; @@ -104,6 +120,15 @@ export const MsgVerifyInvariantResponse = { return message; }, + fromJSON(_: any): MsgVerifyInvariantResponse { + return {}; + }, + + toJSON(_: MsgVerifyInvariantResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgVerifyInvariantResponse { const message = createBaseMsgVerifyInvariantResponse(); return message; diff --git a/src/cosmos/crypto/ed25519/keys.ts b/src/cosmos/crypto/ed25519/keys.ts index 3bee80a6..d3b3b7aa 100644 --- a/src/cosmos/crypto/ed25519/keys.ts +++ b/src/cosmos/crypto/ed25519/keys.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../helpers"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact } from "../../../helpers"; export const protobufPackage = "cosmos.crypto.ed25519"; /** * PubKey is an ed25519 public key for handling Tendermint keys in SDK. @@ -59,6 +59,19 @@ export const PubKey = { return message; }, + fromJSON(object: any): PubKey { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + }; + }, + + toJSON(message: PubKey): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): PubKey { const message = createBasePubKey(); message.key = object.key ?? new Uint8Array(); @@ -103,6 +116,19 @@ export const PrivKey = { return message; }, + fromJSON(object: any): PrivKey { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + }; + }, + + toJSON(message: PrivKey): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): PrivKey { const message = createBasePrivKey(); message.key = object.key ?? new Uint8Array(); diff --git a/src/cosmos/crypto/multisig/keys.ts b/src/cosmos/crypto/multisig/keys.ts index 196f7801..69404109 100644 --- a/src/cosmos/crypto/multisig/keys.ts +++ b/src/cosmos/crypto/multisig/keys.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Any } from "../../../google/protobuf/any"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../helpers"; export const protobufPackage = "cosmos.crypto.multisig"; /** * LegacyAminoPubKey specifies a public key type @@ -60,6 +60,26 @@ export const LegacyAminoPubKey = { return message; }, + fromJSON(object: any): LegacyAminoPubKey { + return { + threshold: isSet(object.threshold) ? Number(object.threshold) : 0, + publicKeys: Array.isArray(object?.publicKeys) ? object.publicKeys.map((e: any) => Any.fromJSON(e)) : [], + }; + }, + + toJSON(message: LegacyAminoPubKey): unknown { + const obj: any = {}; + message.threshold !== undefined && (obj.threshold = Math.round(message.threshold)); + + if (message.publicKeys) { + obj.publicKeys = message.publicKeys.map((e) => (e ? Any.toJSON(e) : undefined)); + } else { + obj.publicKeys = []; + } + + return obj; + }, + fromPartial, I>>(object: I): LegacyAminoPubKey { const message = createBaseLegacyAminoPubKey(); message.threshold = object.threshold ?? 0; diff --git a/src/cosmos/crypto/multisig/v1beta1/multisig.ts b/src/cosmos/crypto/multisig/v1beta1/multisig.ts index 6ed9826d..d8fea648 100644 --- a/src/cosmos/crypto/multisig/v1beta1/multisig.ts +++ b/src/cosmos/crypto/multisig/v1beta1/multisig.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../../helpers"; +import { bytesFromBase64, base64FromBytes, DeepPartial, Exact, isSet } from "../../../../helpers"; export const protobufPackage = "cosmos.crypto.multisig.v1beta1"; /** * MultiSignature wraps the signatures from a multisig.LegacyAminoPubKey. @@ -60,6 +60,26 @@ export const MultiSignature = { return message; }, + fromJSON(object: any): MultiSignature { + return { + signatures: Array.isArray(object?.signatures) + ? object.signatures.map((e: any) => bytesFromBase64(e)) + : [], + }; + }, + + 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, I>>(object: I): MultiSignature { const message = createBaseMultiSignature(); message.signatures = object.signatures?.map((e) => e) || []; @@ -113,6 +133,21 @@ export const CompactBitArray = { return message; }, + fromJSON(object: any): CompactBitArray { + return { + extraBitsStored: isSet(object.extraBitsStored) ? Number(object.extraBitsStored) : 0, + elems: isSet(object.elems) ? bytesFromBase64(object.elems) : new Uint8Array(), + }; + }, + + toJSON(message: CompactBitArray): unknown { + const obj: any = {}; + message.extraBitsStored !== undefined && (obj.extraBitsStored = Math.round(message.extraBitsStored)); + message.elems !== undefined && + (obj.elems = base64FromBytes(message.elems !== undefined ? message.elems : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): CompactBitArray { const message = createBaseCompactBitArray(); message.extraBitsStored = object.extraBitsStored ?? 0; diff --git a/src/cosmos/crypto/secp256k1/keys.ts b/src/cosmos/crypto/secp256k1/keys.ts index 56c909a2..e15d3612 100644 --- a/src/cosmos/crypto/secp256k1/keys.ts +++ b/src/cosmos/crypto/secp256k1/keys.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../helpers"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact } from "../../../helpers"; export const protobufPackage = "cosmos.crypto.secp256k1"; /** * PubKey defines a secp256k1 public key @@ -56,6 +56,19 @@ export const PubKey = { return message; }, + fromJSON(object: any): PubKey { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + }; + }, + + toJSON(message: PubKey): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): PubKey { const message = createBasePubKey(); message.key = object.key ?? new Uint8Array(); @@ -100,6 +113,19 @@ export const PrivKey = { return message; }, + fromJSON(object: any): PrivKey { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + }; + }, + + toJSON(message: PrivKey): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): PrivKey { const message = createBasePrivKey(); message.key = object.key ?? new Uint8Array(); diff --git a/src/cosmos/distribution/v1beta1/distribution.ts b/src/cosmos/distribution/v1beta1/distribution.ts index e54408d5..07ee82f8 100644 --- a/src/cosmos/distribution/v1beta1/distribution.ts +++ b/src/cosmos/distribution/v1beta1/distribution.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { DecCoin, Coin } from "../../base/v1beta1/coin"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../../helpers"; +import { isSet, DeepPartial, Exact, Long } from "../../../helpers"; export const protobufPackage = "cosmos.distribution.v1beta1"; /** Params defines the set of params for the distribution module. */ @@ -189,6 +189,24 @@ export const Params = { return message; }, + fromJSON(object: any): Params { + return { + communityTax: isSet(object.communityTax) ? String(object.communityTax) : "", + baseProposerReward: isSet(object.baseProposerReward) ? String(object.baseProposerReward) : "", + bonusProposerReward: isSet(object.bonusProposerReward) ? String(object.bonusProposerReward) : "", + withdrawAddrEnabled: isSet(object.withdrawAddrEnabled) ? Boolean(object.withdrawAddrEnabled) : false, + }; + }, + + 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, I>>(object: I): Params { const message = createBaseParams(); message.communityTax = object.communityTax ?? ""; @@ -245,6 +263,30 @@ export const ValidatorHistoricalRewards = { return message; }, + fromJSON(object: any): ValidatorHistoricalRewards { + return { + cumulativeRewardRatio: Array.isArray(object?.cumulativeRewardRatio) + ? object.cumulativeRewardRatio.map((e: any) => DecCoin.fromJSON(e)) + : [], + referenceCount: isSet(object.referenceCount) ? Number(object.referenceCount) : 0, + }; + }, + + 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 = Math.round(message.referenceCount)); + return obj; + }, + fromPartial, I>>( object: I, ): ValidatorHistoricalRewards { @@ -301,6 +343,26 @@ export const ValidatorCurrentRewards = { return message; }, + fromJSON(object: any): ValidatorCurrentRewards { + return { + rewards: Array.isArray(object?.rewards) ? object.rewards.map((e: any) => DecCoin.fromJSON(e)) : [], + period: isSet(object.period) ? Long.fromValue(object.period) : Long.UZERO, + }; + }, + + 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, I>>(object: I): ValidatorCurrentRewards { const message = createBaseValidatorCurrentRewards(); message.rewards = object.rewards?.map((e) => DecCoin.fromPartial(e)) || []; @@ -347,6 +409,26 @@ export const ValidatorAccumulatedCommission = { return message; }, + fromJSON(object: any): ValidatorAccumulatedCommission { + return { + commission: Array.isArray(object?.commission) + ? object.commission.map((e: any) => DecCoin.fromJSON(e)) + : [], + }; + }, + + 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, I>>( object: I, ): ValidatorAccumulatedCommission { @@ -393,6 +475,24 @@ export const ValidatorOutstandingRewards = { return message; }, + fromJSON(object: any): ValidatorOutstandingRewards { + return { + rewards: Array.isArray(object?.rewards) ? object.rewards.map((e: any) => DecCoin.fromJSON(e)) : [], + }; + }, + + 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, I>>( object: I, ): ValidatorOutstandingRewards { @@ -448,6 +548,21 @@ export const ValidatorSlashEvent = { return message; }, + fromJSON(object: any): ValidatorSlashEvent { + return { + validatorPeriod: isSet(object.validatorPeriod) ? Long.fromValue(object.validatorPeriod) : Long.UZERO, + fraction: isSet(object.fraction) ? String(object.fraction) : "", + }; + }, + + 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, I>>(object: I): ValidatorSlashEvent { const message = createBaseValidatorSlashEvent(); message.validatorPeriod = @@ -496,6 +611,28 @@ export const ValidatorSlashEvents = { return message; }, + fromJSON(object: any): ValidatorSlashEvents { + return { + validatorSlashEvents: Array.isArray(object?.validatorSlashEvents) + ? object.validatorSlashEvents.map((e: any) => ValidatorSlashEvent.fromJSON(e)) + : [], + }; + }, + + toJSON(message: ValidatorSlashEvents): unknown { + const obj: any = {}; + + if (message.validatorSlashEvents) { + obj.validatorSlashEvents = message.validatorSlashEvents.map((e) => + e ? ValidatorSlashEvent.toJSON(e) : undefined, + ); + } else { + obj.validatorSlashEvents = []; + } + + return obj; + }, + fromPartial, I>>(object: I): ValidatorSlashEvents { const message = createBaseValidatorSlashEvents(); message.validatorSlashEvents = @@ -541,6 +678,26 @@ export const FeePool = { return message; }, + fromJSON(object: any): FeePool { + return { + communityPool: Array.isArray(object?.communityPool) + ? object.communityPool.map((e: any) => DecCoin.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): FeePool { const message = createBaseFeePool(); message.communityPool = object.communityPool?.map((e) => DecCoin.fromPartial(e)) || []; @@ -612,6 +769,30 @@ export const CommunityPoolSpendProposal = { return message; }, + fromJSON(object: any): CommunityPoolSpendProposal { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + recipient: isSet(object.recipient) ? String(object.recipient) : "", + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromJSON(e)) : [], + }; + }, + + 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, I>>( object: I, ): CommunityPoolSpendProposal { @@ -679,6 +860,23 @@ export const DelegatorStartingInfo = { return message; }, + fromJSON(object: any): DelegatorStartingInfo { + return { + previousPeriod: isSet(object.previousPeriod) ? Long.fromValue(object.previousPeriod) : Long.UZERO, + stake: isSet(object.stake) ? String(object.stake) : "", + height: isSet(object.height) ? Long.fromValue(object.height) : Long.UZERO, + }; + }, + + 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, I>>(object: I): DelegatorStartingInfo { const message = createBaseDelegatorStartingInfo(); message.previousPeriod = @@ -738,6 +936,26 @@ export const DelegationDelegatorReward = { return message; }, + fromJSON(object: any): DelegationDelegatorReward { + return { + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + reward: Array.isArray(object?.reward) ? object.reward.map((e: any) => DecCoin.fromJSON(e)) : [], + }; + }, + + 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, I>>( object: I, ): DelegationDelegatorReward { @@ -824,6 +1042,26 @@ export const CommunityPoolSpendProposalWithDeposit = { return message; }, + fromJSON(object: any): CommunityPoolSpendProposalWithDeposit { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + recipient: isSet(object.recipient) ? String(object.recipient) : "", + amount: isSet(object.amount) ? String(object.amount) : "", + deposit: isSet(object.deposit) ? String(object.deposit) : "", + }; + }, + + 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, I>>( object: I, ): CommunityPoolSpendProposalWithDeposit { diff --git a/src/cosmos/distribution/v1beta1/genesis.ts b/src/cosmos/distribution/v1beta1/genesis.ts index f58e63e6..1306cfd5 100644 --- a/src/cosmos/distribution/v1beta1/genesis.ts +++ b/src/cosmos/distribution/v1beta1/genesis.ts @@ -10,7 +10,7 @@ import { FeePool, } from "./distribution"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../../helpers"; +import { isSet, DeepPartial, Exact, Long } from "../../../helpers"; export const protobufPackage = "cosmos.distribution.v1beta1"; /** * DelegatorWithdrawInfo is the address for where distributions rewards are @@ -177,6 +177,20 @@ export const DelegatorWithdrawInfo = { return message; }, + fromJSON(object: any): DelegatorWithdrawInfo { + return { + delegatorAddress: isSet(object.delegatorAddress) ? String(object.delegatorAddress) : "", + withdrawAddress: isSet(object.withdrawAddress) ? String(object.withdrawAddress) : "", + }; + }, + + toJSON(message: DelegatorWithdrawInfo): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.withdrawAddress !== undefined && (obj.withdrawAddress = message.withdrawAddress); + return obj; + }, + fromPartial, I>>(object: I): DelegatorWithdrawInfo { const message = createBaseDelegatorWithdrawInfo(); message.delegatorAddress = object.delegatorAddress ?? ""; @@ -231,6 +245,28 @@ export const ValidatorOutstandingRewardsRecord = { return message; }, + fromJSON(object: any): ValidatorOutstandingRewardsRecord { + return { + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + outstandingRewards: Array.isArray(object?.outstandingRewards) + ? object.outstandingRewards.map((e: any) => DecCoin.fromJSON(e)) + : [], + }; + }, + + toJSON(message: ValidatorOutstandingRewardsRecord): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + + if (message.outstandingRewards) { + obj.outstandingRewards = message.outstandingRewards.map((e) => (e ? DecCoin.toJSON(e) : undefined)); + } else { + obj.outstandingRewards = []; + } + + return obj; + }, + fromPartial, I>>( object: I, ): ValidatorOutstandingRewardsRecord { @@ -290,6 +326,25 @@ export const ValidatorAccumulatedCommissionRecord = { return message; }, + fromJSON(object: any): ValidatorAccumulatedCommissionRecord { + return { + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + accumulated: isSet(object.accumulated) + ? ValidatorAccumulatedCommission.fromJSON(object.accumulated) + : undefined, + }; + }, + + toJSON(message: ValidatorAccumulatedCommissionRecord): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.accumulated !== undefined && + (obj.accumulated = message.accumulated + ? ValidatorAccumulatedCommission.toJSON(message.accumulated) + : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): ValidatorAccumulatedCommissionRecord { @@ -358,6 +413,23 @@ export const ValidatorHistoricalRewardsRecord = { return message; }, + fromJSON(object: any): ValidatorHistoricalRewardsRecord { + return { + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + period: isSet(object.period) ? Long.fromValue(object.period) : Long.UZERO, + rewards: isSet(object.rewards) ? ValidatorHistoricalRewards.fromJSON(object.rewards) : undefined, + }; + }, + + toJSON(message: ValidatorHistoricalRewardsRecord): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.period !== undefined && (obj.period = (message.period || Long.UZERO).toString()); + message.rewards !== undefined && + (obj.rewards = message.rewards ? ValidatorHistoricalRewards.toJSON(message.rewards) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): ValidatorHistoricalRewardsRecord { @@ -419,6 +491,21 @@ export const ValidatorCurrentRewardsRecord = { return message; }, + fromJSON(object: any): ValidatorCurrentRewardsRecord { + return { + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + rewards: isSet(object.rewards) ? ValidatorCurrentRewards.fromJSON(object.rewards) : undefined, + }; + }, + + toJSON(message: ValidatorCurrentRewardsRecord): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.rewards !== undefined && + (obj.rewards = message.rewards ? ValidatorCurrentRewards.toJSON(message.rewards) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): ValidatorCurrentRewardsRecord { @@ -487,6 +574,27 @@ export const DelegatorStartingInfoRecord = { return message; }, + fromJSON(object: any): DelegatorStartingInfoRecord { + return { + delegatorAddress: isSet(object.delegatorAddress) ? String(object.delegatorAddress) : "", + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + startingInfo: isSet(object.startingInfo) + ? DelegatorStartingInfo.fromJSON(object.startingInfo) + : undefined, + }; + }, + + toJSON(message: DelegatorStartingInfoRecord): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.startingInfo !== undefined && + (obj.startingInfo = message.startingInfo + ? DelegatorStartingInfo.toJSON(message.startingInfo) + : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): DelegatorStartingInfoRecord { @@ -565,6 +673,29 @@ export const ValidatorSlashEventRecord = { return message; }, + fromJSON(object: any): ValidatorSlashEventRecord { + return { + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + height: isSet(object.height) ? Long.fromValue(object.height) : Long.UZERO, + period: isSet(object.period) ? Long.fromValue(object.period) : Long.UZERO, + validatorSlashEvent: isSet(object.validatorSlashEvent) + ? ValidatorSlashEvent.fromJSON(object.validatorSlashEvent) + : undefined, + }; + }, + + toJSON(message: ValidatorSlashEventRecord): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.height !== undefined && (obj.height = (message.height || Long.UZERO).toString()); + message.period !== undefined && (obj.period = (message.period || Long.UZERO).toString()); + message.validatorSlashEvent !== undefined && + (obj.validatorSlashEvent = message.validatorSlashEvent + ? ValidatorSlashEvent.toJSON(message.validatorSlashEvent) + : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): ValidatorSlashEventRecord { @@ -704,6 +835,104 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + feePool: isSet(object.feePool) ? FeePool.fromJSON(object.feePool) : undefined, + delegatorWithdrawInfos: Array.isArray(object?.delegatorWithdrawInfos) + ? object.delegatorWithdrawInfos.map((e: any) => DelegatorWithdrawInfo.fromJSON(e)) + : [], + previousProposer: isSet(object.previousProposer) ? String(object.previousProposer) : "", + outstandingRewards: Array.isArray(object?.outstandingRewards) + ? object.outstandingRewards.map((e: any) => ValidatorOutstandingRewardsRecord.fromJSON(e)) + : [], + validatorAccumulatedCommissions: Array.isArray(object?.validatorAccumulatedCommissions) + ? object.validatorAccumulatedCommissions.map((e: any) => + ValidatorAccumulatedCommissionRecord.fromJSON(e), + ) + : [], + validatorHistoricalRewards: Array.isArray(object?.validatorHistoricalRewards) + ? object.validatorHistoricalRewards.map((e: any) => ValidatorHistoricalRewardsRecord.fromJSON(e)) + : [], + validatorCurrentRewards: Array.isArray(object?.validatorCurrentRewards) + ? object.validatorCurrentRewards.map((e: any) => ValidatorCurrentRewardsRecord.fromJSON(e)) + : [], + delegatorStartingInfos: Array.isArray(object?.delegatorStartingInfos) + ? object.delegatorStartingInfos.map((e: any) => DelegatorStartingInfoRecord.fromJSON(e)) + : [], + validatorSlashEvents: Array.isArray(object?.validatorSlashEvents) + ? object.validatorSlashEvents.map((e: any) => ValidatorSlashEventRecord.fromJSON(e)) + : [], + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + message.feePool !== undefined && + (obj.feePool = message.feePool ? FeePool.toJSON(message.feePool) : undefined); + + if (message.delegatorWithdrawInfos) { + obj.delegatorWithdrawInfos = message.delegatorWithdrawInfos.map((e) => + e ? DelegatorWithdrawInfo.toJSON(e) : undefined, + ); + } else { + obj.delegatorWithdrawInfos = []; + } + + message.previousProposer !== undefined && (obj.previousProposer = message.previousProposer); + + if (message.outstandingRewards) { + obj.outstandingRewards = message.outstandingRewards.map((e) => + e ? ValidatorOutstandingRewardsRecord.toJSON(e) : undefined, + ); + } else { + obj.outstandingRewards = []; + } + + if (message.validatorAccumulatedCommissions) { + obj.validatorAccumulatedCommissions = message.validatorAccumulatedCommissions.map((e) => + e ? ValidatorAccumulatedCommissionRecord.toJSON(e) : undefined, + ); + } else { + obj.validatorAccumulatedCommissions = []; + } + + if (message.validatorHistoricalRewards) { + obj.validatorHistoricalRewards = message.validatorHistoricalRewards.map((e) => + e ? ValidatorHistoricalRewardsRecord.toJSON(e) : undefined, + ); + } else { + obj.validatorHistoricalRewards = []; + } + + if (message.validatorCurrentRewards) { + obj.validatorCurrentRewards = message.validatorCurrentRewards.map((e) => + e ? ValidatorCurrentRewardsRecord.toJSON(e) : undefined, + ); + } else { + obj.validatorCurrentRewards = []; + } + + if (message.delegatorStartingInfos) { + obj.delegatorStartingInfos = message.delegatorStartingInfos.map((e) => + e ? DelegatorStartingInfoRecord.toJSON(e) : undefined, + ); + } else { + obj.delegatorStartingInfos = []; + } + + if (message.validatorSlashEvents) { + obj.validatorSlashEvents = message.validatorSlashEvents.map((e) => + e ? ValidatorSlashEventRecord.toJSON(e) : undefined, + ); + } else { + obj.validatorSlashEvents = []; + } + + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.params = diff --git a/src/cosmos/distribution/v1beta1/query.ts b/src/cosmos/distribution/v1beta1/query.ts index c960b767..a4e2da88 100644 --- a/src/cosmos/distribution/v1beta1/query.ts +++ b/src/cosmos/distribution/v1beta1/query.ts @@ -9,7 +9,7 @@ import { } from "./distribution"; import { DecCoin } from "../../base/v1beta1/coin"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long, Rpc } from "../../../helpers"; +import { DeepPartial, Exact, isSet, Long, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.distribution.v1beta1"; /** QueryParamsRequest is the request type for the Query/Params RPC method. */ @@ -206,6 +206,15 @@ export const QueryParamsRequest = { return message; }, + fromJSON(_: any): QueryParamsRequest { + return {}; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryParamsRequest { const message = createBaseQueryParamsRequest(); return message; @@ -249,6 +258,18 @@ export const QueryParamsResponse = { return message; }, + fromJSON(object: any): QueryParamsResponse { + return { + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + }; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryParamsResponse { const message = createBaseQueryParamsResponse(); message.params = @@ -297,6 +318,18 @@ export const QueryValidatorOutstandingRewardsRequest = { return message; }, + fromJSON(object: any): QueryValidatorOutstandingRewardsRequest { + return { + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + }; + }, + + toJSON(message: QueryValidatorOutstandingRewardsRequest): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + return obj; + }, + fromPartial, I>>( object: I, ): QueryValidatorOutstandingRewardsRequest { @@ -346,6 +379,19 @@ export const QueryValidatorOutstandingRewardsResponse = { return message; }, + fromJSON(object: any): QueryValidatorOutstandingRewardsResponse { + return { + rewards: isSet(object.rewards) ? ValidatorOutstandingRewards.fromJSON(object.rewards) : undefined, + }; + }, + + toJSON(message: QueryValidatorOutstandingRewardsResponse): unknown { + const obj: any = {}; + message.rewards !== undefined && + (obj.rewards = message.rewards ? ValidatorOutstandingRewards.toJSON(message.rewards) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryValidatorOutstandingRewardsResponse { @@ -395,6 +441,18 @@ export const QueryValidatorCommissionRequest = { return message; }, + fromJSON(object: any): QueryValidatorCommissionRequest { + return { + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + }; + }, + + toJSON(message: QueryValidatorCommissionRequest): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + return obj; + }, + fromPartial, I>>( object: I, ): QueryValidatorCommissionRequest { @@ -441,6 +499,23 @@ export const QueryValidatorCommissionResponse = { return message; }, + fromJSON(object: any): QueryValidatorCommissionResponse { + return { + commission: isSet(object.commission) + ? ValidatorAccumulatedCommission.fromJSON(object.commission) + : undefined, + }; + }, + + toJSON(message: QueryValidatorCommissionResponse): unknown { + const obj: any = {}; + message.commission !== undefined && + (obj.commission = message.commission + ? ValidatorAccumulatedCommission.toJSON(message.commission) + : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryValidatorCommissionResponse { @@ -517,6 +592,27 @@ export const QueryValidatorSlashesRequest = { return message; }, + fromJSON(object: any): QueryValidatorSlashesRequest { + return { + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + startingHeight: isSet(object.startingHeight) ? Long.fromValue(object.startingHeight) : Long.UZERO, + endingHeight: isSet(object.endingHeight) ? Long.fromValue(object.endingHeight) : Long.UZERO, + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryValidatorSlashesRequest { @@ -584,6 +680,29 @@ export const QueryValidatorSlashesResponse = { return message; }, + fromJSON(object: any): QueryValidatorSlashesResponse { + return { + slashes: Array.isArray(object?.slashes) + ? object.slashes.map((e: any) => ValidatorSlashEvent.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryValidatorSlashesResponse { @@ -643,6 +762,20 @@ export const QueryDelegationRewardsRequest = { return message; }, + fromJSON(object: any): QueryDelegationRewardsRequest { + return { + delegatorAddress: isSet(object.delegatorAddress) ? String(object.delegatorAddress) : "", + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + }; + }, + + toJSON(message: QueryDelegationRewardsRequest): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + return obj; + }, + fromPartial, I>>( object: I, ): QueryDelegationRewardsRequest { @@ -690,6 +823,24 @@ export const QueryDelegationRewardsResponse = { return message; }, + fromJSON(object: any): QueryDelegationRewardsResponse { + return { + rewards: Array.isArray(object?.rewards) ? object.rewards.map((e: any) => DecCoin.fromJSON(e)) : [], + }; + }, + + 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, I>>( object: I, ): QueryDelegationRewardsResponse { @@ -736,6 +887,18 @@ export const QueryDelegationTotalRewardsRequest = { return message; }, + fromJSON(object: any): QueryDelegationTotalRewardsRequest { + return { + delegatorAddress: isSet(object.delegatorAddress) ? String(object.delegatorAddress) : "", + }; + }, + + toJSON(message: QueryDelegationTotalRewardsRequest): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + return obj; + }, + fromPartial, I>>( object: I, ): QueryDelegationTotalRewardsRequest { @@ -791,6 +954,33 @@ export const QueryDelegationTotalRewardsResponse = { return message; }, + fromJSON(object: any): QueryDelegationTotalRewardsResponse { + return { + rewards: Array.isArray(object?.rewards) + ? object.rewards.map((e: any) => DelegationDelegatorReward.fromJSON(e)) + : [], + total: Array.isArray(object?.total) ? object.total.map((e: any) => DecCoin.fromJSON(e)) : [], + }; + }, + + 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, I>>( object: I, ): QueryDelegationTotalRewardsResponse { @@ -838,6 +1028,18 @@ export const QueryDelegatorValidatorsRequest = { return message; }, + fromJSON(object: any): QueryDelegatorValidatorsRequest { + return { + delegatorAddress: isSet(object.delegatorAddress) ? String(object.delegatorAddress) : "", + }; + }, + + toJSON(message: QueryDelegatorValidatorsRequest): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + return obj; + }, + fromPartial, I>>( object: I, ): QueryDelegatorValidatorsRequest { @@ -884,6 +1086,24 @@ export const QueryDelegatorValidatorsResponse = { return message; }, + fromJSON(object: any): QueryDelegatorValidatorsResponse { + return { + validators: Array.isArray(object?.validators) ? object.validators.map((e: any) => String(e)) : [], + }; + }, + + toJSON(message: QueryDelegatorValidatorsResponse): unknown { + const obj: any = {}; + + if (message.validators) { + obj.validators = message.validators.map((e) => e); + } else { + obj.validators = []; + } + + return obj; + }, + fromPartial, I>>( object: I, ): QueryDelegatorValidatorsResponse { @@ -933,6 +1153,18 @@ export const QueryDelegatorWithdrawAddressRequest = { return message; }, + fromJSON(object: any): QueryDelegatorWithdrawAddressRequest { + return { + delegatorAddress: isSet(object.delegatorAddress) ? String(object.delegatorAddress) : "", + }; + }, + + toJSON(message: QueryDelegatorWithdrawAddressRequest): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + return obj; + }, + fromPartial, I>>( object: I, ): QueryDelegatorWithdrawAddressRequest { @@ -982,6 +1214,18 @@ export const QueryDelegatorWithdrawAddressResponse = { return message; }, + fromJSON(object: any): QueryDelegatorWithdrawAddressResponse { + return { + withdrawAddress: isSet(object.withdrawAddress) ? String(object.withdrawAddress) : "", + }; + }, + + toJSON(message: QueryDelegatorWithdrawAddressResponse): unknown { + const obj: any = {}; + message.withdrawAddress !== undefined && (obj.withdrawAddress = message.withdrawAddress); + return obj; + }, + fromPartial, I>>( object: I, ): QueryDelegatorWithdrawAddressResponse { @@ -1018,6 +1262,15 @@ export const QueryCommunityPoolRequest = { return message; }, + fromJSON(_: any): QueryCommunityPoolRequest { + return {}; + }, + + toJSON(_: QueryCommunityPoolRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryCommunityPoolRequest { const message = createBaseQueryCommunityPoolRequest(); return message; @@ -1061,6 +1314,24 @@ export const QueryCommunityPoolResponse = { return message; }, + fromJSON(object: any): QueryCommunityPoolResponse { + return { + pool: Array.isArray(object?.pool) ? object.pool.map((e: any) => DecCoin.fromJSON(e)) : [], + }; + }, + + 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, I>>( object: I, ): QueryCommunityPoolResponse { diff --git a/src/cosmos/distribution/v1beta1/tx.ts b/src/cosmos/distribution/v1beta1/tx.ts index c26618a8..62b84e9b 100644 --- a/src/cosmos/distribution/v1beta1/tx.ts +++ b/src/cosmos/distribution/v1beta1/tx.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Coin } from "../../base/v1beta1/coin"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../helpers"; +import { isSet, DeepPartial, Exact, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.distribution.v1beta1"; /** * MsgSetWithdrawAddress sets the withdraw address for @@ -97,6 +97,20 @@ export const MsgSetWithdrawAddress = { return message; }, + fromJSON(object: any): MsgSetWithdrawAddress { + return { + delegatorAddress: isSet(object.delegatorAddress) ? String(object.delegatorAddress) : "", + withdrawAddress: isSet(object.withdrawAddress) ? String(object.withdrawAddress) : "", + }; + }, + + toJSON(message: MsgSetWithdrawAddress): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.withdrawAddress !== undefined && (obj.withdrawAddress = message.withdrawAddress); + return obj; + }, + fromPartial, I>>(object: I): MsgSetWithdrawAddress { const message = createBaseMsgSetWithdrawAddress(); message.delegatorAddress = object.delegatorAddress ?? ""; @@ -132,6 +146,15 @@ export const MsgSetWithdrawAddressResponse = { return message; }, + fromJSON(_: any): MsgSetWithdrawAddressResponse { + return {}; + }, + + toJSON(_: MsgSetWithdrawAddressResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( _: I, ): MsgSetWithdrawAddressResponse { @@ -186,6 +209,20 @@ export const MsgWithdrawDelegatorReward = { return message; }, + fromJSON(object: any): MsgWithdrawDelegatorReward { + return { + delegatorAddress: isSet(object.delegatorAddress) ? String(object.delegatorAddress) : "", + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + }; + }, + + toJSON(message: MsgWithdrawDelegatorReward): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + return obj; + }, + fromPartial, I>>( object: I, ): MsgWithdrawDelegatorReward { @@ -223,6 +260,15 @@ export const MsgWithdrawDelegatorRewardResponse = { return message; }, + fromJSON(_: any): MsgWithdrawDelegatorRewardResponse { + return {}; + }, + + toJSON(_: MsgWithdrawDelegatorRewardResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( _: I, ): MsgWithdrawDelegatorRewardResponse { @@ -268,6 +314,18 @@ export const MsgWithdrawValidatorCommission = { return message; }, + fromJSON(object: any): MsgWithdrawValidatorCommission { + return { + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + }; + }, + + toJSON(message: MsgWithdrawValidatorCommission): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + return obj; + }, + fromPartial, I>>( object: I, ): MsgWithdrawValidatorCommission { @@ -304,6 +362,15 @@ export const MsgWithdrawValidatorCommissionResponse = { return message; }, + fromJSON(_: any): MsgWithdrawValidatorCommissionResponse { + return {}; + }, + + toJSON(_: MsgWithdrawValidatorCommissionResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( _: I, ): MsgWithdrawValidatorCommissionResponse { @@ -358,6 +425,26 @@ export const MsgFundCommunityPool = { return message; }, + fromJSON(object: any): MsgFundCommunityPool { + return { + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromJSON(e)) : [], + depositor: isSet(object.depositor) ? String(object.depositor) : "", + }; + }, + + 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, I>>(object: I): MsgFundCommunityPool { const message = createBaseMsgFundCommunityPool(); message.amount = object.amount?.map((e) => Coin.fromPartial(e)) || []; @@ -393,6 +480,15 @@ export const MsgFundCommunityPoolResponse = { return message; }, + fromJSON(_: any): MsgFundCommunityPoolResponse { + return {}; + }, + + toJSON(_: MsgFundCommunityPoolResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( _: I, ): MsgFundCommunityPoolResponse { diff --git a/src/cosmos/evidence/v1beta1/evidence.ts b/src/cosmos/evidence/v1beta1/evidence.ts index bcdcef6a..8ea2ab4e 100644 --- a/src/cosmos/evidence/v1beta1/evidence.ts +++ b/src/cosmos/evidence/v1beta1/evidence.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import { Timestamp } from "../../../google/protobuf/timestamp"; -import { Long, DeepPartial, Exact } from "../../../helpers"; +import { Long, isSet, fromJsonTimestamp, fromTimestamp, DeepPartial, Exact } from "../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "cosmos.evidence.v1beta1"; /** @@ -79,6 +79,24 @@ export const Equivocation = { return message; }, + fromJSON(object: any): Equivocation { + return { + height: isSet(object.height) ? Long.fromValue(object.height) : Long.ZERO, + time: isSet(object.time) ? fromJsonTimestamp(object.time) : undefined, + power: isSet(object.power) ? Long.fromValue(object.power) : Long.ZERO, + consensusAddress: isSet(object.consensusAddress) ? String(object.consensusAddress) : "", + }; + }, + + toJSON(message: Equivocation): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + message.time !== undefined && (obj.time = fromTimestamp(message.time).toISOString()); + message.power !== undefined && (obj.power = (message.power || Long.ZERO).toString()); + message.consensusAddress !== undefined && (obj.consensusAddress = message.consensusAddress); + return obj; + }, + fromPartial, I>>(object: I): Equivocation { const message = createBaseEquivocation(); message.height = diff --git a/src/cosmos/evidence/v1beta1/genesis.ts b/src/cosmos/evidence/v1beta1/genesis.ts index fb74d1b6..d5e26fbc 100644 --- a/src/cosmos/evidence/v1beta1/genesis.ts +++ b/src/cosmos/evidence/v1beta1/genesis.ts @@ -47,6 +47,24 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + evidence: Array.isArray(object?.evidence) ? object.evidence.map((e: any) => Any.fromJSON(e)) : [], + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + + if (message.evidence) { + obj.evidence = message.evidence.map((e) => (e ? Any.toJSON(e) : undefined)); + } else { + obj.evidence = []; + } + + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.evidence = object.evidence?.map((e) => Any.fromPartial(e)) || []; diff --git a/src/cosmos/evidence/v1beta1/query.ts b/src/cosmos/evidence/v1beta1/query.ts index fd521f76..6d9c0b44 100644 --- a/src/cosmos/evidence/v1beta1/query.ts +++ b/src/cosmos/evidence/v1beta1/query.ts @@ -2,7 +2,7 @@ import { PageRequest, PageResponse } from "../../base/query/v1beta1/pagination"; import { Any } from "../../../google/protobuf/any"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../helpers"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.evidence.v1beta1"; /** QueryEvidenceRequest is the request type for the Query/Evidence RPC method. */ @@ -75,6 +75,21 @@ export const QueryEvidenceRequest = { return message; }, + fromJSON(object: any): QueryEvidenceRequest { + return { + evidenceHash: isSet(object.evidenceHash) ? bytesFromBase64(object.evidenceHash) : new Uint8Array(), + }; + }, + + toJSON(message: QueryEvidenceRequest): unknown { + const obj: any = {}; + message.evidenceHash !== undefined && + (obj.evidenceHash = base64FromBytes( + message.evidenceHash !== undefined ? message.evidenceHash : new Uint8Array(), + )); + return obj; + }, + fromPartial, I>>(object: I): QueryEvidenceRequest { const message = createBaseQueryEvidenceRequest(); message.evidenceHash = object.evidenceHash ?? new Uint8Array(); @@ -119,6 +134,19 @@ export const QueryEvidenceResponse = { return message; }, + fromJSON(object: any): QueryEvidenceResponse { + return { + evidence: isSet(object.evidence) ? Any.fromJSON(object.evidence) : undefined, + }; + }, + + toJSON(message: QueryEvidenceResponse): unknown { + const obj: any = {}; + message.evidence !== undefined && + (obj.evidence = message.evidence ? Any.toJSON(message.evidence) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryEvidenceResponse { const message = createBaseQueryEvidenceResponse(); message.evidence = @@ -166,6 +194,19 @@ export const QueryAllEvidenceRequest = { return message; }, + fromJSON(object: any): QueryAllEvidenceRequest { + return { + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryAllEvidenceRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryAllEvidenceRequest { const message = createBaseQueryAllEvidenceRequest(); message.pagination = @@ -222,6 +263,27 @@ export const QueryAllEvidenceResponse = { return message; }, + fromJSON(object: any): QueryAllEvidenceResponse { + return { + evidence: Array.isArray(object?.evidence) ? object.evidence.map((e: any) => Any.fromJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryAllEvidenceResponse): unknown { + const obj: any = {}; + + if (message.evidence) { + obj.evidence = message.evidence.map((e) => (e ? Any.toJSON(e) : undefined)); + } else { + obj.evidence = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryAllEvidenceResponse { diff --git a/src/cosmos/evidence/v1beta1/tx.ts b/src/cosmos/evidence/v1beta1/tx.ts index 8380ba2b..cc6a4b31 100644 --- a/src/cosmos/evidence/v1beta1/tx.ts +++ b/src/cosmos/evidence/v1beta1/tx.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Any } from "../../../google/protobuf/any"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../helpers"; +import { isSet, DeepPartial, Exact, bytesFromBase64, base64FromBytes, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.evidence.v1beta1"; /** * MsgSubmitEvidence represents a message that supports submitting arbitrary @@ -65,6 +65,21 @@ export const MsgSubmitEvidence = { return message; }, + fromJSON(object: any): MsgSubmitEvidence { + return { + submitter: isSet(object.submitter) ? String(object.submitter) : "", + evidence: isSet(object.evidence) ? Any.fromJSON(object.evidence) : undefined, + }; + }, + + toJSON(message: MsgSubmitEvidence): unknown { + const obj: any = {}; + message.submitter !== undefined && (obj.submitter = message.submitter); + message.evidence !== undefined && + (obj.evidence = message.evidence ? Any.toJSON(message.evidence) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgSubmitEvidence { const message = createBaseMsgSubmitEvidence(); message.submitter = object.submitter ?? ""; @@ -113,6 +128,19 @@ export const MsgSubmitEvidenceResponse = { return message; }, + fromJSON(object: any): MsgSubmitEvidenceResponse { + return { + hash: isSet(object.hash) ? bytesFromBase64(object.hash) : new Uint8Array(), + }; + }, + + toJSON(message: MsgSubmitEvidenceResponse): unknown { + const obj: any = {}; + message.hash !== undefined && + (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); + return obj; + }, + fromPartial, I>>( object: I, ): MsgSubmitEvidenceResponse { diff --git a/src/cosmos/feegrant/v1beta1/feegrant.ts b/src/cosmos/feegrant/v1beta1/feegrant.ts index 50bc2d4c..39e9866f 100644 --- a/src/cosmos/feegrant/v1beta1/feegrant.ts +++ b/src/cosmos/feegrant/v1beta1/feegrant.ts @@ -4,7 +4,7 @@ import { Timestamp } from "../../../google/protobuf/timestamp"; import { Duration } from "../../../google/protobuf/duration"; import { Any } from "../../../google/protobuf/any"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../helpers"; +import { isSet, fromJsonTimestamp, fromTimestamp, DeepPartial, Exact } from "../../../helpers"; export const protobufPackage = "cosmos.feegrant.v1beta1"; /** * BasicAllowance implements Allowance with a one-time grant of tokens @@ -121,6 +121,28 @@ export const BasicAllowance = { return message; }, + fromJSON(object: any): BasicAllowance { + return { + spendLimit: Array.isArray(object?.spendLimit) + ? object.spendLimit.map((e: any) => Coin.fromJSON(e)) + : [], + expiration: isSet(object.expiration) ? fromJsonTimestamp(object.expiration) : undefined, + }; + }, + + toJSON(message: BasicAllowance): unknown { + const obj: any = {}; + + if (message.spendLimit) { + obj.spendLimit = message.spendLimit.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.spendLimit = []; + } + + message.expiration !== undefined && (obj.expiration = fromTimestamp(message.expiration).toISOString()); + return obj; + }, + fromPartial, I>>(object: I): BasicAllowance { const message = createBaseBasicAllowance(); message.spendLimit = object.spendLimit?.map((e) => Coin.fromPartial(e)) || []; @@ -205,6 +227,43 @@ export const PeriodicAllowance = { return message; }, + fromJSON(object: any): PeriodicAllowance { + return { + basic: isSet(object.basic) ? BasicAllowance.fromJSON(object.basic) : undefined, + period: isSet(object.period) ? Duration.fromJSON(object.period) : undefined, + periodSpendLimit: Array.isArray(object?.periodSpendLimit) + ? object.periodSpendLimit.map((e: any) => Coin.fromJSON(e)) + : [], + periodCanSpend: Array.isArray(object?.periodCanSpend) + ? object.periodCanSpend.map((e: any) => Coin.fromJSON(e)) + : [], + periodReset: isSet(object.periodReset) ? fromJsonTimestamp(object.periodReset) : undefined, + }; + }, + + toJSON(message: PeriodicAllowance): unknown { + const obj: any = {}; + message.basic !== undefined && + (obj.basic = message.basic ? BasicAllowance.toJSON(message.basic) : undefined); + message.period !== undefined && + (obj.period = message.period ? Duration.toJSON(message.period) : undefined); + + if (message.periodSpendLimit) { + obj.periodSpendLimit = message.periodSpendLimit.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.periodSpendLimit = []; + } + + if (message.periodCanSpend) { + obj.periodCanSpend = message.periodCanSpend.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.periodCanSpend = []; + } + + message.periodReset !== undefined && (obj.periodReset = fromTimestamp(message.periodReset).toISOString()); + return obj; + }, + fromPartial, I>>(object: I): PeriodicAllowance { const message = createBasePeriodicAllowance(); message.basic = @@ -269,6 +328,29 @@ export const AllowedMsgAllowance = { return message; }, + fromJSON(object: any): AllowedMsgAllowance { + return { + allowance: isSet(object.allowance) ? Any.fromJSON(object.allowance) : undefined, + allowedMessages: Array.isArray(object?.allowedMessages) + ? object.allowedMessages.map((e: any) => String(e)) + : [], + }; + }, + + toJSON(message: AllowedMsgAllowance): unknown { + const obj: any = {}; + message.allowance !== undefined && + (obj.allowance = message.allowance ? Any.toJSON(message.allowance) : undefined); + + if (message.allowedMessages) { + obj.allowedMessages = message.allowedMessages.map((e) => e); + } else { + obj.allowedMessages = []; + } + + return obj; + }, + fromPartial, I>>(object: I): AllowedMsgAllowance { const message = createBaseAllowedMsgAllowance(); message.allowance = @@ -335,6 +417,23 @@ export const Grant = { return message; }, + fromJSON(object: any): Grant { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + grantee: isSet(object.grantee) ? String(object.grantee) : "", + allowance: isSet(object.allowance) ? Any.fromJSON(object.allowance) : undefined, + }; + }, + + toJSON(message: Grant): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + message.allowance !== undefined && + (obj.allowance = message.allowance ? Any.toJSON(message.allowance) : undefined); + return obj; + }, + fromPartial, I>>(object: I): Grant { const message = createBaseGrant(); message.granter = object.granter ?? ""; diff --git a/src/cosmos/feegrant/v1beta1/genesis.ts b/src/cosmos/feegrant/v1beta1/genesis.ts index 6f33be6c..35ab4b27 100644 --- a/src/cosmos/feegrant/v1beta1/genesis.ts +++ b/src/cosmos/feegrant/v1beta1/genesis.ts @@ -46,6 +46,26 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + allowances: Array.isArray(object?.allowances) + ? object.allowances.map((e: any) => Grant.fromJSON(e)) + : [], + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + + if (message.allowances) { + obj.allowances = message.allowances.map((e) => (e ? Grant.toJSON(e) : undefined)); + } else { + obj.allowances = []; + } + + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.allowances = object.allowances?.map((e) => Grant.fromPartial(e)) || []; diff --git a/src/cosmos/feegrant/v1beta1/query.ts b/src/cosmos/feegrant/v1beta1/query.ts index 30519880..946c70d1 100644 --- a/src/cosmos/feegrant/v1beta1/query.ts +++ b/src/cosmos/feegrant/v1beta1/query.ts @@ -2,7 +2,7 @@ import { PageRequest, PageResponse } from "../../base/query/v1beta1/pagination"; import { Grant } from "./feegrant"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../helpers"; +import { isSet, DeepPartial, Exact, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.feegrant.v1beta1"; /** QueryAllowanceRequest is the request type for the Query/Allowance RPC method. */ @@ -100,6 +100,20 @@ export const QueryAllowanceRequest = { return message; }, + fromJSON(object: any): QueryAllowanceRequest { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + grantee: isSet(object.grantee) ? String(object.grantee) : "", + }; + }, + + toJSON(message: QueryAllowanceRequest): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + return obj; + }, + fromPartial, I>>(object: I): QueryAllowanceRequest { const message = createBaseQueryAllowanceRequest(); message.granter = object.granter ?? ""; @@ -145,6 +159,19 @@ export const QueryAllowanceResponse = { return message; }, + fromJSON(object: any): QueryAllowanceResponse { + return { + allowance: isSet(object.allowance) ? Grant.fromJSON(object.allowance) : undefined, + }; + }, + + toJSON(message: QueryAllowanceResponse): unknown { + const obj: any = {}; + message.allowance !== undefined && + (obj.allowance = message.allowance ? Grant.toJSON(message.allowance) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryAllowanceResponse { const message = createBaseQueryAllowanceResponse(); message.allowance = @@ -201,6 +228,21 @@ export const QueryAllowancesRequest = { return message; }, + fromJSON(object: any): QueryAllowancesRequest { + return { + grantee: isSet(object.grantee) ? String(object.grantee) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryAllowancesRequest): unknown { + const obj: any = {}; + message.grantee !== undefined && (obj.grantee = message.grantee); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryAllowancesRequest { const message = createBaseQueryAllowancesRequest(); message.grantee = object.grantee ?? ""; @@ -258,6 +300,29 @@ export const QueryAllowancesResponse = { return message; }, + fromJSON(object: any): QueryAllowancesResponse { + return { + allowances: Array.isArray(object?.allowances) + ? object.allowances.map((e: any) => Grant.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryAllowancesResponse): unknown { + const obj: any = {}; + + if (message.allowances) { + obj.allowances = message.allowances.map((e) => (e ? Grant.toJSON(e) : undefined)); + } else { + obj.allowances = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryAllowancesResponse { const message = createBaseQueryAllowancesResponse(); message.allowances = object.allowances?.map((e) => Grant.fromPartial(e)) || []; @@ -315,6 +380,21 @@ export const QueryAllowancesByGranterRequest = { return message; }, + fromJSON(object: any): QueryAllowancesByGranterRequest { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryAllowancesByGranterRequest): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryAllowancesByGranterRequest { @@ -374,6 +454,29 @@ export const QueryAllowancesByGranterResponse = { return message; }, + fromJSON(object: any): QueryAllowancesByGranterResponse { + return { + allowances: Array.isArray(object?.allowances) + ? object.allowances.map((e: any) => Grant.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryAllowancesByGranterResponse): unknown { + const obj: any = {}; + + if (message.allowances) { + obj.allowances = message.allowances.map((e) => (e ? Grant.toJSON(e) : undefined)); + } else { + obj.allowances = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryAllowancesByGranterResponse { diff --git a/src/cosmos/feegrant/v1beta1/tx.ts b/src/cosmos/feegrant/v1beta1/tx.ts index be18184c..828c1c05 100644 --- a/src/cosmos/feegrant/v1beta1/tx.ts +++ b/src/cosmos/feegrant/v1beta1/tx.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Any } from "../../../google/protobuf/any"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../helpers"; +import { isSet, DeepPartial, Exact, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.feegrant.v1beta1"; /** * MsgGrantAllowance adds permission for Grantee to spend up to Allowance @@ -89,6 +89,23 @@ export const MsgGrantAllowance = { return message; }, + fromJSON(object: any): MsgGrantAllowance { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + grantee: isSet(object.grantee) ? String(object.grantee) : "", + allowance: isSet(object.allowance) ? Any.fromJSON(object.allowance) : undefined, + }; + }, + + toJSON(message: MsgGrantAllowance): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + message.allowance !== undefined && + (obj.allowance = message.allowance ? Any.toJSON(message.allowance) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgGrantAllowance { const message = createBaseMsgGrantAllowance(); message.granter = object.granter ?? ""; @@ -128,6 +145,15 @@ export const MsgGrantAllowanceResponse = { return message; }, + fromJSON(_: any): MsgGrantAllowanceResponse { + return {}; + }, + + toJSON(_: MsgGrantAllowanceResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgGrantAllowanceResponse { const message = createBaseMsgGrantAllowanceResponse(); return message; @@ -180,6 +206,20 @@ export const MsgRevokeAllowance = { return message; }, + fromJSON(object: any): MsgRevokeAllowance { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + grantee: isSet(object.grantee) ? String(object.grantee) : "", + }; + }, + + toJSON(message: MsgRevokeAllowance): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + return obj; + }, + fromPartial, I>>(object: I): MsgRevokeAllowance { const message = createBaseMsgRevokeAllowance(); message.granter = object.granter ?? ""; @@ -215,6 +255,15 @@ export const MsgRevokeAllowanceResponse = { return message; }, + fromJSON(_: any): MsgRevokeAllowanceResponse { + return {}; + }, + + toJSON(_: MsgRevokeAllowanceResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgRevokeAllowanceResponse { const message = createBaseMsgRevokeAllowanceResponse(); return message; diff --git a/src/cosmos/genutil/v1beta1/genesis.ts b/src/cosmos/genutil/v1beta1/genesis.ts index 9e3bd042..24e0b6ad 100644 --- a/src/cosmos/genutil/v1beta1/genesis.ts +++ b/src/cosmos/genutil/v1beta1/genesis.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../helpers"; +import { bytesFromBase64, base64FromBytes, DeepPartial, Exact } from "../../../helpers"; export const protobufPackage = "cosmos.genutil.v1beta1"; /** GenesisState defines the raw genesis transaction in JSON. */ @@ -46,6 +46,24 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + genTxs: Array.isArray(object?.genTxs) ? object.genTxs.map((e: any) => bytesFromBase64(e)) : [], + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + + if (message.genTxs) { + obj.genTxs = message.genTxs.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.genTxs = []; + } + + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.genTxs = object.genTxs?.map((e) => e) || []; diff --git a/src/cosmos/gov/v1beta1/genesis.ts b/src/cosmos/gov/v1beta1/genesis.ts index 09f99397..ed541920 100644 --- a/src/cosmos/gov/v1beta1/genesis.ts +++ b/src/cosmos/gov/v1beta1/genesis.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import { Deposit, Vote, Proposal, DepositParams, VotingParams, TallyParams } from "./gov"; -import { Long, DeepPartial, Exact } from "../../../helpers"; +import { Long, isSet, DeepPartial, Exact } from "../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "cosmos.gov.v1beta1"; /** GenesisState defines the gov module's genesis state. */ @@ -119,6 +119,54 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + startingProposalId: isSet(object.startingProposalId) + ? Long.fromValue(object.startingProposalId) + : Long.UZERO, + deposits: Array.isArray(object?.deposits) ? object.deposits.map((e: any) => Deposit.fromJSON(e)) : [], + votes: Array.isArray(object?.votes) ? object.votes.map((e: any) => Vote.fromJSON(e)) : [], + proposals: Array.isArray(object?.proposals) + ? object.proposals.map((e: any) => Proposal.fromJSON(e)) + : [], + depositParams: isSet(object.depositParams) ? DepositParams.fromJSON(object.depositParams) : undefined, + votingParams: isSet(object.votingParams) ? VotingParams.fromJSON(object.votingParams) : undefined, + tallyParams: isSet(object.tallyParams) ? TallyParams.fromJSON(object.tallyParams) : undefined, + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.startingProposalId !== undefined && + (obj.startingProposalId = (message.startingProposalId || Long.UZERO).toString()); + + if (message.deposits) { + obj.deposits = message.deposits.map((e) => (e ? Deposit.toJSON(e) : undefined)); + } else { + obj.deposits = []; + } + + if (message.votes) { + obj.votes = message.votes.map((e) => (e ? Vote.toJSON(e) : undefined)); + } else { + obj.votes = []; + } + + if (message.proposals) { + obj.proposals = message.proposals.map((e) => (e ? Proposal.toJSON(e) : undefined)); + } else { + obj.proposals = []; + } + + message.depositParams !== undefined && + (obj.depositParams = message.depositParams ? DepositParams.toJSON(message.depositParams) : undefined); + message.votingParams !== undefined && + (obj.votingParams = message.votingParams ? VotingParams.toJSON(message.votingParams) : undefined); + message.tallyParams !== undefined && + (obj.tallyParams = message.tallyParams ? TallyParams.toJSON(message.tallyParams) : undefined); + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.startingProposalId = diff --git a/src/cosmos/gov/v1beta1/gov.ts b/src/cosmos/gov/v1beta1/gov.ts index 57bef486..4dd490bc 100644 --- a/src/cosmos/gov/v1beta1/gov.ts +++ b/src/cosmos/gov/v1beta1/gov.ts @@ -4,7 +4,16 @@ import { Any } from "../../../google/protobuf/any"; import { Timestamp } from "../../../google/protobuf/timestamp"; import { Duration } from "../../../google/protobuf/duration"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../../helpers"; +import { + isSet, + DeepPartial, + Exact, + Long, + fromJsonTimestamp, + fromTimestamp, + bytesFromBase64, + base64FromBytes, +} from "../../../helpers"; export const protobufPackage = "cosmos.gov.v1beta1"; /** VoteOption enumerates the valid vote options for a given governance proposal. */ @@ -323,6 +332,20 @@ export const WeightedVoteOption = { return message; }, + fromJSON(object: any): WeightedVoteOption { + return { + option: isSet(object.option) ? voteOptionFromJSON(object.option) : 0, + weight: isSet(object.weight) ? String(object.weight) : "", + }; + }, + + toJSON(message: WeightedVoteOption): unknown { + const obj: any = {}; + message.option !== undefined && (obj.option = voteOptionToJSON(message.option)); + message.weight !== undefined && (obj.weight = message.weight); + return obj; + }, + fromPartial, I>>(object: I): WeightedVoteOption { const message = createBaseWeightedVoteOption(); message.option = object.option ?? 0; @@ -377,6 +400,20 @@ export const TextProposal = { return message; }, + fromJSON(object: any): TextProposal { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + }; + }, + + toJSON(message: TextProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + return obj; + }, + fromPartial, I>>(object: I): TextProposal { const message = createBaseTextProposal(); message.title = object.title ?? ""; @@ -440,6 +477,28 @@ export const Deposit = { return message; }, + fromJSON(object: any): Deposit { + return { + proposalId: isSet(object.proposalId) ? Long.fromValue(object.proposalId) : Long.UZERO, + depositor: isSet(object.depositor) ? String(object.depositor) : "", + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromJSON(e)) : [], + }; + }, + + toJSON(message: Deposit): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || Long.UZERO).toString()); + message.depositor !== undefined && (obj.depositor = message.depositor); + + if (message.amount) { + obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.amount = []; + } + + return obj; + }, + fromPartial, I>>(object: I): Deposit { const message = createBaseDeposit(); message.proposalId = @@ -561,6 +620,51 @@ export const Proposal = { return message; }, + fromJSON(object: any): Proposal { + return { + proposalId: isSet(object.proposalId) ? Long.fromValue(object.proposalId) : Long.UZERO, + content: isSet(object.content) ? Any.fromJSON(object.content) : undefined, + status: isSet(object.status) ? proposalStatusFromJSON(object.status) : 0, + finalTallyResult: isSet(object.finalTallyResult) + ? TallyResult.fromJSON(object.finalTallyResult) + : undefined, + submitTime: isSet(object.submitTime) ? fromJsonTimestamp(object.submitTime) : undefined, + depositEndTime: isSet(object.depositEndTime) ? fromJsonTimestamp(object.depositEndTime) : undefined, + totalDeposit: Array.isArray(object?.totalDeposit) + ? object.totalDeposit.map((e: any) => Coin.fromJSON(e)) + : [], + votingStartTime: isSet(object.votingStartTime) ? fromJsonTimestamp(object.votingStartTime) : undefined, + votingEndTime: isSet(object.votingEndTime) ? fromJsonTimestamp(object.votingEndTime) : undefined, + }; + }, + + toJSON(message: Proposal): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || Long.UZERO).toString()); + message.content !== undefined && + (obj.content = message.content ? Any.toJSON(message.content) : undefined); + message.status !== undefined && (obj.status = proposalStatusToJSON(message.status)); + message.finalTallyResult !== undefined && + (obj.finalTallyResult = message.finalTallyResult + ? TallyResult.toJSON(message.finalTallyResult) + : undefined); + message.submitTime !== undefined && (obj.submitTime = fromTimestamp(message.submitTime).toISOString()); + message.depositEndTime !== undefined && + (obj.depositEndTime = fromTimestamp(message.depositEndTime).toISOString()); + + if (message.totalDeposit) { + obj.totalDeposit = message.totalDeposit.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.totalDeposit = []; + } + + message.votingStartTime !== undefined && + (obj.votingStartTime = fromTimestamp(message.votingStartTime).toISOString()); + message.votingEndTime !== undefined && + (obj.votingEndTime = fromTimestamp(message.votingEndTime).toISOString()); + return obj; + }, + fromPartial, I>>(object: I): Proposal { const message = createBaseProposal(); message.proposalId = @@ -659,6 +763,24 @@ export const TallyResult = { return message; }, + fromJSON(object: any): TallyResult { + return { + yes: isSet(object.yes) ? String(object.yes) : "", + abstain: isSet(object.abstain) ? String(object.abstain) : "", + no: isSet(object.no) ? String(object.no) : "", + noWithVeto: isSet(object.noWithVeto) ? String(object.noWithVeto) : "", + }; + }, + + toJSON(message: TallyResult): unknown { + const obj: any = {}; + message.yes !== undefined && (obj.yes = message.yes); + message.abstain !== undefined && (obj.abstain = message.abstain); + message.no !== undefined && (obj.no = message.no); + message.noWithVeto !== undefined && (obj.noWithVeto = message.noWithVeto); + return obj; + }, + fromPartial, I>>(object: I): TallyResult { const message = createBaseTallyResult(); message.yes = object.yes ?? ""; @@ -733,6 +855,32 @@ export const Vote = { return message; }, + fromJSON(object: any): Vote { + return { + proposalId: isSet(object.proposalId) ? Long.fromValue(object.proposalId) : Long.UZERO, + voter: isSet(object.voter) ? String(object.voter) : "", + option: isSet(object.option) ? voteOptionFromJSON(object.option) : 0, + options: Array.isArray(object?.options) + ? object.options.map((e: any) => WeightedVoteOption.fromJSON(e)) + : [], + }; + }, + + toJSON(message: Vote): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || Long.UZERO).toString()); + message.voter !== undefined && (obj.voter = message.voter); + message.option !== undefined && (obj.option = voteOptionToJSON(message.option)); + + if (message.options) { + obj.options = message.options.map((e) => (e ? WeightedVoteOption.toJSON(e) : undefined)); + } else { + obj.options = []; + } + + return obj; + }, + fromPartial, I>>(object: I): Vote { const message = createBaseVote(); message.proposalId = @@ -792,6 +940,33 @@ export const DepositParams = { return message; }, + fromJSON(object: any): DepositParams { + return { + minDeposit: Array.isArray(object?.minDeposit) + ? object.minDeposit.map((e: any) => Coin.fromJSON(e)) + : [], + maxDepositPeriod: isSet(object.maxDepositPeriod) + ? Duration.fromJSON(object.maxDepositPeriod) + : undefined, + }; + }, + + toJSON(message: DepositParams): unknown { + const obj: any = {}; + + if (message.minDeposit) { + obj.minDeposit = message.minDeposit.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.minDeposit = []; + } + + message.maxDepositPeriod !== undefined && + (obj.maxDepositPeriod = message.maxDepositPeriod + ? Duration.toJSON(message.maxDepositPeriod) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): DepositParams { const message = createBaseDepositParams(); message.minDeposit = object.minDeposit?.map((e) => Coin.fromPartial(e)) || []; @@ -840,6 +1015,19 @@ export const VotingParams = { return message; }, + fromJSON(object: any): VotingParams { + return { + votingPeriod: isSet(object.votingPeriod) ? Duration.fromJSON(object.votingPeriod) : undefined, + }; + }, + + toJSON(message: VotingParams): unknown { + const obj: any = {}; + message.votingPeriod !== undefined && + (obj.votingPeriod = message.votingPeriod ? Duration.toJSON(message.votingPeriod) : undefined); + return obj; + }, + fromPartial, I>>(object: I): VotingParams { const message = createBaseVotingParams(); message.votingPeriod = @@ -905,6 +1093,29 @@ export const TallyParams = { return message; }, + fromJSON(object: any): TallyParams { + return { + quorum: isSet(object.quorum) ? bytesFromBase64(object.quorum) : new Uint8Array(), + threshold: isSet(object.threshold) ? bytesFromBase64(object.threshold) : new Uint8Array(), + vetoThreshold: isSet(object.vetoThreshold) ? bytesFromBase64(object.vetoThreshold) : new Uint8Array(), + }; + }, + + toJSON(message: TallyParams): unknown { + const obj: any = {}; + message.quorum !== undefined && + (obj.quorum = base64FromBytes(message.quorum !== undefined ? message.quorum : new Uint8Array())); + message.threshold !== undefined && + (obj.threshold = base64FromBytes( + message.threshold !== undefined ? message.threshold : new Uint8Array(), + )); + message.vetoThreshold !== undefined && + (obj.vetoThreshold = base64FromBytes( + message.vetoThreshold !== undefined ? message.vetoThreshold : new Uint8Array(), + )); + return obj; + }, + fromPartial, I>>(object: I): TallyParams { const message = createBaseTallyParams(); message.quorum = object.quorum ?? new Uint8Array(); diff --git a/src/cosmos/gov/v1beta1/query.ts b/src/cosmos/gov/v1beta1/query.ts index 119be65f..c27f2576 100644 --- a/src/cosmos/gov/v1beta1/query.ts +++ b/src/cosmos/gov/v1beta1/query.ts @@ -8,9 +8,11 @@ import { TallyParams, Deposit, TallyResult, + proposalStatusFromJSON, + proposalStatusToJSON, } from "./gov"; import { PageRequest, PageResponse } from "../../base/query/v1beta1/pagination"; -import { Long, DeepPartial, Exact, Rpc } from "../../../helpers"; +import { Long, isSet, DeepPartial, Exact, Rpc } from "../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "cosmos.gov.v1beta1"; /** QueryProposalRequest is the request type for the Query/Proposal RPC method. */ @@ -186,6 +188,18 @@ export const QueryProposalRequest = { return message; }, + fromJSON(object: any): QueryProposalRequest { + return { + proposalId: isSet(object.proposalId) ? Long.fromValue(object.proposalId) : Long.UZERO, + }; + }, + + toJSON(message: QueryProposalRequest): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): QueryProposalRequest { const message = createBaseQueryProposalRequest(); message.proposalId = @@ -233,6 +247,19 @@ export const QueryProposalResponse = { return message; }, + fromJSON(object: any): QueryProposalResponse { + return { + proposal: isSet(object.proposal) ? Proposal.fromJSON(object.proposal) : undefined, + }; + }, + + toJSON(message: QueryProposalResponse): unknown { + const obj: any = {}; + message.proposal !== undefined && + (obj.proposal = message.proposal ? Proposal.toJSON(message.proposal) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryProposalResponse { const message = createBaseQueryProposalResponse(); message.proposal = @@ -307,6 +334,26 @@ export const QueryProposalsRequest = { return message; }, + fromJSON(object: any): QueryProposalsRequest { + return { + proposalStatus: isSet(object.proposalStatus) ? proposalStatusFromJSON(object.proposalStatus) : 0, + voter: isSet(object.voter) ? String(object.voter) : "", + depositor: isSet(object.depositor) ? String(object.depositor) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryProposalsRequest): unknown { + const obj: any = {}; + message.proposalStatus !== undefined && + (obj.proposalStatus = proposalStatusToJSON(message.proposalStatus)); + message.voter !== undefined && (obj.voter = message.voter); + message.depositor !== undefined && (obj.depositor = message.depositor); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryProposalsRequest { const message = createBaseQueryProposalsRequest(); message.proposalStatus = object.proposalStatus ?? 0; @@ -366,6 +413,29 @@ export const QueryProposalsResponse = { return message; }, + fromJSON(object: any): QueryProposalsResponse { + return { + proposals: Array.isArray(object?.proposals) + ? object.proposals.map((e: any) => Proposal.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryProposalsResponse): unknown { + const obj: any = {}; + + if (message.proposals) { + obj.proposals = message.proposals.map((e) => (e ? Proposal.toJSON(e) : undefined)); + } else { + obj.proposals = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryProposalsResponse { const message = createBaseQueryProposalsResponse(); message.proposals = object.proposals?.map((e) => Proposal.fromPartial(e)) || []; @@ -423,6 +493,20 @@ export const QueryVoteRequest = { return message; }, + fromJSON(object: any): QueryVoteRequest { + return { + proposalId: isSet(object.proposalId) ? Long.fromValue(object.proposalId) : Long.UZERO, + voter: isSet(object.voter) ? String(object.voter) : "", + }; + }, + + toJSON(message: QueryVoteRequest): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || Long.UZERO).toString()); + message.voter !== undefined && (obj.voter = message.voter); + return obj; + }, + fromPartial, I>>(object: I): QueryVoteRequest { const message = createBaseQueryVoteRequest(); message.proposalId = @@ -471,6 +555,18 @@ export const QueryVoteResponse = { return message; }, + fromJSON(object: any): QueryVoteResponse { + return { + vote: isSet(object.vote) ? Vote.fromJSON(object.vote) : undefined, + }; + }, + + toJSON(message: QueryVoteResponse): unknown { + const obj: any = {}; + message.vote !== undefined && (obj.vote = message.vote ? Vote.toJSON(message.vote) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryVoteResponse { const message = createBaseQueryVoteResponse(); message.vote = @@ -525,6 +621,21 @@ export const QueryVotesRequest = { return message; }, + fromJSON(object: any): QueryVotesRequest { + return { + proposalId: isSet(object.proposalId) ? Long.fromValue(object.proposalId) : Long.UZERO, + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryVotesRequest): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || Long.UZERO).toString()); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryVotesRequest { const message = createBaseQueryVotesRequest(); message.proposalId = @@ -585,6 +696,27 @@ export const QueryVotesResponse = { return message; }, + fromJSON(object: any): QueryVotesResponse { + return { + votes: Array.isArray(object?.votes) ? object.votes.map((e: any) => Vote.fromJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryVotesResponse): unknown { + const obj: any = {}; + + if (message.votes) { + obj.votes = message.votes.map((e) => (e ? Vote.toJSON(e) : undefined)); + } else { + obj.votes = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryVotesResponse { const message = createBaseQueryVotesResponse(); message.votes = object.votes?.map((e) => Vote.fromPartial(e)) || []; @@ -633,6 +765,18 @@ export const QueryParamsRequest = { return message; }, + fromJSON(object: any): QueryParamsRequest { + return { + paramsType: isSet(object.paramsType) ? String(object.paramsType) : "", + }; + }, + + toJSON(message: QueryParamsRequest): unknown { + const obj: any = {}; + message.paramsType !== undefined && (obj.paramsType = message.paramsType); + return obj; + }, + fromPartial, I>>(object: I): QueryParamsRequest { const message = createBaseQueryParamsRequest(); message.paramsType = object.paramsType ?? ""; @@ -695,6 +839,25 @@ export const QueryParamsResponse = { return message; }, + fromJSON(object: any): QueryParamsResponse { + return { + votingParams: isSet(object.votingParams) ? VotingParams.fromJSON(object.votingParams) : undefined, + depositParams: isSet(object.depositParams) ? DepositParams.fromJSON(object.depositParams) : undefined, + tallyParams: isSet(object.tallyParams) ? TallyParams.fromJSON(object.tallyParams) : undefined, + }; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.votingParams !== undefined && + (obj.votingParams = message.votingParams ? VotingParams.toJSON(message.votingParams) : undefined); + message.depositParams !== undefined && + (obj.depositParams = message.depositParams ? DepositParams.toJSON(message.depositParams) : undefined); + message.tallyParams !== undefined && + (obj.tallyParams = message.tallyParams ? TallyParams.toJSON(message.tallyParams) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryParamsResponse { const message = createBaseQueryParamsResponse(); message.votingParams = @@ -759,6 +922,20 @@ export const QueryDepositRequest = { return message; }, + fromJSON(object: any): QueryDepositRequest { + return { + proposalId: isSet(object.proposalId) ? Long.fromValue(object.proposalId) : Long.UZERO, + depositor: isSet(object.depositor) ? String(object.depositor) : "", + }; + }, + + toJSON(message: QueryDepositRequest): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || Long.UZERO).toString()); + message.depositor !== undefined && (obj.depositor = message.depositor); + return obj; + }, + fromPartial, I>>(object: I): QueryDepositRequest { const message = createBaseQueryDepositRequest(); message.proposalId = @@ -807,6 +984,19 @@ export const QueryDepositResponse = { return message; }, + fromJSON(object: any): QueryDepositResponse { + return { + deposit: isSet(object.deposit) ? Deposit.fromJSON(object.deposit) : undefined, + }; + }, + + toJSON(message: QueryDepositResponse): unknown { + const obj: any = {}; + message.deposit !== undefined && + (obj.deposit = message.deposit ? Deposit.toJSON(message.deposit) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryDepositResponse { const message = createBaseQueryDepositResponse(); message.deposit = @@ -863,6 +1053,21 @@ export const QueryDepositsRequest = { return message; }, + fromJSON(object: any): QueryDepositsRequest { + return { + proposalId: isSet(object.proposalId) ? Long.fromValue(object.proposalId) : Long.UZERO, + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryDepositsRequest): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || Long.UZERO).toString()); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryDepositsRequest { const message = createBaseQueryDepositsRequest(); message.proposalId = @@ -923,6 +1128,27 @@ export const QueryDepositsResponse = { return message; }, + fromJSON(object: any): QueryDepositsResponse { + return { + deposits: Array.isArray(object?.deposits) ? object.deposits.map((e: any) => Deposit.fromJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryDepositsResponse): unknown { + const obj: any = {}; + + if (message.deposits) { + obj.deposits = message.deposits.map((e) => (e ? Deposit.toJSON(e) : undefined)); + } else { + obj.deposits = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryDepositsResponse { const message = createBaseQueryDepositsResponse(); message.deposits = object.deposits?.map((e) => Deposit.fromPartial(e)) || []; @@ -971,6 +1197,18 @@ export const QueryTallyResultRequest = { return message; }, + fromJSON(object: any): QueryTallyResultRequest { + return { + proposalId: isSet(object.proposalId) ? Long.fromValue(object.proposalId) : Long.UZERO, + }; + }, + + toJSON(message: QueryTallyResultRequest): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): QueryTallyResultRequest { const message = createBaseQueryTallyResultRequest(); message.proposalId = @@ -1018,6 +1256,19 @@ export const QueryTallyResultResponse = { return message; }, + fromJSON(object: any): QueryTallyResultResponse { + return { + tally: isSet(object.tally) ? TallyResult.fromJSON(object.tally) : undefined, + }; + }, + + toJSON(message: QueryTallyResultResponse): unknown { + const obj: any = {}; + message.tally !== undefined && + (obj.tally = message.tally ? TallyResult.toJSON(message.tally) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryTallyResultResponse { diff --git a/src/cosmos/gov/v1beta1/tx.ts b/src/cosmos/gov/v1beta1/tx.ts index a6679261..f732e3b4 100644 --- a/src/cosmos/gov/v1beta1/tx.ts +++ b/src/cosmos/gov/v1beta1/tx.ts @@ -1,9 +1,9 @@ /* eslint-disable */ import { Any } from "../../../google/protobuf/any"; import { Coin } from "../../base/v1beta1/coin"; -import { VoteOption, WeightedVoteOption } from "./gov"; +import { VoteOption, WeightedVoteOption, voteOptionFromJSON, voteOptionToJSON } from "./gov"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long, Rpc } from "../../../helpers"; +import { isSet, DeepPartial, Exact, Long, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.gov.v1beta1"; /** * MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary @@ -114,6 +114,31 @@ export const MsgSubmitProposal = { return message; }, + fromJSON(object: any): MsgSubmitProposal { + return { + content: isSet(object.content) ? Any.fromJSON(object.content) : undefined, + initialDeposit: Array.isArray(object?.initialDeposit) + ? object.initialDeposit.map((e: any) => Coin.fromJSON(e)) + : [], + proposer: isSet(object.proposer) ? String(object.proposer) : "", + }; + }, + + toJSON(message: MsgSubmitProposal): unknown { + const obj: any = {}; + message.content !== undefined && + (obj.content = message.content ? Any.toJSON(message.content) : undefined); + + if (message.initialDeposit) { + obj.initialDeposit = message.initialDeposit.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.initialDeposit = []; + } + + message.proposer !== undefined && (obj.proposer = message.proposer); + return obj; + }, + fromPartial, I>>(object: I): MsgSubmitProposal { const message = createBaseMsgSubmitProposal(); message.content = @@ -161,6 +186,18 @@ export const MsgSubmitProposalResponse = { return message; }, + fromJSON(object: any): MsgSubmitProposalResponse { + return { + proposalId: isSet(object.proposalId) ? Long.fromValue(object.proposalId) : Long.UZERO, + }; + }, + + toJSON(message: MsgSubmitProposalResponse): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>( object: I, ): MsgSubmitProposalResponse { @@ -228,6 +265,22 @@ export const MsgVote = { return message; }, + fromJSON(object: any): MsgVote { + return { + proposalId: isSet(object.proposalId) ? Long.fromValue(object.proposalId) : Long.UZERO, + voter: isSet(object.voter) ? String(object.voter) : "", + option: isSet(object.option) ? voteOptionFromJSON(object.option) : 0, + }; + }, + + toJSON(message: MsgVote): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || Long.UZERO).toString()); + message.voter !== undefined && (obj.voter = message.voter); + message.option !== undefined && (obj.option = voteOptionToJSON(message.option)); + return obj; + }, + fromPartial, I>>(object: I): MsgVote { const message = createBaseMsgVote(); message.proposalId = @@ -267,6 +320,15 @@ export const MsgVoteResponse = { return message; }, + fromJSON(_: any): MsgVoteResponse { + return {}; + }, + + toJSON(_: MsgVoteResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgVoteResponse { const message = createBaseMsgVoteResponse(); return message; @@ -328,6 +390,30 @@ export const MsgVoteWeighted = { return message; }, + fromJSON(object: any): MsgVoteWeighted { + return { + proposalId: isSet(object.proposalId) ? Long.fromValue(object.proposalId) : Long.UZERO, + voter: isSet(object.voter) ? String(object.voter) : "", + options: Array.isArray(object?.options) + ? object.options.map((e: any) => WeightedVoteOption.fromJSON(e)) + : [], + }; + }, + + toJSON(message: MsgVoteWeighted): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || Long.UZERO).toString()); + message.voter !== undefined && (obj.voter = message.voter); + + if (message.options) { + obj.options = message.options.map((e) => (e ? WeightedVoteOption.toJSON(e) : undefined)); + } else { + obj.options = []; + } + + return obj; + }, + fromPartial, I>>(object: I): MsgVoteWeighted { const message = createBaseMsgVoteWeighted(); message.proposalId = @@ -367,6 +453,15 @@ export const MsgVoteWeightedResponse = { return message; }, + fromJSON(_: any): MsgVoteWeightedResponse { + return {}; + }, + + toJSON(_: MsgVoteWeightedResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgVoteWeightedResponse { const message = createBaseMsgVoteWeightedResponse(); return message; @@ -428,6 +523,28 @@ export const MsgDeposit = { return message; }, + fromJSON(object: any): MsgDeposit { + return { + proposalId: isSet(object.proposalId) ? Long.fromValue(object.proposalId) : Long.UZERO, + depositor: isSet(object.depositor) ? String(object.depositor) : "", + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromJSON(e)) : [], + }; + }, + + toJSON(message: MsgDeposit): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || Long.UZERO).toString()); + message.depositor !== undefined && (obj.depositor = message.depositor); + + if (message.amount) { + obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.amount = []; + } + + return obj; + }, + fromPartial, I>>(object: I): MsgDeposit { const message = createBaseMsgDeposit(); message.proposalId = @@ -467,6 +584,15 @@ export const MsgDepositResponse = { return message; }, + fromJSON(_: any): MsgDepositResponse { + return {}; + }, + + toJSON(_: MsgDepositResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgDepositResponse { const message = createBaseMsgDepositResponse(); return message; diff --git a/src/cosmos/mint/v1beta1/genesis.ts b/src/cosmos/mint/v1beta1/genesis.ts index 661e53f9..6703ade5 100644 --- a/src/cosmos/mint/v1beta1/genesis.ts +++ b/src/cosmos/mint/v1beta1/genesis.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Minter, Params } from "./mint"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../helpers"; export const protobufPackage = "cosmos.mint.v1beta1"; /** GenesisState defines the mint module's genesis state. */ @@ -59,6 +59,20 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + minter: isSet(object.minter) ? Minter.fromJSON(object.minter) : undefined, + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.minter !== undefined && (obj.minter = message.minter ? Minter.toJSON(message.minter) : undefined); + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.minter = diff --git a/src/cosmos/mint/v1beta1/mint.ts b/src/cosmos/mint/v1beta1/mint.ts index 8dffd713..e48598ba 100644 --- a/src/cosmos/mint/v1beta1/mint.ts +++ b/src/cosmos/mint/v1beta1/mint.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../../helpers"; +import { isSet, DeepPartial, Exact, Long } from "../../../helpers"; export const protobufPackage = "cosmos.mint.v1beta1"; /** Minter represents the minting state. */ @@ -79,6 +79,20 @@ export const Minter = { return message; }, + fromJSON(object: any): Minter { + return { + inflation: isSet(object.inflation) ? String(object.inflation) : "", + annualProvisions: isSet(object.annualProvisions) ? String(object.annualProvisions) : "", + }; + }, + + toJSON(message: Minter): unknown { + const obj: any = {}; + message.inflation !== undefined && (obj.inflation = message.inflation); + message.annualProvisions !== undefined && (obj.annualProvisions = message.annualProvisions); + return obj; + }, + fromPartial, I>>(object: I): Minter { const message = createBaseMinter(); message.inflation = object.inflation ?? ""; @@ -169,6 +183,29 @@ export const Params = { return message; }, + fromJSON(object: any): Params { + return { + mintDenom: isSet(object.mintDenom) ? String(object.mintDenom) : "", + inflationRateChange: isSet(object.inflationRateChange) ? String(object.inflationRateChange) : "", + inflationMax: isSet(object.inflationMax) ? String(object.inflationMax) : "", + inflationMin: isSet(object.inflationMin) ? String(object.inflationMin) : "", + goalBonded: isSet(object.goalBonded) ? String(object.goalBonded) : "", + blocksPerYear: isSet(object.blocksPerYear) ? Long.fromValue(object.blocksPerYear) : Long.UZERO, + }; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.mintDenom !== undefined && (obj.mintDenom = message.mintDenom); + message.inflationRateChange !== undefined && (obj.inflationRateChange = message.inflationRateChange); + message.inflationMax !== undefined && (obj.inflationMax = message.inflationMax); + message.inflationMin !== undefined && (obj.inflationMin = message.inflationMin); + message.goalBonded !== undefined && (obj.goalBonded = message.goalBonded); + message.blocksPerYear !== undefined && + (obj.blocksPerYear = (message.blocksPerYear || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): Params { const message = createBaseParams(); message.mintDenom = object.mintDenom ?? ""; diff --git a/src/cosmos/mint/v1beta1/query.ts b/src/cosmos/mint/v1beta1/query.ts index b00b4c57..dc4c07fb 100644 --- a/src/cosmos/mint/v1beta1/query.ts +++ b/src/cosmos/mint/v1beta1/query.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Params } from "./mint"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../helpers"; +import { DeepPartial, Exact, isSet, bytesFromBase64, base64FromBytes, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.mint.v1beta1"; /** QueryParamsRequest is the request type for the Query/Params RPC method. */ @@ -67,6 +67,15 @@ export const QueryParamsRequest = { return message; }, + fromJSON(_: any): QueryParamsRequest { + return {}; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryParamsRequest { const message = createBaseQueryParamsRequest(); return message; @@ -110,6 +119,18 @@ export const QueryParamsResponse = { return message; }, + fromJSON(object: any): QueryParamsResponse { + return { + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + }; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryParamsResponse { const message = createBaseQueryParamsResponse(); message.params = @@ -145,6 +166,15 @@ export const QueryInflationRequest = { return message; }, + fromJSON(_: any): QueryInflationRequest { + return {}; + }, + + toJSON(_: QueryInflationRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryInflationRequest { const message = createBaseQueryInflationRequest(); return message; @@ -188,6 +218,21 @@ export const QueryInflationResponse = { return message; }, + fromJSON(object: any): QueryInflationResponse { + return { + inflation: isSet(object.inflation) ? bytesFromBase64(object.inflation) : new Uint8Array(), + }; + }, + + toJSON(message: QueryInflationResponse): unknown { + const obj: any = {}; + message.inflation !== undefined && + (obj.inflation = base64FromBytes( + message.inflation !== undefined ? message.inflation : new Uint8Array(), + )); + return obj; + }, + fromPartial, I>>(object: I): QueryInflationResponse { const message = createBaseQueryInflationResponse(); message.inflation = object.inflation ?? new Uint8Array(); @@ -222,6 +267,15 @@ export const QueryAnnualProvisionsRequest = { return message; }, + fromJSON(_: any): QueryAnnualProvisionsRequest { + return {}; + }, + + toJSON(_: QueryAnnualProvisionsRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( _: I, ): QueryAnnualProvisionsRequest { @@ -267,6 +321,23 @@ export const QueryAnnualProvisionsResponse = { return message; }, + fromJSON(object: any): QueryAnnualProvisionsResponse { + return { + annualProvisions: isSet(object.annualProvisions) + ? bytesFromBase64(object.annualProvisions) + : new Uint8Array(), + }; + }, + + toJSON(message: QueryAnnualProvisionsResponse): unknown { + const obj: any = {}; + message.annualProvisions !== undefined && + (obj.annualProvisions = base64FromBytes( + message.annualProvisions !== undefined ? message.annualProvisions : new Uint8Array(), + )); + return obj; + }, + fromPartial, I>>( object: I, ): QueryAnnualProvisionsResponse { diff --git a/src/cosmos/params/v1beta1/params.ts b/src/cosmos/params/v1beta1/params.ts index d831928b..d5f58d05 100644 --- a/src/cosmos/params/v1beta1/params.ts +++ b/src/cosmos/params/v1beta1/params.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../helpers"; export const protobufPackage = "cosmos.params.v1beta1"; /** ParameterChangeProposal defines a proposal to change one or more parameters. */ @@ -75,6 +75,28 @@ export const ParameterChangeProposal = { return message; }, + fromJSON(object: any): ParameterChangeProposal { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + changes: Array.isArray(object?.changes) ? object.changes.map((e: any) => ParamChange.fromJSON(e)) : [], + }; + }, + + toJSON(message: ParameterChangeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + + if (message.changes) { + obj.changes = message.changes.map((e) => (e ? ParamChange.toJSON(e) : undefined)); + } else { + obj.changes = []; + } + + return obj; + }, + fromPartial, I>>(object: I): ParameterChangeProposal { const message = createBaseParameterChangeProposal(); message.title = object.title ?? ""; @@ -139,6 +161,22 @@ export const ParamChange = { return message; }, + fromJSON(object: any): ParamChange { + return { + subspace: isSet(object.subspace) ? String(object.subspace) : "", + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "", + }; + }, + + toJSON(message: ParamChange): unknown { + const obj: any = {}; + message.subspace !== undefined && (obj.subspace = message.subspace); + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial, I>>(object: I): ParamChange { const message = createBaseParamChange(); message.subspace = object.subspace ?? ""; diff --git a/src/cosmos/params/v1beta1/query.ts b/src/cosmos/params/v1beta1/query.ts index 33521f8d..e703786f 100644 --- a/src/cosmos/params/v1beta1/query.ts +++ b/src/cosmos/params/v1beta1/query.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { ParamChange } from "./params"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../helpers"; +import { isSet, DeepPartial, Exact, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.params.v1beta1"; /** QueryParamsRequest is request type for the Query/Params RPC method. */ @@ -65,6 +65,20 @@ export const QueryParamsRequest = { return message; }, + fromJSON(object: any): QueryParamsRequest { + return { + subspace: isSet(object.subspace) ? String(object.subspace) : "", + key: isSet(object.key) ? String(object.key) : "", + }; + }, + + toJSON(message: QueryParamsRequest): unknown { + const obj: any = {}; + message.subspace !== undefined && (obj.subspace = message.subspace); + message.key !== undefined && (obj.key = message.key); + return obj; + }, + fromPartial, I>>(object: I): QueryParamsRequest { const message = createBaseQueryParamsRequest(); message.subspace = object.subspace ?? ""; @@ -110,6 +124,19 @@ export const QueryParamsResponse = { return message; }, + fromJSON(object: any): QueryParamsResponse { + return { + param: isSet(object.param) ? ParamChange.fromJSON(object.param) : undefined, + }; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.param !== undefined && + (obj.param = message.param ? ParamChange.toJSON(message.param) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryParamsResponse { const message = createBaseQueryParamsResponse(); message.param = diff --git a/src/cosmos/slashing/v1beta1/genesis.ts b/src/cosmos/slashing/v1beta1/genesis.ts index 5d8c1a0c..c07ebb1b 100644 --- a/src/cosmos/slashing/v1beta1/genesis.ts +++ b/src/cosmos/slashing/v1beta1/genesis.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Params, ValidatorSigningInfo } from "./slashing"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../../helpers"; +import { isSet, DeepPartial, Exact, Long } from "../../../helpers"; export const protobufPackage = "cosmos.slashing.v1beta1"; /** GenesisState defines the slashing module's genesis state. */ @@ -107,6 +107,37 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + signingInfos: Array.isArray(object?.signingInfos) + ? object.signingInfos.map((e: any) => SigningInfo.fromJSON(e)) + : [], + missedBlocks: Array.isArray(object?.missedBlocks) + ? object.missedBlocks.map((e: any) => ValidatorMissedBlocks.fromJSON(e)) + : [], + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + + if (message.signingInfos) { + obj.signingInfos = message.signingInfos.map((e) => (e ? SigningInfo.toJSON(e) : undefined)); + } else { + obj.signingInfos = []; + } + + if (message.missedBlocks) { + obj.missedBlocks = message.missedBlocks.map((e) => (e ? ValidatorMissedBlocks.toJSON(e) : undefined)); + } else { + obj.missedBlocks = []; + } + + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.params = @@ -163,6 +194,25 @@ export const SigningInfo = { return message; }, + fromJSON(object: any): SigningInfo { + return { + address: isSet(object.address) ? String(object.address) : "", + validatorSigningInfo: isSet(object.validatorSigningInfo) + ? ValidatorSigningInfo.fromJSON(object.validatorSigningInfo) + : undefined, + }; + }, + + toJSON(message: SigningInfo): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.validatorSigningInfo !== undefined && + (obj.validatorSigningInfo = message.validatorSigningInfo + ? ValidatorSigningInfo.toJSON(message.validatorSigningInfo) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): SigningInfo { const message = createBaseSigningInfo(); message.address = object.address ?? ""; @@ -220,6 +270,28 @@ export const ValidatorMissedBlocks = { return message; }, + fromJSON(object: any): ValidatorMissedBlocks { + return { + address: isSet(object.address) ? String(object.address) : "", + missedBlocks: Array.isArray(object?.missedBlocks) + ? object.missedBlocks.map((e: any) => MissedBlock.fromJSON(e)) + : [], + }; + }, + + toJSON(message: ValidatorMissedBlocks): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + + if (message.missedBlocks) { + obj.missedBlocks = message.missedBlocks.map((e) => (e ? MissedBlock.toJSON(e) : undefined)); + } else { + obj.missedBlocks = []; + } + + return obj; + }, + fromPartial, I>>(object: I): ValidatorMissedBlocks { const message = createBaseValidatorMissedBlocks(); message.address = object.address ?? ""; @@ -274,6 +346,20 @@ export const MissedBlock = { return message; }, + fromJSON(object: any): MissedBlock { + return { + index: isSet(object.index) ? Long.fromValue(object.index) : Long.ZERO, + missed: isSet(object.missed) ? Boolean(object.missed) : false, + }; + }, + + toJSON(message: MissedBlock): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = (message.index || Long.ZERO).toString()); + message.missed !== undefined && (obj.missed = message.missed); + return obj; + }, + fromPartial, I>>(object: I): MissedBlock { const message = createBaseMissedBlock(); message.index = diff --git a/src/cosmos/slashing/v1beta1/query.ts b/src/cosmos/slashing/v1beta1/query.ts index 27fec604..5e1387e5 100644 --- a/src/cosmos/slashing/v1beta1/query.ts +++ b/src/cosmos/slashing/v1beta1/query.ts @@ -2,7 +2,7 @@ import { PageRequest, PageResponse } from "../../base/query/v1beta1/pagination"; import { Params, ValidatorSigningInfo } from "./slashing"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../helpers"; +import { DeepPartial, Exact, isSet, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.slashing.v1beta1"; /** QueryParamsRequest is the request type for the Query/Params RPC method */ @@ -76,6 +76,15 @@ export const QueryParamsRequest = { return message; }, + fromJSON(_: any): QueryParamsRequest { + return {}; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryParamsRequest { const message = createBaseQueryParamsRequest(); return message; @@ -119,6 +128,18 @@ export const QueryParamsResponse = { return message; }, + fromJSON(object: any): QueryParamsResponse { + return { + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + }; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryParamsResponse { const message = createBaseQueryParamsResponse(); message.params = @@ -164,6 +185,18 @@ export const QuerySigningInfoRequest = { return message; }, + fromJSON(object: any): QuerySigningInfoRequest { + return { + consAddress: isSet(object.consAddress) ? String(object.consAddress) : "", + }; + }, + + toJSON(message: QuerySigningInfoRequest): unknown { + const obj: any = {}; + message.consAddress !== undefined && (obj.consAddress = message.consAddress); + return obj; + }, + fromPartial, I>>(object: I): QuerySigningInfoRequest { const message = createBaseQuerySigningInfoRequest(); message.consAddress = object.consAddress ?? ""; @@ -208,6 +241,23 @@ export const QuerySigningInfoResponse = { return message; }, + fromJSON(object: any): QuerySigningInfoResponse { + return { + valSigningInfo: isSet(object.valSigningInfo) + ? ValidatorSigningInfo.fromJSON(object.valSigningInfo) + : undefined, + }; + }, + + toJSON(message: QuerySigningInfoResponse): unknown { + const obj: any = {}; + message.valSigningInfo !== undefined && + (obj.valSigningInfo = message.valSigningInfo + ? ValidatorSigningInfo.toJSON(message.valSigningInfo) + : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QuerySigningInfoResponse { @@ -257,6 +307,19 @@ export const QuerySigningInfosRequest = { return message; }, + fromJSON(object: any): QuerySigningInfosRequest { + return { + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QuerySigningInfosRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QuerySigningInfosRequest { @@ -315,6 +378,27 @@ export const QuerySigningInfosResponse = { return message; }, + fromJSON(object: any): QuerySigningInfosResponse { + return { + info: Array.isArray(object?.info) ? object.info.map((e: any) => ValidatorSigningInfo.fromJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QuerySigningInfosResponse): unknown { + const obj: any = {}; + + if (message.info) { + obj.info = message.info.map((e) => (e ? ValidatorSigningInfo.toJSON(e) : undefined)); + } else { + obj.info = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QuerySigningInfosResponse { diff --git a/src/cosmos/slashing/v1beta1/slashing.ts b/src/cosmos/slashing/v1beta1/slashing.ts index f8e30bf0..6ca7b3a3 100644 --- a/src/cosmos/slashing/v1beta1/slashing.ts +++ b/src/cosmos/slashing/v1beta1/slashing.ts @@ -1,7 +1,16 @@ /* eslint-disable */ import { Timestamp } from "../../../google/protobuf/timestamp"; import { Duration } from "../../../google/protobuf/duration"; -import { Long, DeepPartial, Exact } from "../../../helpers"; +import { + Long, + isSet, + fromJsonTimestamp, + fromTimestamp, + DeepPartial, + Exact, + bytesFromBase64, + base64FromBytes, +} from "../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "cosmos.slashing.v1beta1"; /** @@ -129,6 +138,31 @@ export const ValidatorSigningInfo = { return message; }, + fromJSON(object: any): ValidatorSigningInfo { + return { + address: isSet(object.address) ? String(object.address) : "", + startHeight: isSet(object.startHeight) ? Long.fromValue(object.startHeight) : Long.ZERO, + indexOffset: isSet(object.indexOffset) ? Long.fromValue(object.indexOffset) : Long.ZERO, + jailedUntil: isSet(object.jailedUntil) ? fromJsonTimestamp(object.jailedUntil) : undefined, + tombstoned: isSet(object.tombstoned) ? Boolean(object.tombstoned) : false, + missedBlocksCounter: isSet(object.missedBlocksCounter) + ? Long.fromValue(object.missedBlocksCounter) + : Long.ZERO, + }; + }, + + toJSON(message: ValidatorSigningInfo): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.startHeight !== undefined && (obj.startHeight = (message.startHeight || Long.ZERO).toString()); + message.indexOffset !== undefined && (obj.indexOffset = (message.indexOffset || Long.ZERO).toString()); + message.jailedUntil !== undefined && (obj.jailedUntil = fromTimestamp(message.jailedUntil).toISOString()); + message.tombstoned !== undefined && (obj.tombstoned = message.tombstoned); + message.missedBlocksCounter !== undefined && + (obj.missedBlocksCounter = (message.missedBlocksCounter || Long.ZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): ValidatorSigningInfo { const message = createBaseValidatorSigningInfo(); message.address = object.address ?? ""; @@ -226,6 +260,49 @@ export const Params = { return message; }, + fromJSON(object: any): Params { + return { + signedBlocksWindow: isSet(object.signedBlocksWindow) + ? Long.fromValue(object.signedBlocksWindow) + : Long.ZERO, + minSignedPerWindow: isSet(object.minSignedPerWindow) + ? bytesFromBase64(object.minSignedPerWindow) + : new Uint8Array(), + downtimeJailDuration: isSet(object.downtimeJailDuration) + ? Duration.fromJSON(object.downtimeJailDuration) + : undefined, + slashFractionDoubleSign: isSet(object.slashFractionDoubleSign) + ? bytesFromBase64(object.slashFractionDoubleSign) + : new Uint8Array(), + slashFractionDowntime: isSet(object.slashFractionDowntime) + ? bytesFromBase64(object.slashFractionDowntime) + : new Uint8Array(), + }; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.signedBlocksWindow !== undefined && + (obj.signedBlocksWindow = (message.signedBlocksWindow || Long.ZERO).toString()); + message.minSignedPerWindow !== undefined && + (obj.minSignedPerWindow = base64FromBytes( + message.minSignedPerWindow !== undefined ? message.minSignedPerWindow : new Uint8Array(), + )); + message.downtimeJailDuration !== undefined && + (obj.downtimeJailDuration = message.downtimeJailDuration + ? Duration.toJSON(message.downtimeJailDuration) + : undefined); + message.slashFractionDoubleSign !== undefined && + (obj.slashFractionDoubleSign = base64FromBytes( + message.slashFractionDoubleSign !== undefined ? message.slashFractionDoubleSign : new Uint8Array(), + )); + message.slashFractionDowntime !== undefined && + (obj.slashFractionDowntime = base64FromBytes( + message.slashFractionDowntime !== undefined ? message.slashFractionDowntime : new Uint8Array(), + )); + return obj; + }, + fromPartial, I>>(object: I): Params { const message = createBaseParams(); message.signedBlocksWindow = diff --git a/src/cosmos/slashing/v1beta1/tx.ts b/src/cosmos/slashing/v1beta1/tx.ts index 31508d33..e665505f 100644 --- a/src/cosmos/slashing/v1beta1/tx.ts +++ b/src/cosmos/slashing/v1beta1/tx.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../helpers"; +import { isSet, DeepPartial, Exact, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.slashing.v1beta1"; /** MsgUnjail defines the Msg/Unjail request type */ @@ -48,6 +48,18 @@ export const MsgUnjail = { return message; }, + fromJSON(object: any): MsgUnjail { + return { + validatorAddr: isSet(object.validatorAddr) ? String(object.validatorAddr) : "", + }; + }, + + toJSON(message: MsgUnjail): unknown { + const obj: any = {}; + message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); + return obj; + }, + fromPartial, I>>(object: I): MsgUnjail { const message = createBaseMsgUnjail(); message.validatorAddr = object.validatorAddr ?? ""; @@ -82,6 +94,15 @@ export const MsgUnjailResponse = { return message; }, + fromJSON(_: any): MsgUnjailResponse { + return {}; + }, + + toJSON(_: MsgUnjailResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgUnjailResponse { const message = createBaseMsgUnjailResponse(); return message; diff --git a/src/cosmos/staking/v1beta1/authz.ts b/src/cosmos/staking/v1beta1/authz.ts index c39f5579..1d91155d 100644 --- a/src/cosmos/staking/v1beta1/authz.ts +++ b/src/cosmos/staking/v1beta1/authz.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Coin } from "../../base/v1beta1/coin"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../helpers"; export const protobufPackage = "cosmos.staking.v1beta1"; /** * AuthorizationType defines the type of staking module authorization type @@ -161,6 +161,34 @@ export const StakeAuthorization = { return message; }, + fromJSON(object: any): StakeAuthorization { + return { + maxTokens: isSet(object.maxTokens) ? Coin.fromJSON(object.maxTokens) : undefined, + allowList: isSet(object.allowList) + ? StakeAuthorization_Validators.fromJSON(object.allowList) + : undefined, + denyList: isSet(object.denyList) ? StakeAuthorization_Validators.fromJSON(object.denyList) : undefined, + authorizationType: isSet(object.authorizationType) + ? authorizationTypeFromJSON(object.authorizationType) + : 0, + }; + }, + + toJSON(message: StakeAuthorization): unknown { + const obj: any = {}; + message.maxTokens !== undefined && + (obj.maxTokens = message.maxTokens ? Coin.toJSON(message.maxTokens) : undefined); + message.allowList !== undefined && + (obj.allowList = message.allowList + ? StakeAuthorization_Validators.toJSON(message.allowList) + : undefined); + message.denyList !== undefined && + (obj.denyList = message.denyList ? StakeAuthorization_Validators.toJSON(message.denyList) : undefined); + message.authorizationType !== undefined && + (obj.authorizationType = authorizationTypeToJSON(message.authorizationType)); + return obj; + }, + fromPartial, I>>(object: I): StakeAuthorization { const message = createBaseStakeAuthorization(); message.maxTokens = @@ -217,6 +245,24 @@ export const StakeAuthorization_Validators = { return message; }, + fromJSON(object: any): StakeAuthorization_Validators { + return { + address: Array.isArray(object?.address) ? object.address.map((e: any) => String(e)) : [], + }; + }, + + toJSON(message: StakeAuthorization_Validators): unknown { + const obj: any = {}; + + if (message.address) { + obj.address = message.address.map((e) => e); + } else { + obj.address = []; + } + + return obj; + }, + fromPartial, I>>( object: I, ): StakeAuthorization_Validators { diff --git a/src/cosmos/staking/v1beta1/genesis.ts b/src/cosmos/staking/v1beta1/genesis.ts index 6ea642ad..3bc8a9c5 100644 --- a/src/cosmos/staking/v1beta1/genesis.ts +++ b/src/cosmos/staking/v1beta1/genesis.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Params, Validator, Delegation, UnbondingDelegation, Redelegation } from "./staking"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../../helpers"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact, Long } from "../../../helpers"; export const protobufPackage = "cosmos.staking.v1beta1"; /** GenesisState defines the staking module's genesis state. */ @@ -144,6 +144,77 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + lastTotalPower: isSet(object.lastTotalPower) + ? bytesFromBase64(object.lastTotalPower) + : new Uint8Array(), + lastValidatorPowers: Array.isArray(object?.lastValidatorPowers) + ? object.lastValidatorPowers.map((e: any) => LastValidatorPower.fromJSON(e)) + : [], + validators: Array.isArray(object?.validators) + ? object.validators.map((e: any) => Validator.fromJSON(e)) + : [], + delegations: Array.isArray(object?.delegations) + ? object.delegations.map((e: any) => Delegation.fromJSON(e)) + : [], + unbondingDelegations: Array.isArray(object?.unbondingDelegations) + ? object.unbondingDelegations.map((e: any) => UnbondingDelegation.fromJSON(e)) + : [], + redelegations: Array.isArray(object?.redelegations) + ? object.redelegations.map((e: any) => Redelegation.fromJSON(e)) + : [], + exported: isSet(object.exported) ? Boolean(object.exported) : false, + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + message.lastTotalPower !== undefined && + (obj.lastTotalPower = base64FromBytes( + message.lastTotalPower !== undefined ? message.lastTotalPower : new Uint8Array(), + )); + + if (message.lastValidatorPowers) { + obj.lastValidatorPowers = message.lastValidatorPowers.map((e) => + e ? LastValidatorPower.toJSON(e) : undefined, + ); + } else { + obj.lastValidatorPowers = []; + } + + if (message.validators) { + obj.validators = message.validators.map((e) => (e ? Validator.toJSON(e) : undefined)); + } else { + obj.validators = []; + } + + if (message.delegations) { + obj.delegations = message.delegations.map((e) => (e ? Delegation.toJSON(e) : undefined)); + } else { + obj.delegations = []; + } + + if (message.unbondingDelegations) { + obj.unbondingDelegations = message.unbondingDelegations.map((e) => + e ? UnbondingDelegation.toJSON(e) : undefined, + ); + } else { + obj.unbondingDelegations = []; + } + + if (message.redelegations) { + obj.redelegations = message.redelegations.map((e) => (e ? Redelegation.toJSON(e) : undefined)); + } else { + obj.redelegations = []; + } + + message.exported !== undefined && (obj.exported = message.exported); + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.params = @@ -207,6 +278,20 @@ export const LastValidatorPower = { return message; }, + fromJSON(object: any): LastValidatorPower { + return { + address: isSet(object.address) ? String(object.address) : "", + power: isSet(object.power) ? Long.fromValue(object.power) : Long.ZERO, + }; + }, + + toJSON(message: LastValidatorPower): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.power !== undefined && (obj.power = (message.power || Long.ZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): LastValidatorPower { const message = createBaseLastValidatorPower(); message.address = object.address ?? ""; diff --git a/src/cosmos/staking/v1beta1/query.ts b/src/cosmos/staking/v1beta1/query.ts index 8624669b..99dfec9a 100644 --- a/src/cosmos/staking/v1beta1/query.ts +++ b/src/cosmos/staking/v1beta1/query.ts @@ -10,7 +10,7 @@ import { Params, } from "./staking"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long, Rpc } from "../../../helpers"; +import { isSet, DeepPartial, Exact, Long, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.staking.v1beta1"; /** QueryValidatorsRequest is request type for Query/Validators RPC method. */ @@ -328,6 +328,21 @@ export const QueryValidatorsRequest = { return message; }, + fromJSON(object: any): QueryValidatorsRequest { + return { + status: isSet(object.status) ? String(object.status) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>(object: I): QueryValidatorsRequest { const message = createBaseQueryValidatorsRequest(); message.status = object.status ?? ""; @@ -385,6 +400,29 @@ export const QueryValidatorsResponse = { return message; }, + fromJSON(object: any): QueryValidatorsResponse { + return { + validators: Array.isArray(object?.validators) + ? object.validators.map((e: any) => Validator.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>(object: I): QueryValidatorsResponse { const message = createBaseQueryValidatorsResponse(); message.validators = object.validators?.map((e) => Validator.fromPartial(e)) || []; @@ -433,6 +471,18 @@ export const QueryValidatorRequest = { return message; }, + fromJSON(object: any): QueryValidatorRequest { + return { + validatorAddr: isSet(object.validatorAddr) ? String(object.validatorAddr) : "", + }; + }, + + toJSON(message: QueryValidatorRequest): unknown { + const obj: any = {}; + message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); + return obj; + }, + fromPartial, I>>(object: I): QueryValidatorRequest { const message = createBaseQueryValidatorRequest(); message.validatorAddr = object.validatorAddr ?? ""; @@ -477,6 +527,19 @@ export const QueryValidatorResponse = { return message; }, + fromJSON(object: any): QueryValidatorResponse { + return { + validator: isSet(object.validator) ? Validator.fromJSON(object.validator) : undefined, + }; + }, + + toJSON(message: QueryValidatorResponse): unknown { + const obj: any = {}; + message.validator !== undefined && + (obj.validator = message.validator ? Validator.toJSON(message.validator) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryValidatorResponse { const message = createBaseQueryValidatorResponse(); message.validator = @@ -533,6 +596,21 @@ export const QueryValidatorDelegationsRequest = { return message; }, + fromJSON(object: any): QueryValidatorDelegationsRequest { + return { + validatorAddr: isSet(object.validatorAddr) ? String(object.validatorAddr) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryValidatorDelegationsRequest { @@ -592,6 +670,31 @@ export const QueryValidatorDelegationsResponse = { return message; }, + fromJSON(object: any): QueryValidatorDelegationsResponse { + return { + delegationResponses: Array.isArray(object?.delegationResponses) + ? object.delegationResponses.map((e: any) => DelegationResponse.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryValidatorDelegationsResponse { @@ -655,6 +758,21 @@ export const QueryValidatorUnbondingDelegationsRequest = { return message; }, + fromJSON(object: any): QueryValidatorUnbondingDelegationsRequest { + return { + validatorAddr: isSet(object.validatorAddr) ? String(object.validatorAddr) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryValidatorUnbondingDelegationsRequest { @@ -717,6 +835,31 @@ export const QueryValidatorUnbondingDelegationsResponse = { return message; }, + fromJSON(object: any): QueryValidatorUnbondingDelegationsResponse { + return { + unbondingResponses: Array.isArray(object?.unbondingResponses) + ? object.unbondingResponses.map((e: any) => UnbondingDelegation.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryValidatorUnbondingDelegationsResponse { @@ -777,6 +920,20 @@ export const QueryDelegationRequest = { return message; }, + fromJSON(object: any): QueryDelegationRequest { + return { + delegatorAddr: isSet(object.delegatorAddr) ? String(object.delegatorAddr) : "", + validatorAddr: isSet(object.validatorAddr) ? String(object.validatorAddr) : "", + }; + }, + + toJSON(message: QueryDelegationRequest): unknown { + const obj: any = {}; + message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); + message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); + return obj; + }, + fromPartial, I>>(object: I): QueryDelegationRequest { const message = createBaseQueryDelegationRequest(); message.delegatorAddr = object.delegatorAddr ?? ""; @@ -822,6 +979,23 @@ export const QueryDelegationResponse = { return message; }, + fromJSON(object: any): QueryDelegationResponse { + return { + delegationResponse: isSet(object.delegationResponse) + ? DelegationResponse.fromJSON(object.delegationResponse) + : undefined, + }; + }, + + toJSON(message: QueryDelegationResponse): unknown { + const obj: any = {}; + message.delegationResponse !== undefined && + (obj.delegationResponse = message.delegationResponse + ? DelegationResponse.toJSON(message.delegationResponse) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryDelegationResponse { const message = createBaseQueryDelegationResponse(); message.delegationResponse = @@ -878,6 +1052,20 @@ export const QueryUnbondingDelegationRequest = { return message; }, + fromJSON(object: any): QueryUnbondingDelegationRequest { + return { + delegatorAddr: isSet(object.delegatorAddr) ? String(object.delegatorAddr) : "", + validatorAddr: isSet(object.validatorAddr) ? String(object.validatorAddr) : "", + }; + }, + + toJSON(message: QueryUnbondingDelegationRequest): unknown { + const obj: any = {}; + message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); + message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); + return obj; + }, + fromPartial, I>>( object: I, ): QueryUnbondingDelegationRequest { @@ -925,6 +1113,19 @@ export const QueryUnbondingDelegationResponse = { return message; }, + fromJSON(object: any): QueryUnbondingDelegationResponse { + return { + unbond: isSet(object.unbond) ? UnbondingDelegation.fromJSON(object.unbond) : undefined, + }; + }, + + toJSON(message: QueryUnbondingDelegationResponse): unknown { + const obj: any = {}; + message.unbond !== undefined && + (obj.unbond = message.unbond ? UnbondingDelegation.toJSON(message.unbond) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryUnbondingDelegationResponse { @@ -983,6 +1184,21 @@ export const QueryDelegatorDelegationsRequest = { return message; }, + fromJSON(object: any): QueryDelegatorDelegationsRequest { + return { + delegatorAddr: isSet(object.delegatorAddr) ? String(object.delegatorAddr) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryDelegatorDelegationsRequest { @@ -1042,6 +1258,31 @@ export const QueryDelegatorDelegationsResponse = { return message; }, + fromJSON(object: any): QueryDelegatorDelegationsResponse { + return { + delegationResponses: Array.isArray(object?.delegationResponses) + ? object.delegationResponses.map((e: any) => DelegationResponse.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryDelegatorDelegationsResponse { @@ -1105,6 +1346,21 @@ export const QueryDelegatorUnbondingDelegationsRequest = { return message; }, + fromJSON(object: any): QueryDelegatorUnbondingDelegationsRequest { + return { + delegatorAddr: isSet(object.delegatorAddr) ? String(object.delegatorAddr) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryDelegatorUnbondingDelegationsRequest { @@ -1167,6 +1423,31 @@ export const QueryDelegatorUnbondingDelegationsResponse = { return message; }, + fromJSON(object: any): QueryDelegatorUnbondingDelegationsResponse { + return { + unbondingResponses: Array.isArray(object?.unbondingResponses) + ? object.unbondingResponses.map((e: any) => UnbondingDelegation.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryDelegatorUnbondingDelegationsResponse { @@ -1245,6 +1526,25 @@ export const QueryRedelegationsRequest = { return message; }, + fromJSON(object: any): QueryRedelegationsRequest { + return { + delegatorAddr: isSet(object.delegatorAddr) ? String(object.delegatorAddr) : "", + srcValidatorAddr: isSet(object.srcValidatorAddr) ? String(object.srcValidatorAddr) : "", + dstValidatorAddr: isSet(object.dstValidatorAddr) ? String(object.dstValidatorAddr) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryRedelegationsRequest { @@ -1306,6 +1606,31 @@ export const QueryRedelegationsResponse = { return message; }, + fromJSON(object: any): QueryRedelegationsResponse { + return { + redelegationResponses: Array.isArray(object?.redelegationResponses) + ? object.redelegationResponses.map((e: any) => RedelegationResponse.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryRedelegationsResponse { @@ -1366,6 +1691,21 @@ export const QueryDelegatorValidatorsRequest = { return message; }, + fromJSON(object: any): QueryDelegatorValidatorsRequest { + return { + delegatorAddr: isSet(object.delegatorAddr) ? String(object.delegatorAddr) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryDelegatorValidatorsRequest { @@ -1425,6 +1765,29 @@ export const QueryDelegatorValidatorsResponse = { return message; }, + fromJSON(object: any): QueryDelegatorValidatorsResponse { + return { + validators: Array.isArray(object?.validators) + ? object.validators.map((e: any) => Validator.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryDelegatorValidatorsResponse { @@ -1484,6 +1847,20 @@ export const QueryDelegatorValidatorRequest = { return message; }, + fromJSON(object: any): QueryDelegatorValidatorRequest { + return { + delegatorAddr: isSet(object.delegatorAddr) ? String(object.delegatorAddr) : "", + validatorAddr: isSet(object.validatorAddr) ? String(object.validatorAddr) : "", + }; + }, + + toJSON(message: QueryDelegatorValidatorRequest): unknown { + const obj: any = {}; + message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); + message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); + return obj; + }, + fromPartial, I>>( object: I, ): QueryDelegatorValidatorRequest { @@ -1531,6 +1908,19 @@ export const QueryDelegatorValidatorResponse = { return message; }, + fromJSON(object: any): QueryDelegatorValidatorResponse { + return { + validator: isSet(object.validator) ? Validator.fromJSON(object.validator) : undefined, + }; + }, + + toJSON(message: QueryDelegatorValidatorResponse): unknown { + const obj: any = {}; + message.validator !== undefined && + (obj.validator = message.validator ? Validator.toJSON(message.validator) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryDelegatorValidatorResponse { @@ -1580,6 +1970,18 @@ export const QueryHistoricalInfoRequest = { return message; }, + fromJSON(object: any): QueryHistoricalInfoRequest { + return { + height: isSet(object.height) ? Long.fromValue(object.height) : Long.ZERO, + }; + }, + + toJSON(message: QueryHistoricalInfoRequest): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + return obj; + }, + fromPartial, I>>( object: I, ): QueryHistoricalInfoRequest { @@ -1627,6 +2029,18 @@ export const QueryHistoricalInfoResponse = { return message; }, + fromJSON(object: any): QueryHistoricalInfoResponse { + return { + hist: isSet(object.hist) ? HistoricalInfo.fromJSON(object.hist) : undefined, + }; + }, + + toJSON(message: QueryHistoricalInfoResponse): unknown { + const obj: any = {}; + message.hist !== undefined && (obj.hist = message.hist ? HistoricalInfo.toJSON(message.hist) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryHistoricalInfoResponse { @@ -1664,6 +2078,15 @@ export const QueryPoolRequest = { return message; }, + fromJSON(_: any): QueryPoolRequest { + return {}; + }, + + toJSON(_: QueryPoolRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryPoolRequest { const message = createBaseQueryPoolRequest(); return message; @@ -1707,6 +2130,18 @@ export const QueryPoolResponse = { return message; }, + fromJSON(object: any): QueryPoolResponse { + return { + pool: isSet(object.pool) ? Pool.fromJSON(object.pool) : undefined, + }; + }, + + toJSON(message: QueryPoolResponse): unknown { + const obj: any = {}; + message.pool !== undefined && (obj.pool = message.pool ? Pool.toJSON(message.pool) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryPoolResponse { const message = createBaseQueryPoolResponse(); message.pool = @@ -1742,6 +2177,15 @@ export const QueryParamsRequest = { return message; }, + fromJSON(_: any): QueryParamsRequest { + return {}; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryParamsRequest { const message = createBaseQueryParamsRequest(); return message; @@ -1785,6 +2229,18 @@ export const QueryParamsResponse = { return message; }, + fromJSON(object: any): QueryParamsResponse { + return { + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + }; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryParamsResponse { const message = createBaseQueryParamsResponse(); message.params = diff --git a/src/cosmos/staking/v1beta1/staking.ts b/src/cosmos/staking/v1beta1/staking.ts index 38498de4..b2a1fba2 100644 --- a/src/cosmos/staking/v1beta1/staking.ts +++ b/src/cosmos/staking/v1beta1/staking.ts @@ -5,7 +5,7 @@ import { Any } from "../../../google/protobuf/any"; import { Duration } from "../../../google/protobuf/duration"; import { Coin } from "../../base/v1beta1/coin"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../../helpers"; +import { isSet, DeepPartial, Exact, fromJsonTimestamp, fromTimestamp, Long } from "../../../helpers"; export const protobufPackage = "cosmos.staking.v1beta1"; /** BondStatus is the status of a validator. */ @@ -383,6 +383,26 @@ export const HistoricalInfo = { return message; }, + fromJSON(object: any): HistoricalInfo { + return { + header: isSet(object.header) ? Header.fromJSON(object.header) : undefined, + valset: Array.isArray(object?.valset) ? object.valset.map((e: any) => Validator.fromJSON(e)) : [], + }; + }, + + 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, I>>(object: I): HistoricalInfo { const message = createBaseHistoricalInfo(); message.header = @@ -447,6 +467,22 @@ export const CommissionRates = { return message; }, + fromJSON(object: any): CommissionRates { + return { + rate: isSet(object.rate) ? String(object.rate) : "", + maxRate: isSet(object.maxRate) ? String(object.maxRate) : "", + maxChangeRate: isSet(object.maxChangeRate) ? String(object.maxChangeRate) : "", + }; + }, + + 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, I>>(object: I): CommissionRates { const message = createBaseCommissionRates(); message.rate = object.rate ?? ""; @@ -502,6 +538,25 @@ export const Commission = { return message; }, + fromJSON(object: any): Commission { + return { + commissionRates: isSet(object.commissionRates) + ? CommissionRates.fromJSON(object.commissionRates) + : undefined, + updateTime: isSet(object.updateTime) ? fromJsonTimestamp(object.updateTime) : undefined, + }; + }, + + toJSON(message: Commission): unknown { + const obj: any = {}; + message.commissionRates !== undefined && + (obj.commissionRates = message.commissionRates + ? CommissionRates.toJSON(message.commissionRates) + : undefined); + message.updateTime !== undefined && (obj.updateTime = fromTimestamp(message.updateTime).toISOString()); + return obj; + }, + fromPartial, I>>(object: I): Commission { const message = createBaseCommission(); message.commissionRates = @@ -589,6 +644,26 @@ export const Description = { return message; }, + fromJSON(object: any): Description { + return { + moniker: isSet(object.moniker) ? String(object.moniker) : "", + identity: isSet(object.identity) ? String(object.identity) : "", + website: isSet(object.website) ? String(object.website) : "", + securityContact: isSet(object.securityContact) ? String(object.securityContact) : "", + details: isSet(object.details) ? String(object.details) : "", + }; + }, + + 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, I>>(object: I): Description { const message = createBaseDescription(); message.moniker = object.moniker ?? ""; @@ -727,6 +802,43 @@ export const Validator = { return message; }, + fromJSON(object: any): Validator { + return { + operatorAddress: isSet(object.operatorAddress) ? String(object.operatorAddress) : "", + consensusPubkey: isSet(object.consensusPubkey) ? Any.fromJSON(object.consensusPubkey) : undefined, + jailed: isSet(object.jailed) ? Boolean(object.jailed) : false, + status: isSet(object.status) ? bondStatusFromJSON(object.status) : 0, + tokens: isSet(object.tokens) ? String(object.tokens) : "", + delegatorShares: isSet(object.delegatorShares) ? String(object.delegatorShares) : "", + description: isSet(object.description) ? Description.fromJSON(object.description) : undefined, + unbondingHeight: isSet(object.unbondingHeight) ? Long.fromValue(object.unbondingHeight) : Long.ZERO, + unbondingTime: isSet(object.unbondingTime) ? fromJsonTimestamp(object.unbondingTime) : undefined, + commission: isSet(object.commission) ? Commission.fromJSON(object.commission) : undefined, + minSelfDelegation: isSet(object.minSelfDelegation) ? String(object.minSelfDelegation) : "", + }; + }, + + 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 = fromTimestamp(message.unbondingTime).toISOString()); + message.commission !== undefined && + (obj.commission = message.commission ? Commission.toJSON(message.commission) : undefined); + message.minSelfDelegation !== undefined && (obj.minSelfDelegation = message.minSelfDelegation); + return obj; + }, + fromPartial, I>>(object: I): Validator { const message = createBaseValidator(); message.operatorAddress = object.operatorAddress ?? ""; @@ -796,6 +908,24 @@ export const ValAddresses = { return message; }, + fromJSON(object: any): ValAddresses { + return { + addresses: Array.isArray(object?.addresses) ? object.addresses.map((e: any) => String(e)) : [], + }; + }, + + toJSON(message: ValAddresses): unknown { + const obj: any = {}; + + if (message.addresses) { + obj.addresses = message.addresses.map((e) => e); + } else { + obj.addresses = []; + } + + return obj; + }, + fromPartial, I>>(object: I): ValAddresses { const message = createBaseValAddresses(); message.addresses = object.addresses?.map((e) => e) || []; @@ -849,6 +979,20 @@ export const DVPair = { return message; }, + fromJSON(object: any): DVPair { + return { + delegatorAddress: isSet(object.delegatorAddress) ? String(object.delegatorAddress) : "", + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + }; + }, + + toJSON(message: DVPair): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + return obj; + }, + fromPartial, I>>(object: I): DVPair { const message = createBaseDVPair(); message.delegatorAddress = object.delegatorAddress ?? ""; @@ -894,6 +1038,24 @@ export const DVPairs = { return message; }, + fromJSON(object: any): DVPairs { + return { + pairs: Array.isArray(object?.pairs) ? object.pairs.map((e: any) => DVPair.fromJSON(e)) : [], + }; + }, + + 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, I>>(object: I): DVPairs { const message = createBaseDVPairs(); message.pairs = object.pairs?.map((e) => DVPair.fromPartial(e)) || []; @@ -956,6 +1118,22 @@ export const DVVTriplet = { return message; }, + fromJSON(object: any): DVVTriplet { + return { + delegatorAddress: isSet(object.delegatorAddress) ? String(object.delegatorAddress) : "", + validatorSrcAddress: isSet(object.validatorSrcAddress) ? String(object.validatorSrcAddress) : "", + validatorDstAddress: isSet(object.validatorDstAddress) ? String(object.validatorDstAddress) : "", + }; + }, + + 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, I>>(object: I): DVVTriplet { const message = createBaseDVVTriplet(); message.delegatorAddress = object.delegatorAddress ?? ""; @@ -1002,6 +1180,26 @@ export const DVVTriplets = { return message; }, + fromJSON(object: any): DVVTriplets { + return { + triplets: Array.isArray(object?.triplets) + ? object.triplets.map((e: any) => DVVTriplet.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): DVVTriplets { const message = createBaseDVVTriplets(); message.triplets = object.triplets?.map((e) => DVVTriplet.fromPartial(e)) || []; @@ -1064,6 +1262,22 @@ export const Delegation = { return message; }, + fromJSON(object: any): Delegation { + return { + delegatorAddress: isSet(object.delegatorAddress) ? String(object.delegatorAddress) : "", + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + shares: isSet(object.shares) ? String(object.shares) : "", + }; + }, + + 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, I>>(object: I): Delegation { const message = createBaseDelegation(); message.delegatorAddress = object.delegatorAddress ?? ""; @@ -1128,6 +1342,30 @@ export const UnbondingDelegation = { return message; }, + fromJSON(object: any): UnbondingDelegation { + return { + delegatorAddress: isSet(object.delegatorAddress) ? String(object.delegatorAddress) : "", + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + entries: Array.isArray(object?.entries) + ? object.entries.map((e: any) => UnbondingDelegationEntry.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): UnbondingDelegation { const message = createBaseUnbondingDelegation(); message.delegatorAddress = object.delegatorAddress ?? ""; @@ -1201,6 +1439,26 @@ export const UnbondingDelegationEntry = { return message; }, + fromJSON(object: any): UnbondingDelegationEntry { + return { + creationHeight: isSet(object.creationHeight) ? Long.fromValue(object.creationHeight) : Long.ZERO, + completionTime: isSet(object.completionTime) ? fromJsonTimestamp(object.completionTime) : undefined, + initialBalance: isSet(object.initialBalance) ? String(object.initialBalance) : "", + balance: isSet(object.balance) ? String(object.balance) : "", + }; + }, + + toJSON(message: UnbondingDelegationEntry): unknown { + const obj: any = {}; + message.creationHeight !== undefined && + (obj.creationHeight = (message.creationHeight || Long.ZERO).toString()); + message.completionTime !== undefined && + (obj.completionTime = fromTimestamp(message.completionTime).toISOString()); + message.initialBalance !== undefined && (obj.initialBalance = message.initialBalance); + message.balance !== undefined && (obj.balance = message.balance); + return obj; + }, + fromPartial, I>>( object: I, ): UnbondingDelegationEntry { @@ -1283,6 +1541,26 @@ export const RedelegationEntry = { return message; }, + fromJSON(object: any): RedelegationEntry { + return { + creationHeight: isSet(object.creationHeight) ? Long.fromValue(object.creationHeight) : Long.ZERO, + completionTime: isSet(object.completionTime) ? fromJsonTimestamp(object.completionTime) : undefined, + initialBalance: isSet(object.initialBalance) ? String(object.initialBalance) : "", + sharesDst: isSet(object.sharesDst) ? String(object.sharesDst) : "", + }; + }, + + toJSON(message: RedelegationEntry): unknown { + const obj: any = {}; + message.creationHeight !== undefined && + (obj.creationHeight = (message.creationHeight || Long.ZERO).toString()); + message.completionTime !== undefined && + (obj.completionTime = fromTimestamp(message.completionTime).toISOString()); + message.initialBalance !== undefined && (obj.initialBalance = message.initialBalance); + message.sharesDst !== undefined && (obj.sharesDst = message.sharesDst); + return obj; + }, + fromPartial, I>>(object: I): RedelegationEntry { const message = createBaseRedelegationEntry(); message.creationHeight = @@ -1363,6 +1641,32 @@ export const Redelegation = { return message; }, + fromJSON(object: any): Redelegation { + return { + delegatorAddress: isSet(object.delegatorAddress) ? String(object.delegatorAddress) : "", + validatorSrcAddress: isSet(object.validatorSrcAddress) ? String(object.validatorSrcAddress) : "", + validatorDstAddress: isSet(object.validatorDstAddress) ? String(object.validatorDstAddress) : "", + entries: Array.isArray(object?.entries) + ? object.entries.map((e: any) => RedelegationEntry.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): Redelegation { const message = createBaseRedelegation(); message.delegatorAddress = object.delegatorAddress ?? ""; @@ -1446,6 +1750,28 @@ export const Params = { return message; }, + fromJSON(object: any): Params { + return { + unbondingTime: isSet(object.unbondingTime) ? Duration.fromJSON(object.unbondingTime) : undefined, + maxValidators: isSet(object.maxValidators) ? Number(object.maxValidators) : 0, + maxEntries: isSet(object.maxEntries) ? Number(object.maxEntries) : 0, + historicalEntries: isSet(object.historicalEntries) ? Number(object.historicalEntries) : 0, + bondDenom: isSet(object.bondDenom) ? String(object.bondDenom) : "", + }; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.unbondingTime !== undefined && + (obj.unbondingTime = message.unbondingTime ? Duration.toJSON(message.unbondingTime) : undefined); + message.maxValidators !== undefined && (obj.maxValidators = Math.round(message.maxValidators)); + message.maxEntries !== undefined && (obj.maxEntries = Math.round(message.maxEntries)); + message.historicalEntries !== undefined && + (obj.historicalEntries = Math.round(message.historicalEntries)); + message.bondDenom !== undefined && (obj.bondDenom = message.bondDenom); + return obj; + }, + fromPartial, I>>(object: I): Params { const message = createBaseParams(); message.unbondingTime = @@ -1506,6 +1832,22 @@ export const DelegationResponse = { return message; }, + fromJSON(object: any): DelegationResponse { + return { + delegation: isSet(object.delegation) ? Delegation.fromJSON(object.delegation) : undefined, + balance: isSet(object.balance) ? Coin.fromJSON(object.balance) : undefined, + }; + }, + + 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, I>>(object: I): DelegationResponse { const message = createBaseDelegationResponse(); message.delegation = @@ -1564,6 +1906,25 @@ export const RedelegationEntryResponse = { return message; }, + fromJSON(object: any): RedelegationEntryResponse { + return { + redelegationEntry: isSet(object.redelegationEntry) + ? RedelegationEntry.fromJSON(object.redelegationEntry) + : undefined, + balance: isSet(object.balance) ? String(object.balance) : "", + }; + }, + + 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, I>>( object: I, ): RedelegationEntryResponse { @@ -1623,6 +1984,29 @@ export const RedelegationResponse = { return message; }, + fromJSON(object: any): RedelegationResponse { + return { + redelegation: isSet(object.redelegation) ? Redelegation.fromJSON(object.redelegation) : undefined, + entries: Array.isArray(object?.entries) + ? object.entries.map((e: any) => RedelegationEntryResponse.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): RedelegationResponse { const message = createBaseRedelegationResponse(); message.redelegation = @@ -1680,6 +2064,20 @@ export const Pool = { return message; }, + fromJSON(object: any): Pool { + return { + notBondedTokens: isSet(object.notBondedTokens) ? String(object.notBondedTokens) : "", + bondedTokens: isSet(object.bondedTokens) ? String(object.bondedTokens) : "", + }; + }, + + toJSON(message: Pool): unknown { + const obj: any = {}; + message.notBondedTokens !== undefined && (obj.notBondedTokens = message.notBondedTokens); + message.bondedTokens !== undefined && (obj.bondedTokens = message.bondedTokens); + return obj; + }, + fromPartial, I>>(object: I): Pool { const message = createBasePool(); message.notBondedTokens = object.notBondedTokens ?? ""; diff --git a/src/cosmos/staking/v1beta1/tx.ts b/src/cosmos/staking/v1beta1/tx.ts index 0905417b..70191e45 100644 --- a/src/cosmos/staking/v1beta1/tx.ts +++ b/src/cosmos/staking/v1beta1/tx.ts @@ -4,7 +4,7 @@ import { Any } from "../../../google/protobuf/any"; import { Coin } from "../../base/v1beta1/coin"; import { Timestamp } from "../../../google/protobuf/timestamp"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../helpers"; +import { isSet, DeepPartial, Exact, fromJsonTimestamp, fromTimestamp, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.staking.v1beta1"; /** MsgCreateValidator defines a SDK message for creating a new validator. */ @@ -174,6 +174,32 @@ export const MsgCreateValidator = { return message; }, + fromJSON(object: any): MsgCreateValidator { + return { + description: isSet(object.description) ? Description.fromJSON(object.description) : undefined, + commission: isSet(object.commission) ? CommissionRates.fromJSON(object.commission) : undefined, + minSelfDelegation: isSet(object.minSelfDelegation) ? String(object.minSelfDelegation) : "", + delegatorAddress: isSet(object.delegatorAddress) ? String(object.delegatorAddress) : "", + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + pubkey: isSet(object.pubkey) ? Any.fromJSON(object.pubkey) : undefined, + value: isSet(object.value) ? Coin.fromJSON(object.value) : undefined, + }; + }, + + 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, I>>(object: I): MsgCreateValidator { const message = createBaseMsgCreateValidator(); message.description = @@ -222,6 +248,15 @@ export const MsgCreateValidatorResponse = { return message; }, + fromJSON(_: any): MsgCreateValidatorResponse { + return {}; + }, + + toJSON(_: MsgCreateValidatorResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgCreateValidatorResponse { const message = createBaseMsgCreateValidatorResponse(); return message; @@ -292,6 +327,25 @@ export const MsgEditValidator = { return message; }, + fromJSON(object: any): MsgEditValidator { + return { + description: isSet(object.description) ? Description.fromJSON(object.description) : undefined, + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + commissionRate: isSet(object.commissionRate) ? String(object.commissionRate) : "", + minSelfDelegation: isSet(object.minSelfDelegation) ? String(object.minSelfDelegation) : "", + }; + }, + + 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, I>>(object: I): MsgEditValidator { const message = createBaseMsgEditValidator(); message.description = @@ -332,6 +386,15 @@ export const MsgEditValidatorResponse = { return message; }, + fromJSON(_: any): MsgEditValidatorResponse { + return {}; + }, + + toJSON(_: MsgEditValidatorResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgEditValidatorResponse { const message = createBaseMsgEditValidatorResponse(); return message; @@ -393,6 +456,22 @@ export const MsgDelegate = { return message; }, + fromJSON(object: any): MsgDelegate { + return { + delegatorAddress: isSet(object.delegatorAddress) ? String(object.delegatorAddress) : "", + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + amount: isSet(object.amount) ? Coin.fromJSON(object.amount) : undefined, + }; + }, + + 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, I>>(object: I): MsgDelegate { const message = createBaseMsgDelegate(); message.delegatorAddress = object.delegatorAddress ?? ""; @@ -430,6 +509,15 @@ export const MsgDelegateResponse = { return message; }, + fromJSON(_: any): MsgDelegateResponse { + return {}; + }, + + toJSON(_: MsgDelegateResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgDelegateResponse { const message = createBaseMsgDelegateResponse(); return message; @@ -500,6 +588,24 @@ export const MsgBeginRedelegate = { return message; }, + fromJSON(object: any): MsgBeginRedelegate { + return { + delegatorAddress: isSet(object.delegatorAddress) ? String(object.delegatorAddress) : "", + validatorSrcAddress: isSet(object.validatorSrcAddress) ? String(object.validatorSrcAddress) : "", + validatorDstAddress: isSet(object.validatorDstAddress) ? String(object.validatorDstAddress) : "", + amount: isSet(object.amount) ? Coin.fromJSON(object.amount) : undefined, + }; + }, + + 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, I>>(object: I): MsgBeginRedelegate { const message = createBaseMsgBeginRedelegate(); message.delegatorAddress = object.delegatorAddress ?? ""; @@ -548,6 +654,19 @@ export const MsgBeginRedelegateResponse = { return message; }, + fromJSON(object: any): MsgBeginRedelegateResponse { + return { + completionTime: isSet(object.completionTime) ? fromJsonTimestamp(object.completionTime) : undefined, + }; + }, + + toJSON(message: MsgBeginRedelegateResponse): unknown { + const obj: any = {}; + message.completionTime !== undefined && + (obj.completionTime = fromTimestamp(message.completionTime).toISOString()); + return obj; + }, + fromPartial, I>>( object: I, ): MsgBeginRedelegateResponse { @@ -615,6 +734,22 @@ export const MsgUndelegate = { return message; }, + fromJSON(object: any): MsgUndelegate { + return { + delegatorAddress: isSet(object.delegatorAddress) ? String(object.delegatorAddress) : "", + validatorAddress: isSet(object.validatorAddress) ? String(object.validatorAddress) : "", + amount: isSet(object.amount) ? Coin.fromJSON(object.amount) : undefined, + }; + }, + + 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, I>>(object: I): MsgUndelegate { const message = createBaseMsgUndelegate(); message.delegatorAddress = object.delegatorAddress ?? ""; @@ -662,6 +797,19 @@ export const MsgUndelegateResponse = { return message; }, + fromJSON(object: any): MsgUndelegateResponse { + return { + completionTime: isSet(object.completionTime) ? fromJsonTimestamp(object.completionTime) : undefined, + }; + }, + + toJSON(message: MsgUndelegateResponse): unknown { + const obj: any = {}; + message.completionTime !== undefined && + (obj.completionTime = fromTimestamp(message.completionTime).toISOString()); + return obj; + }, + fromPartial, I>>(object: I): MsgUndelegateResponse { const message = createBaseMsgUndelegateResponse(); message.completionTime = diff --git a/src/cosmos/tx/signing/v1beta1/signing.ts b/src/cosmos/tx/signing/v1beta1/signing.ts index 4f1de02b..e620a02a 100644 --- a/src/cosmos/tx/signing/v1beta1/signing.ts +++ b/src/cosmos/tx/signing/v1beta1/signing.ts @@ -2,7 +2,7 @@ import { CompactBitArray } from "../../../crypto/multisig/v1beta1/multisig"; import { Any } from "../../../../google/protobuf/any"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../../../helpers"; +import { DeepPartial, Exact, Long, isSet, bytesFromBase64, base64FromBytes } from "../../../../helpers"; export const protobufPackage = "cosmos.tx.signing.v1beta1"; /** SignMode represents a signing mode with its own security guarantees. */ @@ -187,6 +187,26 @@ export const SignatureDescriptors = { return message; }, + fromJSON(object: any): SignatureDescriptors { + return { + signatures: Array.isArray(object?.signatures) + ? object.signatures.map((e: any) => SignatureDescriptor.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): SignatureDescriptors { const message = createBaseSignatureDescriptors(); message.signatures = object.signatures?.map((e) => SignatureDescriptor.fromPartial(e)) || []; @@ -249,6 +269,24 @@ export const SignatureDescriptor = { return message; }, + fromJSON(object: any): SignatureDescriptor { + return { + publicKey: isSet(object.publicKey) ? Any.fromJSON(object.publicKey) : undefined, + data: isSet(object.data) ? SignatureDescriptor_Data.fromJSON(object.data) : undefined, + sequence: isSet(object.sequence) ? Long.fromValue(object.sequence) : Long.UZERO, + }; + }, + + 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, I>>(object: I): SignatureDescriptor { const message = createBaseSignatureDescriptor(); message.publicKey = @@ -313,6 +351,22 @@ export const SignatureDescriptor_Data = { return message; }, + fromJSON(object: any): SignatureDescriptor_Data { + return { + single: isSet(object.single) ? SignatureDescriptor_Data_Single.fromJSON(object.single) : undefined, + multi: isSet(object.multi) ? SignatureDescriptor_Data_Multi.fromJSON(object.multi) : undefined, + }; + }, + + 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, I>>( object: I, ): SignatureDescriptor_Data { @@ -375,6 +429,23 @@ export const SignatureDescriptor_Data_Single = { return message; }, + fromJSON(object: any): SignatureDescriptor_Data_Single { + return { + mode: isSet(object.mode) ? signModeFromJSON(object.mode) : 0, + signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(), + }; + }, + + 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, I>>( object: I, ): SignatureDescriptor_Data_Single { @@ -431,6 +502,29 @@ export const SignatureDescriptor_Data_Multi = { return message; }, + fromJSON(object: any): SignatureDescriptor_Data_Multi { + return { + bitarray: isSet(object.bitarray) ? CompactBitArray.fromJSON(object.bitarray) : undefined, + signatures: Array.isArray(object?.signatures) + ? object.signatures.map((e: any) => SignatureDescriptor_Data.fromJSON(e)) + : [], + }; + }, + + 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, I>>( object: I, ): SignatureDescriptor_Data_Multi { diff --git a/src/cosmos/tx/v1beta1/service.ts b/src/cosmos/tx/v1beta1/service.ts index 4e152b23..324581d7 100644 --- a/src/cosmos/tx/v1beta1/service.ts +++ b/src/cosmos/tx/v1beta1/service.ts @@ -5,7 +5,7 @@ import { TxResponse, GasInfo, Result } from "../../base/abci/v1beta1/abci"; import { BlockID } from "../../../tendermint/types/types"; import { Block } from "../../../tendermint/types/block"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long, Rpc } from "../../../helpers"; +import { isSet, DeepPartial, Exact, bytesFromBase64, base64FromBytes, Long, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.tx.v1beta1"; /** OrderBy defines the sorting order */ @@ -307,6 +307,29 @@ export const GetTxsEventRequest = { return message; }, + fromJSON(object: any): GetTxsEventRequest { + return { + events: Array.isArray(object?.events) ? object.events.map((e: any) => String(e)) : [], + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + orderBy: isSet(object.orderBy) ? orderByFromJSON(object.orderBy) : 0, + }; + }, + + toJSON(message: GetTxsEventRequest): unknown { + const obj: any = {}; + + if (message.events) { + obj.events = message.events.map((e) => e); + } else { + obj.events = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + message.orderBy !== undefined && (obj.orderBy = orderByToJSON(message.orderBy)); + return obj; + }, + fromPartial, I>>(object: I): GetTxsEventRequest { const message = createBaseGetTxsEventRequest(); message.events = object.events?.map((e) => e) || []; @@ -374,6 +397,36 @@ export const GetTxsEventResponse = { return message; }, + fromJSON(object: any): GetTxsEventResponse { + return { + txs: Array.isArray(object?.txs) ? object.txs.map((e: any) => Tx.fromJSON(e)) : [], + txResponses: Array.isArray(object?.txResponses) + ? object.txResponses.map((e: any) => TxResponse.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: GetTxsEventResponse): unknown { + const obj: any = {}; + + if (message.txs) { + obj.txs = message.txs.map((e) => (e ? Tx.toJSON(e) : undefined)); + } else { + obj.txs = []; + } + + if (message.txResponses) { + obj.txResponses = message.txResponses.map((e) => (e ? TxResponse.toJSON(e) : undefined)); + } else { + obj.txResponses = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): GetTxsEventResponse { const message = createBaseGetTxsEventResponse(); message.txs = object.txs?.map((e) => Tx.fromPartial(e)) || []; @@ -432,6 +485,21 @@ export const BroadcastTxRequest = { return message; }, + fromJSON(object: any): BroadcastTxRequest { + return { + txBytes: isSet(object.txBytes) ? bytesFromBase64(object.txBytes) : new Uint8Array(), + mode: isSet(object.mode) ? broadcastModeFromJSON(object.mode) : 0, + }; + }, + + toJSON(message: BroadcastTxRequest): unknown { + const obj: any = {}; + message.txBytes !== undefined && + (obj.txBytes = base64FromBytes(message.txBytes !== undefined ? message.txBytes : new Uint8Array())); + message.mode !== undefined && (obj.mode = broadcastModeToJSON(message.mode)); + return obj; + }, + fromPartial, I>>(object: I): BroadcastTxRequest { const message = createBaseBroadcastTxRequest(); message.txBytes = object.txBytes ?? new Uint8Array(); @@ -477,6 +545,19 @@ export const BroadcastTxResponse = { return message; }, + fromJSON(object: any): BroadcastTxResponse { + return { + txResponse: isSet(object.txResponse) ? TxResponse.fromJSON(object.txResponse) : undefined, + }; + }, + + toJSON(message: BroadcastTxResponse): unknown { + const obj: any = {}; + message.txResponse !== undefined && + (obj.txResponse = message.txResponse ? TxResponse.toJSON(message.txResponse) : undefined); + return obj; + }, + fromPartial, I>>(object: I): BroadcastTxResponse { const message = createBaseBroadcastTxResponse(); message.txResponse = @@ -533,6 +614,21 @@ export const SimulateRequest = { return message; }, + fromJSON(object: any): SimulateRequest { + return { + tx: isSet(object.tx) ? Tx.fromJSON(object.tx) : undefined, + txBytes: isSet(object.txBytes) ? bytesFromBase64(object.txBytes) : new Uint8Array(), + }; + }, + + toJSON(message: SimulateRequest): unknown { + const obj: any = {}; + message.tx !== undefined && (obj.tx = message.tx ? Tx.toJSON(message.tx) : undefined); + message.txBytes !== undefined && + (obj.txBytes = base64FromBytes(message.txBytes !== undefined ? message.txBytes : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): SimulateRequest { const message = createBaseSimulateRequest(); message.tx = object.tx !== undefined && object.tx !== null ? Tx.fromPartial(object.tx) : undefined; @@ -587,6 +683,21 @@ export const SimulateResponse = { return message; }, + fromJSON(object: any): SimulateResponse { + return { + gasInfo: isSet(object.gasInfo) ? GasInfo.fromJSON(object.gasInfo) : undefined, + result: isSet(object.result) ? Result.fromJSON(object.result) : undefined, + }; + }, + + toJSON(message: SimulateResponse): 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, I>>(object: I): SimulateResponse { const message = createBaseSimulateResponse(); message.gasInfo = @@ -636,6 +747,18 @@ export const GetTxRequest = { return message; }, + fromJSON(object: any): GetTxRequest { + return { + hash: isSet(object.hash) ? String(object.hash) : "", + }; + }, + + toJSON(message: GetTxRequest): unknown { + const obj: any = {}; + message.hash !== undefined && (obj.hash = message.hash); + return obj; + }, + fromPartial, I>>(object: I): GetTxRequest { const message = createBaseGetTxRequest(); message.hash = object.hash ?? ""; @@ -689,6 +812,21 @@ export const GetTxResponse = { return message; }, + fromJSON(object: any): GetTxResponse { + return { + tx: isSet(object.tx) ? Tx.fromJSON(object.tx) : undefined, + txResponse: isSet(object.txResponse) ? TxResponse.fromJSON(object.txResponse) : undefined, + }; + }, + + toJSON(message: GetTxResponse): unknown { + const obj: any = {}; + message.tx !== undefined && (obj.tx = message.tx ? Tx.toJSON(message.tx) : undefined); + message.txResponse !== undefined && + (obj.txResponse = message.txResponse ? TxResponse.toJSON(message.txResponse) : undefined); + return obj; + }, + fromPartial, I>>(object: I): GetTxResponse { const message = createBaseGetTxResponse(); message.tx = object.tx !== undefined && object.tx !== null ? Tx.fromPartial(object.tx) : undefined; @@ -746,6 +884,21 @@ export const GetBlockWithTxsRequest = { return message; }, + fromJSON(object: any): GetBlockWithTxsRequest { + return { + height: isSet(object.height) ? Long.fromValue(object.height) : Long.ZERO, + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: GetBlockWithTxsRequest): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): GetBlockWithTxsRequest { const message = createBaseGetBlockWithTxsRequest(); message.height = @@ -822,6 +975,32 @@ export const GetBlockWithTxsResponse = { return message; }, + fromJSON(object: any): GetBlockWithTxsResponse { + return { + txs: Array.isArray(object?.txs) ? object.txs.map((e: any) => Tx.fromJSON(e)) : [], + blockId: isSet(object.blockId) ? BlockID.fromJSON(object.blockId) : undefined, + block: isSet(object.block) ? Block.fromJSON(object.block) : undefined, + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: GetBlockWithTxsResponse): unknown { + const obj: any = {}; + + if (message.txs) { + obj.txs = message.txs.map((e) => (e ? Tx.toJSON(e) : undefined)); + } else { + obj.txs = []; + } + + message.blockId !== undefined && + (obj.blockId = message.blockId ? BlockID.toJSON(message.blockId) : undefined); + message.block !== undefined && (obj.block = message.block ? Block.toJSON(message.block) : undefined); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): GetBlockWithTxsResponse { const message = createBaseGetBlockWithTxsResponse(); message.txs = object.txs?.map((e) => Tx.fromPartial(e)) || []; diff --git a/src/cosmos/tx/v1beta1/tx.ts b/src/cosmos/tx/v1beta1/tx.ts index cf6d3943..70b08f6d 100644 --- a/src/cosmos/tx/v1beta1/tx.ts +++ b/src/cosmos/tx/v1beta1/tx.ts @@ -1,10 +1,10 @@ /* eslint-disable */ import { Any } from "../../../google/protobuf/any"; -import { SignMode } from "../signing/v1beta1/signing"; +import { SignMode, signModeFromJSON, signModeToJSON } from "../signing/v1beta1/signing"; import { CompactBitArray } from "../../crypto/multisig/v1beta1/multisig"; import { Coin } from "../../base/v1beta1/coin"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../../helpers"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact, Long } from "../../../helpers"; export const protobufPackage = "cosmos.tx.v1beta1"; /** Tx is the standard type used for broadcasting transactions. */ @@ -284,6 +284,31 @@ export const Tx = { return message; }, + fromJSON(object: any): Tx { + return { + body: isSet(object.body) ? TxBody.fromJSON(object.body) : undefined, + authInfo: isSet(object.authInfo) ? AuthInfo.fromJSON(object.authInfo) : undefined, + signatures: Array.isArray(object?.signatures) + ? object.signatures.map((e: any) => bytesFromBase64(e)) + : [], + }; + }, + + 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, I>>(object: I): Tx { const message = createBaseTx(); message.body = @@ -352,6 +377,36 @@ export const TxRaw = { return message; }, + fromJSON(object: any): TxRaw { + return { + bodyBytes: isSet(object.bodyBytes) ? bytesFromBase64(object.bodyBytes) : new Uint8Array(), + authInfoBytes: isSet(object.authInfoBytes) ? bytesFromBase64(object.authInfoBytes) : new Uint8Array(), + signatures: Array.isArray(object?.signatures) + ? object.signatures.map((e: any) => bytesFromBase64(e)) + : [], + }; + }, + + 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, I>>(object: I): TxRaw { const message = createBaseTxRaw(); message.bodyBytes = object.bodyBytes ?? new Uint8Array(); @@ -425,6 +480,31 @@ export const SignDoc = { return message; }, + fromJSON(object: any): SignDoc { + return { + bodyBytes: isSet(object.bodyBytes) ? bytesFromBase64(object.bodyBytes) : new Uint8Array(), + authInfoBytes: isSet(object.authInfoBytes) ? bytesFromBase64(object.authInfoBytes) : new Uint8Array(), + chainId: isSet(object.chainId) ? String(object.chainId) : "", + accountNumber: isSet(object.accountNumber) ? Long.fromValue(object.accountNumber) : Long.UZERO, + }; + }, + + 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, I>>(object: I): SignDoc { const message = createBaseSignDoc(); message.bodyBytes = object.bodyBytes ?? new Uint8Array(); @@ -511,6 +591,50 @@ export const TxBody = { return message; }, + fromJSON(object: any): TxBody { + return { + messages: Array.isArray(object?.messages) ? object.messages.map((e: any) => Any.fromJSON(e)) : [], + memo: isSet(object.memo) ? String(object.memo) : "", + timeoutHeight: isSet(object.timeoutHeight) ? Long.fromValue(object.timeoutHeight) : Long.UZERO, + extensionOptions: Array.isArray(object?.extensionOptions) + ? object.extensionOptions.map((e: any) => Any.fromJSON(e)) + : [], + nonCriticalExtensionOptions: Array.isArray(object?.nonCriticalExtensionOptions) + ? object.nonCriticalExtensionOptions.map((e: any) => Any.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): TxBody { const message = createBaseTxBody(); message.messages = object.messages?.map((e) => Any.fromPartial(e)) || []; @@ -572,6 +696,28 @@ export const AuthInfo = { return message; }, + fromJSON(object: any): AuthInfo { + return { + signerInfos: Array.isArray(object?.signerInfos) + ? object.signerInfos.map((e: any) => SignerInfo.fromJSON(e)) + : [], + fee: isSet(object.fee) ? Fee.fromJSON(object.fee) : undefined, + }; + }, + + 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, I>>(object: I): AuthInfo { const message = createBaseAuthInfo(); message.signerInfos = object.signerInfos?.map((e) => SignerInfo.fromPartial(e)) || []; @@ -635,6 +781,24 @@ export const SignerInfo = { return message; }, + fromJSON(object: any): SignerInfo { + return { + publicKey: isSet(object.publicKey) ? Any.fromJSON(object.publicKey) : undefined, + modeInfo: isSet(object.modeInfo) ? ModeInfo.fromJSON(object.modeInfo) : undefined, + sequence: isSet(object.sequence) ? Long.fromValue(object.sequence) : Long.UZERO, + }; + }, + + 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, I>>(object: I): SignerInfo { const message = createBaseSignerInfo(); message.publicKey = @@ -699,6 +863,22 @@ export const ModeInfo = { return message; }, + fromJSON(object: any): ModeInfo { + return { + single: isSet(object.single) ? ModeInfo_Single.fromJSON(object.single) : undefined, + multi: isSet(object.multi) ? ModeInfo_Multi.fromJSON(object.multi) : undefined, + }; + }, + + 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, I>>(object: I): ModeInfo { const message = createBaseModeInfo(); message.single = @@ -750,6 +930,18 @@ export const ModeInfo_Single = { return message; }, + fromJSON(object: any): ModeInfo_Single { + return { + mode: isSet(object.mode) ? signModeFromJSON(object.mode) : 0, + }; + }, + + toJSON(message: ModeInfo_Single): unknown { + const obj: any = {}; + message.mode !== undefined && (obj.mode = signModeToJSON(message.mode)); + return obj; + }, + fromPartial, I>>(object: I): ModeInfo_Single { const message = createBaseModeInfo_Single(); message.mode = object.mode ?? 0; @@ -803,6 +995,29 @@ export const ModeInfo_Multi = { return message; }, + fromJSON(object: any): ModeInfo_Multi { + return { + bitarray: isSet(object.bitarray) ? CompactBitArray.fromJSON(object.bitarray) : undefined, + modeInfos: Array.isArray(object?.modeInfos) + ? object.modeInfos.map((e: any) => ModeInfo.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): ModeInfo_Multi { const message = createBaseModeInfo_Multi(); message.bitarray = @@ -878,6 +1093,30 @@ export const Fee = { return message; }, + fromJSON(object: any): Fee { + return { + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromJSON(e)) : [], + gasLimit: isSet(object.gasLimit) ? Long.fromValue(object.gasLimit) : Long.UZERO, + payer: isSet(object.payer) ? String(object.payer) : "", + granter: isSet(object.granter) ? String(object.granter) : "", + }; + }, + + 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, I>>(object: I): Fee { const message = createBaseFee(); message.amount = object.amount?.map((e) => Coin.fromPartial(e)) || []; diff --git a/src/cosmos/upgrade/v1beta1/query.ts b/src/cosmos/upgrade/v1beta1/query.ts index 837af78b..dddfdf22 100644 --- a/src/cosmos/upgrade/v1beta1/query.ts +++ b/src/cosmos/upgrade/v1beta1/query.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Plan, ModuleVersion } from "./upgrade"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long, Rpc } from "../../../helpers"; +import { DeepPartial, Exact, isSet, Long, bytesFromBase64, base64FromBytes, Rpc } from "../../../helpers"; export const protobufPackage = "cosmos.upgrade.v1beta1"; /** * QueryCurrentPlanRequest is the request type for the Query/CurrentPlan RPC @@ -115,6 +115,15 @@ export const QueryCurrentPlanRequest = { return message; }, + fromJSON(_: any): QueryCurrentPlanRequest { + return {}; + }, + + toJSON(_: QueryCurrentPlanRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryCurrentPlanRequest { const message = createBaseQueryCurrentPlanRequest(); return message; @@ -158,6 +167,18 @@ export const QueryCurrentPlanResponse = { return message; }, + fromJSON(object: any): QueryCurrentPlanResponse { + return { + plan: isSet(object.plan) ? Plan.fromJSON(object.plan) : undefined, + }; + }, + + toJSON(message: QueryCurrentPlanResponse): unknown { + const obj: any = {}; + message.plan !== undefined && (obj.plan = message.plan ? Plan.toJSON(message.plan) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryCurrentPlanResponse { @@ -205,6 +226,18 @@ export const QueryAppliedPlanRequest = { return message; }, + fromJSON(object: any): QueryAppliedPlanRequest { + return { + name: isSet(object.name) ? String(object.name) : "", + }; + }, + + toJSON(message: QueryAppliedPlanRequest): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial, I>>(object: I): QueryAppliedPlanRequest { const message = createBaseQueryAppliedPlanRequest(); message.name = object.name ?? ""; @@ -249,6 +282,18 @@ export const QueryAppliedPlanResponse = { return message; }, + fromJSON(object: any): QueryAppliedPlanResponse { + return { + height: isSet(object.height) ? Long.fromValue(object.height) : Long.ZERO, + }; + }, + + toJSON(message: QueryAppliedPlanResponse): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + return obj; + }, + fromPartial, I>>( object: I, ): QueryAppliedPlanResponse { @@ -296,6 +341,18 @@ export const QueryUpgradedConsensusStateRequest = { return message; }, + fromJSON(object: any): QueryUpgradedConsensusStateRequest { + return { + lastHeight: isSet(object.lastHeight) ? Long.fromValue(object.lastHeight) : Long.ZERO, + }; + }, + + toJSON(message: QueryUpgradedConsensusStateRequest): unknown { + const obj: any = {}; + message.lastHeight !== undefined && (obj.lastHeight = (message.lastHeight || Long.ZERO).toString()); + return obj; + }, + fromPartial, I>>( object: I, ): QueryUpgradedConsensusStateRequest { @@ -345,6 +402,23 @@ export const QueryUpgradedConsensusStateResponse = { return message; }, + fromJSON(object: any): QueryUpgradedConsensusStateResponse { + return { + upgradedConsensusState: isSet(object.upgradedConsensusState) + ? bytesFromBase64(object.upgradedConsensusState) + : new Uint8Array(), + }; + }, + + toJSON(message: QueryUpgradedConsensusStateResponse): unknown { + const obj: any = {}; + message.upgradedConsensusState !== undefined && + (obj.upgradedConsensusState = base64FromBytes( + message.upgradedConsensusState !== undefined ? message.upgradedConsensusState : new Uint8Array(), + )); + return obj; + }, + fromPartial, I>>( object: I, ): QueryUpgradedConsensusStateResponse { @@ -391,6 +465,18 @@ export const QueryModuleVersionsRequest = { return message; }, + fromJSON(object: any): QueryModuleVersionsRequest { + return { + moduleName: isSet(object.moduleName) ? String(object.moduleName) : "", + }; + }, + + toJSON(message: QueryModuleVersionsRequest): unknown { + const obj: any = {}; + message.moduleName !== undefined && (obj.moduleName = message.moduleName); + return obj; + }, + fromPartial, I>>( object: I, ): QueryModuleVersionsRequest { @@ -437,6 +523,26 @@ export const QueryModuleVersionsResponse = { return message; }, + fromJSON(object: any): QueryModuleVersionsResponse { + return { + moduleVersions: Array.isArray(object?.moduleVersions) + ? object.moduleVersions.map((e: any) => ModuleVersion.fromJSON(e)) + : [], + }; + }, + + toJSON(message: QueryModuleVersionsResponse): unknown { + const obj: any = {}; + + if (message.moduleVersions) { + obj.moduleVersions = message.moduleVersions.map((e) => (e ? ModuleVersion.toJSON(e) : undefined)); + } else { + obj.moduleVersions = []; + } + + return obj; + }, + fromPartial, I>>( object: I, ): QueryModuleVersionsResponse { diff --git a/src/cosmos/upgrade/v1beta1/upgrade.ts b/src/cosmos/upgrade/v1beta1/upgrade.ts index fcbd100c..c986fe0a 100644 --- a/src/cosmos/upgrade/v1beta1/upgrade.ts +++ b/src/cosmos/upgrade/v1beta1/upgrade.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Timestamp } from "../../../google/protobuf/timestamp"; import { Any } from "../../../google/protobuf/any"; -import { Long, DeepPartial, Exact } from "../../../helpers"; +import { Long, isSet, fromJsonTimestamp, fromTimestamp, DeepPartial, Exact } from "../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "cosmos.upgrade.v1beta1"; /** Plan specifies information about a planned upgrade and when it should occur. */ @@ -154,6 +154,31 @@ export const Plan = { return message; }, + fromJSON(object: any): Plan { + return { + name: isSet(object.name) ? String(object.name) : "", + time: isSet(object.time) ? fromJsonTimestamp(object.time) : undefined, + height: isSet(object.height) ? Long.fromValue(object.height) : Long.ZERO, + info: isSet(object.info) ? String(object.info) : "", + upgradedClientState: isSet(object.upgradedClientState) + ? Any.fromJSON(object.upgradedClientState) + : undefined, + }; + }, + + toJSON(message: Plan): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.time !== undefined && (obj.time = fromTimestamp(message.time).toISOString()); + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + message.info !== undefined && (obj.info = message.info); + message.upgradedClientState !== undefined && + (obj.upgradedClientState = message.upgradedClientState + ? Any.toJSON(message.upgradedClientState) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): Plan { const message = createBasePlan(); message.name = object.name ?? ""; @@ -225,6 +250,22 @@ export const SoftwareUpgradeProposal = { return message; }, + fromJSON(object: any): SoftwareUpgradeProposal { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + plan: isSet(object.plan) ? Plan.fromJSON(object.plan) : undefined, + }; + }, + + toJSON(message: SoftwareUpgradeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.plan !== undefined && (obj.plan = message.plan ? Plan.toJSON(message.plan) : undefined); + return obj; + }, + fromPartial, I>>(object: I): SoftwareUpgradeProposal { const message = createBaseSoftwareUpgradeProposal(); message.title = object.title ?? ""; @@ -281,6 +322,20 @@ export const CancelSoftwareUpgradeProposal = { return message; }, + fromJSON(object: any): CancelSoftwareUpgradeProposal { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + }; + }, + + toJSON(message: CancelSoftwareUpgradeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + return obj; + }, + fromPartial, I>>( object: I, ): CancelSoftwareUpgradeProposal { @@ -337,6 +392,20 @@ export const ModuleVersion = { return message; }, + fromJSON(object: any): ModuleVersion { + return { + name: isSet(object.name) ? String(object.name) : "", + version: isSet(object.version) ? Long.fromValue(object.version) : Long.UZERO, + }; + }, + + toJSON(message: ModuleVersion): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.version !== undefined && (obj.version = (message.version || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): ModuleVersion { const message = createBaseModuleVersion(); message.name = object.name ?? ""; diff --git a/src/cosmos/vesting/v1beta1/tx.ts b/src/cosmos/vesting/v1beta1/tx.ts index ba123ac7..f42f2276 100644 --- a/src/cosmos/vesting/v1beta1/tx.ts +++ b/src/cosmos/vesting/v1beta1/tx.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import { Coin } from "../../base/v1beta1/coin"; -import { Long, DeepPartial, Exact, Rpc } from "../../../helpers"; +import { Long, isSet, DeepPartial, Exact, Rpc } from "../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "cosmos.vesting.v1beta1"; /** @@ -92,6 +92,32 @@ export const MsgCreateVestingAccount = { return message; }, + fromJSON(object: any): MsgCreateVestingAccount { + return { + fromAddress: isSet(object.fromAddress) ? String(object.fromAddress) : "", + toAddress: isSet(object.toAddress) ? String(object.toAddress) : "", + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromJSON(e)) : [], + endTime: isSet(object.endTime) ? Long.fromValue(object.endTime) : Long.ZERO, + delayed: isSet(object.delayed) ? Boolean(object.delayed) : false, + }; + }, + + toJSON(message: MsgCreateVestingAccount): 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 = []; + } + + message.endTime !== undefined && (obj.endTime = (message.endTime || Long.ZERO).toString()); + message.delayed !== undefined && (obj.delayed = message.delayed); + return obj; + }, + fromPartial, I>>(object: I): MsgCreateVestingAccount { const message = createBaseMsgCreateVestingAccount(); message.fromAddress = object.fromAddress ?? ""; @@ -131,6 +157,15 @@ export const MsgCreateVestingAccountResponse = { return message; }, + fromJSON(_: any): MsgCreateVestingAccountResponse { + return {}; + }, + + toJSON(_: MsgCreateVestingAccountResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( _: I, ): MsgCreateVestingAccountResponse { diff --git a/src/cosmos/vesting/v1beta1/vesting.ts b/src/cosmos/vesting/v1beta1/vesting.ts index 14f14588..aceab925 100644 --- a/src/cosmos/vesting/v1beta1/vesting.ts +++ b/src/cosmos/vesting/v1beta1/vesting.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { BaseAccount } from "../../auth/v1beta1/auth"; import { Coin } from "../../base/v1beta1/coin"; -import { Long, DeepPartial, Exact } from "../../../helpers"; +import { Long, isSet, DeepPartial, Exact } from "../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "cosmos.vesting.v1beta1"; /** @@ -135,6 +135,49 @@ export const BaseVestingAccount = { return message; }, + fromJSON(object: any): BaseVestingAccount { + return { + baseAccount: isSet(object.baseAccount) ? BaseAccount.fromJSON(object.baseAccount) : undefined, + originalVesting: Array.isArray(object?.originalVesting) + ? object.originalVesting.map((e: any) => Coin.fromJSON(e)) + : [], + delegatedFree: Array.isArray(object?.delegatedFree) + ? object.delegatedFree.map((e: any) => Coin.fromJSON(e)) + : [], + delegatedVesting: Array.isArray(object?.delegatedVesting) + ? object.delegatedVesting.map((e: any) => Coin.fromJSON(e)) + : [], + endTime: isSet(object.endTime) ? Long.fromValue(object.endTime) : Long.ZERO, + }; + }, + + toJSON(message: BaseVestingAccount): unknown { + const obj: any = {}; + message.baseAccount !== undefined && + (obj.baseAccount = message.baseAccount ? BaseAccount.toJSON(message.baseAccount) : undefined); + + if (message.originalVesting) { + obj.originalVesting = message.originalVesting.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.originalVesting = []; + } + + if (message.delegatedFree) { + obj.delegatedFree = message.delegatedFree.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.delegatedFree = []; + } + + if (message.delegatedVesting) { + obj.delegatedVesting = message.delegatedVesting.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.delegatedVesting = []; + } + + message.endTime !== undefined && (obj.endTime = (message.endTime || Long.ZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): BaseVestingAccount { const message = createBaseBaseVestingAccount(); message.baseAccount = @@ -196,6 +239,25 @@ export const ContinuousVestingAccount = { return message; }, + fromJSON(object: any): ContinuousVestingAccount { + return { + baseVestingAccount: isSet(object.baseVestingAccount) + ? BaseVestingAccount.fromJSON(object.baseVestingAccount) + : undefined, + startTime: isSet(object.startTime) ? Long.fromValue(object.startTime) : Long.ZERO, + }; + }, + + toJSON(message: ContinuousVestingAccount): unknown { + const obj: any = {}; + message.baseVestingAccount !== undefined && + (obj.baseVestingAccount = message.baseVestingAccount + ? BaseVestingAccount.toJSON(message.baseVestingAccount) + : undefined); + message.startTime !== undefined && (obj.startTime = (message.startTime || Long.ZERO).toString()); + return obj; + }, + fromPartial, I>>( object: I, ): ContinuousVestingAccount { @@ -249,6 +311,23 @@ export const DelayedVestingAccount = { return message; }, + fromJSON(object: any): DelayedVestingAccount { + return { + baseVestingAccount: isSet(object.baseVestingAccount) + ? BaseVestingAccount.fromJSON(object.baseVestingAccount) + : undefined, + }; + }, + + toJSON(message: DelayedVestingAccount): unknown { + const obj: any = {}; + message.baseVestingAccount !== undefined && + (obj.baseVestingAccount = message.baseVestingAccount + ? BaseVestingAccount.toJSON(message.baseVestingAccount) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): DelayedVestingAccount { const message = createBaseDelayedVestingAccount(); message.baseVestingAccount = @@ -305,6 +384,26 @@ export const Period = { return message; }, + fromJSON(object: any): Period { + return { + length: isSet(object.length) ? Long.fromValue(object.length) : Long.ZERO, + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromJSON(e)) : [], + }; + }, + + toJSON(message: Period): unknown { + const obj: any = {}; + message.length !== undefined && (obj.length = (message.length || Long.ZERO).toString()); + + if (message.amount) { + obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.amount = []; + } + + return obj; + }, + fromPartial, I>>(object: I): Period { const message = createBasePeriod(); message.length = @@ -369,6 +468,35 @@ export const PeriodicVestingAccount = { return message; }, + fromJSON(object: any): PeriodicVestingAccount { + return { + baseVestingAccount: isSet(object.baseVestingAccount) + ? BaseVestingAccount.fromJSON(object.baseVestingAccount) + : undefined, + startTime: isSet(object.startTime) ? Long.fromValue(object.startTime) : Long.ZERO, + vestingPeriods: Array.isArray(object?.vestingPeriods) + ? object.vestingPeriods.map((e: any) => Period.fromJSON(e)) + : [], + }; + }, + + toJSON(message: PeriodicVestingAccount): unknown { + const obj: any = {}; + message.baseVestingAccount !== undefined && + (obj.baseVestingAccount = message.baseVestingAccount + ? BaseVestingAccount.toJSON(message.baseVestingAccount) + : undefined); + message.startTime !== undefined && (obj.startTime = (message.startTime || Long.ZERO).toString()); + + if (message.vestingPeriods) { + obj.vestingPeriods = message.vestingPeriods.map((e) => (e ? Period.toJSON(e) : undefined)); + } else { + obj.vestingPeriods = []; + } + + return obj; + }, + fromPartial, I>>(object: I): PeriodicVestingAccount { const message = createBasePeriodicVestingAccount(); message.baseVestingAccount = @@ -421,6 +549,23 @@ export const PermanentLockedAccount = { return message; }, + fromJSON(object: any): PermanentLockedAccount { + return { + baseVestingAccount: isSet(object.baseVestingAccount) + ? BaseVestingAccount.fromJSON(object.baseVestingAccount) + : undefined, + }; + }, + + toJSON(message: PermanentLockedAccount): unknown { + const obj: any = {}; + message.baseVestingAccount !== undefined && + (obj.baseVestingAccount = message.baseVestingAccount + ? BaseVestingAccount.toJSON(message.baseVestingAccount) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): PermanentLockedAccount { const message = createBasePermanentLockedAccount(); message.baseVestingAccount = diff --git a/src/cosmwasm/wasm/v1/genesis.ts b/src/cosmwasm/wasm/v1/genesis.ts index 3b0bf7ac..e86ed05c 100644 --- a/src/cosmwasm/wasm/v1/genesis.ts +++ b/src/cosmwasm/wasm/v1/genesis.ts @@ -2,7 +2,7 @@ import { MsgStoreCode, MsgInstantiateContract, MsgExecuteContract } from "./tx"; import { Params, CodeInfo, ContractInfo, Model } from "./types"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../../helpers"; +import { isSet, DeepPartial, Exact, Long, bytesFromBase64, base64FromBytes } from "../../../helpers"; export const protobufPackage = "cosmwasm.wasm.v1"; /** GenesisState - genesis state of x/wasm */ @@ -120,6 +120,53 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + codes: Array.isArray(object?.codes) ? object.codes.map((e: any) => Code.fromJSON(e)) : [], + contracts: Array.isArray(object?.contracts) + ? object.contracts.map((e: any) => Contract.fromJSON(e)) + : [], + sequences: Array.isArray(object?.sequences) + ? object.sequences.map((e: any) => Sequence.fromJSON(e)) + : [], + genMsgs: Array.isArray(object?.genMsgs) + ? object.genMsgs.map((e: any) => GenesisState_GenMsgs.fromJSON(e)) + : [], + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + + if (message.codes) { + obj.codes = message.codes.map((e) => (e ? Code.toJSON(e) : undefined)); + } else { + obj.codes = []; + } + + if (message.contracts) { + obj.contracts = message.contracts.map((e) => (e ? Contract.toJSON(e) : undefined)); + } else { + obj.contracts = []; + } + + if (message.sequences) { + obj.sequences = message.sequences.map((e) => (e ? Sequence.toJSON(e) : undefined)); + } else { + obj.sequences = []; + } + + if (message.genMsgs) { + obj.genMsgs = message.genMsgs.map((e) => (e ? GenesisState_GenMsgs.toJSON(e) : undefined)); + } else { + obj.genMsgs = []; + } + + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.params = @@ -187,6 +234,33 @@ export const GenesisState_GenMsgs = { return message; }, + fromJSON(object: any): GenesisState_GenMsgs { + return { + storeCode: isSet(object.storeCode) ? MsgStoreCode.fromJSON(object.storeCode) : undefined, + instantiateContract: isSet(object.instantiateContract) + ? MsgInstantiateContract.fromJSON(object.instantiateContract) + : undefined, + executeContract: isSet(object.executeContract) + ? MsgExecuteContract.fromJSON(object.executeContract) + : undefined, + }; + }, + + toJSON(message: GenesisState_GenMsgs): unknown { + const obj: any = {}; + message.storeCode !== undefined && + (obj.storeCode = message.storeCode ? MsgStoreCode.toJSON(message.storeCode) : undefined); + message.instantiateContract !== undefined && + (obj.instantiateContract = message.instantiateContract + ? MsgInstantiateContract.toJSON(message.instantiateContract) + : undefined); + message.executeContract !== undefined && + (obj.executeContract = message.executeContract + ? MsgExecuteContract.toJSON(message.executeContract) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): GenesisState_GenMsgs { const message = createBaseGenesisState_GenMsgs(); message.storeCode = @@ -269,6 +343,28 @@ export const Code = { return message; }, + fromJSON(object: any): Code { + return { + codeId: isSet(object.codeId) ? Long.fromValue(object.codeId) : Long.UZERO, + codeInfo: isSet(object.codeInfo) ? CodeInfo.fromJSON(object.codeInfo) : undefined, + codeBytes: isSet(object.codeBytes) ? bytesFromBase64(object.codeBytes) : new Uint8Array(), + pinned: isSet(object.pinned) ? Boolean(object.pinned) : false, + }; + }, + + toJSON(message: Code): unknown { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + message.codeInfo !== undefined && + (obj.codeInfo = message.codeInfo ? CodeInfo.toJSON(message.codeInfo) : undefined); + message.codeBytes !== undefined && + (obj.codeBytes = base64FromBytes( + message.codeBytes !== undefined ? message.codeBytes : new Uint8Array(), + )); + message.pinned !== undefined && (obj.pinned = message.pinned); + return obj; + }, + fromPartial, I>>(object: I): Code { const message = createBaseCode(); message.codeId = @@ -338,6 +434,31 @@ export const Contract = { return message; }, + fromJSON(object: any): Contract { + return { + contractAddress: isSet(object.contractAddress) ? String(object.contractAddress) : "", + contractInfo: isSet(object.contractInfo) ? ContractInfo.fromJSON(object.contractInfo) : undefined, + contractState: Array.isArray(object?.contractState) + ? object.contractState.map((e: any) => Model.fromJSON(e)) + : [], + }; + }, + + toJSON(message: Contract): unknown { + const obj: any = {}; + message.contractAddress !== undefined && (obj.contractAddress = message.contractAddress); + message.contractInfo !== undefined && + (obj.contractInfo = message.contractInfo ? ContractInfo.toJSON(message.contractInfo) : undefined); + + if (message.contractState) { + obj.contractState = message.contractState.map((e) => (e ? Model.toJSON(e) : undefined)); + } else { + obj.contractState = []; + } + + return obj; + }, + fromPartial, I>>(object: I): Contract { const message = createBaseContract(); message.contractAddress = object.contractAddress ?? ""; @@ -396,6 +517,21 @@ export const Sequence = { return message; }, + fromJSON(object: any): Sequence { + return { + idKey: isSet(object.idKey) ? bytesFromBase64(object.idKey) : new Uint8Array(), + value: isSet(object.value) ? Long.fromValue(object.value) : Long.UZERO, + }; + }, + + toJSON(message: Sequence): unknown { + const obj: any = {}; + message.idKey !== undefined && + (obj.idKey = base64FromBytes(message.idKey !== undefined ? message.idKey : new Uint8Array())); + message.value !== undefined && (obj.value = (message.value || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): Sequence { const message = createBaseSequence(); message.idKey = object.idKey ?? new Uint8Array(); diff --git a/src/cosmwasm/wasm/v1/ibc.ts b/src/cosmwasm/wasm/v1/ibc.ts index 663c45f6..00bc4321 100644 --- a/src/cosmwasm/wasm/v1/ibc.ts +++ b/src/cosmwasm/wasm/v1/ibc.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -import { Long, DeepPartial, Exact } from "../../../helpers"; +import { Long, isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact } from "../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "cosmwasm.wasm.v1"; /** MsgIBCSend */ @@ -96,6 +96,27 @@ export const MsgIBCSend = { return message; }, + fromJSON(object: any): MsgIBCSend { + return { + channel: isSet(object.channel) ? String(object.channel) : "", + timeoutHeight: isSet(object.timeoutHeight) ? Long.fromValue(object.timeoutHeight) : Long.UZERO, + timeoutTimestamp: isSet(object.timeoutTimestamp) ? Long.fromValue(object.timeoutTimestamp) : Long.UZERO, + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + }; + }, + + toJSON(message: MsgIBCSend): unknown { + const obj: any = {}; + message.channel !== undefined && (obj.channel = message.channel); + message.timeoutHeight !== undefined && + (obj.timeoutHeight = (message.timeoutHeight || Long.UZERO).toString()); + message.timeoutTimestamp !== undefined && + (obj.timeoutTimestamp = (message.timeoutTimestamp || Long.UZERO).toString()); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): MsgIBCSend { const message = createBaseMsgIBCSend(); message.channel = object.channel ?? ""; @@ -149,6 +170,18 @@ export const MsgIBCCloseChannel = { return message; }, + fromJSON(object: any): MsgIBCCloseChannel { + return { + channel: isSet(object.channel) ? String(object.channel) : "", + }; + }, + + toJSON(message: MsgIBCCloseChannel): unknown { + const obj: any = {}; + message.channel !== undefined && (obj.channel = message.channel); + return obj; + }, + fromPartial, I>>(object: I): MsgIBCCloseChannel { const message = createBaseMsgIBCCloseChannel(); message.channel = object.channel ?? ""; diff --git a/src/cosmwasm/wasm/v1/proposal.ts b/src/cosmwasm/wasm/v1/proposal.ts index 1275c2fe..d4af33bf 100644 --- a/src/cosmwasm/wasm/v1/proposal.ts +++ b/src/cosmwasm/wasm/v1/proposal.ts @@ -2,7 +2,7 @@ import { AccessConfig } from "./types"; import { Coin } from "../../../cosmos/base/v1beta1/coin"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../../helpers"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact, Long } from "../../../helpers"; export const protobufPackage = "cosmwasm.wasm.v1"; /** StoreCodeProposal gov proposal content type to submit WASM code to the system */ @@ -273,6 +273,34 @@ export const StoreCodeProposal = { return message; }, + fromJSON(object: any): StoreCodeProposal { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + runAs: isSet(object.runAs) ? String(object.runAs) : "", + wasmByteCode: isSet(object.wasmByteCode) ? bytesFromBase64(object.wasmByteCode) : new Uint8Array(), + instantiatePermission: isSet(object.instantiatePermission) + ? AccessConfig.fromJSON(object.instantiatePermission) + : undefined, + }; + }, + + toJSON(message: StoreCodeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.runAs !== undefined && (obj.runAs = message.runAs); + message.wasmByteCode !== undefined && + (obj.wasmByteCode = base64FromBytes( + message.wasmByteCode !== undefined ? message.wasmByteCode : new Uint8Array(), + )); + message.instantiatePermission !== undefined && + (obj.instantiatePermission = message.instantiatePermission + ? AccessConfig.toJSON(message.instantiatePermission) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): StoreCodeProposal { const message = createBaseStoreCodeProposal(); message.title = object.title ?? ""; @@ -387,6 +415,39 @@ export const InstantiateContractProposal = { return message; }, + fromJSON(object: any): InstantiateContractProposal { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + runAs: isSet(object.runAs) ? String(object.runAs) : "", + admin: isSet(object.admin) ? String(object.admin) : "", + codeId: isSet(object.codeId) ? Long.fromValue(object.codeId) : Long.UZERO, + label: isSet(object.label) ? String(object.label) : "", + msg: isSet(object.msg) ? bytesFromBase64(object.msg) : new Uint8Array(), + funds: Array.isArray(object?.funds) ? object.funds.map((e: any) => Coin.fromJSON(e)) : [], + }; + }, + + toJSON(message: InstantiateContractProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.runAs !== undefined && (obj.runAs = message.runAs); + 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.msg !== undefined && + (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); + + if (message.funds) { + obj.funds = message.funds.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.funds = []; + } + + return obj; + }, + fromPartial, I>>( object: I, ): InstantiateContractProposal { @@ -477,6 +538,27 @@ export const MigrateContractProposal = { return message; }, + fromJSON(object: any): MigrateContractProposal { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + contract: isSet(object.contract) ? String(object.contract) : "", + codeId: isSet(object.codeId) ? Long.fromValue(object.codeId) : Long.UZERO, + msg: isSet(object.msg) ? bytesFromBase64(object.msg) : new Uint8Array(), + }; + }, + + toJSON(message: MigrateContractProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.contract !== undefined && (obj.contract = message.contract); + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + message.msg !== undefined && + (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): MigrateContractProposal { const message = createBaseMigrateContractProposal(); message.title = object.title ?? ""; @@ -553,6 +635,25 @@ export const SudoContractProposal = { return message; }, + fromJSON(object: any): SudoContractProposal { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + contract: isSet(object.contract) ? String(object.contract) : "", + msg: isSet(object.msg) ? bytesFromBase64(object.msg) : new Uint8Array(), + }; + }, + + toJSON(message: SudoContractProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.contract !== undefined && (obj.contract = message.contract); + message.msg !== undefined && + (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): SudoContractProposal { const message = createBaseSudoContractProposal(); message.title = object.title ?? ""; @@ -645,6 +746,35 @@ export const ExecuteContractProposal = { return message; }, + fromJSON(object: any): ExecuteContractProposal { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + runAs: isSet(object.runAs) ? String(object.runAs) : "", + contract: isSet(object.contract) ? String(object.contract) : "", + msg: isSet(object.msg) ? bytesFromBase64(object.msg) : new Uint8Array(), + funds: Array.isArray(object?.funds) ? object.funds.map((e: any) => Coin.fromJSON(e)) : [], + }; + }, + + toJSON(message: ExecuteContractProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.runAs !== undefined && (obj.runAs = message.runAs); + message.contract !== undefined && (obj.contract = message.contract); + message.msg !== undefined && + (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); + + if (message.funds) { + obj.funds = message.funds.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.funds = []; + } + + return obj; + }, + fromPartial, I>>(object: I): ExecuteContractProposal { const message = createBaseExecuteContractProposal(); message.title = object.title ?? ""; @@ -721,6 +851,24 @@ export const UpdateAdminProposal = { return message; }, + fromJSON(object: any): UpdateAdminProposal { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + newAdmin: isSet(object.newAdmin) ? String(object.newAdmin) : "", + contract: isSet(object.contract) ? String(object.contract) : "", + }; + }, + + toJSON(message: UpdateAdminProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.newAdmin !== undefined && (obj.newAdmin = message.newAdmin); + message.contract !== undefined && (obj.contract = message.contract); + return obj; + }, + fromPartial, I>>(object: I): UpdateAdminProposal { const message = createBaseUpdateAdminProposal(); message.title = object.title ?? ""; @@ -786,6 +934,22 @@ export const ClearAdminProposal = { return message; }, + fromJSON(object: any): ClearAdminProposal { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + contract: isSet(object.contract) ? String(object.contract) : "", + }; + }, + + toJSON(message: ClearAdminProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.contract !== undefined && (obj.contract = message.contract); + return obj; + }, + fromPartial, I>>(object: I): ClearAdminProposal { const message = createBaseClearAdminProposal(); message.title = object.title ?? ""; @@ -862,6 +1026,28 @@ export const PinCodesProposal = { return message; }, + fromJSON(object: any): PinCodesProposal { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + codeIds: Array.isArray(object?.codeIds) ? object.codeIds.map((e: any) => Long.fromValue(e)) : [], + }; + }, + + toJSON(message: PinCodesProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + + if (message.codeIds) { + obj.codeIds = message.codeIds.map((e) => (e || Long.UZERO).toString()); + } else { + obj.codeIds = []; + } + + return obj; + }, + fromPartial, I>>(object: I): PinCodesProposal { const message = createBasePinCodesProposal(); message.title = object.title ?? ""; @@ -938,6 +1124,28 @@ export const UnpinCodesProposal = { return message; }, + fromJSON(object: any): UnpinCodesProposal { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + codeIds: Array.isArray(object?.codeIds) ? object.codeIds.map((e: any) => Long.fromValue(e)) : [], + }; + }, + + toJSON(message: UnpinCodesProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + + if (message.codeIds) { + obj.codeIds = message.codeIds.map((e) => (e || Long.UZERO).toString()); + } else { + obj.codeIds = []; + } + + return obj; + }, + fromPartial, I>>(object: I): UnpinCodesProposal { const message = createBaseUnpinCodesProposal(); message.title = object.title ?? ""; @@ -993,6 +1201,25 @@ export const AccessConfigUpdate = { return message; }, + fromJSON(object: any): AccessConfigUpdate { + return { + codeId: isSet(object.codeId) ? Long.fromValue(object.codeId) : Long.UZERO, + instantiatePermission: isSet(object.instantiatePermission) + ? AccessConfig.fromJSON(object.instantiatePermission) + : undefined, + }; + }, + + toJSON(message: AccessConfigUpdate): unknown { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + message.instantiatePermission !== undefined && + (obj.instantiatePermission = message.instantiatePermission + ? AccessConfig.toJSON(message.instantiatePermission) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): AccessConfigUpdate { const message = createBaseAccessConfigUpdate(); message.codeId = @@ -1060,6 +1287,32 @@ export const UpdateInstantiateConfigProposal = { return message; }, + fromJSON(object: any): UpdateInstantiateConfigProposal { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + accessConfigUpdates: Array.isArray(object?.accessConfigUpdates) + ? object.accessConfigUpdates.map((e: any) => AccessConfigUpdate.fromJSON(e)) + : [], + }; + }, + + toJSON(message: UpdateInstantiateConfigProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + + if (message.accessConfigUpdates) { + obj.accessConfigUpdates = message.accessConfigUpdates.map((e) => + e ? AccessConfigUpdate.toJSON(e) : undefined, + ); + } else { + obj.accessConfigUpdates = []; + } + + return obj; + }, + fromPartial, I>>( object: I, ): UpdateInstantiateConfigProposal { diff --git a/src/cosmwasm/wasm/v1/query.ts b/src/cosmwasm/wasm/v1/query.ts index 50625a08..5b1293f5 100644 --- a/src/cosmwasm/wasm/v1/query.ts +++ b/src/cosmwasm/wasm/v1/query.ts @@ -2,7 +2,7 @@ import { PageRequest, PageResponse } from "../../../cosmos/base/query/v1beta1/pagination"; import { ContractInfo, ContractCodeHistoryEntry, Model, AccessConfig } from "./types"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long, Rpc } from "../../../helpers"; +import { isSet, DeepPartial, Exact, Long, bytesFromBase64, base64FromBytes, Rpc } from "../../../helpers"; export const protobufPackage = "cosmwasm.wasm.v1"; /** * QueryContractInfoRequest is the request type for the Query/ContractInfo RPC @@ -226,6 +226,18 @@ export const QueryContractInfoRequest = { return message; }, + fromJSON(object: any): QueryContractInfoRequest { + return { + address: isSet(object.address) ? String(object.address) : "", + }; + }, + + toJSON(message: QueryContractInfoRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + return obj; + }, + fromPartial, I>>( object: I, ): QueryContractInfoRequest { @@ -281,6 +293,21 @@ export const QueryContractInfoResponse = { return message; }, + fromJSON(object: any): QueryContractInfoResponse { + return { + address: isSet(object.address) ? String(object.address) : "", + contractInfo: isSet(object.contractInfo) ? ContractInfo.fromJSON(object.contractInfo) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryContractInfoResponse { @@ -340,6 +367,21 @@ export const QueryContractHistoryRequest = { return message; }, + fromJSON(object: any): QueryContractHistoryRequest { + return { + address: isSet(object.address) ? String(object.address) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryContractHistoryRequest { @@ -399,6 +441,29 @@ export const QueryContractHistoryResponse = { return message; }, + fromJSON(object: any): QueryContractHistoryResponse { + return { + entries: Array.isArray(object?.entries) + ? object.entries.map((e: any) => ContractCodeHistoryEntry.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryContractHistoryResponse { @@ -458,6 +523,21 @@ export const QueryContractsByCodeRequest = { return message; }, + fromJSON(object: any): QueryContractsByCodeRequest { + return { + codeId: isSet(object.codeId) ? Long.fromValue(object.codeId) : Long.UZERO, + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryContractsByCodeRequest { @@ -518,6 +598,27 @@ export const QueryContractsByCodeResponse = { return message; }, + fromJSON(object: any): QueryContractsByCodeResponse { + return { + contracts: Array.isArray(object?.contracts) ? object.contracts.map((e: any) => String(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryContractsByCodeResponse): unknown { + const obj: any = {}; + + if (message.contracts) { + obj.contracts = message.contracts.map((e) => e); + } else { + obj.contracts = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryContractsByCodeResponse { @@ -577,6 +678,21 @@ export const QueryAllContractStateRequest = { return message; }, + fromJSON(object: any): QueryAllContractStateRequest { + return { + address: isSet(object.address) ? String(object.address) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryAllContractStateRequest { @@ -636,6 +752,27 @@ export const QueryAllContractStateResponse = { return message; }, + fromJSON(object: any): QueryAllContractStateResponse { + return { + models: Array.isArray(object?.models) ? object.models.map((e: any) => Model.fromJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryAllContractStateResponse { @@ -695,6 +832,23 @@ export const QueryRawContractStateRequest = { return message; }, + fromJSON(object: any): QueryRawContractStateRequest { + return { + address: isSet(object.address) ? String(object.address) : "", + queryData: isSet(object.queryData) ? bytesFromBase64(object.queryData) : new Uint8Array(), + }; + }, + + 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, I>>( object: I, ): QueryRawContractStateRequest { @@ -742,6 +896,19 @@ export const QueryRawContractStateResponse = { return message; }, + fromJSON(object: any): QueryRawContractStateResponse { + return { + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + }; + }, + + toJSON(message: QueryRawContractStateResponse): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial, I>>( object: I, ): QueryRawContractStateResponse { @@ -797,6 +964,23 @@ export const QuerySmartContractStateRequest = { return message; }, + fromJSON(object: any): QuerySmartContractStateRequest { + return { + address: isSet(object.address) ? String(object.address) : "", + queryData: isSet(object.queryData) ? bytesFromBase64(object.queryData) : new Uint8Array(), + }; + }, + + 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, I>>( object: I, ): QuerySmartContractStateRequest { @@ -844,6 +1028,19 @@ export const QuerySmartContractStateResponse = { return message; }, + fromJSON(object: any): QuerySmartContractStateResponse { + return { + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + }; + }, + + toJSON(message: QuerySmartContractStateResponse): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial, I>>( object: I, ): QuerySmartContractStateResponse { @@ -890,6 +1087,18 @@ export const QueryCodeRequest = { return message; }, + fromJSON(object: any): QueryCodeRequest { + return { + codeId: isSet(object.codeId) ? Long.fromValue(object.codeId) : Long.UZERO, + }; + }, + + toJSON(message: QueryCodeRequest): unknown { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): QueryCodeRequest { const message = createBaseQueryCodeRequest(); message.codeId = @@ -962,6 +1171,30 @@ export const CodeInfoResponse = { return message; }, + fromJSON(object: any): CodeInfoResponse { + return { + codeId: isSet(object.codeId) ? Long.fromValue(object.codeId) : Long.UZERO, + creator: isSet(object.creator) ? String(object.creator) : "", + dataHash: isSet(object.dataHash) ? bytesFromBase64(object.dataHash) : new Uint8Array(), + instantiatePermission: isSet(object.instantiatePermission) + ? AccessConfig.fromJSON(object.instantiatePermission) + : undefined, + }; + }, + + 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.instantiatePermission !== undefined && + (obj.instantiatePermission = message.instantiatePermission + ? AccessConfig.toJSON(message.instantiatePermission) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): CodeInfoResponse { const message = createBaseCodeInfoResponse(); message.codeId = @@ -1022,6 +1255,22 @@ export const QueryCodeResponse = { return message; }, + fromJSON(object: any): QueryCodeResponse { + return { + codeInfo: isSet(object.codeInfo) ? CodeInfoResponse.fromJSON(object.codeInfo) : undefined, + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + }; + }, + + 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, I>>(object: I): QueryCodeResponse { const message = createBaseQueryCodeResponse(); message.codeInfo = @@ -1070,6 +1319,19 @@ export const QueryCodesRequest = { return message; }, + fromJSON(object: any): QueryCodesRequest { + return { + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryCodesRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryCodesRequest { const message = createBaseQueryCodesRequest(); message.pagination = @@ -1126,6 +1388,29 @@ export const QueryCodesResponse = { return message; }, + fromJSON(object: any): QueryCodesResponse { + return { + codeInfos: Array.isArray(object?.codeInfos) + ? object.codeInfos.map((e: any) => CodeInfoResponse.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>(object: I): QueryCodesResponse { const message = createBaseQueryCodesResponse(); message.codeInfos = object.codeInfos?.map((e) => CodeInfoResponse.fromPartial(e)) || []; @@ -1174,6 +1459,19 @@ export const QueryPinnedCodesRequest = { return message; }, + fromJSON(object: any): QueryPinnedCodesRequest { + return { + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryPinnedCodesRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryPinnedCodesRequest { const message = createBaseQueryPinnedCodesRequest(); message.pagination = @@ -1243,6 +1541,27 @@ export const QueryPinnedCodesResponse = { return message; }, + fromJSON(object: any): QueryPinnedCodesResponse { + return { + codeIds: Array.isArray(object?.codeIds) ? object.codeIds.map((e: any) => Long.fromValue(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryPinnedCodesResponse): unknown { + const obj: any = {}; + + if (message.codeIds) { + obj.codeIds = message.codeIds.map((e) => (e || Long.UZERO).toString()); + } else { + obj.codeIds = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryPinnedCodesResponse { diff --git a/src/cosmwasm/wasm/v1/tx.ts b/src/cosmwasm/wasm/v1/tx.ts index d51c1409..ec947638 100644 --- a/src/cosmwasm/wasm/v1/tx.ts +++ b/src/cosmwasm/wasm/v1/tx.ts @@ -2,7 +2,7 @@ import { AccessConfig } from "./types"; import { Coin } from "../../../cosmos/base/v1beta1/coin"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long, Rpc } from "../../../helpers"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact, Long, Rpc } from "../../../helpers"; export const protobufPackage = "cosmwasm.wasm.v1"; /** MsgStoreCode submit Wasm code to the system */ @@ -186,6 +186,30 @@ export const MsgStoreCode = { return message; }, + fromJSON(object: any): MsgStoreCode { + return { + sender: isSet(object.sender) ? String(object.sender) : "", + wasmByteCode: isSet(object.wasmByteCode) ? bytesFromBase64(object.wasmByteCode) : new Uint8Array(), + instantiatePermission: isSet(object.instantiatePermission) + ? AccessConfig.fromJSON(object.instantiatePermission) + : undefined, + }; + }, + + 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.instantiatePermission !== undefined && + (obj.instantiatePermission = message.instantiatePermission + ? AccessConfig.toJSON(message.instantiatePermission) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgStoreCode { const message = createBaseMsgStoreCode(); message.sender = object.sender ?? ""; @@ -235,6 +259,18 @@ export const MsgStoreCodeResponse = { return message; }, + fromJSON(object: any): MsgStoreCodeResponse { + return { + codeId: isSet(object.codeId) ? Long.fromValue(object.codeId) : Long.UZERO, + }; + }, + + toJSON(message: MsgStoreCodeResponse): unknown { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): MsgStoreCodeResponse { const message = createBaseMsgStoreCodeResponse(); message.codeId = @@ -325,6 +361,35 @@ export const MsgInstantiateContract = { return message; }, + fromJSON(object: any): MsgInstantiateContract { + return { + sender: isSet(object.sender) ? String(object.sender) : "", + admin: isSet(object.admin) ? String(object.admin) : "", + codeId: isSet(object.codeId) ? Long.fromValue(object.codeId) : Long.UZERO, + label: isSet(object.label) ? String(object.label) : "", + msg: isSet(object.msg) ? bytesFromBase64(object.msg) : new Uint8Array(), + funds: Array.isArray(object?.funds) ? object.funds.map((e: any) => Coin.fromJSON(e)) : [], + }; + }, + + 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.msg !== undefined && + (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); + + if (message.funds) { + obj.funds = message.funds.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.funds = []; + } + + return obj; + }, + fromPartial, I>>(object: I): MsgInstantiateContract { const message = createBaseMsgInstantiateContract(); message.sender = object.sender ?? ""; @@ -384,6 +449,21 @@ export const MsgInstantiateContractResponse = { return message; }, + fromJSON(object: any): MsgInstantiateContractResponse { + return { + address: isSet(object.address) ? String(object.address) : "", + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + }; + }, + + toJSON(message: MsgInstantiateContractResponse): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial, I>>( object: I, ): MsgInstantiateContractResponse { @@ -458,6 +538,31 @@ export const MsgExecuteContract = { return message; }, + fromJSON(object: any): MsgExecuteContract { + return { + sender: isSet(object.sender) ? String(object.sender) : "", + contract: isSet(object.contract) ? String(object.contract) : "", + msg: isSet(object.msg) ? bytesFromBase64(object.msg) : new Uint8Array(), + funds: Array.isArray(object?.funds) ? object.funds.map((e: any) => Coin.fromJSON(e)) : [], + }; + }, + + 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.funds) { + obj.funds = message.funds.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.funds = []; + } + + return obj; + }, + fromPartial, I>>(object: I): MsgExecuteContract { const message = createBaseMsgExecuteContract(); message.sender = object.sender ?? ""; @@ -505,6 +610,19 @@ export const MsgExecuteContractResponse = { return message; }, + fromJSON(object: any): MsgExecuteContractResponse { + return { + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + }; + }, + + toJSON(message: MsgExecuteContractResponse): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial, I>>( object: I, ): MsgExecuteContractResponse { @@ -578,6 +696,25 @@ export const MsgMigrateContract = { return message; }, + fromJSON(object: any): MsgMigrateContract { + return { + sender: isSet(object.sender) ? String(object.sender) : "", + contract: isSet(object.contract) ? String(object.contract) : "", + codeId: isSet(object.codeId) ? Long.fromValue(object.codeId) : Long.UZERO, + msg: isSet(object.msg) ? bytesFromBase64(object.msg) : new Uint8Array(), + }; + }, + + 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.msg !== undefined && + (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): MsgMigrateContract { const message = createBaseMsgMigrateContract(); message.sender = object.sender ?? ""; @@ -626,6 +763,19 @@ export const MsgMigrateContractResponse = { return message; }, + fromJSON(object: any): MsgMigrateContractResponse { + return { + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + }; + }, + + toJSON(message: MsgMigrateContractResponse): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial, I>>( object: I, ): MsgMigrateContractResponse { @@ -690,6 +840,22 @@ export const MsgUpdateAdmin = { return message; }, + fromJSON(object: any): MsgUpdateAdmin { + return { + sender: isSet(object.sender) ? String(object.sender) : "", + newAdmin: isSet(object.newAdmin) ? String(object.newAdmin) : "", + contract: isSet(object.contract) ? String(object.contract) : "", + }; + }, + + 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, I>>(object: I): MsgUpdateAdmin { const message = createBaseMsgUpdateAdmin(); message.sender = object.sender ?? ""; @@ -726,6 +892,15 @@ export const MsgUpdateAdminResponse = { return message; }, + fromJSON(_: any): MsgUpdateAdminResponse { + return {}; + }, + + toJSON(_: MsgUpdateAdminResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgUpdateAdminResponse { const message = createBaseMsgUpdateAdminResponse(); return message; @@ -778,6 +953,20 @@ export const MsgClearAdmin = { return message; }, + fromJSON(object: any): MsgClearAdmin { + return { + sender: isSet(object.sender) ? String(object.sender) : "", + contract: isSet(object.contract) ? String(object.contract) : "", + }; + }, + + toJSON(message: MsgClearAdmin): unknown { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.contract !== undefined && (obj.contract = message.contract); + return obj; + }, + fromPartial, I>>(object: I): MsgClearAdmin { const message = createBaseMsgClearAdmin(); message.sender = object.sender ?? ""; @@ -813,6 +1002,15 @@ export const MsgClearAdminResponse = { return message; }, + fromJSON(_: any): MsgClearAdminResponse { + return {}; + }, + + toJSON(_: MsgClearAdminResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgClearAdminResponse { const message = createBaseMsgClearAdminResponse(); return message; diff --git a/src/cosmwasm/wasm/v1/types.ts b/src/cosmwasm/wasm/v1/types.ts index d5310df3..a579255f 100644 --- a/src/cosmwasm/wasm/v1/types.ts +++ b/src/cosmwasm/wasm/v1/types.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Any } from "../../../google/protobuf/any"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../../helpers"; +import { isSet, DeepPartial, Exact, bytesFromBase64, base64FromBytes, Long } from "../../../helpers"; export const protobufPackage = "cosmwasm.wasm.v1"; /** AccessType permission types */ @@ -253,6 +253,18 @@ export const AccessTypeParam = { return message; }, + fromJSON(object: any): AccessTypeParam { + return { + value: isSet(object.value) ? accessTypeFromJSON(object.value) : 0, + }; + }, + + toJSON(message: AccessTypeParam): unknown { + const obj: any = {}; + message.value !== undefined && (obj.value = accessTypeToJSON(message.value)); + return obj; + }, + fromPartial, I>>(object: I): AccessTypeParam { const message = createBaseAccessTypeParam(); message.value = object.value ?? 0; @@ -306,6 +318,20 @@ export const AccessConfig = { return message; }, + fromJSON(object: any): AccessConfig { + return { + permission: isSet(object.permission) ? accessTypeFromJSON(object.permission) : 0, + address: isSet(object.address) ? String(object.address) : "", + }; + }, + + 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, I>>(object: I): AccessConfig { const message = createBaseAccessConfig(); message.permission = object.permission ?? 0; @@ -360,6 +386,28 @@ export const Params = { return message; }, + fromJSON(object: any): Params { + return { + codeUploadAccess: isSet(object.codeUploadAccess) + ? AccessConfig.fromJSON(object.codeUploadAccess) + : undefined, + instantiateDefaultPermission: isSet(object.instantiateDefaultPermission) + ? accessTypeFromJSON(object.instantiateDefaultPermission) + : 0, + }; + }, + + 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)); + return obj; + }, + fromPartial, I>>(object: I): Params { const message = createBaseParams(); message.codeUploadAccess = @@ -426,6 +474,28 @@ export const CodeInfo = { return message; }, + fromJSON(object: any): CodeInfo { + return { + codeHash: isSet(object.codeHash) ? bytesFromBase64(object.codeHash) : new Uint8Array(), + creator: isSet(object.creator) ? String(object.creator) : "", + instantiateConfig: isSet(object.instantiateConfig) + ? AccessConfig.fromJSON(object.instantiateConfig) + : undefined, + }; + }, + + 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.instantiateConfig !== undefined && + (obj.instantiateConfig = message.instantiateConfig + ? AccessConfig.toJSON(message.instantiateConfig) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): CodeInfo { const message = createBaseCodeInfo(); message.codeHash = object.codeHash ?? new Uint8Array(); @@ -529,6 +599,32 @@ export const ContractInfo = { return message; }, + fromJSON(object: any): ContractInfo { + return { + codeId: isSet(object.codeId) ? Long.fromValue(object.codeId) : Long.UZERO, + creator: isSet(object.creator) ? String(object.creator) : "", + admin: isSet(object.admin) ? String(object.admin) : "", + label: isSet(object.label) ? String(object.label) : "", + created: isSet(object.created) ? AbsoluteTxPosition.fromJSON(object.created) : undefined, + ibcPortId: isSet(object.ibcPortId) ? String(object.ibcPortId) : "", + extension: isSet(object.extension) ? Any.fromJSON(object.extension) : undefined, + }; + }, + + 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); + message.ibcPortId !== undefined && (obj.ibcPortId = message.ibcPortId); + message.extension !== undefined && + (obj.extension = message.extension ? Any.toJSON(message.extension) : undefined); + return obj; + }, + fromPartial, I>>(object: I): ContractInfo { const message = createBaseContractInfo(); message.codeId = @@ -613,6 +709,27 @@ export const ContractCodeHistoryEntry = { return message; }, + fromJSON(object: any): ContractCodeHistoryEntry { + return { + operation: isSet(object.operation) ? contractCodeHistoryOperationTypeFromJSON(object.operation) : 0, + codeId: isSet(object.codeId) ? Long.fromValue(object.codeId) : Long.UZERO, + updated: isSet(object.updated) ? AbsoluteTxPosition.fromJSON(object.updated) : undefined, + msg: isSet(object.msg) ? bytesFromBase64(object.msg) : new Uint8Array(), + }; + }, + + 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, I>>( object: I, ): ContractCodeHistoryEntry { @@ -675,6 +792,20 @@ export const AbsoluteTxPosition = { return message; }, + fromJSON(object: any): AbsoluteTxPosition { + return { + blockHeight: isSet(object.blockHeight) ? Long.fromValue(object.blockHeight) : Long.UZERO, + txIndex: isSet(object.txIndex) ? Long.fromValue(object.txIndex) : Long.UZERO, + }; + }, + + 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, I>>(object: I): AbsoluteTxPosition { const message = createBaseAbsoluteTxPosition(); message.blockHeight = @@ -733,6 +864,22 @@ export const Model = { return message; }, + fromJSON(object: any): Model { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), + }; + }, + + 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, I>>(object: I): Model { const message = createBaseModel(); message.key = object.key ?? new Uint8Array(); diff --git a/src/google/api/http.ts b/src/google/api/http.ts index 5469ab44..a5c7bdf6 100644 --- a/src/google/api/http.ts +++ b/src/google/api/http.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../helpers"; +import { isSet, DeepPartial, Exact } from "../../helpers"; export const protobufPackage = "google.api"; /** * Defines the HTTP configuration for an API service. It contains a list of @@ -355,6 +355,29 @@ export const Http = { return message; }, + fromJSON(object: any): Http { + return { + rules: Array.isArray(object?.rules) ? object.rules.map((e: any) => HttpRule.fromJSON(e)) : [], + fullyDecodeReservedExpansion: isSet(object.fullyDecodeReservedExpansion) + ? Boolean(object.fullyDecodeReservedExpansion) + : false, + }; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + + if (message.rules) { + obj.rules = message.rules.map((e) => (e ? HttpRule.toJSON(e) : undefined)); + } else { + obj.rules = []; + } + + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + fromPartial, I>>(object: I): Http { const message = createBaseHttp(); message.rules = object.rules?.map((e) => HttpRule.fromPartial(e)) || []; @@ -481,6 +504,45 @@ export const HttpRule = { return message; }, + fromJSON(object: any): HttpRule { + return { + selector: isSet(object.selector) ? String(object.selector) : "", + get: isSet(object.get) ? String(object.get) : undefined, + put: isSet(object.put) ? String(object.put) : undefined, + post: isSet(object.post) ? String(object.post) : undefined, + delete: isSet(object.delete) ? String(object.delete) : undefined, + patch: isSet(object.patch) ? String(object.patch) : undefined, + custom: isSet(object.custom) ? CustomHttpPattern.fromJSON(object.custom) : undefined, + body: isSet(object.body) ? String(object.body) : "", + responseBody: isSet(object.responseBody) ? String(object.responseBody) : "", + additionalBindings: Array.isArray(object?.additionalBindings) + ? object.additionalBindings.map((e: any) => HttpRule.fromJSON(e)) + : [], + }; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom ? CustomHttpPattern.toJSON(message.custom) : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && (obj.responseBody = message.responseBody); + + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => (e ? HttpRule.toJSON(e) : undefined)); + } else { + obj.additionalBindings = []; + } + + return obj; + }, + fromPartial, I>>(object: I): HttpRule { const message = createBaseHttpRule(); message.selector = object.selector ?? ""; @@ -546,6 +608,20 @@ export const CustomHttpPattern = { return message; }, + fromJSON(object: any): CustomHttpPattern { + return { + kind: isSet(object.kind) ? String(object.kind) : "", + path: isSet(object.path) ? String(object.path) : "", + }; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + fromPartial, I>>(object: I): CustomHttpPattern { const message = createBaseCustomHttpPattern(); message.kind = object.kind ?? ""; diff --git a/src/google/protobuf/any.ts b/src/google/protobuf/any.ts index 30559bb8..429edd39 100644 --- a/src/google/protobuf/any.ts +++ b/src/google/protobuf/any.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../helpers"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact } from "../../helpers"; export const protobufPackage = "google.protobuf"; /** * `Any` contains an arbitrary serialized protocol buffer message along with a @@ -166,6 +166,21 @@ export const Any = { return message; }, + fromJSON(object: any): Any { + return { + typeUrl: isSet(object.typeUrl) ? String(object.typeUrl) : "", + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), + }; + }, + + 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, I>>(object: I): Any { const message = createBaseAny(); message.typeUrl = object.typeUrl ?? ""; diff --git a/src/google/protobuf/descriptor.ts b/src/google/protobuf/descriptor.ts index 89b4d596..019ca367 100644 --- a/src/google/protobuf/descriptor.ts +++ b/src/google/protobuf/descriptor.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../helpers"; +import { DeepPartial, Exact, isSet, Long, bytesFromBase64, base64FromBytes } from "../../helpers"; export const protobufPackage = "google.protobuf"; export enum FieldDescriptorProto_Type { /** @@ -1237,6 +1237,24 @@ export const FileDescriptorSet = { return message; }, + fromJSON(object: any): FileDescriptorSet { + return { + file: Array.isArray(object?.file) ? object.file.map((e: any) => FileDescriptorProto.fromJSON(e)) : [], + }; + }, + + 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, I>>(object: I): FileDescriptorSet { const message = createBaseFileDescriptorSet(); message.file = object.file?.map((e) => FileDescriptorProto.fromPartial(e)) || []; @@ -1405,6 +1423,94 @@ export const FileDescriptorProto = { return message; }, + fromJSON(object: any): FileDescriptorProto { + return { + name: isSet(object.name) ? String(object.name) : "", + package: isSet(object.package) ? String(object.package) : "", + dependency: Array.isArray(object?.dependency) ? object.dependency.map((e: any) => String(e)) : [], + publicDependency: Array.isArray(object?.publicDependency) + ? object.publicDependency.map((e: any) => Number(e)) + : [], + weakDependency: Array.isArray(object?.weakDependency) + ? object.weakDependency.map((e: any) => Number(e)) + : [], + messageType: Array.isArray(object?.messageType) + ? object.messageType.map((e: any) => DescriptorProto.fromJSON(e)) + : [], + enumType: Array.isArray(object?.enumType) + ? object.enumType.map((e: any) => EnumDescriptorProto.fromJSON(e)) + : [], + service: Array.isArray(object?.service) + ? object.service.map((e: any) => ServiceDescriptorProto.fromJSON(e)) + : [], + extension: Array.isArray(object?.extension) + ? object.extension.map((e: any) => FieldDescriptorProto.fromJSON(e)) + : [], + options: isSet(object.options) ? FileOptions.fromJSON(object.options) : undefined, + sourceCodeInfo: isSet(object.sourceCodeInfo) + ? SourceCodeInfo.fromJSON(object.sourceCodeInfo) + : undefined, + syntax: isSet(object.syntax) ? String(object.syntax) : "", + }; + }, + + 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) => Math.round(e)); + } else { + obj.publicDependency = []; + } + + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => Math.round(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, I>>(object: I): FileDescriptorProto { const message = createBaseFileDescriptorProto(); message.name = object.name ?? ""; @@ -1547,6 +1653,97 @@ export const DescriptorProto = { return message; }, + fromJSON(object: any): DescriptorProto { + return { + name: isSet(object.name) ? String(object.name) : "", + field: Array.isArray(object?.field) + ? object.field.map((e: any) => FieldDescriptorProto.fromJSON(e)) + : [], + extension: Array.isArray(object?.extension) + ? object.extension.map((e: any) => FieldDescriptorProto.fromJSON(e)) + : [], + nestedType: Array.isArray(object?.nestedType) + ? object.nestedType.map((e: any) => DescriptorProto.fromJSON(e)) + : [], + enumType: Array.isArray(object?.enumType) + ? object.enumType.map((e: any) => EnumDescriptorProto.fromJSON(e)) + : [], + extensionRange: Array.isArray(object?.extensionRange) + ? object.extensionRange.map((e: any) => DescriptorProto_ExtensionRange.fromJSON(e)) + : [], + oneofDecl: Array.isArray(object?.oneofDecl) + ? object.oneofDecl.map((e: any) => OneofDescriptorProto.fromJSON(e)) + : [], + options: isSet(object.options) ? MessageOptions.fromJSON(object.options) : undefined, + reservedRange: Array.isArray(object?.reservedRange) + ? object.reservedRange.map((e: any) => DescriptorProto_ReservedRange.fromJSON(e)) + : [], + reservedName: Array.isArray(object?.reservedName) ? object.reservedName.map((e: any) => String(e)) : [], + }; + }, + + 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, I>>(object: I): DescriptorProto { const message = createBaseDescriptorProto(); message.name = object.name ?? ""; @@ -1623,6 +1820,23 @@ export const DescriptorProto_ExtensionRange = { return message; }, + fromJSON(object: any): DescriptorProto_ExtensionRange { + return { + start: isSet(object.start) ? Number(object.start) : 0, + end: isSet(object.end) ? Number(object.end) : 0, + options: isSet(object.options) ? ExtensionRangeOptions.fromJSON(object.options) : undefined, + }; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = Math.round(message.start)); + message.end !== undefined && (obj.end = Math.round(message.end)); + message.options !== undefined && + (obj.options = message.options ? ExtensionRangeOptions.toJSON(message.options) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): DescriptorProto_ExtensionRange { @@ -1683,6 +1897,20 @@ export const DescriptorProto_ReservedRange = { return message; }, + fromJSON(object: any): DescriptorProto_ReservedRange { + return { + start: isSet(object.start) ? Number(object.start) : 0, + end: isSet(object.end) ? Number(object.end) : 0, + }; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = Math.round(message.start)); + message.end !== undefined && (obj.end = Math.round(message.end)); + return obj; + }, + fromPartial, I>>( object: I, ): DescriptorProto_ReservedRange { @@ -1730,6 +1958,28 @@ export const ExtensionRangeOptions = { return message; }, + fromJSON(object: any): ExtensionRangeOptions { + return { + uninterpretedOption: Array.isArray(object?.uninterpretedOption) + ? object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)) + : [], + }; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined, + ); + } else { + obj.uninterpretedOption = []; + } + + return obj; + }, + fromPartial, I>>(object: I): ExtensionRangeOptions { const message = createBaseExtensionRangeOptions(); message.uninterpretedOption = @@ -1856,6 +2106,37 @@ export const FieldDescriptorProto = { return message; }, + fromJSON(object: any): FieldDescriptorProto { + return { + name: isSet(object.name) ? String(object.name) : "", + number: isSet(object.number) ? Number(object.number) : 0, + label: isSet(object.label) ? fieldDescriptorProto_LabelFromJSON(object.label) : 0, + type: isSet(object.type) ? fieldDescriptorProto_TypeFromJSON(object.type) : 0, + typeName: isSet(object.typeName) ? String(object.typeName) : "", + extendee: isSet(object.extendee) ? String(object.extendee) : "", + defaultValue: isSet(object.defaultValue) ? String(object.defaultValue) : "", + oneofIndex: isSet(object.oneofIndex) ? Number(object.oneofIndex) : 0, + jsonName: isSet(object.jsonName) ? String(object.jsonName) : "", + options: isSet(object.options) ? FieldOptions.fromJSON(object.options) : undefined, + }; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = Math.round(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 = Math.round(message.oneofIndex)); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options ? FieldOptions.toJSON(message.options) : undefined); + return obj; + }, + fromPartial, I>>(object: I): FieldDescriptorProto { const message = createBaseFieldDescriptorProto(); message.name = object.name ?? ""; @@ -1921,6 +2202,21 @@ export const OneofDescriptorProto = { return message; }, + fromJSON(object: any): OneofDescriptorProto { + return { + name: isSet(object.name) ? String(object.name) : "", + options: isSet(object.options) ? OneofOptions.fromJSON(object.options) : undefined, + }; + }, + + 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, I>>(object: I): OneofDescriptorProto { const message = createBaseOneofDescriptorProto(); message.name = object.name ?? ""; @@ -2005,6 +2301,50 @@ export const EnumDescriptorProto = { return message; }, + fromJSON(object: any): EnumDescriptorProto { + return { + name: isSet(object.name) ? String(object.name) : "", + value: Array.isArray(object?.value) + ? object.value.map((e: any) => EnumValueDescriptorProto.fromJSON(e)) + : [], + options: isSet(object.options) ? EnumOptions.fromJSON(object.options) : undefined, + reservedRange: Array.isArray(object?.reservedRange) + ? object.reservedRange.map((e: any) => EnumDescriptorProto_EnumReservedRange.fromJSON(e)) + : [], + reservedName: Array.isArray(object?.reservedName) ? object.reservedName.map((e: any) => String(e)) : [], + }; + }, + + 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, I>>(object: I): EnumDescriptorProto { const message = createBaseEnumDescriptorProto(); message.name = object.name ?? ""; @@ -2069,6 +2409,20 @@ export const EnumDescriptorProto_EnumReservedRange = { return message; }, + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + return { + start: isSet(object.start) ? Number(object.start) : 0, + end: isSet(object.end) ? Number(object.end) : 0, + }; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = Math.round(message.start)); + message.end !== undefined && (obj.end = Math.round(message.end)); + return obj; + }, + fromPartial, I>>( object: I, ): EnumDescriptorProto_EnumReservedRange { @@ -2134,6 +2488,23 @@ export const EnumValueDescriptorProto = { return message; }, + fromJSON(object: any): EnumValueDescriptorProto { + return { + name: isSet(object.name) ? String(object.name) : "", + number: isSet(object.number) ? Number(object.number) : 0, + options: isSet(object.options) ? EnumValueOptions.fromJSON(object.options) : undefined, + }; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = Math.round(message.number)); + message.options !== undefined && + (obj.options = message.options ? EnumValueOptions.toJSON(message.options) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): EnumValueDescriptorProto { @@ -2203,6 +2574,31 @@ export const ServiceDescriptorProto = { return message; }, + fromJSON(object: any): ServiceDescriptorProto { + return { + name: isSet(object.name) ? String(object.name) : "", + method: Array.isArray(object?.method) + ? object.method.map((e: any) => MethodDescriptorProto.fromJSON(e)) + : [], + options: isSet(object.options) ? ServiceOptions.fromJSON(object.options) : undefined, + }; + }, + + 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, I>>(object: I): ServiceDescriptorProto { const message = createBaseServiceDescriptorProto(); message.name = object.name ?? ""; @@ -2297,6 +2693,29 @@ export const MethodDescriptorProto = { return message; }, + fromJSON(object: any): MethodDescriptorProto { + return { + name: isSet(object.name) ? String(object.name) : "", + inputType: isSet(object.inputType) ? String(object.inputType) : "", + outputType: isSet(object.outputType) ? String(object.outputType) : "", + options: isSet(object.options) ? MethodOptions.fromJSON(object.options) : undefined, + clientStreaming: isSet(object.clientStreaming) ? Boolean(object.clientStreaming) : false, + serverStreaming: isSet(object.serverStreaming) ? Boolean(object.serverStreaming) : false, + }; + }, + + 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, I>>(object: I): MethodDescriptorProto { const message = createBaseMethodDescriptorProto(); message.name = object.name ?? ""; @@ -2529,6 +2948,72 @@ export const FileOptions = { return message; }, + fromJSON(object: any): FileOptions { + return { + javaPackage: isSet(object.javaPackage) ? String(object.javaPackage) : "", + javaOuterClassname: isSet(object.javaOuterClassname) ? String(object.javaOuterClassname) : "", + javaMultipleFiles: isSet(object.javaMultipleFiles) ? Boolean(object.javaMultipleFiles) : false, + javaGenerateEqualsAndHash: isSet(object.javaGenerateEqualsAndHash) + ? Boolean(object.javaGenerateEqualsAndHash) + : false, + javaStringCheckUtf8: isSet(object.javaStringCheckUtf8) ? Boolean(object.javaStringCheckUtf8) : false, + optimizeFor: isSet(object.optimizeFor) ? fileOptions_OptimizeModeFromJSON(object.optimizeFor) : 0, + goPackage: isSet(object.goPackage) ? String(object.goPackage) : "", + ccGenericServices: isSet(object.ccGenericServices) ? Boolean(object.ccGenericServices) : false, + javaGenericServices: isSet(object.javaGenericServices) ? Boolean(object.javaGenericServices) : false, + pyGenericServices: isSet(object.pyGenericServices) ? Boolean(object.pyGenericServices) : false, + phpGenericServices: isSet(object.phpGenericServices) ? Boolean(object.phpGenericServices) : false, + deprecated: isSet(object.deprecated) ? Boolean(object.deprecated) : false, + ccEnableArenas: isSet(object.ccEnableArenas) ? Boolean(object.ccEnableArenas) : false, + objcClassPrefix: isSet(object.objcClassPrefix) ? String(object.objcClassPrefix) : "", + csharpNamespace: isSet(object.csharpNamespace) ? String(object.csharpNamespace) : "", + swiftPrefix: isSet(object.swiftPrefix) ? String(object.swiftPrefix) : "", + phpClassPrefix: isSet(object.phpClassPrefix) ? String(object.phpClassPrefix) : "", + phpNamespace: isSet(object.phpNamespace) ? String(object.phpNamespace) : "", + phpMetadataNamespace: isSet(object.phpMetadataNamespace) ? String(object.phpMetadataNamespace) : "", + rubyPackage: isSet(object.rubyPackage) ? String(object.rubyPackage) : "", + uninterpretedOption: Array.isArray(object?.uninterpretedOption) + ? object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): FileOptions { const message = createBaseFileOptions(); message.javaPackage = object.javaPackage ?? ""; @@ -2630,6 +3115,39 @@ export const MessageOptions = { return message; }, + fromJSON(object: any): MessageOptions { + return { + messageSetWireFormat: isSet(object.messageSetWireFormat) ? Boolean(object.messageSetWireFormat) : false, + noStandardDescriptorAccessor: isSet(object.noStandardDescriptorAccessor) + ? Boolean(object.noStandardDescriptorAccessor) + : false, + deprecated: isSet(object.deprecated) ? Boolean(object.deprecated) : false, + mapEntry: isSet(object.mapEntry) ? Boolean(object.mapEntry) : false, + uninterpretedOption: Array.isArray(object?.uninterpretedOption) + ? object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): MessageOptions { const message = createBaseMessageOptions(); message.messageSetWireFormat = object.messageSetWireFormat ?? false; @@ -2733,6 +3251,40 @@ export const FieldOptions = { return message; }, + fromJSON(object: any): FieldOptions { + return { + ctype: isSet(object.ctype) ? fieldOptions_CTypeFromJSON(object.ctype) : 0, + packed: isSet(object.packed) ? Boolean(object.packed) : false, + jstype: isSet(object.jstype) ? fieldOptions_JSTypeFromJSON(object.jstype) : 0, + lazy: isSet(object.lazy) ? Boolean(object.lazy) : false, + deprecated: isSet(object.deprecated) ? Boolean(object.deprecated) : false, + weak: isSet(object.weak) ? Boolean(object.weak) : false, + uninterpretedOption: Array.isArray(object?.uninterpretedOption) + ? object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): FieldOptions { const message = createBaseFieldOptions(); message.ctype = object.ctype ?? 1; @@ -2784,6 +3336,28 @@ export const OneofOptions = { return message; }, + fromJSON(object: any): OneofOptions { + return { + uninterpretedOption: Array.isArray(object?.uninterpretedOption) + ? object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)) + : [], + }; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined, + ); + } else { + obj.uninterpretedOption = []; + } + + return obj; + }, + fromPartial, I>>(object: I): OneofOptions { const message = createBaseOneofOptions(); message.uninterpretedOption = @@ -2847,6 +3421,32 @@ export const EnumOptions = { return message; }, + fromJSON(object: any): EnumOptions { + return { + allowAlias: isSet(object.allowAlias) ? Boolean(object.allowAlias) : false, + deprecated: isSet(object.deprecated) ? Boolean(object.deprecated) : false, + uninterpretedOption: Array.isArray(object?.uninterpretedOption) + ? object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): EnumOptions { const message = createBaseEnumOptions(); message.allowAlias = object.allowAlias ?? false; @@ -2903,6 +3503,30 @@ export const EnumValueOptions = { return message; }, + fromJSON(object: any): EnumValueOptions { + return { + deprecated: isSet(object.deprecated) ? Boolean(object.deprecated) : false, + uninterpretedOption: Array.isArray(object?.uninterpretedOption) + ? object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): EnumValueOptions { const message = createBaseEnumValueOptions(); message.deprecated = object.deprecated ?? false; @@ -2958,6 +3582,30 @@ export const ServiceOptions = { return message; }, + fromJSON(object: any): ServiceOptions { + return { + deprecated: isSet(object.deprecated) ? Boolean(object.deprecated) : false, + uninterpretedOption: Array.isArray(object?.uninterpretedOption) + ? object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): ServiceOptions { const message = createBaseServiceOptions(); message.deprecated = object.deprecated ?? false; @@ -3022,6 +3670,35 @@ export const MethodOptions = { return message; }, + fromJSON(object: any): MethodOptions { + return { + deprecated: isSet(object.deprecated) ? Boolean(object.deprecated) : false, + idempotencyLevel: isSet(object.idempotencyLevel) + ? methodOptions_IdempotencyLevelFromJSON(object.idempotencyLevel) + : 0, + uninterpretedOption: Array.isArray(object?.uninterpretedOption) + ? object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): MethodOptions { const message = createBaseMethodOptions(); message.deprecated = object.deprecated ?? false; @@ -3123,6 +3800,43 @@ export const UninterpretedOption = { return message; }, + fromJSON(object: any): UninterpretedOption { + return { + name: Array.isArray(object?.name) + ? object.name.map((e: any) => UninterpretedOption_NamePart.fromJSON(e)) + : [], + identifierValue: isSet(object.identifierValue) ? String(object.identifierValue) : "", + positiveIntValue: isSet(object.positiveIntValue) ? Long.fromValue(object.positiveIntValue) : Long.UZERO, + negativeIntValue: isSet(object.negativeIntValue) ? Long.fromValue(object.negativeIntValue) : Long.ZERO, + doubleValue: isSet(object.doubleValue) ? Number(object.doubleValue) : 0, + stringValue: isSet(object.stringValue) ? bytesFromBase64(object.stringValue) : new Uint8Array(), + aggregateValue: isSet(object.aggregateValue) ? String(object.aggregateValue) : "", + }; + }, + + 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, I>>(object: I): UninterpretedOption { const message = createBaseUninterpretedOption(); message.name = object.name?.map((e) => UninterpretedOption_NamePart.fromPartial(e)) || []; @@ -3188,6 +3902,20 @@ export const UninterpretedOption_NamePart = { return message; }, + fromJSON(object: any): UninterpretedOption_NamePart { + return { + namePart: isSet(object.namePart) ? String(object.namePart) : "", + isExtension: isSet(object.isExtension) ? Boolean(object.isExtension) : false, + }; + }, + + 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, I>>( object: I, ): UninterpretedOption_NamePart { @@ -3235,6 +3963,26 @@ export const SourceCodeInfo = { return message; }, + fromJSON(object: any): SourceCodeInfo { + return { + location: Array.isArray(object?.location) + ? object.location.map((e: any) => SourceCodeInfo_Location.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): SourceCodeInfo { const message = createBaseSourceCodeInfo(); message.location = object.location?.map((e) => SourceCodeInfo_Location.fromPartial(e)) || []; @@ -3340,6 +4088,45 @@ export const SourceCodeInfo_Location = { return message; }, + fromJSON(object: any): SourceCodeInfo_Location { + return { + path: Array.isArray(object?.path) ? object.path.map((e: any) => Number(e)) : [], + span: Array.isArray(object?.span) ? object.span.map((e: any) => Number(e)) : [], + leadingComments: isSet(object.leadingComments) ? String(object.leadingComments) : "", + trailingComments: isSet(object.trailingComments) ? String(object.trailingComments) : "", + leadingDetachedComments: Array.isArray(object?.leadingDetachedComments) + ? object.leadingDetachedComments.map((e: any) => String(e)) + : [], + }; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + + if (message.path) { + obj.path = message.path.map((e) => Math.round(e)); + } else { + obj.path = []; + } + + if (message.span) { + obj.span = message.span.map((e) => Math.round(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, I>>(object: I): SourceCodeInfo_Location { const message = createBaseSourceCodeInfo_Location(); message.path = object.path?.map((e) => e) || []; @@ -3388,6 +4175,28 @@ export const GeneratedCodeInfo = { return message; }, + fromJSON(object: any): GeneratedCodeInfo { + return { + annotation: Array.isArray(object?.annotation) + ? object.annotation.map((e: any) => GeneratedCodeInfo_Annotation.fromJSON(e)) + : [], + }; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined, + ); + } else { + obj.annotation = []; + } + + return obj; + }, + fromPartial, I>>(object: I): GeneratedCodeInfo { const message = createBaseGeneratedCodeInfo(); message.annotation = object.annotation?.map((e) => GeneratedCodeInfo_Annotation.fromPartial(e)) || []; @@ -3472,6 +4281,30 @@ export const GeneratedCodeInfo_Annotation = { return message; }, + fromJSON(object: any): GeneratedCodeInfo_Annotation { + return { + path: Array.isArray(object?.path) ? object.path.map((e: any) => Number(e)) : [], + sourceFile: isSet(object.sourceFile) ? String(object.sourceFile) : "", + begin: isSet(object.begin) ? Number(object.begin) : 0, + end: isSet(object.end) ? Number(object.end) : 0, + }; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + + if (message.path) { + obj.path = message.path.map((e) => Math.round(e)); + } else { + obj.path = []; + } + + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = Math.round(message.begin)); + message.end !== undefined && (obj.end = Math.round(message.end)); + return obj; + }, + fromPartial, I>>( object: I, ): GeneratedCodeInfo_Annotation { diff --git a/src/google/protobuf/duration.ts b/src/google/protobuf/duration.ts index 205969e7..d15263cb 100644 --- a/src/google/protobuf/duration.ts +++ b/src/google/protobuf/duration.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -import { Long, DeepPartial, Exact } from "../../helpers"; +import { Long, isSet, DeepPartial, Exact } from "../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "google.protobuf"; /** @@ -128,6 +128,20 @@ export const Duration = { return message; }, + fromJSON(object: any): Duration { + return { + seconds: isSet(object.seconds) ? Long.fromValue(object.seconds) : Long.ZERO, + nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + }; + }, + + toJSON(message: Duration): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = (message.seconds || Long.ZERO).toString()); + message.nanos !== undefined && (obj.nanos = Math.round(message.nanos)); + return obj; + }, + fromPartial, I>>(object: I): Duration { const message = createBaseDuration(); message.seconds = diff --git a/src/google/protobuf/timestamp.ts b/src/google/protobuf/timestamp.ts index 05afa8b6..722153cb 100644 --- a/src/google/protobuf/timestamp.ts +++ b/src/google/protobuf/timestamp.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -import { Long, DeepPartial, Exact } from "../../helpers"; +import { Long, isSet, DeepPartial, Exact } from "../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "google.protobuf"; /** @@ -150,6 +150,20 @@ export const Timestamp = { return message; }, + fromJSON(object: any): Timestamp { + return { + seconds: isSet(object.seconds) ? Long.fromValue(object.seconds) : Long.ZERO, + nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + }; + }, + + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = (message.seconds || Long.ZERO).toString()); + message.nanos !== undefined && (obj.nanos = Math.round(message.nanos)); + return obj; + }, + fromPartial, I>>(object: I): Timestamp { const message = createBaseTimestamp(); message.seconds = diff --git a/src/ibc/applications/interchain_accounts/controller/v1/controller.ts b/src/ibc/applications/interchain_accounts/controller/v1/controller.ts index d993e650..d249eec5 100644 --- a/src/ibc/applications/interchain_accounts/controller/v1/controller.ts +++ b/src/ibc/applications/interchain_accounts/controller/v1/controller.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../../../helpers"; export const protobufPackage = "ibc.applications.interchain_accounts.controller.v1"; /** * Params defines the set of on-chain interchain accounts parameters. @@ -49,6 +49,18 @@ export const Params = { return message; }, + fromJSON(object: any): Params { + return { + controllerEnabled: isSet(object.controllerEnabled) ? Boolean(object.controllerEnabled) : false, + }; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.controllerEnabled !== undefined && (obj.controllerEnabled = message.controllerEnabled); + return obj; + }, + fromPartial, I>>(object: I): Params { const message = createBaseParams(); message.controllerEnabled = object.controllerEnabled ?? false; diff --git a/src/ibc/applications/interchain_accounts/controller/v1/query.ts b/src/ibc/applications/interchain_accounts/controller/v1/query.ts index 17f2e45d..a3dad9eb 100644 --- a/src/ibc/applications/interchain_accounts/controller/v1/query.ts +++ b/src/ibc/applications/interchain_accounts/controller/v1/query.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Params } from "./controller"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../../../helpers"; +import { DeepPartial, Exact, isSet, Rpc } from "../../../../../helpers"; export const protobufPackage = "ibc.applications.interchain_accounts.controller.v1"; /** QueryParamsRequest is the request type for the Query/Params RPC method. */ @@ -40,6 +40,15 @@ export const QueryParamsRequest = { return message; }, + fromJSON(_: any): QueryParamsRequest { + return {}; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryParamsRequest { const message = createBaseQueryParamsRequest(); return message; @@ -83,6 +92,18 @@ export const QueryParamsResponse = { return message; }, + fromJSON(object: any): QueryParamsResponse { + return { + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + }; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryParamsResponse { const message = createBaseQueryParamsResponse(); message.params = diff --git a/src/ibc/applications/interchain_accounts/host/v1/host.ts b/src/ibc/applications/interchain_accounts/host/v1/host.ts index d1aafa3b..7061c3b4 100644 --- a/src/ibc/applications/interchain_accounts/host/v1/host.ts +++ b/src/ibc/applications/interchain_accounts/host/v1/host.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../../../helpers"; export const protobufPackage = "ibc.applications.interchain_accounts.host.v1"; /** * Params defines the set of on-chain interchain accounts parameters. @@ -61,6 +61,28 @@ export const Params = { return message; }, + fromJSON(object: any): Params { + return { + hostEnabled: isSet(object.hostEnabled) ? Boolean(object.hostEnabled) : false, + allowMessages: Array.isArray(object?.allowMessages) + ? object.allowMessages.map((e: any) => String(e)) + : [], + }; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.hostEnabled !== undefined && (obj.hostEnabled = message.hostEnabled); + + if (message.allowMessages) { + obj.allowMessages = message.allowMessages.map((e) => e); + } else { + obj.allowMessages = []; + } + + return obj; + }, + fromPartial, I>>(object: I): Params { const message = createBaseParams(); message.hostEnabled = object.hostEnabled ?? false; diff --git a/src/ibc/applications/interchain_accounts/host/v1/query.ts b/src/ibc/applications/interchain_accounts/host/v1/query.ts index c26c21f4..4ef51112 100644 --- a/src/ibc/applications/interchain_accounts/host/v1/query.ts +++ b/src/ibc/applications/interchain_accounts/host/v1/query.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Params } from "./host"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../../../helpers"; +import { DeepPartial, Exact, isSet, Rpc } from "../../../../../helpers"; export const protobufPackage = "ibc.applications.interchain_accounts.host.v1"; /** QueryParamsRequest is the request type for the Query/Params RPC method. */ @@ -40,6 +40,15 @@ export const QueryParamsRequest = { return message; }, + fromJSON(_: any): QueryParamsRequest { + return {}; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryParamsRequest { const message = createBaseQueryParamsRequest(); return message; @@ -83,6 +92,18 @@ export const QueryParamsResponse = { return message; }, + fromJSON(object: any): QueryParamsResponse { + return { + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + }; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryParamsResponse { const message = createBaseQueryParamsResponse(); message.params = diff --git a/src/ibc/applications/interchain_accounts/v1/account.ts b/src/ibc/applications/interchain_accounts/v1/account.ts index c5849d75..ecc4f4b8 100644 --- a/src/ibc/applications/interchain_accounts/v1/account.ts +++ b/src/ibc/applications/interchain_accounts/v1/account.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { BaseAccount } from "../../../../cosmos/auth/v1beta1/auth"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../../helpers"; export const protobufPackage = "ibc.applications.interchain_accounts.v1"; /** An InterchainAccount is defined as a BaseAccount & the address of the account owner on the controller chain */ @@ -56,6 +56,21 @@ export const InterchainAccount = { return message; }, + fromJSON(object: any): InterchainAccount { + return { + baseAccount: isSet(object.baseAccount) ? BaseAccount.fromJSON(object.baseAccount) : undefined, + accountOwner: isSet(object.accountOwner) ? String(object.accountOwner) : "", + }; + }, + + toJSON(message: InterchainAccount): unknown { + const obj: any = {}; + message.baseAccount !== undefined && + (obj.baseAccount = message.baseAccount ? BaseAccount.toJSON(message.baseAccount) : undefined); + message.accountOwner !== undefined && (obj.accountOwner = message.accountOwner); + return obj; + }, + fromPartial, I>>(object: I): InterchainAccount { const message = createBaseInterchainAccount(); message.baseAccount = diff --git a/src/ibc/applications/interchain_accounts/v1/genesis.ts b/src/ibc/applications/interchain_accounts/v1/genesis.ts index 4cef419c..4ba61838 100644 --- a/src/ibc/applications/interchain_accounts/v1/genesis.ts +++ b/src/ibc/applications/interchain_accounts/v1/genesis.ts @@ -2,7 +2,7 @@ import { Params as Params1 } from "../controller/v1/controller"; import { Params as Params2 } from "../host/v1/host"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../../helpers"; export const protobufPackage = "ibc.applications.interchain_accounts.v1"; /** GenesisState defines the interchain accounts genesis state */ @@ -87,6 +87,30 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + controllerGenesisState: isSet(object.controllerGenesisState) + ? ControllerGenesisState.fromJSON(object.controllerGenesisState) + : undefined, + hostGenesisState: isSet(object.hostGenesisState) + ? HostGenesisState.fromJSON(object.hostGenesisState) + : undefined, + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.controllerGenesisState !== undefined && + (obj.controllerGenesisState = message.controllerGenesisState + ? ControllerGenesisState.toJSON(message.controllerGenesisState) + : undefined); + message.hostGenesisState !== undefined && + (obj.hostGenesisState = message.hostGenesisState + ? HostGenesisState.toJSON(message.hostGenesisState) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.controllerGenesisState = @@ -165,6 +189,47 @@ export const ControllerGenesisState = { return message; }, + fromJSON(object: any): ControllerGenesisState { + return { + activeChannels: Array.isArray(object?.activeChannels) + ? object.activeChannels.map((e: any) => ActiveChannel.fromJSON(e)) + : [], + interchainAccounts: Array.isArray(object?.interchainAccounts) + ? object.interchainAccounts.map((e: any) => RegisteredInterchainAccount.fromJSON(e)) + : [], + ports: Array.isArray(object?.ports) ? object.ports.map((e: any) => String(e)) : [], + params: isSet(object.params) ? Params1.fromJSON(object.params) : undefined, + }; + }, + + toJSON(message: ControllerGenesisState): unknown { + const obj: any = {}; + + if (message.activeChannels) { + obj.activeChannels = message.activeChannels.map((e) => (e ? ActiveChannel.toJSON(e) : undefined)); + } else { + obj.activeChannels = []; + } + + if (message.interchainAccounts) { + obj.interchainAccounts = message.interchainAccounts.map((e) => + e ? RegisteredInterchainAccount.toJSON(e) : undefined, + ); + } else { + obj.interchainAccounts = []; + } + + if (message.ports) { + obj.ports = message.ports.map((e) => e); + } else { + obj.ports = []; + } + + message.params !== undefined && + (obj.params = message.params ? Params1.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): ControllerGenesisState { const message = createBaseControllerGenesisState(); message.activeChannels = object.activeChannels?.map((e) => ActiveChannel.fromPartial(e)) || []; @@ -241,6 +306,42 @@ export const HostGenesisState = { return message; }, + fromJSON(object: any): HostGenesisState { + return { + activeChannels: Array.isArray(object?.activeChannels) + ? object.activeChannels.map((e: any) => ActiveChannel.fromJSON(e)) + : [], + interchainAccounts: Array.isArray(object?.interchainAccounts) + ? object.interchainAccounts.map((e: any) => RegisteredInterchainAccount.fromJSON(e)) + : [], + port: isSet(object.port) ? String(object.port) : "", + params: isSet(object.params) ? Params2.fromJSON(object.params) : undefined, + }; + }, + + toJSON(message: HostGenesisState): unknown { + const obj: any = {}; + + if (message.activeChannels) { + obj.activeChannels = message.activeChannels.map((e) => (e ? ActiveChannel.toJSON(e) : undefined)); + } else { + obj.activeChannels = []; + } + + if (message.interchainAccounts) { + obj.interchainAccounts = message.interchainAccounts.map((e) => + e ? RegisteredInterchainAccount.toJSON(e) : undefined, + ); + } else { + obj.interchainAccounts = []; + } + + message.port !== undefined && (obj.port = message.port); + message.params !== undefined && + (obj.params = message.params ? Params2.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): HostGenesisState { const message = createBaseHostGenesisState(); message.activeChannels = object.activeChannels?.map((e) => ActiveChannel.fromPartial(e)) || []; @@ -308,6 +409,22 @@ export const ActiveChannel = { return message; }, + fromJSON(object: any): ActiveChannel { + return { + connectionId: isSet(object.connectionId) ? String(object.connectionId) : "", + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + }; + }, + + toJSON(message: ActiveChannel): unknown { + const obj: any = {}; + message.connectionId !== undefined && (obj.connectionId = message.connectionId); + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + fromPartial, I>>(object: I): ActiveChannel { const message = createBaseActiveChannel(); message.connectionId = object.connectionId ?? ""; @@ -372,6 +489,22 @@ export const RegisteredInterchainAccount = { return message; }, + fromJSON(object: any): RegisteredInterchainAccount { + return { + connectionId: isSet(object.connectionId) ? String(object.connectionId) : "", + portId: isSet(object.portId) ? String(object.portId) : "", + accountAddress: isSet(object.accountAddress) ? String(object.accountAddress) : "", + }; + }, + + toJSON(message: RegisteredInterchainAccount): unknown { + const obj: any = {}; + message.connectionId !== undefined && (obj.connectionId = message.connectionId); + message.portId !== undefined && (obj.portId = message.portId); + message.accountAddress !== undefined && (obj.accountAddress = message.accountAddress); + return obj; + }, + fromPartial, I>>( object: I, ): RegisteredInterchainAccount { diff --git a/src/ibc/applications/interchain_accounts/v1/metadata.ts b/src/ibc/applications/interchain_accounts/v1/metadata.ts index ec1ffe52..f4b5d1d2 100644 --- a/src/ibc/applications/interchain_accounts/v1/metadata.ts +++ b/src/ibc/applications/interchain_accounts/v1/metadata.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../../helpers"; export const protobufPackage = "ibc.applications.interchain_accounts.v1"; /** * Metadata defines a set of protocol specific data encoded into the ICS27 channel version bytestring @@ -112,6 +112,31 @@ export const Metadata = { return message; }, + fromJSON(object: any): Metadata { + return { + version: isSet(object.version) ? String(object.version) : "", + controllerConnectionId: isSet(object.controllerConnectionId) + ? String(object.controllerConnectionId) + : "", + hostConnectionId: isSet(object.hostConnectionId) ? String(object.hostConnectionId) : "", + address: isSet(object.address) ? String(object.address) : "", + encoding: isSet(object.encoding) ? String(object.encoding) : "", + txType: isSet(object.txType) ? String(object.txType) : "", + }; + }, + + toJSON(message: Metadata): unknown { + const obj: any = {}; + message.version !== undefined && (obj.version = message.version); + message.controllerConnectionId !== undefined && + (obj.controllerConnectionId = message.controllerConnectionId); + message.hostConnectionId !== undefined && (obj.hostConnectionId = message.hostConnectionId); + message.address !== undefined && (obj.address = message.address); + message.encoding !== undefined && (obj.encoding = message.encoding); + message.txType !== undefined && (obj.txType = message.txType); + return obj; + }, + fromPartial, I>>(object: I): Metadata { const message = createBaseMetadata(); message.version = object.version ?? ""; diff --git a/src/ibc/applications/interchain_accounts/v1/packet.ts b/src/ibc/applications/interchain_accounts/v1/packet.ts index 5a5d33a8..75baf7d0 100644 --- a/src/ibc/applications/interchain_accounts/v1/packet.ts +++ b/src/ibc/applications/interchain_accounts/v1/packet.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Any } from "../../../../google/protobuf/any"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../../helpers"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact } from "../../../../helpers"; export const protobufPackage = "ibc.applications.interchain_accounts.v1"; /** * Type defines a classification of message issued from a controller chain to its associated interchain accounts @@ -113,6 +113,23 @@ export const InterchainAccountPacketData = { return message; }, + fromJSON(object: any): InterchainAccountPacketData { + return { + type: isSet(object.type) ? typeFromJSON(object.type) : 0, + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + memo: isSet(object.memo) ? String(object.memo) : "", + }; + }, + + toJSON(message: InterchainAccountPacketData): unknown { + const obj: any = {}; + message.type !== undefined && (obj.type = typeToJSON(message.type)); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + message.memo !== undefined && (obj.memo = message.memo); + return obj; + }, + fromPartial, I>>( object: I, ): InterchainAccountPacketData { @@ -161,6 +178,24 @@ export const CosmosTx = { return message; }, + fromJSON(object: any): CosmosTx { + return { + messages: Array.isArray(object?.messages) ? object.messages.map((e: any) => Any.fromJSON(e)) : [], + }; + }, + + toJSON(message: CosmosTx): unknown { + const obj: any = {}; + + if (message.messages) { + obj.messages = message.messages.map((e) => (e ? Any.toJSON(e) : undefined)); + } else { + obj.messages = []; + } + + return obj; + }, + fromPartial, I>>(object: I): CosmosTx { const message = createBaseCosmosTx(); message.messages = object.messages?.map((e) => Any.fromPartial(e)) || []; diff --git a/src/ibc/applications/transfer/v1/genesis.ts b/src/ibc/applications/transfer/v1/genesis.ts index 7d9967e2..40ba8a05 100644 --- a/src/ibc/applications/transfer/v1/genesis.ts +++ b/src/ibc/applications/transfer/v1/genesis.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { DenomTrace, Params } from "./transfer"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../../helpers"; export const protobufPackage = "ibc.applications.transfer.v1"; /** GenesisState defines the ibc-transfer genesis state */ @@ -66,6 +66,30 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + denomTraces: Array.isArray(object?.denomTraces) + ? object.denomTraces.map((e: any) => DenomTrace.fromJSON(e)) + : [], + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + + if (message.denomTraces) { + obj.denomTraces = message.denomTraces.map((e) => (e ? DenomTrace.toJSON(e) : undefined)); + } else { + obj.denomTraces = []; + } + + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.portId = object.portId ?? ""; diff --git a/src/ibc/applications/transfer/v1/query.ts b/src/ibc/applications/transfer/v1/query.ts index b920528c..fcc31edd 100644 --- a/src/ibc/applications/transfer/v1/query.ts +++ b/src/ibc/applications/transfer/v1/query.ts @@ -2,7 +2,7 @@ import { PageRequest, PageResponse } from "../../../../cosmos/base/query/v1beta1/pagination"; import { DenomTrace, Params } from "./transfer"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../../helpers"; +import { isSet, DeepPartial, Exact, Rpc } from "../../../../helpers"; export const protobufPackage = "ibc.applications.transfer.v1"; /** * QueryDenomTraceRequest is the request type for the Query/DenomTrace RPC @@ -108,6 +108,18 @@ export const QueryDenomTraceRequest = { return message; }, + fromJSON(object: any): QueryDenomTraceRequest { + return { + hash: isSet(object.hash) ? String(object.hash) : "", + }; + }, + + toJSON(message: QueryDenomTraceRequest): unknown { + const obj: any = {}; + message.hash !== undefined && (obj.hash = message.hash); + return obj; + }, + fromPartial, I>>(object: I): QueryDenomTraceRequest { const message = createBaseQueryDenomTraceRequest(); message.hash = object.hash ?? ""; @@ -152,6 +164,19 @@ export const QueryDenomTraceResponse = { return message; }, + fromJSON(object: any): QueryDenomTraceResponse { + return { + denomTrace: isSet(object.denomTrace) ? DenomTrace.fromJSON(object.denomTrace) : undefined, + }; + }, + + toJSON(message: QueryDenomTraceResponse): unknown { + const obj: any = {}; + message.denomTrace !== undefined && + (obj.denomTrace = message.denomTrace ? DenomTrace.toJSON(message.denomTrace) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryDenomTraceResponse { const message = createBaseQueryDenomTraceResponse(); message.denomTrace = @@ -199,6 +224,19 @@ export const QueryDenomTracesRequest = { return message; }, + fromJSON(object: any): QueryDenomTracesRequest { + return { + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryDenomTracesRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryDenomTracesRequest { const message = createBaseQueryDenomTracesRequest(); message.pagination = @@ -255,6 +293,29 @@ export const QueryDenomTracesResponse = { return message; }, + fromJSON(object: any): QueryDenomTracesResponse { + return { + denomTraces: Array.isArray(object?.denomTraces) + ? object.denomTraces.map((e: any) => DenomTrace.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryDenomTracesResponse): unknown { + const obj: any = {}; + + if (message.denomTraces) { + obj.denomTraces = message.denomTraces.map((e) => (e ? DenomTrace.toJSON(e) : undefined)); + } else { + obj.denomTraces = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryDenomTracesResponse { @@ -295,6 +356,15 @@ export const QueryParamsRequest = { return message; }, + fromJSON(_: any): QueryParamsRequest { + return {}; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryParamsRequest { const message = createBaseQueryParamsRequest(); return message; @@ -338,6 +408,18 @@ export const QueryParamsResponse = { return message; }, + fromJSON(object: any): QueryParamsResponse { + return { + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + }; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryParamsResponse { const message = createBaseQueryParamsResponse(); message.params = @@ -383,6 +465,18 @@ export const QueryDenomHashRequest = { return message; }, + fromJSON(object: any): QueryDenomHashRequest { + return { + trace: isSet(object.trace) ? String(object.trace) : "", + }; + }, + + toJSON(message: QueryDenomHashRequest): unknown { + const obj: any = {}; + message.trace !== undefined && (obj.trace = message.trace); + return obj; + }, + fromPartial, I>>(object: I): QueryDenomHashRequest { const message = createBaseQueryDenomHashRequest(); message.trace = object.trace ?? ""; @@ -427,6 +521,18 @@ export const QueryDenomHashResponse = { return message; }, + fromJSON(object: any): QueryDenomHashResponse { + return { + hash: isSet(object.hash) ? String(object.hash) : "", + }; + }, + + toJSON(message: QueryDenomHashResponse): unknown { + const obj: any = {}; + message.hash !== undefined && (obj.hash = message.hash); + return obj; + }, + fromPartial, I>>(object: I): QueryDenomHashResponse { const message = createBaseQueryDenomHashResponse(); message.hash = object.hash ?? ""; diff --git a/src/ibc/applications/transfer/v1/transfer.ts b/src/ibc/applications/transfer/v1/transfer.ts index 6c8958ea..b6ef5e45 100644 --- a/src/ibc/applications/transfer/v1/transfer.ts +++ b/src/ibc/applications/transfer/v1/transfer.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../../helpers"; export const protobufPackage = "ibc.applications.transfer.v1"; /** * DenomTrace contains the base denomination for ICS20 fungible tokens and the @@ -84,6 +84,20 @@ export const DenomTrace = { return message; }, + fromJSON(object: any): DenomTrace { + return { + path: isSet(object.path) ? String(object.path) : "", + baseDenom: isSet(object.baseDenom) ? String(object.baseDenom) : "", + }; + }, + + toJSON(message: DenomTrace): unknown { + const obj: any = {}; + message.path !== undefined && (obj.path = message.path); + message.baseDenom !== undefined && (obj.baseDenom = message.baseDenom); + return obj; + }, + fromPartial, I>>(object: I): DenomTrace { const message = createBaseDenomTrace(); message.path = object.path ?? ""; @@ -138,6 +152,20 @@ export const Params = { return message; }, + fromJSON(object: any): Params { + return { + sendEnabled: isSet(object.sendEnabled) ? Boolean(object.sendEnabled) : false, + receiveEnabled: isSet(object.receiveEnabled) ? Boolean(object.receiveEnabled) : false, + }; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.sendEnabled !== undefined && (obj.sendEnabled = message.sendEnabled); + message.receiveEnabled !== undefined && (obj.receiveEnabled = message.receiveEnabled); + return obj; + }, + fromPartial, I>>(object: I): Params { const message = createBaseParams(); message.sendEnabled = object.sendEnabled ?? false; diff --git a/src/ibc/applications/transfer/v1/tx.ts b/src/ibc/applications/transfer/v1/tx.ts index 168652f6..21e6461a 100644 --- a/src/ibc/applications/transfer/v1/tx.ts +++ b/src/ibc/applications/transfer/v1/tx.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Coin } from "../../../../cosmos/base/v1beta1/coin"; import { Height } from "../../../core/client/v1/client"; -import { Long, DeepPartial, Exact, Rpc } from "../../../../helpers"; +import { Long, isSet, DeepPartial, Exact, Rpc } from "../../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "ibc.applications.transfer.v1"; /** @@ -133,6 +133,32 @@ export const MsgTransfer = { return message; }, + fromJSON(object: any): MsgTransfer { + return { + sourcePort: isSet(object.sourcePort) ? String(object.sourcePort) : "", + sourceChannel: isSet(object.sourceChannel) ? String(object.sourceChannel) : "", + token: isSet(object.token) ? Coin.fromJSON(object.token) : undefined, + sender: isSet(object.sender) ? String(object.sender) : "", + receiver: isSet(object.receiver) ? String(object.receiver) : "", + timeoutHeight: isSet(object.timeoutHeight) ? Height.fromJSON(object.timeoutHeight) : undefined, + timeoutTimestamp: isSet(object.timeoutTimestamp) ? Long.fromValue(object.timeoutTimestamp) : Long.UZERO, + }; + }, + + toJSON(message: MsgTransfer): unknown { + const obj: any = {}; + message.sourcePort !== undefined && (obj.sourcePort = message.sourcePort); + message.sourceChannel !== undefined && (obj.sourceChannel = message.sourceChannel); + message.token !== undefined && (obj.token = message.token ? Coin.toJSON(message.token) : undefined); + message.sender !== undefined && (obj.sender = message.sender); + message.receiver !== undefined && (obj.receiver = message.receiver); + 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, I>>(object: I): MsgTransfer { const message = createBaseMsgTransfer(); message.sourcePort = object.sourcePort ?? ""; @@ -180,6 +206,15 @@ export const MsgTransferResponse = { return message; }, + fromJSON(_: any): MsgTransferResponse { + return {}; + }, + + toJSON(_: MsgTransferResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgTransferResponse { const message = createBaseMsgTransferResponse(); return message; diff --git a/src/ibc/applications/transfer/v2/packet.ts b/src/ibc/applications/transfer/v2/packet.ts index 5a162ab1..7d27d7e2 100644 --- a/src/ibc/applications/transfer/v2/packet.ts +++ b/src/ibc/applications/transfer/v2/packet.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../../helpers"; export const protobufPackage = "ibc.applications.transfer.v2"; /** * FungibleTokenPacketData defines a struct for the packet payload @@ -86,6 +86,24 @@ export const FungibleTokenPacketData = { return message; }, + fromJSON(object: any): FungibleTokenPacketData { + return { + denom: isSet(object.denom) ? String(object.denom) : "", + amount: isSet(object.amount) ? String(object.amount) : "", + sender: isSet(object.sender) ? String(object.sender) : "", + receiver: isSet(object.receiver) ? String(object.receiver) : "", + }; + }, + + toJSON(message: FungibleTokenPacketData): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + message.sender !== undefined && (obj.sender = message.sender); + message.receiver !== undefined && (obj.receiver = message.receiver); + return obj; + }, + fromPartial, I>>(object: I): FungibleTokenPacketData { const message = createBaseFungibleTokenPacketData(); message.denom = object.denom ?? ""; diff --git a/src/ibc/core/channel/v1/channel.ts b/src/ibc/core/channel/v1/channel.ts index 4cd4bff4..bd7ae4df 100644 --- a/src/ibc/core/channel/v1/channel.ts +++ b/src/ibc/core/channel/v1/channel.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Height } from "../../client/v1/client"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../../../helpers"; +import { isSet, DeepPartial, Exact, Long, bytesFromBase64, base64FromBytes } from "../../../../helpers"; export const protobufPackage = "ibc.core.channel.v1"; /** * State defines if a channel is in one of the following states: @@ -336,6 +336,35 @@ export const Channel = { return message; }, + fromJSON(object: any): Channel { + return { + state: isSet(object.state) ? stateFromJSON(object.state) : 0, + ordering: isSet(object.ordering) ? orderFromJSON(object.ordering) : 0, + counterparty: isSet(object.counterparty) ? Counterparty.fromJSON(object.counterparty) : undefined, + connectionHops: Array.isArray(object?.connectionHops) + ? object.connectionHops.map((e: any) => String(e)) + : [], + version: isSet(object.version) ? String(object.version) : "", + }; + }, + + 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, I>>(object: I): Channel { const message = createBaseChannel(); message.state = object.state ?? 0; @@ -441,6 +470,39 @@ export const IdentifiedChannel = { return message; }, + fromJSON(object: any): IdentifiedChannel { + return { + state: isSet(object.state) ? stateFromJSON(object.state) : 0, + ordering: isSet(object.ordering) ? orderFromJSON(object.ordering) : 0, + counterparty: isSet(object.counterparty) ? Counterparty.fromJSON(object.counterparty) : undefined, + connectionHops: Array.isArray(object?.connectionHops) + ? object.connectionHops.map((e: any) => String(e)) + : [], + version: isSet(object.version) ? String(object.version) : "", + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + }; + }, + + 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, I>>(object: I): IdentifiedChannel { const message = createBaseIdentifiedChannel(); message.state = object.state ?? 0; @@ -503,6 +565,20 @@ export const Counterparty = { return message; }, + fromJSON(object: any): Counterparty { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + }; + }, + + toJSON(message: Counterparty): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + fromPartial, I>>(object: I): Counterparty { const message = createBaseCounterparty(); message.portId = object.portId ?? ""; @@ -611,6 +687,35 @@ export const Packet = { return message; }, + fromJSON(object: any): Packet { + return { + sequence: isSet(object.sequence) ? Long.fromValue(object.sequence) : Long.UZERO, + sourcePort: isSet(object.sourcePort) ? String(object.sourcePort) : "", + sourceChannel: isSet(object.sourceChannel) ? String(object.sourceChannel) : "", + destinationPort: isSet(object.destinationPort) ? String(object.destinationPort) : "", + destinationChannel: isSet(object.destinationChannel) ? String(object.destinationChannel) : "", + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + timeoutHeight: isSet(object.timeoutHeight) ? Height.fromJSON(object.timeoutHeight) : undefined, + timeoutTimestamp: isSet(object.timeoutTimestamp) ? Long.fromValue(object.timeoutTimestamp) : Long.UZERO, + }; + }, + + 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, I>>(object: I): Packet { const message = createBasePacket(); message.sequence = @@ -698,6 +803,25 @@ export const PacketState = { return message; }, + fromJSON(object: any): PacketState { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + sequence: isSet(object.sequence) ? Long.fromValue(object.sequence) : Long.UZERO, + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + }; + }, + + 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, I>>(object: I): PacketState { const message = createBasePacketState(); message.portId = object.portId ?? ""; @@ -757,6 +881,21 @@ export const Acknowledgement = { return message; }, + fromJSON(object: any): Acknowledgement { + return { + result: isSet(object.result) ? bytesFromBase64(object.result) : undefined, + error: isSet(object.error) ? String(object.error) : undefined, + }; + }, + + 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, I>>(object: I): Acknowledgement { const message = createBaseAcknowledgement(); message.result = object.result ?? undefined; diff --git a/src/ibc/core/channel/v1/genesis.ts b/src/ibc/core/channel/v1/genesis.ts index 3ea6c51f..cd9b3a50 100644 --- a/src/ibc/core/channel/v1/genesis.ts +++ b/src/ibc/core/channel/v1/genesis.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import { IdentifiedChannel, PacketState } from "./channel"; -import { Long, DeepPartial, Exact } from "../../../../helpers"; +import { Long, isSet, DeepPartial, Exact } from "../../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "ibc.core.channel.v1"; /** GenesisState defines the ibc channel submodule's genesis state. */ @@ -128,6 +128,85 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + channels: Array.isArray(object?.channels) + ? object.channels.map((e: any) => IdentifiedChannel.fromJSON(e)) + : [], + acknowledgements: Array.isArray(object?.acknowledgements) + ? object.acknowledgements.map((e: any) => PacketState.fromJSON(e)) + : [], + commitments: Array.isArray(object?.commitments) + ? object.commitments.map((e: any) => PacketState.fromJSON(e)) + : [], + receipts: Array.isArray(object?.receipts) + ? object.receipts.map((e: any) => PacketState.fromJSON(e)) + : [], + sendSequences: Array.isArray(object?.sendSequences) + ? object.sendSequences.map((e: any) => PacketSequence.fromJSON(e)) + : [], + recvSequences: Array.isArray(object?.recvSequences) + ? object.recvSequences.map((e: any) => PacketSequence.fromJSON(e)) + : [], + ackSequences: Array.isArray(object?.ackSequences) + ? object.ackSequences.map((e: any) => PacketSequence.fromJSON(e)) + : [], + nextChannelSequence: isSet(object.nextChannelSequence) + ? Long.fromValue(object.nextChannelSequence) + : Long.UZERO, + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + + if (message.channels) { + obj.channels = message.channels.map((e) => (e ? IdentifiedChannel.toJSON(e) : undefined)); + } else { + obj.channels = []; + } + + if (message.acknowledgements) { + obj.acknowledgements = message.acknowledgements.map((e) => (e ? PacketState.toJSON(e) : undefined)); + } else { + obj.acknowledgements = []; + } + + if (message.commitments) { + obj.commitments = message.commitments.map((e) => (e ? PacketState.toJSON(e) : undefined)); + } else { + obj.commitments = []; + } + + if (message.receipts) { + obj.receipts = message.receipts.map((e) => (e ? PacketState.toJSON(e) : undefined)); + } else { + obj.receipts = []; + } + + if (message.sendSequences) { + obj.sendSequences = message.sendSequences.map((e) => (e ? PacketSequence.toJSON(e) : undefined)); + } else { + obj.sendSequences = []; + } + + if (message.recvSequences) { + obj.recvSequences = message.recvSequences.map((e) => (e ? PacketSequence.toJSON(e) : undefined)); + } else { + obj.recvSequences = []; + } + + if (message.ackSequences) { + obj.ackSequences = message.ackSequences.map((e) => (e ? PacketSequence.toJSON(e) : undefined)); + } else { + obj.ackSequences = []; + } + + message.nextChannelSequence !== undefined && + (obj.nextChannelSequence = (message.nextChannelSequence || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.channels = object.channels?.map((e) => IdentifiedChannel.fromPartial(e)) || []; @@ -200,6 +279,22 @@ export const PacketSequence = { return message; }, + fromJSON(object: any): PacketSequence { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + sequence: isSet(object.sequence) ? Long.fromValue(object.sequence) : Long.UZERO, + }; + }, + + toJSON(message: PacketSequence): 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, I>>(object: I): PacketSequence { const message = createBasePacketSequence(); message.portId = object.portId ?? ""; diff --git a/src/ibc/core/channel/v1/query.ts b/src/ibc/core/channel/v1/query.ts index e39fdd0a..26e356d8 100644 --- a/src/ibc/core/channel/v1/query.ts +++ b/src/ibc/core/channel/v1/query.ts @@ -4,7 +4,7 @@ import { Channel, IdentifiedChannel, PacketState } from "./channel"; import { Height, IdentifiedClientState } from "../../client/v1/client"; import { Any } from "../../../../google/protobuf/any"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long, Rpc } from "../../../../helpers"; +import { isSet, DeepPartial, Exact, bytesFromBase64, base64FromBytes, Long, Rpc } from "../../../../helpers"; export const protobufPackage = "ibc.core.channel.v1"; /** QueryChannelRequest is the request type for the Query/Channel RPC method */ @@ -421,6 +421,20 @@ export const QueryChannelRequest = { return message; }, + fromJSON(object: any): QueryChannelRequest { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + }; + }, + + toJSON(message: QueryChannelRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + fromPartial, I>>(object: I): QueryChannelRequest { const message = createBaseQueryChannelRequest(); message.portId = object.portId ?? ""; @@ -484,6 +498,25 @@ export const QueryChannelResponse = { return message; }, + fromJSON(object: any): QueryChannelResponse { + return { + channel: isSet(object.channel) ? Channel.fromJSON(object.channel) : undefined, + proof: isSet(object.proof) ? bytesFromBase64(object.proof) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + }; + }, + + 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, I>>(object: I): QueryChannelResponse { const message = createBaseQueryChannelResponse(); message.channel = @@ -536,6 +569,19 @@ export const QueryChannelsRequest = { return message; }, + fromJSON(object: any): QueryChannelsRequest { + return { + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryChannelsRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryChannelsRequest { const message = createBaseQueryChannelsRequest(); message.pagination = @@ -601,6 +647,31 @@ export const QueryChannelsResponse = { return message; }, + fromJSON(object: any): QueryChannelsResponse { + return { + channels: Array.isArray(object?.channels) + ? object.channels.map((e: any) => IdentifiedChannel.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + height: isSet(object.height) ? Height.fromJSON(object.height) : undefined, + }; + }, + + 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, I>>(object: I): QueryChannelsResponse { const message = createBaseQueryChannelsResponse(); message.channels = object.channels?.map((e) => IdentifiedChannel.fromPartial(e)) || []; @@ -660,6 +731,21 @@ export const QueryConnectionChannelsRequest = { return message; }, + fromJSON(object: any): QueryConnectionChannelsRequest { + return { + connection: isSet(object.connection) ? String(object.connection) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryConnectionChannelsRequest { @@ -728,6 +814,31 @@ export const QueryConnectionChannelsResponse = { return message; }, + fromJSON(object: any): QueryConnectionChannelsResponse { + return { + channels: Array.isArray(object?.channels) + ? object.channels.map((e: any) => IdentifiedChannel.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + height: isSet(object.height) ? Height.fromJSON(object.height) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryConnectionChannelsResponse { @@ -789,6 +900,20 @@ export const QueryChannelClientStateRequest = { return message; }, + fromJSON(object: any): QueryChannelClientStateRequest { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + }; + }, + + toJSON(message: QueryChannelClientStateRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + fromPartial, I>>( object: I, ): QueryChannelClientStateRequest { @@ -854,6 +979,29 @@ export const QueryChannelClientStateResponse = { return message; }, + fromJSON(object: any): QueryChannelClientStateResponse { + return { + identifiedClientState: isSet(object.identifiedClientState) + ? IdentifiedClientState.fromJSON(object.identifiedClientState) + : undefined, + proof: isSet(object.proof) ? bytesFromBase64(object.proof) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryChannelClientStateResponse { @@ -935,6 +1083,26 @@ export const QueryChannelConsensusStateRequest = { return message; }, + fromJSON(object: any): QueryChannelConsensusStateRequest { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + revisionNumber: isSet(object.revisionNumber) ? Long.fromValue(object.revisionNumber) : Long.UZERO, + revisionHeight: isSet(object.revisionHeight) ? Long.fromValue(object.revisionHeight) : Long.UZERO, + }; + }, + + 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, I>>( object: I, ): QueryChannelConsensusStateRequest { @@ -1017,6 +1185,27 @@ export const QueryChannelConsensusStateResponse = { return message; }, + fromJSON(object: any): QueryChannelConsensusStateResponse { + return { + consensusState: isSet(object.consensusState) ? Any.fromJSON(object.consensusState) : undefined, + clientId: isSet(object.clientId) ? String(object.clientId) : "", + proof: isSet(object.proof) ? bytesFromBase64(object.proof) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryChannelConsensusStateResponse { @@ -1090,6 +1279,22 @@ export const QueryPacketCommitmentRequest = { return message; }, + fromJSON(object: any): QueryPacketCommitmentRequest { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + sequence: isSet(object.sequence) ? Long.fromValue(object.sequence) : Long.UZERO, + }; + }, + + 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, I>>( object: I, ): QueryPacketCommitmentRequest { @@ -1159,6 +1364,27 @@ export const QueryPacketCommitmentResponse = { return message; }, + fromJSON(object: any): QueryPacketCommitmentResponse { + return { + commitment: isSet(object.commitment) ? bytesFromBase64(object.commitment) : new Uint8Array(), + proof: isSet(object.proof) ? bytesFromBase64(object.proof) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryPacketCommitmentResponse { @@ -1228,6 +1454,23 @@ export const QueryPacketCommitmentsRequest = { return message; }, + fromJSON(object: any): QueryPacketCommitmentsRequest { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryPacketCommitmentsRequest { @@ -1297,6 +1540,31 @@ export const QueryPacketCommitmentsResponse = { return message; }, + fromJSON(object: any): QueryPacketCommitmentsResponse { + return { + commitments: Array.isArray(object?.commitments) + ? object.commitments.map((e: any) => PacketState.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + height: isSet(object.height) ? Height.fromJSON(object.height) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryPacketCommitmentsResponse { @@ -1367,6 +1635,22 @@ export const QueryPacketReceiptRequest = { return message; }, + fromJSON(object: any): QueryPacketReceiptRequest { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + sequence: isSet(object.sequence) ? Long.fromValue(object.sequence) : Long.UZERO, + }; + }, + + 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, I>>( object: I, ): QueryPacketReceiptRequest { @@ -1436,6 +1720,24 @@ export const QueryPacketReceiptResponse = { return message; }, + fromJSON(object: any): QueryPacketReceiptResponse { + return { + received: isSet(object.received) ? Boolean(object.received) : false, + proof: isSet(object.proof) ? bytesFromBase64(object.proof) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryPacketReceiptResponse { @@ -1505,6 +1807,22 @@ export const QueryPacketAcknowledgementRequest = { return message; }, + fromJSON(object: any): QueryPacketAcknowledgementRequest { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + sequence: isSet(object.sequence) ? Long.fromValue(object.sequence) : Long.UZERO, + }; + }, + + 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, I>>( object: I, ): QueryPacketAcknowledgementRequest { @@ -1574,6 +1892,29 @@ export const QueryPacketAcknowledgementResponse = { return message; }, + fromJSON(object: any): QueryPacketAcknowledgementResponse { + return { + acknowledgement: isSet(object.acknowledgement) + ? bytesFromBase64(object.acknowledgement) + : new Uint8Array(), + proof: isSet(object.proof) ? bytesFromBase64(object.proof) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryPacketAcknowledgementResponse { @@ -1664,6 +2005,35 @@ export const QueryPacketAcknowledgementsRequest = { return message; }, + fromJSON(object: any): QueryPacketAcknowledgementsRequest { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + packetCommitmentSequences: Array.isArray(object?.packetCommitmentSequences) + ? object.packetCommitmentSequences.map((e: any) => Long.fromValue(e)) + : [], + }; + }, + + 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); + + if (message.packetCommitmentSequences) { + obj.packetCommitmentSequences = message.packetCommitmentSequences.map((e) => + (e || Long.UZERO).toString(), + ); + } else { + obj.packetCommitmentSequences = []; + } + + return obj; + }, + fromPartial, I>>( object: I, ): QueryPacketAcknowledgementsRequest { @@ -1734,6 +2104,31 @@ export const QueryPacketAcknowledgementsResponse = { return message; }, + fromJSON(object: any): QueryPacketAcknowledgementsResponse { + return { + acknowledgements: Array.isArray(object?.acknowledgements) + ? object.acknowledgements.map((e: any) => PacketState.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + height: isSet(object.height) ? Height.fromJSON(object.height) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryPacketAcknowledgementsResponse { @@ -1816,6 +2211,32 @@ export const QueryUnreceivedPacketsRequest = { return message; }, + fromJSON(object: any): QueryUnreceivedPacketsRequest { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + packetCommitmentSequences: Array.isArray(object?.packetCommitmentSequences) + ? object.packetCommitmentSequences.map((e: any) => Long.fromValue(e)) + : [], + }; + }, + + 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, I>>( object: I, ): QueryUnreceivedPacketsRequest { @@ -1886,6 +2307,26 @@ export const QueryUnreceivedPacketsResponse = { return message; }, + fromJSON(object: any): QueryUnreceivedPacketsResponse { + return { + sequences: Array.isArray(object?.sequences) ? object.sequences.map((e: any) => Long.fromValue(e)) : [], + height: isSet(object.height) ? Height.fromJSON(object.height) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryUnreceivedPacketsResponse { @@ -1964,6 +2405,30 @@ export const QueryUnreceivedAcksRequest = { return message; }, + fromJSON(object: any): QueryUnreceivedAcksRequest { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + packetAckSequences: Array.isArray(object?.packetAckSequences) + ? object.packetAckSequences.map((e: any) => Long.fromValue(e)) + : [], + }; + }, + + 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, I>>( object: I, ): QueryUnreceivedAcksRequest { @@ -2034,6 +2499,26 @@ export const QueryUnreceivedAcksResponse = { return message; }, + fromJSON(object: any): QueryUnreceivedAcksResponse { + return { + sequences: Array.isArray(object?.sequences) ? object.sequences.map((e: any) => Long.fromValue(e)) : [], + height: isSet(object.height) ? Height.fromJSON(object.height) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryUnreceivedAcksResponse { @@ -2091,6 +2576,20 @@ export const QueryNextSequenceReceiveRequest = { return message; }, + fromJSON(object: any): QueryNextSequenceReceiveRequest { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + }; + }, + + toJSON(message: QueryNextSequenceReceiveRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + fromPartial, I>>( object: I, ): QueryNextSequenceReceiveRequest { @@ -2156,6 +2655,27 @@ export const QueryNextSequenceReceiveResponse = { return message; }, + fromJSON(object: any): QueryNextSequenceReceiveResponse { + return { + nextSequenceReceive: isSet(object.nextSequenceReceive) + ? Long.fromValue(object.nextSequenceReceive) + : Long.UZERO, + proof: isSet(object.proof) ? bytesFromBase64(object.proof) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryNextSequenceReceiveResponse { diff --git a/src/ibc/core/channel/v1/tx.ts b/src/ibc/core/channel/v1/tx.ts index 7d3691d4..f091ef65 100644 --- a/src/ibc/core/channel/v1/tx.ts +++ b/src/ibc/core/channel/v1/tx.ts @@ -2,7 +2,7 @@ import { Channel, Packet } from "./channel"; import { Height } from "../../client/v1/client"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long, Rpc } from "../../../../helpers"; +import { isSet, DeepPartial, Exact, bytesFromBase64, base64FromBytes, Long, Rpc } from "../../../../helpers"; export const protobufPackage = "ibc.core.channel.v1"; /** ResponseResultType defines the possible outcomes of the execution of a message */ @@ -271,6 +271,23 @@ export const MsgChannelOpenInit = { return message; }, + fromJSON(object: any): MsgChannelOpenInit { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channel: isSet(object.channel) ? Channel.fromJSON(object.channel) : undefined, + signer: isSet(object.signer) ? String(object.signer) : "", + }; + }, + + toJSON(message: MsgChannelOpenInit): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channel !== undefined && + (obj.channel = message.channel ? Channel.toJSON(message.channel) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgChannelOpenInit { const message = createBaseMsgChannelOpenInit(); message.portId = object.portId ?? ""; @@ -320,6 +337,18 @@ export const MsgChannelOpenInitResponse = { return message; }, + fromJSON(object: any): MsgChannelOpenInitResponse { + return { + channelId: isSet(object.channelId) ? String(object.channelId) : "", + }; + }, + + toJSON(message: MsgChannelOpenInitResponse): unknown { + const obj: any = {}; + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + fromPartial, I>>( object: I, ): MsgChannelOpenInitResponse { @@ -420,6 +449,35 @@ export const MsgChannelOpenTry = { return message; }, + fromJSON(object: any): MsgChannelOpenTry { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + previousChannelId: isSet(object.previousChannelId) ? String(object.previousChannelId) : "", + channel: isSet(object.channel) ? Channel.fromJSON(object.channel) : undefined, + counterpartyVersion: isSet(object.counterpartyVersion) ? String(object.counterpartyVersion) : "", + proofInit: isSet(object.proofInit) ? bytesFromBase64(object.proofInit) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + signer: isSet(object.signer) ? String(object.signer) : "", + }; + }, + + toJSON(message: MsgChannelOpenTry): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.previousChannelId !== undefined && (obj.previousChannelId = message.previousChannelId); + message.channel !== undefined && + (obj.channel = message.channel ? Channel.toJSON(message.channel) : undefined); + message.counterpartyVersion !== undefined && (obj.counterpartyVersion = message.counterpartyVersion); + message.proofInit !== undefined && + (obj.proofInit = base64FromBytes( + message.proofInit !== undefined ? message.proofInit : new Uint8Array(), + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgChannelOpenTry { const message = createBaseMsgChannelOpenTry(); message.portId = object.portId ?? ""; @@ -466,6 +524,15 @@ export const MsgChannelOpenTryResponse = { return message; }, + fromJSON(_: any): MsgChannelOpenTryResponse { + return {}; + }, + + toJSON(_: MsgChannelOpenTryResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgChannelOpenTryResponse { const message = createBaseMsgChannelOpenTryResponse(); return message; @@ -563,6 +630,33 @@ export const MsgChannelOpenAck = { return message; }, + fromJSON(object: any): MsgChannelOpenAck { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + counterpartyChannelId: isSet(object.counterpartyChannelId) ? String(object.counterpartyChannelId) : "", + counterpartyVersion: isSet(object.counterpartyVersion) ? String(object.counterpartyVersion) : "", + proofTry: isSet(object.proofTry) ? bytesFromBase64(object.proofTry) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + signer: isSet(object.signer) ? String(object.signer) : "", + }; + }, + + toJSON(message: MsgChannelOpenAck): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.counterpartyChannelId !== undefined && + (obj.counterpartyChannelId = message.counterpartyChannelId); + message.counterpartyVersion !== undefined && (obj.counterpartyVersion = message.counterpartyVersion); + message.proofTry !== undefined && + (obj.proofTry = base64FromBytes(message.proofTry !== undefined ? message.proofTry : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgChannelOpenAck { const message = createBaseMsgChannelOpenAck(); message.portId = object.portId ?? ""; @@ -606,6 +700,15 @@ export const MsgChannelOpenAckResponse = { return message; }, + fromJSON(_: any): MsgChannelOpenAckResponse { + return {}; + }, + + toJSON(_: MsgChannelOpenAckResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgChannelOpenAckResponse { const message = createBaseMsgChannelOpenAckResponse(); return message; @@ -685,6 +788,28 @@ export const MsgChannelOpenConfirm = { return message; }, + fromJSON(object: any): MsgChannelOpenConfirm { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + proofAck: isSet(object.proofAck) ? bytesFromBase64(object.proofAck) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + signer: isSet(object.signer) ? String(object.signer) : "", + }; + }, + + toJSON(message: MsgChannelOpenConfirm): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.proofAck !== undefined && + (obj.proofAck = base64FromBytes(message.proofAck !== undefined ? message.proofAck : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgChannelOpenConfirm { const message = createBaseMsgChannelOpenConfirm(); message.portId = object.portId ?? ""; @@ -726,6 +851,15 @@ export const MsgChannelOpenConfirmResponse = { return message; }, + fromJSON(_: any): MsgChannelOpenConfirmResponse { + return {}; + }, + + toJSON(_: MsgChannelOpenConfirmResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( _: I, ): MsgChannelOpenConfirmResponse { @@ -789,6 +923,22 @@ export const MsgChannelCloseInit = { return message; }, + fromJSON(object: any): MsgChannelCloseInit { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + signer: isSet(object.signer) ? String(object.signer) : "", + }; + }, + + toJSON(message: MsgChannelCloseInit): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgChannelCloseInit { const message = createBaseMsgChannelCloseInit(); message.portId = object.portId ?? ""; @@ -825,6 +975,15 @@ export const MsgChannelCloseInitResponse = { return message; }, + fromJSON(_: any): MsgChannelCloseInitResponse { + return {}; + }, + + toJSON(_: MsgChannelCloseInitResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( _: I, ): MsgChannelCloseInitResponse { @@ -906,6 +1065,30 @@ export const MsgChannelCloseConfirm = { return message; }, + fromJSON(object: any): MsgChannelCloseConfirm { + return { + portId: isSet(object.portId) ? String(object.portId) : "", + channelId: isSet(object.channelId) ? String(object.channelId) : "", + proofInit: isSet(object.proofInit) ? bytesFromBase64(object.proofInit) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + signer: isSet(object.signer) ? String(object.signer) : "", + }; + }, + + toJSON(message: MsgChannelCloseConfirm): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.proofInit !== undefined && + (obj.proofInit = base64FromBytes( + message.proofInit !== undefined ? message.proofInit : new Uint8Array(), + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgChannelCloseConfirm { const message = createBaseMsgChannelCloseConfirm(); message.portId = object.portId ?? ""; @@ -947,6 +1130,15 @@ export const MsgChannelCloseConfirmResponse = { return message; }, + fromJSON(_: any): MsgChannelCloseConfirmResponse { + return {}; + }, + + toJSON(_: MsgChannelCloseConfirmResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( _: I, ): MsgChannelCloseConfirmResponse { @@ -1019,6 +1211,30 @@ export const MsgRecvPacket = { return message; }, + fromJSON(object: any): MsgRecvPacket { + return { + packet: isSet(object.packet) ? Packet.fromJSON(object.packet) : undefined, + proofCommitment: isSet(object.proofCommitment) + ? bytesFromBase64(object.proofCommitment) + : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + signer: isSet(object.signer) ? String(object.signer) : "", + }; + }, + + toJSON(message: MsgRecvPacket): unknown { + const obj: any = {}; + message.packet !== undefined && (obj.packet = message.packet ? Packet.toJSON(message.packet) : undefined); + message.proofCommitment !== undefined && + (obj.proofCommitment = base64FromBytes( + message.proofCommitment !== undefined ? message.proofCommitment : new Uint8Array(), + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgRecvPacket { const message = createBaseMsgRecvPacket(); message.packet = @@ -1070,6 +1286,18 @@ export const MsgRecvPacketResponse = { return message; }, + fromJSON(object: any): MsgRecvPacketResponse { + return { + result: isSet(object.result) ? responseResultTypeFromJSON(object.result) : 0, + }; + }, + + toJSON(message: MsgRecvPacketResponse): unknown { + const obj: any = {}; + message.result !== undefined && (obj.result = responseResultTypeToJSON(message.result)); + return obj; + }, + fromPartial, I>>(object: I): MsgRecvPacketResponse { const message = createBaseMsgRecvPacketResponse(); message.result = object.result ?? 0; @@ -1150,6 +1378,33 @@ export const MsgTimeout = { return message; }, + fromJSON(object: any): MsgTimeout { + return { + packet: isSet(object.packet) ? Packet.fromJSON(object.packet) : undefined, + proofUnreceived: isSet(object.proofUnreceived) + ? bytesFromBase64(object.proofUnreceived) + : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + nextSequenceRecv: isSet(object.nextSequenceRecv) ? Long.fromValue(object.nextSequenceRecv) : Long.UZERO, + signer: isSet(object.signer) ? String(object.signer) : "", + }; + }, + + toJSON(message: MsgTimeout): unknown { + const obj: any = {}; + message.packet !== undefined && (obj.packet = message.packet ? Packet.toJSON(message.packet) : undefined); + message.proofUnreceived !== undefined && + (obj.proofUnreceived = base64FromBytes( + message.proofUnreceived !== undefined ? message.proofUnreceived : new Uint8Array(), + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.nextSequenceRecv !== undefined && + (obj.nextSequenceRecv = (message.nextSequenceRecv || Long.UZERO).toString()); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgTimeout { const message = createBaseMsgTimeout(); message.packet = @@ -1205,6 +1460,18 @@ export const MsgTimeoutResponse = { return message; }, + fromJSON(object: any): MsgTimeoutResponse { + return { + result: isSet(object.result) ? responseResultTypeFromJSON(object.result) : 0, + }; + }, + + toJSON(message: MsgTimeoutResponse): unknown { + const obj: any = {}; + message.result !== undefined && (obj.result = responseResultTypeToJSON(message.result)); + return obj; + }, + fromPartial, I>>(object: I): MsgTimeoutResponse { const message = createBaseMsgTimeoutResponse(); message.result = object.result ?? 0; @@ -1294,6 +1561,38 @@ export const MsgTimeoutOnClose = { return message; }, + fromJSON(object: any): MsgTimeoutOnClose { + return { + packet: isSet(object.packet) ? Packet.fromJSON(object.packet) : undefined, + proofUnreceived: isSet(object.proofUnreceived) + ? bytesFromBase64(object.proofUnreceived) + : new Uint8Array(), + proofClose: isSet(object.proofClose) ? bytesFromBase64(object.proofClose) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + nextSequenceRecv: isSet(object.nextSequenceRecv) ? Long.fromValue(object.nextSequenceRecv) : Long.UZERO, + signer: isSet(object.signer) ? String(object.signer) : "", + }; + }, + + toJSON(message: MsgTimeoutOnClose): unknown { + const obj: any = {}; + message.packet !== undefined && (obj.packet = message.packet ? Packet.toJSON(message.packet) : undefined); + message.proofUnreceived !== undefined && + (obj.proofUnreceived = base64FromBytes( + message.proofUnreceived !== undefined ? message.proofUnreceived : new Uint8Array(), + )); + message.proofClose !== undefined && + (obj.proofClose = base64FromBytes( + message.proofClose !== undefined ? message.proofClose : new Uint8Array(), + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.nextSequenceRecv !== undefined && + (obj.nextSequenceRecv = (message.nextSequenceRecv || Long.UZERO).toString()); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgTimeoutOnClose { const message = createBaseMsgTimeoutOnClose(); message.packet = @@ -1350,6 +1649,18 @@ export const MsgTimeoutOnCloseResponse = { return message; }, + fromJSON(object: any): MsgTimeoutOnCloseResponse { + return { + result: isSet(object.result) ? responseResultTypeFromJSON(object.result) : 0, + }; + }, + + toJSON(message: MsgTimeoutOnCloseResponse): unknown { + const obj: any = {}; + message.result !== undefined && (obj.result = responseResultTypeToJSON(message.result)); + return obj; + }, + fromPartial, I>>( object: I, ): MsgTimeoutOnCloseResponse { @@ -1432,6 +1743,35 @@ export const MsgAcknowledgement = { return message; }, + fromJSON(object: any): MsgAcknowledgement { + return { + packet: isSet(object.packet) ? Packet.fromJSON(object.packet) : undefined, + acknowledgement: isSet(object.acknowledgement) + ? bytesFromBase64(object.acknowledgement) + : new Uint8Array(), + proofAcked: isSet(object.proofAcked) ? bytesFromBase64(object.proofAcked) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + signer: isSet(object.signer) ? String(object.signer) : "", + }; + }, + + toJSON(message: MsgAcknowledgement): unknown { + const obj: any = {}; + message.packet !== undefined && (obj.packet = message.packet ? Packet.toJSON(message.packet) : undefined); + message.acknowledgement !== undefined && + (obj.acknowledgement = base64FromBytes( + message.acknowledgement !== undefined ? message.acknowledgement : new Uint8Array(), + )); + message.proofAcked !== undefined && + (obj.proofAcked = base64FromBytes( + message.proofAcked !== undefined ? message.proofAcked : new Uint8Array(), + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgAcknowledgement { const message = createBaseMsgAcknowledgement(); message.packet = @@ -1484,6 +1824,18 @@ export const MsgAcknowledgementResponse = { return message; }, + fromJSON(object: any): MsgAcknowledgementResponse { + return { + result: isSet(object.result) ? responseResultTypeFromJSON(object.result) : 0, + }; + }, + + toJSON(message: MsgAcknowledgementResponse): unknown { + const obj: any = {}; + message.result !== undefined && (obj.result = responseResultTypeToJSON(message.result)); + return obj; + }, + fromPartial, I>>( object: I, ): MsgAcknowledgementResponse { diff --git a/src/ibc/core/client/v1/client.ts b/src/ibc/core/client/v1/client.ts index c7af01ec..f7dc4ed9 100644 --- a/src/ibc/core/client/v1/client.ts +++ b/src/ibc/core/client/v1/client.ts @@ -2,7 +2,7 @@ import { Any } from "../../../../google/protobuf/any"; import { Plan } from "../../../../cosmos/upgrade/v1beta1/upgrade"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../../../helpers"; +import { isSet, DeepPartial, Exact, Long } from "../../../../helpers"; export const protobufPackage = "ibc.core.client.v1"; /** * IdentifiedClientState defines a client state with an additional client @@ -156,6 +156,21 @@ export const IdentifiedClientState = { return message; }, + fromJSON(object: any): IdentifiedClientState { + return { + clientId: isSet(object.clientId) ? String(object.clientId) : "", + clientState: isSet(object.clientState) ? Any.fromJSON(object.clientState) : undefined, + }; + }, + + 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, I>>(object: I): IdentifiedClientState { const message = createBaseIdentifiedClientState(); message.clientId = object.clientId ?? ""; @@ -213,6 +228,21 @@ export const ConsensusStateWithHeight = { return message; }, + fromJSON(object: any): ConsensusStateWithHeight { + return { + height: isSet(object.height) ? Height.fromJSON(object.height) : undefined, + consensusState: isSet(object.consensusState) ? Any.fromJSON(object.consensusState) : undefined, + }; + }, + + 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, I>>( object: I, ): ConsensusStateWithHeight { @@ -273,6 +303,30 @@ export const ClientConsensusStates = { return message; }, + fromJSON(object: any): ClientConsensusStates { + return { + clientId: isSet(object.clientId) ? String(object.clientId) : "", + consensusStates: Array.isArray(object?.consensusStates) + ? object.consensusStates.map((e: any) => ConsensusStateWithHeight.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): ClientConsensusStates { const message = createBaseClientConsensusStates(); message.clientId = object.clientId ?? ""; @@ -346,6 +400,24 @@ export const ClientUpdateProposal = { return message; }, + fromJSON(object: any): ClientUpdateProposal { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + subjectClientId: isSet(object.subjectClientId) ? String(object.subjectClientId) : "", + substituteClientId: isSet(object.substituteClientId) ? String(object.substituteClientId) : "", + }; + }, + + toJSON(message: ClientUpdateProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.subjectClientId !== undefined && (obj.subjectClientId = message.subjectClientId); + message.substituteClientId !== undefined && (obj.substituteClientId = message.substituteClientId); + return obj; + }, + fromPartial, I>>(object: I): ClientUpdateProposal { const message = createBaseClientUpdateProposal(); message.title = object.title ?? ""; @@ -420,6 +492,29 @@ export const UpgradeProposal = { return message; }, + fromJSON(object: any): UpgradeProposal { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + plan: isSet(object.plan) ? Plan.fromJSON(object.plan) : undefined, + upgradedClientState: isSet(object.upgradedClientState) + ? Any.fromJSON(object.upgradedClientState) + : undefined, + }; + }, + + toJSON(message: UpgradeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.plan !== undefined && (obj.plan = message.plan ? Plan.toJSON(message.plan) : undefined); + message.upgradedClientState !== undefined && + (obj.upgradedClientState = message.upgradedClientState + ? Any.toJSON(message.upgradedClientState) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): UpgradeProposal { const message = createBaseUpgradeProposal(); message.title = object.title ?? ""; @@ -480,6 +575,22 @@ export const Height = { return message; }, + fromJSON(object: any): Height { + return { + revisionNumber: isSet(object.revisionNumber) ? Long.fromValue(object.revisionNumber) : Long.UZERO, + revisionHeight: isSet(object.revisionHeight) ? Long.fromValue(object.revisionHeight) : Long.UZERO, + }; + }, + + 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, I>>(object: I): Height { const message = createBaseHeight(); message.revisionNumber = @@ -531,6 +642,26 @@ export const Params = { return message; }, + fromJSON(object: any): Params { + return { + allowedClients: Array.isArray(object?.allowedClients) + ? object.allowedClients.map((e: any) => String(e)) + : [], + }; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + + if (message.allowedClients) { + obj.allowedClients = message.allowedClients.map((e) => e); + } else { + obj.allowedClients = []; + } + + return obj; + }, + fromPartial, I>>(object: I): Params { const message = createBaseParams(); message.allowedClients = object.allowedClients?.map((e) => e) || []; diff --git a/src/ibc/core/client/v1/genesis.ts b/src/ibc/core/client/v1/genesis.ts index b4660dd8..da9f35e1 100644 --- a/src/ibc/core/client/v1/genesis.ts +++ b/src/ibc/core/client/v1/genesis.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import { IdentifiedClientState, ClientConsensusStates, Params } from "./client"; -import { Long, DeepPartial, Exact } from "../../../../helpers"; +import { Long, isSet, DeepPartial, Exact, bytesFromBase64, base64FromBytes } from "../../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "ibc.core.client.v1"; /** GenesisState defines the ibc client submodule's genesis state. */ @@ -126,6 +126,57 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + clients: Array.isArray(object?.clients) + ? object.clients.map((e: any) => IdentifiedClientState.fromJSON(e)) + : [], + clientsConsensus: Array.isArray(object?.clientsConsensus) + ? object.clientsConsensus.map((e: any) => ClientConsensusStates.fromJSON(e)) + : [], + clientsMetadata: Array.isArray(object?.clientsMetadata) + ? object.clientsMetadata.map((e: any) => IdentifiedGenesisMetadata.fromJSON(e)) + : [], + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + createLocalhost: isSet(object.createLocalhost) ? Boolean(object.createLocalhost) : false, + nextClientSequence: isSet(object.nextClientSequence) + ? Long.fromValue(object.nextClientSequence) + : Long.UZERO, + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + + if (message.clients) { + obj.clients = message.clients.map((e) => (e ? IdentifiedClientState.toJSON(e) : undefined)); + } else { + obj.clients = []; + } + + if (message.clientsConsensus) { + obj.clientsConsensus = message.clientsConsensus.map((e) => + e ? ClientConsensusStates.toJSON(e) : undefined, + ); + } else { + obj.clientsConsensus = []; + } + + if (message.clientsMetadata) { + obj.clientsMetadata = message.clientsMetadata.map((e) => + e ? IdentifiedGenesisMetadata.toJSON(e) : undefined, + ); + } else { + obj.clientsMetadata = []; + } + + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + message.createLocalhost !== undefined && (obj.createLocalhost = message.createLocalhost); + message.nextClientSequence !== undefined && + (obj.nextClientSequence = (message.nextClientSequence || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.clients = object.clients?.map((e) => IdentifiedClientState.fromPartial(e)) || []; @@ -190,6 +241,22 @@ export const GenesisMetadata = { return message; }, + fromJSON(object: any): GenesisMetadata { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), + }; + }, + + toJSON(message: GenesisMetadata): 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, I>>(object: I): GenesisMetadata { const message = createBaseGenesisMetadata(); message.key = object.key ?? new Uint8Array(); @@ -244,6 +311,28 @@ export const IdentifiedGenesisMetadata = { return message; }, + fromJSON(object: any): IdentifiedGenesisMetadata { + return { + clientId: isSet(object.clientId) ? String(object.clientId) : "", + clientMetadata: Array.isArray(object?.clientMetadata) + ? object.clientMetadata.map((e: any) => GenesisMetadata.fromJSON(e)) + : [], + }; + }, + + toJSON(message: IdentifiedGenesisMetadata): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + + if (message.clientMetadata) { + obj.clientMetadata = message.clientMetadata.map((e) => (e ? GenesisMetadata.toJSON(e) : undefined)); + } else { + obj.clientMetadata = []; + } + + return obj; + }, + fromPartial, I>>( object: I, ): IdentifiedGenesisMetadata { diff --git a/src/ibc/core/client/v1/query.ts b/src/ibc/core/client/v1/query.ts index 45d7382e..cc6e213b 100644 --- a/src/ibc/core/client/v1/query.ts +++ b/src/ibc/core/client/v1/query.ts @@ -3,7 +3,7 @@ import { PageRequest, PageResponse } from "../../../../cosmos/base/query/v1beta1 import { Any } from "../../../../google/protobuf/any"; import { Height, IdentifiedClientState, ConsensusStateWithHeight, Params } from "./client"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long, Rpc } from "../../../../helpers"; +import { isSet, DeepPartial, Exact, bytesFromBase64, base64FromBytes, Long, Rpc } from "../../../../helpers"; export const protobufPackage = "ibc.core.client.v1"; /** * QueryClientStateRequest is the request type for the Query/ClientState RPC @@ -212,6 +212,18 @@ export const QueryClientStateRequest = { return message; }, + fromJSON(object: any): QueryClientStateRequest { + return { + clientId: isSet(object.clientId) ? String(object.clientId) : "", + }; + }, + + toJSON(message: QueryClientStateRequest): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + return obj; + }, + fromPartial, I>>(object: I): QueryClientStateRequest { const message = createBaseQueryClientStateRequest(); message.clientId = object.clientId ?? ""; @@ -274,6 +286,25 @@ export const QueryClientStateResponse = { return message; }, + fromJSON(object: any): QueryClientStateResponse { + return { + clientState: isSet(object.clientState) ? Any.fromJSON(object.clientState) : undefined, + proof: isSet(object.proof) ? bytesFromBase64(object.proof) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + }; + }, + + toJSON(message: QueryClientStateResponse): unknown { + const obj: any = {}; + message.clientState !== undefined && + (obj.clientState = message.clientState ? Any.toJSON(message.clientState) : undefined); + message.proof !== undefined && + (obj.proof = base64FromBytes(message.proof !== undefined ? message.proof : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryClientStateResponse { @@ -328,6 +359,19 @@ export const QueryClientStatesRequest = { return message; }, + fromJSON(object: any): QueryClientStatesRequest { + return { + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryClientStatesRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryClientStatesRequest { @@ -386,6 +430,29 @@ export const QueryClientStatesResponse = { return message; }, + fromJSON(object: any): QueryClientStatesResponse { + return { + clientStates: Array.isArray(object?.clientStates) + ? object.clientStates.map((e: any) => IdentifiedClientState.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryClientStatesResponse): unknown { + const obj: any = {}; + + if (message.clientStates) { + obj.clientStates = message.clientStates.map((e) => (e ? IdentifiedClientState.toJSON(e) : undefined)); + } else { + obj.clientStates = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryClientStatesResponse { @@ -463,6 +530,26 @@ export const QueryConsensusStateRequest = { return message; }, + fromJSON(object: any): QueryConsensusStateRequest { + return { + clientId: isSet(object.clientId) ? String(object.clientId) : "", + revisionNumber: isSet(object.revisionNumber) ? Long.fromValue(object.revisionNumber) : Long.UZERO, + revisionHeight: isSet(object.revisionHeight) ? Long.fromValue(object.revisionHeight) : Long.UZERO, + latestHeight: isSet(object.latestHeight) ? Boolean(object.latestHeight) : false, + }; + }, + + toJSON(message: QueryConsensusStateRequest): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.revisionNumber !== undefined && + (obj.revisionNumber = (message.revisionNumber || Long.UZERO).toString()); + message.revisionHeight !== undefined && + (obj.revisionHeight = (message.revisionHeight || Long.UZERO).toString()); + message.latestHeight !== undefined && (obj.latestHeight = message.latestHeight); + return obj; + }, + fromPartial, I>>( object: I, ): QueryConsensusStateRequest { @@ -536,6 +623,25 @@ export const QueryConsensusStateResponse = { return message; }, + fromJSON(object: any): QueryConsensusStateResponse { + return { + consensusState: isSet(object.consensusState) ? Any.fromJSON(object.consensusState) : undefined, + proof: isSet(object.proof) ? bytesFromBase64(object.proof) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + }; + }, + + toJSON(message: QueryConsensusStateResponse): unknown { + const obj: any = {}; + message.consensusState !== undefined && + (obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined); + message.proof !== undefined && + (obj.proof = base64FromBytes(message.proof !== undefined ? message.proof : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryConsensusStateResponse { @@ -599,6 +705,21 @@ export const QueryConsensusStatesRequest = { return message; }, + fromJSON(object: any): QueryConsensusStatesRequest { + return { + clientId: isSet(object.clientId) ? String(object.clientId) : "", + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryConsensusStatesRequest): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryConsensusStatesRequest { @@ -658,6 +779,31 @@ export const QueryConsensusStatesResponse = { return message; }, + fromJSON(object: any): QueryConsensusStatesResponse { + return { + consensusStates: Array.isArray(object?.consensusStates) + ? object.consensusStates.map((e: any) => ConsensusStateWithHeight.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryConsensusStatesResponse): unknown { + const obj: any = {}; + + if (message.consensusStates) { + obj.consensusStates = message.consensusStates.map((e) => + e ? ConsensusStateWithHeight.toJSON(e) : undefined, + ); + } else { + obj.consensusStates = []; + } + + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryConsensusStatesResponse { @@ -709,6 +855,18 @@ export const QueryClientStatusRequest = { return message; }, + fromJSON(object: any): QueryClientStatusRequest { + return { + clientId: isSet(object.clientId) ? String(object.clientId) : "", + }; + }, + + toJSON(message: QueryClientStatusRequest): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + return obj; + }, + fromPartial, I>>( object: I, ): QueryClientStatusRequest { @@ -755,6 +913,18 @@ export const QueryClientStatusResponse = { return message; }, + fromJSON(object: any): QueryClientStatusResponse { + return { + status: isSet(object.status) ? String(object.status) : "", + }; + }, + + toJSON(message: QueryClientStatusResponse): unknown { + const obj: any = {}; + message.status !== undefined && (obj.status = message.status); + return obj; + }, + fromPartial, I>>( object: I, ): QueryClientStatusResponse { @@ -791,6 +961,15 @@ export const QueryClientParamsRequest = { return message; }, + fromJSON(_: any): QueryClientParamsRequest { + return {}; + }, + + toJSON(_: QueryClientParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): QueryClientParamsRequest { const message = createBaseQueryClientParamsRequest(); return message; @@ -834,6 +1013,18 @@ export const QueryClientParamsResponse = { return message; }, + fromJSON(object: any): QueryClientParamsResponse { + return { + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + }; + }, + + toJSON(message: QueryClientParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryClientParamsResponse { @@ -871,6 +1062,15 @@ export const QueryUpgradedClientStateRequest = { return message; }, + fromJSON(_: any): QueryUpgradedClientStateRequest { + return {}; + }, + + toJSON(_: QueryUpgradedClientStateRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( _: I, ): QueryUpgradedClientStateRequest { @@ -916,6 +1116,23 @@ export const QueryUpgradedClientStateResponse = { return message; }, + fromJSON(object: any): QueryUpgradedClientStateResponse { + return { + upgradedClientState: isSet(object.upgradedClientState) + ? Any.fromJSON(object.upgradedClientState) + : undefined, + }; + }, + + toJSON(message: QueryUpgradedClientStateResponse): unknown { + const obj: any = {}; + message.upgradedClientState !== undefined && + (obj.upgradedClientState = message.upgradedClientState + ? Any.toJSON(message.upgradedClientState) + : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryUpgradedClientStateResponse { @@ -955,6 +1172,15 @@ export const QueryUpgradedConsensusStateRequest = { return message; }, + fromJSON(_: any): QueryUpgradedConsensusStateRequest { + return {}; + }, + + toJSON(_: QueryUpgradedConsensusStateRequest): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( _: I, ): QueryUpgradedConsensusStateRequest { @@ -1000,6 +1226,23 @@ export const QueryUpgradedConsensusStateResponse = { return message; }, + fromJSON(object: any): QueryUpgradedConsensusStateResponse { + return { + upgradedConsensusState: isSet(object.upgradedConsensusState) + ? Any.fromJSON(object.upgradedConsensusState) + : undefined, + }; + }, + + toJSON(message: QueryUpgradedConsensusStateResponse): unknown { + const obj: any = {}; + message.upgradedConsensusState !== undefined && + (obj.upgradedConsensusState = message.upgradedConsensusState + ? Any.toJSON(message.upgradedConsensusState) + : undefined); + return obj; + }, + fromPartial, I>>( object: I, ): QueryUpgradedConsensusStateResponse { diff --git a/src/ibc/core/client/v1/tx.ts b/src/ibc/core/client/v1/tx.ts index 517c0ae8..be1f4b39 100644 --- a/src/ibc/core/client/v1/tx.ts +++ b/src/ibc/core/client/v1/tx.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Any } from "../../../../google/protobuf/any"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Rpc } from "../../../../helpers"; +import { isSet, DeepPartial, Exact, bytesFromBase64, base64FromBytes, Rpc } from "../../../../helpers"; export const protobufPackage = "ibc.core.client.v1"; /** MsgCreateClient defines a message to create an IBC client */ @@ -146,6 +146,24 @@ export const MsgCreateClient = { return message; }, + fromJSON(object: any): MsgCreateClient { + return { + clientState: isSet(object.clientState) ? Any.fromJSON(object.clientState) : undefined, + consensusState: isSet(object.consensusState) ? Any.fromJSON(object.consensusState) : undefined, + signer: isSet(object.signer) ? String(object.signer) : "", + }; + }, + + toJSON(message: MsgCreateClient): unknown { + const obj: any = {}; + message.clientState !== undefined && + (obj.clientState = message.clientState ? Any.toJSON(message.clientState) : undefined); + message.consensusState !== undefined && + (obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgCreateClient { const message = createBaseMsgCreateClient(); message.clientState = @@ -188,6 +206,15 @@ export const MsgCreateClientResponse = { return message; }, + fromJSON(_: any): MsgCreateClientResponse { + return {}; + }, + + toJSON(_: MsgCreateClientResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgCreateClientResponse { const message = createBaseMsgCreateClientResponse(); return message; @@ -249,6 +276,22 @@ export const MsgUpdateClient = { return message; }, + fromJSON(object: any): MsgUpdateClient { + return { + clientId: isSet(object.clientId) ? String(object.clientId) : "", + header: isSet(object.header) ? Any.fromJSON(object.header) : undefined, + signer: isSet(object.signer) ? String(object.signer) : "", + }; + }, + + toJSON(message: MsgUpdateClient): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.header !== undefined && (obj.header = message.header ? Any.toJSON(message.header) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgUpdateClient { const message = createBaseMsgUpdateClient(); message.clientId = object.clientId ?? ""; @@ -286,6 +329,15 @@ export const MsgUpdateClientResponse = { return message; }, + fromJSON(_: any): MsgUpdateClientResponse { + return {}; + }, + + toJSON(_: MsgUpdateClientResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgUpdateClientResponse { const message = createBaseMsgUpdateClientResponse(); return message; @@ -374,6 +426,42 @@ export const MsgUpgradeClient = { return message; }, + fromJSON(object: any): MsgUpgradeClient { + return { + clientId: isSet(object.clientId) ? String(object.clientId) : "", + clientState: isSet(object.clientState) ? Any.fromJSON(object.clientState) : undefined, + consensusState: isSet(object.consensusState) ? Any.fromJSON(object.consensusState) : undefined, + proofUpgradeClient: isSet(object.proofUpgradeClient) + ? bytesFromBase64(object.proofUpgradeClient) + : new Uint8Array(), + proofUpgradeConsensusState: isSet(object.proofUpgradeConsensusState) + ? bytesFromBase64(object.proofUpgradeConsensusState) + : new Uint8Array(), + signer: isSet(object.signer) ? String(object.signer) : "", + }; + }, + + toJSON(message: MsgUpgradeClient): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.clientState !== undefined && + (obj.clientState = message.clientState ? Any.toJSON(message.clientState) : undefined); + message.consensusState !== undefined && + (obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined); + message.proofUpgradeClient !== undefined && + (obj.proofUpgradeClient = base64FromBytes( + message.proofUpgradeClient !== undefined ? message.proofUpgradeClient : new Uint8Array(), + )); + message.proofUpgradeConsensusState !== undefined && + (obj.proofUpgradeConsensusState = base64FromBytes( + message.proofUpgradeConsensusState !== undefined + ? message.proofUpgradeConsensusState + : new Uint8Array(), + )); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgUpgradeClient { const message = createBaseMsgUpgradeClient(); message.clientId = object.clientId ?? ""; @@ -419,6 +507,15 @@ export const MsgUpgradeClientResponse = { return message; }, + fromJSON(_: any): MsgUpgradeClientResponse { + return {}; + }, + + toJSON(_: MsgUpgradeClientResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgUpgradeClientResponse { const message = createBaseMsgUpgradeClientResponse(); return message; @@ -480,6 +577,23 @@ export const MsgSubmitMisbehaviour = { return message; }, + fromJSON(object: any): MsgSubmitMisbehaviour { + return { + clientId: isSet(object.clientId) ? String(object.clientId) : "", + misbehaviour: isSet(object.misbehaviour) ? Any.fromJSON(object.misbehaviour) : undefined, + signer: isSet(object.signer) ? String(object.signer) : "", + }; + }, + + toJSON(message: MsgSubmitMisbehaviour): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.misbehaviour !== undefined && + (obj.misbehaviour = message.misbehaviour ? Any.toJSON(message.misbehaviour) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgSubmitMisbehaviour { const message = createBaseMsgSubmitMisbehaviour(); message.clientId = object.clientId ?? ""; @@ -519,6 +633,15 @@ export const MsgSubmitMisbehaviourResponse = { return message; }, + fromJSON(_: any): MsgSubmitMisbehaviourResponse { + return {}; + }, + + toJSON(_: MsgSubmitMisbehaviourResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( _: I, ): MsgSubmitMisbehaviourResponse { diff --git a/src/ibc/core/commitment/v1/commitment.ts b/src/ibc/core/commitment/v1/commitment.ts index b85b68de..a62fc23a 100644 --- a/src/ibc/core/commitment/v1/commitment.ts +++ b/src/ibc/core/commitment/v1/commitment.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { CommitmentProof } from "../../../../confio/proofs"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../../helpers"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact } from "../../../../helpers"; export const protobufPackage = "ibc.core.commitment.v1"; /** * MerkleRoot defines a merkle root hash. @@ -78,6 +78,19 @@ export const MerkleRoot = { return message; }, + fromJSON(object: any): MerkleRoot { + return { + hash: isSet(object.hash) ? bytesFromBase64(object.hash) : new Uint8Array(), + }; + }, + + toJSON(message: MerkleRoot): unknown { + const obj: any = {}; + message.hash !== undefined && + (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): MerkleRoot { const message = createBaseMerkleRoot(); message.hash = object.hash ?? new Uint8Array(); @@ -122,6 +135,21 @@ export const MerklePrefix = { return message; }, + fromJSON(object: any): MerklePrefix { + return { + keyPrefix: isSet(object.keyPrefix) ? bytesFromBase64(object.keyPrefix) : new Uint8Array(), + }; + }, + + toJSON(message: MerklePrefix): unknown { + const obj: any = {}; + message.keyPrefix !== undefined && + (obj.keyPrefix = base64FromBytes( + message.keyPrefix !== undefined ? message.keyPrefix : new Uint8Array(), + )); + return obj; + }, + fromPartial, I>>(object: I): MerklePrefix { const message = createBaseMerklePrefix(); message.keyPrefix = object.keyPrefix ?? new Uint8Array(); @@ -166,6 +194,24 @@ export const MerklePath = { return message; }, + fromJSON(object: any): MerklePath { + return { + keyPath: Array.isArray(object?.keyPath) ? object.keyPath.map((e: any) => String(e)) : [], + }; + }, + + toJSON(message: MerklePath): unknown { + const obj: any = {}; + + if (message.keyPath) { + obj.keyPath = message.keyPath.map((e) => e); + } else { + obj.keyPath = []; + } + + return obj; + }, + fromPartial, I>>(object: I): MerklePath { const message = createBaseMerklePath(); message.keyPath = object.keyPath?.map((e) => e) || []; @@ -210,6 +256,24 @@ export const MerkleProof = { return message; }, + fromJSON(object: any): MerkleProof { + return { + proofs: Array.isArray(object?.proofs) ? object.proofs.map((e: any) => CommitmentProof.fromJSON(e)) : [], + }; + }, + + 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, I>>(object: I): MerkleProof { const message = createBaseMerkleProof(); message.proofs = object.proofs?.map((e) => CommitmentProof.fromPartial(e)) || []; diff --git a/src/ibc/core/connection/v1/connection.ts b/src/ibc/core/connection/v1/connection.ts index 88b39225..2b240487 100644 --- a/src/ibc/core/connection/v1/connection.ts +++ b/src/ibc/core/connection/v1/connection.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import { MerklePrefix } from "../../commitment/v1/commitment"; -import { Long, DeepPartial, Exact } from "../../../../helpers"; +import { Long, isSet, DeepPartial, Exact } from "../../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "ibc.core.connection.v1"; /** @@ -254,6 +254,33 @@ export const ConnectionEnd = { return message; }, + fromJSON(object: any): ConnectionEnd { + return { + clientId: isSet(object.clientId) ? String(object.clientId) : "", + versions: Array.isArray(object?.versions) ? object.versions.map((e: any) => Version.fromJSON(e)) : [], + state: isSet(object.state) ? stateFromJSON(object.state) : 0, + counterparty: isSet(object.counterparty) ? Counterparty.fromJSON(object.counterparty) : undefined, + delayPeriod: isSet(object.delayPeriod) ? Long.fromValue(object.delayPeriod) : Long.UZERO, + }; + }, + + 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, I>>(object: I): ConnectionEnd { const message = createBaseConnectionEnd(); message.clientId = object.clientId ?? ""; @@ -353,6 +380,35 @@ export const IdentifiedConnection = { return message; }, + fromJSON(object: any): IdentifiedConnection { + return { + id: isSet(object.id) ? String(object.id) : "", + clientId: isSet(object.clientId) ? String(object.clientId) : "", + versions: Array.isArray(object?.versions) ? object.versions.map((e: any) => Version.fromJSON(e)) : [], + state: isSet(object.state) ? stateFromJSON(object.state) : 0, + counterparty: isSet(object.counterparty) ? Counterparty.fromJSON(object.counterparty) : undefined, + delayPeriod: isSet(object.delayPeriod) ? Long.fromValue(object.delayPeriod) : Long.UZERO, + }; + }, + + 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, I>>(object: I): IdentifiedConnection { const message = createBaseIdentifiedConnection(); message.id = object.id ?? ""; @@ -426,6 +482,23 @@ export const Counterparty = { return message; }, + fromJSON(object: any): Counterparty { + return { + clientId: isSet(object.clientId) ? String(object.clientId) : "", + connectionId: isSet(object.connectionId) ? String(object.connectionId) : "", + prefix: isSet(object.prefix) ? MerklePrefix.fromJSON(object.prefix) : undefined, + }; + }, + + 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, I>>(object: I): Counterparty { const message = createBaseCounterparty(); message.clientId = object.clientId ?? ""; @@ -475,6 +548,24 @@ export const ClientPaths = { return message; }, + fromJSON(object: any): ClientPaths { + return { + paths: Array.isArray(object?.paths) ? object.paths.map((e: any) => String(e)) : [], + }; + }, + + toJSON(message: ClientPaths): unknown { + const obj: any = {}; + + if (message.paths) { + obj.paths = message.paths.map((e) => e); + } else { + obj.paths = []; + } + + return obj; + }, + fromPartial, I>>(object: I): ClientPaths { const message = createBaseClientPaths(); message.paths = object.paths?.map((e) => e) || []; @@ -528,6 +619,26 @@ export const ConnectionPaths = { return message; }, + fromJSON(object: any): ConnectionPaths { + return { + clientId: isSet(object.clientId) ? String(object.clientId) : "", + paths: Array.isArray(object?.paths) ? object.paths.map((e: any) => String(e)) : [], + }; + }, + + 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, I>>(object: I): ConnectionPaths { const message = createBaseConnectionPaths(); message.clientId = object.clientId ?? ""; @@ -582,6 +693,26 @@ export const Version = { return message; }, + fromJSON(object: any): Version { + return { + identifier: isSet(object.identifier) ? String(object.identifier) : "", + features: Array.isArray(object?.features) ? object.features.map((e: any) => String(e)) : [], + }; + }, + + 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, I>>(object: I): Version { const message = createBaseVersion(); message.identifier = object.identifier ?? ""; @@ -627,6 +758,21 @@ export const Params = { return message; }, + fromJSON(object: any): Params { + return { + maxExpectedTimePerBlock: isSet(object.maxExpectedTimePerBlock) + ? Long.fromValue(object.maxExpectedTimePerBlock) + : Long.UZERO, + }; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.maxExpectedTimePerBlock !== undefined && + (obj.maxExpectedTimePerBlock = (message.maxExpectedTimePerBlock || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): Params { const message = createBaseParams(); message.maxExpectedTimePerBlock = diff --git a/src/ibc/core/connection/v1/genesis.ts b/src/ibc/core/connection/v1/genesis.ts index 08a602e9..1600b7a8 100644 --- a/src/ibc/core/connection/v1/genesis.ts +++ b/src/ibc/core/connection/v1/genesis.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import { IdentifiedConnection, ConnectionPaths, Params } from "./connection"; -import { Long, DeepPartial, Exact } from "../../../../helpers"; +import { Long, isSet, DeepPartial, Exact } from "../../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "ibc.core.connection.v1"; /** GenesisState defines the ibc connection submodule's genesis state. */ @@ -78,6 +78,44 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + connections: Array.isArray(object?.connections) + ? object.connections.map((e: any) => IdentifiedConnection.fromJSON(e)) + : [], + clientConnectionPaths: Array.isArray(object?.clientConnectionPaths) + ? object.clientConnectionPaths.map((e: any) => ConnectionPaths.fromJSON(e)) + : [], + nextConnectionSequence: isSet(object.nextConnectionSequence) + ? Long.fromValue(object.nextConnectionSequence) + : Long.UZERO, + params: isSet(object.params) ? Params.fromJSON(object.params) : undefined, + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + + if (message.connections) { + obj.connections = message.connections.map((e) => (e ? IdentifiedConnection.toJSON(e) : undefined)); + } else { + obj.connections = []; + } + + if (message.clientConnectionPaths) { + obj.clientConnectionPaths = message.clientConnectionPaths.map((e) => + e ? ConnectionPaths.toJSON(e) : undefined, + ); + } else { + obj.clientConnectionPaths = []; + } + + message.nextConnectionSequence !== undefined && + (obj.nextConnectionSequence = (message.nextConnectionSequence || Long.UZERO).toString()); + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.connections = object.connections?.map((e) => IdentifiedConnection.fromPartial(e)) || []; diff --git a/src/ibc/core/connection/v1/query.ts b/src/ibc/core/connection/v1/query.ts index 1584c335..efa89727 100644 --- a/src/ibc/core/connection/v1/query.ts +++ b/src/ibc/core/connection/v1/query.ts @@ -4,7 +4,7 @@ import { ConnectionEnd, IdentifiedConnection } from "./connection"; import { Height, IdentifiedClientState } from "../../client/v1/client"; import { Any } from "../../../../google/protobuf/any"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long, Rpc } from "../../../../helpers"; +import { isSet, DeepPartial, Exact, bytesFromBase64, base64FromBytes, Long, Rpc } from "../../../../helpers"; export const protobufPackage = "ibc.core.connection.v1"; /** * QueryConnectionRequest is the request type for the Query/Connection RPC @@ -169,6 +169,18 @@ export const QueryConnectionRequest = { return message; }, + fromJSON(object: any): QueryConnectionRequest { + return { + connectionId: isSet(object.connectionId) ? String(object.connectionId) : "", + }; + }, + + toJSON(message: QueryConnectionRequest): unknown { + const obj: any = {}; + message.connectionId !== undefined && (obj.connectionId = message.connectionId); + return obj; + }, + fromPartial, I>>(object: I): QueryConnectionRequest { const message = createBaseQueryConnectionRequest(); message.connectionId = object.connectionId ?? ""; @@ -231,6 +243,25 @@ export const QueryConnectionResponse = { return message; }, + fromJSON(object: any): QueryConnectionResponse { + return { + connection: isSet(object.connection) ? ConnectionEnd.fromJSON(object.connection) : undefined, + proof: isSet(object.proof) ? bytesFromBase64(object.proof) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + }; + }, + + 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, I>>(object: I): QueryConnectionResponse { const message = createBaseQueryConnectionResponse(); message.connection = @@ -283,6 +314,19 @@ export const QueryConnectionsRequest = { return message; }, + fromJSON(object: any): QueryConnectionsRequest { + return { + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryConnectionsRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryConnectionsRequest { const message = createBaseQueryConnectionsRequest(); message.pagination = @@ -348,6 +392,31 @@ export const QueryConnectionsResponse = { return message; }, + fromJSON(object: any): QueryConnectionsResponse { + return { + connections: Array.isArray(object?.connections) + ? object.connections.map((e: any) => IdentifiedConnection.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + height: isSet(object.height) ? Height.fromJSON(object.height) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryConnectionsResponse { @@ -400,6 +469,18 @@ export const QueryClientConnectionsRequest = { return message; }, + fromJSON(object: any): QueryClientConnectionsRequest { + return { + clientId: isSet(object.clientId) ? String(object.clientId) : "", + }; + }, + + toJSON(message: QueryClientConnectionsRequest): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + return obj; + }, + fromPartial, I>>( object: I, ): QueryClientConnectionsRequest { @@ -464,6 +545,32 @@ export const QueryClientConnectionsResponse = { return message; }, + fromJSON(object: any): QueryClientConnectionsResponse { + return { + connectionPaths: Array.isArray(object?.connectionPaths) + ? object.connectionPaths.map((e: any) => String(e)) + : [], + proof: isSet(object.proof) ? bytesFromBase64(object.proof) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryClientConnectionsResponse { @@ -515,6 +622,18 @@ export const QueryConnectionClientStateRequest = { return message; }, + fromJSON(object: any): QueryConnectionClientStateRequest { + return { + connectionId: isSet(object.connectionId) ? String(object.connectionId) : "", + }; + }, + + toJSON(message: QueryConnectionClientStateRequest): unknown { + const obj: any = {}; + message.connectionId !== undefined && (obj.connectionId = message.connectionId); + return obj; + }, + fromPartial, I>>( object: I, ): QueryConnectionClientStateRequest { @@ -579,6 +698,29 @@ export const QueryConnectionClientStateResponse = { return message; }, + fromJSON(object: any): QueryConnectionClientStateResponse { + return { + identifiedClientState: isSet(object.identifiedClientState) + ? IdentifiedClientState.fromJSON(object.identifiedClientState) + : undefined, + proof: isSet(object.proof) ? bytesFromBase64(object.proof) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryConnectionClientStateResponse { @@ -654,6 +796,24 @@ export const QueryConnectionConsensusStateRequest = { return message; }, + fromJSON(object: any): QueryConnectionConsensusStateRequest { + return { + connectionId: isSet(object.connectionId) ? String(object.connectionId) : "", + revisionNumber: isSet(object.revisionNumber) ? Long.fromValue(object.revisionNumber) : Long.UZERO, + revisionHeight: isSet(object.revisionHeight) ? Long.fromValue(object.revisionHeight) : Long.UZERO, + }; + }, + + 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, I>>( object: I, ): QueryConnectionConsensusStateRequest { @@ -738,6 +898,27 @@ export const QueryConnectionConsensusStateResponse = { return message; }, + fromJSON(object: any): QueryConnectionConsensusStateResponse { + return { + consensusState: isSet(object.consensusState) ? Any.fromJSON(object.consensusState) : undefined, + clientId: isSet(object.clientId) ? String(object.clientId) : "", + proof: isSet(object.proof) ? bytesFromBase64(object.proof) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + }; + }, + + 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, I>>( object: I, ): QueryConnectionConsensusStateResponse { diff --git a/src/ibc/core/connection/v1/tx.ts b/src/ibc/core/connection/v1/tx.ts index 35c45e13..f8d70683 100644 --- a/src/ibc/core/connection/v1/tx.ts +++ b/src/ibc/core/connection/v1/tx.ts @@ -2,7 +2,7 @@ import { Counterparty, Version } from "./connection"; import { Any } from "../../../../google/protobuf/any"; import { Height } from "../../client/v1/client"; -import { Long, DeepPartial, Exact, Rpc } from "../../../../helpers"; +import { Long, isSet, DeepPartial, Exact, bytesFromBase64, base64FromBytes, Rpc } from "../../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "ibc.core.connection.v1"; /** @@ -181,6 +181,28 @@ export const MsgConnectionOpenInit = { return message; }, + fromJSON(object: any): MsgConnectionOpenInit { + return { + clientId: isSet(object.clientId) ? String(object.clientId) : "", + counterparty: isSet(object.counterparty) ? Counterparty.fromJSON(object.counterparty) : undefined, + version: isSet(object.version) ? Version.fromJSON(object.version) : undefined, + delayPeriod: isSet(object.delayPeriod) ? Long.fromValue(object.delayPeriod) : Long.UZERO, + signer: isSet(object.signer) ? String(object.signer) : "", + }; + }, + + toJSON(message: MsgConnectionOpenInit): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.counterparty !== undefined && + (obj.counterparty = message.counterparty ? Counterparty.toJSON(message.counterparty) : undefined); + message.version !== undefined && + (obj.version = message.version ? Version.toJSON(message.version) : undefined); + message.delayPeriod !== undefined && (obj.delayPeriod = (message.delayPeriod || Long.UZERO).toString()); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgConnectionOpenInit { const message = createBaseMsgConnectionOpenInit(); message.clientId = object.clientId ?? ""; @@ -228,6 +250,15 @@ export const MsgConnectionOpenInitResponse = { return message; }, + fromJSON(_: any): MsgConnectionOpenInitResponse { + return {}; + }, + + toJSON(_: MsgConnectionOpenInitResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( _: I, ): MsgConnectionOpenInitResponse { @@ -372,6 +403,63 @@ export const MsgConnectionOpenTry = { return message; }, + fromJSON(object: any): MsgConnectionOpenTry { + return { + clientId: isSet(object.clientId) ? String(object.clientId) : "", + previousConnectionId: isSet(object.previousConnectionId) ? String(object.previousConnectionId) : "", + clientState: isSet(object.clientState) ? Any.fromJSON(object.clientState) : undefined, + counterparty: isSet(object.counterparty) ? Counterparty.fromJSON(object.counterparty) : undefined, + delayPeriod: isSet(object.delayPeriod) ? Long.fromValue(object.delayPeriod) : Long.UZERO, + counterpartyVersions: Array.isArray(object?.counterpartyVersions) + ? object.counterpartyVersions.map((e: any) => Version.fromJSON(e)) + : [], + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + proofInit: isSet(object.proofInit) ? bytesFromBase64(object.proofInit) : new Uint8Array(), + proofClient: isSet(object.proofClient) ? bytesFromBase64(object.proofClient) : new Uint8Array(), + proofConsensus: isSet(object.proofConsensus) + ? bytesFromBase64(object.proofConsensus) + : new Uint8Array(), + consensusHeight: isSet(object.consensusHeight) ? Height.fromJSON(object.consensusHeight) : undefined, + signer: isSet(object.signer) ? String(object.signer) : "", + }; + }, + + toJSON(message: MsgConnectionOpenTry): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.previousConnectionId !== undefined && (obj.previousConnectionId = message.previousConnectionId); + message.clientState !== undefined && + (obj.clientState = message.clientState ? Any.toJSON(message.clientState) : undefined); + message.counterparty !== undefined && + (obj.counterparty = message.counterparty ? Counterparty.toJSON(message.counterparty) : undefined); + message.delayPeriod !== undefined && (obj.delayPeriod = (message.delayPeriod || Long.UZERO).toString()); + + if (message.counterpartyVersions) { + obj.counterpartyVersions = message.counterpartyVersions.map((e) => (e ? Version.toJSON(e) : undefined)); + } else { + obj.counterpartyVersions = []; + } + + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.proofInit !== undefined && + (obj.proofInit = base64FromBytes( + message.proofInit !== undefined ? message.proofInit : new Uint8Array(), + )); + message.proofClient !== undefined && + (obj.proofClient = base64FromBytes( + message.proofClient !== undefined ? message.proofClient : new Uint8Array(), + )); + message.proofConsensus !== undefined && + (obj.proofConsensus = base64FromBytes( + message.proofConsensus !== undefined ? message.proofConsensus : new Uint8Array(), + )); + message.consensusHeight !== undefined && + (obj.consensusHeight = message.consensusHeight ? Height.toJSON(message.consensusHeight) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgConnectionOpenTry { const message = createBaseMsgConnectionOpenTry(); message.clientId = object.clientId ?? ""; @@ -432,6 +520,15 @@ export const MsgConnectionOpenTryResponse = { return message; }, + fromJSON(_: any): MsgConnectionOpenTryResponse { + return {}; + }, + + toJSON(_: MsgConnectionOpenTryResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( _: I, ): MsgConnectionOpenTryResponse { @@ -558,6 +655,52 @@ export const MsgConnectionOpenAck = { return message; }, + fromJSON(object: any): MsgConnectionOpenAck { + return { + connectionId: isSet(object.connectionId) ? String(object.connectionId) : "", + counterpartyConnectionId: isSet(object.counterpartyConnectionId) + ? String(object.counterpartyConnectionId) + : "", + version: isSet(object.version) ? Version.fromJSON(object.version) : undefined, + clientState: isSet(object.clientState) ? Any.fromJSON(object.clientState) : undefined, + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + proofTry: isSet(object.proofTry) ? bytesFromBase64(object.proofTry) : new Uint8Array(), + proofClient: isSet(object.proofClient) ? bytesFromBase64(object.proofClient) : new Uint8Array(), + proofConsensus: isSet(object.proofConsensus) + ? bytesFromBase64(object.proofConsensus) + : new Uint8Array(), + consensusHeight: isSet(object.consensusHeight) ? Height.fromJSON(object.consensusHeight) : undefined, + signer: isSet(object.signer) ? String(object.signer) : "", + }; + }, + + toJSON(message: MsgConnectionOpenAck): unknown { + const obj: any = {}; + message.connectionId !== undefined && (obj.connectionId = message.connectionId); + message.counterpartyConnectionId !== undefined && + (obj.counterpartyConnectionId = message.counterpartyConnectionId); + message.version !== undefined && + (obj.version = message.version ? Version.toJSON(message.version) : undefined); + message.clientState !== undefined && + (obj.clientState = message.clientState ? Any.toJSON(message.clientState) : undefined); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.proofTry !== undefined && + (obj.proofTry = base64FromBytes(message.proofTry !== undefined ? message.proofTry : new Uint8Array())); + message.proofClient !== undefined && + (obj.proofClient = base64FromBytes( + message.proofClient !== undefined ? message.proofClient : new Uint8Array(), + )); + message.proofConsensus !== undefined && + (obj.proofConsensus = base64FromBytes( + message.proofConsensus !== undefined ? message.proofConsensus : new Uint8Array(), + )); + message.consensusHeight !== undefined && + (obj.consensusHeight = message.consensusHeight ? Height.toJSON(message.consensusHeight) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>(object: I): MsgConnectionOpenAck { const message = createBaseMsgConnectionOpenAck(); message.connectionId = object.connectionId ?? ""; @@ -613,6 +756,15 @@ export const MsgConnectionOpenAckResponse = { return message; }, + fromJSON(_: any): MsgConnectionOpenAckResponse { + return {}; + }, + + toJSON(_: MsgConnectionOpenAckResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( _: I, ): MsgConnectionOpenAckResponse { @@ -685,6 +837,26 @@ export const MsgConnectionOpenConfirm = { return message; }, + fromJSON(object: any): MsgConnectionOpenConfirm { + return { + connectionId: isSet(object.connectionId) ? String(object.connectionId) : "", + proofAck: isSet(object.proofAck) ? bytesFromBase64(object.proofAck) : new Uint8Array(), + proofHeight: isSet(object.proofHeight) ? Height.fromJSON(object.proofHeight) : undefined, + signer: isSet(object.signer) ? String(object.signer) : "", + }; + }, + + toJSON(message: MsgConnectionOpenConfirm): unknown { + const obj: any = {}; + message.connectionId !== undefined && (obj.connectionId = message.connectionId); + message.proofAck !== undefined && + (obj.proofAck = base64FromBytes(message.proofAck !== undefined ? message.proofAck : new Uint8Array())); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight ? Height.toJSON(message.proofHeight) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial, I>>( object: I, ): MsgConnectionOpenConfirm { @@ -727,6 +899,15 @@ export const MsgConnectionOpenConfirmResponse = { return message; }, + fromJSON(_: any): MsgConnectionOpenConfirmResponse { + return {}; + }, + + toJSON(_: MsgConnectionOpenConfirmResponse): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>( _: I, ): MsgConnectionOpenConfirmResponse { diff --git a/src/ibc/core/types/v1/genesis.ts b/src/ibc/core/types/v1/genesis.ts index 193abf7f..bf193adf 100644 --- a/src/ibc/core/types/v1/genesis.ts +++ b/src/ibc/core/types/v1/genesis.ts @@ -3,7 +3,7 @@ import { GenesisState as GenesisState1 } from "../../client/v1/genesis"; import { GenesisState as GenesisState2 } from "../../connection/v1/genesis"; import { GenesisState as GenesisState3 } from "../../channel/v1/genesis"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../../helpers"; export const protobufPackage = "ibc.core.types.v1"; /** GenesisState defines the ibc module's genesis state. */ @@ -73,6 +73,33 @@ export const GenesisState = { return message; }, + fromJSON(object: any): GenesisState { + return { + clientGenesis: isSet(object.clientGenesis) ? GenesisState1.fromJSON(object.clientGenesis) : undefined, + connectionGenesis: isSet(object.connectionGenesis) + ? GenesisState2.fromJSON(object.connectionGenesis) + : undefined, + channelGenesis: isSet(object.channelGenesis) + ? GenesisState3.fromJSON(object.channelGenesis) + : undefined, + }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.clientGenesis !== undefined && + (obj.clientGenesis = message.clientGenesis ? GenesisState1.toJSON(message.clientGenesis) : undefined); + message.connectionGenesis !== undefined && + (obj.connectionGenesis = message.connectionGenesis + ? GenesisState2.toJSON(message.connectionGenesis) + : undefined); + message.channelGenesis !== undefined && + (obj.channelGenesis = message.channelGenesis + ? GenesisState3.toJSON(message.channelGenesis) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): GenesisState { const message = createBaseGenesisState(); message.clientGenesis = diff --git a/src/ibc/lightclients/localhost/v1/localhost.ts b/src/ibc/lightclients/localhost/v1/localhost.ts index c8ce86b8..ade6eae2 100644 --- a/src/ibc/lightclients/localhost/v1/localhost.ts +++ b/src/ibc/lightclients/localhost/v1/localhost.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Height } from "../../../core/client/v1/client"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../../../helpers"; +import { isSet, DeepPartial, Exact } from "../../../../helpers"; export const protobufPackage = "ibc.lightclients.localhost.v1"; /** * ClientState defines a loopback (localhost) client. It requires (read-only) @@ -62,6 +62,20 @@ export const ClientState = { return message; }, + fromJSON(object: any): ClientState { + return { + chainId: isSet(object.chainId) ? String(object.chainId) : "", + height: isSet(object.height) ? Height.fromJSON(object.height) : undefined, + }; + }, + + toJSON(message: ClientState): unknown { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + message.height !== undefined && (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + fromPartial, I>>(object: I): ClientState { const message = createBaseClientState(); message.chainId = object.chainId ?? ""; diff --git a/src/ibc/lightclients/solomachine/v1/solomachine.ts b/src/ibc/lightclients/solomachine/v1/solomachine.ts index 7c7a95db..4eb2d763 100644 --- a/src/ibc/lightclients/solomachine/v1/solomachine.ts +++ b/src/ibc/lightclients/solomachine/v1/solomachine.ts @@ -2,7 +2,7 @@ import { Any } from "../../../../google/protobuf/any"; import { ConnectionEnd } from "../../../core/connection/v1/connection"; import { Channel } from "../../../core/channel/v1/channel"; -import { Long, DeepPartial, Exact } from "../../../../helpers"; +import { Long, isSet, DeepPartial, Exact, bytesFromBase64, base64FromBytes } from "../../../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "ibc.lightclients.solomachine.v1"; /** @@ -360,6 +360,33 @@ export const ClientState = { return message; }, + fromJSON(object: any): ClientState { + return { + sequence: isSet(object.sequence) ? Long.fromValue(object.sequence) : Long.UZERO, + frozenSequence: isSet(object.frozenSequence) ? Long.fromValue(object.frozenSequence) : Long.UZERO, + consensusState: isSet(object.consensusState) + ? ConsensusState.fromJSON(object.consensusState) + : undefined, + allowUpdateAfterProposal: isSet(object.allowUpdateAfterProposal) + ? Boolean(object.allowUpdateAfterProposal) + : false, + }; + }, + + toJSON(message: ClientState): unknown { + const obj: any = {}; + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + message.frozenSequence !== undefined && + (obj.frozenSequence = (message.frozenSequence || Long.UZERO).toString()); + message.consensusState !== undefined && + (obj.consensusState = message.consensusState + ? ConsensusState.toJSON(message.consensusState) + : undefined); + message.allowUpdateAfterProposal !== undefined && + (obj.allowUpdateAfterProposal = message.allowUpdateAfterProposal); + return obj; + }, + fromPartial, I>>(object: I): ClientState { const message = createBaseClientState(); message.sequence = @@ -434,6 +461,23 @@ export const ConsensusState = { return message; }, + fromJSON(object: any): ConsensusState { + return { + publicKey: isSet(object.publicKey) ? Any.fromJSON(object.publicKey) : undefined, + diversifier: isSet(object.diversifier) ? String(object.diversifier) : "", + timestamp: isSet(object.timestamp) ? Long.fromValue(object.timestamp) : Long.UZERO, + }; + }, + + toJSON(message: ConsensusState): unknown { + const obj: any = {}; + message.publicKey !== undefined && + (obj.publicKey = message.publicKey ? Any.toJSON(message.publicKey) : undefined); + message.diversifier !== undefined && (obj.diversifier = message.diversifier); + message.timestamp !== undefined && (obj.timestamp = (message.timestamp || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): ConsensusState { const message = createBaseConsensusState(); message.publicKey = @@ -522,6 +566,30 @@ export const Header = { return message; }, + fromJSON(object: any): Header { + return { + sequence: isSet(object.sequence) ? Long.fromValue(object.sequence) : Long.UZERO, + timestamp: isSet(object.timestamp) ? Long.fromValue(object.timestamp) : Long.UZERO, + signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(), + newPublicKey: isSet(object.newPublicKey) ? Any.fromJSON(object.newPublicKey) : undefined, + newDiversifier: isSet(object.newDiversifier) ? String(object.newDiversifier) : "", + }; + }, + + toJSON(message: Header): unknown { + const obj: any = {}; + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + message.timestamp !== undefined && (obj.timestamp = (message.timestamp || Long.UZERO).toString()); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array(), + )); + message.newPublicKey !== undefined && + (obj.newPublicKey = message.newPublicKey ? Any.toJSON(message.newPublicKey) : undefined); + message.newDiversifier !== undefined && (obj.newDiversifier = message.newDiversifier); + return obj; + }, + fromPartial, I>>(object: I): Header { const message = createBaseHeader(); message.sequence = @@ -606,6 +674,26 @@ export const Misbehaviour = { return message; }, + fromJSON(object: any): Misbehaviour { + return { + clientId: isSet(object.clientId) ? String(object.clientId) : "", + sequence: isSet(object.sequence) ? Long.fromValue(object.sequence) : Long.UZERO, + signatureOne: isSet(object.signatureOne) ? SignatureAndData.fromJSON(object.signatureOne) : undefined, + signatureTwo: isSet(object.signatureTwo) ? SignatureAndData.fromJSON(object.signatureTwo) : undefined, + }; + }, + + toJSON(message: Misbehaviour): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + message.signatureOne !== undefined && + (obj.signatureOne = message.signatureOne ? SignatureAndData.toJSON(message.signatureOne) : undefined); + message.signatureTwo !== undefined && + (obj.signatureTwo = message.signatureTwo ? SignatureAndData.toJSON(message.signatureTwo) : undefined); + return obj; + }, + fromPartial, I>>(object: I): Misbehaviour { const message = createBaseMisbehaviour(); message.clientId = object.clientId ?? ""; @@ -689,6 +777,28 @@ export const SignatureAndData = { return message; }, + fromJSON(object: any): SignatureAndData { + return { + signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(), + dataType: isSet(object.dataType) ? dataTypeFromJSON(object.dataType) : 0, + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + timestamp: isSet(object.timestamp) ? Long.fromValue(object.timestamp) : Long.UZERO, + }; + }, + + toJSON(message: SignatureAndData): unknown { + const obj: any = {}; + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array(), + )); + message.dataType !== undefined && (obj.dataType = dataTypeToJSON(message.dataType)); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + message.timestamp !== undefined && (obj.timestamp = (message.timestamp || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): SignatureAndData { const message = createBaseSignatureAndData(); message.signature = object.signature ?? new Uint8Array(); @@ -748,6 +858,23 @@ export const TimestampedSignatureData = { return message; }, + fromJSON(object: any): TimestampedSignatureData { + return { + signatureData: isSet(object.signatureData) ? bytesFromBase64(object.signatureData) : new Uint8Array(), + timestamp: isSet(object.timestamp) ? Long.fromValue(object.timestamp) : Long.UZERO, + }; + }, + + toJSON(message: TimestampedSignatureData): unknown { + const obj: any = {}; + message.signatureData !== undefined && + (obj.signatureData = base64FromBytes( + message.signatureData !== undefined ? message.signatureData : new Uint8Array(), + )); + message.timestamp !== undefined && (obj.timestamp = (message.timestamp || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>( object: I, ): TimestampedSignatureData { @@ -834,6 +961,27 @@ export const SignBytes = { return message; }, + fromJSON(object: any): SignBytes { + return { + sequence: isSet(object.sequence) ? Long.fromValue(object.sequence) : Long.UZERO, + timestamp: isSet(object.timestamp) ? Long.fromValue(object.timestamp) : Long.UZERO, + diversifier: isSet(object.diversifier) ? String(object.diversifier) : "", + dataType: isSet(object.dataType) ? dataTypeFromJSON(object.dataType) : 0, + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + }; + }, + + toJSON(message: SignBytes): unknown { + const obj: any = {}; + message.sequence !== undefined && (obj.sequence = (message.sequence || Long.UZERO).toString()); + message.timestamp !== undefined && (obj.timestamp = (message.timestamp || Long.UZERO).toString()); + message.diversifier !== undefined && (obj.diversifier = message.diversifier); + message.dataType !== undefined && (obj.dataType = dataTypeToJSON(message.dataType)); + message.data !== undefined && + (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): SignBytes { const message = createBaseSignBytes(); message.sequence = @@ -897,6 +1045,21 @@ export const HeaderData = { return message; }, + fromJSON(object: any): HeaderData { + return { + newPubKey: isSet(object.newPubKey) ? Any.fromJSON(object.newPubKey) : undefined, + newDiversifier: isSet(object.newDiversifier) ? String(object.newDiversifier) : "", + }; + }, + + toJSON(message: HeaderData): unknown { + const obj: any = {}; + message.newPubKey !== undefined && + (obj.newPubKey = message.newPubKey ? Any.toJSON(message.newPubKey) : undefined); + message.newDiversifier !== undefined && (obj.newDiversifier = message.newDiversifier); + return obj; + }, + fromPartial, I>>(object: I): HeaderData { const message = createBaseHeaderData(); message.newPubKey = @@ -954,6 +1117,22 @@ export const ClientStateData = { return message; }, + fromJSON(object: any): ClientStateData { + return { + path: isSet(object.path) ? bytesFromBase64(object.path) : new Uint8Array(), + clientState: isSet(object.clientState) ? Any.fromJSON(object.clientState) : undefined, + }; + }, + + toJSON(message: ClientStateData): unknown { + const obj: any = {}; + message.path !== undefined && + (obj.path = base64FromBytes(message.path !== undefined ? message.path : new Uint8Array())); + message.clientState !== undefined && + (obj.clientState = message.clientState ? Any.toJSON(message.clientState) : undefined); + return obj; + }, + fromPartial, I>>(object: I): ClientStateData { const message = createBaseClientStateData(); message.path = object.path ?? new Uint8Array(); @@ -1011,6 +1190,22 @@ export const ConsensusStateData = { return message; }, + fromJSON(object: any): ConsensusStateData { + return { + path: isSet(object.path) ? bytesFromBase64(object.path) : new Uint8Array(), + consensusState: isSet(object.consensusState) ? Any.fromJSON(object.consensusState) : undefined, + }; + }, + + toJSON(message: ConsensusStateData): unknown { + const obj: any = {}; + message.path !== undefined && + (obj.path = base64FromBytes(message.path !== undefined ? message.path : new Uint8Array())); + message.consensusState !== undefined && + (obj.consensusState = message.consensusState ? Any.toJSON(message.consensusState) : undefined); + return obj; + }, + fromPartial, I>>(object: I): ConsensusStateData { const message = createBaseConsensusStateData(); message.path = object.path ?? new Uint8Array(); @@ -1068,6 +1263,22 @@ export const ConnectionStateData = { return message; }, + fromJSON(object: any): ConnectionStateData { + return { + path: isSet(object.path) ? bytesFromBase64(object.path) : new Uint8Array(), + connection: isSet(object.connection) ? ConnectionEnd.fromJSON(object.connection) : undefined, + }; + }, + + toJSON(message: ConnectionStateData): unknown { + const obj: any = {}; + message.path !== undefined && + (obj.path = base64FromBytes(message.path !== undefined ? message.path : new Uint8Array())); + message.connection !== undefined && + (obj.connection = message.connection ? ConnectionEnd.toJSON(message.connection) : undefined); + return obj; + }, + fromPartial, I>>(object: I): ConnectionStateData { const message = createBaseConnectionStateData(); message.path = object.path ?? new Uint8Array(); @@ -1125,6 +1336,22 @@ export const ChannelStateData = { return message; }, + fromJSON(object: any): ChannelStateData { + return { + path: isSet(object.path) ? bytesFromBase64(object.path) : new Uint8Array(), + channel: isSet(object.channel) ? Channel.fromJSON(object.channel) : undefined, + }; + }, + + toJSON(message: ChannelStateData): unknown { + const obj: any = {}; + message.path !== undefined && + (obj.path = base64FromBytes(message.path !== undefined ? message.path : new Uint8Array())); + message.channel !== undefined && + (obj.channel = message.channel ? Channel.toJSON(message.channel) : undefined); + return obj; + }, + fromPartial, I>>(object: I): ChannelStateData { const message = createBaseChannelStateData(); message.path = object.path ?? new Uint8Array(); @@ -1182,6 +1409,24 @@ export const PacketCommitmentData = { return message; }, + fromJSON(object: any): PacketCommitmentData { + return { + path: isSet(object.path) ? bytesFromBase64(object.path) : new Uint8Array(), + commitment: isSet(object.commitment) ? bytesFromBase64(object.commitment) : new Uint8Array(), + }; + }, + + toJSON(message: PacketCommitmentData): unknown { + const obj: any = {}; + message.path !== undefined && + (obj.path = base64FromBytes(message.path !== undefined ? message.path : new Uint8Array())); + message.commitment !== undefined && + (obj.commitment = base64FromBytes( + message.commitment !== undefined ? message.commitment : new Uint8Array(), + )); + return obj; + }, + fromPartial, I>>(object: I): PacketCommitmentData { const message = createBasePacketCommitmentData(); message.path = object.path ?? new Uint8Array(); @@ -1236,6 +1481,26 @@ export const PacketAcknowledgementData = { return message; }, + fromJSON(object: any): PacketAcknowledgementData { + return { + path: isSet(object.path) ? bytesFromBase64(object.path) : new Uint8Array(), + acknowledgement: isSet(object.acknowledgement) + ? bytesFromBase64(object.acknowledgement) + : new Uint8Array(), + }; + }, + + toJSON(message: PacketAcknowledgementData): unknown { + const obj: any = {}; + message.path !== undefined && + (obj.path = base64FromBytes(message.path !== undefined ? message.path : new Uint8Array())); + message.acknowledgement !== undefined && + (obj.acknowledgement = base64FromBytes( + message.acknowledgement !== undefined ? message.acknowledgement : new Uint8Array(), + )); + return obj; + }, + fromPartial, I>>( object: I, ): PacketAcknowledgementData { @@ -1283,6 +1548,19 @@ export const PacketReceiptAbsenceData = { return message; }, + fromJSON(object: any): PacketReceiptAbsenceData { + return { + path: isSet(object.path) ? bytesFromBase64(object.path) : new Uint8Array(), + }; + }, + + toJSON(message: PacketReceiptAbsenceData): unknown { + const obj: any = {}; + message.path !== undefined && + (obj.path = base64FromBytes(message.path !== undefined ? message.path : new Uint8Array())); + return obj; + }, + fromPartial, I>>( object: I, ): PacketReceiptAbsenceData { @@ -1338,6 +1616,21 @@ export const NextSequenceRecvData = { return message; }, + fromJSON(object: any): NextSequenceRecvData { + return { + path: isSet(object.path) ? bytesFromBase64(object.path) : new Uint8Array(), + nextSeqRecv: isSet(object.nextSeqRecv) ? Long.fromValue(object.nextSeqRecv) : Long.UZERO, + }; + }, + + toJSON(message: NextSequenceRecvData): unknown { + const obj: any = {}; + message.path !== undefined && + (obj.path = base64FromBytes(message.path !== undefined ? message.path : new Uint8Array())); + message.nextSeqRecv !== undefined && (obj.nextSeqRecv = (message.nextSeqRecv || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): NextSequenceRecvData { const message = createBaseNextSequenceRecvData(); message.path = object.path ?? new Uint8Array(); diff --git a/src/ibc/lightclients/tendermint/v1/tendermint.ts b/src/ibc/lightclients/tendermint/v1/tendermint.ts index a329d749..a6432007 100644 --- a/src/ibc/lightclients/tendermint/v1/tendermint.ts +++ b/src/ibc/lightclients/tendermint/v1/tendermint.ts @@ -7,7 +7,16 @@ import { MerkleRoot } from "../../../core/commitment/v1/commitment"; import { SignedHeader } from "../../../../tendermint/types/types"; import { ValidatorSet } from "../../../../tendermint/types/validator"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../../../helpers"; +import { + isSet, + DeepPartial, + Exact, + fromJsonTimestamp, + bytesFromBase64, + fromTimestamp, + base64FromBytes, + Long, +} from "../../../../helpers"; export const protobufPackage = "ibc.lightclients.tendermint.v1"; /** * ClientState from Tendermint tracks the current validator set, latest height, @@ -243,6 +252,63 @@ export const ClientState = { return message; }, + fromJSON(object: any): ClientState { + return { + chainId: isSet(object.chainId) ? String(object.chainId) : "", + trustLevel: isSet(object.trustLevel) ? Fraction.fromJSON(object.trustLevel) : undefined, + trustingPeriod: isSet(object.trustingPeriod) ? Duration.fromJSON(object.trustingPeriod) : undefined, + unbondingPeriod: isSet(object.unbondingPeriod) ? Duration.fromJSON(object.unbondingPeriod) : undefined, + maxClockDrift: isSet(object.maxClockDrift) ? Duration.fromJSON(object.maxClockDrift) : undefined, + frozenHeight: isSet(object.frozenHeight) ? Height.fromJSON(object.frozenHeight) : undefined, + latestHeight: isSet(object.latestHeight) ? Height.fromJSON(object.latestHeight) : undefined, + proofSpecs: Array.isArray(object?.proofSpecs) + ? object.proofSpecs.map((e: any) => ProofSpec.fromJSON(e)) + : [], + upgradePath: Array.isArray(object?.upgradePath) ? object.upgradePath.map((e: any) => String(e)) : [], + allowUpdateAfterExpiry: isSet(object.allowUpdateAfterExpiry) + ? Boolean(object.allowUpdateAfterExpiry) + : false, + allowUpdateAfterMisbehaviour: isSet(object.allowUpdateAfterMisbehaviour) + ? Boolean(object.allowUpdateAfterMisbehaviour) + : false, + }; + }, + + toJSON(message: ClientState): unknown { + const obj: any = {}; + message.chainId !== undefined && (obj.chainId = message.chainId); + message.trustLevel !== undefined && + (obj.trustLevel = message.trustLevel ? Fraction.toJSON(message.trustLevel) : undefined); + message.trustingPeriod !== undefined && + (obj.trustingPeriod = message.trustingPeriod ? Duration.toJSON(message.trustingPeriod) : undefined); + message.unbondingPeriod !== undefined && + (obj.unbondingPeriod = message.unbondingPeriod ? Duration.toJSON(message.unbondingPeriod) : undefined); + message.maxClockDrift !== undefined && + (obj.maxClockDrift = message.maxClockDrift ? Duration.toJSON(message.maxClockDrift) : undefined); + message.frozenHeight !== undefined && + (obj.frozenHeight = message.frozenHeight ? Height.toJSON(message.frozenHeight) : undefined); + message.latestHeight !== undefined && + (obj.latestHeight = message.latestHeight ? Height.toJSON(message.latestHeight) : undefined); + + if (message.proofSpecs) { + obj.proofSpecs = message.proofSpecs.map((e) => (e ? ProofSpec.toJSON(e) : undefined)); + } else { + obj.proofSpecs = []; + } + + if (message.upgradePath) { + obj.upgradePath = message.upgradePath.map((e) => e); + } else { + obj.upgradePath = []; + } + + message.allowUpdateAfterExpiry !== undefined && + (obj.allowUpdateAfterExpiry = message.allowUpdateAfterExpiry); + message.allowUpdateAfterMisbehaviour !== undefined && + (obj.allowUpdateAfterMisbehaviour = message.allowUpdateAfterMisbehaviour); + return obj; + }, + fromPartial, I>>(object: I): ClientState { const message = createBaseClientState(); message.chainId = object.chainId ?? ""; @@ -333,6 +399,27 @@ export const ConsensusState = { return message; }, + fromJSON(object: any): ConsensusState { + return { + timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined, + root: isSet(object.root) ? MerkleRoot.fromJSON(object.root) : undefined, + nextValidatorsHash: isSet(object.nextValidatorsHash) + ? bytesFromBase64(object.nextValidatorsHash) + : new Uint8Array(), + }; + }, + + toJSON(message: ConsensusState): unknown { + const obj: any = {}; + message.timestamp !== undefined && (obj.timestamp = fromTimestamp(message.timestamp).toISOString()); + message.root !== undefined && (obj.root = message.root ? MerkleRoot.toJSON(message.root) : undefined); + message.nextValidatorsHash !== undefined && + (obj.nextValidatorsHash = base64FromBytes( + message.nextValidatorsHash !== undefined ? message.nextValidatorsHash : new Uint8Array(), + )); + return obj; + }, + fromPartial, I>>(object: I): ConsensusState { const message = createBaseConsensusState(); message.timestamp = @@ -401,6 +488,24 @@ export const Misbehaviour = { return message; }, + fromJSON(object: any): Misbehaviour { + return { + clientId: isSet(object.clientId) ? String(object.clientId) : "", + header1: isSet(object.header1) ? Header.fromJSON(object.header1) : undefined, + header2: isSet(object.header2) ? Header.fromJSON(object.header2) : undefined, + }; + }, + + toJSON(message: Misbehaviour): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.header1 !== undefined && + (obj.header1 = message.header1 ? Header.toJSON(message.header1) : undefined); + message.header2 !== undefined && + (obj.header2 = message.header2 ? Header.toJSON(message.header2) : undefined); + return obj; + }, + fromPartial, I>>(object: I): Misbehaviour { const message = createBaseMisbehaviour(); message.clientId = object.clientId ?? ""; @@ -480,6 +585,32 @@ export const Header = { return message; }, + fromJSON(object: any): Header { + return { + signedHeader: isSet(object.signedHeader) ? SignedHeader.fromJSON(object.signedHeader) : undefined, + validatorSet: isSet(object.validatorSet) ? ValidatorSet.fromJSON(object.validatorSet) : undefined, + trustedHeight: isSet(object.trustedHeight) ? Height.fromJSON(object.trustedHeight) : undefined, + trustedValidators: isSet(object.trustedValidators) + ? ValidatorSet.fromJSON(object.trustedValidators) + : undefined, + }; + }, + + toJSON(message: Header): unknown { + const obj: any = {}; + message.signedHeader !== undefined && + (obj.signedHeader = message.signedHeader ? SignedHeader.toJSON(message.signedHeader) : undefined); + message.validatorSet !== undefined && + (obj.validatorSet = message.validatorSet ? ValidatorSet.toJSON(message.validatorSet) : undefined); + message.trustedHeight !== undefined && + (obj.trustedHeight = message.trustedHeight ? Height.toJSON(message.trustedHeight) : undefined); + message.trustedValidators !== undefined && + (obj.trustedValidators = message.trustedValidators + ? ValidatorSet.toJSON(message.trustedValidators) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): Header { const message = createBaseHeader(); message.signedHeader = @@ -548,6 +679,20 @@ export const Fraction = { return message; }, + fromJSON(object: any): Fraction { + return { + numerator: isSet(object.numerator) ? Long.fromValue(object.numerator) : Long.UZERO, + denominator: isSet(object.denominator) ? Long.fromValue(object.denominator) : Long.UZERO, + }; + }, + + toJSON(message: Fraction): unknown { + const obj: any = {}; + message.numerator !== undefined && (obj.numerator = (message.numerator || Long.UZERO).toString()); + message.denominator !== undefined && (obj.denominator = (message.denominator || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): Fraction { const message = createBaseFraction(); message.numerator = diff --git a/src/tendermint/abci/types.ts b/src/tendermint/abci/types.ts index c67d115d..ce724ebf 100644 --- a/src/tendermint/abci/types.ts +++ b/src/tendermint/abci/types.ts @@ -5,7 +5,17 @@ import { ProofOps } from "../crypto/proof"; import { EvidenceParams, ValidatorParams, VersionParams } from "../types/params"; import { PublicKey } from "../crypto/keys"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long, Rpc } from "../../helpers"; +import { + isSet, + DeepPartial, + Exact, + Long, + fromJsonTimestamp, + bytesFromBase64, + fromTimestamp, + base64FromBytes, + Rpc, +} from "../../helpers"; export const protobufPackage = "tendermint.abci"; export enum CheckTxType { NEW = 0, @@ -726,6 +736,75 @@ export const Request = { return message; }, + fromJSON(object: any): Request { + return { + echo: isSet(object.echo) ? RequestEcho.fromJSON(object.echo) : undefined, + flush: isSet(object.flush) ? RequestFlush.fromJSON(object.flush) : undefined, + info: isSet(object.info) ? RequestInfo.fromJSON(object.info) : undefined, + setOption: isSet(object.setOption) ? RequestSetOption.fromJSON(object.setOption) : undefined, + initChain: isSet(object.initChain) ? RequestInitChain.fromJSON(object.initChain) : undefined, + query: isSet(object.query) ? RequestQuery.fromJSON(object.query) : undefined, + beginBlock: isSet(object.beginBlock) ? RequestBeginBlock.fromJSON(object.beginBlock) : undefined, + checkTx: isSet(object.checkTx) ? RequestCheckTx.fromJSON(object.checkTx) : undefined, + deliverTx: isSet(object.deliverTx) ? RequestDeliverTx.fromJSON(object.deliverTx) : undefined, + endBlock: isSet(object.endBlock) ? RequestEndBlock.fromJSON(object.endBlock) : undefined, + commit: isSet(object.commit) ? RequestCommit.fromJSON(object.commit) : undefined, + listSnapshots: isSet(object.listSnapshots) + ? RequestListSnapshots.fromJSON(object.listSnapshots) + : undefined, + offerSnapshot: isSet(object.offerSnapshot) + ? RequestOfferSnapshot.fromJSON(object.offerSnapshot) + : undefined, + loadSnapshotChunk: isSet(object.loadSnapshotChunk) + ? RequestLoadSnapshotChunk.fromJSON(object.loadSnapshotChunk) + : undefined, + applySnapshotChunk: isSet(object.applySnapshotChunk) + ? RequestApplySnapshotChunk.fromJSON(object.applySnapshotChunk) + : undefined, + }; + }, + + 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, I>>(object: I): Request { const message = createBaseRequest(); message.echo = @@ -825,6 +904,18 @@ export const RequestEcho = { return message; }, + fromJSON(object: any): RequestEcho { + return { + message: isSet(object.message) ? String(object.message) : "", + }; + }, + + toJSON(message: RequestEcho): unknown { + const obj: any = {}; + message.message !== undefined && (obj.message = message.message); + return obj; + }, + fromPartial, I>>(object: I): RequestEcho { const message = createBaseRequestEcho(); message.message = object.message ?? ""; @@ -859,6 +950,15 @@ export const RequestFlush = { return message; }, + fromJSON(_: any): RequestFlush { + return {}; + }, + + toJSON(_: RequestFlush): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): RequestFlush { const message = createBaseRequestFlush(); return message; @@ -920,6 +1020,23 @@ export const RequestInfo = { return message; }, + fromJSON(object: any): RequestInfo { + return { + version: isSet(object.version) ? String(object.version) : "", + blockVersion: isSet(object.blockVersion) ? Long.fromValue(object.blockVersion) : Long.UZERO, + p2pVersion: isSet(object.p2pVersion) ? Long.fromValue(object.p2pVersion) : Long.UZERO, + }; + }, + + 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, I>>(object: I): RequestInfo { const message = createBaseRequestInfo(); message.version = object.version ?? ""; @@ -981,6 +1098,20 @@ export const RequestSetOption = { return message; }, + fromJSON(object: any): RequestSetOption { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "", + }; + }, + + toJSON(message: RequestSetOption): unknown { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial, I>>(object: I): RequestSetOption { const message = createBaseRequestSetOption(); message.key = object.key ?? ""; @@ -1071,6 +1202,45 @@ export const RequestInitChain = { return message; }, + fromJSON(object: any): RequestInitChain { + return { + time: isSet(object.time) ? fromJsonTimestamp(object.time) : undefined, + chainId: isSet(object.chainId) ? String(object.chainId) : "", + consensusParams: isSet(object.consensusParams) + ? ConsensusParams.fromJSON(object.consensusParams) + : undefined, + validators: Array.isArray(object?.validators) + ? object.validators.map((e: any) => ValidatorUpdate.fromJSON(e)) + : [], + appStateBytes: isSet(object.appStateBytes) ? bytesFromBase64(object.appStateBytes) : new Uint8Array(), + initialHeight: isSet(object.initialHeight) ? Long.fromValue(object.initialHeight) : Long.ZERO, + }; + }, + + toJSON(message: RequestInitChain): unknown { + const obj: any = {}; + message.time !== undefined && (obj.time = fromTimestamp(message.time).toISOString()); + 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, I>>(object: I): RequestInitChain { const message = createBaseRequestInitChain(); message.time = @@ -1154,6 +1324,25 @@ export const RequestQuery = { return message; }, + fromJSON(object: any): RequestQuery { + return { + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + path: isSet(object.path) ? String(object.path) : "", + height: isSet(object.height) ? Long.fromValue(object.height) : Long.ZERO, + prove: isSet(object.prove) ? Boolean(object.prove) : false, + }; + }, + + 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, I>>(object: I): RequestQuery { const message = createBaseRequestQuery(); message.data = object.data ?? new Uint8Array(); @@ -1229,6 +1418,38 @@ export const RequestBeginBlock = { return message; }, + fromJSON(object: any): RequestBeginBlock { + return { + hash: isSet(object.hash) ? bytesFromBase64(object.hash) : new Uint8Array(), + header: isSet(object.header) ? Header.fromJSON(object.header) : undefined, + lastCommitInfo: isSet(object.lastCommitInfo) + ? LastCommitInfo.fromJSON(object.lastCommitInfo) + : undefined, + byzantineValidators: Array.isArray(object?.byzantineValidators) + ? object.byzantineValidators.map((e: any) => Evidence.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): RequestBeginBlock { const message = createBaseRequestBeginBlock(); message.hash = object.hash ?? new Uint8Array(); @@ -1289,6 +1510,21 @@ export const RequestCheckTx = { return message; }, + fromJSON(object: any): RequestCheckTx { + return { + tx: isSet(object.tx) ? bytesFromBase64(object.tx) : new Uint8Array(), + type: isSet(object.type) ? checkTxTypeFromJSON(object.type) : 0, + }; + }, + + 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, I>>(object: I): RequestCheckTx { const message = createBaseRequestCheckTx(); message.tx = object.tx ?? new Uint8Array(); @@ -1334,6 +1570,19 @@ export const RequestDeliverTx = { return message; }, + fromJSON(object: any): RequestDeliverTx { + return { + tx: isSet(object.tx) ? bytesFromBase64(object.tx) : new Uint8Array(), + }; + }, + + toJSON(message: RequestDeliverTx): unknown { + const obj: any = {}; + message.tx !== undefined && + (obj.tx = base64FromBytes(message.tx !== undefined ? message.tx : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): RequestDeliverTx { const message = createBaseRequestDeliverTx(); message.tx = object.tx ?? new Uint8Array(); @@ -1378,6 +1627,18 @@ export const RequestEndBlock = { return message; }, + fromJSON(object: any): RequestEndBlock { + return { + height: isSet(object.height) ? Long.fromValue(object.height) : Long.ZERO, + }; + }, + + toJSON(message: RequestEndBlock): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): RequestEndBlock { const message = createBaseRequestEndBlock(); message.height = @@ -1413,6 +1674,15 @@ export const RequestCommit = { return message; }, + fromJSON(_: any): RequestCommit { + return {}; + }, + + toJSON(_: RequestCommit): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): RequestCommit { const message = createBaseRequestCommit(); return message; @@ -1446,6 +1716,15 @@ export const RequestListSnapshots = { return message; }, + fromJSON(_: any): RequestListSnapshots { + return {}; + }, + + toJSON(_: RequestListSnapshots): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): RequestListSnapshots { const message = createBaseRequestListSnapshots(); return message; @@ -1498,6 +1777,22 @@ export const RequestOfferSnapshot = { return message; }, + fromJSON(object: any): RequestOfferSnapshot { + return { + snapshot: isSet(object.snapshot) ? Snapshot.fromJSON(object.snapshot) : undefined, + appHash: isSet(object.appHash) ? bytesFromBase64(object.appHash) : new Uint8Array(), + }; + }, + + 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, I>>(object: I): RequestOfferSnapshot { const message = createBaseRequestOfferSnapshot(); message.snapshot = @@ -1564,6 +1859,22 @@ export const RequestLoadSnapshotChunk = { return message; }, + fromJSON(object: any): RequestLoadSnapshotChunk { + return { + height: isSet(object.height) ? Long.fromValue(object.height) : Long.UZERO, + format: isSet(object.format) ? Number(object.format) : 0, + chunk: isSet(object.chunk) ? Number(object.chunk) : 0, + }; + }, + + toJSON(message: RequestLoadSnapshotChunk): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.UZERO).toString()); + message.format !== undefined && (obj.format = Math.round(message.format)); + message.chunk !== undefined && (obj.chunk = Math.round(message.chunk)); + return obj; + }, + fromPartial, I>>( object: I, ): RequestLoadSnapshotChunk { @@ -1631,6 +1942,23 @@ export const RequestApplySnapshotChunk = { return message; }, + fromJSON(object: any): RequestApplySnapshotChunk { + return { + index: isSet(object.index) ? Number(object.index) : 0, + chunk: isSet(object.chunk) ? bytesFromBase64(object.chunk) : new Uint8Array(), + sender: isSet(object.sender) ? String(object.sender) : "", + }; + }, + + toJSON(message: RequestApplySnapshotChunk): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = Math.round(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, I>>( object: I, ): RequestApplySnapshotChunk { @@ -1814,6 +2142,78 @@ export const Response = { return message; }, + fromJSON(object: any): Response { + return { + exception: isSet(object.exception) ? ResponseException.fromJSON(object.exception) : undefined, + echo: isSet(object.echo) ? ResponseEcho.fromJSON(object.echo) : undefined, + flush: isSet(object.flush) ? ResponseFlush.fromJSON(object.flush) : undefined, + info: isSet(object.info) ? ResponseInfo.fromJSON(object.info) : undefined, + setOption: isSet(object.setOption) ? ResponseSetOption.fromJSON(object.setOption) : undefined, + initChain: isSet(object.initChain) ? ResponseInitChain.fromJSON(object.initChain) : undefined, + query: isSet(object.query) ? ResponseQuery.fromJSON(object.query) : undefined, + beginBlock: isSet(object.beginBlock) ? ResponseBeginBlock.fromJSON(object.beginBlock) : undefined, + checkTx: isSet(object.checkTx) ? ResponseCheckTx.fromJSON(object.checkTx) : undefined, + deliverTx: isSet(object.deliverTx) ? ResponseDeliverTx.fromJSON(object.deliverTx) : undefined, + endBlock: isSet(object.endBlock) ? ResponseEndBlock.fromJSON(object.endBlock) : undefined, + commit: isSet(object.commit) ? ResponseCommit.fromJSON(object.commit) : undefined, + listSnapshots: isSet(object.listSnapshots) + ? ResponseListSnapshots.fromJSON(object.listSnapshots) + : undefined, + offerSnapshot: isSet(object.offerSnapshot) + ? ResponseOfferSnapshot.fromJSON(object.offerSnapshot) + : undefined, + loadSnapshotChunk: isSet(object.loadSnapshotChunk) + ? ResponseLoadSnapshotChunk.fromJSON(object.loadSnapshotChunk) + : undefined, + applySnapshotChunk: isSet(object.applySnapshotChunk) + ? ResponseApplySnapshotChunk.fromJSON(object.applySnapshotChunk) + : undefined, + }; + }, + + 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, I>>(object: I): Response { const message = createBaseResponse(); message.exception = @@ -1917,6 +2317,18 @@ export const ResponseException = { return message; }, + fromJSON(object: any): ResponseException { + return { + error: isSet(object.error) ? String(object.error) : "", + }; + }, + + toJSON(message: ResponseException): unknown { + const obj: any = {}; + message.error !== undefined && (obj.error = message.error); + return obj; + }, + fromPartial, I>>(object: I): ResponseException { const message = createBaseResponseException(); message.error = object.error ?? ""; @@ -1961,6 +2373,18 @@ export const ResponseEcho = { return message; }, + fromJSON(object: any): ResponseEcho { + return { + message: isSet(object.message) ? String(object.message) : "", + }; + }, + + toJSON(message: ResponseEcho): unknown { + const obj: any = {}; + message.message !== undefined && (obj.message = message.message); + return obj; + }, + fromPartial, I>>(object: I): ResponseEcho { const message = createBaseResponseEcho(); message.message = object.message ?? ""; @@ -1995,6 +2419,15 @@ export const ResponseFlush = { return message; }, + fromJSON(_: any): ResponseFlush { + return {}; + }, + + toJSON(_: ResponseFlush): unknown { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): ResponseFlush { const message = createBaseResponseFlush(); return message; @@ -2074,6 +2507,32 @@ export const ResponseInfo = { return message; }, + fromJSON(object: any): ResponseInfo { + return { + data: isSet(object.data) ? String(object.data) : "", + version: isSet(object.version) ? String(object.version) : "", + appVersion: isSet(object.appVersion) ? Long.fromValue(object.appVersion) : Long.UZERO, + lastBlockHeight: isSet(object.lastBlockHeight) ? Long.fromValue(object.lastBlockHeight) : Long.ZERO, + lastBlockAppHash: isSet(object.lastBlockAppHash) + ? bytesFromBase64(object.lastBlockAppHash) + : new Uint8Array(), + }; + }, + + 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, I>>(object: I): ResponseInfo { const message = createBaseResponseInfo(); message.data = object.data ?? ""; @@ -2146,6 +2605,22 @@ export const ResponseSetOption = { return message; }, + fromJSON(object: any): ResponseSetOption { + return { + code: isSet(object.code) ? Number(object.code) : 0, + log: isSet(object.log) ? String(object.log) : "", + info: isSet(object.info) ? String(object.info) : "", + }; + }, + + toJSON(message: ResponseSetOption): unknown { + const obj: any = {}; + message.code !== undefined && (obj.code = Math.round(message.code)); + message.log !== undefined && (obj.log = message.log); + message.info !== undefined && (obj.info = message.info); + return obj; + }, + fromPartial, I>>(object: I): ResponseSetOption { const message = createBaseResponseSetOption(); message.code = object.code ?? 0; @@ -2210,6 +2685,36 @@ export const ResponseInitChain = { return message; }, + fromJSON(object: any): ResponseInitChain { + return { + consensusParams: isSet(object.consensusParams) + ? ConsensusParams.fromJSON(object.consensusParams) + : undefined, + validators: Array.isArray(object?.validators) + ? object.validators.map((e: any) => ValidatorUpdate.fromJSON(e)) + : [], + appHash: isSet(object.appHash) ? bytesFromBase64(object.appHash) : new Uint8Array(), + }; + }, + + 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, I>>(object: I): ResponseInitChain { const message = createBaseResponseInitChain(); message.consensusParams = @@ -2331,6 +2836,37 @@ export const ResponseQuery = { return message; }, + fromJSON(object: any): ResponseQuery { + return { + code: isSet(object.code) ? Number(object.code) : 0, + log: isSet(object.log) ? String(object.log) : "", + info: isSet(object.info) ? String(object.info) : "", + index: isSet(object.index) ? Long.fromValue(object.index) : Long.ZERO, + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), + proofOps: isSet(object.proofOps) ? ProofOps.fromJSON(object.proofOps) : undefined, + height: isSet(object.height) ? Long.fromValue(object.height) : Long.ZERO, + codespace: isSet(object.codespace) ? String(object.codespace) : "", + }; + }, + + toJSON(message: ResponseQuery): unknown { + const obj: any = {}; + message.code !== undefined && (obj.code = Math.round(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, I>>(object: I): ResponseQuery { const message = createBaseResponseQuery(); message.code = object.code ?? 0; @@ -2388,6 +2924,24 @@ export const ResponseBeginBlock = { return message; }, + fromJSON(object: any): ResponseBeginBlock { + return { + events: Array.isArray(object?.events) ? object.events.map((e: any) => Event.fromJSON(e)) : [], + }; + }, + + 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, I>>(object: I): ResponseBeginBlock { const message = createBaseResponseBeginBlock(); message.events = object.events?.map((e) => Event.fromPartial(e)) || []; @@ -2495,6 +3049,39 @@ export const ResponseCheckTx = { return message; }, + fromJSON(object: any): ResponseCheckTx { + return { + code: isSet(object.code) ? Number(object.code) : 0, + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + log: isSet(object.log) ? String(object.log) : "", + info: isSet(object.info) ? String(object.info) : "", + gasWanted: isSet(object.gas_wanted) ? Long.fromValue(object.gas_wanted) : Long.ZERO, + gasUsed: isSet(object.gas_used) ? Long.fromValue(object.gas_used) : Long.ZERO, + events: Array.isArray(object?.events) ? object.events.map((e: any) => Event.fromJSON(e)) : [], + codespace: isSet(object.codespace) ? String(object.codespace) : "", + }; + }, + + toJSON(message: ResponseCheckTx): unknown { + const obj: any = {}; + message.code !== undefined && (obj.code = Math.round(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.gas_wanted = (message.gasWanted || Long.ZERO).toString()); + message.gasUsed !== undefined && (obj.gas_used = (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, I>>(object: I): ResponseCheckTx { const message = createBaseResponseCheckTx(); message.code = object.code ?? 0; @@ -2613,6 +3200,39 @@ export const ResponseDeliverTx = { return message; }, + fromJSON(object: any): ResponseDeliverTx { + return { + code: isSet(object.code) ? Number(object.code) : 0, + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + log: isSet(object.log) ? String(object.log) : "", + info: isSet(object.info) ? String(object.info) : "", + gasWanted: isSet(object.gas_wanted) ? Long.fromValue(object.gas_wanted) : Long.ZERO, + gasUsed: isSet(object.gas_used) ? Long.fromValue(object.gas_used) : Long.ZERO, + events: Array.isArray(object?.events) ? object.events.map((e: any) => Event.fromJSON(e)) : [], + codespace: isSet(object.codespace) ? String(object.codespace) : "", + }; + }, + + toJSON(message: ResponseDeliverTx): unknown { + const obj: any = {}; + message.code !== undefined && (obj.code = Math.round(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.gas_wanted = (message.gasWanted || Long.ZERO).toString()); + message.gasUsed !== undefined && (obj.gas_used = (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, I>>(object: I): ResponseDeliverTx { const message = createBaseResponseDeliverTx(); message.code = object.code ?? 0; @@ -2686,6 +3306,41 @@ export const ResponseEndBlock = { return message; }, + fromJSON(object: any): ResponseEndBlock { + return { + validatorUpdates: Array.isArray(object?.validatorUpdates) + ? object.validatorUpdates.map((e: any) => ValidatorUpdate.fromJSON(e)) + : [], + consensusParamUpdates: isSet(object.consensusParamUpdates) + ? ConsensusParams.fromJSON(object.consensusParamUpdates) + : undefined, + events: Array.isArray(object?.events) ? object.events.map((e: any) => Event.fromJSON(e)) : [], + }; + }, + + 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, I>>(object: I): ResponseEndBlock { const message = createBaseResponseEndBlock(); message.validatorUpdates = object.validatorUpdates?.map((e) => ValidatorUpdate.fromPartial(e)) || []; @@ -2744,6 +3399,21 @@ export const ResponseCommit = { return message; }, + fromJSON(object: any): ResponseCommit { + return { + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + retainHeight: isSet(object.retainHeight) ? Long.fromValue(object.retainHeight) : Long.ZERO, + }; + }, + + 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, I>>(object: I): ResponseCommit { const message = createBaseResponseCommit(); message.data = object.data ?? new Uint8Array(); @@ -2792,6 +3462,26 @@ export const ResponseListSnapshots = { return message; }, + fromJSON(object: any): ResponseListSnapshots { + return { + snapshots: Array.isArray(object?.snapshots) + ? object.snapshots.map((e: any) => Snapshot.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): ResponseListSnapshots { const message = createBaseResponseListSnapshots(); message.snapshots = object.snapshots?.map((e) => Snapshot.fromPartial(e)) || []; @@ -2836,6 +3526,18 @@ export const ResponseOfferSnapshot = { return message; }, + fromJSON(object: any): ResponseOfferSnapshot { + return { + result: isSet(object.result) ? responseOfferSnapshot_ResultFromJSON(object.result) : 0, + }; + }, + + toJSON(message: ResponseOfferSnapshot): unknown { + const obj: any = {}; + message.result !== undefined && (obj.result = responseOfferSnapshot_ResultToJSON(message.result)); + return obj; + }, + fromPartial, I>>(object: I): ResponseOfferSnapshot { const message = createBaseResponseOfferSnapshot(); message.result = object.result ?? 0; @@ -2880,6 +3582,19 @@ export const ResponseLoadSnapshotChunk = { return message; }, + fromJSON(object: any): ResponseLoadSnapshotChunk { + return { + chunk: isSet(object.chunk) ? bytesFromBase64(object.chunk) : new Uint8Array(), + }; + }, + + toJSON(message: ResponseLoadSnapshotChunk): unknown { + const obj: any = {}; + message.chunk !== undefined && + (obj.chunk = base64FromBytes(message.chunk !== undefined ? message.chunk : new Uint8Array())); + return obj; + }, + fromPartial, I>>( object: I, ): ResponseLoadSnapshotChunk { @@ -2957,6 +3672,37 @@ export const ResponseApplySnapshotChunk = { return message; }, + fromJSON(object: any): ResponseApplySnapshotChunk { + return { + result: isSet(object.result) ? responseApplySnapshotChunk_ResultFromJSON(object.result) : 0, + refetchChunks: Array.isArray(object?.refetchChunks) + ? object.refetchChunks.map((e: any) => Number(e)) + : [], + rejectSenders: Array.isArray(object?.rejectSenders) + ? object.rejectSenders.map((e: any) => String(e)) + : [], + }; + }, + + 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) => Math.round(e)); + } else { + obj.refetchChunks = []; + } + + if (message.rejectSenders) { + obj.rejectSenders = message.rejectSenders.map((e) => e); + } else { + obj.rejectSenders = []; + } + + return obj; + }, + fromPartial, I>>( object: I, ): ResponseApplySnapshotChunk { @@ -3032,6 +3778,28 @@ export const ConsensusParams = { return message; }, + fromJSON(object: any): ConsensusParams { + return { + block: isSet(object.block) ? BlockParams.fromJSON(object.block) : undefined, + evidence: isSet(object.evidence) ? EvidenceParams.fromJSON(object.evidence) : undefined, + validator: isSet(object.validator) ? ValidatorParams.fromJSON(object.validator) : undefined, + version: isSet(object.version) ? VersionParams.fromJSON(object.version) : undefined, + }; + }, + + 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, I>>(object: I): ConsensusParams { const message = createBaseConsensusParams(); message.block = @@ -3098,6 +3866,20 @@ export const BlockParams = { return message; }, + fromJSON(object: any): BlockParams { + return { + maxBytes: isSet(object.maxBytes) ? Long.fromValue(object.maxBytes) : Long.ZERO, + maxGas: isSet(object.maxGas) ? Long.fromValue(object.maxGas) : Long.ZERO, + }; + }, + + 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, I>>(object: I): BlockParams { const message = createBaseBlockParams(); message.maxBytes = @@ -3154,6 +3936,26 @@ export const LastCommitInfo = { return message; }, + fromJSON(object: any): LastCommitInfo { + return { + round: isSet(object.round) ? Number(object.round) : 0, + votes: Array.isArray(object?.votes) ? object.votes.map((e: any) => VoteInfo.fromJSON(e)) : [], + }; + }, + + toJSON(message: LastCommitInfo): unknown { + const obj: any = {}; + message.round !== undefined && (obj.round = Math.round(message.round)); + + if (message.votes) { + obj.votes = message.votes.map((e) => (e ? VoteInfo.toJSON(e) : undefined)); + } else { + obj.votes = []; + } + + return obj; + }, + fromPartial, I>>(object: I): LastCommitInfo { const message = createBaseLastCommitInfo(); message.round = object.round ?? 0; @@ -3208,6 +4010,28 @@ export const Event = { return message; }, + fromJSON(object: any): Event { + return { + type: isSet(object.type) ? String(object.type) : "", + attributes: Array.isArray(object?.attributes) + ? object.attributes.map((e: any) => EventAttribute.fromJSON(e)) + : [], + }; + }, + + 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, I>>(object: I): Event { const message = createBaseEvent(); message.type = object.type ?? ""; @@ -3271,6 +4095,24 @@ export const EventAttribute = { return message; }, + fromJSON(object: any): EventAttribute { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), + index: isSet(object.index) ? Boolean(object.index) : false, + }; + }, + + 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, I>>(object: I): EventAttribute { const message = createBaseEventAttribute(); message.key = object.key ?? new Uint8Array(); @@ -3344,6 +4186,26 @@ export const TxResult = { return message; }, + fromJSON(object: any): TxResult { + return { + height: isSet(object.height) ? Long.fromValue(object.height) : Long.ZERO, + index: isSet(object.index) ? Number(object.index) : 0, + tx: isSet(object.tx) ? bytesFromBase64(object.tx) : new Uint8Array(), + result: isSet(object.result) ? ResponseDeliverTx.fromJSON(object.result) : undefined, + }; + }, + + toJSON(message: TxResult): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + message.index !== undefined && (obj.index = Math.round(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, I>>(object: I): TxResult { const message = createBaseTxResult(); message.height = @@ -3404,6 +4266,21 @@ export const Validator = { return message; }, + fromJSON(object: any): Validator { + return { + address: isSet(object.address) ? bytesFromBase64(object.address) : new Uint8Array(), + power: isSet(object.power) ? Long.fromValue(object.power) : Long.ZERO, + }; + }, + + 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, I>>(object: I): Validator { const message = createBaseValidator(); message.address = object.address ?? new Uint8Array(); @@ -3459,6 +4336,21 @@ export const ValidatorUpdate = { return message; }, + fromJSON(object: any): ValidatorUpdate { + return { + pubKey: isSet(object.pubKey) ? PublicKey.fromJSON(object.pubKey) : undefined, + power: isSet(object.power) ? Long.fromValue(object.power) : Long.ZERO, + }; + }, + + 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, I>>(object: I): ValidatorUpdate { const message = createBaseValidatorUpdate(); message.pubKey = @@ -3517,6 +4409,21 @@ export const VoteInfo = { return message; }, + fromJSON(object: any): VoteInfo { + return { + validator: isSet(object.validator) ? Validator.fromJSON(object.validator) : undefined, + signedLastBlock: isSet(object.signedLastBlock) ? Boolean(object.signedLastBlock) : false, + }; + }, + + 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, I>>(object: I): VoteInfo { const message = createBaseVoteInfo(); message.validator = @@ -3601,6 +4508,28 @@ export const Evidence = { return message; }, + fromJSON(object: any): Evidence { + return { + type: isSet(object.type) ? evidenceTypeFromJSON(object.type) : 0, + validator: isSet(object.validator) ? Validator.fromJSON(object.validator) : undefined, + height: isSet(object.height) ? Long.fromValue(object.height) : Long.ZERO, + time: isSet(object.time) ? fromJsonTimestamp(object.time) : undefined, + totalVotingPower: isSet(object.totalVotingPower) ? Long.fromValue(object.totalVotingPower) : Long.ZERO, + }; + }, + + 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 = fromTimestamp(message.time).toISOString()); + message.totalVotingPower !== undefined && + (obj.totalVotingPower = (message.totalVotingPower || Long.ZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): Evidence { const message = createBaseEvidence(); message.type = object.type ?? 0; @@ -3693,6 +4622,28 @@ export const Snapshot = { return message; }, + fromJSON(object: any): Snapshot { + return { + height: isSet(object.height) ? Long.fromValue(object.height) : Long.UZERO, + format: isSet(object.format) ? Number(object.format) : 0, + chunks: isSet(object.chunks) ? Number(object.chunks) : 0, + hash: isSet(object.hash) ? bytesFromBase64(object.hash) : new Uint8Array(), + metadata: isSet(object.metadata) ? bytesFromBase64(object.metadata) : new Uint8Array(), + }; + }, + + toJSON(message: Snapshot): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.UZERO).toString()); + message.format !== undefined && (obj.format = Math.round(message.format)); + message.chunks !== undefined && (obj.chunks = Math.round(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, I>>(object: I): Snapshot { const message = createBaseSnapshot(); message.height = diff --git a/src/tendermint/crypto/keys.ts b/src/tendermint/crypto/keys.ts index 99ff8240..a3c2806e 100644 --- a/src/tendermint/crypto/keys.ts +++ b/src/tendermint/crypto/keys.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../helpers"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact } from "../../helpers"; export const protobufPackage = "tendermint.crypto"; /** PublicKey defines the keys available for use with Tendermint Validators */ @@ -55,6 +55,22 @@ export const PublicKey = { return message; }, + fromJSON(object: any): PublicKey { + return { + ed25519: isSet(object.ed25519) ? bytesFromBase64(object.ed25519) : undefined, + secp256k1: isSet(object.secp256k1) ? bytesFromBase64(object.secp256k1) : undefined, + }; + }, + + 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, I>>(object: I): PublicKey { const message = createBasePublicKey(); message.ed25519 = object.ed25519 ?? undefined; diff --git a/src/tendermint/crypto/proof.ts b/src/tendermint/crypto/proof.ts index 02d997ca..1c62ba56 100644 --- a/src/tendermint/crypto/proof.ts +++ b/src/tendermint/crypto/proof.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -import { Long, DeepPartial, Exact } from "../../helpers"; +import { Long, isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact } from "../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "tendermint.crypto"; export interface Proof { @@ -101,6 +101,31 @@ export const Proof = { return message; }, + fromJSON(object: any): Proof { + return { + total: isSet(object.total) ? Long.fromValue(object.total) : Long.ZERO, + index: isSet(object.index) ? Long.fromValue(object.index) : Long.ZERO, + leafHash: isSet(object.leafHash) ? bytesFromBase64(object.leafHash) : new Uint8Array(), + aunts: Array.isArray(object?.aunts) ? object.aunts.map((e: any) => bytesFromBase64(e)) : [], + }; + }, + + 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, I>>(object: I): Proof { const message = createBaseProof(); message.total = @@ -159,6 +184,21 @@ export const ValueOp = { return message; }, + fromJSON(object: any): ValueOp { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + proof: isSet(object.proof) ? Proof.fromJSON(object.proof) : undefined, + }; + }, + + 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, I>>(object: I): ValueOp { const message = createBaseValueOp(); message.key = object.key ?? new Uint8Array(); @@ -223,6 +263,22 @@ export const DominoOp = { return message; }, + fromJSON(object: any): DominoOp { + return { + key: isSet(object.key) ? String(object.key) : "", + input: isSet(object.input) ? String(object.input) : "", + output: isSet(object.output) ? String(object.output) : "", + }; + }, + + 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, I>>(object: I): DominoOp { const message = createBaseDominoOp(); message.key = object.key ?? ""; @@ -287,6 +343,24 @@ export const ProofOp = { return message; }, + fromJSON(object: any): ProofOp { + return { + type: isSet(object.type) ? String(object.type) : "", + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + }; + }, + + 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, I>>(object: I): ProofOp { const message = createBaseProofOp(); message.type = object.type ?? ""; @@ -333,6 +407,24 @@ export const ProofOps = { return message; }, + fromJSON(object: any): ProofOps { + return { + ops: Array.isArray(object?.ops) ? object.ops.map((e: any) => ProofOp.fromJSON(e)) : [], + }; + }, + + 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, I>>(object: I): ProofOps { const message = createBaseProofOps(); message.ops = object.ops?.map((e) => ProofOp.fromPartial(e)) || []; diff --git a/src/tendermint/p2p/types.ts b/src/tendermint/p2p/types.ts index 1c9ce888..fd58739b 100644 --- a/src/tendermint/p2p/types.ts +++ b/src/tendermint/p2p/types.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../helpers"; +import { isSet, DeepPartial, Exact, Long, bytesFromBase64, base64FromBytes } from "../../helpers"; export const protobufPackage = "tendermint.p2p"; export interface NetAddress { id: string; @@ -82,6 +82,22 @@ export const NetAddress = { return message; }, + fromJSON(object: any): NetAddress { + return { + id: isSet(object.id) ? String(object.id) : "", + ip: isSet(object.ip) ? String(object.ip) : "", + port: isSet(object.port) ? Number(object.port) : 0, + }; + }, + + toJSON(message: NetAddress): unknown { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + message.ip !== undefined && (obj.ip = message.ip); + message.port !== undefined && (obj.port = Math.round(message.port)); + return obj; + }, + fromPartial, I>>(object: I): NetAddress { const message = createBaseNetAddress(); message.id = object.id ?? ""; @@ -146,6 +162,22 @@ export const ProtocolVersion = { return message; }, + fromJSON(object: any): ProtocolVersion { + return { + p2p: isSet(object.p2p) ? Long.fromValue(object.p2p) : Long.UZERO, + block: isSet(object.block) ? Long.fromValue(object.block) : Long.UZERO, + app: isSet(object.app) ? Long.fromValue(object.app) : Long.UZERO, + }; + }, + + toJSON(message: ProtocolVersion): unknown { + const obj: any = {}; + message.p2p !== undefined && (obj.p2p = (message.p2p || Long.UZERO).toString()); + message.block !== undefined && (obj.block = (message.block || Long.UZERO).toString()); + message.app !== undefined && (obj.app = (message.app || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): ProtocolVersion { const message = createBaseProtocolVersion(); message.p2p = object.p2p !== undefined && object.p2p !== null ? Long.fromValue(object.p2p) : Long.UZERO; @@ -256,6 +288,39 @@ export const DefaultNodeInfo = { return message; }, + fromJSON(object: any): DefaultNodeInfo { + return { + protocolVersion: isSet(object.protocolVersion) + ? ProtocolVersion.fromJSON(object.protocolVersion) + : undefined, + defaultNodeId: isSet(object.defaultNodeId) ? String(object.defaultNodeId) : "", + listenAddr: isSet(object.listenAddr) ? String(object.listenAddr) : "", + network: isSet(object.network) ? String(object.network) : "", + version: isSet(object.version) ? String(object.version) : "", + channels: isSet(object.channels) ? bytesFromBase64(object.channels) : new Uint8Array(), + moniker: isSet(object.moniker) ? String(object.moniker) : "", + other: isSet(object.other) ? DefaultNodeInfoOther.fromJSON(object.other) : undefined, + }; + }, + + toJSON(message: DefaultNodeInfo): unknown { + const obj: any = {}; + message.protocolVersion !== undefined && + (obj.protocolVersion = message.protocolVersion + ? ProtocolVersion.toJSON(message.protocolVersion) + : undefined); + message.defaultNodeId !== undefined && (obj.defaultNodeId = message.defaultNodeId); + message.listenAddr !== undefined && (obj.listenAddr = message.listenAddr); + message.network !== undefined && (obj.network = message.network); + message.version !== undefined && (obj.version = message.version); + message.channels !== undefined && + (obj.channels = base64FromBytes(message.channels !== undefined ? message.channels : new Uint8Array())); + message.moniker !== undefined && (obj.moniker = message.moniker); + message.other !== undefined && + (obj.other = message.other ? DefaultNodeInfoOther.toJSON(message.other) : undefined); + return obj; + }, + fromPartial, I>>(object: I): DefaultNodeInfo { const message = createBaseDefaultNodeInfo(); message.protocolVersion = @@ -322,6 +387,20 @@ export const DefaultNodeInfoOther = { return message; }, + fromJSON(object: any): DefaultNodeInfoOther { + return { + txIndex: isSet(object.txIndex) ? String(object.txIndex) : "", + rpcAddress: isSet(object.rpcAddress) ? String(object.rpcAddress) : "", + }; + }, + + toJSON(message: DefaultNodeInfoOther): unknown { + const obj: any = {}; + message.txIndex !== undefined && (obj.txIndex = message.txIndex); + message.rpcAddress !== undefined && (obj.rpcAddress = message.rpcAddress); + return obj; + }, + fromPartial, I>>(object: I): DefaultNodeInfoOther { const message = createBaseDefaultNodeInfoOther(); message.txIndex = object.txIndex ?? ""; diff --git a/src/tendermint/types/block.ts b/src/tendermint/types/block.ts index 1ae63a88..4861981c 100644 --- a/src/tendermint/types/block.ts +++ b/src/tendermint/types/block.ts @@ -2,7 +2,7 @@ import { Header, Data, Commit } from "./types"; import { EvidenceList } from "./evidence"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact } from "../../helpers"; +import { isSet, DeepPartial, Exact } from "../../helpers"; export const protobufPackage = "tendermint.types"; export interface Block { header?: Header; @@ -75,6 +75,26 @@ export const Block = { return message; }, + fromJSON(object: any): Block { + return { + header: isSet(object.header) ? Header.fromJSON(object.header) : undefined, + data: isSet(object.data) ? Data.fromJSON(object.data) : undefined, + evidence: isSet(object.evidence) ? EvidenceList.fromJSON(object.evidence) : undefined, + lastCommit: isSet(object.lastCommit) ? Commit.fromJSON(object.lastCommit) : undefined, + }; + }, + + toJSON(message: Block): unknown { + const obj: any = {}; + message.header !== undefined && (obj.header = message.header ? Header.toJSON(message.header) : undefined); + message.data !== undefined && (obj.data = message.data ? Data.toJSON(message.data) : undefined); + message.evidence !== undefined && + (obj.evidence = message.evidence ? EvidenceList.toJSON(message.evidence) : undefined); + message.lastCommit !== undefined && + (obj.lastCommit = message.lastCommit ? Commit.toJSON(message.lastCommit) : undefined); + return obj; + }, + fromPartial, I>>(object: I): Block { const message = createBaseBlock(); message.header = diff --git a/src/tendermint/types/evidence.ts b/src/tendermint/types/evidence.ts index 8d717adb..ff7c0ded 100644 --- a/src/tendermint/types/evidence.ts +++ b/src/tendermint/types/evidence.ts @@ -3,7 +3,7 @@ import { Vote, LightBlock } from "./types"; import { Timestamp } from "../../google/protobuf/timestamp"; import { Validator } from "./validator"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../helpers"; +import { isSet, DeepPartial, Exact, Long, fromJsonTimestamp, fromTimestamp } from "../../helpers"; export const protobufPackage = "tendermint.types"; export interface Evidence { duplicateVoteEvidence?: DuplicateVoteEvidence; @@ -77,6 +77,30 @@ export const Evidence = { return message; }, + fromJSON(object: any): Evidence { + return { + duplicateVoteEvidence: isSet(object.duplicateVoteEvidence) + ? DuplicateVoteEvidence.fromJSON(object.duplicateVoteEvidence) + : undefined, + lightClientAttackEvidence: isSet(object.lightClientAttackEvidence) + ? LightClientAttackEvidence.fromJSON(object.lightClientAttackEvidence) + : undefined, + }; + }, + + toJSON(message: Evidence): unknown { + const obj: any = {}; + message.duplicateVoteEvidence !== undefined && + (obj.duplicateVoteEvidence = message.duplicateVoteEvidence + ? DuplicateVoteEvidence.toJSON(message.duplicateVoteEvidence) + : undefined); + message.lightClientAttackEvidence !== undefined && + (obj.lightClientAttackEvidence = message.lightClientAttackEvidence + ? LightClientAttackEvidence.toJSON(message.lightClientAttackEvidence) + : undefined); + return obj; + }, + fromPartial, I>>(object: I): Evidence { const message = createBaseEvidence(); message.duplicateVoteEvidence = @@ -164,6 +188,28 @@ export const DuplicateVoteEvidence = { return message; }, + fromJSON(object: any): DuplicateVoteEvidence { + return { + voteA: isSet(object.voteA) ? Vote.fromJSON(object.voteA) : undefined, + voteB: isSet(object.voteB) ? Vote.fromJSON(object.voteB) : undefined, + totalVotingPower: isSet(object.totalVotingPower) ? Long.fromValue(object.totalVotingPower) : Long.ZERO, + validatorPower: isSet(object.validatorPower) ? Long.fromValue(object.validatorPower) : Long.ZERO, + timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined, + }; + }, + + toJSON(message: DuplicateVoteEvidence): unknown { + const obj: any = {}; + message.voteA !== undefined && (obj.voteA = message.voteA ? Vote.toJSON(message.voteA) : undefined); + message.voteB !== undefined && (obj.voteB = message.voteB ? Vote.toJSON(message.voteB) : undefined); + message.totalVotingPower !== undefined && + (obj.totalVotingPower = (message.totalVotingPower || Long.ZERO).toString()); + message.validatorPower !== undefined && + (obj.validatorPower = (message.validatorPower || Long.ZERO).toString()); + message.timestamp !== undefined && (obj.timestamp = fromTimestamp(message.timestamp).toISOString()); + return obj; + }, + fromPartial, I>>(object: I): DuplicateVoteEvidence { const message = createBaseDuplicateVoteEvidence(); message.voteA = @@ -259,6 +305,40 @@ export const LightClientAttackEvidence = { return message; }, + fromJSON(object: any): LightClientAttackEvidence { + return { + conflictingBlock: isSet(object.conflictingBlock) + ? LightBlock.fromJSON(object.conflictingBlock) + : undefined, + commonHeight: isSet(object.commonHeight) ? Long.fromValue(object.commonHeight) : Long.ZERO, + byzantineValidators: Array.isArray(object?.byzantineValidators) + ? object.byzantineValidators.map((e: any) => Validator.fromJSON(e)) + : [], + totalVotingPower: isSet(object.totalVotingPower) ? Long.fromValue(object.totalVotingPower) : Long.ZERO, + timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined, + }; + }, + + toJSON(message: LightClientAttackEvidence): unknown { + const obj: any = {}; + message.conflictingBlock !== undefined && + (obj.conflictingBlock = message.conflictingBlock + ? LightBlock.toJSON(message.conflictingBlock) + : undefined); + message.commonHeight !== undefined && (obj.commonHeight = (message.commonHeight || Long.ZERO).toString()); + + if (message.byzantineValidators) { + obj.byzantineValidators = message.byzantineValidators.map((e) => (e ? Validator.toJSON(e) : undefined)); + } else { + obj.byzantineValidators = []; + } + + message.totalVotingPower !== undefined && + (obj.totalVotingPower = (message.totalVotingPower || Long.ZERO).toString()); + message.timestamp !== undefined && (obj.timestamp = fromTimestamp(message.timestamp).toISOString()); + return obj; + }, + fromPartial, I>>( object: I, ): LightClientAttackEvidence { @@ -321,6 +401,24 @@ export const EvidenceList = { return message; }, + fromJSON(object: any): EvidenceList { + return { + evidence: Array.isArray(object?.evidence) ? object.evidence.map((e: any) => Evidence.fromJSON(e)) : [], + }; + }, + + toJSON(message: EvidenceList): unknown { + const obj: any = {}; + + if (message.evidence) { + obj.evidence = message.evidence.map((e) => (e ? Evidence.toJSON(e) : undefined)); + } else { + obj.evidence = []; + } + + return obj; + }, + fromPartial, I>>(object: I): EvidenceList { const message = createBaseEvidenceList(); message.evidence = object.evidence?.map((e) => Evidence.fromPartial(e)) || []; diff --git a/src/tendermint/types/params.ts b/src/tendermint/types/params.ts index 8e696395..88f83276 100644 --- a/src/tendermint/types/params.ts +++ b/src/tendermint/types/params.ts @@ -1,7 +1,7 @@ /* eslint-disable */ import { Duration } from "../../google/protobuf/duration"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../helpers"; +import { isSet, DeepPartial, Exact, Long } from "../../helpers"; export const protobufPackage = "tendermint.types"; /** * ConsensusParams contains consensus critical parameters that determine the @@ -152,6 +152,28 @@ export const ConsensusParams = { return message; }, + fromJSON(object: any): ConsensusParams { + return { + block: isSet(object.block) ? BlockParams.fromJSON(object.block) : undefined, + evidence: isSet(object.evidence) ? EvidenceParams.fromJSON(object.evidence) : undefined, + validator: isSet(object.validator) ? ValidatorParams.fromJSON(object.validator) : undefined, + version: isSet(object.version) ? VersionParams.fromJSON(object.version) : undefined, + }; + }, + + 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, I>>(object: I): ConsensusParams { const message = createBaseConsensusParams(); message.block = @@ -227,6 +249,22 @@ export const BlockParams = { return message; }, + fromJSON(object: any): BlockParams { + return { + maxBytes: isSet(object.maxBytes) ? Long.fromValue(object.maxBytes) : Long.ZERO, + maxGas: isSet(object.maxGas) ? Long.fromValue(object.maxGas) : Long.ZERO, + timeIotaMs: isSet(object.timeIotaMs) ? Long.fromValue(object.timeIotaMs) : Long.ZERO, + }; + }, + + 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, I>>(object: I): BlockParams { const message = createBaseBlockParams(); message.maxBytes = @@ -296,6 +334,24 @@ export const EvidenceParams = { return message; }, + fromJSON(object: any): EvidenceParams { + return { + maxAgeNumBlocks: isSet(object.maxAgeNumBlocks) ? Long.fromValue(object.maxAgeNumBlocks) : Long.ZERO, + maxAgeDuration: isSet(object.maxAgeDuration) ? Duration.fromJSON(object.maxAgeDuration) : undefined, + maxBytes: isSet(object.maxBytes) ? Long.fromValue(object.maxBytes) : Long.ZERO, + }; + }, + + 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, I>>(object: I): EvidenceParams { const message = createBaseEvidenceParams(); message.maxAgeNumBlocks = @@ -349,6 +405,24 @@ export const ValidatorParams = { return message; }, + fromJSON(object: any): ValidatorParams { + return { + pubKeyTypes: Array.isArray(object?.pubKeyTypes) ? object.pubKeyTypes.map((e: any) => String(e)) : [], + }; + }, + + toJSON(message: ValidatorParams): unknown { + const obj: any = {}; + + if (message.pubKeyTypes) { + obj.pubKeyTypes = message.pubKeyTypes.map((e) => e); + } else { + obj.pubKeyTypes = []; + } + + return obj; + }, + fromPartial, I>>(object: I): ValidatorParams { const message = createBaseValidatorParams(); message.pubKeyTypes = object.pubKeyTypes?.map((e) => e) || []; @@ -393,6 +467,18 @@ export const VersionParams = { return message; }, + fromJSON(object: any): VersionParams { + return { + appVersion: isSet(object.appVersion) ? Long.fromValue(object.appVersion) : Long.UZERO, + }; + }, + + toJSON(message: VersionParams): unknown { + const obj: any = {}; + message.appVersion !== undefined && (obj.appVersion = (message.appVersion || Long.UZERO).toString()); + return obj; + }, + fromPartial, I>>(object: I): VersionParams { const message = createBaseVersionParams(); message.appVersion = @@ -449,6 +535,21 @@ export const HashedParams = { return message; }, + fromJSON(object: any): HashedParams { + return { + blockMaxBytes: isSet(object.blockMaxBytes) ? Long.fromValue(object.blockMaxBytes) : Long.ZERO, + blockMaxGas: isSet(object.blockMaxGas) ? Long.fromValue(object.blockMaxGas) : Long.ZERO, + }; + }, + + 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, I>>(object: I): HashedParams { const message = createBaseHashedParams(); message.blockMaxBytes = diff --git a/src/tendermint/types/types.ts b/src/tendermint/types/types.ts index b2c6ae1d..c81c9bb4 100644 --- a/src/tendermint/types/types.ts +++ b/src/tendermint/types/types.ts @@ -4,7 +4,16 @@ import { Consensus } from "../version/types"; import { Timestamp } from "../../google/protobuf/timestamp"; import { ValidatorSet } from "./validator"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial, Exact, Long } from "../../helpers"; +import { + isSet, + bytesFromBase64, + base64FromBytes, + DeepPartial, + Exact, + Long, + fromJsonTimestamp, + fromTimestamp, +} from "../../helpers"; export const protobufPackage = "tendermint.types"; /** BlockIdFlag indicates which BlcokID the signature is for */ @@ -284,6 +293,21 @@ export const PartSetHeader = { return message; }, + fromJSON(object: any): PartSetHeader { + return { + total: isSet(object.total) ? Number(object.total) : 0, + hash: isSet(object.hash) ? bytesFromBase64(object.hash) : new Uint8Array(), + }; + }, + + toJSON(message: PartSetHeader): unknown { + const obj: any = {}; + message.total !== undefined && (obj.total = Math.round(message.total)); + message.hash !== undefined && + (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): PartSetHeader { const message = createBasePartSetHeader(); message.total = object.total ?? 0; @@ -347,6 +371,23 @@ export const Part = { return message; }, + fromJSON(object: any): Part { + return { + index: isSet(object.index) ? Number(object.index) : 0, + bytes: isSet(object.bytes) ? bytesFromBase64(object.bytes) : new Uint8Array(), + proof: isSet(object.proof) ? Proof.fromJSON(object.proof) : undefined, + }; + }, + + toJSON(message: Part): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = Math.round(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, I>>(object: I): Part { const message = createBasePart(); message.index = object.index ?? 0; @@ -403,6 +444,22 @@ export const BlockID = { return message; }, + fromJSON(object: any): BlockID { + return { + hash: isSet(object.hash) ? bytesFromBase64(object.hash) : new Uint8Array(), + partSetHeader: isSet(object.partSetHeader) ? PartSetHeader.fromJSON(object.partSetHeader) : undefined, + }; + }, + + 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, I>>(object: I): BlockID { const message = createBaseBlockID(); message.hash = object.hash ?? new Uint8Array(); @@ -568,6 +625,79 @@ export const Header = { return message; }, + fromJSON(object: any): Header { + return { + version: isSet(object.version) ? Consensus.fromJSON(object.version) : undefined, + chainId: isSet(object.chainId) ? String(object.chainId) : "", + height: isSet(object.height) ? Long.fromValue(object.height) : Long.ZERO, + time: isSet(object.time) ? fromJsonTimestamp(object.time) : undefined, + lastBlockId: isSet(object.lastBlockId) ? BlockID.fromJSON(object.lastBlockId) : undefined, + lastCommitHash: isSet(object.lastCommitHash) + ? bytesFromBase64(object.lastCommitHash) + : new Uint8Array(), + dataHash: isSet(object.dataHash) ? bytesFromBase64(object.dataHash) : new Uint8Array(), + validatorsHash: isSet(object.validatorsHash) + ? bytesFromBase64(object.validatorsHash) + : new Uint8Array(), + nextValidatorsHash: isSet(object.nextValidatorsHash) + ? bytesFromBase64(object.nextValidatorsHash) + : new Uint8Array(), + consensusHash: isSet(object.consensusHash) ? bytesFromBase64(object.consensusHash) : new Uint8Array(), + appHash: isSet(object.appHash) ? bytesFromBase64(object.appHash) : new Uint8Array(), + lastResultsHash: isSet(object.lastResultsHash) + ? bytesFromBase64(object.lastResultsHash) + : new Uint8Array(), + evidenceHash: isSet(object.evidenceHash) ? bytesFromBase64(object.evidenceHash) : new Uint8Array(), + proposerAddress: isSet(object.proposerAddress) + ? bytesFromBase64(object.proposerAddress) + : new Uint8Array(), + }; + }, + + 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 = fromTimestamp(message.time).toISOString()); + 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, I>>(object: I): Header { const message = createBaseHeader(); message.version = @@ -633,6 +763,24 @@ export const Data = { return message; }, + fromJSON(object: any): Data { + return { + txs: Array.isArray(object?.txs) ? object.txs.map((e: any) => bytesFromBase64(e)) : [], + }; + }, + + 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, I>>(object: I): Data { const message = createBaseData(); message.txs = object.txs?.map((e) => e) || []; @@ -740,6 +888,41 @@ export const Vote = { return message; }, + fromJSON(object: any): Vote { + return { + type: isSet(object.type) ? signedMsgTypeFromJSON(object.type) : 0, + height: isSet(object.height) ? Long.fromValue(object.height) : Long.ZERO, + round: isSet(object.round) ? Number(object.round) : 0, + blockId: isSet(object.blockId) ? BlockID.fromJSON(object.blockId) : undefined, + timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined, + validatorAddress: isSet(object.validatorAddress) + ? bytesFromBase64(object.validatorAddress) + : new Uint8Array(), + validatorIndex: isSet(object.validatorIndex) ? Number(object.validatorIndex) : 0, + signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(), + }; + }, + + 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 = Math.round(message.round)); + message.blockId !== undefined && + (obj.blockId = message.blockId ? BlockID.toJSON(message.blockId) : undefined); + message.timestamp !== undefined && (obj.timestamp = fromTimestamp(message.timestamp).toISOString()); + message.validatorAddress !== undefined && + (obj.validatorAddress = base64FromBytes( + message.validatorAddress !== undefined ? message.validatorAddress : new Uint8Array(), + )); + message.validatorIndex !== undefined && (obj.validatorIndex = Math.round(message.validatorIndex)); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array(), + )); + return obj; + }, + fromPartial, I>>(object: I): Vote { const message = createBaseVote(); message.type = object.type ?? 0; @@ -825,6 +1008,33 @@ export const Commit = { return message; }, + fromJSON(object: any): Commit { + return { + height: isSet(object.height) ? Long.fromValue(object.height) : Long.ZERO, + round: isSet(object.round) ? Number(object.round) : 0, + blockId: isSet(object.blockId) ? BlockID.fromJSON(object.blockId) : undefined, + signatures: Array.isArray(object?.signatures) + ? object.signatures.map((e: any) => CommitSig.fromJSON(e)) + : [], + }; + }, + + toJSON(message: Commit): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); + message.round !== undefined && (obj.round = Math.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, I>>(object: I): Commit { const message = createBaseCommit(); message.height = @@ -903,6 +1113,32 @@ export const CommitSig = { return message; }, + fromJSON(object: any): CommitSig { + return { + blockIdFlag: isSet(object.blockIdFlag) ? blockIDFlagFromJSON(object.blockIdFlag) : 0, + validatorAddress: isSet(object.validatorAddress) + ? bytesFromBase64(object.validatorAddress) + : new Uint8Array(), + timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined, + signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(), + }; + }, + + 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 = fromTimestamp(message.timestamp).toISOString()); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array(), + )); + return obj; + }, + fromPartial, I>>(object: I): CommitSig { const message = createBaseCommitSig(); message.blockIdFlag = object.blockIdFlag ?? 0; @@ -1007,6 +1243,34 @@ export const Proposal = { return message; }, + fromJSON(object: any): Proposal { + return { + type: isSet(object.type) ? signedMsgTypeFromJSON(object.type) : 0, + height: isSet(object.height) ? Long.fromValue(object.height) : Long.ZERO, + round: isSet(object.round) ? Number(object.round) : 0, + polRound: isSet(object.polRound) ? Number(object.polRound) : 0, + blockId: isSet(object.blockId) ? BlockID.fromJSON(object.blockId) : undefined, + timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined, + signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(), + }; + }, + + 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 = Math.round(message.round)); + message.polRound !== undefined && (obj.polRound = Math.round(message.polRound)); + message.blockId !== undefined && + (obj.blockId = message.blockId ? BlockID.toJSON(message.blockId) : undefined); + message.timestamp !== undefined && (obj.timestamp = fromTimestamp(message.timestamp).toISOString()); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array(), + )); + return obj; + }, + fromPartial, I>>(object: I): Proposal { const message = createBaseProposal(); message.type = object.type ?? 0; @@ -1073,6 +1337,20 @@ export const SignedHeader = { return message; }, + fromJSON(object: any): SignedHeader { + return { + header: isSet(object.header) ? Header.fromJSON(object.header) : undefined, + commit: isSet(object.commit) ? Commit.fromJSON(object.commit) : undefined, + }; + }, + + 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, I>>(object: I): SignedHeader { const message = createBaseSignedHeader(); message.header = @@ -1129,6 +1407,22 @@ export const LightBlock = { return message; }, + fromJSON(object: any): LightBlock { + return { + signedHeader: isSet(object.signedHeader) ? SignedHeader.fromJSON(object.signedHeader) : undefined, + validatorSet: isSet(object.validatorSet) ? ValidatorSet.fromJSON(object.validatorSet) : undefined, + }; + }, + + 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, I>>(object: I): LightBlock { const message = createBaseLightBlock(); message.signedHeader = @@ -1207,6 +1501,25 @@ export const BlockMeta = { return message; }, + fromJSON(object: any): BlockMeta { + return { + blockId: isSet(object.blockId) ? BlockID.fromJSON(object.blockId) : undefined, + blockSize: isSet(object.blockSize) ? Long.fromValue(object.blockSize) : Long.ZERO, + header: isSet(object.header) ? Header.fromJSON(object.header) : undefined, + numTxs: isSet(object.numTxs) ? Long.fromValue(object.numTxs) : Long.ZERO, + }; + }, + + 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, I>>(object: I): BlockMeta { const message = createBaseBlockMeta(); message.blockId = @@ -1280,6 +1593,24 @@ export const TxProof = { return message; }, + fromJSON(object: any): TxProof { + return { + rootHash: isSet(object.rootHash) ? bytesFromBase64(object.rootHash) : new Uint8Array(), + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + proof: isSet(object.proof) ? Proof.fromJSON(object.proof) : undefined, + }; + }, + + 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, I>>(object: I): TxProof { const message = createBaseTxProof(); message.rootHash = object.rootHash ?? new Uint8Array(); diff --git a/src/tendermint/types/validator.ts b/src/tendermint/types/validator.ts index e8ee4265..e7e5c76c 100644 --- a/src/tendermint/types/validator.ts +++ b/src/tendermint/types/validator.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import { PublicKey } from "../crypto/keys"; -import { Long, DeepPartial, Exact } from "../../helpers"; +import { Long, isSet, DeepPartial, Exact, bytesFromBase64, base64FromBytes } from "../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "tendermint.types"; export interface ValidatorSet { @@ -74,6 +74,32 @@ export const ValidatorSet = { return message; }, + fromJSON(object: any): ValidatorSet { + return { + validators: Array.isArray(object?.validators) + ? object.validators.map((e: any) => Validator.fromJSON(e)) + : [], + proposer: isSet(object.proposer) ? Validator.fromJSON(object.proposer) : undefined, + totalVotingPower: isSet(object.totalVotingPower) ? Long.fromValue(object.totalVotingPower) : Long.ZERO, + }; + }, + + 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, I>>(object: I): ValidatorSet { const message = createBaseValidatorSet(); message.validators = object.validators?.map((e) => Validator.fromPartial(e)) || []; @@ -153,6 +179,27 @@ export const Validator = { return message; }, + fromJSON(object: any): Validator { + return { + address: isSet(object.address) ? bytesFromBase64(object.address) : new Uint8Array(), + pubKey: isSet(object.pubKey) ? PublicKey.fromJSON(object.pubKey) : undefined, + votingPower: isSet(object.votingPower) ? Long.fromValue(object.votingPower) : Long.ZERO, + proposerPriority: isSet(object.proposerPriority) ? Long.fromValue(object.proposerPriority) : Long.ZERO, + }; + }, + + 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, I>>(object: I): Validator { const message = createBaseValidator(); message.address = object.address ?? new Uint8Array(); @@ -218,6 +265,21 @@ export const SimpleValidator = { return message; }, + fromJSON(object: any): SimpleValidator { + return { + pubKey: isSet(object.pubKey) ? PublicKey.fromJSON(object.pubKey) : undefined, + votingPower: isSet(object.votingPower) ? Long.fromValue(object.votingPower) : Long.ZERO, + }; + }, + + 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, I>>(object: I): SimpleValidator { const message = createBaseSimpleValidator(); message.pubKey = diff --git a/src/tendermint/version/types.ts b/src/tendermint/version/types.ts index 344e71a9..3c326ace 100644 --- a/src/tendermint/version/types.ts +++ b/src/tendermint/version/types.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -import { Long, DeepPartial, Exact } from "../../helpers"; +import { Long, isSet, DeepPartial, Exact } from "../../helpers"; import * as _m0 from "protobufjs/minimal"; export const protobufPackage = "tendermint.version"; /** @@ -69,6 +69,20 @@ export const App = { return message; }, + fromJSON(object: any): App { + return { + protocol: isSet(object.protocol) ? Long.fromValue(object.protocol) : Long.UZERO, + software: isSet(object.software) ? String(object.software) : "", + }; + }, + + 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, I>>(object: I): App { const message = createBaseApp(); message.protocol = @@ -126,6 +140,20 @@ export const Consensus = { return message; }, + fromJSON(object: any): Consensus { + return { + block: isSet(object.block) ? Long.fromValue(object.block) : Long.UZERO, + app: isSet(object.app) ? Long.fromValue(object.app) : Long.UZERO, + }; + }, + + 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, I>>(object: I): Consensus { const message = createBaseConsensus(); message.block =