@0xsquid/react-hooks 9.0.0-beta-bump-wagmi-viem.2 → 9.0.0-beta-nodev24.0

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.
Files changed (142) hide show
  1. package/dist/core/canton/cantonConnector.d.ts +32 -0
  2. package/dist/core/canton/cip103Client.d.ts +20 -0
  3. package/dist/core/canton/errors.d.ts +4 -0
  4. package/dist/core/canton/injectedCantonProvider.d.ts +31 -0
  5. package/dist/core/canton/loopCantonConnector.d.ts +38 -0
  6. package/dist/core/client/index.d.ts +1 -0
  7. package/dist/core/connectors/bitcoin/wallets/keplr.d.ts +3 -0
  8. package/dist/core/connectors/bitcoin/wallets/phantom.d.ts +3 -1
  9. package/dist/core/connectors/bitcoin/wallets/unisat.d.ts +15 -0
  10. package/dist/core/constants.d.ts +9 -4
  11. package/dist/core/externalLinks.d.ts +1 -1
  12. package/dist/core/fallbackWallets.d.ts +16 -0
  13. package/dist/core/index.d.ts +1 -1
  14. package/dist/core/providers/CantonProvider.d.ts +19 -0
  15. package/dist/core/queries/queries-keys.d.ts +9 -4
  16. package/dist/core/queries/queryClient.d.ts +2 -0
  17. package/dist/core/types/bitcoin.d.ts +3 -0
  18. package/dist/core/types/canton.d.ts +92 -0
  19. package/dist/core/types/config.d.ts +9 -3
  20. package/dist/core/types/cosmos.d.ts +5 -0
  21. package/dist/core/types/error.d.ts +0 -6
  22. package/dist/core/types/event.d.ts +4 -0
  23. package/dist/core/types/history.d.ts +14 -6
  24. package/dist/core/types/index.d.ts +4 -3
  25. package/dist/core/types/solana.d.ts +8 -0
  26. package/dist/core/types/status.d.ts +116 -0
  27. package/dist/core/types/stellar.d.ts +52 -0
  28. package/dist/core/types/tokens.d.ts +4 -0
  29. package/dist/core/types/transaction.d.ts +5 -31
  30. package/dist/core/types/wallet.d.ts +16 -8
  31. package/dist/core/wallets.d.ts +5 -0
  32. package/dist/hooks/canton/useCanton.d.ts +2 -0
  33. package/dist/hooks/canton/useCantonWallets.d.ts +10 -0
  34. package/dist/hooks/chains/useSquidChains.d.ts +1 -0
  35. package/dist/hooks/index.d.ts +4 -2
  36. package/dist/hooks/stellar/useStellarTrustLine.d.ts +13 -0
  37. package/dist/hooks/store/historyStoreMigration.d.ts +9 -0
  38. package/dist/hooks/store/useDepositAddressStore.d.ts +18 -5
  39. package/dist/hooks/store/useHistoryStore.d.ts +2 -4
  40. package/dist/hooks/swap/useDepositAddress.d.ts +6 -7
  41. package/dist/hooks/swap/useUrlSwapParams.d.ts +10 -0
  42. package/dist/hooks/tokens/useBalance.d.ts +1 -0
  43. package/dist/hooks/tokens/useNativeBalance.d.ts +1 -0
  44. package/dist/hooks/tokens/useSourceChainGasToken.d.ts +13 -0
  45. package/dist/hooks/tokens/useSquidTokens.d.ts +1 -0
  46. package/dist/hooks/transaction/liveSwapStatus.d.ts +12 -0
  47. package/dist/hooks/transaction/send/useEstimateSendTransactionGas.d.ts +11 -2
  48. package/dist/hooks/transaction/swapStatusEffects.d.ts +9 -0
  49. package/dist/hooks/transaction/useAllTransactionsStatus.d.ts +1 -28
  50. package/dist/hooks/transaction/useArcFeeCheck.d.ts +5 -0
  51. package/dist/hooks/transaction/useDepositTransactionStatus.d.ts +18 -0
  52. package/dist/hooks/transaction/useEstimate.d.ts +7 -12
  53. package/dist/hooks/transaction/useSwapStatusQuery.d.ts +42 -0
  54. package/dist/hooks/transaction/useSwapTransactionStatus.d.ts +11 -7
  55. package/dist/hooks/transaction/useTempoFeeCheck.d.ts +11 -0
  56. package/dist/hooks/user/useHistory.d.ts +2 -2
  57. package/dist/hooks/wallet/useMultiChainWallet.d.ts +55 -29
  58. package/dist/hooks/wallet/useSigner.d.ts +1 -0
  59. package/dist/hooks/wallet/useWallet.d.ts +59 -29
  60. package/dist/hooks/xrpl/useXrplWallets.d.ts +2 -2
  61. package/dist/{index-DvtX3lMK.js → index-BlAWmCDu.js} +5726 -1884
  62. package/dist/index-BlAWmCDu.js.map +1 -0
  63. package/dist/{index-Am7B-ANI.js → index-lvZT1hVo.js} +5732 -1885
  64. package/dist/index-lvZT1hVo.js.map +1 -0
  65. package/dist/{index.es-tQM55FRF.js → index.es-C2hTEGoR.js} +8 -7
  66. package/dist/index.es-C2hTEGoR.js.map +1 -0
  67. package/dist/{index.es-D8CJEHCT.js → index.es-hfCMk9rm.js} +8 -7
  68. package/dist/index.es-hfCMk9rm.js.map +1 -0
  69. package/dist/index.esm.js +7 -6
  70. package/dist/index.esm.js.map +1 -1
  71. package/dist/index.js +37 -39
  72. package/dist/index.js.map +1 -1
  73. package/dist/provider/index.d.ts +0 -1
  74. package/dist/{secretService-owSXKwWk.js → secretService-C3-RQz_Q.js} +8 -7
  75. package/dist/{secretService-owSXKwWk.js.map → secretService-C3-RQz_Q.js.map} +1 -1
  76. package/dist/{secretService-j1xXWg00.js → secretService-CqZdXZDv.js} +8 -7
  77. package/dist/{secretService-j1xXWg00.js.map → secretService-CqZdXZDv.js.map} +1 -1
  78. package/dist/server.d.ts +1 -0
  79. package/dist/server.esm.js +120 -0
  80. package/dist/server.esm.js.map +1 -0
  81. package/dist/server.js +132 -0
  82. package/dist/server.js.map +1 -0
  83. package/dist/services/external/onrampAdapter.d.ts +3 -4
  84. package/dist/services/external/rpcService.d.ts +16 -1
  85. package/dist/services/external/stellarApiClient.d.ts +4 -0
  86. package/dist/services/external/stellarRpcClient.d.ts +2 -2
  87. package/dist/services/external/xrplRpcClient.d.ts +2 -1
  88. package/dist/services/index.d.ts +5 -0
  89. package/dist/services/internal/apiService.d.ts +0 -2
  90. package/dist/services/internal/arcService.d.ts +9 -0
  91. package/dist/services/internal/assetsService.d.ts +12 -3
  92. package/dist/services/internal/cantonDamlValue.d.ts +71 -0
  93. package/dist/services/internal/cantonService.d.ts +82 -0
  94. package/dist/services/internal/cantonTransferService.d.ts +93 -0
  95. package/dist/services/internal/configService.d.ts +2 -62
  96. package/dist/services/internal/errorService.d.ts +6 -4
  97. package/dist/services/internal/estimateService.d.ts +30 -33
  98. package/dist/services/internal/eventService.d.ts +4 -0
  99. package/dist/services/internal/evmService.d.ts +4 -2
  100. package/dist/services/internal/solanaTokenProgramService.d.ts +9 -0
  101. package/dist/services/internal/status/statusApi.d.ts +41 -0
  102. package/dist/services/internal/status/statusExplorerLinks.d.ts +52 -0
  103. package/dist/services/internal/status/statusFollow.d.ts +29 -0
  104. package/dist/services/internal/status/statusGuards.d.ts +19 -0
  105. package/dist/services/internal/status/statusHistory.d.ts +35 -0
  106. package/dist/services/internal/status/statusKeys.d.ts +8 -0
  107. package/dist/services/internal/status/statusMapping.d.ts +73 -0
  108. package/dist/services/internal/status/statusPolicy.d.ts +45 -0
  109. package/dist/services/internal/status/statusSteps.d.ts +40 -0
  110. package/dist/services/internal/status/statusWsClient.d.ts +157 -0
  111. package/dist/services/internal/stellarService.d.ts +9 -0
  112. package/dist/services/internal/tempoService.d.ts +42 -0
  113. package/dist/services/internal/transactionService.d.ts +11 -24
  114. package/dist/services/internal/transactionStatusService.d.ts +1 -54
  115. package/dist/services/internal/typeGuards.d.ts +10 -0
  116. package/dist/services/internal/urlParamsService.d.ts +19 -0
  117. package/dist/services/internal/walletService.d.ts +3 -6
  118. package/dist/services/internal/xrplService.d.ts +2 -0
  119. package/dist/{stellarService.client-B8EBfqQK.js → stellarService.client-C-9OeI3W.js} +10 -9
  120. package/dist/{stellarService.client-B8EBfqQK.js.map → stellarService.client-C-9OeI3W.js.map} +1 -1
  121. package/dist/{stellarService.client-x3phx3SN.js → stellarService.client-Dwpk6ir6.js} +10 -9
  122. package/dist/{stellarService.client-x3phx3SN.js.map → stellarService.client-Dwpk6ir6.js.map} +1 -1
  123. package/package.json +36 -35
  124. package/dist/hooks/squid/useSquidWagmiConfig.d.ts +0 -41
  125. package/dist/hooks/user/useUserParams.d.ts +0 -4
  126. package/dist/index-Am7B-ANI.js.map +0 -1
  127. package/dist/index-DvtX3lMK.js.map +0 -1
  128. package/dist/index.es-D8CJEHCT.js.map +0 -1
  129. package/dist/index.es-tQM55FRF.js.map +0 -1
  130. package/dist/services/internal/fiatToCryptoService.test.d.ts +0 -1
  131. package/dist/tests/apiService.test.d.ts +0 -1
  132. package/dist/tests/assetsService.test.d.ts +0 -1
  133. package/dist/tests/configService.test.d.ts +0 -1
  134. package/dist/tests/estimateService.test.d.ts +0 -1
  135. package/dist/tests/fetchSquidData.d.ts +0 -8
  136. package/dist/tests/numberService.test.d.ts +0 -1
  137. package/dist/tests/priceService.test.d.ts +0 -1
  138. package/dist/tests/searchService.test.d.ts +0 -1
  139. package/dist/tests/swapConfig.test.d.ts +0 -1
  140. package/dist/tests/transactionService.test.d.ts +0 -1
  141. package/dist/tests/transactionStatusService.test.d.ts +0 -1
  142. package/dist/tests/walletService.test.d.ts +0 -1
