diff --git a/package-lock.json b/package-lock.json index 28b8b69..2bd8365 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,20 @@ { "name": "@babylonlabs-io/babylon-proto-ts", - "version": "0.0.3", + "version": "0.0.3-canary.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@babylonlabs-io/babylon-proto-ts", - "version": "0.0.3", + "version": "0.0.3-canary.1", "license": "ISC", "dependencies": { "@bufbuild/protobuf": "^2.2.0" }, "devDependencies": { "@bufbuild/buf": "^1.45.0", - "shelljs": "^0.8.5" + "shelljs": "^0.8.5", + "typescript": "^5.6.3" } }, "node_modules/@bufbuild/buf": { @@ -371,6 +372,20 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/typescript": { + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", + "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/package.json b/package.json index bd920a5..96554f9 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,10 @@ { "name": "@babylonlabs-io/babylon-proto-ts", - "version": "0.0.3", - "main": "index.js", + "version": "0.0.3-canary.1", + "main": "dist/index.js", + "types": "dist/index.d.ts", "scripts": { - "build": "node scripts/build-proto.js", + "build": "tsc && node scripts/build-proto.js", "prepublishOnly": "npm run build" }, "files": [ @@ -15,7 +16,8 @@ "description": "", "devDependencies": { "@bufbuild/buf": "^1.45.0", - "shelljs": "^0.8.5" + "shelljs": "^0.8.5", + "typescript": "^5.6.3" }, "dependencies": { "@bufbuild/protobuf": "^2.2.0" @@ -23,4 +25,4 @@ "publishConfig": { "access": "public" } -} +} \ No newline at end of file diff --git a/scripts/build-proto.js b/scripts/build-proto.js index d993aa0..119f314 100644 --- a/scripts/build-proto.js +++ b/scripts/build-proto.js @@ -1,7 +1,7 @@ // scripts/build-proto.js const shell = require("shelljs") -const BABYLON_REPO_URL = "https://github.com/babylonchain/babylon.git" +const BABYLON_REPO_URL = "https://github.com/babylonlabs-io/babylon.git" const BABYLON_REPO_DIR = "babylon" const PROTO_DIR = "proto" diff --git a/src/generated/babylon/btccheckpoint/v1/btccheckpoint.ts b/src/generated/babylon/btccheckpoint/v1/btccheckpoint.ts index d696e0d..8567ff2 100644 --- a/src/generated/babylon/btccheckpoint/v1/btccheckpoint.ts +++ b/src/generated/babylon/btccheckpoint/v1/btccheckpoint.ts @@ -819,7 +819,7 @@ export const BTCCheckpointInfo: MessageFns = { writer.uint32(8).uint64(message.epochNumber); } if (message.bestSubmissionBtcBlockHeight !== 0) { - writer.uint32(16).uint64(message.bestSubmissionBtcBlockHeight); + writer.uint32(16).uint32(message.bestSubmissionBtcBlockHeight); } if (message.bestSubmissionBtcBlockHash.length !== 0) { writer.uint32(26).bytes(message.bestSubmissionBtcBlockHash); @@ -852,7 +852,7 @@ export const BTCCheckpointInfo: MessageFns = { break; } - message.bestSubmissionBtcBlockHeight = longToNumber(reader.uint64()); + message.bestSubmissionBtcBlockHeight = reader.uint32(); continue; case 3: if (tag !== 26) { diff --git a/src/generated/babylon/btccheckpoint/v1/params.ts b/src/generated/babylon/btccheckpoint/v1/params.ts index f900f46..de9d7f0 100644 --- a/src/generated/babylon/btccheckpoint/v1/params.ts +++ b/src/generated/babylon/btccheckpoint/v1/params.ts @@ -40,10 +40,10 @@ function createBaseParams(): Params { export const Params: MessageFns = { encode(message: Params, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.btcConfirmationDepth !== 0) { - writer.uint32(8).uint64(message.btcConfirmationDepth); + writer.uint32(8).uint32(message.btcConfirmationDepth); } if (message.checkpointFinalizationTimeout !== 0) { - writer.uint32(16).uint64(message.checkpointFinalizationTimeout); + writer.uint32(16).uint32(message.checkpointFinalizationTimeout); } if (message.checkpointTag !== "") { writer.uint32(26).string(message.checkpointTag); @@ -63,14 +63,14 @@ export const Params: MessageFns = { break; } - message.btcConfirmationDepth = longToNumber(reader.uint64()); + message.btcConfirmationDepth = reader.uint32(); continue; case 2: if (tag !== 16) { break; } - message.checkpointFinalizationTimeout = longToNumber(reader.uint64()); + message.checkpointFinalizationTimeout = reader.uint32(); continue; case 3: if (tag !== 26) { @@ -136,17 +136,6 @@ type KeysOfUnion = T extends T ? keyof T : never; export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; -function longToNumber(int64: { toString(): string }): number { - const num = globalThis.Number(int64.toString()); - if (num > globalThis.Number.MAX_SAFE_INTEGER) { - throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); - } - if (num < globalThis.Number.MIN_SAFE_INTEGER) { - throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); - } - return num; -} - function isSet(value: any): boolean { return value !== null && value !== undefined; } diff --git a/src/generated/babylon/btccheckpoint/v1/query.ts b/src/generated/babylon/btccheckpoint/v1/query.ts index ce42ecb..f9ea8e4 100644 --- a/src/generated/babylon/btccheckpoint/v1/query.ts +++ b/src/generated/babylon/btccheckpoint/v1/query.ts @@ -650,7 +650,7 @@ export const BTCCheckpointInfoResponse: MessageFns = writer.uint32(8).uint64(message.epochNumber); } if (message.bestSubmissionBtcBlockHeight !== 0) { - writer.uint32(16).uint64(message.bestSubmissionBtcBlockHeight); + writer.uint32(16).uint32(message.bestSubmissionBtcBlockHeight); } if (message.bestSubmissionBtcBlockHash !== "") { writer.uint32(26).string(message.bestSubmissionBtcBlockHash); @@ -683,7 +683,7 @@ export const BTCCheckpointInfoResponse: MessageFns = break; } - message.bestSubmissionBtcBlockHeight = longToNumber(reader.uint64()); + message.bestSubmissionBtcBlockHeight = reader.uint32(); continue; case 3: if (tag !== 26) { diff --git a/src/generated/babylon/btccheckpoint/v1/tx.ts b/src/generated/babylon/btccheckpoint/v1/tx.ts index 6ab9d65..fcf1469 100644 --- a/src/generated/babylon/btccheckpoint/v1/tx.ts +++ b/src/generated/babylon/btccheckpoint/v1/tx.ts @@ -12,7 +12,7 @@ import { Params } from "./params"; export const protobufPackage = "babylon.btccheckpoint.v1"; /** - * MsgInsertBTCSpvProof defines resquest to insert a new checkpoint into the + * MsgInsertBTCSpvProof defines request to insert a new checkpoint into the * store */ export interface MsgInsertBTCSpvProof { diff --git a/src/generated/babylon/btclightclient/v1/btclightclient.ts b/src/generated/babylon/btclightclient/v1/btclightclient.ts index 4d96b23..08f1d5e 100644 --- a/src/generated/babylon/btclightclient/v1/btclightclient.ts +++ b/src/generated/babylon/btclightclient/v1/btclightclient.ts @@ -39,7 +39,7 @@ export const BTCHeaderInfo: MessageFns = { writer.uint32(18).bytes(message.hash); } if (message.height !== 0) { - writer.uint32(24).uint64(message.height); + writer.uint32(24).uint32(message.height); } if (message.work.length !== 0) { writer.uint32(34).bytes(message.work); @@ -73,7 +73,7 @@ export const BTCHeaderInfo: MessageFns = { break; } - message.height = longToNumber(reader.uint64()); + message.height = reader.uint32(); continue; case 4: if (tag !== 34) { @@ -167,17 +167,6 @@ type KeysOfUnion = T extends T ? keyof T : never; export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; -function longToNumber(int64: { toString(): string }): number { - const num = globalThis.Number(int64.toString()); - if (num > globalThis.Number.MAX_SAFE_INTEGER) { - throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); - } - if (num < globalThis.Number.MIN_SAFE_INTEGER) { - throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); - } - return num; -} - function isSet(value: any): boolean { return value !== null && value !== undefined; } diff --git a/src/generated/babylon/btclightclient/v1/query.ts b/src/generated/babylon/btclightclient/v1/query.ts index ecd4a7d..6541ab9 100644 --- a/src/generated/babylon/btclightclient/v1/query.ts +++ b/src/generated/babylon/btclightclient/v1/query.ts @@ -1006,7 +1006,7 @@ function createBaseQueryHeaderDepthResponse(): QueryHeaderDepthResponse { export const QueryHeaderDepthResponse: MessageFns = { encode(message: QueryHeaderDepthResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.depth !== 0) { - writer.uint32(8).uint64(message.depth); + writer.uint32(8).uint32(message.depth); } return writer; }, @@ -1023,7 +1023,7 @@ export const QueryHeaderDepthResponse: MessageFns = { break; } - message.depth = longToNumber(reader.uint64()); + message.depth = reader.uint32(); continue; } if ((tag & 7) === 4 || tag === 0) { @@ -1069,7 +1069,7 @@ export const BTCHeaderInfoResponse: MessageFns = { writer.uint32(18).string(message.hashHex); } if (message.height !== 0) { - writer.uint32(24).uint64(message.height); + writer.uint32(24).uint32(message.height); } if (message.work !== "") { writer.uint32(34).string(message.work); @@ -1103,7 +1103,7 @@ export const BTCHeaderInfoResponse: MessageFns = { break; } - message.height = longToNumber(reader.uint64()); + message.height = reader.uint32(); continue; case 4: if (tag !== 34) { @@ -1171,7 +1171,7 @@ export interface Query { /** * ContainsBytes is a temporary method that * checks whether a hash is maintained by the module. - * See discussion at https://github.com/babylonchain/babylon/pull/132 + * See discussion at https://github.com/babylonlabs-io/babylon/pull/132 * for more details. */ ContainsBytes(request: QueryContainsBytesRequest): Promise; @@ -1297,17 +1297,6 @@ type KeysOfUnion = T extends T ? keyof T : never; export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; -function longToNumber(int64: { toString(): string }): number { - const num = globalThis.Number(int64.toString()); - if (num > globalThis.Number.MAX_SAFE_INTEGER) { - throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); - } - if (num < globalThis.Number.MIN_SAFE_INTEGER) { - throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); - } - return num; -} - function isSet(value: any): boolean { return value !== null && value !== undefined; } diff --git a/src/generated/babylon/btcstaking/v1/btcstaking.ts b/src/generated/babylon/btcstaking/v1/btcstaking.ts index 28d52c5..cbb1295 100644 --- a/src/generated/babylon/btcstaking/v1/btcstaking.ts +++ b/src/generated/babylon/btcstaking/v1/btcstaking.ts @@ -7,29 +7,41 @@ /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; import { Description } from "../../../cosmos/staking/v1beta1/staking"; +import { TransactionKey } from "../../btccheckpoint/v1/btccheckpoint"; import { ProofOfPossessionBTC } from "./pop"; export const protobufPackage = "babylon.btcstaking.v1"; /** - * BTCDelegationStatus is the status of a delegation. The state transition path is - * PENDING -> ACTIVE -> UNBONDED with two possibilities: - * 1. the typical path when timelock of staking transaction expires. - * 2. the path when staker requests early undelegation through MsgBTCUndelegate message. + * BTCDelegationStatus is the status of a delegation. + * There are two possible valid state transition paths for a BTC delegation: + * - PENDING -> ACTIVE -> UNBONDED + * - PENDING -> VERIFIED -> ACTIVE -> UNBONDED + * and one invalid state transition path: + * - PENDING -> VERIFIED -> UNBONDED i.e the staker unbonded before + * activating delegation on Babylon chain. + * In valid transition paths, the delegation becomes UNBONDED when: + * - either the staking transaction timelock expires + * - or the staker requests early undelegation through MsgBTCUndelegate message. */ export enum BTCDelegationStatus { - /** PENDING - PENDING defines a delegation that is waiting for covenant signatures to become active. */ + /** PENDING - PENDING defines a delegation that is waiting for covenant signatures. */ PENDING = 0, + /** + * VERIFIED - VERIFIED defines a delegation that has covenant signatures but is not yet + * included in the BTC chain. + */ + VERIFIED = 1, /** ACTIVE - ACTIVE defines a delegation that has voting power */ - ACTIVE = 1, + ACTIVE = 2, /** * UNBONDED - UNBONDED defines a delegation no longer has voting power: * - either reaching the end of staking transaction timelock * - or receiving unbonding tx with signatures from staker and covenant committee */ - UNBONDED = 2, + UNBONDED = 3, /** ANY - ANY is any of the above status */ - ANY = 3, + ANY = 4, UNRECOGNIZED = -1, } @@ -39,12 +51,15 @@ export function bTCDelegationStatusFromJSON(object: any): BTCDelegationStatus { case "PENDING": return BTCDelegationStatus.PENDING; case 1: + case "VERIFIED": + return BTCDelegationStatus.VERIFIED; + case 2: case "ACTIVE": return BTCDelegationStatus.ACTIVE; - case 2: + case 3: case "UNBONDED": return BTCDelegationStatus.UNBONDED; - case 3: + case 4: case "ANY": return BTCDelegationStatus.ANY; case -1: @@ -58,6 +73,8 @@ export function bTCDelegationStatusToJSON(object: BTCDelegationStatus): string { switch (object) { case BTCDelegationStatus.PENDING: return "PENDING"; + case BTCDelegationStatus.VERIFIED: + return "VERIFIED"; case BTCDelegationStatus.ACTIVE: return "ACTIVE"; case BTCDelegationStatus.UNBONDED: @@ -104,8 +121,8 @@ export interface FinalityProvider { * if it's 0 then the finality provider is not slashed */ slashedBtcHeight: number; - /** sluggish defines whether the finality provider is detected sluggish */ - sluggish: boolean; + /** jailed defines whether the finality provider is jailed */ + jailed: boolean; } /** FinalityProviderWithMeta wraps the FinalityProvider with metadata. */ @@ -131,8 +148,8 @@ export interface FinalityProviderWithMeta { * if it's 0 then the finality provider is not slashed */ slashedBtcHeight: number; - /** sluggish defines whether the finality provider is detected sluggish */ - sluggish: boolean; + /** jailed defines whether the finality provider is detected jailed */ + jailed: boolean; } /** BTCDelegation defines a BTC delegation */ @@ -155,6 +172,8 @@ export interface BTCDelegation { * to multiple finality providers */ fpBtcPkList: Uint8Array[]; + /** staking_time is the number of blocks for which the delegation is locked on BTC chain */ + stakingTime: number; /** * start_height is the start BTC height of the BTC delegation * it is the start BTC height of the timelock @@ -162,7 +181,7 @@ export interface BTCDelegation { startHeight: number; /** * end_height is the end height of the BTC delegation - * it is the end BTC height of the timelock - w + * it is calculated by end_height = start_height + staking_time */ endHeight: number; /** @@ -205,6 +224,20 @@ export interface BTCDelegation { paramsVersion: number; } +/** + * DelegatorUnbondingInfo contains the information about transaction which spent + * the staking output. It contains: + * - spend_stake_tx: the transaction which spent the staking output + */ +export interface DelegatorUnbondingInfo { + /** + * spend_stake_tx is the transaction which spent the staking output. It is + * filled only if spend_stake_tx is different than unbonding_tx registered + * on the Babylon chain. + */ + spendStakeTx: Uint8Array; +} + /** BTCUndelegation contains the information about the early unbonding path of the BTC delegation */ export interface BTCUndelegation { /** @@ -219,14 +252,6 @@ export interface BTCUndelegation { * finality provider or covenant yet. */ slashingTx: Uint8Array; - /** - * delegator_unbonding_sig is the signature on the unbonding tx - * by the delegator (i.e., SK corresponding to btc_pk). - * It effectively proves that the delegator wants to unbond and thus - * Babylon will consider this BTC delegation unbonded. Delegator's BTC - * on Bitcoin will be unbonded after timelock - */ - delegatorUnbondingSig: Uint8Array; /** * delegator_slashing_sig is the signature on the slashing tx * by the delegator (i.e., SK corresponding to btc_pk). @@ -245,6 +270,11 @@ export interface BTCUndelegation { * It must be provided after processing undelegate message by Babylon */ covenantUnbondingSigList: SignatureInfo[]; + /** + * delegator_unbonding_info is the information about transaction which spent + * the staking output + */ + delegatorUnbondingInfo: DelegatorUnbondingInfo | undefined; } /** BTCDelegatorDelegations is a collection of BTC delegations from the same delegator. */ @@ -301,6 +331,21 @@ export interface SelectiveSlashingEvidence { recoveredFpBtcSk: Uint8Array; } +/** + * InclusionProof proves the existence of tx on BTC blockchain + * including + * - the position of the tx on BTC blockchain + * - the Merkle proof that this tx is on the above position + */ +export interface InclusionProof { + /** key is the position (txIdx, blockHash) of this tx on BTC blockchain */ + key: + | TransactionKey + | undefined; + /** proof is the Merkle proof that this tx is included in the position in `key` */ + proof: Uint8Array; +} + function createBaseFinalityProvider(): FinalityProvider { return { addr: "", @@ -310,7 +355,7 @@ function createBaseFinalityProvider(): FinalityProvider { pop: undefined, slashedBabylonHeight: 0, slashedBtcHeight: 0, - sluggish: false, + jailed: false, }; } @@ -335,10 +380,10 @@ export const FinalityProvider: MessageFns = { writer.uint32(48).uint64(message.slashedBabylonHeight); } if (message.slashedBtcHeight !== 0) { - writer.uint32(56).uint64(message.slashedBtcHeight); + writer.uint32(56).uint32(message.slashedBtcHeight); } - if (message.sluggish !== false) { - writer.uint32(64).bool(message.sluggish); + if (message.jailed !== false) { + writer.uint32(64).bool(message.jailed); } return writer; }, @@ -397,14 +442,14 @@ export const FinalityProvider: MessageFns = { break; } - message.slashedBtcHeight = longToNumber(reader.uint64()); + message.slashedBtcHeight = reader.uint32(); continue; case 8: if (tag !== 64) { break; } - message.sluggish = reader.bool(); + message.jailed = reader.bool(); continue; } if ((tag & 7) === 4 || tag === 0) { @@ -424,7 +469,7 @@ export const FinalityProvider: MessageFns = { pop: isSet(object.pop) ? ProofOfPossessionBTC.fromJSON(object.pop) : undefined, slashedBabylonHeight: isSet(object.slashedBabylonHeight) ? globalThis.Number(object.slashedBabylonHeight) : 0, slashedBtcHeight: isSet(object.slashedBtcHeight) ? globalThis.Number(object.slashedBtcHeight) : 0, - sluggish: isSet(object.sluggish) ? globalThis.Boolean(object.sluggish) : false, + jailed: isSet(object.jailed) ? globalThis.Boolean(object.jailed) : false, }; }, @@ -451,8 +496,8 @@ export const FinalityProvider: MessageFns = { if (message.slashedBtcHeight !== 0) { obj.slashedBtcHeight = Math.round(message.slashedBtcHeight); } - if (message.sluggish !== false) { - obj.sluggish = message.sluggish; + if (message.jailed !== false) { + obj.jailed = message.jailed; } return obj; }, @@ -473,7 +518,7 @@ export const FinalityProvider: MessageFns = { : undefined; message.slashedBabylonHeight = object.slashedBabylonHeight ?? 0; message.slashedBtcHeight = object.slashedBtcHeight ?? 0; - message.sluggish = object.sluggish ?? false; + message.jailed = object.jailed ?? false; return message; }, }; @@ -485,7 +530,7 @@ function createBaseFinalityProviderWithMeta(): FinalityProviderWithMeta { votingPower: 0, slashedBabylonHeight: 0, slashedBtcHeight: 0, - sluggish: false, + jailed: false, }; } @@ -504,10 +549,10 @@ export const FinalityProviderWithMeta: MessageFns = { writer.uint32(32).uint64(message.slashedBabylonHeight); } if (message.slashedBtcHeight !== 0) { - writer.uint32(40).uint64(message.slashedBtcHeight); + writer.uint32(40).uint32(message.slashedBtcHeight); } - if (message.sluggish !== false) { - writer.uint32(48).bool(message.sluggish); + if (message.jailed !== false) { + writer.uint32(48).bool(message.jailed); } return writer; }, @@ -552,14 +597,14 @@ export const FinalityProviderWithMeta: MessageFns = { break; } - message.slashedBtcHeight = longToNumber(reader.uint64()); + message.slashedBtcHeight = reader.uint32(); continue; case 6: if (tag !== 48) { break; } - message.sluggish = reader.bool(); + message.jailed = reader.bool(); continue; } if ((tag & 7) === 4 || tag === 0) { @@ -577,7 +622,7 @@ export const FinalityProviderWithMeta: MessageFns = { votingPower: isSet(object.votingPower) ? globalThis.Number(object.votingPower) : 0, slashedBabylonHeight: isSet(object.slashedBabylonHeight) ? globalThis.Number(object.slashedBabylonHeight) : 0, slashedBtcHeight: isSet(object.slashedBtcHeight) ? globalThis.Number(object.slashedBtcHeight) : 0, - sluggish: isSet(object.sluggish) ? globalThis.Boolean(object.sluggish) : false, + jailed: isSet(object.jailed) ? globalThis.Boolean(object.jailed) : false, }; }, @@ -598,8 +643,8 @@ export const FinalityProviderWithMeta: MessageFns = { if (message.slashedBtcHeight !== 0) { obj.slashedBtcHeight = Math.round(message.slashedBtcHeight); } - if (message.sluggish !== false) { - obj.sluggish = message.sluggish; + if (message.jailed !== false) { + obj.jailed = message.jailed; } return obj; }, @@ -614,7 +659,7 @@ export const FinalityProviderWithMeta: MessageFns = { message.votingPower = object.votingPower ?? 0; message.slashedBabylonHeight = object.slashedBabylonHeight ?? 0; message.slashedBtcHeight = object.slashedBtcHeight ?? 0; - message.sluggish = object.sluggish ?? false; + message.jailed = object.jailed ?? false; return message; }, }; @@ -625,6 +670,7 @@ function createBaseBTCDelegation(): BTCDelegation { btcPk: new Uint8Array(0), pop: undefined, fpBtcPkList: [], + stakingTime: 0, startHeight: 0, endHeight: 0, totalSat: 0, @@ -653,38 +699,41 @@ export const BTCDelegation: MessageFns = { for (const v of message.fpBtcPkList) { writer.uint32(34).bytes(v!); } + if (message.stakingTime !== 0) { + writer.uint32(40).uint32(message.stakingTime); + } if (message.startHeight !== 0) { - writer.uint32(40).uint64(message.startHeight); + writer.uint32(48).uint32(message.startHeight); } if (message.endHeight !== 0) { - writer.uint32(48).uint64(message.endHeight); + writer.uint32(56).uint32(message.endHeight); } if (message.totalSat !== 0) { - writer.uint32(56).uint64(message.totalSat); + writer.uint32(64).uint64(message.totalSat); } if (message.stakingTx.length !== 0) { - writer.uint32(66).bytes(message.stakingTx); + writer.uint32(74).bytes(message.stakingTx); } if (message.stakingOutputIdx !== 0) { - writer.uint32(72).uint32(message.stakingOutputIdx); + writer.uint32(80).uint32(message.stakingOutputIdx); } if (message.slashingTx.length !== 0) { - writer.uint32(82).bytes(message.slashingTx); + writer.uint32(90).bytes(message.slashingTx); } if (message.delegatorSig.length !== 0) { - writer.uint32(90).bytes(message.delegatorSig); + writer.uint32(98).bytes(message.delegatorSig); } for (const v of message.covenantSigs) { - CovenantAdaptorSignatures.encode(v!, writer.uint32(98).fork()).join(); + CovenantAdaptorSignatures.encode(v!, writer.uint32(106).fork()).join(); } if (message.unbondingTime !== 0) { - writer.uint32(104).uint32(message.unbondingTime); + writer.uint32(112).uint32(message.unbondingTime); } if (message.btcUndelegation !== undefined) { - BTCUndelegation.encode(message.btcUndelegation, writer.uint32(114).fork()).join(); + BTCUndelegation.encode(message.btcUndelegation, writer.uint32(122).fork()).join(); } if (message.paramsVersion !== 0) { - writer.uint32(120).uint32(message.paramsVersion); + writer.uint32(128).uint32(message.paramsVersion); } return writer; }, @@ -729,73 +778,80 @@ export const BTCDelegation: MessageFns = { break; } - message.startHeight = longToNumber(reader.uint64()); + message.stakingTime = reader.uint32(); continue; case 6: if (tag !== 48) { break; } - message.endHeight = longToNumber(reader.uint64()); + message.startHeight = reader.uint32(); continue; case 7: if (tag !== 56) { break; } - message.totalSat = longToNumber(reader.uint64()); + message.endHeight = reader.uint32(); continue; case 8: - if (tag !== 66) { + if (tag !== 64) { break; } - message.stakingTx = reader.bytes(); + message.totalSat = longToNumber(reader.uint64()); continue; case 9: - if (tag !== 72) { + if (tag !== 74) { break; } - message.stakingOutputIdx = reader.uint32(); + message.stakingTx = reader.bytes(); continue; case 10: - if (tag !== 82) { + if (tag !== 80) { break; } - message.slashingTx = reader.bytes(); + message.stakingOutputIdx = reader.uint32(); continue; case 11: if (tag !== 90) { break; } - message.delegatorSig = reader.bytes(); + message.slashingTx = reader.bytes(); continue; case 12: if (tag !== 98) { break; } - message.covenantSigs.push(CovenantAdaptorSignatures.decode(reader, reader.uint32())); + message.delegatorSig = reader.bytes(); continue; case 13: - if (tag !== 104) { + if (tag !== 106) { break; } - message.unbondingTime = reader.uint32(); + message.covenantSigs.push(CovenantAdaptorSignatures.decode(reader, reader.uint32())); continue; case 14: - if (tag !== 114) { + if (tag !== 112) { break; } - message.btcUndelegation = BTCUndelegation.decode(reader, reader.uint32()); + message.unbondingTime = reader.uint32(); continue; case 15: - if (tag !== 120) { + if (tag !== 122) { + break; + } + + message.btcUndelegation = BTCUndelegation.decode(reader, reader.uint32()); + continue; + case 16: + if (tag !== 128) { break; } @@ -818,6 +874,7 @@ export const BTCDelegation: MessageFns = { fpBtcPkList: globalThis.Array.isArray(object?.fpBtcPkList) ? object.fpBtcPkList.map((e: any) => bytesFromBase64(e)) : [], + stakingTime: isSet(object.stakingTime) ? globalThis.Number(object.stakingTime) : 0, startHeight: isSet(object.startHeight) ? globalThis.Number(object.startHeight) : 0, endHeight: isSet(object.endHeight) ? globalThis.Number(object.endHeight) : 0, totalSat: isSet(object.totalSat) ? globalThis.Number(object.totalSat) : 0, @@ -848,6 +905,9 @@ export const BTCDelegation: MessageFns = { if (message.fpBtcPkList?.length) { obj.fpBtcPkList = message.fpBtcPkList.map((e) => base64FromBytes(e)); } + if (message.stakingTime !== 0) { + obj.stakingTime = Math.round(message.stakingTime); + } if (message.startHeight !== 0) { obj.startHeight = Math.round(message.startHeight); } @@ -895,6 +955,7 @@ export const BTCDelegation: MessageFns = { ? ProofOfPossessionBTC.fromPartial(object.pop) : undefined; message.fpBtcPkList = object.fpBtcPkList?.map((e) => e) || []; + message.stakingTime = object.stakingTime ?? 0; message.startHeight = object.startHeight ?? 0; message.endHeight = object.endHeight ?? 0; message.totalSat = object.totalSat ?? 0; @@ -912,14 +973,71 @@ export const BTCDelegation: MessageFns = { }, }; +function createBaseDelegatorUnbondingInfo(): DelegatorUnbondingInfo { + return { spendStakeTx: new Uint8Array(0) }; +} + +export const DelegatorUnbondingInfo: MessageFns = { + encode(message: DelegatorUnbondingInfo, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.spendStakeTx.length !== 0) { + writer.uint32(10).bytes(message.spendStakeTx); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): DelegatorUnbondingInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDelegatorUnbondingInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.spendStakeTx = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): DelegatorUnbondingInfo { + return { spendStakeTx: isSet(object.spendStakeTx) ? bytesFromBase64(object.spendStakeTx) : new Uint8Array(0) }; + }, + + toJSON(message: DelegatorUnbondingInfo): unknown { + const obj: any = {}; + if (message.spendStakeTx.length !== 0) { + obj.spendStakeTx = base64FromBytes(message.spendStakeTx); + } + return obj; + }, + + create, I>>(base?: I): DelegatorUnbondingInfo { + return DelegatorUnbondingInfo.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): DelegatorUnbondingInfo { + const message = createBaseDelegatorUnbondingInfo(); + message.spendStakeTx = object.spendStakeTx ?? new Uint8Array(0); + return message; + }, +}; + function createBaseBTCUndelegation(): BTCUndelegation { return { unbondingTx: new Uint8Array(0), slashingTx: new Uint8Array(0), - delegatorUnbondingSig: new Uint8Array(0), delegatorSlashingSig: new Uint8Array(0), covenantSlashingSigs: [], covenantUnbondingSigList: [], + delegatorUnbondingInfo: undefined, }; } @@ -931,17 +1049,17 @@ export const BTCUndelegation: MessageFns = { if (message.slashingTx.length !== 0) { writer.uint32(18).bytes(message.slashingTx); } - if (message.delegatorUnbondingSig.length !== 0) { - writer.uint32(26).bytes(message.delegatorUnbondingSig); - } if (message.delegatorSlashingSig.length !== 0) { - writer.uint32(34).bytes(message.delegatorSlashingSig); + writer.uint32(26).bytes(message.delegatorSlashingSig); } for (const v of message.covenantSlashingSigs) { - CovenantAdaptorSignatures.encode(v!, writer.uint32(42).fork()).join(); + CovenantAdaptorSignatures.encode(v!, writer.uint32(34).fork()).join(); } for (const v of message.covenantUnbondingSigList) { - SignatureInfo.encode(v!, writer.uint32(50).fork()).join(); + SignatureInfo.encode(v!, writer.uint32(42).fork()).join(); + } + if (message.delegatorUnbondingInfo !== undefined) { + DelegatorUnbondingInfo.encode(message.delegatorUnbondingInfo, writer.uint32(50).fork()).join(); } return writer; }, @@ -972,28 +1090,28 @@ export const BTCUndelegation: MessageFns = { break; } - message.delegatorUnbondingSig = reader.bytes(); + message.delegatorSlashingSig = reader.bytes(); continue; case 4: if (tag !== 34) { break; } - message.delegatorSlashingSig = reader.bytes(); + message.covenantSlashingSigs.push(CovenantAdaptorSignatures.decode(reader, reader.uint32())); continue; case 5: if (tag !== 42) { break; } - message.covenantSlashingSigs.push(CovenantAdaptorSignatures.decode(reader, reader.uint32())); + message.covenantUnbondingSigList.push(SignatureInfo.decode(reader, reader.uint32())); continue; case 6: if (tag !== 50) { break; } - message.covenantUnbondingSigList.push(SignatureInfo.decode(reader, reader.uint32())); + message.delegatorUnbondingInfo = DelegatorUnbondingInfo.decode(reader, reader.uint32()); continue; } if ((tag & 7) === 4 || tag === 0) { @@ -1008,9 +1126,6 @@ export const BTCUndelegation: MessageFns = { return { unbondingTx: isSet(object.unbondingTx) ? bytesFromBase64(object.unbondingTx) : new Uint8Array(0), slashingTx: isSet(object.slashingTx) ? bytesFromBase64(object.slashingTx) : new Uint8Array(0), - delegatorUnbondingSig: isSet(object.delegatorUnbondingSig) - ? bytesFromBase64(object.delegatorUnbondingSig) - : new Uint8Array(0), delegatorSlashingSig: isSet(object.delegatorSlashingSig) ? bytesFromBase64(object.delegatorSlashingSig) : new Uint8Array(0), @@ -1020,6 +1135,9 @@ export const BTCUndelegation: MessageFns = { covenantUnbondingSigList: globalThis.Array.isArray(object?.covenantUnbondingSigList) ? object.covenantUnbondingSigList.map((e: any) => SignatureInfo.fromJSON(e)) : [], + delegatorUnbondingInfo: isSet(object.delegatorUnbondingInfo) + ? DelegatorUnbondingInfo.fromJSON(object.delegatorUnbondingInfo) + : undefined, }; }, @@ -1031,9 +1149,6 @@ export const BTCUndelegation: MessageFns = { if (message.slashingTx.length !== 0) { obj.slashingTx = base64FromBytes(message.slashingTx); } - if (message.delegatorUnbondingSig.length !== 0) { - obj.delegatorUnbondingSig = base64FromBytes(message.delegatorUnbondingSig); - } if (message.delegatorSlashingSig.length !== 0) { obj.delegatorSlashingSig = base64FromBytes(message.delegatorSlashingSig); } @@ -1043,6 +1158,9 @@ export const BTCUndelegation: MessageFns = { if (message.covenantUnbondingSigList?.length) { obj.covenantUnbondingSigList = message.covenantUnbondingSigList.map((e) => SignatureInfo.toJSON(e)); } + if (message.delegatorUnbondingInfo !== undefined) { + obj.delegatorUnbondingInfo = DelegatorUnbondingInfo.toJSON(message.delegatorUnbondingInfo); + } return obj; }, @@ -1053,11 +1171,14 @@ export const BTCUndelegation: MessageFns = { const message = createBaseBTCUndelegation(); message.unbondingTx = object.unbondingTx ?? new Uint8Array(0); message.slashingTx = object.slashingTx ?? new Uint8Array(0); - message.delegatorUnbondingSig = object.delegatorUnbondingSig ?? new Uint8Array(0); message.delegatorSlashingSig = object.delegatorSlashingSig ?? new Uint8Array(0); message.covenantSlashingSigs = object.covenantSlashingSigs?.map((e) => CovenantAdaptorSignatures.fromPartial(e)) || []; message.covenantUnbondingSigList = object.covenantUnbondingSigList?.map((e) => SignatureInfo.fromPartial(e)) || []; + message.delegatorUnbondingInfo = + (object.delegatorUnbondingInfo !== undefined && object.delegatorUnbondingInfo !== null) + ? DelegatorUnbondingInfo.fromPartial(object.delegatorUnbondingInfo) + : undefined; return message; }, }; @@ -1421,6 +1542,82 @@ export const SelectiveSlashingEvidence: MessageFns = }, }; +function createBaseInclusionProof(): InclusionProof { + return { key: undefined, proof: new Uint8Array(0) }; +} + +export const InclusionProof: MessageFns = { + encode(message: InclusionProof, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.key !== undefined) { + TransactionKey.encode(message.key, writer.uint32(10).fork()).join(); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): InclusionProof { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseInclusionProof(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.key = TransactionKey.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.proof = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): InclusionProof { + return { + key: isSet(object.key) ? TransactionKey.fromJSON(object.key) : undefined, + proof: isSet(object.proof) ? bytesFromBase64(object.proof) : new Uint8Array(0), + }; + }, + + toJSON(message: InclusionProof): unknown { + const obj: any = {}; + if (message.key !== undefined) { + obj.key = TransactionKey.toJSON(message.key); + } + if (message.proof.length !== 0) { + obj.proof = base64FromBytes(message.proof); + } + return obj; + }, + + create, I>>(base?: I): InclusionProof { + return InclusionProof.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): InclusionProof { + const message = createBaseInclusionProof(); + message.key = (object.key !== undefined && object.key !== null) + ? TransactionKey.fromPartial(object.key) + : undefined; + message.proof = object.proof ?? new Uint8Array(0); + return message; + }, +}; + function bytesFromBase64(b64: string): Uint8Array { if ((globalThis as any).Buffer) { return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); diff --git a/src/generated/babylon/btcstaking/v1/events.ts b/src/generated/babylon/btcstaking/v1/events.ts index fba6c5d..c1da808 100644 --- a/src/generated/babylon/btcstaking/v1/events.ts +++ b/src/generated/babylon/btcstaking/v1/events.ts @@ -10,15 +10,103 @@ import { BTCDelegationStatus, bTCDelegationStatusFromJSON, bTCDelegationStatusToJSON, - FinalityProvider, SelectiveSlashingEvidence, } from "./btcstaking"; export const protobufPackage = "babylon.btcstaking.v1"; -/** EventNewFinalityProvider is the event emitted when a finality provider is created */ -export interface EventNewFinalityProvider { - fp: FinalityProvider | undefined; +/** FinalityProviderStatus is the status of a finality provider. */ +export enum FinalityProviderStatus { + /** + * FINALITY_PROVIDER_STATUS_INACTIVE - FINALITY_PROVIDER_STATUS_INACTIVE defines a finality provider that does not have sufficient + * delegations or does not have timestamped public randomness. + */ + FINALITY_PROVIDER_STATUS_INACTIVE = 0, + /** + * FINALITY_PROVIDER_STATUS_ACTIVE - FINALITY_PROVIDER_STATUS_ACTIVE defines a finality provider that have sufficient delegations + * and have timestamped public randomness. + */ + FINALITY_PROVIDER_STATUS_ACTIVE = 1, + /** FINALITY_PROVIDER_STATUS_JAILED - FINALITY_PROVIDER_STATUS_JAILED defines a finality provider that is jailed due to downtime */ + FINALITY_PROVIDER_STATUS_JAILED = 2, + /** FINALITY_PROVIDER_STATUS_SLASHED - FINALITY_PROVIDER_STATUS_SLASHED defines a finality provider that is slashed due to double-sign */ + FINALITY_PROVIDER_STATUS_SLASHED = 3, + UNRECOGNIZED = -1, +} + +export function finalityProviderStatusFromJSON(object: any): FinalityProviderStatus { + switch (object) { + case 0: + case "FINALITY_PROVIDER_STATUS_INACTIVE": + return FinalityProviderStatus.FINALITY_PROVIDER_STATUS_INACTIVE; + case 1: + case "FINALITY_PROVIDER_STATUS_ACTIVE": + return FinalityProviderStatus.FINALITY_PROVIDER_STATUS_ACTIVE; + case 2: + case "FINALITY_PROVIDER_STATUS_JAILED": + return FinalityProviderStatus.FINALITY_PROVIDER_STATUS_JAILED; + case 3: + case "FINALITY_PROVIDER_STATUS_SLASHED": + return FinalityProviderStatus.FINALITY_PROVIDER_STATUS_SLASHED; + case -1: + case "UNRECOGNIZED": + default: + return FinalityProviderStatus.UNRECOGNIZED; + } +} + +export function finalityProviderStatusToJSON(object: FinalityProviderStatus): string { + switch (object) { + case FinalityProviderStatus.FINALITY_PROVIDER_STATUS_INACTIVE: + return "FINALITY_PROVIDER_STATUS_INACTIVE"; + case FinalityProviderStatus.FINALITY_PROVIDER_STATUS_ACTIVE: + return "FINALITY_PROVIDER_STATUS_ACTIVE"; + case FinalityProviderStatus.FINALITY_PROVIDER_STATUS_JAILED: + return "FINALITY_PROVIDER_STATUS_JAILED"; + case FinalityProviderStatus.FINALITY_PROVIDER_STATUS_SLASHED: + return "FINALITY_PROVIDER_STATUS_SLASHED"; + case FinalityProviderStatus.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} + +/** EventFinalityProviderCreated is the event emitted when a finality provider is created */ +export interface EventFinalityProviderCreated { + /** btc_pk_hex is the hex string of Bitcoin secp256k1 PK of this finality provider */ + btcPkHex: string; + /** addr is the babylon address to receive commission from delegations. */ + addr: string; + /** commission defines the commission rate of the finality provider in decimals. */ + commission: string; + /** moniker defines a human-readable name for the finality provider. */ + moniker: string; + /** identity defines an optional identity signature (ex. UPort or Keybase). */ + identity: string; + /** website defines an optional website link. */ + website: string; + /** security_contact defines an optional email for security contact. */ + securityContact: string; + /** details define other optional details. */ + details: string; +} + +/** EventFinalityProviderEdited is the event emitted when a finality provider is edited */ +export interface EventFinalityProviderEdited { + /** btc_pk_hex is the hex string of Bitcoin secp256k1 PK of this finality provider */ + btcPkHex: string; + /** commission defines the commission rate of the finality provider in decimals. */ + commission: string; + /** moniker defines a human-readable name for the finality provider. */ + moniker: string; + /** identity defines an optional identity signature (ex. UPort or Keybase). */ + identity: string; + /** website defines an optional website link. */ + website: string; + /** security_contact defines an optional email for security contact. */ + securityContact: string; + /** details define other optional details. */ + details: string; } /** @@ -49,7 +137,7 @@ export interface EventSelectiveSlashing { } /** - * EventPowerDistUpdate is an event that affects voting power distirbution + * EventPowerDistUpdate is an event that affects voting power distribution * of BTC staking protocol */ export interface EventPowerDistUpdate { @@ -57,6 +145,14 @@ export interface EventPowerDistUpdate { slashedFp?: | EventPowerDistUpdate_EventSlashedFinalityProvider | undefined; + /** jailed_fp means a finality provider is jailed */ + jailedFp?: + | EventPowerDistUpdate_EventJailedFinalityProvider + | undefined; + /** unjailed_fp means a jailed finality provider is unjailed */ + unjailedFp?: + | EventPowerDistUpdate_EventUnjailedFinalityProvider + | undefined; /** btc_del_state_update means a BTC delegation's state is updated */ btcDelStateUpdate?: EventBTCDelegationStateUpdate | undefined; } @@ -70,22 +166,403 @@ export interface EventPowerDistUpdate_EventSlashedFinalityProvider { pk: Uint8Array; } -function createBaseEventNewFinalityProvider(): EventNewFinalityProvider { - return { fp: undefined }; +/** + * EventJailedFinalityProvider defines an event that a finality provider + * is jailed after being detected sluggish + */ +export interface EventPowerDistUpdate_EventJailedFinalityProvider { + pk: Uint8Array; +} + +/** + * EventUnjailedFinalityProvider defines an event that a jailed finality provider + * is unjailed after the jailing period is passed + */ +export interface EventPowerDistUpdate_EventUnjailedFinalityProvider { + pk: Uint8Array; +} + +/** + * A finality provider starts with status INACTIVE once registered. + * Possible status transitions are when: + * 1. it has accumulated sufficient delegations and has + * timestamped public randomness: + * INACTIVE -> ACTIVE + * 2. it is jailed due to downtime: + * ACTIVE -> JAILED + * 3. it is slashed due to double-sign: + * ACTIVE -> SLASHED + * 4. it is unjailed after a jailing period: + * JAILED -> INACTIVE/ACTIVE (depending on (1)) + * 5. it does not have sufficient delegations or does not + * have timestamped public randomness: + * ACTIVE -> INACTIVE. + * Note that it is impossible for a SLASHED finality provider to + * transition to other status + */ +export interface EventFinalityProviderStatusChange { + /** btc_pk is the BTC public key of the finality provider */ + btcPk: string; + /** + * new_state is the status that the finality provider + * is transitioned to, following FinalityProviderStatus + */ + newState: string; +} + +/** + * EventBTCDelegationCreated is the event emitted when a BTC delegation is created + * on the Babylon chain + */ +export interface EventBTCDelegationCreated { + /** + * staking_tx_hash is the hash of the staking tx. + * It uniquely identifies a BTC delegation + */ + stakingTxHash: string; + /** version of the params used to validate the delegation */ + paramsVersion: string; + /** + * finality_provider_btc_pks_hex is the list of hex str of Bitcoin secp256k1 PK of + * the finality providers that this BTC delegation delegates to + * the PK follows encoding in BIP-340 spec + */ + finalityProviderBtcPksHex: string[]; + /** + * staker_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the staker that + * creates this BTC delegation the PK follows encoding in BIP-340 spec + */ + stakerBtcPkHex: string; + /** staking_time is the timelock of the staking tx specified in the BTC script */ + stakingTime: string; + /** + * staking_amount is the total amount of BTC stake in this delegation + * quantified in satoshi + */ + stakingAmount: string; + /** unbonding_time is the time is timelock on unbonding tx chosen by the staker */ + unbondingTime: string; + /** unbonding_tx is hex encoded bytes of the unsigned unbonding tx */ + unbondingTx: string; + /** new_state of the BTC delegation */ + newState: string; +} + +/** + * EventCovenantSignatureReceived is the event emitted when a covenant committee + * sends valid covenant signatures for a BTC delegation + */ +export interface EventCovenantSignatureReceived { + /** + * staking_tx_hash is the hash of the staking identifing the BTC delegation + * that this covenant signature is for + */ + stakingTxHash: string; + /** + * covenant_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the + * covnenat committee that send the signature + */ + covenantBtcPkHex: string; + /** + * covenant_unbonding_signature_hex is the hex str of the BIP340 Schnorr + * signature of the covenant committee on the unbonding tx + */ + covenantUnbondingSignatureHex: string; +} + +/** + * EventCovenantQuorumReached is the event emitted quorum of covenant committee + * is reached for a BTC delegation + */ +export interface EventCovenantQuorumReached { + /** + * staking_tx_hash is the hash of the staking identifing the BTC delegation + * that this covenant signature is for + */ + stakingTxHash: string; + /** new_state of the BTC delegation */ + newState: string; +} + +/** + * EventBTCDelegationInclusionProofReceived is the event emitted when a BTC delegation + * inclusion proof is received + */ +export interface EventBTCDelegationInclusionProofReceived { + /** + * staking_tx_hash is the hash of the staking tx. + * It uniquely identifies a BTC delegation + */ + stakingTxHash: string; + /** + * start_height is the start BTC height of the BTC delegation + * it is the start BTC height of the timelock + */ + startHeight: string; + /** + * end_height is the end height of the BTC delegation + * it is calculated by end_height = start_height + staking_time + */ + endHeight: string; + /** new_state of the BTC delegation */ + newState: string; +} + +/** + * EventBTCDelgationUnbondedEarly is the event emitted when a BTC delegation + * is unbonded by staker sending unbonding tx to BTC + */ +export interface EventBTCDelgationUnbondedEarly { + /** + * staking_tx_hash is the hash of the staking tx. + * It uniquely identifies a BTC delegation + */ + stakingTxHash: string; + /** start_height is the start BTC height of the early unbonding */ + startHeight: string; + /** new_state of the BTC delegation */ + newState: string; +} + +/** + * EventBTCDelegationExpired is the event emitted when a BTC delegation + * is unbonded by expiration of the staking tx timelock + */ +export interface EventBTCDelegationExpired { + /** + * staking_tx_hash is the hash of the staking tx. + * It uniquely identifies a BTC delegation + */ + stakingTxHash: string; + /** new_state of the BTC delegation */ + newState: string; +} + +/** + * EventUnexpectedUnbondingTx is the event emitted when an unbonding tx is + * is different that the one registered in the BTC delegation. + */ +export interface EventUnexpectedUnbondingTx { + /** staking_tx_hash uniquely identifies a BTC delegation being unbonded */ + stakingTxHash: string; + /** spend_stake_tx_hash has of the transactin spending staking output */ + spendStakeTxHash: string; + /** + * spend_stake_tx_header_hash is the hash of the header of the block that + * includes the spend_stake_tx + */ + spendStakeTxHeaderHash: string; + /** spend_stake_tx_block_index is the spend_stake_tx index in the block */ + spendStakeTxBlockIndex: number; +} + +function createBaseEventFinalityProviderCreated(): EventFinalityProviderCreated { + return { + btcPkHex: "", + addr: "", + commission: "", + moniker: "", + identity: "", + website: "", + securityContact: "", + details: "", + }; +} + +export const EventFinalityProviderCreated: MessageFns = { + encode(message: EventFinalityProviderCreated, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.btcPkHex !== "") { + writer.uint32(10).string(message.btcPkHex); + } + if (message.addr !== "") { + writer.uint32(18).string(message.addr); + } + if (message.commission !== "") { + writer.uint32(26).string(message.commission); + } + if (message.moniker !== "") { + writer.uint32(34).string(message.moniker); + } + if (message.identity !== "") { + writer.uint32(42).string(message.identity); + } + if (message.website !== "") { + writer.uint32(50).string(message.website); + } + if (message.securityContact !== "") { + writer.uint32(58).string(message.securityContact); + } + if (message.details !== "") { + writer.uint32(66).string(message.details); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): EventFinalityProviderCreated { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventFinalityProviderCreated(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.btcPkHex = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.addr = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.commission = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.moniker = reader.string(); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.identity = reader.string(); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.website = reader.string(); + continue; + case 7: + if (tag !== 58) { + break; + } + + message.securityContact = reader.string(); + continue; + case 8: + if (tag !== 66) { + break; + } + + message.details = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): EventFinalityProviderCreated { + return { + btcPkHex: isSet(object.btcPkHex) ? globalThis.String(object.btcPkHex) : "", + addr: isSet(object.addr) ? globalThis.String(object.addr) : "", + commission: isSet(object.commission) ? globalThis.String(object.commission) : "", + moniker: isSet(object.moniker) ? globalThis.String(object.moniker) : "", + identity: isSet(object.identity) ? globalThis.String(object.identity) : "", + website: isSet(object.website) ? globalThis.String(object.website) : "", + securityContact: isSet(object.securityContact) ? globalThis.String(object.securityContact) : "", + details: isSet(object.details) ? globalThis.String(object.details) : "", + }; + }, + + toJSON(message: EventFinalityProviderCreated): unknown { + const obj: any = {}; + if (message.btcPkHex !== "") { + obj.btcPkHex = message.btcPkHex; + } + if (message.addr !== "") { + obj.addr = message.addr; + } + if (message.commission !== "") { + obj.commission = message.commission; + } + if (message.moniker !== "") { + obj.moniker = message.moniker; + } + if (message.identity !== "") { + obj.identity = message.identity; + } + if (message.website !== "") { + obj.website = message.website; + } + if (message.securityContact !== "") { + obj.securityContact = message.securityContact; + } + if (message.details !== "") { + obj.details = message.details; + } + return obj; + }, + + create, I>>(base?: I): EventFinalityProviderCreated { + return EventFinalityProviderCreated.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): EventFinalityProviderCreated { + const message = createBaseEventFinalityProviderCreated(); + message.btcPkHex = object.btcPkHex ?? ""; + message.addr = object.addr ?? ""; + message.commission = object.commission ?? ""; + message.moniker = object.moniker ?? ""; + message.identity = object.identity ?? ""; + message.website = object.website ?? ""; + message.securityContact = object.securityContact ?? ""; + message.details = object.details ?? ""; + return message; + }, +}; + +function createBaseEventFinalityProviderEdited(): EventFinalityProviderEdited { + return { btcPkHex: "", commission: "", moniker: "", identity: "", website: "", securityContact: "", details: "" }; } -export const EventNewFinalityProvider: MessageFns = { - encode(message: EventNewFinalityProvider, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.fp !== undefined) { - FinalityProvider.encode(message.fp, writer.uint32(10).fork()).join(); +export const EventFinalityProviderEdited: MessageFns = { + encode(message: EventFinalityProviderEdited, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.btcPkHex !== "") { + writer.uint32(10).string(message.btcPkHex); + } + if (message.commission !== "") { + writer.uint32(18).string(message.commission); + } + if (message.moniker !== "") { + writer.uint32(26).string(message.moniker); + } + if (message.identity !== "") { + writer.uint32(34).string(message.identity); + } + if (message.website !== "") { + writer.uint32(42).string(message.website); + } + if (message.securityContact !== "") { + writer.uint32(50).string(message.securityContact); + } + if (message.details !== "") { + writer.uint32(58).string(message.details); } return writer; }, - decode(input: BinaryReader | Uint8Array, length?: number): EventNewFinalityProvider { + decode(input: BinaryReader | Uint8Array, length?: number): EventFinalityProviderEdited { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseEventNewFinalityProvider(); + const message = createBaseEventFinalityProviderEdited(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -94,7 +571,49 @@ export const EventNewFinalityProvider: MessageFns = { break; } - message.fp = FinalityProvider.decode(reader, reader.uint32()); + message.btcPkHex = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.commission = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.moniker = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.identity = reader.string(); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.website = reader.string(); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.securityContact = reader.string(); + continue; + case 7: + if (tag !== 58) { + break; + } + + message.details = reader.string(); continue; } if ((tag & 7) === 4 || tag === 0) { @@ -105,24 +624,56 @@ export const EventNewFinalityProvider: MessageFns = { return message; }, - fromJSON(object: any): EventNewFinalityProvider { - return { fp: isSet(object.fp) ? FinalityProvider.fromJSON(object.fp) : undefined }; + fromJSON(object: any): EventFinalityProviderEdited { + return { + btcPkHex: isSet(object.btcPkHex) ? globalThis.String(object.btcPkHex) : "", + commission: isSet(object.commission) ? globalThis.String(object.commission) : "", + moniker: isSet(object.moniker) ? globalThis.String(object.moniker) : "", + identity: isSet(object.identity) ? globalThis.String(object.identity) : "", + website: isSet(object.website) ? globalThis.String(object.website) : "", + securityContact: isSet(object.securityContact) ? globalThis.String(object.securityContact) : "", + details: isSet(object.details) ? globalThis.String(object.details) : "", + }; }, - toJSON(message: EventNewFinalityProvider): unknown { + toJSON(message: EventFinalityProviderEdited): unknown { const obj: any = {}; - if (message.fp !== undefined) { - obj.fp = FinalityProvider.toJSON(message.fp); + if (message.btcPkHex !== "") { + obj.btcPkHex = message.btcPkHex; + } + if (message.commission !== "") { + obj.commission = message.commission; + } + if (message.moniker !== "") { + obj.moniker = message.moniker; + } + if (message.identity !== "") { + obj.identity = message.identity; + } + if (message.website !== "") { + obj.website = message.website; + } + if (message.securityContact !== "") { + obj.securityContact = message.securityContact; + } + if (message.details !== "") { + obj.details = message.details; } return obj; }, - create, I>>(base?: I): EventNewFinalityProvider { - return EventNewFinalityProvider.fromPartial(base ?? ({} as any)); + create, I>>(base?: I): EventFinalityProviderEdited { + return EventFinalityProviderEdited.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>(object: I): EventNewFinalityProvider { - const message = createBaseEventNewFinalityProvider(); - message.fp = (object.fp !== undefined && object.fp !== null) ? FinalityProvider.fromPartial(object.fp) : undefined; + fromPartial, I>>(object: I): EventFinalityProviderEdited { + const message = createBaseEventFinalityProviderEdited(); + message.btcPkHex = object.btcPkHex ?? ""; + message.commission = object.commission ?? ""; + message.moniker = object.moniker ?? ""; + message.identity = object.identity ?? ""; + message.website = object.website ?? ""; + message.securityContact = object.securityContact ?? ""; + message.details = object.details ?? ""; return message; }, }; @@ -263,7 +814,7 @@ export const EventSelectiveSlashing: MessageFns = { }; function createBaseEventPowerDistUpdate(): EventPowerDistUpdate { - return { slashedFp: undefined, btcDelStateUpdate: undefined }; + return { slashedFp: undefined, jailedFp: undefined, unjailedFp: undefined, btcDelStateUpdate: undefined }; } export const EventPowerDistUpdate: MessageFns = { @@ -271,8 +822,14 @@ export const EventPowerDistUpdate: MessageFns = { if (message.slashedFp !== undefined) { EventPowerDistUpdate_EventSlashedFinalityProvider.encode(message.slashedFp, writer.uint32(10).fork()).join(); } + if (message.jailedFp !== undefined) { + EventPowerDistUpdate_EventJailedFinalityProvider.encode(message.jailedFp, writer.uint32(18).fork()).join(); + } + if (message.unjailedFp !== undefined) { + EventPowerDistUpdate_EventUnjailedFinalityProvider.encode(message.unjailedFp, writer.uint32(26).fork()).join(); + } if (message.btcDelStateUpdate !== undefined) { - EventBTCDelegationStateUpdate.encode(message.btcDelStateUpdate, writer.uint32(18).fork()).join(); + EventBTCDelegationStateUpdate.encode(message.btcDelStateUpdate, writer.uint32(34).fork()).join(); } return writer; }, @@ -296,6 +853,20 @@ export const EventPowerDistUpdate: MessageFns = { break; } + message.jailedFp = EventPowerDistUpdate_EventJailedFinalityProvider.decode(reader, reader.uint32()); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.unjailedFp = EventPowerDistUpdate_EventUnjailedFinalityProvider.decode(reader, reader.uint32()); + continue; + case 4: + if (tag !== 34) { + break; + } + message.btcDelStateUpdate = EventBTCDelegationStateUpdate.decode(reader, reader.uint32()); continue; } @@ -312,6 +883,12 @@ export const EventPowerDistUpdate: MessageFns = { slashedFp: isSet(object.slashedFp) ? EventPowerDistUpdate_EventSlashedFinalityProvider.fromJSON(object.slashedFp) : undefined, + jailedFp: isSet(object.jailedFp) + ? EventPowerDistUpdate_EventJailedFinalityProvider.fromJSON(object.jailedFp) + : undefined, + unjailedFp: isSet(object.unjailedFp) + ? EventPowerDistUpdate_EventUnjailedFinalityProvider.fromJSON(object.unjailedFp) + : undefined, btcDelStateUpdate: isSet(object.btcDelStateUpdate) ? EventBTCDelegationStateUpdate.fromJSON(object.btcDelStateUpdate) : undefined, @@ -323,6 +900,12 @@ export const EventPowerDistUpdate: MessageFns = { if (message.slashedFp !== undefined) { obj.slashedFp = EventPowerDistUpdate_EventSlashedFinalityProvider.toJSON(message.slashedFp); } + if (message.jailedFp !== undefined) { + obj.jailedFp = EventPowerDistUpdate_EventJailedFinalityProvider.toJSON(message.jailedFp); + } + if (message.unjailedFp !== undefined) { + obj.unjailedFp = EventPowerDistUpdate_EventUnjailedFinalityProvider.toJSON(message.unjailedFp); + } if (message.btcDelStateUpdate !== undefined) { obj.btcDelStateUpdate = EventBTCDelegationStateUpdate.toJSON(message.btcDelStateUpdate); } @@ -337,6 +920,12 @@ export const EventPowerDistUpdate: MessageFns = { message.slashedFp = (object.slashedFp !== undefined && object.slashedFp !== null) ? EventPowerDistUpdate_EventSlashedFinalityProvider.fromPartial(object.slashedFp) : undefined; + message.jailedFp = (object.jailedFp !== undefined && object.jailedFp !== null) + ? EventPowerDistUpdate_EventJailedFinalityProvider.fromPartial(object.jailedFp) + : undefined; + message.unjailedFp = (object.unjailedFp !== undefined && object.unjailedFp !== null) + ? EventPowerDistUpdate_EventUnjailedFinalityProvider.fromPartial(object.unjailedFp) + : undefined; message.btcDelStateUpdate = (object.btcDelStateUpdate !== undefined && object.btcDelStateUpdate !== null) ? EventBTCDelegationStateUpdate.fromPartial(object.btcDelStateUpdate) : undefined; @@ -410,6 +999,955 @@ export const EventPowerDistUpdate_EventSlashedFinalityProvider: MessageFns< }, }; +function createBaseEventPowerDistUpdate_EventJailedFinalityProvider(): EventPowerDistUpdate_EventJailedFinalityProvider { + return { pk: new Uint8Array(0) }; +} + +export const EventPowerDistUpdate_EventJailedFinalityProvider: MessageFns< + EventPowerDistUpdate_EventJailedFinalityProvider +> = { + encode( + message: EventPowerDistUpdate_EventJailedFinalityProvider, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { + if (message.pk.length !== 0) { + writer.uint32(10).bytes(message.pk); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): EventPowerDistUpdate_EventJailedFinalityProvider { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventPowerDistUpdate_EventJailedFinalityProvider(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.pk = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): EventPowerDistUpdate_EventJailedFinalityProvider { + return { pk: isSet(object.pk) ? bytesFromBase64(object.pk) : new Uint8Array(0) }; + }, + + toJSON(message: EventPowerDistUpdate_EventJailedFinalityProvider): unknown { + const obj: any = {}; + if (message.pk.length !== 0) { + obj.pk = base64FromBytes(message.pk); + } + return obj; + }, + + create, I>>( + base?: I, + ): EventPowerDistUpdate_EventJailedFinalityProvider { + return EventPowerDistUpdate_EventJailedFinalityProvider.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): EventPowerDistUpdate_EventJailedFinalityProvider { + const message = createBaseEventPowerDistUpdate_EventJailedFinalityProvider(); + message.pk = object.pk ?? new Uint8Array(0); + return message; + }, +}; + +function createBaseEventPowerDistUpdate_EventUnjailedFinalityProvider(): EventPowerDistUpdate_EventUnjailedFinalityProvider { + return { pk: new Uint8Array(0) }; +} + +export const EventPowerDistUpdate_EventUnjailedFinalityProvider: MessageFns< + EventPowerDistUpdate_EventUnjailedFinalityProvider +> = { + encode( + message: EventPowerDistUpdate_EventUnjailedFinalityProvider, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { + if (message.pk.length !== 0) { + writer.uint32(10).bytes(message.pk); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): EventPowerDistUpdate_EventUnjailedFinalityProvider { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventPowerDistUpdate_EventUnjailedFinalityProvider(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.pk = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): EventPowerDistUpdate_EventUnjailedFinalityProvider { + return { pk: isSet(object.pk) ? bytesFromBase64(object.pk) : new Uint8Array(0) }; + }, + + toJSON(message: EventPowerDistUpdate_EventUnjailedFinalityProvider): unknown { + const obj: any = {}; + if (message.pk.length !== 0) { + obj.pk = base64FromBytes(message.pk); + } + return obj; + }, + + create, I>>( + base?: I, + ): EventPowerDistUpdate_EventUnjailedFinalityProvider { + return EventPowerDistUpdate_EventUnjailedFinalityProvider.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): EventPowerDistUpdate_EventUnjailedFinalityProvider { + const message = createBaseEventPowerDistUpdate_EventUnjailedFinalityProvider(); + message.pk = object.pk ?? new Uint8Array(0); + return message; + }, +}; + +function createBaseEventFinalityProviderStatusChange(): EventFinalityProviderStatusChange { + return { btcPk: "", newState: "" }; +} + +export const EventFinalityProviderStatusChange: MessageFns = { + encode(message: EventFinalityProviderStatusChange, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.btcPk !== "") { + writer.uint32(10).string(message.btcPk); + } + if (message.newState !== "") { + writer.uint32(18).string(message.newState); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): EventFinalityProviderStatusChange { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventFinalityProviderStatusChange(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.btcPk = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.newState = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): EventFinalityProviderStatusChange { + return { + btcPk: isSet(object.btcPk) ? globalThis.String(object.btcPk) : "", + newState: isSet(object.newState) ? globalThis.String(object.newState) : "", + }; + }, + + toJSON(message: EventFinalityProviderStatusChange): unknown { + const obj: any = {}; + if (message.btcPk !== "") { + obj.btcPk = message.btcPk; + } + if (message.newState !== "") { + obj.newState = message.newState; + } + return obj; + }, + + create, I>>( + base?: I, + ): EventFinalityProviderStatusChange { + return EventFinalityProviderStatusChange.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): EventFinalityProviderStatusChange { + const message = createBaseEventFinalityProviderStatusChange(); + message.btcPk = object.btcPk ?? ""; + message.newState = object.newState ?? ""; + return message; + }, +}; + +function createBaseEventBTCDelegationCreated(): EventBTCDelegationCreated { + return { + stakingTxHash: "", + paramsVersion: "", + finalityProviderBtcPksHex: [], + stakerBtcPkHex: "", + stakingTime: "", + stakingAmount: "", + unbondingTime: "", + unbondingTx: "", + newState: "", + }; +} + +export const EventBTCDelegationCreated: MessageFns = { + encode(message: EventBTCDelegationCreated, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.stakingTxHash !== "") { + writer.uint32(10).string(message.stakingTxHash); + } + if (message.paramsVersion !== "") { + writer.uint32(18).string(message.paramsVersion); + } + for (const v of message.finalityProviderBtcPksHex) { + writer.uint32(26).string(v!); + } + if (message.stakerBtcPkHex !== "") { + writer.uint32(34).string(message.stakerBtcPkHex); + } + if (message.stakingTime !== "") { + writer.uint32(42).string(message.stakingTime); + } + if (message.stakingAmount !== "") { + writer.uint32(50).string(message.stakingAmount); + } + if (message.unbondingTime !== "") { + writer.uint32(58).string(message.unbondingTime); + } + if (message.unbondingTx !== "") { + writer.uint32(66).string(message.unbondingTx); + } + if (message.newState !== "") { + writer.uint32(74).string(message.newState); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): EventBTCDelegationCreated { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventBTCDelegationCreated(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.stakingTxHash = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.paramsVersion = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.finalityProviderBtcPksHex.push(reader.string()); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.stakerBtcPkHex = reader.string(); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.stakingTime = reader.string(); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.stakingAmount = reader.string(); + continue; + case 7: + if (tag !== 58) { + break; + } + + message.unbondingTime = reader.string(); + continue; + case 8: + if (tag !== 66) { + break; + } + + message.unbondingTx = reader.string(); + continue; + case 9: + if (tag !== 74) { + break; + } + + message.newState = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): EventBTCDelegationCreated { + return { + stakingTxHash: isSet(object.stakingTxHash) ? globalThis.String(object.stakingTxHash) : "", + paramsVersion: isSet(object.paramsVersion) ? globalThis.String(object.paramsVersion) : "", + finalityProviderBtcPksHex: globalThis.Array.isArray(object?.finalityProviderBtcPksHex) + ? object.finalityProviderBtcPksHex.map((e: any) => globalThis.String(e)) + : [], + stakerBtcPkHex: isSet(object.stakerBtcPkHex) ? globalThis.String(object.stakerBtcPkHex) : "", + stakingTime: isSet(object.stakingTime) ? globalThis.String(object.stakingTime) : "", + stakingAmount: isSet(object.stakingAmount) ? globalThis.String(object.stakingAmount) : "", + unbondingTime: isSet(object.unbondingTime) ? globalThis.String(object.unbondingTime) : "", + unbondingTx: isSet(object.unbondingTx) ? globalThis.String(object.unbondingTx) : "", + newState: isSet(object.newState) ? globalThis.String(object.newState) : "", + }; + }, + + toJSON(message: EventBTCDelegationCreated): unknown { + const obj: any = {}; + if (message.stakingTxHash !== "") { + obj.stakingTxHash = message.stakingTxHash; + } + if (message.paramsVersion !== "") { + obj.paramsVersion = message.paramsVersion; + } + if (message.finalityProviderBtcPksHex?.length) { + obj.finalityProviderBtcPksHex = message.finalityProviderBtcPksHex; + } + if (message.stakerBtcPkHex !== "") { + obj.stakerBtcPkHex = message.stakerBtcPkHex; + } + if (message.stakingTime !== "") { + obj.stakingTime = message.stakingTime; + } + if (message.stakingAmount !== "") { + obj.stakingAmount = message.stakingAmount; + } + if (message.unbondingTime !== "") { + obj.unbondingTime = message.unbondingTime; + } + if (message.unbondingTx !== "") { + obj.unbondingTx = message.unbondingTx; + } + if (message.newState !== "") { + obj.newState = message.newState; + } + return obj; + }, + + create, I>>(base?: I): EventBTCDelegationCreated { + return EventBTCDelegationCreated.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): EventBTCDelegationCreated { + const message = createBaseEventBTCDelegationCreated(); + message.stakingTxHash = object.stakingTxHash ?? ""; + message.paramsVersion = object.paramsVersion ?? ""; + message.finalityProviderBtcPksHex = object.finalityProviderBtcPksHex?.map((e) => e) || []; + message.stakerBtcPkHex = object.stakerBtcPkHex ?? ""; + message.stakingTime = object.stakingTime ?? ""; + message.stakingAmount = object.stakingAmount ?? ""; + message.unbondingTime = object.unbondingTime ?? ""; + message.unbondingTx = object.unbondingTx ?? ""; + message.newState = object.newState ?? ""; + return message; + }, +}; + +function createBaseEventCovenantSignatureReceived(): EventCovenantSignatureReceived { + return { stakingTxHash: "", covenantBtcPkHex: "", covenantUnbondingSignatureHex: "" }; +} + +export const EventCovenantSignatureReceived: MessageFns = { + encode(message: EventCovenantSignatureReceived, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.stakingTxHash !== "") { + writer.uint32(10).string(message.stakingTxHash); + } + if (message.covenantBtcPkHex !== "") { + writer.uint32(18).string(message.covenantBtcPkHex); + } + if (message.covenantUnbondingSignatureHex !== "") { + writer.uint32(26).string(message.covenantUnbondingSignatureHex); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): EventCovenantSignatureReceived { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventCovenantSignatureReceived(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.stakingTxHash = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.covenantBtcPkHex = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.covenantUnbondingSignatureHex = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): EventCovenantSignatureReceived { + return { + stakingTxHash: isSet(object.stakingTxHash) ? globalThis.String(object.stakingTxHash) : "", + covenantBtcPkHex: isSet(object.covenantBtcPkHex) ? globalThis.String(object.covenantBtcPkHex) : "", + covenantUnbondingSignatureHex: isSet(object.covenantUnbondingSignatureHex) + ? globalThis.String(object.covenantUnbondingSignatureHex) + : "", + }; + }, + + toJSON(message: EventCovenantSignatureReceived): unknown { + const obj: any = {}; + if (message.stakingTxHash !== "") { + obj.stakingTxHash = message.stakingTxHash; + } + if (message.covenantBtcPkHex !== "") { + obj.covenantBtcPkHex = message.covenantBtcPkHex; + } + if (message.covenantUnbondingSignatureHex !== "") { + obj.covenantUnbondingSignatureHex = message.covenantUnbondingSignatureHex; + } + return obj; + }, + + create, I>>(base?: I): EventCovenantSignatureReceived { + return EventCovenantSignatureReceived.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): EventCovenantSignatureReceived { + const message = createBaseEventCovenantSignatureReceived(); + message.stakingTxHash = object.stakingTxHash ?? ""; + message.covenantBtcPkHex = object.covenantBtcPkHex ?? ""; + message.covenantUnbondingSignatureHex = object.covenantUnbondingSignatureHex ?? ""; + return message; + }, +}; + +function createBaseEventCovenantQuorumReached(): EventCovenantQuorumReached { + return { stakingTxHash: "", newState: "" }; +} + +export const EventCovenantQuorumReached: MessageFns = { + encode(message: EventCovenantQuorumReached, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.stakingTxHash !== "") { + writer.uint32(10).string(message.stakingTxHash); + } + if (message.newState !== "") { + writer.uint32(18).string(message.newState); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): EventCovenantQuorumReached { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventCovenantQuorumReached(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.stakingTxHash = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.newState = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): EventCovenantQuorumReached { + return { + stakingTxHash: isSet(object.stakingTxHash) ? globalThis.String(object.stakingTxHash) : "", + newState: isSet(object.newState) ? globalThis.String(object.newState) : "", + }; + }, + + toJSON(message: EventCovenantQuorumReached): unknown { + const obj: any = {}; + if (message.stakingTxHash !== "") { + obj.stakingTxHash = message.stakingTxHash; + } + if (message.newState !== "") { + obj.newState = message.newState; + } + return obj; + }, + + create, I>>(base?: I): EventCovenantQuorumReached { + return EventCovenantQuorumReached.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): EventCovenantQuorumReached { + const message = createBaseEventCovenantQuorumReached(); + message.stakingTxHash = object.stakingTxHash ?? ""; + message.newState = object.newState ?? ""; + return message; + }, +}; + +function createBaseEventBTCDelegationInclusionProofReceived(): EventBTCDelegationInclusionProofReceived { + return { stakingTxHash: "", startHeight: "", endHeight: "", newState: "" }; +} + +export const EventBTCDelegationInclusionProofReceived: MessageFns = { + encode(message: EventBTCDelegationInclusionProofReceived, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.stakingTxHash !== "") { + writer.uint32(10).string(message.stakingTxHash); + } + if (message.startHeight !== "") { + writer.uint32(18).string(message.startHeight); + } + if (message.endHeight !== "") { + writer.uint32(26).string(message.endHeight); + } + if (message.newState !== "") { + writer.uint32(34).string(message.newState); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): EventBTCDelegationInclusionProofReceived { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventBTCDelegationInclusionProofReceived(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.stakingTxHash = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.startHeight = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.endHeight = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.newState = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): EventBTCDelegationInclusionProofReceived { + return { + stakingTxHash: isSet(object.stakingTxHash) ? globalThis.String(object.stakingTxHash) : "", + startHeight: isSet(object.startHeight) ? globalThis.String(object.startHeight) : "", + endHeight: isSet(object.endHeight) ? globalThis.String(object.endHeight) : "", + newState: isSet(object.newState) ? globalThis.String(object.newState) : "", + }; + }, + + toJSON(message: EventBTCDelegationInclusionProofReceived): unknown { + const obj: any = {}; + if (message.stakingTxHash !== "") { + obj.stakingTxHash = message.stakingTxHash; + } + if (message.startHeight !== "") { + obj.startHeight = message.startHeight; + } + if (message.endHeight !== "") { + obj.endHeight = message.endHeight; + } + if (message.newState !== "") { + obj.newState = message.newState; + } + return obj; + }, + + create, I>>( + base?: I, + ): EventBTCDelegationInclusionProofReceived { + return EventBTCDelegationInclusionProofReceived.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): EventBTCDelegationInclusionProofReceived { + const message = createBaseEventBTCDelegationInclusionProofReceived(); + message.stakingTxHash = object.stakingTxHash ?? ""; + message.startHeight = object.startHeight ?? ""; + message.endHeight = object.endHeight ?? ""; + message.newState = object.newState ?? ""; + return message; + }, +}; + +function createBaseEventBTCDelgationUnbondedEarly(): EventBTCDelgationUnbondedEarly { + return { stakingTxHash: "", startHeight: "", newState: "" }; +} + +export const EventBTCDelgationUnbondedEarly: MessageFns = { + encode(message: EventBTCDelgationUnbondedEarly, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.stakingTxHash !== "") { + writer.uint32(10).string(message.stakingTxHash); + } + if (message.startHeight !== "") { + writer.uint32(18).string(message.startHeight); + } + if (message.newState !== "") { + writer.uint32(26).string(message.newState); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): EventBTCDelgationUnbondedEarly { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventBTCDelgationUnbondedEarly(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.stakingTxHash = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.startHeight = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.newState = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): EventBTCDelgationUnbondedEarly { + return { + stakingTxHash: isSet(object.stakingTxHash) ? globalThis.String(object.stakingTxHash) : "", + startHeight: isSet(object.startHeight) ? globalThis.String(object.startHeight) : "", + newState: isSet(object.newState) ? globalThis.String(object.newState) : "", + }; + }, + + toJSON(message: EventBTCDelgationUnbondedEarly): unknown { + const obj: any = {}; + if (message.stakingTxHash !== "") { + obj.stakingTxHash = message.stakingTxHash; + } + if (message.startHeight !== "") { + obj.startHeight = message.startHeight; + } + if (message.newState !== "") { + obj.newState = message.newState; + } + return obj; + }, + + create, I>>(base?: I): EventBTCDelgationUnbondedEarly { + return EventBTCDelgationUnbondedEarly.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): EventBTCDelgationUnbondedEarly { + const message = createBaseEventBTCDelgationUnbondedEarly(); + message.stakingTxHash = object.stakingTxHash ?? ""; + message.startHeight = object.startHeight ?? ""; + message.newState = object.newState ?? ""; + return message; + }, +}; + +function createBaseEventBTCDelegationExpired(): EventBTCDelegationExpired { + return { stakingTxHash: "", newState: "" }; +} + +export const EventBTCDelegationExpired: MessageFns = { + encode(message: EventBTCDelegationExpired, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.stakingTxHash !== "") { + writer.uint32(10).string(message.stakingTxHash); + } + if (message.newState !== "") { + writer.uint32(18).string(message.newState); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): EventBTCDelegationExpired { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventBTCDelegationExpired(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.stakingTxHash = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.newState = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): EventBTCDelegationExpired { + return { + stakingTxHash: isSet(object.stakingTxHash) ? globalThis.String(object.stakingTxHash) : "", + newState: isSet(object.newState) ? globalThis.String(object.newState) : "", + }; + }, + + toJSON(message: EventBTCDelegationExpired): unknown { + const obj: any = {}; + if (message.stakingTxHash !== "") { + obj.stakingTxHash = message.stakingTxHash; + } + if (message.newState !== "") { + obj.newState = message.newState; + } + return obj; + }, + + create, I>>(base?: I): EventBTCDelegationExpired { + return EventBTCDelegationExpired.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): EventBTCDelegationExpired { + const message = createBaseEventBTCDelegationExpired(); + message.stakingTxHash = object.stakingTxHash ?? ""; + message.newState = object.newState ?? ""; + return message; + }, +}; + +function createBaseEventUnexpectedUnbondingTx(): EventUnexpectedUnbondingTx { + return { stakingTxHash: "", spendStakeTxHash: "", spendStakeTxHeaderHash: "", spendStakeTxBlockIndex: 0 }; +} + +export const EventUnexpectedUnbondingTx: MessageFns = { + encode(message: EventUnexpectedUnbondingTx, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.stakingTxHash !== "") { + writer.uint32(10).string(message.stakingTxHash); + } + if (message.spendStakeTxHash !== "") { + writer.uint32(18).string(message.spendStakeTxHash); + } + if (message.spendStakeTxHeaderHash !== "") { + writer.uint32(26).string(message.spendStakeTxHeaderHash); + } + if (message.spendStakeTxBlockIndex !== 0) { + writer.uint32(32).uint32(message.spendStakeTxBlockIndex); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): EventUnexpectedUnbondingTx { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventUnexpectedUnbondingTx(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.stakingTxHash = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.spendStakeTxHash = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.spendStakeTxHeaderHash = reader.string(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.spendStakeTxBlockIndex = reader.uint32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): EventUnexpectedUnbondingTx { + return { + stakingTxHash: isSet(object.stakingTxHash) ? globalThis.String(object.stakingTxHash) : "", + spendStakeTxHash: isSet(object.spendStakeTxHash) ? globalThis.String(object.spendStakeTxHash) : "", + spendStakeTxHeaderHash: isSet(object.spendStakeTxHeaderHash) + ? globalThis.String(object.spendStakeTxHeaderHash) + : "", + spendStakeTxBlockIndex: isSet(object.spendStakeTxBlockIndex) + ? globalThis.Number(object.spendStakeTxBlockIndex) + : 0, + }; + }, + + toJSON(message: EventUnexpectedUnbondingTx): unknown { + const obj: any = {}; + if (message.stakingTxHash !== "") { + obj.stakingTxHash = message.stakingTxHash; + } + if (message.spendStakeTxHash !== "") { + obj.spendStakeTxHash = message.spendStakeTxHash; + } + if (message.spendStakeTxHeaderHash !== "") { + obj.spendStakeTxHeaderHash = message.spendStakeTxHeaderHash; + } + if (message.spendStakeTxBlockIndex !== 0) { + obj.spendStakeTxBlockIndex = Math.round(message.spendStakeTxBlockIndex); + } + return obj; + }, + + create, I>>(base?: I): EventUnexpectedUnbondingTx { + return EventUnexpectedUnbondingTx.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): EventUnexpectedUnbondingTx { + const message = createBaseEventUnexpectedUnbondingTx(); + message.stakingTxHash = object.stakingTxHash ?? ""; + message.spendStakeTxHash = object.spendStakeTxHash ?? ""; + message.spendStakeTxHeaderHash = object.spendStakeTxHeaderHash ?? ""; + message.spendStakeTxBlockIndex = object.spendStakeTxBlockIndex ?? 0; + return message; + }, +}; + function bytesFromBase64(b64: string): Uint8Array { if ((globalThis as any).Buffer) { return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); diff --git a/src/generated/babylon/btcstaking/v1/genesis.ts b/src/generated/babylon/btcstaking/v1/genesis.ts index 0f4df00..cee18c1 100644 --- a/src/generated/babylon/btcstaking/v1/genesis.ts +++ b/src/generated/babylon/btcstaking/v1/genesis.ts @@ -449,7 +449,7 @@ export const BlockHeightBbnToBtc: MessageFns = { writer.uint32(8).uint64(message.blockHeightBbn); } if (message.blockHeightBtc !== 0) { - writer.uint32(16).uint64(message.blockHeightBtc); + writer.uint32(16).uint32(message.blockHeightBtc); } return writer; }, @@ -473,7 +473,7 @@ export const BlockHeightBbnToBtc: MessageFns = { break; } - message.blockHeightBtc = longToNumber(reader.uint64()); + message.blockHeightBtc = reader.uint32(); continue; } if ((tag & 7) === 4 || tag === 0) { @@ -614,7 +614,7 @@ export const EventIndex: MessageFns = { writer.uint32(8).uint64(message.idx); } if (message.blockHeightBtc !== 0) { - writer.uint32(16).uint64(message.blockHeightBtc); + writer.uint32(16).uint32(message.blockHeightBtc); } if (message.event !== undefined) { EventPowerDistUpdate.encode(message.event, writer.uint32(26).fork()).join(); @@ -641,7 +641,7 @@ export const EventIndex: MessageFns = { break; } - message.blockHeightBtc = longToNumber(reader.uint64()); + message.blockHeightBtc = reader.uint32(); continue; case 3: if (tag !== 26) { diff --git a/src/generated/babylon/btcstaking/v1/incentive.ts b/src/generated/babylon/btcstaking/v1/incentive.ts index 5d27e7e..daecb6a 100644 --- a/src/generated/babylon/btcstaking/v1/incentive.ts +++ b/src/generated/babylon/btcstaking/v1/incentive.ts @@ -14,9 +14,18 @@ export const protobufPackage = "babylon.btcstaking.v1"; * and their BTC delegations at a height */ export interface VotingPowerDistCache { - totalVotingPower: number; + /** + * total_sat is the total amount of bonded BTC stake (in Satoshi) of all the finality providers + * in the cache + */ + totalBondedSat: number; /** finality_providers is a list of finality providers' voting power information */ finalityProviders: FinalityProviderDistInfo[]; + /** + * num_active_fps is the number of finality providers that have active BTC + * delegations as well as timestamped public randomness + */ + numActiveFps: number; } /** FinalityProviderDistInfo is the reward distribution of a finality provider and its BTC delegations */ @@ -30,13 +39,29 @@ export interface FinalityProviderDistInfo { addr: string; /** commission defines the commission rate of finality provider */ commission: string; - /** total_voting_power is the total voting power of the finality provider */ - totalVotingPower: number; + /** total_bonded_sat is the total amount of bonded BTC stake (in Satoshi) of the finality provider */ + totalBondedSat: number; /** btc_dels is a list of BTC delegations' voting power information under this finality provider */ btcDels: BTCDelDistInfo[]; + /** + * is_timestamped indicates whether the finality provider + * has timestamped public randomness committed + * if no, it should not be assigned voting power + */ + isTimestamped: boolean; + /** + * is_jailed indicates whether the finality provider + * is jailed, if so, it should not be assigned voting power + */ + isJailed: boolean; + /** + * is_slashed indicates whether the finality provider + * is slashed, if so, it should not be assigned voting power + */ + isSlashed: boolean; } -/** BTCDelDistInfo contains the information related to reward distribution for a BTC delegation */ +/** BTCDelDistInfo contains the information related to voting power distribution for a BTC delegation */ export interface BTCDelDistInfo { /** * btc_pk is the Bitcoin secp256k1 PK of this BTC delegation @@ -47,22 +72,25 @@ export interface BTCDelDistInfo { stakerAddr: string; /** staking_tx_hash is the staking tx hash of the BTC delegation */ stakingTxHash: string; - /** voting_power is the voting power of the BTC delegation */ - votingPower: number; + /** total_sat is the amount of BTC stake (in Satoshi) of the BTC delegation */ + totalSat: number; } function createBaseVotingPowerDistCache(): VotingPowerDistCache { - return { totalVotingPower: 0, finalityProviders: [] }; + return { totalBondedSat: 0, finalityProviders: [], numActiveFps: 0 }; } export const VotingPowerDistCache: MessageFns = { encode(message: VotingPowerDistCache, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.totalVotingPower !== 0) { - writer.uint32(8).uint64(message.totalVotingPower); + if (message.totalBondedSat !== 0) { + writer.uint32(8).uint64(message.totalBondedSat); } for (const v of message.finalityProviders) { FinalityProviderDistInfo.encode(v!, writer.uint32(18).fork()).join(); } + if (message.numActiveFps !== 0) { + writer.uint32(24).uint32(message.numActiveFps); + } return writer; }, @@ -78,7 +106,7 @@ export const VotingPowerDistCache: MessageFns = { break; } - message.totalVotingPower = longToNumber(reader.uint64()); + message.totalBondedSat = longToNumber(reader.uint64()); continue; case 2: if (tag !== 18) { @@ -87,6 +115,13 @@ export const VotingPowerDistCache: MessageFns = { message.finalityProviders.push(FinalityProviderDistInfo.decode(reader, reader.uint32())); continue; + case 3: + if (tag !== 24) { + break; + } + + message.numActiveFps = reader.uint32(); + continue; } if ((tag & 7) === 4 || tag === 0) { break; @@ -98,21 +133,25 @@ export const VotingPowerDistCache: MessageFns = { fromJSON(object: any): VotingPowerDistCache { return { - totalVotingPower: isSet(object.totalVotingPower) ? globalThis.Number(object.totalVotingPower) : 0, + totalBondedSat: isSet(object.totalBondedSat) ? globalThis.Number(object.totalBondedSat) : 0, finalityProviders: globalThis.Array.isArray(object?.finalityProviders) ? object.finalityProviders.map((e: any) => FinalityProviderDistInfo.fromJSON(e)) : [], + numActiveFps: isSet(object.numActiveFps) ? globalThis.Number(object.numActiveFps) : 0, }; }, toJSON(message: VotingPowerDistCache): unknown { const obj: any = {}; - if (message.totalVotingPower !== 0) { - obj.totalVotingPower = Math.round(message.totalVotingPower); + if (message.totalBondedSat !== 0) { + obj.totalBondedSat = Math.round(message.totalBondedSat); } if (message.finalityProviders?.length) { obj.finalityProviders = message.finalityProviders.map((e) => FinalityProviderDistInfo.toJSON(e)); } + if (message.numActiveFps !== 0) { + obj.numActiveFps = Math.round(message.numActiveFps); + } return obj; }, @@ -121,14 +160,24 @@ export const VotingPowerDistCache: MessageFns = { }, fromPartial, I>>(object: I): VotingPowerDistCache { const message = createBaseVotingPowerDistCache(); - message.totalVotingPower = object.totalVotingPower ?? 0; + message.totalBondedSat = object.totalBondedSat ?? 0; message.finalityProviders = object.finalityProviders?.map((e) => FinalityProviderDistInfo.fromPartial(e)) || []; + message.numActiveFps = object.numActiveFps ?? 0; return message; }, }; function createBaseFinalityProviderDistInfo(): FinalityProviderDistInfo { - return { btcPk: new Uint8Array(0), addr: "", commission: "", totalVotingPower: 0, btcDels: [] }; + return { + btcPk: new Uint8Array(0), + addr: "", + commission: "", + totalBondedSat: 0, + btcDels: [], + isTimestamped: false, + isJailed: false, + isSlashed: false, + }; } export const FinalityProviderDistInfo: MessageFns = { @@ -142,12 +191,21 @@ export const FinalityProviderDistInfo: MessageFns = { if (message.commission !== "") { writer.uint32(26).string(message.commission); } - if (message.totalVotingPower !== 0) { - writer.uint32(32).uint64(message.totalVotingPower); + if (message.totalBondedSat !== 0) { + writer.uint32(32).uint64(message.totalBondedSat); } for (const v of message.btcDels) { BTCDelDistInfo.encode(v!, writer.uint32(42).fork()).join(); } + if (message.isTimestamped !== false) { + writer.uint32(48).bool(message.isTimestamped); + } + if (message.isJailed !== false) { + writer.uint32(56).bool(message.isJailed); + } + if (message.isSlashed !== false) { + writer.uint32(64).bool(message.isSlashed); + } return writer; }, @@ -184,7 +242,7 @@ export const FinalityProviderDistInfo: MessageFns = { break; } - message.totalVotingPower = longToNumber(reader.uint64()); + message.totalBondedSat = longToNumber(reader.uint64()); continue; case 5: if (tag !== 42) { @@ -193,6 +251,27 @@ export const FinalityProviderDistInfo: MessageFns = { message.btcDels.push(BTCDelDistInfo.decode(reader, reader.uint32())); continue; + case 6: + if (tag !== 48) { + break; + } + + message.isTimestamped = reader.bool(); + continue; + case 7: + if (tag !== 56) { + break; + } + + message.isJailed = reader.bool(); + continue; + case 8: + if (tag !== 64) { + break; + } + + message.isSlashed = reader.bool(); + continue; } if ((tag & 7) === 4 || tag === 0) { break; @@ -207,10 +286,13 @@ export const FinalityProviderDistInfo: MessageFns = { btcPk: isSet(object.btcPk) ? bytesFromBase64(object.btcPk) : new Uint8Array(0), addr: isSet(object.addr) ? globalThis.String(object.addr) : "", commission: isSet(object.commission) ? globalThis.String(object.commission) : "", - totalVotingPower: isSet(object.totalVotingPower) ? globalThis.Number(object.totalVotingPower) : 0, + totalBondedSat: isSet(object.totalBondedSat) ? globalThis.Number(object.totalBondedSat) : 0, btcDels: globalThis.Array.isArray(object?.btcDels) ? object.btcDels.map((e: any) => BTCDelDistInfo.fromJSON(e)) : [], + isTimestamped: isSet(object.isTimestamped) ? globalThis.Boolean(object.isTimestamped) : false, + isJailed: isSet(object.isJailed) ? globalThis.Boolean(object.isJailed) : false, + isSlashed: isSet(object.isSlashed) ? globalThis.Boolean(object.isSlashed) : false, }; }, @@ -225,12 +307,21 @@ export const FinalityProviderDistInfo: MessageFns = { if (message.commission !== "") { obj.commission = message.commission; } - if (message.totalVotingPower !== 0) { - obj.totalVotingPower = Math.round(message.totalVotingPower); + if (message.totalBondedSat !== 0) { + obj.totalBondedSat = Math.round(message.totalBondedSat); } if (message.btcDels?.length) { obj.btcDels = message.btcDels.map((e) => BTCDelDistInfo.toJSON(e)); } + if (message.isTimestamped !== false) { + obj.isTimestamped = message.isTimestamped; + } + if (message.isJailed !== false) { + obj.isJailed = message.isJailed; + } + if (message.isSlashed !== false) { + obj.isSlashed = message.isSlashed; + } return obj; }, @@ -242,14 +333,17 @@ export const FinalityProviderDistInfo: MessageFns = { message.btcPk = object.btcPk ?? new Uint8Array(0); message.addr = object.addr ?? ""; message.commission = object.commission ?? ""; - message.totalVotingPower = object.totalVotingPower ?? 0; + message.totalBondedSat = object.totalBondedSat ?? 0; message.btcDels = object.btcDels?.map((e) => BTCDelDistInfo.fromPartial(e)) || []; + message.isTimestamped = object.isTimestamped ?? false; + message.isJailed = object.isJailed ?? false; + message.isSlashed = object.isSlashed ?? false; return message; }, }; function createBaseBTCDelDistInfo(): BTCDelDistInfo { - return { btcPk: new Uint8Array(0), stakerAddr: "", stakingTxHash: "", votingPower: 0 }; + return { btcPk: new Uint8Array(0), stakerAddr: "", stakingTxHash: "", totalSat: 0 }; } export const BTCDelDistInfo: MessageFns = { @@ -263,8 +357,8 @@ export const BTCDelDistInfo: MessageFns = { if (message.stakingTxHash !== "") { writer.uint32(26).string(message.stakingTxHash); } - if (message.votingPower !== 0) { - writer.uint32(32).uint64(message.votingPower); + if (message.totalSat !== 0) { + writer.uint32(32).uint64(message.totalSat); } return writer; }, @@ -302,7 +396,7 @@ export const BTCDelDistInfo: MessageFns = { break; } - message.votingPower = longToNumber(reader.uint64()); + message.totalSat = longToNumber(reader.uint64()); continue; } if ((tag & 7) === 4 || tag === 0) { @@ -318,7 +412,7 @@ export const BTCDelDistInfo: MessageFns = { btcPk: isSet(object.btcPk) ? bytesFromBase64(object.btcPk) : new Uint8Array(0), stakerAddr: isSet(object.stakerAddr) ? globalThis.String(object.stakerAddr) : "", stakingTxHash: isSet(object.stakingTxHash) ? globalThis.String(object.stakingTxHash) : "", - votingPower: isSet(object.votingPower) ? globalThis.Number(object.votingPower) : 0, + totalSat: isSet(object.totalSat) ? globalThis.Number(object.totalSat) : 0, }; }, @@ -333,8 +427,8 @@ export const BTCDelDistInfo: MessageFns = { if (message.stakingTxHash !== "") { obj.stakingTxHash = message.stakingTxHash; } - if (message.votingPower !== 0) { - obj.votingPower = Math.round(message.votingPower); + if (message.totalSat !== 0) { + obj.totalSat = Math.round(message.totalSat); } return obj; }, @@ -347,7 +441,7 @@ export const BTCDelDistInfo: MessageFns = { message.btcPk = object.btcPk ?? new Uint8Array(0); message.stakerAddr = object.stakerAddr ?? ""; message.stakingTxHash = object.stakingTxHash ?? ""; - message.votingPower = object.votingPower ?? 0; + message.totalSat = object.totalSat ?? 0; return message; }, }; diff --git a/src/generated/babylon/btcstaking/v1/params.ts b/src/generated/babylon/btcstaking/v1/params.ts index 1f33e77..3faceb0 100644 --- a/src/generated/babylon/btcstaking/v1/params.ts +++ b/src/generated/babylon/btcstaking/v1/params.ts @@ -12,6 +12,7 @@ export const protobufPackage = "babylon.btcstaking.v1"; /** Params defines the parameters for the module. */ export interface Params { /** + * PARAMETERS COVERING STAKING * covenant_pks is the list of public keys held by the covenant committee * each PK follows encoding in BIP-340 spec on Bitcoin */ @@ -21,36 +22,50 @@ export interface Params { * multisignature */ covenantQuorum: number; + /** min_staking_value_sat is the minimum of satoshis locked in staking output */ + minStakingValueSat: number; + /** max_staking_value_sat is the maximum of satoshis locked in staking output */ + maxStakingValueSat: number; + /** min_staking_time is the minimum lock time specified in staking output script */ + minStakingTimeBlocks: number; + /** max_staking_time_blocks is the maximum lock time time specified in staking output script */ + maxStakingTimeBlocks: number; /** - * slashing address is the address that the slashed BTC goes to - * the address is in string on Bitcoin + * PARAMETERS COVERING SLASHING + * slashing_pk_script is the pk_script expected in slashing output ie. the first + * output of slashing transaction */ - slashingAddress: string; + slashingPkScript: Uint8Array; /** * min_slashing_tx_fee_sat is the minimum amount of tx fee (quantified - * in Satoshi) needed for the pre-signed slashing tx - * TODO: change to satoshi per byte? + * in Satoshi) needed for the pre-signed slashing tx. It covers both: + * staking slashing transaction and unbonding slashing transaction */ minSlashingTxFeeSat: number; - /** min_commission_rate is the chain-wide minimum commission rate that a finality provider can charge their delegators */ - minCommissionRate: string; /** * slashing_rate determines the portion of the staked amount to be slashed, - * expressed as a decimal (e.g., 0.5 for 50%). + * expressed as a decimal (e.g., 0.5 for 50%). Maximal precion is 2 decimal + * places */ slashingRate: string; - /** max_active_finality_providers is the maximum number of active finality providers in the BTC staking protocol */ - maxActiveFinalityProviders: number; - /** min_unbonding_time is the minimum time for unbonding transaction timelock in BTC blocks */ - minUnbondingTime: number; /** - * min_unbonding_rate is the minimum amount of BTC that are required in unbonding - * output, expressed as a fraction of staking output - * example: if min_unbonding_rate=0.9, then the unbonding output value - * must be at least 90% of staking output, for staking request to be considered - * valid + * PARAMETERS COVERING UNBONDING + * min_unbonding_time is the minimum time for unbonding transaction timelock in BTC blocks + */ + minUnbondingTimeBlocks: number; + /** unbonding_fee exact fee required for unbonding transaction */ + unbondingFeeSat: number; + /** + * PARAMETERS COVERING FINALITY PROVIDERS + * min_commission_rate is the chain-wide minimum commission rate that a finality provider + * can charge their delegators expressed as a decimal (e.g., 0.5 for 50%). Maximal precion + * is 2 decimal places */ - minUnbondingRate: string; + minCommissionRate: string; + /** max_active_finality_providers is the maximum number of active finality providers in the BTC staking protocol */ + maxActiveFinalityProviders: number; + /** base gas fee for delegation creation */ + delegationCreationBaseGasFee: number; } /** StoredParams attach information about the version of stored parameters */ @@ -68,13 +83,18 @@ function createBaseParams(): Params { return { covenantPks: [], covenantQuorum: 0, - slashingAddress: "", + minStakingValueSat: 0, + maxStakingValueSat: 0, + minStakingTimeBlocks: 0, + maxStakingTimeBlocks: 0, + slashingPkScript: new Uint8Array(0), minSlashingTxFeeSat: 0, - minCommissionRate: "", slashingRate: "", + minUnbondingTimeBlocks: 0, + unbondingFeeSat: 0, + minCommissionRate: "", maxActiveFinalityProviders: 0, - minUnbondingTime: 0, - minUnbondingRate: "", + delegationCreationBaseGasFee: 0, }; } @@ -86,26 +106,41 @@ export const Params: MessageFns = { if (message.covenantQuorum !== 0) { writer.uint32(16).uint32(message.covenantQuorum); } - if (message.slashingAddress !== "") { - writer.uint32(26).string(message.slashingAddress); + if (message.minStakingValueSat !== 0) { + writer.uint32(24).int64(message.minStakingValueSat); } - if (message.minSlashingTxFeeSat !== 0) { - writer.uint32(32).int64(message.minSlashingTxFeeSat); + if (message.maxStakingValueSat !== 0) { + writer.uint32(32).int64(message.maxStakingValueSat); } - if (message.minCommissionRate !== "") { - writer.uint32(42).string(message.minCommissionRate); + if (message.minStakingTimeBlocks !== 0) { + writer.uint32(40).uint32(message.minStakingTimeBlocks); + } + if (message.maxStakingTimeBlocks !== 0) { + writer.uint32(48).uint32(message.maxStakingTimeBlocks); + } + if (message.slashingPkScript.length !== 0) { + writer.uint32(58).bytes(message.slashingPkScript); + } + if (message.minSlashingTxFeeSat !== 0) { + writer.uint32(64).int64(message.minSlashingTxFeeSat); } if (message.slashingRate !== "") { - writer.uint32(50).string(message.slashingRate); + writer.uint32(74).string(message.slashingRate); } - if (message.maxActiveFinalityProviders !== 0) { - writer.uint32(56).uint32(message.maxActiveFinalityProviders); + if (message.minUnbondingTimeBlocks !== 0) { + writer.uint32(80).uint32(message.minUnbondingTimeBlocks); } - if (message.minUnbondingTime !== 0) { - writer.uint32(64).uint32(message.minUnbondingTime); + if (message.unbondingFeeSat !== 0) { + writer.uint32(88).int64(message.unbondingFeeSat); } - if (message.minUnbondingRate !== "") { - writer.uint32(74).string(message.minUnbondingRate); + if (message.minCommissionRate !== "") { + writer.uint32(98).string(message.minCommissionRate); + } + if (message.maxActiveFinalityProviders !== 0) { + writer.uint32(104).uint32(message.maxActiveFinalityProviders); + } + if (message.delegationCreationBaseGasFee !== 0) { + writer.uint32(112).uint64(message.delegationCreationBaseGasFee); } return writer; }, @@ -132,53 +167,88 @@ export const Params: MessageFns = { message.covenantQuorum = reader.uint32(); continue; case 3: - if (tag !== 26) { + if (tag !== 24) { break; } - message.slashingAddress = reader.string(); + message.minStakingValueSat = longToNumber(reader.int64()); continue; case 4: if (tag !== 32) { break; } - message.minSlashingTxFeeSat = longToNumber(reader.int64()); + message.maxStakingValueSat = longToNumber(reader.int64()); continue; case 5: - if (tag !== 42) { + if (tag !== 40) { break; } - message.minCommissionRate = reader.string(); + message.minStakingTimeBlocks = reader.uint32(); continue; case 6: - if (tag !== 50) { + if (tag !== 48) { break; } - message.slashingRate = reader.string(); + message.maxStakingTimeBlocks = reader.uint32(); continue; case 7: - if (tag !== 56) { + if (tag !== 58) { break; } - message.maxActiveFinalityProviders = reader.uint32(); + message.slashingPkScript = reader.bytes(); continue; case 8: if (tag !== 64) { break; } - message.minUnbondingTime = reader.uint32(); + message.minSlashingTxFeeSat = longToNumber(reader.int64()); continue; case 9: if (tag !== 74) { break; } - message.minUnbondingRate = reader.string(); + message.slashingRate = reader.string(); + continue; + case 10: + if (tag !== 80) { + break; + } + + message.minUnbondingTimeBlocks = reader.uint32(); + continue; + case 11: + if (tag !== 88) { + break; + } + + message.unbondingFeeSat = longToNumber(reader.int64()); + continue; + case 12: + if (tag !== 98) { + break; + } + + message.minCommissionRate = reader.string(); + continue; + case 13: + if (tag !== 104) { + break; + } + + message.maxActiveFinalityProviders = reader.uint32(); + continue; + case 14: + if (tag !== 112) { + break; + } + + message.delegationCreationBaseGasFee = longToNumber(reader.uint64()); continue; } if ((tag & 7) === 4 || tag === 0) { @@ -195,15 +265,24 @@ export const Params: MessageFns = { ? object.covenantPks.map((e: any) => bytesFromBase64(e)) : [], covenantQuorum: isSet(object.covenantQuorum) ? globalThis.Number(object.covenantQuorum) : 0, - slashingAddress: isSet(object.slashingAddress) ? globalThis.String(object.slashingAddress) : "", + minStakingValueSat: isSet(object.minStakingValueSat) ? globalThis.Number(object.minStakingValueSat) : 0, + maxStakingValueSat: isSet(object.maxStakingValueSat) ? globalThis.Number(object.maxStakingValueSat) : 0, + minStakingTimeBlocks: isSet(object.minStakingTimeBlocks) ? globalThis.Number(object.minStakingTimeBlocks) : 0, + maxStakingTimeBlocks: isSet(object.maxStakingTimeBlocks) ? globalThis.Number(object.maxStakingTimeBlocks) : 0, + slashingPkScript: isSet(object.slashingPkScript) ? bytesFromBase64(object.slashingPkScript) : new Uint8Array(0), minSlashingTxFeeSat: isSet(object.minSlashingTxFeeSat) ? globalThis.Number(object.minSlashingTxFeeSat) : 0, - minCommissionRate: isSet(object.minCommissionRate) ? globalThis.String(object.minCommissionRate) : "", slashingRate: isSet(object.slashingRate) ? globalThis.String(object.slashingRate) : "", + minUnbondingTimeBlocks: isSet(object.minUnbondingTimeBlocks) + ? globalThis.Number(object.minUnbondingTimeBlocks) + : 0, + unbondingFeeSat: isSet(object.unbondingFeeSat) ? globalThis.Number(object.unbondingFeeSat) : 0, + minCommissionRate: isSet(object.minCommissionRate) ? globalThis.String(object.minCommissionRate) : "", maxActiveFinalityProviders: isSet(object.maxActiveFinalityProviders) ? globalThis.Number(object.maxActiveFinalityProviders) : 0, - minUnbondingTime: isSet(object.minUnbondingTime) ? globalThis.Number(object.minUnbondingTime) : 0, - minUnbondingRate: isSet(object.minUnbondingRate) ? globalThis.String(object.minUnbondingRate) : "", + delegationCreationBaseGasFee: isSet(object.delegationCreationBaseGasFee) + ? globalThis.Number(object.delegationCreationBaseGasFee) + : 0, }; }, @@ -215,26 +294,41 @@ export const Params: MessageFns = { if (message.covenantQuorum !== 0) { obj.covenantQuorum = Math.round(message.covenantQuorum); } - if (message.slashingAddress !== "") { - obj.slashingAddress = message.slashingAddress; + if (message.minStakingValueSat !== 0) { + obj.minStakingValueSat = Math.round(message.minStakingValueSat); + } + if (message.maxStakingValueSat !== 0) { + obj.maxStakingValueSat = Math.round(message.maxStakingValueSat); + } + if (message.minStakingTimeBlocks !== 0) { + obj.minStakingTimeBlocks = Math.round(message.minStakingTimeBlocks); + } + if (message.maxStakingTimeBlocks !== 0) { + obj.maxStakingTimeBlocks = Math.round(message.maxStakingTimeBlocks); + } + if (message.slashingPkScript.length !== 0) { + obj.slashingPkScript = base64FromBytes(message.slashingPkScript); } if (message.minSlashingTxFeeSat !== 0) { obj.minSlashingTxFeeSat = Math.round(message.minSlashingTxFeeSat); } - if (message.minCommissionRate !== "") { - obj.minCommissionRate = message.minCommissionRate; - } if (message.slashingRate !== "") { obj.slashingRate = message.slashingRate; } + if (message.minUnbondingTimeBlocks !== 0) { + obj.minUnbondingTimeBlocks = Math.round(message.minUnbondingTimeBlocks); + } + if (message.unbondingFeeSat !== 0) { + obj.unbondingFeeSat = Math.round(message.unbondingFeeSat); + } + if (message.minCommissionRate !== "") { + obj.minCommissionRate = message.minCommissionRate; + } if (message.maxActiveFinalityProviders !== 0) { obj.maxActiveFinalityProviders = Math.round(message.maxActiveFinalityProviders); } - if (message.minUnbondingTime !== 0) { - obj.minUnbondingTime = Math.round(message.minUnbondingTime); - } - if (message.minUnbondingRate !== "") { - obj.minUnbondingRate = message.minUnbondingRate; + if (message.delegationCreationBaseGasFee !== 0) { + obj.delegationCreationBaseGasFee = Math.round(message.delegationCreationBaseGasFee); } return obj; }, @@ -246,13 +340,18 @@ export const Params: MessageFns = { const message = createBaseParams(); message.covenantPks = object.covenantPks?.map((e) => e) || []; message.covenantQuorum = object.covenantQuorum ?? 0; - message.slashingAddress = object.slashingAddress ?? ""; + message.minStakingValueSat = object.minStakingValueSat ?? 0; + message.maxStakingValueSat = object.maxStakingValueSat ?? 0; + message.minStakingTimeBlocks = object.minStakingTimeBlocks ?? 0; + message.maxStakingTimeBlocks = object.maxStakingTimeBlocks ?? 0; + message.slashingPkScript = object.slashingPkScript ?? new Uint8Array(0); message.minSlashingTxFeeSat = object.minSlashingTxFeeSat ?? 0; - message.minCommissionRate = object.minCommissionRate ?? ""; message.slashingRate = object.slashingRate ?? ""; + message.minUnbondingTimeBlocks = object.minUnbondingTimeBlocks ?? 0; + message.unbondingFeeSat = object.unbondingFeeSat ?? 0; + message.minCommissionRate = object.minCommissionRate ?? ""; message.maxActiveFinalityProviders = object.maxActiveFinalityProviders ?? 0; - message.minUnbondingTime = object.minUnbondingTime ?? 0; - message.minUnbondingRate = object.minUnbondingRate ?? ""; + message.delegationCreationBaseGasFee = object.delegationCreationBaseGasFee ?? 0; return message; }, }; diff --git a/src/generated/babylon/btcstaking/v1/query.ts b/src/generated/babylon/btcstaking/v1/query.ts index 5777622..dc3f3ef 100644 --- a/src/generated/babylon/btcstaking/v1/query.ts +++ b/src/generated/babylon/btcstaking/v1/query.ts @@ -13,7 +13,6 @@ import { bTCDelegationStatusFromJSON, bTCDelegationStatusToJSON, CovenantAdaptorSignatures, - FinalityProviderWithMeta, SignatureInfo, } from "./btcstaking"; import { Params } from "./params"; @@ -155,13 +154,40 @@ export interface QueryActiveFinalityProvidersAtHeightRequest { pagination: PageRequest | undefined; } +/** ActiveFinalityProvidersAtHeightResponse wraps the FinalityProvider with metadata. */ +export interface ActiveFinalityProvidersAtHeightResponse { + /** + * btc_pk is the Bitcoin secp256k1 PK of thisfinality provider + * the PK follows encoding in BIP-340 spec + */ + btcPkHex: string; + /** height is the queried Babylon height */ + height: number; + /** voting_power is the voting power of this finality provider at the given height */ + votingPower: number; + /** + * slashed_babylon_height indicates the Babylon height when + * the finality provider is slashed. + * if it's 0 then the finality provider is not slashed + */ + slashedBabylonHeight: number; + /** + * slashed_btc_height indicates the BTC height when + * the finality provider is slashed. + * if it's 0 then the finality provider is not slashed + */ + slashedBtcHeight: number; + /** jailed defines whether the finality provider is detected jailed */ + jailed: boolean; +} + /** * QueryActiveFinalityProvidersAtHeightResponse is the response type for the * Query/ActiveFinalityProvidersAtHeight RPC method. */ export interface QueryActiveFinalityProvidersAtHeightResponse { /** finality_providers contains all the queried finality providersn. */ - finalityProviders: FinalityProviderWithMeta[]; + finalityProviders: ActiveFinalityProvidersAtHeightResponse[]; /** pagination defines the pagination in the response. */ pagination: PageResponse | undefined; } @@ -233,6 +259,8 @@ export interface BTCDelegationResponse { * this BTC delegation delegates to */ fpBtcPkList: Uint8Array[]; + /** staking_time is the number of blocks for which the delegation is locked on BTC chain */ + stakingTime: number; /** * start_height is the start BTC height of the BTC delegation * it is the start BTC height of the timelock @@ -283,6 +311,18 @@ export interface BTCDelegationResponse { paramsVersion: number; } +/** + * DelegatorUnbondingInfoResponse provides all necessary info about transaction + * which spent the staking output + */ +export interface DelegatorUnbondingInfoResponse { + /** + * spend_stake_tx_hex is the transaction which spent the staking output. It is + * filled only if the spend_stake_tx_hex is different than the unbonding_tx_hex + */ + spendStakeTxHex: string; +} + /** BTCUndelegationResponse provides all necessary info about the undeleagation */ export interface BTCUndelegationResponse { /** @@ -291,14 +331,6 @@ export interface BTCUndelegationResponse { * than staking output. The unbonding tx as string hex. */ unbondingTxHex: string; - /** - * delegator_unbonding_sig is the signature on the unbonding tx - * by the delegator (i.e., SK corresponding to btc_pk). - * It effectively proves that the delegator wants to unbond and thus - * Babylon will consider this BTC delegation unbonded. Delegator's BTC - * on Bitcoin will be unbonded after timelock. The unbonding delegator sig as string hex. - */ - delegatorUnbondingSigHex: string; /** * covenant_unbonding_sig_list is the list of signatures on the unbonding tx * by covenant members @@ -319,6 +351,11 @@ export interface BTCUndelegationResponse { * It will be a part of the witness for the staking tx output. */ covenantSlashingSigs: CovenantAdaptorSignatures[]; + /** + * btc_undelegation_info contains all necessary info about the transaction + * which spent the staking output + */ + delegatorUnbondingInfoResponse: DelegatorUnbondingInfoResponse | undefined; } /** BTCDelegatorDelegationsResponse is a collection of BTC delegations responses from the same delegator. */ @@ -364,8 +401,8 @@ export interface FinalityProviderResponse { height: number; /** voting_power is the voting power of this finality provider at the given height */ votingPower: number; - /** sluggish defines whether the finality provider is detected sluggish */ - sluggish: boolean; + /** jailed defines whether the finality provider is jailed */ + jailed: boolean; } function createBaseQueryParamsRequest(): QueryParamsRequest { @@ -1364,6 +1401,144 @@ export const QueryActiveFinalityProvidersAtHeightRequest: MessageFns = { + encode(message: ActiveFinalityProvidersAtHeightResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.btcPkHex !== "") { + writer.uint32(10).string(message.btcPkHex); + } + if (message.height !== 0) { + writer.uint32(16).uint64(message.height); + } + if (message.votingPower !== 0) { + writer.uint32(24).uint64(message.votingPower); + } + if (message.slashedBabylonHeight !== 0) { + writer.uint32(32).uint64(message.slashedBabylonHeight); + } + if (message.slashedBtcHeight !== 0) { + writer.uint32(40).uint32(message.slashedBtcHeight); + } + if (message.jailed !== false) { + writer.uint32(48).bool(message.jailed); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): ActiveFinalityProvidersAtHeightResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseActiveFinalityProvidersAtHeightResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.btcPkHex = reader.string(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.height = longToNumber(reader.uint64()); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.votingPower = longToNumber(reader.uint64()); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.slashedBabylonHeight = longToNumber(reader.uint64()); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.slashedBtcHeight = reader.uint32(); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.jailed = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): ActiveFinalityProvidersAtHeightResponse { + return { + btcPkHex: isSet(object.btcPkHex) ? globalThis.String(object.btcPkHex) : "", + height: isSet(object.height) ? globalThis.Number(object.height) : 0, + votingPower: isSet(object.votingPower) ? globalThis.Number(object.votingPower) : 0, + slashedBabylonHeight: isSet(object.slashedBabylonHeight) ? globalThis.Number(object.slashedBabylonHeight) : 0, + slashedBtcHeight: isSet(object.slashedBtcHeight) ? globalThis.Number(object.slashedBtcHeight) : 0, + jailed: isSet(object.jailed) ? globalThis.Boolean(object.jailed) : false, + }; + }, + + toJSON(message: ActiveFinalityProvidersAtHeightResponse): unknown { + const obj: any = {}; + if (message.btcPkHex !== "") { + obj.btcPkHex = message.btcPkHex; + } + if (message.height !== 0) { + obj.height = Math.round(message.height); + } + if (message.votingPower !== 0) { + obj.votingPower = Math.round(message.votingPower); + } + if (message.slashedBabylonHeight !== 0) { + obj.slashedBabylonHeight = Math.round(message.slashedBabylonHeight); + } + if (message.slashedBtcHeight !== 0) { + obj.slashedBtcHeight = Math.round(message.slashedBtcHeight); + } + if (message.jailed !== false) { + obj.jailed = message.jailed; + } + return obj; + }, + + create, I>>( + base?: I, + ): ActiveFinalityProvidersAtHeightResponse { + return ActiveFinalityProvidersAtHeightResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): ActiveFinalityProvidersAtHeightResponse { + const message = createBaseActiveFinalityProvidersAtHeightResponse(); + message.btcPkHex = object.btcPkHex ?? ""; + message.height = object.height ?? 0; + message.votingPower = object.votingPower ?? 0; + message.slashedBabylonHeight = object.slashedBabylonHeight ?? 0; + message.slashedBtcHeight = object.slashedBtcHeight ?? 0; + message.jailed = object.jailed ?? false; + return message; + }, +}; + function createBaseQueryActiveFinalityProvidersAtHeightResponse(): QueryActiveFinalityProvidersAtHeightResponse { return { finalityProviders: [], pagination: undefined }; } @@ -1374,7 +1549,7 @@ export const QueryActiveFinalityProvidersAtHeightResponse: MessageFns FinalityProviderWithMeta.fromJSON(e)) + ? object.finalityProviders.map((e: any) => ActiveFinalityProvidersAtHeightResponse.fromJSON(e)) : [], pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, }; @@ -1424,7 +1599,7 @@ export const QueryActiveFinalityProvidersAtHeightResponse: MessageFns FinalityProviderWithMeta.toJSON(e)); + obj.finalityProviders = message.finalityProviders.map((e) => ActiveFinalityProvidersAtHeightResponse.toJSON(e)); } if (message.pagination !== undefined) { obj.pagination = PageResponse.toJSON(message.pagination); @@ -1441,7 +1616,8 @@ export const QueryActiveFinalityProvidersAtHeightResponse: MessageFns FinalityProviderWithMeta.fromPartial(e)) || []; + message.finalityProviders = + object.finalityProviders?.map((e) => ActiveFinalityProvidersAtHeightResponse.fromPartial(e)) || []; message.pagination = (object.pagination !== undefined && object.pagination !== null) ? PageResponse.fromPartial(object.pagination) : undefined; @@ -1837,6 +2013,7 @@ function createBaseBTCDelegationResponse(): BTCDelegationResponse { stakerAddr: "", btcPk: new Uint8Array(0), fpBtcPkList: [], + stakingTime: 0, startHeight: 0, endHeight: 0, totalSat: 0, @@ -1864,44 +2041,47 @@ export const BTCDelegationResponse: MessageFns = { for (const v of message.fpBtcPkList) { writer.uint32(26).bytes(v!); } + if (message.stakingTime !== 0) { + writer.uint32(32).uint32(message.stakingTime); + } if (message.startHeight !== 0) { - writer.uint32(32).uint64(message.startHeight); + writer.uint32(40).uint32(message.startHeight); } if (message.endHeight !== 0) { - writer.uint32(40).uint64(message.endHeight); + writer.uint32(48).uint32(message.endHeight); } if (message.totalSat !== 0) { - writer.uint32(48).uint64(message.totalSat); + writer.uint32(56).uint64(message.totalSat); } if (message.stakingTxHex !== "") { - writer.uint32(58).string(message.stakingTxHex); + writer.uint32(66).string(message.stakingTxHex); } if (message.slashingTxHex !== "") { - writer.uint32(66).string(message.slashingTxHex); + writer.uint32(74).string(message.slashingTxHex); } if (message.delegatorSlashSigHex !== "") { - writer.uint32(74).string(message.delegatorSlashSigHex); + writer.uint32(82).string(message.delegatorSlashSigHex); } for (const v of message.covenantSigs) { - CovenantAdaptorSignatures.encode(v!, writer.uint32(82).fork()).join(); + CovenantAdaptorSignatures.encode(v!, writer.uint32(90).fork()).join(); } if (message.stakingOutputIdx !== 0) { - writer.uint32(88).uint32(message.stakingOutputIdx); + writer.uint32(96).uint32(message.stakingOutputIdx); } if (message.active !== false) { - writer.uint32(96).bool(message.active); + writer.uint32(104).bool(message.active); } if (message.statusDesc !== "") { - writer.uint32(106).string(message.statusDesc); + writer.uint32(114).string(message.statusDesc); } if (message.unbondingTime !== 0) { - writer.uint32(112).uint32(message.unbondingTime); + writer.uint32(120).uint32(message.unbondingTime); } if (message.undelegationResponse !== undefined) { - BTCUndelegationResponse.encode(message.undelegationResponse, writer.uint32(122).fork()).join(); + BTCUndelegationResponse.encode(message.undelegationResponse, writer.uint32(130).fork()).join(); } if (message.paramsVersion !== 0) { - writer.uint32(128).uint32(message.paramsVersion); + writer.uint32(136).uint32(message.paramsVersion); } return writer; }, @@ -1939,87 +2119,94 @@ export const BTCDelegationResponse: MessageFns = { break; } - message.startHeight = longToNumber(reader.uint64()); + message.stakingTime = reader.uint32(); continue; case 5: if (tag !== 40) { break; } - message.endHeight = longToNumber(reader.uint64()); + message.startHeight = reader.uint32(); continue; case 6: if (tag !== 48) { break; } - message.totalSat = longToNumber(reader.uint64()); + message.endHeight = reader.uint32(); continue; case 7: - if (tag !== 58) { + if (tag !== 56) { break; } - message.stakingTxHex = reader.string(); + message.totalSat = longToNumber(reader.uint64()); continue; case 8: if (tag !== 66) { break; } - message.slashingTxHex = reader.string(); + message.stakingTxHex = reader.string(); continue; case 9: if (tag !== 74) { break; } - message.delegatorSlashSigHex = reader.string(); + message.slashingTxHex = reader.string(); continue; case 10: if (tag !== 82) { break; } - message.covenantSigs.push(CovenantAdaptorSignatures.decode(reader, reader.uint32())); + message.delegatorSlashSigHex = reader.string(); continue; case 11: - if (tag !== 88) { + if (tag !== 90) { break; } - message.stakingOutputIdx = reader.uint32(); + message.covenantSigs.push(CovenantAdaptorSignatures.decode(reader, reader.uint32())); continue; case 12: if (tag !== 96) { break; } - message.active = reader.bool(); + message.stakingOutputIdx = reader.uint32(); continue; case 13: - if (tag !== 106) { + if (tag !== 104) { break; } - message.statusDesc = reader.string(); + message.active = reader.bool(); continue; case 14: - if (tag !== 112) { + if (tag !== 114) { break; } - message.unbondingTime = reader.uint32(); + message.statusDesc = reader.string(); continue; case 15: - if (tag !== 122) { + if (tag !== 120) { break; } - message.undelegationResponse = BTCUndelegationResponse.decode(reader, reader.uint32()); + message.unbondingTime = reader.uint32(); continue; case 16: - if (tag !== 128) { + if (tag !== 130) { + break; + } + + message.undelegationResponse = BTCUndelegationResponse.decode(reader, reader.uint32()); + continue; + case 17: + if (tag !== 136) { break; } @@ -2041,6 +2228,7 @@ export const BTCDelegationResponse: MessageFns = { fpBtcPkList: globalThis.Array.isArray(object?.fpBtcPkList) ? object.fpBtcPkList.map((e: any) => bytesFromBase64(e)) : [], + stakingTime: isSet(object.stakingTime) ? globalThis.Number(object.stakingTime) : 0, startHeight: isSet(object.startHeight) ? globalThis.Number(object.startHeight) : 0, endHeight: isSet(object.endHeight) ? globalThis.Number(object.endHeight) : 0, totalSat: isSet(object.totalSat) ? globalThis.Number(object.totalSat) : 0, @@ -2072,6 +2260,9 @@ export const BTCDelegationResponse: MessageFns = { if (message.fpBtcPkList?.length) { obj.fpBtcPkList = message.fpBtcPkList.map((e) => base64FromBytes(e)); } + if (message.stakingTime !== 0) { + obj.stakingTime = Math.round(message.stakingTime); + } if (message.startHeight !== 0) { obj.startHeight = Math.round(message.startHeight); } @@ -2122,6 +2313,7 @@ export const BTCDelegationResponse: MessageFns = { message.stakerAddr = object.stakerAddr ?? ""; message.btcPk = object.btcPk ?? new Uint8Array(0); message.fpBtcPkList = object.fpBtcPkList?.map((e) => e) || []; + message.stakingTime = object.stakingTime ?? 0; message.startHeight = object.startHeight ?? 0; message.endHeight = object.endHeight ?? 0; message.totalSat = object.totalSat ?? 0; @@ -2141,14 +2333,73 @@ export const BTCDelegationResponse: MessageFns = { }, }; +function createBaseDelegatorUnbondingInfoResponse(): DelegatorUnbondingInfoResponse { + return { spendStakeTxHex: "" }; +} + +export const DelegatorUnbondingInfoResponse: MessageFns = { + encode(message: DelegatorUnbondingInfoResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.spendStakeTxHex !== "") { + writer.uint32(10).string(message.spendStakeTxHex); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): DelegatorUnbondingInfoResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDelegatorUnbondingInfoResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.spendStakeTxHex = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): DelegatorUnbondingInfoResponse { + return { spendStakeTxHex: isSet(object.spendStakeTxHex) ? globalThis.String(object.spendStakeTxHex) : "" }; + }, + + toJSON(message: DelegatorUnbondingInfoResponse): unknown { + const obj: any = {}; + if (message.spendStakeTxHex !== "") { + obj.spendStakeTxHex = message.spendStakeTxHex; + } + return obj; + }, + + create, I>>(base?: I): DelegatorUnbondingInfoResponse { + return DelegatorUnbondingInfoResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): DelegatorUnbondingInfoResponse { + const message = createBaseDelegatorUnbondingInfoResponse(); + message.spendStakeTxHex = object.spendStakeTxHex ?? ""; + return message; + }, +}; + function createBaseBTCUndelegationResponse(): BTCUndelegationResponse { return { unbondingTxHex: "", - delegatorUnbondingSigHex: "", covenantUnbondingSigList: [], slashingTxHex: "", delegatorSlashingSigHex: "", covenantSlashingSigs: [], + delegatorUnbondingInfoResponse: undefined, }; } @@ -2157,20 +2408,20 @@ export const BTCUndelegationResponse: MessageFns = { if (message.unbondingTxHex !== "") { writer.uint32(10).string(message.unbondingTxHex); } - if (message.delegatorUnbondingSigHex !== "") { - writer.uint32(18).string(message.delegatorUnbondingSigHex); - } for (const v of message.covenantUnbondingSigList) { - SignatureInfo.encode(v!, writer.uint32(26).fork()).join(); + SignatureInfo.encode(v!, writer.uint32(18).fork()).join(); } if (message.slashingTxHex !== "") { - writer.uint32(34).string(message.slashingTxHex); + writer.uint32(26).string(message.slashingTxHex); } if (message.delegatorSlashingSigHex !== "") { - writer.uint32(42).string(message.delegatorSlashingSigHex); + writer.uint32(34).string(message.delegatorSlashingSigHex); } for (const v of message.covenantSlashingSigs) { - CovenantAdaptorSignatures.encode(v!, writer.uint32(50).fork()).join(); + CovenantAdaptorSignatures.encode(v!, writer.uint32(42).fork()).join(); + } + if (message.delegatorUnbondingInfoResponse !== undefined) { + DelegatorUnbondingInfoResponse.encode(message.delegatorUnbondingInfoResponse, writer.uint32(50).fork()).join(); } return writer; }, @@ -2194,35 +2445,35 @@ export const BTCUndelegationResponse: MessageFns = { break; } - message.delegatorUnbondingSigHex = reader.string(); + message.covenantUnbondingSigList.push(SignatureInfo.decode(reader, reader.uint32())); continue; case 3: if (tag !== 26) { break; } - message.covenantUnbondingSigList.push(SignatureInfo.decode(reader, reader.uint32())); + message.slashingTxHex = reader.string(); continue; case 4: if (tag !== 34) { break; } - message.slashingTxHex = reader.string(); + message.delegatorSlashingSigHex = reader.string(); continue; case 5: if (tag !== 42) { break; } - message.delegatorSlashingSigHex = reader.string(); + message.covenantSlashingSigs.push(CovenantAdaptorSignatures.decode(reader, reader.uint32())); continue; case 6: if (tag !== 50) { break; } - message.covenantSlashingSigs.push(CovenantAdaptorSignatures.decode(reader, reader.uint32())); + message.delegatorUnbondingInfoResponse = DelegatorUnbondingInfoResponse.decode(reader, reader.uint32()); continue; } if ((tag & 7) === 4 || tag === 0) { @@ -2236,9 +2487,6 @@ export const BTCUndelegationResponse: MessageFns = { fromJSON(object: any): BTCUndelegationResponse { return { unbondingTxHex: isSet(object.unbondingTxHex) ? globalThis.String(object.unbondingTxHex) : "", - delegatorUnbondingSigHex: isSet(object.delegatorUnbondingSigHex) - ? globalThis.String(object.delegatorUnbondingSigHex) - : "", covenantUnbondingSigList: globalThis.Array.isArray(object?.covenantUnbondingSigList) ? object.covenantUnbondingSigList.map((e: any) => SignatureInfo.fromJSON(e)) : [], @@ -2249,6 +2497,9 @@ export const BTCUndelegationResponse: MessageFns = { covenantSlashingSigs: globalThis.Array.isArray(object?.covenantSlashingSigs) ? object.covenantSlashingSigs.map((e: any) => CovenantAdaptorSignatures.fromJSON(e)) : [], + delegatorUnbondingInfoResponse: isSet(object.delegatorUnbondingInfoResponse) + ? DelegatorUnbondingInfoResponse.fromJSON(object.delegatorUnbondingInfoResponse) + : undefined, }; }, @@ -2257,9 +2508,6 @@ export const BTCUndelegationResponse: MessageFns = { if (message.unbondingTxHex !== "") { obj.unbondingTxHex = message.unbondingTxHex; } - if (message.delegatorUnbondingSigHex !== "") { - obj.delegatorUnbondingSigHex = message.delegatorUnbondingSigHex; - } if (message.covenantUnbondingSigList?.length) { obj.covenantUnbondingSigList = message.covenantUnbondingSigList.map((e) => SignatureInfo.toJSON(e)); } @@ -2272,6 +2520,11 @@ export const BTCUndelegationResponse: MessageFns = { if (message.covenantSlashingSigs?.length) { obj.covenantSlashingSigs = message.covenantSlashingSigs.map((e) => CovenantAdaptorSignatures.toJSON(e)); } + if (message.delegatorUnbondingInfoResponse !== undefined) { + obj.delegatorUnbondingInfoResponse = DelegatorUnbondingInfoResponse.toJSON( + message.delegatorUnbondingInfoResponse, + ); + } return obj; }, @@ -2281,12 +2534,15 @@ export const BTCUndelegationResponse: MessageFns = { fromPartial, I>>(object: I): BTCUndelegationResponse { const message = createBaseBTCUndelegationResponse(); message.unbondingTxHex = object.unbondingTxHex ?? ""; - message.delegatorUnbondingSigHex = object.delegatorUnbondingSigHex ?? ""; message.covenantUnbondingSigList = object.covenantUnbondingSigList?.map((e) => SignatureInfo.fromPartial(e)) || []; message.slashingTxHex = object.slashingTxHex ?? ""; message.delegatorSlashingSigHex = object.delegatorSlashingSigHex ?? ""; message.covenantSlashingSigs = object.covenantSlashingSigs?.map((e) => CovenantAdaptorSignatures.fromPartial(e)) || []; + message.delegatorUnbondingInfoResponse = + (object.delegatorUnbondingInfoResponse !== undefined && object.delegatorUnbondingInfoResponse !== null) + ? DelegatorUnbondingInfoResponse.fromPartial(object.delegatorUnbondingInfoResponse) + : undefined; return message; }, }; @@ -2365,7 +2621,7 @@ function createBaseFinalityProviderResponse(): FinalityProviderResponse { slashedBtcHeight: 0, height: 0, votingPower: 0, - sluggish: false, + jailed: false, }; } @@ -2390,7 +2646,7 @@ export const FinalityProviderResponse: MessageFns = { writer.uint32(48).uint64(message.slashedBabylonHeight); } if (message.slashedBtcHeight !== 0) { - writer.uint32(56).uint64(message.slashedBtcHeight); + writer.uint32(56).uint32(message.slashedBtcHeight); } if (message.height !== 0) { writer.uint32(64).uint64(message.height); @@ -2398,8 +2654,8 @@ export const FinalityProviderResponse: MessageFns = { if (message.votingPower !== 0) { writer.uint32(72).uint64(message.votingPower); } - if (message.sluggish !== false) { - writer.uint32(80).bool(message.sluggish); + if (message.jailed !== false) { + writer.uint32(80).bool(message.jailed); } return writer; }, @@ -2458,7 +2714,7 @@ export const FinalityProviderResponse: MessageFns = { break; } - message.slashedBtcHeight = longToNumber(reader.uint64()); + message.slashedBtcHeight = reader.uint32(); continue; case 8: if (tag !== 64) { @@ -2479,7 +2735,7 @@ export const FinalityProviderResponse: MessageFns = { break; } - message.sluggish = reader.bool(); + message.jailed = reader.bool(); continue; } if ((tag & 7) === 4 || tag === 0) { @@ -2501,7 +2757,7 @@ export const FinalityProviderResponse: MessageFns = { slashedBtcHeight: isSet(object.slashedBtcHeight) ? globalThis.Number(object.slashedBtcHeight) : 0, height: isSet(object.height) ? globalThis.Number(object.height) : 0, votingPower: isSet(object.votingPower) ? globalThis.Number(object.votingPower) : 0, - sluggish: isSet(object.sluggish) ? globalThis.Boolean(object.sluggish) : false, + jailed: isSet(object.jailed) ? globalThis.Boolean(object.jailed) : false, }; }, @@ -2534,8 +2790,8 @@ export const FinalityProviderResponse: MessageFns = { if (message.votingPower !== 0) { obj.votingPower = Math.round(message.votingPower); } - if (message.sluggish !== false) { - obj.sluggish = message.sluggish; + if (message.jailed !== false) { + obj.jailed = message.jailed; } return obj; }, @@ -2558,7 +2814,7 @@ export const FinalityProviderResponse: MessageFns = { message.slashedBtcHeight = object.slashedBtcHeight ?? 0; message.height = object.height ?? 0; message.votingPower = object.votingPower ?? 0; - message.sluggish = object.sluggish ?? false; + message.jailed = object.jailed ?? false; return message; }, }; diff --git a/src/generated/babylon/btcstaking/v1/tx.ts b/src/generated/babylon/btcstaking/v1/tx.ts index b599df4..f0a336c 100644 --- a/src/generated/babylon/btcstaking/v1/tx.ts +++ b/src/generated/babylon/btcstaking/v1/tx.ts @@ -7,7 +7,7 @@ /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; import { Description } from "../../../cosmos/staking/v1beta1/staking"; -import { TransactionInfo } from "../../btccheckpoint/v1/btccheckpoint"; +import { InclusionProof } from "./btcstaking"; import { Params } from "./params"; import { ProofOfPossessionBTC } from "./pop"; @@ -76,9 +76,11 @@ export interface MsgCreateBTCDelegation { stakingTime: number; /** staking_value is the amount of satoshis locked in staking output */ stakingValue: number; - /** staking_tx is the staking tx along with the merkle proof of inclusion in btc block */ - stakingTx: - | TransactionInfo + /** staking_tx is a bitcoin staking transaction i.e transaction that locks funds */ + stakingTx: Uint8Array; + /** staking_tx_inclusion_proof is the inclusion proof of the staking tx in BTC chain */ + stakingTxInclusionProof: + | InclusionProof | undefined; /** * slashing_tx is the slashing tx @@ -124,6 +126,22 @@ export interface MsgCreateBTCDelegation { export interface MsgCreateBTCDelegationResponse { } +/** MsgAddBTCDelegationInclusionProof is the message for adding proof of inclusion of BTC delegation on BTC chain */ +export interface MsgAddBTCDelegationInclusionProof { + signer: string; + /** + * staking_tx_hash is the hash of the staking tx. + * It uniquely identifies a BTC delegation + */ + stakingTxHash: string; + /** staking_tx_inclusion_proof is the inclusion proof of the staking tx in BTC chain */ + stakingTxInclusionProof: InclusionProof | undefined; +} + +/** MsgAddBTCDelegationInclusionProofResponse is the response for MsgAddBTCDelegationInclusionProof */ +export interface MsgAddBTCDelegationInclusionProofResponse { +} + /** MsgAddCovenantSigs is the message for handling signatures from a covenant member */ export interface MsgAddCovenantSigs { signer: string; @@ -171,10 +189,15 @@ export interface MsgBTCUndelegate { */ stakingTxHash: string; /** - * unbonding_tx_sig is the signature of the staker on the unbonding tx submitted to babylon - * the signature follows encoding in BIP-340 spec + * stake_spending_tx is a bitcoin transaction that spends the staking transaction + * i.e it has staking output as an input */ - unbondingTxSig: Uint8Array; + stakeSpendingTx: Uint8Array; + /** + * spend_spending_tx_inclusion_proof is the proof of inclusion of the + * stake_spending_tx in the BTC chain + */ + stakeSpendingTxInclusionProof: InclusionProof | undefined; } /** MsgBTCUndelegateResponse is the response for MsgBTCUndelegate */ @@ -553,7 +576,8 @@ function createBaseMsgCreateBTCDelegation(): MsgCreateBTCDelegation { fpBtcPkList: [], stakingTime: 0, stakingValue: 0, - stakingTx: undefined, + stakingTx: new Uint8Array(0), + stakingTxInclusionProof: undefined, slashingTx: new Uint8Array(0), delegatorSlashingSig: new Uint8Array(0), unbondingTime: 0, @@ -584,29 +608,32 @@ export const MsgCreateBTCDelegation: MessageFns = { if (message.stakingValue !== 0) { writer.uint32(48).int64(message.stakingValue); } - if (message.stakingTx !== undefined) { - TransactionInfo.encode(message.stakingTx, writer.uint32(58).fork()).join(); + if (message.stakingTx.length !== 0) { + writer.uint32(58).bytes(message.stakingTx); + } + if (message.stakingTxInclusionProof !== undefined) { + InclusionProof.encode(message.stakingTxInclusionProof, writer.uint32(66).fork()).join(); } if (message.slashingTx.length !== 0) { - writer.uint32(66).bytes(message.slashingTx); + writer.uint32(74).bytes(message.slashingTx); } if (message.delegatorSlashingSig.length !== 0) { - writer.uint32(74).bytes(message.delegatorSlashingSig); + writer.uint32(82).bytes(message.delegatorSlashingSig); } if (message.unbondingTime !== 0) { - writer.uint32(80).uint32(message.unbondingTime); + writer.uint32(88).uint32(message.unbondingTime); } if (message.unbondingTx.length !== 0) { - writer.uint32(90).bytes(message.unbondingTx); + writer.uint32(98).bytes(message.unbondingTx); } if (message.unbondingValue !== 0) { - writer.uint32(96).int64(message.unbondingValue); + writer.uint32(104).int64(message.unbondingValue); } if (message.unbondingSlashingTx.length !== 0) { - writer.uint32(106).bytes(message.unbondingSlashingTx); + writer.uint32(114).bytes(message.unbondingSlashingTx); } if (message.delegatorUnbondingSlashingSig.length !== 0) { - writer.uint32(114).bytes(message.delegatorUnbondingSlashingSig); + writer.uint32(122).bytes(message.delegatorUnbondingSlashingSig); } return writer; }, @@ -665,55 +692,62 @@ export const MsgCreateBTCDelegation: MessageFns = { break; } - message.stakingTx = TransactionInfo.decode(reader, reader.uint32()); + message.stakingTx = reader.bytes(); continue; case 8: if (tag !== 66) { break; } - message.slashingTx = reader.bytes(); + message.stakingTxInclusionProof = InclusionProof.decode(reader, reader.uint32()); continue; case 9: if (tag !== 74) { break; } - message.delegatorSlashingSig = reader.bytes(); + message.slashingTx = reader.bytes(); continue; case 10: - if (tag !== 80) { + if (tag !== 82) { break; } - message.unbondingTime = reader.uint32(); + message.delegatorSlashingSig = reader.bytes(); continue; case 11: - if (tag !== 90) { + if (tag !== 88) { break; } - message.unbondingTx = reader.bytes(); + message.unbondingTime = reader.uint32(); continue; case 12: - if (tag !== 96) { + if (tag !== 98) { break; } - message.unbondingValue = longToNumber(reader.int64()); + message.unbondingTx = reader.bytes(); continue; case 13: - if (tag !== 106) { + if (tag !== 104) { break; } - message.unbondingSlashingTx = reader.bytes(); + message.unbondingValue = longToNumber(reader.int64()); continue; case 14: if (tag !== 114) { break; } + message.unbondingSlashingTx = reader.bytes(); + continue; + case 15: + if (tag !== 122) { + break; + } + message.delegatorUnbondingSlashingSig = reader.bytes(); continue; } @@ -735,7 +769,10 @@ export const MsgCreateBTCDelegation: MessageFns = { : [], stakingTime: isSet(object.stakingTime) ? globalThis.Number(object.stakingTime) : 0, stakingValue: isSet(object.stakingValue) ? globalThis.Number(object.stakingValue) : 0, - stakingTx: isSet(object.stakingTx) ? TransactionInfo.fromJSON(object.stakingTx) : undefined, + stakingTx: isSet(object.stakingTx) ? bytesFromBase64(object.stakingTx) : new Uint8Array(0), + stakingTxInclusionProof: isSet(object.stakingTxInclusionProof) + ? InclusionProof.fromJSON(object.stakingTxInclusionProof) + : undefined, slashingTx: isSet(object.slashingTx) ? bytesFromBase64(object.slashingTx) : new Uint8Array(0), delegatorSlashingSig: isSet(object.delegatorSlashingSig) ? bytesFromBase64(object.delegatorSlashingSig) @@ -772,8 +809,11 @@ export const MsgCreateBTCDelegation: MessageFns = { if (message.stakingValue !== 0) { obj.stakingValue = Math.round(message.stakingValue); } - if (message.stakingTx !== undefined) { - obj.stakingTx = TransactionInfo.toJSON(message.stakingTx); + if (message.stakingTx.length !== 0) { + obj.stakingTx = base64FromBytes(message.stakingTx); + } + if (message.stakingTxInclusionProof !== undefined) { + obj.stakingTxInclusionProof = InclusionProof.toJSON(message.stakingTxInclusionProof); } if (message.slashingTx.length !== 0) { obj.slashingTx = base64FromBytes(message.slashingTx); @@ -812,9 +852,11 @@ export const MsgCreateBTCDelegation: MessageFns = { message.fpBtcPkList = object.fpBtcPkList?.map((e) => e) || []; message.stakingTime = object.stakingTime ?? 0; message.stakingValue = object.stakingValue ?? 0; - message.stakingTx = (object.stakingTx !== undefined && object.stakingTx !== null) - ? TransactionInfo.fromPartial(object.stakingTx) - : undefined; + message.stakingTx = object.stakingTx ?? new Uint8Array(0); + message.stakingTxInclusionProof = + (object.stakingTxInclusionProof !== undefined && object.stakingTxInclusionProof !== null) + ? InclusionProof.fromPartial(object.stakingTxInclusionProof) + : undefined; message.slashingTx = object.slashingTx ?? new Uint8Array(0); message.delegatorSlashingSig = object.delegatorSlashingSig ?? new Uint8Array(0); message.unbondingTime = object.unbondingTime ?? 0; @@ -869,6 +911,151 @@ export const MsgCreateBTCDelegationResponse: MessageFns = { + encode(message: MsgAddBTCDelegationInclusionProof, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.signer !== "") { + writer.uint32(10).string(message.signer); + } + if (message.stakingTxHash !== "") { + writer.uint32(18).string(message.stakingTxHash); + } + if (message.stakingTxInclusionProof !== undefined) { + InclusionProof.encode(message.stakingTxInclusionProof, writer.uint32(26).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): MsgAddBTCDelegationInclusionProof { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgAddBTCDelegationInclusionProof(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.signer = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.stakingTxHash = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.stakingTxInclusionProof = InclusionProof.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): MsgAddBTCDelegationInclusionProof { + return { + signer: isSet(object.signer) ? globalThis.String(object.signer) : "", + stakingTxHash: isSet(object.stakingTxHash) ? globalThis.String(object.stakingTxHash) : "", + stakingTxInclusionProof: isSet(object.stakingTxInclusionProof) + ? InclusionProof.fromJSON(object.stakingTxInclusionProof) + : undefined, + }; + }, + + toJSON(message: MsgAddBTCDelegationInclusionProof): unknown { + const obj: any = {}; + if (message.signer !== "") { + obj.signer = message.signer; + } + if (message.stakingTxHash !== "") { + obj.stakingTxHash = message.stakingTxHash; + } + if (message.stakingTxInclusionProof !== undefined) { + obj.stakingTxInclusionProof = InclusionProof.toJSON(message.stakingTxInclusionProof); + } + return obj; + }, + + create, I>>( + base?: I, + ): MsgAddBTCDelegationInclusionProof { + return MsgAddBTCDelegationInclusionProof.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): MsgAddBTCDelegationInclusionProof { + const message = createBaseMsgAddBTCDelegationInclusionProof(); + message.signer = object.signer ?? ""; + message.stakingTxHash = object.stakingTxHash ?? ""; + message.stakingTxInclusionProof = + (object.stakingTxInclusionProof !== undefined && object.stakingTxInclusionProof !== null) + ? InclusionProof.fromPartial(object.stakingTxInclusionProof) + : undefined; + return message; + }, +}; + +function createBaseMsgAddBTCDelegationInclusionProofResponse(): MsgAddBTCDelegationInclusionProofResponse { + return {}; +} + +export const MsgAddBTCDelegationInclusionProofResponse: MessageFns = { + encode(_: MsgAddBTCDelegationInclusionProofResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): MsgAddBTCDelegationInclusionProofResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgAddBTCDelegationInclusionProofResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(_: any): MsgAddBTCDelegationInclusionProofResponse { + return {}; + }, + + toJSON(_: MsgAddBTCDelegationInclusionProofResponse): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>( + base?: I, + ): MsgAddBTCDelegationInclusionProofResponse { + return MsgAddBTCDelegationInclusionProofResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): MsgAddBTCDelegationInclusionProofResponse { + const message = createBaseMsgAddBTCDelegationInclusionProofResponse(); + return message; + }, +}; + function createBaseMsgAddCovenantSigs(): MsgAddCovenantSigs { return { signer: "", @@ -1058,7 +1245,12 @@ export const MsgAddCovenantSigsResponse: MessageFns }; function createBaseMsgBTCUndelegate(): MsgBTCUndelegate { - return { signer: "", stakingTxHash: "", unbondingTxSig: new Uint8Array(0) }; + return { + signer: "", + stakingTxHash: "", + stakeSpendingTx: new Uint8Array(0), + stakeSpendingTxInclusionProof: undefined, + }; } export const MsgBTCUndelegate: MessageFns = { @@ -1069,8 +1261,11 @@ export const MsgBTCUndelegate: MessageFns = { if (message.stakingTxHash !== "") { writer.uint32(18).string(message.stakingTxHash); } - if (message.unbondingTxSig.length !== 0) { - writer.uint32(26).bytes(message.unbondingTxSig); + if (message.stakeSpendingTx.length !== 0) { + writer.uint32(26).bytes(message.stakeSpendingTx); + } + if (message.stakeSpendingTxInclusionProof !== undefined) { + InclusionProof.encode(message.stakeSpendingTxInclusionProof, writer.uint32(34).fork()).join(); } return writer; }, @@ -1101,7 +1296,14 @@ export const MsgBTCUndelegate: MessageFns = { break; } - message.unbondingTxSig = reader.bytes(); + message.stakeSpendingTx = reader.bytes(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.stakeSpendingTxInclusionProof = InclusionProof.decode(reader, reader.uint32()); continue; } if ((tag & 7) === 4 || tag === 0) { @@ -1116,7 +1318,10 @@ export const MsgBTCUndelegate: MessageFns = { return { signer: isSet(object.signer) ? globalThis.String(object.signer) : "", stakingTxHash: isSet(object.stakingTxHash) ? globalThis.String(object.stakingTxHash) : "", - unbondingTxSig: isSet(object.unbondingTxSig) ? bytesFromBase64(object.unbondingTxSig) : new Uint8Array(0), + stakeSpendingTx: isSet(object.stakeSpendingTx) ? bytesFromBase64(object.stakeSpendingTx) : new Uint8Array(0), + stakeSpendingTxInclusionProof: isSet(object.stakeSpendingTxInclusionProof) + ? InclusionProof.fromJSON(object.stakeSpendingTxInclusionProof) + : undefined, }; }, @@ -1128,8 +1333,11 @@ export const MsgBTCUndelegate: MessageFns = { if (message.stakingTxHash !== "") { obj.stakingTxHash = message.stakingTxHash; } - if (message.unbondingTxSig.length !== 0) { - obj.unbondingTxSig = base64FromBytes(message.unbondingTxSig); + if (message.stakeSpendingTx.length !== 0) { + obj.stakeSpendingTx = base64FromBytes(message.stakeSpendingTx); + } + if (message.stakeSpendingTxInclusionProof !== undefined) { + obj.stakeSpendingTxInclusionProof = InclusionProof.toJSON(message.stakeSpendingTxInclusionProof); } return obj; }, @@ -1141,7 +1349,11 @@ export const MsgBTCUndelegate: MessageFns = { const message = createBaseMsgBTCUndelegate(); message.signer = object.signer ?? ""; message.stakingTxHash = object.stakingTxHash ?? ""; - message.unbondingTxSig = object.unbondingTxSig ?? new Uint8Array(0); + message.stakeSpendingTx = object.stakeSpendingTx ?? new Uint8Array(0); + message.stakeSpendingTxInclusionProof = + (object.stakeSpendingTxInclusionProof !== undefined && object.stakeSpendingTxInclusionProof !== null) + ? InclusionProof.fromPartial(object.stakeSpendingTxInclusionProof) + : undefined; return message; }, }; @@ -1455,6 +1667,10 @@ export interface Msg { EditFinalityProvider(request: MsgEditFinalityProvider): Promise; /** CreateBTCDelegation creates a new BTC delegation */ CreateBTCDelegation(request: MsgCreateBTCDelegation): Promise; + /** AddBTCDelegationInclusionProof adds inclusion proof of a given delegation on BTC chain */ + AddBTCDelegationInclusionProof( + request: MsgAddBTCDelegationInclusionProof, + ): Promise; /** AddCovenantSigs handles signatures from a covenant member */ AddCovenantSigs(request: MsgAddCovenantSigs): Promise; /** BTCUndelegate handles a signature on unbonding tx from its delegator */ @@ -1478,6 +1694,7 @@ export class MsgClientImpl implements Msg { this.CreateFinalityProvider = this.CreateFinalityProvider.bind(this); this.EditFinalityProvider = this.EditFinalityProvider.bind(this); this.CreateBTCDelegation = this.CreateBTCDelegation.bind(this); + this.AddBTCDelegationInclusionProof = this.AddBTCDelegationInclusionProof.bind(this); this.AddCovenantSigs = this.AddCovenantSigs.bind(this); this.BTCUndelegate = this.BTCUndelegate.bind(this); this.SelectiveSlashingEvidence = this.SelectiveSlashingEvidence.bind(this); @@ -1501,6 +1718,14 @@ export class MsgClientImpl implements Msg { return promise.then((data) => MsgCreateBTCDelegationResponse.decode(new BinaryReader(data))); } + AddBTCDelegationInclusionProof( + request: MsgAddBTCDelegationInclusionProof, + ): Promise { + const data = MsgAddBTCDelegationInclusionProof.encode(request).finish(); + const promise = this.rpc.request(this.service, "AddBTCDelegationInclusionProof", data); + return promise.then((data) => MsgAddBTCDelegationInclusionProofResponse.decode(new BinaryReader(data))); + } + AddCovenantSigs(request: MsgAddCovenantSigs): Promise { const data = MsgAddCovenantSigs.encode(request).finish(); const promise = this.rpc.request(this.service, "AddCovenantSigs", data); diff --git a/src/generated/babylon/checkpointing/v1/checkpoint.ts b/src/generated/babylon/checkpointing/v1/checkpoint.ts index c959743..f4c6815 100644 --- a/src/generated/babylon/checkpointing/v1/checkpoint.ts +++ b/src/generated/babylon/checkpointing/v1/checkpoint.ts @@ -105,8 +105,12 @@ export interface RawCheckpointWithMeta { lifecycle: CheckpointStateUpdate[]; } -/** InjectedCheckpoint wraps the checkpoint and the extended votes */ -export interface InjectedCheckpoint { +/** + * MsgInjectedCheckpoint wraps the checkpoint and the extended votes + * Note: this is a special message type that is only for internal ABCI++ usage + * for inserting checkpoint into the block + */ +export interface MsgInjectedCheckpoint { ckpt: | RawCheckpointWithMeta | undefined; @@ -382,12 +386,12 @@ export const RawCheckpointWithMeta: MessageFns = { }, }; -function createBaseInjectedCheckpoint(): InjectedCheckpoint { +function createBaseMsgInjectedCheckpoint(): MsgInjectedCheckpoint { return { ckpt: undefined, extendedCommitInfo: undefined }; } -export const InjectedCheckpoint: MessageFns = { - encode(message: InjectedCheckpoint, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { +export const MsgInjectedCheckpoint: MessageFns = { + encode(message: MsgInjectedCheckpoint, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.ckpt !== undefined) { RawCheckpointWithMeta.encode(message.ckpt, writer.uint32(10).fork()).join(); } @@ -397,10 +401,10 @@ export const InjectedCheckpoint: MessageFns = { return writer; }, - decode(input: BinaryReader | Uint8Array, length?: number): InjectedCheckpoint { + decode(input: BinaryReader | Uint8Array, length?: number): MsgInjectedCheckpoint { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseInjectedCheckpoint(); + const message = createBaseMsgInjectedCheckpoint(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -427,7 +431,7 @@ export const InjectedCheckpoint: MessageFns = { return message; }, - fromJSON(object: any): InjectedCheckpoint { + fromJSON(object: any): MsgInjectedCheckpoint { return { ckpt: isSet(object.ckpt) ? RawCheckpointWithMeta.fromJSON(object.ckpt) : undefined, extendedCommitInfo: isSet(object.extendedCommitInfo) @@ -436,7 +440,7 @@ export const InjectedCheckpoint: MessageFns = { }; }, - toJSON(message: InjectedCheckpoint): unknown { + toJSON(message: MsgInjectedCheckpoint): unknown { const obj: any = {}; if (message.ckpt !== undefined) { obj.ckpt = RawCheckpointWithMeta.toJSON(message.ckpt); @@ -447,11 +451,11 @@ export const InjectedCheckpoint: MessageFns = { return obj; }, - create, I>>(base?: I): InjectedCheckpoint { - return InjectedCheckpoint.fromPartial(base ?? ({} as any)); + create, I>>(base?: I): MsgInjectedCheckpoint { + return MsgInjectedCheckpoint.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>(object: I): InjectedCheckpoint { - const message = createBaseInjectedCheckpoint(); + fromPartial, I>>(object: I): MsgInjectedCheckpoint { + const message = createBaseMsgInjectedCheckpoint(); message.ckpt = (object.ckpt !== undefined && object.ckpt !== null) ? RawCheckpointWithMeta.fromPartial(object.ckpt) : undefined; diff --git a/src/generated/babylon/checkpointing/v1/query.ts b/src/generated/babylon/checkpointing/v1/query.ts index 19d155f..7fcc41f 100644 --- a/src/generated/babylon/checkpointing/v1/query.ts +++ b/src/generated/babylon/checkpointing/v1/query.ts @@ -8,7 +8,6 @@ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; import { PageRequest, PageResponse } from "../../../cosmos/base/query/v1beta1/pagination"; import { Timestamp } from "../../../google/protobuf/timestamp"; -import { ValidatorWithBlsKey } from "./bls_key"; import { CheckpointStatus, checkpointStatusFromJSON, checkpointStatusToJSON } from "./checkpoint"; export const protobufPackage = "babylon.checkpointing.v1"; @@ -83,12 +82,25 @@ export interface QueryBlsPublicKeyListRequest { pagination: PageRequest | undefined; } +/** + * BlsPublicKeyListResponse couples validator address, voting power, and its bls + * public key + */ +export interface BlsPublicKeyListResponse { + /** validator_address is the address of the validator */ + validatorAddress: string; + /** bls_pub_key is the BLS public key of the validator */ + blsPubKeyHex: string; + /** voting_power is the voting power of the validator at the given epoch */ + votingPower: number; +} + /** * QueryBlsPublicKeyListResponse is the response type for the * Query/BlsPublicKeys RPC method. */ export interface QueryBlsPublicKeyListResponse { - validatorWithBlsKeys: ValidatorWithBlsKey[]; + validatorWithBlsKeys: BlsPublicKeyListResponse[]; /** pagination defines the pagination in the response. */ pagination: PageResponse | undefined; } @@ -174,7 +186,7 @@ export interface RawCheckpointResponse { export interface CheckpointStateUpdateResponse { /** state defines the event of a state transition towards this state */ state: CheckpointStatus; - /** status_desc respresents the description of status enum. */ + /** status_desc represents the description of status enum. */ statusDesc: string; /** * block_height is the height of the Babylon block that triggers the state @@ -195,7 +207,7 @@ export interface RawCheckpointWithMetaResponse { | undefined; /** status defines the status of the checkpoint */ status: CheckpointStatus; - /** status_desc respresents the description of status enum. */ + /** status_desc represents the description of status enum. */ statusDesc: string; /** bls_aggr_pk defines the aggregated BLS public key */ blsAggrPk: Uint8Array; @@ -700,6 +712,95 @@ export const QueryBlsPublicKeyListRequest: MessageFns = { + encode(message: BlsPublicKeyListResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.validatorAddress !== "") { + writer.uint32(10).string(message.validatorAddress); + } + if (message.blsPubKeyHex !== "") { + writer.uint32(18).string(message.blsPubKeyHex); + } + if (message.votingPower !== 0) { + writer.uint32(24).uint64(message.votingPower); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): BlsPublicKeyListResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBlsPublicKeyListResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.validatorAddress = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.blsPubKeyHex = reader.string(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.votingPower = longToNumber(reader.uint64()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): BlsPublicKeyListResponse { + return { + validatorAddress: isSet(object.validatorAddress) ? globalThis.String(object.validatorAddress) : "", + blsPubKeyHex: isSet(object.blsPubKeyHex) ? globalThis.String(object.blsPubKeyHex) : "", + votingPower: isSet(object.votingPower) ? globalThis.Number(object.votingPower) : 0, + }; + }, + + toJSON(message: BlsPublicKeyListResponse): unknown { + const obj: any = {}; + if (message.validatorAddress !== "") { + obj.validatorAddress = message.validatorAddress; + } + if (message.blsPubKeyHex !== "") { + obj.blsPubKeyHex = message.blsPubKeyHex; + } + if (message.votingPower !== 0) { + obj.votingPower = Math.round(message.votingPower); + } + return obj; + }, + + create, I>>(base?: I): BlsPublicKeyListResponse { + return BlsPublicKeyListResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): BlsPublicKeyListResponse { + const message = createBaseBlsPublicKeyListResponse(); + message.validatorAddress = object.validatorAddress ?? ""; + message.blsPubKeyHex = object.blsPubKeyHex ?? ""; + message.votingPower = object.votingPower ?? 0; + return message; + }, +}; + function createBaseQueryBlsPublicKeyListResponse(): QueryBlsPublicKeyListResponse { return { validatorWithBlsKeys: [], pagination: undefined }; } @@ -707,7 +808,7 @@ function createBaseQueryBlsPublicKeyListResponse(): QueryBlsPublicKeyListRespons export const QueryBlsPublicKeyListResponse: MessageFns = { encode(message: QueryBlsPublicKeyListResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { for (const v of message.validatorWithBlsKeys) { - ValidatorWithBlsKey.encode(v!, writer.uint32(10).fork()).join(); + BlsPublicKeyListResponse.encode(v!, writer.uint32(10).fork()).join(); } if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).join(); @@ -727,7 +828,7 @@ export const QueryBlsPublicKeyListResponse: MessageFns ValidatorWithBlsKey.fromJSON(e)) + ? object.validatorWithBlsKeys.map((e: any) => BlsPublicKeyListResponse.fromJSON(e)) : [], pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, }; @@ -757,7 +858,7 @@ export const QueryBlsPublicKeyListResponse: MessageFns ValidatorWithBlsKey.toJSON(e)); + obj.validatorWithBlsKeys = message.validatorWithBlsKeys.map((e) => BlsPublicKeyListResponse.toJSON(e)); } if (message.pagination !== undefined) { obj.pagination = PageResponse.toJSON(message.pagination); @@ -772,7 +873,8 @@ export const QueryBlsPublicKeyListResponse: MessageFns ValidatorWithBlsKey.fromPartial(e)) || []; + message.validatorWithBlsKeys = object.validatorWithBlsKeys?.map((e) => BlsPublicKeyListResponse.fromPartial(e)) || + []; message.pagination = (object.pagination !== undefined && object.pagination !== null) ? PageResponse.fromPartial(object.pagination) : undefined; diff --git a/src/generated/babylon/finality/v1/events.ts b/src/generated/babylon/finality/v1/events.ts index f76b8cc..fa01bef 100644 --- a/src/generated/babylon/finality/v1/events.ts +++ b/src/generated/babylon/finality/v1/events.ts @@ -20,19 +20,10 @@ export interface EventSlashedFinalityProvider { } /** - * EventSluggishFinalityProviderDetected is the event emitted when a finality provider is - * detected as sluggish + * EventJailedFinalityProvider is the event emitted when a finality provider is + * jailed due to inactivity */ -export interface EventSluggishFinalityProviderDetected { - /** public_key is the BTC public key of the finality provider */ - publicKey: string; -} - -/** - * EventSluggishFinalityProviderReverted is the event emitted when a sluggish finality - * provider is no longer considered sluggish - */ -export interface EventSluggishFinalityProviderReverted { +export interface EventJailedFinalityProvider { /** public_key is the BTC public key of the finality provider */ publicKey: string; } @@ -96,83 +87,22 @@ export const EventSlashedFinalityProvider: MessageFns = { - encode(message: EventSluggishFinalityProviderDetected, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.publicKey !== "") { - writer.uint32(10).string(message.publicKey); - } - return writer; - }, - - decode(input: BinaryReader | Uint8Array, length?: number): EventSluggishFinalityProviderDetected { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseEventSluggishFinalityProviderDetected(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.publicKey = reader.string(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skip(tag & 7); - } - return message; - }, - - fromJSON(object: any): EventSluggishFinalityProviderDetected { - return { publicKey: isSet(object.publicKey) ? globalThis.String(object.publicKey) : "" }; - }, - - toJSON(message: EventSluggishFinalityProviderDetected): unknown { - const obj: any = {}; - if (message.publicKey !== "") { - obj.publicKey = message.publicKey; - } - return obj; - }, - - create, I>>( - base?: I, - ): EventSluggishFinalityProviderDetected { - return EventSluggishFinalityProviderDetected.fromPartial(base ?? ({} as any)); - }, - fromPartial, I>>( - object: I, - ): EventSluggishFinalityProviderDetected { - const message = createBaseEventSluggishFinalityProviderDetected(); - message.publicKey = object.publicKey ?? ""; - return message; - }, -}; - -function createBaseEventSluggishFinalityProviderReverted(): EventSluggishFinalityProviderReverted { +function createBaseEventJailedFinalityProvider(): EventJailedFinalityProvider { return { publicKey: "" }; } -export const EventSluggishFinalityProviderReverted: MessageFns = { - encode(message: EventSluggishFinalityProviderReverted, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { +export const EventJailedFinalityProvider: MessageFns = { + encode(message: EventJailedFinalityProvider, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.publicKey !== "") { writer.uint32(10).string(message.publicKey); } return writer; }, - decode(input: BinaryReader | Uint8Array, length?: number): EventSluggishFinalityProviderReverted { + decode(input: BinaryReader | Uint8Array, length?: number): EventJailedFinalityProvider { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseEventSluggishFinalityProviderReverted(); + const message = createBaseEventJailedFinalityProvider(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -192,11 +122,11 @@ export const EventSluggishFinalityProviderReverted: MessageFns, I>>( - base?: I, - ): EventSluggishFinalityProviderReverted { - return EventSluggishFinalityProviderReverted.fromPartial(base ?? ({} as any)); + create, I>>(base?: I): EventJailedFinalityProvider { + return EventJailedFinalityProvider.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>( - object: I, - ): EventSluggishFinalityProviderReverted { - const message = createBaseEventSluggishFinalityProviderReverted(); + fromPartial, I>>(object: I): EventJailedFinalityProvider { + const message = createBaseEventJailedFinalityProvider(); message.publicKey = object.publicKey ?? ""; return message; }, diff --git a/src/generated/babylon/finality/v1/finality.ts b/src/generated/babylon/finality/v1/finality.ts index 363b581..c639637 100644 --- a/src/generated/babylon/finality/v1/finality.ts +++ b/src/generated/babylon/finality/v1/finality.ts @@ -6,6 +6,7 @@ /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; +import { Timestamp } from "../../../google/protobuf/timestamp"; export const protobufPackage = "babylon.finality.v1"; @@ -37,6 +38,8 @@ export interface PubRandCommit { * currently, it is the root of the merkle tree constructed by the public randomness */ commitment: Uint8Array; + /** epoch_num defines the epoch number that the commit falls into */ + epochNum: number; } /** @@ -82,6 +85,8 @@ export interface FinalityProviderSigningInfo { * Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. */ missedBlocksCounter: number; + /** Timestamp until which the validator is jailed due to liveness downtime. */ + jailedUntil: Date | undefined; } function createBaseIndexedBlock(): IndexedBlock { @@ -174,7 +179,7 @@ export const IndexedBlock: MessageFns = { }; function createBasePubRandCommit(): PubRandCommit { - return { startHeight: 0, numPubRand: 0, commitment: new Uint8Array(0) }; + return { startHeight: 0, numPubRand: 0, commitment: new Uint8Array(0), epochNum: 0 }; } export const PubRandCommit: MessageFns = { @@ -188,6 +193,9 @@ export const PubRandCommit: MessageFns = { if (message.commitment.length !== 0) { writer.uint32(26).bytes(message.commitment); } + if (message.epochNum !== 0) { + writer.uint32(32).uint64(message.epochNum); + } return writer; }, @@ -219,6 +227,13 @@ export const PubRandCommit: MessageFns = { message.commitment = reader.bytes(); continue; + case 4: + if (tag !== 32) { + break; + } + + message.epochNum = longToNumber(reader.uint64()); + continue; } if ((tag & 7) === 4 || tag === 0) { break; @@ -233,6 +248,7 @@ export const PubRandCommit: MessageFns = { startHeight: isSet(object.startHeight) ? globalThis.Number(object.startHeight) : 0, numPubRand: isSet(object.numPubRand) ? globalThis.Number(object.numPubRand) : 0, commitment: isSet(object.commitment) ? bytesFromBase64(object.commitment) : new Uint8Array(0), + epochNum: isSet(object.epochNum) ? globalThis.Number(object.epochNum) : 0, }; }, @@ -247,6 +263,9 @@ export const PubRandCommit: MessageFns = { if (message.commitment.length !== 0) { obj.commitment = base64FromBytes(message.commitment); } + if (message.epochNum !== 0) { + obj.epochNum = Math.round(message.epochNum); + } return obj; }, @@ -258,6 +277,7 @@ export const PubRandCommit: MessageFns = { message.startHeight = object.startHeight ?? 0; message.numPubRand = object.numPubRand ?? 0; message.commitment = object.commitment ?? new Uint8Array(0); + message.epochNum = object.epochNum ?? 0; return message; }, }; @@ -422,7 +442,7 @@ export const Evidence: MessageFns = { }; function createBaseFinalityProviderSigningInfo(): FinalityProviderSigningInfo { - return { fpBtcPk: new Uint8Array(0), startHeight: 0, missedBlocksCounter: 0 }; + return { fpBtcPk: new Uint8Array(0), startHeight: 0, missedBlocksCounter: 0, jailedUntil: undefined }; } export const FinalityProviderSigningInfo: MessageFns = { @@ -436,6 +456,9 @@ export const FinalityProviderSigningInfo: MessageFns = T extends T ? keyof T : never; export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; +function toTimestamp(date: Date): Timestamp { + const seconds = Math.trunc(date.getTime() / 1_000); + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = (t.seconds || 0) * 1_000; + millis += (t.nanos || 0) / 1_000_000; + return new globalThis.Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof globalThis.Date) { + return o; + } else if (typeof o === "string") { + return new globalThis.Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + function longToNumber(int64: { toString(): string }): number { const num = globalThis.Number(int64.toString()); if (num > globalThis.Number.MAX_SAFE_INTEGER) { diff --git a/src/generated/babylon/finality/v1/genesis.ts b/src/generated/babylon/finality/v1/genesis.ts index b6af4d6..704317b 100644 --- a/src/generated/babylon/finality/v1/genesis.ts +++ b/src/generated/babylon/finality/v1/genesis.ts @@ -23,9 +23,9 @@ export interface GenesisState { evidences: Evidence[]; /** votes_sigs contains all the votes of finality providers ever registered. */ voteSigs: VoteSig[]; - /** public_randomness contains all the public randomness ever commited from the finality providers. */ + /** public_randomness contains all the public randomness ever committed from the finality providers. */ publicRandomness: PublicRandomness[]; - /** pub_rand_commit contains all the public randomness commitment ever commited from the finality providers. */ + /** pub_rand_commit contains all the public randomness commitment ever committed from the finality providers. */ pubRandCommit: PubRandCommitWithPK[]; /** * signing_infos represents a map between finality provider public key and their @@ -57,7 +57,7 @@ export interface VoteSig { /** PublicRandomness the block height and public randomness that the finality provider has submitted. */ export interface PublicRandomness { - /** block_height is the height of block which the finality provider submited public randomness. */ + /** block_height is the height of block which the finality provider submitted public randomness. */ blockHeight: number; /** fp_btc_pk is the BTC PK of the finality provider that casts this vote. */ fpBtcPk: Uint8Array; diff --git a/src/generated/babylon/finality/v1/params.ts b/src/generated/babylon/finality/v1/params.ts index 76d974c..67d8971 100644 --- a/src/generated/babylon/finality/v1/params.ts +++ b/src/generated/babylon/finality/v1/params.ts @@ -6,6 +6,7 @@ /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; +import { Duration } from "../../../google/protobuf/duration"; export const protobufPackage = "babylon.finality.v1"; @@ -20,7 +21,7 @@ export interface Params { finalitySigTimeout: number; /** * min_signed_per_window defines the minimum number of blocks that a finality provider is required to sign - * within the sliding window to avoid being detected as sluggish + * within the sliding window to avoid being jailed */ minSignedPerWindow: Uint8Array; /** @@ -28,10 +29,27 @@ export interface Params { * message should commit */ minPubRand: number; + /** jail_duration is the minimum period of time that a finality provider remains jailed */ + jailDuration: + | Duration + | undefined; + /** + * finality_activation_height is the babylon block height which the finality module will + * start to accept finality voting and the minimum allowed value for the public randomness + * commit start height. + */ + finalityActivationHeight: number; } function createBaseParams(): Params { - return { signedBlocksWindow: 0, finalitySigTimeout: 0, minSignedPerWindow: new Uint8Array(0), minPubRand: 0 }; + return { + signedBlocksWindow: 0, + finalitySigTimeout: 0, + minSignedPerWindow: new Uint8Array(0), + minPubRand: 0, + jailDuration: undefined, + finalityActivationHeight: 0, + }; } export const Params: MessageFns = { @@ -48,6 +66,12 @@ export const Params: MessageFns = { if (message.minPubRand !== 0) { writer.uint32(32).uint64(message.minPubRand); } + if (message.jailDuration !== undefined) { + Duration.encode(message.jailDuration, writer.uint32(42).fork()).join(); + } + if (message.finalityActivationHeight !== 0) { + writer.uint32(48).uint64(message.finalityActivationHeight); + } return writer; }, @@ -86,6 +110,20 @@ export const Params: MessageFns = { message.minPubRand = longToNumber(reader.uint64()); continue; + case 5: + if (tag !== 42) { + break; + } + + message.jailDuration = Duration.decode(reader, reader.uint32()); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.finalityActivationHeight = longToNumber(reader.uint64()); + continue; } if ((tag & 7) === 4 || tag === 0) { break; @@ -103,6 +141,10 @@ export const Params: MessageFns = { ? bytesFromBase64(object.minSignedPerWindow) : new Uint8Array(0), minPubRand: isSet(object.minPubRand) ? globalThis.Number(object.minPubRand) : 0, + jailDuration: isSet(object.jailDuration) ? Duration.fromJSON(object.jailDuration) : undefined, + finalityActivationHeight: isSet(object.finalityActivationHeight) + ? globalThis.Number(object.finalityActivationHeight) + : 0, }; }, @@ -120,6 +162,12 @@ export const Params: MessageFns = { if (message.minPubRand !== 0) { obj.minPubRand = Math.round(message.minPubRand); } + if (message.jailDuration !== undefined) { + obj.jailDuration = Duration.toJSON(message.jailDuration); + } + if (message.finalityActivationHeight !== 0) { + obj.finalityActivationHeight = Math.round(message.finalityActivationHeight); + } return obj; }, @@ -132,6 +180,10 @@ export const Params: MessageFns = { message.finalitySigTimeout = object.finalitySigTimeout ?? 0; message.minSignedPerWindow = object.minSignedPerWindow ?? new Uint8Array(0); message.minPubRand = object.minPubRand ?? 0; + message.jailDuration = (object.jailDuration !== undefined && object.jailDuration !== null) + ? Duration.fromPartial(object.jailDuration) + : undefined; + message.finalityActivationHeight = object.finalityActivationHeight ?? 0; return message; }, }; diff --git a/src/generated/babylon/finality/v1/query.ts b/src/generated/babylon/finality/v1/query.ts index 7a014c2..9f8d8c6 100644 --- a/src/generated/babylon/finality/v1/query.ts +++ b/src/generated/babylon/finality/v1/query.ts @@ -7,7 +7,8 @@ /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; import { PageRequest, PageResponse } from "../../../cosmos/base/query/v1beta1/pagination"; -import { Evidence, FinalityProviderSigningInfo, IndexedBlock } from "./finality"; +import { Timestamp } from "../../../google/protobuf/timestamp"; +import { IndexedBlock } from "./finality"; import { Params } from "./params"; export const protobufPackage = "babylon.finality.v1"; @@ -101,6 +102,8 @@ export interface PubRandCommitResponse { numPubRand: number; /** commitment is the value of the commitment */ commitment: Uint8Array; + /** epoch_num defines the epoch number that the commit falls into */ + epochNum: number; } /** @@ -206,12 +209,41 @@ export interface QueryEvidenceRequest { fpBtcPkHex: string; } +/** + * Evidence is the evidence that a finality provider has signed finality + * signatures with correct public randomness on two conflicting Babylon headers + */ +export interface EvidenceResponse { + /** fp_btc_pk_hex is the BTC PK of the finality provider that casts this vote */ + fpBtcPkHex: string; + /** block_height is the height of the conflicting blocks */ + blockHeight: number; + /** pub_rand is the public randomness the finality provider has committed to */ + pubRand: Uint8Array; + /** canonical_app_hash is the AppHash of the canonical block */ + canonicalAppHash: Uint8Array; + /** fork_app_hash is the AppHash of the fork block */ + forkAppHash: Uint8Array; + /** + * canonical_finality_sig is the finality signature to the canonical block + * where finality signature is an EOTS signature, i.e., + * the `s` in a Schnorr signature `(r, s)` + * `r` is the public randomness that is already committed by the finality provider + */ + canonicalFinalitySig: Uint8Array; + /** + * fork_finality_sig is the finality signature to the fork block + * where finality signature is an EOTS signature + */ + forkFinalitySig: Uint8Array; +} + /** * QueryEvidenceResponse is the response type for the * Query/Evidence RPC method. */ export interface QueryEvidenceResponse { - evidence: Evidence | undefined; + evidence: EvidenceResponse | undefined; } /** @@ -234,7 +266,7 @@ export interface QueryListEvidencesRequest { */ export interface QueryListEvidencesResponse { /** blocks is the list of evidences */ - evidences: Evidence[]; + evidences: EvidenceResponse[]; /** pagination defines the pagination in the response. */ pagination: PageResponse | undefined; } @@ -251,13 +283,30 @@ export interface QuerySigningInfoRequest { fpBtcPkHex: string; } +/** + * SigningInfoResponse defines the API response containing a finality provider's signing info + * for monitoring their liveness activity. + */ +export interface SigningInfoResponse { + /** fp_btc_pk is the BTC PK of the finality provider that casts this vote */ + fpBtcPkHex: string; + /** start_height is the block height at which finality provider become active */ + startHeight: number; + /** + * missed_blocks_counter defines a counter to avoid unnecessary array reads. + * Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. + */ + missedBlocksCounter: number; + /** Timestamp until which the validator is jailed due to liveness downtime. */ + jailedUntil: Date | undefined; +} + /** * QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC * method */ export interface QuerySigningInfoResponse { - /** fp_signing_info is the signing info of requested finality provider BTC public key */ - fpSigningInfo: FinalityProviderSigningInfo | undefined; + signingInfo: SigningInfoResponse | undefined; } /** @@ -274,7 +323,7 @@ export interface QuerySigningInfosRequest { */ export interface QuerySigningInfosResponse { /** info is the signing info of all finality providers with signing info */ - fpSigningInfos: FinalityProviderSigningInfo[]; + signingInfos: SigningInfoResponse[]; pagination: PageResponse | undefined; } @@ -647,7 +696,7 @@ export const QueryListPublicRandomnessResponse_PubRandMapEntry: MessageFns< }; function createBasePubRandCommitResponse(): PubRandCommitResponse { - return { numPubRand: 0, commitment: new Uint8Array(0) }; + return { numPubRand: 0, commitment: new Uint8Array(0), epochNum: 0 }; } export const PubRandCommitResponse: MessageFns = { @@ -658,6 +707,9 @@ export const PubRandCommitResponse: MessageFns = { if (message.commitment.length !== 0) { writer.uint32(18).bytes(message.commitment); } + if (message.epochNum !== 0) { + writer.uint32(24).uint64(message.epochNum); + } return writer; }, @@ -682,6 +734,13 @@ export const PubRandCommitResponse: MessageFns = { message.commitment = reader.bytes(); continue; + case 3: + if (tag !== 24) { + break; + } + + message.epochNum = longToNumber(reader.uint64()); + continue; } if ((tag & 7) === 4 || tag === 0) { break; @@ -695,6 +754,7 @@ export const PubRandCommitResponse: MessageFns = { return { numPubRand: isSet(object.numPubRand) ? globalThis.Number(object.numPubRand) : 0, commitment: isSet(object.commitment) ? bytesFromBase64(object.commitment) : new Uint8Array(0), + epochNum: isSet(object.epochNum) ? globalThis.Number(object.epochNum) : 0, }; }, @@ -706,6 +766,9 @@ export const PubRandCommitResponse: MessageFns = { if (message.commitment.length !== 0) { obj.commitment = base64FromBytes(message.commitment); } + if (message.epochNum !== 0) { + obj.epochNum = Math.round(message.epochNum); + } return obj; }, @@ -716,6 +779,7 @@ export const PubRandCommitResponse: MessageFns = { const message = createBasePubRandCommitResponse(); message.numPubRand = object.numPubRand ?? 0; message.commitment = object.commitment ?? new Uint8Array(0); + message.epochNum = object.epochNum ?? 0; return message; }, }; @@ -1427,6 +1491,165 @@ export const QueryEvidenceRequest: MessageFns = { }, }; +function createBaseEvidenceResponse(): EvidenceResponse { + return { + fpBtcPkHex: "", + blockHeight: 0, + pubRand: new Uint8Array(0), + canonicalAppHash: new Uint8Array(0), + forkAppHash: new Uint8Array(0), + canonicalFinalitySig: new Uint8Array(0), + forkFinalitySig: new Uint8Array(0), + }; +} + +export const EvidenceResponse: MessageFns = { + encode(message: EvidenceResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.fpBtcPkHex !== "") { + writer.uint32(10).string(message.fpBtcPkHex); + } + if (message.blockHeight !== 0) { + writer.uint32(16).uint64(message.blockHeight); + } + if (message.pubRand.length !== 0) { + writer.uint32(26).bytes(message.pubRand); + } + if (message.canonicalAppHash.length !== 0) { + writer.uint32(34).bytes(message.canonicalAppHash); + } + if (message.forkAppHash.length !== 0) { + writer.uint32(42).bytes(message.forkAppHash); + } + if (message.canonicalFinalitySig.length !== 0) { + writer.uint32(50).bytes(message.canonicalFinalitySig); + } + if (message.forkFinalitySig.length !== 0) { + writer.uint32(58).bytes(message.forkFinalitySig); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): EvidenceResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEvidenceResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.fpBtcPkHex = reader.string(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.blockHeight = longToNumber(reader.uint64()); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.pubRand = reader.bytes(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.canonicalAppHash = reader.bytes(); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.forkAppHash = reader.bytes(); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.canonicalFinalitySig = reader.bytes(); + continue; + case 7: + if (tag !== 58) { + break; + } + + message.forkFinalitySig = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): EvidenceResponse { + return { + fpBtcPkHex: isSet(object.fpBtcPkHex) ? globalThis.String(object.fpBtcPkHex) : "", + blockHeight: isSet(object.blockHeight) ? globalThis.Number(object.blockHeight) : 0, + pubRand: isSet(object.pubRand) ? bytesFromBase64(object.pubRand) : new Uint8Array(0), + canonicalAppHash: isSet(object.canonicalAppHash) ? bytesFromBase64(object.canonicalAppHash) : new Uint8Array(0), + forkAppHash: isSet(object.forkAppHash) ? bytesFromBase64(object.forkAppHash) : new Uint8Array(0), + canonicalFinalitySig: isSet(object.canonicalFinalitySig) + ? bytesFromBase64(object.canonicalFinalitySig) + : new Uint8Array(0), + forkFinalitySig: isSet(object.forkFinalitySig) ? bytesFromBase64(object.forkFinalitySig) : new Uint8Array(0), + }; + }, + + toJSON(message: EvidenceResponse): unknown { + const obj: any = {}; + if (message.fpBtcPkHex !== "") { + obj.fpBtcPkHex = message.fpBtcPkHex; + } + if (message.blockHeight !== 0) { + obj.blockHeight = Math.round(message.blockHeight); + } + if (message.pubRand.length !== 0) { + obj.pubRand = base64FromBytes(message.pubRand); + } + if (message.canonicalAppHash.length !== 0) { + obj.canonicalAppHash = base64FromBytes(message.canonicalAppHash); + } + if (message.forkAppHash.length !== 0) { + obj.forkAppHash = base64FromBytes(message.forkAppHash); + } + if (message.canonicalFinalitySig.length !== 0) { + obj.canonicalFinalitySig = base64FromBytes(message.canonicalFinalitySig); + } + if (message.forkFinalitySig.length !== 0) { + obj.forkFinalitySig = base64FromBytes(message.forkFinalitySig); + } + return obj; + }, + + create, I>>(base?: I): EvidenceResponse { + return EvidenceResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): EvidenceResponse { + const message = createBaseEvidenceResponse(); + message.fpBtcPkHex = object.fpBtcPkHex ?? ""; + message.blockHeight = object.blockHeight ?? 0; + message.pubRand = object.pubRand ?? new Uint8Array(0); + message.canonicalAppHash = object.canonicalAppHash ?? new Uint8Array(0); + message.forkAppHash = object.forkAppHash ?? new Uint8Array(0); + message.canonicalFinalitySig = object.canonicalFinalitySig ?? new Uint8Array(0); + message.forkFinalitySig = object.forkFinalitySig ?? new Uint8Array(0); + return message; + }, +}; + function createBaseQueryEvidenceResponse(): QueryEvidenceResponse { return { evidence: undefined }; } @@ -1434,7 +1657,7 @@ function createBaseQueryEvidenceResponse(): QueryEvidenceResponse { export const QueryEvidenceResponse: MessageFns = { encode(message: QueryEvidenceResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.evidence !== undefined) { - Evidence.encode(message.evidence, writer.uint32(10).fork()).join(); + EvidenceResponse.encode(message.evidence, writer.uint32(10).fork()).join(); } return writer; }, @@ -1451,7 +1674,7 @@ export const QueryEvidenceResponse: MessageFns = { break; } - message.evidence = Evidence.decode(reader, reader.uint32()); + message.evidence = EvidenceResponse.decode(reader, reader.uint32()); continue; } if ((tag & 7) === 4 || tag === 0) { @@ -1463,13 +1686,13 @@ export const QueryEvidenceResponse: MessageFns = { }, fromJSON(object: any): QueryEvidenceResponse { - return { evidence: isSet(object.evidence) ? Evidence.fromJSON(object.evidence) : undefined }; + return { evidence: isSet(object.evidence) ? EvidenceResponse.fromJSON(object.evidence) : undefined }; }, toJSON(message: QueryEvidenceResponse): unknown { const obj: any = {}; if (message.evidence !== undefined) { - obj.evidence = Evidence.toJSON(message.evidence); + obj.evidence = EvidenceResponse.toJSON(message.evidence); } return obj; }, @@ -1480,7 +1703,7 @@ export const QueryEvidenceResponse: MessageFns = { fromPartial, I>>(object: I): QueryEvidenceResponse { const message = createBaseQueryEvidenceResponse(); message.evidence = (object.evidence !== undefined && object.evidence !== null) - ? Evidence.fromPartial(object.evidence) + ? EvidenceResponse.fromPartial(object.evidence) : undefined; return message; }, @@ -1569,7 +1792,7 @@ function createBaseQueryListEvidencesResponse(): QueryListEvidencesResponse { export const QueryListEvidencesResponse: MessageFns = { encode(message: QueryListEvidencesResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { for (const v of message.evidences) { - Evidence.encode(v!, writer.uint32(10).fork()).join(); + EvidenceResponse.encode(v!, writer.uint32(10).fork()).join(); } if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).join(); @@ -1589,7 +1812,7 @@ export const QueryListEvidencesResponse: MessageFns break; } - message.evidences.push(Evidence.decode(reader, reader.uint32())); + message.evidences.push(EvidenceResponse.decode(reader, reader.uint32())); continue; case 2: if (tag !== 18) { @@ -1610,7 +1833,7 @@ export const QueryListEvidencesResponse: MessageFns fromJSON(object: any): QueryListEvidencesResponse { return { evidences: globalThis.Array.isArray(object?.evidences) - ? object.evidences.map((e: any) => Evidence.fromJSON(e)) + ? object.evidences.map((e: any) => EvidenceResponse.fromJSON(e)) : [], pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, }; @@ -1619,7 +1842,7 @@ export const QueryListEvidencesResponse: MessageFns toJSON(message: QueryListEvidencesResponse): unknown { const obj: any = {}; if (message.evidences?.length) { - obj.evidences = message.evidences.map((e) => Evidence.toJSON(e)); + obj.evidences = message.evidences.map((e) => EvidenceResponse.toJSON(e)); } if (message.pagination !== undefined) { obj.pagination = PageResponse.toJSON(message.pagination); @@ -1632,7 +1855,7 @@ export const QueryListEvidencesResponse: MessageFns }, fromPartial, I>>(object: I): QueryListEvidencesResponse { const message = createBaseQueryListEvidencesResponse(); - message.evidences = object.evidences?.map((e) => Evidence.fromPartial(e)) || []; + message.evidences = object.evidences?.map((e) => EvidenceResponse.fromPartial(e)) || []; message.pagination = (object.pagination !== undefined && object.pagination !== null) ? PageResponse.fromPartial(object.pagination) : undefined; @@ -1697,14 +1920,118 @@ export const QuerySigningInfoRequest: MessageFns = { }, }; +function createBaseSigningInfoResponse(): SigningInfoResponse { + return { fpBtcPkHex: "", startHeight: 0, missedBlocksCounter: 0, jailedUntil: undefined }; +} + +export const SigningInfoResponse: MessageFns = { + encode(message: SigningInfoResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.fpBtcPkHex !== "") { + writer.uint32(10).string(message.fpBtcPkHex); + } + if (message.startHeight !== 0) { + writer.uint32(16).int64(message.startHeight); + } + if (message.missedBlocksCounter !== 0) { + writer.uint32(24).int64(message.missedBlocksCounter); + } + if (message.jailedUntil !== undefined) { + Timestamp.encode(toTimestamp(message.jailedUntil), writer.uint32(34).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): SigningInfoResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSigningInfoResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.fpBtcPkHex = reader.string(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.startHeight = longToNumber(reader.int64()); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.missedBlocksCounter = longToNumber(reader.int64()); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.jailedUntil = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): SigningInfoResponse { + return { + fpBtcPkHex: isSet(object.fpBtcPkHex) ? globalThis.String(object.fpBtcPkHex) : "", + startHeight: isSet(object.startHeight) ? globalThis.Number(object.startHeight) : 0, + missedBlocksCounter: isSet(object.missedBlocksCounter) ? globalThis.Number(object.missedBlocksCounter) : 0, + jailedUntil: isSet(object.jailedUntil) ? fromJsonTimestamp(object.jailedUntil) : undefined, + }; + }, + + toJSON(message: SigningInfoResponse): unknown { + const obj: any = {}; + if (message.fpBtcPkHex !== "") { + obj.fpBtcPkHex = message.fpBtcPkHex; + } + if (message.startHeight !== 0) { + obj.startHeight = Math.round(message.startHeight); + } + if (message.missedBlocksCounter !== 0) { + obj.missedBlocksCounter = Math.round(message.missedBlocksCounter); + } + if (message.jailedUntil !== undefined) { + obj.jailedUntil = message.jailedUntil.toISOString(); + } + return obj; + }, + + create, I>>(base?: I): SigningInfoResponse { + return SigningInfoResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): SigningInfoResponse { + const message = createBaseSigningInfoResponse(); + message.fpBtcPkHex = object.fpBtcPkHex ?? ""; + message.startHeight = object.startHeight ?? 0; + message.missedBlocksCounter = object.missedBlocksCounter ?? 0; + message.jailedUntil = object.jailedUntil ?? undefined; + return message; + }, +}; + function createBaseQuerySigningInfoResponse(): QuerySigningInfoResponse { - return { fpSigningInfo: undefined }; + return { signingInfo: undefined }; } export const QuerySigningInfoResponse: MessageFns = { encode(message: QuerySigningInfoResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.fpSigningInfo !== undefined) { - FinalityProviderSigningInfo.encode(message.fpSigningInfo, writer.uint32(10).fork()).join(); + if (message.signingInfo !== undefined) { + SigningInfoResponse.encode(message.signingInfo, writer.uint32(10).fork()).join(); } return writer; }, @@ -1721,7 +2048,7 @@ export const QuerySigningInfoResponse: MessageFns = { break; } - message.fpSigningInfo = FinalityProviderSigningInfo.decode(reader, reader.uint32()); + message.signingInfo = SigningInfoResponse.decode(reader, reader.uint32()); continue; } if ((tag & 7) === 4 || tag === 0) { @@ -1733,17 +2060,13 @@ export const QuerySigningInfoResponse: MessageFns = { }, fromJSON(object: any): QuerySigningInfoResponse { - return { - fpSigningInfo: isSet(object.fpSigningInfo) - ? FinalityProviderSigningInfo.fromJSON(object.fpSigningInfo) - : undefined, - }; + return { signingInfo: isSet(object.signingInfo) ? SigningInfoResponse.fromJSON(object.signingInfo) : undefined }; }, toJSON(message: QuerySigningInfoResponse): unknown { const obj: any = {}; - if (message.fpSigningInfo !== undefined) { - obj.fpSigningInfo = FinalityProviderSigningInfo.toJSON(message.fpSigningInfo); + if (message.signingInfo !== undefined) { + obj.signingInfo = SigningInfoResponse.toJSON(message.signingInfo); } return obj; }, @@ -1753,8 +2076,8 @@ export const QuerySigningInfoResponse: MessageFns = { }, fromPartial, I>>(object: I): QuerySigningInfoResponse { const message = createBaseQuerySigningInfoResponse(); - message.fpSigningInfo = (object.fpSigningInfo !== undefined && object.fpSigningInfo !== null) - ? FinalityProviderSigningInfo.fromPartial(object.fpSigningInfo) + message.signingInfo = (object.signingInfo !== undefined && object.signingInfo !== null) + ? SigningInfoResponse.fromPartial(object.signingInfo) : undefined; return message; }, @@ -1820,13 +2143,13 @@ export const QuerySigningInfosRequest: MessageFns = { }; function createBaseQuerySigningInfosResponse(): QuerySigningInfosResponse { - return { fpSigningInfos: [], pagination: undefined }; + return { signingInfos: [], pagination: undefined }; } export const QuerySigningInfosResponse: MessageFns = { encode(message: QuerySigningInfosResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - for (const v of message.fpSigningInfos) { - FinalityProviderSigningInfo.encode(v!, writer.uint32(10).fork()).join(); + for (const v of message.signingInfos) { + SigningInfoResponse.encode(v!, writer.uint32(10).fork()).join(); } if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).join(); @@ -1846,7 +2169,7 @@ export const QuerySigningInfosResponse: MessageFns = break; } - message.fpSigningInfos.push(FinalityProviderSigningInfo.decode(reader, reader.uint32())); + message.signingInfos.push(SigningInfoResponse.decode(reader, reader.uint32())); continue; case 2: if (tag !== 18) { @@ -1866,8 +2189,8 @@ export const QuerySigningInfosResponse: MessageFns = fromJSON(object: any): QuerySigningInfosResponse { return { - fpSigningInfos: globalThis.Array.isArray(object?.fpSigningInfos) - ? object.fpSigningInfos.map((e: any) => FinalityProviderSigningInfo.fromJSON(e)) + signingInfos: globalThis.Array.isArray(object?.signingInfos) + ? object.signingInfos.map((e: any) => SigningInfoResponse.fromJSON(e)) : [], pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, }; @@ -1875,8 +2198,8 @@ export const QuerySigningInfosResponse: MessageFns = toJSON(message: QuerySigningInfosResponse): unknown { const obj: any = {}; - if (message.fpSigningInfos?.length) { - obj.fpSigningInfos = message.fpSigningInfos.map((e) => FinalityProviderSigningInfo.toJSON(e)); + if (message.signingInfos?.length) { + obj.signingInfos = message.signingInfos.map((e) => SigningInfoResponse.toJSON(e)); } if (message.pagination !== undefined) { obj.pagination = PageResponse.toJSON(message.pagination); @@ -1889,7 +2212,7 @@ export const QuerySigningInfosResponse: MessageFns = }, fromPartial, I>>(object: I): QuerySigningInfosResponse { const message = createBaseQuerySigningInfosResponse(); - message.fpSigningInfos = object.fpSigningInfos?.map((e) => FinalityProviderSigningInfo.fromPartial(e)) || []; + message.signingInfos = object.signingInfos?.map((e) => SigningInfoResponse.fromPartial(e)) || []; message.pagination = (object.pagination !== undefined && object.pagination !== null) ? PageResponse.fromPartial(object.pagination) : undefined; @@ -1904,7 +2227,7 @@ export interface Query { /** * ListPublicRandomness is a range query for public randomness of a given finality provider * NOTE: Babylon only has the knowledge of public randomness that is already revealed by - * finality providers, i.e., the finality provider alreayd provides a finality signature + * finality providers, i.e., the finality provider already provides a finality signature * at the corresponding height * TODO: remove public randomness storage? */ @@ -2047,6 +2370,28 @@ type KeysOfUnion = T extends T ? keyof T : never; export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; +function toTimestamp(date: Date): Timestamp { + const seconds = Math.trunc(date.getTime() / 1_000); + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = (t.seconds || 0) * 1_000; + millis += (t.nanos || 0) / 1_000_000; + return new globalThis.Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof globalThis.Date) { + return o; + } else if (typeof o === "string") { + return new globalThis.Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + function longToNumber(int64: { toString(): string }): number { const num = globalThis.Number(int64.toString()); if (num > globalThis.Number.MAX_SAFE_INTEGER) { diff --git a/src/generated/babylon/finality/v1/tx.ts b/src/generated/babylon/finality/v1/tx.ts index e553568..56945f4 100644 --- a/src/generated/babylon/finality/v1/tx.ts +++ b/src/generated/babylon/finality/v1/tx.ts @@ -88,6 +88,17 @@ export interface MsgUpdateParams { export interface MsgUpdateParamsResponse { } +/** MsgUnjailFinalityProvider defines the Msg/UnjailFinalityProvider request type */ +export interface MsgUnjailFinalityProvider { + signer: string; + /** fp_btc_pk is the BTC PK of the finality provider that commits the public randomness */ + fpBtcPk: Uint8Array; +} + +/** MsgUnjailFinalityProviderResponse defines the Msg/UnjailFinalityProvider response type */ +export interface MsgUnjailFinalityProviderResponse { +} + function createBaseMsgCommitPubRandList(): MsgCommitPubRandList { return { signer: "", @@ -591,6 +602,127 @@ export const MsgUpdateParamsResponse: MessageFns = { }, }; +function createBaseMsgUnjailFinalityProvider(): MsgUnjailFinalityProvider { + return { signer: "", fpBtcPk: new Uint8Array(0) }; +} + +export const MsgUnjailFinalityProvider: MessageFns = { + encode(message: MsgUnjailFinalityProvider, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.signer !== "") { + writer.uint32(10).string(message.signer); + } + if (message.fpBtcPk.length !== 0) { + writer.uint32(18).bytes(message.fpBtcPk); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): MsgUnjailFinalityProvider { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUnjailFinalityProvider(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.signer = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.fpBtcPk = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): MsgUnjailFinalityProvider { + return { + signer: isSet(object.signer) ? globalThis.String(object.signer) : "", + fpBtcPk: isSet(object.fpBtcPk) ? bytesFromBase64(object.fpBtcPk) : new Uint8Array(0), + }; + }, + + toJSON(message: MsgUnjailFinalityProvider): unknown { + const obj: any = {}; + if (message.signer !== "") { + obj.signer = message.signer; + } + if (message.fpBtcPk.length !== 0) { + obj.fpBtcPk = base64FromBytes(message.fpBtcPk); + } + return obj; + }, + + create, I>>(base?: I): MsgUnjailFinalityProvider { + return MsgUnjailFinalityProvider.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): MsgUnjailFinalityProvider { + const message = createBaseMsgUnjailFinalityProvider(); + message.signer = object.signer ?? ""; + message.fpBtcPk = object.fpBtcPk ?? new Uint8Array(0); + return message; + }, +}; + +function createBaseMsgUnjailFinalityProviderResponse(): MsgUnjailFinalityProviderResponse { + return {}; +} + +export const MsgUnjailFinalityProviderResponse: MessageFns = { + encode(_: MsgUnjailFinalityProviderResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): MsgUnjailFinalityProviderResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUnjailFinalityProviderResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(_: any): MsgUnjailFinalityProviderResponse { + return {}; + }, + + toJSON(_: MsgUnjailFinalityProviderResponse): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>( + base?: I, + ): MsgUnjailFinalityProviderResponse { + return MsgUnjailFinalityProviderResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): MsgUnjailFinalityProviderResponse { + const message = createBaseMsgUnjailFinalityProviderResponse(); + return message; + }, +}; + /** Msg defines the Msg service. */ export interface Msg { /** CommitPubRandList commits a list of public randomness for EOTS */ @@ -602,6 +734,11 @@ export interface Msg { * UpdateParams updates the finality module parameters. */ UpdateParams(request: MsgUpdateParams): Promise; + /** + * UnjailFinalityProvider defines a method for unjailing a jailed + * finality provider, thus it can receive voting power + */ + UnjailFinalityProvider(request: MsgUnjailFinalityProvider): Promise; } export const MsgServiceName = "babylon.finality.v1.Msg"; @@ -614,6 +751,7 @@ export class MsgClientImpl implements Msg { this.CommitPubRandList = this.CommitPubRandList.bind(this); this.AddFinalitySig = this.AddFinalitySig.bind(this); this.UpdateParams = this.UpdateParams.bind(this); + this.UnjailFinalityProvider = this.UnjailFinalityProvider.bind(this); } CommitPubRandList(request: MsgCommitPubRandList): Promise { const data = MsgCommitPubRandList.encode(request).finish(); @@ -632,6 +770,12 @@ export class MsgClientImpl implements Msg { const promise = this.rpc.request(this.service, "UpdateParams", data); return promise.then((data) => MsgUpdateParamsResponse.decode(new BinaryReader(data))); } + + UnjailFinalityProvider(request: MsgUnjailFinalityProvider): Promise { + const data = MsgUnjailFinalityProvider.encode(request).finish(); + const promise = this.rpc.request(this.service, "UnjailFinalityProvider", data); + return promise.then((data) => MsgUnjailFinalityProviderResponse.decode(new BinaryReader(data))); + } } interface Rpc { diff --git a/src/generated/babylon/incentive/query.ts b/src/generated/babylon/incentive/query.ts index f67c493..1755916 100644 --- a/src/generated/babylon/incentive/query.ts +++ b/src/generated/babylon/incentive/query.ts @@ -6,7 +6,7 @@ /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; -import { Gauge, RewardGauge } from "./incentive"; +import { Coin } from "../../cosmos/base/v1beta1/coin"; import { Params } from "./params"; export const protobufPackage = "babylon.incentive"; @@ -27,18 +27,29 @@ export interface QueryRewardGaugesRequest { address: string; } +/** RewardGaugesResponse is an object that stores rewards distributed to a BTC staking/timestamping stakeholder */ +export interface RewardGaugesResponse { + /** + * coins are coins that have been in the gauge + * Can have multiple coin denoms + */ + coins: Coin[]; + /** withdrawn_coins are coins that have been withdrawn by the stakeholder already */ + withdrawnCoins: Coin[]; +} + /** QueryRewardGaugesResponse is response type for the Query/RewardGauges RPC method. */ export interface QueryRewardGaugesResponse { /** * reward_gauges is the map of reward gauges, where key is the stakeholder type * and value is the reward gauge holding all rewards for the stakeholder in that type */ - rewardGauges: { [key: string]: RewardGauge }; + rewardGauges: { [key: string]: RewardGaugesResponse }; } export interface QueryRewardGaugesResponse_RewardGaugesEntry { key: string; - value: RewardGauge | undefined; + value: RewardGaugesResponse | undefined; } /** QueryBTCStakingGaugeRequest is request type for the Query/BTCStakingGauge RPC method. */ @@ -47,10 +58,26 @@ export interface QueryBTCStakingGaugeRequest { height: number; } +export interface BTCStakingGaugeResponse { + /** + * coins that have been in the gauge + * can have multiple coin denoms + */ + coins: Coin[]; +} + +export interface BTCTimestampingGaugeResponse { + /** + * coins that have been in the gauge + * can have multiple coin denoms + */ + coins: Coin[]; +} + /** QueryBTCStakingGaugeResponse is response type for the Query/BTCStakingGauge RPC method. */ export interface QueryBTCStakingGaugeResponse { /** gauge is the BTC staking gauge at the queried height */ - gauge: Gauge | undefined; + gauge: BTCStakingGaugeResponse | undefined; } /** QueryBTCTimestampingGaugeRequest is request type for the Query/BTCTimestampingGauge RPC method. */ @@ -62,7 +89,7 @@ export interface QueryBTCTimestampingGaugeRequest { /** QueryBTCTimestampingGaugeResponse is response type for the Query/BTCTimestampingGauge RPC method. */ export interface QueryBTCTimestampingGaugeResponse { /** gauge is the BTC timestamping gauge at the queried epoch */ - gauge: Gauge | undefined; + gauge: BTCTimestampingGaugeResponse | undefined; } function createBaseQueryParamsRequest(): QueryParamsRequest { @@ -224,6 +251,82 @@ export const QueryRewardGaugesRequest: MessageFns = { }, }; +function createBaseRewardGaugesResponse(): RewardGaugesResponse { + return { coins: [], withdrawnCoins: [] }; +} + +export const RewardGaugesResponse: MessageFns = { + encode(message: RewardGaugesResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + for (const v of message.coins) { + Coin.encode(v!, writer.uint32(10).fork()).join(); + } + for (const v of message.withdrawnCoins) { + Coin.encode(v!, writer.uint32(18).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): RewardGaugesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRewardGaugesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.coins.push(Coin.decode(reader, reader.uint32())); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.withdrawnCoins.push(Coin.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): RewardGaugesResponse { + return { + coins: globalThis.Array.isArray(object?.coins) ? object.coins.map((e: any) => Coin.fromJSON(e)) : [], + withdrawnCoins: globalThis.Array.isArray(object?.withdrawnCoins) + ? object.withdrawnCoins.map((e: any) => Coin.fromJSON(e)) + : [], + }; + }, + + toJSON(message: RewardGaugesResponse): unknown { + const obj: any = {}; + if (message.coins?.length) { + obj.coins = message.coins.map((e) => Coin.toJSON(e)); + } + if (message.withdrawnCoins?.length) { + obj.withdrawnCoins = message.withdrawnCoins.map((e) => Coin.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): RewardGaugesResponse { + return RewardGaugesResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): RewardGaugesResponse { + const message = createBaseRewardGaugesResponse(); + message.coins = object.coins?.map((e) => Coin.fromPartial(e)) || []; + message.withdrawnCoins = object.withdrawnCoins?.map((e) => Coin.fromPartial(e)) || []; + return message; + }, +}; + function createBaseQueryRewardGaugesResponse(): QueryRewardGaugesResponse { return { rewardGauges: {} }; } @@ -265,8 +368,8 @@ export const QueryRewardGaugesResponse: MessageFns = fromJSON(object: any): QueryRewardGaugesResponse { return { rewardGauges: isObject(object.rewardGauges) - ? Object.entries(object.rewardGauges).reduce<{ [key: string]: RewardGauge }>((acc, [key, value]) => { - acc[key] = RewardGauge.fromJSON(value); + ? Object.entries(object.rewardGauges).reduce<{ [key: string]: RewardGaugesResponse }>((acc, [key, value]) => { + acc[key] = RewardGaugesResponse.fromJSON(value); return acc; }, {}) : {}, @@ -280,7 +383,7 @@ export const QueryRewardGaugesResponse: MessageFns = if (entries.length > 0) { obj.rewardGauges = {}; entries.forEach(([k, v]) => { - obj.rewardGauges[k] = RewardGauge.toJSON(v); + obj.rewardGauges[k] = RewardGaugesResponse.toJSON(v); }); } } @@ -292,10 +395,10 @@ export const QueryRewardGaugesResponse: MessageFns = }, fromPartial, I>>(object: I): QueryRewardGaugesResponse { const message = createBaseQueryRewardGaugesResponse(); - message.rewardGauges = Object.entries(object.rewardGauges ?? {}).reduce<{ [key: string]: RewardGauge }>( + message.rewardGauges = Object.entries(object.rewardGauges ?? {}).reduce<{ [key: string]: RewardGaugesResponse }>( (acc, [key, value]) => { if (value !== undefined) { - acc[key] = RewardGauge.fromPartial(value); + acc[key] = RewardGaugesResponse.fromPartial(value); } return acc; }, @@ -318,7 +421,7 @@ export const QueryRewardGaugesResponse_RewardGaugesEntry: MessageFns = { + encode(message: BTCStakingGaugeResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + for (const v of message.coins) { + Coin.encode(v!, writer.uint32(10).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): BTCStakingGaugeResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBTCStakingGaugeResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.coins.push(Coin.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): BTCStakingGaugeResponse { + return { coins: globalThis.Array.isArray(object?.coins) ? object.coins.map((e: any) => Coin.fromJSON(e)) : [] }; + }, + + toJSON(message: BTCStakingGaugeResponse): unknown { + const obj: any = {}; + if (message.coins?.length) { + obj.coins = message.coins.map((e) => Coin.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): BTCStakingGaugeResponse { + return BTCStakingGaugeResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): BTCStakingGaugeResponse { + const message = createBaseBTCStakingGaugeResponse(); + message.coins = object.coins?.map((e) => Coin.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseBTCTimestampingGaugeResponse(): BTCTimestampingGaugeResponse { + return { coins: [] }; +} + +export const BTCTimestampingGaugeResponse: MessageFns = { + encode(message: BTCTimestampingGaugeResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + for (const v of message.coins) { + Coin.encode(v!, writer.uint32(10).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): BTCTimestampingGaugeResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBTCTimestampingGaugeResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.coins.push(Coin.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): BTCTimestampingGaugeResponse { + return { coins: globalThis.Array.isArray(object?.coins) ? object.coins.map((e: any) => Coin.fromJSON(e)) : [] }; + }, + + toJSON(message: BTCTimestampingGaugeResponse): unknown { + const obj: any = {}; + if (message.coins?.length) { + obj.coins = message.coins.map((e) => Coin.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): BTCTimestampingGaugeResponse { + return BTCTimestampingGaugeResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): BTCTimestampingGaugeResponse { + const message = createBaseBTCTimestampingGaugeResponse(); + message.coins = object.coins?.map((e) => Coin.fromPartial(e)) || []; + return message; + }, +}; + function createBaseQueryBTCStakingGaugeResponse(): QueryBTCStakingGaugeResponse { return { gauge: undefined }; } @@ -452,7 +669,7 @@ function createBaseQueryBTCStakingGaugeResponse(): QueryBTCStakingGaugeResponse export const QueryBTCStakingGaugeResponse: MessageFns = { encode(message: QueryBTCStakingGaugeResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.gauge !== undefined) { - Gauge.encode(message.gauge, writer.uint32(10).fork()).join(); + BTCStakingGaugeResponse.encode(message.gauge, writer.uint32(10).fork()).join(); } return writer; }, @@ -469,7 +686,7 @@ export const QueryBTCStakingGaugeResponse: MessageFns, I>>(object: I): QueryBTCStakingGaugeResponse { const message = createBaseQueryBTCStakingGaugeResponse(); - message.gauge = (object.gauge !== undefined && object.gauge !== null) ? Gauge.fromPartial(object.gauge) : undefined; + message.gauge = (object.gauge !== undefined && object.gauge !== null) + ? BTCStakingGaugeResponse.fromPartial(object.gauge) + : undefined; return message; }, }; @@ -570,7 +789,7 @@ function createBaseQueryBTCTimestampingGaugeResponse(): QueryBTCTimestampingGaug export const QueryBTCTimestampingGaugeResponse: MessageFns = { encode(message: QueryBTCTimestampingGaugeResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.gauge !== undefined) { - Gauge.encode(message.gauge, writer.uint32(10).fork()).join(); + BTCTimestampingGaugeResponse.encode(message.gauge, writer.uint32(10).fork()).join(); } return writer; }, @@ -587,7 +806,7 @@ export const QueryBTCTimestampingGaugeResponse: MessageFns = { encode(message: QueryEndedEpochBtcHeightResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.btcLightClientHeight !== 0) { - writer.uint32(8).uint64(message.btcLightClientHeight); + writer.uint32(8).uint32(message.btcLightClientHeight); } return writer; }, @@ -127,7 +127,7 @@ export const QueryEndedEpochBtcHeightResponse: MessageFns = { encode(message: QueryReportedCheckpointBtcHeightResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.btcLightClientHeight !== 0) { - writer.uint32(8).uint64(message.btcLightClientHeight); + writer.uint32(8).uint32(message.btcLightClientHeight); } return writer; }, @@ -251,7 +251,7 @@ export const QueryReportedCheckpointBtcHeightResponse: MessageFns