@shogun-sdk/one-shot
Version:
Shogun Network unified SDK — core logic, React hooks, and wallet adapters.
214 lines (206 loc) • 6.64 kB
TypeScript
import * as vue from 'vue';
import { App, ComputedRef, Ref } from 'vue';
import { O as OneShotSDKConfig, e as OneShotSDK, d as QuoteParams, Q as QuoteResponse, P as PlaceOrderResult, f as Stage, T as TokenInfo, c as BalanceRequestParams, B as BalanceResponse } from './index-CxfzE4Zk.js';
export { C as ChainId, a as SupportedChain, S as SupportedChains, b as TokenBalance, i as isEvmChain } from './index-CxfzE4Zk.js';
import { A as AdaptedWallet } from './wallet-DfvPIcuW.js';
import { WalletClient } from 'viem';
import '@solana/web3.js';
declare const OneShotSymbol: unique symbol;
/**
* Provides a OneShotSDK instance into the Vue app's dependency injection system.
*
* Use inside `app.use()` or a component's `setup()` function.
*/
declare function provideOneShot(config: OneShotSDKConfig): OneShotSDK;
/**
* Vue plugin installer for OneShotSDK.
*
* Usage:
* ```ts
* app.use(OneShotPlugin, { apiKey: "YOUR_KEY" });
* ```
*/
declare const OneShotPlugin: {
install(app: App, config: OneShotSDKConfig): void;
};
/**
* Injects the OneShotSDK instance from context.
* Must be called after `provideOneShot()` or `app.use(OneShotPlugin, ...)`.
*/
declare function useOneShot(): OneShotSDK;
declare function useQuote(params?: QuoteParams | ComputedRef<QuoteParams> | null): {
data: vue.Ref<QuoteResponse | null, QuoteResponse | null> | vue.Ref<undefined, undefined>;
error: vue.Ref<Error, Error> | vue.Ref<null, null>;
loading: vue.Ref<boolean, boolean>;
refetch: () => Promise<void>;
setParams(next: QuoteParams | null): void;
};
/**
* ⚡ useExecuteTransaction — Vue composable
* Executes a quote via EVM or Solana wallet with reactive status tracking.
*/
declare function useExecuteTransaction(): {
execute: ({ quote, wallet, options }: {
quote: QuoteResponse;
wallet: AdaptedWallet | WalletClient;
options?: {
maxAttempts?: number;
retryDelayMs?: number;
};
}) => Promise<PlaceOrderResult>;
isLoading: vue.Ref<boolean, boolean>;
stage: vue.Ref<Stage | null, Stage | null>;
message: vue.Ref<string | null, string | null>;
error: vue.Ref<string | null, string | null>;
result: vue.Ref<{
status: boolean;
srcTxHash: string;
srcChainId: number;
destChainId: number;
destTxHash: string;
} | {
status: boolean;
message: string;
stage: string;
} | null | undefined, PlaceOrderResult | {
status: boolean;
srcTxHash: string;
srcChainId: number;
destChainId: number;
destTxHash: string;
} | {
status: boolean;
message: string;
stage: string;
} | null>;
};
/**
* useTokenList — Vue composable for token discovery & pagination
*
*
* Features:
* - Fetches tokens from the Shogun Token Search API
* - Supports infinite scrolling (page-based pagination)
* - Manages loading & error states
* - Caches last search query
*
* ---
* ## Example Usage
* ```ts
* const {
* tokens,
* loading,
* error,
* hasMore,
* loadTokens,
* resetTokens
* } = useTokenList()
*
* onMounted(() => {
* loadTokens({ q: 'usdc', networkId: 7565164, reset: true })
* })
* ```
*/
declare function useTokenList(): {
/** Reactive state */
tokens: vue.Ref<{
address: string;
symbol: string;
name: string;
chainId: number;
decimals: number;
image?: string | undefined;
isVerified?: boolean | undefined;
priceUSD?: string | undefined;
}[], TokenInfo[] | {
address: string;
symbol: string;
name: string;
chainId: number;
decimals: number;
image?: string | undefined;
isVerified?: boolean | undefined;
priceUSD?: string | undefined;
}[]>;
loading: vue.Ref<boolean, boolean>;
error: vue.Ref<string | null, string | null>;
hasMore: vue.Ref<boolean, boolean>;
page: vue.Ref<number, number>;
lastQuery: vue.Ref<{
q?: string | undefined;
networkId?: number | undefined;
}, {
q?: string;
networkId?: number;
} | {
q?: string | undefined;
networkId?: number | undefined;
}>;
/** Actions */
loadTokens: (params: {
q?: string;
networkId?: number;
reset?: boolean;
}) => Promise<void>;
resetTokens: () => void;
};
/**
* Vue composable for balance retrieval using TanStack Query.
*
* Features:
* - Client-only execution to prevent SSR hydration issues
* - Shared query cache across components
* - Reactive parameter tracking
* - Abort-safe concurrent requests
* - Keeps previous data visible during refetch
* - Strongly typed request and response objects
*/
declare function useBalances(initialParams?: BalanceRequestParams | ComputedRef<BalanceRequestParams> | null): {
/** Query data */
data: vue.Ref<undefined, undefined> | vue.Ref<BalanceResponse | null, BalanceResponse | null>;
/** Loading state */
loading: vue.Ref<boolean, boolean>;
/** Error state */
error: vue.Ref<Error, Error> | vue.Ref<null, null>;
/** Manual refetch function */
refetch: () => Promise<void>;
/** Update request parameters */
setParams: (next: BalanceRequestParams | null) => void;
/** Current active parameters */
readonly activeParams: {
addresses: {
evm?: string | undefined;
svm?: string | undefined;
};
cursorEvm?: string | undefined;
cursorSvm?: string | undefined;
} | null;
};
/**
* Fetches metadata and prices for multiple tokens.
* Works with both reactive and plain address arrays.
*/
declare function useTokensData(addresses: string[] | Ref<string[]> | ComputedRef<string[]>): {
data: Ref<{
address: string;
symbol: string;
name: string;
chainId: number;
decimals: number;
image?: string | undefined;
isVerified?: boolean | undefined;
priceUSD?: string | undefined;
}[], TokenInfo[] | {
address: string;
symbol: string;
name: string;
chainId: number;
decimals: number;
image?: string | undefined;
isVerified?: boolean | undefined;
priceUSD?: string | undefined;
}[]>;
loading: Ref<boolean, boolean>;
error: Ref<Error | null, Error | null>;
};
export { BalanceRequestParams, BalanceResponse, OneShotPlugin, OneShotSymbol, QuoteParams, QuoteResponse, provideOneShot, useBalances, useExecuteTransaction, useOneShot, useQuote, useTokenList, useTokensData };