@@ -0,0 +1,19 @@
1
+ import type { StatusWsServerFrame, StatusWsTicket, SwapStatusDocument } from "../../../core/types/status";
2
+ /**
3
+ * Checks the fields that the status code reads. Unknown action types, bridge
4
+ * names and extra fields are accepted.
5
+ */
6
+ export declare const isSwapStatusDocument: (value: unknown) => value is SwapStatusDocument;
7
+ /**
8
+ * Reads a status document like `isSwapStatusDocument`, but keeps a document
9
+ * whose status is a value that the API added later: the swap shows as in
10
+ * progress until it gets a known status.
11
+ */
12
+ export declare const readSwapStatusDocument: (value: unknown) => SwapStatusDocument | undefined;
13
+ export declare const isStatusWsTicket: (value: unknown) => value is StatusWsTicket;
14
+ /**
15
+ * Reads a text frame of the status WebSocket
16
+ *
17
+ * @returns undefined for a frame that is not valid or not known
18
+ */
19
+ export declare const parseStatusWsFrame: (raw: string) => StatusWsServerFrame | undefined;
@@ -0,0 +1,35 @@
1
+ import { HistoryTxType, type HistoryTransaction, type SwapTransactionHistory } from "../../../core/types/history";
2
+ import { TransactionStatus } from "../../../core/types/transaction";
3
+ import { type SwapStatusOrNotFound } from "./statusMapping";
4
+ export declare const isNotSwapTransaction: (tx: HistoryTransaction) => tx is {
5
+ data: import("../../../core/types/history").FiatTransactionHistory;
6
+ txType: HistoryTxType.BUY;
7
+ } | {
8
+ data: import("../../../core/types/history").SendTransactionHistory;
9
+ txType: HistoryTxType.SEND;
10
+ };
11
+ export declare const swapHistoryPendingStatuses: readonly TransactionStatus[];
12
+ /**
13
+ * - `follow`: follow the status until it is final
14
+ * - `recheck`: request the status one time per app load
15
+ * - `none`: the status is final, cannot be requested or is too old
16
+ */
17
+ type SwapHistoryStatusPlan = "follow" | "recheck" | "none";
18
+ export declare const getSwapHistoryStatusPlan: (transaction: SwapTransactionHistory, now: number) => SwapHistoryStatusPlan;
19
+ /**
20
+ * Returns the status that the history item got from the status API. It is
21
+ * undefined when the item has another status, for example after a failure of
22
+ * the source transaction in the wallet.
23
+ */
24
+ export declare const getKnownSwapStatus: (transaction: Pick<SwapTransactionHistory, "status" | "statusSummary">) => SwapStatusOrNotFound | undefined;
25
+ export interface SwapHistoryQueryParams {
26
+ /**
27
+ * Time of the transaction in milliseconds
28
+ */
29
+ startedAt: number;
30
+ notFoundTimeoutMs: number;
31
+ failedSince?: number;
32
+ depositTxVerificationSignature?: string;
33
+ }
34
+ export declare const getSwapHistoryQueryParams: (transaction: SwapTransactionHistory, transactionSignature?: string) => SwapHistoryQueryParams;
35
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { StatusKeys } from "../../../core/types/status";
2
+ import type { SwapTransactionForStatus } from "../../../core/types/transaction";
3
+ /**
4
+ * Returns the keys of the status request, or undefined when the status of the
5
+ * transaction cannot be requested
6
+ */
7
+ export declare const getSwapStatusKeys: (transaction: Pick<SwapTransactionForStatus, "fromChain" | "transactionId" | "transactionIdForStatus" | "quoteId">) => StatusKeys | undefined;
8
+ export declare const getSwapStatusKeyId: ({ quoteId, transactionId }: StatusKeys) => string;
@@ -0,0 +1,73 @@
1
+ import type { KnownSwapStatusActionStatus, StatusKeys, SwapStatus, SwapStatusAction, SwapStatusBridgeSourceTxHashes, SwapStatusDocument, SwapStatusSummary } from "../../../core/types/status";
2
+ import { type TransactionParams, TransactionStatus } from "../../../core/types/transaction";
3
+ export declare const SWAP_STATUS_NOT_FOUND = "not_found";
4
+ export declare const SWAP_STATUS_NOT_FOUND_SLOW_AFTER_MS: number;
5
+ export declare const SWAP_STATUS_NOT_FOUND_TIMEOUT_MS: number;
6
+ export declare const SWAP_STATUS_FAILED_FOLLOW_MS: number;
7
+ export declare const SWAP_STATUS_MAX_FOLLOW_AGE_MS: number;
8
+ export declare const SWAP_STATUS_RECHECK_MAX_AGE_MS: number;
9
+ export declare const SWAP_STATUS_NOT_FOUND_SLOW_POLL_INTERVAL_MS = 30000;
10
+ export type SwapStatusOrNotFound = SwapStatus | typeof SWAP_STATUS_NOT_FOUND;
11
+ export declare const isSwapStatus: (value: unknown) => value is SwapStatus;
12
+ /**
13
+ * `failed` is not final: a failed bridge leg can be retried and reach
14
+ * `success` or `refunded`.
15
+ */
16
+ export declare const isFinalSwapStatus: (status: SwapStatus) => boolean;
17
+ export declare const getSwapTransactionStatus: (status: SwapStatus) => TransactionStatus;
18
+ /**
19
+ * The status that the progress view of a swap shows. A `success` document
20
+ * wins over the local transaction, because the steps show it as delivered.
21
+ */
22
+ export declare const getDisplayedSwapStatus: (transaction: Pick<TransactionParams, "error" | "sourceStatus"> | undefined, latestStatus: TransactionStatus | undefined, document: Pick<SwapStatusDocument, "status"> | undefined) => TransactionStatus;
23
+ /**
24
+ * Returns the `squidTransactionStatus` value of the v2 status API, which is
25
+ * the value of the `swapStatus` widget event
26
+ */
27
+ export declare const getLegacySwapStatus: (status: SwapStatusOrNotFound) => string;
28
+ /**
29
+ * @returns the delay before the next status request in milliseconds, or
30
+ * undefined when the status is final
31
+ */
32
+ export declare const getSwapStatusPollInterval: (status: SwapStatusOrNotFound) => number | undefined;
33
+ /**
34
+ * @returns the time at which the swap started to fail, or undefined when the
35
+ * status is not `failed`
36
+ */
37
+ export declare const getFailedSince: (status: SwapStatusOrNotFound | undefined, failedSince?: number) => number | undefined;
38
+ export declare const getBridgeSourceTxHashes: (actions: Pick<SwapStatusAction, "bridgeType" | "sourceTxHash">[] | undefined) => SwapStatusBridgeSourceTxHashes | undefined;
39
+ export declare const CHAINFLIP_SCAN_URL = "https://scan.chainflip.io";
40
+ export declare const getChainflipExplorerUrl: (actions: Pick<SwapStatusAction, "type" | "swapId" | "depositChannelId" | "explorerUrl">[] | undefined) => string | undefined;
41
+ export declare const isSameBridgeSourceTxHashes: (a: SwapStatusBridgeSourceTxHashes | undefined, b: SwapStatusBridgeSourceTxHashes | undefined) => boolean;
42
+ export declare const getSwapStatusSummary: (document: SwapStatusDocument, failedSince?: number) => SwapStatusSummary;
43
+ export interface SwapStatusSegment {
44
+ status: KnownSwapStatusActionStatus;
45
+ actions: SwapStatusAction[];
46
+ }
47
+ export interface SwapStatusSegments {
48
+ source: SwapStatusSegment;
49
+ bridge: SwapStatusSegment | undefined;
50
+ destination: SwapStatusSegment | undefined;
51
+ refund: SwapStatusAction | undefined;
52
+ }
53
+ /**
54
+ * Groups the actions of a document into the source, bridge and destination
55
+ * segments of the route.
56
+ *
57
+ * The status of a segment does not come from its own actions alone. The
58
+ * source action of some deposit routes stays `NOT_STARTED` for the whole
59
+ * swap, so a segment is `COMPLETED` when a later segment has started or when
60
+ * the swap was delivered.
61
+ */
62
+ export declare const getSwapStatusSegments: (document: Pick<SwapStatusDocument, "status" | "actions">) => SwapStatusSegments;
63
+ /**
64
+ * Checks if the funds of the user arrived and the swap is now in progress.
65
+ * Used by deposit address flows, where there is no wallet transaction to wait
66
+ * for.
67
+ *
68
+ * A document has a source `transactionId` only when the source transaction
69
+ * exists, and its actions can all stay `NOT_STARTED` for some time after
70
+ * that. The backend can echo the queried channel id as the `transactionId`,
71
+ * so that value does not count.
72
+ */
73
+ export declare const isSourceDepositReceived: (document: Pick<SwapStatusDocument, "status" | "actions" | "transactionId">, keys: StatusKeys) => boolean;
@@ -0,0 +1,45 @@
1
+ import type { SwapTransactionHistory } from "../../../core/types/history";
2
+ import type { SwapStatusDocument, SwapStatusResult, SwapStatusSummary } from "../../../core/types/status";
3
+ import { TransactionStatus } from "../../../core/types/transaction";
4
+ import { type SwapStatusLimit } from "./statusFollow";
5
+ /**
6
+ * `null` is a 404: the backend does not know the swap yet
7
+ */
8
+ export type SwapStatusQueryData = SwapStatusDocument | null;
9
+ export interface SwapStatusRefetchIntervalParams extends SwapStatusLimit {
10
+ document: SwapStatusQueryData | undefined;
11
+ isError: boolean;
12
+ failedSince?: number;
13
+ /**
14
+ * True while the status WebSocket delivers every change of the swap
15
+ */
16
+ isLive?: boolean;
17
+ /**
18
+ * The backend registers the deposit of a signed order only from a REST
19
+ * request with the signature, so a live `not_found` alone never ends
20
+ */
21
+ hasSignature?: boolean;
22
+ now: number;
23
+ }
24
+ export interface SwapStatusHistoryUpdate {
25
+ status: TransactionStatus;
26
+ statusSummary?: SwapStatusSummary;
27
+ }
28
+ /**
29
+ * The one merge rule for a status result, from a request or from a push
30
+ */
31
+ export declare const mergeSwapStatus: (current: SwapStatusQueryData | undefined, result: SwapStatusResult) => SwapStatusQueryData;
32
+ /**
33
+ * @returns the delay before the next status request in milliseconds, or
34
+ * false when the swap is no longer followed
35
+ */
36
+ export declare const getSwapStatusRefetchInterval: ({ document, isError, startedAt, notFoundTimeoutMs, failedSince, isLive, hasSignature, now, }: SwapStatusRefetchIntervalParams) => number | false;
37
+ export declare const shouldRetrySwapStatus: ({ now, ...limit }: SwapStatusLimit & {
38
+ now: number;
39
+ }) => boolean;
40
+ export declare const getSwapStatusRetryDelay: (failureCount: number, error: Error) => number;
41
+ /**
42
+ * @returns what to write to the history item for the status data, or
43
+ * undefined when the item must not change
44
+ */
45
+ export declare const getSwapStatusHistoryUpdate: (item: SwapTransactionHistory, data: SwapStatusQueryData, now: number, fetchedAt: number) => SwapStatusHistoryUpdate | undefined;
@@ -0,0 +1,40 @@
1
+ import type { SwapStatusDocument } from "../../../core/types/status";
2
+ import { type PatchedRouteActionResponse, TransactionStatus } from "../../../core/types/transaction";
3
+ export type SwapStepStatus = "NOT_STARTED" | "IN_PROGRESS" | "COMPLETED" | "FAILED" | "WARNING";
4
+ export type SwapRouteSegment = "source" | "bridge" | "destination";
5
+ export type SwapProgressRouteAction = Pick<PatchedRouteActionResponse, "type" | "fromChain" | "toChain" | "coralV2Order">;
6
+ export interface SwapRouteActionProgress<T extends SwapProgressRouteAction = SwapProgressRouteAction> {
7
+ action: T;
8
+ segment: SwapRouteSegment;
9
+ status: SwapStepStatus;
10
+ }
11
+ export interface SwapProgress<T extends SwapProgressRouteAction = SwapProgressRouteAction> {
12
+ /**
13
+ * The source transaction
14
+ */
15
+ pay: SwapStepStatus;
16
+ /**
17
+ * One entry per route action. Only the first unfinished action is
18
+ * `IN_PROGRESS`.
19
+ */
20
+ actions: SwapRouteActionProgress<T>[];
21
+ /**
22
+ * `COMPLETED` when the swap was delivered
23
+ */
24
+ receive: SwapStepStatus;
25
+ }
26
+ export declare const isCoralRouteAction: (action: SwapProgressRouteAction) => boolean;
27
+ /**
28
+ * Resolves the progress of a swap from the route actions, the status
29
+ * document and the local status of the source transaction.
30
+ *
31
+ * @param sourceStatus the status of the source transaction in the wallet
32
+ * @param txStatus the status that the progress view shows
33
+ */
34
+ export declare const getSwapProgress: <T extends SwapProgressRouteAction>({ actions, fromChainId, document, sourceStatus, txStatus, }: {
35
+ actions: T[];
36
+ fromChainId: string;
37
+ document: SwapStatusDocument | undefined;
38
+ sourceStatus: TransactionStatus | undefined;
39
+ txStatus: TransactionStatus | undefined;
40
+ }) => SwapProgress<T>;
@@ -0,0 +1,157 @@
1
+ import type { StatusKeys, StatusWsTicket, SwapStatusResult } from "../../../core/types/status";
2
+ import { SwapStatusRequestError } from "./statusApi";
3
+ export interface StatusWsSocketHandlers {
4
+ onOpen: () => void;
5
+ onMessage: (data: string) => void;
6
+ onClose: (code: number, reason: string) => void;
7
+ }
8
+ export interface StatusWsSocket {
9
+ send: (data: string) => void;
10
+ close: (code?: number) => void;
11
+ }
12
+ export interface StatusWsClientDependencies {
13
+ /**
14
+ * A ticket opens one connection, so this is called for each attempt
15
+ */
16
+ requestTicket: () => Promise<StatusWsTicket>;
17
+ /**
18
+ * Defaults to the global `WebSocket`
19
+ */
20
+ createSocket?: (url: string, handlers: StatusWsSocketHandlers) => StatusWsSocket;
21
+ now?: () => number;
22
+ random?: () => number;
23
+ }
24
+ export interface StatusWsConnectionEnd {
25
+ /**
26
+ * The close event of the socket. Without it, the attempt failed before the
27
+ * server closed the socket.
28
+ */
29
+ close?: {
30
+ code: number;
31
+ reason: string;
32
+ };
33
+ /**
34
+ * The error of the ticket request. Its `retryAfterMs` can be longer than
35
+ * the backoff limit.
36
+ */
37
+ ticketError?: Partial<Pick<SwapStatusRequestError, "httpStatus" | "retryAfterMs">>;
38
+ wasStable: boolean;
39
+ failedAttempts: number;
40
+ hasSubscribableKeys: boolean;
41
+ }
42
+ export type StatusWsEndAction = {
43
+ type: "disable";
44
+ warning?: string;
45
+ } | {
46
+ type: "idle";
47
+ } | {
48
+ type: "reconnectNow";
49
+ } | {
50
+ type: "backoff";
51
+ retryAfterMs: number;
52
+ };
53
+ export interface StatusWsEndDecision {
54
+ action: StatusWsEndAction;
55
+ failedAttempts: number;
56
+ resetBackoff: boolean;
57
+ }
58
+ export declare const getStatusWsEndDecision: ({ close, ticketError, wasStable, failedAttempts, hasSubscribableKeys, }: StatusWsConnectionEnd) => StatusWsEndDecision;
59
+ /**
60
+ * Follows the status of swaps over the status WebSocket.
61
+ *
62
+ * It holds one connection for all watched status keys. When the WebSocket
63
+ * cannot be used, no status keys are live and the owner of the client polls
64
+ * instead.
65
+ */
66
+ export declare class StatusWsClient {
67
+ private readonly deps;
68
+ private readonly watches;
69
+ private readonly liveListeners;
70
+ private liveVersion;
71
+ private readonly closedKeys;
72
+ private readonly subscriptions;
73
+ private phase;
74
+ private disabled;
75
+ private connectionId;
76
+ private closingConnectionId;
77
+ private socket;
78
+ private subscriptionLimit;
79
+ private subscriptionCount;
80
+ private readyAt;
81
+ private backoffCount;
82
+ private failedAttempts;
83
+ private nextAttemptAt;
84
+ private ticketOrigin;
85
+ private removePolicyListener;
86
+ private outbox;
87
+ private sentAt;
88
+ private outboxTimer;
89
+ private readyTimer;
90
+ private reconnectTimer;
91
+ private idleTimer;
92
+ constructor(deps: StatusWsClientDependencies);
93
+ watch(keys: StatusKeys, onUpdate: (result: SwapStatusResult) => void, depositTxVerificationSignature?: string): () => void;
94
+ isLive(keys: StatusKeys): boolean;
95
+ /**
96
+ * Changes on each live change, for `useSyncExternalStore`
97
+ */
98
+ getLiveVersion(): number;
99
+ onLiveChange(listener: () => void): () => void;
100
+ /**
101
+ * Drops the connection and the disabled state, then connects again when
102
+ * there are watched status keys. For a change of the API or of the
103
+ * integrator.
104
+ */
105
+ reset(): void;
106
+ private createWatch;
107
+ private getInitialState;
108
+ private isEnded;
109
+ private hasWantedWatch;
110
+ private hasSubscribableWatch;
111
+ private notifyLiveChange;
112
+ private connect;
113
+ private open;
114
+ private handleMessage;
115
+ private handleReady;
116
+ private handleSubscribed;
117
+ private deliver;
118
+ private handleError;
119
+ private handleSubscriptionEnd;
120
+ /**
121
+ * @returns undefined when the status keys of the subscription are no longer
122
+ * watched, or when they are watched again without this subscription
123
+ */
124
+ private getSubscribedWatch;
125
+ private requeueCapped;
126
+ private subscribeQueued;
127
+ private send;
128
+ private flushOutbox;
129
+ /**
130
+ * Handles the end of a connection or of an attempt to connect
131
+ */
132
+ private endConnection;
133
+ /**
134
+ * Closes the socket and forgets the state of the connection. All status keys
135
+ * stop being live.
136
+ */
137
+ private dropConnection;
138
+ /**
139
+ * Stops the use of the WebSocket until `reset` or a page load
140
+ */
141
+ private disable;
142
+ /**
143
+ * Closes the connection when no status keys need it for some time, so that
144
+ * a new watch right after an unwatch uses the same connection. The failed
145
+ * attempts and the backoff stay, so that the limit applies across watches.
146
+ */
147
+ private syncIdle;
148
+ /**
149
+ * A content security policy that blocks the WebSocket URL does not change,
150
+ * so the client stops at the first violation. The socket only reports a
151
+ * close without a cause, and the event can arrive after that close.
152
+ */
153
+ private startPolicyListener;
154
+ private stopPolicyListener;
155
+ private isStable;
156
+ private now;
157
+ }
@@ -1,7 +1,16 @@
1
+ import { ChainData, Token } from "@0xsquid/squid-types";
1
2
  import { Networks as StellarNetwork } from "@stellar/stellar-sdk";
