@0xsquid/react-hooks 9.0.0-beta-bump-wagmi-viem.1 → 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 (141) 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 +5 -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-C6kS-jmR.js → index-BlAWmCDu.js} +6331 -2423
  62. package/dist/index-BlAWmCDu.js.map +1 -0
  63. package/dist/{index-qdyx4kRv.js → index-lvZT1hVo.js} +6336 -2420
  64. package/dist/index-lvZT1hVo.js.map +1 -0
  65. package/dist/{index.es-BFUlxkuY.js → index.es-C2hTEGoR.js} +5 -4
  66. package/dist/index.es-C2hTEGoR.js.map +1 -0
  67. package/dist/{index.es-DYkdUayP.js → index.es-hfCMk9rm.js} +5 -4
  68. package/dist/index.es-hfCMk9rm.js.map +1 -0
  69. package/dist/index.esm.js +4 -3
  70. package/dist/index.esm.js.map +1 -1
  71. package/dist/index.js +34 -33
  72. package/dist/index.js.map +1 -1
  73. package/dist/provider/index.d.ts +0 -1
  74. package/dist/{secretService-B0dq0pBR.js → secretService-C3-RQz_Q.js} +5 -4
  75. package/dist/{secretService-B0dq0pBR.js.map → secretService-C3-RQz_Q.js.map} +1 -1
  76. package/dist/{secretService-CVRY2vnf.js → secretService-CqZdXZDv.js} +5 -4
  77. package/dist/{secretService-CVRY2vnf.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 -1
  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-BL7JVIrT.js → stellarService.client-C-9OeI3W.js} +7 -6
  120. package/dist/{stellarService.client-BL7JVIrT.js.map → stellarService.client-C-9OeI3W.js.map} +1 -1
  121. package/dist/{stellarService.client-DdI-363G.js → stellarService.client-Dwpk6ir6.js} +7 -6
  122. package/dist/{stellarService.client-DdI-363G.js.map → stellarService.client-Dwpk6ir6.js.map} +1 -1
  123. package/package.json +36 -35
  124. package/dist/hooks/user/useUserParams.d.ts +0 -4
  125. package/dist/index-C6kS-jmR.js.map +0 -1
  126. package/dist/index-qdyx4kRv.js.map +0 -1
  127. package/dist/index.es-BFUlxkuY.js.map +0 -1
  128. package/dist/index.es-DYkdUayP.js.map +0 -1
  129. package/dist/services/internal/fiatToCryptoService.test.d.ts +0 -1
  130. package/dist/tests/apiService.test.d.ts +0 -1
  131. package/dist/tests/assetsService.test.d.ts +0 -1
  132. package/dist/tests/configService.test.d.ts +0 -1
  133. package/dist/tests/estimateService.test.d.ts +0 -1
  134. package/dist/tests/fetchSquidData.d.ts +0 -8
  135. package/dist/tests/numberService.test.d.ts +0 -1
  136. package/dist/tests/priceService.test.d.ts +0 -1
  137. package/dist/tests/searchService.test.d.ts +0 -1
  138. package/dist/tests/swapConfig.test.d.ts +0 -1
  139. package/dist/tests/transactionService.test.d.ts +0 -1
  140. package/dist/tests/transactionStatusService.test.d.ts +0 -1
  141. package/dist/tests/walletService.test.d.ts +0 -1
