utils

package
v0.0.41 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CAIP2Namespace added in v0.0.40

func CAIP2Namespace(chain string) string

CAIP2Namespace returns the namespace component of a CAIP-2 chain id ("eip155:1" → "eip155"). Returns "" when the id has no namespace.

func CanonicalizeAddressByNamespace added in v0.0.40

func CanonicalizeAddressByNamespace(chain, addr string) (string, error)

CanonicalizeAddressByNamespace canonicalizes an address for the given CAIP-2 chain. Empty input passes through (optional fields).

func CanonicalizeEVMAddress added in v0.0.40

func CanonicalizeEVMAddress(s string) (string, error)

CanonicalizeEVMAddress validates s as a 20-byte hex address (with or without 0x) and returns the EIP-55 checksummed, 0x-prefixed form.

func CanonicalizeEVMHash added in v0.0.40

func CanonicalizeEVMHash(s string) (string, error)

CanonicalizeEVMHash validates s as a 32-byte hex hash (with or without 0x) and returns the 0x-prefixed lowercase form.

func CanonicalizeHexBlob added in v0.0.40

func CanonicalizeHexBlob(s string) string

CanonicalizeHexBlob lenient-canonicalizes free-length hex payloads (raw_payload, verification_data): valid hex (with or without 0x, even length) → 0x-prefixed lowercase; anything else is returned trimmed as-is.

func CanonicalizeTxHashByNamespace added in v0.0.40

func CanonicalizeTxHashByNamespace(chain, txHash string) (string, error)

CanonicalizeTxHashByNamespace canonicalizes a transaction hash/signature for the given CAIP-2 chain. Empty input passes through (e.g. failed outbound observations carry no hash).

func ConvertAnyAddressToBytes

func ConvertAnyAddressToBytes(addr string) ([]byte, error)

convert the 0x and/or cosmos address to raw bytes

func ConvertAnyAddressesToBytes

func ConvertAnyAddressesToBytes[T ByteType](addr ...string) ([]T, error)

return either []byte or common.Address

func ExtractEvmChainID added in v0.0.13

func ExtractEvmChainID(chainID string) (string, error)

Returns evm chainId, e.g. push-chain-42101 -> 42101

func GetAddressPair

func GetAddressPair(addr string) (sdk.AccAddress, common.Address, error)

get address pair returns both the cosmos and the 0x addresses, or an error

func GetEnvRPCOverride

func GetEnvRPCOverride(chain string) string

chain is a CAIP-2 chain identifier, e.g., "eip155:1"

func HexToBytes

func HexToBytes(s string) ([]byte, error)

func IsValidAddress

func IsValidAddress(addr string, at AddressType) bool

IsValidAddress checks if the address is a valid COSMOS, HEX (0x), or EITHER address

func LenientCanonicalizeAddress added in v0.0.40

func LenientCanonicalizeAddress(chain, addr string) string

LenientCanonicalizeAddress canonicalizes addr for chain, falling back to the trimmed input when it does not parse.

func LenientCanonicalizeEVMAddress added in v0.0.40

func LenientCanonicalizeEVMAddress(addr string) string

LenientCanonicalizeEVMAddress canonicalizes a Push-Chain (EVM) address to EIP-55, falling back to the trimmed input when it does not parse.

func LenientCanonicalizeTxHash added in v0.0.40

func LenientCanonicalizeTxHash(chain, txHash string) string

LenientCanonicalizeTxHash canonicalizes txHash for chain, falling back to the trimmed input when it does not parse.

func MustConvertCosmosToHex

func MustConvertCosmosToHex(addr string) string

func StringToBigInt

func StringToBigInt(s string) *big.Int

Types

type AddressType

type AddressType int

create an enum for COSMOS, 0x, or EITHER

const (
	COSMOS AddressType = iota
	HEX
	EITHER
)

type ByteType

type ByteType interface {
	[]byte | common.Address
}

Type constraint that allows either []byte or common.Address

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL