UNPKG

@interchainjs/injective

Version:
102 lines (101 loc) 3.91 kB
import { SignatureFormatFunction } from '@interchainjs/auth'; import { BaseCryptoBytes } from '@interchainjs/utils'; /** * Utility functions that implement the BytesUtils functionality mentioned in requirements * Defined first to avoid forward reference issues */ export declare const BytesUtils: { /** * Split signature into components */ splitSignature: (signature: Uint8Array) => { r: Uint8Array; s: Uint8Array; recovery?: number; }; /** * Combine signature components */ combineSignature: (r: Uint8Array, s: Uint8Array, recovery?: number) => Uint8Array; /** * Convert to Uint8Array (arrayify equivalent) */ arrayify: (data: Uint8Array) => Uint8Array; /** * Concatenate byte arrays */ concat: (arrays: Uint8Array[]) => Uint8Array; }; /** * Injective signature format function type * Takes raw signature bytes and returns processed signature bytes */ export type InjectiveSignatureFormatFunction = (signature: Uint8Array) => Uint8Array; /** * Preset Injective signature format functions mapping * These implement the InjectiveSignatureFormat enum (COMPACT, FULL, RAW) mentioned in requirements */ export declare const PRESET_INJECTIVE_SIGNATURE_FORMATS: Record<string, InjectiveSignatureFormatFunction>; /** * Resolve Injective signature format function * @param formatFn - Format function or string identifier * @param defaultFn - Default format to use if formatFn is not provided * @returns Resolved signature format function */ export declare function resolveInjectiveSignatureFormat(formatFn?: InjectiveSignatureFormatFunction | string, defaultFn?: InjectiveSignatureFormatFunction | string): InjectiveSignatureFormatFunction | undefined; /** * Utility class for processing Injective signatures * Implements the configurable signature post-processing logic * that was previously hardcoded in EthSecp256k1Signature.toCompact() */ export declare class InjectiveSignatureProcessor { /** * Process a signature according to the specified format * @param signature - Raw signature bytes (typically 65 bytes with recovery) * @param format - Desired signature format (string or function) * @returns Processed signature bytes */ static processSignature(signature: Uint8Array, format?: SignatureFormatFunction | string): Uint8Array; /** * Convert signature to BaseCryptoBytes for use in workflows * @param signature - Signature bytes * @param format - Desired signature format * @returns BaseCryptoBytes instance */ static toBaseCryptoBytes(signature: Uint8Array, format?: SignatureFormatFunction | string): BaseCryptoBytes; } /** * Legacy compatibility class that implements the EthSecp256k1Signature interface * This provides backward compatibility for code that expects the old toCompact() method */ export declare class EthSecp256k1Signature { readonly signature: Uint8Array; constructor(signature: Uint8Array); /** * Convert signature to compact format * This method maintains backward compatibility with the original implementation * @returns Compact signature as BaseCryptoBytes (Key-like object) */ toCompact(): BaseCryptoBytes; /** * Convert signature to full format * @returns Full signature as BaseCryptoBytes */ toFull(): BaseCryptoBytes; /** * Get raw signature * @returns Raw signature as BaseCryptoBytes */ toRaw(): BaseCryptoBytes; /** * Process signature with configurable format * @param format - Desired signature format * @returns Processed signature as BaseCryptoBytes */ process(format: SignatureFormatFunction | string): BaseCryptoBytes; } /** * Type alias for backward compatibility * Represents the Key class mentioned in the original requirements */ export type Key = BaseCryptoBytes;