@lifi/sdk 0.0.0-preview-9b9526be → 0.0.0-preview-e8c80bc4

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 (43) hide show
  1. package/CHANGELOG.md +23 -1
  2. package/dist/cjs/actions/getRelayerQuote.d.ts +15 -7
  3. package/dist/cjs/actions/getRelayerQuote.js +16 -32
  4. package/dist/cjs/actions/getRelayerQuote.js.map +1 -1
  5. package/dist/cjs/actions/index.d.ts +2 -0
  6. package/dist/cjs/actions/index.js.map +1 -1
  7. package/dist/cjs/actions/relayTransaction.js +1 -2
  8. package/dist/cjs/actions/relayTransaction.js.map +1 -1
  9. package/dist/cjs/index.d.ts +2 -1
  10. package/dist/cjs/index.js +3 -0
  11. package/dist/cjs/utils/checkPackageUpdates.js +1 -1
  12. package/dist/cjs/utils/isGaslessStep.d.ts +13 -0
  13. package/dist/cjs/utils/isGaslessStep.js +20 -0
  14. package/dist/cjs/utils/isGaslessStep.js.map +1 -0
  15. package/dist/cjs/version.d.ts +1 -1
  16. package/dist/cjs/version.js +1 -1
  17. package/dist/cjs/version.js.map +1 -1
  18. package/dist/esm/actions/getRelayerQuote.d.ts +15 -7
  19. package/dist/esm/actions/getRelayerQuote.d.ts.map +1 -1
  20. package/dist/esm/actions/getRelayerQuote.js +16 -32
  21. package/dist/esm/actions/getRelayerQuote.js.map +1 -1
  22. package/dist/esm/actions/index.d.ts +2 -0
  23. package/dist/esm/actions/index.d.ts.map +1 -1
  24. package/dist/esm/actions/index.js.map +1 -1
  25. package/dist/esm/actions/relayTransaction.js +1 -2
  26. package/dist/esm/actions/relayTransaction.js.map +1 -1
  27. package/dist/esm/index.d.ts +2 -1
  28. package/dist/esm/index.js +2 -1
  29. package/dist/esm/utils/checkPackageUpdates.js +1 -1
  30. package/dist/esm/utils/isGaslessStep.d.ts +14 -0
  31. package/dist/esm/utils/isGaslessStep.d.ts.map +1 -0
  32. package/dist/esm/utils/isGaslessStep.js +18 -0
  33. package/dist/esm/utils/isGaslessStep.js.map +1 -0
  34. package/dist/esm/version.d.ts +1 -1
  35. package/dist/esm/version.js +1 -1
  36. package/dist/esm/version.js.map +1 -1
  37. package/package.json +1 -1
  38. package/src/actions/getRelayerQuote.ts +26 -76
  39. package/src/actions/index.ts +2 -0
  40. package/src/actions/relayTransaction.ts +1 -9
  41. package/src/index.ts +1 -0
  42. package/src/utils/isGaslessStep.ts +21 -0
  43. package/src/version.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,28 @@
1
1
  # @lifi/sdk
2
2
 
