fix: es-client builds

This commit is contained in:
Prad Nukala 2025-01-07 14:16:58 -05:00
parent e90fd76f69
commit d83b60a5db
502 changed files with 115019 additions and 4 deletions

67
.github/workflows/cd.yml vendored Normal file
View File

@ -0,0 +1,67 @@
# This workflow will create a GitHub release every time a tag is pushed
name: Deploy @onsonr/es to npm
on:
push:
branches:
- "master"
- "main"
jobs:
release:
permissions:
contents: write
runs-on: ubuntu-latest
if: contains(github.event.head_commit.modified, 'src/')
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install deps (with cache)
run: pnpm install
- name: Setup Git Config
run: |
git config user.name "Prad N."
git config user.email "prad@sonr.io"
- name: Build
run: pnpm run build
- name: "Automated Version Bump and Release"
run: |
git add .
git commit -m "chore: update build artifacts [skip ci]" || echo "No changes to commit"
pnpm version patch
git push
git push --tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}

View File

@ -1,12 +1,20 @@
# https://taskfile.dev # https://taskfile.dev
version: '3' version: '3'
vars:
GREETING: Hello, World!
tasks: tasks:
templ-gen: templ-gen:
cmds: cmds:
- templ generate - templ generate
silent: true silent: true
nebula-build:
dir: .
cmds:
- bun run build
silent: true
esclient-build:
dir: ./libs/es-client
cmds:
- devbox run build
silent: true

View File

@ -0,0 +1,33 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
extends: [
"plugin:@typescript-eslint/recommended",
/**
* Should be last in this array to override other configs
* @see https://github.com/prettier/eslint-config-prettier#installation
*/
"prettier",
],
rules: {
// Remove errors for unused args/vars starting with underscore
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
// Remove errors for intentional empty functions
"no-empty-function": "off",
"@typescript-eslint/no-empty-function": [
"error",
{
allow: ["private-constructors", "protected-constructors"],
},
],
},
};

41
libs/es-client/.gitignore vendored Normal file
View File

@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
node_modules
.pnp
.pnp.js
# testing
coverage
# build
dist/
# production
build
# misc
.DS_Store
*.pem
.vscode
.tmp
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
# local env files
.env
.env*.local
# vercel
.vercel
# typescript
*.tsbuildinfo
# turbo
.turbo
.aider*

View File

@ -0,0 +1,10 @@
/** @type {import("prettier").Config} */
module.exports = {
tabWidth: 2,
printWidth: 80,
singleQuote: false,
jsxSingleQuote: false,
semi: true,
trailingComma: "es5",
arrowParens: "always",
};

337
libs/es-client/CHANGELOG.md Normal file
View File

@ -0,0 +1,337 @@
# Changelog
## `v0.0.71`
### Features
- Add optional `label` field to `ConnectedWallet` instances, which contains the user-defined label of the wallet
### Fixes
- Handle more wallet errors in the `wrap` function
## `v0.0.70`
### Features
- Add legacy amino type to `MsgSend` model
- Add `MsgMigrateContract`, `MsgStoreCode`, `MsgBeginRedelegate`, `MsgDelegate`, `MsgUndelegate`, `MsgWithdrawDelegatorRewards`, `MsgWithdrawValidatorCommission` models
- Add ed25519 signature type
### Fixes
- Add Keplr default sign options to `WalletConnectV2`
## `v0.0.69`
### Chore
- Pin `@walletconnect/sign-client` dep to v2.8.x to reduce bundle size
## `v0.0.68`
### Chore
- Regenerate `pnpm-lock.yaml` to fix dep issues
## `v0.0.67`
### Fixes
- Fix `RpcClient`'s `RequestMessage` type error when using a request with an existing `height` field
## `v0.0.66`
### Features
- Add custom `WalletError` class to normalise wallet errors
- Add `MsgInstantiateContract` class
### Fixes
- Fixed verification of station mobile signatures
## `v0.0.65`
### Fixes
- Fixed `verifyArbitrary` to verify arbitrary signatures done via Station's new Keplr interface
## `v0.0.64`
### Features
- Added OWallet extension support (*does not support wallet connect yet*)
## `v0.0.63`
### Fixes
- Ignore all errors in retrieving public keys for Station Extension
## `v0.0.62`
### Improvements
- Txs are now broadcasted directly via the user-specified RPC instead of via the wallet (closes <https://github.com/coinhall/@onsonr/es/issues/17>)
- Update Station extension to use Keplr's API interface
## `v0.0.60`
### Features
- Parse `EthermintAccount` in `toBaseAccount` util function
## `v0.0.59`
### Fixes
- Fix Station mobile wallet to not throw errors if pub keys do not exist
## `v0.0.58`
### Fixes
- Fix Station mobile wallet connect issue when connecting more than 1 chain
## `v0.0.57`
### Fixes
- Allow Terra testnet to work correctly with Station extension
## `v0.0.56`
### Features
- Added Dymension's GAMM protobufs
### Miscellaneous
- Pinned Cosmos SDK protobuf to `v0.47.9`
## `v0.0.55`
### Features
- Added tx signing support for Dymension chain
## `v0.0.54`
### Fixes
- Fixed `MnemonicWallet` to generate Injective signatures correctly
## `v0.0.53`
### Fixes
- Fixed `MnemonicWallet` to resolve Injective address correctly
## `v0.0.52`
### Features
- Added Ninji wallet support to execute txs via Ninji extension on Injective network (*does not support wallet connect yet*)
## `v0.0.51`
### Fixes
- Fixed MetaMask on Injective to work correctly with `MsgExecuteContractCompat` when `funds` are empty
## `v0.0.50`
### Fixes
- Fixed the `verifyArbitrary` function to work correctly for all chains, including Injective which uses a different key algorithm
## `v0.0.49`
### Features
- Added the `verifyArbitrary` helper function (exported by `@onsonr/es/wallet`) to verify signatures signed using `ConnectedWallet.signArbitrary`
### Fixes
- Fixed the `recoverPubKeyFromEthSignature` helper function to calculate and use the correct recovery bit when generating the `secp256k1` model
## `v0.0.48`
### Features
- Added Compass wallet support to execute txs via Compass extension on Sei network (*does not support wallet connect yet*)
## `v0.0.47`
### Features
- Added MetaMask wallet support to execute txs via MetaMask extension on Injective network (*does not support wallet connect yet*)
### Improvements
- Added `extensionOptions` to `Tx.toSignedProto`
## `v0.0.46`
### Fixes
- Fixed `ConnectedWallet.estimateFee` to properly extract account sequences from errors thrown by Injective RPCs
## `v0.0.45`
### Improvements
- Included `isCW20` option for `simulateAstroportSinglePoolSwap` function to handle swapping from CW20 assets
## `v0.0.44`
### Fixes
- Fixed Leap wallet android deep link to ensure redirect happens correctly
- Fixed `toKeplrChainInfo` to return `undefined` for coingecko ID if it is absent
## `v0.0.43`
### Improvements
- Added `timeout_height` parameter when simulating or broadcasting txs
- Use sign mode direct (instead of legacy amino) for non-ledger extension wallets and `MnemonicWallet`
- Added support for sign mode direct for `WalletConnectV2` (although no mobile wallets support it currently)
- Reduced bundle size by combining Keplr-like wallets into the same interface (`examples/solid-vite` reduced from 509kb to 487kb minified)
## `v0.0.42`
### Features
- Added support for Injective chain (both mainnet and testnet)
## `v0.0.40`
### Fixes
- Use `JSON.stringify` on errors thrown by Station Extension to avoid `[object Object]` errors
### Miscellaneous
- Added `Tx.toSignDoc` method to form an unsigned, proto encoded tx ready to be signed by a wallet
## `v0.0.39`
### Features
- Added the optional `height` params to the `FetchClient` to execute queries at a custom block height
- Added batching of queries to `FetchClient` (see `examples/batch-query`)
## `v0.0.38` [breaking change]
### Features
- Added `MnemonicWallet` to allow programmatic signing and broadcasting of txs without relying on a 3rd party wallet/signer (see examples directory)
- Simplified wallet APIs **[breaking change]**
- `getAccount()`: renamed and reworked to `getAuthInfo()`, but consumers are no longer required to call this method to broadcast transactions
- `estimateFee()`: second parameter now accepts the `feeMultiplier` directly (still optional) instead of the auth info
- `broadcastTx()`: second parameter now accepts the `fee` from the result of `estimateFee()` (no longer optional) instead of the auth info
- `broadcastTxSync()`: new function that executes `estimateFee`, `broadcastTx`, and `pollTx` sequentially
- Handle account sequence mismatch errors directly in `ConnectedWallet.estimateFee()` by retrying once with the correct sequence
### Miscellaneous
- Removed the various `fromXxxToYyy` encoding/decoding functions within `@onsonr/es/codec` in favour of `@scure/base` **[breaking change]**
- The `@scure/base` pkg is re-exported in `@onsonr/es/codec`
- Consumers should import the correct encoder or decoder directly from `@onsonr/es/codec`: eg. change `fromHexToUint8Array(...)` to `base16.decode(...)`
- Re-exported `@keplr-wallet/types` from `@onsonr/es/registry`
## `v0.0.35`
### Features
- Added the `@onsonr/es/registry` package with the following additions:
- APIs to dynamically query for data in Chain Registry
- Util function to transform Chain Registry data to Keplr's chain info
### Miscellaneous
- The `toBaseAccount` utility can now handle all vesting account types
## `v0.0.34`
### Fixes
- Prevent redirecting users to the mobile app when querying for the user's account via WalletConnect (on first connect)
## `v0.0.33`
### Fixes
- Allow memo and fee fields to be set by user for WalletConnect wallets
- Fixed Cosmostation WalletConnect to use updated API changes
## `v0.0.32`
### Fixes
- Added missing `memo` field for `MsgIbcTransfer`
## `v0.0.31`
### Miscellaneous
- Added missing barrel export for `MsgIbcTransfer` model
## `v0.0.30`
### Features
- Added ICS 23 protobufs from [`cosmos/ics23`](https://github.com/cosmos/ics23) to fix `ibc-go` dependency issues
## `v0.0.29`
### Features
- Added IBC protobufs from [`cosmos/ibc-go`](https://github.com/cosmos/ibc-go)
- Added `MsgIbcTransfer` model
## `v0.0.28`
### Features
- Updated Station extension to use the new APIs injected into the `window` scope
## `v0.0.27`
### Miscellaneous
- Changed `lodash` dependency to `lodash-es`
## `v0.0.26`
### Breaking Changes
- The `onDisconnect` callback in the `WalletController` class now accepts a function that contains a list of disconnected wallets instead of a list of disconnected chain ID strings
### Features
- Added the `onAccountChange` event to the `WalletController` class to allow consumers to detect wallet account changes (works for all wallets except Station via WalletConnect v1)
### Miscellaneous
- Added `lodash` as peer dependency
## `v0.0.25`
### Improvements
- Replaced all `@walletconnect-v1` dependencies with correct legacy libraries at <https://github.com/WalletConnect/walletconnect-legacy>
- Added bundle size benchmarks (see `./benchmarks` folder)
- Improved docs on installing, polyfills, and benchmarks
### Miscellaneous
- Changed GPL v3 license to MIT license
## `v0.0.24`
### Features
- First public release

View File

@ -0,0 +1,149 @@
<!-- omit in toc -->
# Contributing
- [Directory Structure](#directory-structure)
- [Getting Started](#getting-started)
- [Installing](#installing)
- [Adding Dependencies](#adding-dependencies)
- [Developing](#developing)
- [Building](#building)
- [Publishing](#publishing)
- [Testing \& CI](#testing--ci)
- [Design Decisions](#design-decisions)
- [Minimise Bundle Size](#minimise-bundle-size)
- [Minimise Side Effects](#minimise-side-effects)
- [No Minifying](#no-minifying)
- [No Bundling](#no-bundling)
- [No Barrel Files](#no-barrel-files)
- [Full ESM Compatibility](#full-esm-compatibility)
## Directory Structure
This is a [pure ESM package](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c), written in TypeScript and managed by [pnpm](https://pnpm.io).
- [`/benchmarks`](./benchmarks) - contains bundle size comparisons between `@onsonr/es` and other packages like Cosmos Kit
- [`/examples`](./examples) - contains example applications that consume from the `@onsonr/es` package
- [`/scripts`](./scripts) - contains internal scripts for use in this monorepo
- [`/src`](./src) - contains the source code for the `@onsonr/es` package
## Getting Started
### Installing
Firstly, install all dependencies by running:
```sh
pnpm i
```
### Adding Dependencies
Dependencies that are not `devDependencies` should be added as `peerDependencies`. See ["No Bundling"](#no-bundling) for more information.
To add a new dev dependency, run:
```sh
pnpm add -D [dependency_name]
```
To add a new peer dependency (note that it is also automatically added as a dev dependency), run:
```sh
pnpm add --save-peer [dependency_name]
```
### Developing
All examples in the `/examples` directory are independent packages that contain a symlink to the root `@onsonr/es` package. This allows us to develop the `@onsonr/es` package and test it in the examples at the same time.
Firstly, to watch the `@onsonr/es` package and rebuild on changes, run the following in the root of the project:
```sh
# Run `pnpm build` first if this is your first time running this command
pnpm dev
```
Then, in a separate terminal, start the example app:
```sh
cd examples/solid-vite
pnpm install # If necessary
pnpm dev
```
### Building
All generated files should be committed to the repository. The convention is to prefix the commands with `gen:`. If there is a need to regenerate the files, run:
```sh
pnpm gen:protobufs
pnpm gen:registry
```
To build the package to the `dist` folder, run:
```sh
pnpm build
```
### Publishing
To bump the package version prior to publishing, run:
```sh
# To bump the patch number (most publishes should use this)
pnpm version patch --no-git-tag-version
# To bump the prerelease number (if and only if a RC version is required)
pnpm version prerelease --no-git-tag-version --preid=rc
```
To publish the package to NPM, run:
```sh
pnpm publish
```
### Testing & CI
To run all unit tests, run:
```sh
pnpm test
```
To emulate the full test suite (linting, typechecking, unit tests) that is automatically run in CI, run:
```sh
pnpm test:suite
```
## Design Decisions
If you intend to contribute to this monorepo, please read this section carefully and adhere to the guidelines (which are listed most important first).
### Minimise Bundle Size
This library's primary target users are web apps, built using a suitable bundler, running on modern browsers. As such, we should ensure that tree shaking works as well as possible, and use native browser APIs instead of relying on external dependencies/polyfills.
### Minimise Side Effects
Modules must not contain [side effects](https://blog.saeloun.com/2022/11/24/tree-shaking-in-webpack-5/#what-are-sideeffects) where possible. This allows us to specify the `sideEffects: false` flag in `package.json`, which allows bundlers to tree shake more effectively.
### No Minifying
All TypeScript code is *only transpiled*, not minified. Minifying changes the code structure and may [cause tree shaking issues for bundlers](https://stackoverflow.com/questions/71275009/bundling-and-publishing-an-npm-library-is-it-common-to-resolve-all-dependencies). Assuming that most consumers worried about bundle size will already be using a bundler, it is better to leave the minifying to their bundler.
### No Bundling
Dependencies must not be bundled but should instead be installed as [`peerDependencies`](https://blog.bitsrc.io/understanding-peer-dependencies-in-javascript-dbdb4ab5a7be?gi=c8dc907bb6cf). This allows consumers to use a different version of the dependency if need be, and [shifts dependency resolution and bundling](https://stackoverflow.com/questions/71275009/bundling-and-publishing-an-npm-library-is-it-common-to-resolve-all-dependencies) to the consumer's package manager and bundler. For the latter, it allows consumers to avoid having multiple copies of the same dependency in their bundle.
### No Barrel Files
There should only be one [barrel file](https://basarat.gitbook.io/typescript/main-1/barrel) located in the immediate subdirectories in the `src` directory, which defines the public API of the library. No other barrel files should exist as it [creates more issue than it solves](https://steven-lemon182.medium.com/are-typescript-barrel-files-an-anti-pattern-72a713004250), like making it [harder for bundlers to tree shake](https://github.com/vercel/next.js/issues/12557).
### Full ESM Compatibility
Full ESM compatibility of the emitted JavaScript files is required so that consumers can still use this library *without having to use a bundler* (even if they are not our primary target users). Most importantly, all imports and exports must use a [fully qualified relative path](https://nodejs.org/api/esm.html#mandatory-file-extensions) (ie. starts with `.` and ends with `.js`).
We achieve this by using `tsc-alias` on the emitted JavaScript files. It transforms the `path` alias configured in `tsconfig.json` to the relative path and adds the `.js` extensions to all imports and exports. See [`configs/tsconfig`](./configs/tsconfig) for the up to date configurations.

21
libs/es-client/LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Coinhall
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

183
libs/es-client/README.md Normal file
View File

@ -0,0 +1,183 @@
!-- omit in toc -->
# `@onsonr/es`
A tree-shakeable, framework agnostic, [pure ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) alternative of [CosmJS](https://github.com/cosmos/cosmjs) and [Cosmos Kit](https://cosmoskit.com) (**generate bundles up to 10x smaller than Cosmos Kit**).
- [Features](#features)
- [Installing](#installing)
- [Using with TypeScript](#using-with-typescript)
- [Using with Vite](#using-with-vite)
- [Using Station wallet](#using-station-wallet)
- [Examples](#examples)
- [Modules](#modules)
- [`@onsonr/es/client`](#@onsonr/esclient)
- [`@onsonr/es/codec`](#@onsonr/escodec)
- [`@onsonr/es/protobufs`](#@onsonr/esprotobufs)
- [`@onsonr/es/registry`](#@onsonr/esregistry)
- [`@onsonr/es/wallet`](#@onsonr/eswallet)
- [Benchmarks](#benchmarks)
- [Results](#results)
- [See More](#see-more)
## Features
> [!WARNING]
> **This is still a work in progress**. Before `v1` is reached, the API is not guaranteed to be semver compatible - patch releases may break everything. See the [changelog](./CHANGELOG.md) for notable changes.
- **Fully tree-shakeable**: import and bundle only the modules you need
- **Framework agnostic**: integrate with any web framework (React, Vue, Svelte, Solid, etc.)
- **Lightweight and minimal**: 153 KB gzipped to connect a React app to Keplr via browser extension or WalletConnect, 10x smaller than Cosmos Kit V2 (see [benchmarks](#benchmarks))
- **Uses modern web APIs**: no dependencies on Node.js and minimal dependencies on third-party libraries where possible
- **Supports modern bundlers**: works with Vite, SWC, Rollup, etc.
- **Fully typed**: written in TypeScript and ships with type definitions
## Installing
For Cosmos SDK v0.47 and below:
```sh
npm install @onsonr/es
pnpm add @onsonr/es
yarn add @onsonr/es
```
For Cosmos SDK v0.50, install using the `sdk50` tag:
```sh
npm install @onsonr/es@sdk50
pnpm add @onsonr/es@sdk50
yarn add @onsonr/es@sdk50
```
> [!IMPORTANT]
> The bump from v0.47 to v0.50 introduces significant breaking changes and is not recommended to be used unless necessary. To reduce the impact on consumers, the `main` branch and the published package on npm with the `latest` tag will continue to target v0.47 until the majority of live chains have migrated to v0.50.
>
> The [`parallel/sdk50`](https://github.com/coinhall/@onsonr/es/tree/parallel/sdk50) branch targetting v0.50 will be developed and maintained in parallel with the `main` branch, where the same patch version number should have feature parity (eg. `@onsonr/es@0.0.69` should have the same features as `@onsonr/es@0.0.69-sdk50.0`).
### Using with TypeScript
This library only exports ES modules. To ensure imports from this library work correctly, the following configuration is required in `tsconfig.json`:
```ts
{
"compilerOptions": {
"moduleResolution": "bundler", // recommended if using modern bundlers
// or "node16"
// or "nodenext"
// but NOT "node"
}
}
```
### Using with Vite
If you are using Vite, the following configuration is required in `vite.config.ts`:
```ts
export default defineConfig({
define: {
global: "window",
},
});
```
> This can be removed once support for WalletConnect v1 is no longer required.
### Using Station wallet
The Station wallet currently relies on WalletConnect v1. If you want to import and use `StationController`, a polyfill for `Buffer` is required:
```ts
// First, install the buffer package
npm install buffer
// Then, create a new file 'polyfill.ts'
import { Buffer } from "buffer";
(window as any).Buffer = Buffer;
// Finally, import the above file in your entry file
import "./polyfill";
```
See [`examples/solid-vite`](./examples/solid-vite) for a working example.
> This can be removed once support for WalletConnect v1 is no longer required.
## Examples
Docs do not exist yet - see the [`examples`](./examples) folder for various working examples:
1. [How do I connect to third party wallets via browser extension or WalletConnect? How do I create, sign, and broadcast transactions?](./examples/solid-vite)
2. [How do I programmatically sign and broadcast transactions without relying on a third party wallet?](./examples/mnemonic-wallet)
3. [How do I verify signatures signed using the `signArbitrary` function?](./examples/verify-signatures)
4. [How do I batch queries to the blockchain?](./examples/batch-query)
## Modules
This package is split into multiple subdirectories, with each subdirectory having their own set of functionalities. The root directory does not contain any exports, and all exports are exported from the subdirectories. Thus, imports must be done by referencing the subdirectories (ie. `import { ... } from "@onsonr/es/client"`).
### `@onsonr/es/client`
This directory contains models and helper functions to interact with Cosmos SDK via the [CometBFT RPC](https://docs.cosmos.network/v0.50/core/grpc_rest#cometbft-rpc).
### `@onsonr/es/codec`
This directory contains various encoding and decoding functions that relies solely on [Web APIs](https://developer.mozilla.org/en-US/docs/Web/API) and has no dependencies on Node.js. For modern browsers and Node v16+, this should work out of the box.
### `@onsonr/es/protobufs`
This directory contains the auto-generated code for various Cosmos SDK based protobufs. See `scripts/gen-protobufs.mjs` for the script that generates the code.
### `@onsonr/es/registry`
This directory contains various APIs, data, and types needed for wallet interactions (ie. Keplr). Some types are auto-generated, see `scripts/gen-registry.mjs` for the script that generates the types.
### `@onsonr/es/wallet`
This directory is a [Cosmos Kit](https://cosmoskit.com) alternative to interact with wallets across all Cosmos SDK based blockchains. See [`examples/solid-vite`](./examples/solid-vite) for a working example.
**Wallets supported**:
- [Station](https://docs.terra.money/learn/station/)
- [Keplr](https://www.keplr.app/)
- [Leap](https://www.leapwallet.io/)
- [Cosmostation](https://wallet.cosmostation.io/)
- [OWallet](https://owallet.dev/)
- [Compass](https://compasswallet.io/) (for Sei only)
- [MetaMask](https://metamask.io/) (for Injective only)
- [Ninji](https://ninji.xyz/) (for Injective only)
**Features**:
- Supports both browser extension (desktop) and WalletConnect (mobile)
- Unified interface for connecting, signing, broadcasting, and event handling
- Signing of arbitrary messages (for wallets that support it)
- Simultaneous connections to multiple WalletConnect wallets
## Benchmarks
See the [`benchmarks`](./benchmarks) folder, where the bundle size of SonrES is compared against Cosmos Kit. The following are adhered to:
- Apps should only contain the minimal functionality of connecting to Osmosis via Keplr using both the browser extension and WalletConnect wallets
- Apps should be built using React 18 (as Cosmos Kit has a [hard dependency](https://docs.cosmoskit.com/get-started)) and Vite
- Use the total sum of all generated bundles as reported by Vite after running the `vite build` command, including the size of all other dependencies like React/HTML/CSS/etc. (note: this is crude and not 100% accurate, but is the simplest method)
### Results
> Last updated: 4th May 2024
| Package | Minified | Gzipped |
| ------------- | -------- | ------- |
| SonrES | 553 KB | 153 KB |
| Cosmos Kit v1 | 6010 KB | 1399 KB |
| Cosmos Kit v2 | 6780 KB | 1556 KB |
## See More
- [Changelog](./CHANGELOG.md) - for notable changes
- [Contributing](./CONTRIBUTING.md) - if you want to contribute to this project

View File

@ -0,0 +1,10 @@
# see: https://docs.buf.build/configuration/v1/buf-gen-yaml
version: v1
plugins:
- plugin: es
opt: target=ts
out: .
- plugin: cosmes
path: ./scripts/protoc-gen-cosmes.mjs
opt: target=ts
out: .

2
libs/es-client/buf.lock Normal file
View File

@ -0,0 +1,2 @@
# Generated by buf. DO NOT EDIT.
version: v1

View File

@ -0,0 +1,20 @@
{
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.13.1/.schema/devbox.schema.json",
"packages": [
"pnpm@latest"
],
"shell": {
"init_hook": [
"pnpm install"
],
"scripts": {
"build": [
"pnpm run gen:protobufs",
"pnpm run build"
],
"publish": [
"pnpm publish"
]
}
}
}

View File

@ -0,0 +1,53 @@
{
"lockfile_version": "1",
"packages": {
"pnpm@latest": {
"last_modified": "2024-09-13T05:52:00Z",
"resolved": "github:NixOS/nixpkgs/673d99f1406cb09b8eb6feab4743ebdf70046557#pnpm",
"source": "devbox-search",
"version": "9.10.0",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/78jk4n2nn48f19cincpzk0fk1ylnhfw1-pnpm-9.10.0",
"default": true
}
],
"store_path": "/nix/store/78jk4n2nn48f19cincpzk0fk1ylnhfw1-pnpm-9.10.0"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/sgkja64j6077yla4wm0f1zck60imxxv6-pnpm-9.10.0",
"default": true
}
],
"store_path": "/nix/store/sgkja64j6077yla4wm0f1zck60imxxv6-pnpm-9.10.0"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/zw1lnwjig1anr1gjkp5ps5g0pd03hxmn-pnpm-9.10.0",
"default": true
}
],
"store_path": "/nix/store/zw1lnwjig1anr1gjkp5ps5g0pd03hxmn-pnpm-9.10.0"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/8zlqhgw5hbakbk2850wvky9x2vqbsqyw-pnpm-9.10.0",
"default": true
}
],
"store_path": "/nix/store/8zlqhgw5hbakbk2850wvky9x2vqbsqyw-pnpm-9.10.0"
}
}
}
}
}

View File

@ -0,0 +1,83 @@
{
"name": "@onsonr/es",
"version": "0.0.2",
"private": false,
"packageManager": "pnpm@8.3.0",
"sideEffects": false,
"type": "module",
"publishConfig": {
"access": "public"
},
"files": [
"src",
"dist"
],
"jsdelivr": "dist/client/index.js",
"exports": {
"./client": "./dist/client/index.js",
"./codec": "./dist/codec/index.js",
"./protobufs": "./dist/protobufs/index.js",
"./registry": "./dist/registry/index.js",
"./wallet": "./dist/wallet/index.js"
},
"scripts": {
"clean": "rimraf dist",
"build": "pnpm clean && tsc && tsc-alias",
"dev": "concurrently \"tsc -w\" \"tsc-alias -w\"",
"gen:protobufs": "node scripts/gen-protobufs.mjs",
"gen:registry": "node scripts/gen-registry.mjs",
"lint": "eslint **/*.ts",
"typecheck": "tsc --noEmit",
"test": "vitest --run",
"test:suite": "pnpm lint && pnpm typecheck && pnpm test",
"prepublishOnly": "pnpm build"
},
"peerDependencies": {
"@bufbuild/protobuf": "1.2.0",
"@noble/hashes": "^1.3.2",
"@noble/secp256k1": "^2.0.0",
"@scure/base": "^1.1.3",
"@scure/bip32": "^1.3.2",
"@scure/bip39": "^1.2.1",
"@walletconnect/legacy-client": "^2.0.0",
"@walletconnect/sign-client": "2.8.6",
"lodash-es": "^4.17.21"
},
"devDependencies": {
"@bufbuild/buf": "1.18.0-1",
"@bufbuild/protobuf": "1.2.0",
"@bufbuild/protoc-gen-es": "1.2.0",
"@bufbuild/protoplugin": "1.2.0",
"@keplr-wallet/types": "^0.11.62",
"@metamask/providers": "^14.0.2",
"@noble/hashes": "^1.3.2",
"@noble/secp256k1": "^2.0.0",
"@scure/base": "^1.1.3",
"@scure/bip32": "^1.3.2",
"@scure/bip39": "^1.2.1",
"@types/degit": "^2.8.3",
"@types/lodash-es": "^4.17.7",
"@typescript-eslint/eslint-plugin": "^5.59.5",
"@typescript-eslint/parser": "^5.59.5",
"@walletconnect/legacy-client": "^2.0.0",
"@walletconnect/legacy-types": "^2.0.0",
"@walletconnect/sign-client": "2.8.6",
"@walletconnect/types": "2.8.6",
"autoprefixer": "^10.4.14",
"concurrently": "^8.0.1",
"degit": "^2.8.4",
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.8.0",
"glob": "^10.2.3",
"json-schema-to-typescript": "^13.1.1",
"lodash-es": "^4.17.21",
"postcss": "^8.4.23",
"prettier": "^2.8.8",
"prettier-plugin-tailwindcss": "^0.2.8",
"rimraf": "^5.0.0",
"tsc-alias": "^1.8.6",
"tsx": "^3.12.7",
"typescript": "^5.0.4",
"vitest": "^0.31.0"
}
}

4598
libs/es-client/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,171 @@
// @ts-check
/**
* This script generates the src/protobufs directory from the proto files in the
* repos specified in `REPOS`. It uses `buf` to generate TS files from the proto
* files, and then generates an `index.ts` file to re-export the generated code.
*/
import { spawnSync } from "child_process";
import degit from "degit";
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
import { globSync } from "glob";
import { capitalize } from "lodash-es";
import { dirname, join } from "path";
import { fileURLToPath } from "url";
/**
* @typedef Repo
* @type {object}
* @property {string} repo - Git repo and branch to clone
* @property {string[]} paths - Paths to proto files relative to the repo root
*/
/**
* TODO: Add more repos here when necessary.
* @type {Repo[]}
*/
const REPOS = [
{
repo: "cosmos/cosmos-sdk#v0.50.5",
paths: ["proto"],
},
{
repo: "cosmos/ics23#master",
paths: ["proto"],
},
{
repo: "cosmos/ibc-go#main",
paths: ["proto"],
},
{
repo: "onsonr/sonr#main",
paths: ["proto"],
},
{
repo: "CosmWasm/wasmd#main",
paths: ["proto"],
},
{
repo: "osmosis-labs/osmosis#main",
paths: ["proto"],
},
{
repo: "evmos/ethermint#main",
paths: ["proto"],
},
{
repo: "nomic-io/nomic#develop",
paths: ["src/babylon/proto"],
},
];
const __dirname = dirname(fileURLToPath(import.meta.url));
const PROTOBUFS_DIR = join(__dirname, "..", "src", "protobufs");
const TMP_DIR = join(PROTOBUFS_DIR, ".tmp");
/** Generates a unique dirname from `repo` to use in `TMP_DIR`. */
const id = (/** @type {string} */ repo) => repo.replace(/[#/]/g, "-");
console.log("Initialising directories...");
{
rmSync(PROTOBUFS_DIR, { recursive: true, force: true });
rmSync(TMP_DIR, { recursive: true, force: true });
mkdirSync(PROTOBUFS_DIR);
mkdirSync(TMP_DIR);
}
console.log("Cloning required repos...");
{
await Promise.all(
REPOS.map(({ repo }) => degit(repo).clone(join(TMP_DIR, id(repo))))
);
}
console.log("Generating TS files from proto files...");
{
for (const { repo, paths } of REPOS) {
for (const path of paths) {
spawnSync(
"pnpm",
[
"buf",
"generate",
join(TMP_DIR, id(repo), path),
"--output",
join(
PROTOBUFS_DIR,
repo.startsWith("dymensionxyz") ? "dymension" : ""
),
],
{
cwd: process.cwd(),
stdio: "inherit",
}
);
}
console.log(`✔️ [${repo}]`);
}
}
console.log("Generating src/index.ts file and renaming exports...");
{
const LAST_SEGMENT_REGEX = /[^/]+$/;
const EXPORTED_NAME_REGEX = /^export \w+ (\w+) /gm;
let contents =
"/** This file is generated by gen-protobufs.mjs. Do not edit. */\n\n";
/**
* Builds the `src/proto/index.ts` file to re-export generated code.
* A prefix is added to the exported names to avoid name collisions.
* The prefix is the names of the directories in `proto` leading up
* to the directory of the exported code, concatenated in PascalCase.
* For example, if the exported code is in `proto/foo/bar/goo.ts`, the
* prefix will be `FooBar`.
* @param {string} dir
*/
function generateIndexExports(dir) {
const files = globSync(join(dir, "*"));
if (files.length === 0) {
return;
}
const prefixName = dir
.replace(PROTOBUFS_DIR + "/", "")
.split("/")
.map((name) =>
// convert all names to PascalCase
name.split(/[-_]/).map(capitalize).join("")
)
.join("");
for (const file of files) {
const fileName = file.match(LAST_SEGMENT_REGEX)?.[0];
if (!fileName) {
console.error("Could not find name for", file);
continue;
}
if (!fileName.endsWith(".ts")) {
continue;
}
const code = readFileSync(file, "utf8");
contents += `export {\n`;
for (const match of code.matchAll(EXPORTED_NAME_REGEX)) {
const exportedName = match[1];
contents += ` ${exportedName} as ${prefixName + exportedName},\n`;
}
const exportedFile = file
.replace(PROTOBUFS_DIR + "/", "")
.replace(".ts", ".js");
contents += `} from "./${exportedFile}";\n`;
}
for (const file of files) {
generateIndexExports(file);
}
}
generateIndexExports(PROTOBUFS_DIR);
writeFileSync(join(PROTOBUFS_DIR, "index.ts"), contents);
}
console.log("Cleaning up...");
{
rmSync(TMP_DIR, { recursive: true, force: true });
}
console.log("Proto generation completed successfully!");

View File

@ -0,0 +1,53 @@
import { writeFileSync } from "fs";
import { compile } from "json-schema-to-typescript";
import { dirname, join } from "path";
import { fileURLToPath } from "url";
const __dirname = dirname(fileURLToPath(import.meta.url));
async function genChainRegistryChainInfo() {
const tsName = "ChainRegistryChainInfo";
const tsFile = tsName + ".ts";
console.log("Retrieving JSON schema...");
const res = await fetch(
"https://raw.githubusercontent.com/cosmos/chain-registry/master/chain.schema.json"
);
const schema = await res.json();
schema.title = tsName;
console.log("Compiling JSON schema to TypeScript...");
const types = await compile(schema, tsName, {
// See: https://github.com/bcherny/json-schema-to-typescript?tab=readme-ov-file#options
strictIndexSignatures: true,
});
const target = join(__dirname, "..", "src", "registry", "types", tsFile);
writeFileSync(target, types);
console.log("Wrote types to", target);
}
async function genChainRegistryAssetList() {
const tsName = "ChainRegistryAssetList";
const tsFile = tsName + ".ts";
console.log("Retrieving JSON schema...");
const res = await fetch(
"https://raw.githubusercontent.com/cosmos/chain-registry/master/assetlist.schema.json"
);
const schema = await res.json();
schema.title = tsName;
console.log("Compiling JSON schema to TypeScript...");
const types = await compile(schema, tsName, {
// See: https://github.com/bcherny/json-schema-to-typescript?tab=readme-ov-file#options
strictIndexSignatures: true,
});
const target = join(__dirname, "..", "src", "registry", "types", tsFile);
writeFileSync(target, types);
console.log("Wrote types to", target);
}
await genChainRegistryChainInfo();
await genChainRegistryAssetList();

View File

@ -0,0 +1,50 @@
#!/usr/bin/env node
// @ts-check
/**
* This is a custom plugin for `buf` that generates TS files from the services
* defined in the proto files, and is referred to by the root `buf.gen.yaml`.
* Files generated using this plugin contains the `_@onsonr/es` suffix.
*
* Do not convert this to a TS file as it runs 4x slower!
*/
import { createEcmaScriptPlugin, runNodeJs } from "@bufbuild/protoplugin";
import {
literalString,
localName,
makeJsDoc,
} from "@bufbuild/protoplugin/ecmascript";
export function generateTs(schema) {
for (const protoFile of schema.files) {
const file = schema.generateFile(protoFile.name + "_cosmes.ts");
file.preamble(protoFile);
for (const service of protoFile.services) {
generateService(schema, file, service);
}
}
}
function generateService(schema, f, service) {
f.print("const TYPE_NAME = ", literalString(service.typeName), ";");
f.print("");
for (const method of service.methods) {
f.print(makeJsDoc(method));
f.print("export const ", localName(service), method.name, "Service = {");
f.print(" typeName: TYPE_NAME,");
f.print(" method: ", literalString(method.name), ",");
f.print(" Request: ", method.input, ",");
f.print(" Response: ", method.output, ",");
f.print("} as const;");
f.print("");
}
}
runNodeJs(
createEcmaScriptPlugin({
name: "protoc-gen-cosmes",
version: "v0.0.1",
generateTs,
})
);

View File

@ -0,0 +1,19 @@
import { Prettify } from "../../typeutils/prettify";
import { RpcClient } from "../clients/RpcClient";
import { ToSignedProtoParams, Tx } from "../models/Tx";
export type BroadcastTxParams = Prettify<
ToSignedProtoParams & {
tx: Tx;
}
>;
/**
* Broadcasts a tx to the network and returns the tx hash if successful.
*/
export async function broadcastTx(
endpoint: string,
{ tx, ...params }: BroadcastTxParams
) {
return RpcClient.broadcastTx(endpoint, tx.toSignedProto(params));
}

View File

@ -0,0 +1,19 @@
import { CosmosAuthV1beta1QueryAccountService as QueryAccountService } from "@onsonr/es/protobufs";
import { RpcClient } from "../clients/RpcClient";
export type GetAccountParams = {
address: string;
};
export async function getAccount(endpoint: string, params: GetAccountParams) {
const { account } = await RpcClient.query(
endpoint,
QueryAccountService,
params
);
if (!account) {
throw new Error("Account not found");
}
return account;
}

View File

@ -0,0 +1,30 @@
import { queryContract } from "./queryContract";
export type GetCw20BalanceParams = {
address: string;
token: string;
};
type Response = {
balance: string;
};
export async function getCw20Balance(
endpoint: string,
{ address, token }: GetCw20BalanceParams
): Promise<bigint> {
try {
const { balance } = await queryContract<Response>(endpoint, {
address: token,
query: {
balance: {
address: address,
},
},
});
return BigInt(balance);
} catch (err) {
console.error(err);
return 0n;
}
}

View File

@ -0,0 +1,20 @@
import { CosmosBankV1beta1QueryAllBalancesService as QueryAllBalancesService } from "@onsonr/es/protobufs";
import { RpcClient } from "../clients/RpcClient";
export type GetNativeBalancesParams = {
address: string;
};
export async function getNativeBalances(
endpoint: string,
params: GetNativeBalancesParams
) {
// TODO: handle pagination
const { balances } = await RpcClient.query(
endpoint,
QueryAllBalancesService,
params
);
return balances;
}

View File

@ -0,0 +1,21 @@
import {
CosmosTxV1beta1GetTxResponse as GetTxResponse,
CosmosTxV1beta1ServiceGetTxService as GetTxService,
} from "@onsonr/es/protobufs";
import { RpcClient } from "../clients/RpcClient";
export type GetTxParams = {
hash: string;
};
/**
* Returns the tx matching the given hash. Throws if the tx is not found.
*/
export async function getTx(endpoint: string, params: GetTxParams) {
const res = await RpcClient.query(endpoint, GetTxService, params);
if (!res.tx || !res.txResponse) {
throw new Error("Tx not found");
}
return res as Required<GetTxResponse>;
}

View File

@ -0,0 +1,28 @@
import { wait } from "../utils/wait";
import { getTx } from "./getTx";
export type PollTxParams = {
hash: string;
intervalSeconds?: number;
maxAttempts?: number;
};
/**
* Polls for the tx matching the given `hash`, with a minimum interval of
* `intervalSeconds`. Throws if the tx is not found after the given number
* of `maxAttempts`.
*/
export async function pollTx(
endpoint: string,
{ intervalSeconds = 2, maxAttempts = 64, ...getTxParams }: PollTxParams
) {
const intervalMillis = intervalSeconds * 1000;
for (let i = 0; i < maxAttempts; i++) {
try {
return await getTx(endpoint, getTxParams);
} catch (err) {
await wait(intervalMillis);
}
}
throw new Error("Tx not found");
}

View File

@ -0,0 +1,29 @@
import { JsonValue } from "@bufbuild/protobuf";
import { utf8 } from "@onsonr/es/codec";
import { CosmwasmWasmV1QuerySmartContractStateService as QuerySmartContractStateService } from "@onsonr/es/protobufs";
import { RpcClient } from "../clients/RpcClient";
export type QueryContractParams = {
address: string;
query: JsonValue;
};
/**
* Queries the contract at `address` with the given `query` JSON message,
* and returns the parsed JSON response.
*/
export async function queryContract<T extends JsonValue>(
endpoint: string,
{ address, query }: QueryContractParams
): Promise<T> {
const { data } = await RpcClient.query(
endpoint,
QuerySmartContractStateService,
{
address,
queryData: utf8.decode(JSON.stringify(query)),
}
);
return JSON.parse(utf8.encode(data));
}

View File

@ -0,0 +1,49 @@
import { queryContract } from "./queryContract";
export type SimulateAstroportSinglePoolSwapParams = {
poolId: string;
fromAsset: string;
fromAmount: bigint;
isCW20?: boolean | undefined;
};
type Response = {
return_amount: string;
spread_amount: string;
commission_amount: string;
};
/**
* Simulates the amount of assets that would be received by swapping
* `fromAmount` amount of `fromAsset` assets via the `poolId` pool.
* If `fromAsset` is a CW20 token, `isCW20` must be set to `true`.
*/
export async function simulateAstroportSinglePoolSwap(
endpoint: string,
{
poolId,
fromAsset,
fromAmount,
isCW20,
}: SimulateAstroportSinglePoolSwapParams
): Promise<bigint> {
try {
const { return_amount } = await queryContract<Response>(endpoint, {
address: poolId,
query: {
simulation: {
offer_asset: {
info: isCW20
? { token: { contract_addr: fromAsset } }
: { native_token: { denom: fromAsset } },
amount: fromAmount.toString(),
},
},
},
});
return BigInt(return_amount);
} catch (err) {
console.error(err);
return 0n;
}
}

View File

@ -0,0 +1,44 @@
import { queryContract } from "./queryContract";
export type SimulateKujiraSinglePoolSwapParams = {
poolId: string;
fromAsset: string;
fromAmount: bigint;
};
type Response = {
return_amount: string;
spread_amount: string;
commission_amount: string;
};
/**
* Simulates the amount of assets that would be received by swapping
* `fromAmount` amount of `fromAsset` assets via the `poolId` pool.
*/
export async function simulateKujiraSinglePoolSwap(
endpoint: string,
{ poolId, fromAsset, fromAmount }: SimulateKujiraSinglePoolSwapParams
): Promise<bigint> {
try {
const { return_amount } = await queryContract<Response>(endpoint, {
address: poolId,
query: {
simulation: {
offer_asset: {
info: {
native_token: {
denom: fromAsset,
},
},
amount: fromAmount.toString(),
},
},
},
});
return BigInt(return_amount);
} catch (err) {
console.error(err);
return 0n;
}
}

View File

@ -0,0 +1,23 @@
import { CosmosTxV1beta1ServiceSimulateService as SimulateService } from "@onsonr/es/protobufs";
import { Prettify } from "../../typeutils/prettify";
import { RpcClient } from "../clients/RpcClient";
import { ToUnsignedProtoParams, Tx } from "../models/Tx";
export type SimulateTxParams = Prettify<
ToUnsignedProtoParams & {
tx: Tx;
}
>;
/**
* Simulates a tx for the purpose of estimating gas fees.
*/
export async function simulateTx(
endpoint: string,
{ tx, ...params }: SimulateTxParams
) {
return RpcClient.query(endpoint, SimulateService, {
txBytes: tx.toUnsignedProto(params).toBinary(),
});
}

View File

@ -0,0 +1,33 @@
import { JsonValue } from "@bufbuild/protobuf";
/**
* A simple and minimal wrapper around the native `fetch` API.
*/
export class FetchClient {
/**
* Performs a GET request to the given `endpoint`, and returns the
* JSON response.
*/
public static async get<T>(
endpoint: string,
searchParams?: Record<string, string> | undefined
): Promise<T> {
const url = new URL(endpoint);
url.search = new URLSearchParams(searchParams).toString();
const res = await fetch(url, { method: "GET" });
return res.json();
}
/**
* Performs a POST request to the given `endpoint`, and returns the
* JSON response.
*/
public static async post<T>(endpoint: string, body: JsonValue): Promise<T> {
const res = await fetch(endpoint, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
return res.json();
}
}

View File

@ -0,0 +1,210 @@
import { JsonValue, Message, PartialMessage } from "@bufbuild/protobuf";
import { base16, base64 } from "@onsonr/es/codec";
import { CosmosTxV1beta1TxRaw as TxRaw } from "@onsonr/es/protobufs";
import { FetchClient } from "./FetchClient";
type ErrorResponse = {
id: number;
jsonrpc: string;
error: {
code: number;
message: string;
data: string;
};
result: never;
};
type SuccessResponse<T> = {
id: number;
jsonrpc: string;
result: T;
error: never;
};
type Response<T> = SuccessResponse<T> | ErrorResponse;
type QueryResult = {
response: {
code: number;
log: string;
info: string;
index: string;
key: string | null;
value: string | null;
proofOps: string[] | null;
height: string;
codespace: string;
};
};
type QueryService<T extends Message<T>, U extends Message<U>> = {
typeName: string;
method: string;
Request: new (msg: PartialMessage<T>) => T;
Response: { fromBinary: (bytes: Uint8Array) => U };
};
type BroadcastTxResult = {
code: number;
codespace: string;
data: string;
hash: string;
log: string;
};
/**
* Wraps the request message with an optional `height` field.
*/
type RequestMessage<T extends Message<T>> = T extends {
height: bigint | string | number;
}
? PartialMessage<T>
: PartialMessage<T> & {
/**
* The block height at which the query should be executed. Providing a height
* that is outside the range of the full node will result in an error. Leave
* this field empty to default to the latest block.
*/
height?: number | undefined;
};
export class RpcClient {
private static async doRequest<T>(
endpoint: string,
method: string,
params: JsonValue
) {
const { result, error } = await FetchClient.post<Response<T>>(endpoint, {
id: Date.now(),
jsonrpc: "2.0",
method,
params,
});
if (error != null) {
throw new Error(error.data);
}
return result;
}
/**
* Posts an ABCI query to the RPC `endpoint`. If successful, returns the response,
* otherwise throws an error.
*/
public static async query<T extends Message<T>, U extends Message<U>>(
endpoint: string,
{ typeName, method, Request, Response }: QueryService<T, U>,
requestMsg: RequestMessage<T>
): Promise<U> {
const { response } = await this.doRequest<QueryResult>(
endpoint,
"abci_query",
{
path: `/${typeName}/${method}`,
data: base16.encode(new Request(requestMsg).toBinary()),
...(requestMsg.height ? { height: requestMsg.height.toString() } : {}),
}
);
const { log, value } = response;
if (!value) {
throw new Error(log);
}
return Response.fromBinary(base64.decode(value));
}
/**
* Posts a `broadcast_tx_sync` request to the RPC `endpoint`. If successful,
* returns the tx hash, otherwise throws an error.
*/
public static async broadcastTx(
endpoint: string,
txRaw: TxRaw
): Promise<string> {
const { code, log, hash } = await this.doRequest<BroadcastTxResult>(
endpoint,
"broadcast_tx_sync",
{
tx: base64.encode(txRaw.toBinary()),
}
);
if (code !== 0) {
throw new Error(log);
}
return hash;
}
/**
* Creates a new ABCI batch query.
*/
public static newBatchQuery(endpoint: string): BatchQuery {
return new BatchQuery(endpoint);
}
}
class BatchQuery {
private readonly endpoint: string;
private readonly queries: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
queryService: QueryService<any, any>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
requestMsg: RequestMessage<any>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
callback: (err: Error | null, response: any) => unknown;
}[] = [];
constructor(endpoint: string) {
this.endpoint = endpoint;
}
/**
* Adds an `abci_query` to this query batch.
*
* @param callback An error-first callback function for the response of the query.
* If `err` is not `null`, `response` will be `null` and should not be used.
*/
public add<T extends Message<T>, U extends Message<U>>(
queryService: QueryService<T, U>,
requestMsg: RequestMessage<T>,
callback: (err: Error | null, response: U) => unknown
) {
this.queries.push({ queryService, requestMsg, callback });
return this;
}
/**
* Executes the batched query.
*/
public async send() {
if (this.queries.length === 0) {
return;
}
const payload = this.queries.map(({ queryService, requestMsg }, idx) => ({
id: idx,
jsonrpc: "2.0",
method: "abci_query",
params: {
path: `/${queryService.typeName}/${queryService.method}`,
data: base16.encode(new queryService.Request(requestMsg).toBinary()),
...(requestMsg.height ? { height: requestMsg.height.toString() } : {}),
},
}));
const res = await FetchClient.post<
// Array is returned if and only if the payload has more than one query
Response<QueryResult>[] | Response<QueryResult>
>(this.endpoint, payload);
const results = Array.isArray(res) ? res : [res];
for (const { id, result, error } of results) {
const { queryService, callback: handler } = this.queries[id];
if (error != null) {
handler(new Error(error.data), null);
continue;
}
const { log, value } = result.response;
if (!value) {
handler(new Error(log), null);
continue;
}
const responseMsg = queryService.Response.fromBinary(
base64.decode(value)
);
handler(null, responseMsg);
}
}
}

View File

@ -0,0 +1,47 @@
export { broadcastTx, type BroadcastTxParams } from "./apis/broadcastTx";
export { getAccount, type GetAccountParams } from "./apis/getAccount";
export {
getCw20Balance,
type GetCw20BalanceParams,
} from "./apis/getCw20Balance";
export {
getNativeBalances,
type GetNativeBalancesParams,
} from "./apis/getNativeBalances";
export { getTx, type GetTxParams } from "./apis/getTx";
export { pollTx, type PollTxParams } from "./apis/pollTx";
export { queryContract, type QueryContractParams } from "./apis/queryContract";
export {
simulateAstroportSinglePoolSwap,
type SimulateAstroportSinglePoolSwapParams,
} from "./apis/simulateAstroportSinglePoolSwap";
export {
simulateKujiraSinglePoolSwap,
type SimulateKujiraSinglePoolSwapParams,
} from "./apis/simulateKujiraSinglePoolSwap";
export { simulateTx, type SimulateTxParams } from "./apis/simulateTx";
export { RpcClient } from "./clients/RpcClient";
export { type Adapter } from "./models/Adapter";
export { MsgExecuteContract } from "./models/MsgExecuteContract";
export { MsgInstantiateContract } from "./models/MsgInstantiateContract";
export { MsgStoreCode } from "./models/MsgStoreCode";
export { MsgMigrateContract } from "./models/MsgMigrateContract";
export { MsgIbcTransfer } from "./models/MsgIbcTransfer";
export { MsgSend } from "./models/MsgSend";
export { MsgDelegate } from "./models/MsgDelegate";
export { MsgUndelegate } from "./models/MsgUndelegate";
export { MsgBeginRedelegate } from "./models/MsgBeginRedelegate";
export { MsgWithdrawDelegatorRewards } from "./models/MsgWithdrawDelegatorRewards";
export { MsgWithdrawValidatorCommission } from "./models/MsgWithdrawValidatorCommission";
export { Secp256k1PubKey } from "./models/Secp256k1PubKey";
export {
Tx,
type ToSignDocParams,
type ToSignedProtoParams,
type ToStdSignDocParams,
type ToUnsignedProtoParams,
} from "./models/Tx";
export { calculateFee } from "./utils/calculateFee";
export { toAny } from "./utils/toAny";
export { toBaseAccount } from "./utils/toBaseAccount";

View File

@ -0,0 +1,12 @@
import { Message } from "@bufbuild/protobuf";
/**
* An adapter to translate between protobuf and amino encodings.
*/
export type Adapter = {
toProto: () => Message;
toAmino: () => {
type: string;
value: Record<string, unknown>;
};
};

View File

@ -0,0 +1,31 @@
import { PlainMessage } from "@bufbuild/protobuf";
import { CosmosStakingV1beta1MsgBeginRedelegate as ProtoMsgBeginRedelegate } from "@onsonr/es/protobufs";
import { DeepPrettify } from "../../typeutils/prettify";
import { Adapter } from "./Adapter";
type Data = DeepPrettify<PlainMessage<ProtoMsgBeginRedelegate>>;
export class MsgBeginRedelegate implements Adapter {
private readonly data: Data;
constructor(data: Data) {
this.data = data;
}
public toProto() {
return new ProtoMsgBeginRedelegate(this.data);
}
public toAmino() {
return {
type: "cosmos-sdk/MsgBeginRedelegate",
value: {
delegator_address: this.data.delegatorAddress,
validator_src_address: this.data.validatorSrcAddress,
validator_dst_address: this.data.validatorDstAddress,
amount: this.data.amount,
},
};
}
}

View File

@ -0,0 +1,30 @@
import { PlainMessage } from "@bufbuild/protobuf";
import { CosmosStakingV1beta1MsgDelegate as ProtoMsgDelegate } from "@onsonr/es/protobufs";
import { DeepPrettify } from "../../typeutils/prettify";
import { Adapter } from "./Adapter";
type Data = DeepPrettify<PlainMessage<ProtoMsgDelegate>>;
export class MsgDelegate implements Adapter {
private readonly data: Data;
constructor(data: Data) {
this.data = data;
}
public toProto() {
return new ProtoMsgDelegate(this.data);
}
public toAmino() {
return {
type: "cosmos-sdk/MsgDelegate",
value: {
delegator_address: this.data.delegatorAddress,
validator_address: this.data.validatorAddress,
amount: this.data.amount,
},
};
}
}

View File

@ -0,0 +1,34 @@
import { PlainMessage } from "@bufbuild/protobuf";
import { utf8 } from "@onsonr/es/codec";
import { CosmwasmWasmV1MsgExecuteContract as ProtoMsgExecuteContract } from "@onsonr/es/protobufs";
import { DeepPrettify, Prettify } from "../../typeutils/prettify";
import { Adapter } from "./Adapter";
type Data<T> = Prettify<
DeepPrettify<Omit<PlainMessage<ProtoMsgExecuteContract>, "msg">> & {
msg: T;
}
>;
export class MsgExecuteContract<T> implements Adapter {
private readonly data: Data<T>;
constructor(data: Data<T>) {
this.data = data;
}
public toProto() {
return new ProtoMsgExecuteContract({
...this.data,
msg: utf8.decode(JSON.stringify(this.data.msg)),
});
}
public toAmino() {
return {
type: "wasm/MsgExecuteContract",
value: this.data,
};
}
}

View File

@ -0,0 +1,47 @@
import { PlainMessage } from "@bufbuild/protobuf";
import { IbcApplicationsTransferV1MsgTransfer as ProtoMsgIbcTransfer } from "@onsonr/es/protobufs";
import { DeepPrettify } from "../../typeutils/prettify";
import { Adapter } from "./Adapter";
type Data = DeepPrettify<PlainMessage<ProtoMsgIbcTransfer>>;
export class MsgIbcTransfer implements Adapter {
private readonly data: Data;
constructor(data: Data) {
this.data = data;
}
public toProto() {
return new ProtoMsgIbcTransfer(this.data);
}
public toAmino() {
return {
type: "cosmos-sdk/MsgTransfer",
value: {
source_port: this.data.sourcePort,
source_channel: this.data.sourceChannel,
token: this.data.token,
sender: this.data.sender,
receiver: this.data.receiver,
/**
* Protobuf type is optional, but Amino type is non-optional.
*
* @see https://github.com/cosmos/cosmjs/blob/358260bff71c9d3e7ad6644fcf64dc00325cdfb9/packages/stargate/src/modules/ibc/aminomessages.ts#L16-L42
*/
timeout_height: this.data.timeoutHeight
? {
revision_number:
this.data.timeoutHeight.revisionNumber.toString(),
revision_height:
this.data.timeoutHeight.revisionHeight.toString(),
}
: {},
timeout_timestamp: this.data.timeoutTimestamp.toString(),
memo: this.data.memo,
},
};
}
}

View File

@ -0,0 +1,41 @@
import { PlainMessage } from "@bufbuild/protobuf";
import { utf8 } from "@onsonr/es/codec";
import { CosmwasmWasmV1MsgInstantiateContract as ProtoMsgInstantiateContract } from "@onsonr/es/protobufs";
import { DeepPrettify, Prettify } from "../../typeutils/prettify";
import { Adapter } from "./Adapter";
type Data<T> = Prettify<
DeepPrettify<Omit<PlainMessage<ProtoMsgInstantiateContract>, "msg">> & {
msg: T;
}
>;
export class MsgInstantiateContract<T> implements Adapter {
private readonly data: Data<T>;
constructor(data: Data<T>) {
this.data = data;
}
public toProto() {
return new ProtoMsgInstantiateContract({
...this.data,
msg: utf8.decode(JSON.stringify(this.data.msg)),
});
}
public toAmino() {
return {
type: "wasm/MsgInstantiateContract",
value: {
sender: this.data.sender,
admin: this.data.admin,
code_id: this.data.codeId.toString(),
label: this.data.label,
msg: this.data.msg,
funds: this.data.funds,
},
};
}
}

View File

@ -0,0 +1,39 @@
import { PlainMessage } from "@bufbuild/protobuf";
import { utf8 } from "@onsonr/es/codec";
import { CosmwasmWasmV1MsgMigrateContract as ProtoMsgMigrateContract } from "@onsonr/es/protobufs";
import { DeepPrettify, Prettify } from "../../typeutils/prettify";
import { Adapter } from "./Adapter";
type Data<T> = Prettify<
DeepPrettify<Omit<PlainMessage<ProtoMsgMigrateContract>, "msg">> & {
msg: T;
}
>;
export class MsgMigrateContract<T> implements Adapter {
private readonly data: Data<T>;
constructor(data: Data<T>) {
this.data = data;
}
public toProto() {
return new ProtoMsgMigrateContract({
...this.data,
msg: utf8.decode(JSON.stringify(this.data.msg)),
});
}
public toAmino() {
return {
type: "wasm/MsgMigrateContract",
value: {
sender: this.data.sender,
code_id: this.data.codeId,
contract: this.data.contract,
msg: this.data.msg,
}
};
}
}

View File

@ -0,0 +1,32 @@
import { PlainMessage } from "@bufbuild/protobuf";
import { CosmosBankV1beta1MsgSend as ProtoMsgSend } from "@onsonr/es/protobufs";
import { DeepPrettify } from "../../typeutils/prettify";
import { Adapter } from "./Adapter";
type Data = DeepPrettify<PlainMessage<ProtoMsgSend>>;
export class MsgSend implements Adapter {
private readonly data: Data;
private readonly legacy: boolean;
constructor(data: Data, legacy = false) {
this.data = data;
this.legacy = legacy;
}
public toProto() {
return new ProtoMsgSend(this.data);
}
public toAmino() {
return {
type: this.legacy ? "bank/MsgSend" : "cosmos-sdk/MsgSend",
value: {
from_address: this.data.fromAddress,
to_address: this.data.toAddress,
amount: this.data.amount,
},
};
}
}

View File

@ -0,0 +1,33 @@
import { PlainMessage } from "@bufbuild/protobuf";
import { base64 } from "@onsonr/es/codec";
import { CosmwasmWasmV1MsgStoreCode as ProtoMsgStoreCode } from "@onsonr/es/protobufs";
import { DeepPrettify } from "../../typeutils/prettify";
import { Adapter } from "./Adapter";
type Data = DeepPrettify<PlainMessage<ProtoMsgStoreCode>>;
export class MsgStoreCode implements Adapter {
private readonly data: Data;
constructor(data: Data) {
this.data = data;
}
public toProto() {
return new ProtoMsgStoreCode({
...this.data,
});
}
public toAmino() {
return {
type: "wasm/MsgStoreCode",
value: {
sender: this.data.sender,
wasm_byte_code: base64.encode(this.data.wasmByteCode),
instantiate_permission: this.data.instantiatePermission,
}
};
}
}

View File

@ -0,0 +1,30 @@
import { PlainMessage } from "@bufbuild/protobuf";
import { CosmosStakingV1beta1MsgUndelegate as ProtoMsgUndelegate } from "@onsonr/es/protobufs";
import { DeepPrettify } from "../../typeutils/prettify";
import { Adapter } from "./Adapter";
type Data = DeepPrettify<PlainMessage<ProtoMsgUndelegate>>;
export class MsgUndelegate implements Adapter {
private readonly data: Data;
constructor(data: Data) {
this.data = data;
}
public toProto() {
return new ProtoMsgUndelegate(this.data);
}
public toAmino() {
return {
type: "cosmos-sdk/MsgUndelegate",
value: {
delegator_address: this.data.delegatorAddress,
validator_address: this.data.validatorAddress,
amount: this.data.amount,
},
};
}
}

View File

@ -0,0 +1,33 @@
import { PlainMessage } from "@bufbuild/protobuf";
import { CosmosDistributionV1beta1MsgWithdrawDelegatorReward as ProtoMsgWithdrawDelegatorRewards } from "@onsonr/es/protobufs";
import { DeepPrettify } from "../../typeutils/prettify";
import { Adapter } from "./Adapter";
type Data = DeepPrettify<PlainMessage<ProtoMsgWithdrawDelegatorRewards>>;
export class MsgWithdrawDelegatorRewards implements Adapter {
private readonly data: Data;
private readonly isLegacy: boolean;
constructor(data: Data, isLegacy = false) {
this.data = data;
this.isLegacy = isLegacy;
}
public toProto() {
return new ProtoMsgWithdrawDelegatorRewards(this.data);
}
public toAmino() {
return {
type: this.isLegacy
? "distribution/MsgWithdrawDelegationReward"
: "cosmos-sdk/MsgWithdrawDelegationReward",
value: {
validator_address: this.data.validatorAddress,
delegator_address: this.data.delegatorAddress,
},
};
}
}

View File

@ -0,0 +1,28 @@
import { PlainMessage } from "@bufbuild/protobuf";
import { CosmosDistributionV1beta1MsgWithdrawValidatorCommission as ProtoMsgWithdrawValidatorCommission } from "@onsonr/es/protobufs";
import { DeepPrettify } from "../../typeutils/prettify";
import { Adapter } from "./Adapter";
type Data = DeepPrettify<PlainMessage<ProtoMsgWithdrawValidatorCommission>>;
export class MsgWithdrawValidatorCommission implements Adapter {
private readonly data: Data;
constructor(data: Data) {
this.data = data;
}
public toProto() {
return new ProtoMsgWithdrawValidatorCommission(this.data);
}
public toAmino() {
return {
type: "cosmos-sdk/MsgWithdrawValidatorCommission",
value: {
validator_address: this.data.validatorAddress,
},
};
}
}

View File

@ -0,0 +1,41 @@
import { PlainMessage } from "@bufbuild/protobuf";
import { base64 } from "@onsonr/es/codec";
import {
EthermintCryptoV1Ethsecp256k1PubKey as ProtoEthermintSecp256k1PubKey,
CosmosCryptoSecp256k1PubKey as ProtoSecp256k1PubKey,
} from "@onsonr/es/protobufs";
import { DeepPrettify } from "../../typeutils/prettify";
import { Adapter } from "./Adapter";
type Data = DeepPrettify<
{
chainId?: string | undefined;
} & PlainMessage<ProtoSecp256k1PubKey>
>;
export class Secp256k1PubKey implements Adapter {
private readonly data: Data;
private readonly type: string;
constructor(data: Data) {
this.data = data;
this.type = data.chainId?.split(/[-_]/, 2).at(0) ?? "";
}
public toProto() {
return this.type === "dymension" || this.type === "evmos"
? new ProtoEthermintSecp256k1PubKey(this.data)
: new ProtoSecp256k1PubKey(this.data);
}
// TODO: needs to be updated to include injective/dymension support
public toAmino() {
return {
type: "tendermint/PubKeySecp256k1",
value: {
key: base64.encode(this.data.key),
},
};
}
}

View File

@ -0,0 +1,214 @@
import { Message, PlainMessage } from "@bufbuild/protobuf";
import { base64 } from "@scure/base";
import {
CosmosTxV1beta1AuthInfo as ProtoAuthInfo,
CosmosTxV1beta1Fee as ProtoFee,
CosmosTxV1beta1SignDoc as ProtoSignDoc,
CosmosTxSigningV1beta1SignMode as ProtoSignMode,
CosmosTxV1beta1SignerInfo as ProtoSignerInfo,
CosmosTxV1beta1TxBody as ProtoTxBody,
CosmosTxV1beta1TxRaw as ProtoTxRaw,
} from "@onsonr/es/protobufs";
import { SignDoc, StdSignDoc } from "@onsonr/es/registry";
import { toAny } from "../utils/toAny";
import { Adapter } from "./Adapter";
import { Secp256k1PubKey } from "./Secp256k1PubKey";
type Data = {
chainId: string;
pubKey: Secp256k1PubKey;
msgs: Adapter[];
};
export type ToSignedProtoParams = {
sequence: bigint;
fee: ProtoFee;
signMode: ProtoSignMode;
signature: Uint8Array;
memo?: string | undefined;
timeoutHeight?: bigint | undefined;
extensionOptions?: Message[] | undefined;
};
export type ToUnsignedProtoParams = Pick<
ToSignedProtoParams,
"sequence" | "memo" | "timeoutHeight"
>;
export type ToSignDocParams = {
accountNumber: bigint;
sequence: bigint;
fee: ProtoFee;
memo?: string | undefined;
timeoutHeight?: bigint | undefined;
};
export type ToStdSignDocParams = ToSignDocParams;
export class Tx {
private readonly data: Data;
constructor(data: Data) {
this.data = data;
}
/**
* Returns the signed, proto-encoded tx, ready to be broadcasted. To create an
* unsigned tx for the purpose of simulating it, use {@link toUnsignedProto}.
*/
public toSignedProto({
fee,
sequence,
signMode,
signature,
memo,
timeoutHeight,
extensionOptions,
}: ToSignedProtoParams): ProtoTxRaw {
return new ProtoTxRaw({
authInfoBytes: new ProtoAuthInfo({
fee: fee,
signerInfos: [this.getSignerInfo(sequence, signMode)],
}).toBinary(),
bodyBytes: new ProtoTxBody({
messages: this.data.msgs.map((m) => toAny(m.toProto())),
memo: memo,
timeoutHeight: timeoutHeight,
extensionOptions: extensionOptions?.map(toAny),
}).toBinary(),
signatures: [signature],
});
}
/**
* Returns the proto-encoded tx with the sign mode set to `UNSPECIFIED`, useful
* for simulating the tx. To create a signed tx, use {@link toSignedProto}.
*/
public toUnsignedProto(info: ToUnsignedProtoParams): ProtoTxRaw {
return this.toSignedProto({
...info,
fee: new ProtoFee(),
signMode: ProtoSignMode.UNSPECIFIED,
signature: new Uint8Array(),
});
}
/**
* Combines the given `StdSignDoc` and `signature` and returns the proto-encoded
* tx with sign mode set to `LEGACY_AMINO_JSON`, ready to be broadcasted.
*
* @param signature Must be a base64 encoded string or an `Uint8Array`
*/
public toSignedAmino(
{ sequence, fee, memo, timeout_height }: StdSignDoc,
signature: string | Uint8Array
): ProtoTxRaw {
return this.toSignedProto({
sequence: BigInt(sequence),
fee: new ProtoFee({
amount: fee.amount.slice(),
gasLimit: BigInt(fee.gas),
payer: fee.payer,
granter: fee.granter,
}),
signMode: ProtoSignMode.LEGACY_AMINO_JSON,
signature:
typeof signature === "string" ? base64.decode(signature) : signature,
memo: memo,
timeoutHeight: timeout_height ? BigInt(timeout_height) : undefined,
});
}
/**
* Combines the given `SignDoc` and `signature` and returns the proto-encoded tx,
* ready to be broadcasted.
*
* @param signature Must be a base64 encoded string or an `Uint8Array`
*/
public toSignedDirect(
{ bodyBytes, authInfoBytes }: SignDoc,
signature: string | Uint8Array
): ProtoTxRaw {
return new ProtoTxRaw({
authInfoBytes,
bodyBytes,
signatures: [
typeof signature === "string" ? base64.decode(signature) : signature,
],
});
}
/**
* Returns the unsigned, proto-encoded tx ready to be signed by a wallet.
*/
public toSignDoc({
accountNumber,
sequence,
fee,
memo,
timeoutHeight,
}: ToSignDocParams): ProtoSignDoc {
return new ProtoSignDoc({
chainId: this.data.chainId,
accountNumber: accountNumber,
authInfoBytes: new ProtoAuthInfo({
fee: fee,
signerInfos: [this.getSignerInfo(sequence, ProtoSignMode.DIRECT)],
}).toBinary(),
bodyBytes: new ProtoTxBody({
messages: this.data.msgs.map((m) => toAny(m.toProto())),
memo: memo,
timeoutHeight: timeoutHeight,
}).toBinary(),
});
}
/**
* Returns the unsigned, amino-encoded tx ready to be signed by a wallet.
*/
public toStdSignDoc({
accountNumber,
sequence,
fee,
memo,
timeoutHeight,
}: ToStdSignDocParams): StdSignDoc {
return {
chain_id: this.data.chainId,
account_number: accountNumber.toString(),
sequence: sequence.toString(),
fee: {
amount: fee.amount,
gas: fee.gasLimit.toString(),
},
msgs: this.data.msgs.map((m) => m.toAmino()),
memo: memo ?? "",
timeout_height: timeoutHeight?.toString(),
};
}
/**
* Returns the signer info. The chain ID is used to determine if the public key
* should be encoded using Injective's custom protobuf.
*
* **Warning**: Injective's chain ID might change, causing potential issues here.
*/
private getSignerInfo(
sequence: bigint,
mode: ProtoSignMode
): PlainMessage<ProtoSignerInfo> {
return {
publicKey: toAny(this.data.pubKey.toProto()),
sequence: sequence,
modeInfo: {
sum: {
case: "single",
value: {
mode: mode,
},
},
},
};
}
}

View File

@ -0,0 +1,26 @@
import {
CosmosBaseV1beta1Coin as Coin,
CosmosTxV1beta1Fee as Fee,
CosmosBaseAbciV1beta1GasInfo as GasInfo,
} from "@onsonr/es/protobufs";
/**
* Estimates the fee for a transaction. For txs which uses more gas, the
* `multiplier` can be decreased (default: `1.4`).
*/
export function calculateFee(
{ gasUsed }: GasInfo,
{ amount, denom }: Coin,
multiplier = 1.4
): Fee {
const gasLimit = Number(gasUsed) * multiplier;
return new Fee({
amount: [
{
amount: Math.ceil(gasLimit * Number(amount)).toFixed(0),
denom: denom,
},
],
gasLimit: BigInt(Math.floor(gasLimit)),
});
}

View File

@ -0,0 +1,8 @@
import { Any, Message } from "@bufbuild/protobuf";
export function toAny(msg: Message): Any {
return new Any({
typeUrl: `/${msg.getType().typeName}`,
value: msg.toBinary(),
});
}

View File

@ -0,0 +1,63 @@
import { Any } from "@bufbuild/protobuf";
import {
CosmosAuthV1beta1BaseAccount as BaseAccount,
CosmosVestingV1beta1BaseVestingAccount as BaseVestingAccount,
CosmosVestingV1beta1ContinuousVestingAccount as ContinuousVestingAccount,
CosmosVestingV1beta1DelayedVestingAccount as DelayedVesting,
EthermintTypesV1EthAccount as EthermintAccount,
CosmosVestingV1beta1PeriodicVestingAccount as PeriodicVestingAccount,
} from "@onsonr/es/protobufs";
const ERR_UNKNOWN_ACCOUNT_TYPE = "Unknown account type";
const ERR_UNABLE_TO_RESOLVE_BASE_ACCOUNT = "Unable to resolve base account";
// TODO: add more account types
/**
* Parses an `Any` protobuf message and returns the `BaseAccount`. Throws if unable
* to parse correctly.
*/
export function toBaseAccount({ typeUrl, value }: Any): BaseAccount {
switch (typeUrl.slice(1)) {
case BaseAccount.typeName: {
return BaseAccount.fromBinary(value);
}
case BaseVestingAccount.typeName: {
const { baseAccount } = BaseVestingAccount.fromBinary(value);
if (!baseAccount) {
throw new Error(ERR_UNABLE_TO_RESOLVE_BASE_ACCOUNT);
}
return baseAccount;
}
case ContinuousVestingAccount.typeName: {
const { baseVestingAccount } = ContinuousVestingAccount.fromBinary(value);
if (!baseVestingAccount?.baseAccount) {
throw new Error(ERR_UNABLE_TO_RESOLVE_BASE_ACCOUNT);
}
return baseVestingAccount.baseAccount;
}
case DelayedVesting.typeName: {
const { baseVestingAccount } = DelayedVesting.fromBinary(value);
if (!baseVestingAccount?.baseAccount) {
throw new Error(ERR_UNABLE_TO_RESOLVE_BASE_ACCOUNT);
}
return baseVestingAccount.baseAccount;
}
case PeriodicVestingAccount.typeName: {
const { baseVestingAccount } = PeriodicVestingAccount.fromBinary(value);
if (!baseVestingAccount?.baseAccount) {
throw new Error(ERR_UNABLE_TO_RESOLVE_BASE_ACCOUNT);
}
return baseVestingAccount.baseAccount;
}
case EthermintAccount.typeName: {
const { baseAccount } = EthermintAccount.fromBinary(value);
if (!baseAccount) {
throw new Error(ERR_UNABLE_TO_RESOLVE_BASE_ACCOUNT);
}
return baseAccount;
}
default: {
throw new Error(`${ERR_UNKNOWN_ACCOUNT_TYPE}: ${typeUrl.slice(1)}`);
}
}
}

View File

@ -0,0 +1,6 @@
/**
* Synchronously waits for the given number of `milliseconds`.
*/
export async function wait(milliseconds: number) {
return new Promise((resolve) => setTimeout(resolve, milliseconds));
}

View File

@ -0,0 +1,45 @@
import { describe, expect, it } from "vitest";
import { resolveBech32Address, translateEthToBech32Address } from "./address";
const PUB_KEY_1 = "A6Y9fcWSn5Av/HLHBwthTaVE/vdyRKvsTzi5U7j9bFj5"; // random pub key
const PUB_KEY_2 = "Ag/a1BOl3cdwh67Z8iCbGmAu4WWmBwtuQlQMbDaN385V"; // coinhall.org val pubkey
const PUB_KEY_3 = "AmGjuPKUsuIAuGgJ3xH7KGWlSU9cwVnsesrwWwyYLbMg"; // random pub key
const ETH_ADDRESS_1 = "0xd6E80d86483C0cF463E03cC95246bDc0FeF6cfbD"; // random eth address
describe("resolveBech32Address", () => {
it("should resolve stars address correctly", () => {
const translated = resolveBech32Address(PUB_KEY_1, "stars");
expect(translated).toBe("stars14y420auq56p6xgt78sl8vwz3jxy77r9cuw900r");
});
it("should resolve cosmos address correctly", () => {
const translated = resolveBech32Address(PUB_KEY_1, "cosmos");
expect(translated).toBe("cosmos14y420auq56p6xgt78sl8vwz3jxy77r9cgjjjyj");
});
it("should resolve terra address correctly", () => {
const translated = resolveBech32Address(PUB_KEY_2, "terra");
expect(translated).toBe("terra1ge3vqn6cjkk2xkfwpg5ussjwxvahs2f6aytr5j");
});
it("should resolve terravaloper address correctly", () => {
const translated = resolveBech32Address(PUB_KEY_2, "terravaloper");
expect(translated).toBe(
"terravaloper1ge3vqn6cjkk2xkfwpg5ussjwxvahs2f6at87yp"
);
});
it("should resolve ethsecp256k1 type address correctly", () => {
const translated = resolveBech32Address(PUB_KEY_3, "inj", "ethsecp256k1");
expect(translated).toBe("inj1ys3hr2a6sn3wwqsmmrk8pgrvk58e8wrn6zn44m");
});
});
describe("translateEthToBech32Address", () => {
it("should translate eth address correctly", () => {
const translated = translateEthToBech32Address(ETH_ADDRESS_1, "inj");
expect(translated).toBe("inj16m5qmpjg8sx0gclq8ny4y34acrl0dnaantdev0");
});
});

View File

@ -0,0 +1,46 @@
import { ripemd160 } from "@noble/hashes/ripemd160";
import { sha256 } from "@noble/hashes/sha256";
import { keccak_256 } from "@noble/hashes/sha3";
import { ProjectivePoint } from "@noble/secp256k1";
import { base64, bech32 } from "@scure/base";
import { ethhex } from "./ethhex";
/**
* Returns the bech32 address from the given `publicKey` and `prefix`. If needed,
* the `type` of the key should be appropriately set.
*
* @param publicKey Must be either a base64 encoded string or a `Uint8Array`.
*/
export function resolveBech32Address(
publicKey: string | Uint8Array,
prefix: string,
type: "secp256k1" | "ed25519" | "ethsecp256k1" = "secp256k1"
): string {
const pubKey =
typeof publicKey === "string" ? base64.decode(publicKey) : publicKey;
const address =
type === "secp256k1"
? // For cosmos: take the ripemd160 of the sha256 of the public key
ripemd160(sha256(pubKey))
: type === "ed25519"
? // For cosmos: take the first 20 bytes of the sha256 of the public key
sha256(pubKey).slice(0, 20)
: // For eth: take the last 20 bytes of the keccak of the uncompressed public key without the first byte
keccak_256(
ProjectivePoint.fromHex(pubKey).toRawBytes(false).slice(1)
).slice(-20);
return bech32.encode(prefix, bech32.toWords(address));
}
/**
* Translates the given ethereum address to a bech32 address.
* @param ethAddress Must be a valid ethereum address (eg. `0x123...DeF`).
*/
export function translateEthToBech32Address(
ethAddress: string,
prefix: string
) {
const bytes = ethhex.decode(ethAddress);
return bech32.encode(prefix, bech32.toWords(bytes));
}

View File

@ -0,0 +1,13 @@
import { BytesCoder, hex } from "@scure/base";
/**
* Convenience wrapper around `hex` that deals with hex strings typically
* seen in Ethereum, where strings start with `0x` and are lower case.
*
* - For `encode`, the resulting string will be lower case
* - For `decode`, the `str` arg can either be lower or upper case
*/
export const ethhex = {
encode: (bytes) => "0x" + hex.encode(bytes),
decode: (str) => hex.decode(str.replace(/^0x/, "").toLowerCase()),
} satisfies BytesCoder;

View File

@ -0,0 +1,14 @@
// Re-export @scure/base for their codecs
export * from "@scure/base";
export { resolveBech32Address, translateEthToBech32Address } from "./address";
export { ethhex } from "./ethhex";
export { resolveKeyPair } from "./key";
export { serialiseSignDoc } from "./serialise";
export {
hashEthArbitraryMessage,
recoverPubKeyFromEthSignature,
signAmino,
signDirect,
} from "./sign";
export { verifyADR36, verifyECDSA, verifyEIP191 } from "./verify";

View File

@ -0,0 +1,44 @@
import { base64 } from "@scure/base";
import { describe, expect, it } from "vitest";
import { resolveKeyPair } from "./key";
// Randomly generated seed phrase
const SEED_PHRASE_1 =
"witness snack faint milk gesture memory exhibit oak require mountain hammer crawl innocent day library drum youth result mutual remove capable hour front connect";
describe("resolveKeyPair", () => {
it("should resolve 118 coin type correctly", () => {
const { publicKey, privateKey } = resolveKeyPair(SEED_PHRASE_1);
expect(base64.encode(publicKey)).toBe(
"AijdjMWZdjiXxSj0YCNbJHgnW6EsYwNyB9Yf7Wg5PcmE"
);
expect(base64.encode(privateKey)).toBe(
"SojKJzJhFNruMSceBq3Imw3qZ+kS4p/6+iEpxdPsNg0="
);
});
it("should resolve 330 coin type correctly", () => {
const { publicKey, privateKey } = resolveKeyPair(SEED_PHRASE_1, {
coinType: 330,
});
expect(base64.encode(publicKey)).toBe(
"A5G4nX2MIYCsnEdm40NJx7Bb1Z+oUNbEWWcVMssrgI3n"
);
expect(base64.encode(privateKey)).toBe(
"kpvZKN+f7oWhVLLLk1pmKOazycgfECinugqQZgKRlXg="
);
});
it("should resolve provided index correctly", () => {
const { publicKey, privateKey } = resolveKeyPair(SEED_PHRASE_1, {
index: 69,
});
expect(base64.encode(publicKey)).toBe(
"ArHwuHKnyiuPDbprTpWLVl3ZuomV70yzquzzlunGXlmj"
);
expect(base64.encode(privateKey)).toBe(
"Fdm+CxL/KnM35bjDx/wg3eZc3tZN2q83I+xcY2wSMwk="
);
});
});

View File

@ -0,0 +1,29 @@
import { HDKey } from "@scure/bip32";
import { mnemonicToSeedSync } from "@scure/bip39";
/**
* Resolves the given `mnemonic` (aka 12-24 words seed phrase) to its public and
* private key pair. Derivation path uses the default for Cosmos chains - provide
* the optional `opts` to override.
*/
export function resolveKeyPair(
mnemonic: string,
opts?:
| { coinType?: number | undefined; index?: number | undefined }
| undefined
): {
publicKey: Uint8Array;
privateKey: Uint8Array;
} {
const seed = mnemonicToSeedSync(mnemonic);
const { publicKey, privateKey } = HDKey.fromMasterSeed(seed).derive(
`m/44'/${opts?.coinType ?? 118}'/0'/0/${opts?.index ?? 0}`
);
if (!publicKey || !privateKey) {
throw new Error("invalid mnemonic");
}
return {
publicKey,
privateKey,
};
}

View File

@ -0,0 +1,38 @@
import { describe, expect, it } from "vitest";
import { sortObjectByKey } from "./serialise";
describe("sortObjectByKey", () => {
it("should sort keys correctly", () => {
const obj = {
zzz: 1,
aaa: 1,
xxx: null,
bbb: {
ttt: {
ppp: true,
iii: undefined,
lll: "1",
},
ddd: [4, 8, 3, undefined, 4, 5, 7, 8],
},
};
const expected = {
aaa: 1,
bbb: {
ddd: [4, 8, 3, undefined, 4, 5, 7, 8], // arrays are not sorted
ttt: {
iii: undefined,
lll: "1",
ppp: true,
},
},
xxx: null,
zzz: 1,
};
// Before sorting, the stringified versions of the objects should NOT be equal
expect(JSON.stringify(obj)).not.toBe(JSON.stringify(expected));
// After sorting, the stringified versions of the objects should be equal
expect(JSON.stringify(sortObjectByKey(obj))).toBe(JSON.stringify(expected));
});
});

View File

@ -0,0 +1,38 @@
import { utf8 } from "@scure/base";
import { StdSignDoc } from "@onsonr/es/registry";
/**
* Escapes <,>,& in string.
* Golang's json marshaller escapes <,>,& by default.
* However, because JS doesn't do that by default, to match the sign doc with cosmos-sdk,
* we should escape <,>,& in string manually.
* @param str
*/
function escapeHtml(str: string): string {
return str
.replace(/</g, "\\u003c")
.replace(/>/g, "\\u003e")
.replace(/&/g, "\\u0026");
}
export function sortObjectByKey<T>(obj: T): T {
if (typeof obj !== "object" || obj == null) {
return obj;
}
if (Array.isArray(obj)) {
return obj.map(sortObjectByKey) as T;
}
const sortedKeys = Object.keys(obj).sort();
const result: Record<string, unknown> = {};
sortedKeys.forEach((key) => {
result[key] = sortObjectByKey((obj as Record<string, unknown>)[key]);
});
return result as T;
}
/**
* Serialises the given sign doc to a `Uint8Array` in a deterministic manner.
*/
export function serialiseSignDoc(doc: StdSignDoc): Uint8Array {
return utf8.decode(escapeHtml(JSON.stringify(sortObjectByKey(doc))));
}

View File

@ -0,0 +1,72 @@
import { StdSignDoc } from "@keplr-wallet/types";
import { base16, base64, utf8 } from "@scure/base";
import { describe, expect, it } from "vitest";
import { ethhex } from "./ethhex";
import {
hashEthArbitraryMessage,
recoverPubKeyFromEthSignature,
signAmino,
} from "./sign";
describe("signAmino", () => {
it("should sign Injective txs correctly", () => {
const stdSignDoc: StdSignDoc = {
chain_id: "",
account_number: "0",
sequence: "0",
fee: {
gas: "0",
amount: [],
},
msgs: [
{
type: "sign/MsgSignData",
value: {
signer: "inj1l8w4vvmhcku28ryntpeazm37umshetzzl2gc33",
data: base64.encode(
utf8.decode(
"Hi from CosmeES! This is a test message just to prove that the wallet is working."
)
),
},
},
],
memo: "",
};
const privKey = base64.decode(
"o5di+2p2NdLgRYLtBIhJl9gsB9FWll8wKBaep3CmbI0="
);
const expected = // Signature taken from keplr signArbitrary
"qrkZpuo1jpfXgbF3TtBtdR7DynE1nV3xd//bsGXm2FkS08waXeiJJ+FAvdtt9hvStyP/wGae07hxnyYPHEw+Uw==";
const actual = base64.encode(
signAmino(stdSignDoc, privKey, "ethsecp256k1")
);
expect(actual).toStrictEqual(expected);
});
});
describe("hashEthArbitraryMessage", () => {
it("should hash correctly", () => {
const msg = utf8.decode("Hello World!");
const expected = hashEthArbitraryMessage(msg);
const actual = ethhex.decode(
"0xec3608877ecbf8084c29896b7eab2a368b2b3c8d003288584d145613dfa4706c"
);
expect(actual).toStrictEqual(expected);
});
});
describe("recoverPubKeyFromEthSignature", () => {
it("should recover public key correctly from a personal_sign signature", () => {
const message = utf8.decode("Hello World");
const signature = ethhex.decode(
"0x63da4222cbcc36f43b22cbe417aa78963c29d088f7db3c9c6d06417dc34cf2df2dc6ffe9a5c9072a12a16a71c93bebf42bf388357aff81190d7dce166e4fa7ad1c"
);
const expected = base16.decode(
"03f73842e6959e5b79f7979f81016e1e4f4d9481a7351a492ddb0807d98bb31f19".toUpperCase()
);
const actual = recoverPubKeyFromEthSignature(message, signature);
expect(expected).toStrictEqual(actual);
});
});

View File

@ -0,0 +1,84 @@
import { hmac } from "@noble/hashes/hmac";
import { sha256 } from "@noble/hashes/sha256";
import { keccak_256 } from "@noble/hashes/sha3";
import * as secp256k1 from "@noble/secp256k1";
import { utf8 } from "@scure/base";
import { CosmosTxV1beta1SignDoc as SignDoc } from "@onsonr/es/protobufs";
import { StdSignDoc } from "@onsonr/es/registry";
import { serialiseSignDoc } from "./serialise";
function sign(
bytes: Uint8Array,
privateKey: Uint8Array,
type: "secp256k1" | "ethsecp256k1"
): Uint8Array {
// Required polyfills for secp256k1 that must be called before any sign ops.
// See: https://github.com/paulmillr/noble-secp256k1?tab=readme-ov-file#usage
secp256k1.etc.hmacSha256Sync = (k, ...m) =>
hmac(sha256, k, secp256k1.etc.concatBytes(...m));
const hash = type === "secp256k1" ? sha256(bytes) : keccak_256(bytes);
return secp256k1.sign(hash, privateKey).toCompactRawBytes();
}
/**
* Signs the given amino-encoded `stdSignDoc` with the given `privateKey` using
* secp256k1, and returns the signature bytes. For Injective, the `type` param
* must be set to `ethsecp256k1`.
*/
export function signAmino(
stdSignDoc: StdSignDoc,
privateKey: Uint8Array,
type: "secp256k1" | "ethsecp256k1" = "secp256k1"
): Uint8Array {
return sign(serialiseSignDoc(stdSignDoc), privateKey, type);
}
/**
* Signs the given proto-encoded `signDoc` with the given `privateKey` using
* secp256k1, and returns the signature bytes. For Injective, the `type` param
* must be set to `ethsecp256k1`.
*/
export function signDirect(
signDoc: SignDoc,
privateKey: Uint8Array,
type: "secp256k1" | "ethsecp256k1" = "secp256k1"
): Uint8Array {
return sign(signDoc.toBinary(), privateKey, type);
}
/**
* Hashes and returns the digest of the given EIP191 `message` bytes.
*/
export function hashEthArbitraryMessage(message: Uint8Array): Uint8Array {
return keccak_256(
Uint8Array.from([
...utf8.decode("\x19Ethereum Signed Message:\n"),
...utf8.decode(message.length.toString()),
...message,
])
);
}
/**
* Recovers and returns the secp256k1 public key of the signer given the arbitrary
* `message` and `signature` that was signed using EIP191.
*/
export function recoverPubKeyFromEthSignature(
message: Uint8Array,
signature: Uint8Array
): Uint8Array {
if (signature.length !== 65) {
throw new Error("Invalid signature");
}
const r = signature.slice(0, 32);
const s = signature.slice(32, 64);
const v = signature[64];
// Adapted from https://github.com/ethers-io/ethers.js/blob/6017d3d39a4d428793bddae33d82fd814cacd878/src.ts/crypto/signature.ts#L255-L265
const yParity = v <= 1 ? v : (v + 1) % 2;
const secpSignature = secp256k1.Signature.fromCompact(
Uint8Array.from([...r, ...s])
).addRecoveryBit(yParity);
const digest = hashEthArbitraryMessage(message);
return secpSignature.recoverPublicKey(digest).toRawBytes(true);
}

View File

@ -0,0 +1,115 @@
import { base64, utf8 } from "@scure/base";
import { describe, expect, it } from "vitest";
import { verifyADR36, verifyECDSA, verifyEIP191 } from "./verify";
const DATA = utf8.decode(
"Hi from CosmeES! This is a test message just to prove that the wallet is working."
);
// Generated using coin type "330" and seed phrase "poverty flat amazing draw goose clay sorry nothing erase switch law intact only invest find memory what weasel fan connect tilt detect trap viable"
const VALID_PUBKEY_1 = base64.decode(
"Ai7ZXTtRWFte/tX7Z6MlKWVd9XA49p3cDNqd61RuKTdT"
);
// Generated using coin type "118" and seed phrase "poverty flat amazing draw goose clay sorry nothing erase switch law intact only invest find memory what weasel fan connect tilt detect trap viable"
const VALID_PUBKEY_2 = base64.decode(
"A8i9vMNUGcTtUgpbmiZqcFtsIrPZ6n8ZYN4/PVRlQvGr"
);
// Generated using coin type "60" and seed phrase "poverty flat amazing draw goose clay sorry nothing erase switch law intact only invest find memory what weasel fan connect tilt detect trap viable"
const VALID_PUBKEY_3 = base64.decode(
"AmGjuPKUsuIAuGgJ3xH7KGWlSU9cwVnsesrwWwyYLbMg"
);
describe("verifyECDSA", () => {
it("should verify correctly", () => {
// Signed using Station wallet on Terra
const signature = base64.decode(
"Od87qNoOyXuDOVdLCGTXB6dFN7U0XF9Oegc8KDa+AWwX3jkrDXG++2nlPfsF4VJzlDHsoikPeZpxrB7v9PINnw=="
);
const res1 = verifyECDSA({
pubKey: VALID_PUBKEY_1,
data: DATA,
signature,
});
expect(res1).toBe(true);
// Different pub key
const res2 = verifyECDSA({
pubKey: VALID_PUBKEY_2,
data: DATA,
signature,
});
expect(res2).toBe(false);
});
});
describe("verifyADR36", () => {
it("should verify correctly", () => {
// Signed using Keplr wallet on Osmosis
const signature = base64.decode(
"nvlcV0x0Ge8ADXLSAQGtfMw6EJkOfpmkDxgP7UI79uR8MhnAOp9T+e+ofgW9kY4bEIr0yhyBG+vSVAZRv9uCxA=="
);
const res1 = verifyADR36({
bech32Prefix: "osmo",
pubKey: VALID_PUBKEY_2,
data: DATA,
signature,
});
expect(res1).toBe(true);
// Different bech32 prefix
const res2 = verifyADR36({
bech32Prefix: "terra",
pubKey: VALID_PUBKEY_2,
data: DATA,
signature,
});
expect(res2).toBe(false);
// Different pub key
const res3 = verifyADR36({
bech32Prefix: "osmo",
pubKey: VALID_PUBKEY_1,
data: DATA,
signature,
});
expect(res3).toBe(false);
});
it("should verify ethsecp256k1 type signatures correctly", () => {
// Signed using Keplr wallet on Injective
const signature = base64.decode(
"+7PNZm4XxKtpvZA+HqxpMKJgZcqA2w3WVSheLGvzrrIBJZGOTdcpBT7wLUhluY46EokTeRRWUaBDSv2vVoEdfw=="
);
const res1 = verifyADR36({
bech32Prefix: "inj",
pubKey: VALID_PUBKEY_3,
data: DATA,
signature,
type: "ethsecp256k1",
});
expect(res1).toBe(true);
});
});
describe("verifyEIP191", () => {
it("should verify correctly", () => {
// Signed using MetaMask wallet on Injective
const signature = base64.decode(
"MpriWY0Kq7C+/jR3eOfNB5vUQM144tQk7KkzKyYCTFB5QHGLZjzJyeOSr8/ENFES0k+aaEF47Wepk7OHoZuLzxs="
);
const res1 = verifyEIP191({
pubKey: VALID_PUBKEY_3,
data: DATA,
signature,
});
expect(res1).toBe(true);
// Different pub key
const res2 = verifyEIP191({
pubKey: VALID_PUBKEY_2,
data: DATA,
signature,
});
expect(res2).toBe(false);
});
});

View File

@ -0,0 +1,80 @@
import { sha256 } from "@noble/hashes/sha256";
import { keccak_256 } from "@noble/hashes/sha3";
import * as secp256k1 from "@noble/secp256k1";
import { base64 } from "@scure/base";
import { resolveBech32Address } from "./address";
import { serialiseSignDoc } from "./serialise";
import { recoverPubKeyFromEthSignature } from "./sign";
type VerifyArbitraryParams = {
/** The public key which created the signature */
pubKey: Uint8Array;
/** The bech32 account address prefix of the signer */
bech32Prefix: string;
/** The arbitrary bytes that was signed */
data: Uint8Array;
/** The signature bytes */
signature: Uint8Array;
/** The type of the signature */
type?: "secp256k1" | "ethsecp256k1";
};
export function verifyECDSA({
pubKey,
data,
signature,
type,
}: Omit<VerifyArbitraryParams, "bech32Prefix">): boolean {
return secp256k1.verify(
signature,
type === "ethsecp256k1" ? keccak_256(data) : sha256(data),
pubKey
);
}
export function verifyADR36({
pubKey,
bech32Prefix,
data,
signature,
type,
}: VerifyArbitraryParams): boolean {
const msg = serialiseSignDoc({
chain_id: "",
account_number: "0",
sequence: "0",
fee: {
gas: "0",
amount: [],
},
msgs: [
{
type: "sign/MsgSignData",
value: {
signer: resolveBech32Address(pubKey, bech32Prefix, type),
data: base64.encode(data),
},
},
],
memo: "",
});
return verifyECDSA({
pubKey,
data: msg,
signature,
type,
});
}
export function verifyEIP191({
pubKey,
data,
signature,
}: Omit<VerifyArbitraryParams, "bech32Prefix">): boolean {
const recoveredPubKey = recoverPubKeyFromEthSignature(data, signature);
return (
pubKey.length === recoveredPubKey.length &&
pubKey.every((v, i) => v === recoveredPubKey[i])
);
}

View File

@ -0,0 +1,531 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/btccheckpoint/v1/btccheckpoint.proto (package babylon.btccheckpoint.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, protoInt64 } from "@bufbuild/protobuf";
/**
* BtcStatus is an enum describing the current btc status of the checkpoint
*
* @generated from enum babylon.btccheckpoint.v1.BtcStatus
*/
export enum BtcStatus {
/**
* SUBMITTED Epoch has Submitted btc status if there ever was at least one
* known submission on btc main chain
*
* @generated from enum value: EPOCH_STATUS_SUBMITTED = 0;
*/
EPOCH_STATUS_SUBMITTED = 0,
/**
* CONFIRMED Epoch has Confirmed btc status if there ever was at least one
* known submission on btc main chain which was k-deep
*
* @generated from enum value: EPOCH_STATUS_CONFIRMED = 1;
*/
EPOCH_STATUS_CONFIRMED = 1,
/**
* CONFIRMED Epoch has Finalized btc status if there is was at exactly one
* knon submission on btc main chain which is w-deep
*
* @generated from enum value: EPOCH_STATUS_FINALIZED = 2;
*/
EPOCH_STATUS_FINALIZED = 2,
}
// Retrieve enum metadata with: proto3.getEnumType(BtcStatus)
proto3.util.setEnumType(BtcStatus, "babylon.btccheckpoint.v1.BtcStatus", [
{ no: 0, name: "EPOCH_STATUS_SUBMITTED" },
{ no: 1, name: "EPOCH_STATUS_CONFIRMED" },
{ no: 2, name: "EPOCH_STATUS_FINALIZED" },
]);
/**
* Consider we have a Merkle tree with following structure:
* ROOT
* / \
* H1234 H5555
* / \ \
* H12 H34 H55
* / \ / \ /
* H1 H2 H3 H4 H5
* L1 L2 L3 L4 L5
* To prove L3 was part of ROOT we need:
* - btc_transaction_index = 2 which in binary is 010
* (where 0 means going left, 1 means going right in the tree)
* - merkle_nodes we'd have H4 || H12 || H5555
* By looking at 010 we would know that H4 is a right sibling,
* H12 is left, H5555 is right again.
*
* @generated from message babylon.btccheckpoint.v1.BTCSpvProof
*/
export class BTCSpvProof extends Message<BTCSpvProof> {
/**
* Valid bitcoin transaction containing OP_RETURN opcode.
*
* @generated from field: bytes btc_transaction = 1;
*/
btcTransaction = new Uint8Array(0);
/**
* Index of transaction within the block. Index is needed to determine if
* currently hashed node is left or right.
*
* @generated from field: uint32 btc_transaction_index = 2;
*/
btcTransactionIndex = 0;
/**
* List of concatenated intermediate merkle tree nodes, without root node and
* leaf node against which we calculate the proof. Each node has 32 byte
* length. Example proof can look like: 32_bytes_of_node1 || 32_bytes_of_node2
* || 32_bytes_of_node3 so the length of the proof will always be divisible
* by 32.
*
* @generated from field: bytes merkle_nodes = 3;
*/
merkleNodes = new Uint8Array(0);
/**
* Valid btc header which confirms btc_transaction.
* Should have exactly 80 bytes
*
* @generated from field: bytes confirming_btc_header = 4;
*/
confirmingBtcHeader = new Uint8Array(0);
constructor(data?: PartialMessage<BTCSpvProof>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.BTCSpvProof";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "btc_transaction", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 2, name: "btc_transaction_index", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
{ no: 3, name: "merkle_nodes", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 4, name: "confirming_btc_header", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BTCSpvProof {
return new BTCSpvProof().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BTCSpvProof {
return new BTCSpvProof().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BTCSpvProof {
return new BTCSpvProof().fromJsonString(jsonString, options);
}
static equals(a: BTCSpvProof | PlainMessage<BTCSpvProof> | undefined, b: BTCSpvProof | PlainMessage<BTCSpvProof> | undefined): boolean {
return proto3.util.equals(BTCSpvProof, a, b);
}
}
/**
* Each provided OP_RETURN transaction can be identified by hash of block in
* which transaction was included and transaction index in the block
*
* @generated from message babylon.btccheckpoint.v1.TransactionKey
*/
export class TransactionKey extends Message<TransactionKey> {
/**
* @generated from field: uint32 index = 1;
*/
index = 0;
/**
* @generated from field: bytes hash = 2;
*/
hash = new Uint8Array(0);
constructor(data?: PartialMessage<TransactionKey>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.TransactionKey";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "index", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
{ no: 2, name: "hash", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): TransactionKey {
return new TransactionKey().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): TransactionKey {
return new TransactionKey().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): TransactionKey {
return new TransactionKey().fromJsonString(jsonString, options);
}
static equals(a: TransactionKey | PlainMessage<TransactionKey> | undefined, b: TransactionKey | PlainMessage<TransactionKey> | undefined): boolean {
return proto3.util.equals(TransactionKey, a, b);
}
}
/**
* Checkpoint can be composed from multiple transactions, so to identify whole
* submission we need list of transaction keys.
* Each submission can generally be identified by this list of (txIdx,
* blockHash) tuples. Note: this could possibly be optimized as if transactions
* were in one block they would have the same block hash and different indexes,
* but each blockhash is only 33 (1 byte for prefix encoding and 32 byte hash),
* so there should be other strong arguments for this optimization
*
* @generated from message babylon.btccheckpoint.v1.SubmissionKey
*/
export class SubmissionKey extends Message<SubmissionKey> {
/**
* @generated from field: repeated babylon.btccheckpoint.v1.TransactionKey key = 1;
*/
key: TransactionKey[] = [];
constructor(data?: PartialMessage<SubmissionKey>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.SubmissionKey";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "key", kind: "message", T: TransactionKey, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): SubmissionKey {
return new SubmissionKey().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): SubmissionKey {
return new SubmissionKey().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): SubmissionKey {
return new SubmissionKey().fromJsonString(jsonString, options);
}
static equals(a: SubmissionKey | PlainMessage<SubmissionKey> | undefined, b: SubmissionKey | PlainMessage<SubmissionKey> | undefined): boolean {
return proto3.util.equals(SubmissionKey, a, b);
}
}
/**
* TransactionInfo is the info of a tx on Bitcoin,
* including
* - the position of the tx on BTC blockchain
* - the full tx content
* - the Merkle proof that this tx is on the above position
*
* @generated from message babylon.btccheckpoint.v1.TransactionInfo
*/
export class TransactionInfo extends Message<TransactionInfo> {
/**
* key is the position (txIdx, blockHash) of this tx on BTC blockchain
* Although it is already a part of SubmissionKey, we store it here again
* to make TransactionInfo self-contained.
* For example, storing the key allows TransactionInfo to not relay on
* the fact that TransactionInfo will be ordered in the same order as
* TransactionKeys in SubmissionKey.
*
* @generated from field: babylon.btccheckpoint.v1.TransactionKey key = 1;
*/
key?: TransactionKey;
/**
* transaction is the full transaction in bytes
*
* @generated from field: bytes transaction = 2;
*/
transaction = new Uint8Array(0);
/**
* proof is the Merkle proof that this tx is included in the position in `key`
* TODO: maybe it could use here better format as we already processed and
* validated the proof?
*
* @generated from field: bytes proof = 3;
*/
proof = new Uint8Array(0);
constructor(data?: PartialMessage<TransactionInfo>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.TransactionInfo";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "key", kind: "message", T: TransactionKey },
{ no: 2, name: "transaction", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 3, name: "proof", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): TransactionInfo {
return new TransactionInfo().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): TransactionInfo {
return new TransactionInfo().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): TransactionInfo {
return new TransactionInfo().fromJsonString(jsonString, options);
}
static equals(a: TransactionInfo | PlainMessage<TransactionInfo> | undefined, b: TransactionInfo | PlainMessage<TransactionInfo> | undefined): boolean {
return proto3.util.equals(TransactionInfo, a, b);
}
}
/**
* TODO: Determine if we should keep any block number or depth info.
* On one hand it may be useful to determine if block is stable or not, on
* other depth/block number info, without context (i.e info about chain) is
* pretty useless and blockhash in enough to retrieve is from lightclient
*
* @generated from message babylon.btccheckpoint.v1.SubmissionData
*/
export class SubmissionData extends Message<SubmissionData> {
/**
* address of the submitter and reporter
*
* @generated from field: babylon.btccheckpoint.v1.CheckpointAddresses vigilante_addresses = 1;
*/
vigilanteAddresses?: CheckpointAddresses;
/**
* txs_info is the two `TransactionInfo`s corresponding to the submission
* It is used for
* - recovering address of sender of btc transaction to payup the reward.
* - allowing the ZoneConcierge module to prove the checkpoint is submitted to
* BTC
*
* @generated from field: repeated babylon.btccheckpoint.v1.TransactionInfo txs_info = 2;
*/
txsInfo: TransactionInfo[] = [];
/**
* @generated from field: uint64 epoch = 3;
*/
epoch = protoInt64.zero;
constructor(data?: PartialMessage<SubmissionData>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.SubmissionData";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "vigilante_addresses", kind: "message", T: CheckpointAddresses },
{ no: 2, name: "txs_info", kind: "message", T: TransactionInfo, repeated: true },
{ no: 3, name: "epoch", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): SubmissionData {
return new SubmissionData().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): SubmissionData {
return new SubmissionData().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): SubmissionData {
return new SubmissionData().fromJsonString(jsonString, options);
}
static equals(a: SubmissionData | PlainMessage<SubmissionData> | undefined, b: SubmissionData | PlainMessage<SubmissionData> | undefined): boolean {
return proto3.util.equals(SubmissionData, a, b);
}
}
/**
* Data stored in db and indexed by epoch number
* TODO: Add btc blockheight at epoch end, when adding handling of epoching
* callbacks
*
* @generated from message babylon.btccheckpoint.v1.EpochData
*/
export class EpochData extends Message<EpochData> {
/**
* keys is the list of all received checkpoints during this epoch, sorted by
* order of submission.
*
* @generated from field: repeated babylon.btccheckpoint.v1.SubmissionKey keys = 1;
*/
keys: SubmissionKey[] = [];
/**
* status is the current btc status of the epoch
*
* @generated from field: babylon.btccheckpoint.v1.BtcStatus status = 2;
*/
status = BtcStatus.EPOCH_STATUS_SUBMITTED;
constructor(data?: PartialMessage<EpochData>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.EpochData";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "keys", kind: "message", T: SubmissionKey, repeated: true },
{ no: 2, name: "status", kind: "enum", T: proto3.getEnumType(BtcStatus) },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EpochData {
return new EpochData().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EpochData {
return new EpochData().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EpochData {
return new EpochData().fromJsonString(jsonString, options);
}
static equals(a: EpochData | PlainMessage<EpochData> | undefined, b: EpochData | PlainMessage<EpochData> | undefined): boolean {
return proto3.util.equals(EpochData, a, b);
}
}
/**
* CheckpointAddresses contains the addresses of the submitter and reporter of a
* given checkpoint
*
* @generated from message babylon.btccheckpoint.v1.CheckpointAddresses
*/
export class CheckpointAddresses extends Message<CheckpointAddresses> {
/**
* TODO: this could probably be better typed
* submitter is the address of the checkpoint submitter to BTC, extracted from
* the checkpoint itself.
*
* @generated from field: bytes submitter = 1;
*/
submitter = new Uint8Array(0);
/**
* reporter is the address of the reporter who reported the submissions,
* calculated from submission message MsgInsertBTCSpvProof itself
*
* @generated from field: bytes reporter = 2;
*/
reporter = new Uint8Array(0);
constructor(data?: PartialMessage<CheckpointAddresses>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.CheckpointAddresses";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "submitter", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 2, name: "reporter", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): CheckpointAddresses {
return new CheckpointAddresses().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): CheckpointAddresses {
return new CheckpointAddresses().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): CheckpointAddresses {
return new CheckpointAddresses().fromJsonString(jsonString, options);
}
static equals(a: CheckpointAddresses | PlainMessage<CheckpointAddresses> | undefined, b: CheckpointAddresses | PlainMessage<CheckpointAddresses> | undefined): boolean {
return proto3.util.equals(CheckpointAddresses, a, b);
}
}
/**
* BTCCheckpointInfo contains all data about best submission of checkpoint for
* given epoch. Best submission is the submission which is deeper in btc ledger
*
* @generated from message babylon.btccheckpoint.v1.BTCCheckpointInfo
*/
export class BTCCheckpointInfo extends Message<BTCCheckpointInfo> {
/**
* epoch number of this checkpoint
*
* @generated from field: uint64 epoch_number = 1;
*/
epochNumber = protoInt64.zero;
/**
* btc height of the best submission of the epoch
*
* @generated from field: uint64 best_submission_btc_block_height = 2;
*/
bestSubmissionBtcBlockHeight = protoInt64.zero;
/**
* hash of the btc block which determines checkpoint btc block height i.e.
* youngest block of best submission
*
* @generated from field: bytes best_submission_btc_block_hash = 3;
*/
bestSubmissionBtcBlockHash = new Uint8Array(0);
/**
* the BTC checkpoint transactions of the best submission
*
* @generated from field: repeated babylon.btccheckpoint.v1.TransactionInfo best_submission_transactions = 4;
*/
bestSubmissionTransactions: TransactionInfo[] = [];
/**
* list of vigilantes' addresses of the best submission
*
* @generated from field: repeated babylon.btccheckpoint.v1.CheckpointAddresses best_submission_vigilante_address_list = 5;
*/
bestSubmissionVigilanteAddressList: CheckpointAddresses[] = [];
constructor(data?: PartialMessage<BTCCheckpointInfo>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.BTCCheckpointInfo";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "epoch_number", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 2, name: "best_submission_btc_block_height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 3, name: "best_submission_btc_block_hash", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 4, name: "best_submission_transactions", kind: "message", T: TransactionInfo, repeated: true },
{ no: 5, name: "best_submission_vigilante_address_list", kind: "message", T: CheckpointAddresses, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BTCCheckpointInfo {
return new BTCCheckpointInfo().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BTCCheckpointInfo {
return new BTCCheckpointInfo().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BTCCheckpointInfo {
return new BTCCheckpointInfo().fromJsonString(jsonString, options);
}
static equals(a: BTCCheckpointInfo | PlainMessage<BTCCheckpointInfo> | undefined, b: BTCCheckpointInfo | PlainMessage<BTCCheckpointInfo> | undefined): boolean {
return proto3.util.equals(BTCCheckpointInfo, a, b);
}
}

View File

@ -0,0 +1,48 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/btccheckpoint/v1/genesis.proto (package babylon.btccheckpoint.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3 } from "@bufbuild/protobuf";
import { Params } from "./params_pb.js";
/**
* GenesisState defines the btccheckpoint module's genesis state.
*
* @generated from message babylon.btccheckpoint.v1.GenesisState
*/
export class GenesisState extends Message<GenesisState> {
/**
* @generated from field: babylon.btccheckpoint.v1.Params params = 1;
*/
params?: Params;
constructor(data?: PartialMessage<GenesisState>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.GenesisState";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "params", kind: "message", T: Params },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GenesisState {
return new GenesisState().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GenesisState {
return new GenesisState().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GenesisState {
return new GenesisState().fromJsonString(jsonString, options);
}
static equals(a: GenesisState | PlainMessage<GenesisState> | undefined, b: GenesisState | PlainMessage<GenesisState> | undefined): boolean {
return proto3.util.equals(GenesisState, a, b);
}
}

View File

@ -0,0 +1,73 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/btccheckpoint/v1/params.proto (package babylon.btccheckpoint.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, protoInt64 } from "@bufbuild/protobuf";
/**
* Params defines the parameters for the module.
*
* @generated from message babylon.btccheckpoint.v1.Params
*/
export class Params extends Message<Params> {
/**
* btc_confirmation_depth is the confirmation depth in BTC.
* A block is considered irreversible only when it is at least k-deep in BTC
* (k in research paper)
*
* @generated from field: uint64 btc_confirmation_depth = 1;
*/
btcConfirmationDepth = protoInt64.zero;
/**
* checkpoint_finalization_timeout is the maximum time window (measured in BTC
* blocks) between a checkpoint
* - being submitted to BTC, and
* - being reported back to BBN
* If a checkpoint has not been reported back within w BTC blocks, then BBN
* has dishonest majority and is stalling checkpoints (w in research paper)
*
* @generated from field: uint64 checkpoint_finalization_timeout = 2;
*/
checkpointFinalizationTimeout = protoInt64.zero;
/**
* 4byte tag in hex format, required to be present in the OP_RETURN transaction
* related to babylon
*
* @generated from field: string checkpoint_tag = 3;
*/
checkpointTag = "";
constructor(data?: PartialMessage<Params>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.Params";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "btc_confirmation_depth", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 2, name: "checkpoint_finalization_timeout", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 3, name: "checkpoint_tag", kind: "scalar", T: 9 /* ScalarType.STRING */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Params {
return new Params().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Params {
return new Params().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Params {
return new Params().fromJsonString(jsonString, options);
}
static equals(a: Params | PlainMessage<Params> | undefined, b: Params | PlainMessage<Params> | undefined): boolean {
return proto3.util.equals(Params, a, b);
}
}

View File

@ -0,0 +1,57 @@
// @generated by protoc-gen-cosmes v0.0.1 with parameter "target=ts"
// @generated from file babylon/btccheckpoint/v1/query.proto (package babylon.btccheckpoint.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import { QueryBtcCheckpointInfoRequest, QueryBtcCheckpointInfoResponse, QueryBtcCheckpointsInfoRequest, QueryBtcCheckpointsInfoResponse, QueryEpochSubmissionsRequest, QueryEpochSubmissionsResponse, QueryParamsRequest, QueryParamsResponse } from "./query_pb.js";
const TYPE_NAME = "babylon.btccheckpoint.v1.Query";
/**
* Parameters queries the parameters of the module.
*
* @generated from rpc babylon.btccheckpoint.v1.Query.Params
*/
export const QueryParamsService = {
typeName: TYPE_NAME,
method: "Params",
Request: QueryParamsRequest,
Response: QueryParamsResponse,
} as const;
/**
* BtcCheckpointInfo returns checkpoint info for a given epoch
*
* @generated from rpc babylon.btccheckpoint.v1.Query.BtcCheckpointInfo
*/
export const QueryBtcCheckpointInfoService = {
typeName: TYPE_NAME,
method: "BtcCheckpointInfo",
Request: QueryBtcCheckpointInfoRequest,
Response: QueryBtcCheckpointInfoResponse,
} as const;
/**
* BtcCheckpointsInfo returns checkpoint info for a range of epochs
*
* @generated from rpc babylon.btccheckpoint.v1.Query.BtcCheckpointsInfo
*/
export const QueryBtcCheckpointsInfoService = {
typeName: TYPE_NAME,
method: "BtcCheckpointsInfo",
Request: QueryBtcCheckpointsInfoRequest,
Response: QueryBtcCheckpointsInfoResponse,
} as const;
/**
* EpochSubmissions returns all submissions for a given epoch
*
* @generated from rpc babylon.btccheckpoint.v1.Query.EpochSubmissions
*/
export const QueryEpochSubmissionsService = {
typeName: TYPE_NAME,
method: "EpochSubmissions",
Request: QueryEpochSubmissionsRequest,
Response: QueryEpochSubmissionsResponse,
} as const;

View File

@ -0,0 +1,604 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/btccheckpoint/v1/query.proto (package babylon.btccheckpoint.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, protoInt64 } from "@bufbuild/protobuf";
import { Params } from "./params_pb.js";
import { PageRequest, PageResponse } from "../../../cosmos/base/query/v1beta1/pagination_pb.js";
/**
* QueryParamsRequest is request type for the Query/Params RPC method.
*
* @generated from message babylon.btccheckpoint.v1.QueryParamsRequest
*/
export class QueryParamsRequest extends Message<QueryParamsRequest> {
constructor(data?: PartialMessage<QueryParamsRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.QueryParamsRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryParamsRequest {
return new QueryParamsRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryParamsRequest {
return new QueryParamsRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryParamsRequest {
return new QueryParamsRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryParamsRequest | PlainMessage<QueryParamsRequest> | undefined, b: QueryParamsRequest | PlainMessage<QueryParamsRequest> | undefined): boolean {
return proto3.util.equals(QueryParamsRequest, a, b);
}
}
/**
* QueryParamsResponse is response type for the Query/Params RPC method.
*
* @generated from message babylon.btccheckpoint.v1.QueryParamsResponse
*/
export class QueryParamsResponse extends Message<QueryParamsResponse> {
/**
* params holds all the parameters of this module.
*
* @generated from field: babylon.btccheckpoint.v1.Params params = 1;
*/
params?: Params;
constructor(data?: PartialMessage<QueryParamsResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.QueryParamsResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "params", kind: "message", T: Params },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryParamsResponse {
return new QueryParamsResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryParamsResponse {
return new QueryParamsResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryParamsResponse {
return new QueryParamsResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryParamsResponse | PlainMessage<QueryParamsResponse> | undefined, b: QueryParamsResponse | PlainMessage<QueryParamsResponse> | undefined): boolean {
return proto3.util.equals(QueryParamsResponse, a, b);
}
}
/**
* QueryBtcCheckpointInfoRequest defines the query to get the best checkpoint
* for a given epoch
*
* @generated from message babylon.btccheckpoint.v1.QueryBtcCheckpointInfoRequest
*/
export class QueryBtcCheckpointInfoRequest extends Message<QueryBtcCheckpointInfoRequest> {
/**
* Number of epoch for which the earliest checkpointing btc height is
* requested
*
* @generated from field: uint64 epoch_num = 1;
*/
epochNum = protoInt64.zero;
constructor(data?: PartialMessage<QueryBtcCheckpointInfoRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.QueryBtcCheckpointInfoRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "epoch_num", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryBtcCheckpointInfoRequest {
return new QueryBtcCheckpointInfoRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryBtcCheckpointInfoRequest {
return new QueryBtcCheckpointInfoRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryBtcCheckpointInfoRequest {
return new QueryBtcCheckpointInfoRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryBtcCheckpointInfoRequest | PlainMessage<QueryBtcCheckpointInfoRequest> | undefined, b: QueryBtcCheckpointInfoRequest | PlainMessage<QueryBtcCheckpointInfoRequest> | undefined): boolean {
return proto3.util.equals(QueryBtcCheckpointInfoRequest, a, b);
}
}
/**
* QueryBtcCheckpointInfoResponse is response type for the
* Query/BtcCheckpointInfo RPC method
*
* @generated from message babylon.btccheckpoint.v1.QueryBtcCheckpointInfoResponse
*/
export class QueryBtcCheckpointInfoResponse extends Message<QueryBtcCheckpointInfoResponse> {
/**
* @generated from field: babylon.btccheckpoint.v1.BTCCheckpointInfoResponse info = 1;
*/
info?: BTCCheckpointInfoResponse;
constructor(data?: PartialMessage<QueryBtcCheckpointInfoResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.QueryBtcCheckpointInfoResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "info", kind: "message", T: BTCCheckpointInfoResponse },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryBtcCheckpointInfoResponse {
return new QueryBtcCheckpointInfoResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryBtcCheckpointInfoResponse {
return new QueryBtcCheckpointInfoResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryBtcCheckpointInfoResponse {
return new QueryBtcCheckpointInfoResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryBtcCheckpointInfoResponse | PlainMessage<QueryBtcCheckpointInfoResponse> | undefined, b: QueryBtcCheckpointInfoResponse | PlainMessage<QueryBtcCheckpointInfoResponse> | undefined): boolean {
return proto3.util.equals(QueryBtcCheckpointInfoResponse, a, b);
}
}
/**
* QueryBtcCheckpointsInfoRequest is request type for the
* Query/BtcCheckpointsInfo RPC method
*
* @generated from message babylon.btccheckpoint.v1.QueryBtcCheckpointsInfoRequest
*/
export class QueryBtcCheckpointsInfoRequest extends Message<QueryBtcCheckpointsInfoRequest> {
/**
* pagination defines whether to have the pagination in the request
*
* @generated from field: cosmos.base.query.v1beta1.PageRequest pagination = 1;
*/
pagination?: PageRequest;
constructor(data?: PartialMessage<QueryBtcCheckpointsInfoRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.QueryBtcCheckpointsInfoRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "pagination", kind: "message", T: PageRequest },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryBtcCheckpointsInfoRequest {
return new QueryBtcCheckpointsInfoRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryBtcCheckpointsInfoRequest {
return new QueryBtcCheckpointsInfoRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryBtcCheckpointsInfoRequest {
return new QueryBtcCheckpointsInfoRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryBtcCheckpointsInfoRequest | PlainMessage<QueryBtcCheckpointsInfoRequest> | undefined, b: QueryBtcCheckpointsInfoRequest | PlainMessage<QueryBtcCheckpointsInfoRequest> | undefined): boolean {
return proto3.util.equals(QueryBtcCheckpointsInfoRequest, a, b);
}
}
/**
* QueryBtcCheckpointsInfoResponse is response type for the
* Query/BtcCheckpointsInfo RPC method
*
* @generated from message babylon.btccheckpoint.v1.QueryBtcCheckpointsInfoResponse
*/
export class QueryBtcCheckpointsInfoResponse extends Message<QueryBtcCheckpointsInfoResponse> {
/**
* @generated from field: repeated babylon.btccheckpoint.v1.BTCCheckpointInfoResponse info_list = 1;
*/
infoList: BTCCheckpointInfoResponse[] = [];
/**
* pagination defines the pagination in the response
*
* @generated from field: cosmos.base.query.v1beta1.PageResponse pagination = 2;
*/
pagination?: PageResponse;
constructor(data?: PartialMessage<QueryBtcCheckpointsInfoResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.QueryBtcCheckpointsInfoResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "info_list", kind: "message", T: BTCCheckpointInfoResponse, repeated: true },
{ no: 2, name: "pagination", kind: "message", T: PageResponse },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryBtcCheckpointsInfoResponse {
return new QueryBtcCheckpointsInfoResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryBtcCheckpointsInfoResponse {
return new QueryBtcCheckpointsInfoResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryBtcCheckpointsInfoResponse {
return new QueryBtcCheckpointsInfoResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryBtcCheckpointsInfoResponse | PlainMessage<QueryBtcCheckpointsInfoResponse> | undefined, b: QueryBtcCheckpointsInfoResponse | PlainMessage<QueryBtcCheckpointsInfoResponse> | undefined): boolean {
return proto3.util.equals(QueryBtcCheckpointsInfoResponse, a, b);
}
}
/**
* QueryEpochSubmissionsRequest defines a request to get all submissions in
* given epoch
*
* @generated from message babylon.btccheckpoint.v1.QueryEpochSubmissionsRequest
*/
export class QueryEpochSubmissionsRequest extends Message<QueryEpochSubmissionsRequest> {
/**
* Number of epoch for which submissions are requested
*
* @generated from field: uint64 epoch_num = 1;
*/
epochNum = protoInt64.zero;
constructor(data?: PartialMessage<QueryEpochSubmissionsRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.QueryEpochSubmissionsRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "epoch_num", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryEpochSubmissionsRequest {
return new QueryEpochSubmissionsRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryEpochSubmissionsRequest {
return new QueryEpochSubmissionsRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryEpochSubmissionsRequest {
return new QueryEpochSubmissionsRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryEpochSubmissionsRequest | PlainMessage<QueryEpochSubmissionsRequest> | undefined, b: QueryEpochSubmissionsRequest | PlainMessage<QueryEpochSubmissionsRequest> | undefined): boolean {
return proto3.util.equals(QueryEpochSubmissionsRequest, a, b);
}
}
/**
* QueryEpochSubmissionsResponse defines a response to get all submissions in
* given epoch (QueryEpochSubmissionsRequest)
*
* @generated from message babylon.btccheckpoint.v1.QueryEpochSubmissionsResponse
*/
export class QueryEpochSubmissionsResponse extends Message<QueryEpochSubmissionsResponse> {
/**
* Keys All submissions transactions key saved during an epoch.
*
* @generated from field: repeated babylon.btccheckpoint.v1.SubmissionKeyResponse keys = 1;
*/
keys: SubmissionKeyResponse[] = [];
constructor(data?: PartialMessage<QueryEpochSubmissionsResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.QueryEpochSubmissionsResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "keys", kind: "message", T: SubmissionKeyResponse, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryEpochSubmissionsResponse {
return new QueryEpochSubmissionsResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryEpochSubmissionsResponse {
return new QueryEpochSubmissionsResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryEpochSubmissionsResponse {
return new QueryEpochSubmissionsResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryEpochSubmissionsResponse | PlainMessage<QueryEpochSubmissionsResponse> | undefined, b: QueryEpochSubmissionsResponse | PlainMessage<QueryEpochSubmissionsResponse> | undefined): boolean {
return proto3.util.equals(QueryEpochSubmissionsResponse, a, b);
}
}
/**
* BTCCheckpointInfoResponse contains all data about best submission of checkpoint for
* given epoch. Best submission is the submission which is deeper in btc ledger.
*
* @generated from message babylon.btccheckpoint.v1.BTCCheckpointInfoResponse
*/
export class BTCCheckpointInfoResponse extends Message<BTCCheckpointInfoResponse> {
/**
* EpochNumber of this checkpoint.
*
* @generated from field: uint64 epoch_number = 1;
*/
epochNumber = protoInt64.zero;
/**
* btc height of the best submission of the epoch
*
* @generated from field: uint64 best_submission_btc_block_height = 2;
*/
bestSubmissionBtcBlockHeight = protoInt64.zero;
/**
* hash of the btc block which determines checkpoint btc block height i.e.
* youngest block of best submission Hexadecimal
*
* @generated from field: string best_submission_btc_block_hash = 3;
*/
bestSubmissionBtcBlockHash = "";
/**
* the BTC checkpoint transactions of the best submission
*
* @generated from field: repeated babylon.btccheckpoint.v1.TransactionInfoResponse best_submission_transactions = 4;
*/
bestSubmissionTransactions: TransactionInfoResponse[] = [];
/**
* list of vigilantes' addresses of the best submission
*
* @generated from field: repeated babylon.btccheckpoint.v1.CheckpointAddressesResponse best_submission_vigilante_address_list = 5;
*/
bestSubmissionVigilanteAddressList: CheckpointAddressesResponse[] = [];
constructor(data?: PartialMessage<BTCCheckpointInfoResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.BTCCheckpointInfoResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "epoch_number", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 2, name: "best_submission_btc_block_height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 3, name: "best_submission_btc_block_hash", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 4, name: "best_submission_transactions", kind: "message", T: TransactionInfoResponse, repeated: true },
{ no: 5, name: "best_submission_vigilante_address_list", kind: "message", T: CheckpointAddressesResponse, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BTCCheckpointInfoResponse {
return new BTCCheckpointInfoResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BTCCheckpointInfoResponse {
return new BTCCheckpointInfoResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BTCCheckpointInfoResponse {
return new BTCCheckpointInfoResponse().fromJsonString(jsonString, options);
}
static equals(a: BTCCheckpointInfoResponse | PlainMessage<BTCCheckpointInfoResponse> | undefined, b: BTCCheckpointInfoResponse | PlainMessage<BTCCheckpointInfoResponse> | undefined): boolean {
return proto3.util.equals(BTCCheckpointInfoResponse, a, b);
}
}
/**
* TransactionInfoResponse is the info of a tx on Bitcoin,
* including
* - the position of the tx on BTC blockchain
* - the full tx content
* - the Merkle proof that this tx is on the above position
*
* @generated from message babylon.btccheckpoint.v1.TransactionInfoResponse
*/
export class TransactionInfoResponse extends Message<TransactionInfoResponse> {
/**
* Index Bitcoin Transaction index in block.
*
* @generated from field: uint32 index = 1;
*/
index = 0;
/**
* Hash BTC Header hash as hex.
*
* @generated from field: string hash = 2;
*/
hash = "";
/**
* transaction is the full transaction data as str hex.
*
* @generated from field: string transaction = 3;
*/
transaction = "";
/**
* proof is the Merkle proof that this tx is included in the position in `key`
*
* @generated from field: string proof = 4;
*/
proof = "";
constructor(data?: PartialMessage<TransactionInfoResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.TransactionInfoResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "index", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
{ no: 2, name: "hash", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "transaction", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 4, name: "proof", kind: "scalar", T: 9 /* ScalarType.STRING */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): TransactionInfoResponse {
return new TransactionInfoResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): TransactionInfoResponse {
return new TransactionInfoResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): TransactionInfoResponse {
return new TransactionInfoResponse().fromJsonString(jsonString, options);
}
static equals(a: TransactionInfoResponse | PlainMessage<TransactionInfoResponse> | undefined, b: TransactionInfoResponse | PlainMessage<TransactionInfoResponse> | undefined): boolean {
return proto3.util.equals(TransactionInfoResponse, a, b);
}
}
/**
* CheckpointAddressesResponse contains the addresses of the submitter and reporter of a
* given checkpoint
*
* @generated from message babylon.btccheckpoint.v1.CheckpointAddressesResponse
*/
export class CheckpointAddressesResponse extends Message<CheckpointAddressesResponse> {
/**
* submitter is the address of the checkpoint submitter to BTC, extracted from
* the checkpoint itself.
*
* @generated from field: string submitter = 1;
*/
submitter = "";
/**
* reporter is the address of the reporter who reported the submissions,
* calculated from submission message MsgInsertBTCSpvProof itself
*
* @generated from field: string reporter = 2;
*/
reporter = "";
constructor(data?: PartialMessage<CheckpointAddressesResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.CheckpointAddressesResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "submitter", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "reporter", kind: "scalar", T: 9 /* ScalarType.STRING */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): CheckpointAddressesResponse {
return new CheckpointAddressesResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): CheckpointAddressesResponse {
return new CheckpointAddressesResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): CheckpointAddressesResponse {
return new CheckpointAddressesResponse().fromJsonString(jsonString, options);
}
static equals(a: CheckpointAddressesResponse | PlainMessage<CheckpointAddressesResponse> | undefined, b: CheckpointAddressesResponse | PlainMessage<CheckpointAddressesResponse> | undefined): boolean {
return proto3.util.equals(CheckpointAddressesResponse, a, b);
}
}
/**
* SubmissionKeyResponse Checkpoint can be composed from multiple transactions,
* so to identify whole submission we need list of transaction keys.
* Each submission can generally be identified by this list of (txIdx,
* blockHash) tuples. Note: this could possibly be optimized as if transactions
* were in one block they would have the same block hash and different indexes,
* but each blockhash is only 33 (1 byte for prefix encoding and 32 byte hash),
* so there should be other strong arguments for this optimization
*
* @generated from message babylon.btccheckpoint.v1.SubmissionKeyResponse
*/
export class SubmissionKeyResponse extends Message<SubmissionKeyResponse> {
/**
* FirstTxBlockHash is the BTCHeaderHashBytes in hex.
*
* @generated from field: string first_tx_block_hash = 1;
*/
firstTxBlockHash = "";
/**
* @generated from field: uint32 first_tx_index = 2;
*/
firstTxIndex = 0;
/**
* SecondBlockHash is the BTCHeaderHashBytes in hex.
*
* @generated from field: string second_tx_block_hash = 3;
*/
secondTxBlockHash = "";
/**
* @generated from field: uint32 second_tx_index = 4;
*/
secondTxIndex = 0;
constructor(data?: PartialMessage<SubmissionKeyResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.SubmissionKeyResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "first_tx_block_hash", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "first_tx_index", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
{ no: 3, name: "second_tx_block_hash", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 4, name: "second_tx_index", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): SubmissionKeyResponse {
return new SubmissionKeyResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): SubmissionKeyResponse {
return new SubmissionKeyResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): SubmissionKeyResponse {
return new SubmissionKeyResponse().fromJsonString(jsonString, options);
}
static equals(a: SubmissionKeyResponse | PlainMessage<SubmissionKeyResponse> | undefined, b: SubmissionKeyResponse | PlainMessage<SubmissionKeyResponse> | undefined): boolean {
return proto3.util.equals(SubmissionKeyResponse, a, b);
}
}

View File

@ -0,0 +1,33 @@
// @generated by protoc-gen-cosmes v0.0.1 with parameter "target=ts"
// @generated from file babylon/btccheckpoint/v1/tx.proto (package babylon.btccheckpoint.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import { MsgInsertBTCSpvProof, MsgInsertBTCSpvProofResponse, MsgUpdateParams, MsgUpdateParamsResponse } from "./tx_pb.js";
const TYPE_NAME = "babylon.btccheckpoint.v1.Msg";
/**
* InsertBTCSpvProof tries to insert a new checkpoint into the store.
*
* @generated from rpc babylon.btccheckpoint.v1.Msg.InsertBTCSpvProof
*/
export const MsgInsertBTCSpvProofService = {
typeName: TYPE_NAME,
method: "InsertBTCSpvProof",
Request: MsgInsertBTCSpvProof,
Response: MsgInsertBTCSpvProofResponse,
} as const;
/**
* UpdateParams updates the btccheckpoint module parameters.
*
* @generated from rpc babylon.btccheckpoint.v1.Msg.UpdateParams
*/
export const MsgUpdateParamsService = {
typeName: TYPE_NAME,
method: "UpdateParams",
Request: MsgUpdateParams,
Response: MsgUpdateParamsResponse,
} as const;

View File

@ -0,0 +1,177 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/btccheckpoint/v1/tx.proto (package babylon.btccheckpoint.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3 } from "@bufbuild/protobuf";
import { BTCSpvProof } from "./btccheckpoint_pb.js";
import { Params } from "./params_pb.js";
/**
* MsgInsertBTCSpvProof defines resquest to insert a new checkpoint into the
* store
*
* @generated from message babylon.btccheckpoint.v1.MsgInsertBTCSpvProof
*/
export class MsgInsertBTCSpvProof extends Message<MsgInsertBTCSpvProof> {
/**
* @generated from field: string submitter = 1;
*/
submitter = "";
/**
* @generated from field: repeated babylon.btccheckpoint.v1.BTCSpvProof proofs = 2;
*/
proofs: BTCSpvProof[] = [];
constructor(data?: PartialMessage<MsgInsertBTCSpvProof>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.MsgInsertBTCSpvProof";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "submitter", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "proofs", kind: "message", T: BTCSpvProof, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgInsertBTCSpvProof {
return new MsgInsertBTCSpvProof().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgInsertBTCSpvProof {
return new MsgInsertBTCSpvProof().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgInsertBTCSpvProof {
return new MsgInsertBTCSpvProof().fromJsonString(jsonString, options);
}
static equals(a: MsgInsertBTCSpvProof | PlainMessage<MsgInsertBTCSpvProof> | undefined, b: MsgInsertBTCSpvProof | PlainMessage<MsgInsertBTCSpvProof> | undefined): boolean {
return proto3.util.equals(MsgInsertBTCSpvProof, a, b);
}
}
/**
* MsgInsertBTCSpvProofResponse defines the response for the
* MsgInsertBTCSpvProof message
*
* @generated from message babylon.btccheckpoint.v1.MsgInsertBTCSpvProofResponse
*/
export class MsgInsertBTCSpvProofResponse extends Message<MsgInsertBTCSpvProofResponse> {
constructor(data?: PartialMessage<MsgInsertBTCSpvProofResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.MsgInsertBTCSpvProofResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgInsertBTCSpvProofResponse {
return new MsgInsertBTCSpvProofResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgInsertBTCSpvProofResponse {
return new MsgInsertBTCSpvProofResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgInsertBTCSpvProofResponse {
return new MsgInsertBTCSpvProofResponse().fromJsonString(jsonString, options);
}
static equals(a: MsgInsertBTCSpvProofResponse | PlainMessage<MsgInsertBTCSpvProofResponse> | undefined, b: MsgInsertBTCSpvProofResponse | PlainMessage<MsgInsertBTCSpvProofResponse> | undefined): boolean {
return proto3.util.equals(MsgInsertBTCSpvProofResponse, a, b);
}
}
/**
* MsgUpdateParams defines a message to update the btccheckpoint module params.
*
* @generated from message babylon.btccheckpoint.v1.MsgUpdateParams
*/
export class MsgUpdateParams extends Message<MsgUpdateParams> {
/**
* authority is the address of the governance account.
* just FYI: cosmos.AddressString marks that this field should use type alias
* for AddressString instead of string, but the functionality is not yet implemented
* in cosmos-proto
*
* @generated from field: string authority = 1;
*/
authority = "";
/**
* params defines the btccheckpoint parameters to update.
*
* NOTE: All parameters must be supplied.
*
* @generated from field: babylon.btccheckpoint.v1.Params params = 2;
*/
params?: Params;
constructor(data?: PartialMessage<MsgUpdateParams>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.MsgUpdateParams";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "authority", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "params", kind: "message", T: Params },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgUpdateParams {
return new MsgUpdateParams().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgUpdateParams {
return new MsgUpdateParams().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgUpdateParams {
return new MsgUpdateParams().fromJsonString(jsonString, options);
}
static equals(a: MsgUpdateParams | PlainMessage<MsgUpdateParams> | undefined, b: MsgUpdateParams | PlainMessage<MsgUpdateParams> | undefined): boolean {
return proto3.util.equals(MsgUpdateParams, a, b);
}
}
/**
* MsgUpdateParamsResponse defines the response to the MsgUpdateParams message.
*
* @generated from message babylon.btccheckpoint.v1.MsgUpdateParamsResponse
*/
export class MsgUpdateParamsResponse extends Message<MsgUpdateParamsResponse> {
constructor(data?: PartialMessage<MsgUpdateParamsResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btccheckpoint.v1.MsgUpdateParamsResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgUpdateParamsResponse {
return new MsgUpdateParamsResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgUpdateParamsResponse {
return new MsgUpdateParamsResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgUpdateParamsResponse {
return new MsgUpdateParamsResponse().fromJsonString(jsonString, options);
}
static equals(a: MsgUpdateParamsResponse | PlainMessage<MsgUpdateParamsResponse> | undefined, b: MsgUpdateParamsResponse | PlainMessage<MsgUpdateParamsResponse> | undefined): boolean {
return proto3.util.equals(MsgUpdateParamsResponse, a, b);
}
}

View File

@ -0,0 +1,72 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/btclightclient/v1/btclightclient.proto (package babylon.btclightclient.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, protoInt64 } from "@bufbuild/protobuf";
/**
* BTCHeaderInfo is a structure that contains all relevant information about a
* BTC header
* - Full header bytes
* - Header hash for easy retrieval
* - Height of the header in the BTC chain
* - Total work spent on the header. This is the sum of the work corresponding
* to the header Bits field
* and the total work of the header.
*
* @generated from message babylon.btclightclient.v1.BTCHeaderInfo
*/
export class BTCHeaderInfo extends Message<BTCHeaderInfo> {
/**
* @generated from field: bytes header = 1;
*/
header = new Uint8Array(0);
/**
* @generated from field: bytes hash = 2;
*/
hash = new Uint8Array(0);
/**
* @generated from field: uint64 height = 3;
*/
height = protoInt64.zero;
/**
* @generated from field: bytes work = 4;
*/
work = new Uint8Array(0);
constructor(data?: PartialMessage<BTCHeaderInfo>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.BTCHeaderInfo";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "header", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 2, name: "hash", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 3, name: "height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 4, name: "work", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BTCHeaderInfo {
return new BTCHeaderInfo().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BTCHeaderInfo {
return new BTCHeaderInfo().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BTCHeaderInfo {
return new BTCHeaderInfo().fromJsonString(jsonString, options);
}
static equals(a: BTCHeaderInfo | PlainMessage<BTCHeaderInfo> | undefined, b: BTCHeaderInfo | PlainMessage<BTCHeaderInfo> | undefined): boolean {
return proto3.util.equals(BTCHeaderInfo, a, b);
}
}

View File

@ -0,0 +1,134 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/btclightclient/v1/event.proto (package babylon.btclightclient.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3 } from "@bufbuild/protobuf";
import { BTCHeaderInfo } from "./btclightclient_pb.js";
/**
* The header included in the event is the block in the history
* of the current mainchain to which we are rolling back to.
* In other words, there is one rollback event emitted per re-org, to the
* greatest common ancestor of the old and the new fork.
*
* @generated from message babylon.btclightclient.v1.EventBTCRollBack
*/
export class EventBTCRollBack extends Message<EventBTCRollBack> {
/**
* @generated from field: babylon.btclightclient.v1.BTCHeaderInfo header = 1;
*/
header?: BTCHeaderInfo;
constructor(data?: PartialMessage<EventBTCRollBack>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.EventBTCRollBack";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "header", kind: "message", T: BTCHeaderInfo },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventBTCRollBack {
return new EventBTCRollBack().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventBTCRollBack {
return new EventBTCRollBack().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventBTCRollBack {
return new EventBTCRollBack().fromJsonString(jsonString, options);
}
static equals(a: EventBTCRollBack | PlainMessage<EventBTCRollBack> | undefined, b: EventBTCRollBack | PlainMessage<EventBTCRollBack> | undefined): boolean {
return proto3.util.equals(EventBTCRollBack, a, b);
}
}
/**
* EventBTCRollForward is emitted on Msg/InsertHeader
* The header included in the event is the one the main chain is extended with.
* In the event of a reorg, each block on the new fork that comes after
* the greatest common ancestor will have a corresponding roll forward event.
*
* @generated from message babylon.btclightclient.v1.EventBTCRollForward
*/
export class EventBTCRollForward extends Message<EventBTCRollForward> {
/**
* @generated from field: babylon.btclightclient.v1.BTCHeaderInfo header = 1;
*/
header?: BTCHeaderInfo;
constructor(data?: PartialMessage<EventBTCRollForward>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.EventBTCRollForward";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "header", kind: "message", T: BTCHeaderInfo },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventBTCRollForward {
return new EventBTCRollForward().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventBTCRollForward {
return new EventBTCRollForward().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventBTCRollForward {
return new EventBTCRollForward().fromJsonString(jsonString, options);
}
static equals(a: EventBTCRollForward | PlainMessage<EventBTCRollForward> | undefined, b: EventBTCRollForward | PlainMessage<EventBTCRollForward> | undefined): boolean {
return proto3.util.equals(EventBTCRollForward, a, b);
}
}
/**
* EventBTCHeaderInserted is emitted on Msg/InsertHeader
* The header included in the event is the one that was added to the
* on chain BTC storage.
*
* @generated from message babylon.btclightclient.v1.EventBTCHeaderInserted
*/
export class EventBTCHeaderInserted extends Message<EventBTCHeaderInserted> {
/**
* @generated from field: babylon.btclightclient.v1.BTCHeaderInfo header = 1;
*/
header?: BTCHeaderInfo;
constructor(data?: PartialMessage<EventBTCHeaderInserted>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.EventBTCHeaderInserted";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "header", kind: "message", T: BTCHeaderInfo },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventBTCHeaderInserted {
return new EventBTCHeaderInserted().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventBTCHeaderInserted {
return new EventBTCHeaderInserted().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventBTCHeaderInserted {
return new EventBTCHeaderInserted().fromJsonString(jsonString, options);
}
static equals(a: EventBTCHeaderInserted | PlainMessage<EventBTCHeaderInserted> | undefined, b: EventBTCHeaderInserted | PlainMessage<EventBTCHeaderInserted> | undefined): boolean {
return proto3.util.equals(EventBTCHeaderInserted, a, b);
}
}

View File

@ -0,0 +1,55 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/btclightclient/v1/genesis.proto (package babylon.btclightclient.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3 } from "@bufbuild/protobuf";
import { Params } from "./params_pb.js";
import { BTCHeaderInfo } from "./btclightclient_pb.js";
/**
* GenesisState defines the btclightclient module's genesis state.
*
* @generated from message babylon.btclightclient.v1.GenesisState
*/
export class GenesisState extends Message<GenesisState> {
/**
* @generated from field: babylon.btclightclient.v1.Params params = 1;
*/
params?: Params;
/**
* @generated from field: repeated babylon.btclightclient.v1.BTCHeaderInfo btc_headers = 2;
*/
btcHeaders: BTCHeaderInfo[] = [];
constructor(data?: PartialMessage<GenesisState>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.GenesisState";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "params", kind: "message", T: Params },
{ no: 2, name: "btc_headers", kind: "message", T: BTCHeaderInfo, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GenesisState {
return new GenesisState().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GenesisState {
return new GenesisState().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GenesisState {
return new GenesisState().fromJsonString(jsonString, options);
}
static equals(a: GenesisState | PlainMessage<GenesisState> | undefined, b: GenesisState | PlainMessage<GenesisState> | undefined): boolean {
return proto3.util.equals(GenesisState, a, b);
}
}

View File

@ -0,0 +1,50 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/btclightclient/v1/params.proto (package babylon.btclightclient.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3 } from "@bufbuild/protobuf";
/**
* Params defines the parameters for the module.
*
* @generated from message babylon.btclightclient.v1.Params
*/
export class Params extends Message<Params> {
/**
* List of addresses which are allowed to insert headers to btc light client
* if the list is empty, any address can insert headers
*
* @generated from field: repeated string insert_headers_allow_list = 1;
*/
insertHeadersAllowList: string[] = [];
constructor(data?: PartialMessage<Params>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.Params";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "insert_headers_allow_list", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Params {
return new Params().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Params {
return new Params().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Params {
return new Params().fromJsonString(jsonString, options);
}
static equals(a: Params | PlainMessage<Params> | undefined, b: Params | PlainMessage<Params> | undefined): boolean {
return proto3.util.equals(Params, a, b);
}
}

View File

@ -0,0 +1,110 @@
// @generated by protoc-gen-cosmes v0.0.1 with parameter "target=ts"
// @generated from file babylon/btclightclient/v1/query.proto (package babylon.btclightclient.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import { QueryBaseHeaderRequest, QueryBaseHeaderResponse, QueryContainsBytesRequest, QueryContainsBytesResponse, QueryContainsRequest, QueryContainsResponse, QueryHashesRequest, QueryHashesResponse, QueryHeaderDepthRequest, QueryHeaderDepthResponse, QueryMainChainRequest, QueryMainChainResponse, QueryParamsRequest, QueryParamsResponse, QueryTipRequest, QueryTipResponse } from "./query_pb.js";
const TYPE_NAME = "babylon.btclightclient.v1.Query";
/**
* Params queries the parameters of the module.
*
* @generated from rpc babylon.btclightclient.v1.Query.Params
*/
export const QueryParamsService = {
typeName: TYPE_NAME,
method: "Params",
Request: QueryParamsRequest,
Response: QueryParamsResponse,
} as const;
/**
* Hashes retrieves the hashes maintained by the module.
*
* @generated from rpc babylon.btclightclient.v1.Query.Hashes
*/
export const QueryHashesService = {
typeName: TYPE_NAME,
method: "Hashes",
Request: QueryHashesRequest,
Response: QueryHashesResponse,
} as const;
/**
* Contains checks whether a hash is maintained by the module.
*
* @generated from rpc babylon.btclightclient.v1.Query.Contains
*/
export const QueryContainsService = {
typeName: TYPE_NAME,
method: "Contains",
Request: QueryContainsRequest,
Response: QueryContainsResponse,
} as const;
/**
* ContainsBytes is a temporary method that
* checks whether a hash is maintained by the module.
* See discussion at https://github.com/babylonchain/babylon/pull/132
* for more details.
*
* @generated from rpc babylon.btclightclient.v1.Query.ContainsBytes
*/
export const QueryContainsBytesService = {
typeName: TYPE_NAME,
method: "ContainsBytes",
Request: QueryContainsBytesRequest,
Response: QueryContainsBytesResponse,
} as const;
/**
* MainChain returns the canonical chain
*
* @generated from rpc babylon.btclightclient.v1.Query.MainChain
*/
export const QueryMainChainService = {
typeName: TYPE_NAME,
method: "MainChain",
Request: QueryMainChainRequest,
Response: QueryMainChainResponse,
} as const;
/**
* Tip return best header on canonical chain
*
* @generated from rpc babylon.btclightclient.v1.Query.Tip
*/
export const QueryTipService = {
typeName: TYPE_NAME,
method: "Tip",
Request: QueryTipRequest,
Response: QueryTipResponse,
} as const;
/**
* BaseHeader returns the base BTC header of the chain. This header is defined
* on genesis.
*
* @generated from rpc babylon.btclightclient.v1.Query.BaseHeader
*/
export const QueryBaseHeaderService = {
typeName: TYPE_NAME,
method: "BaseHeader",
Request: QueryBaseHeaderRequest,
Response: QueryBaseHeaderResponse,
} as const;
/**
* HeaderDepth returns the depth of the header in main chain or error if the
* block is not found or it exists on fork
*
* @generated from rpc babylon.btclightclient.v1.Query.HeaderDepth
*/
export const QueryHeaderDepthService = {
typeName: TYPE_NAME,
method: "HeaderDepth",
Request: QueryHeaderDepthRequest,
Response: QueryHeaderDepthResponse,
} as const;

View File

@ -0,0 +1,705 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/btclightclient/v1/query.proto (package babylon.btclightclient.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, protoInt64 } from "@bufbuild/protobuf";
import { Params } from "./params_pb.js";
import { PageRequest, PageResponse } from "../../../cosmos/base/query/v1beta1/pagination_pb.js";
/**
* QueryParamsRequest is the request type for the Query/Params RPC method.
*
* @generated from message babylon.btclightclient.v1.QueryParamsRequest
*/
export class QueryParamsRequest extends Message<QueryParamsRequest> {
constructor(data?: PartialMessage<QueryParamsRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.QueryParamsRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryParamsRequest {
return new QueryParamsRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryParamsRequest {
return new QueryParamsRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryParamsRequest {
return new QueryParamsRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryParamsRequest | PlainMessage<QueryParamsRequest> | undefined, b: QueryParamsRequest | PlainMessage<QueryParamsRequest> | undefined): boolean {
return proto3.util.equals(QueryParamsRequest, a, b);
}
}
/**
* QueryParamsResponse is the response type for the Query/Params RPC method.
*
* @generated from message babylon.btclightclient.v1.QueryParamsResponse
*/
export class QueryParamsResponse extends Message<QueryParamsResponse> {
/**
* params holds all the parameters of this module.
*
* @generated from field: babylon.btclightclient.v1.Params params = 1;
*/
params?: Params;
constructor(data?: PartialMessage<QueryParamsResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.QueryParamsResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "params", kind: "message", T: Params },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryParamsResponse {
return new QueryParamsResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryParamsResponse {
return new QueryParamsResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryParamsResponse {
return new QueryParamsResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryParamsResponse | PlainMessage<QueryParamsResponse> | undefined, b: QueryParamsResponse | PlainMessage<QueryParamsResponse> | undefined): boolean {
return proto3.util.equals(QueryParamsResponse, a, b);
}
}
/**
* QueryHashesRequest is request type for the Query/Hashes RPC method.
* It involves retrieving all hashes that are maintained by the module.
*
* @generated from message babylon.btclightclient.v1.QueryHashesRequest
*/
export class QueryHashesRequest extends Message<QueryHashesRequest> {
/**
* @generated from field: cosmos.base.query.v1beta1.PageRequest pagination = 1;
*/
pagination?: PageRequest;
constructor(data?: PartialMessage<QueryHashesRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.QueryHashesRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "pagination", kind: "message", T: PageRequest },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryHashesRequest {
return new QueryHashesRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryHashesRequest {
return new QueryHashesRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryHashesRequest {
return new QueryHashesRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryHashesRequest | PlainMessage<QueryHashesRequest> | undefined, b: QueryHashesRequest | PlainMessage<QueryHashesRequest> | undefined): boolean {
return proto3.util.equals(QueryHashesRequest, a, b);
}
}
/**
* QueryHashesResponse is response type for the Query/Hashes RPC method.
*
* @generated from message babylon.btclightclient.v1.QueryHashesResponse
*/
export class QueryHashesResponse extends Message<QueryHashesResponse> {
/**
* @generated from field: repeated bytes hashes = 1;
*/
hashes: Uint8Array[] = [];
/**
* @generated from field: cosmos.base.query.v1beta1.PageResponse pagination = 2;
*/
pagination?: PageResponse;
constructor(data?: PartialMessage<QueryHashesResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.QueryHashesResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "hashes", kind: "scalar", T: 12 /* ScalarType.BYTES */, repeated: true },
{ no: 2, name: "pagination", kind: "message", T: PageResponse },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryHashesResponse {
return new QueryHashesResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryHashesResponse {
return new QueryHashesResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryHashesResponse {
return new QueryHashesResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryHashesResponse | PlainMessage<QueryHashesResponse> | undefined, b: QueryHashesResponse | PlainMessage<QueryHashesResponse> | undefined): boolean {
return proto3.util.equals(QueryHashesResponse, a, b);
}
}
/**
* QueryContainsRequest is request type for the Query/Contains RPC method.
* It involves checking whether a hash is maintained by the module.
*
* @generated from message babylon.btclightclient.v1.QueryContainsRequest
*/
export class QueryContainsRequest extends Message<QueryContainsRequest> {
/**
* @generated from field: bytes hash = 1;
*/
hash = new Uint8Array(0);
constructor(data?: PartialMessage<QueryContainsRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.QueryContainsRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "hash", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryContainsRequest {
return new QueryContainsRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryContainsRequest {
return new QueryContainsRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryContainsRequest {
return new QueryContainsRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryContainsRequest | PlainMessage<QueryContainsRequest> | undefined, b: QueryContainsRequest | PlainMessage<QueryContainsRequest> | undefined): boolean {
return proto3.util.equals(QueryContainsRequest, a, b);
}
}
/**
* QueryContainsResponse is response type for the Query/Contains RPC method.
*
* @generated from message babylon.btclightclient.v1.QueryContainsResponse
*/
export class QueryContainsResponse extends Message<QueryContainsResponse> {
/**
* @generated from field: bool contains = 1;
*/
contains = false;
constructor(data?: PartialMessage<QueryContainsResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.QueryContainsResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "contains", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryContainsResponse {
return new QueryContainsResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryContainsResponse {
return new QueryContainsResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryContainsResponse {
return new QueryContainsResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryContainsResponse | PlainMessage<QueryContainsResponse> | undefined, b: QueryContainsResponse | PlainMessage<QueryContainsResponse> | undefined): boolean {
return proto3.util.equals(QueryContainsResponse, a, b);
}
}
/**
* QueryContainsRequest is request type for the temporary Query/ContainsBytes
* RPC method. It involves checking whether a hash is maintained by the module.
*
* @generated from message babylon.btclightclient.v1.QueryContainsBytesRequest
*/
export class QueryContainsBytesRequest extends Message<QueryContainsBytesRequest> {
/**
* @generated from field: bytes hash = 1;
*/
hash = new Uint8Array(0);
constructor(data?: PartialMessage<QueryContainsBytesRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.QueryContainsBytesRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "hash", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryContainsBytesRequest {
return new QueryContainsBytesRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryContainsBytesRequest {
return new QueryContainsBytesRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryContainsBytesRequest {
return new QueryContainsBytesRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryContainsBytesRequest | PlainMessage<QueryContainsBytesRequest> | undefined, b: QueryContainsBytesRequest | PlainMessage<QueryContainsBytesRequest> | undefined): boolean {
return proto3.util.equals(QueryContainsBytesRequest, a, b);
}
}
/**
* QueryContainsResponse is response type for the temporary Query/ContainsBytes
* RPC method.
*
* @generated from message babylon.btclightclient.v1.QueryContainsBytesResponse
*/
export class QueryContainsBytesResponse extends Message<QueryContainsBytesResponse> {
/**
* @generated from field: bool contains = 1;
*/
contains = false;
constructor(data?: PartialMessage<QueryContainsBytesResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.QueryContainsBytesResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "contains", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryContainsBytesResponse {
return new QueryContainsBytesResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryContainsBytesResponse {
return new QueryContainsBytesResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryContainsBytesResponse {
return new QueryContainsBytesResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryContainsBytesResponse | PlainMessage<QueryContainsBytesResponse> | undefined, b: QueryContainsBytesResponse | PlainMessage<QueryContainsBytesResponse> | undefined): boolean {
return proto3.util.equals(QueryContainsBytesResponse, a, b);
}
}
/**
* QueryMainChainRequest is request type for the Query/MainChain RPC method.
* It involves retrieving the canonical chain maintained by the module.
*
* @generated from message babylon.btclightclient.v1.QueryMainChainRequest
*/
export class QueryMainChainRequest extends Message<QueryMainChainRequest> {
/**
* @generated from field: cosmos.base.query.v1beta1.PageRequest pagination = 1;
*/
pagination?: PageRequest;
constructor(data?: PartialMessage<QueryMainChainRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.QueryMainChainRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "pagination", kind: "message", T: PageRequest },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryMainChainRequest {
return new QueryMainChainRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryMainChainRequest {
return new QueryMainChainRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryMainChainRequest {
return new QueryMainChainRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryMainChainRequest | PlainMessage<QueryMainChainRequest> | undefined, b: QueryMainChainRequest | PlainMessage<QueryMainChainRequest> | undefined): boolean {
return proto3.util.equals(QueryMainChainRequest, a, b);
}
}
/**
* QueryMainChainResponse is response type for the Query/MainChain RPC method.
*
* @generated from message babylon.btclightclient.v1.QueryMainChainResponse
*/
export class QueryMainChainResponse extends Message<QueryMainChainResponse> {
/**
* @generated from field: repeated babylon.btclightclient.v1.BTCHeaderInfoResponse headers = 1;
*/
headers: BTCHeaderInfoResponse[] = [];
/**
* @generated from field: cosmos.base.query.v1beta1.PageResponse pagination = 2;
*/
pagination?: PageResponse;
constructor(data?: PartialMessage<QueryMainChainResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.QueryMainChainResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "headers", kind: "message", T: BTCHeaderInfoResponse, repeated: true },
{ no: 2, name: "pagination", kind: "message", T: PageResponse },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryMainChainResponse {
return new QueryMainChainResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryMainChainResponse {
return new QueryMainChainResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryMainChainResponse {
return new QueryMainChainResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryMainChainResponse | PlainMessage<QueryMainChainResponse> | undefined, b: QueryMainChainResponse | PlainMessage<QueryMainChainResponse> | undefined): boolean {
return proto3.util.equals(QueryMainChainResponse, a, b);
}
}
/**
* QueryTipRequest is the request type for the Query/Tip RPC method.
*
* @generated from message babylon.btclightclient.v1.QueryTipRequest
*/
export class QueryTipRequest extends Message<QueryTipRequest> {
constructor(data?: PartialMessage<QueryTipRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.QueryTipRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryTipRequest {
return new QueryTipRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryTipRequest {
return new QueryTipRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryTipRequest {
return new QueryTipRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryTipRequest | PlainMessage<QueryTipRequest> | undefined, b: QueryTipRequest | PlainMessage<QueryTipRequest> | undefined): boolean {
return proto3.util.equals(QueryTipRequest, a, b);
}
}
/**
* QueryTipResponse is the response type for the Query/Tip RPC method.
*
* @generated from message babylon.btclightclient.v1.QueryTipResponse
*/
export class QueryTipResponse extends Message<QueryTipResponse> {
/**
* @generated from field: babylon.btclightclient.v1.BTCHeaderInfoResponse header = 1;
*/
header?: BTCHeaderInfoResponse;
constructor(data?: PartialMessage<QueryTipResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.QueryTipResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "header", kind: "message", T: BTCHeaderInfoResponse },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryTipResponse {
return new QueryTipResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryTipResponse {
return new QueryTipResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryTipResponse {
return new QueryTipResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryTipResponse | PlainMessage<QueryTipResponse> | undefined, b: QueryTipResponse | PlainMessage<QueryTipResponse> | undefined): boolean {
return proto3.util.equals(QueryTipResponse, a, b);
}
}
/**
* QueryBaseHeaderRequest is the request type for the Query/BaseHeader RPC
* method.
*
* @generated from message babylon.btclightclient.v1.QueryBaseHeaderRequest
*/
export class QueryBaseHeaderRequest extends Message<QueryBaseHeaderRequest> {
constructor(data?: PartialMessage<QueryBaseHeaderRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.QueryBaseHeaderRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryBaseHeaderRequest {
return new QueryBaseHeaderRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryBaseHeaderRequest {
return new QueryBaseHeaderRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryBaseHeaderRequest {
return new QueryBaseHeaderRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryBaseHeaderRequest | PlainMessage<QueryBaseHeaderRequest> | undefined, b: QueryBaseHeaderRequest | PlainMessage<QueryBaseHeaderRequest> | undefined): boolean {
return proto3.util.equals(QueryBaseHeaderRequest, a, b);
}
}
/**
* QueryBaseHeaderResponse is the response type for the Query/BaseHeader RPC
* method.
*
* @generated from message babylon.btclightclient.v1.QueryBaseHeaderResponse
*/
export class QueryBaseHeaderResponse extends Message<QueryBaseHeaderResponse> {
/**
* @generated from field: babylon.btclightclient.v1.BTCHeaderInfoResponse header = 1;
*/
header?: BTCHeaderInfoResponse;
constructor(data?: PartialMessage<QueryBaseHeaderResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.QueryBaseHeaderResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "header", kind: "message", T: BTCHeaderInfoResponse },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryBaseHeaderResponse {
return new QueryBaseHeaderResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryBaseHeaderResponse {
return new QueryBaseHeaderResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryBaseHeaderResponse {
return new QueryBaseHeaderResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryBaseHeaderResponse | PlainMessage<QueryBaseHeaderResponse> | undefined, b: QueryBaseHeaderResponse | PlainMessage<QueryBaseHeaderResponse> | undefined): boolean {
return proto3.util.equals(QueryBaseHeaderResponse, a, b);
}
}
/**
* QueryMainChainDepthRequest is the request type for the Query/MainChainDepth RPC
* it contains hex encoded hash of btc block header as parameter
*
* @generated from message babylon.btclightclient.v1.QueryHeaderDepthRequest
*/
export class QueryHeaderDepthRequest extends Message<QueryHeaderDepthRequest> {
/**
* @generated from field: string hash = 1;
*/
hash = "";
constructor(data?: PartialMessage<QueryHeaderDepthRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.QueryHeaderDepthRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "hash", kind: "scalar", T: 9 /* ScalarType.STRING */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryHeaderDepthRequest {
return new QueryHeaderDepthRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryHeaderDepthRequest {
return new QueryHeaderDepthRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryHeaderDepthRequest {
return new QueryHeaderDepthRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryHeaderDepthRequest | PlainMessage<QueryHeaderDepthRequest> | undefined, b: QueryHeaderDepthRequest | PlainMessage<QueryHeaderDepthRequest> | undefined): boolean {
return proto3.util.equals(QueryHeaderDepthRequest, a, b);
}
}
/**
* QueryMainChainDepthResponse is the response type for the Query/MainChainDepth RPC
* it contains depth of the block in main chain
*
* @generated from message babylon.btclightclient.v1.QueryHeaderDepthResponse
*/
export class QueryHeaderDepthResponse extends Message<QueryHeaderDepthResponse> {
/**
* @generated from field: uint64 depth = 1;
*/
depth = protoInt64.zero;
constructor(data?: PartialMessage<QueryHeaderDepthResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.QueryHeaderDepthResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "depth", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryHeaderDepthResponse {
return new QueryHeaderDepthResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryHeaderDepthResponse {
return new QueryHeaderDepthResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryHeaderDepthResponse {
return new QueryHeaderDepthResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryHeaderDepthResponse | PlainMessage<QueryHeaderDepthResponse> | undefined, b: QueryHeaderDepthResponse | PlainMessage<QueryHeaderDepthResponse> | undefined): boolean {
return proto3.util.equals(QueryHeaderDepthResponse, a, b);
}
}
/**
* BTCHeaderInfoResponse is a structure that contains all relevant information about a
* BTC header response
* - Full header as string hex.
* - Header hash for easy retrieval as string hex.
* - Height of the header in the BTC chain.
* - Total work spent on the header. This is the sum of the work corresponding
* to the header Bits field
* and the total work of the header.
*
* @generated from message babylon.btclightclient.v1.BTCHeaderInfoResponse
*/
export class BTCHeaderInfoResponse extends Message<BTCHeaderInfoResponse> {
/**
* @generated from field: string header_hex = 1;
*/
headerHex = "";
/**
* @generated from field: string hash_hex = 2;
*/
hashHex = "";
/**
* @generated from field: uint64 height = 3;
*/
height = protoInt64.zero;
/**
* Work is the sdkmath.Uint as string.
*
* @generated from field: string work = 4;
*/
work = "";
constructor(data?: PartialMessage<BTCHeaderInfoResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.BTCHeaderInfoResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "header_hex", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "hash_hex", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 4, name: "work", kind: "scalar", T: 9 /* ScalarType.STRING */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BTCHeaderInfoResponse {
return new BTCHeaderInfoResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BTCHeaderInfoResponse {
return new BTCHeaderInfoResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BTCHeaderInfoResponse {
return new BTCHeaderInfoResponse().fromJsonString(jsonString, options);
}
static equals(a: BTCHeaderInfoResponse | PlainMessage<BTCHeaderInfoResponse> | undefined, b: BTCHeaderInfoResponse | PlainMessage<BTCHeaderInfoResponse> | undefined): boolean {
return proto3.util.equals(BTCHeaderInfoResponse, a, b);
}
}

View File

@ -0,0 +1,33 @@
// @generated by protoc-gen-cosmes v0.0.1 with parameter "target=ts"
// @generated from file babylon/btclightclient/v1/tx.proto (package babylon.btclightclient.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import { MsgInsertHeaders, MsgInsertHeadersResponse, MsgUpdateParams, MsgUpdateParamsResponse } from "./tx_pb.js";
const TYPE_NAME = "babylon.btclightclient.v1.Msg";
/**
* InsertHeaders adds a batch of headers to the BTC light client chain
*
* @generated from rpc babylon.btclightclient.v1.Msg.InsertHeaders
*/
export const MsgInsertHeadersService = {
typeName: TYPE_NAME,
method: "InsertHeaders",
Request: MsgInsertHeaders,
Response: MsgInsertHeadersResponse,
} as const;
/**
* UpdateParams defines a method for updating btc light client module parameters.
*
* @generated from rpc babylon.btclightclient.v1.Msg.UpdateParams
*/
export const MsgUpdateParamsService = {
typeName: TYPE_NAME,
method: "UpdateParams",
Request: MsgUpdateParams,
Response: MsgUpdateParamsResponse,
} as const;

View File

@ -0,0 +1,174 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/btclightclient/v1/tx.proto (package babylon.btclightclient.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3 } from "@bufbuild/protobuf";
import { Params } from "./params_pb.js";
/**
* MsgInsertHeaders defines the message for multiple incoming header bytes
*
* @generated from message babylon.btclightclient.v1.MsgInsertHeaders
*/
export class MsgInsertHeaders extends Message<MsgInsertHeaders> {
/**
* @generated from field: string signer = 1;
*/
signer = "";
/**
* @generated from field: repeated bytes headers = 2;
*/
headers: Uint8Array[] = [];
constructor(data?: PartialMessage<MsgInsertHeaders>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.MsgInsertHeaders";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "signer", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "headers", kind: "scalar", T: 12 /* ScalarType.BYTES */, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgInsertHeaders {
return new MsgInsertHeaders().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgInsertHeaders {
return new MsgInsertHeaders().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgInsertHeaders {
return new MsgInsertHeaders().fromJsonString(jsonString, options);
}
static equals(a: MsgInsertHeaders | PlainMessage<MsgInsertHeaders> | undefined, b: MsgInsertHeaders | PlainMessage<MsgInsertHeaders> | undefined): boolean {
return proto3.util.equals(MsgInsertHeaders, a, b);
}
}
/**
* MsgInsertHeadersResponse defines the response for the InsertHeaders transaction
*
* @generated from message babylon.btclightclient.v1.MsgInsertHeadersResponse
*/
export class MsgInsertHeadersResponse extends Message<MsgInsertHeadersResponse> {
constructor(data?: PartialMessage<MsgInsertHeadersResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.MsgInsertHeadersResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgInsertHeadersResponse {
return new MsgInsertHeadersResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgInsertHeadersResponse {
return new MsgInsertHeadersResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgInsertHeadersResponse {
return new MsgInsertHeadersResponse().fromJsonString(jsonString, options);
}
static equals(a: MsgInsertHeadersResponse | PlainMessage<MsgInsertHeadersResponse> | undefined, b: MsgInsertHeadersResponse | PlainMessage<MsgInsertHeadersResponse> | undefined): boolean {
return proto3.util.equals(MsgInsertHeadersResponse, a, b);
}
}
/**
* MsgUpdateParams defines a message for updating btc light client module parameters.
*
* @generated from message babylon.btclightclient.v1.MsgUpdateParams
*/
export class MsgUpdateParams extends Message<MsgUpdateParams> {
/**
* authority is the address of the governance account.
* just FYI: cosmos.AddressString marks that this field should use type alias
* for AddressString instead of string, but the functionality is not yet implemented
* in cosmos-proto
*
* @generated from field: string authority = 1;
*/
authority = "";
/**
* params defines the btc light client parameters to update.
*
* NOTE: All parameters must be supplied.
*
* @generated from field: babylon.btclightclient.v1.Params params = 2;
*/
params?: Params;
constructor(data?: PartialMessage<MsgUpdateParams>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.MsgUpdateParams";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "authority", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "params", kind: "message", T: Params },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgUpdateParams {
return new MsgUpdateParams().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgUpdateParams {
return new MsgUpdateParams().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgUpdateParams {
return new MsgUpdateParams().fromJsonString(jsonString, options);
}
static equals(a: MsgUpdateParams | PlainMessage<MsgUpdateParams> | undefined, b: MsgUpdateParams | PlainMessage<MsgUpdateParams> | undefined): boolean {
return proto3.util.equals(MsgUpdateParams, a, b);
}
}
/**
* MsgUpdateParamsResponse is the response to the MsgUpdateParams message.
*
* @generated from message babylon.btclightclient.v1.MsgUpdateParamsResponse
*/
export class MsgUpdateParamsResponse extends Message<MsgUpdateParamsResponse> {
constructor(data?: PartialMessage<MsgUpdateParamsResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btclightclient.v1.MsgUpdateParamsResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgUpdateParamsResponse {
return new MsgUpdateParamsResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgUpdateParamsResponse {
return new MsgUpdateParamsResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgUpdateParamsResponse {
return new MsgUpdateParamsResponse().fromJsonString(jsonString, options);
}
static equals(a: MsgUpdateParamsResponse | PlainMessage<MsgUpdateParamsResponse> | undefined, b: MsgUpdateParamsResponse | PlainMessage<MsgUpdateParamsResponse> | undefined): boolean {
return proto3.util.equals(MsgUpdateParamsResponse, a, b);
}
}

View File

@ -0,0 +1,723 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/btcstaking/v1/btcstaking.proto (package babylon.btcstaking.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, protoInt64 } from "@bufbuild/protobuf";
import { Description } from "../../../cosmos/staking/v1beta1/staking_pb.js";
import { PubKey } from "../../../cosmos/crypto/secp256k1/keys_pb.js";
import { ProofOfPossession } from "./pop_pb.js";
/**
* BTCDelegationStatus is the status of a delegation. The state transition path is
* PENDING -> ACTIVE -> UNBONDED with two possibilities:
* 1. the typical path when timelock of staking transaction expires.
* 2. the path when staker requests early undelegation through MsgBTCUndelegate message.
*
* @generated from enum babylon.btcstaking.v1.BTCDelegationStatus
*/
export enum BTCDelegationStatus {
/**
* PENDING defines a delegation that is waiting for covenant signatures to become active.
*
* @generated from enum value: PENDING = 0;
*/
PENDING = 0,
/**
* ACTIVE defines a delegation that has voting power
*
* @generated from enum value: ACTIVE = 1;
*/
ACTIVE = 1,
/**
* UNBONDED defines a delegation no longer has voting power:
* - either reaching the end of staking transaction timelock
* - or receiving unbonding tx with signatures from staker and covenant committee
*
* @generated from enum value: UNBONDED = 2;
*/
UNBONDED = 2,
/**
* ANY is any of the above status
*
* @generated from enum value: ANY = 3;
*/
ANY = 3,
}
// Retrieve enum metadata with: proto3.getEnumType(BTCDelegationStatus)
proto3.util.setEnumType(BTCDelegationStatus, "babylon.btcstaking.v1.BTCDelegationStatus", [
{ no: 0, name: "PENDING" },
{ no: 1, name: "ACTIVE" },
{ no: 2, name: "UNBONDED" },
{ no: 3, name: "ANY" },
]);
/**
* FinalityProvider defines a finality provider
*
* @generated from message babylon.btcstaking.v1.FinalityProvider
*/
export class FinalityProvider extends Message<FinalityProvider> {
/**
* description defines the description terms for the finality provider.
*
* @generated from field: cosmos.staking.v1beta1.Description description = 1;
*/
description?: Description;
/**
* commission defines the commission rate of the finality provider.
*
* @generated from field: string commission = 2;
*/
commission = "";
/**
* babylon_pk is the Babylon secp256k1 PK of this finality provider
*
* @generated from field: cosmos.crypto.secp256k1.PubKey babylon_pk = 3;
*/
babylonPk?: PubKey;
/**
* btc_pk is the Bitcoin secp256k1 PK of this finality provider
* the PK follows encoding in BIP-340 spec
*
* @generated from field: bytes btc_pk = 4;
*/
btcPk = new Uint8Array(0);
/**
* pop is the proof of possession of babylon_pk and btc_pk
*
* @generated from field: babylon.btcstaking.v1.ProofOfPossession pop = 5;
*/
pop?: ProofOfPossession;
/**
* slashed_babylon_height indicates the Babylon height when
* the finality provider is slashed.
* if it's 0 then the finality provider is not slashed
*
* @generated from field: uint64 slashed_babylon_height = 6;
*/
slashedBabylonHeight = protoInt64.zero;
/**
* slashed_btc_height indicates the BTC height when
* the finality provider is slashed.
* if it's 0 then the finality provider is not slashed
*
* @generated from field: uint64 slashed_btc_height = 7;
*/
slashedBtcHeight = protoInt64.zero;
constructor(data?: PartialMessage<FinalityProvider>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.FinalityProvider";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "description", kind: "message", T: Description },
{ no: 2, name: "commission", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "babylon_pk", kind: "message", T: PubKey },
{ no: 4, name: "btc_pk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 5, name: "pop", kind: "message", T: ProofOfPossession },
{ no: 6, name: "slashed_babylon_height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 7, name: "slashed_btc_height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): FinalityProvider {
return new FinalityProvider().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): FinalityProvider {
return new FinalityProvider().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): FinalityProvider {
return new FinalityProvider().fromJsonString(jsonString, options);
}
static equals(a: FinalityProvider | PlainMessage<FinalityProvider> | undefined, b: FinalityProvider | PlainMessage<FinalityProvider> | undefined): boolean {
return proto3.util.equals(FinalityProvider, a, b);
}
}
/**
* FinalityProviderWithMeta wraps the FinalityProvider with metadata.
*
* @generated from message babylon.btcstaking.v1.FinalityProviderWithMeta
*/
export class FinalityProviderWithMeta extends Message<FinalityProviderWithMeta> {
/**
* btc_pk is the Bitcoin secp256k1 PK of thisfinality provider
* the PK follows encoding in BIP-340 spec
*
* @generated from field: bytes btc_pk = 1;
*/
btcPk = new Uint8Array(0);
/**
* height is the queried Babylon height
*
* @generated from field: uint64 height = 2;
*/
height = protoInt64.zero;
/**
* voting_power is the voting power of this finality provider at the given height
*
* @generated from field: uint64 voting_power = 3;
*/
votingPower = protoInt64.zero;
/**
* slashed_babylon_height indicates the Babylon height when
* the finality provider is slashed.
* if it's 0 then the finality provider is not slashed
*
* @generated from field: uint64 slashed_babylon_height = 4;
*/
slashedBabylonHeight = protoInt64.zero;
/**
* slashed_btc_height indicates the BTC height when
* the finality provider is slashed.
* if it's 0 then the finality provider is not slashed
*
* @generated from field: uint64 slashed_btc_height = 5;
*/
slashedBtcHeight = protoInt64.zero;
constructor(data?: PartialMessage<FinalityProviderWithMeta>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.FinalityProviderWithMeta";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "btc_pk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 2, name: "height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 3, name: "voting_power", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 4, name: "slashed_babylon_height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 5, name: "slashed_btc_height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): FinalityProviderWithMeta {
return new FinalityProviderWithMeta().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): FinalityProviderWithMeta {
return new FinalityProviderWithMeta().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): FinalityProviderWithMeta {
return new FinalityProviderWithMeta().fromJsonString(jsonString, options);
}
static equals(a: FinalityProviderWithMeta | PlainMessage<FinalityProviderWithMeta> | undefined, b: FinalityProviderWithMeta | PlainMessage<FinalityProviderWithMeta> | undefined): boolean {
return proto3.util.equals(FinalityProviderWithMeta, a, b);
}
}
/**
* BTCDelegation defines a BTC delegation
*
* @generated from message babylon.btcstaking.v1.BTCDelegation
*/
export class BTCDelegation extends Message<BTCDelegation> {
/**
* babylon_pk is the Babylon secp256k1 PK of this BTC delegation
*
* @generated from field: cosmos.crypto.secp256k1.PubKey babylon_pk = 1;
*/
babylonPk?: PubKey;
/**
* btc_pk is the Bitcoin secp256k1 PK of this BTC delegation
* the PK follows encoding in BIP-340 spec
*
* @generated from field: bytes btc_pk = 2;
*/
btcPk = new Uint8Array(0);
/**
* pop is the proof of possession of babylon_pk and btc_pk
*
* @generated from field: babylon.btcstaking.v1.ProofOfPossession pop = 3;
*/
pop?: ProofOfPossession;
/**
* fp_btc_pk_list is the list of BIP-340 PKs of the finality providers that
* this BTC delegation delegates to
* If there is more than 1 PKs, then this means the delegation is restaked
* to multiple finality providers
*
* @generated from field: repeated bytes fp_btc_pk_list = 4;
*/
fpBtcPkList: Uint8Array[] = [];
/**
* start_height is the start BTC height of the BTC delegation
* it is the start BTC height of the timelock
*
* @generated from field: uint64 start_height = 5;
*/
startHeight = protoInt64.zero;
/**
* end_height is the end height of the BTC delegation
* it is the end BTC height of the timelock - w
*
* @generated from field: uint64 end_height = 6;
*/
endHeight = protoInt64.zero;
/**
* total_sat is the total amount of BTC stakes in this delegation
* quantified in satoshi
*
* @generated from field: uint64 total_sat = 7;
*/
totalSat = protoInt64.zero;
/**
* staking_tx is the staking tx
*
* @generated from field: bytes staking_tx = 8;
*/
stakingTx = new Uint8Array(0);
/**
* staking_output_idx is the index of the staking output in the staking tx
*
* @generated from field: uint32 staking_output_idx = 9;
*/
stakingOutputIdx = 0;
/**
* slashing_tx is the slashing tx
* It is partially signed by SK corresponding to btc_pk, but not signed by
* finality provider or covenant yet.
*
* @generated from field: bytes slashing_tx = 10;
*/
slashingTx = new Uint8Array(0);
/**
* delegator_sig is the signature on the slashing tx
* by the delegator (i.e., SK corresponding to btc_pk).
* It will be a part of the witness for the staking tx output.
*
* @generated from field: bytes delegator_sig = 11;
*/
delegatorSig = new Uint8Array(0);
/**
* covenant_sigs is a list of adaptor signatures on the slashing tx
* by each covenant member
* It will be a part of the witness for the staking tx output.
*
* @generated from field: repeated babylon.btcstaking.v1.CovenantAdaptorSignatures covenant_sigs = 12;
*/
covenantSigs: CovenantAdaptorSignatures[] = [];
/**
* unbonding_time describes how long the funds will be locked either in unbonding output
* or slashing change output
*
* @generated from field: uint32 unbonding_time = 13;
*/
unbondingTime = 0;
/**
* btc_undelegation is the information about the early unbonding path of the BTC delegation
*
* @generated from field: babylon.btcstaking.v1.BTCUndelegation btc_undelegation = 14;
*/
btcUndelegation?: BTCUndelegation;
constructor(data?: PartialMessage<BTCDelegation>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.BTCDelegation";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "babylon_pk", kind: "message", T: PubKey },
{ no: 2, name: "btc_pk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 3, name: "pop", kind: "message", T: ProofOfPossession },
{ no: 4, name: "fp_btc_pk_list", kind: "scalar", T: 12 /* ScalarType.BYTES */, repeated: true },
{ no: 5, name: "start_height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 6, name: "end_height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 7, name: "total_sat", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 8, name: "staking_tx", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 9, name: "staking_output_idx", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
{ no: 10, name: "slashing_tx", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 11, name: "delegator_sig", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 12, name: "covenant_sigs", kind: "message", T: CovenantAdaptorSignatures, repeated: true },
{ no: 13, name: "unbonding_time", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
{ no: 14, name: "btc_undelegation", kind: "message", T: BTCUndelegation },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BTCDelegation {
return new BTCDelegation().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BTCDelegation {
return new BTCDelegation().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BTCDelegation {
return new BTCDelegation().fromJsonString(jsonString, options);
}
static equals(a: BTCDelegation | PlainMessage<BTCDelegation> | undefined, b: BTCDelegation | PlainMessage<BTCDelegation> | undefined): boolean {
return proto3.util.equals(BTCDelegation, a, b);
}
}
/**
* BTCUndelegation contains the information about the early unbonding path of the BTC delegation
*
* @generated from message babylon.btcstaking.v1.BTCUndelegation
*/
export class BTCUndelegation extends Message<BTCUndelegation> {
/**
* unbonding_tx is the transaction which will transfer the funds from staking
* output to unbonding output. Unbonding output will usually have lower timelock
* than staking output.
*
* @generated from field: bytes unbonding_tx = 1;
*/
unbondingTx = new Uint8Array(0);
/**
* slashing_tx is the slashing tx for unbonding transactions
* It is partially signed by SK corresponding to btc_pk, but not signed by
* finality provider or covenant yet.
*
* @generated from field: bytes slashing_tx = 2;
*/
slashingTx = new Uint8Array(0);
/**
* delegator_unbonding_sig is the signature on the unbonding tx
* by the delegator (i.e., SK corresponding to btc_pk).
* It effectively proves that the delegator wants to unbond and thus
* Babylon will consider this BTC delegation unbonded. Delegator's BTC
* on Bitcoin will be unbonded after timelock
*
* @generated from field: bytes delegator_unbonding_sig = 3;
*/
delegatorUnbondingSig = new Uint8Array(0);
/**
* delegator_slashing_sig is the signature on the slashing tx
* by the delegator (i.e., SK corresponding to btc_pk).
* It will be a part of the witness for the unbonding tx output.
*
* @generated from field: bytes delegator_slashing_sig = 4;
*/
delegatorSlashingSig = new Uint8Array(0);
/**
* covenant_slashing_sigs is a list of adaptor signatures on the slashing tx
* by each covenant member
* It will be a part of the witness for the staking tx output.
*
* @generated from field: repeated babylon.btcstaking.v1.CovenantAdaptorSignatures covenant_slashing_sigs = 5;
*/
covenantSlashingSigs: CovenantAdaptorSignatures[] = [];
/**
* covenant_unbonding_sig_list is the list of signatures on the unbonding tx
* by covenant members
* It must be provided after processing undelegate message by Babylon
*
* @generated from field: repeated babylon.btcstaking.v1.SignatureInfo covenant_unbonding_sig_list = 6;
*/
covenantUnbondingSigList: SignatureInfo[] = [];
constructor(data?: PartialMessage<BTCUndelegation>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.BTCUndelegation";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "unbonding_tx", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 2, name: "slashing_tx", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 3, name: "delegator_unbonding_sig", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 4, name: "delegator_slashing_sig", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 5, name: "covenant_slashing_sigs", kind: "message", T: CovenantAdaptorSignatures, repeated: true },
{ no: 6, name: "covenant_unbonding_sig_list", kind: "message", T: SignatureInfo, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BTCUndelegation {
return new BTCUndelegation().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BTCUndelegation {
return new BTCUndelegation().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BTCUndelegation {
return new BTCUndelegation().fromJsonString(jsonString, options);
}
static equals(a: BTCUndelegation | PlainMessage<BTCUndelegation> | undefined, b: BTCUndelegation | PlainMessage<BTCUndelegation> | undefined): boolean {
return proto3.util.equals(BTCUndelegation, a, b);
}
}
/**
* BTCDelegatorDelegations is a collection of BTC delegations from the same delegator.
*
* @generated from message babylon.btcstaking.v1.BTCDelegatorDelegations
*/
export class BTCDelegatorDelegations extends Message<BTCDelegatorDelegations> {
/**
* @generated from field: repeated babylon.btcstaking.v1.BTCDelegation dels = 1;
*/
dels: BTCDelegation[] = [];
constructor(data?: PartialMessage<BTCDelegatorDelegations>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.BTCDelegatorDelegations";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "dels", kind: "message", T: BTCDelegation, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BTCDelegatorDelegations {
return new BTCDelegatorDelegations().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BTCDelegatorDelegations {
return new BTCDelegatorDelegations().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BTCDelegatorDelegations {
return new BTCDelegatorDelegations().fromJsonString(jsonString, options);
}
static equals(a: BTCDelegatorDelegations | PlainMessage<BTCDelegatorDelegations> | undefined, b: BTCDelegatorDelegations | PlainMessage<BTCDelegatorDelegations> | undefined): boolean {
return proto3.util.equals(BTCDelegatorDelegations, a, b);
}
}
/**
* BTCDelegatorDelegationIndex is a list of staking tx hashes of BTC delegations from the same delegator.
*
* @generated from message babylon.btcstaking.v1.BTCDelegatorDelegationIndex
*/
export class BTCDelegatorDelegationIndex extends Message<BTCDelegatorDelegationIndex> {
/**
* @generated from field: repeated bytes staking_tx_hash_list = 1;
*/
stakingTxHashList: Uint8Array[] = [];
constructor(data?: PartialMessage<BTCDelegatorDelegationIndex>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.BTCDelegatorDelegationIndex";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "staking_tx_hash_list", kind: "scalar", T: 12 /* ScalarType.BYTES */, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BTCDelegatorDelegationIndex {
return new BTCDelegatorDelegationIndex().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BTCDelegatorDelegationIndex {
return new BTCDelegatorDelegationIndex().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BTCDelegatorDelegationIndex {
return new BTCDelegatorDelegationIndex().fromJsonString(jsonString, options);
}
static equals(a: BTCDelegatorDelegationIndex | PlainMessage<BTCDelegatorDelegationIndex> | undefined, b: BTCDelegatorDelegationIndex | PlainMessage<BTCDelegatorDelegationIndex> | undefined): boolean {
return proto3.util.equals(BTCDelegatorDelegationIndex, a, b);
}
}
/**
* SignatureInfo is a BIP-340 signature together with its signer's BIP-340 PK
*
* @generated from message babylon.btcstaking.v1.SignatureInfo
*/
export class SignatureInfo extends Message<SignatureInfo> {
/**
* @generated from field: bytes pk = 1;
*/
pk = new Uint8Array(0);
/**
* @generated from field: bytes sig = 2;
*/
sig = new Uint8Array(0);
constructor(data?: PartialMessage<SignatureInfo>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.SignatureInfo";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "pk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 2, name: "sig", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): SignatureInfo {
return new SignatureInfo().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): SignatureInfo {
return new SignatureInfo().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): SignatureInfo {
return new SignatureInfo().fromJsonString(jsonString, options);
}
static equals(a: SignatureInfo | PlainMessage<SignatureInfo> | undefined, b: SignatureInfo | PlainMessage<SignatureInfo> | undefined): boolean {
return proto3.util.equals(SignatureInfo, a, b);
}
}
/**
* CovenantAdaptorSignatures is a list adaptor signatures signed by the
* covenant with different finality provider's public keys as encryption keys
*
* @generated from message babylon.btcstaking.v1.CovenantAdaptorSignatures
*/
export class CovenantAdaptorSignatures extends Message<CovenantAdaptorSignatures> {
/**
* cov_pk is the public key of the covenant emulator, used as the public key of the adaptor signature
*
* @generated from field: bytes cov_pk = 1;
*/
covPk = new Uint8Array(0);
/**
* adaptor_sigs is a list of adaptor signatures, each encrypted by a restaked BTC finality provider's public key
*
* @generated from field: repeated bytes adaptor_sigs = 2;
*/
adaptorSigs: Uint8Array[] = [];
constructor(data?: PartialMessage<CovenantAdaptorSignatures>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.CovenantAdaptorSignatures";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "cov_pk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 2, name: "adaptor_sigs", kind: "scalar", T: 12 /* ScalarType.BYTES */, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): CovenantAdaptorSignatures {
return new CovenantAdaptorSignatures().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): CovenantAdaptorSignatures {
return new CovenantAdaptorSignatures().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): CovenantAdaptorSignatures {
return new CovenantAdaptorSignatures().fromJsonString(jsonString, options);
}
static equals(a: CovenantAdaptorSignatures | PlainMessage<CovenantAdaptorSignatures> | undefined, b: CovenantAdaptorSignatures | PlainMessage<CovenantAdaptorSignatures> | undefined): boolean {
return proto3.util.equals(CovenantAdaptorSignatures, a, b);
}
}
/**
* SelectiveSlashingEvidence is the evidence that the finality provider
* selectively slashed a BTC delegation
* NOTE: it's possible that a slashed finality provider exploits the
* SelectiveSlashingEvidence endpoint while it is actually slashed due to
* equivocation. But such behaviour does not affect the system's security
* or gives any benefit for the adversary
*
* @generated from message babylon.btcstaking.v1.SelectiveSlashingEvidence
*/
export class SelectiveSlashingEvidence extends Message<SelectiveSlashingEvidence> {
/**
* staking_tx_hash is the hash of the staking tx.
* It uniquely identifies a BTC delegation
*
* @generated from field: string staking_tx_hash = 1;
*/
stakingTxHash = "";
/**
* fp_btc_pk is the BTC PK of the finality provider who
* launches the selective slashing offence
*
* @generated from field: bytes fp_btc_pk = 2;
*/
fpBtcPk = new Uint8Array(0);
/**
* recovered_fp_btc_sk is the finality provider's BTC SK recovered from
* the covenant adaptor/Schnorr signature pair. It is the consequence
* of selective slashing.
*
* @generated from field: bytes recovered_fp_btc_sk = 3;
*/
recoveredFpBtcSk = new Uint8Array(0);
constructor(data?: PartialMessage<SelectiveSlashingEvidence>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.SelectiveSlashingEvidence";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "staking_tx_hash", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "fp_btc_pk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 3, name: "recovered_fp_btc_sk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): SelectiveSlashingEvidence {
return new SelectiveSlashingEvidence().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): SelectiveSlashingEvidence {
return new SelectiveSlashingEvidence().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): SelectiveSlashingEvidence {
return new SelectiveSlashingEvidence().fromJsonString(jsonString, options);
}
static equals(a: SelectiveSlashingEvidence | PlainMessage<SelectiveSlashingEvidence> | undefined, b: SelectiveSlashingEvidence | PlainMessage<SelectiveSlashingEvidence> | undefined): boolean {
return proto3.util.equals(SelectiveSlashingEvidence, a, b);
}
}

View File

@ -0,0 +1,245 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/btcstaking/v1/events.proto (package babylon.btcstaking.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3 } from "@bufbuild/protobuf";
import { BTCDelegationStatus, FinalityProvider, SelectiveSlashingEvidence } from "./btcstaking_pb.js";
/**
* EventNewFinalityProvider is the event emitted when a finality provider is created
*
* @generated from message babylon.btcstaking.v1.EventNewFinalityProvider
*/
export class EventNewFinalityProvider extends Message<EventNewFinalityProvider> {
/**
* @generated from field: babylon.btcstaking.v1.FinalityProvider fp = 1;
*/
fp?: FinalityProvider;
constructor(data?: PartialMessage<EventNewFinalityProvider>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.EventNewFinalityProvider";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "fp", kind: "message", T: FinalityProvider },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventNewFinalityProvider {
return new EventNewFinalityProvider().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventNewFinalityProvider {
return new EventNewFinalityProvider().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventNewFinalityProvider {
return new EventNewFinalityProvider().fromJsonString(jsonString, options);
}
static equals(a: EventNewFinalityProvider | PlainMessage<EventNewFinalityProvider> | undefined, b: EventNewFinalityProvider | PlainMessage<EventNewFinalityProvider> | undefined): boolean {
return proto3.util.equals(EventNewFinalityProvider, a, b);
}
}
/**
* EventBTCDelegationStateUpdate is the event emitted when a BTC delegation's state is
* updated. There are the following possible state transitions:
* - non-existing -> pending, which happens upon `MsgCreateBTCDelegation`
* - pending -> active, which happens upon `MsgAddCovenantSigs`
* - active -> unbonded, which happens upon `MsgBTCUndelegate` or upon staking tx timelock expires
*
* @generated from message babylon.btcstaking.v1.EventBTCDelegationStateUpdate
*/
export class EventBTCDelegationStateUpdate extends Message<EventBTCDelegationStateUpdate> {
/**
* staking_tx_hash is the hash of the staking tx.
* It uniquely identifies a BTC delegation
*
* @generated from field: string staking_tx_hash = 1;
*/
stakingTxHash = "";
/**
* new_state is the new state of this BTC delegation
*
* @generated from field: babylon.btcstaking.v1.BTCDelegationStatus new_state = 2;
*/
newState = BTCDelegationStatus.PENDING;
constructor(data?: PartialMessage<EventBTCDelegationStateUpdate>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.EventBTCDelegationStateUpdate";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "staking_tx_hash", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "new_state", kind: "enum", T: proto3.getEnumType(BTCDelegationStatus) },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventBTCDelegationStateUpdate {
return new EventBTCDelegationStateUpdate().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventBTCDelegationStateUpdate {
return new EventBTCDelegationStateUpdate().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventBTCDelegationStateUpdate {
return new EventBTCDelegationStateUpdate().fromJsonString(jsonString, options);
}
static equals(a: EventBTCDelegationStateUpdate | PlainMessage<EventBTCDelegationStateUpdate> | undefined, b: EventBTCDelegationStateUpdate | PlainMessage<EventBTCDelegationStateUpdate> | undefined): boolean {
return proto3.util.equals(EventBTCDelegationStateUpdate, a, b);
}
}
/**
* EventSelectiveSlashing is the event emitted when an adversarial
* finality provider selectively slashes a BTC delegation. This will
* result in slashing of all BTC delegations under this finality provider.
*
* @generated from message babylon.btcstaking.v1.EventSelectiveSlashing
*/
export class EventSelectiveSlashing extends Message<EventSelectiveSlashing> {
/**
* evidence is the evidence of selective slashing
*
* @generated from field: babylon.btcstaking.v1.SelectiveSlashingEvidence evidence = 1;
*/
evidence?: SelectiveSlashingEvidence;
constructor(data?: PartialMessage<EventSelectiveSlashing>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.EventSelectiveSlashing";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "evidence", kind: "message", T: SelectiveSlashingEvidence },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventSelectiveSlashing {
return new EventSelectiveSlashing().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventSelectiveSlashing {
return new EventSelectiveSlashing().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventSelectiveSlashing {
return new EventSelectiveSlashing().fromJsonString(jsonString, options);
}
static equals(a: EventSelectiveSlashing | PlainMessage<EventSelectiveSlashing> | undefined, b: EventSelectiveSlashing | PlainMessage<EventSelectiveSlashing> | undefined): boolean {
return proto3.util.equals(EventSelectiveSlashing, a, b);
}
}
/**
* EventPowerDistUpdate is an event that affects voting power distirbution
* of BTC staking protocol
*
* @generated from message babylon.btcstaking.v1.EventPowerDistUpdate
*/
export class EventPowerDistUpdate extends Message<EventPowerDistUpdate> {
/**
* ev is the event that affects voting power distribution
*
* @generated from oneof babylon.btcstaking.v1.EventPowerDistUpdate.ev
*/
ev: {
/**
* slashed_fp means a finality provider is slashed
*
* @generated from field: babylon.btcstaking.v1.EventPowerDistUpdate.EventSlashedFinalityProvider slashed_fp = 1;
*/
value: EventPowerDistUpdate_EventSlashedFinalityProvider;
case: "slashedFp";
} | {
/**
* btc_del_state_update means a BTC delegation's state is updated
*
* @generated from field: babylon.btcstaking.v1.EventBTCDelegationStateUpdate btc_del_state_update = 2;
*/
value: EventBTCDelegationStateUpdate;
case: "btcDelStateUpdate";
} | { case: undefined; value?: undefined } = { case: undefined };
constructor(data?: PartialMessage<EventPowerDistUpdate>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.EventPowerDistUpdate";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "slashed_fp", kind: "message", T: EventPowerDistUpdate_EventSlashedFinalityProvider, oneof: "ev" },
{ no: 2, name: "btc_del_state_update", kind: "message", T: EventBTCDelegationStateUpdate, oneof: "ev" },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventPowerDistUpdate {
return new EventPowerDistUpdate().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventPowerDistUpdate {
return new EventPowerDistUpdate().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventPowerDistUpdate {
return new EventPowerDistUpdate().fromJsonString(jsonString, options);
}
static equals(a: EventPowerDistUpdate | PlainMessage<EventPowerDistUpdate> | undefined, b: EventPowerDistUpdate | PlainMessage<EventPowerDistUpdate> | undefined): boolean {
return proto3.util.equals(EventPowerDistUpdate, a, b);
}
}
/**
* EventSlashedFinalityProvider defines an event that a finality provider
* is slashed
* TODO: unify with existing slashing events
*
* @generated from message babylon.btcstaking.v1.EventPowerDistUpdate.EventSlashedFinalityProvider
*/
export class EventPowerDistUpdate_EventSlashedFinalityProvider extends Message<EventPowerDistUpdate_EventSlashedFinalityProvider> {
/**
* @generated from field: bytes pk = 1;
*/
pk = new Uint8Array(0);
constructor(data?: PartialMessage<EventPowerDistUpdate_EventSlashedFinalityProvider>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.EventPowerDistUpdate.EventSlashedFinalityProvider";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "pk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventPowerDistUpdate_EventSlashedFinalityProvider {
return new EventPowerDistUpdate_EventSlashedFinalityProvider().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventPowerDistUpdate_EventSlashedFinalityProvider {
return new EventPowerDistUpdate_EventSlashedFinalityProvider().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventPowerDistUpdate_EventSlashedFinalityProvider {
return new EventPowerDistUpdate_EventSlashedFinalityProvider().fromJsonString(jsonString, options);
}
static equals(a: EventPowerDistUpdate_EventSlashedFinalityProvider | PlainMessage<EventPowerDistUpdate_EventSlashedFinalityProvider> | undefined, b: EventPowerDistUpdate_EventSlashedFinalityProvider | PlainMessage<EventPowerDistUpdate_EventSlashedFinalityProvider> | undefined): boolean {
return proto3.util.equals(EventPowerDistUpdate_EventSlashedFinalityProvider, a, b);
}
}

View File

@ -0,0 +1,378 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/btcstaking/v1/genesis.proto (package babylon.btcstaking.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, protoInt64 } from "@bufbuild/protobuf";
import { Params } from "./params_pb.js";
import { BTCDelegation, BTCDelegatorDelegationIndex, FinalityProvider } from "./btcstaking_pb.js";
import { VotingPowerDistCache } from "./incentive_pb.js";
import { EventPowerDistUpdate } from "./events_pb.js";
/**
* GenesisState defines the btcstaking module's genesis state.
*
* @generated from message babylon.btcstaking.v1.GenesisState
*/
export class GenesisState extends Message<GenesisState> {
/**
* @generated from field: babylon.btcstaking.v1.Params params = 1;
*/
params?: Params;
/**
* finality_providers all the finality providers registered.
*
* @generated from field: repeated babylon.btcstaking.v1.FinalityProvider finality_providers = 2;
*/
finalityProviders: FinalityProvider[] = [];
/**
* btc_delegations all the btc delegations in the state.
*
* @generated from field: repeated babylon.btcstaking.v1.BTCDelegation btc_delegations = 3;
*/
btcDelegations: BTCDelegation[] = [];
/**
* voting_powers the voting power of every finality provider at every block height.
*
* @generated from field: repeated babylon.btcstaking.v1.VotingPowerFP voting_powers = 4;
*/
votingPowers: VotingPowerFP[] = [];
/**
* block_height_chains the block height of babylon and bitcoin.
*
* @generated from field: repeated babylon.btcstaking.v1.BlockHeightBbnToBtc block_height_chains = 5;
*/
blockHeightChains: BlockHeightBbnToBtc[] = [];
/**
* btc_delegators contains all the btc delegators with the associated finality provider.
*
* @generated from field: repeated babylon.btcstaking.v1.BTCDelegator btc_delegators = 6;
*/
btcDelegators: BTCDelegator[] = [];
/**
* all the events and its indexes.
*
* @generated from field: repeated babylon.btcstaking.v1.EventIndex events = 7;
*/
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.
*
* @generated from field: repeated babylon.btcstaking.v1.VotingPowerDistCacheBlkHeight vp_dst_cache = 8;
*/
vpDstCache: VotingPowerDistCacheBlkHeight[] = [];
constructor(data?: PartialMessage<GenesisState>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.GenesisState";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "params", kind: "message", T: Params },
{ no: 2, name: "finality_providers", kind: "message", T: FinalityProvider, repeated: true },
{ no: 3, name: "btc_delegations", kind: "message", T: BTCDelegation, repeated: true },
{ no: 4, name: "voting_powers", kind: "message", T: VotingPowerFP, repeated: true },
{ no: 5, name: "block_height_chains", kind: "message", T: BlockHeightBbnToBtc, repeated: true },
{ no: 6, name: "btc_delegators", kind: "message", T: BTCDelegator, repeated: true },
{ no: 7, name: "events", kind: "message", T: EventIndex, repeated: true },
{ no: 8, name: "vp_dst_cache", kind: "message", T: VotingPowerDistCacheBlkHeight, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GenesisState {
return new GenesisState().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GenesisState {
return new GenesisState().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GenesisState {
return new GenesisState().fromJsonString(jsonString, options);
}
static equals(a: GenesisState | PlainMessage<GenesisState> | undefined, b: GenesisState | PlainMessage<GenesisState> | undefined): boolean {
return proto3.util.equals(GenesisState, a, b);
}
}
/**
* VotingPowerFP contains the information about the voting power
* of an finality provider in a specific block height.
*
* @generated from message babylon.btcstaking.v1.VotingPowerFP
*/
export class VotingPowerFP extends Message<VotingPowerFP> {
/**
* block_height is the height of the block the voting power was stored.
*
* @generated from field: uint64 block_height = 1;
*/
blockHeight = protoInt64.zero;
/**
* fp_btc_pk the finality provider btc public key.
*
* @generated from field: bytes fp_btc_pk = 2;
*/
fpBtcPk = new Uint8Array(0);
/**
* voting_power is the power of the finality provider at this specific block height.
*
* @generated from field: uint64 voting_power = 3;
*/
votingPower = protoInt64.zero;
constructor(data?: PartialMessage<VotingPowerFP>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.VotingPowerFP";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "block_height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 2, name: "fp_btc_pk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 3, name: "voting_power", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): VotingPowerFP {
return new VotingPowerFP().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): VotingPowerFP {
return new VotingPowerFP().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): VotingPowerFP {
return new VotingPowerFP().fromJsonString(jsonString, options);
}
static equals(a: VotingPowerFP | PlainMessage<VotingPowerFP> | undefined, b: VotingPowerFP | PlainMessage<VotingPowerFP> | undefined): boolean {
return proto3.util.equals(VotingPowerFP, a, b);
}
}
/**
* VotingPowerDistCacheBlkHeight the total voting power of the finality providers at one specific block height
*
* @generated from message babylon.btcstaking.v1.VotingPowerDistCacheBlkHeight
*/
export class VotingPowerDistCacheBlkHeight extends Message<VotingPowerDistCacheBlkHeight> {
/**
* block_height is the height of the block the voting power distribution cached was stored.
*
* @generated from field: uint64 block_height = 1;
*/
blockHeight = protoInt64.zero;
/**
* vp_distribution the finality providers distribution cache at that height.
*
* @generated from field: babylon.btcstaking.v1.VotingPowerDistCache vp_distribution = 2;
*/
vpDistribution?: VotingPowerDistCache;
constructor(data?: PartialMessage<VotingPowerDistCacheBlkHeight>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.VotingPowerDistCacheBlkHeight";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "block_height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 2, name: "vp_distribution", kind: "message", T: VotingPowerDistCache },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): VotingPowerDistCacheBlkHeight {
return new VotingPowerDistCacheBlkHeight().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): VotingPowerDistCacheBlkHeight {
return new VotingPowerDistCacheBlkHeight().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): VotingPowerDistCacheBlkHeight {
return new VotingPowerDistCacheBlkHeight().fromJsonString(jsonString, options);
}
static equals(a: VotingPowerDistCacheBlkHeight | PlainMessage<VotingPowerDistCacheBlkHeight> | undefined, b: VotingPowerDistCacheBlkHeight | PlainMessage<VotingPowerDistCacheBlkHeight> | undefined): boolean {
return proto3.util.equals(VotingPowerDistCacheBlkHeight, a, b);
}
}
/**
* BlockHeightBbnToBtc stores the btc <-> bbn block.
*
* @generated from message babylon.btcstaking.v1.BlockHeightBbnToBtc
*/
export class BlockHeightBbnToBtc extends Message<BlockHeightBbnToBtc> {
/**
* block_height_bbn is the height of the block in the babylon chain.
*
* @generated from field: uint64 block_height_bbn = 1;
*/
blockHeightBbn = protoInt64.zero;
/**
* block_height_btc is the height of the block in the BTC.
*
* @generated from field: uint64 block_height_btc = 2;
*/
blockHeightBtc = protoInt64.zero;
constructor(data?: PartialMessage<BlockHeightBbnToBtc>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.BlockHeightBbnToBtc";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "block_height_bbn", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 2, name: "block_height_btc", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BlockHeightBbnToBtc {
return new BlockHeightBbnToBtc().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BlockHeightBbnToBtc {
return new BlockHeightBbnToBtc().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BlockHeightBbnToBtc {
return new BlockHeightBbnToBtc().fromJsonString(jsonString, options);
}
static equals(a: BlockHeightBbnToBtc | PlainMessage<BlockHeightBbnToBtc> | undefined, b: BlockHeightBbnToBtc | PlainMessage<BlockHeightBbnToBtc> | undefined): boolean {
return proto3.util.equals(BlockHeightBbnToBtc, a, b);
}
}
/**
* BTCDelegator BTC delegator information with the associated finality provider.
*
* @generated from message babylon.btcstaking.v1.BTCDelegator
*/
export class BTCDelegator extends Message<BTCDelegator> {
/**
* idx the btc delegator index.
*
* @generated from field: babylon.btcstaking.v1.BTCDelegatorDelegationIndex idx = 1;
*/
idx?: BTCDelegatorDelegationIndex;
/**
* fp_btc_pk the finality provider btc public key.
*
* @generated from field: bytes fp_btc_pk = 2;
*/
fpBtcPk = new Uint8Array(0);
/**
* del_btc_pk the delegator btc public key.
*
* @generated from field: bytes del_btc_pk = 3;
*/
delBtcPk = new Uint8Array(0);
constructor(data?: PartialMessage<BTCDelegator>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.BTCDelegator";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "idx", kind: "message", T: BTCDelegatorDelegationIndex },
{ no: 2, name: "fp_btc_pk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 3, name: "del_btc_pk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BTCDelegator {
return new BTCDelegator().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BTCDelegator {
return new BTCDelegator().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BTCDelegator {
return new BTCDelegator().fromJsonString(jsonString, options);
}
static equals(a: BTCDelegator | PlainMessage<BTCDelegator> | undefined, b: BTCDelegator | PlainMessage<BTCDelegator> | undefined): boolean {
return proto3.util.equals(BTCDelegator, a, b);
}
}
/**
* EventIndex contains the event and its index.
*
* @generated from message babylon.btcstaking.v1.EventIndex
*/
export class EventIndex extends Message<EventIndex> {
/**
* idx is the index the event was stored.
*
* @generated from field: uint64 idx = 1;
*/
idx = protoInt64.zero;
/**
* block_height_btc is the height of the block in the BTC chain.
*
* @generated from field: uint64 block_height_btc = 2;
*/
blockHeightBtc = protoInt64.zero;
/**
* event the event stored.
*
* @generated from field: babylon.btcstaking.v1.EventPowerDistUpdate event = 3;
*/
event?: EventPowerDistUpdate;
constructor(data?: PartialMessage<EventIndex>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.EventIndex";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "idx", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 2, name: "block_height_btc", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 3, name: "event", kind: "message", T: EventPowerDistUpdate },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventIndex {
return new EventIndex().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventIndex {
return new EventIndex().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventIndex {
return new EventIndex().fromJsonString(jsonString, options);
}
static equals(a: EventIndex | PlainMessage<EventIndex> | undefined, b: EventIndex | PlainMessage<EventIndex> | undefined): boolean {
return proto3.util.equals(EventIndex, a, b);
}
}

View File

@ -0,0 +1,197 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/btcstaking/v1/incentive.proto (package babylon.btcstaking.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, protoInt64 } from "@bufbuild/protobuf";
import { PubKey } from "../../../cosmos/crypto/secp256k1/keys_pb.js";
/**
* VotingPowerDistCache is the cache for voting power distribution of finality providers
* and their BTC delegations at a height
*
* @generated from message babylon.btcstaking.v1.VotingPowerDistCache
*/
export class VotingPowerDistCache extends Message<VotingPowerDistCache> {
/**
* @generated from field: uint64 total_voting_power = 1;
*/
totalVotingPower = protoInt64.zero;
/**
* finality_providers is a list of finality providers' voting power information
*
* @generated from field: repeated babylon.btcstaking.v1.FinalityProviderDistInfo finality_providers = 2;
*/
finalityProviders: FinalityProviderDistInfo[] = [];
constructor(data?: PartialMessage<VotingPowerDistCache>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.VotingPowerDistCache";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "total_voting_power", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 2, name: "finality_providers", kind: "message", T: FinalityProviderDistInfo, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): VotingPowerDistCache {
return new VotingPowerDistCache().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): VotingPowerDistCache {
return new VotingPowerDistCache().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): VotingPowerDistCache {
return new VotingPowerDistCache().fromJsonString(jsonString, options);
}
static equals(a: VotingPowerDistCache | PlainMessage<VotingPowerDistCache> | undefined, b: VotingPowerDistCache | PlainMessage<VotingPowerDistCache> | undefined): boolean {
return proto3.util.equals(VotingPowerDistCache, a, b);
}
}
/**
* FinalityProviderDistInfo is the reward distribution of a finality provider and its BTC delegations
*
* @generated from message babylon.btcstaking.v1.FinalityProviderDistInfo
*/
export class FinalityProviderDistInfo extends Message<FinalityProviderDistInfo> {
/**
* btc_pk is the Bitcoin secp256k1 PK of this finality provider
* the PK follows encoding in BIP-340 spec
*
* @generated from field: bytes btc_pk = 1;
*/
btcPk = new Uint8Array(0);
/**
* babylon_pk is the Babylon public key of the finality provider
*
* @generated from field: cosmos.crypto.secp256k1.PubKey babylon_pk = 2;
*/
babylonPk?: PubKey;
/**
* commission defines the commission rate of finality provider
*
* @generated from field: string commission = 3;
*/
commission = "";
/**
* total_voting_power is the total voting power of the finality provider
*
* @generated from field: uint64 total_voting_power = 4;
*/
totalVotingPower = protoInt64.zero;
/**
* btc_dels is a list of BTC delegations' voting power information under this finality provider
*
* @generated from field: repeated babylon.btcstaking.v1.BTCDelDistInfo btc_dels = 5;
*/
btcDels: BTCDelDistInfo[] = [];
constructor(data?: PartialMessage<FinalityProviderDistInfo>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.FinalityProviderDistInfo";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "btc_pk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 2, name: "babylon_pk", kind: "message", T: PubKey },
{ no: 3, name: "commission", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 4, name: "total_voting_power", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 5, name: "btc_dels", kind: "message", T: BTCDelDistInfo, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): FinalityProviderDistInfo {
return new FinalityProviderDistInfo().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): FinalityProviderDistInfo {
return new FinalityProviderDistInfo().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): FinalityProviderDistInfo {
return new FinalityProviderDistInfo().fromJsonString(jsonString, options);
}
static equals(a: FinalityProviderDistInfo | PlainMessage<FinalityProviderDistInfo> | undefined, b: FinalityProviderDistInfo | PlainMessage<FinalityProviderDistInfo> | undefined): boolean {
return proto3.util.equals(FinalityProviderDistInfo, a, b);
}
}
/**
* BTCDelDistInfo contains the information related to reward distribution for a BTC delegation
*
* @generated from message babylon.btcstaking.v1.BTCDelDistInfo
*/
export class BTCDelDistInfo extends Message<BTCDelDistInfo> {
/**
* btc_pk is the Bitcoin secp256k1 PK of this BTC delegation
* the PK follows encoding in BIP-340 spec
*
* @generated from field: bytes btc_pk = 1;
*/
btcPk = new Uint8Array(0);
/**
* babylon_pk is the Babylon public key of the BTC delegation
*
* @generated from field: cosmos.crypto.secp256k1.PubKey babylon_pk = 2;
*/
babylonPk?: PubKey;
/**
* staking_tx_hash is the staking tx hash of the BTC delegation
*
* @generated from field: string staking_tx_hash = 3;
*/
stakingTxHash = "";
/**
* voting_power is the voting power of the BTC delegation
*
* @generated from field: uint64 voting_power = 4;
*/
votingPower = protoInt64.zero;
constructor(data?: PartialMessage<BTCDelDistInfo>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.BTCDelDistInfo";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "btc_pk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 2, name: "babylon_pk", kind: "message", T: PubKey },
{ no: 3, name: "staking_tx_hash", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 4, name: "voting_power", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BTCDelDistInfo {
return new BTCDelDistInfo().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BTCDelDistInfo {
return new BTCDelDistInfo().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BTCDelDistInfo {
return new BTCDelDistInfo().fromJsonString(jsonString, options);
}
static equals(a: BTCDelDistInfo | PlainMessage<BTCDelDistInfo> | undefined, b: BTCDelDistInfo | PlainMessage<BTCDelDistInfo> | undefined): boolean {
return proto3.util.equals(BTCDelDistInfo, a, b);
}
}

View File

@ -0,0 +1,123 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/btcstaking/v1/params.proto (package babylon.btcstaking.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, protoInt64 } from "@bufbuild/protobuf";
/**
* Params defines the parameters for the module.
*
* @generated from message babylon.btcstaking.v1.Params
*/
export class Params extends Message<Params> {
/**
* covenant_pks is the list of public keys held by the covenant committee
* each PK follows encoding in BIP-340 spec on Bitcoin
*
* @generated from field: repeated bytes covenant_pks = 1;
*/
covenantPks: Uint8Array[] = [];
/**
* covenant_quorum is the minimum number of signatures needed for the covenant
* multisignature
*
* @generated from field: uint32 covenant_quorum = 2;
*/
covenantQuorum = 0;
/**
* slashing address is the address that the slashed BTC goes to
* the address is in string on Bitcoin
*
* @generated from field: string slashing_address = 3;
*/
slashingAddress = "";
/**
* min_slashing_tx_fee_sat is the minimum amount of tx fee (quantified
* in Satoshi) needed for the pre-signed slashing tx
* TODO: change to satoshi per byte?
*
* @generated from field: int64 min_slashing_tx_fee_sat = 4;
*/
minSlashingTxFeeSat = protoInt64.zero;
/**
* min_commission_rate is the chain-wide minimum commission rate that a finality provider can charge their delegators
*
* @generated from field: string min_commission_rate = 5;
*/
minCommissionRate = "";
/**
* slashing_rate determines the portion of the staked amount to be slashed,
* expressed as a decimal (e.g., 0.5 for 50%).
*
* @generated from field: string slashing_rate = 6;
*/
slashingRate = "";
/**
* max_active_finality_providers is the maximum number of active finality providers in the BTC staking protocol
*
* @generated from field: uint32 max_active_finality_providers = 7;
*/
maxActiveFinalityProviders = 0;
/**
* min_unbonding_time is the minimum time for unbonding transaction timelock in BTC blocks
*
* @generated from field: uint32 min_unbonding_time = 8;
*/
minUnbondingTime = 0;
/**
* min_unbonding_rate is the minimum amount of BTC that are required in unbonding
* output, expressed as a fraction of staking output
* example: if min_unbonding_rate=0.9, then the unbonding output value
* must be at least 90% of staking output, for staking request to be considered
* valid
*
* @generated from field: string min_unbonding_rate = 9;
*/
minUnbondingRate = "";
constructor(data?: PartialMessage<Params>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.Params";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "covenant_pks", kind: "scalar", T: 12 /* ScalarType.BYTES */, repeated: true },
{ no: 2, name: "covenant_quorum", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
{ no: 3, name: "slashing_address", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 4, name: "min_slashing_tx_fee_sat", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
{ no: 5, name: "min_commission_rate", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 6, name: "slashing_rate", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 7, name: "max_active_finality_providers", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
{ no: 8, name: "min_unbonding_time", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
{ no: 9, name: "min_unbonding_rate", kind: "scalar", T: 9 /* ScalarType.STRING */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Params {
return new Params().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Params {
return new Params().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Params {
return new Params().fromJsonString(jsonString, options);
}
static equals(a: Params | PlainMessage<Params> | undefined, b: Params | PlainMessage<Params> | undefined): boolean {
return proto3.util.equals(Params, a, b);
}
}

View File

@ -0,0 +1,153 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/btcstaking/v1/pop.proto (package babylon.btcstaking.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3 } from "@bufbuild/protobuf";
/**
* BTCSigType indicates the type of btc_sig in a pop
*
* @generated from enum babylon.btcstaking.v1.BTCSigType
*/
export enum BTCSigType {
/**
* BIP340 means the btc_sig will follow the BIP-340 encoding
*
* @generated from enum value: BIP340 = 0;
*/
BIP340 = 0,
/**
* BIP322 means the btc_sig will follow the BIP-322 encoding
*
* @generated from enum value: BIP322 = 1;
*/
BIP322 = 1,
/**
* ECDSA means the btc_sig will follow the ECDSA encoding
* ref: https://github.com/okx/js-wallet-sdk/blob/a57c2acbe6ce917c0aa4e951d96c4e562ad58444/packages/coin-bitcoin/src/BtcWallet.ts#L331
*
* @generated from enum value: ECDSA = 2;
*/
ECDSA = 2,
}
// Retrieve enum metadata with: proto3.getEnumType(BTCSigType)
proto3.util.setEnumType(BTCSigType, "babylon.btcstaking.v1.BTCSigType", [
{ no: 0, name: "BIP340" },
{ no: 1, name: "BIP322" },
{ no: 2, name: "ECDSA" },
]);
/**
* ProofOfPossession is the proof of possession that a Babylon secp256k1
* secret key and a Bitcoin secp256k1 secret key are held by the same
* person
*
* @generated from message babylon.btcstaking.v1.ProofOfPossession
*/
export class ProofOfPossession extends Message<ProofOfPossession> {
/**
* btc_sig_type indicates the type of btc_sig in the pop
*
* @generated from field: babylon.btcstaking.v1.BTCSigType btc_sig_type = 1;
*/
btcSigType = BTCSigType.BIP340;
/**
* babylon_sig is the signature generated via sign(sk_babylon, pk_btc)
*
* @generated from field: bytes babylon_sig = 2;
*/
babylonSig = new Uint8Array(0);
/**
* btc_sig is the signature generated via sign(sk_btc, babylon_sig)
* the signature follows encoding in either BIP-340 spec or BIP-322 spec
*
* @generated from field: bytes btc_sig = 3;
*/
btcSig = new Uint8Array(0);
constructor(data?: PartialMessage<ProofOfPossession>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.ProofOfPossession";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "btc_sig_type", kind: "enum", T: proto3.getEnumType(BTCSigType) },
{ no: 2, name: "babylon_sig", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 3, name: "btc_sig", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ProofOfPossession {
return new ProofOfPossession().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ProofOfPossession {
return new ProofOfPossession().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ProofOfPossession {
return new ProofOfPossession().fromJsonString(jsonString, options);
}
static equals(a: ProofOfPossession | PlainMessage<ProofOfPossession> | undefined, b: ProofOfPossession | PlainMessage<ProofOfPossession> | undefined): boolean {
return proto3.util.equals(ProofOfPossession, a, b);
}
}
/**
* BIP322Sig is a BIP-322 signature together with the address corresponding to
* the signer
*
* @generated from message babylon.btcstaking.v1.BIP322Sig
*/
export class BIP322Sig extends Message<BIP322Sig> {
/**
* address is the signer's address
*
* @generated from field: string address = 1;
*/
address = "";
/**
* sig is the actual signature in BIP-322 format
*
* @generated from field: bytes sig = 2;
*/
sig = new Uint8Array(0);
constructor(data?: PartialMessage<BIP322Sig>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.BIP322Sig";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "address", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "sig", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BIP322Sig {
return new BIP322Sig().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BIP322Sig {
return new BIP322Sig().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BIP322Sig {
return new BIP322Sig().fromJsonString(jsonString, options);
}
static equals(a: BIP322Sig | PlainMessage<BIP322Sig> | undefined, b: BIP322Sig | PlainMessage<BIP322Sig> | undefined): boolean {
return proto3.util.equals(BIP322Sig, a, b);
}
}

View File

@ -0,0 +1,130 @@
// @generated by protoc-gen-cosmes v0.0.1 with parameter "target=ts"
// @generated from file babylon/btcstaking/v1/query.proto (package babylon.btcstaking.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import { QueryActivatedHeightRequest, QueryActivatedHeightResponse, QueryActiveFinalityProvidersAtHeightRequest, QueryActiveFinalityProvidersAtHeightResponse, QueryBTCDelegationRequest, QueryBTCDelegationResponse, QueryBTCDelegationsRequest, QueryBTCDelegationsResponse, QueryFinalityProviderCurrentPowerRequest, QueryFinalityProviderCurrentPowerResponse, QueryFinalityProviderDelegationsRequest, QueryFinalityProviderDelegationsResponse, QueryFinalityProviderPowerAtHeightRequest, QueryFinalityProviderPowerAtHeightResponse, QueryFinalityProviderRequest, QueryFinalityProviderResponse, QueryFinalityProvidersRequest, QueryFinalityProvidersResponse, QueryParamsRequest, QueryParamsResponse } from "./query_pb.js";
const TYPE_NAME = "babylon.btcstaking.v1.Query";
/**
* Parameters queries the parameters of the module.
*
* @generated from rpc babylon.btcstaking.v1.Query.Params
*/
export const QueryParamsService = {
typeName: TYPE_NAME,
method: "Params",
Request: QueryParamsRequest,
Response: QueryParamsResponse,
} as const;
/**
* FinalityProviders queries all finality providers
*
* @generated from rpc babylon.btcstaking.v1.Query.FinalityProviders
*/
export const QueryFinalityProvidersService = {
typeName: TYPE_NAME,
method: "FinalityProviders",
Request: QueryFinalityProvidersRequest,
Response: QueryFinalityProvidersResponse,
} as const;
/**
* FinalityProvider info about one finality provider
*
* @generated from rpc babylon.btcstaking.v1.Query.FinalityProvider
*/
export const QueryFinalityProviderService = {
typeName: TYPE_NAME,
method: "FinalityProvider",
Request: QueryFinalityProviderRequest,
Response: QueryFinalityProviderResponse,
} as const;
/**
* BTCDelegations queries all BTC delegations under a given status
*
* @generated from rpc babylon.btcstaking.v1.Query.BTCDelegations
*/
export const QueryBTCDelegationsService = {
typeName: TYPE_NAME,
method: "BTCDelegations",
Request: QueryBTCDelegationsRequest,
Response: QueryBTCDelegationsResponse,
} as const;
/**
* ActiveFinalityProvidersAtHeight queries finality providers with non zero voting power at given height.
*
* @generated from rpc babylon.btcstaking.v1.Query.ActiveFinalityProvidersAtHeight
*/
export const QueryActiveFinalityProvidersAtHeightService = {
typeName: TYPE_NAME,
method: "ActiveFinalityProvidersAtHeight",
Request: QueryActiveFinalityProvidersAtHeightRequest,
Response: QueryActiveFinalityProvidersAtHeightResponse,
} as const;
/**
* FinalityProviderPowerAtHeight queries the voting power of a finality provider at a given height
*
* @generated from rpc babylon.btcstaking.v1.Query.FinalityProviderPowerAtHeight
*/
export const QueryFinalityProviderPowerAtHeightService = {
typeName: TYPE_NAME,
method: "FinalityProviderPowerAtHeight",
Request: QueryFinalityProviderPowerAtHeightRequest,
Response: QueryFinalityProviderPowerAtHeightResponse,
} as const;
/**
* FinalityProviderCurrentPower queries the voting power of a finality provider at the current height
*
* @generated from rpc babylon.btcstaking.v1.Query.FinalityProviderCurrentPower
*/
export const QueryFinalityProviderCurrentPowerService = {
typeName: TYPE_NAME,
method: "FinalityProviderCurrentPower",
Request: QueryFinalityProviderCurrentPowerRequest,
Response: QueryFinalityProviderCurrentPowerResponse,
} as const;
/**
* ActivatedHeight queries the height when BTC staking protocol is activated, i.e., the first height when
* there exists 1 finality provider with voting power
*
* @generated from rpc babylon.btcstaking.v1.Query.ActivatedHeight
*/
export const QueryActivatedHeightService = {
typeName: TYPE_NAME,
method: "ActivatedHeight",
Request: QueryActivatedHeightRequest,
Response: QueryActivatedHeightResponse,
} as const;
/**
* FinalityProviderDelegations queries all BTC delegations of the given finality provider
*
* @generated from rpc babylon.btcstaking.v1.Query.FinalityProviderDelegations
*/
export const QueryFinalityProviderDelegationsService = {
typeName: TYPE_NAME,
method: "FinalityProviderDelegations",
Request: QueryFinalityProviderDelegationsRequest,
Response: QueryFinalityProviderDelegationsResponse,
} as const;
/**
* BTCDelegation retrieves delegation by corresponding staking tx hash
*
* @generated from rpc babylon.btcstaking.v1.Query.BTCDelegation
*/
export const QueryBTCDelegationService = {
typeName: TYPE_NAME,
method: "BTCDelegation",
Request: QueryBTCDelegationRequest,
Response: QueryBTCDelegationResponse,
} as const;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,94 @@
// @generated by protoc-gen-cosmes v0.0.1 with parameter "target=ts"
// @generated from file babylon/btcstaking/v1/tx.proto (package babylon.btcstaking.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import { MsgAddCovenantSigs, MsgAddCovenantSigsResponse, MsgBTCUndelegate, MsgBTCUndelegateResponse, MsgCreateBTCDelegation, MsgCreateBTCDelegationResponse, MsgCreateFinalityProvider, MsgCreateFinalityProviderResponse, MsgEditFinalityProvider, MsgEditFinalityProviderResponse, MsgSelectiveSlashingEvidence, MsgSelectiveSlashingEvidenceResponse, MsgUpdateParams, MsgUpdateParamsResponse } from "./tx_pb.js";
const TYPE_NAME = "babylon.btcstaking.v1.Msg";
/**
* CreateFinalityProvider creates a new finality provider
*
* @generated from rpc babylon.btcstaking.v1.Msg.CreateFinalityProvider
*/
export const MsgCreateFinalityProviderService = {
typeName: TYPE_NAME,
method: "CreateFinalityProvider",
Request: MsgCreateFinalityProvider,
Response: MsgCreateFinalityProviderResponse,
} as const;
/**
* EditFinalityProvider edits an existing finality provider
*
* @generated from rpc babylon.btcstaking.v1.Msg.EditFinalityProvider
*/
export const MsgEditFinalityProviderService = {
typeName: TYPE_NAME,
method: "EditFinalityProvider",
Request: MsgEditFinalityProvider,
Response: MsgEditFinalityProviderResponse,
} as const;
/**
* CreateBTCDelegation creates a new BTC delegation
*
* @generated from rpc babylon.btcstaking.v1.Msg.CreateBTCDelegation
*/
export const MsgCreateBTCDelegationService = {
typeName: TYPE_NAME,
method: "CreateBTCDelegation",
Request: MsgCreateBTCDelegation,
Response: MsgCreateBTCDelegationResponse,
} as const;
/**
* AddCovenantSigs handles signatures from a covenant member
*
* @generated from rpc babylon.btcstaking.v1.Msg.AddCovenantSigs
*/
export const MsgAddCovenantSigsService = {
typeName: TYPE_NAME,
method: "AddCovenantSigs",
Request: MsgAddCovenantSigs,
Response: MsgAddCovenantSigsResponse,
} as const;
/**
* BTCUndelegate handles a signature on unbonding tx from its delegator
*
* @generated from rpc babylon.btcstaking.v1.Msg.BTCUndelegate
*/
export const MsgBTCUndelegateService = {
typeName: TYPE_NAME,
method: "BTCUndelegate",
Request: MsgBTCUndelegate,
Response: MsgBTCUndelegateResponse,
} as const;
/**
* SelectiveSlashingEvidence handles the evidence of selective slashing launched
* by a finality provider
*
* @generated from rpc babylon.btcstaking.v1.Msg.SelectiveSlashingEvidence
*/
export const MsgSelectiveSlashingEvidenceService = {
typeName: TYPE_NAME,
method: "SelectiveSlashingEvidence",
Request: MsgSelectiveSlashingEvidence,
Response: MsgSelectiveSlashingEvidenceResponse,
} as const;
/**
* UpdateParams updates the btcstaking module parameters.
*
* @generated from rpc babylon.btcstaking.v1.Msg.UpdateParams
*/
export const MsgUpdateParamsService = {
typeName: TYPE_NAME,
method: "UpdateParams",
Request: MsgUpdateParams,
Response: MsgUpdateParamsResponse,
} as const;

View File

@ -0,0 +1,812 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/btcstaking/v1/tx.proto (package babylon.btcstaking.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, protoInt64 } from "@bufbuild/protobuf";
import { Description } from "../../../cosmos/staking/v1beta1/staking_pb.js";
import { PubKey } from "../../../cosmos/crypto/secp256k1/keys_pb.js";
import { ProofOfPossession } from "./pop_pb.js";
import { TransactionInfo } from "../../btccheckpoint/v1/btccheckpoint_pb.js";
import { Params } from "./params_pb.js";
/**
* MsgCreateFinalityProvider is the message for creating a finality provider
*
* @generated from message babylon.btcstaking.v1.MsgCreateFinalityProvider
*/
export class MsgCreateFinalityProvider extends Message<MsgCreateFinalityProvider> {
/**
* @generated from field: string signer = 1;
*/
signer = "";
/**
* description defines the description terms for the finality provider
*
* @generated from field: cosmos.staking.v1beta1.Description description = 2;
*/
description?: Description;
/**
* commission defines the commission rate of the finality provider
*
* @generated from field: string commission = 3;
*/
commission = "";
/**
* babylon_pk is the Babylon secp256k1 PK of this finality provider
*
* @generated from field: cosmos.crypto.secp256k1.PubKey babylon_pk = 4;
*/
babylonPk?: PubKey;
/**
* btc_pk is the Bitcoin secp256k1 PK of this finality provider
* the PK follows encoding in BIP-340 spec
*
* @generated from field: bytes btc_pk = 5;
*/
btcPk = new Uint8Array(0);
/**
* pop is the proof of possession of babylon_pk and btc_pk
*
* @generated from field: babylon.btcstaking.v1.ProofOfPossession pop = 6;
*/
pop?: ProofOfPossession;
constructor(data?: PartialMessage<MsgCreateFinalityProvider>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.MsgCreateFinalityProvider";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "signer", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "description", kind: "message", T: Description },
{ no: 3, name: "commission", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 4, name: "babylon_pk", kind: "message", T: PubKey },
{ no: 5, name: "btc_pk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 6, name: "pop", kind: "message", T: ProofOfPossession },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgCreateFinalityProvider {
return new MsgCreateFinalityProvider().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgCreateFinalityProvider {
return new MsgCreateFinalityProvider().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgCreateFinalityProvider {
return new MsgCreateFinalityProvider().fromJsonString(jsonString, options);
}
static equals(a: MsgCreateFinalityProvider | PlainMessage<MsgCreateFinalityProvider> | undefined, b: MsgCreateFinalityProvider | PlainMessage<MsgCreateFinalityProvider> | undefined): boolean {
return proto3.util.equals(MsgCreateFinalityProvider, a, b);
}
}
/**
* MsgCreateFinalityProviderResponse is the response for MsgCreateFinalityProvider
*
* @generated from message babylon.btcstaking.v1.MsgCreateFinalityProviderResponse
*/
export class MsgCreateFinalityProviderResponse extends Message<MsgCreateFinalityProviderResponse> {
constructor(data?: PartialMessage<MsgCreateFinalityProviderResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.MsgCreateFinalityProviderResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgCreateFinalityProviderResponse {
return new MsgCreateFinalityProviderResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgCreateFinalityProviderResponse {
return new MsgCreateFinalityProviderResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgCreateFinalityProviderResponse {
return new MsgCreateFinalityProviderResponse().fromJsonString(jsonString, options);
}
static equals(a: MsgCreateFinalityProviderResponse | PlainMessage<MsgCreateFinalityProviderResponse> | undefined, b: MsgCreateFinalityProviderResponse | PlainMessage<MsgCreateFinalityProviderResponse> | undefined): boolean {
return proto3.util.equals(MsgCreateFinalityProviderResponse, a, b);
}
}
/**
* MsgEditFinalityProvider is the message for editing an existing finality provider
*
* @generated from message babylon.btcstaking.v1.MsgEditFinalityProvider
*/
export class MsgEditFinalityProvider extends Message<MsgEditFinalityProvider> {
/**
* NOTE: this signer needs to correspond to babylon_pk of the finality provider
*
* @generated from field: string signer = 1;
*/
signer = "";
/**
* btc_pk is the Bitcoin secp256k1 PK of the finality provider to be edited
*
* @generated from field: bytes btc_pk = 2;
*/
btcPk = new Uint8Array(0);
/**
* description defines the updated description terms for the finality provider
*
* @generated from field: cosmos.staking.v1beta1.Description description = 3;
*/
description?: Description;
/**
* commission defines the updated commission rate of the finality provider
*
* @generated from field: string commission = 4;
*/
commission = "";
constructor(data?: PartialMessage<MsgEditFinalityProvider>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.MsgEditFinalityProvider";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "signer", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "btc_pk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 3, name: "description", kind: "message", T: Description },
{ no: 4, name: "commission", kind: "scalar", T: 9 /* ScalarType.STRING */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgEditFinalityProvider {
return new MsgEditFinalityProvider().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgEditFinalityProvider {
return new MsgEditFinalityProvider().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgEditFinalityProvider {
return new MsgEditFinalityProvider().fromJsonString(jsonString, options);
}
static equals(a: MsgEditFinalityProvider | PlainMessage<MsgEditFinalityProvider> | undefined, b: MsgEditFinalityProvider | PlainMessage<MsgEditFinalityProvider> | undefined): boolean {
return proto3.util.equals(MsgEditFinalityProvider, a, b);
}
}
/**
* MsgEditFinalityProviderResponse is the response for MsgEditFinalityProvider
*
* @generated from message babylon.btcstaking.v1.MsgEditFinalityProviderResponse
*/
export class MsgEditFinalityProviderResponse extends Message<MsgEditFinalityProviderResponse> {
constructor(data?: PartialMessage<MsgEditFinalityProviderResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.MsgEditFinalityProviderResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgEditFinalityProviderResponse {
return new MsgEditFinalityProviderResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgEditFinalityProviderResponse {
return new MsgEditFinalityProviderResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgEditFinalityProviderResponse {
return new MsgEditFinalityProviderResponse().fromJsonString(jsonString, options);
}
static equals(a: MsgEditFinalityProviderResponse | PlainMessage<MsgEditFinalityProviderResponse> | undefined, b: MsgEditFinalityProviderResponse | PlainMessage<MsgEditFinalityProviderResponse> | undefined): boolean {
return proto3.util.equals(MsgEditFinalityProviderResponse, a, b);
}
}
/**
* MsgCreateBTCDelegation is the message for creating a BTC delegation
*
* @generated from message babylon.btcstaking.v1.MsgCreateBTCDelegation
*/
export class MsgCreateBTCDelegation extends Message<MsgCreateBTCDelegation> {
/**
* @generated from field: string signer = 1;
*/
signer = "";
/**
* babylon_pk is the Babylon secp256k1 PK of this BTC delegation
*
* @generated from field: cosmos.crypto.secp256k1.PubKey babylon_pk = 2;
*/
babylonPk?: PubKey;
/**
* pop is the proof of possession of babylon_pk and btc_pk
*
* @generated from field: babylon.btcstaking.v1.ProofOfPossession pop = 3;
*/
pop?: ProofOfPossession;
/**
* btc_pk is the Bitcoin secp256k1 PK of the BTC delegator
*
* @generated from field: bytes btc_pk = 4;
*/
btcPk = new Uint8Array(0);
/**
* fp_btc_pk_list is the list of Bitcoin secp256k1 PKs of the finality providers, if there is more than one
* finality provider pk it means that delegation is re-staked
*
* @generated from field: repeated bytes fp_btc_pk_list = 5;
*/
fpBtcPkList: Uint8Array[] = [];
/**
* staking_time is the time lock used in staking transaction
*
* @generated from field: uint32 staking_time = 6;
*/
stakingTime = 0;
/**
* staking_value is the amount of satoshis locked in staking output
*
* @generated from field: int64 staking_value = 7;
*/
stakingValue = protoInt64.zero;
/**
* staking_tx is the staking tx along with the merkle proof of inclusion in btc block
*
* @generated from field: babylon.btccheckpoint.v1.TransactionInfo staking_tx = 8;
*/
stakingTx?: TransactionInfo;
/**
* slashing_tx is the slashing tx
* Note that the tx itself does not contain signatures, which are off-chain.
*
* @generated from field: bytes slashing_tx = 9;
*/
slashingTx = new Uint8Array(0);
/**
* delegator_slashing_sig is the signature on the slashing tx by the delegator (i.e., SK corresponding to btc_pk).
* It will be a part of the witness for the staking tx output.
* The staking tx output further needs signatures from covenant and finality provider in
* order to be spendable.
*
* @generated from field: bytes delegator_slashing_sig = 10;
*/
delegatorSlashingSig = new Uint8Array(0);
/**
* unbonding_time is the time lock used when funds are being unbonded. It is be used in:
* - unbonding transaction, time lock spending path
* - staking slashing transaction, change output
* - unbonding slashing transaction, change output
* It must be smaller than math.MaxUInt16 and larger that max(MinUnbondingTime, CheckpointFinalizationTimeout)
*
* @generated from field: uint32 unbonding_time = 11;
*/
unbondingTime = 0;
/**
* fields related to unbonding transaction
* unbonding_tx is a bitcoin unbonding transaction i.e transaction that spends
* staking output and sends it to the unbonding output
*
* @generated from field: bytes unbonding_tx = 12;
*/
unbondingTx = new Uint8Array(0);
/**
* unbonding_value is amount of satoshis locked in unbonding output.
* NOTE: staking_value and unbonding_value could be different because of the difference between the fee for staking tx and that for unbonding
*
* @generated from field: int64 unbonding_value = 13;
*/
unbondingValue = protoInt64.zero;
/**
* unbonding_slashing_tx is the slashing tx which slash unbonding contract
* Note that the tx itself does not contain signatures, which are off-chain.
*
* @generated from field: bytes unbonding_slashing_tx = 14;
*/
unbondingSlashingTx = new Uint8Array(0);
/**
* delegator_unbonding_slashing_sig is the signature on the slashing tx by the delegator (i.e., SK corresponding to btc_pk).
*
* @generated from field: bytes delegator_unbonding_slashing_sig = 15;
*/
delegatorUnbondingSlashingSig = new Uint8Array(0);
constructor(data?: PartialMessage<MsgCreateBTCDelegation>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.MsgCreateBTCDelegation";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "signer", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "babylon_pk", kind: "message", T: PubKey },
{ no: 3, name: "pop", kind: "message", T: ProofOfPossession },
{ no: 4, name: "btc_pk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 5, name: "fp_btc_pk_list", kind: "scalar", T: 12 /* ScalarType.BYTES */, repeated: true },
{ no: 6, name: "staking_time", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
{ no: 7, name: "staking_value", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
{ no: 8, name: "staking_tx", kind: "message", T: TransactionInfo },
{ no: 9, name: "slashing_tx", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 10, name: "delegator_slashing_sig", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 11, name: "unbonding_time", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
{ no: 12, name: "unbonding_tx", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 13, name: "unbonding_value", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
{ no: 14, name: "unbonding_slashing_tx", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 15, name: "delegator_unbonding_slashing_sig", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgCreateBTCDelegation {
return new MsgCreateBTCDelegation().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgCreateBTCDelegation {
return new MsgCreateBTCDelegation().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgCreateBTCDelegation {
return new MsgCreateBTCDelegation().fromJsonString(jsonString, options);
}
static equals(a: MsgCreateBTCDelegation | PlainMessage<MsgCreateBTCDelegation> | undefined, b: MsgCreateBTCDelegation | PlainMessage<MsgCreateBTCDelegation> | undefined): boolean {
return proto3.util.equals(MsgCreateBTCDelegation, a, b);
}
}
/**
* MsgCreateBTCDelegationResponse is the response for MsgCreateBTCDelegation
*
* @generated from message babylon.btcstaking.v1.MsgCreateBTCDelegationResponse
*/
export class MsgCreateBTCDelegationResponse extends Message<MsgCreateBTCDelegationResponse> {
constructor(data?: PartialMessage<MsgCreateBTCDelegationResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.MsgCreateBTCDelegationResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgCreateBTCDelegationResponse {
return new MsgCreateBTCDelegationResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgCreateBTCDelegationResponse {
return new MsgCreateBTCDelegationResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgCreateBTCDelegationResponse {
return new MsgCreateBTCDelegationResponse().fromJsonString(jsonString, options);
}
static equals(a: MsgCreateBTCDelegationResponse | PlainMessage<MsgCreateBTCDelegationResponse> | undefined, b: MsgCreateBTCDelegationResponse | PlainMessage<MsgCreateBTCDelegationResponse> | undefined): boolean {
return proto3.util.equals(MsgCreateBTCDelegationResponse, a, b);
}
}
/**
* MsgAddCovenantSigs is the message for handling signatures from a covenant member
*
* @generated from message babylon.btcstaking.v1.MsgAddCovenantSigs
*/
export class MsgAddCovenantSigs extends Message<MsgAddCovenantSigs> {
/**
* @generated from field: string signer = 1;
*/
signer = "";
/**
* pk is the BTC public key of the covenant member
*
* @generated from field: bytes pk = 2;
*/
pk = new Uint8Array(0);
/**
* staking_tx_hash is the hash of the staking tx.
* It uniquely identifies a BTC delegation
*
* @generated from field: string staking_tx_hash = 3;
*/
stakingTxHash = "";
/**
* sigs is a list of adaptor signatures of the covenant
* the order of sigs should respect the order of finality providers
* of the corresponding delegation
*
* @generated from field: repeated bytes slashing_tx_sigs = 4;
*/
slashingTxSigs: Uint8Array[] = [];
/**
* unbonding_tx_sig is the signature of the covenant on the unbonding tx submitted to babylon
* the signature follows encoding in BIP-340 spec
*
* @generated from field: bytes unbonding_tx_sig = 5;
*/
unbondingTxSig = new Uint8Array(0);
/**
* slashing_unbonding_tx_sigs is a list of adaptor signatures of the covenant
* on slashing tx corresponding to unbonding tx submitted to babylon
* the order of sigs should respect the order of finality providers
* of the corresponding delegation
*
* @generated from field: repeated bytes slashing_unbonding_tx_sigs = 6;
*/
slashingUnbondingTxSigs: Uint8Array[] = [];
constructor(data?: PartialMessage<MsgAddCovenantSigs>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.MsgAddCovenantSigs";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "signer", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "pk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 3, name: "staking_tx_hash", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 4, name: "slashing_tx_sigs", kind: "scalar", T: 12 /* ScalarType.BYTES */, repeated: true },
{ no: 5, name: "unbonding_tx_sig", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 6, name: "slashing_unbonding_tx_sigs", kind: "scalar", T: 12 /* ScalarType.BYTES */, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgAddCovenantSigs {
return new MsgAddCovenantSigs().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgAddCovenantSigs {
return new MsgAddCovenantSigs().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgAddCovenantSigs {
return new MsgAddCovenantSigs().fromJsonString(jsonString, options);
}
static equals(a: MsgAddCovenantSigs | PlainMessage<MsgAddCovenantSigs> | undefined, b: MsgAddCovenantSigs | PlainMessage<MsgAddCovenantSigs> | undefined): boolean {
return proto3.util.equals(MsgAddCovenantSigs, a, b);
}
}
/**
* MsgAddCovenantSigsResponse is the response for MsgAddCovenantSigs
*
* @generated from message babylon.btcstaking.v1.MsgAddCovenantSigsResponse
*/
export class MsgAddCovenantSigsResponse extends Message<MsgAddCovenantSigsResponse> {
constructor(data?: PartialMessage<MsgAddCovenantSigsResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.MsgAddCovenantSigsResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgAddCovenantSigsResponse {
return new MsgAddCovenantSigsResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgAddCovenantSigsResponse {
return new MsgAddCovenantSigsResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgAddCovenantSigsResponse {
return new MsgAddCovenantSigsResponse().fromJsonString(jsonString, options);
}
static equals(a: MsgAddCovenantSigsResponse | PlainMessage<MsgAddCovenantSigsResponse> | undefined, b: MsgAddCovenantSigsResponse | PlainMessage<MsgAddCovenantSigsResponse> | undefined): boolean {
return proto3.util.equals(MsgAddCovenantSigsResponse, a, b);
}
}
/**
* MsgBTCUndelegate is the message for handling signature on unbonding tx
* from its delegator. This signature effectively proves that the delegator
* wants to unbond this BTC delegation
*
* @generated from message babylon.btcstaking.v1.MsgBTCUndelegate
*/
export class MsgBTCUndelegate extends Message<MsgBTCUndelegate> {
/**
* @generated from field: string signer = 1;
*/
signer = "";
/**
* staking_tx_hash is the hash of the staking tx.
* It uniquely identifies a BTC delegation
*
* @generated from field: string staking_tx_hash = 2;
*/
stakingTxHash = "";
/**
* unbonding_tx_sig is the signature of the staker on the unbonding tx submitted to babylon
* the signature follows encoding in BIP-340 spec
*
* @generated from field: bytes unbonding_tx_sig = 3;
*/
unbondingTxSig = new Uint8Array(0);
constructor(data?: PartialMessage<MsgBTCUndelegate>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.MsgBTCUndelegate";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "signer", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "staking_tx_hash", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "unbonding_tx_sig", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgBTCUndelegate {
return new MsgBTCUndelegate().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgBTCUndelegate {
return new MsgBTCUndelegate().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgBTCUndelegate {
return new MsgBTCUndelegate().fromJsonString(jsonString, options);
}
static equals(a: MsgBTCUndelegate | PlainMessage<MsgBTCUndelegate> | undefined, b: MsgBTCUndelegate | PlainMessage<MsgBTCUndelegate> | undefined): boolean {
return proto3.util.equals(MsgBTCUndelegate, a, b);
}
}
/**
* MsgBTCUndelegateResponse is the response for MsgBTCUndelegate
*
* @generated from message babylon.btcstaking.v1.MsgBTCUndelegateResponse
*/
export class MsgBTCUndelegateResponse extends Message<MsgBTCUndelegateResponse> {
constructor(data?: PartialMessage<MsgBTCUndelegateResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.MsgBTCUndelegateResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgBTCUndelegateResponse {
return new MsgBTCUndelegateResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgBTCUndelegateResponse {
return new MsgBTCUndelegateResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgBTCUndelegateResponse {
return new MsgBTCUndelegateResponse().fromJsonString(jsonString, options);
}
static equals(a: MsgBTCUndelegateResponse | PlainMessage<MsgBTCUndelegateResponse> | undefined, b: MsgBTCUndelegateResponse | PlainMessage<MsgBTCUndelegateResponse> | undefined): boolean {
return proto3.util.equals(MsgBTCUndelegateResponse, a, b);
}
}
/**
* MsgSelectiveSlashingEvidence is the message for handling evidence of selective slashing
* launched by a finality provider
*
* @generated from message babylon.btcstaking.v1.MsgSelectiveSlashingEvidence
*/
export class MsgSelectiveSlashingEvidence extends Message<MsgSelectiveSlashingEvidence> {
/**
* @generated from field: string signer = 1;
*/
signer = "";
/**
* staking_tx_hash is the hash of the staking tx.
* It uniquely identifies a BTC delegation
*
* @generated from field: string staking_tx_hash = 2;
*/
stakingTxHash = "";
/**
* recovered_fp_btc_sk is the BTC SK of the finality provider who
* launches the selective slashing offence. The SK is recovered by
* using a covenant adaptor signature and the corresponding Schnorr
* signature
*
* @generated from field: bytes recovered_fp_btc_sk = 3;
*/
recoveredFpBtcSk = new Uint8Array(0);
constructor(data?: PartialMessage<MsgSelectiveSlashingEvidence>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.MsgSelectiveSlashingEvidence";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "signer", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "staking_tx_hash", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "recovered_fp_btc_sk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgSelectiveSlashingEvidence {
return new MsgSelectiveSlashingEvidence().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgSelectiveSlashingEvidence {
return new MsgSelectiveSlashingEvidence().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgSelectiveSlashingEvidence {
return new MsgSelectiveSlashingEvidence().fromJsonString(jsonString, options);
}
static equals(a: MsgSelectiveSlashingEvidence | PlainMessage<MsgSelectiveSlashingEvidence> | undefined, b: MsgSelectiveSlashingEvidence | PlainMessage<MsgSelectiveSlashingEvidence> | undefined): boolean {
return proto3.util.equals(MsgSelectiveSlashingEvidence, a, b);
}
}
/**
* MsgSelectiveSlashingEvidenceResponse is the response for MsgSelectiveSlashingEvidence
*
* @generated from message babylon.btcstaking.v1.MsgSelectiveSlashingEvidenceResponse
*/
export class MsgSelectiveSlashingEvidenceResponse extends Message<MsgSelectiveSlashingEvidenceResponse> {
constructor(data?: PartialMessage<MsgSelectiveSlashingEvidenceResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.MsgSelectiveSlashingEvidenceResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgSelectiveSlashingEvidenceResponse {
return new MsgSelectiveSlashingEvidenceResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgSelectiveSlashingEvidenceResponse {
return new MsgSelectiveSlashingEvidenceResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgSelectiveSlashingEvidenceResponse {
return new MsgSelectiveSlashingEvidenceResponse().fromJsonString(jsonString, options);
}
static equals(a: MsgSelectiveSlashingEvidenceResponse | PlainMessage<MsgSelectiveSlashingEvidenceResponse> | undefined, b: MsgSelectiveSlashingEvidenceResponse | PlainMessage<MsgSelectiveSlashingEvidenceResponse> | undefined): boolean {
return proto3.util.equals(MsgSelectiveSlashingEvidenceResponse, a, b);
}
}
/**
* MsgUpdateParams defines a message for updating btcstaking module parameters.
*
* @generated from message babylon.btcstaking.v1.MsgUpdateParams
*/
export class MsgUpdateParams extends Message<MsgUpdateParams> {
/**
* authority is the address of the governance account.
* just FYI: cosmos.AddressString marks that this field should use type alias
* for AddressString instead of string, but the functionality is not yet implemented
* in cosmos-proto
*
* @generated from field: string authority = 1;
*/
authority = "";
/**
* params defines the finality parameters to update.
*
* NOTE: All parameters must be supplied.
*
* @generated from field: babylon.btcstaking.v1.Params params = 2;
*/
params?: Params;
constructor(data?: PartialMessage<MsgUpdateParams>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.MsgUpdateParams";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "authority", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "params", kind: "message", T: Params },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgUpdateParams {
return new MsgUpdateParams().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgUpdateParams {
return new MsgUpdateParams().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgUpdateParams {
return new MsgUpdateParams().fromJsonString(jsonString, options);
}
static equals(a: MsgUpdateParams | PlainMessage<MsgUpdateParams> | undefined, b: MsgUpdateParams | PlainMessage<MsgUpdateParams> | undefined): boolean {
return proto3.util.equals(MsgUpdateParams, a, b);
}
}
/**
* MsgUpdateParamsResponse is the response to the MsgUpdateParams message.
*
* @generated from message babylon.btcstaking.v1.MsgUpdateParamsResponse
*/
export class MsgUpdateParamsResponse extends Message<MsgUpdateParamsResponse> {
constructor(data?: PartialMessage<MsgUpdateParamsResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.btcstaking.v1.MsgUpdateParamsResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgUpdateParamsResponse {
return new MsgUpdateParamsResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgUpdateParamsResponse {
return new MsgUpdateParamsResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgUpdateParamsResponse {
return new MsgUpdateParamsResponse().fromJsonString(jsonString, options);
}
static equals(a: MsgUpdateParamsResponse | PlainMessage<MsgUpdateParamsResponse> | undefined, b: MsgUpdateParamsResponse | PlainMessage<MsgUpdateParamsResponse> | undefined): boolean {
return proto3.util.equals(MsgUpdateParamsResponse, a, b);
}
}

View File

@ -0,0 +1,287 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/checkpointing/v1/bls_key.proto (package babylon.checkpointing.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, protoInt64 } from "@bufbuild/protobuf";
/**
* BlsKey wraps BLS public key with PoP
*
* @generated from message babylon.checkpointing.v1.BlsKey
*/
export class BlsKey extends Message<BlsKey> {
/**
* pubkey is the BLS public key of a validator
*
* @generated from field: bytes pubkey = 1;
*/
pubkey = new Uint8Array(0);
/**
* pop is the proof-of-possession of the BLS key
*
* @generated from field: babylon.checkpointing.v1.ProofOfPossession pop = 2;
*/
pop?: ProofOfPossession;
constructor(data?: PartialMessage<BlsKey>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.BlsKey";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "pubkey", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 2, name: "pop", kind: "message", T: ProofOfPossession },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BlsKey {
return new BlsKey().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BlsKey {
return new BlsKey().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BlsKey {
return new BlsKey().fromJsonString(jsonString, options);
}
static equals(a: BlsKey | PlainMessage<BlsKey> | undefined, b: BlsKey | PlainMessage<BlsKey> | undefined): boolean {
return proto3.util.equals(BlsKey, a, b);
}
}
/**
* ProofOfPossession defines proof for the ownership of Ed25519 and BLS private
* keys
*
* @generated from message babylon.checkpointing.v1.ProofOfPossession
*/
export class ProofOfPossession extends Message<ProofOfPossession> {
/**
* ed25519_sig is used for verification, ed25519_sig = sign(key = Ed25519_sk,
* data = BLS_pk)
*
* @generated from field: bytes ed25519_sig = 1;
*/
ed25519Sig = new Uint8Array(0);
/**
* bls_sig is the result of PoP, bls_sig = sign(key = BLS_sk, data =
* ed25519_sig)
*
* @generated from field: bytes bls_sig = 2;
*/
blsSig = new Uint8Array(0);
constructor(data?: PartialMessage<ProofOfPossession>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.ProofOfPossession";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "ed25519_sig", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 2, name: "bls_sig", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ProofOfPossession {
return new ProofOfPossession().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ProofOfPossession {
return new ProofOfPossession().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ProofOfPossession {
return new ProofOfPossession().fromJsonString(jsonString, options);
}
static equals(a: ProofOfPossession | PlainMessage<ProofOfPossession> | undefined, b: ProofOfPossession | PlainMessage<ProofOfPossession> | undefined): boolean {
return proto3.util.equals(ProofOfPossession, a, b);
}
}
/**
* ValidatorWithBLSSet defines a set of validators with their BLS public keys
*
* @generated from message babylon.checkpointing.v1.ValidatorWithBlsKeySet
*/
export class ValidatorWithBlsKeySet extends Message<ValidatorWithBlsKeySet> {
/**
* @generated from field: repeated babylon.checkpointing.v1.ValidatorWithBlsKey val_set = 1;
*/
valSet: ValidatorWithBlsKey[] = [];
constructor(data?: PartialMessage<ValidatorWithBlsKeySet>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.ValidatorWithBlsKeySet";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "val_set", kind: "message", T: ValidatorWithBlsKey, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ValidatorWithBlsKeySet {
return new ValidatorWithBlsKeySet().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ValidatorWithBlsKeySet {
return new ValidatorWithBlsKeySet().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ValidatorWithBlsKeySet {
return new ValidatorWithBlsKeySet().fromJsonString(jsonString, options);
}
static equals(a: ValidatorWithBlsKeySet | PlainMessage<ValidatorWithBlsKeySet> | undefined, b: ValidatorWithBlsKeySet | PlainMessage<ValidatorWithBlsKeySet> | undefined): boolean {
return proto3.util.equals(ValidatorWithBlsKeySet, a, b);
}
}
/**
* ValidatorWithBlsKey couples validator address, voting power, and its bls
* public key
*
* @generated from message babylon.checkpointing.v1.ValidatorWithBlsKey
*/
export class ValidatorWithBlsKey extends Message<ValidatorWithBlsKey> {
/**
* validator_address is the address of the validator
*
* @generated from field: string validator_address = 1;
*/
validatorAddress = "";
/**
* bls_pub_key is the BLS public key of the validator
*
* @generated from field: bytes bls_pub_key = 2;
*/
blsPubKey = new Uint8Array(0);
/**
* voting_power is the voting power of the validator at the given epoch
*
* @generated from field: uint64 voting_power = 3;
*/
votingPower = protoInt64.zero;
constructor(data?: PartialMessage<ValidatorWithBlsKey>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.ValidatorWithBlsKey";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "validator_address", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "bls_pub_key", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 3, name: "voting_power", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ValidatorWithBlsKey {
return new ValidatorWithBlsKey().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ValidatorWithBlsKey {
return new ValidatorWithBlsKey().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ValidatorWithBlsKey {
return new ValidatorWithBlsKey().fromJsonString(jsonString, options);
}
static equals(a: ValidatorWithBlsKey | PlainMessage<ValidatorWithBlsKey> | undefined, b: ValidatorWithBlsKey | PlainMessage<ValidatorWithBlsKey> | undefined): boolean {
return proto3.util.equals(ValidatorWithBlsKey, a, b);
}
}
/**
* VoteExtension defines the structure used to create a BLS vote extension.
*
* @generated from message babylon.checkpointing.v1.VoteExtension
*/
export class VoteExtension extends Message<VoteExtension> {
/**
* signer is the address of the vote extension signer
*
* @generated from field: string signer = 1;
*/
signer = "";
/**
* validator_address is the address of the validator
*
* @generated from field: string validator_address = 2;
*/
validatorAddress = "";
/**
* block_hash is the hash of the block that the vote extension is signed over
*
* @generated from field: bytes block_hash = 3;
*/
blockHash = new Uint8Array(0);
/**
* epoch_num is the epoch number of the vote extension
*
* @generated from field: uint64 epoch_num = 4;
*/
epochNum = protoInt64.zero;
/**
* height is the height of the vote extension
*
* @generated from field: uint64 height = 5;
*/
height = protoInt64.zero;
/**
* bls_sig is the BLS signature
*
* @generated from field: bytes bls_sig = 6;
*/
blsSig = new Uint8Array(0);
constructor(data?: PartialMessage<VoteExtension>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.VoteExtension";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "signer", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "validator_address", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "block_hash", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 4, name: "epoch_num", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 5, name: "height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 6, name: "bls_sig", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): VoteExtension {
return new VoteExtension().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): VoteExtension {
return new VoteExtension().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): VoteExtension {
return new VoteExtension().fromJsonString(jsonString, options);
}
static equals(a: VoteExtension | PlainMessage<VoteExtension> | undefined, b: VoteExtension | PlainMessage<VoteExtension> | undefined): boolean {
return proto3.util.equals(VoteExtension, a, b);
}
}

View File

@ -0,0 +1,382 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/checkpointing/v1/checkpoint.proto (package babylon.checkpointing.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, protoInt64, Timestamp } from "@bufbuild/protobuf";
import { ExtendedCommitInfo } from "../../../tendermint/abci/types_pb.js";
/**
* CheckpointStatus is the status of a checkpoint.
*
* @generated from enum babylon.checkpointing.v1.CheckpointStatus
*/
export enum CheckpointStatus {
/**
* ACCUMULATING defines a checkpoint that is awaiting for BLS signatures.
*
* @generated from enum value: CKPT_STATUS_ACCUMULATING = 0;
*/
CKPT_STATUS_ACCUMULATING = 0,
/**
* SEALED defines a checkpoint that has accumulated sufficient BLS signatures.
*
* @generated from enum value: CKPT_STATUS_SEALED = 1;
*/
CKPT_STATUS_SEALED = 1,
/**
* SUBMITTED defines a checkpoint that is included on BTC.
*
* @generated from enum value: CKPT_STATUS_SUBMITTED = 2;
*/
CKPT_STATUS_SUBMITTED = 2,
/**
* CONFIRMED defines a checkpoint that is k-deep on BTC.
*
* @generated from enum value: CKPT_STATUS_CONFIRMED = 3;
*/
CKPT_STATUS_CONFIRMED = 3,
/**
* FINALIZED defines a checkpoint that is w-deep on BTC.
*
* @generated from enum value: CKPT_STATUS_FINALIZED = 4;
*/
CKPT_STATUS_FINALIZED = 4,
}
// Retrieve enum metadata with: proto3.getEnumType(CheckpointStatus)
proto3.util.setEnumType(CheckpointStatus, "babylon.checkpointing.v1.CheckpointStatus", [
{ no: 0, name: "CKPT_STATUS_ACCUMULATING" },
{ no: 1, name: "CKPT_STATUS_SEALED" },
{ no: 2, name: "CKPT_STATUS_SUBMITTED" },
{ no: 3, name: "CKPT_STATUS_CONFIRMED" },
{ no: 4, name: "CKPT_STATUS_FINALIZED" },
]);
/**
* RawCheckpoint wraps the BLS multi sig with metadata
*
* @generated from message babylon.checkpointing.v1.RawCheckpoint
*/
export class RawCheckpoint extends Message<RawCheckpoint> {
/**
* epoch_num defines the epoch number the raw checkpoint is for
*
* @generated from field: uint64 epoch_num = 1;
*/
epochNum = protoInt64.zero;
/**
* block_hash defines the 'BlockID.Hash', which is the hash of
* the block that individual BLS sigs are signed on
*
* @generated from field: bytes block_hash = 2;
*/
blockHash = new Uint8Array(0);
/**
* bitmap defines the bitmap that indicates the signers of the BLS multi sig
*
* @generated from field: bytes bitmap = 3;
*/
bitmap = new Uint8Array(0);
/**
* bls_multi_sig defines the multi sig that is aggregated from individual BLS
* sigs
*
* @generated from field: bytes bls_multi_sig = 4;
*/
blsMultiSig = new Uint8Array(0);
constructor(data?: PartialMessage<RawCheckpoint>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.RawCheckpoint";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "epoch_num", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 2, name: "block_hash", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 3, name: "bitmap", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 4, name: "bls_multi_sig", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): RawCheckpoint {
return new RawCheckpoint().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): RawCheckpoint {
return new RawCheckpoint().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): RawCheckpoint {
return new RawCheckpoint().fromJsonString(jsonString, options);
}
static equals(a: RawCheckpoint | PlainMessage<RawCheckpoint> | undefined, b: RawCheckpoint | PlainMessage<RawCheckpoint> | undefined): boolean {
return proto3.util.equals(RawCheckpoint, a, b);
}
}
/**
* RawCheckpointWithMeta wraps the raw checkpoint with metadata.
*
* @generated from message babylon.checkpointing.v1.RawCheckpointWithMeta
*/
export class RawCheckpointWithMeta extends Message<RawCheckpointWithMeta> {
/**
* @generated from field: babylon.checkpointing.v1.RawCheckpoint ckpt = 1;
*/
ckpt?: RawCheckpoint;
/**
* status defines the status of the checkpoint
*
* @generated from field: babylon.checkpointing.v1.CheckpointStatus status = 2;
*/
status = CheckpointStatus.CKPT_STATUS_ACCUMULATING;
/**
* bls_aggr_pk defines the aggregated BLS public key
*
* @generated from field: bytes bls_aggr_pk = 3;
*/
blsAggrPk = new Uint8Array(0);
/**
* power_sum defines the accumulated voting power for the checkpoint
*
* @generated from field: uint64 power_sum = 4;
*/
powerSum = protoInt64.zero;
/**
* lifecycle defines the lifecycle of this checkpoint, i.e., each state
* transition and the time (in both timestamp and block height) of this
* transition.
*
* @generated from field: repeated babylon.checkpointing.v1.CheckpointStateUpdate lifecycle = 5;
*/
lifecycle: CheckpointStateUpdate[] = [];
constructor(data?: PartialMessage<RawCheckpointWithMeta>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.RawCheckpointWithMeta";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "ckpt", kind: "message", T: RawCheckpoint },
{ no: 2, name: "status", kind: "enum", T: proto3.getEnumType(CheckpointStatus) },
{ no: 3, name: "bls_aggr_pk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 4, name: "power_sum", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 5, name: "lifecycle", kind: "message", T: CheckpointStateUpdate, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): RawCheckpointWithMeta {
return new RawCheckpointWithMeta().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): RawCheckpointWithMeta {
return new RawCheckpointWithMeta().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): RawCheckpointWithMeta {
return new RawCheckpointWithMeta().fromJsonString(jsonString, options);
}
static equals(a: RawCheckpointWithMeta | PlainMessage<RawCheckpointWithMeta> | undefined, b: RawCheckpointWithMeta | PlainMessage<RawCheckpointWithMeta> | undefined): boolean {
return proto3.util.equals(RawCheckpointWithMeta, a, b);
}
}
/**
* InjectedCheckpoint wraps the checkpoint and the extended votes
*
* @generated from message babylon.checkpointing.v1.InjectedCheckpoint
*/
export class InjectedCheckpoint extends Message<InjectedCheckpoint> {
/**
* @generated from field: babylon.checkpointing.v1.RawCheckpointWithMeta ckpt = 1;
*/
ckpt?: RawCheckpointWithMeta;
/**
* extended_commit_info is the commit info including the vote extensions
* from the previous proposal
*
* @generated from field: tendermint.abci.ExtendedCommitInfo extended_commit_info = 2;
*/
extendedCommitInfo?: ExtendedCommitInfo;
constructor(data?: PartialMessage<InjectedCheckpoint>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.InjectedCheckpoint";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "ckpt", kind: "message", T: RawCheckpointWithMeta },
{ no: 2, name: "extended_commit_info", kind: "message", T: ExtendedCommitInfo },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): InjectedCheckpoint {
return new InjectedCheckpoint().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): InjectedCheckpoint {
return new InjectedCheckpoint().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): InjectedCheckpoint {
return new InjectedCheckpoint().fromJsonString(jsonString, options);
}
static equals(a: InjectedCheckpoint | PlainMessage<InjectedCheckpoint> | undefined, b: InjectedCheckpoint | PlainMessage<InjectedCheckpoint> | undefined): boolean {
return proto3.util.equals(InjectedCheckpoint, a, b);
}
}
/**
* CheckpointStateUpdate defines a state transition on the checkpoint.
*
* @generated from message babylon.checkpointing.v1.CheckpointStateUpdate
*/
export class CheckpointStateUpdate extends Message<CheckpointStateUpdate> {
/**
* state defines the event of a state transition towards this state
*
* @generated from field: babylon.checkpointing.v1.CheckpointStatus state = 1;
*/
state = CheckpointStatus.CKPT_STATUS_ACCUMULATING;
/**
* block_height is the height of the Babylon block that triggers the state
* update
*
* @generated from field: uint64 block_height = 2;
*/
blockHeight = protoInt64.zero;
/**
* block_time is the timestamp in the Babylon block that triggers the state
* update
*
* @generated from field: google.protobuf.Timestamp block_time = 3;
*/
blockTime?: Timestamp;
constructor(data?: PartialMessage<CheckpointStateUpdate>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.CheckpointStateUpdate";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "state", kind: "enum", T: proto3.getEnumType(CheckpointStatus) },
{ no: 2, name: "block_height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 3, name: "block_time", kind: "message", T: Timestamp },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): CheckpointStateUpdate {
return new CheckpointStateUpdate().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): CheckpointStateUpdate {
return new CheckpointStateUpdate().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): CheckpointStateUpdate {
return new CheckpointStateUpdate().fromJsonString(jsonString, options);
}
static equals(a: CheckpointStateUpdate | PlainMessage<CheckpointStateUpdate> | undefined, b: CheckpointStateUpdate | PlainMessage<CheckpointStateUpdate> | undefined): boolean {
return proto3.util.equals(CheckpointStateUpdate, a, b);
}
}
/**
* BlsSig wraps the BLS sig with metadata.
*
* @generated from message babylon.checkpointing.v1.BlsSig
*/
export class BlsSig extends Message<BlsSig> {
/**
* epoch_num defines the epoch number that the BLS sig is signed on
*
* @generated from field: uint64 epoch_num = 1;
*/
epochNum = protoInt64.zero;
/**
* block_hash defines the 'BlockID.Hash', which is the hash of
* the block that individual BLS sigs are signed on
*
* @generated from field: bytes block_hash = 2;
*/
blockHash = new Uint8Array(0);
/**
* @generated from field: bytes bls_sig = 3;
*/
blsSig = new Uint8Array(0);
/**
* can't find cosmos_proto.scalar when compiling due to cosmos v0.45.4 does
* not support scalar string signer_address = 4 [(cosmos_proto.scalar) =
* "cosmos.AddressString"]
* the signer_address defines the address of the
* signer
*
* @generated from field: string signer_address = 4;
*/
signerAddress = "";
/**
* validator_address defines the validator's consensus address
*
* @generated from field: string validator_address = 5;
*/
validatorAddress = "";
constructor(data?: PartialMessage<BlsSig>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.BlsSig";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "epoch_num", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 2, name: "block_hash", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 3, name: "bls_sig", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 4, name: "signer_address", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 5, name: "validator_address", kind: "scalar", T: 9 /* ScalarType.STRING */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BlsSig {
return new BlsSig().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BlsSig {
return new BlsSig().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BlsSig {
return new BlsSig().fromJsonString(jsonString, options);
}
static equals(a: BlsSig | PlainMessage<BlsSig> | undefined, b: BlsSig | PlainMessage<BlsSig> | undefined): boolean {
return proto3.util.equals(BlsSig, a, b);
}
}

View File

@ -0,0 +1,295 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/checkpointing/v1/events.proto (package babylon.checkpointing.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3 } from "@bufbuild/protobuf";
import { RawCheckpoint, RawCheckpointWithMeta } from "./checkpoint_pb.js";
/**
* EventCheckpointAccumulating is emitted when a checkpoint reaches the
* `Accumulating` state.
*
* @generated from message babylon.checkpointing.v1.EventCheckpointAccumulating
*/
export class EventCheckpointAccumulating extends Message<EventCheckpointAccumulating> {
/**
* @generated from field: babylon.checkpointing.v1.RawCheckpointWithMeta checkpoint = 1;
*/
checkpoint?: RawCheckpointWithMeta;
constructor(data?: PartialMessage<EventCheckpointAccumulating>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.EventCheckpointAccumulating";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "checkpoint", kind: "message", T: RawCheckpointWithMeta },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventCheckpointAccumulating {
return new EventCheckpointAccumulating().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventCheckpointAccumulating {
return new EventCheckpointAccumulating().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventCheckpointAccumulating {
return new EventCheckpointAccumulating().fromJsonString(jsonString, options);
}
static equals(a: EventCheckpointAccumulating | PlainMessage<EventCheckpointAccumulating> | undefined, b: EventCheckpointAccumulating | PlainMessage<EventCheckpointAccumulating> | undefined): boolean {
return proto3.util.equals(EventCheckpointAccumulating, a, b);
}
}
/**
* EventCheckpointSealed is emitted when a checkpoint reaches the `Sealed`
* state.
*
* @generated from message babylon.checkpointing.v1.EventCheckpointSealed
*/
export class EventCheckpointSealed extends Message<EventCheckpointSealed> {
/**
* @generated from field: babylon.checkpointing.v1.RawCheckpointWithMeta checkpoint = 1;
*/
checkpoint?: RawCheckpointWithMeta;
constructor(data?: PartialMessage<EventCheckpointSealed>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.EventCheckpointSealed";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "checkpoint", kind: "message", T: RawCheckpointWithMeta },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventCheckpointSealed {
return new EventCheckpointSealed().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventCheckpointSealed {
return new EventCheckpointSealed().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventCheckpointSealed {
return new EventCheckpointSealed().fromJsonString(jsonString, options);
}
static equals(a: EventCheckpointSealed | PlainMessage<EventCheckpointSealed> | undefined, b: EventCheckpointSealed | PlainMessage<EventCheckpointSealed> | undefined): boolean {
return proto3.util.equals(EventCheckpointSealed, a, b);
}
}
/**
* EventCheckpointSubmitted is emitted when a checkpoint reaches the `Submitted`
* state.
*
* @generated from message babylon.checkpointing.v1.EventCheckpointSubmitted
*/
export class EventCheckpointSubmitted extends Message<EventCheckpointSubmitted> {
/**
* @generated from field: babylon.checkpointing.v1.RawCheckpointWithMeta checkpoint = 1;
*/
checkpoint?: RawCheckpointWithMeta;
constructor(data?: PartialMessage<EventCheckpointSubmitted>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.EventCheckpointSubmitted";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "checkpoint", kind: "message", T: RawCheckpointWithMeta },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventCheckpointSubmitted {
return new EventCheckpointSubmitted().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventCheckpointSubmitted {
return new EventCheckpointSubmitted().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventCheckpointSubmitted {
return new EventCheckpointSubmitted().fromJsonString(jsonString, options);
}
static equals(a: EventCheckpointSubmitted | PlainMessage<EventCheckpointSubmitted> | undefined, b: EventCheckpointSubmitted | PlainMessage<EventCheckpointSubmitted> | undefined): boolean {
return proto3.util.equals(EventCheckpointSubmitted, a, b);
}
}
/**
* EventCheckpointConfirmed is emitted when a checkpoint reaches the `Confirmed`
* state.
*
* @generated from message babylon.checkpointing.v1.EventCheckpointConfirmed
*/
export class EventCheckpointConfirmed extends Message<EventCheckpointConfirmed> {
/**
* @generated from field: babylon.checkpointing.v1.RawCheckpointWithMeta checkpoint = 1;
*/
checkpoint?: RawCheckpointWithMeta;
constructor(data?: PartialMessage<EventCheckpointConfirmed>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.EventCheckpointConfirmed";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "checkpoint", kind: "message", T: RawCheckpointWithMeta },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventCheckpointConfirmed {
return new EventCheckpointConfirmed().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventCheckpointConfirmed {
return new EventCheckpointConfirmed().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventCheckpointConfirmed {
return new EventCheckpointConfirmed().fromJsonString(jsonString, options);
}
static equals(a: EventCheckpointConfirmed | PlainMessage<EventCheckpointConfirmed> | undefined, b: EventCheckpointConfirmed | PlainMessage<EventCheckpointConfirmed> | undefined): boolean {
return proto3.util.equals(EventCheckpointConfirmed, a, b);
}
}
/**
* EventCheckpointFinalized is emitted when a checkpoint reaches the `Finalized`
* state.
*
* @generated from message babylon.checkpointing.v1.EventCheckpointFinalized
*/
export class EventCheckpointFinalized extends Message<EventCheckpointFinalized> {
/**
* @generated from field: babylon.checkpointing.v1.RawCheckpointWithMeta checkpoint = 1;
*/
checkpoint?: RawCheckpointWithMeta;
constructor(data?: PartialMessage<EventCheckpointFinalized>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.EventCheckpointFinalized";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "checkpoint", kind: "message", T: RawCheckpointWithMeta },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventCheckpointFinalized {
return new EventCheckpointFinalized().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventCheckpointFinalized {
return new EventCheckpointFinalized().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventCheckpointFinalized {
return new EventCheckpointFinalized().fromJsonString(jsonString, options);
}
static equals(a: EventCheckpointFinalized | PlainMessage<EventCheckpointFinalized> | undefined, b: EventCheckpointFinalized | PlainMessage<EventCheckpointFinalized> | undefined): boolean {
return proto3.util.equals(EventCheckpointFinalized, a, b);
}
}
/**
* EventCheckpointForgotten is emitted when a checkpoint switches to a
* `Forgotten` state.
*
* @generated from message babylon.checkpointing.v1.EventCheckpointForgotten
*/
export class EventCheckpointForgotten extends Message<EventCheckpointForgotten> {
/**
* @generated from field: babylon.checkpointing.v1.RawCheckpointWithMeta checkpoint = 1;
*/
checkpoint?: RawCheckpointWithMeta;
constructor(data?: PartialMessage<EventCheckpointForgotten>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.EventCheckpointForgotten";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "checkpoint", kind: "message", T: RawCheckpointWithMeta },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventCheckpointForgotten {
return new EventCheckpointForgotten().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventCheckpointForgotten {
return new EventCheckpointForgotten().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventCheckpointForgotten {
return new EventCheckpointForgotten().fromJsonString(jsonString, options);
}
static equals(a: EventCheckpointForgotten | PlainMessage<EventCheckpointForgotten> | undefined, b: EventCheckpointForgotten | PlainMessage<EventCheckpointForgotten> | undefined): boolean {
return proto3.util.equals(EventCheckpointForgotten, a, b);
}
}
/**
* EventConflictingCheckpoint is emitted when two conflicting checkpoints are
* found.
*
* @generated from message babylon.checkpointing.v1.EventConflictingCheckpoint
*/
export class EventConflictingCheckpoint extends Message<EventConflictingCheckpoint> {
/**
* @generated from field: babylon.checkpointing.v1.RawCheckpoint conflicting_checkpoint = 1;
*/
conflictingCheckpoint?: RawCheckpoint;
/**
* @generated from field: babylon.checkpointing.v1.RawCheckpointWithMeta local_checkpoint = 2;
*/
localCheckpoint?: RawCheckpointWithMeta;
constructor(data?: PartialMessage<EventConflictingCheckpoint>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.EventConflictingCheckpoint";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "conflicting_checkpoint", kind: "message", T: RawCheckpoint },
{ no: 2, name: "local_checkpoint", kind: "message", T: RawCheckpointWithMeta },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventConflictingCheckpoint {
return new EventConflictingCheckpoint().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventConflictingCheckpoint {
return new EventConflictingCheckpoint().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventConflictingCheckpoint {
return new EventConflictingCheckpoint().fromJsonString(jsonString, options);
}
static equals(a: EventConflictingCheckpoint | PlainMessage<EventConflictingCheckpoint> | undefined, b: EventConflictingCheckpoint | PlainMessage<EventConflictingCheckpoint> | undefined): boolean {
return proto3.util.equals(EventConflictingCheckpoint, a, b);
}
}

View File

@ -0,0 +1,108 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/checkpointing/v1/genesis.proto (package babylon.checkpointing.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3 } from "@bufbuild/protobuf";
import { BlsKey } from "./bls_key_pb.js";
import { PubKey } from "../../../cosmos/crypto/ed25519/keys_pb.js";
/**
* GenesisState defines the checkpointing module's genesis state.
*
* @generated from message babylon.checkpointing.v1.GenesisState
*/
export class GenesisState extends Message<GenesisState> {
/**
* genesis_keys defines the public keys for the genesis validators
*
* @generated from field: repeated babylon.checkpointing.v1.GenesisKey genesis_keys = 1;
*/
genesisKeys: GenesisKey[] = [];
constructor(data?: PartialMessage<GenesisState>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.GenesisState";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "genesis_keys", kind: "message", T: GenesisKey, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GenesisState {
return new GenesisState().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GenesisState {
return new GenesisState().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GenesisState {
return new GenesisState().fromJsonString(jsonString, options);
}
static equals(a: GenesisState | PlainMessage<GenesisState> | undefined, b: GenesisState | PlainMessage<GenesisState> | undefined): boolean {
return proto3.util.equals(GenesisState, a, b);
}
}
/**
* GenesisKey defines public key information about the genesis validators
*
* @generated from message babylon.checkpointing.v1.GenesisKey
*/
export class GenesisKey extends Message<GenesisKey> {
/**
* validator_address is the address corresponding to a validator
*
* @generated from field: string validator_address = 1;
*/
validatorAddress = "";
/**
* bls_key defines the BLS key of the validator at genesis
*
* @generated from field: babylon.checkpointing.v1.BlsKey bls_key = 2;
*/
blsKey?: BlsKey;
/**
* val_pubkey defines the ed25519 public key of the validator at genesis
*
* @generated from field: cosmos.crypto.ed25519.PubKey val_pubkey = 3;
*/
valPubkey?: PubKey;
constructor(data?: PartialMessage<GenesisKey>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.GenesisKey";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "validator_address", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "bls_key", kind: "message", T: BlsKey },
{ no: 3, name: "val_pubkey", kind: "message", T: PubKey },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GenesisKey {
return new GenesisKey().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GenesisKey {
return new GenesisKey().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GenesisKey {
return new GenesisKey().fromJsonString(jsonString, options);
}
static equals(a: GenesisKey | PlainMessage<GenesisKey> | undefined, b: GenesisKey | PlainMessage<GenesisKey> | undefined): boolean {
return proto3.util.equals(GenesisKey, a, b);
}
}

View File

@ -0,0 +1,96 @@
// @generated by protoc-gen-cosmes v0.0.1 with parameter "target=ts"
// @generated from file babylon/checkpointing/v1/query.proto (package babylon.checkpointing.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import { QueryBlsPublicKeyListRequest, QueryBlsPublicKeyListResponse, QueryEpochStatusRequest, QueryEpochStatusResponse, QueryLastCheckpointWithStatusRequest, QueryLastCheckpointWithStatusResponse, QueryRawCheckpointListRequest, QueryRawCheckpointListResponse, QueryRawCheckpointRequest, QueryRawCheckpointResponse, QueryRawCheckpointsRequest, QueryRawCheckpointsResponse, QueryRecentEpochStatusCountRequest, QueryRecentEpochStatusCountResponse } from "./query_pb.js";
const TYPE_NAME = "babylon.checkpointing.v1.Query";
/**
* RawCheckpointList queries all checkpoints that match the given status.
*
* @generated from rpc babylon.checkpointing.v1.Query.RawCheckpointList
*/
export const QueryRawCheckpointListService = {
typeName: TYPE_NAME,
method: "RawCheckpointList",
Request: QueryRawCheckpointListRequest,
Response: QueryRawCheckpointListResponse,
} as const;
/**
* RawCheckpoint queries a checkpoints at a given epoch number.
*
* @generated from rpc babylon.checkpointing.v1.Query.RawCheckpoint
*/
export const QueryRawCheckpointService = {
typeName: TYPE_NAME,
method: "RawCheckpoint",
Request: QueryRawCheckpointRequest,
Response: QueryRawCheckpointResponse,
} as const;
/**
* RawCheckpoints queries checkpoints for a epoch range specified in pagination params.
*
* @generated from rpc babylon.checkpointing.v1.Query.RawCheckpoints
*/
export const QueryRawCheckpointsService = {
typeName: TYPE_NAME,
method: "RawCheckpoints",
Request: QueryRawCheckpointsRequest,
Response: QueryRawCheckpointsResponse,
} as const;
/**
* BlsPublicKeyList queries a list of bls public keys of the validators at a
* given epoch number.
*
* @generated from rpc babylon.checkpointing.v1.Query.BlsPublicKeyList
*/
export const QueryBlsPublicKeyListService = {
typeName: TYPE_NAME,
method: "BlsPublicKeyList",
Request: QueryBlsPublicKeyListRequest,
Response: QueryBlsPublicKeyListResponse,
} as const;
/**
* EpochStatus queries the status of the checkpoint at a given epoch
*
* @generated from rpc babylon.checkpointing.v1.Query.EpochStatus
*/
export const QueryEpochStatusService = {
typeName: TYPE_NAME,
method: "EpochStatus",
Request: QueryEpochStatusRequest,
Response: QueryEpochStatusResponse,
} as const;
/**
* RecentEpochStatusCount queries the number of epochs with each status in
* recent epochs
*
* @generated from rpc babylon.checkpointing.v1.Query.RecentEpochStatusCount
*/
export const QueryRecentEpochStatusCountService = {
typeName: TYPE_NAME,
method: "RecentEpochStatusCount",
Request: QueryRecentEpochStatusCountRequest,
Response: QueryRecentEpochStatusCountResponse,
} as const;
/**
* LastCheckpointWithStatus queries the last checkpoint with a given status or
* a more matured status
*
* @generated from rpc babylon.checkpointing.v1.Query.LastCheckpointWithStatus
*/
export const QueryLastCheckpointWithStatusService = {
typeName: TYPE_NAME,
method: "LastCheckpointWithStatus",
Request: QueryLastCheckpointWithStatusRequest,
Response: QueryLastCheckpointWithStatusResponse,
} as const;

View File

@ -0,0 +1,853 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/checkpointing/v1/query.proto (package babylon.checkpointing.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, protoInt64, Timestamp } from "@bufbuild/protobuf";
import { CheckpointStatus } from "./checkpoint_pb.js";
import { PageRequest, PageResponse } from "../../../cosmos/base/query/v1beta1/pagination_pb.js";
import { ValidatorWithBlsKey } from "./bls_key_pb.js";
/**
* QueryRawCheckpointListRequest is the request type for the
* Query/RawCheckpoints RPC method.
*
* @generated from message babylon.checkpointing.v1.QueryRawCheckpointListRequest
*/
export class QueryRawCheckpointListRequest extends Message<QueryRawCheckpointListRequest> {
/**
* status defines the status of the raw checkpoints of the query
*
* @generated from field: babylon.checkpointing.v1.CheckpointStatus status = 1;
*/
status = CheckpointStatus.CKPT_STATUS_ACCUMULATING;
/**
* pagination defines an optional pagination for the request.
*
* @generated from field: cosmos.base.query.v1beta1.PageRequest pagination = 2;
*/
pagination?: PageRequest;
constructor(data?: PartialMessage<QueryRawCheckpointListRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.QueryRawCheckpointListRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "status", kind: "enum", T: proto3.getEnumType(CheckpointStatus) },
{ no: 2, name: "pagination", kind: "message", T: PageRequest },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryRawCheckpointListRequest {
return new QueryRawCheckpointListRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryRawCheckpointListRequest {
return new QueryRawCheckpointListRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryRawCheckpointListRequest {
return new QueryRawCheckpointListRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryRawCheckpointListRequest | PlainMessage<QueryRawCheckpointListRequest> | undefined, b: QueryRawCheckpointListRequest | PlainMessage<QueryRawCheckpointListRequest> | undefined): boolean {
return proto3.util.equals(QueryRawCheckpointListRequest, a, b);
}
}
/**
* QueryRawCheckpointListResponse is the response type for the
* Query/RawCheckpoints RPC method.
*
* @generated from message babylon.checkpointing.v1.QueryRawCheckpointListResponse
*/
export class QueryRawCheckpointListResponse extends Message<QueryRawCheckpointListResponse> {
/**
* the order is going from the newest to oldest based on the epoch number
*
* @generated from field: repeated babylon.checkpointing.v1.RawCheckpointWithMetaResponse raw_checkpoints = 1;
*/
rawCheckpoints: RawCheckpointWithMetaResponse[] = [];
/**
* pagination defines the pagination in the response.
*
* @generated from field: cosmos.base.query.v1beta1.PageResponse pagination = 2;
*/
pagination?: PageResponse;
constructor(data?: PartialMessage<QueryRawCheckpointListResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.QueryRawCheckpointListResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "raw_checkpoints", kind: "message", T: RawCheckpointWithMetaResponse, repeated: true },
{ no: 2, name: "pagination", kind: "message", T: PageResponse },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryRawCheckpointListResponse {
return new QueryRawCheckpointListResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryRawCheckpointListResponse {
return new QueryRawCheckpointListResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryRawCheckpointListResponse {
return new QueryRawCheckpointListResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryRawCheckpointListResponse | PlainMessage<QueryRawCheckpointListResponse> | undefined, b: QueryRawCheckpointListResponse | PlainMessage<QueryRawCheckpointListResponse> | undefined): boolean {
return proto3.util.equals(QueryRawCheckpointListResponse, a, b);
}
}
/**
* QueryRawCheckpointRequest is the request type for the Query/RawCheckpoint
* RPC method.
*
* @generated from message babylon.checkpointing.v1.QueryRawCheckpointRequest
*/
export class QueryRawCheckpointRequest extends Message<QueryRawCheckpointRequest> {
/**
* epoch_num defines the epoch for the queried checkpoint
*
* @generated from field: uint64 epoch_num = 1;
*/
epochNum = protoInt64.zero;
constructor(data?: PartialMessage<QueryRawCheckpointRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.QueryRawCheckpointRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "epoch_num", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryRawCheckpointRequest {
return new QueryRawCheckpointRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryRawCheckpointRequest {
return new QueryRawCheckpointRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryRawCheckpointRequest {
return new QueryRawCheckpointRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryRawCheckpointRequest | PlainMessage<QueryRawCheckpointRequest> | undefined, b: QueryRawCheckpointRequest | PlainMessage<QueryRawCheckpointRequest> | undefined): boolean {
return proto3.util.equals(QueryRawCheckpointRequest, a, b);
}
}
/**
* QueryRawCheckpointResponse is the response type for the Query/RawCheckpoint
* RPC method.
*
* @generated from message babylon.checkpointing.v1.QueryRawCheckpointResponse
*/
export class QueryRawCheckpointResponse extends Message<QueryRawCheckpointResponse> {
/**
* @generated from field: babylon.checkpointing.v1.RawCheckpointWithMetaResponse raw_checkpoint = 1;
*/
rawCheckpoint?: RawCheckpointWithMetaResponse;
constructor(data?: PartialMessage<QueryRawCheckpointResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.QueryRawCheckpointResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "raw_checkpoint", kind: "message", T: RawCheckpointWithMetaResponse },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryRawCheckpointResponse {
return new QueryRawCheckpointResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryRawCheckpointResponse {
return new QueryRawCheckpointResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryRawCheckpointResponse {
return new QueryRawCheckpointResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryRawCheckpointResponse | PlainMessage<QueryRawCheckpointResponse> | undefined, b: QueryRawCheckpointResponse | PlainMessage<QueryRawCheckpointResponse> | undefined): boolean {
return proto3.util.equals(QueryRawCheckpointResponse, a, b);
}
}
/**
* QueryRawCheckpointsRequest is the request type for the Query/RawCheckpoints
* RPC method.
*
* @generated from message babylon.checkpointing.v1.QueryRawCheckpointsRequest
*/
export class QueryRawCheckpointsRequest extends Message<QueryRawCheckpointsRequest> {
/**
* pagination defines whether to have the pagination in the request
*
* @generated from field: cosmos.base.query.v1beta1.PageRequest pagination = 1;
*/
pagination?: PageRequest;
constructor(data?: PartialMessage<QueryRawCheckpointsRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.QueryRawCheckpointsRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "pagination", kind: "message", T: PageRequest },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryRawCheckpointsRequest {
return new QueryRawCheckpointsRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryRawCheckpointsRequest {
return new QueryRawCheckpointsRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryRawCheckpointsRequest {
return new QueryRawCheckpointsRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryRawCheckpointsRequest | PlainMessage<QueryRawCheckpointsRequest> | undefined, b: QueryRawCheckpointsRequest | PlainMessage<QueryRawCheckpointsRequest> | undefined): boolean {
return proto3.util.equals(QueryRawCheckpointsRequest, a, b);
}
}
/**
* QueryRawCheckpointsResponse is the response type for the Query/RawCheckpoints
* RPC method.
*
* @generated from message babylon.checkpointing.v1.QueryRawCheckpointsResponse
*/
export class QueryRawCheckpointsResponse extends Message<QueryRawCheckpointsResponse> {
/**
* the order is going from the newest to oldest based on the epoch number
*
* @generated from field: repeated babylon.checkpointing.v1.RawCheckpointWithMetaResponse raw_checkpoints = 1;
*/
rawCheckpoints: RawCheckpointWithMetaResponse[] = [];
/**
* pagination defines the pagination in the response.
*
* @generated from field: cosmos.base.query.v1beta1.PageResponse pagination = 2;
*/
pagination?: PageResponse;
constructor(data?: PartialMessage<QueryRawCheckpointsResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.QueryRawCheckpointsResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "raw_checkpoints", kind: "message", T: RawCheckpointWithMetaResponse, repeated: true },
{ no: 2, name: "pagination", kind: "message", T: PageResponse },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryRawCheckpointsResponse {
return new QueryRawCheckpointsResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryRawCheckpointsResponse {
return new QueryRawCheckpointsResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryRawCheckpointsResponse {
return new QueryRawCheckpointsResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryRawCheckpointsResponse | PlainMessage<QueryRawCheckpointsResponse> | undefined, b: QueryRawCheckpointsResponse | PlainMessage<QueryRawCheckpointsResponse> | undefined): boolean {
return proto3.util.equals(QueryRawCheckpointsResponse, a, b);
}
}
/**
* QueryBlsPublicKeyListRequest is the request type for the Query/BlsPublicKeys
* RPC method.
*
* @generated from message babylon.checkpointing.v1.QueryBlsPublicKeyListRequest
*/
export class QueryBlsPublicKeyListRequest extends Message<QueryBlsPublicKeyListRequest> {
/**
* epoch_num defines the epoch for the queried bls public keys
*
* @generated from field: uint64 epoch_num = 1;
*/
epochNum = protoInt64.zero;
/**
* pagination defines an optional pagination for the request.
*
* @generated from field: cosmos.base.query.v1beta1.PageRequest pagination = 2;
*/
pagination?: PageRequest;
constructor(data?: PartialMessage<QueryBlsPublicKeyListRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.QueryBlsPublicKeyListRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "epoch_num", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 2, name: "pagination", kind: "message", T: PageRequest },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryBlsPublicKeyListRequest {
return new QueryBlsPublicKeyListRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryBlsPublicKeyListRequest {
return new QueryBlsPublicKeyListRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryBlsPublicKeyListRequest {
return new QueryBlsPublicKeyListRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryBlsPublicKeyListRequest | PlainMessage<QueryBlsPublicKeyListRequest> | undefined, b: QueryBlsPublicKeyListRequest | PlainMessage<QueryBlsPublicKeyListRequest> | undefined): boolean {
return proto3.util.equals(QueryBlsPublicKeyListRequest, a, b);
}
}
/**
* QueryBlsPublicKeyListResponse is the response type for the
* Query/BlsPublicKeys RPC method.
*
* @generated from message babylon.checkpointing.v1.QueryBlsPublicKeyListResponse
*/
export class QueryBlsPublicKeyListResponse extends Message<QueryBlsPublicKeyListResponse> {
/**
* @generated from field: repeated babylon.checkpointing.v1.ValidatorWithBlsKey validator_with_bls_keys = 1;
*/
validatorWithBlsKeys: ValidatorWithBlsKey[] = [];
/**
* pagination defines the pagination in the response.
*
* @generated from field: cosmos.base.query.v1beta1.PageResponse pagination = 2;
*/
pagination?: PageResponse;
constructor(data?: PartialMessage<QueryBlsPublicKeyListResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.QueryBlsPublicKeyListResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "validator_with_bls_keys", kind: "message", T: ValidatorWithBlsKey, repeated: true },
{ no: 2, name: "pagination", kind: "message", T: PageResponse },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryBlsPublicKeyListResponse {
return new QueryBlsPublicKeyListResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryBlsPublicKeyListResponse {
return new QueryBlsPublicKeyListResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryBlsPublicKeyListResponse {
return new QueryBlsPublicKeyListResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryBlsPublicKeyListResponse | PlainMessage<QueryBlsPublicKeyListResponse> | undefined, b: QueryBlsPublicKeyListResponse | PlainMessage<QueryBlsPublicKeyListResponse> | undefined): boolean {
return proto3.util.equals(QueryBlsPublicKeyListResponse, a, b);
}
}
/**
* QueryEpochStatusRequest is the request type for the Query/EpochStatus
* RPC method.
*
* @generated from message babylon.checkpointing.v1.QueryEpochStatusRequest
*/
export class QueryEpochStatusRequest extends Message<QueryEpochStatusRequest> {
/**
* @generated from field: uint64 epoch_num = 1;
*/
epochNum = protoInt64.zero;
constructor(data?: PartialMessage<QueryEpochStatusRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.QueryEpochStatusRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "epoch_num", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryEpochStatusRequest {
return new QueryEpochStatusRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryEpochStatusRequest {
return new QueryEpochStatusRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryEpochStatusRequest {
return new QueryEpochStatusRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryEpochStatusRequest | PlainMessage<QueryEpochStatusRequest> | undefined, b: QueryEpochStatusRequest | PlainMessage<QueryEpochStatusRequest> | undefined): boolean {
return proto3.util.equals(QueryEpochStatusRequest, a, b);
}
}
/**
* QueryEpochStatusResponse is the response type for the Query/EpochStatus
* RPC method.
*
* @generated from message babylon.checkpointing.v1.QueryEpochStatusResponse
*/
export class QueryEpochStatusResponse extends Message<QueryEpochStatusResponse> {
/**
* @generated from field: babylon.checkpointing.v1.CheckpointStatus status = 1;
*/
status = CheckpointStatus.CKPT_STATUS_ACCUMULATING;
constructor(data?: PartialMessage<QueryEpochStatusResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.QueryEpochStatusResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "status", kind: "enum", T: proto3.getEnumType(CheckpointStatus) },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryEpochStatusResponse {
return new QueryEpochStatusResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryEpochStatusResponse {
return new QueryEpochStatusResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryEpochStatusResponse {
return new QueryEpochStatusResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryEpochStatusResponse | PlainMessage<QueryEpochStatusResponse> | undefined, b: QueryEpochStatusResponse | PlainMessage<QueryEpochStatusResponse> | undefined): boolean {
return proto3.util.equals(QueryEpochStatusResponse, a, b);
}
}
/**
* QueryRecentEpochStatusCountRequest is the request type for the
* Query/EpochStatusCount RPC method.
*
* @generated from message babylon.checkpointing.v1.QueryRecentEpochStatusCountRequest
*/
export class QueryRecentEpochStatusCountRequest extends Message<QueryRecentEpochStatusCountRequest> {
/**
* epoch_count is the number of the most recent epochs to include in the
* aggregation
*
* @generated from field: uint64 epoch_count = 1;
*/
epochCount = protoInt64.zero;
constructor(data?: PartialMessage<QueryRecentEpochStatusCountRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.QueryRecentEpochStatusCountRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "epoch_count", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryRecentEpochStatusCountRequest {
return new QueryRecentEpochStatusCountRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryRecentEpochStatusCountRequest {
return new QueryRecentEpochStatusCountRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryRecentEpochStatusCountRequest {
return new QueryRecentEpochStatusCountRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryRecentEpochStatusCountRequest | PlainMessage<QueryRecentEpochStatusCountRequest> | undefined, b: QueryRecentEpochStatusCountRequest | PlainMessage<QueryRecentEpochStatusCountRequest> | undefined): boolean {
return proto3.util.equals(QueryRecentEpochStatusCountRequest, a, b);
}
}
/**
* QueryRecentEpochStatusCountResponse is the response type for the
* Query/EpochStatusCount RPC method.
*
* @generated from message babylon.checkpointing.v1.QueryRecentEpochStatusCountResponse
*/
export class QueryRecentEpochStatusCountResponse extends Message<QueryRecentEpochStatusCountResponse> {
/**
* @generated from field: uint64 tip_epoch = 1;
*/
tipEpoch = protoInt64.zero;
/**
* @generated from field: uint64 epoch_count = 2;
*/
epochCount = protoInt64.zero;
/**
* @generated from field: map<string, uint64> status_count = 3;
*/
statusCount: { [key: string]: bigint } = {};
constructor(data?: PartialMessage<QueryRecentEpochStatusCountResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.QueryRecentEpochStatusCountResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "tip_epoch", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 2, name: "epoch_count", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 3, name: "status_count", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 4 /* ScalarType.UINT64 */} },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryRecentEpochStatusCountResponse {
return new QueryRecentEpochStatusCountResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryRecentEpochStatusCountResponse {
return new QueryRecentEpochStatusCountResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryRecentEpochStatusCountResponse {
return new QueryRecentEpochStatusCountResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryRecentEpochStatusCountResponse | PlainMessage<QueryRecentEpochStatusCountResponse> | undefined, b: QueryRecentEpochStatusCountResponse | PlainMessage<QueryRecentEpochStatusCountResponse> | undefined): boolean {
return proto3.util.equals(QueryRecentEpochStatusCountResponse, a, b);
}
}
/**
* QueryLastCheckpointWithStatusRequest is the request type for the
* Query/LastCheckpointWithStatus RPC method.
*
* @generated from message babylon.checkpointing.v1.QueryLastCheckpointWithStatusRequest
*/
export class QueryLastCheckpointWithStatusRequest extends Message<QueryLastCheckpointWithStatusRequest> {
/**
* @generated from field: babylon.checkpointing.v1.CheckpointStatus status = 1;
*/
status = CheckpointStatus.CKPT_STATUS_ACCUMULATING;
constructor(data?: PartialMessage<QueryLastCheckpointWithStatusRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.QueryLastCheckpointWithStatusRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "status", kind: "enum", T: proto3.getEnumType(CheckpointStatus) },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryLastCheckpointWithStatusRequest {
return new QueryLastCheckpointWithStatusRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryLastCheckpointWithStatusRequest {
return new QueryLastCheckpointWithStatusRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryLastCheckpointWithStatusRequest {
return new QueryLastCheckpointWithStatusRequest().fromJsonString(jsonString, options);
}
static equals(a: QueryLastCheckpointWithStatusRequest | PlainMessage<QueryLastCheckpointWithStatusRequest> | undefined, b: QueryLastCheckpointWithStatusRequest | PlainMessage<QueryLastCheckpointWithStatusRequest> | undefined): boolean {
return proto3.util.equals(QueryLastCheckpointWithStatusRequest, a, b);
}
}
/**
* QueryLastCheckpointWithStatusResponse is the response type for the
* Query/LastCheckpointWithStatus RPC method.
*
* @generated from message babylon.checkpointing.v1.QueryLastCheckpointWithStatusResponse
*/
export class QueryLastCheckpointWithStatusResponse extends Message<QueryLastCheckpointWithStatusResponse> {
/**
* @generated from field: babylon.checkpointing.v1.RawCheckpointResponse raw_checkpoint = 1;
*/
rawCheckpoint?: RawCheckpointResponse;
constructor(data?: PartialMessage<QueryLastCheckpointWithStatusResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.QueryLastCheckpointWithStatusResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "raw_checkpoint", kind: "message", T: RawCheckpointResponse },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueryLastCheckpointWithStatusResponse {
return new QueryLastCheckpointWithStatusResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueryLastCheckpointWithStatusResponse {
return new QueryLastCheckpointWithStatusResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueryLastCheckpointWithStatusResponse {
return new QueryLastCheckpointWithStatusResponse().fromJsonString(jsonString, options);
}
static equals(a: QueryLastCheckpointWithStatusResponse | PlainMessage<QueryLastCheckpointWithStatusResponse> | undefined, b: QueryLastCheckpointWithStatusResponse | PlainMessage<QueryLastCheckpointWithStatusResponse> | undefined): boolean {
return proto3.util.equals(QueryLastCheckpointWithStatusResponse, a, b);
}
}
/**
* RawCheckpointResponse wraps the BLS multi sig with metadata
*
* @generated from message babylon.checkpointing.v1.RawCheckpointResponse
*/
export class RawCheckpointResponse extends Message<RawCheckpointResponse> {
/**
* epoch_num defines the epoch number the raw checkpoint is for
*
* @generated from field: uint64 epoch_num = 1;
*/
epochNum = protoInt64.zero;
/**
* block_hash_hex defines the 'BlockID.Hash', which is the hash of
* the block that individual BLS sigs are signed on as hex string
*
* @generated from field: string block_hash_hex = 2;
*/
blockHashHex = "";
/**
* bitmap defines the bitmap that indicates the signers of the BLS multi sig
*
* @generated from field: bytes bitmap = 3;
*/
bitmap = new Uint8Array(0);
/**
* bls_multi_sig defines the multi sig that is aggregated from individual BLS
* sigs
*
* @generated from field: bytes bls_multi_sig = 4;
*/
blsMultiSig = new Uint8Array(0);
constructor(data?: PartialMessage<RawCheckpointResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.RawCheckpointResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "epoch_num", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 2, name: "block_hash_hex", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "bitmap", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 4, name: "bls_multi_sig", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): RawCheckpointResponse {
return new RawCheckpointResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): RawCheckpointResponse {
return new RawCheckpointResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): RawCheckpointResponse {
return new RawCheckpointResponse().fromJsonString(jsonString, options);
}
static equals(a: RawCheckpointResponse | PlainMessage<RawCheckpointResponse> | undefined, b: RawCheckpointResponse | PlainMessage<RawCheckpointResponse> | undefined): boolean {
return proto3.util.equals(RawCheckpointResponse, a, b);
}
}
/**
* CheckpointStateUpdateResponse defines a state transition on the checkpoint.
*
* @generated from message babylon.checkpointing.v1.CheckpointStateUpdateResponse
*/
export class CheckpointStateUpdateResponse extends Message<CheckpointStateUpdateResponse> {
/**
* state defines the event of a state transition towards this state
*
* @generated from field: babylon.checkpointing.v1.CheckpointStatus state = 1;
*/
state = CheckpointStatus.CKPT_STATUS_ACCUMULATING;
/**
* status_desc respresents the description of status enum.
*
* @generated from field: string status_desc = 2;
*/
statusDesc = "";
/**
* block_height is the height of the Babylon block that triggers the state
* update
*
* @generated from field: uint64 block_height = 3;
*/
blockHeight = protoInt64.zero;
/**
* block_time is the timestamp in the Babylon block that triggers the state
* update
*
* @generated from field: google.protobuf.Timestamp block_time = 4;
*/
blockTime?: Timestamp;
constructor(data?: PartialMessage<CheckpointStateUpdateResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.CheckpointStateUpdateResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "state", kind: "enum", T: proto3.getEnumType(CheckpointStatus) },
{ no: 2, name: "status_desc", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "block_height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 4, name: "block_time", kind: "message", T: Timestamp },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): CheckpointStateUpdateResponse {
return new CheckpointStateUpdateResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): CheckpointStateUpdateResponse {
return new CheckpointStateUpdateResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): CheckpointStateUpdateResponse {
return new CheckpointStateUpdateResponse().fromJsonString(jsonString, options);
}
static equals(a: CheckpointStateUpdateResponse | PlainMessage<CheckpointStateUpdateResponse> | undefined, b: CheckpointStateUpdateResponse | PlainMessage<CheckpointStateUpdateResponse> | undefined): boolean {
return proto3.util.equals(CheckpointStateUpdateResponse, a, b);
}
}
/**
* RawCheckpointWithMetaResponse wraps the raw checkpoint with metadata.
*
* @generated from message babylon.checkpointing.v1.RawCheckpointWithMetaResponse
*/
export class RawCheckpointWithMetaResponse extends Message<RawCheckpointWithMetaResponse> {
/**
* @generated from field: babylon.checkpointing.v1.RawCheckpointResponse ckpt = 1;
*/
ckpt?: RawCheckpointResponse;
/**
* status defines the status of the checkpoint
*
* @generated from field: babylon.checkpointing.v1.CheckpointStatus status = 2;
*/
status = CheckpointStatus.CKPT_STATUS_ACCUMULATING;
/**
* status_desc respresents the description of status enum.
*
* @generated from field: string status_desc = 3;
*/
statusDesc = "";
/**
* bls_aggr_pk defines the aggregated BLS public key
*
* @generated from field: bytes bls_aggr_pk = 4;
*/
blsAggrPk = new Uint8Array(0);
/**
* power_sum defines the accumulated voting power for the checkpoint
*
* @generated from field: uint64 power_sum = 5;
*/
powerSum = protoInt64.zero;
/**
* lifecycle defines the lifecycle of this checkpoint, i.e., each state
* transition and the time (in both timestamp and block height) of this
* transition.
*
* @generated from field: repeated babylon.checkpointing.v1.CheckpointStateUpdateResponse lifecycle = 6;
*/
lifecycle: CheckpointStateUpdateResponse[] = [];
constructor(data?: PartialMessage<RawCheckpointWithMetaResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.RawCheckpointWithMetaResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "ckpt", kind: "message", T: RawCheckpointResponse },
{ no: 2, name: "status", kind: "enum", T: proto3.getEnumType(CheckpointStatus) },
{ no: 3, name: "status_desc", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 4, name: "bls_aggr_pk", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 5, name: "power_sum", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 6, name: "lifecycle", kind: "message", T: CheckpointStateUpdateResponse, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): RawCheckpointWithMetaResponse {
return new RawCheckpointWithMetaResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): RawCheckpointWithMetaResponse {
return new RawCheckpointWithMetaResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): RawCheckpointWithMetaResponse {
return new RawCheckpointWithMetaResponse().fromJsonString(jsonString, options);
}
static equals(a: RawCheckpointWithMetaResponse | PlainMessage<RawCheckpointWithMetaResponse> | undefined, b: RawCheckpointWithMetaResponse | PlainMessage<RawCheckpointWithMetaResponse> | undefined): boolean {
return proto3.util.equals(RawCheckpointWithMetaResponse, a, b);
}
}

View File

@ -0,0 +1,21 @@
// @generated by protoc-gen-cosmes v0.0.1 with parameter "target=ts"
// @generated from file babylon/checkpointing/v1/tx.proto (package babylon.checkpointing.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import { MsgWrappedCreateValidator, MsgWrappedCreateValidatorResponse } from "./tx_pb.js";
const TYPE_NAME = "babylon.checkpointing.v1.Msg";
/**
* WrappedCreateValidator defines a method for registering a new validator
*
* @generated from rpc babylon.checkpointing.v1.Msg.WrappedCreateValidator
*/
export const MsgWrappedCreateValidatorService = {
typeName: TYPE_NAME,
method: "WrappedCreateValidator",
Request: MsgWrappedCreateValidator,
Response: MsgWrappedCreateValidatorResponse,
} as const;

View File

@ -0,0 +1,89 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/checkpointing/v1/tx.proto (package babylon.checkpointing.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3 } from "@bufbuild/protobuf";
import { BlsKey } from "./bls_key_pb.js";
import { MsgCreateValidator } from "../../../cosmos/staking/v1beta1/tx_pb.js";
/**
* MsgWrappedCreateValidator defines a wrapped message to create a validator
*
* @generated from message babylon.checkpointing.v1.MsgWrappedCreateValidator
*/
export class MsgWrappedCreateValidator extends Message<MsgWrappedCreateValidator> {
/**
* @generated from field: babylon.checkpointing.v1.BlsKey key = 1;
*/
key?: BlsKey;
/**
* @generated from field: cosmos.staking.v1beta1.MsgCreateValidator msg_create_validator = 2;
*/
msgCreateValidator?: MsgCreateValidator;
constructor(data?: PartialMessage<MsgWrappedCreateValidator>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.MsgWrappedCreateValidator";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "key", kind: "message", T: BlsKey },
{ no: 2, name: "msg_create_validator", kind: "message", T: MsgCreateValidator },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgWrappedCreateValidator {
return new MsgWrappedCreateValidator().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgWrappedCreateValidator {
return new MsgWrappedCreateValidator().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgWrappedCreateValidator {
return new MsgWrappedCreateValidator().fromJsonString(jsonString, options);
}
static equals(a: MsgWrappedCreateValidator | PlainMessage<MsgWrappedCreateValidator> | undefined, b: MsgWrappedCreateValidator | PlainMessage<MsgWrappedCreateValidator> | undefined): boolean {
return proto3.util.equals(MsgWrappedCreateValidator, a, b);
}
}
/**
* MsgWrappedCreateValidatorResponse defines the MsgWrappedCreateValidator
* response type
*
* @generated from message babylon.checkpointing.v1.MsgWrappedCreateValidatorResponse
*/
export class MsgWrappedCreateValidatorResponse extends Message<MsgWrappedCreateValidatorResponse> {
constructor(data?: PartialMessage<MsgWrappedCreateValidatorResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.checkpointing.v1.MsgWrappedCreateValidatorResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): MsgWrappedCreateValidatorResponse {
return new MsgWrappedCreateValidatorResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): MsgWrappedCreateValidatorResponse {
return new MsgWrappedCreateValidatorResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): MsgWrappedCreateValidatorResponse {
return new MsgWrappedCreateValidatorResponse().fromJsonString(jsonString, options);
}
static equals(a: MsgWrappedCreateValidatorResponse | PlainMessage<MsgWrappedCreateValidatorResponse> | undefined, b: MsgWrappedCreateValidatorResponse | PlainMessage<MsgWrappedCreateValidatorResponse> | undefined): boolean {
return proto3.util.equals(MsgWrappedCreateValidatorResponse, a, b);
}
}

View File

@ -0,0 +1,523 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/epoching/v1/epoching.proto (package babylon.epoching.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, protoInt64, Timestamp } from "@bufbuild/protobuf";
import { MsgBeginRedelegate, MsgCancelUnbondingDelegation, MsgCreateValidator, MsgDelegate, MsgUndelegate } from "../../../cosmos/staking/v1beta1/tx_pb.js";
import { Coin } from "../../../cosmos/base/v1beta1/coin_pb.js";
/**
* BondState is the bond state of a validator or delegation
*
* @generated from enum babylon.epoching.v1.BondState
*/
export enum BondState {
/**
* CREATED is when the validator/delegation has been created
*
* @generated from enum value: CREATED = 0;
*/
CREATED = 0,
/**
* CREATED is when the validator/delegation has become bonded
*
* @generated from enum value: BONDED = 1;
*/
BONDED = 1,
/**
* CREATED is when the validator/delegation has become unbonding
*
* @generated from enum value: UNBONDING = 2;
*/
UNBONDING = 2,
/**
* CREATED is when the validator/delegation has become unbonded
*
* @generated from enum value: UNBONDED = 3;
*/
UNBONDED = 3,
/**
* CREATED is when the validator/delegation has been removed
*
* @generated from enum value: REMOVED = 4;
*/
REMOVED = 4,
}
// Retrieve enum metadata with: proto3.getEnumType(BondState)
proto3.util.setEnumType(BondState, "babylon.epoching.v1.BondState", [
{ no: 0, name: "CREATED" },
{ no: 1, name: "BONDED" },
{ no: 2, name: "UNBONDING" },
{ no: 3, name: "UNBONDED" },
{ no: 4, name: "REMOVED" },
]);
/**
* Epoch is a structure that contains the metadata of an epoch
*
* @generated from message babylon.epoching.v1.Epoch
*/
export class Epoch extends Message<Epoch> {
/**
* epoch_number is the number of this epoch
*
* @generated from field: uint64 epoch_number = 1;
*/
epochNumber = protoInt64.zero;
/**
* current_epoch_interval is the epoch interval at the time of this epoch
*
* @generated from field: uint64 current_epoch_interval = 2;
*/
currentEpochInterval = protoInt64.zero;
/**
* first_block_height is the height of the first block in this epoch
*
* @generated from field: uint64 first_block_height = 3;
*/
firstBlockHeight = protoInt64.zero;
/**
* last_block_time is the time of the last block in this epoch.
* Babylon needs to remember the last header's time of each epoch to complete
* unbonding validators/delegations when a previous epoch's checkpoint is
* finalised. The last_block_time field is nil in the epoch's beginning, and
* is set upon the end of this epoch.
*
* @generated from field: google.protobuf.Timestamp last_block_time = 4;
*/
lastBlockTime?: Timestamp;
/**
* app_hash_root is the Merkle root of all AppHashs in this epoch
* It will be used for proving a block is in an epoch
*
* @generated from field: bytes app_hash_root = 5;
*/
appHashRoot = new Uint8Array(0);
/**
* sealer is the last block of the sealed epoch
* sealer_app_hash points to the sealer but stored in the 1st header
* of the next epoch
*
* @generated from field: bytes sealer_app_hash = 6;
*/
sealerAppHash = new Uint8Array(0);
/**
* sealer_block_hash is the hash of the sealer
* the validator set has generated a BLS multisig on the hash,
* i.e., hash of the last block in the epoch
*
* @generated from field: bytes sealer_block_hash = 7;
*/
sealerBlockHash = new Uint8Array(0);
constructor(data?: PartialMessage<Epoch>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.epoching.v1.Epoch";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "epoch_number", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 2, name: "current_epoch_interval", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 3, name: "first_block_height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 4, name: "last_block_time", kind: "message", T: Timestamp },
{ no: 5, name: "app_hash_root", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 6, name: "sealer_app_hash", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 7, name: "sealer_block_hash", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Epoch {
return new Epoch().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Epoch {
return new Epoch().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Epoch {
return new Epoch().fromJsonString(jsonString, options);
}
static equals(a: Epoch | PlainMessage<Epoch> | undefined, b: Epoch | PlainMessage<Epoch> | undefined): boolean {
return proto3.util.equals(Epoch, a, b);
}
}
/**
* QueuedMessage is a message that can change the validator set and is delayed
* to the end of an epoch
*
* @generated from message babylon.epoching.v1.QueuedMessage
*/
export class QueuedMessage extends Message<QueuedMessage> {
/**
* tx_id is the ID of the tx that contains the message
*
* @generated from field: bytes tx_id = 1;
*/
txId = new Uint8Array(0);
/**
* msg_id is the original message ID, i.e., hash of the marshaled message
*
* @generated from field: bytes msg_id = 2;
*/
msgId = new Uint8Array(0);
/**
* block_height is the height when this msg is submitted to Babylon
*
* @generated from field: uint64 block_height = 3;
*/
blockHeight = protoInt64.zero;
/**
* block_time is the timestamp when this msg is submitted to Babylon
*
* @generated from field: google.protobuf.Timestamp block_time = 4;
*/
blockTime?: Timestamp;
/**
* msg is the actual message that is sent by a user and is queued by the
* epoching module
*
* @generated from oneof babylon.epoching.v1.QueuedMessage.msg
*/
msg: {
/**
* @generated from field: cosmos.staking.v1beta1.MsgCreateValidator msg_create_validator = 5;
*/
value: MsgCreateValidator;
case: "msgCreateValidator";
} | {
/**
* @generated from field: cosmos.staking.v1beta1.MsgDelegate msg_delegate = 6;
*/
value: MsgDelegate;
case: "msgDelegate";
} | {
/**
* @generated from field: cosmos.staking.v1beta1.MsgUndelegate msg_undelegate = 7;
*/
value: MsgUndelegate;
case: "msgUndelegate";
} | {
/**
* @generated from field: cosmos.staking.v1beta1.MsgBeginRedelegate msg_begin_redelegate = 8;
*/
value: MsgBeginRedelegate;
case: "msgBeginRedelegate";
} | {
/**
* @generated from field: cosmos.staking.v1beta1.MsgCancelUnbondingDelegation msg_cancel_unbonding_delegation = 9;
*/
value: MsgCancelUnbondingDelegation;
case: "msgCancelUnbondingDelegation";
} | { case: undefined; value?: undefined } = { case: undefined };
constructor(data?: PartialMessage<QueuedMessage>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.epoching.v1.QueuedMessage";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "tx_id", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 2, name: "msg_id", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 3, name: "block_height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 4, name: "block_time", kind: "message", T: Timestamp },
{ no: 5, name: "msg_create_validator", kind: "message", T: MsgCreateValidator, oneof: "msg" },
{ no: 6, name: "msg_delegate", kind: "message", T: MsgDelegate, oneof: "msg" },
{ no: 7, name: "msg_undelegate", kind: "message", T: MsgUndelegate, oneof: "msg" },
{ no: 8, name: "msg_begin_redelegate", kind: "message", T: MsgBeginRedelegate, oneof: "msg" },
{ no: 9, name: "msg_cancel_unbonding_delegation", kind: "message", T: MsgCancelUnbondingDelegation, oneof: "msg" },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): QueuedMessage {
return new QueuedMessage().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): QueuedMessage {
return new QueuedMessage().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): QueuedMessage {
return new QueuedMessage().fromJsonString(jsonString, options);
}
static equals(a: QueuedMessage | PlainMessage<QueuedMessage> | undefined, b: QueuedMessage | PlainMessage<QueuedMessage> | undefined): boolean {
return proto3.util.equals(QueuedMessage, a, b);
}
}
/**
* ValStateUpdate is a message that records a state update of a validator
*
* @generated from message babylon.epoching.v1.ValStateUpdate
*/
export class ValStateUpdate extends Message<ValStateUpdate> {
/**
* @generated from field: babylon.epoching.v1.BondState state = 1;
*/
state = BondState.CREATED;
/**
* @generated from field: uint64 block_height = 2;
*/
blockHeight = protoInt64.zero;
/**
* @generated from field: google.protobuf.Timestamp block_time = 3;
*/
blockTime?: Timestamp;
constructor(data?: PartialMessage<ValStateUpdate>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.epoching.v1.ValStateUpdate";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "state", kind: "enum", T: proto3.getEnumType(BondState) },
{ no: 2, name: "block_height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 3, name: "block_time", kind: "message", T: Timestamp },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ValStateUpdate {
return new ValStateUpdate().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ValStateUpdate {
return new ValStateUpdate().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ValStateUpdate {
return new ValStateUpdate().fromJsonString(jsonString, options);
}
static equals(a: ValStateUpdate | PlainMessage<ValStateUpdate> | undefined, b: ValStateUpdate | PlainMessage<ValStateUpdate> | undefined): boolean {
return proto3.util.equals(ValStateUpdate, a, b);
}
}
/**
* ValidatorLifecycle is a message that records the lifecycle of
* a validator
*
* @generated from message babylon.epoching.v1.ValidatorLifecycle
*/
export class ValidatorLifecycle extends Message<ValidatorLifecycle> {
/**
* @generated from field: string val_addr = 1;
*/
valAddr = "";
/**
* @generated from field: repeated babylon.epoching.v1.ValStateUpdate val_life = 2;
*/
valLife: ValStateUpdate[] = [];
constructor(data?: PartialMessage<ValidatorLifecycle>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.epoching.v1.ValidatorLifecycle";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "val_addr", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "val_life", kind: "message", T: ValStateUpdate, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ValidatorLifecycle {
return new ValidatorLifecycle().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ValidatorLifecycle {
return new ValidatorLifecycle().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ValidatorLifecycle {
return new ValidatorLifecycle().fromJsonString(jsonString, options);
}
static equals(a: ValidatorLifecycle | PlainMessage<ValidatorLifecycle> | undefined, b: ValidatorLifecycle | PlainMessage<ValidatorLifecycle> | undefined): boolean {
return proto3.util.equals(ValidatorLifecycle, a, b);
}
}
/**
* DelegationStateUpdate is the message that records a state update of a
* delegation
*
* @generated from message babylon.epoching.v1.DelegationStateUpdate
*/
export class DelegationStateUpdate extends Message<DelegationStateUpdate> {
/**
* @generated from field: babylon.epoching.v1.BondState state = 1;
*/
state = BondState.CREATED;
/**
* @generated from field: string val_addr = 2;
*/
valAddr = "";
/**
* @generated from field: cosmos.base.v1beta1.Coin amount = 3;
*/
amount?: Coin;
/**
* @generated from field: uint64 block_height = 4;
*/
blockHeight = protoInt64.zero;
/**
* @generated from field: google.protobuf.Timestamp block_time = 5;
*/
blockTime?: Timestamp;
constructor(data?: PartialMessage<DelegationStateUpdate>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.epoching.v1.DelegationStateUpdate";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "state", kind: "enum", T: proto3.getEnumType(BondState) },
{ no: 2, name: "val_addr", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "amount", kind: "message", T: Coin },
{ no: 4, name: "block_height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 5, name: "block_time", kind: "message", T: Timestamp },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): DelegationStateUpdate {
return new DelegationStateUpdate().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): DelegationStateUpdate {
return new DelegationStateUpdate().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): DelegationStateUpdate {
return new DelegationStateUpdate().fromJsonString(jsonString, options);
}
static equals(a: DelegationStateUpdate | PlainMessage<DelegationStateUpdate> | undefined, b: DelegationStateUpdate | PlainMessage<DelegationStateUpdate> | undefined): boolean {
return proto3.util.equals(DelegationStateUpdate, a, b);
}
}
/**
* ValidatorLifecycle is a message that records the lifecycle of
* a delegation
*
* @generated from message babylon.epoching.v1.DelegationLifecycle
*/
export class DelegationLifecycle extends Message<DelegationLifecycle> {
/**
* @generated from field: string del_addr = 1;
*/
delAddr = "";
/**
* @generated from field: repeated babylon.epoching.v1.DelegationStateUpdate del_life = 2;
*/
delLife: DelegationStateUpdate[] = [];
constructor(data?: PartialMessage<DelegationLifecycle>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.epoching.v1.DelegationLifecycle";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "del_addr", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "del_life", kind: "message", T: DelegationStateUpdate, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): DelegationLifecycle {
return new DelegationLifecycle().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): DelegationLifecycle {
return new DelegationLifecycle().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): DelegationLifecycle {
return new DelegationLifecycle().fromJsonString(jsonString, options);
}
static equals(a: DelegationLifecycle | PlainMessage<DelegationLifecycle> | undefined, b: DelegationLifecycle | PlainMessage<DelegationLifecycle> | undefined): boolean {
return proto3.util.equals(DelegationLifecycle, a, b);
}
}
/**
* Validator is a message that denotes a validator
*
* @generated from message babylon.epoching.v1.Validator
*/
export class Validator extends Message<Validator> {
/**
* addr is the validator's address (in sdk.ValAddress)
*
* @generated from field: bytes addr = 1;
*/
addr = new Uint8Array(0);
/**
* power is the validator's voting power
*
* @generated from field: int64 power = 2;
*/
power = protoInt64.zero;
constructor(data?: PartialMessage<Validator>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.epoching.v1.Validator";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "addr", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 2, name: "power", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Validator {
return new Validator().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Validator {
return new Validator().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Validator {
return new Validator().fromJsonString(jsonString, options);
}
static equals(a: Validator | PlainMessage<Validator> | undefined, b: Validator | PlainMessage<Validator> | undefined): boolean {
return proto3.util.equals(Validator, a, b);
}
}

View File

@ -0,0 +1,476 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/epoching/v1/events.proto (package babylon.epoching.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, protoInt64 } from "@bufbuild/protobuf";
/**
* EventBeginEpoch is the event emitted when an epoch has started
*
* @generated from message babylon.epoching.v1.EventBeginEpoch
*/
export class EventBeginEpoch extends Message<EventBeginEpoch> {
/**
* @generated from field: uint64 epoch_number = 1;
*/
epochNumber = protoInt64.zero;
constructor(data?: PartialMessage<EventBeginEpoch>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.epoching.v1.EventBeginEpoch";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "epoch_number", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventBeginEpoch {
return new EventBeginEpoch().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventBeginEpoch {
return new EventBeginEpoch().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventBeginEpoch {
return new EventBeginEpoch().fromJsonString(jsonString, options);
}
static equals(a: EventBeginEpoch | PlainMessage<EventBeginEpoch> | undefined, b: EventBeginEpoch | PlainMessage<EventBeginEpoch> | undefined): boolean {
return proto3.util.equals(EventBeginEpoch, a, b);
}
}
/**
* EventEndEpoch is the event emitted when an epoch has ended
*
* @generated from message babylon.epoching.v1.EventEndEpoch
*/
export class EventEndEpoch extends Message<EventEndEpoch> {
/**
* @generated from field: uint64 epoch_number = 1;
*/
epochNumber = protoInt64.zero;
constructor(data?: PartialMessage<EventEndEpoch>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.epoching.v1.EventEndEpoch";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "epoch_number", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventEndEpoch {
return new EventEndEpoch().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventEndEpoch {
return new EventEndEpoch().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventEndEpoch {
return new EventEndEpoch().fromJsonString(jsonString, options);
}
static equals(a: EventEndEpoch | PlainMessage<EventEndEpoch> | undefined, b: EventEndEpoch | PlainMessage<EventEndEpoch> | undefined): boolean {
return proto3.util.equals(EventEndEpoch, a, b);
}
}
/**
* EventHandleQueuedMsg is the event emitted when a queued message has been
* handled
*
* @generated from message babylon.epoching.v1.EventHandleQueuedMsg
*/
export class EventHandleQueuedMsg extends Message<EventHandleQueuedMsg> {
/**
* @generated from field: string original_event_type = 1;
*/
originalEventType = "";
/**
* @generated from field: uint64 epoch_number = 2;
*/
epochNumber = protoInt64.zero;
/**
* @generated from field: uint64 height = 3;
*/
height = protoInt64.zero;
/**
* @generated from field: bytes tx_id = 4;
*/
txId = new Uint8Array(0);
/**
* @generated from field: bytes msg_id = 5;
*/
msgId = new Uint8Array(0);
/**
* @generated from field: repeated bytes original_attributes = 6;
*/
originalAttributes: Uint8Array[] = [];
/**
* @generated from field: string error = 7;
*/
error = "";
constructor(data?: PartialMessage<EventHandleQueuedMsg>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.epoching.v1.EventHandleQueuedMsg";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "original_event_type", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "epoch_number", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 3, name: "height", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 4, name: "tx_id", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 5, name: "msg_id", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
{ no: 6, name: "original_attributes", kind: "scalar", T: 12 /* ScalarType.BYTES */, repeated: true },
{ no: 7, name: "error", kind: "scalar", T: 9 /* ScalarType.STRING */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventHandleQueuedMsg {
return new EventHandleQueuedMsg().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventHandleQueuedMsg {
return new EventHandleQueuedMsg().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventHandleQueuedMsg {
return new EventHandleQueuedMsg().fromJsonString(jsonString, options);
}
static equals(a: EventHandleQueuedMsg | PlainMessage<EventHandleQueuedMsg> | undefined, b: EventHandleQueuedMsg | PlainMessage<EventHandleQueuedMsg> | undefined): boolean {
return proto3.util.equals(EventHandleQueuedMsg, a, b);
}
}
/**
* EventSlashThreshold is the event emitted when a set of validators have been
* slashed
*
* @generated from message babylon.epoching.v1.EventSlashThreshold
*/
export class EventSlashThreshold extends Message<EventSlashThreshold> {
/**
* @generated from field: int64 slashed_voting_power = 1;
*/
slashedVotingPower = protoInt64.zero;
/**
* @generated from field: int64 total_voting_power = 2;
*/
totalVotingPower = protoInt64.zero;
/**
* @generated from field: repeated bytes slashed_validators = 3;
*/
slashedValidators: Uint8Array[] = [];
constructor(data?: PartialMessage<EventSlashThreshold>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.epoching.v1.EventSlashThreshold";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "slashed_voting_power", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
{ no: 2, name: "total_voting_power", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
{ no: 3, name: "slashed_validators", kind: "scalar", T: 12 /* ScalarType.BYTES */, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventSlashThreshold {
return new EventSlashThreshold().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventSlashThreshold {
return new EventSlashThreshold().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventSlashThreshold {
return new EventSlashThreshold().fromJsonString(jsonString, options);
}
static equals(a: EventSlashThreshold | PlainMessage<EventSlashThreshold> | undefined, b: EventSlashThreshold | PlainMessage<EventSlashThreshold> | undefined): boolean {
return proto3.util.equals(EventSlashThreshold, a, b);
}
}
/**
* EventWrappedDelegate is the event emitted when a MsgWrappedDelegate has been
* queued
*
* @generated from message babylon.epoching.v1.EventWrappedDelegate
*/
export class EventWrappedDelegate extends Message<EventWrappedDelegate> {
/**
* @generated from field: string delegator_address = 1;
*/
delegatorAddress = "";
/**
* @generated from field: string validator_address = 2;
*/
validatorAddress = "";
/**
* @generated from field: uint64 amount = 3;
*/
amount = protoInt64.zero;
/**
* @generated from field: string denom = 4;
*/
denom = "";
/**
* @generated from field: uint64 epoch_boundary = 5;
*/
epochBoundary = protoInt64.zero;
constructor(data?: PartialMessage<EventWrappedDelegate>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.epoching.v1.EventWrappedDelegate";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "delegator_address", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "validator_address", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "amount", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 4, name: "denom", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 5, name: "epoch_boundary", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventWrappedDelegate {
return new EventWrappedDelegate().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventWrappedDelegate {
return new EventWrappedDelegate().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventWrappedDelegate {
return new EventWrappedDelegate().fromJsonString(jsonString, options);
}
static equals(a: EventWrappedDelegate | PlainMessage<EventWrappedDelegate> | undefined, b: EventWrappedDelegate | PlainMessage<EventWrappedDelegate> | undefined): boolean {
return proto3.util.equals(EventWrappedDelegate, a, b);
}
}
/**
* EventWrappedUndelegate is the event emitted when a MsgWrappedUndelegate has
* been queued
*
* @generated from message babylon.epoching.v1.EventWrappedUndelegate
*/
export class EventWrappedUndelegate extends Message<EventWrappedUndelegate> {
/**
* @generated from field: string delegator_address = 1;
*/
delegatorAddress = "";
/**
* @generated from field: string validator_address = 2;
*/
validatorAddress = "";
/**
* @generated from field: uint64 amount = 3;
*/
amount = protoInt64.zero;
/**
* @generated from field: string denom = 4;
*/
denom = "";
/**
* @generated from field: uint64 epoch_boundary = 5;
*/
epochBoundary = protoInt64.zero;
constructor(data?: PartialMessage<EventWrappedUndelegate>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.epoching.v1.EventWrappedUndelegate";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "delegator_address", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "validator_address", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "amount", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 4, name: "denom", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 5, name: "epoch_boundary", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventWrappedUndelegate {
return new EventWrappedUndelegate().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventWrappedUndelegate {
return new EventWrappedUndelegate().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventWrappedUndelegate {
return new EventWrappedUndelegate().fromJsonString(jsonString, options);
}
static equals(a: EventWrappedUndelegate | PlainMessage<EventWrappedUndelegate> | undefined, b: EventWrappedUndelegate | PlainMessage<EventWrappedUndelegate> | undefined): boolean {
return proto3.util.equals(EventWrappedUndelegate, a, b);
}
}
/**
* EventWrappedBeginRedelegate is the event emitted when a
* MsgWrappedBeginRedelegate has been queued
*
* @generated from message babylon.epoching.v1.EventWrappedBeginRedelegate
*/
export class EventWrappedBeginRedelegate extends Message<EventWrappedBeginRedelegate> {
/**
* @generated from field: string delegator_address = 1;
*/
delegatorAddress = "";
/**
* @generated from field: string source_validator_address = 2;
*/
sourceValidatorAddress = "";
/**
* @generated from field: string destination_validator_address = 3;
*/
destinationValidatorAddress = "";
/**
* @generated from field: uint64 amount = 4;
*/
amount = protoInt64.zero;
/**
* @generated from field: string denom = 5;
*/
denom = "";
/**
* @generated from field: uint64 epoch_boundary = 6;
*/
epochBoundary = protoInt64.zero;
constructor(data?: PartialMessage<EventWrappedBeginRedelegate>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.epoching.v1.EventWrappedBeginRedelegate";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "delegator_address", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "source_validator_address", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "destination_validator_address", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 4, name: "amount", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 5, name: "denom", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 6, name: "epoch_boundary", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventWrappedBeginRedelegate {
return new EventWrappedBeginRedelegate().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventWrappedBeginRedelegate {
return new EventWrappedBeginRedelegate().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventWrappedBeginRedelegate {
return new EventWrappedBeginRedelegate().fromJsonString(jsonString, options);
}
static equals(a: EventWrappedBeginRedelegate | PlainMessage<EventWrappedBeginRedelegate> | undefined, b: EventWrappedBeginRedelegate | PlainMessage<EventWrappedBeginRedelegate> | undefined): boolean {
return proto3.util.equals(EventWrappedBeginRedelegate, a, b);
}
}
/**
* EventWrappedCancelUnbondingDelegation is the event emitted when a
* MsgWrappedCancelUnbondingDelegation has been queued
*
* @generated from message babylon.epoching.v1.EventWrappedCancelUnbondingDelegation
*/
export class EventWrappedCancelUnbondingDelegation extends Message<EventWrappedCancelUnbondingDelegation> {
/**
* @generated from field: string delegator_address = 1;
*/
delegatorAddress = "";
/**
* @generated from field: string validator_address = 2;
*/
validatorAddress = "";
/**
* @generated from field: uint64 amount = 3;
*/
amount = protoInt64.zero;
/**
* @generated from field: int64 creation_height = 4;
*/
creationHeight = protoInt64.zero;
/**
* @generated from field: uint64 epoch_boundary = 5;
*/
epochBoundary = protoInt64.zero;
constructor(data?: PartialMessage<EventWrappedCancelUnbondingDelegation>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.epoching.v1.EventWrappedCancelUnbondingDelegation";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "delegator_address", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "validator_address", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "amount", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
{ no: 4, name: "creation_height", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
{ no: 5, name: "epoch_boundary", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): EventWrappedCancelUnbondingDelegation {
return new EventWrappedCancelUnbondingDelegation().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): EventWrappedCancelUnbondingDelegation {
return new EventWrappedCancelUnbondingDelegation().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): EventWrappedCancelUnbondingDelegation {
return new EventWrappedCancelUnbondingDelegation().fromJsonString(jsonString, options);
}
static equals(a: EventWrappedCancelUnbondingDelegation | PlainMessage<EventWrappedCancelUnbondingDelegation> | undefined, b: EventWrappedCancelUnbondingDelegation | PlainMessage<EventWrappedCancelUnbondingDelegation> | undefined): boolean {
return proto3.util.equals(EventWrappedCancelUnbondingDelegation, a, b);
}
}

View File

@ -0,0 +1,48 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/epoching/v1/genesis.proto (package babylon.epoching.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3 } from "@bufbuild/protobuf";
import { Params } from "./params_pb.js";
/**
* GenesisState defines the epoching module's genesis state.
*
* @generated from message babylon.epoching.v1.GenesisState
*/
export class GenesisState extends Message<GenesisState> {
/**
* @generated from field: babylon.epoching.v1.Params params = 1;
*/
params?: Params;
constructor(data?: PartialMessage<GenesisState>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.epoching.v1.GenesisState";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "params", kind: "message", T: Params },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GenesisState {
return new GenesisState().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GenesisState {
return new GenesisState().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GenesisState {
return new GenesisState().fromJsonString(jsonString, options);
}
static equals(a: GenesisState | PlainMessage<GenesisState> | undefined, b: GenesisState | PlainMessage<GenesisState> | undefined): boolean {
return proto3.util.equals(GenesisState, a, b);
}
}

View File

@ -0,0 +1,49 @@
// @generated by protoc-gen-es v1.2.0 with parameter "target=ts"
// @generated from file babylon/epoching/v1/params.proto (package babylon.epoching.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, protoInt64 } from "@bufbuild/protobuf";
/**
* Params defines the parameters for the module.
*
* @generated from message babylon.epoching.v1.Params
*/
export class Params extends Message<Params> {
/**
* epoch_interval is the number of consecutive blocks to form an epoch
*
* @generated from field: uint64 epoch_interval = 1;
*/
epochInterval = protoInt64.zero;
constructor(data?: PartialMessage<Params>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "babylon.epoching.v1.Params";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "epoch_interval", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Params {
return new Params().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Params {
return new Params().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Params {
return new Params().fromJsonString(jsonString, options);
}
static equals(a: Params | PlainMessage<Params> | undefined, b: Params | PlainMessage<Params> | undefined): boolean {
return proto3.util.equals(Params, a, b);
}
}

View File

@ -0,0 +1,120 @@
// @generated by protoc-gen-cosmes v0.0.1 with parameter "target=ts"
// @generated from file babylon/epoching/v1/query.proto (package babylon.epoching.v1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import { QueryCurrentEpochRequest, QueryCurrentEpochResponse, QueryDelegationLifecycleRequest, QueryDelegationLifecycleResponse, QueryEpochInfoRequest, QueryEpochInfoResponse, QueryEpochMsgsRequest, QueryEpochMsgsResponse, QueryEpochsInfoRequest, QueryEpochsInfoResponse, QueryEpochValSetRequest, QueryEpochValSetResponse, QueryLatestEpochMsgsRequest, QueryLatestEpochMsgsResponse, QueryParamsRequest, QueryParamsResponse, QueryValidatorLifecycleRequest, QueryValidatorLifecycleResponse } from "./query_pb.js";
const TYPE_NAME = "babylon.epoching.v1.Query";
/**
* Params queries the parameters of the module.
*
* @generated from rpc babylon.epoching.v1.Query.Params
*/
export const QueryParamsService = {
typeName: TYPE_NAME,
method: "Params",
Request: QueryParamsRequest,
Response: QueryParamsResponse,
} as const;
/**
* EpochInfo queries the information of a given epoch
*
* @generated from rpc babylon.epoching.v1.Query.EpochInfo
*/
export const QueryEpochInfoService = {
typeName: TYPE_NAME,
method: "EpochInfo",
Request: QueryEpochInfoRequest,
Response: QueryEpochInfoResponse,
} as const;
/**
* EpochsInfo queries the metadata of epochs in a given range, depending on
* the parameters in the pagination request. Th main use case will be querying
* the latest epochs in time order.
*
* @generated from rpc babylon.epoching.v1.Query.EpochsInfo
*/
export const QueryEpochsInfoService = {
typeName: TYPE_NAME,
method: "EpochsInfo",
Request: QueryEpochsInfoRequest,
Response: QueryEpochsInfoResponse,
} as const;
/**
* CurrentEpoch queries the current epoch
*
* @generated from rpc babylon.epoching.v1.Query.CurrentEpoch
*/
export const QueryCurrentEpochService = {
typeName: TYPE_NAME,
method: "CurrentEpoch",
Request: QueryCurrentEpochRequest,
Response: QueryCurrentEpochResponse,
} as const;
/**
* EpochMsgs queries the messages of a given epoch
*
* @generated from rpc babylon.epoching.v1.Query.EpochMsgs
*/
export const QueryEpochMsgsService = {
typeName: TYPE_NAME,
method: "EpochMsgs",
Request: QueryEpochMsgsRequest,
Response: QueryEpochMsgsResponse,
} as const;
/**
* LatestEpochMsgs queries the messages within a given number of most recent
* epochs
*
* @generated from rpc babylon.epoching.v1.Query.LatestEpochMsgs
*/
export const QueryLatestEpochMsgsService = {
typeName: TYPE_NAME,
method: "LatestEpochMsgs",
Request: QueryLatestEpochMsgsRequest,
Response: QueryLatestEpochMsgsResponse,
} as const;
/**
* ValidatorLifecycle queries the lifecycle of a given validator
*
* @generated from rpc babylon.epoching.v1.Query.ValidatorLifecycle
*/
export const QueryValidatorLifecycleService = {
typeName: TYPE_NAME,
method: "ValidatorLifecycle",
Request: QueryValidatorLifecycleRequest,
Response: QueryValidatorLifecycleResponse,
} as const;
/**
* DelegationLifecycle queries the lifecycle of a given delegation
*
* @generated from rpc babylon.epoching.v1.Query.DelegationLifecycle
*/
export const QueryDelegationLifecycleService = {
typeName: TYPE_NAME,
method: "DelegationLifecycle",
Request: QueryDelegationLifecycleRequest,
Response: QueryDelegationLifecycleResponse,
} as const;
/**
* EpochValSet queries the validator set of a given epoch
*
* @generated from rpc babylon.epoching.v1.Query.EpochValSet
*/
export const QueryEpochValSetService = {
typeName: TYPE_NAME,
method: "EpochValSet",
Request: QueryEpochValSetRequest,
Response: QueryEpochValSetResponse,
} as const;

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More