@lifi/sdk 4.2.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/actions/getTokenBalancesByChain.js.map +1 -1
  3. package/dist/cjs/actions/index.d.ts +1 -8
  4. package/dist/cjs/actions/index.js +0 -2
  5. package/dist/cjs/actions/index.js.map +1 -1
  6. package/dist/cjs/core/execution.js.map +1 -1
  7. package/dist/cjs/index.d.ts +1 -2
  8. package/dist/cjs/index.js +0 -2
  9. package/dist/cjs/utils/checkPackageUpdates.js +1 -1
  10. package/dist/cjs/version.d.ts +1 -1
  11. package/dist/cjs/version.js +1 -1
  12. package/dist/cjs/version.js.map +1 -1
  13. package/dist/esm/actions/getTokenBalancesByChain.d.ts.map +1 -1
  14. package/dist/esm/actions/getTokenBalancesByChain.js.map +1 -1
  15. package/dist/esm/actions/index.d.ts +1 -8
  16. package/dist/esm/actions/index.d.ts.map +1 -1
  17. package/dist/esm/actions/index.js +0 -2
  18. package/dist/esm/actions/index.js.map +1 -1
  19. package/dist/esm/core/execution.js.map +1 -1
  20. package/dist/esm/index.d.ts +1 -2
  21. package/dist/esm/index.js +1 -2
  22. package/dist/esm/utils/checkPackageUpdates.js +1 -1
  23. package/dist/esm/version.d.ts +1 -1
  24. package/dist/esm/version.js +1 -1
  25. package/dist/esm/version.js.map +1 -1
  26. package/package.json +2 -2
  27. package/src/actions/index.ts +0 -15
  28. package/src/index.ts +0 -1
  29. package/src/version.ts +1 -1
  30. package/dist/cjs/actions/getWalletBalances.d.ts +0 -15
  31. package/dist/cjs/actions/getWalletBalances.js +0 -20
  32. package/dist/cjs/actions/getWalletBalances.js.map +0 -1
  33. package/dist/esm/actions/getWalletBalances.d.ts +0 -15
  34. package/dist/esm/actions/getWalletBalances.d.ts.map +0 -1
  35. package/dist/esm/actions/getWalletBalances.js +0 -19
  36. package/dist/esm/actions/getWalletBalances.js.map +0 -1
  37. package/src/actions/getWalletBalances.ts +0 -36
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @lifi/sdk
2
2
 
3
+ ## 4.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#431](https://github.com/lifinance/sdk/pull/431) [`08b54da`](https://github.com/lifinance/sdk/commit/08b54dadebef063bc20af06630f0e43ec5850dca) Thanks [@chybisov](https://github.com/chybisov)! - Remove the `getWalletBalances` action and client method — the underlying `/wallets/{address}/balances` API endpoint is deprecated. Use `getTokenBalances`/`getTokenBalancesByChain` to fetch balances directly from RPCs instead.
8
+
9
+ ### Patch Changes
10
+
11
+ - [#435](https://github.com/lifinance/sdk/pull/435) [`d8b7adb`](https://github.com/lifinance/sdk/commit/d8b7adb6f797734f25d8c7d458121752a2567998) Thanks [@chybisov](https://github.com/chybisov)! - Bump runtime dependencies: @lifi/types to 17.86.0 (sdk), viem to 2.55.8 (ethereum), and @mysten/sui to 2.22.1 (sui).
12
+
3
13
  ## 4.2.0
4
14
 
5
15
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"getTokenBalancesByChain.js","names":["ValidationError","isToken"],"sources":["../../../src/actions/getTokenBalancesByChain.ts"],"sourcesContent":["import type {\n Token,\n TokenAmount,\n TokenAmountExtended,\n TokenExtended,\n} from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport type { SDKClient } from '../types/core.js'\nimport { isToken } from '../utils/isToken.js'\n\n/**\n * This method queries the balances of tokens for a specific list of chains for a given wallet.\n * @param client - The SDK client.\n * @param walletAddress - A wallet address.\n * @param tokensByChain - A list of token objects organized by chain ids.\n * @returns A list of objects containing the tokens and the amounts on different chains organized by the chosen chains.\n * @throws {ValidationError} Throws a ValidationError if validation fails.\n * @throws {Error} Throws an Error if the SDK Provider for the wallet address is not found.\n */\nexport async function getTokenBalancesByChain(\n client: SDKClient,\n walletAddress: string,\n tokensByChain: { [chainId: number]: Token[] }\n): Promise<{ [chainId: number]: TokenAmount[] }>\nexport async function getTokenBalancesByChain(\n client: SDKClient,\n walletAddress: string,\n tokensByChain: { [chainId: number]: TokenExtended[] }\n): Promise<{ [chainId: number]: TokenAmountExtended[] }> {\n if (!walletAddress) {\n throw new ValidationError('Missing walletAddress.')\n }\n\n const tokenList = Object.values(tokensByChain).flat()\n const invalidTokens = tokenList.filter((token) => !isToken(token))\n if (invalidTokens.length) {\n throw new ValidationError('Invalid tokens passed.')\n }\n\n const provider = client.providers.find((provider) =>\n provider.isAddress(walletAddress)\n )\n if (!provider) {\n throw new Error(`SDK Token Provider for ${walletAddress} is not found.`)\n }\n\n const tokenAmountsByChain: {\n [chainId: number]: TokenAmount[] | TokenAmountExtended[]\n } = {}\n const tokenAmountsSettled = await Promise.allSettled(\n Object.keys(tokensByChain).map(async (chainIdStr) => {\n const chainId = Number.parseInt(chainIdStr, 10)\n const chain = await client.getChainById(chainId)\n if (provider.type === chain.chainType) {\n const tokenAmounts = await provider.getBalance(\n client,\n walletAddress,\n tokensByChain[chainId]\n )\n tokenAmountsByChain[chainId] = tokenAmounts\n } else {\n // if the provider is not the same as the chain type,\n // return the tokens as is\n tokenAmountsByChain[chainId] = tokensByChain[chainId]\n }\n })\n )\n if (client.config.debug) {\n for (const result of tokenAmountsSettled) {\n if (result.status === 'rejected') {\n console.warn(\"Couldn't fetch token balance.\", result.reason)\n }\n }\n }\n return tokenAmountsByChain\n}\n"],"mappings":";;;;AAwBA,eAAsB,wBACpB,QACA,eACA,eACuD;CACvD,IAAI,CAAC,eACH,MAAM,IAAIA,sBAAAA,gBAAgB,wBAAwB;CAKpD,IAFkB,OAAO,OAAO,aAAa,CAAC,CAAC,KACjB,CAAC,CAAC,QAAQ,UAAU,CAACC,sBAAAA,QAAQ,KAAK,CAChD,CAAC,CAAC,QAChB,MAAM,IAAID,sBAAAA,gBAAgB,wBAAwB;CAGpD,MAAM,WAAW,OAAO,UAAU,MAAM,aACtC,SAAS,UAAU,aAAa,CAClC;CACA,IAAI,CAAC,UACH,MAAM,IAAI,MAAM,0BAA0B,cAAc,eAAe;CAGzE,MAAM,sBAEF,CAAC;CACL,MAAM,sBAAsB,MAAM,QAAQ,WACxC,OAAO,KAAK,aAAa,CAAC,CAAC,IAAI,OAAO,eAAe;EACnD,MAAM,UAAU,OAAO,SAAS,YAAY,EAAE;EAC9C,MAAM,QAAQ,MAAM,OAAO,aAAa,OAAO;EAC/C,IAAI,SAAS,SAAS,MAAM,WAAW;GACrC,MAAM,eAAe,MAAM,SAAS,WAClC,QACA,eACA,cAAc,QAChB;GACA,oBAAoB,WAAW;EACjC,OAGE,oBAAoB,WAAW,cAAc;CAEjD,CAAC,CACH;CACA,IAAI,OAAO,OAAO;OACX,MAAM,UAAU,qBACnB,IAAI,OAAO,WAAW,YACpB,QAAQ,KAAK,iCAAiC,OAAO,MAAM;CAAA;CAIjE,OAAO;AACT"}
1
+ {"version":3,"file":"getTokenBalancesByChain.js","names":["ValidationError","isToken"],"sources":["../../../src/actions/getTokenBalancesByChain.ts"],"sourcesContent":["import type {\n Token,\n TokenAmount,\n TokenAmountExtended,\n TokenExtended,\n} from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport type { SDKClient } from '../types/core.js'\nimport { isToken } from '../utils/isToken.js'\n\n/**\n * This method queries the balances of tokens for a specific list of chains for a given wallet.\n * @param client - The SDK client.\n * @param walletAddress - A wallet address.\n * @param tokensByChain - A list of token objects organized by chain ids.\n * @returns A list of objects containing the tokens and the amounts on different chains organized by the chosen chains.\n * @throws {ValidationError} Throws a ValidationError if validation fails.\n * @throws {Error} Throws an Error if the SDK Provider for the wallet address is not found.\n */\nexport async function getTokenBalancesByChain(\n client: SDKClient,\n walletAddress: string,\n tokensByChain: { [chainId: number]: Token[] }\n): Promise<{ [chainId: number]: TokenAmount[] }>\nexport async function getTokenBalancesByChain(\n client: SDKClient,\n walletAddress: string,\n tokensByChain: { [chainId: number]: TokenExtended[] }\n): Promise<{ [chainId: number]: TokenAmountExtended[] }> {\n if (!walletAddress) {\n throw new ValidationError('Missing walletAddress.')\n }\n\n const tokenList = Object.values(tokensByChain).flat()\n const invalidTokens = tokenList.filter((token) => !isToken(token))\n if (invalidTokens.length) {\n throw new ValidationError('Invalid tokens passed.')\n }\n\n const provider = client.providers.find((provider) =>\n provider.isAddress(walletAddress)\n )\n if (!provider) {\n throw new Error(`SDK Token Provider for ${walletAddress} is not found.`)\n }\n\n const tokenAmountsByChain: {\n [chainId: number]: TokenAmount[] | TokenAmountExtended[]\n } = {}\n const tokenAmountsSettled = await Promise.allSettled(\n Object.keys(tokensByChain).map(async (chainIdStr) => {\n const chainId = Number.parseInt(chainIdStr, 10)\n const chain = await client.getChainById(chainId)\n if (provider.type === chain.chainType) {\n const tokenAmounts = await provider.getBalance(\n client,\n walletAddress,\n tokensByChain[chainId]\n )\n tokenAmountsByChain[chainId] = tokenAmounts\n } else {\n // if the provider is not the same as the chain type,\n // return the tokens as is\n tokenAmountsByChain[chainId] = tokensByChain[chainId]\n }\n })\n )\n if (client.config.debug) {\n for (const result of tokenAmountsSettled) {\n if (result.status === 'rejected') {\n console.warn(\"Couldn't fetch token balance.\", result.reason)\n }\n }\n }\n return tokenAmountsByChain\n}\n"],"mappings":";;;;AAwBA,eAAsB,wBACpB,QACA,eACA,eACuD;CACvD,IAAI,CAAC,eACH,MAAM,IAAIA,sBAAAA,gBAAgB,wBAAwB;CAKpD,IAFkB,OAAO,OAAO,aAAa,CAAC,CAAC,KACjB,CAAC,CAAC,QAAQ,UAAU,CAACC,sBAAAA,QAAQ,KAAK,CAChD,CAAC,CAAC,QAChB,MAAM,IAAID,sBAAAA,gBAAgB,wBAAwB;CAGpD,MAAM,WAAW,OAAO,UAAU,MAAM,aACtC,SAAS,UAAU,aAAa,CAClC;CACA,IAAI,CAAC,UACH,MAAM,IAAI,MAAM,0BAA0B,cAAc,eAAe;CAGzE,MAAM,sBAEF,CAAC;CACL,MAAM,sBAAsB,MAAM,QAAQ,WACxC,OAAO,KAAK,aAAa,CAAC,CAAC,IAAI,OAAO,eAAe;EACnD,MAAM,UAAU,OAAO,SAAS,YAAY,EAAE;EAC9C,MAAM,QAAQ,MAAM,OAAO,aAAa,OAAO;EAC/C,IAAI,SAAS,SAAS,MAAM,WAAW;GACrC,MAAM,eAAe,MAAM,SAAS,WAClC,QACA,eACA,cAAc,QAChB;GACA,oBAAoB,WAAW;EACjC,OAGE,oBAAoB,WAAW,cAAc;CAEjD,CAAC,CACH;CACA,IAAI,OAAO,OAAO,OACX;OAAA,MAAM,UAAU,qBACnB,IAAI,OAAO,WAAW,YACpB,QAAQ,KAAK,iCAAiC,OAAO,MAAM;CAAA;CAIjE,OAAO;AACT"}
@@ -2,7 +2,7 @@ import { SDKClient } from "../types/core.js";
2
2
  import { GetStatusRequestExtended, LiFiStepRequest, QuoteRequestFromAmount, RoutesRequest as RoutesRequest$1 } from "../types/actions.js";
