httpay
Version:
HTTPay SDK for interacting with HTTPay smart contracts on Neutron
844 lines (825 loc) • 36.6 kB
TypeScript
import * as _tanstack_react_query from '@tanstack/react-query';
import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
import { StdFee, Coin } from '@cosmjs/amino';
import * as _cosmjs_cosmwasm_stargate from '@cosmjs/cosmwasm-stargate';
import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate';
import * as react_jsx_runtime from 'react/jsx-runtime';
import { ReactNode } from 'react';
import * as z from 'zod';
type Uint128$1 = string;
type Addr = string;
interface CollectedFeesResponse {
collected_fees: [string, Uint128$1][];
fee_percentage: number;
owner: Addr;
}
interface EscrowResponse {
auth_token: string;
caller: Addr;
denom: string;
escrow_id: number;
expires: number;
max_fee: Uint128$1;
provider: Addr;
}
interface EscrowsResponse {
escrows: EscrowResponse[];
}
/**
* This file was automatically generated by @cosmwasm/ts-codegen@1.12.1.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
interface EscrowReadOnlyInterface {
contractAddress: string;
getEscrow: ({ escrowId }: {
escrowId: number;
}) => Promise<EscrowResponse>;
getCollectedFees: () => Promise<CollectedFeesResponse>;
getEscrows: ({ caller, limit, provider, startAfter, }: {
caller?: string;
limit?: number;
provider?: string;
startAfter?: number;
}) => Promise<EscrowsResponse>;
}
declare class EscrowQueryClient implements EscrowReadOnlyInterface {
client: CosmWasmClient;
contractAddress: string;
constructor(client: CosmWasmClient, contractAddress: string);
getEscrow: ({ escrowId, }: {
escrowId: number;
}) => Promise<EscrowResponse>;
getCollectedFees: () => Promise<CollectedFeesResponse>;
getEscrows: ({ caller, limit, provider, startAfter, }: {
caller?: string;
limit?: number;
provider?: string;
startAfter?: number;
}) => Promise<EscrowsResponse>;
}
interface EscrowInterface extends EscrowReadOnlyInterface {
contractAddress: string;
sender: string;
lockFunds: ({ authToken, expires, maxFee, toolId, }: {
authToken: string;
expires: number;
maxFee: Uint128$1;
toolId: string;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
release: ({ escrowId, usageFee, }: {
escrowId: number;
usageFee: Uint128$1;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
refundExpired: ({ escrowId, }: {
escrowId: number;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
claimFees: ({ denom, }: {
denom?: string;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
}
declare class EscrowClient extends EscrowQueryClient implements EscrowInterface {
client: SigningCosmWasmClient;
sender: string;
contractAddress: string;
constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string);
lockFunds: ({ authToken, expires, maxFee, toolId, }: {
authToken: string;
expires: number;
maxFee: Uint128$1;
toolId: string;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
release: ({ escrowId, usageFee, }: {
escrowId: number;
usageFee: Uint128$1;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
refundExpired: ({ escrowId, }: {
escrowId: number;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
claimFees: ({ denom, }: {
denom?: string;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
}
declare const escrowQueryKeys: {
contract: readonly [{
readonly contract: "escrow";
}];
address: (contractAddress: string | undefined) => readonly [{
readonly address: string;
readonly contract: "escrow";
}];
getEscrow: (contractAddress: string | undefined, args?: Record<string, unknown>) => readonly [{
readonly method: "get_escrow";
readonly args: Record<string, unknown>;
readonly address: string;
readonly contract: "escrow";
}];
getCollectedFees: (contractAddress: string | undefined, args?: Record<string, unknown>) => readonly [{
readonly method: "get_collected_fees";
readonly args: Record<string, unknown>;
readonly address: string;
readonly contract: "escrow";
}];
getEscrows: (contractAddress: string | undefined, args?: Record<string, unknown>) => readonly [{
readonly method: "get_escrows";
readonly args: Record<string, unknown>;
readonly address: string;
readonly contract: "escrow";
}];
};
interface EscrowReactQuery<TResponse, TData = TResponse> {
client: EscrowQueryClient | undefined;
options?: Omit<UseQueryOptions<TResponse, Error, TData>, "'queryKey' | 'queryFn' | 'initialData'"> & {
initialData?: undefined;
};
}
interface EscrowGetEscrowsQuery<TData> extends EscrowReactQuery<EscrowsResponse, TData> {
args: {
caller?: string;
limit?: number;
provider?: string;
startAfter?: number;
};
}
declare function useEscrowGetEscrowsQuery<TData = EscrowsResponse>({ client, args, options, }: EscrowGetEscrowsQuery<TData>): _tanstack_react_query.UseQueryResult<TData, Error>;
interface EscrowGetCollectedFeesQuery<TData> extends EscrowReactQuery<CollectedFeesResponse, TData> {
}
declare function useEscrowGetCollectedFeesQuery<TData = CollectedFeesResponse>({ client, options, }: EscrowGetCollectedFeesQuery<TData>): _tanstack_react_query.UseQueryResult<TData, Error>;
interface EscrowGetEscrowQuery<TData> extends EscrowReactQuery<EscrowResponse, TData> {
args: {
escrowId: number;
};
}
declare function useEscrowGetEscrowQuery<TData = EscrowResponse>({ client, args, options, }: EscrowGetEscrowQuery<TData>): _tanstack_react_query.UseQueryResult<TData, Error>;
interface EscrowClaimFeesMutation {
client: EscrowClient;
msg: {
denom?: string;
};
args?: {
fee?: number | StdFee | "auto";
memo?: string;
funds?: Coin[];
};
}
declare function useEscrowClaimFeesMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, EscrowClaimFeesMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<ExecuteResult, Error, EscrowClaimFeesMutation, unknown>;
interface EscrowRefundExpiredMutation {
client: EscrowClient;
msg: {
escrowId: number;
};
args?: {
fee?: number | StdFee | "auto";
memo?: string;
funds?: Coin[];
};
}
declare function useEscrowRefundExpiredMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, EscrowRefundExpiredMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<ExecuteResult, Error, EscrowRefundExpiredMutation, unknown>;
interface EscrowReleaseMutation {
client: EscrowClient;
msg: {
escrowId: number;
usageFee: Uint128$1;
};
args?: {
fee?: number | StdFee | "auto";
memo?: string;
funds?: Coin[];
};
}
declare function useEscrowReleaseMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, EscrowReleaseMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<ExecuteResult, Error, EscrowReleaseMutation, unknown>;
interface EscrowLockFundsMutation {
client: EscrowClient;
msg: {
authToken: string;
expires: number;
maxFee: Uint128$1;
toolId: string;
};
args?: {
fee?: number | StdFee | "auto";
memo?: string;
funds?: Coin[];
};
}
declare function useEscrowLockFundsMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, EscrowLockFundsMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<ExecuteResult, Error, EscrowLockFundsMutation, unknown>;
type Uint128 = string;
interface ToolResponse {
denom: string;
description: string;
endpoint: string;
is_active: boolean;
price: Uint128;
provider: string;
tool_id: string;
}
interface ToolsResponse {
tools: ToolResponse[];
}
/**
* This file was automatically generated by @cosmwasm/ts-codegen@1.12.1.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
interface RegistryReadOnlyInterface {
contractAddress: string;
getTool: ({ toolId }: {
toolId: string;
}) => Promise<ToolResponse>;
getTools: () => Promise<ToolsResponse>;
}
declare class RegistryQueryClient implements RegistryReadOnlyInterface {
client: CosmWasmClient;
contractAddress: string;
constructor(client: CosmWasmClient, contractAddress: string);
getTool: ({ toolId }: {
toolId: string;
}) => Promise<ToolResponse>;
getTools: () => Promise<ToolsResponse>;
}
interface RegistryInterface extends RegistryReadOnlyInterface {
contractAddress: string;
sender: string;
registerTool: ({ denom, description, endpoint, price, toolId, }: {
denom?: string;
description: string;
endpoint: string;
price: Uint128;
toolId: string;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
updatePrice: ({ price, toolId, }: {
price: Uint128;
toolId: string;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
updateDenom: ({ denom, toolId, }: {
denom: string;
toolId: string;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
updateEndpoint: ({ endpoint, toolId, }: {
endpoint: string;
toolId: string;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
pauseTool: ({ toolId, }: {
toolId: string;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
resumeTool: ({ toolId, }: {
toolId: string;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
}
declare class RegistryClient extends RegistryQueryClient implements RegistryInterface {
client: SigningCosmWasmClient;
sender: string;
contractAddress: string;
constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string);
registerTool: ({ denom, description, endpoint, price, toolId, }: {
denom?: string;
description: string;
endpoint: string;
price: Uint128;
toolId: string;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
updatePrice: ({ price, toolId, }: {
price: Uint128;
toolId: string;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
updateDenom: ({ denom, toolId, }: {
denom: string;
toolId: string;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
updateEndpoint: ({ endpoint, toolId, }: {
endpoint: string;
toolId: string;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
pauseTool: ({ toolId, }: {
toolId: string;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
resumeTool: ({ toolId, }: {
toolId: string;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
}
declare const registryQueryKeys: {
contract: readonly [{
readonly contract: "registry";
}];
address: (contractAddress: string | undefined) => readonly [{
readonly address: string;
readonly contract: "registry";
}];
getTool: (contractAddress: string | undefined, args?: Record<string, unknown>) => readonly [{
readonly method: "get_tool";
readonly args: Record<string, unknown>;
readonly address: string;
readonly contract: "registry";
}];
getTools: (contractAddress: string | undefined, args?: Record<string, unknown>) => readonly [{
readonly method: "get_tools";
readonly args: Record<string, unknown>;
readonly address: string;
readonly contract: "registry";
}];
};
interface RegistryReactQuery<TResponse, TData = TResponse> {
client: RegistryQueryClient | undefined;
options?: Omit<UseQueryOptions<TResponse, Error, TData>, "'queryKey' | 'queryFn' | 'initialData'"> & {
initialData?: undefined;
};
}
interface RegistryGetToolsQuery<TData> extends RegistryReactQuery<ToolsResponse, TData> {
}
declare function useRegistryGetToolsQuery<TData = ToolsResponse>({ client, options, }: RegistryGetToolsQuery<TData>): _tanstack_react_query.UseQueryResult<TData, Error>;
interface RegistryGetToolQuery<TData> extends RegistryReactQuery<ToolResponse, TData> {
args: {
toolId: string;
};
}
declare function useRegistryGetToolQuery<TData = ToolResponse>({ client, args, options, }: RegistryGetToolQuery<TData>): _tanstack_react_query.UseQueryResult<TData, Error>;
interface RegistryResumeToolMutation {
client: RegistryClient;
msg: {
toolId: string;
};
args?: {
fee?: number | StdFee | "auto";
memo?: string;
funds?: Coin[];
};
}
declare function useRegistryResumeToolMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, RegistryResumeToolMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<ExecuteResult, Error, RegistryResumeToolMutation, unknown>;
interface RegistryPauseToolMutation {
client: RegistryClient;
msg: {
toolId: string;
};
args?: {
fee?: number | StdFee | "auto";
memo?: string;
funds?: Coin[];
};
}
declare function useRegistryPauseToolMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, RegistryPauseToolMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<ExecuteResult, Error, RegistryPauseToolMutation, unknown>;
interface RegistryUpdateEndpointMutation {
client: RegistryClient;
msg: {
endpoint: string;
toolId: string;
};
args?: {
fee?: number | StdFee | "auto";
memo?: string;
funds?: Coin[];
};
}
declare function useRegistryUpdateEndpointMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, RegistryUpdateEndpointMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<ExecuteResult, Error, RegistryUpdateEndpointMutation, unknown>;
interface RegistryUpdateDenomMutation {
client: RegistryClient;
msg: {
denom: string;
toolId: string;
};
args?: {
fee?: number | StdFee | "auto";
memo?: string;
funds?: Coin[];
};
}
declare function useRegistryUpdateDenomMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, RegistryUpdateDenomMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<ExecuteResult, Error, RegistryUpdateDenomMutation, unknown>;
interface RegistryUpdatePriceMutation {
client: RegistryClient;
msg: {
price: Uint128;
toolId: string;
};
args?: {
fee?: number | StdFee | "auto";
memo?: string;
funds?: Coin[];
};
}
declare function useRegistryUpdatePriceMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, RegistryUpdatePriceMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<ExecuteResult, Error, RegistryUpdatePriceMutation, unknown>;
interface RegistryRegisterToolMutation {
client: RegistryClient;
msg: {
denom?: string;
description: string;
endpoint: string;
price: Uint128;
toolId: string;
};
args?: {
fee?: number | StdFee | "auto";
memo?: string;
funds?: Coin[];
};
}
declare function useRegistryRegisterToolMutation(options?: Omit<UseMutationOptions<ExecuteResult, Error, RegistryRegisterToolMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<ExecuteResult, Error, RegistryRegisterToolMutation, unknown>;
interface HTTPaySDKConfig {
rpcEndpoint: string;
chainId: string;
registryAddress: string;
escrowAddress: string;
gasPrice: string;
gasAdjustment: number;
}
interface HTTPayClients {
registryQuery: RegistryQueryClient | null;
escrowQuery: EscrowQueryClient | null;
registry: RegistryClient | null;
escrow: EscrowClient | null;
cosmWasmClient: CosmWasmClient | null;
signingClient: SigningCosmWasmClient | null;
}
declare const toolRegistrationSchema: z.ZodObject<{
toolId: z.ZodString;
description: z.ZodString;
price: z.ZodEffects<z.ZodString, string, string>;
endpoint: z.ZodString;
denom: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
toolId?: string;
endpoint?: string;
denom?: string;
price?: string;
description?: string;
}, {
toolId?: string;
endpoint?: string;
denom?: string;
price?: string;
description?: string;
}>;
declare const escrowCreationSchema: z.ZodObject<{
toolId: z.ZodString;
maxFee: z.ZodEffects<z.ZodString, string, string>;
authToken: z.ZodString;
ttl: z.ZodEffects<z.ZodString, string, string>;
}, "strip", z.ZodTypeAny, {
toolId?: string;
maxFee?: string;
authToken?: string;
ttl?: string;
}, {
toolId?: string;
maxFee?: string;
authToken?: string;
ttl?: string;
}>;
declare const escrowVerificationSchema: z.ZodObject<{
escrowId: z.ZodEffects<z.ZodString, string, string>;
authToken: z.ZodString;
providerAddr: z.ZodString;
}, "strip", z.ZodTypeAny, {
authToken?: string;
escrowId?: string;
providerAddr?: string;
}, {
authToken?: string;
escrowId?: string;
providerAddr?: string;
}>;
declare const usagePostingSchema: z.ZodObject<{
escrowId: z.ZodEffects<z.ZodString, string, string>;
usageFee: z.ZodEffects<z.ZodString, string, string>;
}, "strip", z.ZodTypeAny, {
escrowId?: string;
usageFee?: string;
}, {
escrowId?: string;
usageFee?: string;
}>;
type ToolRegistrationForm = z.infer<typeof toolRegistrationSchema>;
type EscrowCreationForm = z.infer<typeof escrowCreationSchema>;
type EscrowVerificationForm = z.infer<typeof escrowVerificationSchema>;
type UsagePostingForm = z.infer<typeof usagePostingSchema>;
type Tool = ToolResponse;
type Escrow = EscrowResponse;
interface EscrowsFilter {
caller?: string;
provider?: string;
startAfter?: number;
limit?: number;
}
interface ConnectionState {
isConnected: boolean;
hasSigningCapabilities: boolean;
walletAddress: string | null;
currentBlockHeight: number | null;
}
interface LockFundsResult {
transactionHash: string;
escrowId: number;
denom?: string;
}
interface PostUsageResult {
transactionHash: string;
claimedAmount: string;
}
interface VerificationResult {
isValid: boolean;
error?: string;
escrow?: Escrow;
blockHeight?: number;
}
interface RegistrationResult {
transactionHash: string;
toolId: string;
}
interface ReleaseResult {
transactionHash: string;
releasedAmount: string;
escrowId: number;
}
interface LoadingStates {
connecting: boolean;
wallet: boolean;
tools: boolean;
escrows: boolean;
registerTool: boolean;
updateEndpoint: boolean;
lockFunds: boolean;
verifyEscrow: boolean;
postUsage: boolean;
pauseTool: boolean;
resumeTool: boolean;
updatePrice: boolean;
updateDenom: boolean;
refundEscrow: boolean;
claimFees: boolean;
[key: string]: boolean;
}
interface HTTPaySDKContextType {
config: HTTPaySDKConfig;
setConfig: (config: HTTPaySDKConfig) => void;
isConnected: boolean;
hasSigningCapabilities: boolean;
clients: HTTPayClients;
walletAddress: string | null;
isWalletConnected: boolean;
isWalletConnecting: boolean;
connectWallet: () => Promise<void>;
disconnectWallet: () => Promise<void>;
tools: Tool[];
escrows: Escrow[];
hasMoreEscrows: boolean;
currentBlockHeight: number | null;
loading: LoadingStates;
setLoadingState: (key: string, loading: boolean) => void;
initializeSDK: () => Promise<void>;
initializeWalletSDK: () => Promise<void>;
forceReconnectWallet: () => Promise<void>;
loadTools: () => Promise<void>;
registerTool: (toolData: ToolRegistrationForm) => Promise<void>;
updateEndpoint: (toolId: string, endpoint: string) => Promise<void>;
updatePrice: (toolId: string, price: string) => Promise<void>;
updateDenom: (toolId: string, denom: string) => Promise<void>;
pauseTool: (toolId: string) => Promise<void>;
resumeTool: (toolId: string) => Promise<void>;
loadEscrows: (filter?: EscrowsFilter) => Promise<void>;
loadMoreEscrows: () => Promise<void>;
resetEscrowsFilter: () => Promise<void>;
lockFunds: (escrowData: EscrowCreationForm) => Promise<LockFundsResult | undefined>;
verifyEscrow: (verificationData: EscrowVerificationForm) => Promise<VerificationResult>;
postUsage: (usageData: UsagePostingForm) => Promise<void>;
refundExpired: (escrowId: number) => Promise<void>;
claimFees: (denom?: string) => Promise<void>;
getCurrentBlockHeight: () => Promise<number>;
handleError: (error: Error | unknown, operation: string) => void;
}
interface ToastFunction {
(options: {
title: string;
description: string;
variant?: "default" | "destructive";
}): void;
}
interface UseRegistryProps {
clients: HTTPayClients;
walletAddress: string | null;
isWalletConnected: boolean;
hasSigningCapabilities: boolean;
loading: LoadingStates;
setLoadingState: (key: string, loading: boolean) => void;
toast: ToastFunction;
}
declare function useRegistry({ clients, walletAddress, isWalletConnected, hasSigningCapabilities, loading, setLoadingState, toast, }: UseRegistryProps): {
tools: ToolResponse[];
loadTools: () => Promise<void>;
registerTool: (toolData: ToolRegistrationForm) => Promise<void>;
updateEndpoint: (toolId: string, endpoint: string) => Promise<void>;
updatePrice: (toolId: string, price: string) => Promise<void>;
updateDenom: (toolId: string, denom: string) => Promise<void>;
pauseTool: (toolId: string) => Promise<void>;
resumeTool: (toolId: string) => Promise<void>;
};
interface HTTPaySDKProviderProps {
children: ReactNode;
initialConfig?: Partial<HTTPaySDKConfig>;
chainName: string;
toast: ToastFunction;
walletAddress?: string | null;
isWalletConnected?: boolean;
getSigningCosmWasmClient?: () => Promise<SigningCosmWasmClient>;
}
declare function HTTPaySDKProvider({ children, initialConfig, chainName, toast, walletAddress, isWalletConnected, getSigningCosmWasmClient }: HTTPaySDKProviderProps): react_jsx_runtime.JSX.Element;
declare function useHTTPaySDK(): HTTPaySDKContextType;
declare const useSDK: typeof useHTTPaySDK;
interface UseEscrowProps {
clients: HTTPayClients;
walletAddress: string | null;
isWalletConnected: boolean;
hasSigningCapabilities: boolean;
loading: LoadingStates;
setLoadingState: (key: string, loading: boolean) => void;
getCurrentBlockHeight: () => Promise<number>;
toast: ToastFunction;
}
declare function useEscrow({ clients, walletAddress, isWalletConnected, hasSigningCapabilities, loading, setLoadingState, getCurrentBlockHeight, toast, }: UseEscrowProps): {
escrows: EscrowResponse[];
hasMoreEscrows: boolean;
loadEscrows: (filter?: EscrowsFilter) => Promise<void>;
loadMoreEscrows: () => Promise<void>;
resetEscrowsFilter: () => Promise<void>;
lockFunds: (escrowData: EscrowCreationForm) => Promise<LockFundsResult | undefined>;
verifyEscrow: (verificationData: EscrowVerificationForm) => Promise<VerificationResult>;
postUsage: (usageData: UsagePostingForm) => Promise<void>;
refundExpired: (escrowId: number) => Promise<void>;
claimFees: (denom?: string) => Promise<void>;
};
interface UseWalletIntegrationReturn {
clients: HTTPayClients;
isConnected: boolean;
hasSigningCapabilities: boolean;
walletAddress: string | undefined;
isWalletConnected: boolean;
isWalletConnecting: boolean;
isWalletDisconnected: boolean;
isWalletError: boolean;
walletStatus: any;
walletMessage: string | undefined;
initializeSDK: () => Promise<void>;
initializeWalletSDK: () => Promise<void>;
forceReconnectWallet: () => Promise<void>;
connectWallet: () => Promise<void>;
disconnectWallet: () => Promise<void>;
}
interface UseWalletIntegrationProps {
config: HTTPaySDKConfig;
setLoadingState: (key: string, loading: boolean) => void;
chainName: string;
toast: ToastFunction;
walletAddress?: string | null;
isWalletConnected?: boolean;
isWalletConnecting?: boolean;
isWalletDisconnected?: boolean;
isWalletError?: boolean;
walletStatus?: any;
walletMessage?: string;
getSigningCosmWasmClient?: () => Promise<SigningCosmWasmClient>;
connectWallet?: () => Promise<void>;
disconnectWallet?: () => Promise<void>;
}
declare function useWalletIntegration({ config, setLoadingState, chainName, toast, walletAddress, isWalletConnected, isWalletConnecting, isWalletDisconnected, isWalletError, walletStatus, walletMessage, getSigningCosmWasmClient, connectWallet, disconnectWallet }: UseWalletIntegrationProps): UseWalletIntegrationReturn;
interface UseBlockHeightProps {
clients: HTTPayClients;
isConnected: boolean;
}
declare function useBlockHeight({ clients, isConnected }: UseBlockHeightProps): {
currentBlockHeight: number;
getCurrentBlockHeight: () => Promise<number>;
updateBlockHeight: () => Promise<void>;
};
/**
* Create read-only (query) clients for HTTPay contracts
*/
declare function createQueryClients(config: HTTPaySDKConfig): Promise<{
cosmWasmClient: CosmWasmClient;
registryQuery: RegistryQueryClient;
escrowQuery: EscrowQueryClient;
}>;
/**
* Create signing clients for HTTPay contracts
*/
declare function createSigningClients(signingClient: SigningCosmWasmClient, walletAddress: string, config: HTTPaySDKConfig): {
registry: RegistryClient;
escrow: EscrowClient;
};
/**
* Create empty clients object
*/
declare function createEmptyClients(): HTTPayClients;
/**
* Handle and normalize errors from SDK operations
*/
declare function handleSDKError(error: unknown, operation: string): Error;
/**
* Extract escrow ID from transaction attributes
*/
declare function extractEscrowIdFromTx(txHash: string, events: any[]): number | null;
/**
* Convert base64 string to regular string
*/
declare function fromBase64(base64String: string): string;
/**
* Convert string to base64
*/
declare function toBase64(input: string): string;
/**
* Validate wallet address format
*/
declare function isValidAddress(address: string, prefix?: string): boolean;
/**
* Format token amount for display
*/
declare function formatTokenAmount(amount: string, decimals?: number): string;
/**
* Parse token amount from user input to smallest unit
*/
declare function parseTokenAmount(amount: string, decimals?: number): string;
/**
* Get short address for display (e.g., "neutron1abc...xyz")
*/
declare function getShortAddress(address: string, startChars?: number, endChars?: number): string;
/**
* Calculate blocks until expiration
*/
declare function getBlocksUntilExpiration(expirationBlock: number, currentBlock: number): number;
/**
* Estimate time until expiration (assuming ~6 second block time)
*/
declare function estimateTimeUntilExpiration(expirationBlock: number, currentBlock: number): string;
declare namespace contracts$1 {
const Escrow: {
useEscrowGetEscrowsQuery<TData = EscrowsResponse>({ client, args, options, }: EscrowGetEscrowsQuery<TData>): _tanstack_react_query.UseQueryResult<TData, Error>;
useEscrowGetCollectedFeesQuery<TData = CollectedFeesResponse>({ client, options, }: EscrowGetCollectedFeesQuery<TData>): _tanstack_react_query.UseQueryResult<TData, Error>;
useEscrowGetEscrowQuery<TData = EscrowResponse>({ client, args, options, }: EscrowGetEscrowQuery<TData>): _tanstack_react_query.UseQueryResult<TData, Error>;
useEscrowClaimFeesMutation(options?: Omit<_tanstack_react_query.UseMutationOptions<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, EscrowClaimFeesMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, EscrowClaimFeesMutation, unknown>;
useEscrowRefundExpiredMutation(options?: Omit<_tanstack_react_query.UseMutationOptions<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, EscrowRefundExpiredMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, EscrowRefundExpiredMutation, unknown>;
useEscrowReleaseMutation(options?: Omit<_tanstack_react_query.UseMutationOptions<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, EscrowReleaseMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, EscrowReleaseMutation, unknown>;
useEscrowLockFundsMutation(options?: Omit<_tanstack_react_query.UseMutationOptions<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, EscrowLockFundsMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, EscrowLockFundsMutation, unknown>;
escrowQueryKeys: {
contract: readonly [{
readonly contract: "escrow";
}];
address: (contractAddress: string | undefined) => readonly [{
readonly address: string;
readonly contract: "escrow";
}];
getEscrow: (contractAddress: string | undefined, args?: Record<string, unknown>) => readonly [{
readonly method: "get_escrow";
readonly args: Record<string, unknown>;
readonly address: string;
readonly contract: "escrow";
}];
getCollectedFees: (contractAddress: string | undefined, args?: Record<string, unknown>) => readonly [{
readonly method: "get_collected_fees";
readonly args: Record<string, unknown>;
readonly address: string;
readonly contract: "escrow";
}];
getEscrows: (contractAddress: string | undefined, args?: Record<string, unknown>) => readonly [{
readonly method: "get_escrows";
readonly args: Record<string, unknown>;
readonly address: string;
readonly contract: "escrow";
}];
};
EscrowQueryClient: typeof EscrowQueryClient;
EscrowClient: typeof EscrowClient;
};
}
declare namespace contracts {
const Registry: {
useRegistryGetToolsQuery<TData = ToolsResponse>({ client, options, }: RegistryGetToolsQuery<TData>): _tanstack_react_query.UseQueryResult<TData, Error>;
useRegistryGetToolQuery<TData = ToolResponse>({ client, args, options, }: RegistryGetToolQuery<TData>): _tanstack_react_query.UseQueryResult<TData, Error>;
useRegistryResumeToolMutation(options?: Omit<_tanstack_react_query.UseMutationOptions<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, RegistryResumeToolMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, RegistryResumeToolMutation, unknown>;
useRegistryPauseToolMutation(options?: Omit<_tanstack_react_query.UseMutationOptions<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, RegistryPauseToolMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, RegistryPauseToolMutation, unknown>;
useRegistryUpdateEndpointMutation(options?: Omit<_tanstack_react_query.UseMutationOptions<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, RegistryUpdateEndpointMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, RegistryUpdateEndpointMutation, unknown>;
useRegistryUpdateDenomMutation(options?: Omit<_tanstack_react_query.UseMutationOptions<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, RegistryUpdateDenomMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, RegistryUpdateDenomMutation, unknown>;
useRegistryUpdatePriceMutation(options?: Omit<_tanstack_react_query.UseMutationOptions<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, RegistryUpdatePriceMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, RegistryUpdatePriceMutation, unknown>;
useRegistryRegisterToolMutation(options?: Omit<_tanstack_react_query.UseMutationOptions<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, RegistryRegisterToolMutation>, "mutationFn">): _tanstack_react_query.UseMutationResult<_cosmjs_cosmwasm_stargate.ExecuteResult, Error, RegistryRegisterToolMutation, unknown>;
registryQueryKeys: {
contract: readonly [{
readonly contract: "registry";
}];
address: (contractAddress: string | undefined) => readonly [{
readonly address: string;
readonly contract: "registry";
}];
getTool: (contractAddress: string | undefined, args?: Record<string, unknown>) => readonly [{
readonly method: "get_tool";
readonly args: Record<string, unknown>;
readonly address: string;
readonly contract: "registry";
}];
getTools: (contractAddress: string | undefined, args?: Record<string, unknown>) => readonly [{
readonly method: "get_tools";
readonly args: Record<string, unknown>;
readonly address: string;
readonly contract: "registry";
}];
};
RegistryQueryClient: typeof RegistryQueryClient;
RegistryClient: typeof RegistryClient;
};
}
export { Escrow, EscrowClient, contracts$1 as EscrowContracts, EscrowQueryClient, Escrow as EscrowType, HTTPaySDKProvider, RegistryClient, contracts as RegistryContracts, RegistryQueryClient, createEmptyClients, createQueryClients, createSigningClients, escrowCreationSchema, escrowQueryKeys, escrowVerificationSchema, estimateTimeUntilExpiration, extractEscrowIdFromTx, formatTokenAmount, fromBase64, getBlocksUntilExpiration, getShortAddress, handleSDKError, isValidAddress, parseTokenAmount, registryQueryKeys, toBase64, toolRegistrationSchema, usagePostingSchema, useBlockHeight, useEscrow, useEscrowClaimFeesMutation, useEscrowGetCollectedFeesQuery, useEscrowGetEscrowQuery, useEscrowGetEscrowsQuery, useEscrowLockFundsMutation, useEscrowRefundExpiredMutation, useEscrowReleaseMutation, useHTTPaySDK, useRegistry, useRegistryGetToolQuery, useRegistryGetToolsQuery, useRegistryPauseToolMutation, useRegistryRegisterToolMutation, useRegistryResumeToolMutation, useRegistryUpdateDenomMutation, useRegistryUpdateEndpointMutation, useRegistryUpdatePriceMutation, useSDK, useWalletIntegration };
export type { ConnectionState, EscrowClaimFeesMutation, EscrowCreationForm, EscrowGetCollectedFeesQuery, EscrowGetEscrowQuery, EscrowGetEscrowsQuery, EscrowLockFundsMutation, EscrowReactQuery, EscrowRefundExpiredMutation, EscrowReleaseMutation, EscrowVerificationForm, EscrowsFilter, HTTPayClients, HTTPaySDKConfig, HTTPaySDKContextType, LoadingStates, LockFundsResult, PostUsageResult, RegistrationResult, RegistryGetToolQuery, RegistryGetToolsQuery, RegistryPauseToolMutation, RegistryReactQuery, RegistryRegisterToolMutation, RegistryResumeToolMutation, RegistryUpdateDenomMutation, RegistryUpdateEndpointMutation, RegistryUpdatePriceMutation, ReleaseResult, ToastFunction, Tool, ToolRegistrationForm, UsagePostingForm, VerificationResult };