Skip to content

Cosmos.ts

This module handles Cosmos related functionality.

Added in v2.0.0

Signature

export declare class ChannelDestination

Added in v2.0.0

Source: src/Cosmos.ts:91

Signature

export declare class ChannelSource

Added in v2.0.0

Source: src/Cosmos.ts:105

A neutral CosmWasmClient that can be used for general-purpose operations that don’t specifically target source or destination chains

Signature

export declare class Client

Added in v2.0.0

Source: src/Cosmos.ts:148

Context for providing a CosmWasmClient for the destination chain

Signature

export declare class ClientDestination

Added in v2.0.0

Source: src/Cosmos.ts:134

Context for providing a CosmWasmClient for the source chain

Signature

export declare class ClientSource

Added in v2.0.0

Source: src/Cosmos.ts:121

Signature

export declare class DestinationConfig

Added in v2.0.0

Source: src/Cosmos.ts:172

Context for providing a SigningCosmWasmClient

Signature

export declare class SigningClient

Added in v2.0.0

Source: src/Cosmos.ts:161

Error type for CosmWasm client failures

Signature

export declare class ClientError

Added in v2.0.0

Source: src/Cosmos.ts:183

Error type for CosmWasm contract execution failures

Signature

export declare class ExecuteContractError

Added in v2.0.0

Source: src/Cosmos.ts:205

Error when fetching a balance at latest height

Signature

export declare class GetBalanceError

Added in v2.0.0

Source: src/Cosmos.ts:228

Error when fetching the latest block height

Signature

export declare class GetHeightError

Added in v2.0.0

Source: src/Cosmos.ts:218

Error type for HttpRequest execution failures

Signature

export declare class HttpRequestFailed

Added in v2.0.0

Source: src/Cosmos.ts:341

Error type for CosmWasm contract query failures

Signature

export declare class QueryContractError

Added in v2.0.0

Source: src/Cosmos.ts:193

Added in v2.0.0

Signature

export interface Channel {
readonly ucs03address: string
readonly channelId: number
}

Source: src/Cosmos.ts:43

Added in v2.0.0

Signature

export interface PublicClient {
client: CosmWasmClient
}

Source: src/Cosmos.ts:27

Added in v2.0.0

Signature

export interface SigningClient {
client: SigningCosmWasmClient
}

Source: src/Cosmos.ts:35

Added in v2.0.0

Interface for CW20 token balance response

Signature

export interface Cw20AllowanceResponse {
allowance: number
expiration: any // XXX
}

Source: src/Cosmos.ts:459

Added in v2.0.0

Interface for CW20 token balance response

Signature

export interface Cw20BalanceResponse {
balance: string
}

Source: src/Cosmos.ts:449

Added in v2.0.0

Interface for CW20 token metadata

Signature

export interface Cw20TokenInfo {
name: string
symbol: string
decimals: number
total_supply: string
}

Source: src/Cosmos.ts:436

Added in v2.0.0

Signature

export declare const channelBalance: (
path: bigint,
token: string
) => Effect.Effect<unknown, TimeoutException | QueryContractError, ClientDestination | ChannelDestination>

Source: src/Cosmos.ts:656

Added in v2.0.0

Signature

export declare const channelBalanceAtHeight: (
rest: string,
path: bigint,
token: string,
height: number
) => Effect.Effect<string, QueryContractError, ChannelDestination>

Source: src/Cosmos.ts:675

Added in v2.0.0

A type-safe wrapper around CosmWasm’s executeContract that handles error cases and returns an Effect with proper type inference.

Signature

export declare const executeContract: (
senderAddress: string,
contractAddress: string,
msg: Record<string, unknown>,
funds?: ReadonlyArray<{ denom: string; amount: string }>
) => Effect.Effect<ExecuteResult, ExecuteContractError, SigningClient>

Source: src/Cosmos.ts:270

Added in v2.0.0

Fetch an account’s balance for a denom at a specific block height.

Signature

export declare function getBalanceAtHeight(restEndpoint: string, address: string, denom: string, height: number)

