UNPKG

@cheqd/ts-proto

Version:

A TypeScript package for all transpiled cheqd ProtoBuf definitions.

189 lines 7.01 kB
// Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v2.11.4 // protoc unknown // source: cheqd/oracle/v2/abci.proto /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; import { DecCoin } from "../../../cosmos/base/v1beta1/coin.js"; import { AggregateExchangeRateVote } from "./oracle.js"; function createBaseOracleVoteExtension() { return { height: 0n, exchangeRates: [] }; } export const OracleVoteExtension = { encode(message, writer = new BinaryWriter()) { if (message.height !== 0n) { if (BigInt.asIntN(64, message.height) !== message.height) { throw new globalThis.Error("value provided for field message.height of type int64 too large"); } writer.uint32(8).int64(message.height); } for (const v of message.exchangeRates) { DecCoin.encode(v, writer.uint32(18).fork()).join(); } return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseOracleVoteExtension(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 8) { break; } message.height = reader.int64(); continue; } case 2: { if (tag !== 18) { break; } message.exchangeRates.push(DecCoin.decode(reader, reader.uint32())); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { height: isSet(object.height) ? BigInt(object.height) : 0n, exchangeRates: globalThis.Array.isArray(object?.exchangeRates) ? object.exchangeRates.map((e) => DecCoin.fromJSON(e)) : globalThis.Array.isArray(object?.exchange_rates) ? object.exchange_rates.map((e) => DecCoin.fromJSON(e)) : [], }; }, toJSON(message) { const obj = {}; if (message.height !== 0n) { obj.height = message.height.toString(); } if (message.exchangeRates?.length) { obj.exchangeRates = message.exchangeRates.map((e) => DecCoin.toJSON(e)); } return obj; }, create(base) { return OracleVoteExtension.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseOracleVoteExtension(); message.height = object.height ?? 0n; message.exchangeRates = object.exchangeRates?.map((e) => DecCoin.fromPartial(e)) || []; return message; }, }; function createBaseInjectedVoteExtensionTx() { return { exchangeRateVotes: [], extendedCommitInfo: new Uint8Array(0) }; } export const InjectedVoteExtensionTx = { encode(message, writer = new BinaryWriter()) { for (const v of message.exchangeRateVotes) { AggregateExchangeRateVote.encode(v, writer.uint32(10).fork()).join(); } if (message.extendedCommitInfo.length !== 0) { writer.uint32(18).bytes(message.extendedCommitInfo); } return writer; }, decode(input, length) { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInjectedVoteExtensionTx(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.exchangeRateVotes.push(AggregateExchangeRateVote.decode(reader, reader.uint32())); continue; } case 2: { if (tag !== 18) { break; } message.extendedCommitInfo = reader.bytes(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { exchangeRateVotes: globalThis.Array.isArray(object?.exchangeRateVotes) ? object.exchangeRateVotes.map((e) => AggregateExchangeRateVote.fromJSON(e)) : globalThis.Array.isArray(object?.exchange_rate_votes) ? object.exchange_rate_votes.map((e) => AggregateExchangeRateVote.fromJSON(e)) : [], extendedCommitInfo: isSet(object.extendedCommitInfo) ? bytesFromBase64(object.extendedCommitInfo) : isSet(object.extended_commit_info) ? bytesFromBase64(object.extended_commit_info) : new Uint8Array(0), }; }, toJSON(message) { const obj = {}; if (message.exchangeRateVotes?.length) { obj.exchangeRateVotes = message.exchangeRateVotes.map((e) => AggregateExchangeRateVote.toJSON(e)); } if (message.extendedCommitInfo.length !== 0) { obj.extendedCommitInfo = base64FromBytes(message.extendedCommitInfo); } return obj; }, create(base) { return InjectedVoteExtensionTx.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseInjectedVoteExtensionTx(); message.exchangeRateVotes = object.exchangeRateVotes?.map((e) => AggregateExchangeRateVote.fromPartial(e)) || []; message.extendedCommitInfo = object.extendedCommitInfo ?? new Uint8Array(0); return message; }, }; function bytesFromBase64(b64) { if (globalThis.Buffer) { return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); for (let i = 0; i < bin.length; ++i) { arr[i] = bin.charCodeAt(i); } return arr; } } function base64FromBytes(arr) { if (globalThis.Buffer) { return globalThis.Buffer.from(arr).toString("base64"); } else { const bin = []; arr.forEach((byte) => { bin.push(globalThis.String.fromCharCode(byte)); }); return globalThis.btoa(bin.join("")); } } function isSet(value) { return value !== null && value !== undefined; } //# sourceMappingURL=abci.js.map