diff --git a/app/nexus/avail-nexus-sdk/_meta.ts b/app/nexus/avail-nexus-sdk/_meta.ts index d9248585..0977752c 100644 --- a/app/nexus/avail-nexus-sdk/_meta.ts +++ b/app/nexus/avail-nexus-sdk/_meta.ts @@ -1,4 +1,4 @@ export default { - "nexus-core": "Nexus (Headless)", + "nexus-core": "Nexus Core", "nexus-widgets": "Nexus Widgets" } \ No newline at end of file diff --git a/app/nexus/avail-nexus-sdk/nexus-core/api-reference/page.mdx b/app/nexus/avail-nexus-sdk/nexus-core/api-reference/page.mdx index 9a55978b..8d7946af 100644 --- a/app/nexus/avail-nexus-sdk/nexus-core/api-reference/page.mdx +++ b/app/nexus/avail-nexus-sdk/nexus-core/api-reference/page.mdx @@ -1,14 +1,14 @@ --- -title: 'Avail Nexus headless SDK API Reference' -description: 'Complete API reference for the Avail Nexus headless SDK including initialization, network configuration, bridging, transfers, and utility functions' +title: 'Nexus Core SDK API Reference' +description: 'Complete API reference for the Nexus Core SDK including initialization, network configuration, bridging, transfers, and utility functions' image: '/img/docs-link-preview.png' --- import { Callout, Steps, Tabs } from 'nextra/components' -# Avail Nexus (Headless) SDK API Reference +# Nexus Core SDK API Reference -The Avail Nexus headlessSDK provides a comprehensive set of APIs for cross-chain bridging, token transfers, and balance management across multiple EVM chains. +The Nexus Core SDK provides a comprehensive set of APIs for cross-chain bridging, token transfers, and balance management across multiple EVM chains. ## Quick Start @@ -20,7 +20,7 @@ const sdk = new NexusSDK({ network: 'mainnet' }); await sdk.initialize(provider); // Your wallet provider // Get unified balances -const balances = await sdk.getUnifiedBalances(); +const balances = await sdk.getUnifiedBalances( true ); console.log('All balances:', balances); // Bridge tokens @@ -248,9 +248,10 @@ All events include the same `typeID` structure and runtime `data` such as `trans import type { UserAsset, TokenBalance } from '@avail-project/nexus-core'; // Get all balances across chains -const balances: UserAsset[] = await sdk.getUnifiedBalances(); +const balances: UserAsset[] = await sdk.getUnifiedBalances( true ); // Get balance for specific token +// You can optionally include swappable assets as well const usdcBalance: UserAsset | undefined = await sdk.getUnifiedBalance('USDC'); ``` diff --git a/app/nexus/avail-nexus-sdk/nexus-core/fetch-unified-balances/page.mdx b/app/nexus/avail-nexus-sdk/nexus-core/fetch-unified-balances/page.mdx index 0b1e071a..00744c52 100644 --- a/app/nexus/avail-nexus-sdk/nexus-core/fetch-unified-balances/page.mdx +++ b/app/nexus/avail-nexus-sdk/nexus-core/fetch-unified-balances/page.mdx @@ -22,13 +22,17 @@ Use these functions to fetch consolidated token balances across all supported ch ## Method signatures ```typescript showLineNumbers filename="Typescript" -async getUnifiedBalances(): Promise -async getUnifiedBalance(symbol: string): Promise +async getUnifiedBalances(includeSwappableBalances: boolean): Promise +async getUnifiedBalance(symbol: string, includeSwappableBalances: boolean): Promise ``` ## Parameters - `symbol` (string, required for `getUnifiedBalance`): Token symbol, e.g. `'USDC' | 'USDT' | 'ETH'`. +- `includeSwappableBalances` (boolean, optional; default `false`): + - `false` (default): Only return CA-supported assets (tokens that can be used directly in chain abstraction flows). + - `true`: Also include swappable wallet assets that the SDK can utilize via swap as sources for operations. This includes tokens that are not CA-supported but can be used via swap. + ### `getUnifiedBalances()` @@ -39,16 +43,31 @@ Fetches the unified balance of all tokens across all chains for a user. await sdk.getUnifiedBalances(): Promise ``` -### `getUnifiedBalance(symbol)` +### `getUnifiedBalance()` + +Fetches the unified balance of all tokens across all chains for a user. + +```typescript showLineNumbers filename="Typescript" +// Default: CA-supported assets only +const balances = await sdk.getUnifiedBalances(); + +// Include swappable assets as well +const balancesWithSwappable = await sdk.getUnifiedBalances(true); +``` + +### `getUnifiedBalance()` Fetches the unified balance of a specific token across all chains for a user. ```typescript showLineNumbers filename="Typescript" -// Takes a token symbol parameter -await sdk.getUnifiedBalance(symbol: string): Promise +// Default: CA-supported assets only +const usdc = await sdk.getUnifiedBalance('USDC'); + +// Include swappable assets as well in search +const usdcFromAllSources = await sdk.getUnifiedBalance('USDC', true); ``` -## Example +## Example Here are some minimal examples of how to use the functions to fetch the unified balance of a user: @@ -58,14 +77,14 @@ const allBalances = await sdk.getUnifiedBalances(); console.log('All balances:', allBalances); // Get balance for specific token -const usdcBalance = await sdk.getUnifiedBalance('USDC'); +const usdcBalance = await sdk.getUnifiedBalance('USDC', true); console.log('USDC balance:', usdcBalance); ``` ## Return Value -- `getUnifiedBalances()`: Returns `Promise` - Array of `UserAsset` class instances -- `getUnifiedBalance(symbol)`: Returns `Promise` - Single `UserAsset` instance or undefined +- `getUnifiedBalances(includeSwappableBalances)`: Returns `Promise` - Array of `UserAsset` class instances +- `getUnifiedBalance(symbol, includeSwappableBalances)`: Returns `Promise` - Single `UserAsset` instance or undefined ```typescript showLineNumbers filename="Typescript" class UserAsset { diff --git a/app/nexus/avail-nexus-sdk/nexus-widgets/api-reference/page.mdx b/app/nexus/avail-nexus-sdk/nexus-widgets/api-reference/page.mdx index 4a12b936..ac0d652d 100644 --- a/app/nexus/avail-nexus-sdk/nexus-widgets/api-reference/page.mdx +++ b/app/nexus/avail-nexus-sdk/nexus-widgets/api-reference/page.mdx @@ -13,7 +13,7 @@ The Avail Nexus SDK provides a comprehensive set of APIs for cross-chain bridgin **Note:**
This page will focus on the UI widgets available as part of the Avail Nexus SDK. -If you are looking for the API reference for the headless SDK, please refer to [this](/nexus/avail-nexus-sdk/examples/nexus-core/api-reference) page. +If you are looking for the API reference for the Nexus Core SDK, please refer to [this](/nexus/avail-nexus-sdk/examples/nexus-core/api-reference) page.
## Quick Start diff --git a/app/nexus/introduction-to-nexus/page.mdx b/app/nexus/introduction-to-nexus/page.mdx index 81f60975..f439a7b1 100644 --- a/app/nexus/introduction-to-nexus/page.mdx +++ b/app/nexus/introduction-to-nexus/page.mdx @@ -72,5 +72,5 @@ Developers benefit from the '*deploy once, scale everywhere*' paradigm that Nexu Test out our app demos with Nexus embedded, to see how you can also tap into cross-chain liquidity in seconds. - [Nexus UI Demo](https://nexus-demo.availproject.org/) -- [Nexus Headless SDK Demo](https://avail-headless-nexus-demo.avail.so/) +- [Nexus Core SDK Demo](https://avail-headless-nexus-demo.avail.so/) - [Hyperliquid Demo](https://avail-project.notion.site/Avail-Nexus-x-HyperLiquid-257e67c666dd80cc9589e661b2460fbb) \ No newline at end of file diff --git a/app/nexus/nexus-cheatsheet/page.mdx b/app/nexus/nexus-cheatsheet/page.mdx index 31b2d2fd..00f66017 100644 --- a/app/nexus/nexus-cheatsheet/page.mdx +++ b/app/nexus/nexus-cheatsheet/page.mdx @@ -37,7 +37,7 @@ The headless version , for fine-grained control over the Nexus SDK. We also built a demo app with `nexus-core` to provide more reference code: - } href="https://avail-nexus-demo-five.vercel.app/" target="_blank" rel="noopener noreferrer" arrow /> + } href="https://avail-nexus-demo-five.vercel.app/" target="_blank" rel="noopener noreferrer" arrow /> } href="https://github.com/availproject/avail-nexus-demo" target="_blank" rel="noopener noreferrer" arrow /> diff --git a/app/nexus/nexus-examples/nexus-initialization-basic/page.mdx b/app/nexus/nexus-examples/nexus-initialization-basic/page.mdx index adc5fd3b..09caf01e 100644 --- a/app/nexus/nexus-examples/nexus-initialization-basic/page.mdx +++ b/app/nexus/nexus-examples/nexus-initialization-basic/page.mdx @@ -63,7 +63,7 @@ by using an injected wallet provider that follows the [`EIP-1193`](https://eips. - And to do that, you need to call the `.initialize()` function of the SDK while passing the wallet provider to it. -- The flows to do this differ between the headless and the widgets SDK. +- The flows to do this differ between Nexus Core and Nexus Widgets. We will go over both of them in this tutorial. diff --git a/app/nexus/nexus-overview/page.mdx b/app/nexus/nexus-overview/page.mdx index b170c337..4c56a51f 100644 --- a/app/nexus/nexus-overview/page.mdx +++ b/app/nexus/nexus-overview/page.mdx @@ -43,7 +43,7 @@ pnpm add @avail-project/nexus-core -1. The headless SDK still requires an injected wallet provider (e.g. MetaMask, WalletConnect, etc.) +1. Nexus Core SDK still requires an injected wallet provider (e.g. MetaMask, WalletConnect, etc.) 2. It is designed for client-side browser environments and **cannot be used** in any server-side environments. diff --git a/app/nexus/nexus-quickstart/page.mdx b/app/nexus/nexus-quickstart/page.mdx index f942388c..270f9f35 100644 --- a/app/nexus/nexus-quickstart/page.mdx +++ b/app/nexus/nexus-quickstart/page.mdx @@ -19,13 +19,13 @@ This page will help you get started with `nexus-core` as well as `nexus-widgets` ## Nexus Core -We also made a demo app for the headless package to make it easier for devs to get on-boarded with the Avail Nexus SDK: +We also made a demo app for Nexus Core to make it easier for devs to get on-boarded with the Avail Nexus SDK: - [avail-headless-nexus-demo.avail.so](https://avail-headless-nexus-demo.avail.so/) - [Github repo for the demo app](https://github.com/availproject/avail-nexus-demo) -Getting started with the headless Nexus SDK is simple. +Getting started with Nexus core is simple.