Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 <amartya@availproject.org>",
"contributors": [
Expand All @@ -25,7 +25,7 @@
"postinstall": "fumadocs-mdx"
},
"dependencies": {
"@avail-project/nexus-core": "2.2.4",
"@avail-project/nexus-core": "2.4.1",
"@radix-ui/react-accordion": "^1.2.12",
"@radix-ui/react-checkbox": "^1.3.3",
"@radix-ui/react-collapsible": "^1.1.12",
Expand Down
4 changes: 2 additions & 2 deletions packages/widgets/package.json
Original file line number Diff line number Diff line change
@@ -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 <shrinathprabhu.123@gmail.com>",
"contributors": [
Expand Down Expand Up @@ -38,7 +38,7 @@
"registry": "https://registry.npmjs.org/"
},
"dependencies": {
"@avail-project/nexus-core": "2.2.4",
"@avail-project/nexus-core": "2.4.1",
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-slot": "^1.2.4",
"class-variance-authority": "^0.7.1",
Expand Down
689 changes: 438 additions & 251 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
}
],
"dependencies": [
"@avail-project/nexus-core@2.2.3",
"@avail-project/nexus-core@2.2.4",
"lucide-react",
"viem"
],
Expand Down Expand Up @@ -609,7 +609,7 @@
}
],
"dependencies": [
"@avail-project/nexus-core@2.2.3",
"@avail-project/nexus-core@2.2.4",
"clsx",
"lucide-react",
"tailwind-merge",
Expand Down Expand Up @@ -807,7 +807,7 @@
}
],
"dependencies": [
"@avail-project/nexus-core@2.2.3",
"@avail-project/nexus-core@2.2.4",
"lucide-react",
"viem"
],
Expand Down Expand Up @@ -1065,7 +1065,7 @@
}
],
"dependencies": [
"@avail-project/nexus-core@2.2.3",
"@avail-project/nexus-core@2.2.4",
"decimal.js",
"lucide-react",
"viem",
Expand Down Expand Up @@ -1095,7 +1095,7 @@
}
],
"dependencies": [
"@avail-project/nexus-core@2.2.3",
"@avail-project/nexus-core@2.2.4",
"wagmi"
]
},
Expand Down Expand Up @@ -1348,7 +1348,7 @@
}
],
"dependencies": [
"@avail-project/nexus-core@2.2.3",
"@avail-project/nexus-core@2.2.4",
"lucide-react",
"viem"
],
Expand Down Expand Up @@ -1561,7 +1561,7 @@
}
],
"dependencies": [
"@avail-project/nexus-core@2.2.3",
"@avail-project/nexus-core@2.2.4",
"lucide-react",
"viem"
],
Expand Down Expand Up @@ -1599,7 +1599,7 @@
}
],
"dependencies": [
"@avail-project/nexus-core@2.2.3",
"@avail-project/nexus-core@2.2.4",
"lucide-react"
],
"registryDependencies": [
Expand Down Expand Up @@ -1752,7 +1752,7 @@
}
],
"dependencies": [
"@avail-project/nexus-core@2.2.3",
"@avail-project/nexus-core@2.2.4",
"lucide-react"
],
"registryDependencies": [
Expand Down
20 changes: 8 additions & 12 deletions registry/avail-widgets/deposit/hooks/use-deposit-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -236,6 +233,7 @@ export function useDepositWidget(
...inputs,
sources: fromSources,
};
console.log("[NexusSDK] Calling swapAndExecute with config:", inputsWithSources);
let transactionSucceeded = false;
nexusSDK
.swapAndExecute(inputsWithSources, {
Expand Down Expand Up @@ -526,14 +524,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)
: BigInt(1_000_000);

const newInputs: SwapAndExecuteParams = {
toChainId: destination.chainId,
Expand All @@ -554,7 +550,7 @@ export function useDepositWidget(
spender: executeParams.tokenApproval.spender,
}
: undefined,
gas: executeParams.gas,
gas: resolvedGas,
},
};

Expand Down
4 changes: 2 additions & 2 deletions registry/avail-widgets/deposit/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ export interface ExecuteDepositParams {
user: Address;
}

export type ExecuteDepositResult = Omit<ExecuteParams, "toChainId"> & {
gas: bigint;
export type ExecuteDepositResult = Omit<ExecuteParams, "toChainId" | "gas"> & {
gas?: bigint;
};

export interface UseDepositWidgetProps {
Expand Down
37 changes: 36 additions & 1 deletion registry/avail-widgets/deposit/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,48 @@ export function resolveDepositSourceSelection(params: {
sourceIds: sourcePoolIds,
});

const fromSources = buildSortedFromSources({
const sortedFromSources = buildSortedFromSources({
sourceIds: resolvedSelectedSourceIds,
swapBalance,
destination,
minimumBalanceUsd,
});

const gasSources: Array<{ tokenAddress: Hex; chainId: number }> = [];

// Destination chain native gas token (e.g. ETH on Arbitrum/Optimism, POL on Polygon, etc.)
if (destination.chainId) {
gasSources.push({
chainId: destination.chainId,
tokenAddress: ZERO_ADDRESS as Hex,
});
}

// Active source chain(s) native gas tokens
for (const s of sortedFromSources) {
if (s.chainId) {
gasSources.push({
chainId: s.chainId,
tokenAddress: ZERO_ADDRESS as Hex,
});
}
}

const seen = new Set<string>();
const fromSources: Array<{ tokenAddress: Hex; chainId: number }> = [];

for (const source of [...sortedFromSources, ...gasSources]) {
const addr = source.tokenAddress.toLowerCase();
const normalized =
addr === ZERO_ADDRESS || addr === EVM_NATIVE_PLACEHOLDER
? ZERO_ADDRESS
: addr;
const key = `${source.chainId}:${normalized}`;
if (seen.has(key)) continue;
seen.add(key);
fromSources.push(source);
}

return {
sourcePoolIds,
selectedSourceIds: resolvedSelectedSourceIds,
Expand Down
Loading