3
+ import { StellarHorizonIssuedAsset, StellarHorizonNativeAsset, StellarIssuedToken, StellarToken } from "../../core/types/stellar";
4
+ import { TrustLineAsset } from "../../core/types/tokens";
2
5
  export declare function isStellarAddressValid(address: string): boolean;
3
6
  export declare function getStellarNetwork(chainId: string): StellarNetwork | null;
4
7
  /**
5
8
  * Converts a Stellar address to a Soroban Contract address value
6
9
  */
7
10
  export declare function stellarAddressToScVal(addressString: string): import("@stellar/stellar-sdk").xdr.ScVal;
11
+ export declare function getStellarTrustLineAsset(token: StellarIssuedToken): TrustLineAsset | null;
12
+ export declare function isStellarToken(token: Token): token is StellarToken;
13
+ export declare function isStellarIssuedToken(token: Token): token is StellarIssuedToken;
14
+ export declare function getStellarHorizonApiUrl(chain: ChainData): string | null;
15
+ export declare function isValidIssuedAsset(asset: unknown): asset is StellarHorizonIssuedAsset;
16
+ export declare function isValidHorizonAsset(asset: unknown): asset is StellarHorizonNativeAsset | StellarHorizonIssuedAsset;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @docs https://docs.tempo.xyz/protocol/fees/spec-fee-amm#2-feemanager-contract
3
+ */
4
+ export declare const TEMPO_FEE_MANAGER_ADDRESS: "0xfeec000000000000000000000000000000000000";
5
+ export declare const feeManagerAbi: readonly [{
6
+ readonly name: "userTokens";
7
+ readonly type: "function";
8
+ readonly stateMutability: "view";
9
+ readonly inputs: readonly [{
10
+ readonly type: "address";
11
+ readonly name: "user";
12
+ }];
13
+ readonly outputs: readonly [{
14
+ readonly type: "address";
15
+ }];
16
+ }];
17
+ export declare const isTempoChain: (chainId: string | undefined) => boolean;
18
+ /**
19
+ * Convert a gas fee amount from 18 decimals (attodollars)
20
+ * to 6-decimal TIP-20 stablecoin units (microdollars).
21
+ * All TIP-20 tokens on Tempo have 6 decimals.
22
+ * @docs https://docs.tempo.xyz/protocol/fees/spec-fee#fee-units
23
+ */
24
+ export declare const convertTempoFeeToStablecoinUnits: (feeIn18Dec: bigint) => bigint;
25
+ export type TempoFeeData = {
26
+ gasBalance: bigint;
27
+ /**
28
+ * The address of the resolved gas token.
29
+ * Either the account-preferred token address or the fromToken address.
30
+ */
31
+ gasTokenAddress: string;
32
+ };
33
+ export type ChainFeeParams = {
34
+ fromTokenPaysGasFees: boolean;
35
+ gasTokenBalanceWei: bigint;
36
+ /**
37
+ * Converts a raw fee (from gas estimator)
38
+ * into the correct unit for the resolved gas token.
39
+ * Handles the 18-dec to 6-dec conversion for Tempo.
40
+ */
41
+ normalizeFee: (rawFee: bigint) => bigint;
42
+ };
@@ -1,30 +1,18 @@
1
- import { OnChainExecutionData, RouteResponse, SquidData, type ChainData, type StatusResponse } from "@0xsquid/squid-types";
2
- import { HistoryTransaction, SwapTransactionHistory } from "../../core/types/history";
3
- import { PatchedRouteActionResponse, SimplifiedRouteAction, SwapTransactionForHistoryStore, SwapTransactionForStatus, TransactionParams } from "../../core/types/transaction";
1
+ import { OnChainExecutionData, RouteActionResponse, RouteResponse, SquidData, type ChainData } from "@0xsquid/squid-types";
2
+ import { HistoryTransaction } from "../../core/types/history";
3
+ import { PatchedRouteActionResponse, SimplifiedRouteAction, SwapTransactionForHistoryStore } from "../../core/types/transaction";
4
4
  export declare const formatTransactionHistoryDate: (transaction: SwapTransactionForHistoryStore | undefined) => {
5
5
  month: string;
6
6
  day: string;
7
7
  } | undefined;