3
- ## 0.0.0-preview-9b9526be
3
+ ## 0.0.0-preview-e8c80bc4
4
+
5
+ ### Minor Changes
6
+
7
+ - [#548](https://github.com/lifinance/sdk/pull/548) [`de384d3`](https://github.com/lifinance/sdk/commit/de384d3fffbe0f87f73f268529b8f528cf2c4a8b) Thanks [@chybisov](https://github.com/chybisov)! - Support the new LI.FI gasless flow, and stop calling the legacy gasless service.
8
+
9
+ Request a gasless route with `options.gasless: true`. The `LIFI Gasless Relay Fee` entry in `estimate.feeCosts` marks its step. The new `isGaslessStep(step)` in `@lifi/sdk` checks for this marker, and `GASLESS_RELAY_FEE_NAME` holds its name.
10
+
11
+ For a gasless step, the EVM provider now does the following:
12
+
13
+ - It executes the step through the relayer from the start.
14
+ - It does not check native gas, does not approve, and does not sign its own permit. The relayer pays the gas, and the backend handles the allowance.
15
+ - It re-quotes through `/advanced/stepTransaction` without the old typed data.
16
+ - It relays every typed-data step through `/advanced/relay`, including `PermitWitnessTransferFrom`.
17
+ - It tracks the relay on `/v1/status?taskId=`, with the same wait as other relayed steps. Other relayed steps keep `getRelayedTransactionStatus`. On a bridge route, the wait ends when the relayed source transaction has landed. A later bridge failure then does not cause a second signature. After a `FAILED` answer, the SDK reads the source receipt to find out if the source landed.
18
+ - It fails before signing when `disableMessageSigning` is set, or when the step needs an EIP-7702 authorization.
19
+
20
+ For all relayed steps, the wait now ends after five status errors in a row, not after three errors in total. A status answer resets the count. A failed request, `NOT_FOUND` and 422/1004 count as errors. The error is not final, so a resume waits for the same task and asks for no new signature.
21
+
22
+ Deprecated (still exported, so that published consumers keep building):
23
+
24
+ - `getRelayerQuote` in `@lifi/sdk` and in the client actions. The legacy relayer endpoint is shut down, so it now rejects at once with a `NotFound` error and sends no request. Use `getRoutes` with `options.gasless: true`.
25
+ - `isGaslessStep(step, chain)` in `@lifi/sdk-provider-ethereum`. It detects only the legacy typed data. Use `isGaslessStep(step)` from `@lifi/sdk`.
4
26
 
5
27
  ### Patch Changes
6
28
 
@@ -2,11 +2,19 @@ import { QuoteRequestFromAmount } from "../types/actions.js";
2
2
  import { SDKClient } from "../types/core.js";
3
3
  import { LiFiStep, RequestOptions } from "@lifi/types";
4
4
  /**
5
- * Get a relayer quote for a token transfer
6
- * @param client - The SDK client
7
- * @param params - The configuration of the requested quote
8
- * @param options - Request options
9
- * @throws {LiFiError} - Throws a LiFiError if request fails
10
- * @returns Relayer quote for a token transfer
5
+ * Get a relayer quote for a token transfer. The legacy gasless relayer service
6
+ * behind it is shut down, so this always rejects and sends no request.
7
+ *
8
+ * Kept only so that published consumers that still import it keep building.
9
+ * It stays `async`: callers such as `getRelayerQuote(...).catch(() => null)`
10
+ * need a rejected promise, not a synchronous throw.
11
+ * @param _client - The SDK client
12
+ * @param _params - The configuration of the requested quote
13
+ * @param _options - Request options
14
+ * @throws {SDKError} - Always, with a `NotFound` cause.
15
+ * @returns Never resolves with a quote.
16
+ * @deprecated The legacy gasless relayer service is shut down. Request
17
+ * gasless routes with `options.gasless: true` on `getRoutes`, or
18
+ * `gasless: true` on `getQuote`, and detect them with `isGaslessStep`.
11
19
  */
12
- export declare const getRelayerQuote: (client: SDKClient, params: QuoteRequestFromAmount, options?: RequestOptions) => Promise<LiFiStep>;
20
+ export declare const getRelayerQuote: (_client: SDKClient, _params: QuoteRequestFromAmount, _options?: RequestOptions) => Promise<LiFiStep>;
@@ -1,42 +1,26 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_errors_baseError = require("../errors/baseError.js");
3
3
  require("../errors/constants.js");
4
- const require_errors_errors = require("../errors/errors.js");
5
4
  const require_errors_SDKError = require("../errors/SDKError.js");
6
- const require_utils_request = require("../utils/request.js");
7
5
  // src/actions/getRelayerQuote.ts
8
6
  /**
9
- * Get a relayer quote for a token transfer
10
- * @param client - The SDK client
11
- * @param params - The configuration of the requested quote
12
- * @param options - Request options
13
- * @throws {LiFiError} - Throws a LiFiError if request fails
14
- * @returns Relayer quote for a token transfer
7
+ * Get a relayer quote for a token transfer. The legacy gasless relayer service
8
+ * behind it is shut down, so this always rejects and sends no request.
9
+ *
10
+ * Kept only so that published consumers that still import it keep building.
11
+ * It stays `async`: callers such as `getRelayerQuote(...).catch(() => null)`
12
+ * need a rejected promise, not a synchronous throw.
13
+ * @param _client - The SDK client
14
+ * @param _params - The configuration of the requested quote
15
+ * @param _options - Request options
16
+ * @throws {SDKError} - Always, with a `NotFound` cause.
17
+ * @returns Never resolves with a quote.
18
+ * @deprecated The legacy gasless relayer service is shut down. Request
19
+ * gasless routes with `options.gasless: true` on `getRoutes`, or
20
+ * `gasless: true` on `getQuote`, and detect them with `isGaslessStep`.
15
21
  */
16
- const getRelayerQuote = async (client, params, options) => {
17
- for (const requiredParameter of [
18
- "fromChain",
19
- "fromToken",
20
- "fromAddress",
21
- "fromAmount",
22
- "toChain",
23
- "toToken"
24
- ]) if (!params[requiredParameter]) throw new require_errors_SDKError.SDKError(new require_errors_errors.ValidationError(`Required parameter "${requiredParameter}" is missing.`));
25
- params.integrator ??= client.config.integrator;
26
- params.order ??= client.config.routeOptions?.order;
27
- params.slippage ??= client.config.routeOptions?.slippage;
28
- params.referrer ??= client.config.routeOptions?.referrer;
29
- params.fee ??= client.config.routeOptions?.fee;
30
- params.allowBridges ??= client.config.routeOptions?.bridges?.allow;
31
- params.denyBridges ??= client.config.routeOptions?.bridges?.deny;
32
- params.preferBridges ??= client.config.routeOptions?.bridges?.prefer;
33
- params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow;
34
- params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny;
35
- params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer;
36
- for (const key of Object.keys(params)) if (params[key] === void 0 || params[key] === null) delete params[key];
37
- const result = await require_utils_request.request(client.config, `${client.config.apiUrl}/relayer/quote?${new URLSearchParams(params)}`, { signal: options?.signal });
38
- if (result.status === "error") throw new require_errors_baseError.BaseError("ServerError", result.data.code, result.data.message);
39
- return result.data;
22
+ const getRelayerQuote = async (_client, _params, _options) => {
23
+ throw new require_errors_SDKError.SDKError(new require_errors_baseError.BaseError("NotFoundError", 1006, "The legacy gasless relayer service is shut down. Request gasless routes with `options.gasless: true` on `getRoutes`."));
40
24
  };
41
25
  exports.getRelayerQuote = getRelayerQuote;
42
26
 
@@ -1 +1 @@
1
- {"version":3,"file":"getRelayerQuote.js","names":["SDKError","ValidationError","request","BaseError"],"sources":["../../../src/actions/getRelayerQuote.ts"],"sourcesContent":["import type {\n LiFiStep,\n RelayerQuoteResponse,\n RequestOptions,\n} from '@lifi/types'\nimport { BaseError } from '../errors/baseError.js'\nimport { ErrorName } from '../errors/constants.js'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { QuoteRequest, QuoteRequestFromAmount } from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get a relayer quote for a token transfer\n * @param client - The SDK client\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Relayer quote for a token transfer\n */\nexport const getRelayerQuote = async (\n client: SDKClient,\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n): Promise<LiFiStep> => {\n const requiredParameters: Array<keyof QuoteRequestFromAmount> = [\n 'fromChain',\n 'fromToken',\n 'fromAddress',\n 'fromAmount',\n 'toChain',\n 'toToken',\n ]\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n\n // apply defaults\n params.integrator ??= client.config.integrator\n params.order ??= client.config.routeOptions?.order\n params.slippage ??= client.config.routeOptions?.slippage\n params.referrer ??= client.config.routeOptions?.referrer\n params.fee ??= client.config.routeOptions?.fee\n params.allowBridges ??= client.config.routeOptions?.bridges?.allow\n params.denyBridges ??= client.config.routeOptions?.bridges?.deny\n params.preferBridges ??= client.config.routeOptions?.bridges?.prefer\n params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow\n params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny\n params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer\n\n for (const key of Object.keys(params)) {\n if (\n params[key as keyof QuoteRequest] === undefined ||\n params[key as keyof QuoteRequest] === null\n ) {\n delete params[key as keyof QuoteRequest]\n }\n }\n\n const result = await request<RelayerQuoteResponse>(\n client.config,\n `${client.config.apiUrl}/relayer/quote?${new URLSearchParams(\n params as unknown as Record<string, string>\n )}`,\n {\n signal: options?.signal,\n }\n )\n\n if (result.status === 'error') {\n throw new BaseError(\n ErrorName.ServerError,\n result.data.code,\n result.data.message\n )\n }\n\n return result.data\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAa,kBAAkB,OAC7B,QACA,QACA,YACsB;CAStB,KAAK,MAAM,qBAAqB;EAP9B;EACA;EACA;EACA;EACA;EACA;CAE+C,GAC/C,IAAI,CAAC,OAAO,oBACV,MAAM,IAAIA,wBAAAA,SACR,IAAIC,sBAAAA,gBACF,uBAAuB,kBAAkB,cAC3C,CACF;CAKJ,OAAO,eAAe,OAAO,OAAO;CACpC,OAAO,UAAU,OAAO,OAAO,cAAc;CAC7C,OAAO,aAAa,OAAO,OAAO,cAAc;CAChD,OAAO,aAAa,OAAO,OAAO,cAAc;CAChD,OAAO,QAAQ,OAAO,OAAO,cAAc;CAC3C,OAAO,iBAAiB,OAAO,OAAO,cAAc,SAAS;CAC7D,OAAO,gBAAgB,OAAO,OAAO,cAAc,SAAS;CAC5D,OAAO,kBAAkB,OAAO,OAAO,cAAc,SAAS;CAC9D,OAAO,mBAAmB,OAAO,OAAO,cAAc,WAAW;CACjE,OAAO,kBAAkB,OAAO,OAAO,cAAc,WAAW;CAChE,OAAO,oBAAoB,OAAO,OAAO,cAAc,WAAW;CAElE,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,GAClC,IACE,OAAO,SAA+B,KAAA,KACtC,OAAO,SAA+B,MAEtC,OAAO,OAAO;CAIlB,MAAM,SAAS,MAAMC,sBAAAA,QACnB,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,iBAAiB,IAAI,gBAC3C,MACF,KACA,EACE,QAAQ,SAAS,OACnB,CACF;CAEA,IAAI,OAAO,WAAW,SACpB,MAAM,IAAIC,yBAAAA,UAAAA,eAER,OAAO,KAAK,MACZ,OAAO,KAAK,OACd;CAGF,OAAO,OAAO;AAChB"}
1
+ {"version":3,"file":"getRelayerQuote.js","names":["SDKError","BaseError"],"sources":["../../../src/actions/getRelayerQuote.ts"],"sourcesContent":["import type { LiFiStep, RequestOptions } from '@lifi/types'\nimport { BaseError } from '../errors/baseError.js'\nimport { ErrorName, LiFiErrorCode } from '../errors/constants.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { QuoteRequestFromAmount } from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\n\n/**\n * Get a relayer quote for a token transfer. The legacy gasless relayer service\n * behind it is shut down, so this always rejects and sends no request.\n *\n * Kept only so that published consumers that still import it keep building.\n * It stays `async`: callers such as `getRelayerQuote(...).catch(() => null)`\n * need a rejected promise, not a synchronous throw.\n * @param _client - The SDK client\n * @param _params - The configuration of the requested quote\n * @param _options - Request options\n * @throws {SDKError} - Always, with a `NotFound` cause.\n * @returns Never resolves with a quote.\n * @deprecated The legacy gasless relayer service is shut down. Request\n * gasless routes with `options.gasless: true` on `getRoutes`, or\n * `gasless: true` on `getQuote`, and detect them with `isGaslessStep`.\n */\nexport const getRelayerQuote = async (\n _client: SDKClient,\n _params: QuoteRequestFromAmount,\n _options?: RequestOptions\n): Promise<LiFiStep> => {\n throw new SDKError(\n new BaseError(\n ErrorName.NotFoundError,\n LiFiErrorCode.NotFound,\n 'The legacy gasless relayer service is shut down. Request gasless routes with `options.gasless: true` on `getRoutes`.'\n )\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,kBAAkB,OAC7B,SACA,SACA,aACsB;CACtB,MAAM,IAAIA,wBAAAA,SACR,IAAIC,yBAAAA,UAAAA,iBAAAA,MAGF,sHACF,CACF;AACF"}
@@ -58,6 +58,8 @@ export type Actions = {
58
58
  * @param params - The configuration of the requested relayer quote
59
59
  * @param options - Request options
60
60
  * @returns Quote from a relayer
61
+ * @deprecated The legacy gasless relayer service is shut down. Use
62
+ * `getRoutes` with `options.gasless: true`.
61
63
  */
62
64
  getRelayerQuote: (params: QuoteRequestFromAmount, options?: RequestOptions) => Promise<LiFiStep>;
63
65
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["getChains","getConnections","getContractCallsQuote","getGasRecommendation","getNameServiceAddress","getTokens","getTools","getQuote","getRelayedTransactionStatus","getRelayerQuote","getRoutes","getStatus","getStepTransaction","getToken","getTokenBalance","getTokenBalances","getTokenBalancesByChain","getTransactionHistory","relayTransaction","patchContractCalls"],"sources":["../../../src/actions/index.ts"],"sourcesContent":["import type {\n ChainId,\n ChainKey,\n ChainsRequest,\n ChainType,\n ConnectionsRequest,\n ConnectionsResponse,\n ContractCallsQuoteRequest,\n ExtendedChain,\n GasRecommendationRequest,\n GasRecommendationResponse,\n LiFiStep,\n PatchCallDataRequest,\n RelayRequest,\n RelayResponseData,\n RelayStatusRequest,\n RelayStatusResponseData,\n RequestOptions,\n RoutesResponse,\n StatusResponse,\n Token,\n TokenAmount,\n TokenExtended,\n TokensExtendedResponse,\n TokensRequest,\n TokensResponse,\n ToolsRequest,\n ToolsResponse,\n TransactionAnalyticsRequest,\n TransactionAnalyticsResponse,\n} from '@lifi/types'\nimport type {\n GetStatusRequestExtended,\n LiFiStepRequest,\n QuoteRequestFromAmount,\n RoutesRequest,\n} from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { getChains } from './getChains.js'\nimport { getConnections } from './getConnections.js'\nimport { getContractCallsQuote } from './getContractCallsQuote.js'\nimport { getGasRecommendation } from './getGasRecommendation.js'\nimport { getNameServiceAddress } from './getNameServiceAddress.js'\nimport { getQuote } from './getQuote.js'\nimport { getRelayedTransactionStatus } from './getRelayedTransactionStatus.js'\nimport { getRelayerQuote } from './getRelayerQuote.js'\nimport { getRoutes } from './getRoutes.js'\nimport { getStatus } from './getStatus.js'\nimport { getStepTransaction } from './getStepTransaction.js'\nimport { getToken } from './getToken.js'\nimport { getTokenBalance } from './getTokenBalance.js'\nimport { getTokenBalances } from './getTokenBalances.js'\nimport { getTokenBalancesByChain } from './getTokenBalancesByChain.js'\nimport { getTokens } from './getTokens.js'\nimport { getTools } from './getTools.js'\nimport { getTransactionHistory } from './getTransactionHistory.js'\nimport {\n patchContractCalls,\n type PatchContractCallsResponse,\n} from './patchContractCalls.js'\nimport { relayTransaction } from './relayTransaction.js'\n\nexport type Actions = {\n /**\n * Get all available chains\n * @param params - The configuration of the requested chains\n * @param options - Request options\n * @returns A list of all available chains\n */\n getChains: (\n params?: ChainsRequest,\n options?: RequestOptions\n ) => Promise<ExtendedChain[]>\n\n /**\n * Get connections between chains\n * @param params - The configuration of the requested connections\n * @param options - Request options\n * @returns A list of connections\n */\n getConnections: (\n params: ConnectionsRequest,\n options?: RequestOptions\n ) => Promise<ConnectionsResponse>\n\n /**\n * Get a quote for contract calls\n * @param params - The configuration of the requested contract calls quote\n * @param options - Request options\n * @returns Quote for contract calls\n */\n getContractCallsQuote: (\n params: ContractCallsQuoteRequest,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get gas recommendation for a chain\n * @param params - The configuration of the requested gas recommendation\n * @param options - Request options\n * @returns Gas recommendation\n */\n getGasRecommendation: (\n params: GasRecommendationRequest,\n options?: RequestOptions\n ) => Promise<GasRecommendationResponse>\n\n /**\n * Get the address of a name service\n * @param name - The name to resolve\n * @param chainType - The chain type to resolve the name on\n * @returns The address of the name service\n */\n getNameServiceAddress: (\n name: string,\n chainType?: ChainType\n ) => Promise<string | undefined>\n\n /**\n * Get a quote for a token transfer\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @returns Quote for a token transfer\n */\n getQuote: (\n params: Parameters<typeof getQuote>[1],\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get the status of a relayed transaction\n * @param params - The configuration of the requested relay status\n * @param options - Request options\n * @returns Status of the relayed transaction\n */\n getRelayedTransactionStatus: (\n params: RelayStatusRequest,\n options?: RequestOptions\n ) => Promise<RelayStatusResponseData>\n\n /**\n * Get a quote from a relayer\n * @param params - The configuration of the requested relayer quote\n * @param options - Request options\n * @returns Quote from a relayer\n */\n getRelayerQuote: (\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get a set of routes for a request that describes a transfer of tokens.\n * Optional limit-order fields (`toAmount`, `validUntil`, `partiallyFillable`)\n * may be supplied and are resolved on the backend.\n * @param params - A description of the transfer\n * @param options - Request options\n * @returns The resulting routes that can be used to realize the described transfer\n */\n getRoutes: (\n params: RoutesRequest,\n options?: RequestOptions\n ) => Promise<RoutesResponse>\n\n /**\n * Get the status of a transaction\n * @param params - The configuration of the requested status\n * @param options - Request options\n * @returns Status of the transaction\n */\n getStatus: (\n params: GetStatusRequestExtended,\n options?: RequestOptions\n ) => Promise<StatusResponse>\n\n /**\n * Get a step transaction. The step's `action` may carry the optional\n * limit-order fields, which are resolved on the backend.\n * @param params - The configuration of the requested step transaction\n * @param options - Request options\n * @returns Step transaction\n */\n getStepTransaction: (\n params: LiFiStepRequest,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get a specific token\n * @param chain - Id or key of the chain that contains the token\n * @param token - Address or symbol of the token on the requested chain\n * @param options - Request options\n * @returns Token information\n */\n getToken: (\n chain: ChainKey | ChainId,\n token: string,\n options?: RequestOptions\n ) => Promise<TokenExtended>\n\n /**\n * Get token balance for a specific token\n * @param walletAddress - A wallet address\n * @param token - A Token object\n * @returns Token balance\n */\n getTokenBalance: (\n walletAddress: string,\n token: Token\n ) => Promise<TokenAmount | null>\n\n /**\n * Get token balances for multiple tokens\n * @param walletAddress - A wallet address\n * @param tokens - A list of Token objects\n * @returns Token balances\n */\n getTokenBalances: (\n walletAddress: string,\n tokens: Token[]\n ) => Promise<TokenAmount[]>\n\n /**\n * Get token balances by chain\n * @param walletAddress - A wallet address\n * @param tokensByChain - A list of token objects organized by chain ids\n * @returns Token balances by chain\n */\n getTokenBalancesByChain: (\n walletAddress: string,\n tokensByChain: { [chainId: number]: Token[] }\n ) => Promise<{\n [chainId: number]: TokenAmount[]\n }>\n\n /**\n * Get all available tokens\n * @param params - The configuration of the requested tokens\n * @param options - Request options\n * @returns A list of all available tokens\n */\n getTokens: {\n (\n params?: TokensRequest & { extended?: false | undefined },\n options?: RequestOptions\n ): Promise<TokensResponse>\n (\n params: TokensRequest & { extended: true },\n options?: RequestOptions\n ): Promise<TokensExtendedResponse>\n }\n\n /**\n * Get all available tools (bridges and exchanges)\n * @param params - The configuration of the requested tools\n * @param options - Request options\n * @returns A list of all available tools\n */\n getTools: (\n params?: ToolsRequest,\n options?: RequestOptions\n ) => Promise<ToolsResponse>\n\n /**\n * Get transaction history\n * @param params - The configuration of the requested transaction history\n * @param options - Request options\n * @returns Transaction history\n */\n getTransactionHistory: (\n params: TransactionAnalyticsRequest,\n options?: RequestOptions\n ) => Promise<TransactionAnalyticsResponse>\n\n /**\n * Relay a transaction through the relayer service\n * @param params - The configuration for the relay request\n * @param options - Request options\n * @returns Task ID and transaction link for the relayed transaction\n */\n relayTransaction: (\n params: RelayRequest,\n options?: RequestOptions\n ) => Promise<RelayResponseData>\n\n /**\n * Patch contract calls\n * @param params - The configuration for the patch contract calls request\n * @param options - Request options\n * @returns Patched contract calls\n */\n patchContractCalls: (\n params: PatchCallDataRequest,\n options?: RequestOptions\n ) => Promise<PatchContractCallsResponse[]>\n}\n\nexport function actions(client: SDKClient): Actions {\n return {\n getChains: (params, options) => getChains(client, params, options),\n getConnections: (params, options) =>\n getConnections(client, params, options),\n getContractCallsQuote: (params, options) =>\n getContractCallsQuote(client, params, options),\n getGasRecommendation: (params, options) =>\n getGasRecommendation(client, params, options),\n getNameServiceAddress: (name, chainType) =>\n getNameServiceAddress(client, name, chainType),\n getTokens: (params, options) => getTokens(client, params as any, options),\n getTools: (params, options) => getTools(client, params, options),\n getQuote: (params, options) => getQuote(client, params, options),\n getRelayedTransactionStatus: (params, options) =>\n getRelayedTransactionStatus(client, params, options),\n getRelayerQuote: (params, options) =>\n getRelayerQuote(client, params, options),\n getRoutes: (params, options) => getRoutes(client, params, options),\n getStatus: (params, options) => getStatus(client, params, options),\n getStepTransaction: (params, options) =>\n getStepTransaction(client, params, options),\n getToken: (chain, token, options) =>\n getToken(client, chain, token, options),\n getTokenBalance: (walletAddress, token) =>\n getTokenBalance(client, walletAddress, token),\n getTokenBalances: (walletAddress, tokens) =>\n getTokenBalances(client, walletAddress, tokens),\n getTokenBalancesByChain: (walletAddress, tokensByChain) =>\n getTokenBalancesByChain(client, walletAddress, tokensByChain),\n getTransactionHistory: (params, options) =>\n getTransactionHistory(client, params, options),\n relayTransaction: (params, options) =>\n relayTransaction(client, params, options),\n patchContractCalls: (params, options) =>\n patchContractCalls(client, params, options),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAySA,SAAgB,QAAQ,QAA4B;CAClD,OAAO;EACL,YAAY,QAAQ,YAAYA,0BAAAA,UAAU,QAAQ,QAAQ,OAAO;EACjE,iBAAiB,QAAQ,YACvBC,+BAAAA,eAAe,QAAQ,QAAQ,OAAO;EACxC,wBAAwB,QAAQ,YAC9BC,sCAAAA,sBAAsB,QAAQ,QAAQ,OAAO;EAC/C,uBAAuB,QAAQ,YAC7BC,qCAAAA,qBAAqB,QAAQ,QAAQ,OAAO;EAC9C,wBAAwB,MAAM,cAC5BC,sCAAAA,sBAAsB,QAAQ,MAAM,SAAS;EAC/C,YAAY,QAAQ,YAAYC,0BAAAA,UAAU,QAAQ,QAAe,OAAO;EACxE,WAAW,QAAQ,YAAYC,yBAAAA,SAAS,QAAQ,QAAQ,OAAO;EAC/D,WAAW,QAAQ,YAAYC,yBAAAA,SAAS,QAAQ,QAAQ,OAAO;EAC/D,8BAA8B,QAAQ,YACpCC,4CAAAA,4BAA4B,QAAQ,QAAQ,OAAO;EACrD,kBAAkB,QAAQ,YACxBC,gCAAAA,gBAAgB,QAAQ,QAAQ,OAAO;EACzC,YAAY,QAAQ,YAAYC,0BAAAA,UAAU,QAAQ,QAAQ,OAAO;EACjE,YAAY,QAAQ,YAAYC,0BAAAA,UAAU,QAAQ,QAAQ,OAAO;EACjE,qBAAqB,QAAQ,YAC3BC,mCAAAA,mBAAmB,QAAQ,QAAQ,OAAO;EAC5C,WAAW,OAAO,OAAO,YACvBC,yBAAAA,SAAS,QAAQ,OAAO,OAAO,OAAO;EACxC,kBAAkB,eAAe,UAC/BC,gCAAAA,gBAAgB,QAAQ,eAAe,KAAK;EAC9C,mBAAmB,eAAe,WAChCC,iCAAAA,iBAAiB,QAAQ,eAAe,MAAM;EAChD,0BAA0B,eAAe,kBACvCC,wCAAAA,wBAAwB,QAAQ,eAAe,aAAa;EAC9D,wBAAwB,QAAQ,YAC9BC,sCAAAA,sBAAsB,QAAQ,QAAQ,OAAO;EAC/C,mBAAmB,QAAQ,YACzBC,iCAAAA,iBAAiB,QAAQ,QAAQ,OAAO;EAC1C,qBAAqB,QAAQ,YAC3BC,mCAAAA,mBAAmB,QAAQ,QAAQ,OAAO;CAC9C;AACF"}
1
+ {"version":3,"file":"index.js","names":["getChains","getConnections","getContractCallsQuote","getGasRecommendation","getNameServiceAddress","getTokens","getTools","getQuote","getRelayedTransactionStatus","getRelayerQuote","getRoutes","getStatus","getStepTransaction","getToken","getTokenBalance","getTokenBalances","getTokenBalancesByChain","getTransactionHistory","relayTransaction","patchContractCalls"],"sources":["../../../src/actions/index.ts"],"sourcesContent":["import type {\n ChainId,\n ChainKey,\n ChainsRequest,\n ChainType,\n ConnectionsRequest,\n ConnectionsResponse,\n ContractCallsQuoteRequest,\n ExtendedChain,\n GasRecommendationRequest,\n GasRecommendationResponse,\n LiFiStep,\n PatchCallDataRequest,\n RelayRequest,\n RelayResponseData,\n RelayStatusRequest,\n RelayStatusResponseData,\n RequestOptions,\n RoutesResponse,\n StatusResponse,\n Token,\n TokenAmount,\n TokenExtended,\n TokensExtendedResponse,\n TokensRequest,\n TokensResponse,\n ToolsRequest,\n ToolsResponse,\n TransactionAnalyticsRequest,\n TransactionAnalyticsResponse,\n} from '@lifi/types'\nimport type {\n GetStatusRequestExtended,\n LiFiStepRequest,\n QuoteRequestFromAmount,\n RoutesRequest,\n} from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { getChains } from './getChains.js'\nimport { getConnections } from './getConnections.js'\nimport { getContractCallsQuote } from './getContractCallsQuote.js'\nimport { getGasRecommendation } from './getGasRecommendation.js'\nimport { getNameServiceAddress } from './getNameServiceAddress.js'\nimport { getQuote } from './getQuote.js'\nimport { getRelayedTransactionStatus } from './getRelayedTransactionStatus.js'\nimport { getRelayerQuote } from './getRelayerQuote.js'\nimport { getRoutes } from './getRoutes.js'\nimport { getStatus } from './getStatus.js'\nimport { getStepTransaction } from './getStepTransaction.js'\nimport { getToken } from './getToken.js'\nimport { getTokenBalance } from './getTokenBalance.js'\nimport { getTokenBalances } from './getTokenBalances.js'\nimport { getTokenBalancesByChain } from './getTokenBalancesByChain.js'\nimport { getTokens } from './getTokens.js'\nimport { getTools } from './getTools.js'\nimport { getTransactionHistory } from './getTransactionHistory.js'\nimport {\n patchContractCalls,\n type PatchContractCallsResponse,\n} from './patchContractCalls.js'\nimport { relayTransaction } from './relayTransaction.js'\n\nexport type Actions = {\n /**\n * Get all available chains\n * @param params - The configuration of the requested chains\n * @param options - Request options\n * @returns A list of all available chains\n */\n getChains: (\n params?: ChainsRequest,\n options?: RequestOptions\n ) => Promise<ExtendedChain[]>\n\n /**\n * Get connections between chains\n * @param params - The configuration of the requested connections\n * @param options - Request options\n * @returns A list of connections\n */\n getConnections: (\n params: ConnectionsRequest,\n options?: RequestOptions\n ) => Promise<ConnectionsResponse>\n\n /**\n * Get a quote for contract calls\n * @param params - The configuration of the requested contract calls quote\n * @param options - Request options\n * @returns Quote for contract calls\n */\n getContractCallsQuote: (\n params: ContractCallsQuoteRequest,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get gas recommendation for a chain\n * @param params - The configuration of the requested gas recommendation\n * @param options - Request options\n * @returns Gas recommendation\n */\n getGasRecommendation: (\n params: GasRecommendationRequest,\n options?: RequestOptions\n ) => Promise<GasRecommendationResponse>\n\n /**\n * Get the address of a name service\n * @param name - The name to resolve\n * @param chainType - The chain type to resolve the name on\n * @returns The address of the name service\n */\n getNameServiceAddress: (\n name: string,\n chainType?: ChainType\n ) => Promise<string | undefined>\n\n /**\n * Get a quote for a token transfer\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @returns Quote for a token transfer\n */\n getQuote: (\n params: Parameters<typeof getQuote>[1],\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get the status of a relayed transaction\n * @param params - The configuration of the requested relay status\n * @param options - Request options\n * @returns Status of the relayed transaction\n */\n getRelayedTransactionStatus: (\n params: RelayStatusRequest,\n options?: RequestOptions\n ) => Promise<RelayStatusResponseData>\n\n /**\n * Get a quote from a relayer\n * @param params - The configuration of the requested relayer quote\n * @param options - Request options\n * @returns Quote from a relayer\n * @deprecated The legacy gasless relayer service is shut down. Use\n * `getRoutes` with `options.gasless: true`.\n */\n getRelayerQuote: (\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get a set of routes for a request that describes a transfer of tokens.\n * Optional limit-order fields (`toAmount`, `validUntil`, `partiallyFillable`)\n * may be supplied and are resolved on the backend.\n * @param params - A description of the transfer\n * @param options - Request options\n * @returns The resulting routes that can be used to realize the described transfer\n */\n getRoutes: (\n params: RoutesRequest,\n options?: RequestOptions\n ) => Promise<RoutesResponse>\n\n /**\n * Get the status of a transaction\n * @param params - The configuration of the requested status\n * @param options - Request options\n * @returns Status of the transaction\n */\n getStatus: (\n params: GetStatusRequestExtended,\n options?: RequestOptions\n ) => Promise<StatusResponse>\n\n /**\n * Get a step transaction. The step's `action` may carry the optional\n * limit-order fields, which are resolved on the backend.\n * @param params - The configuration of the requested step transaction\n * @param options - Request options\n * @returns Step transaction\n */\n getStepTransaction: (\n params: LiFiStepRequest,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get a specific token\n * @param chain - Id or key of the chain that contains the token\n * @param token - Address or symbol of the token on the requested chain\n * @param options - Request options\n * @returns Token information\n */\n getToken: (\n chain: ChainKey | ChainId,\n token: string,\n options?: RequestOptions\n ) => Promise<TokenExtended>\n\n /**\n * Get token balance for a specific token\n * @param walletAddress - A wallet address\n * @param token - A Token object\n * @returns Token balance\n */\n getTokenBalance: (\n walletAddress: string,\n token: Token\n ) => Promise<TokenAmount | null>\n\n /**\n * Get token balances for multiple tokens\n * @param walletAddress - A wallet address\n * @param tokens - A list of Token objects\n * @returns Token balances\n */\n getTokenBalances: (\n walletAddress: string,\n tokens: Token[]\n ) => Promise<TokenAmount[]>\n\n /**\n * Get token balances by chain\n * @param walletAddress - A wallet address\n * @param tokensByChain - A list of token objects organized by chain ids\n * @returns Token balances by chain\n */\n getTokenBalancesByChain: (\n walletAddress: string,\n tokensByChain: { [chainId: number]: Token[] }\n ) => Promise<{\n [chainId: number]: TokenAmount[]\n }>\n\n /**\n * Get all available tokens\n * @param params - The configuration of the requested tokens\n * @param options - Request options\n * @returns A list of all available tokens\n */\n getTokens: {\n (\n params?: TokensRequest & { extended?: false | undefined },\n options?: RequestOptions\n ): Promise<TokensResponse>\n (\n params: TokensRequest & { extended: true },\n options?: RequestOptions\n ): Promise<TokensExtendedResponse>\n }\n\n /**\n * Get all available tools (bridges and exchanges)\n * @param params - The configuration of the requested tools\n * @param options - Request options\n * @returns A list of all available tools\n */\n getTools: (\n params?: ToolsRequest,\n options?: RequestOptions\n ) => Promise<ToolsResponse>\n\n /**\n * Get transaction history\n * @param params - The configuration of the requested transaction history\n * @param options - Request options\n * @returns Transaction history\n */\n getTransactionHistory: (\n params: TransactionAnalyticsRequest,\n options?: RequestOptions\n ) => Promise<TransactionAnalyticsResponse>\n\n /**\n * Relay a transaction through the relayer service\n * @param params - The configuration for the relay request\n * @param options - Request options\n * @returns Task ID and transaction link for the relayed transaction\n */\n relayTransaction: (\n params: RelayRequest,\n options?: RequestOptions\n ) => Promise<RelayResponseData>\n\n /**\n * Patch contract calls\n * @param params - The configuration for the patch contract calls request\n * @param options - Request options\n * @returns Patched contract calls\n */\n patchContractCalls: (\n params: PatchCallDataRequest,\n options?: RequestOptions\n ) => Promise<PatchContractCallsResponse[]>\n}\n\nexport function actions(client: SDKClient): Actions {\n return {\n getChains: (params, options) => getChains(client, params, options),\n getConnections: (params, options) =>\n getConnections(client, params, options),\n getContractCallsQuote: (params, options) =>\n getContractCallsQuote(client, params, options),\n getGasRecommendation: (params, options) =>\n getGasRecommendation(client, params, options),\n getNameServiceAddress: (name, chainType) =>\n getNameServiceAddress(client, name, chainType),\n getTokens: (params, options) => getTokens(client, params as any, options),\n getTools: (params, options) => getTools(client, params, options),\n getQuote: (params, options) => getQuote(client, params, options),\n getRelayedTransactionStatus: (params, options) =>\n getRelayedTransactionStatus(client, params, options),\n getRelayerQuote: (params, options) =>\n getRelayerQuote(client, params, options),\n getRoutes: (params, options) => getRoutes(client, params, options),\n getStatus: (params, options) => getStatus(client, params, options),\n getStepTransaction: (params, options) =>\n getStepTransaction(client, params, options),\n getToken: (chain, token, options) =>\n getToken(client, chain, token, options),\n getTokenBalance: (walletAddress, token) =>\n getTokenBalance(client, walletAddress, token),\n getTokenBalances: (walletAddress, tokens) =>\n getTokenBalances(client, walletAddress, tokens),\n getTokenBalancesByChain: (walletAddress, tokensByChain) =>\n getTokenBalancesByChain(client, walletAddress, tokensByChain),\n getTransactionHistory: (params, options) =>\n getTransactionHistory(client, params, options),\n relayTransaction: (params, options) =>\n relayTransaction(client, params, options),\n patchContractCalls: (params, options) =>\n patchContractCalls(client, params, options),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2SA,SAAgB,QAAQ,QAA4B;CAClD,OAAO;EACL,YAAY,QAAQ,YAAYA,0BAAAA,UAAU,QAAQ,QAAQ,OAAO;EACjE,iBAAiB,QAAQ,YACvBC,+BAAAA,eAAe,QAAQ,QAAQ,OAAO;EACxC,wBAAwB,QAAQ,YAC9BC,sCAAAA,sBAAsB,QAAQ,QAAQ,OAAO;EAC/C,uBAAuB,QAAQ,YAC7BC,qCAAAA,qBAAqB,QAAQ,QAAQ,OAAO;EAC9C,wBAAwB,MAAM,cAC5BC,sCAAAA,sBAAsB,QAAQ,MAAM,SAAS;EAC/C,YAAY,QAAQ,YAAYC,0BAAAA,UAAU,QAAQ,QAAe,OAAO;EACxE,WAAW,QAAQ,YAAYC,yBAAAA,SAAS,QAAQ,QAAQ,OAAO;EAC/D,WAAW,QAAQ,YAAYC,yBAAAA,SAAS,QAAQ,QAAQ,OAAO;EAC/D,8BAA8B,QAAQ,YACpCC,4CAAAA,4BAA4B,QAAQ,QAAQ,OAAO;EACrD,kBAAkB,QAAQ,YACxBC,gCAAAA,gBAAgB,QAAQ,QAAQ,OAAO;EACzC,YAAY,QAAQ,YAAYC,0BAAAA,UAAU,QAAQ,QAAQ,OAAO;EACjE,YAAY,QAAQ,YAAYC,0BAAAA,UAAU,QAAQ,QAAQ,OAAO;EACjE,qBAAqB,QAAQ,YAC3BC,mCAAAA,mBAAmB,QAAQ,QAAQ,OAAO;EAC5C,WAAW,OAAO,OAAO,YACvBC,yBAAAA,SAAS,QAAQ,OAAO,OAAO,OAAO;EACxC,kBAAkB,eAAe,UAC/BC,gCAAAA,gBAAgB,QAAQ,eAAe,KAAK;EAC9C,mBAAmB,eAAe,WAChCC,iCAAAA,iBAAiB,QAAQ,eAAe,MAAM;EAChD,0BAA0B,eAAe,kBACvCC,wCAAAA,wBAAwB,QAAQ,eAAe,aAAa;EAC9D,wBAAwB,QAAQ,YAC9BC,sCAAAA,sBAAsB,QAAQ,QAAQ,OAAO;EAC/C,mBAAmB,QAAQ,YACzBC,iCAAAA,iBAAiB,QAAQ,QAAQ,OAAO;EAC1C,qBAAqB,QAAQ,YAC3BC,mCAAAA,mBAAmB,QAAQ,QAAQ,OAAO;CAC9C;AACF"}
@@ -15,8 +15,7 @@ const require_utils_request = require("../utils/request.js");
15
15
  */
16
16
  const relayTransaction = async (client, params, options) => {
17
17
  for (const requiredParameter of ["typedData"]) if (!params[requiredParameter]) throw new require_errors_SDKError.SDKError(new require_errors_errors.ValidationError(`Required parameter "${requiredParameter}" is missing.`));
18
- const relayerPath = params.typedData.some((t) => t.primaryType === "PermitWitnessTransferFrom") ? "/relayer/relay" : "/advanced/relay";
19
- const result = await require_utils_request.request(client.config, `${client.config.apiUrl}${relayerPath}`, {
18
+ const result = await require_utils_request.request(client.config, `${client.config.apiUrl}/advanced/relay`, {
20
19
  method: "POST",
21
20
  headers: { "Content-Type": "application/json" },
22
21
  body: JSON.stringify(params, (_, value) => {
@@ -1 +1 @@
1
- {"version":3,"file":"relayTransaction.js","names":["SDKError","ValidationError","request","BaseError"],"sources":["../../../src/actions/relayTransaction.ts"],"sourcesContent":["import type {\n RelayRequest,\n RelayResponse,\n RelayResponseData,\n RequestOptions,\n} from '@lifi/types'\nimport { BaseError } from '../errors/baseError.js'\nimport { ErrorName } from '../errors/constants.js'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Relay a transaction through the relayer service\n * @param client - The SDK client\n * @param params - The configuration for the relay request\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Task ID and transaction link for the relayed transaction\n */\nexport const relayTransaction = async (\n client: SDKClient,\n params: RelayRequest,\n options?: RequestOptions\n): Promise<RelayResponseData> => {\n const requiredParameters: Array<keyof RelayRequest> = ['typedData']\n\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n\n // Determine if the request is for a gasless relayer service or advanced relayer service\n // We will use the same endpoint for both after the gasless relayer service is deprecated\n const relayerPath = params.typedData.some(\n (t) => t.primaryType === 'PermitWitnessTransferFrom'\n )\n ? '/relayer/relay'\n : '/advanced/relay'\n\n const result = await request<RelayResponse>(\n client.config,\n `${client.config.apiUrl}${relayerPath}`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params, (_, value) => {\n if (typeof value === 'bigint') {\n return value.toString()\n }\n return value\n }),\n signal: options?.signal,\n }\n )\n\n if (result.status === 'error') {\n throw new BaseError(\n ErrorName.ServerError,\n result.data.code,\n result.data.message\n )\n }\n\n return result.data\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAa,mBAAmB,OAC9B,QACA,QACA,YAC+B;CAG/B,KAAK,MAAM,qBAAqB,CAFuB,WAEN,GAC/C,IAAI,CAAC,OAAO,oBACV,MAAM,IAAIA,wBAAAA,SACR,IAAIC,sBAAAA,gBACF,uBAAuB,kBAAkB,cAC3C,CACF;CAMJ,MAAM,cAAc,OAAO,UAAU,MAClC,MAAM,EAAE,gBAAgB,2BAC3B,IACI,mBACA;CAEJ,MAAM,SAAS,MAAMC,sBAAAA,QACnB,OAAO,QACP,GAAG,OAAO,OAAO,SAAS,eAC1B;EACE,QAAQ;EACR,SAAS,EACP,gBAAgB,mBAClB;EACA,MAAM,KAAK,UAAU,SAAS,GAAG,UAAU;GACzC,IAAI,OAAO,UAAU,UACnB,OAAO,MAAM,SAAS;GAExB,OAAO;EACT,CAAC;EACD,QAAQ,SAAS;CACnB,CACF;CAEA,IAAI,OAAO,WAAW,SACpB,MAAM,IAAIC,yBAAAA,UAAAA,eAER,OAAO,KAAK,MACZ,OAAO,KAAK,OACd;CAGF,OAAO,OAAO;AAChB"}
1
+ {"version":3,"file":"relayTransaction.js","names":["SDKError","ValidationError","request","BaseError"],"sources":["../../../src/actions/relayTransaction.ts"],"sourcesContent":["import type {\n RelayRequest,\n RelayResponse,\n RelayResponseData,\n RequestOptions,\n} from '@lifi/types'\nimport { BaseError } from '../errors/baseError.js'\nimport { ErrorName } from '../errors/constants.js'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Relay a transaction through the relayer service\n * @param client - The SDK client\n * @param params - The configuration for the relay request\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Task ID and transaction link for the relayed transaction\n */\nexport const relayTransaction = async (\n client: SDKClient,\n params: RelayRequest,\n options?: RequestOptions\n): Promise<RelayResponseData> => {\n const requiredParameters: Array<keyof RelayRequest> = ['typedData']\n\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n\n const result = await request<RelayResponse>(\n client.config,\n `${client.config.apiUrl}/advanced/relay`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params, (_, value) => {\n if (typeof value === 'bigint') {\n return value.toString()\n }\n return value\n }),\n signal: options?.signal,\n }\n )\n\n if (result.status === 'error') {\n throw new BaseError(\n ErrorName.ServerError,\n result.data.code,\n result.data.message\n )\n }\n\n return result.data\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAa,mBAAmB,OAC9B,QACA,QACA,YAC+B;CAG/B,KAAK,MAAM,qBAAqB,CAFuB,WAEN,GAC/C,IAAI,CAAC,OAAO,oBACV,MAAM,IAAIA,wBAAAA,SACR,IAAIC,sBAAAA,gBACF,uBAAuB,kBAAkB,cAC3C,CACF;CAIJ,MAAM,SAAS,MAAMC,sBAAAA,QACnB,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,kBACxB;EACE,QAAQ;EACR,SAAS,EACP,gBAAgB,mBAClB;EACA,MAAM,KAAK,UAAU,SAAS,GAAG,UAAU;GACzC,IAAI,OAAO,UAAU,UACnB,OAAO,MAAM,SAAS;GAExB,OAAO;EACT,CAAC;EACD,QAAQ,SAAS;CACnB,CACF;CAEA,IAAI,OAAO,WAAW,SACpB,MAAM,IAAIC,yBAAAA,UAAAA,eAER,OAAO,KAAK,MACZ,OAAO,KAAK,OACd;CAGF,OAAO,OAAO;AAChB"}
@@ -48,6 +48,7 @@ import { checkPackageUpdates } from "./utils/checkPackageUpdates.js";
48
48
  import { convertQuoteToRoute } from "./utils/convertQuoteToRoute.js";
49
49
  import { fetchTxErrorDetails } from "./utils/fetchTxErrorDetails.js";
50
50
  import { formatUnits } from "./utils/formatUnits.js";
51
+ import { GASLESS_RELAY_FEE_NAME, isGaslessStep } from "./utils/isGaslessStep.js";
51
52
  import { isHex } from "./utils/isHex.js";
52
53
  import { LruMap } from "./utils/lru.js";
53
54
  import { parseUnits } from "./utils/parseUnits.js";
@@ -57,4 +58,4 @@ import { withDedupe } from "./utils/withDedupe.js";
57
58
  import { withTimeout } from "./utils/withTimeout.js";
58
59
  import { name, version } from "./version.js";
59
60
  export * from "@lifi/types";
60
- export { type AcceptExchangeRateUpdateHook, type AcceptSlippageUpdateHook, type AcceptSlippageUpdateHookParams, BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, CLEARED_TRANSACTION_FIELDS, CLOCK_SKEW_MARGIN_MS, type CheckBalanceOptions, CheckBalanceTask, type ContractCallParams, type ContractTool, DROPPED_FALLBACK_AGE_MS, type ErrorCode, ErrorMessage, ErrorName, type ExchangeRateUpdateParams, ExecuteStepRetryError, type ExecuteStepRetryParams, type Execution, type ExecutionAction, type ExecutionActionStatus, type ExecutionActionType, type ExecutionOptions, type ExecutionStatus, type GetContractCallsHook, type GetContractCallsResult, type GetStatusRequestExtended, HTTPError, InMemoryStorage, type InteractionSettings, LiFiErrorCode, type LiFiStepExtended, type LiFiStepRequest, LocalStorageAdapter, LruMap, MAX_RESEND_AGE_MS, PrepareTransactionTask, ProviderError, type QuoteRequest, type QuoteRequestFromAmount, type QuoteRequestToAmount, RPCError, type RPCUrls, type RPCUrlsByRole, type RPCUrlsConfig, type RequestInterceptor, type RouteExecutionData, type RouteExecutionDataDictionary, type RouteExecutionDictionary, type RouteExtended, type SDKBaseConfig, type SDKClient, type SDKConfig, SDKError, type SDKProvider, type SDKStorage, ServerError, StatusManager, type StepExecutor, type StepExecutorBaseContext, type StepExecutorContext, type StepExecutorOptions, type StepExtended, TaskPipeline, type TaskResult, type TaskStatus, TransactionError, type TransactionErrorOptions, type TransactionMethodType, type TransactionParameters, type TransactionRequestParameters, type TransactionRequestUpdateHook, UnknownError, type UpdateRouteHook, ValidationError, WaitForTransactionStatusTask, actions, assertNoOpenTransaction, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, findProvider, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, hasOpenTransaction, isFinalTransactionError, isHex, isKnownToStatusApi, isOldEnoughToDrop, isResendAllowed, name, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, version, waitForResult, withDedupe, withTimeout };
61
+ export { type AcceptExchangeRateUpdateHook, type AcceptSlippageUpdateHook, type AcceptSlippageUpdateHookParams, BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, CLEARED_TRANSACTION_FIELDS, CLOCK_SKEW_MARGIN_MS, type CheckBalanceOptions, CheckBalanceTask, type ContractCallParams, type ContractTool, DROPPED_FALLBACK_AGE_MS, type ErrorCode, ErrorMessage, ErrorName, type ExchangeRateUpdateParams, ExecuteStepRetryError, type ExecuteStepRetryParams, type Execution, type ExecutionAction, type ExecutionActionStatus, type ExecutionActionType, type ExecutionOptions, type ExecutionStatus, GASLESS_RELAY_FEE_NAME, type GetContractCallsHook, type GetContractCallsResult, type GetStatusRequestExtended, HTTPError, InMemoryStorage, type InteractionSettings, LiFiErrorCode, type LiFiStepExtended, type LiFiStepRequest, LocalStorageAdapter, LruMap, MAX_RESEND_AGE_MS, PrepareTransactionTask, ProviderError, type QuoteRequest, type QuoteRequestFromAmount, type QuoteRequestToAmount, RPCError, type RPCUrls, type RPCUrlsByRole, type RPCUrlsConfig, type RequestInterceptor, type RouteExecutionData, type RouteExecutionDataDictionary, type RouteExecutionDictionary, type RouteExtended, type SDKBaseConfig, type SDKClient, type SDKConfig, SDKError, type SDKProvider, type SDKStorage, ServerError, StatusManager, type StepExecutor, type StepExecutorBaseContext, type StepExecutorContext, type StepExecutorOptions, type StepExtended, TaskPipeline, type TaskResult, type TaskStatus, TransactionError, type TransactionErrorOptions, type TransactionMethodType, type TransactionParameters, type TransactionRequestParameters, type TransactionRequestUpdateHook, UnknownError, type UpdateRouteHook, ValidationError, WaitForTransactionStatusTask, actions, assertNoOpenTransaction, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, findProvider, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, hasOpenTransaction, isFinalTransactionError, isGaslessStep, isHex, isKnownToStatusApi, isOldEnoughToDrop, isResendAllowed, name, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, version, waitForResult, withDedupe, withTimeout };
package/dist/cjs/index.js CHANGED
@@ -46,6 +46,7 @@ const require_utils_checkPackageUpdates = require("./utils/checkPackageUpdates.j
46
46
  const require_utils_convertQuoteToRoute = require("./utils/convertQuoteToRoute.js");
47
47
  const require_utils_fetchTxErrorDetails = require("./utils/fetchTxErrorDetails.js");
48
48
  const require_utils_formatUnits = require("./utils/formatUnits.js");
49
+ const require_utils_isGaslessStep = require("./utils/isGaslessStep.js");
49
50
  const require_utils_isHex = require("./utils/isHex.js");
50
51
  const require_utils_lru = require("./utils/lru.js");
51
52
  const require_utils_parseUnits = require("./utils/parseUnits.js");
@@ -65,6 +66,7 @@ exports.DROPPED_FALLBACK_AGE_MS = require_core_transactionState.DROPPED_FALLBACK
65
66
  exports.ErrorMessage = require_errors_constants.ErrorMessage;
66
67
  exports.ErrorName = require_errors_constants.ErrorName;
67
68
  exports.ExecuteStepRetryError = require_errors_errors.ExecuteStepRetryError;
69
+ exports.GASLESS_RELAY_FEE_NAME = require_utils_isGaslessStep.GASLESS_RELAY_FEE_NAME;
68
70
  exports.HTTPError = require_errors_httpError.HTTPError;
69
71
  exports.InMemoryStorage = require_core_storage.InMemoryStorage;
70
72
  exports.LiFiErrorCode = require_errors_constants.LiFiErrorCode;
@@ -118,6 +120,7 @@ exports.getTransactionHistory = require_actions_getTransactionHistory.getTransac
118
120
  exports.getTransactionRequestData = require_core_tasks_helpers_getTransactionRequestData.getTransactionRequestData;
119
121
  exports.hasOpenTransaction = require_core_transactionState.hasOpenTransaction;
120
122
  exports.isFinalTransactionError = require_core_transactionState.isFinalTransactionError;
123
+ exports.isGaslessStep = require_utils_isGaslessStep.isGaslessStep;
121
124
  exports.isHex = require_utils_isHex.isHex;
122
125
  exports.isKnownToStatusApi = require_core_tasks_helpers_isKnownToStatusApi.isKnownToStatusApi;
123
126
  exports.isOldEnoughToDrop = require_core_transactionState.isOldEnoughToDrop;
@@ -5,7 +5,7 @@ const checkPackageUpdates = async (packageName, packageVersion) => {
5
5
  try {
6
6
  const pkgName = packageName ?? "@lifi/sdk";
7
7
  const latestVersion = (await (await fetch(`https://registry.npmjs.org/${pkgName}/latest`)).json()).version;
8
- const currentVersion = packageVersion ?? "0.0.0-preview-9b9526be";
8
+ const currentVersion = packageVersion ?? "0.0.0-preview-e8c80bc4";
9
9
  if (latestVersion > currentVersion) console.warn(`${pkgName}: new package version is available. Please update as soon as possible to enjoy the newest features. Current version: ${currentVersion}. Latest version: ${latestVersion}.`);
10
10
  } catch (_error) {}
11
11
  };
@@ -0,0 +1,13 @@
1
+ import { LiFiStep } from "@lifi/types";
2
+ /**
3
+ * The `feeCosts` name of the gasless relay fee. The backend marks every
4
+ * gasless step with it and guarantees that the name does not change.
5
+ */
6
+ export declare const GASLESS_RELAY_FEE_NAME = "LIFI Gasless Relay Fee";
7
+ /**
8
+ * Whether the step executes gasless: the user signs typed data and the LI.FI
9
+ * relayer submits it and pays the gas. The relay fee is the only marker that
10
+ * exists already at routes time, before `/advanced/stepTransaction` adds the
11
+ * typed data.
12
+ */
13
+ export declare function isGaslessStep(step: Pick<LiFiStep, "estimate">): boolean;
@@ -0,0 +1,20 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ // src/utils/isGaslessStep.ts
3
+ /**
4
+ * The `feeCosts` name of the gasless relay fee. The backend marks every
5
+ * gasless step with it and guarantees that the name does not change.
6
+ */
7
+ const GASLESS_RELAY_FEE_NAME = "LIFI Gasless Relay Fee";
8
+ /**
9
+ * Whether the step executes gasless: the user signs typed data and the LI.FI
10
+ * relayer submits it and pays the gas. The relay fee is the only marker that
11
+ * exists already at routes time, before `/advanced/stepTransaction` adds the
12
+ * typed data.
13
+ */
14
+ function isGaslessStep(step) {
15
+ return step.estimate?.feeCosts?.some((feeCost) => feeCost.name === "LIFI Gasless Relay Fee") ?? false;
16
+ }
17
+ exports.GASLESS_RELAY_FEE_NAME = GASLESS_RELAY_FEE_NAME;
18
+ exports.isGaslessStep = isGaslessStep;
19
+
20
+ //# sourceMappingURL=isGaslessStep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isGaslessStep.js","names":[],"sources":["../../../src/utils/isGaslessStep.ts"],"sourcesContent":["import type { LiFiStep } from '@lifi/types'\n\n/**\n * The `feeCosts` name of the gasless relay fee. The backend marks every\n * gasless step with it and guarantees that the name does not change.\n */\nexport const GASLESS_RELAY_FEE_NAME = 'LIFI Gasless Relay Fee'\n\n/**\n * Whether the step executes gasless: the user signs typed data and the LI.FI\n * relayer submits it and pays the gas. The relay fee is the only marker that\n * exists already at routes time, before `/advanced/stepTransaction` adds the\n * typed data.\n */\nexport function isGaslessStep(step: Pick<LiFiStep, 'estimate'>): boolean {\n return (\n step.estimate?.feeCosts?.some(\n (feeCost) => feeCost.name === GASLESS_RELAY_FEE_NAME\n ) ?? false\n )\n}\n"],"mappings":";;;;;;AAMA,MAAa,yBAAyB;;;;;;;AAQtC,SAAgB,cAAc,MAA2C;CACvE,OACE,KAAK,UAAU,UAAU,MACtB,YAAY,QAAQ,SAAA,wBACvB,KAAK;AAET"}
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/sdk";
2
- export declare const version = "0.0.0-preview-9b9526be";
2
+ export declare const version = "0.0.0-preview-e8c80bc4";
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  // src/version.ts
3
3
  const name = "@lifi/sdk";
4
- const version = "0.0.0-preview-9b9526be";
4
+ const version = "0.0.0-preview-e8c80bc4";
5
5
  exports.name = name;
6
6
  exports.version = version;
7
7
 
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '0.0.0-preview-9b9526be'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
1
+ {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '0.0.0-preview-e8c80bc4'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
@@ -2,12 +2,20 @@ import { QuoteRequestFromAmount } from "../types/actions.js";
2
2
  import { SDKClient } from "../types/core.js";
3
3
  import { LiFiStep, RequestOptions } from "@lifi/types";
4
4
  /**
5
- * Get a relayer quote for a token transfer
6
- * @param client - The SDK client
7
- * @param params - The configuration of the requested quote
8
- * @param options - Request options
9
- * @throws {LiFiError} - Throws a LiFiError if request fails
10
- * @returns Relayer quote for a token transfer
5
+ * Get a relayer quote for a token transfer. The legacy gasless relayer service
6
+ * behind it is shut down, so this always rejects and sends no request.
7
+ *
8
+ * Kept only so that published consumers that still import it keep building.
9
+ * It stays `async`: callers such as `getRelayerQuote(...).catch(() => null)`
10
+ * need a rejected promise, not a synchronous throw.
11
+ * @param _client - The SDK client
12
+ * @param _params - The configuration of the requested quote
13
+ * @param _options - Request options
14
+ * @throws {SDKError} - Always, with a `NotFound` cause.
15
+ * @returns Never resolves with a quote.
16
+ * @deprecated The legacy gasless relayer service is shut down. Request
17
+ * gasless routes with `options.gasless: true` on `getRoutes`, or
18
+ * `gasless: true` on `getQuote`, and detect them with `isGaslessStep`.
11
19
  */
12
- export declare const getRelayerQuote: (client: SDKClient, params: QuoteRequestFromAmount, options?: RequestOptions) => Promise<LiFiStep>;
20
+ export declare const getRelayerQuote: (_client: SDKClient, _params: QuoteRequestFromAmount, _options?: RequestOptions) => Promise<LiFiStep>;
13
21
  //# sourceMappingURL=getRelayerQuote.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getRelayerQuote.d.ts","names":[],"sources":["../../../src/actions/getRelayerQuote.ts"],"mappings":";;;;;;;;;;;qBAqBa,kBACX,QAAQ,WACR,QAAQ,wBACR,UAAU,mBACT,QAAQ"}
1
+ {"version":3,"file":"getRelayerQuote.d.ts","names":[],"sources":["../../../src/actions/getRelayerQuote.ts"],"mappings":";;;;;;;;;;;;;;;;;;;qBAuBa,kBACX,SAAS,WACT,SAAS,wBACT,WAAW,mBACV,QAAQ"}
@@ -1,41 +1,25 @@
1
1
  import { BaseError } from "../errors/baseError.js";
2
2
  import "../errors/constants.js";
3
- import { ValidationError } from "../errors/errors.js";
4
3
  import { SDKError } from "../errors/SDKError.js";
5
- import { request } from "../utils/request.js";
6
4
  // src/actions/getRelayerQuote.ts
7
5
  /**
8
- * Get a relayer quote for a token transfer
9
- * @param client - The SDK client
10
- * @param params - The configuration of the requested quote
11
- * @param options - Request options
12
- * @throws {LiFiError} - Throws a LiFiError if request fails
13
- * @returns Relayer quote for a token transfer
6
+ * Get a relayer quote for a token transfer. The legacy gasless relayer service
7
+ * behind it is shut down, so this always rejects and sends no request.
8
+ *
9
+ * Kept only so that published consumers that still import it keep building.
10
+ * It stays `async`: callers such as `getRelayerQuote(...).catch(() => null)`
11
+ * need a rejected promise, not a synchronous throw.
12
+ * @param _client - The SDK client
13
+ * @param _params - The configuration of the requested quote
14
+ * @param _options - Request options
15
+ * @throws {SDKError} - Always, with a `NotFound` cause.
16
+ * @returns Never resolves with a quote.
17
+ * @deprecated The legacy gasless relayer service is shut down. Request
18
+ * gasless routes with `options.gasless: true` on `getRoutes`, or
19
+ * `gasless: true` on `getQuote`, and detect them with `isGaslessStep`.
14
20
  */
15
- const getRelayerQuote = async (client, params, options) => {
16
- for (const requiredParameter of [
17
- "fromChain",
18
- "fromToken",
19
- "fromAddress",
20
- "fromAmount",
21
- "toChain",
22
- "toToken"
23
- ]) if (!params[requiredParameter]) throw new SDKError(new ValidationError(`Required parameter "${requiredParameter}" is missing.`));
24
- params.integrator ??= client.config.integrator;
25
- params.order ??= client.config.routeOptions?.order;
26
- params.slippage ??= client.config.routeOptions?.slippage;
27
- params.referrer ??= client.config.routeOptions?.referrer;
28
- params.fee ??= client.config.routeOptions?.fee;
29
- params.allowBridges ??= client.config.routeOptions?.bridges?.allow;
30
- params.denyBridges ??= client.config.routeOptions?.bridges?.deny;
31
- params.preferBridges ??= client.config.routeOptions?.bridges?.prefer;
32
- params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow;
33
- params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny;
34
- params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer;
35
- for (const key of Object.keys(params)) if (params[key] === void 0 || params[key] === null) delete params[key];
36
- const result = await request(client.config, `${client.config.apiUrl}/relayer/quote?${new URLSearchParams(params)}`, { signal: options?.signal });
37
- if (result.status === "error") throw new BaseError("ServerError", result.data.code, result.data.message);
38
- return result.data;
21
+ const getRelayerQuote = async (_client, _params, _options) => {
22
+ throw new SDKError(new BaseError("NotFoundError", 1006, "The legacy gasless relayer service is shut down. Request gasless routes with `options.gasless: true` on `getRoutes`."));
39
23
  };
40
24
  export { getRelayerQuote };
41
25
 
@@ -1 +1 @@
1
- {"version":3,"file":"getRelayerQuote.js","names":[],"sources":["../../../src/actions/getRelayerQuote.ts"],"sourcesContent":["import type {\n LiFiStep,\n RelayerQuoteResponse,\n RequestOptions,\n} from '@lifi/types'\nimport { BaseError } from '../errors/baseError.js'\nimport { ErrorName } from '../errors/constants.js'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { QuoteRequest, QuoteRequestFromAmount } from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Get a relayer quote for a token transfer\n * @param client - The SDK client\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Relayer quote for a token transfer\n */\nexport const getRelayerQuote = async (\n client: SDKClient,\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n): Promise<LiFiStep> => {\n const requiredParameters: Array<keyof QuoteRequestFromAmount> = [\n 'fromChain',\n 'fromToken',\n 'fromAddress',\n 'fromAmount',\n 'toChain',\n 'toToken',\n ]\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n\n // apply defaults\n params.integrator ??= client.config.integrator\n params.order ??= client.config.routeOptions?.order\n params.slippage ??= client.config.routeOptions?.slippage\n params.referrer ??= client.config.routeOptions?.referrer\n params.fee ??= client.config.routeOptions?.fee\n params.allowBridges ??= client.config.routeOptions?.bridges?.allow\n params.denyBridges ??= client.config.routeOptions?.bridges?.deny\n params.preferBridges ??= client.config.routeOptions?.bridges?.prefer\n params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow\n params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny\n params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer\n\n for (const key of Object.keys(params)) {\n if (\n params[key as keyof QuoteRequest] === undefined ||\n params[key as keyof QuoteRequest] === null\n ) {\n delete params[key as keyof QuoteRequest]\n }\n }\n\n const result = await request<RelayerQuoteResponse>(\n client.config,\n `${client.config.apiUrl}/relayer/quote?${new URLSearchParams(\n params as unknown as Record<string, string>\n )}`,\n {\n signal: options?.signal,\n }\n )\n\n if (result.status === 'error') {\n throw new BaseError(\n ErrorName.ServerError,\n result.data.code,\n result.data.message\n )\n }\n\n return result.data\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,MAAa,kBAAkB,OAC7B,QACA,QACA,YACsB;CAStB,KAAK,MAAM,qBAAqB;EAP9B;EACA;EACA;EACA;EACA;EACA;CAE+C,GAC/C,IAAI,CAAC,OAAO,oBACV,MAAM,IAAI,SACR,IAAI,gBACF,uBAAuB,kBAAkB,cAC3C,CACF;CAKJ,OAAO,eAAe,OAAO,OAAO;CACpC,OAAO,UAAU,OAAO,OAAO,cAAc;CAC7C,OAAO,aAAa,OAAO,OAAO,cAAc;CAChD,OAAO,aAAa,OAAO,OAAO,cAAc;CAChD,OAAO,QAAQ,OAAO,OAAO,cAAc;CAC3C,OAAO,iBAAiB,OAAO,OAAO,cAAc,SAAS;CAC7D,OAAO,gBAAgB,OAAO,OAAO,cAAc,SAAS;CAC5D,OAAO,kBAAkB,OAAO,OAAO,cAAc,SAAS;CAC9D,OAAO,mBAAmB,OAAO,OAAO,cAAc,WAAW;CACjE,OAAO,kBAAkB,OAAO,OAAO,cAAc,WAAW;CAChE,OAAO,oBAAoB,OAAO,OAAO,cAAc,WAAW;CAElE,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,GAClC,IACE,OAAO,SAA+B,KAAA,KACtC,OAAO,SAA+B,MAEtC,OAAO,OAAO;CAIlB,MAAM,SAAS,MAAM,QACnB,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,iBAAiB,IAAI,gBAC3C,MACF,KACA,EACE,QAAQ,SAAS,OACnB,CACF;CAEA,IAAI,OAAO,WAAW,SACpB,MAAM,IAAI,UAAA,eAER,OAAO,KAAK,MACZ,OAAO,KAAK,OACd;CAGF,OAAO,OAAO;AAChB"}
1
+ {"version":3,"file":"getRelayerQuote.js","names":[],"sources":["../../../src/actions/getRelayerQuote.ts"],"sourcesContent":["import type { LiFiStep, RequestOptions } from '@lifi/types'\nimport { BaseError } from '../errors/baseError.js'\nimport { ErrorName, LiFiErrorCode } from '../errors/constants.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { QuoteRequestFromAmount } from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\n\n/**\n * Get a relayer quote for a token transfer. The legacy gasless relayer service\n * behind it is shut down, so this always rejects and sends no request.\n *\n * Kept only so that published consumers that still import it keep building.\n * It stays `async`: callers such as `getRelayerQuote(...).catch(() => null)`\n * need a rejected promise, not a synchronous throw.\n * @param _client - The SDK client\n * @param _params - The configuration of the requested quote\n * @param _options - Request options\n * @throws {SDKError} - Always, with a `NotFound` cause.\n * @returns Never resolves with a quote.\n * @deprecated The legacy gasless relayer service is shut down. Request\n * gasless routes with `options.gasless: true` on `getRoutes`, or\n * `gasless: true` on `getQuote`, and detect them with `isGaslessStep`.\n */\nexport const getRelayerQuote = async (\n _client: SDKClient,\n _params: QuoteRequestFromAmount,\n _options?: RequestOptions\n): Promise<LiFiStep> => {\n throw new SDKError(\n new BaseError(\n ErrorName.NotFoundError,\n LiFiErrorCode.NotFound,\n 'The legacy gasless relayer service is shut down. Request gasless routes with `options.gasless: true` on `getRoutes`.'\n )\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,kBAAkB,OAC7B,SACA,SACA,aACsB;CACtB,MAAM,IAAI,SACR,IAAI,UAAA,iBAAA,MAGF,sHACF,CACF;AACF"}
@@ -58,6 +58,8 @@ export type Actions = {
58
58
  * @param params - The configuration of the requested relayer quote
59
59
  * @param options - Request options
60
60
  * @returns Quote from a relayer
61
+ * @deprecated The legacy gasless relayer service is shut down. Use
62
+ * `getRoutes` with `options.gasless: true`.
61
63
  */
62
64
  getRelayerQuote: (params: QuoteRequestFromAmount, options?: RequestOptions) => Promise<LiFiStep>;
63
65
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["RoutesRequest"],"sources":["../../../src/actions/index.ts"],"mappings":";;;;;YA8DY;;;;;;;EAOV,YACE,SAAS,eACT,UAAU,mBACP,QAAQ;;;;;;;EAQb,iBACE,QAAQ,oBACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,wBACE,QAAQ,2BACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,uBACE,QAAQ,0BACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,wBACE,cACA,YAAY,cACT;;;;;;;EAQL,WACE,QAAQ,kBAAkB,cAC1B,UAAU,mBACP,QAAQ;;;;;;;EAQb,8BACE,QAAQ,oBACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,kBACE,QAAQ,wBACR,UAAU,mBACP,QAAQ;;;;;;;;;EAUb,YACE,QAAQA,iBACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,YACE,QAAQ,0BACR,UAAU,mBACP,QAAQ;;;;;;;;EASb,qBACE,QAAQ,iBACR,UAAU,mBACP,QAAQ;;;;;;;;EASb,WACE,OAAO,WAAW,SAClB,eACA,UAAU,mBACP,QAAQ;;;;;;;EAQb,kBACE,uBACA,OAAO,UACJ,QAAQ;;;;;;;EAQb,mBACE,uBACA,QAAQ,YACL,QAAQ;;;;;;;EAQb,0BACE,uBACA;KAAoC,kBAAA;QACjC;KACgB,kBAAA;;;;;;;;EASrB;KAEI,SAAS;MAAkB;OAC3B,UAAU,iBACT,QAAQ;KAET,QAAQ;MAAkB;OAC1B,UAAU,iBACT,QAAQ;;;;;;;;EASb,WACE,SAAS,cACT,UAAU,mBACP,QAAQ;;;;;;;EAQb,wBACE,QAAQ,6BACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,mBACE,QAAQ,cACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,qBACE,QAAQ,sBACR,UAAU,mBACP,QAAQ;;wBAGC,QAAQ,QAAQ,YAAY"}
1
+ {"version":3,"file":"index.d.ts","names":["RoutesRequest"],"sources":["../../../src/actions/index.ts"],"mappings":";;;;;YA8DY;;;;;;;EAOV,YACE,SAAS,eACT,UAAU,mBACP,QAAQ;;;;;;;EAQb,iBACE,QAAQ,oBACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,wBACE,QAAQ,2BACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,uBACE,QAAQ,0BACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,wBACE,cACA,YAAY,cACT;;;;;;;EAQL,WACE,QAAQ,kBAAkB,cAC1B,UAAU,mBACP,QAAQ;;;;;;;EAQb,8BACE,QAAQ,oBACR,UAAU,mBACP,QAAQ;;;;;;;;;EAUb,kBACE,QAAQ,wBACR,UAAU,mBACP,QAAQ;;;;;;;;;EAUb,YACE,QAAQA,iBACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,YACE,QAAQ,0BACR,UAAU,mBACP,QAAQ;;;;;;;;EASb,qBACE,QAAQ,iBACR,UAAU,mBACP,QAAQ;;;;;;;;EASb,WACE,OAAO,WAAW,SAClB,eACA,UAAU,mBACP,QAAQ;;;;;;;EAQb,kBACE,uBACA,OAAO,UACJ,QAAQ;;;;;;;EAQb,mBACE,uBACA,QAAQ,YACL,QAAQ;;;;;;;EAQb,0BACE,uBACA;KAAoC,kBAAA;QACjC;KACgB,kBAAA;;;;;;;;EASrB;KAEI,SAAS;MAAkB;OAC3B,UAAU,iBACT,QAAQ;KAET,QAAQ;MAAkB;OAC1B,UAAU,iBACT,QAAQ;;;;;;;;EASb,WACE,SAAS,cACT,UAAU,mBACP,QAAQ;;;;;;;EAQb,wBACE,QAAQ,6BACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,mBACE,QAAQ,cACR,UAAU,mBACP,QAAQ;;;;;;;EAQb,qBACE,QAAQ,sBACR,UAAU,mBACP,QAAQ;;wBAGC,QAAQ,QAAQ,YAAY"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/actions/index.ts"],"sourcesContent":["import type {\n ChainId,\n ChainKey,\n ChainsRequest,\n ChainType,\n ConnectionsRequest,\n ConnectionsResponse,\n ContractCallsQuoteRequest,\n ExtendedChain,\n GasRecommendationRequest,\n GasRecommendationResponse,\n LiFiStep,\n PatchCallDataRequest,\n RelayRequest,\n RelayResponseData,\n RelayStatusRequest,\n RelayStatusResponseData,\n RequestOptions,\n RoutesResponse,\n StatusResponse,\n Token,\n TokenAmount,\n TokenExtended,\n TokensExtendedResponse,\n TokensRequest,\n TokensResponse,\n ToolsRequest,\n ToolsResponse,\n TransactionAnalyticsRequest,\n TransactionAnalyticsResponse,\n} from '@lifi/types'\nimport type {\n GetStatusRequestExtended,\n LiFiStepRequest,\n QuoteRequestFromAmount,\n RoutesRequest,\n} from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { getChains } from './getChains.js'\nimport { getConnections } from './getConnections.js'\nimport { getContractCallsQuote } from './getContractCallsQuote.js'\nimport { getGasRecommendation } from './getGasRecommendation.js'\nimport { getNameServiceAddress } from './getNameServiceAddress.js'\nimport { getQuote } from './getQuote.js'\nimport { getRelayedTransactionStatus } from './getRelayedTransactionStatus.js'\nimport { getRelayerQuote } from './getRelayerQuote.js'\nimport { getRoutes } from './getRoutes.js'\nimport { getStatus } from './getStatus.js'\nimport { getStepTransaction } from './getStepTransaction.js'\nimport { getToken } from './getToken.js'\nimport { getTokenBalance } from './getTokenBalance.js'\nimport { getTokenBalances } from './getTokenBalances.js'\nimport { getTokenBalancesByChain } from './getTokenBalancesByChain.js'\nimport { getTokens } from './getTokens.js'\nimport { getTools } from './getTools.js'\nimport { getTransactionHistory } from './getTransactionHistory.js'\nimport {\n patchContractCalls,\n type PatchContractCallsResponse,\n} from './patchContractCalls.js'\nimport { relayTransaction } from './relayTransaction.js'\n\nexport type Actions = {\n /**\n * Get all available chains\n * @param params - The configuration of the requested chains\n * @param options - Request options\n * @returns A list of all available chains\n */\n getChains: (\n params?: ChainsRequest,\n options?: RequestOptions\n ) => Promise<ExtendedChain[]>\n\n /**\n * Get connections between chains\n * @param params - The configuration of the requested connections\n * @param options - Request options\n * @returns A list of connections\n */\n getConnections: (\n params: ConnectionsRequest,\n options?: RequestOptions\n ) => Promise<ConnectionsResponse>\n\n /**\n * Get a quote for contract calls\n * @param params - The configuration of the requested contract calls quote\n * @param options - Request options\n * @returns Quote for contract calls\n */\n getContractCallsQuote: (\n params: ContractCallsQuoteRequest,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get gas recommendation for a chain\n * @param params - The configuration of the requested gas recommendation\n * @param options - Request options\n * @returns Gas recommendation\n */\n getGasRecommendation: (\n params: GasRecommendationRequest,\n options?: RequestOptions\n ) => Promise<GasRecommendationResponse>\n\n /**\n * Get the address of a name service\n * @param name - The name to resolve\n * @param chainType - The chain type to resolve the name on\n * @returns The address of the name service\n */\n getNameServiceAddress: (\n name: string,\n chainType?: ChainType\n ) => Promise<string | undefined>\n\n /**\n * Get a quote for a token transfer\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @returns Quote for a token transfer\n */\n getQuote: (\n params: Parameters<typeof getQuote>[1],\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get the status of a relayed transaction\n * @param params - The configuration of the requested relay status\n * @param options - Request options\n * @returns Status of the relayed transaction\n */\n getRelayedTransactionStatus: (\n params: RelayStatusRequest,\n options?: RequestOptions\n ) => Promise<RelayStatusResponseData>\n\n /**\n * Get a quote from a relayer\n * @param params - The configuration of the requested relayer quote\n * @param options - Request options\n * @returns Quote from a relayer\n */\n getRelayerQuote: (\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get a set of routes for a request that describes a transfer of tokens.\n * Optional limit-order fields (`toAmount`, `validUntil`, `partiallyFillable`)\n * may be supplied and are resolved on the backend.\n * @param params - A description of the transfer\n * @param options - Request options\n * @returns The resulting routes that can be used to realize the described transfer\n */\n getRoutes: (\n params: RoutesRequest,\n options?: RequestOptions\n ) => Promise<RoutesResponse>\n\n /**\n * Get the status of a transaction\n * @param params - The configuration of the requested status\n * @param options - Request options\n * @returns Status of the transaction\n */\n getStatus: (\n params: GetStatusRequestExtended,\n options?: RequestOptions\n ) => Promise<StatusResponse>\n\n /**\n * Get a step transaction. The step's `action` may carry the optional\n * limit-order fields, which are resolved on the backend.\n * @param params - The configuration of the requested step transaction\n * @param options - Request options\n * @returns Step transaction\n */\n getStepTransaction: (\n params: LiFiStepRequest,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get a specific token\n * @param chain - Id or key of the chain that contains the token\n * @param token - Address or symbol of the token on the requested chain\n * @param options - Request options\n * @returns Token information\n */\n getToken: (\n chain: ChainKey | ChainId,\n token: string,\n options?: RequestOptions\n ) => Promise<TokenExtended>\n\n /**\n * Get token balance for a specific token\n * @param walletAddress - A wallet address\n * @param token - A Token object\n * @returns Token balance\n */\n getTokenBalance: (\n walletAddress: string,\n token: Token\n ) => Promise<TokenAmount | null>\n\n /**\n * Get token balances for multiple tokens\n * @param walletAddress - A wallet address\n * @param tokens - A list of Token objects\n * @returns Token balances\n */\n getTokenBalances: (\n walletAddress: string,\n tokens: Token[]\n ) => Promise<TokenAmount[]>\n\n /**\n * Get token balances by chain\n * @param walletAddress - A wallet address\n * @param tokensByChain - A list of token objects organized by chain ids\n * @returns Token balances by chain\n */\n getTokenBalancesByChain: (\n walletAddress: string,\n tokensByChain: { [chainId: number]: Token[] }\n ) => Promise<{\n [chainId: number]: TokenAmount[]\n }>\n\n /**\n * Get all available tokens\n * @param params - The configuration of the requested tokens\n * @param options - Request options\n * @returns A list of all available tokens\n */\n getTokens: {\n (\n params?: TokensRequest & { extended?: false | undefined },\n options?: RequestOptions\n ): Promise<TokensResponse>\n (\n params: TokensRequest & { extended: true },\n options?: RequestOptions\n ): Promise<TokensExtendedResponse>\n }\n\n /**\n * Get all available tools (bridges and exchanges)\n * @param params - The configuration of the requested tools\n * @param options - Request options\n * @returns A list of all available tools\n */\n getTools: (\n params?: ToolsRequest,\n options?: RequestOptions\n ) => Promise<ToolsResponse>\n\n /**\n * Get transaction history\n * @param params - The configuration of the requested transaction history\n * @param options - Request options\n * @returns Transaction history\n */\n getTransactionHistory: (\n params: TransactionAnalyticsRequest,\n options?: RequestOptions\n ) => Promise<TransactionAnalyticsResponse>\n\n /**\n * Relay a transaction through the relayer service\n * @param params - The configuration for the relay request\n * @param options - Request options\n * @returns Task ID and transaction link for the relayed transaction\n */\n relayTransaction: (\n params: RelayRequest,\n options?: RequestOptions\n ) => Promise<RelayResponseData>\n\n /**\n * Patch contract calls\n * @param params - The configuration for the patch contract calls request\n * @param options - Request options\n * @returns Patched contract calls\n */\n patchContractCalls: (\n params: PatchCallDataRequest,\n options?: RequestOptions\n ) => Promise<PatchContractCallsResponse[]>\n}\n\nexport function actions(client: SDKClient): Actions {\n return {\n getChains: (params, options) => getChains(client, params, options),\n getConnections: (params, options) =>\n getConnections(client, params, options),\n getContractCallsQuote: (params, options) =>\n getContractCallsQuote(client, params, options),\n getGasRecommendation: (params, options) =>\n getGasRecommendation(client, params, options),\n getNameServiceAddress: (name, chainType) =>\n getNameServiceAddress(client, name, chainType),\n getTokens: (params, options) => getTokens(client, params as any, options),\n getTools: (params, options) => getTools(client, params, options),\n getQuote: (params, options) => getQuote(client, params, options),\n getRelayedTransactionStatus: (params, options) =>\n getRelayedTransactionStatus(client, params, options),\n getRelayerQuote: (params, options) =>\n getRelayerQuote(client, params, options),\n getRoutes: (params, options) => getRoutes(client, params, options),\n getStatus: (params, options) => getStatus(client, params, options),\n getStepTransaction: (params, options) =>\n getStepTransaction(client, params, options),\n getToken: (chain, token, options) =>\n getToken(client, chain, token, options),\n getTokenBalance: (walletAddress, token) =>\n getTokenBalance(client, walletAddress, token),\n getTokenBalances: (walletAddress, tokens) =>\n getTokenBalances(client, walletAddress, tokens),\n getTokenBalancesByChain: (walletAddress, tokensByChain) =>\n getTokenBalancesByChain(client, walletAddress, tokensByChain),\n getTransactionHistory: (params, options) =>\n getTransactionHistory(client, params, options),\n relayTransaction: (params, options) =>\n relayTransaction(client, params, options),\n patchContractCalls: (params, options) =>\n patchContractCalls(client, params, options),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAySA,SAAgB,QAAQ,QAA4B;CAClD,OAAO;EACL,YAAY,QAAQ,YAAY,UAAU,QAAQ,QAAQ,OAAO;EACjE,iBAAiB,QAAQ,YACvB,eAAe,QAAQ,QAAQ,OAAO;EACxC,wBAAwB,QAAQ,YAC9B,sBAAsB,QAAQ,QAAQ,OAAO;EAC/C,uBAAuB,QAAQ,YAC7B,qBAAqB,QAAQ,QAAQ,OAAO;EAC9C,wBAAwB,MAAM,cAC5B,sBAAsB,QAAQ,MAAM,SAAS;EAC/C,YAAY,QAAQ,YAAY,UAAU,QAAQ,QAAe,OAAO;EACxE,WAAW,QAAQ,YAAY,SAAS,QAAQ,QAAQ,OAAO;EAC/D,WAAW,QAAQ,YAAY,SAAS,QAAQ,QAAQ,OAAO;EAC/D,8BAA8B,QAAQ,YACpC,4BAA4B,QAAQ,QAAQ,OAAO;EACrD,kBAAkB,QAAQ,YACxB,gBAAgB,QAAQ,QAAQ,OAAO;EACzC,YAAY,QAAQ,YAAY,UAAU,QAAQ,QAAQ,OAAO;EACjE,YAAY,QAAQ,YAAY,UAAU,QAAQ,QAAQ,OAAO;EACjE,qBAAqB,QAAQ,YAC3B,mBAAmB,QAAQ,QAAQ,OAAO;EAC5C,WAAW,OAAO,OAAO,YACvB,SAAS,QAAQ,OAAO,OAAO,OAAO;EACxC,kBAAkB,eAAe,UAC/B,gBAAgB,QAAQ,eAAe,KAAK;EAC9C,mBAAmB,eAAe,WAChC,iBAAiB,QAAQ,eAAe,MAAM;EAChD,0BAA0B,eAAe,kBACvC,wBAAwB,QAAQ,eAAe,aAAa;EAC9D,wBAAwB,QAAQ,YAC9B,sBAAsB,QAAQ,QAAQ,OAAO;EAC/C,mBAAmB,QAAQ,YACzB,iBAAiB,QAAQ,QAAQ,OAAO;EAC1C,qBAAqB,QAAQ,YAC3B,mBAAmB,QAAQ,QAAQ,OAAO;CAC9C;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/actions/index.ts"],"sourcesContent":["import type {\n ChainId,\n ChainKey,\n ChainsRequest,\n ChainType,\n ConnectionsRequest,\n ConnectionsResponse,\n ContractCallsQuoteRequest,\n ExtendedChain,\n GasRecommendationRequest,\n GasRecommendationResponse,\n LiFiStep,\n PatchCallDataRequest,\n RelayRequest,\n RelayResponseData,\n RelayStatusRequest,\n RelayStatusResponseData,\n RequestOptions,\n RoutesResponse,\n StatusResponse,\n Token,\n TokenAmount,\n TokenExtended,\n TokensExtendedResponse,\n TokensRequest,\n TokensResponse,\n ToolsRequest,\n ToolsResponse,\n TransactionAnalyticsRequest,\n TransactionAnalyticsResponse,\n} from '@lifi/types'\nimport type {\n GetStatusRequestExtended,\n LiFiStepRequest,\n QuoteRequestFromAmount,\n RoutesRequest,\n} from '../types/actions.js'\nimport type { SDKClient } from '../types/core.js'\nimport { getChains } from './getChains.js'\nimport { getConnections } from './getConnections.js'\nimport { getContractCallsQuote } from './getContractCallsQuote.js'\nimport { getGasRecommendation } from './getGasRecommendation.js'\nimport { getNameServiceAddress } from './getNameServiceAddress.js'\nimport { getQuote } from './getQuote.js'\nimport { getRelayedTransactionStatus } from './getRelayedTransactionStatus.js'\nimport { getRelayerQuote } from './getRelayerQuote.js'\nimport { getRoutes } from './getRoutes.js'\nimport { getStatus } from './getStatus.js'\nimport { getStepTransaction } from './getStepTransaction.js'\nimport { getToken } from './getToken.js'\nimport { getTokenBalance } from './getTokenBalance.js'\nimport { getTokenBalances } from './getTokenBalances.js'\nimport { getTokenBalancesByChain } from './getTokenBalancesByChain.js'\nimport { getTokens } from './getTokens.js'\nimport { getTools } from './getTools.js'\nimport { getTransactionHistory } from './getTransactionHistory.js'\nimport {\n patchContractCalls,\n type PatchContractCallsResponse,\n} from './patchContractCalls.js'\nimport { relayTransaction } from './relayTransaction.js'\n\nexport type Actions = {\n /**\n * Get all available chains\n * @param params - The configuration of the requested chains\n * @param options - Request options\n * @returns A list of all available chains\n */\n getChains: (\n params?: ChainsRequest,\n options?: RequestOptions\n ) => Promise<ExtendedChain[]>\n\n /**\n * Get connections between chains\n * @param params - The configuration of the requested connections\n * @param options - Request options\n * @returns A list of connections\n */\n getConnections: (\n params: ConnectionsRequest,\n options?: RequestOptions\n ) => Promise<ConnectionsResponse>\n\n /**\n * Get a quote for contract calls\n * @param params - The configuration of the requested contract calls quote\n * @param options - Request options\n * @returns Quote for contract calls\n */\n getContractCallsQuote: (\n params: ContractCallsQuoteRequest,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get gas recommendation for a chain\n * @param params - The configuration of the requested gas recommendation\n * @param options - Request options\n * @returns Gas recommendation\n */\n getGasRecommendation: (\n params: GasRecommendationRequest,\n options?: RequestOptions\n ) => Promise<GasRecommendationResponse>\n\n /**\n * Get the address of a name service\n * @param name - The name to resolve\n * @param chainType - The chain type to resolve the name on\n * @returns The address of the name service\n */\n getNameServiceAddress: (\n name: string,\n chainType?: ChainType\n ) => Promise<string | undefined>\n\n /**\n * Get a quote for a token transfer\n * @param params - The configuration of the requested quote\n * @param options - Request options\n * @returns Quote for a token transfer\n */\n getQuote: (\n params: Parameters<typeof getQuote>[1],\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get the status of a relayed transaction\n * @param params - The configuration of the requested relay status\n * @param options - Request options\n * @returns Status of the relayed transaction\n */\n getRelayedTransactionStatus: (\n params: RelayStatusRequest,\n options?: RequestOptions\n ) => Promise<RelayStatusResponseData>\n\n /**\n * Get a quote from a relayer\n * @param params - The configuration of the requested relayer quote\n * @param options - Request options\n * @returns Quote from a relayer\n * @deprecated The legacy gasless relayer service is shut down. Use\n * `getRoutes` with `options.gasless: true`.\n */\n getRelayerQuote: (\n params: QuoteRequestFromAmount,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get a set of routes for a request that describes a transfer of tokens.\n * Optional limit-order fields (`toAmount`, `validUntil`, `partiallyFillable`)\n * may be supplied and are resolved on the backend.\n * @param params - A description of the transfer\n * @param options - Request options\n * @returns The resulting routes that can be used to realize the described transfer\n */\n getRoutes: (\n params: RoutesRequest,\n options?: RequestOptions\n ) => Promise<RoutesResponse>\n\n /**\n * Get the status of a transaction\n * @param params - The configuration of the requested status\n * @param options - Request options\n * @returns Status of the transaction\n */\n getStatus: (\n params: GetStatusRequestExtended,\n options?: RequestOptions\n ) => Promise<StatusResponse>\n\n /**\n * Get a step transaction. The step's `action` may carry the optional\n * limit-order fields, which are resolved on the backend.\n * @param params - The configuration of the requested step transaction\n * @param options - Request options\n * @returns Step transaction\n */\n getStepTransaction: (\n params: LiFiStepRequest,\n options?: RequestOptions\n ) => Promise<LiFiStep>\n\n /**\n * Get a specific token\n * @param chain - Id or key of the chain that contains the token\n * @param token - Address or symbol of the token on the requested chain\n * @param options - Request options\n * @returns Token information\n */\n getToken: (\n chain: ChainKey | ChainId,\n token: string,\n options?: RequestOptions\n ) => Promise<TokenExtended>\n\n /**\n * Get token balance for a specific token\n * @param walletAddress - A wallet address\n * @param token - A Token object\n * @returns Token balance\n */\n getTokenBalance: (\n walletAddress: string,\n token: Token\n ) => Promise<TokenAmount | null>\n\n /**\n * Get token balances for multiple tokens\n * @param walletAddress - A wallet address\n * @param tokens - A list of Token objects\n * @returns Token balances\n */\n getTokenBalances: (\n walletAddress: string,\n tokens: Token[]\n ) => Promise<TokenAmount[]>\n\n /**\n * Get token balances by chain\n * @param walletAddress - A wallet address\n * @param tokensByChain - A list of token objects organized by chain ids\n * @returns Token balances by chain\n */\n getTokenBalancesByChain: (\n walletAddress: string,\n tokensByChain: { [chainId: number]: Token[] }\n ) => Promise<{\n [chainId: number]: TokenAmount[]\n }>\n\n /**\n * Get all available tokens\n * @param params - The configuration of the requested tokens\n * @param options - Request options\n * @returns A list of all available tokens\n */\n getTokens: {\n (\n params?: TokensRequest & { extended?: false | undefined },\n options?: RequestOptions\n ): Promise<TokensResponse>\n (\n params: TokensRequest & { extended: true },\n options?: RequestOptions\n ): Promise<TokensExtendedResponse>\n }\n\n /**\n * Get all available tools (bridges and exchanges)\n * @param params - The configuration of the requested tools\n * @param options - Request options\n * @returns A list of all available tools\n */\n getTools: (\n params?: ToolsRequest,\n options?: RequestOptions\n ) => Promise<ToolsResponse>\n\n /**\n * Get transaction history\n * @param params - The configuration of the requested transaction history\n * @param options - Request options\n * @returns Transaction history\n */\n getTransactionHistory: (\n params: TransactionAnalyticsRequest,\n options?: RequestOptions\n ) => Promise<TransactionAnalyticsResponse>\n\n /**\n * Relay a transaction through the relayer service\n * @param params - The configuration for the relay request\n * @param options - Request options\n * @returns Task ID and transaction link for the relayed transaction\n */\n relayTransaction: (\n params: RelayRequest,\n options?: RequestOptions\n ) => Promise<RelayResponseData>\n\n /**\n * Patch contract calls\n * @param params - The configuration for the patch contract calls request\n * @param options - Request options\n * @returns Patched contract calls\n */\n patchContractCalls: (\n params: PatchCallDataRequest,\n options?: RequestOptions\n ) => Promise<PatchContractCallsResponse[]>\n}\n\nexport function actions(client: SDKClient): Actions {\n return {\n getChains: (params, options) => getChains(client, params, options),\n getConnections: (params, options) =>\n getConnections(client, params, options),\n getContractCallsQuote: (params, options) =>\n getContractCallsQuote(client, params, options),\n getGasRecommendation: (params, options) =>\n getGasRecommendation(client, params, options),\n getNameServiceAddress: (name, chainType) =>\n getNameServiceAddress(client, name, chainType),\n getTokens: (params, options) => getTokens(client, params as any, options),\n getTools: (params, options) => getTools(client, params, options),\n getQuote: (params, options) => getQuote(client, params, options),\n getRelayedTransactionStatus: (params, options) =>\n getRelayedTransactionStatus(client, params, options),\n getRelayerQuote: (params, options) =>\n getRelayerQuote(client, params, options),\n getRoutes: (params, options) => getRoutes(client, params, options),\n getStatus: (params, options) => getStatus(client, params, options),\n getStepTransaction: (params, options) =>\n getStepTransaction(client, params, options),\n getToken: (chain, token, options) =>\n getToken(client, chain, token, options),\n getTokenBalance: (walletAddress, token) =>\n getTokenBalance(client, walletAddress, token),\n getTokenBalances: (walletAddress, tokens) =>\n getTokenBalances(client, walletAddress, tokens),\n getTokenBalancesByChain: (walletAddress, tokensByChain) =>\n getTokenBalancesByChain(client, walletAddress, tokensByChain),\n getTransactionHistory: (params, options) =>\n getTransactionHistory(client, params, options),\n relayTransaction: (params, options) =>\n relayTransaction(client, params, options),\n patchContractCalls: (params, options) =>\n patchContractCalls(client, params, options),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2SA,SAAgB,QAAQ,QAA4B;CAClD,OAAO;EACL,YAAY,QAAQ,YAAY,UAAU,QAAQ,QAAQ,OAAO;EACjE,iBAAiB,QAAQ,YACvB,eAAe,QAAQ,QAAQ,OAAO;EACxC,wBAAwB,QAAQ,YAC9B,sBAAsB,QAAQ,QAAQ,OAAO;EAC/C,uBAAuB,QAAQ,YAC7B,qBAAqB,QAAQ,QAAQ,OAAO;EAC9C,wBAAwB,MAAM,cAC5B,sBAAsB,QAAQ,MAAM,SAAS;EAC/C,YAAY,QAAQ,YAAY,UAAU,QAAQ,QAAe,OAAO;EACxE,WAAW,QAAQ,YAAY,SAAS,QAAQ,QAAQ,OAAO;EAC/D,WAAW,QAAQ,YAAY,SAAS,QAAQ,QAAQ,OAAO;EAC/D,8BAA8B,QAAQ,YACpC,4BAA4B,QAAQ,QAAQ,OAAO;EACrD,kBAAkB,QAAQ,YACxB,gBAAgB,QAAQ,QAAQ,OAAO;EACzC,YAAY,QAAQ,YAAY,UAAU,QAAQ,QAAQ,OAAO;EACjE,YAAY,QAAQ,YAAY,UAAU,QAAQ,QAAQ,OAAO;EACjE,qBAAqB,QAAQ,YAC3B,mBAAmB,QAAQ,QAAQ,OAAO;EAC5C,WAAW,OAAO,OAAO,YACvB,SAAS,QAAQ,OAAO,OAAO,OAAO;EACxC,kBAAkB,eAAe,UAC/B,gBAAgB,QAAQ,eAAe,KAAK;EAC9C,mBAAmB,eAAe,WAChC,iBAAiB,QAAQ,eAAe,MAAM;EAChD,0BAA0B,eAAe,kBACvC,wBAAwB,QAAQ,eAAe,aAAa;EAC9D,wBAAwB,QAAQ,YAC9B,sBAAsB,QAAQ,QAAQ,OAAO;EAC/C,mBAAmB,QAAQ,YACzB,iBAAiB,QAAQ,QAAQ,OAAO;EAC1C,qBAAqB,QAAQ,YAC3B,mBAAmB,QAAQ,QAAQ,OAAO;CAC9C;AACF"}
@@ -14,8 +14,7 @@ import { request } from "../utils/request.js";
14
14
  */
15
15
  const relayTransaction = async (client, params, options) => {
16
16
  for (const requiredParameter of ["typedData"]) if (!params[requiredParameter]) throw new SDKError(new ValidationError(`Required parameter "${requiredParameter}" is missing.`));
17
- const relayerPath = params.typedData.some((t) => t.primaryType === "PermitWitnessTransferFrom") ? "/relayer/relay" : "/advanced/relay";
18
- const result = await request(client.config, `${client.config.apiUrl}${relayerPath}`, {
17
+ const result = await request(client.config, `${client.config.apiUrl}/advanced/relay`, {
19
18
  method: "POST",
20
19
  headers: { "Content-Type": "application/json" },
21
20
  body: JSON.stringify(params, (_, value) => {
@@ -1 +1 @@
1
- {"version":3,"file":"relayTransaction.js","names":[],"sources":["../../../src/actions/relayTransaction.ts"],"sourcesContent":["import type {\n RelayRequest,\n RelayResponse,\n RelayResponseData,\n RequestOptions,\n} from '@lifi/types'\nimport { BaseError } from '../errors/baseError.js'\nimport { ErrorName } from '../errors/constants.js'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Relay a transaction through the relayer service\n * @param client - The SDK client\n * @param params - The configuration for the relay request\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Task ID and transaction link for the relayed transaction\n */\nexport const relayTransaction = async (\n client: SDKClient,\n params: RelayRequest,\n options?: RequestOptions\n): Promise<RelayResponseData> => {\n const requiredParameters: Array<keyof RelayRequest> = ['typedData']\n\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n\n // Determine if the request is for a gasless relayer service or advanced relayer service\n // We will use the same endpoint for both after the gasless relayer service is deprecated\n const relayerPath = params.typedData.some(\n (t) => t.primaryType === 'PermitWitnessTransferFrom'\n )\n ? '/relayer/relay'\n : '/advanced/relay'\n\n const result = await request<RelayResponse>(\n client.config,\n `${client.config.apiUrl}${relayerPath}`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params, (_, value) => {\n if (typeof value === 'bigint') {\n return value.toString()\n }\n return value\n }),\n signal: options?.signal,\n }\n )\n\n if (result.status === 'error') {\n throw new BaseError(\n ErrorName.ServerError,\n result.data.code,\n result.data.message\n )\n }\n\n return result.data\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,MAAa,mBAAmB,OAC9B,QACA,QACA,YAC+B;CAG/B,KAAK,MAAM,qBAAqB,CAFuB,WAEN,GAC/C,IAAI,CAAC,OAAO,oBACV,MAAM,IAAI,SACR,IAAI,gBACF,uBAAuB,kBAAkB,cAC3C,CACF;CAMJ,MAAM,cAAc,OAAO,UAAU,MAClC,MAAM,EAAE,gBAAgB,2BAC3B,IACI,mBACA;CAEJ,MAAM,SAAS,MAAM,QACnB,OAAO,QACP,GAAG,OAAO,OAAO,SAAS,eAC1B;EACE,QAAQ;EACR,SAAS,EACP,gBAAgB,mBAClB;EACA,MAAM,KAAK,UAAU,SAAS,GAAG,UAAU;GACzC,IAAI,OAAO,UAAU,UACnB,OAAO,MAAM,SAAS;GAExB,OAAO;EACT,CAAC;EACD,QAAQ,SAAS;CACnB,CACF;CAEA,IAAI,OAAO,WAAW,SACpB,MAAM,IAAI,UAAA,eAER,OAAO,KAAK,MACZ,OAAO,KAAK,OACd;CAGF,OAAO,OAAO;AAChB"}
1
+ {"version":3,"file":"relayTransaction.js","names":[],"sources":["../../../src/actions/relayTransaction.ts"],"sourcesContent":["import type {\n RelayRequest,\n RelayResponse,\n RelayResponseData,\n RequestOptions,\n} from '@lifi/types'\nimport { BaseError } from '../errors/baseError.js'\nimport { ErrorName } from '../errors/constants.js'\nimport { ValidationError } from '../errors/errors.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Relay a transaction through the relayer service\n * @param client - The SDK client\n * @param params - The configuration for the relay request\n * @param options - Request options\n * @throws {LiFiError} - Throws a LiFiError if request fails\n * @returns Task ID and transaction link for the relayed transaction\n */\nexport const relayTransaction = async (\n client: SDKClient,\n params: RelayRequest,\n options?: RequestOptions\n): Promise<RelayResponseData> => {\n const requiredParameters: Array<keyof RelayRequest> = ['typedData']\n\n for (const requiredParameter of requiredParameters) {\n if (!params[requiredParameter]) {\n throw new SDKError(\n new ValidationError(\n `Required parameter \"${requiredParameter}\" is missing.`\n )\n )\n }\n }\n\n const result = await request<RelayResponse>(\n client.config,\n `${client.config.apiUrl}/advanced/relay`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params, (_, value) => {\n if (typeof value === 'bigint') {\n return value.toString()\n }\n return value\n }),\n signal: options?.signal,\n }\n )\n\n if (result.status === 'error') {\n throw new BaseError(\n ErrorName.ServerError,\n result.data.code,\n result.data.message\n )\n }\n\n return result.data\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,MAAa,mBAAmB,OAC9B,QACA,QACA,YAC+B;CAG/B,KAAK,MAAM,qBAAqB,CAFuB,WAEN,GAC/C,IAAI,CAAC,OAAO,oBACV,MAAM,IAAI,SACR,IAAI,gBACF,uBAAuB,kBAAkB,cAC3C,CACF;CAIJ,MAAM,SAAS,MAAM,QACnB,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,kBACxB;EACE,QAAQ;EACR,SAAS,EACP,gBAAgB,mBAClB;EACA,MAAM,KAAK,UAAU,SAAS,GAAG,UAAU;GACzC,IAAI,OAAO,UAAU,UACnB,OAAO,MAAM,SAAS;GAExB,OAAO;EACT,CAAC;EACD,QAAQ,SAAS;CACnB,CACF;CAEA,IAAI,OAAO,WAAW,SACpB,MAAM,IAAI,UAAA,eAER,OAAO,KAAK,MACZ,OAAO,KAAK,OACd;CAGF,OAAO,OAAO;AAChB"}
@@ -48,6 +48,7 @@ import { checkPackageUpdates } from "./utils/checkPackageUpdates.js";
48
48
  import { convertQuoteToRoute } from "./utils/convertQuoteToRoute.js";
49
49
  import { fetchTxErrorDetails } from "./utils/fetchTxErrorDetails.js";
50
50
  import { formatUnits } from "./utils/formatUnits.js";
51
+ import { GASLESS_RELAY_FEE_NAME, isGaslessStep } from "./utils/isGaslessStep.js";
51
52
  import { isHex } from "./utils/isHex.js";
52
53
  import { LruMap } from "./utils/lru.js";
53
54
  import { parseUnits } from "./utils/parseUnits.js";
@@ -57,4 +58,4 @@ import { withDedupe } from "./utils/withDedupe.js";
57
58
  import { withTimeout } from "./utils/withTimeout.js";
58
59
  import { name, version } from "./version.js";
59
60
  export * from "@lifi/types";
60
- export { type AcceptExchangeRateUpdateHook, type AcceptSlippageUpdateHook, type AcceptSlippageUpdateHookParams, BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, CLEARED_TRANSACTION_FIELDS, CLOCK_SKEW_MARGIN_MS, type CheckBalanceOptions, CheckBalanceTask, type ContractCallParams, type ContractTool, DROPPED_FALLBACK_AGE_MS, type ErrorCode, ErrorMessage, ErrorName, type ExchangeRateUpdateParams, ExecuteStepRetryError, type ExecuteStepRetryParams, type Execution, type ExecutionAction, type ExecutionActionStatus, type ExecutionActionType, type ExecutionOptions, type ExecutionStatus, type GetContractCallsHook, type GetContractCallsResult, type GetStatusRequestExtended, HTTPError, InMemoryStorage, type InteractionSettings, LiFiErrorCode, type LiFiStepExtended, type LiFiStepRequest, LocalStorageAdapter, LruMap, MAX_RESEND_AGE_MS, PrepareTransactionTask, ProviderError, type QuoteRequest, type QuoteRequestFromAmount, type QuoteRequestToAmount, RPCError, type RPCUrls, type RPCUrlsByRole, type RPCUrlsConfig, type RequestInterceptor, type RouteExecutionData, type RouteExecutionDataDictionary, type RouteExecutionDictionary, type RouteExtended, type SDKBaseConfig, type SDKClient, type SDKConfig, SDKError, type SDKProvider, type SDKStorage, ServerError, StatusManager, type StepExecutor, type StepExecutorBaseContext, type StepExecutorContext, type StepExecutorOptions, type StepExtended, TaskPipeline, type TaskResult, type TaskStatus, TransactionError, type TransactionErrorOptions, type TransactionMethodType, type TransactionParameters, type TransactionRequestParameters, type TransactionRequestUpdateHook, UnknownError, type UpdateRouteHook, ValidationError, WaitForTransactionStatusTask, actions, assertNoOpenTransaction, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, findProvider, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, hasOpenTransaction, isFinalTransactionError, isHex, isKnownToStatusApi, isOldEnoughToDrop, isResendAllowed, name, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, version, waitForResult, withDedupe, withTimeout };
61
+ export { type AcceptExchangeRateUpdateHook, type AcceptSlippageUpdateHook, type AcceptSlippageUpdateHookParams, BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, CLEARED_TRANSACTION_FIELDS, CLOCK_SKEW_MARGIN_MS, type CheckBalanceOptions, CheckBalanceTask, type ContractCallParams, type ContractTool, DROPPED_FALLBACK_AGE_MS, type ErrorCode, ErrorMessage, ErrorName, type ExchangeRateUpdateParams, ExecuteStepRetryError, type ExecuteStepRetryParams, type Execution, type ExecutionAction, type ExecutionActionStatus, type ExecutionActionType, type ExecutionOptions, type ExecutionStatus, GASLESS_RELAY_FEE_NAME, type GetContractCallsHook, type GetContractCallsResult, type GetStatusRequestExtended, HTTPError, InMemoryStorage, type InteractionSettings, LiFiErrorCode, type LiFiStepExtended, type LiFiStepRequest, LocalStorageAdapter, LruMap, MAX_RESEND_AGE_MS, PrepareTransactionTask, ProviderError, type QuoteRequest, type QuoteRequestFromAmount, type QuoteRequestToAmount, RPCError, type RPCUrls, type RPCUrlsByRole, type RPCUrlsConfig, type RequestInterceptor, type RouteExecutionData, type RouteExecutionDataDictionary, type RouteExecutionDictionary, type RouteExtended, type SDKBaseConfig, type SDKClient, type SDKConfig, SDKError, type SDKProvider, type SDKStorage, ServerError, StatusManager, type StepExecutor, type StepExecutorBaseContext, type StepExecutorContext, type StepExecutorOptions, type StepExtended, TaskPipeline, type TaskResult, type TaskStatus, TransactionError, type TransactionErrorOptions, type TransactionMethodType, type TransactionParameters, type TransactionRequestParameters, type TransactionRequestUpdateHook, UnknownError, type UpdateRouteHook, ValidationError, WaitForTransactionStatusTask, actions, assertNoOpenTransaction, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, findProvider, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, hasOpenTransaction, isFinalTransactionError, isGaslessStep, isHex, isKnownToStatusApi, isOldEnoughToDrop, isResendAllowed, name, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, version, waitForResult, withDedupe, withTimeout };
package/dist/esm/index.js CHANGED
@@ -45,6 +45,7 @@ import { checkPackageUpdates } from "./utils/checkPackageUpdates.js";
45
45
  import { convertQuoteToRoute } from "./utils/convertQuoteToRoute.js";
46
46
  import { fetchTxErrorDetails } from "./utils/fetchTxErrorDetails.js";
47
47
  import { formatUnits } from "./utils/formatUnits.js";
48
+ import { GASLESS_RELAY_FEE_NAME, isGaslessStep } from "./utils/isGaslessStep.js";
48
49
  import { isHex } from "./utils/isHex.js";
49
50
  import { LruMap } from "./utils/lru.js";
50
51
  import { parseUnits } from "./utils/parseUnits.js";
@@ -54,4 +55,4 @@ import { withDedupe } from "./utils/withDedupe.js";
54
55
  import { withTimeout } from "./utils/withTimeout.js";
55
56
  import { name, version } from "./version.js";
56
57
  export * from "@lifi/types";
57
- export { BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, CLEARED_TRANSACTION_FIELDS, CLOCK_SKEW_MARGIN_MS, CheckBalanceTask, DROPPED_FALLBACK_AGE_MS, ErrorMessage, ErrorName, ExecuteStepRetryError, HTTPError, InMemoryStorage, LiFiErrorCode, LocalStorageAdapter, LruMap, MAX_RESEND_AGE_MS, PrepareTransactionTask, ProviderError, RPCError, SDKError, ServerError, StatusManager, TaskPipeline, TransactionError, UnknownError, ValidationError, WaitForTransactionStatusTask, actions, assertNoOpenTransaction, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, findProvider, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, hasOpenTransaction, isFinalTransactionError, isHex, isKnownToStatusApi, isOldEnoughToDrop, isResendAllowed, name, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, version, waitForResult, withDedupe, withTimeout };
58
+ export { BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, CLEARED_TRANSACTION_FIELDS, CLOCK_SKEW_MARGIN_MS, CheckBalanceTask, DROPPED_FALLBACK_AGE_MS, ErrorMessage, ErrorName, ExecuteStepRetryError, GASLESS_RELAY_FEE_NAME, HTTPError, InMemoryStorage, LiFiErrorCode, LocalStorageAdapter, LruMap, MAX_RESEND_AGE_MS, PrepareTransactionTask, ProviderError, RPCError, SDKError, ServerError, StatusManager, TaskPipeline, TransactionError, UnknownError, ValidationError, WaitForTransactionStatusTask, actions, assertNoOpenTransaction, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, findProvider, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, hasOpenTransaction, isFinalTransactionError, isGaslessStep, isHex, isKnownToStatusApi, isOldEnoughToDrop, isResendAllowed, name, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, version, waitForResult, withDedupe, withTimeout };
@@ -4,7 +4,7 @@ const checkPackageUpdates = async (packageName, packageVersion) => {
4
4
  try {
5
5
  const pkgName = packageName ?? "@lifi/sdk";
6
6
  const latestVersion = (await (await fetch(`https://registry.npmjs.org/${pkgName}/latest`)).json()).version;
7
- const currentVersion = packageVersion ?? "0.0.0-preview-9b9526be";
7
+ const currentVersion = packageVersion ?? "0.0.0-preview-e8c80bc4";
8
8
  if (latestVersion > currentVersion) console.warn(`${pkgName}: new package version is available. Please update as soon as possible to enjoy the newest features. Current version: ${currentVersion}. Latest version: ${latestVersion}.`);
9
9
  } catch (_error) {}
10
10
  };
@@ -0,0 +1,14 @@
1
+ import { LiFiStep } from "@lifi/types";
2
+ /**
3
+ * The `feeCosts` name of the gasless relay fee. The backend marks every
4
+ * gasless step with it and guarantees that the name does not change.
5
+ */
6
+ export declare const GASLESS_RELAY_FEE_NAME = "LIFI Gasless Relay Fee";
7
+ /**
8
+ * Whether the step executes gasless: the user signs typed data and the LI.FI
9
+ * relayer submits it and pays the gas. The relay fee is the only marker that
10
+ * exists already at routes time, before `/advanced/stepTransaction` adds the
11
+ * typed data.
12
+ */
13
+ export declare function isGaslessStep(step: Pick<LiFiStep, "estimate">): boolean;
14
+ //# sourceMappingURL=isGaslessStep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isGaslessStep.d.ts","names":[],"sources":["../../../src/utils/isGaslessStep.ts"],"mappings":";;;;;qBAMa;;;;;;;wBAQG,cAAc,MAAM,KAAK"}
@@ -0,0 +1,18 @@
1
+ // src/utils/isGaslessStep.ts
2
+ /**
3
+ * The `feeCosts` name of the gasless relay fee. The backend marks every
4
+ * gasless step with it and guarantees that the name does not change.
5
+ */
6
+ const GASLESS_RELAY_FEE_NAME = "LIFI Gasless Relay Fee";
7
+ /**
8
+ * Whether the step executes gasless: the user signs typed data and the LI.FI
9
+ * relayer submits it and pays the gas. The relay fee is the only marker that
10
+ * exists already at routes time, before `/advanced/stepTransaction` adds the
11
+ * typed data.
12
+ */
13
+ function isGaslessStep(step) {
14
+ return step.estimate?.feeCosts?.some((feeCost) => feeCost.name === "LIFI Gasless Relay Fee") ?? false;
15
+ }
16
+ export { GASLESS_RELAY_FEE_NAME, isGaslessStep };
17
+
18
+ //# sourceMappingURL=isGaslessStep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isGaslessStep.js","names":[],"sources":["../../../src/utils/isGaslessStep.ts"],"sourcesContent":["import type { LiFiStep } from '@lifi/types'\n\n/**\n * The `feeCosts` name of the gasless relay fee. The backend marks every\n * gasless step with it and guarantees that the name does not change.\n */\nexport const GASLESS_RELAY_FEE_NAME = 'LIFI Gasless Relay Fee'\n\n/**\n * Whether the step executes gasless: the user signs typed data and the LI.FI\n * relayer submits it and pays the gas. The relay fee is the only marker that\n * exists already at routes time, before `/advanced/stepTransaction` adds the\n * typed data.\n */\nexport function isGaslessStep(step: Pick<LiFiStep, 'estimate'>): boolean {\n return (\n step.estimate?.feeCosts?.some(\n (feeCost) => feeCost.name === GASLESS_RELAY_FEE_NAME\n ) ?? false\n )\n}\n"],"mappings":";;;;;AAMA,MAAa,yBAAyB;;;;;;;AAQtC,SAAgB,cAAc,MAA2C;CACvE,OACE,KAAK,UAAU,UAAU,MACtB,YAAY,QAAQ,SAAA,wBACvB,KAAK;AAET"}
@@ -1,3 +1,3 @@
1
1
  export declare const name = "@lifi/sdk";
2
- export declare const version = "0.0.0-preview-9b9526be";
2
+ export declare const version = "0.0.0-preview-e8c80bc4";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1,6 +1,6 @@
1
1
  // src/version.ts
2
2
  const name = "@lifi/sdk";
3
- const version = "0.0.0-preview-9b9526be";
3
+ const version = "0.0.0-preview-e8c80bc4";
4
4
  export { name, version };
5
5
 
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '0.0.0-preview-9b9526be'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
1
+ {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '0.0.0-preview-e8c80bc4'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/sdk",
3
- "version": "0.0.0-preview-9b9526be",
3
+ "version": "0.0.0-preview-e8c80bc4",
4
4
  "description": "LI.FI SDK for Any-to-Any Cross-Chain-Swap",
5
5
  "homepage": "https://github.com/lifinance/sdk",
6
6
  "bugs": {
@@ -1,86 +1,36 @@
1
- import type {
2
- LiFiStep,
3
- RelayerQuoteResponse,
4
- RequestOptions,
5
- } from '@lifi/types'
1
+ import type { LiFiStep, RequestOptions } from '@lifi/types'
6
2
  import { BaseError } from '../errors/baseError.js'
7
- import { ErrorName } from '../errors/constants.js'
8
- import { ValidationError } from '../errors/errors.js'
3
+ import { ErrorName, LiFiErrorCode } from '../errors/constants.js'
9
4
  import { SDKError } from '../errors/SDKError.js'
10
- import type { QuoteRequest, QuoteRequestFromAmount } from '../types/actions.js'
5
+ import type { QuoteRequestFromAmount } from '../types/actions.js'
11
6
  import type { SDKClient } from '../types/core.js'
12
- import { request } from '../utils/request.js'
13
7
 
14
8
  /**
15
- * Get a relayer quote for a token transfer
16
- * @param client - The SDK client
17
- * @param params - The configuration of the requested quote
18
- * @param options - Request options
19
- * @throws {LiFiError} - Throws a LiFiError if request fails
20
- * @returns Relayer quote for a token transfer
9
+ * Get a relayer quote for a token transfer. The legacy gasless relayer service
10
+ * behind it is shut down, so this always rejects and sends no request.
11
+ *
12
+ * Kept only so that published consumers that still import it keep building.
13
+ * It stays `async`: callers such as `getRelayerQuote(...).catch(() => null)`
14
+ * need a rejected promise, not a synchronous throw.
15
+ * @param _client - The SDK client
16
+ * @param _params - The configuration of the requested quote
17
+ * @param _options - Request options
18
+ * @throws {SDKError} - Always, with a `NotFound` cause.
19
+ * @returns Never resolves with a quote.
20
+ * @deprecated The legacy gasless relayer service is shut down. Request
21
+ * gasless routes with `options.gasless: true` on `getRoutes`, or
22
+ * `gasless: true` on `getQuote`, and detect them with `isGaslessStep`.
21
23
  */
22
24
  export const getRelayerQuote = async (
23
- client: SDKClient,
24
- params: QuoteRequestFromAmount,
25
- options?: RequestOptions
25
+ _client: SDKClient,
26
+ _params: QuoteRequestFromAmount,
27
+ _options?: RequestOptions
26
28
  ): Promise<LiFiStep> => {
27
- const requiredParameters: Array<keyof QuoteRequestFromAmount> = [
28
- 'fromChain',
29
- 'fromToken',
30
- 'fromAddress',
31
- 'fromAmount',
32
- 'toChain',
33
- 'toToken',
34
- ]
35
- for (const requiredParameter of requiredParameters) {
36
- if (!params[requiredParameter]) {
37
- throw new SDKError(
38
- new ValidationError(
39
- `Required parameter "${requiredParameter}" is missing.`
40
- )
41
- )
42
- }
43
- }
44
-
45
- // apply defaults
46
- params.integrator ??= client.config.integrator
47
- params.order ??= client.config.routeOptions?.order
48
- params.slippage ??= client.config.routeOptions?.slippage
49
- params.referrer ??= client.config.routeOptions?.referrer
50
- params.fee ??= client.config.routeOptions?.fee
51
- params.allowBridges ??= client.config.routeOptions?.bridges?.allow
52
- params.denyBridges ??= client.config.routeOptions?.bridges?.deny
53
- params.preferBridges ??= client.config.routeOptions?.bridges?.prefer
54
- params.allowExchanges ??= client.config.routeOptions?.exchanges?.allow
55
- params.denyExchanges ??= client.config.routeOptions?.exchanges?.deny
56
- params.preferExchanges ??= client.config.routeOptions?.exchanges?.prefer
57
-
58
- for (const key of Object.keys(params)) {
59
- if (
60
- params[key as keyof QuoteRequest] === undefined ||
61
- params[key as keyof QuoteRequest] === null
62
- ) {
63
- delete params[key as keyof QuoteRequest]
64
- }
65
- }
66
-
67
- const result = await request<RelayerQuoteResponse>(
68
- client.config,
69
- `${client.config.apiUrl}/relayer/quote?${new URLSearchParams(
70
- params as unknown as Record<string, string>
71
- )}`,
72
- {
73
- signal: options?.signal,
74
- }
75
- )
76
-
77
- if (result.status === 'error') {
78
- throw new BaseError(
79
- ErrorName.ServerError,
80
- result.data.code,
81
- result.data.message
29
+ throw new SDKError(
30
+ new BaseError(
31
+ ErrorName.NotFoundError,
32
+ LiFiErrorCode.NotFound,
33
+ 'The legacy gasless relayer service is shut down. Request gasless routes with `options.gasless: true` on `getRoutes`.'
82
34
  )
83
- }
84
-
85
- return result.data
35
+ )
86
36
  }
@@ -143,6 +143,8 @@ export type Actions = {
143
143
  * @param params - The configuration of the requested relayer quote
144
144
  * @param options - Request options
145
145
  * @returns Quote from a relayer
146
+ * @deprecated The legacy gasless relayer service is shut down. Use
147
+ * `getRoutes` with `options.gasless: true`.
146
148
  */
147
149
  getRelayerQuote: (
148
150
  params: QuoteRequestFromAmount,
@@ -36,17 +36,9 @@ export const relayTransaction = async (
36
36
  }
37
37
  }
38
38
 
39
- // Determine if the request is for a gasless relayer service or advanced relayer service
40
- // We will use the same endpoint for both after the gasless relayer service is deprecated
41
- const relayerPath = params.typedData.some(
42
- (t) => t.primaryType === 'PermitWitnessTransferFrom'
43
- )
44
- ? '/relayer/relay'
45
- : '/advanced/relay'
46
-
47
39
  const result = await request<RelayResponse>(
48
40
  client.config,
49
- `${client.config.apiUrl}${relayerPath}`,
41
+ `${client.config.apiUrl}/advanced/relay`,
50
42
  {
51
43
  method: 'POST',
52
44
  headers: {
package/src/index.ts CHANGED
@@ -135,6 +135,7 @@ export { checkPackageUpdates } from './utils/checkPackageUpdates.js'
135
135
  export { convertQuoteToRoute } from './utils/convertQuoteToRoute.js'
136
136
  export { fetchTxErrorDetails } from './utils/fetchTxErrorDetails.js'
137
137
  export { formatUnits } from './utils/formatUnits.js'
138
+ export { GASLESS_RELAY_FEE_NAME, isGaslessStep } from './utils/isGaslessStep.js'
138
139
  export { isHex } from './utils/isHex.js'
139
140
  export { LruMap } from './utils/lru.js'
140
141
  export { parseUnits } from './utils/parseUnits.js'
@@ -0,0 +1,21 @@
1
+ import type { LiFiStep } from '@lifi/types'
2
+
3
+ /**
4
+ * The `feeCosts` name of the gasless relay fee. The backend marks every
5
+ * gasless step with it and guarantees that the name does not change.
6
+ */
7
+ export const GASLESS_RELAY_FEE_NAME = 'LIFI Gasless Relay Fee'
8
+
9
+ /**
10
+ * Whether the step executes gasless: the user signs typed data and the LI.FI
11
+ * relayer submits it and pays the gas. The relay fee is the only marker that
12
+ * exists already at routes time, before `/advanced/stepTransaction` adds the
13
+ * typed data.
14
+ */
15
+ export function isGaslessStep(step: Pick<LiFiStep, 'estimate'>): boolean {
16
+ return (
17
+ step.estimate?.feeCosts?.some(
18
+ (feeCost) => feeCost.name === GASLESS_RELAY_FEE_NAME
19
+ ) ?? false
20
+ )
21
+ }
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk'
2
- export const version = '0.0.0-preview-9b9526be'
2
+ export const version = '0.0.0-preview-e8c80bc4'