Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/tolerate-null-swap-approval-fields.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@across-protocol/app-sdk": patch
---

Accept `null` (in addition to `undefined`) for optional fields in `swapApprovalResponseSchema`: `approvalTxns`, `steps.originSwap`, `steps.destinationSwap`, and `swapTx`. The `/swap/approval` endpoint now serializes these as explicit `null` for cases where they don't apply (e.g. `bridgeableToBridgeable` routes), which previously caused `getSwapQuote` to throw `Invalid swap approval response`. Consumers already coerce to truthy, so behavior is unchanged.
8 changes: 4 additions & 4 deletions packages/sdk/src/api/swap-approval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@ export const swapApprovalResponseSchema = z.object({
data: z.string(),
}),
)
.optional(),
.nullish(),
steps: z.object({
originSwap: swapStepSchema.optional(),
originSwap: swapStepSchema.nullish(),
bridge: bridgeStepSchema,
destinationSwap: swapStepSchema.optional(),
destinationSwap: swapStepSchema.nullish(),
}),
inputToken: z.object({
address: anyChainAddress,
Expand Down Expand Up @@ -280,7 +280,7 @@ export const swapApprovalResponseSchema = z.object({
expectedOutputAmount: bigNumberString,
minOutputAmount: bigNumberString,
expectedFillTime: positiveInteger,
swapTx: z.union([swapTxSchema, permitSwapTxSchema]).optional(),
swapTx: z.union([swapTxSchema, permitSwapTxSchema]).nullish(),
id: z.string().optional(),
});

Expand Down
2 changes: 0 additions & 2 deletions packages/sdk/test/common/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
polygon,
linea,
lisk,
scroll,
zora,
sepolia,
} from "viem/chains";
Expand All @@ -22,7 +21,6 @@ export const MAINNET_SUPPORTED_CHAINS = [
polygon,
linea,
lisk,
scroll,
zora,
] as const;

Expand Down
Loading