From 25f40d008aaca57937b76b1291e336019525e8df Mon Sep 17 00:00:00 2001 From: shrinathprabhu Date: Thu, 20 Aug 2026 18:44:49 +0530 Subject: [PATCH 1/3] Update the nexus core to 2.0.6 --- package.json | 4 ++-- packages/widgets/package.json | 4 ++-- pnpm-lock.yaml | 28 ++++++++++++++-------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index cb9ac72..36615db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "avail-widgets", - "version": "2.0.5", + "version": "2.0.6", "description": "A modern component registry built with Next.js and shadcn/ui for Avail Nexus", "author": "decocereus ", "contributors": [ @@ -25,7 +25,7 @@ "postinstall": "fumadocs-mdx" }, "dependencies": { - "@avail-project/nexus-core": "2.2.4", + "@avail-project/nexus-core": "2.4.0", "@radix-ui/react-accordion": "^1.2.12", "@radix-ui/react-checkbox": "^1.3.3", "@radix-ui/react-collapsible": "^1.1.12", diff --git a/packages/widgets/package.json b/packages/widgets/package.json index bc84646..a7cdbd6 100644 --- a/packages/widgets/package.json +++ b/packages/widgets/package.json @@ -1,6 +1,6 @@ { "name": "@avail-project/widgets", - "version": "2.0.5", + "version": "2.0.6", "description": "Compiled Avail widgets for React applications.", "author": "shrinathprabhu ", "contributors": [ @@ -38,7 +38,7 @@ "registry": "https://registry.npmjs.org/" }, "dependencies": { - "@avail-project/nexus-core": "2.2.4", + "@avail-project/nexus-core": "2.4.0", "@radix-ui/react-dialog": "^1.1.15", "@radix-ui/react-slot": "^1.2.4", "class-variance-authority": "^0.7.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2a7efb0..d29c6fa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,8 +14,8 @@ importers: .: dependencies: '@avail-project/nexus-core': - specifier: 2.2.4 - version: 2.2.4(@opentelemetry/api@1.9.1)(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10) + specifier: 2.4.0 + version: 2.4.0(@opentelemetry/api@1.9.1)(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10) '@radix-ui/react-accordion': specifier: ^1.2.12 version: 1.2.15(@types/react-dom@19.1.2(@types/react@19.1.2))(@types/react@19.1.2)(react-dom@19.2.2(react@19.2.2))(react@19.2.2) @@ -177,8 +177,8 @@ importers: packages/widgets: dependencies: '@avail-project/nexus-core': - specifier: 2.2.4 - version: 2.2.4(@opentelemetry/api@1.9.1)(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) + specifier: 2.4.0 + version: 2.4.0(@opentelemetry/api@1.9.1)(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) '@radix-ui/react-dialog': specifier: ^1.1.15 version: 1.1.18(@types/react-dom@19.1.2(@types/react@19.1.2))(@types/react@19.1.2)(react-dom@19.2.2(react@19.2.2))(react@19.2.2) @@ -267,12 +267,12 @@ packages: resolution: {integrity: sha512-C90iyzm/jLV7Lomv2UzwWUzRv9WZr1oRsFRKsX5HjQL4EXrbi9H/RtBkjCP+NF+ABZXUKpAa4F1dkoTaea4zHg==} hasBin: true - '@avail-project/nexus-core@2.2.4': - resolution: {integrity: sha512-acD+gpk0XsZ+dMM+Zp6qcCCU6IsiTbld3LkHfdgonoKKv96R3nNP1VO7z8nFsHFv/H0+cR+l+JdpEB8f5coXMg==} + '@avail-project/nexus-core@2.4.0': + resolution: {integrity: sha512-uXksQFviSN/NJtQNmqeve0nbJRbYtOzACHsM4F9IVbqpc8TzutG6eh8lnFckXdWZxlGfrM9pwBlxkVenmw9Yfw==} engines: {node: '>=18.0.0'} - '@avail-project/nexus-types@0.1.21': - resolution: {integrity: sha512-GMn36KmRa71qZDgZ505eWHDxsfxPEBJcXuafe3/8EVRdCzdXXT/2xVkCaAC61pyUAnktSP2oL7sLHWoA6r+6Gg==} + '@avail-project/nexus-types@0.1.25': + resolution: {integrity: sha512-KDEFVSjfGmCW0tKiNGS/zrB8yl9m8IPt+HBvIlgYk1G4Nh45fxCEfi0vKHyfzdmy7Ya44HNZglf+R/l6YkGM5A==} peerDependencies: zod: '>=4.0.0' @@ -6906,9 +6906,9 @@ snapshots: '@antfu/ni@23.3.1': {} - '@avail-project/nexus-core@2.2.4(@opentelemetry/api@1.9.1)(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)': + '@avail-project/nexus-core@2.4.0(@opentelemetry/api@1.9.1)(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)': dependencies: - '@avail-project/nexus-types': 0.1.21(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.4.3) + '@avail-project/nexus-types': 0.1.25(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.4.3) '@opentelemetry/api-logs': 0.219.0 '@opentelemetry/exporter-logs-otlp-http': 0.219.0(@opentelemetry/api@1.9.1) '@opentelemetry/resources': 2.8.0(@opentelemetry/api@1.9.1) @@ -6930,9 +6930,9 @@ snapshots: - typescript - utf-8-validate - '@avail-project/nexus-core@2.2.4(@opentelemetry/api@1.9.1)(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6)': + '@avail-project/nexus-core@2.4.0(@opentelemetry/api@1.9.1)(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6)': dependencies: - '@avail-project/nexus-types': 0.1.21(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6)(zod@4.4.3) + '@avail-project/nexus-types': 0.1.25(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6)(zod@4.4.3) '@opentelemetry/api-logs': 0.219.0 '@opentelemetry/exporter-logs-otlp-http': 0.219.0(@opentelemetry/api@1.9.1) '@opentelemetry/resources': 2.8.0(@opentelemetry/api@1.9.1) @@ -6954,7 +6954,7 @@ snapshots: - typescript - utf-8-validate - '@avail-project/nexus-types@0.1.21(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.4.3)': + '@avail-project/nexus-types@0.1.25(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.4.3)': dependencies: '@mayanfinance/swap-sdk': 13.3.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10) viem: 2.54.1(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.4.3) @@ -6967,7 +6967,7 @@ snapshots: - typescript - utf-8-validate - '@avail-project/nexus-types@0.1.21(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6)(zod@4.4.3)': + '@avail-project/nexus-types@0.1.25(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6)(zod@4.4.3)': dependencies: '@mayanfinance/swap-sdk': 13.3.0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6) viem: 2.54.1(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@6.0.6)(zod@4.4.3) From 78dd0f2c6585c9028e99a898120e5bae21fd5816 Mon Sep 17 00:00:00 2001 From: shrinathprabhu Date: Fri, 21 Aug 2026 16:51:59 +0530 Subject: [PATCH 2/3] Update the gas requirement --- registry.json | 18 +++--- registry/avail-widgets/deposit/utils.ts | 45 ++++++++++++++- .../nexus-widget/nexus-widget.tsx | 50 ++++++++++++++++- .../utils/deposit-source-selection.ts | 55 +++++++++++++++++-- .../avail-widgets/swaps/hooks/useSwaps.ts | 37 ++++++++++++- 5 files changed, 187 insertions(+), 18 deletions(-) diff --git a/registry.json b/registry.json index 1809043..2f251b7 100644 --- a/registry.json +++ b/registry.json @@ -248,7 +248,7 @@ } ], "dependencies": [ - "@avail-project/nexus-core@2.2.3", + "@avail-project/nexus-core@2.2.4", "lucide-react", "viem" ], @@ -609,7 +609,7 @@ } ], "dependencies": [ - "@avail-project/nexus-core@2.2.3", + "@avail-project/nexus-core@2.2.4", "clsx", "lucide-react", "tailwind-merge", @@ -807,7 +807,7 @@ } ], "dependencies": [ - "@avail-project/nexus-core@2.2.3", + "@avail-project/nexus-core@2.2.4", "lucide-react", "viem" ], @@ -1065,7 +1065,7 @@ } ], "dependencies": [ - "@avail-project/nexus-core@2.2.3", + "@avail-project/nexus-core@2.2.4", "decimal.js", "lucide-react", "viem", @@ -1095,7 +1095,7 @@ } ], "dependencies": [ - "@avail-project/nexus-core@2.2.3", + "@avail-project/nexus-core@2.2.4", "wagmi" ] }, @@ -1348,7 +1348,7 @@ } ], "dependencies": [ - "@avail-project/nexus-core@2.2.3", + "@avail-project/nexus-core@2.2.4", "lucide-react", "viem" ], @@ -1561,7 +1561,7 @@ } ], "dependencies": [ - "@avail-project/nexus-core@2.2.3", + "@avail-project/nexus-core@2.2.4", "lucide-react", "viem" ], @@ -1599,7 +1599,7 @@ } ], "dependencies": [ - "@avail-project/nexus-core@2.2.3", + "@avail-project/nexus-core@2.2.4", "lucide-react" ], "registryDependencies": [ @@ -1752,7 +1752,7 @@ } ], "dependencies": [ - "@avail-project/nexus-core@2.2.3", + "@avail-project/nexus-core@2.2.4", "lucide-react" ], "registryDependencies": [ diff --git a/registry/avail-widgets/deposit/utils.ts b/registry/avail-widgets/deposit/utils.ts index c837a8e..80696b0 100644 --- a/registry/avail-widgets/deposit/utils.ts +++ b/registry/avail-widgets/deposit/utils.ts @@ -390,13 +390,56 @@ export function resolveDepositSourceSelection(params: { sourceIds: sourcePoolIds, }); - const fromSources = buildSortedFromSources({ + const sortedFromSources = buildSortedFromSources({ sourceIds: resolvedSelectedSourceIds, swapBalance, destination, minimumBalanceUsd, }); + const destChainId = destination.chainId; + const nativeSymbol = (CHAIN_METADATA as any)[destChainId]?.nativeCurrency?.symbol?.toUpperCase(); + let destGasTokenAddress: Hex = ZERO_ADDRESS as Hex; + for (const asset of swapBalance ?? []) { + for (const breakdown of asset.breakdown ?? []) { + if (breakdown.chain?.id !== destChainId) continue; + const breakdownSymbol = ( + breakdown.symbol ?? + asset.symbol ?? + "" + ).toUpperCase(); + const assetSymbol = (asset.symbol ?? "").toUpperCase(); + const isNativeBal = + breakdown.contractAddress?.toLowerCase() === ZERO_ADDRESS || + breakdown.contractAddress?.toLowerCase() === EVM_NATIVE_PLACEHOLDER || + Boolean( + nativeSymbol && + (breakdownSymbol === nativeSymbol || assetSymbol === nativeSymbol) + ); + if (isNativeBal && breakdown.contractAddress) { + destGasTokenAddress = + breakdown.contractAddress.toLowerCase() === EVM_NATIVE_PLACEHOLDER + ? (ZERO_ADDRESS as Hex) + : (breakdown.contractAddress as Hex); + break; + } + } + } + + const hasDestGasToken = sortedFromSources.some( + (s) => + s.chainId === destChainId && + (s.tokenAddress.toLowerCase() === ZERO_ADDRESS || + s.tokenAddress.toLowerCase() === EVM_NATIVE_PLACEHOLDER) + ); + + const fromSources = hasDestGasToken + ? sortedFromSources + : [ + ...sortedFromSources, + { chainId: destChainId, tokenAddress: destGasTokenAddress }, + ]; + return { sourcePoolIds, selectedSourceIds: resolvedSelectedSourceIds, diff --git a/registry/avail-widgets/nexus-widget/nexus-widget.tsx b/registry/avail-widgets/nexus-widget/nexus-widget.tsx index f8e179c..bcd7b44 100644 --- a/registry/avail-widgets/nexus-widget/nexus-widget.tsx +++ b/registry/avail-widgets/nexus-widget/nexus-widget.tsx @@ -5822,6 +5822,47 @@ function NexusWidgetInner({ }; }; + const getDestinationGasTokenSource = () => { + const destChainId = toToken?.chainId; + if (!destChainId) { + return undefined; + } + + const nativeSymbol = + CHAIN_METADATA[destChainId]?.nativeCurrency?.symbol?.toUpperCase(); + let gasTokenAddress: `0x${string}` = zeroAddress; + + for (const asset of swapBalance ?? []) { + for (const breakdown of asset.breakdown ?? []) { + if (breakdown.chain?.id !== destChainId) continue; + const breakdownSymbol = ( + breakdown.symbol ?? + asset.symbol ?? + "" + ).toUpperCase(); + const assetSymbol = (asset.symbol ?? "").toUpperCase(); + const isNativeBalance = + isNativeTokenAddress(breakdown.contractAddress) || + Boolean( + nativeSymbol && + (breakdownSymbol === nativeSymbol || assetSymbol === nativeSymbol) + ); + + if (isNativeBalance && breakdown.contractAddress) { + gasTokenAddress = isNativeTokenAddress(breakdown.contractAddress) + ? zeroAddress + : (breakdown.contractAddress as `0x${string}`); + break; + } + } + } + + return { + chainId: destChainId, + tokenAddress: gasTokenAddress, + }; + }; + const shouldSendExactOutSourceAllowlist = () => { if (activeMode === "deposit") { return sourceSelectionTouched || depositSourceFilter !== "all"; @@ -5836,7 +5877,13 @@ function NexusWidgetInner({ const buildExactOutSourcesPayload = (tokens: SwapTokenOption[]) => { if (activeMode !== "deposit" && activeMode !== "send") { - return buildExplicitSourcesPayload(tokens); + const explicitSources = buildExplicitSourcesPayload(tokens).sources; + const sources = dedupeSdkSources([ + ...explicitSources, + getHeldDestinationTokenSource(), + getDestinationGasTokenSource(), + ]); + return sources.length > 0 ? { sources } : {}; } const sourceTokens = shouldSendExactOutSourceAllowlist() @@ -5846,6 +5893,7 @@ function NexusWidgetInner({ const sources = dedupeSdkSources([ ...explicitSources, getHeldDestinationTokenSource(), + getDestinationGasTokenSource(), ]); return sources.length > 0 ? { sources } : {}; diff --git a/registry/avail-widgets/nexus-widget/utils/deposit-source-selection.ts b/registry/avail-widgets/nexus-widget/utils/deposit-source-selection.ts index f44e977..982370d 100644 --- a/registry/avail-widgets/nexus-widget/utils/deposit-source-selection.ts +++ b/registry/avail-widgets/nexus-widget/utils/deposit-source-selection.ts @@ -416,14 +416,57 @@ export const resolveDepositSourceSelection = (params: { sourceIds: sourcePoolIds, }); + const sortedFromSources = buildSortedFromSources({ + sourceIds: resolvedSelectedSourceIds, + swapBalance, + destination, + minimumBalanceUsd, + }); + + const destChainId = destination.chainId; + const nativeSymbol = + CHAIN_METADATA[destChainId]?.nativeCurrency?.symbol?.toUpperCase(); + let destGasTokenAddress: Hex = ZERO_ADDRESS as Hex; + for (const asset of swapBalance ?? []) { + for (const breakdown of asset.breakdown ?? []) { + if (breakdown.chain?.id !== destChainId) continue; + const breakdownSymbol = ( + breakdown.symbol ?? + asset.symbol ?? + "" + ).toUpperCase(); + const assetSymbol = (asset.symbol ?? "").toUpperCase(); + const isNativeBal = + isNativeAddress(breakdown.contractAddress) || + Boolean( + nativeSymbol && + (breakdownSymbol === nativeSymbol || assetSymbol === nativeSymbol) + ); + if (isNativeBal && breakdown.contractAddress) { + destGasTokenAddress = isNativeAddress(breakdown.contractAddress) + ? (ZERO_ADDRESS as Hex) + : (breakdown.contractAddress as Hex); + break; + } + } + } + + const hasDestGasToken = sortedFromSources.some( + (s) => + s.chainId === destChainId && + isNativeAddress(s.tokenAddress) + ); + + const fromSources = hasDestGasToken + ? sortedFromSources + : [ + ...sortedFromSources, + { chainId: destChainId, tokenAddress: destGasTokenAddress }, + ]; + return { sourcePoolIds, selectedSourceIds: resolvedSelectedSourceIds, - fromSources: buildSortedFromSources({ - sourceIds: resolvedSelectedSourceIds, - swapBalance, - destination, - minimumBalanceUsd, - }), + fromSources, }; }; diff --git a/registry/avail-widgets/swaps/hooks/useSwaps.ts b/registry/avail-widgets/swaps/hooks/useSwaps.ts index cdf2958..33cb702 100644 --- a/registry/avail-widgets/swaps/hooks/useSwaps.ts +++ b/registry/avail-widgets/swaps/hooks/useSwaps.ts @@ -519,8 +519,43 @@ const useSwaps = ({ sources.push({ chainId: opt.chainId, tokenAddress: opt.tokenAddress }); } + const destChainId = state.inputs.toChainID; + if (destChainId) { + const hasDestGasToken = sources.some( + (s) => + s.chainId === destChainId && + toComparableSdkAddress(s.tokenAddress) === + toComparableSdkAddress(ZERO_ADDRESS), + ); + if (!hasDestGasToken) { + let gasTokenAddress = ZERO_ADDRESS as `0x${string}`; + for (const asset of swapBalance ?? []) { + for (const breakdown of asset.breakdown ?? []) { + if ( + breakdown.chain?.id === destChainId && + toComparableSdkAddress(breakdown.contractAddress) === + toComparableSdkAddress(ZERO_ADDRESS) + ) { + gasTokenAddress = breakdown.contractAddress as `0x${string}`; + break; + } + } + } + sources.push({ + chainId: destChainId, + tokenAddress: gasTokenAddress, + }); + } + } + return sources.length > 0 ? sources : undefined; - }, [state.swapMode, effectiveExactOutSelectedKeys, exactOutSourceOptions]); + }, [ + state.swapMode, + effectiveExactOutSelectedKeys, + exactOutSourceOptions, + state.inputs.toChainID, + swapBalance, + ]); const isExactOutSourceSelectionDirty = useMemo(() => { return ( state.swapMode === "exactOut" && From 2b52ba8184c8a923910dc2a97d9d2ca49d6f1275 Mon Sep 17 00:00:00 2001 From: shrinathprabhu Date: Fri, 21 Aug 2026 22:29:08 +0530 Subject: [PATCH 3/3] Keep embed false --- .../deposit/hooks/use-deposit-widget.ts | 19 +++++++------------ registry/avail-widgets/deposit/types.ts | 4 ++-- .../nexus-widget/nexus-widget.tsx | 15 ++++++++------- registry/avail-widgets/nexus-widget/types.ts | 2 +- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/registry/avail-widgets/deposit/hooks/use-deposit-widget.ts b/registry/avail-widgets/deposit/hooks/use-deposit-widget.ts index 4a8c37e..5ad558c 100644 --- a/registry/avail-widgets/deposit/hooks/use-deposit-widget.ts +++ b/registry/avail-widgets/deposit/hooks/use-deposit-widget.ts @@ -62,9 +62,6 @@ function parseUsdAmount(value?: string): number { return parsed; } -function hasPositiveGasLimit(value: unknown): value is bigint { - return typeof value === "bigint" && value > BigInt(0); -} function summarizeIntentSources( intentSources: OnSwapIntentHookData["intent"]["sources"] | undefined, @@ -526,14 +523,12 @@ export function useDepositWidget( address, ); - if (!hasPositiveGasLimit(executeParams.gas)) { - const message = - "Deposit config executeDeposit must return a positive gas limit."; - dispatch({ type: "setError", payload: message }); - dispatch({ type: "setStatus", payload: "error" }); - onError?.(message); - return false; - } + const resolvedGas = + typeof executeParams?.gas === "bigint" + ? executeParams.gas + : executeParams?.gas !== undefined && executeParams?.gas !== null + ? BigInt(executeParams.gas) + : 1_000_000n; const newInputs: SwapAndExecuteParams = { toChainId: destination.chainId, @@ -554,7 +549,7 @@ export function useDepositWidget( spender: executeParams.tokenApproval.spender, } : undefined, - gas: executeParams.gas, + gas: resolvedGas, }, }; diff --git a/registry/avail-widgets/deposit/types.ts b/registry/avail-widgets/deposit/types.ts index 61a0117..ea2c4a5 100644 --- a/registry/avail-widgets/deposit/types.ts +++ b/registry/avail-widgets/deposit/types.ts @@ -88,8 +88,8 @@ export interface ExecuteDepositParams { user: Address; } -export type ExecuteDepositResult = Omit & { - gas: bigint; +export type ExecuteDepositResult = Omit & { + gas?: bigint; }; export interface UseDepositWidgetProps { diff --git a/registry/avail-widgets/nexus-widget/nexus-widget.tsx b/registry/avail-widgets/nexus-widget/nexus-widget.tsx index bcd7b44..7e218cd 100644 --- a/registry/avail-widgets/nexus-widget/nexus-widget.tsx +++ b/registry/avail-widgets/nexus-widget/nexus-widget.tsx @@ -3527,7 +3527,7 @@ export function NexusWidget(props: NexusWidgetProps) { function NexusWidgetInner({ config: rawConfig, - embed = true, + embed = false, className, connectedAddress, open: controlledOpen, @@ -9156,17 +9156,18 @@ function NexusWidgetInner({ selectedOpportunity.chainId, user ); - if (!isPositiveGasLimit(executeParams.gas)) { - throw new Error( - "Deposit config executeDeposit must return a positive gas limit." - ); - } + const resolvedGas = + typeof executeParams?.gas === "bigint" + ? executeParams.gas + : executeParams?.gas !== undefined && executeParams?.gas !== null + ? BigInt(executeParams.gas) + : 1_000_000n; executeConfig = { to: executeParams.to, value: executeParams.value, data: executeParams.data, tokenApproval: executeParams.tokenApproval, - gas: executeParams.gas, + gas: resolvedGas, }; } else if ( (activeMode === "send" || hasCustomSwapRecipient) && diff --git a/registry/avail-widgets/nexus-widget/types.ts b/registry/avail-widgets/nexus-widget/types.ts index 1eeb72c..03ee11f 100644 --- a/registry/avail-widgets/nexus-widget/types.ts +++ b/registry/avail-widgets/nexus-widget/types.ts @@ -11,7 +11,7 @@ export type DepositExecuteConfig = { to: Address; value?: bigint; data?: `0x${string}`; - gas: bigint; + gas?: bigint; tokenApproval?: { toTokenAddress: Address; amount: bigint;