Skip to main content

Generated Python types for Xion blockchain protocol buffers

Project description

@burnt-labs/xion-types

What is xion-types?

The xion-types repository is a type definition package that acts as a bridge between different programming languages and the Xion blockchain. Think of it as a "translator" that helps developers work with Xion blockchain data in their preferred programming language.

The Core Problem It Solves

Blockchains like Xion use a data format called Protocol Buffers (Protobuf) to define their data structures. However, most developers don't write code directly in Protobuf - they use languages like TypeScript, Swift, or Kotlin.

Without xion-types, developers would have to:

  • Manually write type definitions for every blockchain data structure
  • Risk making errors when handling blockchain data
  • Spend time figuring out what fields exist and what types they should be

What It Provides

The repository generates type-safe definitions for multiple programming languages:

  • TypeScript/JavaScript - For web apps and Node.js projects
  • Swift - For iOS/macOS apps
  • Kotlin - For Android apps
  • Python - For Python projects
  • Go - For Go projects
  • Rust - For Rust projects
  • Java - For Java applications
  • And more - Including C, C++, C#, Objective-C, PHP, Ruby, and Scala

These type definitions ensure that when developers work with Xion blockchain data (like transactions, account information, or smart contract calls), they get:

  • Autocomplete in their code editor
  • Error checking if they try to use wrong data types
  • Documentation of what fields are available

Benefits

  1. Reduced Development Time - No need to manually write type definitions
  2. Fewer Bugs - Type safety catches errors at compile time
  3. Better Developer Experience - Autocomplete and IntelliSense support
  4. Consistency - Same types across different languages and projects
  5. Maintainability - Types automatically update when the blockchain protocol changes

Table of Contents


Installation

Install the @burnt-labs/xion-types package via npm or yarn:

# Using npm
npm install @burnt-labs/xion-types

# Using yarn
yarn add @burnt-labs/xion-types

Usage

Once installed, you can import the type definitions in your TypeScript project. The types are generated from the Protobuf files used in the Xion project.

import { MyProtobufType } from '@burnt-labs/xion-types/types/filename';

const myData: MyProtobufType = {
  field1: 'value',
  field2: 42
};

Note: Replace filename with the appropriate file name where the type is defined.


Example

Here is a full example of how you might use the @burnt-labs/xion-types package in a TypeScript project:

import { MyProtobufType } from '@burnt-labs/xion-types/types/filename';

function processData(data: MyProtobufType): void {
  console.log(`Field 1: ${data.field1}`);
  console.log(`Field 2: ${data.field2}`);
}

const sampleData: MyProtobufType = {
  field1: 'Hello, Xion!',
  field2: 100
};

processData(sampleData);

This simple example illustrates how you can work with the types generated from Xion's Protobuf definitions.


Development

If you want to modify or regenerate type definitions from Protobuf files, follow these steps:

  1. Initialize and Update Submodules

    # Initialize and update all submodules (contracts and xion)
    make submodules
    
    # Alternatively, you can run these commands manually:
    git submodule init contracts
    git submodule update --init contracts
    git submodule init xion
    git submodule update --init xion
    
  2. Build Docker Image

    # Build the protobuf builder image (required for code generation)
    make build-proto-builder-image
    
    # You can verify the image was built successfully with:
    docker images | grep proto-builder
    
  3. Generate Type Definitions

    Generate types for all supported languages:

    make proto-gen-all
    

    Or generate types for a specific language:

    # TypeScript/JavaScript
    make proto-gen-ts
    
    # Python
    make proto-gen-python
    
    # Swift
    make proto-gen-swift
    
    # Kotlin
    make proto-gen-kotlin
    
    # Go (uses xion's built-in proto generation)
    make proto-gen
    
    # Other languages: proto-gen-c, proto-gen-cpp, proto-gen-java,
    # proto-gen-objc, proto-gen-php, proto-gen-ruby, proto-gen-rust, proto-gen-scala
    
  4. Generate Contract Code (TypeScript)

    make contract-code-gen
    

These steps will generate type definitions from the Protobuf files located in the xion submodule.


License

This project is licensed under the MIT License. See the LICENSE file for details.


For more information, check out Xion's GitHub repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xion_types-26.1.0rc3.tar.gz (363.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xion_types-26.1.0rc3-py3-none-any.whl (821.4 kB view details)

Uploaded Python 3

File details

Details for the file xion_types-26.1.0rc3.tar.gz.

File metadata

  • Download URL: xion_types-26.1.0rc3.tar.gz
  • Upload date:
  • Size: 363.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xion_types-26.1.0rc3.tar.gz
Algorithm Hash digest
SHA256 8dd7bbb634d8a8142af42b0943d045a14e6208128b124ef8bb10c7af83ff2442
MD5 23bd6733c000775952da50bda9c54a92
BLAKE2b-256 66ab2d8fec4b6529c534c1312be5fbb1e39361f4e6fd04a89602e5cfa29e1bba

See more details on using hashes here.

File details

Details for the file xion_types-26.1.0rc3-py3-none-any.whl.

File metadata

  • Download URL: xion_types-26.1.0rc3-py3-none-any.whl
  • Upload date:
  • Size: 821.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xion_types-26.1.0rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 8ad61c0bd384733da8042318db286cd0c8528e06a279d8aa83dd08be13cd10a4
MD5 f2a44258b81a2f374299c47950b6846b
BLAKE2b-256 e6bacab178b771451cb8886e166fd8f7030080354afae3bd9375e86b824b03ba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page