3
3
  import { getQuote } from "./getQuote.js";
4
4
  import { PatchContractCallsResponse } from "./patchContractCalls.js";
5
- import { ChainId, ChainKey, ChainType, ChainsRequest, ConnectionsRequest, ConnectionsResponse, ContractCallsQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, LiFiStep, PatchCallDataRequest, RelayRequest, RelayResponseData, RelayStatusRequest, RelayStatusResponseData, RequestOptions, RoutesResponse, StatusResponse, Token, TokenAmount, TokenExtended, TokensExtendedResponse, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse, TransactionAnalyticsRequest, TransactionAnalyticsResponse, WalletTokenExtended } from "@lifi/types";
5
+ import { ChainId, ChainKey, ChainType, ChainsRequest, ConnectionsRequest, ConnectionsResponse, ContractCallsQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, LiFiStep, PatchCallDataRequest, RelayRequest, RelayResponseData, RelayStatusRequest, RelayStatusResponseData, RequestOptions, RoutesResponse, StatusResponse, Token, TokenAmount, TokenExtended, TokensExtendedResponse, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse, TransactionAnalyticsRequest, TransactionAnalyticsResponse } from "@lifi/types";
6
6
  //#region src/actions/index.d.ts
7
7
  type Actions = {
8
8
  /**
@@ -146,13 +146,6 @@ type Actions = {
146
146
  * @returns Transaction history
147
147
  */
148
148
  getTransactionHistory: (params: TransactionAnalyticsRequest, options?: RequestOptions) => Promise<TransactionAnalyticsResponse>;
149
- /**
150
- * Get wallet balances
151
- * @param params - The configuration of the requested wallet balances
152
- * @param options - Request options
153
- * @returns Wallet balances
154
- */
155
- getWalletBalances: (walletAddress: string, options?: RequestOptions) => Promise<Record<number, WalletTokenExtended[]>>;
156
149
  /**
157
150
  * Relay a transaction through the relayer service
158
151
  * @param params - The configuration for the relay request
@@ -17,7 +17,6 @@ const require_actions_getTokenBalance = require("./getTokenBalance.js");
17
17
  const require_actions_getTokens = require("./getTokens.js");
18
18
  const require_actions_getTools = require("./getTools.js");
19
19
  const require_actions_getTransactionHistory = require("./getTransactionHistory.js");
20
- const require_actions_getWalletBalances = require("./getWalletBalances.js");
21
20
  const require_actions_patchContractCalls = require("./patchContractCalls.js");
22
21
  const require_actions_relayTransaction = require("./relayTransaction.js");
23
22
  //#region src/actions/index.ts
@@ -41,7 +40,6 @@ function actions(client) {
41
40
  getTokenBalances: (walletAddress, tokens) => require_actions_getTokenBalances.getTokenBalances(client, walletAddress, tokens),
42
41
  getTokenBalancesByChain: (walletAddress, tokensByChain) => require_actions_getTokenBalancesByChain.getTokenBalancesByChain(client, walletAddress, tokensByChain),
43
42
  getTransactionHistory: (params, options) => require_actions_getTransactionHistory.getTransactionHistory(client, params, options),
44
- getWalletBalances: (walletAddress, options) => require_actions_getWalletBalances.getWalletBalances(client, walletAddress, options),
45
43
  relayTransaction: (params, options) => require_actions_relayTransaction.relayTransaction(client, params, options),
46
44
  patchContractCalls: (params, options) => require_actions_patchContractCalls.patchContractCalls(client, params, options)
47
45
  };
@@ -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","getWalletBalances","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 WalletTokenExtended,\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 { getWalletBalances } from './getWalletBalances.js'\nimport {\n type PatchContractCallsResponse,\n patchContractCalls,\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 * Get wallet balances\n * @param params - The configuration of the requested wallet balances\n * @param options - Request options\n * @returns Wallet balances\n */\n getWalletBalances: (\n walletAddress: string,\n options?: RequestOptions\n ) => Promise<Record<number, WalletTokenExtended[]>>\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 getWalletBalances: (walletAddress, options) =>\n getWalletBalances(client, walletAddress, options),\n relayTransaction: (params, options) =>\n relayTransaction(client, params, options),\n patchContractCalls: (params, options) =>\n patchContractCalls(client, params, options),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsTA,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,oBAAoB,eAAe,YACjCC,kCAAAA,kBAAkB,QAAQ,eAAe,OAAO;EAClD,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 type PatchContractCallsResponse,\n patchContractCalls,\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;EAC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AAQ,OAAO;CAC9C;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"execution.js","names":["executionState","ProviderError","ExecuteStepRetryError"],"sources":["../../../src/core/execution.ts"],"sourcesContent":["import type { Route } from '@lifi/types'\nimport { LiFiErrorCode } from '../errors/constants.js'\nimport { ExecuteStepRetryError, ProviderError } from '../errors/errors.js'\nimport type {\n ExecutionOptions,\n LiFiStepExtended,\n RouteExtended,\n SDKClient,\n SDKProvider,\n} from '../types/core.js'\nimport { executionState } from './executionState.js'\nimport { prepareRestart } from './prepareRestart.js'\n\n/**\n * Execute a route.\n * @param client - The SDK client.\n * @param route - The route that should be executed. Cannot be an active route.\n * @param executionOptions - An object containing settings and callbacks.\n * @returns The executed route.\n * @throws {LiFiError} Throws a LiFiError if the execution fails.\n */\nexport const executeRoute = async (\n client: SDKClient,\n route: Route,\n executionOptions?: ExecutionOptions\n): Promise<RouteExtended> => {\n // Deep clone to prevent side effects\n const clonedRoute = structuredClone<Route>(route)\n\n let executionPromise = executionState.get(clonedRoute.id)?.promise\n // Check if route is already running\n if (executionPromise) {\n return executionPromise\n }\n\n executionState.create({ route: clonedRoute, executionOptions })\n executionPromise = executeSteps(client, clonedRoute)\n executionState.update({\n route: clonedRoute,\n promise: executionPromise,\n })\n\n return executionPromise\n}\n\n/**\n * Resume the execution of a route that has been stopped or had an error while executing.\n * @param client - The SDK client.\n * @param route - The route that is to be executed. Cannot be an active route.\n * @param executionOptions - An object containing settings and callbacks.\n * @returns The executed route.\n * @throws {LiFiError} Throws a LiFiError if the execution fails.\n */\nexport const resumeRoute = async (\n client: SDKClient,\n route: Route,\n executionOptions?: ExecutionOptions\n): Promise<RouteExtended> => {\n const execution = executionState.get(route.id)\n\n if (execution) {\n const executionHalted = execution.executors.some(\n (executor) => !executor.allowExecution\n )\n if (!executionHalted) {\n // Check if we want to resume route execution in the background\n updateRouteExecution(route, {\n executeInBackground: executionOptions?.executeInBackground,\n })\n if (!execution.promise) {\n // We should never reach this point if we do clean-up properly\n throw new Error('Route execution promise not found.')\n }\n return execution.promise\n }\n }\n\n prepareRestart(route)\n\n return executeRoute(client, route, executionOptions)\n}\n\nconst executeSteps = async (\n client: SDKClient,\n route: RouteExtended\n): Promise<RouteExtended> => {\n // Loop over steps and execute them\n for (let index = 0; index < route.steps.length; index++) {\n const execution = executionState.get(route.id)\n // Check if execution has stopped in the meantime\n if (!execution) {\n break\n }\n\n const step = route.steps[index]\n const previousStep = route.steps[index - 1]\n // Check if the step is already done\n if (step.execution?.status === 'DONE') {\n continue\n }\n\n // Update step fromAmount using output of the previous step execution. In the future this should be handled by calling `updateRoute`\n if (previousStep?.execution?.toAmount) {\n step.action.fromAmount = previousStep.execution.toAmount\n if (step.includedSteps?.length) {\n step.includedSteps[0].action.fromAmount =\n previousStep.execution.toAmount\n }\n }\n\n try {\n const fromAddress = step.action.fromAddress\n if (!fromAddress) {\n throw new Error('Action fromAddress is not specified.')\n }\n\n const provider = client.providers.find((provider: SDKProvider) =>\n provider.isAddress(fromAddress)\n )\n\n if (!provider) {\n throw new ProviderError(\n LiFiErrorCode.ProviderUnavailable,\n 'SDK Execution Provider not found.'\n )\n }\n\n const stepExecutor = await provider.getStepExecutor({\n routeId: route.id,\n executionOptions: execution.executionOptions,\n })\n execution.executors.push(stepExecutor)\n\n // Check if we want to execute this step in the background\n if (execution.executionOptions) {\n updateRouteExecution(route, execution.executionOptions)\n }\n\n let executedStep: LiFiStepExtended\n try {\n executedStep = await stepExecutor.executeStep(client, step)\n } catch (e) {\n if (e instanceof ExecuteStepRetryError) {\n step.execution = undefined\n executedStep = await stepExecutor.executeStep(\n client,\n step,\n e.retryParams\n )\n } else {\n throw e\n }\n }\n\n // We may reach this point if user interaction isn't allowed. We want to stop execution until we resume it\n if (executedStep.execution?.status !== 'DONE') {\n stopRouteExecution(route)\n }\n\n // Execution stopped during the current step, we don't want to continue to the next step so we return already\n if (!stepExecutor.allowExecution) {\n return route\n }\n } catch (e) {\n stopRouteExecution(route)\n throw e\n }\n }\n\n // Clean up after the execution\n executionState.delete(route.id)\n return route\n}\n\n/**\n * Updates route execution to background or foreground state.\n * @param route - A route that is currently in execution.\n * @param options - An object with execution settings.\n */\nexport const updateRouteExecution = (\n route: Route,\n options: ExecutionOptions\n): void => {\n const execution = executionState.get(route.id)\n if (!execution) {\n return\n }\n\n if ('executeInBackground' in options) {\n for (const executor of execution.executors) {\n executor.setInteraction({\n allowInteraction: !options?.executeInBackground,\n allowUpdates: true,\n })\n }\n }\n // Update active route settings so we know what the current state of execution is\n execution.executionOptions = {\n ...execution.executionOptions,\n ...options,\n }\n}\n\n/**\n * Stops the execution of an active route.\n * @param route - A route that is currently in execution.\n * @returns The stopped route.\n */\nexport const stopRouteExecution = (route: Route): Route => {\n const execution = executionState.get(route.id)\n if (!execution) {\n return route\n }\n\n for (const executor of execution.executors) {\n executor.setInteraction({\n allowInteraction: false,\n allowUpdates: false,\n allowExecution: false,\n })\n }\n executionState.delete(route.id)\n return execution.route\n}\n\n/**\n * Get the list of active routes.\n * @returns A list of routes.\n */\nexport const getActiveRoutes = (): RouteExtended[] => {\n return Object.values(executionState.state)\n .map((dict) => dict?.route)\n .filter(Boolean) as RouteExtended[]\n}\n\n/**\n * Return the current route information for given route. The route has to be active.\n * @param routeId - A route id.\n * @returns The updated route.\n */\nexport const getActiveRoute = (routeId: string): RouteExtended | undefined => {\n return executionState.get(routeId)?.route\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,MAAa,eAAe,OAC1B,QACA,OACA,qBAC2B;CAE3B,MAAM,cAAc,gBAAuB,KAAK;CAEhD,IAAI,mBAAmBA,4BAAAA,eAAe,IAAI,YAAY,EAAE,CAAC,EAAE;CAE3D,IAAI,kBACF,OAAO;CAGT,4BAAA,eAAe,OAAO;EAAE,OAAO;EAAa;CAAiB,CAAC;CAC9D,mBAAmB,aAAa,QAAQ,WAAW;CACnD,4BAAA,eAAe,OAAO;EACpB,OAAO;EACP,SAAS;CACX,CAAC;CAED,OAAO;AACT;;;;;;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names":["executionState","ProviderError","ExecuteStepRetryError"],"sources":["../../../src/core/execution.ts"],"sourcesContent":["import type { Route } from '@lifi/types'\nimport { LiFiErrorCode } from '../errors/constants.js'\nimport { ExecuteStepRetryError, ProviderError } from '../errors/errors.js'\nimport type {\n ExecutionOptions,\n LiFiStepExtended,\n RouteExtended,\n SDKClient,\n SDKProvider,\n} from '../types/core.js'\nimport { executionState } from './executionState.js'\nimport { prepareRestart } from './prepareRestart.js'\n\n/**\n * Execute a route.\n * @param client - The SDK client.\n * @param route - The route that should be executed. Cannot be an active route.\n * @param executionOptions - An object containing settings and callbacks.\n * @returns The executed route.\n * @throws {LiFiError} Throws a LiFiError if the execution fails.\n */\nexport const executeRoute = async (\n client: SDKClient,\n route: Route,\n executionOptions?: ExecutionOptions\n): Promise<RouteExtended> => {\n // Deep clone to prevent side effects\n const clonedRoute = structuredClone<Route>(route)\n\n let executionPromise = executionState.get(clonedRoute.id)?.promise\n // Check if route is already running\n if (executionPromise) {\n return executionPromise\n }\n\n executionState.create({ route: clonedRoute, executionOptions })\n executionPromise = executeSteps(client, clonedRoute)\n executionState.update({\n route: clonedRoute,\n promise: executionPromise,\n })\n\n return executionPromise\n}\n\n/**\n * Resume the execution of a route that has been stopped or had an error while executing.\n * @param client - The SDK client.\n * @param route - The route that is to be executed. Cannot be an active route.\n * @param executionOptions - An object containing settings and callbacks.\n * @returns The executed route.\n * @throws {LiFiError} Throws a LiFiError if the execution fails.\n */\nexport const resumeRoute = async (\n client: SDKClient,\n route: Route,\n executionOptions?: ExecutionOptions\n): Promise<RouteExtended> => {\n const execution = executionState.get(route.id)\n\n if (execution) {\n const executionHalted = execution.executors.some(\n (executor) => !executor.allowExecution\n )\n if (!executionHalted) {\n // Check if we want to resume route execution in the background\n updateRouteExecution(route, {\n executeInBackground: executionOptions?.executeInBackground,\n })\n if (!execution.promise) {\n // We should never reach this point if we do clean-up properly\n throw new Error('Route execution promise not found.')\n }\n return execution.promise\n }\n }\n\n prepareRestart(route)\n\n return executeRoute(client, route, executionOptions)\n}\n\nconst executeSteps = async (\n client: SDKClient,\n route: RouteExtended\n): Promise<RouteExtended> => {\n // Loop over steps and execute them\n for (let index = 0; index < route.steps.length; index++) {\n const execution = executionState.get(route.id)\n // Check if execution has stopped in the meantime\n if (!execution) {\n break\n }\n\n const step = route.steps[index]\n const previousStep = route.steps[index - 1]\n // Check if the step is already done\n if (step.execution?.status === 'DONE') {\n continue\n }\n\n // Update step fromAmount using output of the previous step execution. In the future this should be handled by calling `updateRoute`\n if (previousStep?.execution?.toAmount) {\n step.action.fromAmount = previousStep.execution.toAmount\n if (step.includedSteps?.length) {\n step.includedSteps[0].action.fromAmount =\n previousStep.execution.toAmount\n }\n }\n\n try {\n const fromAddress = step.action.fromAddress\n if (!fromAddress) {\n throw new Error('Action fromAddress is not specified.')\n }\n\n const provider = client.providers.find((provider: SDKProvider) =>\n provider.isAddress(fromAddress)\n )\n\n if (!provider) {\n throw new ProviderError(\n LiFiErrorCode.ProviderUnavailable,\n 'SDK Execution Provider not found.'\n )\n }\n\n const stepExecutor = await provider.getStepExecutor({\n routeId: route.id,\n executionOptions: execution.executionOptions,\n })\n execution.executors.push(stepExecutor)\n\n // Check if we want to execute this step in the background\n if (execution.executionOptions) {\n updateRouteExecution(route, execution.executionOptions)\n }\n\n let executedStep: LiFiStepExtended\n try {\n executedStep = await stepExecutor.executeStep(client, step)\n } catch (e) {\n if (e instanceof ExecuteStepRetryError) {\n step.execution = undefined\n executedStep = await stepExecutor.executeStep(\n client,\n step,\n e.retryParams\n )\n } else {\n throw e\n }\n }\n\n // We may reach this point if user interaction isn't allowed. We want to stop execution until we resume it\n if (executedStep.execution?.status !== 'DONE') {\n stopRouteExecution(route)\n }\n\n // Execution stopped during the current step, we don't want to continue to the next step so we return already\n if (!stepExecutor.allowExecution) {\n return route\n }\n } catch (e) {\n stopRouteExecution(route)\n throw e\n }\n }\n\n // Clean up after the execution\n executionState.delete(route.id)\n return route\n}\n\n/**\n * Updates route execution to background or foreground state.\n * @param route - A route that is currently in execution.\n * @param options - An object with execution settings.\n */\nexport const updateRouteExecution = (\n route: Route,\n options: ExecutionOptions\n): void => {\n const execution = executionState.get(route.id)\n if (!execution) {\n return\n }\n\n if ('executeInBackground' in options) {\n for (const executor of execution.executors) {\n executor.setInteraction({\n allowInteraction: !options?.executeInBackground,\n allowUpdates: true,\n })\n }\n }\n // Update active route settings so we know what the current state of execution is\n execution.executionOptions = {\n ...execution.executionOptions,\n ...options,\n }\n}\n\n/**\n * Stops the execution of an active route.\n * @param route - A route that is currently in execution.\n * @returns The stopped route.\n */\nexport const stopRouteExecution = (route: Route): Route => {\n const execution = executionState.get(route.id)\n if (!execution) {\n return route\n }\n\n for (const executor of execution.executors) {\n executor.setInteraction({\n allowInteraction: false,\n allowUpdates: false,\n allowExecution: false,\n })\n }\n executionState.delete(route.id)\n return execution.route\n}\n\n/**\n * Get the list of active routes.\n * @returns A list of routes.\n */\nexport const getActiveRoutes = (): RouteExtended[] => {\n return Object.values(executionState.state)\n .map((dict) => dict?.route)\n .filter(Boolean) as RouteExtended[]\n}\n\n/**\n * Return the current route information for given route. The route has to be active.\n * @param routeId - A route id.\n * @returns The updated route.\n */\nexport const getActiveRoute = (routeId: string): RouteExtended | undefined => {\n return executionState.get(routeId)?.route\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,MAAa,eAAe,OAC1B,QACA,OACA,qBAC2B;CAE3B,MAAM,cAAc,gBAAuB,KAAK;CAEhD,IAAI,mBAAmBA,4BAAAA,eAAe,IAAI,YAAY,EAAE,CAAC,EAAE;CAE3D,IAAI,kBACF,OAAO;CAGT,4BAAA,eAAe,OAAO;EAAE,OAAO;EAAa;CAAiB,CAAC;CAC9D,mBAAmB,aAAa,QAAQ,WAAW;CACnD,4BAAA,eAAe,OAAO;EACpB,OAAO;EACP,SAAS;CACX,CAAC;CAED,OAAO;AACT;;;;;;;;;AAUA,MAAa,cAAc,OACzB,QACA,OACA,qBAC2B;CAC3B,MAAM,YAA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,SAAS,GAAG;IACV,IAAI,aAAaC,sBAAAA,uBAAuB;KACtC,KAAK,YAAY,KAAA;KACjB,eAAe,MAAM,aAAa,YAChC,QACA,MACA,EAAE,WACJ;IACF,OACE,MAAM;GAEV;GAGA,IAAI,aAAa,WAAW,WAAW,QACrC,mBAAmB,KAAK;GAI1B,IAAI,CAAC,aAAa,gBAChB,OAAO;EAEX,SAAS,GAAG;GACV,mBAAmB,KAAK;GACxB,MAAM;EACR;CACF;CAGA,4BAAA,eAAe,OAAO,MAAM,EAAE;CAC9B,OAAO;AACT;;;;;;AAOA,MAAa,wBACX,OACA,YACS;CACT,MAAM,YAAYF,4BAAAA,eAAe,IAAI,MAAM,EAAE;CAC7C,IAAI,CAAC,WACH;CAGF,IAAI,yBAAyB,SAC3B,KAAK,MAAM,YAAY,UAAU,WAC/B,SAAS,eAAe;EACtB,kBAAkB,CAAC,SAAS;EAC5B,cAAc;CAChB,CAAC;CAIL,UAAU,mBAAmB;EAC3B,GAAG,UAAU;EACb,GAAG;CACL;AACF;;;;;;AAOA,MAAa,sBAAsB,UAAwB;CACzD,MAAM,YAAYA,4BAAAA,eAAe,IAAI,MAAM,EAAE;CAC7C,IAAI,CAAC,WACH,OAAO;CAGT,KAAK,MAAM,YAAY,UAAU,WAC/B,SAAS,eAAe;EACtB,kBAAkB;EAClB,cAAc;EACd,gBAAgB;CAClB,CAAC;CAEH,4BAAA,eAAe,OAAO,MAAM,EAAE;CAC9B,OAAO,UAAU;AACnB;;;;;AAMA,MAAa,wBAAyC;CACpD,OAAO,OAAO,OAAOA,4BAAAA,eAAe,KAAK,CAAC,CACvC,KAAK,SAAS,MAAM,KAAK,CAAC,CAC1B,OAAO,OAAO;AACnB;;;;;;AAOA,MAAa,kBAAkB,YAA+C;CAC5E,OAAOA,4BAAAA,eAAe,IAAI,OAAO,CAAC,EAAE;AACtC"}
@@ -19,7 +19,6 @@ import { getTokenBalancesByChain } from "./actions/getTokenBalancesByChain.js";
19
19
  import { getTokens } from "./actions/getTokens.js";
20
20
  import { getTools } from "./actions/getTools.js";
21
21
  import { getTransactionHistory } from "./actions/getTransactionHistory.js";
22
- import { getWalletBalances } from "./actions/getWalletBalances.js";
23
22
  import { patchContractCalls } from "./actions/patchContractCalls.js";
24
23
  import { actions } from "./actions/index.js";
25
24
  import { relayTransaction } from "./actions/relayTransaction.js";
@@ -53,4 +52,4 @@ import { waitForResult } from "./utils/waitForResult.js";
53
52
  import { LruMap, withDedupe } from "./utils/withDedupe.js";
54
53
  import { withTimeout } from "./utils/withTimeout.js";
55
54
  export * from "@lifi/types";
56
- export { type AcceptExchangeRateUpdateHook, type AcceptSlippageUpdateHook, type AcceptSlippageUpdateHookParams, BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, type CheckBalanceOptions, CheckBalanceTask, type ContractCallParams, type ContractTool, 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, PrepareTransactionTask, ProviderError, type QuoteRequest, type QuoteRequestFromAmount, type QuoteRequestToAmount, RPCError, type RPCUrls, 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 TransactionMethodType, type TransactionParameters, type TransactionRequestParameters, type TransactionRequestUpdateHook, UnknownError, type UpdateRouteHook, ValidationError, WaitForTransactionStatusTask, actions, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, getWalletBalances, isHex, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, waitForResult, withDedupe, withTimeout };
55
+ export { type AcceptExchangeRateUpdateHook, type AcceptSlippageUpdateHook, type AcceptSlippageUpdateHookParams, BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, type CheckBalanceOptions, CheckBalanceTask, type ContractCallParams, type ContractTool, 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, PrepareTransactionTask, ProviderError, type QuoteRequest, type QuoteRequestFromAmount, type QuoteRequestToAmount, RPCError, type RPCUrls, 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 TransactionMethodType, type TransactionParameters, type TransactionRequestParameters, type TransactionRequestUpdateHook, UnknownError, type UpdateRouteHook, ValidationError, WaitForTransactionStatusTask, actions, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, isHex, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, waitForResult, withDedupe, withTimeout };
package/dist/cjs/index.js CHANGED
@@ -24,7 +24,6 @@ const require_actions_getTokenBalance = require("./actions/getTokenBalance.js");
24
24
  const require_actions_getTokens = require("./actions/getTokens.js");
25
25
  const require_actions_getTools = require("./actions/getTools.js");
26
26
  const require_actions_getTransactionHistory = require("./actions/getTransactionHistory.js");
27
- const require_actions_getWalletBalances = require("./actions/getWalletBalances.js");
28
27
  const require_actions_patchContractCalls = require("./actions/patchContractCalls.js");
29
28
  const require_actions_relayTransaction = require("./actions/relayTransaction.js");
30
29
  const require_actions_index = require("./actions/index.js");
@@ -106,7 +105,6 @@ exports.getTokens = require_actions_getTokens.getTokens;
106
105
  exports.getTools = require_actions_getTools.getTools;
107
106
  exports.getTransactionHistory = require_actions_getTransactionHistory.getTransactionHistory;
108
107
  exports.getTransactionRequestData = require_core_tasks_helpers_getTransactionRequestData.getTransactionRequestData;
109
- exports.getWalletBalances = require_actions_getWalletBalances.getWalletBalances;
110
108
  exports.isHex = require_utils_isHex.isHex;
111
109
  exports.parseUnits = require_utils_parseUnits.parseUnits;
112
110
  exports.patchContractCalls = require_actions_patchContractCalls.patchContractCalls;
@@ -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 ?? "4.2.0";
8
+ const currentVersion = packageVersion ?? "4.3.0";
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
  };
@@ -1,6 +1,6 @@
1
1
  //#region src/version.d.ts
2
2
  declare const name = "@lifi/sdk";
3
- declare const version = "4.2.0";
3
+ declare const version = "4.3.0";
4
4
  //#endregion
5
5
  export { name, version };
6
6
  //# sourceMappingURL=version.d.ts.map
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/version.ts
3
3
  const name = "@lifi/sdk";
4
- const version = "4.2.0";
4
+ const version = "4.3.0";
5
5
  //#endregion
6
6
  exports.name = name;
7
7
  exports.version = version;
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '4.2.0'\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 = '4.3.0'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"getTokenBalancesByChain.d.ts","names":[],"sources":["../../../src/actions/getTokenBalancesByChain.ts"],"mappings":";;;;;;;;;;;;iBAmBsB,wBACpB,QAAQ,WACR,uBACA;qBAAoC;IACnC;qBAA6B"}
1
+ {"version":3,"file":"getTokenBalancesByChain.d.ts","names":[],"sources":["../../../src/actions/getTokenBalancesByChain.ts"],"mappings":";;;;;;;;;;;;iBAmBsB,wBACpB,QAAQ,WACR,uBACA;GAAoC,kBAAA;IACnC;GAA6B,kBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getTokenBalancesByChain.js","names":[],"sources":["../../../src/actions/getTokenBalancesByChain.ts"],"sourcesContent":["import type {\n Token,\n TokenAmount,\n TokenAmountExtended,\n TokenExtended,\n} from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport type { SDKClient } from '../types/core.js'\nimport { isToken } from '../utils/isToken.js'\n\n/**\n * This method queries the balances of tokens for a specific list of chains for a given wallet.\n * @param client - The SDK client.\n * @param walletAddress - A wallet address.\n * @param tokensByChain - A list of token objects organized by chain ids.\n * @returns A list of objects containing the tokens and the amounts on different chains organized by the chosen chains.\n * @throws {ValidationError} Throws a ValidationError if validation fails.\n * @throws {Error} Throws an Error if the SDK Provider for the wallet address is not found.\n */\nexport async function getTokenBalancesByChain(\n client: SDKClient,\n walletAddress: string,\n tokensByChain: { [chainId: number]: Token[] }\n): Promise<{ [chainId: number]: TokenAmount[] }>\nexport async function getTokenBalancesByChain(\n client: SDKClient,\n walletAddress: string,\n tokensByChain: { [chainId: number]: TokenExtended[] }\n): Promise<{ [chainId: number]: TokenAmountExtended[] }> {\n if (!walletAddress) {\n throw new ValidationError('Missing walletAddress.')\n }\n\n const tokenList = Object.values(tokensByChain).flat()\n const invalidTokens = tokenList.filter((token) => !isToken(token))\n if (invalidTokens.length) {\n throw new ValidationError('Invalid tokens passed.')\n }\n\n const provider = client.providers.find((provider) =>\n provider.isAddress(walletAddress)\n )\n if (!provider) {\n throw new Error(`SDK Token Provider for ${walletAddress} is not found.`)\n }\n\n const tokenAmountsByChain: {\n [chainId: number]: TokenAmount[] | TokenAmountExtended[]\n } = {}\n const tokenAmountsSettled = await Promise.allSettled(\n Object.keys(tokensByChain).map(async (chainIdStr) => {\n const chainId = Number.parseInt(chainIdStr, 10)\n const chain = await client.getChainById(chainId)\n if (provider.type === chain.chainType) {\n const tokenAmounts = await provider.getBalance(\n client,\n walletAddress,\n tokensByChain[chainId]\n )\n tokenAmountsByChain[chainId] = tokenAmounts\n } else {\n // if the provider is not the same as the chain type,\n // return the tokens as is\n tokenAmountsByChain[chainId] = tokensByChain[chainId]\n }\n })\n )\n if (client.config.debug) {\n for (const result of tokenAmountsSettled) {\n if (result.status === 'rejected') {\n console.warn(\"Couldn't fetch token balance.\", result.reason)\n }\n }\n }\n return tokenAmountsByChain\n}\n"],"mappings":";;;AAwBA,eAAsB,wBACpB,QACA,eACA,eACuD;CACvD,IAAI,CAAC,eACH,MAAM,IAAI,gBAAgB,wBAAwB;CAKpD,IAFkB,OAAO,OAAO,aAAa,CAAC,CAAC,KACjB,CAAC,CAAC,QAAQ,UAAU,CAAC,QAAQ,KAAK,CAChD,CAAC,CAAC,QAChB,MAAM,IAAI,gBAAgB,wBAAwB;CAGpD,MAAM,WAAW,OAAO,UAAU,MAAM,aACtC,SAAS,UAAU,aAAa,CAClC;CACA,IAAI,CAAC,UACH,MAAM,IAAI,MAAM,0BAA0B,cAAc,eAAe;CAGzE,MAAM,sBAEF,CAAC;CACL,MAAM,sBAAsB,MAAM,QAAQ,WACxC,OAAO,KAAK,aAAa,CAAC,CAAC,IAAI,OAAO,eAAe;EACnD,MAAM,UAAU,OAAO,SAAS,YAAY,EAAE;EAC9C,MAAM,QAAQ,MAAM,OAAO,aAAa,OAAO;EAC/C,IAAI,SAAS,SAAS,MAAM,WAAW;GACrC,MAAM,eAAe,MAAM,SAAS,WAClC,QACA,eACA,cAAc,QAChB;GACA,oBAAoB,WAAW;EACjC,OAGE,oBAAoB,WAAW,cAAc;CAEjD,CAAC,CACH;CACA,IAAI,OAAO,OAAO;OACX,MAAM,UAAU,qBACnB,IAAI,OAAO,WAAW,YACpB,QAAQ,KAAK,iCAAiC,OAAO,MAAM;CAAA;CAIjE,OAAO;AACT"}
1
+ {"version":3,"file":"getTokenBalancesByChain.js","names":[],"sources":["../../../src/actions/getTokenBalancesByChain.ts"],"sourcesContent":["import type {\n Token,\n TokenAmount,\n TokenAmountExtended,\n TokenExtended,\n} from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport type { SDKClient } from '../types/core.js'\nimport { isToken } from '../utils/isToken.js'\n\n/**\n * This method queries the balances of tokens for a specific list of chains for a given wallet.\n * @param client - The SDK client.\n * @param walletAddress - A wallet address.\n * @param tokensByChain - A list of token objects organized by chain ids.\n * @returns A list of objects containing the tokens and the amounts on different chains organized by the chosen chains.\n * @throws {ValidationError} Throws a ValidationError if validation fails.\n * @throws {Error} Throws an Error if the SDK Provider for the wallet address is not found.\n */\nexport async function getTokenBalancesByChain(\n client: SDKClient,\n walletAddress: string,\n tokensByChain: { [chainId: number]: Token[] }\n): Promise<{ [chainId: number]: TokenAmount[] }>\nexport async function getTokenBalancesByChain(\n client: SDKClient,\n walletAddress: string,\n tokensByChain: { [chainId: number]: TokenExtended[] }\n): Promise<{ [chainId: number]: TokenAmountExtended[] }> {\n if (!walletAddress) {\n throw new ValidationError('Missing walletAddress.')\n }\n\n const tokenList = Object.values(tokensByChain).flat()\n const invalidTokens = tokenList.filter((token) => !isToken(token))\n if (invalidTokens.length) {\n throw new ValidationError('Invalid tokens passed.')\n }\n\n const provider = client.providers.find((provider) =>\n provider.isAddress(walletAddress)\n )\n if (!provider) {\n throw new Error(`SDK Token Provider for ${walletAddress} is not found.`)\n }\n\n const tokenAmountsByChain: {\n [chainId: number]: TokenAmount[] | TokenAmountExtended[]\n } = {}\n const tokenAmountsSettled = await Promise.allSettled(\n Object.keys(tokensByChain).map(async (chainIdStr) => {\n const chainId = Number.parseInt(chainIdStr, 10)\n const chain = await client.getChainById(chainId)\n if (provider.type === chain.chainType) {\n const tokenAmounts = await provider.getBalance(\n client,\n walletAddress,\n tokensByChain[chainId]\n )\n tokenAmountsByChain[chainId] = tokenAmounts\n } else {\n // if the provider is not the same as the chain type,\n // return the tokens as is\n tokenAmountsByChain[chainId] = tokensByChain[chainId]\n }\n })\n )\n if (client.config.debug) {\n for (const result of tokenAmountsSettled) {\n if (result.status === 'rejected') {\n console.warn(\"Couldn't fetch token balance.\", result.reason)\n }\n }\n }\n return tokenAmountsByChain\n}\n"],"mappings":";;;AAwBA,eAAsB,wBACpB,QACA,eACA,eACuD;CACvD,IAAI,CAAC,eACH,MAAM,IAAI,gBAAgB,wBAAwB;CAKpD,IAFkB,OAAO,OAAO,aAAa,CAAC,CAAC,KACjB,CAAC,CAAC,QAAQ,UAAU,CAAC,QAAQ,KAAK,CAChD,CAAC,CAAC,QAChB,MAAM,IAAI,gBAAgB,wBAAwB;CAGpD,MAAM,WAAW,OAAO,UAAU,MAAM,aACtC,SAAS,UAAU,aAAa,CAClC;CACA,IAAI,CAAC,UACH,MAAM,IAAI,MAAM,0BAA0B,cAAc,eAAe;CAGzE,MAAM,sBAEF,CAAC;CACL,MAAM,sBAAsB,MAAM,QAAQ,WACxC,OAAO,KAAK,aAAa,CAAC,CAAC,IAAI,OAAO,eAAe;EACnD,MAAM,UAAU,OAAO,SAAS,YAAY,EAAE;EAC9C,MAAM,QAAQ,MAAM,OAAO,aAAa,OAAO;EAC/C,IAAI,SAAS,SAAS,MAAM,WAAW;GACrC,MAAM,eAAe,MAAM,SAAS,WAClC,QACA,eACA,cAAc,QAChB;GACA,oBAAoB,WAAW;EACjC,OAGE,oBAAoB,WAAW,cAAc;CAEjD,CAAC,CACH;CACA,IAAI,OAAO,OAAO,OACX;OAAA,MAAM,UAAU,qBACnB,IAAI,OAAO,WAAW,YACpB,QAAQ,KAAK,iCAAiC,OAAO,MAAM;CAAA;CAIjE,OAAO;AACT"}
@@ -2,7 +2,7 @@ import { SDKClient } from "../types/core.js";
2
2
  import { GetStatusRequestExtended, LiFiStepRequest, QuoteRequestFromAmount, RoutesRequest as RoutesRequest$1 } from "../types/actions.js";
