interchainjs
Version:
InterchainJS is a JavaScript library for interacting with Cosmos SDK based blockchains.
1,205 lines • 107 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValidatorUpdates = exports.Pool = exports.RedelegationResponse = exports.RedelegationEntryResponse = exports.DelegationResponse = exports.Params = exports.Redelegation = exports.RedelegationEntry = exports.UnbondingDelegationEntry = exports.UnbondingDelegation = exports.Delegation = exports.DVVTriplets = exports.DVVTriplet = exports.DVPairs = exports.DVPair = exports.ValAddresses = exports.Validator = exports.Description = exports.Commission = exports.CommissionRates = exports.HistoricalInfo = exports.InfractionAmino = exports.Infraction = exports.BondStatusAmino = exports.BondStatus = void 0;
exports.bondStatusFromJSON = bondStatusFromJSON;
exports.bondStatusToJSON = bondStatusToJSON;
exports.infractionFromJSON = infractionFromJSON;
exports.infractionToJSON = infractionToJSON;
const types_1 = require("../../../tendermint/types/types");
const timestamp_1 = require("../../../google/protobuf/timestamp");
const any_1 = require("../../../google/protobuf/any");
const duration_1 = require("../../../google/protobuf/duration");
const coin_1 = require("../../base/v1beta1/coin");
const types_2 = require("../../../tendermint/abci/types");
const binary_1 = require("../../../binary");
const registry_1 = require("../../../registry");
const helpers_1 = require("../../../helpers");
const math_1 = require("@interchainjs/math");
const pubkey_1 = require("@interchainjs/pubkey");
/** BondStatus is the status of a validator. */
var BondStatus;
(function (BondStatus) {
/** BOND_STATUS_UNSPECIFIED - UNSPECIFIED defines an invalid validator status. */
BondStatus[BondStatus["BOND_STATUS_UNSPECIFIED"] = 0] = "BOND_STATUS_UNSPECIFIED";
/** BOND_STATUS_UNBONDED - UNBONDED defines a validator that is not bonded. */
BondStatus[BondStatus["BOND_STATUS_UNBONDED"] = 1] = "BOND_STATUS_UNBONDED";
/** BOND_STATUS_UNBONDING - UNBONDING defines a validator that is unbonding. */
BondStatus[BondStatus["BOND_STATUS_UNBONDING"] = 2] = "BOND_STATUS_UNBONDING";
/** BOND_STATUS_BONDED - BONDED defines a validator that is bonded. */
BondStatus[BondStatus["BOND_STATUS_BONDED"] = 3] = "BOND_STATUS_BONDED";
BondStatus[BondStatus["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(BondStatus || (exports.BondStatus = BondStatus = {}));
exports.BondStatusAmino = BondStatus;
function bondStatusFromJSON(object) {
switch (object) {
case 0:
case "BOND_STATUS_UNSPECIFIED":
return BondStatus.BOND_STATUS_UNSPECIFIED;
case 1:
case "BOND_STATUS_UNBONDED":
return BondStatus.BOND_STATUS_UNBONDED;
case 2:
case "BOND_STATUS_UNBONDING":
return BondStatus.BOND_STATUS_UNBONDING;
case 3:
case "BOND_STATUS_BONDED":
return BondStatus.BOND_STATUS_BONDED;
case -1:
case "UNRECOGNIZED":
default:
return BondStatus.UNRECOGNIZED;
}
}
function bondStatusToJSON(object) {
switch (object) {
case BondStatus.BOND_STATUS_UNSPECIFIED:
return "BOND_STATUS_UNSPECIFIED";
case BondStatus.BOND_STATUS_UNBONDED:
return "BOND_STATUS_UNBONDED";
case BondStatus.BOND_STATUS_UNBONDING:
return "BOND_STATUS_UNBONDING";
case BondStatus.BOND_STATUS_BONDED:
return "BOND_STATUS_BONDED";
case BondStatus.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
/** Infraction indicates the infraction a validator commited. */
var Infraction;
(function (Infraction) {
/** INFRACTION_UNSPECIFIED - UNSPECIFIED defines an empty infraction. */
Infraction[Infraction["INFRACTION_UNSPECIFIED"] = 0] = "INFRACTION_UNSPECIFIED";
/** INFRACTION_DOUBLE_SIGN - DOUBLE_SIGN defines a validator that double-signs a block. */
Infraction[Infraction["INFRACTION_DOUBLE_SIGN"] = 1] = "INFRACTION_DOUBLE_SIGN";
/** INFRACTION_DOWNTIME - DOWNTIME defines a validator that missed signing too many blocks. */
Infraction[Infraction["INFRACTION_DOWNTIME"] = 2] = "INFRACTION_DOWNTIME";
Infraction[Infraction["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(Infraction || (exports.Infraction = Infraction = {}));
exports.InfractionAmino = Infraction;
function infractionFromJSON(object) {
switch (object) {
case 0:
case "INFRACTION_UNSPECIFIED":
return Infraction.INFRACTION_UNSPECIFIED;
case 1:
case "INFRACTION_DOUBLE_SIGN":
return Infraction.INFRACTION_DOUBLE_SIGN;
case 2:
case "INFRACTION_DOWNTIME":
return Infraction.INFRACTION_DOWNTIME;
case -1:
case "UNRECOGNIZED":
default:
return Infraction.UNRECOGNIZED;
}
}
function infractionToJSON(object) {
switch (object) {
case Infraction.INFRACTION_UNSPECIFIED:
return "INFRACTION_UNSPECIFIED";
case Infraction.INFRACTION_DOUBLE_SIGN:
return "INFRACTION_DOUBLE_SIGN";
case Infraction.INFRACTION_DOWNTIME:
return "INFRACTION_DOWNTIME";
case Infraction.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
function createBaseHistoricalInfo() {
return {
header: types_1.Header.fromPartial({}),
valset: []
};
}
/**
* HistoricalInfo contains header and validator information for a given block.
* It is stored as part of staking module's state, which persists the `n` most
* recent HistoricalInfo
* (`n` is set by the staking module's `historical_entries` parameter).
* @name HistoricalInfo
* @package cosmos.staking.v1beta1
* @see proto type: cosmos.staking.v1beta1.HistoricalInfo
*/
exports.HistoricalInfo = {
typeUrl: "/cosmos.staking.v1beta1.HistoricalInfo",
aminoType: "cosmos-sdk/HistoricalInfo",
is(o) {
return o && (o.$typeUrl === exports.HistoricalInfo.typeUrl || types_1.Header.is(o.header) && Array.isArray(o.valset) && (!o.valset.length || exports.Validator.is(o.valset[0])));
},
isAmino(o) {
return o && (o.$typeUrl === exports.HistoricalInfo.typeUrl || types_1.Header.isAmino(o.header) && Array.isArray(o.valset) && (!o.valset.length || exports.Validator.isAmino(o.valset[0])));
},
encode(message, writer = binary_1.BinaryWriter.create()) {
if (message.header !== undefined) {
types_1.Header.encode(message.header, writer.uint32(10).fork()).ldelim();
}
for (const v of message.valset) {
exports.Validator.encode(v, writer.uint32(18).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseHistoricalInfo();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.header = types_1.Header.decode(reader, reader.uint32());
break;
case 2:
message.valset.push(exports.Validator.decode(reader, reader.uint32()));
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseHistoricalInfo();
message.header = object.header !== undefined && object.header !== null ? types_1.Header.fromPartial(object.header) : undefined;
message.valset = object.valset?.map(e => exports.Validator.fromPartial(e)) || [];
return message;
},
fromAmino(object) {
const message = createBaseHistoricalInfo();
if (object.header !== undefined && object.header !== null) {
message.header = types_1.Header.fromAmino(object.header);
}
message.valset = object.valset?.map(e => exports.Validator.fromAmino(e)) || [];
return message;
},
toAmino(message) {
const obj = {};
obj.header = message.header ? types_1.Header.toAmino(message.header) : types_1.Header.toAmino(types_1.Header.fromPartial({}));
if (message.valset) {
obj.valset = message.valset.map(e => e ? exports.Validator.toAmino(e) : undefined);
}
else {
obj.valset = message.valset;
}
return obj;
},
fromAminoMsg(object) {
return exports.HistoricalInfo.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/HistoricalInfo",
value: exports.HistoricalInfo.toAmino(message)
};
},
fromProtoMsg(message) {
return exports.HistoricalInfo.decode(message.value);
},
toProto(message) {
return exports.HistoricalInfo.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.staking.v1beta1.HistoricalInfo",
value: exports.HistoricalInfo.encode(message).finish()
};
},
registerTypeUrl() {
if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.HistoricalInfo.typeUrl)) {
return;
}
types_1.Header.registerTypeUrl();
exports.Validator.registerTypeUrl();
}
};
function createBaseCommissionRates() {
return {
rate: "",
maxRate: "",
maxChangeRate: ""
};
}
/**
* CommissionRates defines the initial commission rates to be used for creating
* a validator.
* @name CommissionRates
* @package cosmos.staking.v1beta1
* @see proto type: cosmos.staking.v1beta1.CommissionRates
*/
exports.CommissionRates = {
typeUrl: "/cosmos.staking.v1beta1.CommissionRates",
aminoType: "cosmos-sdk/CommissionRates",
is(o) {
return o && (o.$typeUrl === exports.CommissionRates.typeUrl || typeof o.rate === "string" && typeof o.maxRate === "string" && typeof o.maxChangeRate === "string");
},
isAmino(o) {
return o && (o.$typeUrl === exports.CommissionRates.typeUrl || typeof o.rate === "string" && typeof o.max_rate === "string" && typeof o.max_change_rate === "string");
},
encode(message, writer = binary_1.BinaryWriter.create()) {
if (message.rate !== "") {
writer.uint32(10).string(math_1.Decimal.fromUserInput(message.rate, 18).atomics);
}
if (message.maxRate !== "") {
writer.uint32(18).string(math_1.Decimal.fromUserInput(message.maxRate, 18).atomics);
}
if (message.maxChangeRate !== "") {
writer.uint32(26).string(math_1.Decimal.fromUserInput(message.maxChangeRate, 18).atomics);
}
return writer;
},
decode(input, length) {
const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseCommissionRates();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.rate = math_1.Decimal.fromAtomics(reader.string(), 18).toString();
break;
case 2:
message.maxRate = math_1.Decimal.fromAtomics(reader.string(), 18).toString();
break;
case 3:
message.maxChangeRate = math_1.Decimal.fromAtomics(reader.string(), 18).toString();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseCommissionRates();
message.rate = object.rate ?? "";
message.maxRate = object.maxRate ?? "";
message.maxChangeRate = object.maxChangeRate ?? "";
return message;
},
fromAmino(object) {
const message = createBaseCommissionRates();
if (object.rate !== undefined && object.rate !== null) {
message.rate = object.rate;
}
if (object.max_rate !== undefined && object.max_rate !== null) {
message.maxRate = object.max_rate;
}
if (object.max_change_rate !== undefined && object.max_change_rate !== null) {
message.maxChangeRate = object.max_change_rate;
}
return message;
},
toAmino(message) {
const obj = {};
obj.rate = math_1.Decimal.fromUserInput(message.rate, 18).atomics ?? "";
obj.max_rate = math_1.Decimal.fromUserInput(message.maxRate, 18).atomics ?? "";
obj.max_change_rate = math_1.Decimal.fromUserInput(message.maxChangeRate, 18).atomics ?? "";
return obj;
},
fromAminoMsg(object) {
return exports.CommissionRates.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/CommissionRates",
value: exports.CommissionRates.toAmino(message)
};
},
fromProtoMsg(message) {
return exports.CommissionRates.decode(message.value);
},
toProto(message) {
return exports.CommissionRates.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.staking.v1beta1.CommissionRates",
value: exports.CommissionRates.encode(message).finish()
};
},
registerTypeUrl() { }
};
function createBaseCommission() {
return {
commissionRates: exports.CommissionRates.fromPartial({}),
updateTime: new Date()
};
}
/**
* Commission defines commission parameters for a given validator.
* @name Commission
* @package cosmos.staking.v1beta1
* @see proto type: cosmos.staking.v1beta1.Commission
*/
exports.Commission = {
typeUrl: "/cosmos.staking.v1beta1.Commission",
aminoType: "cosmos-sdk/Commission",
is(o) {
return o && (o.$typeUrl === exports.Commission.typeUrl || exports.CommissionRates.is(o.commissionRates) && timestamp_1.Timestamp.is(o.updateTime));
},
isAmino(o) {
return o && (o.$typeUrl === exports.Commission.typeUrl || exports.CommissionRates.isAmino(o.commission_rates) && timestamp_1.Timestamp.isAmino(o.update_time));
},
encode(message, writer = binary_1.BinaryWriter.create()) {
if (message.commissionRates !== undefined) {
exports.CommissionRates.encode(message.commissionRates, writer.uint32(10).fork()).ldelim();
}
if (message.updateTime !== undefined) {
timestamp_1.Timestamp.encode((0, helpers_1.toTimestamp)(message.updateTime), writer.uint32(18).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseCommission();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.commissionRates = exports.CommissionRates.decode(reader, reader.uint32());
break;
case 2:
message.updateTime = (0, helpers_1.fromTimestamp)(timestamp_1.Timestamp.decode(reader, reader.uint32()));
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseCommission();
message.commissionRates = object.commissionRates !== undefined && object.commissionRates !== null ? exports.CommissionRates.fromPartial(object.commissionRates) : undefined;
message.updateTime = object.updateTime ?? undefined;
return message;
},
fromAmino(object) {
const message = createBaseCommission();
if (object.commission_rates !== undefined && object.commission_rates !== null) {
message.commissionRates = exports.CommissionRates.fromAmino(object.commission_rates);
}
if (object.update_time !== undefined && object.update_time !== null) {
message.updateTime = (0, helpers_1.fromTimestamp)(timestamp_1.Timestamp.fromAmino(object.update_time));
}
return message;
},
toAmino(message) {
const obj = {};
obj.commission_rates = message.commissionRates ? exports.CommissionRates.toAmino(message.commissionRates) : exports.CommissionRates.toAmino(exports.CommissionRates.fromPartial({}));
obj.update_time = message.updateTime ? timestamp_1.Timestamp.toAmino((0, helpers_1.toTimestamp)(message.updateTime)) : new Date();
return obj;
},
fromAminoMsg(object) {
return exports.Commission.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/Commission",
value: exports.Commission.toAmino(message)
};
},
fromProtoMsg(message) {
return exports.Commission.decode(message.value);
},
toProto(message) {
return exports.Commission.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.staking.v1beta1.Commission",
value: exports.Commission.encode(message).finish()
};
},
registerTypeUrl() {
if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.Commission.typeUrl)) {
return;
}
exports.CommissionRates.registerTypeUrl();
}
};
function createBaseDescription() {
return {
moniker: "",
identity: "",
website: "",
securityContact: "",
details: ""
};
}
/**
* Description defines a validator description.
* @name Description
* @package cosmos.staking.v1beta1
* @see proto type: cosmos.staking.v1beta1.Description
*/
exports.Description = {
typeUrl: "/cosmos.staking.v1beta1.Description",
aminoType: "cosmos-sdk/Description",
is(o) {
return o && (o.$typeUrl === exports.Description.typeUrl || typeof o.moniker === "string" && typeof o.identity === "string" && typeof o.website === "string" && typeof o.securityContact === "string" && typeof o.details === "string");
},
isAmino(o) {
return o && (o.$typeUrl === exports.Description.typeUrl || typeof o.moniker === "string" && typeof o.identity === "string" && typeof o.website === "string" && typeof o.security_contact === "string" && typeof o.details === "string");
},
encode(message, writer = binary_1.BinaryWriter.create()) {
if (message.moniker !== "") {
writer.uint32(10).string(message.moniker);
}
if (message.identity !== "") {
writer.uint32(18).string(message.identity);
}
if (message.website !== "") {
writer.uint32(26).string(message.website);
}
if (message.securityContact !== "") {
writer.uint32(34).string(message.securityContact);
}
if (message.details !== "") {
writer.uint32(42).string(message.details);
}
return writer;
},
decode(input, length) {
const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseDescription();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.moniker = reader.string();
break;
case 2:
message.identity = reader.string();
break;
case 3:
message.website = reader.string();
break;
case 4:
message.securityContact = reader.string();
break;
case 5:
message.details = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseDescription();
message.moniker = object.moniker ?? "";
message.identity = object.identity ?? "";
message.website = object.website ?? "";
message.securityContact = object.securityContact ?? "";
message.details = object.details ?? "";
return message;
},
fromAmino(object) {
const message = createBaseDescription();
if (object.moniker !== undefined && object.moniker !== null) {
message.moniker = object.moniker;
}
if (object.identity !== undefined && object.identity !== null) {
message.identity = object.identity;
}
if (object.website !== undefined && object.website !== null) {
message.website = object.website;
}
if (object.security_contact !== undefined && object.security_contact !== null) {
message.securityContact = object.security_contact;
}
if (object.details !== undefined && object.details !== null) {
message.details = object.details;
}
return message;
},
toAmino(message) {
const obj = {};
obj.moniker = message.moniker === "" ? undefined : message.moniker;
obj.identity = message.identity === "" ? undefined : message.identity;
obj.website = message.website === "" ? undefined : message.website;
obj.security_contact = message.securityContact === "" ? undefined : message.securityContact;
obj.details = message.details === "" ? undefined : message.details;
return obj;
},
fromAminoMsg(object) {
return exports.Description.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/Description",
value: exports.Description.toAmino(message)
};
},
fromProtoMsg(message) {
return exports.Description.decode(message.value);
},
toProto(message) {
return exports.Description.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.staking.v1beta1.Description",
value: exports.Description.encode(message).finish()
};
},
registerTypeUrl() { }
};
function createBaseValidator() {
return {
operatorAddress: "",
consensusPubkey: undefined,
jailed: false,
status: 0,
tokens: "",
delegatorShares: "",
description: exports.Description.fromPartial({}),
unbondingHeight: BigInt(0),
unbondingTime: new Date(),
commission: exports.Commission.fromPartial({}),
minSelfDelegation: "",
unbondingOnHoldRefCount: BigInt(0),
unbondingIds: []
};
}
/**
* Validator defines a validator, together with the total amount of the
* Validator's bond shares and their exchange rate to coins. Slashing results in
* a decrease in the exchange rate, allowing correct calculation of future
* undelegations without iterating over delegators. When coins are delegated to
* this validator, the validator is credited with a delegation whose number of
* bond shares is based on the amount of coins delegated divided by the current
* exchange rate. Voting power can be calculated as total bonded shares
* multiplied by exchange rate.
* @name Validator
* @package cosmos.staking.v1beta1
* @see proto type: cosmos.staking.v1beta1.Validator
*/
exports.Validator = {
typeUrl: "/cosmos.staking.v1beta1.Validator",
aminoType: "cosmos-sdk/Validator",
is(o) {
return o && (o.$typeUrl === exports.Validator.typeUrl || typeof o.operatorAddress === "string" && typeof o.jailed === "boolean" && (0, helpers_1.isSet)(o.status) && typeof o.tokens === "string" && typeof o.delegatorShares === "string" && exports.Description.is(o.description) && typeof o.unbondingHeight === "bigint" && timestamp_1.Timestamp.is(o.unbondingTime) && exports.Commission.is(o.commission) && typeof o.minSelfDelegation === "string" && typeof o.unbondingOnHoldRefCount === "bigint" && Array.isArray(o.unbondingIds) && (!o.unbondingIds.length || typeof o.unbondingIds[0] === "bigint"));
},
isAmino(o) {
return o && (o.$typeUrl === exports.Validator.typeUrl || typeof o.operator_address === "string" && typeof o.jailed === "boolean" && (0, helpers_1.isSet)(o.status) && typeof o.tokens === "string" && typeof o.delegator_shares === "string" && exports.Description.isAmino(o.description) && typeof o.unbonding_height === "bigint" && timestamp_1.Timestamp.isAmino(o.unbonding_time) && exports.Commission.isAmino(o.commission) && typeof o.min_self_delegation === "string" && typeof o.unbonding_on_hold_ref_count === "bigint" && Array.isArray(o.unbonding_ids) && (!o.unbonding_ids.length || typeof o.unbonding_ids[0] === "bigint"));
},
encode(message, writer = binary_1.BinaryWriter.create()) {
if (message.operatorAddress !== "") {
writer.uint32(10).string(message.operatorAddress);
}
if (message.consensusPubkey !== undefined) {
any_1.Any.encode(registry_1.GlobalDecoderRegistry.wrapAny(message.consensusPubkey), writer.uint32(18).fork()).ldelim();
}
if (message.jailed === true) {
writer.uint32(24).bool(message.jailed);
}
if (message.status !== 0) {
writer.uint32(32).int32(message.status);
}
if (message.tokens !== "") {
writer.uint32(42).string(message.tokens);
}
if (message.delegatorShares !== "") {
writer.uint32(50).string(math_1.Decimal.fromUserInput(message.delegatorShares, 18).atomics);
}
if (message.description !== undefined) {
exports.Description.encode(message.description, writer.uint32(58).fork()).ldelim();
}
if (message.unbondingHeight !== BigInt(0)) {
writer.uint32(64).int64(message.unbondingHeight);
}
if (message.unbondingTime !== undefined) {
timestamp_1.Timestamp.encode((0, helpers_1.toTimestamp)(message.unbondingTime), writer.uint32(74).fork()).ldelim();
}
if (message.commission !== undefined) {
exports.Commission.encode(message.commission, writer.uint32(82).fork()).ldelim();
}
if (message.minSelfDelegation !== "") {
writer.uint32(90).string(message.minSelfDelegation);
}
if (message.unbondingOnHoldRefCount !== BigInt(0)) {
writer.uint32(96).int64(message.unbondingOnHoldRefCount);
}
writer.uint32(106).fork();
for (const v of message.unbondingIds) {
writer.uint64(v);
}
writer.ldelim();
return writer;
},
decode(input, length) {
const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseValidator();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.operatorAddress = reader.string();
break;
case 2:
message.consensusPubkey = registry_1.GlobalDecoderRegistry.unwrapAny(reader);
break;
case 3:
message.jailed = reader.bool();
break;
case 4:
message.status = reader.int32();
break;
case 5:
message.tokens = reader.string();
break;
case 6:
message.delegatorShares = math_1.Decimal.fromAtomics(reader.string(), 18).toString();
break;
case 7:
message.description = exports.Description.decode(reader, reader.uint32());
break;
case 8:
message.unbondingHeight = reader.int64();
break;
case 9:
message.unbondingTime = (0, helpers_1.fromTimestamp)(timestamp_1.Timestamp.decode(reader, reader.uint32()));
break;
case 10:
message.commission = exports.Commission.decode(reader, reader.uint32());
break;
case 11:
message.minSelfDelegation = reader.string();
break;
case 12:
message.unbondingOnHoldRefCount = reader.int64();
break;
case 13:
if ((tag & 7) === 2) {
const end2 = reader.uint32() + reader.pos;
while (reader.pos < end2) {
message.unbondingIds.push(reader.uint64());
}
}
else {
message.unbondingIds.push(reader.uint64());
}
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseValidator();
message.operatorAddress = object.operatorAddress ?? "";
message.consensusPubkey = object.consensusPubkey !== undefined && object.consensusPubkey !== null ? registry_1.GlobalDecoderRegistry.fromPartial(object.consensusPubkey) : undefined;
message.jailed = object.jailed ?? false;
message.status = object.status ?? 0;
message.tokens = object.tokens ?? "";
message.delegatorShares = object.delegatorShares ?? "";
message.description = object.description !== undefined && object.description !== null ? exports.Description.fromPartial(object.description) : undefined;
message.unbondingHeight = object.unbondingHeight !== undefined && object.unbondingHeight !== null ? BigInt(object.unbondingHeight.toString()) : BigInt(0);
message.unbondingTime = object.unbondingTime ?? undefined;
message.commission = object.commission !== undefined && object.commission !== null ? exports.Commission.fromPartial(object.commission) : undefined;
message.minSelfDelegation = object.minSelfDelegation ?? "";
message.unbondingOnHoldRefCount = object.unbondingOnHoldRefCount !== undefined && object.unbondingOnHoldRefCount !== null ? BigInt(object.unbondingOnHoldRefCount.toString()) : BigInt(0);
message.unbondingIds = object.unbondingIds?.map(e => BigInt(e.toString())) || [];
return message;
},
fromAmino(object) {
const message = createBaseValidator();
if (object.operator_address !== undefined && object.operator_address !== null) {
message.operatorAddress = object.operator_address;
}
if (object.consensus_pubkey !== undefined && object.consensus_pubkey !== null) {
message.consensusPubkey = (0, pubkey_1.encodePubkey)(object.consensus_pubkey);
}
if (object.jailed !== undefined && object.jailed !== null) {
message.jailed = object.jailed;
}
if (object.status !== undefined && object.status !== null) {
message.status = object.status;
}
if (object.tokens !== undefined && object.tokens !== null) {
message.tokens = object.tokens;
}
if (object.delegator_shares !== undefined && object.delegator_shares !== null) {
message.delegatorShares = object.delegator_shares;
}
if (object.description !== undefined && object.description !== null) {
message.description = exports.Description.fromAmino(object.description);
}
if (object.unbonding_height !== undefined && object.unbonding_height !== null) {
message.unbondingHeight = BigInt(object.unbonding_height);
}
if (object.unbonding_time !== undefined && object.unbonding_time !== null) {
message.unbondingTime = (0, helpers_1.fromTimestamp)(timestamp_1.Timestamp.fromAmino(object.unbonding_time));
}
if (object.commission !== undefined && object.commission !== null) {
message.commission = exports.Commission.fromAmino(object.commission);
}
if (object.min_self_delegation !== undefined && object.min_self_delegation !== null) {
message.minSelfDelegation = object.min_self_delegation;
}
if (object.unbonding_on_hold_ref_count !== undefined && object.unbonding_on_hold_ref_count !== null) {
message.unbondingOnHoldRefCount = BigInt(object.unbonding_on_hold_ref_count);
}
message.unbondingIds = object.unbonding_ids?.map(e => BigInt(e)) || [];
return message;
},
toAmino(message) {
const obj = {};
obj.operator_address = message.operatorAddress === "" ? undefined : message.operatorAddress;
obj.consensus_pubkey = message.consensusPubkey ? (0, pubkey_1.decodePubkey)(message.consensusPubkey) : undefined;
obj.jailed = message.jailed === false ? undefined : message.jailed;
obj.status = message.status === 0 ? undefined : message.status;
obj.tokens = message.tokens === "" ? undefined : message.tokens;
obj.delegator_shares = message.delegatorShares === "" ? undefined : math_1.Decimal.fromUserInput(message.delegatorShares, 18).atomics;
obj.description = message.description ? exports.Description.toAmino(message.description) : exports.Description.toAmino(exports.Description.fromPartial({}));
obj.unbonding_height = message.unbondingHeight !== BigInt(0) ? message.unbondingHeight?.toString() : undefined;
obj.unbonding_time = message.unbondingTime ? timestamp_1.Timestamp.toAmino((0, helpers_1.toTimestamp)(message.unbondingTime)) : new Date();
obj.commission = message.commission ? exports.Commission.toAmino(message.commission) : exports.Commission.toAmino(exports.Commission.fromPartial({}));
obj.min_self_delegation = message.minSelfDelegation === "" ? undefined : message.minSelfDelegation;
obj.unbonding_on_hold_ref_count = message.unbondingOnHoldRefCount !== BigInt(0) ? message.unbondingOnHoldRefCount?.toString() : undefined;
if (message.unbondingIds) {
obj.unbonding_ids = message.unbondingIds.map(e => e.toString());
}
else {
obj.unbonding_ids = message.unbondingIds;
}
return obj;
},
fromAminoMsg(object) {
return exports.Validator.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/Validator",
value: exports.Validator.toAmino(message)
};
},
fromProtoMsg(message) {
return exports.Validator.decode(message.value);
},
toProto(message) {
return exports.Validator.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.staking.v1beta1.Validator",
value: exports.Validator.encode(message).finish()
};
},
registerTypeUrl() {
if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.Validator.typeUrl)) {
return;
}
exports.Description.registerTypeUrl();
exports.Commission.registerTypeUrl();
}
};
function createBaseValAddresses() {
return {
addresses: []
};
}
/**
* ValAddresses defines a repeated set of validator addresses.
* @name ValAddresses
* @package cosmos.staking.v1beta1
* @see proto type: cosmos.staking.v1beta1.ValAddresses
*/
exports.ValAddresses = {
typeUrl: "/cosmos.staking.v1beta1.ValAddresses",
aminoType: "cosmos-sdk/ValAddresses",
is(o) {
return o && (o.$typeUrl === exports.ValAddresses.typeUrl || Array.isArray(o.addresses) && (!o.addresses.length || typeof o.addresses[0] === "string"));
},
isAmino(o) {
return o && (o.$typeUrl === exports.ValAddresses.typeUrl || Array.isArray(o.addresses) && (!o.addresses.length || typeof o.addresses[0] === "string"));
},
encode(message, writer = binary_1.BinaryWriter.create()) {
for (const v of message.addresses) {
writer.uint32(10).string(v);
}
return writer;
},
decode(input, length) {
const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseValAddresses();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.addresses.push(reader.string());
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseValAddresses();
message.addresses = object.addresses?.map(e => e) || [];
return message;
},
fromAmino(object) {
const message = createBaseValAddresses();
message.addresses = object.addresses?.map(e => e) || [];
return message;
},
toAmino(message) {
const obj = {};
if (message.addresses) {
obj.addresses = message.addresses.map(e => e);
}
else {
obj.addresses = message.addresses;
}
return obj;
},
fromAminoMsg(object) {
return exports.ValAddresses.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/ValAddresses",
value: exports.ValAddresses.toAmino(message)
};
},
fromProtoMsg(message) {
return exports.ValAddresses.decode(message.value);
},
toProto(message) {
return exports.ValAddresses.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.staking.v1beta1.ValAddresses",
value: exports.ValAddresses.encode(message).finish()
};
},
registerTypeUrl() { }
};
function createBaseDVPair() {
return {
delegatorAddress: "",
validatorAddress: ""
};
}
/**
* DVPair is struct that just has a delegator-validator pair with no other data.
* It is intended to be used as a marshalable pointer. For example, a DVPair can
* be used to construct the key to getting an UnbondingDelegation from state.
* @name DVPair
* @package cosmos.staking.v1beta1
* @see proto type: cosmos.staking.v1beta1.DVPair
*/
exports.DVPair = {
typeUrl: "/cosmos.staking.v1beta1.DVPair",
aminoType: "cosmos-sdk/DVPair",
is(o) {
return o && (o.$typeUrl === exports.DVPair.typeUrl || typeof o.delegatorAddress === "string" && typeof o.validatorAddress === "string");
},
isAmino(o) {
return o && (o.$typeUrl === exports.DVPair.typeUrl || typeof o.delegator_address === "string" && typeof o.validator_address === "string");
},
encode(message, writer = binary_1.BinaryWriter.create()) {
if (message.delegatorAddress !== "") {
writer.uint32(10).string(message.delegatorAddress);
}
if (message.validatorAddress !== "") {
writer.uint32(18).string(message.validatorAddress);
}
return writer;
},
decode(input, length) {
const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseDVPair();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.delegatorAddress = reader.string();
break;
case 2:
message.validatorAddress = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseDVPair();
message.delegatorAddress = object.delegatorAddress ?? "";
message.validatorAddress = object.validatorAddress ?? "";
return message;
},
fromAmino(object) {
const message = createBaseDVPair();
if (object.delegator_address !== undefined && object.delegator_address !== null) {
message.delegatorAddress = object.delegator_address;
}
if (object.validator_address !== undefined && object.validator_address !== null) {
message.validatorAddress = object.validator_address;
}
return message;
},
toAmino(message) {
const obj = {};
obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress;
obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress;
return obj;
},
fromAminoMsg(object) {
return exports.DVPair.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/DVPair",
value: exports.DVPair.toAmino(message)
};
},
fromProtoMsg(message) {
return exports.DVPair.decode(message.value);
},
toProto(message) {
return exports.DVPair.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.staking.v1beta1.DVPair",
value: exports.DVPair.encode(message).finish()
};
},
registerTypeUrl() { }
};
function createBaseDVPairs() {
return {
pairs: []
};
}
/**
* DVPairs defines an array of DVPair objects.
* @name DVPairs
* @package cosmos.staking.v1beta1
* @see proto type: cosmos.staking.v1beta1.DVPairs
*/
exports.DVPairs = {
typeUrl: "/cosmos.staking.v1beta1.DVPairs",
aminoType: "cosmos-sdk/DVPairs",
is(o) {
return o && (o.$typeUrl === exports.DVPairs.typeUrl || Array.isArray(o.pairs) && (!o.pairs.length || exports.DVPair.is(o.pairs[0])));
},
isAmino(o) {
return o && (o.$typeUrl === exports.DVPairs.typeUrl || Array.isArray(o.pairs) && (!o.pairs.length || exports.DVPair.isAmino(o.pairs[0])));
},
encode(message, writer = binary_1.BinaryWriter.create()) {
for (const v of message.pairs) {
exports.DVPair.encode(v, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseDVPairs();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.pairs.push(exports.DVPair.decode(reader, reader.uint32()));
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseDVPairs();
message.pairs = object.pairs?.map(e => exports.DVPair.fromPartial(e)) || [];
return message;
},
fromAmino(object) {
const message = createBaseDVPairs();
message.pairs = object.pairs?.map(e => exports.DVPair.fromAmino(e)) || [];
return message;
},
toAmino(message) {
const obj = {};
if (message.pairs) {
obj.pairs = message.pairs.map(e => e ? exports.DVPair.toAmino(e) : undefined);
}
else {
obj.pairs = message.pairs;
}
return obj;
},
fromAminoMsg(object) {
return exports.DVPairs.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/DVPairs",
value: exports.DVPairs.toAmino(message)
};
},
fromProtoMsg(message) {
return exports.DVPairs.decode(message.value);
},
toProto(message) {
return exports.DVPairs.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.staking.v1beta1.DVPairs",
value: exports.DVPairs.encode(message).finish()
};
},
registerTypeUrl() {
if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.DVPairs.typeUrl)) {
return;
}
exports.DVPair.registerTypeUrl();
}
};
function createBaseDVVTriplet() {
return {
delegatorAddress: "",
validatorSrcAddress: "",
validatorDstAddress: ""
};
}
/**
* DVVTriplet is struct that just has a delegator-validator-validator triplet
* with no other data. It is intended to be used as a marshalable pointer. For
* example, a DVVTriplet can be used to construct the key to getting a
* Redelegation from state.
* @name DVVTriplet
* @package cosmos.staking.v1beta1
* @see proto type: cosmos.staking.v1beta1.DVVTriplet
*/
exports.DVVTriplet = {
typeUrl: "/cosmos.staking.v1beta1.DVVTriplet",
aminoType: "cosmos-sdk/DVVTriplet",
is(o) {
return o && (o.$typeUrl === exports.DVVTriplet.typeUrl || typeof o.delegatorAddress === "string" && typeof o.validatorSrcAddress === "string" && typeof o.validatorDstAddress === "string");
},
isAmino(o) {
return o && (o.$typeUrl === exports.DVVTriplet.typeUrl || typeof o.delegator_address === "string" && typeof o.validator_src_address === "string" && typeof o.validator_dst_address === "string");
},
encode(message, writer = binary_1.BinaryWriter.create()) {
if (message.delegatorAddress !== "") {
writer.uint32(10).string(message.delegatorAddress);
}
if (message.validatorSrcAddress !== "") {
writer.uint32(18).string(message.validatorSrcAddress);
}
if (message.validatorDstAddress !== "") {
writer.uint32(26).string(message.validatorDstAddress);
}
return writer;
},
decode(input, length) {
const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseDVVTriplet();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.delegatorAddress = reader.string();
break;
case 2:
message.validatorSrcAddress = reader.string();
break;
case 3:
message.validatorDstAddress = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromPartial(object) {
const message = createBaseDVVTriplet();
message.delegatorAddress = object.delegatorAddress ?? "";
message.validatorSrcAddress = object.validatorSrcAddress ?? "";
message.validatorDstAddress = object.validatorDstAddress ?? "";
return message;
},
fromAmino(object) {
const message = createBaseDVVTriplet();
if (object.delegator_address !== undefined && object.delegator_address !== null) {
message.delegatorAddress = object.delegator_address;
}
if (object.validator_src_address !== undefined && object.validator_src_address !== null) {
message.validatorSrcAddress = object.validator_src_address;
}
if (object.validator_dst_address !== undefined && object.validator_dst_address !== null) {
message.validatorDstAddress = object.validator_dst_address;
}
return message;
},
toAmino(message) {
const obj = {};
obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress;
obj.validator_src_address = message.validatorSrcAddress === "" ? undefined : message.validatorSrcAddress;
obj.validator_dst_address = message.validatorDstAddress === "" ? undefined : message.validatorDstAddress;
return obj;
},
fromAminoMsg(object) {
return exports.DVVTriplet.fromAmino(object.value);
},
toAminoMsg(message) {
return {
type: "cosmos-sdk/DVVTriplet",
value: exports.DVVTriplet.toAmino(message)
};
},
fromProtoMsg(message) {
return exports.DVVTriplet.decode(message.value);
},
toProto(message) {
return exports.DVVTriplet.encode(message).finish();
},
toProtoMsg(message) {
return {
typeUrl: "/cosmos.staking.v1beta1.DVVTriplet",
value: exports.DVVTriplet.encode(message).finish()
};
},
registerTypeUrl() { }
};
function createBaseDVVTriplets() {
return {
triplets: []
};
}
/**
* DVVTriplets defines an array of DVVTriplet objects.
* @name DVVTriplets
* @package cosmos.staking.v1beta1
* @see proto type: cosmos.staking.v1beta1.DVVTriplets
*/
exports.DVVTriplets = {
typeUrl: "/cosmos.staking.v1b