Source: src/Cosmos.ts:392

Added in v2.0.0

Wrap CosmWasmClient.getBalance() in an Effect

Signature

export declare function getBalanceNow(client: CosmWasmClient, address: string, denom: string)

Source: src/Cosmos.ts:321

Added in v2.0.0

Wrap CosmWasmClient.getHeight() in an Effect

Signature

export declare function getChainHeight(client: CosmWasmClient)

Source: src/Cosmos.ts:303

Added in v2.0.0

Checks whether a denom is a native token or CW20.

Signature

export declare const isDenomNative: (denom: string) => Effect.Effect<boolean, never, Client>

Source: src/Cosmos.ts:641

Added in v2.0.0

Signature

export declare const predictQuoteToken: (
baseToken: string
) => Effect.Effect<`0x${string}`, TimeoutException | QueryContractError, ClientDestination | ChannelDestination>

Source: src/Cosmos.ts:695

Added in v2.0.0

A type-safe wrapper around CosmWasm’s queryContract that handles error cases and returns an Effect with proper type inference.

Signature

export declare const queryContract: <T = unknown>(
client: CosmWasmClient,
contractAddress: string,
queryMsg: Record<string, unknown>
) => Effect.Effect<T, TimeoutException | QueryContractError, never>

Source: src/Cosmos.ts:244

Added in v2.0.0

Query a contract at an explicit block height.

Signature

export declare function queryContractSmartAtHeight<T = unknown>(
restEndpoint: string,
contractAddress: string,
queryMsg: Record<string, unknown>,
height: number
)

Source: src/Cosmos.ts:352

Added in v2.0.0

Read the allowance of a CW20 token for a specific addresses

Signature

export declare const readCw20Allowance: (
contract: AddressCosmosDisplay,
owner: AddressCosmosDisplay,
spender: AddressCosmosDisplay
) => Effect.Effect<number, TimeoutException | QueryContractError, Client>

Source: src/Cosmos.ts:589

Added in v2.0.0

Read the balance of a CW20 token for a specific address

Signature

export declare const readCw20Balance: (
contractAddress: string,
address: string
) => Effect.Effect<string, TimeoutException | QueryContractError, Client>

Source: src/Cosmos.ts:566

Added in v2.0.0

Read the balance of a CW20 token for a specific address

Signature

export declare const readCw20BalanceAtHeight: (
rest: string,
contractAddress: string,
address: string,
height: number
) => Effect.Effect<string, QueryContractError, never>

Source: src/Cosmos.ts:507

Added in v2.0.0

Read CW20 token metadata (name, symbol, decimals, total_supply)

Signature

export declare const readCw20TokenInfo: (
contractAddress: string
) => Effect.Effect<Cw20TokenInfo, TimeoutException | QueryContractError, Client>

Source: src/Cosmos.ts:472

Added in v2.0.0

Read CW20 token total_supply

Signature

export declare const readCw20TotalSupply: (
contractAddress: string
) => Effect.Effect<string, TimeoutException | QueryContractError, Client>

Source: src/Cosmos.ts:487

Added in v2.0.0

Read CW20 token total_supply

Signature

export declare const readCw20TotalSupplyAtHeight: (
rest: string,
contractAddress: string,
height: number
) => Effect.Effect<string, QueryContractError, never>

Source: src/Cosmos.ts:540

Added in v2.0.0

Signature

export declare const sendInstruction: (
instruction: Ucs03.Instruction,
address: string,
funds?: NonEmptyReadonlyArray<{ denom: string; amount: string }>
) => Effect.Effect<ExecuteResult, ExecuteContractError | Utils.CryptoError, SigningClient | ChannelSource>

Source: src/Cosmos.ts:715

Added in v2.0.0

Increase the allowance of a CW20 token for a specific spender.

Signature

export declare const writeCw20IncreaseAllowance: (
contractAddress: string,
senderAddress: string,
spenderAddress: string,
amount: string
) => Effect.Effect<ExecuteResult, ExecuteContractError, SigningClient>

Source: src/Cosmos.ts:620

Added in v2.0.0