@xswap-link/sdk 0.15.1 → 0.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.json CHANGED
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "root": true,
3
+ "ignorePatterns": ["example"],
3
4
  "parser": "@typescript-eslint/parser",
4
5
  "plugins": ["@typescript-eslint"],
5
6
  "extends": [
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @xswap-link/xswap-sdk
2
2
 
3
+ ## 0.15.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 8d44122: Report fast delivery for CCTP routes and wait for the funds before calling a cross-chain swap done.
8
+
9
+ A route's speed is now read from the API's own `route.expressDelivery` flag where the API states it, instead of always being inferred from a non-zero express-delivery fee. CCTP charges no such fee — Circle's fast-transfer fee is taken out of the bridged USDC — so its routes were labelled "Est. Time 30 Min." and tracked with a 30-minute estimate while actually settling in seconds; they now report the flag outright. The fee test remains the fallback for the CCIP paths, where the fee is what buys express delivery, and the express-delivery fee row now only shows when there is a fee to show.
10
+
11
+ Once the source transaction is mined, a cross-chain swap now shows a delivery-progress view — spinner, per-chain steps and elapsed time — and polls `GET /getTransactionStatus` (the call that also claims an unclaimed CCTP transfer) until the transfer settles. The success view appears when the funds have actually landed, reports a delivery that arrived as the bridged token instead of the requested one, and links to the destination transaction. New public API: `getTransactionStatus`, the `useCrossChainDelivery` hook and the `TransactionStatusResponse` / `CrossChainDeliveryStatus` models.
12
+
3
13
  ## 0.15.1
4
14
 
5
15
  ### Patch Changes
package/README.md CHANGED
@@ -88,21 +88,39 @@ cd xswap-sdk
88
88
  pnpm i
89
89
  ```
90
90
 
91
- #### 2. Create new branch based on the `develop` one
91
+ #### 2. Test locally with the example app
92
+
93
+ ```sh
94
+ pnpm build # or `pnpm watch` to rebuild on every src change
95
+ cd example && pnpm i && pnpm dev
96
+ ```
97
+
98
+ Vite pre-bundles the SDK, so restart `pnpm dev` after every rebuild — a running
99
+ server keeps serving the bundle it started with.
100
+
101
+ Opens a Vite playground on http://localhost:5173 with `@xswap-link/sdk` linked
102
+ from the repo root (`link:..`). Chains and tokens come from the live `/chains`
103
+ endpoint, so `srcChain` / `srcToken` / `dstChain` / `dstToken` /
104
+ `highlightedDstTokens` are pickers, colors use color inputs and `width` a slider.
105
+ Picking a chain or token remounts the widget automatically (it reads those props
106
+ only on mount), "Remount" does it manually after editing `integratorId` or
107
+ `apiUrl`. Config is kept in localStorage, widget callbacks go to the console.
108
+
109
+ #### 3. Create new branch based on the `develop` one
92
110
 
93
111
  ```sh
94
112
  git checkout develop
95
113
  git checkout -b feature/<your_feature_name>
96
114
  ```
97
115
 
98
- #### 3. Create changeset
116
+ #### 4. Create changeset
99
117
 
100
118
  `pnpm changeset` and follow instructions to describe your changes
101
119
 
102
- #### 4. Commit changes
120
+ #### 5. Commit changes
103
121
 
104
122
  including changeset: `git commit -m "feat: <your desc>>"`
105
123
 
106
- #### 5. Create PR to `develop` branch
124
+ #### 6. Create PR to `develop` branch
107
125
 
108
126
  <p align="right">(<a href="#readme-top">back to top</a>)</p>
package/dist/index.d.mts CHANGED
@@ -265,6 +265,19 @@ interface BaseRoute {
265
265
  minAmountOut: string;
266
266
  xSwapFees: XSwapFees;
267
267
  message?: string;
268
+ /**
269
+ * Whether the route is delivered as express delivery, stated outright by the API.
270
+ *
271
+ * Served by the bridges whose speed the fee breakdown cannot express — today CCTP,
272
+ * which reports true on every route: it charges no express-delivery fee at all
273
+ * (Circle's fast-transfer fee comes out of the bridged USDC), so a client reading
274
+ * the fee saw every CCTP transfer as the slow tier.
275
+ *
276
+ * Absent everywhere else (the CCIP paths, single-chain), where the fee IS the
277
+ * signal — express delivery there is what a non-zero `expressDeliveryFee` buys —
278
+ * so fall back to the fee when this is undefined, never instead of it.
279
+ */
280
+ expressDelivery?: boolean;
268
281
  }
269
282
  interface EVMRoute extends BaseRoute {
270
283
  ecosystem: "evm";
@@ -363,6 +376,39 @@ type ImportedTokenData = {
363
376
  decimals: number;
364
377
  };
365
378
 
379
+ /**
380
+ * States the API reports for a submitted transaction (`GET /getTransactionStatus`).
381
+ *
382
+ * - `NOT_FOUND` — the source tx is not visible to the API's RPCs yet. Expected for
383
+ * the first poll or two after a swap; it is not a failure.
384
+ * - `IN_PROGRESS` — the source tx is mined and the destination has not settled yet.
385
+ * - `DONE` — the destination leg ran and the user holds the token they asked for.
386
+ * - `PARTIALLY_FAILED` — the transfer arrived but its destination swap did not run
387
+ * (or produced less than the committed minimum), so the bridged token was
388
+ * forwarded to the receiver as-is. Terminal: no swap will happen later.
389
+ * - `FAILED` — the source tx itself reverted.
390
+ * - `STUCK` — mined, but the bridge has not moved it for long enough that it needs
391
+ * looking at rather than waiting on.
392
+ */
393
+ type CrossChainDeliveryStatus = "NOT_FOUND" | "IN_PROGRESS" | "DONE" | "STUCK" | "FAILED" | "PARTIALLY_FAILED";
394
+ type DeliveryTransferInfo = {
395
+ hash: string;
396
+ chainId: string;
397
+ /** Absent on the plain tx references (the middle hop), which carry no transfer. */
398
+ token?: string;
399
+ amount?: string;
400
+ };
401
+ type TransactionStatusResponse = {
402
+ status: CrossChainDeliveryStatus;
403
+ integratorHash?: string;
404
+ /** The speed the transfer actually settled at, as resolved by the bridge itself. */
405
+ expressDelivery?: boolean;
406
+ receiver?: string;
407
+ sourceTx?: DeliveryTransferInfo;
408
+ middleTx?: DeliveryTransferInfo;
409
+ targetTx?: DeliveryTransferInfo;
410
+ };
411
+
366
412
  type TransferType = "CROSS_CHAIN" | "SINGLE_CHAIN";
367
413
  type TransactionHistory = {
368
414
  history: HistoryTransaction[];
@@ -524,4 +570,4 @@ declare const XPay: {
524
570
  TxWidgetWC: CustomElementConstructor;
525
571
  };
526
572
 
527
- export { type Addresses, type BridgeToken, type BridgeTokensDictionary, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, ContractName, type Contracts, type EVMRoute, Ecosystem, type EnqueueTxProps, Environment, type GenerateStakingCallsParams, type GetLeaderboardChangePayload, type GetPricesPayload, type GetRoutePayload, type GetSolanaRoutePayload, type GetTokenBalancesPayload, type HistoryTransaction, type ImportedTokenData, type ModalIntegrationPayload, type ModalIntegrationStyles, type ModalIntegrationThemeStyles, type MonitoredTransaction, type Prices, type Protocol, type SolanaRoute, SolanaWeb3Network, type Token, type TokenBalances, type TokenOption, type TokenPrices, type Transaction, type TransactionHistory, type TransactionRequest, type TransactionStatus, type Transactions, type TxConfigFormData, type TxStats, TxStatus, type TxUIWrapperState, TxWidgetWCWrapped as TxWidget, TxWidgetWC, type UnifiedRoute, Web3Environment, type WidgetIntegrationPayload, XSwapCallType, type XSwapFee, type XSwapFees, XPay as default, openTransactionModal };
573
+ export { type Addresses, type BridgeToken, type BridgeTokensDictionary, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, ContractName, type Contracts, type CrossChainDeliveryStatus, type DeliveryTransferInfo, type EVMRoute, Ecosystem, type EnqueueTxProps, Environment, type GenerateStakingCallsParams, type GetLeaderboardChangePayload, type GetPricesPayload, type GetRoutePayload, type GetSolanaRoutePayload, type GetTokenBalancesPayload, type HistoryTransaction, type ImportedTokenData, type ModalIntegrationPayload, type ModalIntegrationStyles, type ModalIntegrationThemeStyles, type MonitoredTransaction, type Prices, type Protocol, type SolanaRoute, SolanaWeb3Network, type Token, type TokenBalances, type TokenOption, type TokenPrices, type Transaction, type TransactionHistory, type TransactionRequest, type TransactionStatus, type TransactionStatusResponse, type Transactions, type TxConfigFormData, type TxStats, TxStatus, type TxUIWrapperState, TxWidgetWCWrapped as TxWidget, TxWidgetWC, type UnifiedRoute, Web3Environment, type WidgetIntegrationPayload, XSwapCallType, type XSwapFee, type XSwapFees, XPay as default, openTransactionModal };
package/dist/index.d.ts CHANGED
@@ -265,6 +265,19 @@ interface BaseRoute {
265
265
  minAmountOut: string;
266
266
  xSwapFees: XSwapFees;
267
267
  message?: string;
268
+ /**
269
+ * Whether the route is delivered as express delivery, stated outright by the API.
270
+ *
271
+ * Served by the bridges whose speed the fee breakdown cannot express — today CCTP,
272
+ * which reports true on every route: it charges no express-delivery fee at all
273
+ * (Circle's fast-transfer fee comes out of the bridged USDC), so a client reading
274
+ * the fee saw every CCTP transfer as the slow tier.
275
+ *
276
+ * Absent everywhere else (the CCIP paths, single-chain), where the fee IS the
277
+ * signal — express delivery there is what a non-zero `expressDeliveryFee` buys —
278
+ * so fall back to the fee when this is undefined, never instead of it.
279
+ */
280
+ expressDelivery?: boolean;
268
281
  }
269
282
  interface EVMRoute extends BaseRoute {
270
283
  ecosystem: "evm";
@@ -363,6 +376,39 @@ type ImportedTokenData = {
363
376
  decimals: number;
364
377
  };
365
378
 
379
+ /**
380
+ * States the API reports for a submitted transaction (`GET /getTransactionStatus`).
381
+ *
382
+ * - `NOT_FOUND` — the source tx is not visible to the API's RPCs yet. Expected for
383
+ * the first poll or two after a swap; it is not a failure.
384
+ * - `IN_PROGRESS` — the source tx is mined and the destination has not settled yet.
385
+ * - `DONE` — the destination leg ran and the user holds the token they asked for.
386
+ * - `PARTIALLY_FAILED` — the transfer arrived but its destination swap did not run
387
+ * (or produced less than the committed minimum), so the bridged token was
388
+ * forwarded to the receiver as-is. Terminal: no swap will happen later.
389
+ * - `FAILED` — the source tx itself reverted.
390
+ * - `STUCK` — mined, but the bridge has not moved it for long enough that it needs
391
+ * looking at rather than waiting on.
392
+ */
393
+ type CrossChainDeliveryStatus = "NOT_FOUND" | "IN_PROGRESS" | "DONE" | "STUCK" | "FAILED" | "PARTIALLY_FAILED";
394
+ type DeliveryTransferInfo = {
395
+ hash: string;
396
+ chainId: string;
397
+ /** Absent on the plain tx references (the middle hop), which carry no transfer. */
398
+ token?: string;
399
+ amount?: string;
400
+ };
401
+ type TransactionStatusResponse = {
402
+ status: CrossChainDeliveryStatus;
403
+ integratorHash?: string;
404
+ /** The speed the transfer actually settled at, as resolved by the bridge itself. */
405
+ expressDelivery?: boolean;
406
+ receiver?: string;
407
+ sourceTx?: DeliveryTransferInfo;
408
+ middleTx?: DeliveryTransferInfo;
409
+ targetTx?: DeliveryTransferInfo;
410
+ };
411
+
366
412
  type TransferType = "CROSS_CHAIN" | "SINGLE_CHAIN";
367
413
  type TransactionHistory = {
368
414
  history: HistoryTransaction[];
@@ -524,4 +570,4 @@ declare const XPay: {
524
570
  TxWidgetWC: CustomElementConstructor;
525
571
  };
526
572
 
527
- export { type Addresses, type BridgeToken, type BridgeTokensDictionary, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, ContractName, type Contracts, type EVMRoute, Ecosystem, type EnqueueTxProps, Environment, type GenerateStakingCallsParams, type GetLeaderboardChangePayload, type GetPricesPayload, type GetRoutePayload, type GetSolanaRoutePayload, type GetTokenBalancesPayload, type HistoryTransaction, type ImportedTokenData, type ModalIntegrationPayload, type ModalIntegrationStyles, type ModalIntegrationThemeStyles, type MonitoredTransaction, type Prices, type Protocol, type SolanaRoute, SolanaWeb3Network, type Token, type TokenBalances, type TokenOption, type TokenPrices, type Transaction, type TransactionHistory, type TransactionRequest, type TransactionStatus, type Transactions, type TxConfigFormData, type TxStats, TxStatus, type TxUIWrapperState, TxWidgetWCWrapped as TxWidget, TxWidgetWC, type UnifiedRoute, Web3Environment, type WidgetIntegrationPayload, XSwapCallType, type XSwapFee, type XSwapFees, XPay as default, openTransactionModal };
573
+ export { type Addresses, type BridgeToken, type BridgeTokensDictionary, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, ContractName, type Contracts, type CrossChainDeliveryStatus, type DeliveryTransferInfo, type EVMRoute, Ecosystem, type EnqueueTxProps, Environment, type GenerateStakingCallsParams, type GetLeaderboardChangePayload, type GetPricesPayload, type GetRoutePayload, type GetSolanaRoutePayload, type GetTokenBalancesPayload, type HistoryTransaction, type ImportedTokenData, type ModalIntegrationPayload, type ModalIntegrationStyles, type ModalIntegrationThemeStyles, type MonitoredTransaction, type Prices, type Protocol, type SolanaRoute, SolanaWeb3Network, type Token, type TokenBalances, type TokenOption, type TokenPrices, type Transaction, type TransactionHistory, type TransactionRequest, type TransactionStatus, type TransactionStatusResponse, type Transactions, type TxConfigFormData, type TxStats, TxStatus, type TxUIWrapperState, TxWidgetWCWrapped as TxWidget, TxWidgetWC, type UnifiedRoute, Web3Environment, type WidgetIntegrationPayload, XSwapCallType, type XSwapFee, type XSwapFees, XPay as default, openTransactionModal };