8
- export declare const getAxelarExplorerTxUrl: (urlPrefix: string | undefined, routeType: string | undefined, txID: string) => string | undefined;
9
8
  export declare const getSourceExplorerTxUrl: (chain: ChainData | undefined, txID: string) => string | undefined;
10
- export declare const getMainExplorerUrl: (transaction?: TransactionParams) => any;
11
9
  export declare const formatDistance: (date: number | Date, baseDate: number | Date, options?: {
12
10
  includeSeconds?: boolean | undefined;
13
11
  addSuffix?: boolean | undefined;
14
12
  locale?: Locale | undefined;
15
13
  }) => string;
16
14
  export declare const formatSeconds: (seconds: number, secondsTemplate?: string, minutesTemplate?: string, hoursTemplate?: string) => string;
17
- /**
18
- * Remove the chainData from statusResponse to gain some storage space
19
- */
20
- export declare const formatSwapTxStatusResponseForStorage: (sr: StatusResponse | undefined) => SwapTransactionHistory["statusResponse"];
21
15
  export declare const simplifyRouteAction: (action: PatchedRouteActionResponse) => SimplifiedRouteAction;
22
- export declare const fetchSwapTransactionStatus: ({ transaction, integratorId, apiUrl, }: {
23
- transaction?: SwapTransactionForStatus | undefined;
24
- integratorId: string;
25
- apiUrl: string;
26
- }) => Promise<StatusResponse>;
27
- export declare const compareTransactionIds: (idA: string, idB: string) => boolean;
28
16
  interface Locale {
29
17
  locale?: string;
30
18
  }