3
3
  import { getQuote } from "./getQuote.js";
4
4
  import { PatchContractCallsResponse } from "./patchContractCalls.js";
5
- import { ChainId, ChainKey, ChainType, ChainsRequest, ConnectionsRequest, ConnectionsResponse, ContractCallsQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, LiFiStep, PatchCallDataRequest, RelayRequest, RelayResponseData, RelayStatusRequest, RelayStatusResponseData, RequestOptions, RoutesResponse, StatusResponse, Token, TokenAmount, TokenExtended, TokensExtendedResponse, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse, TransactionAnalyticsRequest, TransactionAnalyticsResponse, WalletTokenExtended } from "@lifi/types";
5
+ import { ChainId, ChainKey, ChainType, ChainsRequest, ConnectionsRequest, ConnectionsResponse, ContractCallsQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, LiFiStep, PatchCallDataRequest, RelayRequest, RelayResponseData, RelayStatusRequest, RelayStatusResponseData, RequestOptions, RoutesResponse, StatusResponse, Token, TokenAmount, TokenExtended, TokensExtendedResponse, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse, TransactionAnalyticsRequest, TransactionAnalyticsResponse } from "@lifi/types";
6
6
  //#region src/actions/index.d.ts
7
7
  type Actions = {
8
8
  /**
@@ -146,13 +146,6 @@ type Actions = {
146
146
  * @returns Transaction history
147
147
  */
148
148
  getTransactionHistory: (params: TransactionAnalyticsRequest, options?: RequestOptions) => Promise<TransactionAnalyticsResponse>;
149
- /**
150
- * Get wallet balances
151
- * @param params - The configuration of the requested wallet balances
152
- * @param options - Request options
153
- * @returns Wallet balances
154
- */
155
- getWalletBalances: (walletAddress: string, options?: RequestOptions) => Promise<Record<number, WalletTokenExtended[]>>;
156
149
  /**
157
150
  * Relay a transaction through the relayer service
158
151
  * @param params - The configuration for the relay request
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/actions/index.ts"],"mappings":";;;;;;KAgEY;;;;;;;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,8BAC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R,UAAU,mBACP,QAAQ;;;;;;;EAQb,kBACE,QAAQ,wBACR,UAAU,mBACP,QAAQ;;;;;;;;;EAUb,YACE,QAAQ,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;;iBAGC,QAAQ,QAAQ,YAAY"}
@@ -16,7 +16,6 @@ import { getTokenBalance } from "./getTokenBalance.js";
16
16
  import { getTokens } from "./getTokens.js";
17
17
  import { getTools } from "./getTools.js";
18
18
  import { getTransactionHistory } from "./getTransactionHistory.js";
19
- import { getWalletBalances } from "./getWalletBalances.js";
20
19
  import { patchContractCalls } from "./patchContractCalls.js";
21
20
  import { relayTransaction } from "./relayTransaction.js";
22
21
  //#region src/actions/index.ts
@@ -40,7 +39,6 @@ function actions(client) {
40
39
  getTokenBalances: (walletAddress, tokens) => getTokenBalances(client, walletAddress, tokens),
41
40
  getTokenBalancesByChain: (walletAddress, tokensByChain) => getTokenBalancesByChain(client, walletAddress, tokensByChain),
42
41
  getTransactionHistory: (params, options) => getTransactionHistory(client, params, options),
43
- getWalletBalances: (walletAddress, options) => getWalletBalances(client, walletAddress, options),
44
42
  relayTransaction: (params, options) => relayTransaction(client, params, options),
45
43
  patchContractCalls: (params, options) => patchContractCalls(client, params, options)
46
44
  };
@@ -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 WalletTokenExtended,\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 { getWalletBalances } from './getWalletBalances.js'\nimport {\n type PatchContractCallsResponse,\n patchContractCalls,\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 * Get wallet balances\n * @param params - The configuration of the requested wallet balances\n * @param options - Request options\n * @returns Wallet balances\n */\n getWalletBalances: (\n walletAddress: string,\n options?: RequestOptions\n ) => Promise<Record<number, WalletTokenExtended[]>>\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 getWalletBalances: (walletAddress, options) =>\n getWalletBalances(client, walletAddress, options),\n relayTransaction: (params, options) =>\n relayTransaction(client, params, options),\n patchContractCalls: (params, options) =>\n patchContractCalls(client, params, options),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsTA,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,oBAAoB,eAAe,YACjC,kBAAkB,QAAQ,eAAe,OAAO;EAClD,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 type PatchContractCallsResponse,\n patchContractCalls,\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 +1 @@
1
- {"version":3,"file":"execution.js","names":[],"sources":["../../../src/core/execution.ts"],"sourcesContent":["import type { Route } from '@lifi/types'\nimport { LiFiErrorCode } from '../errors/constants.js'\nimport { ExecuteStepRetryError, ProviderError } from '../errors/errors.js'\nimport type {\n ExecutionOptions,\n LiFiStepExtended,\n RouteExtended,\n SDKClient,\n SDKProvider,\n} from '../types/core.js'\nimport { executionState } from './executionState.js'\nimport { prepareRestart } from './prepareRestart.js'\n\n/**\n * Execute a route.\n * @param client - The SDK client.\n * @param route - The route that should be executed. Cannot be an active route.\n * @param executionOptions - An object containing settings and callbacks.\n * @returns The executed route.\n * @throws {LiFiError} Throws a LiFiError if the execution fails.\n */\nexport const executeRoute = async (\n client: SDKClient,\n route: Route,\n executionOptions?: ExecutionOptions\n): Promise<RouteExtended> => {\n // Deep clone to prevent side effects\n const clonedRoute = structuredClone<Route>(route)\n\n let executionPromise = executionState.get(clonedRoute.id)?.promise\n // Check if route is already running\n if (executionPromise) {\n return executionPromise\n }\n\n executionState.create({ route: clonedRoute, executionOptions })\n executionPromise = executeSteps(client, clonedRoute)\n executionState.update({\n route: clonedRoute,\n promise: executionPromise,\n })\n\n return executionPromise\n}\n\n/**\n * Resume the execution of a route that has been stopped or had an error while executing.\n * @param client - The SDK client.\n * @param route - The route that is to be executed. Cannot be an active route.\n * @param executionOptions - An object containing settings and callbacks.\n * @returns The executed route.\n * @throws {LiFiError} Throws a LiFiError if the execution fails.\n */\nexport const resumeRoute = async (\n client: SDKClient,\n route: Route,\n executionOptions?: ExecutionOptions\n): Promise<RouteExtended> => {\n const execution = executionState.get(route.id)\n\n if (execution) {\n const executionHalted = execution.executors.some(\n (executor) => !executor.allowExecution\n )\n if (!executionHalted) {\n // Check if we want to resume route execution in the background\n updateRouteExecution(route, {\n executeInBackground: executionOptions?.executeInBackground,\n })\n if (!execution.promise) {\n // We should never reach this point if we do clean-up properly\n throw new Error('Route execution promise not found.')\n }\n return execution.promise\n }\n }\n\n prepareRestart(route)\n\n return executeRoute(client, route, executionOptions)\n}\n\nconst executeSteps = async (\n client: SDKClient,\n route: RouteExtended\n): Promise<RouteExtended> => {\n // Loop over steps and execute them\n for (let index = 0; index < route.steps.length; index++) {\n const execution = executionState.get(route.id)\n // Check if execution has stopped in the meantime\n if (!execution) {\n break\n }\n\n const step = route.steps[index]\n const previousStep = route.steps[index - 1]\n // Check if the step is already done\n if (step.execution?.status === 'DONE') {\n continue\n }\n\n // Update step fromAmount using output of the previous step execution. In the future this should be handled by calling `updateRoute`\n if (previousStep?.execution?.toAmount) {\n step.action.fromAmount = previousStep.execution.toAmount\n if (step.includedSteps?.length) {\n step.includedSteps[0].action.fromAmount =\n previousStep.execution.toAmount\n }\n }\n\n try {\n const fromAddress = step.action.fromAddress\n if (!fromAddress) {\n throw new Error('Action fromAddress is not specified.')\n }\n\n const provider = client.providers.find((provider: SDKProvider) =>\n provider.isAddress(fromAddress)\n )\n\n if (!provider) {\n throw new ProviderError(\n LiFiErrorCode.ProviderUnavailable,\n 'SDK Execution Provider not found.'\n )\n }\n\n const stepExecutor = await provider.getStepExecutor({\n routeId: route.id,\n executionOptions: execution.executionOptions,\n })\n execution.executors.push(stepExecutor)\n\n // Check if we want to execute this step in the background\n if (execution.executionOptions) {\n updateRouteExecution(route, execution.executionOptions)\n }\n\n let executedStep: LiFiStepExtended\n try {\n executedStep = await stepExecutor.executeStep(client, step)\n } catch (e) {\n if (e instanceof ExecuteStepRetryError) {\n step.execution = undefined\n executedStep = await stepExecutor.executeStep(\n client,\n step,\n e.retryParams\n )\n } else {\n throw e\n }\n }\n\n // We may reach this point if user interaction isn't allowed. We want to stop execution until we resume it\n if (executedStep.execution?.status !== 'DONE') {\n stopRouteExecution(route)\n }\n\n // Execution stopped during the current step, we don't want to continue to the next step so we return already\n if (!stepExecutor.allowExecution) {\n return route\n }\n } catch (e) {\n stopRouteExecution(route)\n throw e\n }\n }\n\n // Clean up after the execution\n executionState.delete(route.id)\n return route\n}\n\n/**\n * Updates route execution to background or foreground state.\n * @param route - A route that is currently in execution.\n * @param options - An object with execution settings.\n */\nexport const updateRouteExecution = (\n route: Route,\n options: ExecutionOptions\n): void => {\n const execution = executionState.get(route.id)\n if (!execution) {\n return\n }\n\n if ('executeInBackground' in options) {\n for (const executor of execution.executors) {\n executor.setInteraction({\n allowInteraction: !options?.executeInBackground,\n allowUpdates: true,\n })\n }\n }\n // Update active route settings so we know what the current state of execution is\n execution.executionOptions = {\n ...execution.executionOptions,\n ...options,\n }\n}\n\n/**\n * Stops the execution of an active route.\n * @param route - A route that is currently in execution.\n * @returns The stopped route.\n */\nexport const stopRouteExecution = (route: Route): Route => {\n const execution = executionState.get(route.id)\n if (!execution) {\n return route\n }\n\n for (const executor of execution.executors) {\n executor.setInteraction({\n allowInteraction: false,\n allowUpdates: false,\n allowExecution: false,\n })\n }\n executionState.delete(route.id)\n return execution.route\n}\n\n/**\n * Get the list of active routes.\n * @returns A list of routes.\n */\nexport const getActiveRoutes = (): RouteExtended[] => {\n return Object.values(executionState.state)\n .map((dict) => dict?.route)\n .filter(Boolean) as RouteExtended[]\n}\n\n/**\n * Return the current route information for given route. The route has to be active.\n * @param routeId - A route id.\n * @returns The updated route.\n */\nexport const getActiveRoute = (routeId: string): RouteExtended | undefined => {\n return executionState.get(routeId)?.route\n}\n"],"mappings":";;;;;;;;;;;;;AAqBA,MAAa,eAAe,OAC1B,QACA,OACA,qBAC2B;CAE3B,MAAM,cAAc,gBAAuB,KAAK;CAEhD,IAAI,mBAAmB,eAAe,IAAI,YAAY,EAAE,CAAC,EAAE;CAE3D,IAAI,kBACF,OAAO;CAGT,eAAe,OAAO;EAAE,OAAO;EAAa;CAAiB,CAAC;CAC9D,mBAAmB,aAAa,QAAQ,WAAW;CACnD,eAAe,OAAO;EACpB,OAAO;EACP,SAAS;CACX,CAAC;CAED,OAAO;AACT;;;;;;;;;AAUA,MAAa,cAAc,OACzB,QACA,OACA,qBAC2B;CAC3B,MAAM,YAAY,eAAe,IAAI,MAAM,EAAE;CAE7C,IAAI;MAIE,CAHoB,UAAU,UAAU,MACzC,aAAa,CAAC,SAAS,cAEP,GAAG;GAEpB,qBAAqB,OAAO,EAC1B,qBAAqB,kBAAkB,oBACzC,CAAC;GACD,IAAI,CAAC,UAAU,SAEb,MAAM,IAAI,MAAM,oCAAoC;GAEtD,OAAO,UAAU;EACnB;;CAGF,eAAe,KAAK;CAEpB,OAAO,aAAa,QAAQ,OAAO,gBAAgB;AACrD;AAEA,MAAM,eAAe,OACnB,QACA,UAC2B;CAE3B,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,MAAM,QAAQ,SAAS;EACvD,MAAM,YAAY,eAAe,IAAI,MAAM,EAAE;EAE7C,IAAI,CAAC,WACH;EAGF,MAAM,OAAO,MAAM,MAAM;EACzB,MAAM,eAAe,MAA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AmB;EAC3B,GAAG,UAAU;EACb,GAAG;CACL;AACF;;;;;;AAOA,MAAa,sBAAsB,UAAwB;CACzD,MAAM,YAAY,eAAe,IAAI,MAAM,EAAE;CAC7C,IAAI,CAAC,WACH,OAAO;CAGT,KAAK,MAAM,YAAY,UAAU,WAC/B,SAAS,eAAe;EACtB,kBAAkB;EAClB,cAAc;EACd,gBAAgB;CAClB,CAAC;CAEH,eAAe,OAAO,MAAM,EAAE;CAC9B,OAAO,UAAU;AACnB;;;;;AAMA,MAAa,wBAAyC;CACpD,OAAO,OAAO,OAAO,eAAe,KAAK,CAAC,CACvC,KAAK,SAAS,MAAM,KAAK,CAAC,CAC1B,OAAO,OAAO;AACnB;;;;;;AAOA,MAAa,kBAAkB,YAA+C;CAC5E,OAAO,eAAe,IAAI,OAAO,CAAC,EAAE;AACtC"}
1
+ {"version":3,"file":"execution.js","names":[],"sources":["../../../src/core/execution.ts"],"sourcesContent":["import type { Route } from '@lifi/types'\nimport { LiFiErrorCode } from '../errors/constants.js'\nimport { ExecuteStepRetryError, ProviderError } from '../errors/errors.js'\nimport type {\n ExecutionOptions,\n LiFiStepExtended,\n RouteExtended,\n SDKClient,\n SDKProvider,\n} from '../types/core.js'\nimport { executionState } from './executionState.js'\nimport { prepareRestart } from './prepareRestart.js'\n\n/**\n * Execute a route.\n * @param client - The SDK client.\n * @param route - The route that should be executed. Cannot be an active route.\n * @param executionOptions - An object containing settings and callbacks.\n * @returns The executed route.\n * @throws {LiFiError} Throws a LiFiError if the execution fails.\n */\nexport const executeRoute = async (\n client: SDKClient,\n route: Route,\n executionOptions?: ExecutionOptions\n): Promise<RouteExtended> => {\n // Deep clone to prevent side effects\n const clonedRoute = structuredClone<Route>(route)\n\n let executionPromise = executionState.get(clonedRoute.id)?.promise\n // Check if route is already running\n if (executionPromise) {\n return executionPromise\n }\n\n executionState.create({ route: clonedRoute, executionOptions })\n executionPromise = executeSteps(client, clonedRoute)\n executionState.update({\n route: clonedRoute,\n promise: executionPromise,\n })\n\n return executionPromise\n}\n\n/**\n * Resume the execution of a route that has been stopped or had an error while executing.\n * @param client - The SDK client.\n * @param route - The route that is to be executed. Cannot be an active route.\n * @param executionOptions - An object containing settings and callbacks.\n * @returns The executed route.\n * @throws {LiFiError} Throws a LiFiError if the execution fails.\n */\nexport const resumeRoute = async (\n client: SDKClient,\n route: Route,\n executionOptions?: ExecutionOptions\n): Promise<RouteExtended> => {\n const execution = executionState.get(route.id)\n\n if (execution) {\n const executionHalted = execution.executors.some(\n (executor) => !executor.allowExecution\n )\n if (!executionHalted) {\n // Check if we want to resume route execution in the background\n updateRouteExecution(route, {\n executeInBackground: executionOptions?.executeInBackground,\n })\n if (!execution.promise) {\n // We should never reach this point if we do clean-up properly\n throw new Error('Route execution promise not found.')\n }\n return execution.promise\n }\n }\n\n prepareRestart(route)\n\n return executeRoute(client, route, executionOptions)\n}\n\nconst executeSteps = async (\n client: SDKClient,\n route: RouteExtended\n): Promise<RouteExtended> => {\n // Loop over steps and execute them\n for (let index = 0; index < route.steps.length; index++) {\n const execution = executionState.get(route.id)\n // Check if execution has stopped in the meantime\n if (!execution) {\n break\n }\n\n const step = route.steps[index]\n const previousStep = route.steps[index - 1]\n // Check if the step is already done\n if (step.execution?.status === 'DONE') {\n continue\n }\n\n // Update step fromAmount using output of the previous step execution. In the future this should be handled by calling `updateRoute`\n if (previousStep?.execution?.toAmount) {\n step.action.fromAmount = previousStep.execution.toAmount\n if (step.includedSteps?.length) {\n step.includedSteps[0].action.fromAmount =\n previousStep.execution.toAmount\n }\n }\n\n try {\n const fromAddress = step.action.fromAddress\n if (!fromAddress) {\n throw new Error('Action fromAddress is not specified.')\n }\n\n const provider = client.providers.find((provider: SDKProvider) =>\n provider.isAddress(fromAddress)\n )\n\n if (!provider) {\n throw new ProviderError(\n LiFiErrorCode.ProviderUnavailable,\n 'SDK Execution Provider not found.'\n )\n }\n\n const stepExecutor = await provider.getStepExecutor({\n routeId: route.id,\n executionOptions: execution.executionOptions,\n })\n execution.executors.push(stepExecutor)\n\n // Check if we want to execute this step in the background\n if (execution.executionOptions) {\n updateRouteExecution(route, execution.executionOptions)\n }\n\n let executedStep: LiFiStepExtended\n try {\n executedStep = await stepExecutor.executeStep(client, step)\n } catch (e) {\n if (e instanceof ExecuteStepRetryError) {\n step.execution = undefined\n executedStep = await stepExecutor.executeStep(\n client,\n step,\n e.retryParams\n )\n } else {\n throw e\n }\n }\n\n // We may reach this point if user interaction isn't allowed. We want to stop execution until we resume it\n if (executedStep.execution?.status !== 'DONE') {\n stopRouteExecution(route)\n }\n\n // Execution stopped during the current step, we don't want to continue to the next step so we return already\n if (!stepExecutor.allowExecution) {\n return route\n }\n } catch (e) {\n stopRouteExecution(route)\n throw e\n }\n }\n\n // Clean up after the execution\n executionState.delete(route.id)\n return route\n}\n\n/**\n * Updates route execution to background or foreground state.\n * @param route - A route that is currently in execution.\n * @param options - An object with execution settings.\n */\nexport const updateRouteExecution = (\n route: Route,\n options: ExecutionOptions\n): void => {\n const execution = executionState.get(route.id)\n if (!execution) {\n return\n }\n\n if ('executeInBackground' in options) {\n for (const executor of execution.executors) {\n executor.setInteraction({\n allowInteraction: !options?.executeInBackground,\n allowUpdates: true,\n })\n }\n }\n // Update active route settings so we know what the current state of execution is\n execution.executionOptions = {\n ...execution.executionOptions,\n ...options,\n }\n}\n\n/**\n * Stops the execution of an active route.\n * @param route - A route that is currently in execution.\n * @returns The stopped route.\n */\nexport const stopRouteExecution = (route: Route): Route => {\n const execution = executionState.get(route.id)\n if (!execution) {\n return route\n }\n\n for (const executor of execution.executors) {\n executor.setInteraction({\n allowInteraction: false,\n allowUpdates: false,\n allowExecution: false,\n })\n }\n executionState.delete(route.id)\n return execution.route\n}\n\n/**\n * Get the list of active routes.\n * @returns A list of routes.\n */\nexport const getActiveRoutes = (): RouteExtended[] => {\n return Object.values(executionState.state)\n .map((dict) => dict?.route)\n .filter(Boolean) as RouteExtended[]\n}\n\n/**\n * Return the current route information for given route. The route has to be active.\n * @param routeId - A route id.\n * @returns The updated route.\n */\nexport const getActiveRoute = (routeId: string): RouteExtended | undefined => {\n return executionState.get(routeId)?.route\n}\n"],"mappings":";;;;;;;;;;;;;AAqBA,MAAa,eAAe,OAC1B,QACA,OACA,qBAC2B;CAE3B,MAAM,cAAc,gBAAuB,KAAK;CAEhD,IAAI,mBAAmB,eAAe,IAAI,YAAY,EAAE,CAAC,EAAE;CAE3D,IAAI,kBACF,OAAO;CAGT,eAAe,OAAO;EAAE,OAAO;EAAa;CAAiB,CAAC;CAC9D,mBAAmB,aAAa,QAAQ,WAAW;CACnD,eAAe,OAAO;EACpB,OAAO;EACP,SAAS;CACX,CAAC;CAED,OAAO;AACT;;;;;;;;;AAUA,MAAa,cAAc,OACzB,QACA,OACA,qBAC2B;CAC3B,MAAM,YAAY,eAAe,IAAI,MAAM,EAAE;CAE7C,IAAI,WAIE;MAAA,CAHoB,UAAU,UAAU,MACzC,aAAa,CAAC,SAAS,cAEP,GAAG;GAEpB,qBAAqB,OAAO,EAC1B,qBAAqB,kBAAkB,oBACzC,CAAC;GACD,IAAI,CAAC,UAAU,SAEb,MAAM,IAAI,MAAM,oCAAoC;GAEtD,OAAO,UAAU;EACnB;;CAGF,eAAe,KAAK;CAEpB,OAAO,aAAa,QAAQ,OAAO,gBAAgB;AACrD;AAEA,MAAM,eAAe,OACnB,QACA,UAC2B;CAE3B,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,MAAM,QAAQ,SAAS;EACvD,MAAM,YAAY,eAAe,IAAI,MAAM,EAAE;EAE7C,IAAI,CAAC,WACH;EAGF,MAAM,OAAO,MAAM,MAAM;EACzB,MAAM,eAAe,MAAM,MAAM,QAAQ;EAEzC,IAAI,KAAK,WAAW,WAAW,QAC7B;EAIF,IAAI,cAAc,WAAW,UAAU;GACrC,KAAK,OAAO,aAAa,aAAa,UAAU;GAChD,IAAI,KAAK,eAAe,QACtB,KAAK,cAAc,EAAE,CAAC,OAAO,aAC3B,aAAa,UAAU;EAE7B;E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AAkB;EAClB,cAAc;EACd,gBAAgB;CAClB,CAAC;CAEH,eAAe,OAAO,MAAM,EAAE;CAC9B,OAAO,UAAU;AACnB;;;;;AAMA,MAAa,wBAAyC;CACpD,OAAO,OAAO,OAAO,eAAe,KAAK,CAAC,CACvC,KAAK,SAAS,MAAM,KAAK,CAAC,CAC1B,OAAO,OAAO;AACnB;;;;;;AAOA,MAAa,kBAAkB,YAA+C;CAC5E,OAAO,eAAe,IAAI,OAAO,CAAC,EAAE;AACtC"}
@@ -19,7 +19,6 @@ import { getTokenBalancesByChain } from "./actions/getTokenBalancesByChain.js";
19
19
  import { getTokens } from "./actions/getTokens.js";
20
20
  import { getTools } from "./actions/getTools.js";
21
21
  import { getTransactionHistory } from "./actions/getTransactionHistory.js";
22
- import { getWalletBalances } from "./actions/getWalletBalances.js";
23
22
  import { patchContractCalls } from "./actions/patchContractCalls.js";
24
23
  import { actions } from "./actions/index.js";
25
24
  import { relayTransaction } from "./actions/relayTransaction.js";
@@ -53,4 +52,4 @@ import { waitForResult } from "./utils/waitForResult.js";
53
52
  import { LruMap, withDedupe } from "./utils/withDedupe.js";
54
53
  import { withTimeout } from "./utils/withTimeout.js";
55
54
  export * from "@lifi/types";
56
- export { type AcceptExchangeRateUpdateHook, type AcceptSlippageUpdateHook, type AcceptSlippageUpdateHookParams, BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, type CheckBalanceOptions, CheckBalanceTask, type ContractCallParams, type ContractTool, 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, PrepareTransactionTask, ProviderError, type QuoteRequest, type QuoteRequestFromAmount, type QuoteRequestToAmount, RPCError, type RPCUrls, 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 TransactionMethodType, type TransactionParameters, type TransactionRequestParameters, type TransactionRequestUpdateHook, UnknownError, type UpdateRouteHook, ValidationError, WaitForTransactionStatusTask, actions, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, getWalletBalances, isHex, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, waitForResult, withDedupe, withTimeout };
55
+ export { type AcceptExchangeRateUpdateHook, type AcceptSlippageUpdateHook, type AcceptSlippageUpdateHookParams, BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, type CheckBalanceOptions, CheckBalanceTask, type ContractCallParams, type ContractTool, 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, PrepareTransactionTask, ProviderError, type QuoteRequest, type QuoteRequestFromAmount, type QuoteRequestToAmount, RPCError, type RPCUrls, 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 TransactionMethodType, type TransactionParameters, type TransactionRequestParameters, type TransactionRequestUpdateHook, UnknownError, type UpdateRouteHook, ValidationError, WaitForTransactionStatusTask, actions, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, isHex, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, waitForResult, withDedupe, withTimeout };
package/dist/esm/index.js CHANGED
@@ -23,7 +23,6 @@ import { getTokenBalance } from "./actions/getTokenBalance.js";
23
23
  import { getTokens } from "./actions/getTokens.js";
24
24
  import { getTools } from "./actions/getTools.js";
25
25
  import { getTransactionHistory } from "./actions/getTransactionHistory.js";
26
- import { getWalletBalances } from "./actions/getWalletBalances.js";
27
26
  import { patchContractCalls } from "./actions/patchContractCalls.js";
28
27
  import { relayTransaction } from "./actions/relayTransaction.js";
29
28
  import { actions } from "./actions/index.js";
@@ -50,4 +49,4 @@ import { fetchTxErrorDetails } from "./utils/fetchTxErrorDetails.js";
50
49
  import { isHex } from "./utils/isHex.js";
51
50
  import { parseUnits } from "./utils/parseUnits.js";
52
51
  export * from "@lifi/types";
53
- export { BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, CheckBalanceTask, ErrorMessage, ErrorName, ExecuteStepRetryError, HTTPError, InMemoryStorage, LiFiErrorCode, LocalStorageAdapter, LruMap, PrepareTransactionTask, ProviderError, RPCError, SDKError, ServerError, StatusManager, TaskPipeline, TransactionError, UnknownError, ValidationError, WaitForTransactionStatusTask, actions, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, getWalletBalances, isHex, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, waitForResult, withDedupe, withTimeout };
52
+ export { BalanceError, BaseError, BaseStepExecutionTask, BaseStepExecutor, CheckBalanceTask, ErrorMessage, ErrorName, ExecuteStepRetryError, HTTPError, InMemoryStorage, LiFiErrorCode, LocalStorageAdapter, LruMap, PrepareTransactionTask, ProviderError, RPCError, SDKError, ServerError, StatusManager, TaskPipeline, TransactionError, UnknownError, ValidationError, WaitForTransactionStatusTask, actions, checkBalance, checkPackageUpdates, convertQuoteToRoute, createClient, createDefaultStorage, executeRoute, fetchTxErrorDetails, formatUnits, getActionMessage, getActiveRoute, getActiveRoutes, getChains, getConnections, getContractCallsQuote, getGasRecommendation, getNameServiceAddress, getQuote, getRelayedTransactionStatus, getRelayerQuote, getRoutes, getStatus, getStepTransaction, getSubstatusMessage, getToken, getTokenBalance, getTokenBalances, getTokenBalancesByChain, getTokens, getTools, getTransactionHistory, getTransactionRequestData, isHex, parseUnits, patchContractCalls, relayTransaction, resumeRoute, sleep, stepComparison, stopRouteExecution, updateRouteExecution, 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 ?? "4.2.0";
7
+ const currentVersion = packageVersion ?? "4.3.0";
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
  };
@@ -1,6 +1,6 @@
1
1
  //#region src/version.d.ts
2
2
  declare const name = "@lifi/sdk";
3
- declare const version = "4.2.0";
3
+ declare const version = "4.3.0";
4
4
  //#endregion
5
5
  export { name, version };
6
6
  //# sourceMappingURL=version.d.ts.map
@@ -1,6 +1,6 @@
1
1
  //#region src/version.ts
2
2
  const name = "@lifi/sdk";
3
- const version = "4.2.0";
3
+ const version = "4.3.0";
4
4
  //#endregion
5
5
  export { name, version };
6
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk'\nexport const version = '4.2.0'\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 = '4.3.0'\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": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "description": "LI.FI SDK for Any-to-Any Cross-Chain-Swap",
5
5
  "homepage": "https://github.com/lifinance/sdk",
6
6
  "bugs": {
@@ -28,7 +28,7 @@
28
28
  "./package.json": "./package.json"
29
29
  },
30
30
  "dependencies": {
31
- "@lifi/types": "17.85.0"
31
+ "@lifi/types": "17.86.0"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
@@ -28,7 +28,6 @@ import type {
28
28
  ToolsResponse,
29
29
  TransactionAnalyticsRequest,
30
30
  TransactionAnalyticsResponse,
31
- WalletTokenExtended,
32
31
  } from '@lifi/types'
33
32
  import type {
34
33
  GetStatusRequestExtended,
@@ -55,7 +54,6 @@ import { getTokenBalancesByChain } from './getTokenBalancesByChain.js'
55
54
  import { getTokens } from './getTokens.js'
56
55
  import { getTools } from './getTools.js'
57
56
  import { getTransactionHistory } from './getTransactionHistory.js'
58
- import { getWalletBalances } from './getWalletBalances.js'
59
57
  import {
60
58
  type PatchContractCallsResponse,
61
59
  patchContractCalls,
@@ -274,17 +272,6 @@ export type Actions = {
274
272
  options?: RequestOptions
275
273
  ) => Promise<TransactionAnalyticsResponse>
276
274
 
277
- /**
278
- * Get wallet balances
279
- * @param params - The configuration of the requested wallet balances
280
- * @param options - Request options
281
- * @returns Wallet balances
282
- */
283
- getWalletBalances: (
284
- walletAddress: string,
285
- options?: RequestOptions
286
- ) => Promise<Record<number, WalletTokenExtended[]>>
287
-
288
275
  /**
289
276
  * Relay a transaction through the relayer service
290
277
  * @param params - The configuration for the relay request
@@ -340,8 +327,6 @@ export function actions(client: SDKClient): Actions {
340
327
  getTokenBalancesByChain(client, walletAddress, tokensByChain),
341
328
  getTransactionHistory: (params, options) =>
342
329
  getTransactionHistory(client, params, options),
343
- getWalletBalances: (walletAddress, options) =>
344
- getWalletBalances(client, walletAddress, options),
345
330
  relayTransaction: (params, options) =>
346
331
  relayTransaction(client, params, options),
347
332
  patchContractCalls: (params, options) =>
package/src/index.ts CHANGED
@@ -19,7 +19,6 @@ export { getTokenBalancesByChain } from './actions/getTokenBalancesByChain.js'
19
19
  export { getTokens } from './actions/getTokens.js'
20
20
  export { getTools } from './actions/getTools.js'
21
21
  export { getTransactionHistory } from './actions/getTransactionHistory.js'
22
- export { getWalletBalances } from './actions/getWalletBalances.js'
23
22
  export { actions } from './actions/index.js'
24
23
  export { patchContractCalls } from './actions/patchContractCalls.js'
25
24
  export { relayTransaction } from './actions/relayTransaction.js'
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk'
2
- export const version = '4.2.0'
2
+ export const version = '4.3.0'
@@ -1,15 +0,0 @@
1
- import { SDKClient } from "../types/core.js";
2
- import { RequestOptions, WalletTokenExtended } from "@lifi/types";
3
- //#region src/actions/getWalletBalances.d.ts
4
- /**
5
- * Returns the balances of tokens a wallet holds across EVM chains.
6
- * @param client - The SDK client.
7
- * @param walletAddress - A wallet address.
8
- * @param options - Optional request options.
9
- * @returns An object containing the tokens and the amounts organized by chain ids.
10
- * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
11
- */
12
- declare const getWalletBalances: (client: SDKClient, walletAddress: string, options?: RequestOptions) => Promise<Record<number, WalletTokenExtended[]>>;
13
- //#endregion
14
- export { getWalletBalances };
15
- //# sourceMappingURL=getWalletBalances.d.ts.map
@@ -1,20 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_errors_errors = require("../errors/errors.js");
3
- const require_utils_request = require("../utils/request.js");
4
- //#region src/actions/getWalletBalances.ts
5
- /**
6
- * Returns the balances of tokens a wallet holds across EVM chains.
7
- * @param client - The SDK client.
8
- * @param walletAddress - A wallet address.
9
- * @param options - Optional request options.
10
- * @returns An object containing the tokens and the amounts organized by chain ids.
11
- * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
12
- */
13
- const getWalletBalances = async (client, walletAddress, options) => {
14
- if (!walletAddress) throw new require_errors_errors.ValidationError("Missing walletAddress.");
15
- return (await require_utils_request.request(client.config, `${client.config.apiUrl}/wallets/${walletAddress}/balances?extended=true`, { signal: options?.signal }))?.balances || {};
16
- };
17
- //#endregion
18
- exports.getWalletBalances = getWalletBalances;
19
-
20
- //# sourceMappingURL=getWalletBalances.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getWalletBalances.js","names":["ValidationError","request"],"sources":["../../../src/actions/getWalletBalances.ts"],"sourcesContent":["import type {\n GetWalletBalanceExtendedResponse,\n RequestOptions,\n WalletTokenExtended,\n} from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Returns the balances of tokens a wallet holds across EVM chains.\n * @param client - The SDK client.\n * @param walletAddress - A wallet address.\n * @param options - Optional request options.\n * @returns An object containing the tokens and the amounts organized by chain ids.\n * @throws {ValidationError} Throws a ValidationError if parameters are invalid.\n */\nexport const getWalletBalances = async (\n client: SDKClient,\n walletAddress: string,\n options?: RequestOptions\n): Promise<Record<number, WalletTokenExtended[]>> => {\n if (!walletAddress) {\n throw new ValidationError('Missing walletAddress.')\n }\n\n const response = await request<GetWalletBalanceExtendedResponse>(\n client.config,\n `${client.config.apiUrl}/wallets/${walletAddress}/balances?extended=true`,\n {\n signal: options?.signal,\n }\n )\n\n return (response?.balances || {}) as Record<number, WalletTokenExtended[]>\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAa,oBAAoB,OAC/B,QACA,eACA,YACmD;CACnD,IAAI,CAAC,eACH,MAAM,IAAIA,sBAAAA,gBAAgB,wBAAwB;CAWpD,QAAQ,MAReC,sBAAAA,QACrB,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,WAAW,cAAc,0BACjD,EACE,QAAQ,SAAS,OACnB,CACF,EAAA,EAEkB,YAAY,CAAC;AACjC"}
@@ -1,15 +0,0 @@
1
- import { SDKClient } from "../types/core.js";
2
- import { RequestOptions, WalletTokenExtended } from "@lifi/types";
3
- //#region src/actions/getWalletBalances.d.ts
4
- /**
5
- * Returns the balances of tokens a wallet holds across EVM chains.
6
- * @param client - The SDK client.
7
- * @param walletAddress - A wallet address.
8
- * @param options - Optional request options.
9
- * @returns An object containing the tokens and the amounts organized by chain ids.
10
- * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
11
- */
12
- declare const getWalletBalances: (client: SDKClient, walletAddress: string, options?: RequestOptions) => Promise<Record<number, WalletTokenExtended[]>>;
13
- //#endregion
14
- export { getWalletBalances };
15
- //# sourceMappingURL=getWalletBalances.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getWalletBalances.d.ts","names":[],"sources":["../../../src/actions/getWalletBalances.ts"],"mappings":";;;;;;;;;;;cAiBa,oBACX,QAAQ,WACR,uBACA,UAAU,mBACT,QAAQ,eAAe"}
@@ -1,19 +0,0 @@
1
- import { ValidationError } from "../errors/errors.js";
2
- import { request } from "../utils/request.js";
3
- //#region src/actions/getWalletBalances.ts
4
- /**
5
- * Returns the balances of tokens a wallet holds across EVM chains.
6
- * @param client - The SDK client.
7
- * @param walletAddress - A wallet address.
8
- * @param options - Optional request options.
9
- * @returns An object containing the tokens and the amounts organized by chain ids.
10
- * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
11
- */
12
- const getWalletBalances = async (client, walletAddress, options) => {
13
- if (!walletAddress) throw new ValidationError("Missing walletAddress.");
14
- return (await request(client.config, `${client.config.apiUrl}/wallets/${walletAddress}/balances?extended=true`, { signal: options?.signal }))?.balances || {};
15
- };
16
- //#endregion
17
- export { getWalletBalances };
18
-
19
- //# sourceMappingURL=getWalletBalances.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getWalletBalances.js","names":[],"sources":["../../../src/actions/getWalletBalances.ts"],"sourcesContent":["import type {\n GetWalletBalanceExtendedResponse,\n RequestOptions,\n WalletTokenExtended,\n} from '@lifi/types'\nimport { ValidationError } from '../errors/errors.js'\nimport type { SDKClient } from '../types/core.js'\nimport { request } from '../utils/request.js'\n\n/**\n * Returns the balances of tokens a wallet holds across EVM chains.\n * @param client - The SDK client.\n * @param walletAddress - A wallet address.\n * @param options - Optional request options.\n * @returns An object containing the tokens and the amounts organized by chain ids.\n * @throws {ValidationError} Throws a ValidationError if parameters are invalid.\n */\nexport const getWalletBalances = async (\n client: SDKClient,\n walletAddress: string,\n options?: RequestOptions\n): Promise<Record<number, WalletTokenExtended[]>> => {\n if (!walletAddress) {\n throw new ValidationError('Missing walletAddress.')\n }\n\n const response = await request<GetWalletBalanceExtendedResponse>(\n client.config,\n `${client.config.apiUrl}/wallets/${walletAddress}/balances?extended=true`,\n {\n signal: options?.signal,\n }\n )\n\n return (response?.balances || {}) as Record<number, WalletTokenExtended[]>\n}\n"],"mappings":";;;;;;;;;;;AAiBA,MAAa,oBAAoB,OAC/B,QACA,eACA,YACmD;CACnD,IAAI,CAAC,eACH,MAAM,IAAI,gBAAgB,wBAAwB;CAWpD,QAAQ,MARe,QACrB,OAAO,QACP,GAAG,OAAO,OAAO,OAAO,WAAW,cAAc,0BACjD,EACE,QAAQ,SAAS,OACnB,CACF,EAAA,EAEkB,YAAY,CAAC;AACjC"}
@@ -1,36 +0,0 @@
1
- import type {
2
- GetWalletBalanceExtendedResponse,
3
- RequestOptions,
4
- WalletTokenExtended,
5
- } from '@lifi/types'
6
- import { ValidationError } from '../errors/errors.js'
7
- import type { SDKClient } from '../types/core.js'
8
- import { request } from '../utils/request.js'
9
-
10
- /**
11
- * Returns the balances of tokens a wallet holds across EVM chains.
12
- * @param client - The SDK client.
13
- * @param walletAddress - A wallet address.
14
- * @param options - Optional request options.
15
- * @returns An object containing the tokens and the amounts organized by chain ids.
16
- * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
17
- */
18
- export const getWalletBalances = async (
19
- client: SDKClient,
20
- walletAddress: string,
21
- options?: RequestOptions
22
- ): Promise<Record<number, WalletTokenExtended[]>> => {
23
- if (!walletAddress) {
24
- throw new ValidationError('Missing walletAddress.')
25
- }
26
-
27
- const response = await request<GetWalletBalanceExtendedResponse>(
28
- client.config,
29
- `${client.config.apiUrl}/wallets/${walletAddress}/balances?extended=true`,
30
- {
31
- signal: options?.signal,
32
- }
33
- )
34
-
35
- return (response?.balances || {}) as Record<number, WalletTokenExtended[]>
36
- }