From d86f3bdb8893d4affaae95bee3ea267b3feac558 Mon Sep 17 00:00:00 2001 From: wjrjerome Date: Thu, 7 Nov 2024 20:34:18 +1100 Subject: [PATCH] fix: issue with not able to publish types --- package.json | 5 +- src/generated/babylon/btcstaking/v1/events.ts | 66 +- .../babylon/btcstaking/v1/genesis.ts | 234 +--- src/generated/babylon/btcstaking/v1/params.ts | 22 +- src/generated/babylon/btcstaking/v1/query.ts | 1140 ++-------------- src/generated/babylon/finality/v1/finality.ts | 437 +++++++ src/generated/babylon/finality/v1/genesis.ts | 230 +++- src/generated/babylon/finality/v1/params.ts | 50 +- src/generated/babylon/finality/v1/query.ts | 1147 ++++++++++++++--- src/generated/babylon/mint/v1/genesis.ts | 98 ++ src/generated/babylon/mint/v1/mint.ts | 246 ++++ src/generated/babylon/mint/v1/query.ts | 479 +++++++ src/index.ts | 9 +- tsconfig.json | 3 +- 14 files changed, 2718 insertions(+), 1448 deletions(-) create mode 100644 src/generated/babylon/mint/v1/genesis.ts create mode 100644 src/generated/babylon/mint/v1/mint.ts create mode 100644 src/generated/babylon/mint/v1/query.ts diff --git a/package.json b/package.json index 96554f9..87dc366 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@babylonlabs-io/babylon-proto-ts", - "version": "0.0.3-canary.1", + "version": "0.0.3-canary.2", "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { @@ -8,7 +8,8 @@ "prepublishOnly": "npm run build" }, "files": [ - "src/generated/**/*" + "dist", + "dist/**/*.d.ts" ], "keywords": [], "author": "", diff --git a/src/generated/babylon/btcstaking/v1/events.ts b/src/generated/babylon/btcstaking/v1/events.ts index c1da808..22211dd 100644 --- a/src/generated/babylon/btcstaking/v1/events.ts +++ b/src/generated/babylon/btcstaking/v1/events.ts @@ -220,6 +220,10 @@ export interface EventBTCDelegationCreated { * It uniquely identifies a BTC delegation */ stakingTxHash: string; + /** staking_output_pk_script is the hex encoded PK script of the staking output */ + stakingOutputPkScript: string; + /** staking_output_index is the index of the staking output in the staking tx */ + stakingOutputIndex: string; /** version of the params used to validate the delegation */ paramsVersion: string; /** @@ -1212,6 +1216,8 @@ export const EventFinalityProviderStatusChange: MessageFns = if (message.stakingTxHash !== "") { writer.uint32(10).string(message.stakingTxHash); } + if (message.stakingOutputPkScript !== "") { + writer.uint32(18).string(message.stakingOutputPkScript); + } + if (message.stakingOutputIndex !== "") { + writer.uint32(26).string(message.stakingOutputIndex); + } if (message.paramsVersion !== "") { - writer.uint32(18).string(message.paramsVersion); + writer.uint32(34).string(message.paramsVersion); } for (const v of message.finalityProviderBtcPksHex) { - writer.uint32(26).string(v!); + writer.uint32(42).string(v!); } if (message.stakerBtcPkHex !== "") { - writer.uint32(34).string(message.stakerBtcPkHex); + writer.uint32(50).string(message.stakerBtcPkHex); } if (message.stakingTime !== "") { - writer.uint32(42).string(message.stakingTime); + writer.uint32(58).string(message.stakingTime); } if (message.stakingAmount !== "") { - writer.uint32(50).string(message.stakingAmount); + writer.uint32(66).string(message.stakingAmount); } if (message.unbondingTime !== "") { - writer.uint32(58).string(message.unbondingTime); + writer.uint32(74).string(message.unbondingTime); } if (message.unbondingTx !== "") { - writer.uint32(66).string(message.unbondingTx); + writer.uint32(82).string(message.unbondingTx); } if (message.newState !== "") { - writer.uint32(74).string(message.newState); + writer.uint32(90).string(message.newState); } return writer; }, @@ -1274,55 +1286,69 @@ export const EventBTCDelegationCreated: MessageFns = break; } - message.paramsVersion = reader.string(); + message.stakingOutputPkScript = reader.string(); continue; case 3: if (tag !== 26) { break; } - message.finalityProviderBtcPksHex.push(reader.string()); + message.stakingOutputIndex = reader.string(); continue; case 4: if (tag !== 34) { break; } - message.stakerBtcPkHex = reader.string(); + message.paramsVersion = reader.string(); continue; case 5: if (tag !== 42) { break; } - message.stakingTime = reader.string(); + message.finalityProviderBtcPksHex.push(reader.string()); continue; case 6: if (tag !== 50) { break; } - message.stakingAmount = reader.string(); + message.stakerBtcPkHex = reader.string(); continue; case 7: if (tag !== 58) { break; } - message.unbondingTime = reader.string(); + message.stakingTime = reader.string(); continue; case 8: if (tag !== 66) { break; } - message.unbondingTx = reader.string(); + message.stakingAmount = reader.string(); continue; case 9: if (tag !== 74) { break; } + message.unbondingTime = reader.string(); + continue; + case 10: + if (tag !== 82) { + break; + } + + message.unbondingTx = reader.string(); + continue; + case 11: + if (tag !== 90) { + break; + } + message.newState = reader.string(); continue; } @@ -1337,6 +1363,8 @@ export const EventBTCDelegationCreated: MessageFns = fromJSON(object: any): EventBTCDelegationCreated { return { stakingTxHash: isSet(object.stakingTxHash) ? globalThis.String(object.stakingTxHash) : "", + stakingOutputPkScript: isSet(object.stakingOutputPkScript) ? globalThis.String(object.stakingOutputPkScript) : "", + stakingOutputIndex: isSet(object.stakingOutputIndex) ? globalThis.String(object.stakingOutputIndex) : "", paramsVersion: isSet(object.paramsVersion) ? globalThis.String(object.paramsVersion) : "", finalityProviderBtcPksHex: globalThis.Array.isArray(object?.finalityProviderBtcPksHex) ? object.finalityProviderBtcPksHex.map((e: any) => globalThis.String(e)) @@ -1355,6 +1383,12 @@ export const EventBTCDelegationCreated: MessageFns = if (message.stakingTxHash !== "") { obj.stakingTxHash = message.stakingTxHash; } + if (message.stakingOutputPkScript !== "") { + obj.stakingOutputPkScript = message.stakingOutputPkScript; + } + if (message.stakingOutputIndex !== "") { + obj.stakingOutputIndex = message.stakingOutputIndex; + } if (message.paramsVersion !== "") { obj.paramsVersion = message.paramsVersion; } @@ -1388,6 +1422,8 @@ export const EventBTCDelegationCreated: MessageFns = fromPartial, I>>(object: I): EventBTCDelegationCreated { const message = createBaseEventBTCDelegationCreated(); message.stakingTxHash = object.stakingTxHash ?? ""; + message.stakingOutputPkScript = object.stakingOutputPkScript ?? ""; + message.stakingOutputIndex = object.stakingOutputIndex ?? ""; message.paramsVersion = object.paramsVersion ?? ""; message.finalityProviderBtcPksHex = object.finalityProviderBtcPksHex?.map((e) => e) || []; message.stakerBtcPkHex = object.stakerBtcPkHex ?? ""; diff --git a/src/generated/babylon/btcstaking/v1/genesis.ts b/src/generated/babylon/btcstaking/v1/genesis.ts index cee18c1..23d16a6 100644 --- a/src/generated/babylon/btcstaking/v1/genesis.ts +++ b/src/generated/babylon/btcstaking/v1/genesis.ts @@ -8,7 +8,6 @@ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; import { BTCDelegation, BTCDelegatorDelegationIndex, FinalityProvider } from "./btcstaking"; import { EventPowerDistUpdate } from "./events"; -import { VotingPowerDistCache } from "./incentive"; import { Params } from "./params"; export const protobufPackage = "babylon.btcstaking.v1"; @@ -21,40 +20,12 @@ export interface GenesisState { finalityProviders: FinalityProvider[]; /** btc_delegations all the btc delegations in the state. */ btcDelegations: BTCDelegation[]; - /** voting_powers the voting power of every finality provider at every block height. */ - votingPowers: VotingPowerFP[]; /** block_height_chains the block height of babylon and bitcoin. */ blockHeightChains: BlockHeightBbnToBtc[]; /** btc_delegators contains all the btc delegators with the associated finality provider. */ btcDelegators: BTCDelegator[]; /** all the events and its indexes. */ events: EventIndex[]; - /** - * vp_dst_cache is the table of all providers voting power with the total at one specific block. - * TODO: remove this after not storing in the keeper store it anymore. - */ - vpDstCache: VotingPowerDistCacheBlkHeight[]; -} - -/** - * VotingPowerFP contains the information about the voting power - * of an finality provider in a specific block height. - */ -export interface VotingPowerFP { - /** block_height is the height of the block the voting power was stored. */ - blockHeight: number; - /** fp_btc_pk the finality provider btc public key. */ - fpBtcPk: Uint8Array; - /** voting_power is the power of the finality provider at this specific block height. */ - votingPower: number; -} - -/** VotingPowerDistCacheBlkHeight the total voting power of the finality providers at one specific block height */ -export interface VotingPowerDistCacheBlkHeight { - /** block_height is the height of the block the voting power distribution cached was stored. */ - blockHeight: number; - /** vp_distribution the finality providers distribution cache at that height. */ - vpDistribution: VotingPowerDistCache | undefined; } /** BlockHeightBbnToBtc stores the btc <-> bbn block. */ @@ -92,11 +63,9 @@ function createBaseGenesisState(): GenesisState { params: [], finalityProviders: [], btcDelegations: [], - votingPowers: [], blockHeightChains: [], btcDelegators: [], events: [], - vpDstCache: [], }; } @@ -111,9 +80,6 @@ export const GenesisState: MessageFns = { for (const v of message.btcDelegations) { BTCDelegation.encode(v!, writer.uint32(26).fork()).join(); } - for (const v of message.votingPowers) { - VotingPowerFP.encode(v!, writer.uint32(34).fork()).join(); - } for (const v of message.blockHeightChains) { BlockHeightBbnToBtc.encode(v!, writer.uint32(42).fork()).join(); } @@ -123,9 +89,6 @@ export const GenesisState: MessageFns = { for (const v of message.events) { EventIndex.encode(v!, writer.uint32(58).fork()).join(); } - for (const v of message.vpDstCache) { - VotingPowerDistCacheBlkHeight.encode(v!, writer.uint32(66).fork()).join(); - } return writer; }, @@ -157,13 +120,6 @@ export const GenesisState: MessageFns = { message.btcDelegations.push(BTCDelegation.decode(reader, reader.uint32())); continue; - case 4: - if (tag !== 34) { - break; - } - - message.votingPowers.push(VotingPowerFP.decode(reader, reader.uint32())); - continue; case 5: if (tag !== 42) { break; @@ -185,13 +141,6 @@ export const GenesisState: MessageFns = { message.events.push(EventIndex.decode(reader, reader.uint32())); continue; - case 8: - if (tag !== 66) { - break; - } - - message.vpDstCache.push(VotingPowerDistCacheBlkHeight.decode(reader, reader.uint32())); - continue; } if ((tag & 7) === 4 || tag === 0) { break; @@ -210,18 +159,14 @@ export const GenesisState: MessageFns = { btcDelegations: globalThis.Array.isArray(object?.btcDelegations) ? object.btcDelegations.map((e: any) => BTCDelegation.fromJSON(e)) : [], - votingPowers: globalThis.Array.isArray(object?.votingPowers) - ? object.votingPowers.map((e: any) => VotingPowerFP.fromJSON(e)) - : [], blockHeightChains: globalThis.Array.isArray(object?.blockHeightChains) ? object.blockHeightChains.map((e: any) => BlockHeightBbnToBtc.fromJSON(e)) : [], btcDelegators: globalThis.Array.isArray(object?.btcDelegators) ? object.btcDelegators.map((e: any) => BTCDelegator.fromJSON(e)) : [], - events: globalThis.Array.isArray(object?.events) ? object.events.map((e: any) => EventIndex.fromJSON(e)) : [], - vpDstCache: globalThis.Array.isArray(object?.vpDstCache) - ? object.vpDstCache.map((e: any) => VotingPowerDistCacheBlkHeight.fromJSON(e)) + events: globalThis.Array.isArray(object?.events) + ? object.events.map((e: any) => EventIndex.fromJSON(e)) : [], }; }, @@ -237,9 +182,6 @@ export const GenesisState: MessageFns = { if (message.btcDelegations?.length) { obj.btcDelegations = message.btcDelegations.map((e) => BTCDelegation.toJSON(e)); } - if (message.votingPowers?.length) { - obj.votingPowers = message.votingPowers.map((e) => VotingPowerFP.toJSON(e)); - } if (message.blockHeightChains?.length) { obj.blockHeightChains = message.blockHeightChains.map((e) => BlockHeightBbnToBtc.toJSON(e)); } @@ -249,9 +191,6 @@ export const GenesisState: MessageFns = { if (message.events?.length) { obj.events = message.events.map((e) => EventIndex.toJSON(e)); } - if (message.vpDstCache?.length) { - obj.vpDstCache = message.vpDstCache.map((e) => VotingPowerDistCacheBlkHeight.toJSON(e)); - } return obj; }, @@ -263,178 +202,9 @@ export const GenesisState: MessageFns = { message.params = object.params?.map((e) => Params.fromPartial(e)) || []; message.finalityProviders = object.finalityProviders?.map((e) => FinalityProvider.fromPartial(e)) || []; message.btcDelegations = object.btcDelegations?.map((e) => BTCDelegation.fromPartial(e)) || []; - message.votingPowers = object.votingPowers?.map((e) => VotingPowerFP.fromPartial(e)) || []; message.blockHeightChains = object.blockHeightChains?.map((e) => BlockHeightBbnToBtc.fromPartial(e)) || []; message.btcDelegators = object.btcDelegators?.map((e) => BTCDelegator.fromPartial(e)) || []; message.events = object.events?.map((e) => EventIndex.fromPartial(e)) || []; - message.vpDstCache = object.vpDstCache?.map((e) => VotingPowerDistCacheBlkHeight.fromPartial(e)) || []; - return message; - }, -}; - -function createBaseVotingPowerFP(): VotingPowerFP { - return { blockHeight: 0, fpBtcPk: new Uint8Array(0), votingPower: 0 }; -} - -export const VotingPowerFP: MessageFns = { - encode(message: VotingPowerFP, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.blockHeight !== 0) { - writer.uint32(8).uint64(message.blockHeight); - } - if (message.fpBtcPk.length !== 0) { - writer.uint32(18).bytes(message.fpBtcPk); - } - if (message.votingPower !== 0) { - writer.uint32(24).uint64(message.votingPower); - } - return writer; - }, - - decode(input: BinaryReader | Uint8Array, length?: number): VotingPowerFP { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseVotingPowerFP(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.blockHeight = longToNumber(reader.uint64()); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.fpBtcPk = reader.bytes(); - 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): VotingPowerFP { - return { - blockHeight: isSet(object.blockHeight) ? globalThis.Number(object.blockHeight) : 0, - fpBtcPk: isSet(object.fpBtcPk) ? bytesFromBase64(object.fpBtcPk) : new Uint8Array(0), - votingPower: isSet(object.votingPower) ? globalThis.Number(object.votingPower) : 0, - }; - }, - - toJSON(message: VotingPowerFP): unknown { - const obj: any = {}; - if (message.blockHeight !== 0) { - obj.blockHeight = Math.round(message.blockHeight); - } - if (message.fpBtcPk.length !== 0) { - obj.fpBtcPk = base64FromBytes(message.fpBtcPk); - } - if (message.votingPower !== 0) { - obj.votingPower = Math.round(message.votingPower); - } - return obj; - }, - - create, I>>(base?: I): VotingPowerFP { - return VotingPowerFP.fromPartial(base ?? ({} as any)); - }, - fromPartial, I>>(object: I): VotingPowerFP { - const message = createBaseVotingPowerFP(); - message.blockHeight = object.blockHeight ?? 0; - message.fpBtcPk = object.fpBtcPk ?? new Uint8Array(0); - message.votingPower = object.votingPower ?? 0; - return message; - }, -}; - -function createBaseVotingPowerDistCacheBlkHeight(): VotingPowerDistCacheBlkHeight { - return { blockHeight: 0, vpDistribution: undefined }; -} - -export const VotingPowerDistCacheBlkHeight: MessageFns = { - encode(message: VotingPowerDistCacheBlkHeight, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.blockHeight !== 0) { - writer.uint32(8).uint64(message.blockHeight); - } - if (message.vpDistribution !== undefined) { - VotingPowerDistCache.encode(message.vpDistribution, writer.uint32(18).fork()).join(); - } - return writer; - }, - - decode(input: BinaryReader | Uint8Array, length?: number): VotingPowerDistCacheBlkHeight { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseVotingPowerDistCacheBlkHeight(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.blockHeight = longToNumber(reader.uint64()); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.vpDistribution = VotingPowerDistCache.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skip(tag & 7); - } - return message; - }, - - fromJSON(object: any): VotingPowerDistCacheBlkHeight { - return { - blockHeight: isSet(object.blockHeight) ? globalThis.Number(object.blockHeight) : 0, - vpDistribution: isSet(object.vpDistribution) ? VotingPowerDistCache.fromJSON(object.vpDistribution) : undefined, - }; - }, - - toJSON(message: VotingPowerDistCacheBlkHeight): unknown { - const obj: any = {}; - if (message.blockHeight !== 0) { - obj.blockHeight = Math.round(message.blockHeight); - } - if (message.vpDistribution !== undefined) { - obj.vpDistribution = VotingPowerDistCache.toJSON(message.vpDistribution); - } - return obj; - }, - - create, I>>(base?: I): VotingPowerDistCacheBlkHeight { - return VotingPowerDistCacheBlkHeight.fromPartial(base ?? ({} as any)); - }, - fromPartial, I>>( - object: I, - ): VotingPowerDistCacheBlkHeight { - const message = createBaseVotingPowerDistCacheBlkHeight(); - message.blockHeight = object.blockHeight ?? 0; - message.vpDistribution = (object.vpDistribution !== undefined && object.vpDistribution !== null) - ? VotingPowerDistCache.fromPartial(object.vpDistribution) - : undefined; return message; }, }; diff --git a/src/generated/babylon/btcstaking/v1/params.ts b/src/generated/babylon/btcstaking/v1/params.ts index 3faceb0..30e01c9 100644 --- a/src/generated/babylon/btcstaking/v1/params.ts +++ b/src/generated/babylon/btcstaking/v1/params.ts @@ -62,8 +62,6 @@ export interface Params { * is 2 decimal places */ 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; } @@ -93,7 +91,6 @@ function createBaseParams(): Params { minUnbondingTimeBlocks: 0, unbondingFeeSat: 0, minCommissionRate: "", - maxActiveFinalityProviders: 0, delegationCreationBaseGasFee: 0, }; } @@ -136,11 +133,8 @@ export const Params: MessageFns = { 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); + writer.uint32(104).uint64(message.delegationCreationBaseGasFee); } return writer; }, @@ -241,13 +235,6 @@ export const Params: MessageFns = { break; } - message.maxActiveFinalityProviders = reader.uint32(); - continue; - case 14: - if (tag !== 112) { - break; - } - message.delegationCreationBaseGasFee = longToNumber(reader.uint64()); continue; } @@ -277,9 +264,6 @@ export const Params: MessageFns = { : 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, delegationCreationBaseGasFee: isSet(object.delegationCreationBaseGasFee) ? globalThis.Number(object.delegationCreationBaseGasFee) : 0, @@ -324,9 +308,6 @@ export const Params: MessageFns = { if (message.minCommissionRate !== "") { obj.minCommissionRate = message.minCommissionRate; } - if (message.maxActiveFinalityProviders !== 0) { - obj.maxActiveFinalityProviders = Math.round(message.maxActiveFinalityProviders); - } if (message.delegationCreationBaseGasFee !== 0) { obj.delegationCreationBaseGasFee = Math.round(message.delegationCreationBaseGasFee); } @@ -350,7 +331,6 @@ export const Params: MessageFns = { message.minUnbondingTimeBlocks = object.minUnbondingTimeBlocks ?? 0; message.unbondingFeeSat = object.unbondingFeeSat ?? 0; message.minCommissionRate = object.minCommissionRate ?? ""; - message.maxActiveFinalityProviders = object.maxActiveFinalityProviders ?? 0; 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 dc3f3ef..31d6243 100644 --- a/src/generated/babylon/btcstaking/v1/query.ts +++ b/src/generated/babylon/btcstaking/v1/query.ts @@ -95,112 +95,6 @@ export interface QueryBTCDelegationsResponse { pagination: PageResponse | undefined; } -/** - * QueryFinalityProviderPowerAtHeightRequest is the request type for the - * Query/FinalityProviderPowerAtHeight RPC method. - */ -export interface QueryFinalityProviderPowerAtHeightRequest { - /** - * fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that - * this BTC delegation delegates to - * the PK follows encoding in BIP-340 spec - */ - fpBtcPkHex: string; - /** height is used for querying the given finality provider's voting power at this height */ - height: number; -} - -/** - * QueryFinalityProviderPowerAtHeightResponse is the response type for the - * Query/FinalityProviderPowerAtHeight RPC method. - */ -export interface QueryFinalityProviderPowerAtHeightResponse { - /** voting_power is the voting power of the finality provider */ - votingPower: number; -} - -/** - * QueryFinalityProviderCurrentPowerRequest is the request type for the - * Query/FinalityProviderCurrentPower RPC method. - */ -export interface QueryFinalityProviderCurrentPowerRequest { - /** - * fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that - * this BTC delegation delegates to - * the PK follows encoding in BIP-340 spec - */ - fpBtcPkHex: string; -} - -/** - * QueryFinalityProviderCurrentPowerResponse is the response type for the - * Query/FinalityProviderCurrentPower RPC method. - */ -export interface QueryFinalityProviderCurrentPowerResponse { - /** height is the current height */ - height: number; - /** voting_power is the voting power of the finality provider */ - votingPower: number; -} - -/** - * QueryActiveFinalityProvidersAtHeightRequest is the request type for the - * Query/ActiveFinalityProvidersAtHeight RPC method. - */ -export interface QueryActiveFinalityProvidersAtHeightRequest { - /** height defines at which Babylon height to query the finality providers info. */ - height: number; - /** pagination defines an optional pagination for the request. */ - 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: ActiveFinalityProvidersAtHeightResponse[]; - /** pagination defines the pagination in the response. */ - pagination: PageResponse | undefined; -} - -/** QueryActivatedHeightRequest is the request type for the Query/ActivatedHeight RPC method. */ -export interface QueryActivatedHeightRequest { -} - -/** QueryActivatedHeightResponse is the response type for the Query/ActivatedHeight RPC method. */ -export interface QueryActivatedHeightResponse { - height: number; -} - /** * QueryFinalityProviderDelegationsRequest is the request type for the * Query/FinalityProviderDelegations RPC method. @@ -399,8 +293,6 @@ export interface FinalityProviderResponse { slashedBtcHeight: number; /** height is the queried Babylon height */ height: number; - /** voting_power is the voting power of this finality provider at the given height */ - votingPower: number; /** jailed defines whether the finality provider is jailed */ jailed: boolean; } @@ -740,698 +632,46 @@ export const QueryFinalityProvidersResponse: MessageFns FinalityProviderResponse.toJSON(e)); - } - if (message.pagination !== undefined) { - obj.pagination = PageResponse.toJSON(message.pagination); - } - return obj; - }, - - create, I>>(base?: I): QueryFinalityProvidersResponse { - return QueryFinalityProvidersResponse.fromPartial(base ?? ({} as any)); - }, - fromPartial, I>>( - object: I, - ): QueryFinalityProvidersResponse { - const message = createBaseQueryFinalityProvidersResponse(); - message.finalityProviders = object.finalityProviders?.map((e) => FinalityProviderResponse.fromPartial(e)) || []; - message.pagination = (object.pagination !== undefined && object.pagination !== null) - ? PageResponse.fromPartial(object.pagination) - : undefined; - return message; - }, -}; - -function createBaseQueryFinalityProviderRequest(): QueryFinalityProviderRequest { - return { fpBtcPkHex: "" }; -} - -export const QueryFinalityProviderRequest: MessageFns = { - encode(message: QueryFinalityProviderRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.fpBtcPkHex !== "") { - writer.uint32(10).string(message.fpBtcPkHex); - } - return writer; - }, - - decode(input: BinaryReader | Uint8Array, length?: number): QueryFinalityProviderRequest { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseQueryFinalityProviderRequest(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.fpBtcPkHex = reader.string(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skip(tag & 7); - } - return message; - }, - - fromJSON(object: any): QueryFinalityProviderRequest { - return { fpBtcPkHex: isSet(object.fpBtcPkHex) ? globalThis.String(object.fpBtcPkHex) : "" }; - }, - - toJSON(message: QueryFinalityProviderRequest): unknown { - const obj: any = {}; - if (message.fpBtcPkHex !== "") { - obj.fpBtcPkHex = message.fpBtcPkHex; - } - return obj; - }, - - create, I>>(base?: I): QueryFinalityProviderRequest { - return QueryFinalityProviderRequest.fromPartial(base ?? ({} as any)); - }, - fromPartial, I>>(object: I): QueryFinalityProviderRequest { - const message = createBaseQueryFinalityProviderRequest(); - message.fpBtcPkHex = object.fpBtcPkHex ?? ""; - return message; - }, -}; - -function createBaseQueryFinalityProviderResponse(): QueryFinalityProviderResponse { - return { finalityProvider: undefined }; -} - -export const QueryFinalityProviderResponse: MessageFns = { - encode(message: QueryFinalityProviderResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.finalityProvider !== undefined) { - FinalityProviderResponse.encode(message.finalityProvider, writer.uint32(10).fork()).join(); - } - return writer; - }, - - decode(input: BinaryReader | Uint8Array, length?: number): QueryFinalityProviderResponse { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseQueryFinalityProviderResponse(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.finalityProvider = FinalityProviderResponse.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skip(tag & 7); - } - return message; - }, - - fromJSON(object: any): QueryFinalityProviderResponse { - return { - finalityProvider: isSet(object.finalityProvider) - ? FinalityProviderResponse.fromJSON(object.finalityProvider) - : undefined, - }; - }, - - toJSON(message: QueryFinalityProviderResponse): unknown { - const obj: any = {}; - if (message.finalityProvider !== undefined) { - obj.finalityProvider = FinalityProviderResponse.toJSON(message.finalityProvider); - } - return obj; - }, - - create, I>>(base?: I): QueryFinalityProviderResponse { - return QueryFinalityProviderResponse.fromPartial(base ?? ({} as any)); - }, - fromPartial, I>>( - object: I, - ): QueryFinalityProviderResponse { - const message = createBaseQueryFinalityProviderResponse(); - message.finalityProvider = (object.finalityProvider !== undefined && object.finalityProvider !== null) - ? FinalityProviderResponse.fromPartial(object.finalityProvider) - : undefined; - return message; - }, -}; - -function createBaseQueryBTCDelegationsRequest(): QueryBTCDelegationsRequest { - return { status: 0, pagination: undefined }; -} - -export const QueryBTCDelegationsRequest: MessageFns = { - encode(message: QueryBTCDelegationsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.status !== 0) { - writer.uint32(8).int32(message.status); - } - if (message.pagination !== undefined) { - PageRequest.encode(message.pagination, writer.uint32(18).fork()).join(); - } - return writer; - }, - - decode(input: BinaryReader | Uint8Array, length?: number): QueryBTCDelegationsRequest { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseQueryBTCDelegationsRequest(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.status = reader.int32() as any; - continue; - case 2: - if (tag !== 18) { - break; - } - - message.pagination = PageRequest.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skip(tag & 7); - } - return message; - }, - - fromJSON(object: any): QueryBTCDelegationsRequest { - return { - status: isSet(object.status) ? bTCDelegationStatusFromJSON(object.status) : 0, - pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, - }; - }, - - toJSON(message: QueryBTCDelegationsRequest): unknown { - const obj: any = {}; - if (message.status !== 0) { - obj.status = bTCDelegationStatusToJSON(message.status); - } - if (message.pagination !== undefined) { - obj.pagination = PageRequest.toJSON(message.pagination); - } - return obj; - }, - - create, I>>(base?: I): QueryBTCDelegationsRequest { - return QueryBTCDelegationsRequest.fromPartial(base ?? ({} as any)); - }, - fromPartial, I>>(object: I): QueryBTCDelegationsRequest { - const message = createBaseQueryBTCDelegationsRequest(); - message.status = object.status ?? 0; - message.pagination = (object.pagination !== undefined && object.pagination !== null) - ? PageRequest.fromPartial(object.pagination) - : undefined; - return message; - }, -}; - -function createBaseQueryBTCDelegationsResponse(): QueryBTCDelegationsResponse { - return { btcDelegations: [], pagination: undefined }; -} - -export const QueryBTCDelegationsResponse: MessageFns = { - encode(message: QueryBTCDelegationsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - for (const v of message.btcDelegations) { - BTCDelegationResponse.encode(v!, writer.uint32(10).fork()).join(); - } - if (message.pagination !== undefined) { - PageResponse.encode(message.pagination, writer.uint32(18).fork()).join(); - } - return writer; - }, - - decode(input: BinaryReader | Uint8Array, length?: number): QueryBTCDelegationsResponse { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseQueryBTCDelegationsResponse(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.btcDelegations.push(BTCDelegationResponse.decode(reader, reader.uint32())); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.pagination = PageResponse.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skip(tag & 7); - } - return message; - }, - - fromJSON(object: any): QueryBTCDelegationsResponse { - return { - btcDelegations: globalThis.Array.isArray(object?.btcDelegations) - ? object.btcDelegations.map((e: any) => BTCDelegationResponse.fromJSON(e)) - : [], - pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, - }; - }, - - toJSON(message: QueryBTCDelegationsResponse): unknown { - const obj: any = {}; - if (message.btcDelegations?.length) { - obj.btcDelegations = message.btcDelegations.map((e) => BTCDelegationResponse.toJSON(e)); - } - if (message.pagination !== undefined) { - obj.pagination = PageResponse.toJSON(message.pagination); - } - return obj; - }, - - create, I>>(base?: I): QueryBTCDelegationsResponse { - return QueryBTCDelegationsResponse.fromPartial(base ?? ({} as any)); - }, - fromPartial, I>>(object: I): QueryBTCDelegationsResponse { - const message = createBaseQueryBTCDelegationsResponse(); - message.btcDelegations = object.btcDelegations?.map((e) => BTCDelegationResponse.fromPartial(e)) || []; - message.pagination = (object.pagination !== undefined && object.pagination !== null) - ? PageResponse.fromPartial(object.pagination) - : undefined; - return message; - }, -}; - -function createBaseQueryFinalityProviderPowerAtHeightRequest(): QueryFinalityProviderPowerAtHeightRequest { - return { fpBtcPkHex: "", height: 0 }; -} - -export const QueryFinalityProviderPowerAtHeightRequest: MessageFns = { - encode(message: QueryFinalityProviderPowerAtHeightRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.fpBtcPkHex !== "") { - writer.uint32(10).string(message.fpBtcPkHex); - } - if (message.height !== 0) { - writer.uint32(16).uint64(message.height); - } - return writer; - }, - - decode(input: BinaryReader | Uint8Array, length?: number): QueryFinalityProviderPowerAtHeightRequest { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseQueryFinalityProviderPowerAtHeightRequest(); - 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.height = longToNumber(reader.uint64()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skip(tag & 7); - } - return message; - }, - - fromJSON(object: any): QueryFinalityProviderPowerAtHeightRequest { - return { - fpBtcPkHex: isSet(object.fpBtcPkHex) ? globalThis.String(object.fpBtcPkHex) : "", - height: isSet(object.height) ? globalThis.Number(object.height) : 0, - }; - }, - - toJSON(message: QueryFinalityProviderPowerAtHeightRequest): unknown { - const obj: any = {}; - if (message.fpBtcPkHex !== "") { - obj.fpBtcPkHex = message.fpBtcPkHex; - } - if (message.height !== 0) { - obj.height = Math.round(message.height); - } - return obj; - }, - - create, I>>( - base?: I, - ): QueryFinalityProviderPowerAtHeightRequest { - return QueryFinalityProviderPowerAtHeightRequest.fromPartial(base ?? ({} as any)); - }, - fromPartial, I>>( - object: I, - ): QueryFinalityProviderPowerAtHeightRequest { - const message = createBaseQueryFinalityProviderPowerAtHeightRequest(); - message.fpBtcPkHex = object.fpBtcPkHex ?? ""; - message.height = object.height ?? 0; - return message; - }, -}; - -function createBaseQueryFinalityProviderPowerAtHeightResponse(): QueryFinalityProviderPowerAtHeightResponse { - return { votingPower: 0 }; -} - -export const QueryFinalityProviderPowerAtHeightResponse: MessageFns = { - encode(message: QueryFinalityProviderPowerAtHeightResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.votingPower !== 0) { - writer.uint32(8).uint64(message.votingPower); - } - return writer; - }, - - decode(input: BinaryReader | Uint8Array, length?: number): QueryFinalityProviderPowerAtHeightResponse { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseQueryFinalityProviderPowerAtHeightResponse(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.votingPower = longToNumber(reader.uint64()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skip(tag & 7); - } - return message; - }, - - fromJSON(object: any): QueryFinalityProviderPowerAtHeightResponse { - return { votingPower: isSet(object.votingPower) ? globalThis.Number(object.votingPower) : 0 }; - }, - - toJSON(message: QueryFinalityProviderPowerAtHeightResponse): unknown { - const obj: any = {}; - if (message.votingPower !== 0) { - obj.votingPower = Math.round(message.votingPower); - } - return obj; - }, - - create, I>>( - base?: I, - ): QueryFinalityProviderPowerAtHeightResponse { - return QueryFinalityProviderPowerAtHeightResponse.fromPartial(base ?? ({} as any)); - }, - fromPartial, I>>( - object: I, - ): QueryFinalityProviderPowerAtHeightResponse { - const message = createBaseQueryFinalityProviderPowerAtHeightResponse(); - message.votingPower = object.votingPower ?? 0; - return message; - }, -}; - -function createBaseQueryFinalityProviderCurrentPowerRequest(): QueryFinalityProviderCurrentPowerRequest { - return { fpBtcPkHex: "" }; -} - -export const QueryFinalityProviderCurrentPowerRequest: MessageFns = { - encode(message: QueryFinalityProviderCurrentPowerRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.fpBtcPkHex !== "") { - writer.uint32(10).string(message.fpBtcPkHex); - } - return writer; - }, - - decode(input: BinaryReader | Uint8Array, length?: number): QueryFinalityProviderCurrentPowerRequest { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseQueryFinalityProviderCurrentPowerRequest(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 10) { - break; - } - - message.fpBtcPkHex = reader.string(); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skip(tag & 7); - } - return message; - }, - - fromJSON(object: any): QueryFinalityProviderCurrentPowerRequest { - return { fpBtcPkHex: isSet(object.fpBtcPkHex) ? globalThis.String(object.fpBtcPkHex) : "" }; - }, - - toJSON(message: QueryFinalityProviderCurrentPowerRequest): unknown { - const obj: any = {}; - if (message.fpBtcPkHex !== "") { - obj.fpBtcPkHex = message.fpBtcPkHex; - } - return obj; - }, - - create, I>>( - base?: I, - ): QueryFinalityProviderCurrentPowerRequest { - return QueryFinalityProviderCurrentPowerRequest.fromPartial(base ?? ({} as any)); - }, - fromPartial, I>>( - object: I, - ): QueryFinalityProviderCurrentPowerRequest { - const message = createBaseQueryFinalityProviderCurrentPowerRequest(); - message.fpBtcPkHex = object.fpBtcPkHex ?? ""; - return message; - }, -}; - -function createBaseQueryFinalityProviderCurrentPowerResponse(): QueryFinalityProviderCurrentPowerResponse { - return { height: 0, votingPower: 0 }; -} - -export const QueryFinalityProviderCurrentPowerResponse: MessageFns = { - encode(message: QueryFinalityProviderCurrentPowerResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.height !== 0) { - writer.uint32(8).uint64(message.height); - } - if (message.votingPower !== 0) { - writer.uint32(16).uint64(message.votingPower); - } - return writer; - }, - - decode(input: BinaryReader | Uint8Array, length?: number): QueryFinalityProviderCurrentPowerResponse { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseQueryFinalityProviderCurrentPowerResponse(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.height = longToNumber(reader.uint64()); - continue; - case 2: - if (tag !== 16) { - break; - } - - message.votingPower = longToNumber(reader.uint64()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skip(tag & 7); - } - return message; - }, - - fromJSON(object: any): QueryFinalityProviderCurrentPowerResponse { - return { - height: isSet(object.height) ? globalThis.Number(object.height) : 0, - votingPower: isSet(object.votingPower) ? globalThis.Number(object.votingPower) : 0, - }; - }, - - toJSON(message: QueryFinalityProviderCurrentPowerResponse): unknown { - const obj: any = {}; - if (message.height !== 0) { - obj.height = Math.round(message.height); - } - if (message.votingPower !== 0) { - obj.votingPower = Math.round(message.votingPower); - } - return obj; - }, - - create, I>>( - base?: I, - ): QueryFinalityProviderCurrentPowerResponse { - return QueryFinalityProviderCurrentPowerResponse.fromPartial(base ?? ({} as any)); - }, - fromPartial, I>>( - object: I, - ): QueryFinalityProviderCurrentPowerResponse { - const message = createBaseQueryFinalityProviderCurrentPowerResponse(); - message.height = object.height ?? 0; - message.votingPower = object.votingPower ?? 0; - return message; - }, -}; - -function createBaseQueryActiveFinalityProvidersAtHeightRequest(): QueryActiveFinalityProvidersAtHeightRequest { - return { height: 0, pagination: undefined }; -} - -export const QueryActiveFinalityProvidersAtHeightRequest: MessageFns = { - encode( - message: QueryActiveFinalityProvidersAtHeightRequest, - writer: BinaryWriter = new BinaryWriter(), - ): BinaryWriter { - if (message.height !== 0) { - writer.uint32(8).uint64(message.height); - } - if (message.pagination !== undefined) { - PageRequest.encode(message.pagination, writer.uint32(18).fork()).join(); - } - return writer; - }, - - decode(input: BinaryReader | Uint8Array, length?: number): QueryActiveFinalityProvidersAtHeightRequest { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseQueryActiveFinalityProvidersAtHeightRequest(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (tag !== 8) { - break; - } - - message.height = longToNumber(reader.uint64()); - continue; - case 2: - if (tag !== 18) { - break; - } - - message.pagination = PageRequest.decode(reader, reader.uint32()); - continue; - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skip(tag & 7); - } - return message; - }, - - fromJSON(object: any): QueryActiveFinalityProvidersAtHeightRequest { - return { - height: isSet(object.height) ? globalThis.Number(object.height) : 0, - pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, - }; - }, - - toJSON(message: QueryActiveFinalityProvidersAtHeightRequest): unknown { - const obj: any = {}; - if (message.height !== 0) { - obj.height = Math.round(message.height); + if (message.finalityProviders?.length) { + obj.finalityProviders = message.finalityProviders.map((e) => FinalityProviderResponse.toJSON(e)); } if (message.pagination !== undefined) { - obj.pagination = PageRequest.toJSON(message.pagination); + obj.pagination = PageResponse.toJSON(message.pagination); } return obj; }, - create, I>>( - base?: I, - ): QueryActiveFinalityProvidersAtHeightRequest { - return QueryActiveFinalityProvidersAtHeightRequest.fromPartial(base ?? ({} as any)); + create, I>>(base?: I): QueryFinalityProvidersResponse { + return QueryFinalityProvidersResponse.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>( + fromPartial, I>>( object: I, - ): QueryActiveFinalityProvidersAtHeightRequest { - const message = createBaseQueryActiveFinalityProvidersAtHeightRequest(); - message.height = object.height ?? 0; + ): QueryFinalityProvidersResponse { + const message = createBaseQueryFinalityProvidersResponse(); + message.finalityProviders = object.finalityProviders?.map((e) => FinalityProviderResponse.fromPartial(e)) || []; message.pagination = (object.pagination !== undefined && object.pagination !== null) - ? PageRequest.fromPartial(object.pagination) + ? PageResponse.fromPartial(object.pagination) : undefined; return message; }, }; -function createBaseActiveFinalityProvidersAtHeightResponse(): ActiveFinalityProvidersAtHeightResponse { - return { btcPkHex: "", height: 0, votingPower: 0, slashedBabylonHeight: 0, slashedBtcHeight: 0, jailed: false }; +function createBaseQueryFinalityProviderRequest(): QueryFinalityProviderRequest { + return { fpBtcPkHex: "" }; } -export const ActiveFinalityProvidersAtHeightResponse: 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); +export const QueryFinalityProviderRequest: MessageFns = { + encode(message: QueryFinalityProviderRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.fpBtcPkHex !== "") { + writer.uint32(10).string(message.fpBtcPkHex); } return writer; }, - decode(input: BinaryReader | Uint8Array, length?: number): ActiveFinalityProvidersAtHeightResponse { + decode(input: BinaryReader | Uint8Array, length?: number): QueryFinalityProviderRequest { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseActiveFinalityProvidersAtHeightResponse(); + const message = createBaseQueryFinalityProviderRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -1440,42 +680,7 @@ export const ActiveFinalityProvidersAtHeightResponse: MessageFns, I>>( - base?: I, - ): ActiveFinalityProvidersAtHeightResponse { - return ActiveFinalityProvidersAtHeightResponse.fromPartial(base ?? ({} as any)); + create, I>>(base?: I): QueryFinalityProviderRequest { + return QueryFinalityProviderRequest.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; + fromPartial, I>>(object: I): QueryFinalityProviderRequest { + const message = createBaseQueryFinalityProviderRequest(); + message.fpBtcPkHex = object.fpBtcPkHex ?? ""; return message; }, }; -function createBaseQueryActiveFinalityProvidersAtHeightResponse(): QueryActiveFinalityProvidersAtHeightResponse { - return { finalityProviders: [], pagination: undefined }; +function createBaseQueryFinalityProviderResponse(): QueryFinalityProviderResponse { + return { finalityProvider: undefined }; } -export const QueryActiveFinalityProvidersAtHeightResponse: MessageFns = { - encode( - message: QueryActiveFinalityProvidersAtHeightResponse, - writer: BinaryWriter = new BinaryWriter(), - ): BinaryWriter { - for (const v of message.finalityProviders) { - ActiveFinalityProvidersAtHeightResponse.encode(v!, writer.uint32(10).fork()).join(); - } - if (message.pagination !== undefined) { - PageResponse.encode(message.pagination, writer.uint32(18).fork()).join(); +export const QueryFinalityProviderResponse: MessageFns = { + encode(message: QueryFinalityProviderResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.finalityProvider !== undefined) { + FinalityProviderResponse.encode(message.finalityProvider, writer.uint32(10).fork()).join(); } return writer; }, - decode(input: BinaryReader | Uint8Array, length?: number): QueryActiveFinalityProvidersAtHeightResponse { + decode(input: BinaryReader | Uint8Array, length?: number): QueryFinalityProviderResponse { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseQueryActiveFinalityProvidersAtHeightResponse(); + const message = createBaseQueryFinalityProviderResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -1569,14 +737,7 @@ export const QueryActiveFinalityProvidersAtHeightResponse: MessageFns ActiveFinalityProvidersAtHeightResponse.fromJSON(e)) - : [], - pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + finalityProvider: isSet(object.finalityProvider) + ? FinalityProviderResponse.fromJSON(object.finalityProvider) + : undefined, }; }, - toJSON(message: QueryActiveFinalityProvidersAtHeightResponse): unknown { + toJSON(message: QueryFinalityProviderResponse): unknown { const obj: any = {}; - if (message.finalityProviders?.length) { - obj.finalityProviders = message.finalityProviders.map((e) => ActiveFinalityProvidersAtHeightResponse.toJSON(e)); - } - if (message.pagination !== undefined) { - obj.pagination = PageResponse.toJSON(message.pagination); + if (message.finalityProvider !== undefined) { + obj.finalityProvider = FinalityProviderResponse.toJSON(message.finalityProvider); } return obj; }, - create, I>>( - base?: I, - ): QueryActiveFinalityProvidersAtHeightResponse { - return QueryActiveFinalityProvidersAtHeightResponse.fromPartial(base ?? ({} as any)); + create, I>>(base?: I): QueryFinalityProviderResponse { + return QueryFinalityProviderResponse.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>( + fromPartial, I>>( object: I, - ): QueryActiveFinalityProvidersAtHeightResponse { - const message = createBaseQueryActiveFinalityProvidersAtHeightResponse(); - message.finalityProviders = - object.finalityProviders?.map((e) => ActiveFinalityProvidersAtHeightResponse.fromPartial(e)) || []; - message.pagination = (object.pagination !== undefined && object.pagination !== null) - ? PageResponse.fromPartial(object.pagination) + ): QueryFinalityProviderResponse { + const message = createBaseQueryFinalityProviderResponse(); + message.finalityProvider = (object.finalityProvider !== undefined && object.finalityProvider !== null) + ? FinalityProviderResponse.fromPartial(object.finalityProvider) : undefined; return message; }, }; -function createBaseQueryActivatedHeightRequest(): QueryActivatedHeightRequest { - return {}; +function createBaseQueryBTCDelegationsRequest(): QueryBTCDelegationsRequest { + return { status: 0, pagination: undefined }; } -export const QueryActivatedHeightRequest: MessageFns = { - encode(_: QueryActivatedHeightRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { +export const QueryBTCDelegationsRequest: MessageFns = { + encode(message: QueryBTCDelegationsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.status !== 0) { + writer.uint32(8).int32(message.status); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).join(); + } return writer; }, - decode(input: BinaryReader | Uint8Array, length?: number): QueryActivatedHeightRequest { + decode(input: BinaryReader | Uint8Array, length?: number): QueryBTCDelegationsRequest { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseQueryActivatedHeightRequest(); + const message = createBaseQueryBTCDelegationsRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.status = reader.int32() as any; + continue; + case 2: + if (tag !== 18) { + break; + } + + message.pagination = PageRequest.decode(reader, reader.uint32()); + continue; } if ((tag & 7) === 4 || tag === 0) { break; @@ -1650,49 +823,72 @@ export const QueryActivatedHeightRequest: MessageFns, I>>(base?: I): QueryActivatedHeightRequest { - return QueryActivatedHeightRequest.fromPartial(base ?? ({} as any)); + create, I>>(base?: I): QueryBTCDelegationsRequest { + return QueryBTCDelegationsRequest.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>(_: I): QueryActivatedHeightRequest { - const message = createBaseQueryActivatedHeightRequest(); + fromPartial, I>>(object: I): QueryBTCDelegationsRequest { + const message = createBaseQueryBTCDelegationsRequest(); + message.status = object.status ?? 0; + message.pagination = (object.pagination !== undefined && object.pagination !== null) + ? PageRequest.fromPartial(object.pagination) + : undefined; return message; }, }; -function createBaseQueryActivatedHeightResponse(): QueryActivatedHeightResponse { - return { height: 0 }; +function createBaseQueryBTCDelegationsResponse(): QueryBTCDelegationsResponse { + return { btcDelegations: [], pagination: undefined }; } -export const QueryActivatedHeightResponse: MessageFns = { - encode(message: QueryActivatedHeightResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.height !== 0) { - writer.uint32(8).uint64(message.height); +export const QueryBTCDelegationsResponse: MessageFns = { + encode(message: QueryBTCDelegationsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + for (const v of message.btcDelegations) { + BTCDelegationResponse.encode(v!, writer.uint32(10).fork()).join(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).join(); } return writer; }, - decode(input: BinaryReader | Uint8Array, length?: number): QueryActivatedHeightResponse { + decode(input: BinaryReader | Uint8Array, length?: number): QueryBTCDelegationsResponse { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseQueryActivatedHeightResponse(); + const message = createBaseQueryBTCDelegationsResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - if (tag !== 8) { + if (tag !== 10) { break; } - message.height = longToNumber(reader.uint64()); + message.btcDelegations.push(BTCDelegationResponse.decode(reader, reader.uint32())); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.pagination = PageResponse.decode(reader, reader.uint32()); continue; } if ((tag & 7) === 4 || tag === 0) { @@ -1703,24 +899,35 @@ export const QueryActivatedHeightResponse: MessageFns BTCDelegationResponse.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; }, - toJSON(message: QueryActivatedHeightResponse): unknown { + toJSON(message: QueryBTCDelegationsResponse): unknown { const obj: any = {}; - if (message.height !== 0) { - obj.height = Math.round(message.height); + if (message.btcDelegations?.length) { + obj.btcDelegations = message.btcDelegations.map((e) => BTCDelegationResponse.toJSON(e)); + } + if (message.pagination !== undefined) { + obj.pagination = PageResponse.toJSON(message.pagination); } return obj; }, - create, I>>(base?: I): QueryActivatedHeightResponse { - return QueryActivatedHeightResponse.fromPartial(base ?? ({} as any)); + create, I>>(base?: I): QueryBTCDelegationsResponse { + return QueryBTCDelegationsResponse.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>(object: I): QueryActivatedHeightResponse { - const message = createBaseQueryActivatedHeightResponse(); - message.height = object.height ?? 0; + fromPartial, I>>(object: I): QueryBTCDelegationsResponse { + const message = createBaseQueryBTCDelegationsResponse(); + message.btcDelegations = object.btcDelegations?.map((e) => BTCDelegationResponse.fromPartial(e)) || []; + message.pagination = (object.pagination !== undefined && object.pagination !== null) + ? PageResponse.fromPartial(object.pagination) + : undefined; return message; }, }; @@ -2620,7 +1827,6 @@ function createBaseFinalityProviderResponse(): FinalityProviderResponse { slashedBabylonHeight: 0, slashedBtcHeight: 0, height: 0, - votingPower: 0, jailed: false, }; } @@ -2651,11 +1857,8 @@ export const FinalityProviderResponse: MessageFns = { if (message.height !== 0) { writer.uint32(64).uint64(message.height); } - if (message.votingPower !== 0) { - writer.uint32(72).uint64(message.votingPower); - } if (message.jailed !== false) { - writer.uint32(80).bool(message.jailed); + writer.uint32(72).bool(message.jailed); } return writer; }, @@ -2728,13 +1931,6 @@ export const FinalityProviderResponse: MessageFns = { break; } - message.votingPower = longToNumber(reader.uint64()); - continue; - case 10: - if (tag !== 80) { - break; - } - message.jailed = reader.bool(); continue; } @@ -2756,7 +1952,6 @@ export const FinalityProviderResponse: MessageFns = { slashedBabylonHeight: isSet(object.slashedBabylonHeight) ? globalThis.Number(object.slashedBabylonHeight) : 0, 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, jailed: isSet(object.jailed) ? globalThis.Boolean(object.jailed) : false, }; }, @@ -2787,9 +1982,6 @@ export const FinalityProviderResponse: MessageFns = { if (message.height !== 0) { obj.height = Math.round(message.height); } - if (message.votingPower !== 0) { - obj.votingPower = Math.round(message.votingPower); - } if (message.jailed !== false) { obj.jailed = message.jailed; } @@ -2813,7 +2005,6 @@ export const FinalityProviderResponse: MessageFns = { message.slashedBabylonHeight = object.slashedBabylonHeight ?? 0; message.slashedBtcHeight = object.slashedBtcHeight ?? 0; message.height = object.height ?? 0; - message.votingPower = object.votingPower ?? 0; message.jailed = object.jailed ?? false; return message; }, @@ -2831,23 +2022,6 @@ export interface Query { FinalityProvider(request: QueryFinalityProviderRequest): Promise; /** BTCDelegations queries all BTC delegations under a given status */ BTCDelegations(request: QueryBTCDelegationsRequest): Promise; - /** ActiveFinalityProvidersAtHeight queries finality providers with non zero voting power at given height. */ - ActiveFinalityProvidersAtHeight( - request: QueryActiveFinalityProvidersAtHeightRequest, - ): Promise; - /** FinalityProviderPowerAtHeight queries the voting power of a finality provider at a given height */ - FinalityProviderPowerAtHeight( - request: QueryFinalityProviderPowerAtHeightRequest, - ): Promise; - /** FinalityProviderCurrentPower queries the voting power of a finality provider at the current height */ - FinalityProviderCurrentPower( - request: QueryFinalityProviderCurrentPowerRequest, - ): Promise; - /** - * ActivatedHeight queries the height when BTC staking protocol is activated, i.e., the first height when - * there exists 1 finality provider with voting power - */ - ActivatedHeight(request: QueryActivatedHeightRequest): Promise; /** FinalityProviderDelegations queries all BTC delegations of the given finality provider */ FinalityProviderDelegations( request: QueryFinalityProviderDelegationsRequest, @@ -2868,10 +2042,6 @@ export class QueryClientImpl implements Query { this.FinalityProviders = this.FinalityProviders.bind(this); this.FinalityProvider = this.FinalityProvider.bind(this); this.BTCDelegations = this.BTCDelegations.bind(this); - this.ActiveFinalityProvidersAtHeight = this.ActiveFinalityProvidersAtHeight.bind(this); - this.FinalityProviderPowerAtHeight = this.FinalityProviderPowerAtHeight.bind(this); - this.FinalityProviderCurrentPower = this.FinalityProviderCurrentPower.bind(this); - this.ActivatedHeight = this.ActivatedHeight.bind(this); this.FinalityProviderDelegations = this.FinalityProviderDelegations.bind(this); this.BTCDelegation = this.BTCDelegation.bind(this); } @@ -2905,36 +2075,6 @@ export class QueryClientImpl implements Query { return promise.then((data) => QueryBTCDelegationsResponse.decode(new BinaryReader(data))); } - ActiveFinalityProvidersAtHeight( - request: QueryActiveFinalityProvidersAtHeightRequest, - ): Promise { - const data = QueryActiveFinalityProvidersAtHeightRequest.encode(request).finish(); - const promise = this.rpc.request(this.service, "ActiveFinalityProvidersAtHeight", data); - return promise.then((data) => QueryActiveFinalityProvidersAtHeightResponse.decode(new BinaryReader(data))); - } - - FinalityProviderPowerAtHeight( - request: QueryFinalityProviderPowerAtHeightRequest, - ): Promise { - const data = QueryFinalityProviderPowerAtHeightRequest.encode(request).finish(); - const promise = this.rpc.request(this.service, "FinalityProviderPowerAtHeight", data); - return promise.then((data) => QueryFinalityProviderPowerAtHeightResponse.decode(new BinaryReader(data))); - } - - FinalityProviderCurrentPower( - request: QueryFinalityProviderCurrentPowerRequest, - ): Promise { - const data = QueryFinalityProviderCurrentPowerRequest.encode(request).finish(); - const promise = this.rpc.request(this.service, "FinalityProviderCurrentPower", data); - return promise.then((data) => QueryFinalityProviderCurrentPowerResponse.decode(new BinaryReader(data))); - } - - ActivatedHeight(request: QueryActivatedHeightRequest): Promise { - const data = QueryActivatedHeightRequest.encode(request).finish(); - const promise = this.rpc.request(this.service, "ActivatedHeight", data); - return promise.then((data) => QueryActivatedHeightResponse.decode(new BinaryReader(data))); - } - FinalityProviderDelegations( request: QueryFinalityProviderDelegationsRequest, ): Promise { diff --git a/src/generated/babylon/finality/v1/finality.ts b/src/generated/babylon/finality/v1/finality.ts index c639637..d7a254e 100644 --- a/src/generated/babylon/finality/v1/finality.ts +++ b/src/generated/babylon/finality/v1/finality.ts @@ -10,6 +10,73 @@ import { Timestamp } from "../../../google/protobuf/timestamp"; export const protobufPackage = "babylon.finality.v1"; +/** + * VotingPowerDistCache is the cache for voting power distribution of finality providers + * and their BTC delegations at a height + */ +export interface VotingPowerDistCache { + /** + * 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 */ +export interface FinalityProviderDistInfo { + /** + * btc_pk is the Bitcoin secp256k1 PK of this finality provider + * the PK follows encoding in BIP-340 spec + */ + btcPk: Uint8Array; + /** addr is the bytes of the address to receive commission from delegations. */ + addr: Uint8Array; + /** commission defines the commission rate of finality provider */ + commission: string; + /** 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 voting power distribution for a BTC delegation */ +export interface BTCDelDistInfo { + /** + * btc_pk is the Bitcoin secp256k1 PK of this BTC delegation + * the PK follows encoding in BIP-340 spec + */ + btcPk: Uint8Array; + /** staker_addr is the address to receive rewards from BTC delegation. */ + stakerAddr: string; + /** staking_tx_hash is the staking tx hash of the BTC delegation */ + stakingTxHash: string; + /** total_sat is the amount of BTC stake (in Satoshi) of the BTC delegation */ + totalSat: number; +} + /** IndexedBlock is the necessary metadata and finalization status of a block */ export interface IndexedBlock { /** height is the height of the block */ @@ -89,6 +156,376 @@ export interface FinalityProviderSigningInfo { jailedUntil: Date | undefined; } +function createBaseVotingPowerDistCache(): VotingPowerDistCache { + return { totalBondedSat: 0, finalityProviders: [], numActiveFps: 0 }; +} + +export const VotingPowerDistCache: MessageFns = { + encode(message: VotingPowerDistCache, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + 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; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): VotingPowerDistCache { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseVotingPowerDistCache(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.totalBondedSat = longToNumber(reader.uint64()); + continue; + case 2: + if (tag !== 18) { + break; + } + + 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; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): VotingPowerDistCache { + return { + 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.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; + }, + + create, I>>(base?: I): VotingPowerDistCache { + return VotingPowerDistCache.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): VotingPowerDistCache { + const message = createBaseVotingPowerDistCache(); + 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: new Uint8Array(0), + commission: "", + totalBondedSat: 0, + btcDels: [], + isTimestamped: false, + isJailed: false, + isSlashed: false, + }; +} + +export const FinalityProviderDistInfo: MessageFns = { + encode(message: FinalityProviderDistInfo, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.btcPk.length !== 0) { + writer.uint32(10).bytes(message.btcPk); + } + if (message.addr.length !== 0) { + writer.uint32(18).bytes(message.addr); + } + if (message.commission !== "") { + writer.uint32(26).string(message.commission); + } + 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; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): FinalityProviderDistInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFinalityProviderDistInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.btcPk = reader.bytes(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.addr = reader.bytes(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.commission = reader.string(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.totalBondedSat = longToNumber(reader.uint64()); + continue; + case 5: + if (tag !== 42) { + break; + } + + 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; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): FinalityProviderDistInfo { + return { + btcPk: isSet(object.btcPk) ? bytesFromBase64(object.btcPk) : new Uint8Array(0), + addr: isSet(object.addr) ? bytesFromBase64(object.addr) : new Uint8Array(0), + commission: isSet(object.commission) ? globalThis.String(object.commission) : "", + 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, + }; + }, + + toJSON(message: FinalityProviderDistInfo): unknown { + const obj: any = {}; + if (message.btcPk.length !== 0) { + obj.btcPk = base64FromBytes(message.btcPk); + } + if (message.addr.length !== 0) { + obj.addr = base64FromBytes(message.addr); + } + if (message.commission !== "") { + obj.commission = message.commission; + } + 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; + }, + + create, I>>(base?: I): FinalityProviderDistInfo { + return FinalityProviderDistInfo.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): FinalityProviderDistInfo { + const message = createBaseFinalityProviderDistInfo(); + message.btcPk = object.btcPk ?? new Uint8Array(0); + message.addr = object.addr ?? new Uint8Array(0); + message.commission = object.commission ?? ""; + 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: "", totalSat: 0 }; +} + +export const BTCDelDistInfo: MessageFns = { + encode(message: BTCDelDistInfo, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.btcPk.length !== 0) { + writer.uint32(10).bytes(message.btcPk); + } + if (message.stakerAddr !== "") { + writer.uint32(18).string(message.stakerAddr); + } + if (message.stakingTxHash !== "") { + writer.uint32(26).string(message.stakingTxHash); + } + if (message.totalSat !== 0) { + writer.uint32(32).uint64(message.totalSat); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): BTCDelDistInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBTCDelDistInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.btcPk = reader.bytes(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.stakerAddr = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.stakingTxHash = reader.string(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.totalSat = longToNumber(reader.uint64()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): BTCDelDistInfo { + return { + 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) : "", + totalSat: isSet(object.totalSat) ? globalThis.Number(object.totalSat) : 0, + }; + }, + + toJSON(message: BTCDelDistInfo): unknown { + const obj: any = {}; + if (message.btcPk.length !== 0) { + obj.btcPk = base64FromBytes(message.btcPk); + } + if (message.stakerAddr !== "") { + obj.stakerAddr = message.stakerAddr; + } + if (message.stakingTxHash !== "") { + obj.stakingTxHash = message.stakingTxHash; + } + if (message.totalSat !== 0) { + obj.totalSat = Math.round(message.totalSat); + } + return obj; + }, + + create, I>>(base?: I): BTCDelDistInfo { + return BTCDelDistInfo.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): BTCDelDistInfo { + const message = createBaseBTCDelDistInfo(); + message.btcPk = object.btcPk ?? new Uint8Array(0); + message.stakerAddr = object.stakerAddr ?? ""; + message.stakingTxHash = object.stakingTxHash ?? ""; + message.totalSat = object.totalSat ?? 0; + return message; + }, +}; + function createBaseIndexedBlock(): IndexedBlock { return { height: 0, appHash: new Uint8Array(0), finalized: false }; } diff --git a/src/generated/babylon/finality/v1/genesis.ts b/src/generated/babylon/finality/v1/genesis.ts index 704317b..3e09a35 100644 --- a/src/generated/babylon/finality/v1/genesis.ts +++ b/src/generated/babylon/finality/v1/genesis.ts @@ -6,7 +6,7 @@ /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; -import { Evidence, FinalityProviderSigningInfo, IndexedBlock, PubRandCommit } from "./finality"; +import { Evidence, FinalityProviderSigningInfo, IndexedBlock, PubRandCommit, VotingPowerDistCache } from "./finality"; import { Params } from "./params"; export const protobufPackage = "babylon.finality.v1"; @@ -37,6 +37,10 @@ export interface GenesisState { * missed blocks. */ missedBlocks: FinalityProviderMissedBlocks[]; + /** voting_powers the voting power of every finality provider at every block height. */ + votingPowers: VotingPowerFP[]; + /** vp_dst_cache is the table of all providers voting power with the total at one specific block. */ + vpDstCache: VotingPowerDistCacheBlkHeight[]; } /** @@ -100,6 +104,27 @@ export interface MissedBlock { missed: boolean; } +/** + * VotingPowerFP contains the information about the voting power + * of an finality provider in a specific block height. + */ +export interface VotingPowerFP { + /** block_height is the height of the block the voting power was stored. */ + blockHeight: number; + /** fp_btc_pk the finality provider btc public key. */ + fpBtcPk: Uint8Array; + /** voting_power is the power of the finality provider at this specific block height. */ + votingPower: number; +} + +/** VotingPowerDistCacheBlkHeight the total voting power of the finality providers at one specific block height */ +export interface VotingPowerDistCacheBlkHeight { + /** block_height is the height of the block the voting power distribution cached was stored. */ + blockHeight: number; + /** vp_distribution the finality providers distribution cache at that height. */ + vpDistribution: VotingPowerDistCache | undefined; +} + function createBaseGenesisState(): GenesisState { return { params: undefined, @@ -110,6 +135,8 @@ function createBaseGenesisState(): GenesisState { pubRandCommit: [], signingInfos: [], missedBlocks: [], + votingPowers: [], + vpDstCache: [], }; } @@ -139,6 +166,12 @@ export const GenesisState: MessageFns = { for (const v of message.missedBlocks) { FinalityProviderMissedBlocks.encode(v!, writer.uint32(66).fork()).join(); } + for (const v of message.votingPowers) { + VotingPowerFP.encode(v!, writer.uint32(74).fork()).join(); + } + for (const v of message.vpDstCache) { + VotingPowerDistCacheBlkHeight.encode(v!, writer.uint32(82).fork()).join(); + } return writer; }, @@ -205,6 +238,20 @@ export const GenesisState: MessageFns = { message.missedBlocks.push(FinalityProviderMissedBlocks.decode(reader, reader.uint32())); continue; + case 9: + if (tag !== 74) { + break; + } + + message.votingPowers.push(VotingPowerFP.decode(reader, reader.uint32())); + continue; + case 10: + if (tag !== 82) { + break; + } + + message.vpDstCache.push(VotingPowerDistCacheBlkHeight.decode(reader, reader.uint32())); + continue; } if ((tag & 7) === 4 || tag === 0) { break; @@ -236,6 +283,12 @@ export const GenesisState: MessageFns = { missedBlocks: globalThis.Array.isArray(object?.missedBlocks) ? object.missedBlocks.map((e: any) => FinalityProviderMissedBlocks.fromJSON(e)) : [], + votingPowers: globalThis.Array.isArray(object?.votingPowers) + ? object.votingPowers.map((e: any) => VotingPowerFP.fromJSON(e)) + : [], + vpDstCache: globalThis.Array.isArray(object?.vpDstCache) + ? object.vpDstCache.map((e: any) => VotingPowerDistCacheBlkHeight.fromJSON(e)) + : [], }; }, @@ -265,6 +318,12 @@ export const GenesisState: MessageFns = { if (message.missedBlocks?.length) { obj.missedBlocks = message.missedBlocks.map((e) => FinalityProviderMissedBlocks.toJSON(e)); } + if (message.votingPowers?.length) { + obj.votingPowers = message.votingPowers.map((e) => VotingPowerFP.toJSON(e)); + } + if (message.vpDstCache?.length) { + obj.vpDstCache = message.vpDstCache.map((e) => VotingPowerDistCacheBlkHeight.toJSON(e)); + } return obj; }, @@ -283,6 +342,8 @@ export const GenesisState: MessageFns = { message.pubRandCommit = object.pubRandCommit?.map((e) => PubRandCommitWithPK.fromPartial(e)) || []; message.signingInfos = object.signingInfos?.map((e) => SigningInfo.fromPartial(e)) || []; message.missedBlocks = object.missedBlocks?.map((e) => FinalityProviderMissedBlocks.fromPartial(e)) || []; + message.votingPowers = object.votingPowers?.map((e) => VotingPowerFP.fromPartial(e)) || []; + message.vpDstCache = object.vpDstCache?.map((e) => VotingPowerDistCacheBlkHeight.fromPartial(e)) || []; return message; }, }; @@ -769,6 +830,173 @@ export const MissedBlock: MessageFns = { }, }; +function createBaseVotingPowerFP(): VotingPowerFP { + return { blockHeight: 0, fpBtcPk: new Uint8Array(0), votingPower: 0 }; +} + +export const VotingPowerFP: MessageFns = { + encode(message: VotingPowerFP, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.blockHeight !== 0) { + writer.uint32(8).uint64(message.blockHeight); + } + if (message.fpBtcPk.length !== 0) { + writer.uint32(18).bytes(message.fpBtcPk); + } + if (message.votingPower !== 0) { + writer.uint32(24).uint64(message.votingPower); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): VotingPowerFP { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseVotingPowerFP(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.blockHeight = longToNumber(reader.uint64()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.fpBtcPk = reader.bytes(); + 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): VotingPowerFP { + return { + blockHeight: isSet(object.blockHeight) ? globalThis.Number(object.blockHeight) : 0, + fpBtcPk: isSet(object.fpBtcPk) ? bytesFromBase64(object.fpBtcPk) : new Uint8Array(0), + votingPower: isSet(object.votingPower) ? globalThis.Number(object.votingPower) : 0, + }; + }, + + toJSON(message: VotingPowerFP): unknown { + const obj: any = {}; + if (message.blockHeight !== 0) { + obj.blockHeight = Math.round(message.blockHeight); + } + if (message.fpBtcPk.length !== 0) { + obj.fpBtcPk = base64FromBytes(message.fpBtcPk); + } + if (message.votingPower !== 0) { + obj.votingPower = Math.round(message.votingPower); + } + return obj; + }, + + create, I>>(base?: I): VotingPowerFP { + return VotingPowerFP.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): VotingPowerFP { + const message = createBaseVotingPowerFP(); + message.blockHeight = object.blockHeight ?? 0; + message.fpBtcPk = object.fpBtcPk ?? new Uint8Array(0); + message.votingPower = object.votingPower ?? 0; + return message; + }, +}; + +function createBaseVotingPowerDistCacheBlkHeight(): VotingPowerDistCacheBlkHeight { + return { blockHeight: 0, vpDistribution: undefined }; +} + +export const VotingPowerDistCacheBlkHeight: MessageFns = { + encode(message: VotingPowerDistCacheBlkHeight, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.blockHeight !== 0) { + writer.uint32(8).uint64(message.blockHeight); + } + if (message.vpDistribution !== undefined) { + VotingPowerDistCache.encode(message.vpDistribution, writer.uint32(18).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): VotingPowerDistCacheBlkHeight { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseVotingPowerDistCacheBlkHeight(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.blockHeight = longToNumber(reader.uint64()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.vpDistribution = VotingPowerDistCache.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): VotingPowerDistCacheBlkHeight { + return { + blockHeight: isSet(object.blockHeight) ? globalThis.Number(object.blockHeight) : 0, + vpDistribution: isSet(object.vpDistribution) ? VotingPowerDistCache.fromJSON(object.vpDistribution) : undefined, + }; + }, + + toJSON(message: VotingPowerDistCacheBlkHeight): unknown { + const obj: any = {}; + if (message.blockHeight !== 0) { + obj.blockHeight = Math.round(message.blockHeight); + } + if (message.vpDistribution !== undefined) { + obj.vpDistribution = VotingPowerDistCache.toJSON(message.vpDistribution); + } + return obj; + }, + + create, I>>(base?: I): VotingPowerDistCacheBlkHeight { + return VotingPowerDistCacheBlkHeight.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): VotingPowerDistCacheBlkHeight { + const message = createBaseVotingPowerDistCacheBlkHeight(); + message.blockHeight = object.blockHeight ?? 0; + message.vpDistribution = (object.vpDistribution !== undefined && object.vpDistribution !== null) + ? VotingPowerDistCache.fromPartial(object.vpDistribution) + : undefined; + 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/finality/v1/params.ts b/src/generated/babylon/finality/v1/params.ts index 67d8971..b4fe900 100644 --- a/src/generated/babylon/finality/v1/params.ts +++ b/src/generated/babylon/finality/v1/params.ts @@ -12,6 +12,8 @@ export const protobufPackage = "babylon.finality.v1"; /** Params defines the parameters for the module. */ export interface Params { + /** max_active_finality_providers is the maximum number of active finality providers in the BTC staking protocol */ + maxActiveFinalityProviders: number; /** signed_blocks_window defines the size of the sliding window for tracking finality provider liveness */ signedBlocksWindow: number; /** @@ -43,6 +45,7 @@ export interface Params { function createBaseParams(): Params { return { + maxActiveFinalityProviders: 0, signedBlocksWindow: 0, finalitySigTimeout: 0, minSignedPerWindow: new Uint8Array(0), @@ -54,23 +57,26 @@ function createBaseParams(): Params { export const Params: MessageFns = { encode(message: Params, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.maxActiveFinalityProviders !== 0) { + writer.uint32(8).uint32(message.maxActiveFinalityProviders); + } if (message.signedBlocksWindow !== 0) { - writer.uint32(8).int64(message.signedBlocksWindow); + writer.uint32(16).int64(message.signedBlocksWindow); } if (message.finalitySigTimeout !== 0) { - writer.uint32(16).int64(message.finalitySigTimeout); + writer.uint32(24).int64(message.finalitySigTimeout); } if (message.minSignedPerWindow.length !== 0) { - writer.uint32(26).bytes(message.minSignedPerWindow); + writer.uint32(34).bytes(message.minSignedPerWindow); } if (message.minPubRand !== 0) { - writer.uint32(32).uint64(message.minPubRand); + writer.uint32(40).uint64(message.minPubRand); } if (message.jailDuration !== undefined) { - Duration.encode(message.jailDuration, writer.uint32(42).fork()).join(); + Duration.encode(message.jailDuration, writer.uint32(50).fork()).join(); } if (message.finalityActivationHeight !== 0) { - writer.uint32(48).uint64(message.finalityActivationHeight); + writer.uint32(56).uint64(message.finalityActivationHeight); } return writer; }, @@ -87,38 +93,45 @@ export const Params: MessageFns = { break; } - message.signedBlocksWindow = longToNumber(reader.int64()); + message.maxActiveFinalityProviders = reader.uint32(); continue; case 2: if (tag !== 16) { break; } - message.finalitySigTimeout = longToNumber(reader.int64()); + message.signedBlocksWindow = longToNumber(reader.int64()); continue; case 3: - if (tag !== 26) { + if (tag !== 24) { break; } - message.minSignedPerWindow = reader.bytes(); + message.finalitySigTimeout = longToNumber(reader.int64()); continue; case 4: - if (tag !== 32) { + if (tag !== 34) { break; } - message.minPubRand = longToNumber(reader.uint64()); + message.minSignedPerWindow = reader.bytes(); continue; case 5: - if (tag !== 42) { + if (tag !== 40) { break; } - message.jailDuration = Duration.decode(reader, reader.uint32()); + message.minPubRand = longToNumber(reader.uint64()); continue; case 6: - if (tag !== 48) { + if (tag !== 50) { + break; + } + + message.jailDuration = Duration.decode(reader, reader.uint32()); + continue; + case 7: + if (tag !== 56) { break; } @@ -135,6 +148,9 @@ export const Params: MessageFns = { fromJSON(object: any): Params { return { + maxActiveFinalityProviders: isSet(object.maxActiveFinalityProviders) + ? globalThis.Number(object.maxActiveFinalityProviders) + : 0, signedBlocksWindow: isSet(object.signedBlocksWindow) ? globalThis.Number(object.signedBlocksWindow) : 0, finalitySigTimeout: isSet(object.finalitySigTimeout) ? globalThis.Number(object.finalitySigTimeout) : 0, minSignedPerWindow: isSet(object.minSignedPerWindow) @@ -150,6 +166,9 @@ export const Params: MessageFns = { toJSON(message: Params): unknown { const obj: any = {}; + if (message.maxActiveFinalityProviders !== 0) { + obj.maxActiveFinalityProviders = Math.round(message.maxActiveFinalityProviders); + } if (message.signedBlocksWindow !== 0) { obj.signedBlocksWindow = Math.round(message.signedBlocksWindow); } @@ -176,6 +195,7 @@ export const Params: MessageFns = { }, fromPartial, I>>(object: I): Params { const message = createBaseParams(); + message.maxActiveFinalityProviders = object.maxActiveFinalityProviders ?? 0; message.signedBlocksWindow = object.signedBlocksWindow ?? 0; message.finalitySigTimeout = object.finalitySigTimeout ?? 0; message.minSignedPerWindow = object.minSignedPerWindow ?? new Uint8Array(0); diff --git a/src/generated/babylon/finality/v1/query.ts b/src/generated/babylon/finality/v1/query.ts index 9f8d8c6..6b13f62 100644 --- a/src/generated/babylon/finality/v1/query.ts +++ b/src/generated/babylon/finality/v1/query.ts @@ -66,6 +66,112 @@ export interface QueryParamsResponse { params: Params | undefined; } +/** + * QueryFinalityProviderPowerAtHeightRequest is the request type for the + * Query/FinalityProviderPowerAtHeight RPC method. + */ +export interface QueryFinalityProviderPowerAtHeightRequest { + /** + * fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that + * this BTC delegation delegates to + * the PK follows encoding in BIP-340 spec + */ + fpBtcPkHex: string; + /** height is used for querying the given finality provider's voting power at this height */ + height: number; +} + +/** + * QueryFinalityProviderPowerAtHeightResponse is the response type for the + * Query/FinalityProviderPowerAtHeight RPC method. + */ +export interface QueryFinalityProviderPowerAtHeightResponse { + /** voting_power is the voting power of the finality provider */ + votingPower: number; +} + +/** + * QueryFinalityProviderCurrentPowerRequest is the request type for the + * Query/FinalityProviderCurrentPower RPC method. + */ +export interface QueryFinalityProviderCurrentPowerRequest { + /** + * fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that + * this BTC delegation delegates to + * the PK follows encoding in BIP-340 spec + */ + fpBtcPkHex: string; +} + +/** + * QueryFinalityProviderCurrentPowerResponse is the response type for the + * Query/FinalityProviderCurrentPower RPC method. + */ +export interface QueryFinalityProviderCurrentPowerResponse { + /** height is the current height */ + height: number; + /** voting_power is the voting power of the finality provider */ + votingPower: number; +} + +/** + * QueryActiveFinalityProvidersAtHeightRequest is the request type for the + * Query/ActiveFinalityProvidersAtHeight RPC method. + */ +export interface QueryActiveFinalityProvidersAtHeightRequest { + /** height defines at which Babylon height to query the finality providers info. */ + height: number; + /** pagination defines an optional pagination for the request. */ + 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: ActiveFinalityProvidersAtHeightResponse[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +/** QueryActivatedHeightRequest is the request type for the Query/ActivatedHeight RPC method. */ +export interface QueryActivatedHeightRequest { +} + +/** QueryActivatedHeightResponse is the response type for the Query/ActivatedHeight RPC method. */ +export interface QueryActivatedHeightResponse { + height: number; +} + /** * QueryListPublicRandomnessRequest is the request type for the * Query/ListPublicRandomness RPC method. @@ -197,149 +303,836 @@ export interface QueryVotesAtHeightResponse { btcPks: Uint8Array[]; } -/** - * QueryEvidenceRequest is the request type for the - * Query/Evidence RPC method. - */ -export interface QueryEvidenceRequest { - /** - * fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK - * (in BIP340 format) of the finality provider - */ - fpBtcPkHex: string; -} +/** + * QueryEvidenceRequest is the request type for the + * Query/Evidence RPC method. + */ +export interface QueryEvidenceRequest { + /** + * fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK + * (in BIP340 format) of the finality provider + */ + 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: EvidenceResponse | undefined; +} + +/** + * QueryListEvidencesRequest is the request type for the + * Query/ListEvidences RPC method. + */ +export interface QueryListEvidencesRequest { + /** + * start_height is the starting height that the querier specifies + * such that the RPC will only return evidences since this height + */ + startHeight: number; + /** pagination defines an optional pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** + * QueryListEvidencesResponse is the response type for the + * Query/ListEvidences RPC method. + */ +export interface QueryListEvidencesResponse { + /** blocks is the list of evidences */ + evidences: EvidenceResponse[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +/** + * QuerySigningInfoRequest is the request type for the Query/SigningInfo RPC + * method + */ +export interface QuerySigningInfoRequest { + /** + * fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK + * (in BIP340 format) of the finality provider + */ + 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 { + signingInfo: SigningInfoResponse | undefined; +} + +/** + * QuerySigningInfosRequest is the request type for the Query/SigningInfos RPC + * method + */ +export interface QuerySigningInfosRequest { + pagination: PageRequest | undefined; +} + +/** + * QuerySigningInfosResponse is the response type for the Query/SigningInfos RPC + * method + */ +export interface QuerySigningInfosResponse { + /** info is the signing info of all finality providers with signing info */ + signingInfos: SigningInfoResponse[]; + pagination: PageResponse | undefined; +} + +function createBaseQueryParamsRequest(): QueryParamsRequest { + return {}; +} + +export const QueryParamsRequest: MessageFns = { + encode(_: QueryParamsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + 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): QueryParamsRequest { + return {}; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): QueryParamsRequest { + return QueryParamsRequest.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(_: I): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, +}; + +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { params: undefined }; +} + +export const QueryParamsResponse: MessageFns = { + encode(message: QueryParamsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.params = Params.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + return { params: isSet(object.params) ? Params.fromJSON(object.params) : undefined }; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + if (message.params !== undefined) { + obj.params = Params.toJSON(message.params); + } + return obj; + }, + + create, I>>(base?: I): QueryParamsResponse { + return QueryParamsResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + message.params = (object.params !== undefined && object.params !== null) + ? Params.fromPartial(object.params) + : undefined; + return message; + }, +}; + +function createBaseQueryFinalityProviderPowerAtHeightRequest(): QueryFinalityProviderPowerAtHeightRequest { + return { fpBtcPkHex: "", height: 0 }; +} + +export const QueryFinalityProviderPowerAtHeightRequest: MessageFns = { + encode(message: QueryFinalityProviderPowerAtHeightRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.fpBtcPkHex !== "") { + writer.uint32(10).string(message.fpBtcPkHex); + } + if (message.height !== 0) { + writer.uint32(16).uint64(message.height); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): QueryFinalityProviderPowerAtHeightRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryFinalityProviderPowerAtHeightRequest(); + 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.height = longToNumber(reader.uint64()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): QueryFinalityProviderPowerAtHeightRequest { + return { + fpBtcPkHex: isSet(object.fpBtcPkHex) ? globalThis.String(object.fpBtcPkHex) : "", + height: isSet(object.height) ? globalThis.Number(object.height) : 0, + }; + }, + + toJSON(message: QueryFinalityProviderPowerAtHeightRequest): unknown { + const obj: any = {}; + if (message.fpBtcPkHex !== "") { + obj.fpBtcPkHex = message.fpBtcPkHex; + } + if (message.height !== 0) { + obj.height = Math.round(message.height); + } + return obj; + }, + + create, I>>( + base?: I, + ): QueryFinalityProviderPowerAtHeightRequest { + return QueryFinalityProviderPowerAtHeightRequest.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): QueryFinalityProviderPowerAtHeightRequest { + const message = createBaseQueryFinalityProviderPowerAtHeightRequest(); + message.fpBtcPkHex = object.fpBtcPkHex ?? ""; + message.height = object.height ?? 0; + return message; + }, +}; + +function createBaseQueryFinalityProviderPowerAtHeightResponse(): QueryFinalityProviderPowerAtHeightResponse { + return { votingPower: 0 }; +} + +export const QueryFinalityProviderPowerAtHeightResponse: MessageFns = { + encode(message: QueryFinalityProviderPowerAtHeightResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.votingPower !== 0) { + writer.uint32(8).uint64(message.votingPower); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): QueryFinalityProviderPowerAtHeightResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryFinalityProviderPowerAtHeightResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.votingPower = longToNumber(reader.uint64()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): QueryFinalityProviderPowerAtHeightResponse { + return { votingPower: isSet(object.votingPower) ? globalThis.Number(object.votingPower) : 0 }; + }, + + toJSON(message: QueryFinalityProviderPowerAtHeightResponse): unknown { + const obj: any = {}; + if (message.votingPower !== 0) { + obj.votingPower = Math.round(message.votingPower); + } + return obj; + }, + + create, I>>( + base?: I, + ): QueryFinalityProviderPowerAtHeightResponse { + return QueryFinalityProviderPowerAtHeightResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): QueryFinalityProviderPowerAtHeightResponse { + const message = createBaseQueryFinalityProviderPowerAtHeightResponse(); + message.votingPower = object.votingPower ?? 0; + return message; + }, +}; + +function createBaseQueryFinalityProviderCurrentPowerRequest(): QueryFinalityProviderCurrentPowerRequest { + return { fpBtcPkHex: "" }; +} + +export const QueryFinalityProviderCurrentPowerRequest: MessageFns = { + encode(message: QueryFinalityProviderCurrentPowerRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.fpBtcPkHex !== "") { + writer.uint32(10).string(message.fpBtcPkHex); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): QueryFinalityProviderCurrentPowerRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryFinalityProviderCurrentPowerRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.fpBtcPkHex = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): QueryFinalityProviderCurrentPowerRequest { + return { fpBtcPkHex: isSet(object.fpBtcPkHex) ? globalThis.String(object.fpBtcPkHex) : "" }; + }, + + toJSON(message: QueryFinalityProviderCurrentPowerRequest): unknown { + const obj: any = {}; + if (message.fpBtcPkHex !== "") { + obj.fpBtcPkHex = message.fpBtcPkHex; + } + return obj; + }, + + create, I>>( + base?: I, + ): QueryFinalityProviderCurrentPowerRequest { + return QueryFinalityProviderCurrentPowerRequest.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): QueryFinalityProviderCurrentPowerRequest { + const message = createBaseQueryFinalityProviderCurrentPowerRequest(); + message.fpBtcPkHex = object.fpBtcPkHex ?? ""; + return message; + }, +}; + +function createBaseQueryFinalityProviderCurrentPowerResponse(): QueryFinalityProviderCurrentPowerResponse { + return { height: 0, votingPower: 0 }; +} + +export const QueryFinalityProviderCurrentPowerResponse: MessageFns = { + encode(message: QueryFinalityProviderCurrentPowerResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.height !== 0) { + writer.uint32(8).uint64(message.height); + } + if (message.votingPower !== 0) { + writer.uint32(16).uint64(message.votingPower); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): QueryFinalityProviderCurrentPowerResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryFinalityProviderCurrentPowerResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.height = longToNumber(reader.uint64()); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.votingPower = longToNumber(reader.uint64()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): QueryFinalityProviderCurrentPowerResponse { + return { + height: isSet(object.height) ? globalThis.Number(object.height) : 0, + votingPower: isSet(object.votingPower) ? globalThis.Number(object.votingPower) : 0, + }; + }, + + toJSON(message: QueryFinalityProviderCurrentPowerResponse): unknown { + const obj: any = {}; + if (message.height !== 0) { + obj.height = Math.round(message.height); + } + if (message.votingPower !== 0) { + obj.votingPower = Math.round(message.votingPower); + } + return obj; + }, + + create, I>>( + base?: I, + ): QueryFinalityProviderCurrentPowerResponse { + return QueryFinalityProviderCurrentPowerResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): QueryFinalityProviderCurrentPowerResponse { + const message = createBaseQueryFinalityProviderCurrentPowerResponse(); + message.height = object.height ?? 0; + message.votingPower = object.votingPower ?? 0; + return message; + }, +}; + +function createBaseQueryActiveFinalityProvidersAtHeightRequest(): QueryActiveFinalityProvidersAtHeightRequest { + return { height: 0, pagination: undefined }; +} + +export const QueryActiveFinalityProvidersAtHeightRequest: MessageFns = { + encode( + message: QueryActiveFinalityProvidersAtHeightRequest, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { + if (message.height !== 0) { + writer.uint32(8).uint64(message.height); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): QueryActiveFinalityProvidersAtHeightRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryActiveFinalityProvidersAtHeightRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.height = longToNumber(reader.uint64()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.pagination = PageRequest.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): QueryActiveFinalityProvidersAtHeightRequest { + return { + height: isSet(object.height) ? globalThis.Number(object.height) : 0, + pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: QueryActiveFinalityProvidersAtHeightRequest): unknown { + const obj: any = {}; + if (message.height !== 0) { + obj.height = Math.round(message.height); + } + if (message.pagination !== undefined) { + obj.pagination = PageRequest.toJSON(message.pagination); + } + return obj; + }, + + create, I>>( + base?: I, + ): QueryActiveFinalityProvidersAtHeightRequest { + return QueryActiveFinalityProvidersAtHeightRequest.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): QueryActiveFinalityProvidersAtHeightRequest { + const message = createBaseQueryActiveFinalityProvidersAtHeightRequest(); + message.height = object.height ?? 0; + message.pagination = (object.pagination !== undefined && object.pagination !== null) + ? PageRequest.fromPartial(object.pagination) + : undefined; + return message; + }, +}; + +function createBaseActiveFinalityProvidersAtHeightResponse(): ActiveFinalityProvidersAtHeightResponse { + return { btcPkHex: "", height: 0, votingPower: 0, slashedBabylonHeight: 0, slashedBtcHeight: 0, jailed: false }; +} + +export const ActiveFinalityProvidersAtHeightResponse: 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, + }; + }, -/** - * 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; -} + 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; + }, -/** - * QueryEvidenceResponse is the response type for the - * Query/Evidence RPC method. - */ -export interface QueryEvidenceResponse { - evidence: EvidenceResponse | undefined; -} + 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; + }, +}; -/** - * QueryListEvidencesRequest is the request type for the - * Query/ListEvidences RPC method. - */ -export interface QueryListEvidencesRequest { - /** - * start_height is the starting height that the querier specifies - * such that the RPC will only return evidences since this height - */ - startHeight: number; - /** pagination defines an optional pagination for the request. */ - pagination: PageRequest | undefined; +function createBaseQueryActiveFinalityProvidersAtHeightResponse(): QueryActiveFinalityProvidersAtHeightResponse { + return { finalityProviders: [], pagination: undefined }; } -/** - * QueryListEvidencesResponse is the response type for the - * Query/ListEvidences RPC method. - */ -export interface QueryListEvidencesResponse { - /** blocks is the list of evidences */ - evidences: EvidenceResponse[]; - /** pagination defines the pagination in the response. */ - pagination: PageResponse | undefined; -} +export const QueryActiveFinalityProvidersAtHeightResponse: MessageFns = { + encode( + message: QueryActiveFinalityProvidersAtHeightResponse, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { + for (const v of message.finalityProviders) { + ActiveFinalityProvidersAtHeightResponse.encode(v!, writer.uint32(10).fork()).join(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).join(); + } + return writer; + }, -/** - * QuerySigningInfoRequest is the request type for the Query/SigningInfo RPC - * method - */ -export interface QuerySigningInfoRequest { - /** - * fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK - * (in BIP340 format) of the finality provider - */ - fpBtcPkHex: string; -} + decode(input: BinaryReader | Uint8Array, length?: number): QueryActiveFinalityProvidersAtHeightResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryActiveFinalityProvidersAtHeightResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } -/** - * 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; -} + message.finalityProviders.push(ActiveFinalityProvidersAtHeightResponse.decode(reader, reader.uint32())); + continue; + case 2: + if (tag !== 18) { + break; + } -/** - * QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC - * method - */ -export interface QuerySigningInfoResponse { - signingInfo: SigningInfoResponse | undefined; -} + message.pagination = PageResponse.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, -/** - * QuerySigningInfosRequest is the request type for the Query/SigningInfos RPC - * method - */ -export interface QuerySigningInfosRequest { - pagination: PageRequest | undefined; -} + fromJSON(object: any): QueryActiveFinalityProvidersAtHeightResponse { + return { + finalityProviders: globalThis.Array.isArray(object?.finalityProviders) + ? object.finalityProviders.map((e: any) => ActiveFinalityProvidersAtHeightResponse.fromJSON(e)) + : [], + pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined, + }; + }, -/** - * QuerySigningInfosResponse is the response type for the Query/SigningInfos RPC - * method - */ -export interface QuerySigningInfosResponse { - /** info is the signing info of all finality providers with signing info */ - signingInfos: SigningInfoResponse[]; - pagination: PageResponse | undefined; -} + toJSON(message: QueryActiveFinalityProvidersAtHeightResponse): unknown { + const obj: any = {}; + if (message.finalityProviders?.length) { + obj.finalityProviders = message.finalityProviders.map((e) => ActiveFinalityProvidersAtHeightResponse.toJSON(e)); + } + if (message.pagination !== undefined) { + obj.pagination = PageResponse.toJSON(message.pagination); + } + return obj; + }, -function createBaseQueryParamsRequest(): QueryParamsRequest { + create, I>>( + base?: I, + ): QueryActiveFinalityProvidersAtHeightResponse { + return QueryActiveFinalityProvidersAtHeightResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): QueryActiveFinalityProvidersAtHeightResponse { + const message = createBaseQueryActiveFinalityProvidersAtHeightResponse(); + message.finalityProviders = + object.finalityProviders?.map((e) => ActiveFinalityProvidersAtHeightResponse.fromPartial(e)) || []; + message.pagination = (object.pagination !== undefined && object.pagination !== null) + ? PageResponse.fromPartial(object.pagination) + : undefined; + return message; + }, +}; + +function createBaseQueryActivatedHeightRequest(): QueryActivatedHeightRequest { return {}; } -export const QueryParamsRequest: MessageFns = { - encode(_: QueryParamsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { +export const QueryActivatedHeightRequest: MessageFns = { + encode(_: QueryActivatedHeightRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { return writer; }, - decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + decode(input: BinaryReader | Uint8Array, length?: number): QueryActivatedHeightRequest { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseQueryParamsRequest(); + const message = createBaseQueryActivatedHeightRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -352,49 +1145,49 @@ export const QueryParamsRequest: MessageFns = { return message; }, - fromJSON(_: any): QueryParamsRequest { + fromJSON(_: any): QueryActivatedHeightRequest { return {}; }, - toJSON(_: QueryParamsRequest): unknown { + toJSON(_: QueryActivatedHeightRequest): unknown { const obj: any = {}; return obj; }, - create, I>>(base?: I): QueryParamsRequest { - return QueryParamsRequest.fromPartial(base ?? ({} as any)); + create, I>>(base?: I): QueryActivatedHeightRequest { + return QueryActivatedHeightRequest.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>(_: I): QueryParamsRequest { - const message = createBaseQueryParamsRequest(); + fromPartial, I>>(_: I): QueryActivatedHeightRequest { + const message = createBaseQueryActivatedHeightRequest(); return message; }, }; -function createBaseQueryParamsResponse(): QueryParamsResponse { - return { params: undefined }; +function createBaseQueryActivatedHeightResponse(): QueryActivatedHeightResponse { + return { height: 0 }; } -export const QueryParamsResponse: MessageFns = { - encode(message: QueryParamsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.params !== undefined) { - Params.encode(message.params, writer.uint32(10).fork()).join(); +export const QueryActivatedHeightResponse: MessageFns = { + encode(message: QueryActivatedHeightResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.height !== 0) { + writer.uint32(8).uint64(message.height); } return writer; }, - decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + decode(input: BinaryReader | Uint8Array, length?: number): QueryActivatedHeightResponse { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseQueryParamsResponse(); + const message = createBaseQueryActivatedHeightResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - if (tag !== 10) { + if (tag !== 8) { break; } - message.params = Params.decode(reader, reader.uint32()); + message.height = longToNumber(reader.uint64()); continue; } if ((tag & 7) === 4 || tag === 0) { @@ -405,26 +1198,24 @@ export const QueryParamsResponse: MessageFns = { return message; }, - fromJSON(object: any): QueryParamsResponse { - return { params: isSet(object.params) ? Params.fromJSON(object.params) : undefined }; + fromJSON(object: any): QueryActivatedHeightResponse { + return { height: isSet(object.height) ? globalThis.Number(object.height) : 0 }; }, - toJSON(message: QueryParamsResponse): unknown { + toJSON(message: QueryActivatedHeightResponse): unknown { const obj: any = {}; - if (message.params !== undefined) { - obj.params = Params.toJSON(message.params); + if (message.height !== 0) { + obj.height = Math.round(message.height); } return obj; }, - create, I>>(base?: I): QueryParamsResponse { - return QueryParamsResponse.fromPartial(base ?? ({} as any)); + create, I>>(base?: I): QueryActivatedHeightResponse { + return QueryActivatedHeightResponse.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>(object: I): QueryParamsResponse { - const message = createBaseQueryParamsResponse(); - message.params = (object.params !== undefined && object.params !== null) - ? Params.fromPartial(object.params) - : undefined; + fromPartial, I>>(object: I): QueryActivatedHeightResponse { + const message = createBaseQueryActivatedHeightResponse(); + message.height = object.height ?? 0; return message; }, }; @@ -2224,12 +3015,28 @@ export const QuerySigningInfosResponse: MessageFns = export interface Query { /** Parameters queries the parameters of the module. */ Params(request: QueryParamsRequest): Promise; + /** ActiveFinalityProvidersAtHeight queries finality providers with non zero voting power at given height. */ + ActiveFinalityProvidersAtHeight( + request: QueryActiveFinalityProvidersAtHeightRequest, + ): Promise; + /** FinalityProviderPowerAtHeight queries the voting power of a finality provider at a given height */ + FinalityProviderPowerAtHeight( + request: QueryFinalityProviderPowerAtHeightRequest, + ): Promise; + /** FinalityProviderCurrentPower queries the voting power of a finality provider at the current height */ + FinalityProviderCurrentPower( + request: QueryFinalityProviderCurrentPowerRequest, + ): Promise; + /** + * ActivatedHeight queries the height when BTC staking protocol is activated, i.e., the first height when + * there exists 1 finality provider with voting power + */ + ActivatedHeight(request: QueryActivatedHeightRequest): Promise; /** * 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 already provides a finality signature * at the corresponding height - * TODO: remove public randomness storage? */ ListPublicRandomness(request: QueryListPublicRandomnessRequest): Promise; /** ListPubRandCommit is a range query for public randomness commitments of a given finality provider */ @@ -2258,6 +3065,10 @@ export class QueryClientImpl implements Query { this.service = opts?.service || QueryServiceName; this.rpc = rpc; this.Params = this.Params.bind(this); + this.ActiveFinalityProvidersAtHeight = this.ActiveFinalityProvidersAtHeight.bind(this); + this.FinalityProviderPowerAtHeight = this.FinalityProviderPowerAtHeight.bind(this); + this.FinalityProviderCurrentPower = this.FinalityProviderCurrentPower.bind(this); + this.ActivatedHeight = this.ActivatedHeight.bind(this); this.ListPublicRandomness = this.ListPublicRandomness.bind(this); this.ListPubRandCommit = this.ListPubRandCommit.bind(this); this.Block = this.Block.bind(this); @@ -2274,6 +3085,36 @@ export class QueryClientImpl implements Query { return promise.then((data) => QueryParamsResponse.decode(new BinaryReader(data))); } + ActiveFinalityProvidersAtHeight( + request: QueryActiveFinalityProvidersAtHeightRequest, + ): Promise { + const data = QueryActiveFinalityProvidersAtHeightRequest.encode(request).finish(); + const promise = this.rpc.request(this.service, "ActiveFinalityProvidersAtHeight", data); + return promise.then((data) => QueryActiveFinalityProvidersAtHeightResponse.decode(new BinaryReader(data))); + } + + FinalityProviderPowerAtHeight( + request: QueryFinalityProviderPowerAtHeightRequest, + ): Promise { + const data = QueryFinalityProviderPowerAtHeightRequest.encode(request).finish(); + const promise = this.rpc.request(this.service, "FinalityProviderPowerAtHeight", data); + return promise.then((data) => QueryFinalityProviderPowerAtHeightResponse.decode(new BinaryReader(data))); + } + + FinalityProviderCurrentPower( + request: QueryFinalityProviderCurrentPowerRequest, + ): Promise { + const data = QueryFinalityProviderCurrentPowerRequest.encode(request).finish(); + const promise = this.rpc.request(this.service, "FinalityProviderCurrentPower", data); + return promise.then((data) => QueryFinalityProviderCurrentPowerResponse.decode(new BinaryReader(data))); + } + + ActivatedHeight(request: QueryActivatedHeightRequest): Promise { + const data = QueryActivatedHeightRequest.encode(request).finish(); + const promise = this.rpc.request(this.service, "ActivatedHeight", data); + return promise.then((data) => QueryActivatedHeightResponse.decode(new BinaryReader(data))); + } + ListPublicRandomness(request: QueryListPublicRandomnessRequest): Promise { const data = QueryListPublicRandomnessRequest.encode(request).finish(); const promise = this.rpc.request(this.service, "ListPublicRandomness", data); diff --git a/src/generated/babylon/mint/v1/genesis.ts b/src/generated/babylon/mint/v1/genesis.ts new file mode 100644 index 0000000..c9a2a82 --- /dev/null +++ b/src/generated/babylon/mint/v1/genesis.ts @@ -0,0 +1,98 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.2.0 +// protoc unknown +// source: babylon/mint/v1/genesis.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; + +export const protobufPackage = "babylon.mint.v1"; + +/** GenesisState defines the mint module's genesis state. */ +export interface GenesisState { + /** BondDenom is the denomination of the token that should be minted. */ + bondDenom: string; +} + +function createBaseGenesisState(): GenesisState { + return { bondDenom: "" }; +} + +export const GenesisState: MessageFns = { + encode(message: GenesisState, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.bondDenom !== "") { + writer.uint32(18).string(message.bondDenom); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + if (tag !== 18) { + break; + } + + message.bondDenom = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): GenesisState { + return { bondDenom: isSet(object.bondDenom) ? globalThis.String(object.bondDenom) : "" }; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + if (message.bondDenom !== "") { + obj.bondDenom = message.bondDenom; + } + return obj; + }, + + create, I>>(base?: I): GenesisState { + return GenesisState.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): GenesisState { + const message = createBaseGenesisState(); + message.bondDenom = object.bondDenom ?? ""; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +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 isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create, I>>(base?: I): T; + fromPartial, I>>(object: I): T; +} diff --git a/src/generated/babylon/mint/v1/mint.ts b/src/generated/babylon/mint/v1/mint.ts new file mode 100644 index 0000000..c942099 --- /dev/null +++ b/src/generated/babylon/mint/v1/mint.ts @@ -0,0 +1,246 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.2.0 +// protoc unknown +// source: babylon/mint/v1/mint.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; +import { Timestamp } from "../../../google/protobuf/timestamp"; + +export const protobufPackage = "babylon.mint.v1"; + +/** Minter represents the mint state. */ +export interface Minter { + /** + * InflationRate is the rate at which new tokens should be minted for the + * current year. For example if InflationRate=0.1, then 10% of the total + * supply will be minted over the course of the year. + */ + inflationRate: string; + /** + * AnnualProvisions is the total number of tokens to be minted in the current + * year due to inflation. + */ + annualProvisions: string; + /** PreviousBlockTime is the timestamp of the previous block. */ + previousBlockTime: + | Date + | undefined; + /** BondDenom is the denomination of the token that should be minted. */ + bondDenom: string; +} + +/** GenesisTime contains the timestamp of the genesis block. */ +export interface GenesisTime { + /** GenesisTime is the timestamp of the genesis block. */ + genesisTime: Date | undefined; +} + +function createBaseMinter(): Minter { + return { inflationRate: "", annualProvisions: "", previousBlockTime: undefined, bondDenom: "" }; +} + +export const Minter: MessageFns = { + encode(message: Minter, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.inflationRate !== "") { + writer.uint32(10).string(message.inflationRate); + } + if (message.annualProvisions !== "") { + writer.uint32(18).string(message.annualProvisions); + } + if (message.previousBlockTime !== undefined) { + Timestamp.encode(toTimestamp(message.previousBlockTime), writer.uint32(34).fork()).join(); + } + if (message.bondDenom !== "") { + writer.uint32(42).string(message.bondDenom); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): Minter { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMinter(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.inflationRate = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.annualProvisions = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.previousBlockTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.bondDenom = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): Minter { + return { + inflationRate: isSet(object.inflationRate) ? globalThis.String(object.inflationRate) : "", + annualProvisions: isSet(object.annualProvisions) ? globalThis.String(object.annualProvisions) : "", + previousBlockTime: isSet(object.previousBlockTime) ? fromJsonTimestamp(object.previousBlockTime) : undefined, + bondDenom: isSet(object.bondDenom) ? globalThis.String(object.bondDenom) : "", + }; + }, + + toJSON(message: Minter): unknown { + const obj: any = {}; + if (message.inflationRate !== "") { + obj.inflationRate = message.inflationRate; + } + if (message.annualProvisions !== "") { + obj.annualProvisions = message.annualProvisions; + } + if (message.previousBlockTime !== undefined) { + obj.previousBlockTime = message.previousBlockTime.toISOString(); + } + if (message.bondDenom !== "") { + obj.bondDenom = message.bondDenom; + } + return obj; + }, + + create, I>>(base?: I): Minter { + return Minter.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): Minter { + const message = createBaseMinter(); + message.inflationRate = object.inflationRate ?? ""; + message.annualProvisions = object.annualProvisions ?? ""; + message.previousBlockTime = object.previousBlockTime ?? undefined; + message.bondDenom = object.bondDenom ?? ""; + return message; + }, +}; + +function createBaseGenesisTime(): GenesisTime { + return { genesisTime: undefined }; +} + +export const GenesisTime: MessageFns = { + encode(message: GenesisTime, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.genesisTime !== undefined) { + Timestamp.encode(toTimestamp(message.genesisTime), writer.uint32(10).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): GenesisTime { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisTime(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.genesisTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): GenesisTime { + return { genesisTime: isSet(object.genesisTime) ? fromJsonTimestamp(object.genesisTime) : undefined }; + }, + + toJSON(message: GenesisTime): unknown { + const obj: any = {}; + if (message.genesisTime !== undefined) { + obj.genesisTime = message.genesisTime.toISOString(); + } + return obj; + }, + + create, I>>(base?: I): GenesisTime { + return GenesisTime.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): GenesisTime { + const message = createBaseGenesisTime(); + message.genesisTime = object.genesisTime ?? undefined; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +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 isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create, I>>(base?: I): T; + fromPartial, I>>(object: I): T; +} diff --git a/src/generated/babylon/mint/v1/query.ts b/src/generated/babylon/mint/v1/query.ts new file mode 100644 index 0000000..37d4f93 --- /dev/null +++ b/src/generated/babylon/mint/v1/query.ts @@ -0,0 +1,479 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.2.0 +// protoc unknown +// source: babylon/mint/v1/query.proto + +/* eslint-disable */ +import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; +import { Timestamp } from "../../../google/protobuf/timestamp"; + +export const protobufPackage = "babylon.mint.v1"; + +/** + * QueryInflationRateRequest is the request type for the Query/InflationRate RPC + * method. + */ +export interface QueryInflationRateRequest { +} + +/** + * QueryInflationRateResponse is the response type for the Query/InflationRate + * RPC method. + */ +export interface QueryInflationRateResponse { + /** InflationRate is the current inflation rate. */ + inflationRate: Uint8Array; +} + +/** + * QueryAnnualProvisionsRequest is the request type for the + * Query/AnnualProvisions RPC method. + */ +export interface QueryAnnualProvisionsRequest { +} + +/** + * QueryAnnualProvisionsResponse is the response type for the + * Query/AnnualProvisions RPC method. + */ +export interface QueryAnnualProvisionsResponse { + /** AnnualProvisions is the current annual provisions. */ + annualProvisions: Uint8Array; +} + +/** + * QueryGenesisTimeRequest is the request type for the Query/GenesisTime RPC + * method. + */ +export interface QueryGenesisTimeRequest { +} + +/** + * QueryGenesisTimeResponse is the response type for the Query/GenesisTime RPC + * method. + */ +export interface QueryGenesisTimeResponse { + /** GenesisTime is the timestamp associated with the first block. */ + genesisTime: Date | undefined; +} + +function createBaseQueryInflationRateRequest(): QueryInflationRateRequest { + return {}; +} + +export const QueryInflationRateRequest: MessageFns = { + encode(_: QueryInflationRateRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): QueryInflationRateRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryInflationRateRequest(); + 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): QueryInflationRateRequest { + return {}; + }, + + toJSON(_: QueryInflationRateRequest): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): QueryInflationRateRequest { + return QueryInflationRateRequest.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(_: I): QueryInflationRateRequest { + const message = createBaseQueryInflationRateRequest(); + return message; + }, +}; + +function createBaseQueryInflationRateResponse(): QueryInflationRateResponse { + return { inflationRate: new Uint8Array(0) }; +} + +export const QueryInflationRateResponse: MessageFns = { + encode(message: QueryInflationRateResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.inflationRate.length !== 0) { + writer.uint32(10).bytes(message.inflationRate); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): QueryInflationRateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryInflationRateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.inflationRate = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): QueryInflationRateResponse { + return { inflationRate: isSet(object.inflationRate) ? bytesFromBase64(object.inflationRate) : new Uint8Array(0) }; + }, + + toJSON(message: QueryInflationRateResponse): unknown { + const obj: any = {}; + if (message.inflationRate.length !== 0) { + obj.inflationRate = base64FromBytes(message.inflationRate); + } + return obj; + }, + + create, I>>(base?: I): QueryInflationRateResponse { + return QueryInflationRateResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): QueryInflationRateResponse { + const message = createBaseQueryInflationRateResponse(); + message.inflationRate = object.inflationRate ?? new Uint8Array(0); + return message; + }, +}; + +function createBaseQueryAnnualProvisionsRequest(): QueryAnnualProvisionsRequest { + return {}; +} + +export const QueryAnnualProvisionsRequest: MessageFns = { + encode(_: QueryAnnualProvisionsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): QueryAnnualProvisionsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAnnualProvisionsRequest(); + 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): QueryAnnualProvisionsRequest { + return {}; + }, + + toJSON(_: QueryAnnualProvisionsRequest): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): QueryAnnualProvisionsRequest { + return QueryAnnualProvisionsRequest.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(_: I): QueryAnnualProvisionsRequest { + const message = createBaseQueryAnnualProvisionsRequest(); + return message; + }, +}; + +function createBaseQueryAnnualProvisionsResponse(): QueryAnnualProvisionsResponse { + return { annualProvisions: new Uint8Array(0) }; +} + +export const QueryAnnualProvisionsResponse: MessageFns = { + encode(message: QueryAnnualProvisionsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.annualProvisions.length !== 0) { + writer.uint32(10).bytes(message.annualProvisions); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): QueryAnnualProvisionsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAnnualProvisionsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.annualProvisions = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): QueryAnnualProvisionsResponse { + return { + annualProvisions: isSet(object.annualProvisions) ? bytesFromBase64(object.annualProvisions) : new Uint8Array(0), + }; + }, + + toJSON(message: QueryAnnualProvisionsResponse): unknown { + const obj: any = {}; + if (message.annualProvisions.length !== 0) { + obj.annualProvisions = base64FromBytes(message.annualProvisions); + } + return obj; + }, + + create, I>>(base?: I): QueryAnnualProvisionsResponse { + return QueryAnnualProvisionsResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): QueryAnnualProvisionsResponse { + const message = createBaseQueryAnnualProvisionsResponse(); + message.annualProvisions = object.annualProvisions ?? new Uint8Array(0); + return message; + }, +}; + +function createBaseQueryGenesisTimeRequest(): QueryGenesisTimeRequest { + return {}; +} + +export const QueryGenesisTimeRequest: MessageFns = { + encode(_: QueryGenesisTimeRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): QueryGenesisTimeRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGenesisTimeRequest(); + 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): QueryGenesisTimeRequest { + return {}; + }, + + toJSON(_: QueryGenesisTimeRequest): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): QueryGenesisTimeRequest { + return QueryGenesisTimeRequest.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(_: I): QueryGenesisTimeRequest { + const message = createBaseQueryGenesisTimeRequest(); + return message; + }, +}; + +function createBaseQueryGenesisTimeResponse(): QueryGenesisTimeResponse { + return { genesisTime: undefined }; +} + +export const QueryGenesisTimeResponse: MessageFns = { + encode(message: QueryGenesisTimeResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + if (message.genesisTime !== undefined) { + Timestamp.encode(toTimestamp(message.genesisTime), writer.uint32(10).fork()).join(); + } + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): QueryGenesisTimeResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGenesisTimeResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.genesisTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): QueryGenesisTimeResponse { + return { genesisTime: isSet(object.genesisTime) ? fromJsonTimestamp(object.genesisTime) : undefined }; + }, + + toJSON(message: QueryGenesisTimeResponse): unknown { + const obj: any = {}; + if (message.genesisTime !== undefined) { + obj.genesisTime = message.genesisTime.toISOString(); + } + return obj; + }, + + create, I>>(base?: I): QueryGenesisTimeResponse { + return QueryGenesisTimeResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): QueryGenesisTimeResponse { + const message = createBaseQueryGenesisTimeResponse(); + message.genesisTime = object.genesisTime ?? undefined; + return message; + }, +}; + +/** Query defines the gRPC querier service. */ +export interface Query { + /** InflationRate returns the current inflation rate. */ + InflationRate(request: QueryInflationRateRequest): Promise; + /** AnnualProvisions returns the current annual provisions. */ + AnnualProvisions(request: QueryAnnualProvisionsRequest): Promise; + /** GenesisTime returns the genesis time. */ + GenesisTime(request: QueryGenesisTimeRequest): Promise; +} + +export const QueryServiceName = "babylon.mint.v1.Query"; +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + private readonly service: string; + constructor(rpc: Rpc, opts?: { service?: string }) { + this.service = opts?.service || QueryServiceName; + this.rpc = rpc; + this.InflationRate = this.InflationRate.bind(this); + this.AnnualProvisions = this.AnnualProvisions.bind(this); + this.GenesisTime = this.GenesisTime.bind(this); + } + InflationRate(request: QueryInflationRateRequest): Promise { + const data = QueryInflationRateRequest.encode(request).finish(); + const promise = this.rpc.request(this.service, "InflationRate", data); + return promise.then((data) => QueryInflationRateResponse.decode(new BinaryReader(data))); + } + + AnnualProvisions(request: QueryAnnualProvisionsRequest): Promise { + const data = QueryAnnualProvisionsRequest.encode(request).finish(); + const promise = this.rpc.request(this.service, "AnnualProvisions", data); + return promise.then((data) => QueryAnnualProvisionsResponse.decode(new BinaryReader(data))); + } + + GenesisTime(request: QueryGenesisTimeRequest): Promise { + const data = QueryGenesisTimeRequest.encode(request).finish(); + const promise = this.rpc.request(this.service, "GenesisTime", data); + return promise.then((data) => QueryGenesisTimeResponse.decode(new BinaryReader(data))); + } +} + +interface Rpc { + request(service: string, method: string, data: Uint8Array): Promise; +} + +function bytesFromBase64(b64: string): Uint8Array { + if ((globalThis as any).Buffer) { + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); + } else { + const bin = globalThis.atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; + } +} + +function base64FromBytes(arr: Uint8Array): string { + if ((globalThis as any).Buffer) { + return globalThis.Buffer.from(arr).toString("base64"); + } else { + const bin: string[] = []; + arr.forEach((byte) => { + bin.push(globalThis.String.fromCharCode(byte)); + }); + return globalThis.btoa(bin.join("")); + } +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +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 isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export interface MessageFns { + encode(message: T, writer?: BinaryWriter): BinaryWriter; + decode(input: BinaryReader | Uint8Array, length?: number): T; + fromJSON(object: any): T; + toJSON(message: T): unknown; + create, I>>(base?: I): T; + fromPartial, I>>(object: I): T; +} diff --git a/src/index.ts b/src/index.ts index a2b6a43..1dc9bff 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,3 @@ -export * as btccheckpoint from './generated/babylon/btccheckpoint/v1/btccheckpoint'; -export * as btccheckpointparams from './generated/babylon/btccheckpoint/v1/params'; -export * as btccheckpointquery from './generated/babylon/btccheckpoint/v1/query'; -export * as btccheckpointtx from './generated/babylon/btccheckpoint/v1/tx'; - -export * as btcstaking from './generated/babylon/btcstaking/v1/btcstaking'; -export * as btcstakingparams from './generated/babylon/btcstaking/v1/params'; -export * as btcstakingquery from './generated/babylon/btcstaking/v1/query'; export * as btcstakingtx from './generated/babylon/btcstaking/v1/tx'; +export * as btcstaking from './generated/babylon/btcstaking/v1/btcstaking'; export * as btcstakingpop from './generated/babylon/btcstaking/v1/pop'; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 4f969d2..7791989 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,8 @@ ] // Include ES2017 libraries for compatibility }, "include": [ - "src/**/*.ts" + "src/**/*.ts", + "dist/**/*" ], "exclude": [ "node_modules",