@@ -0,0 +1,71 @@
1
+ export type DamlValueJson = {
2
+ party: string;
3
+ } | {
4
+ text: string;
5
+ } | {
6
+ numeric: string;
7
+ } | {
8
+ contractId: string;
9
+ } | {
10
+ timestamp: string;
11
+ } | {
12
+ bool: boolean;
13
+ } | {
14
+ list: {
15
+ elements: DamlValueJson[];
16
+ };
17
+ } | {
18
+ record: {
19
+ fields: Array<{
20
+ label: string;
21
+ value: DamlValueJson;
22
+ }>;
23
+ };
24
+ } | {
25
+ textMap: {
26
+ entries: Array<{
27
+ key: string;
28
+ value: DamlValueJson;
29
+ }>;
30
+ };
31
+ } | {
32
+ variant: {
33
+ constructor: string;
34
+ value: DamlValueJson;
35
+ };
36
+ };
37
+ type DamlValueField = [label: string, value: DamlValueJson];
38
+ type ChoiceContextScalar = string | number | boolean | null;
39
+ type ChoiceContextObject = {
40
+ [key: string]: ChoiceContextScalar;
41
+ };
42
+ type TaggedChoiceContextValue = string | {
43
+ tag: "AV_Text";
44
+ value: string;
45
+ } | {
46
+ tag: "AV_ContractId";
47
+ value: string;
48
+ } | {
49
+ tag: "AV_Bool";
50
+ value: boolean;
51
+ } | {
52
+ tag: "AV_List";
53
+ value: TaggedChoiceContextValue[];
54
+ } | {
55
+ tag: string;
56
+ value: ChoiceContextScalar | TaggedChoiceContextValue[] | ChoiceContextObject;
57
+ };
58
+ export declare const vParty: (party: string) => DamlValueJson;
59
+ export declare const vText: (text: string) => DamlValueJson;
60
+ export declare const vNumeric: (numeric: string) => DamlValueJson;
61
+ export declare const vContractId: (contractId: string) => DamlValueJson;
62
+ export declare const vList: (elements: DamlValueJson[]) => DamlValueJson;
63
+ export declare const vRecord: (fields: DamlValueField[]) => DamlValueJson;
64
+ export declare const vTextMap: (entries: Array<{
65
+ key: string;
66
+ value: DamlValueJson;
67
+ }>) => DamlValueJson;
68
+ export declare const vTimestamp: (isoString: string) => DamlValueJson;
69
+ export declare function normalizeChoiceContextValue(value: unknown): TaggedChoiceContextValue | null;
70
+ export declare function choiceContextValueToAnyValue(value: TaggedChoiceContextValue): DamlValueJson;
71
+ export {};
@@ -0,0 +1,82 @@
1
+ import { CantonConnector, CantonHolding, CantonInstrument } from "../../core/types/canton";
2
+ import { CantonWallet, ConnectorID } from "../../core/types/wallet";
3
+ export declare function getCantonCommandId(memo: string): string;
4
+ /**
5
+ * Format a Canton connector into a Squid {@link CantonWallet}. Shared by the
6
+ * announce-discovery and injected-provider paths.
7
+ */
8
+ export declare function formatCantonWallet({ connectorId, name, icon, connector, }: {
9
+ connectorId: ConnectorID;
10
+ name: string;
11
+ icon: string | undefined;
12
+ connector: CantonConnector;
13
+ }): CantonWallet;
14
+ /**
15
+ * Append injected wallets that aren't already covered by an announce-discovered
16
+ * wallet with the same connectorId (in case a wallet later does both).
17
+ */
18
+ export declare function mergeInjectedCantonWallets(announced: CantonWallet[], injected: CantonWallet[]): CantonWallet[];
19
+ export declare const CANTON_PARTY_ID_SEPARATOR = "::";
20
+ /** Canton Coin's well-known token-standard instrument id (its address carries no id prefix). */
21
+ export declare const CANTON_AMULET_INSTRUMENT_ID = "Amulet";
22
+ export declare function isCantonAddressValid(address: string): boolean;
23
+ /**
24
+ * Splice token-standard Holding interface id. A party's balance for an
25
+ * instrument is the sum of `amount` across active contracts implementing this interface.
26
+ */
27
+ export declare const CANTON_HOLDING_INTERFACE_ID = "#splice-api-token-holding-v1:Splice.Api.Token.HoldingV1:Holding";
28
+ /**
29
+ * Derive the token-standard instrument `{ admin, id }` from a Squid Canton token
30
+ * address (use the case-sensitive `originalAddress`), or `null` when the address
31
+ * is not a valid Canton token address.
32
+ *
33
+ * The admin party is the last two `::` segments (`name::fingerprint`); the
34
+ * instrument id is everything before that. Canton Coin has no id prefix
35
+ * (`DSO::1220…`) and uses the well-known id `Amulet`.
36
+ * - `DSO::1220…` -> { admin: "DSO::1220…", id: "Amulet" }
37
+ * - `USDCx::decentralized-usdc-…::12208…` -> { admin: "decentralized-usdc-…::12208…", id: "USDCx" }
38
+ */
39
+ export declare function parseCantonInstrument(address: string): CantonInstrument | null;
40
+ /**
41
+ * Body for `POST /v2/state/active-contracts`, filtered to the party's Holding
42
+ * contracts with the interface view included (so we can read amount/instrument).
43
+ *
44
+ * ACS: Active Contract Set — the ledger's currently-active contracts (created and
45
+ * not yet archived) as of a ledger offset.
46
+ */
47
+ export declare function buildHoldingsAcsRequestBody(partyId: string, activeAtOffset: string): {
48
+ activeAtOffset: string;
49
+ eventFormat: {
50
+ verbose: boolean;
51
+ filtersByParty: {
52
+ [x: string]: {
53
+ cumulative: {
54
+ identifierFilter: {
55
+ InterfaceFilter: {
56
+ value: {
57
+ interfaceId: string;
58
+ includeInterfaceView: boolean;
59
+ includeCreatedEventBlob: boolean;
60
+ };
61
+ };
62
+ };
63
+ }[];
64
+ };
65
+ };
66
+ };
67
+ };
68
+ /**
69
+ * Parse the party's Holding contracts (with contract ids) from a raw
70
+ * `/v2/state/active-contracts` response
71
+ * Defensive: skips entries it can't parse.
72
+ */
73
+ export declare function parseCantonHoldings(acsResponse: unknown): CantonHolding[];
74
+ export declare function cantonInstrumentKey(instrument: CantonInstrument): string;
75
+ /**
76
+ * Group the (unlocked) Holding amounts by instrument from a raw
77
+ * `/v2/state/active-contracts` response. Returns a map of instrument key
78
+ * (`admin|id`) -> human-readable decimal string (the token-standard `amount`
79
+ * is already a Decimal, not base units).
80
+ */
81
+ export declare function groupCantonHoldingBalances(acsResponse: unknown): Record<string, string>;
82
+ export declare function sumCantonHoldingBalances(holdings: readonly Pick<CantonHolding, "instrument" | "amount">[]): Record<string, string>;
@@ -0,0 +1,93 @@
1
+ import type { CantonLedgerReader, CantonHolding, CantonInstrument, CantonPrepareExecuteParams } from "../../core/types/canton";
2
+ import type { Token } from "../../core/types/tokens";
3
+ import type { DamlValueJson } from "./cantonDamlValue";
4
+ /** Metadata key used by Splice token-standard transfers to carry our Squid orderhash memo. */
5
+ export declare const CANTON_MEMO_KEY = "splice.lfdecentralizedtrust.org/reason";
6
+ /** Interface id for the transfer factory contract returned by the token registry. */
7
+ export declare const TRANSFER_FACTORY_INTERFACE_ID = "#splice-api-token-transfer-instruction-v1:Splice.Api.Token.TransferInstructionV1:TransferFactory";
8
+ export declare function resolveCantonRegistryUrl(instrument: CantonInstrument): string;
9
+ type ChoiceContextData = {
10
+ values?: Record<string, unknown>;
11
+ } & Record<string, unknown>;
12
+ interface TransferChoiceArgs {
13
+ expectedAdmin: string;
14
+ transfer: {
15
+ sender: string;
16
+ receiver: string;
17
+ amount: string;
18
+ instrumentId: {
19
+ admin: string;
20
+ id: string;
21
+ };
22
+ requestedAt: string;
23
+ executeBefore: string;
24
+ /**
25
+ * The input holdings to transfer.
26
+ * Cids: Contract IDs
27
+ */
28
+ inputHoldingCids: string[];
29
+ meta: {
30
+ values: Record<string, string>;
31
+ };
32
+ };
33
+ extraArgs: {
34
+ context: ChoiceContextData;
35
+ meta: {
36
+ values: Record<string, string>;
37
+ };
38
+ };
39
+ }
40
+ /**
41
+ * Build the plain JSON arguments expected by the registry transfer-factory
42
+ * endpoint before it adds choice context and disclosed contracts.
43
+ */
44
+ export declare function buildTransferChoiceArgs({ sender, receiver, amount, instrument, inputHoldingCids, memo, nowMs, }: {
45
+ sender: string;
46
+ receiver: string;
47
+ amount: string;
48
+ instrument: CantonInstrument;
49
+ inputHoldingCids: string[];
50
+ memo: string;
51
+ nowMs: number;
52
+ }): TransferChoiceArgs;
53
+ /**
54
+ * Canton's Holding contracts follow Bitcoin-style UTXOs model.
55
+ *
56
+ * Pick Holding contract ids covering `amount` for the instrument: prefer a
57
+ * single exact-amount holding, else accumulate largest-first.
58
+ */
59
+ export declare function selectInputHoldingCids(holdings: CantonHolding[], instrument: CantonInstrument, amount: string): string[];
60
+ export declare function fetchInputHoldingCids(connector: CantonLedgerReader, party: string, instrument: CantonInstrument, amount: string): Promise<string[]>;
61
+ interface TransferFactoryResponse {
62
+ factoryId: string;
63
+ transferKind?: string;
64
+ choiceContext: {
65
+ choiceContextData?: ChoiceContextData;
66
+ disclosedContracts?: Array<Record<string, unknown>>;
67
+ };
68
+ }
69
+ /**
70
+ * Ask the token registry for the transfer factory contract and extra context
71
+ * required to exercise its transfer choice.
72
+ */
73
+ export declare function fetchTransferFactory(registryUrl: string, choiceArgs: TransferChoiceArgs): Promise<TransferFactoryResponse>;
74
+ /**
75
+ * Convert transfer choice args into strict Daml Value JSON for the wallet's
76
+ * prepareExecute ExerciseCommand.
77
+ */
78
+ export declare function buildPrepareChoiceArgument(choiceArgs: TransferChoiceArgs): DamlValueJson;
79
+ /**
80
+ * Build a Splice token-standard transfer of `amount` of `token` from `sender`
81
+ * to `receiver`, carrying `memo`, ready to hand to a wallet's prepareExecute.
82
+ * Returns the full prepareExecute params (commandId + commands + actAs +
83
+ * disclosedContracts).
84
+ */
85
+ export declare function buildCantonTransfer(connector: CantonLedgerReader, { sender, receiver, amount, token, memo, nowMs, }: {
86
+ sender: string;
87
+ receiver: string;
88
+ amount: string;
89
+ token: Token;
90
+ memo: string;
91
+ nowMs: number;
92
+ }): Promise<CantonPrepareExecuteParams>;
93
+ export {};
@@ -1,7 +1,8 @@
1
1
  import { QueryClient } from "@tanstack/react-query";