@@ -32,12 +20,14 @@ interface Locale {
32
20
  * Checks if the provided action is Coral bridge action
33
21
  */
34
22
  export declare function isCoralBridgeAction(action: SimplifiedRouteAction): boolean;
35
- export declare function sleep(ms: number): Promise<unknown>;
36
- export declare const isDepositRoute: (route?: RouteResponse["route"]) => boolean;
37
23
  /**
38
- * Checks if the route contains a Chainflip bridge action
24
+ * Determines if a given action completes as part of the user's source transaction.
25
+ * Action types like RFQ are fulfilled by a solver in a separate transaction,
26
+ * so they are NOT completed on source even if they share the same chain.
39
27
  */
40
- export declare function isChainflipBridgeTransaction(actions?: SimplifiedRouteAction[]): boolean;
28
+ export declare function isActionCompletedOnSourceTx(action: Pick<RouteActionResponse, "type" | "fromChain" | "toChain">, fromChainId: string): boolean;
29
+ export declare function sleep(ms: number): Promise<unknown>;
30
+ export declare const isChainflipDepositRoute: (route?: RouteResponse["route"]) => boolean;
41
31
  /**
42
32
  * Checks if a route is of type {@link OnChainExecutionData}
43
33
  *
@@ -45,11 +35,8 @@ export declare function isChainflipBridgeTransaction(actions?: SimplifiedRouteAc
45
35
  */
46
36
  export declare function isOnChainTxData(squidData: SquidData): squidData is OnChainExecutionData;
47
37
  /**
48
- * Checks if a route is of type deposit-with-signature
49
- *
50
- * deposit-with-signature routes are on-chain routes
51
- * that require a signature from the user to execute
38
+ * Checks if a route is of type DepositAddressDirectTransfer
52
39
  */
53
- export declare function isDepositWithSignatureTxData(squidData: SquidData): squidData is OnChainExecutionData;
40
+ export declare function isDepositAddressDirectTransferRoute(squidData: SquidData): squidData is OnChainExecutionData;
54
41
  export declare function getHistoryTransactionId(tx: HistoryTransaction): string;
55
42
  export {};
@@ -1,64 +1,11 @@
1
- import { ChainType, type ChainData, type StatusResponse, type Token } from "@0xsquid/squid-types";
2
- import { UseQueryResult } from "@tanstack/react-query";
1
+ import { ChainType } from "@0xsquid/squid-types";
3
2
  import { HistoryTransaction } from "../../core/types/history";
4
- import type { SimplifiedRouteAction, StepStatusGetterProps, SwapTransactionForStatus, TransactionParams } from "../../core/types/transaction";
5
- import { TransactionStatus, TransactionType } from "../../core/types/transaction";
6
- /**
7
- * Get the steps for a transaction
8
- * First step and second step are always the same
9
- * @param transaction
10
- * @param statusResponse
11
- * @returns {TransactionStepStatus[]}
12
- */
13
- export declare const getStepStatuses: ({ transaction, statusResponse, onlyFullStatusStep, }: StepStatusGetterProps) => TransactionStatus[];
14
- export declare const getHalfSuccessState: (status?: TransactionStatus) => TransactionStatus | undefined;
15
- export declare const getStepsInfos: ({ fromChain, toChain, fromToken, toToken, amount, txType, transaction, statusResponse, }: {
16
- txType: TransactionType;
17
- amount: string;
18
- fromChain?: ChainData | undefined;
19
- toChain?: ChainData | undefined;
20
- fromToken?: Token | undefined;
21
- toToken?: Token | undefined;
22
- transaction?: TransactionParams | undefined;
23
- statusResponse?: UseQueryResult<StatusResponse, unknown> | undefined;
24
- }) => {
25
- label: string;
26
- status: TransactionStatus;
27
- subTitle?: string;
28
- link?: string;
29
- }[];
30
- /**
31
- * Returns the status refetch interval of a Swap transaction
32
- * Some routes have a faster refetch interval (i.e Coral RFQ routes)
33
- *
34
- * @returns Refetch interval in milliseconds
35
- */
36
- export declare const getSwapTxStatusRefetchInterval: (transaction: Pick<SwapTransactionForStatus, "actions"> | undefined) => number;
37
3
  /**
38
4
  * Returns the status refetch interval of a Send transaction
39
5
  *
40
6
  * @returns Refetch interval in milliseconds
41
7
  */
42
8
  export declare const getSendTxStatusRefetchInterval: (chainType: ChainType) => number;
43
- export declare const chainflipMultihopBridgeType = "chainflipMultihop";
44
- /**
45
- * Some routes have special bridges, like CCTP or Chainflip
46
- * Squid API is using a different status endpoint to track status of these bridges
47
- * Only certain bridges are supported
48
- * @param transaction
49
- * @returns
50
- */
51
- export declare const getBridgeType: (actions?: SimplifiedRouteAction[]) => string | undefined;
52
- export declare const getTransactionStatus: (statusResponse: Pick<StatusResponse, "status" | "squidTransactionStatus">) => string | undefined;
53
- /**
54
- * Checks statusResponse of a transaction and returns the end status (if any)
55
- * If transaction status is not an end status, means the transaction is still pending
56
- *
57
- * End statuses are success, refunded, or error
58
- */
59
- export declare const getTransactionEndStatus: ({ statusResponse, }: {
60
- statusResponse: StatusResponse;
61
- }) => TransactionStatus | undefined;
62
9
  export declare function isHistoryTransactionPending({ txType, data, }: HistoryTransaction): boolean;
63
10
  export declare function isHistoryTransactionFailed({ txType, data, }: HistoryTransaction): boolean;
64
11
  export declare function isHistoryTransactionWarning({ txType, data, }: HistoryTransaction): boolean;
@@ -0,0 +1,10 @@
1
+ export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
2
+ export declare const isOptionalString: (value: unknown) => value is string | undefined;
3
+ export declare const isOneOf: <T>(values: readonly T[], value: unknown) => value is T;
4
+ export declare const isDefined: <T>(value: T | undefined) => value is T;
5
+ /**
6
+ * @returns undefined when the text is not valid JSON
7
+ */
8
+ export declare const parseJson: (text: string) => unknown;
9
+ export declare const readString: (value: unknown) => string;
10
+ export declare const readOptionalString: (value: unknown) => string | undefined;
@@ -0,0 +1,19 @@
1
+ import type { AppConfig } from "../../core/types/config";
2
+ import type { WidgetEventMap } from "../../core/types/event";
3
+ /**
4
+ * Parses URL search params into an initialAssets config object.
5
+ *
6
+ * Supports two formats:
7
+ * - Legacy: ?chains=fromId,toId&tokens=fromAddr,toAddr
8
+ * - Pretty: ?fromChain=ethereum&fromToken=eth&toChain=polygon&toToken=usdc
9
+ * - Collapsed chain/token: when both from/to chains or tokens are the same,
10
+ * they are collapsed into a single param:
11
+ * - ?chain=ethereum -> from and to chains are both ethereum
12
+ * - ?token=eth -> from and to tokens are both eth
13
+ */
14
+ export declare const parseInitialAssetsFromUrl: (searchParams: URLSearchParams) => AppConfig["initialAssets"];
15
+ /**
16
+ * Builds URL search params from a `swapParamsChanged` event detail.
17
+ * Uses the pretty format, collapsing chain/token params when both sides match.
18
+ */
19
+ export declare const buildUrlSearchParamsFromSwapEvent: (swapParams: WidgetEventMap["swapParamsChanged"]) => URLSearchParams;
@@ -2,6 +2,7 @@ import type { ChainData, Token } from "@0xsquid/squid-types";
2
2
  import { ChainType } from "@0xsquid/squid-types";
3
3
  import { Connector } from "@wagmi/core";
4
4
  import { IBitcoinContextData } from "../../core/providers/BitcoinProvider";
5
+ import { ICantonContextData } from "../../core/providers/CantonProvider";
5
6
  import { ICosmosContextData } from "../../core/providers/CosmosProvider";
6
7
  import { IEvmContextData } from "../../core/providers/EvmProvider";
7
8
  import { ISolanaContextData } from "../../core/providers/SolanaProvider";
@@ -17,14 +18,9 @@ type FormatHashParams = {
17
18
  export declare const formatHash: ({ chainType, hash }: FormatHashParams) => string;
18
19
  export declare const isWalletAddressValid: (chainData?: ChainData, address?: string) => boolean;
19
20
  export declare const redirectToExtensionsStore: (wallet: Wallet) => void;
20
- /**
21
- * Dynamically accesses a nested property of an object based on a dot-separated string path.
22
- * Returns the value of the property if found, otherwise undefined.
23
- * e.g. "xfi.keplr" will return window.xfi.keplr
24
- */
25
- export declare const accessProperty: (object: Record<string, any>, path: string) => any;
26
21
  export declare const definedInWindow: (path: string | undefined, clientWindow: Window | undefined) => boolean;
27
22
  export declare const populateWallets: <T extends Wallet>(window: Window | undefined, wallets: T[]) => T[];
23
+ export declare const buildFallbackWallets: (discovered: Wallet[]) => Wallet[];
28
24
  /**
29
25
  * Get the base chain to connect to
30
26
  * If only one chain type is selected, use that chain type
@@ -74,6 +70,7 @@ interface ConnectWalletMutations {
74
70
  connectSui: ISuiContextData["connectSui"];
75
71
  connectXrpl: IXrplContextData["connectXrpl"];
76
72
  connectStellar: IStellarContextData["connectStellar"];
73
+ connectCanton: ICantonContextData["connectCanton"];
77
74
  }
78
75
  type ConnectWalletParams = {
79
76
  wallet: Wallet;
@@ -1,4 +1,5 @@
1
1
  import { Token } from "@0xsquid/squid-types";
2
+ import { TrustLineAsset } from "../../core/types/tokens";
2
3
  import { XrplNetwork, XrplPaymentTx, XrplTrustSetTx } from "../../core/types/xrpl";
3
4
  /**
4
5
  * Validates that a given address is a valid XRPL address.
@@ -15,3 +16,4 @@ export declare function buildXrplTrustSetTx({ amount, sourceAddress, token, }: {
15
16
  }): XrplTrustSetTx;
16
17
  export declare function getXrplNetwork(chainId: string): XrplNetwork | null;
17
18
  export declare function parseXrplPaymentTx(data: unknown): XrplPaymentTx | null;
19
+ export declare function parseXrplTokenAddress(address: string): TrustLineAsset | null;