2
- import type { AppConfig } from "../../core/types/config";
2
+ import type { AppConfig, NamedTokenConfig, TokenConfig } from "../../core/types/config";
3
3
  import { SwapDirection } from "../../core/types/swap";
4
4
  import { Chain, Token } from "../../core/types/tokens";
5
+ export declare const resolveChainIdFromAsset: (asset: TokenConfig | NamedTokenConfig, chains: Chain[]) => string | undefined;
5
6
  export declare const getConfigWithDefaults: (config: AppConfig | undefined) => AppConfig;
6
7
  export declare const randomIntFromInterval: (min: number, max: number) => number;
7
8
  export declare const getTokensForChain: (tokens: Token[], chainId: number | string | undefined) => Token[];
@@ -1,16 +1,19 @@
1
1
  import { RouteResponse } from "@0xsquid/squid-types";
2
- import type { SquidRouteError, SquidStatusError, TransactionErrorWithMessage } from "../../core/types/error";
2
+ import type { SquidRouteError, TransactionErrorWithMessage } from "../../core/types/error";
3
3
  import type { TransactionParams } from "../../core/types/transaction";
4
4
  interface NormalizedError {
5
5
  code?: string | number;
6
6
  message?: string;
7
7
  reason?: string;
8
+ dataCode?: string | number;
9
+ dataMessage?: string;
10
+ causeMessage?: string;
8
11
  }
9
12
  /**
10
13
  * Normalizes different error structures into a consistent format
11
14
  * This helps handle different wallet error formats uniformly
12
15
  */
13
- export declare const normalizeError: (error: any) => NormalizedError;
16
+ export declare const normalizeError: (error: unknown) => NormalizedError;
14
17
  export declare const transactionErrorCode: Record<string, TransactionErrorWithMessage>;
15
18
  /**
16
19
  * Detects if an error is a user rejection based on normalized error structure
@@ -21,7 +24,7 @@ export declare const isUserRejectionError: (normalizedError: NormalizedError) =>
21
24
  * @param error The error to convert
22
25
  * @returns A standardized error object
23
26
  */
24
- export declare const getTransactionError: (error: any) => TransactionErrorWithMessage;
27
+ export declare const getTransactionError: (error: unknown) => TransactionErrorWithMessage;
25
28
  /**
26
29
  * Handles dispatching appropriate events based on the error type
27
30
  */
@@ -35,5 +38,4 @@ export declare const handleTransactionErrorEvents: ({ error, transactionParams,
35
38
  * Check if the error is a Squid route error
36
39
  */
37
40
  export declare const isSwapRouteError: (error: any) => error is SquidRouteError;
38
- export declare const isStatusError: (error: any) => error is SquidStatusError;
39
41
  export {};
@@ -1,6 +1,7 @@
1
1
  import { RouteResponse } from "@0xsquid/sdk/dist/types";
2
- import { ChainData, ChainType, FeeCost, GasCost, Token } from "@0xsquid/squid-types";
2
+ import { ChainData, ChainType, Estimate, FeeCost, GasCost, Token } from "@0xsquid/squid-types";
3
3
  import { SimplifiedRouteAction } from "../../core/types/transaction";
4
+ import { ChainFeeParams } from "./tempoService";
4
5
  export type PartialFeeCost = Pick<FeeCost, "amount"> & {
5
6
  token?: Pick<FeeCost["token"], "decimals">;
6
7
  };
@@ -19,18 +20,15 @@ export declare const calculateTotalNativeFees: ({ expressFeeCost, firstFeeCost,
19
20
  firstGasCost: Pick<GasCost, "amount"> | undefined;
20
21
  sameTokenBetweenFees: boolean;
21
22
  }) => bigint;
22
- export declare const isFromBalanceEnoughToSwap: ({ isFromTokenNative, fromAmount, totalFeesInNativeTokenPlusRatio, nativeTokenBalanceFromChainWei, }: {
23
- isFromTokenNative: boolean;
23
+ export declare const checkIsGasBalanceEnough: ({ fromAmount, networkFeesWei, chainFeeParams, }: {
24
24
  fromAmount: string | undefined;
25
- fromTokenDecimals: number | undefined;
26
- totalFeesInNativeTokenPlusRatio: bigint;
27
- nativeTokenBalanceFromChainWei: bigint;
25
+ networkFeesWei: bigint;
26
+ chainFeeParams: ChainFeeParams | null;
28
27
  }) => boolean;
29
- export declare const calculateMinAmountValueWarnMsg: ({ isFromTokenNative, nativeTokenBalanceFromChainWei, sourceChainNativeTokenDecimals, totalFeesInNativeTokenPlusRatio, }: {
30
- isFromTokenNative: boolean;
31
- nativeTokenBalanceFromChainWei: bigint;
32
- sourceChainNativeTokenDecimals: number | undefined;
33
- totalFeesInNativeTokenPlusRatio: bigint;
28
+ export declare const calculateMinAmountValueWarnMsg: ({ networkFeesWei, chainFeeParams, fromTokenDecimals, }: {
29
+ networkFeesWei: bigint;
30
+ chainFeeParams: ChainFeeParams | null;
31
+ fromTokenDecimals: number | undefined;
34
32
  }) => string | undefined;
35
33
  /**
36
34
  * Calculates the estimated duration of a route
@@ -60,19 +58,28 @@ export declare const formatEstimatedRouteDuration: ({ estimatedRouteDuration, is
60
58
  * @returns {Object} An object containing various estimate results and calculations, including token information,
61
59
  * amounts, fees, gas costs, and other relevant data for the transaction.
62
60
  */
63
- export declare const calculateEstimateResults: ({ squidRoute, tokens, fromChain, toChain, collectFees, nativeTokenBalanceFromChainWei, }: {
64
- squidRoute: RouteResponse["route"] | undefined;
65
- tokens: Token[];
66
- fromChain?: ChainData | undefined;
67
- toChain?: ChainData | undefined;
61
+ export type EstimateRouteInput = {
62
+ params: Pick<RouteResponse["route"]["params"], "fromChain" | "fromToken">;
63
+ estimate: Pick<Estimate, "fromAmount" | "toAmount" | "toAmountMin" | "toAmountUSD" | "toAmountMinUSD" | "exchangeRate" | "estimatedRouteDuration" | "feeCosts"> & {
64
+ toToken: Pick<Token, "decimals">;
65
+ gasCosts: (Omit<GasCost, "token"> & {
66
+ token: Pick<Token, "chainId" | "address" | "decimals">;
67
+ })[];
68
+ actions?: Estimate["actions"];
69
+ };
70
+ };
71
+ export declare const calculateEstimateResults: <T extends Pick<Token, "chainId" | "address" | "decimals"> = Token>({ squidRoute, tokens, fromChain, toChain, collectFees, chainFeeParams, gasToken, }: {
72
+ squidRoute: EstimateRouteInput | undefined;
73
+ tokens: T[];
74
+ fromChain?: Pick<ChainData, "chainType" | "chainId"> | undefined;
75
+ toChain?: Pick<ChainData, "chainType" | "chainId"> | undefined;
68
76
  collectFees: boolean;
69
- nativeTokenBalanceFromChainWei: bigint;
77
+ chainFeeParams: ChainFeeParams | null;
78
+ gasToken: Pick<Token, "decimals"> | undefined;
70
79
  }) => {
71
- fromToken: any;
80
+ fromToken: T | undefined;
72
81
  fromAmount: string | undefined;
73
82
  fromAmountFormatted: string;
74
- sourceChainNativeToken: Token | undefined;
75
- destChainNativeToken: Token | undefined;
76
83
  toAmountUSD: string | undefined;
77
84
  exchangeRate: string;
78
85
  toAmountMinUSD: string;
@@ -87,15 +94,15 @@ export declare const calculateEstimateResults: ({ squidRoute, tokens, fromChain,
87
94
  expectedGasRefundCost: bigint;
88
95
  expectedGasRefundCostUSD: string;
89
96
  sameTokenBetweenFees: boolean;
90
- isFromTokenNative: boolean;
97
+ fromTokenPaysGasFees: boolean;
91
98
  totalNativeFees: bigint;
92
- totalFeesInNativeTokenPlusRatio: bigint;
93
- fromBalanceEnoughToSwap: boolean;
99
+ isGasBalanceEnough: boolean;
94
100
  minAmountValueWarnMsg: string | undefined;
95
101
  estimatedRouteDuration: {
96
102
  seconds: number;
97
103
  format: (sTemplate?: string, mTemplate?: string, hTemplate?: string) => string;
98
104
  };
105
+ gasBalanceNeeded: string | undefined;
99
106
  };
100
107
  /**
101
108
  * Calculates the total estimate with refund for a transaction.
@@ -110,13 +117,3 @@ export declare const calculateTotalWithRefundEstimate: (allFeeCosts: FeeCost[] |
110
117
  totalAmountUSD: number;
111
118
  feeToken: Token | undefined;
112
119
  };
113
- /**
114
- * Calculates the proposed gas amount for the destination chain.
115
- *
116
- * @param destChainNativeToken - The symbol of the native token for the destination chain.
117
- * @returns An object containing the proposed gas amount value and the currency symbol.
118
- */
119
- export declare const getProposedGasDestinationAmount: (destChainNativeToken: string | undefined) => {
120
- value: number;
121
- currency: string | undefined;
122
- };
@@ -56,6 +56,10 @@ export declare class WidgetEvents extends EventTarget {
56
56
  toChainId?: string;
57
57
  fromTokenAddress?: string;
58
58
  toTokenAddress?: string;
59
+ fromNetworkName?: string;
60
+ toNetworkName?: string;
61
+ fromTokenSymbol?: string;
62
+ toTokenSymbol?: string;
59
63
  }): void;
60
64
  /**
61
65
  * Dispatch event when we are waiting for the user to sign the swap transaction
@@ -1,18 +1,20 @@
1
- import { ChainData } from "@0xsquid/squid-types";
1
+ import { ChainData, Token } from "@0xsquid/squid-types";
2
2
  import type { TransactionReceipt, TransactionResponse } from "ethers";
3
3
  import { Address as EvmAddress } from "viem";
4
4
  import { Connector } from "wagmi";
5
5
  import { EvmWallet } from "../../core/types/wallet";
6
6
  export declare const EvmNetworkNotSupportedErrorCode = 4902;
7
+ export declare function requiresZeroAllowanceReset(token: Token): boolean;
7
8
  export declare function addEthereumChain({ chain, provider, }: {
8
9
  chain: ChainData;
9
10
  provider: any;
10
11
  }): Promise<any>;
12
+ export declare const isEvmAddressValid: (address: string | undefined) => boolean;
11
13
  export declare const parseEvmAddress: (address: string | undefined) => EvmAddress | undefined;
12
14
  /**
13
15
  * Formats a Wagmi connector into a Squid Wallet
14
16
  */
15
- export declare function formatEvmWallet(connector: Connector): EvmWallet;
17
+ export declare function formatEvmWallet(connector: Connector, isMetaMaskAnnounced?: boolean): EvmWallet;
16
18
  export declare function filterWagmiConnector(connector: Connector): boolean;
17
19
  /**
18
20
  * Waits for a transaction receipt, handling retries if indexing is in progress
@@ -0,0 +1,9 @@
1
+ import type { Token } from "@0xsquid/squid-types";
2
+ import { Connection, PublicKey } from "@solana/web3.js";
3
+ export declare const solanaTokenProgramIds: readonly [PublicKey, PublicKey];
4
+ export declare const isSupportedSolanaTokenProgramId: (programId: PublicKey) => boolean;
5
+ export declare const getSupportedSolanaTokenProgramId: (tokenProgramId?: string) => PublicKey | undefined;
6
+ export declare const resolveSolanaTokenProgramId: ({ connection, token, }: {
7
+ connection: Connection;
8
+ token: Token;
9
+ }) => Promise<PublicKey>;
@@ -0,0 +1,41 @@
1
+ import type { StatusKeys, StatusWsTicket, SwapStatusResult } from "../../../core/types/status";
2
+ export declare class SwapStatusRequestError extends Error {
3
+ /**
4
+ * Undefined when the request got no response
5
+ */
6
+ readonly httpStatus?: number | undefined;
7
+ readonly retryAfterMs?: number | undefined;
8
+ constructor(message: string,
9
+ /**
10
+ * Undefined when the request got no response
11
+ */
12
+ httpStatus?: number | undefined, retryAfterMs?: number | undefined, options?: ErrorOptions);
13
+ }
14
+ export interface SwapStatusRequestParams {
15
+ keys: StatusKeys;
16
+ apiUrl: string;
17
+ integratorId: string;
18
+ /**
19
+ * Without it, the backend does not register the deposit of a route with a
20
+ * `SquidDataType.OnChainExecutionWithSignature` or
21
+ * `SquidDataType.DepositAddressWithSignature` transaction request
22
+ */
23
+ depositTxVerificationSignature?: string;
24
+ }
25
+ /**
26
+ * Requests the status of a swap from `GET /v3/status`.
27
+ *
28
+ * A 404 is a normal answer until the backend tracks the transaction, so it is
29
+ * returned as a value. Every other failure throws a `SwapStatusRequestError`.
30
+ */
31
+ export declare const fetchSwapStatus: (params: SwapStatusRequestParams) => Promise<SwapStatusResult>;
32
+ interface StatusWsTicketRequestParams {
33
+ apiUrl: string;
34
+ integratorId: string;
35
+ }
36
+ /**
37
+ * Requests a ticket for one connection to the status WebSocket from
38
+ * `POST /v3/status/ws/token`
39
+ */
40
+ export declare const requestStatusWsTicket: ({ apiUrl, integratorId, }: StatusWsTicketRequestParams) => Promise<StatusWsTicket>;
41
+ export {};
@@ -0,0 +1,52 @@
1
+ import { type ChainData } from "@0xsquid/squid-types";
2
+ import type { LegacyExplorerLinks } from "../../../core/types/history";
3
+ import type { SwapStatusAction, SwapStatusBridgeSourceTxHashes, SwapStatusDocument } from "../../../core/types/status";
4
+ import type { PatchedRouteActionResponse } from "../../../core/types/transaction";
5
+ import { type SwapProgressRouteAction, type SwapRouteSegment } from "./statusSteps";
6
+ export type SwapExplorerLinkType = "squidscan" | "axelarscan" | "chainflip" | "source";
7
+ export interface SwapExplorerLinks {
8
+ source: string | undefined;
9
+ destination: string | undefined;
10
+ axelarscan: string | undefined;
11
+ squidscan: string | undefined;
12
+ chainflip: string | undefined;
13
+ /**
14
+ * The link that shows the most of the swap
15
+ */
16
+ main: {
17
+ type: SwapExplorerLinkType;
18
+ url: string;
19
+ } | undefined;
20
+ }
21
+ /**
22
+ * The fields that the links are built from. A `SwapStatusDocument` and the
23
+ * `statusSummary` of a history item both have them.
24
+ */
25
+ export type SwapExplorerLinksSource = Pick<SwapStatusDocument, "transactionId" | "destinationTxHash" | "orderHash" | "bridges"> & {
26
+ actions?: Pick<SwapStatusAction, "type" | "bridgeType" | "sourceTxHash" | "swapId" | "depositChannelId" | "explorerUrl">[];
27
+ bridgeSourceTxHashes?: SwapStatusBridgeSourceTxHashes;
28
+ chainflipExplorerUrl?: string;
29
+ };
30
+ /**
31
+ * Builds the explorer links of a swap. The v3 status document has no URLs.
32
+ *
33
+ * @param statusTransactionId the transaction id that is sent to the status
34
+ * API. For a Chainflip deposit channel it is the channel id.
35
+ * @param sourceTxExplorerUrl the source link that the transaction already has.
36
+ * It is used instead of the link built from the source chain.
37
+ * @param legacy links that a history item got from the v2 status API
38
+ */
39
+ export declare const getSwapExplorerLinks: ({ document, fromChain, toChain, statusTransactionId, sourceTxExplorerUrl, legacy, }: {
40
+ document: SwapExplorerLinksSource | undefined;
41
+ fromChain: ChainData | undefined;
42
+ toChain: ChainData | undefined;
43
+ statusTransactionId: string | undefined;
44
+ sourceTxExplorerUrl?: string | undefined;
45
+ legacy?: LegacyExplorerLinks | undefined;
46
+ }) => SwapExplorerLinks;
47
+ export declare const getSwapStepLink: ({ action, segment, links, fromChainId, }: {
48
+ action: SwapProgressRouteAction & Pick<PatchedRouteActionResponse, "provider">;
49
+ segment: SwapRouteSegment;
50
+ links: SwapExplorerLinks;
51
+ fromChainId: string | undefined;
52
+ }) => string | undefined;
@@ -0,0 +1,29 @@
1
+ import { type SwapStatusOrNotFound } from "./statusMapping";
2
+ export interface SwapStatusLimit {
3
+ /**
4
+ * Time of the transaction in milliseconds
5
+ */
6
+ startedAt?: number;
7
+ /**
8
+ * How long a 404 or a request error counts as "in progress", from
9
+ * `startedAt`. Without it, or with `Infinity`, the swap is followed until
10
+ * it has a final status.
11
+ */
12
+ notFoundTimeoutMs?: number;
13
+ }
14
+ export interface SwapFollowLimit extends SwapStatusLimit {
15
+ /**
16
+ * Time in milliseconds at which the swap started to fail
17
+ */
18
+ failedSince?: number;
19
+ }
20
+ export declare const getSwapStatusNotFoundDeadline: ({ startedAt, notFoundTimeoutMs, }: SwapStatusLimit) => number | undefined;
21
+ /**
22
+ * @param status the status of a swap that is not final. `not_found` is a
23
+ * swap without a document.
24
+ * @returns the time from which a swap is no longer followed, or undefined
25
+ * when there is no limit
26
+ */
27
+ export declare const getSwapFollowDeadline: ({ status, failedSince, ...limit }: SwapFollowLimit & {
28
+ status: SwapStatusOrNotFound;
29
+ }) => number | undefined;
@@ -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;